2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vppinfra/socket.h>
22 #include <svm/memfd.h>
23 #include <vlibapi/api.h>
24 #include <vlibmemory/api.h>
25 #include <vnet/ip/ip.h>
26 #include <vnet/l2/l2_input.h>
27 #include <vnet/l2tp/l2tp.h>
28 #include <vnet/vxlan/vxlan.h>
29 #include <vnet/geneve/geneve.h>
30 #include <vnet/gre/gre.h>
31 #include <vnet/vxlan-gpe/vxlan_gpe.h>
32 #include <vnet/lisp-gpe/lisp_gpe.h>
34 #include <vpp/api/vpe_msg_enum.h>
35 #include <vnet/l2/l2_classify.h>
36 #include <vnet/l2/l2_vtr.h>
37 #include <vnet/classify/input_acl.h>
38 #include <vnet/classify/policer_classify.h>
39 #include <vnet/classify/flow_classify.h>
40 #include <vnet/mpls/mpls.h>
41 #include <vnet/ipsec/ipsec.h>
42 #include <vnet/ipsec/ikev2.h>
44 #include <vnet/map/map.h>
45 #include <vnet/cop/cop.h>
46 #include <vnet/ip/ip6_hop_by_hop.h>
47 #include <vnet/ip/ip_source_and_port_range_check.h>
48 #include <vnet/policer/xlate.h>
49 #include <vnet/span/span.h>
50 #include <vnet/policer/policer.h>
51 #include <vnet/policer/police.h>
52 #include <vnet/mfib/mfib_types.h>
54 #include "vat/json_format.h"
59 #define vl_typedefs /* define message structures */
60 #include <vpp/api/vpe_all_api_h.h>
63 /* declare message handlers for each api */
65 #define vl_endianfun /* define message structures */
66 #include <vpp/api/vpe_all_api_h.h>
69 /* instantiate all the print functions we know about */
70 #define vl_print(handle, ...)
72 #include <vpp/api/vpe_all_api_h.h>
75 #define __plugin_msg_base 0
76 #include <vlibapi/vat_helper_macros.h>
78 #if VPP_API_TEST_BUILTIN == 0
88 vat_socket_connect (vat_main_t * vam)
90 return vl_socket_client_connect
91 (&vam->socket_client_main, (char *) vam->socket_name,
92 "vpp_api_test(s)", 0 /* default socket rx, tx buffer */ );
94 #else /* vpp built-in case, we don't do sockets... */
96 vat_socket_connect (vat_main_t * vam)
102 vl_socket_client_read_reply (socket_client_main_t * scm)
109 vat_time_now (vat_main_t * vam)
111 #if VPP_API_TEST_BUILTIN
112 return vlib_time_now (vam->vlib_main);
114 return clib_time_now (&vam->clib_time);
119 errmsg (char *fmt, ...)
121 vat_main_t *vam = &vat_main;
126 s = va_format (0, fmt, &va);
131 #if VPP_API_TEST_BUILTIN
132 vlib_cli_output (vam->vlib_main, (char *) s);
135 if (vam->ifp != stdin)
136 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
137 vam->input_line_number);
138 fformat (vam->ofp, (char *) s);
146 #if VPP_API_TEST_BUILTIN == 0
148 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
150 vat_main_t *vam = va_arg (*args, vat_main_t *);
151 u32 *result = va_arg (*args, u32 *);
155 if (!unformat (input, "%s", &if_name))
158 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
165 /* Parse an IP4 address %d.%d.%d.%d. */
167 unformat_ip4_address (unformat_input_t * input, va_list * args)
169 u8 *result = va_arg (*args, u8 *);
172 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
175 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
187 unformat_ethernet_address (unformat_input_t * input, va_list * args)
189 u8 *result = va_arg (*args, u8 *);
192 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
193 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
197 for (i = 0; i < 6; i++)
198 if (a[i] >= (1 << 8))
201 for (i = 0; i < 6; i++)
207 /* Returns ethernet type as an int in host byte order. */
209 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
212 u16 *result = va_arg (*args, u16 *);
216 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
218 if (type >= (1 << 16))
226 /* Parse an IP6 address. */
228 unformat_ip6_address (unformat_input_t * input, va_list * args)
230 ip6_address_t *result = va_arg (*args, ip6_address_t *);
232 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
233 uword c, n_colon, double_colon_index;
235 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
236 double_colon_index = ARRAY_LEN (hex_quads);
237 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
240 if (c >= '0' && c <= '9')
242 else if (c >= 'a' && c <= 'f')
243 hex_digit = c + 10 - 'a';
244 else if (c >= 'A' && c <= 'F')
245 hex_digit = c + 10 - 'A';
246 else if (c == ':' && n_colon < 2)
250 unformat_put_input (input);
254 /* Too many hex quads. */
255 if (n_hex_quads >= ARRAY_LEN (hex_quads))
260 hex_quad = (hex_quad << 4) | hex_digit;
262 /* Hex quad must fit in 16 bits. */
263 if (n_hex_digits >= 4)
270 /* Save position of :: */
273 /* More than one :: ? */
274 if (double_colon_index < ARRAY_LEN (hex_quads))
276 double_colon_index = n_hex_quads;
279 if (n_colon > 0 && n_hex_digits > 0)
281 hex_quads[n_hex_quads++] = hex_quad;
287 if (n_hex_digits > 0)
288 hex_quads[n_hex_quads++] = hex_quad;
293 /* Expand :: to appropriate number of zero hex quads. */
294 if (double_colon_index < ARRAY_LEN (hex_quads))
296 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
298 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
299 hex_quads[n_zero + i] = hex_quads[i];
301 for (i = 0; i < n_zero; i++)
302 hex_quads[double_colon_index + i] = 0;
304 n_hex_quads = ARRAY_LEN (hex_quads);
307 /* Too few hex quads given. */
308 if (n_hex_quads < ARRAY_LEN (hex_quads))
311 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
312 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
319 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
321 u32 *r = va_arg (*args, u32 *);
324 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
325 foreach_ipsec_policy_action
333 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
335 u32 *r = va_arg (*args, u32 *);
338 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
339 foreach_ipsec_crypto_alg
347 format_ipsec_crypto_alg (u8 * s, va_list * args)
349 u32 i = va_arg (*args, u32);
354 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
355 foreach_ipsec_crypto_alg
358 return format (s, "unknown");
360 return format (s, "%s", t);
364 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
366 u32 *r = va_arg (*args, u32 *);
369 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
370 foreach_ipsec_integ_alg
378 format_ipsec_integ_alg (u8 * s, va_list * args)
380 u32 i = va_arg (*args, u32);
385 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
386 foreach_ipsec_integ_alg
389 return format (s, "unknown");
391 return format (s, "%s", t);
395 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
397 u32 *r = va_arg (*args, u32 *);
400 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
401 foreach_ikev2_auth_method
409 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
411 u32 *r = va_arg (*args, u32 *);
414 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
415 foreach_ikev2_id_type
421 #else /* VPP_API_TEST_BUILTIN == 1 */
423 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
425 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
426 vnet_main_t *vnm = vnet_get_main ();
427 u32 *result = va_arg (*args, u32 *);
430 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
433 *result = sw_if_index;
436 #endif /* VPP_API_TEST_BUILTIN */
439 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
441 u8 *r = va_arg (*args, u8 *);
443 if (unformat (input, "kbps"))
444 *r = SSE2_QOS_RATE_KBPS;
445 else if (unformat (input, "pps"))
446 *r = SSE2_QOS_RATE_PPS;
453 unformat_policer_round_type (unformat_input_t * input, va_list * args)
455 u8 *r = va_arg (*args, u8 *);
457 if (unformat (input, "closest"))
458 *r = SSE2_QOS_ROUND_TO_CLOSEST;
459 else if (unformat (input, "up"))
460 *r = SSE2_QOS_ROUND_TO_UP;
461 else if (unformat (input, "down"))
462 *r = SSE2_QOS_ROUND_TO_DOWN;
469 unformat_policer_type (unformat_input_t * input, va_list * args)
471 u8 *r = va_arg (*args, u8 *);
473 if (unformat (input, "1r2c"))
474 *r = SSE2_QOS_POLICER_TYPE_1R2C;
475 else if (unformat (input, "1r3c"))
476 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
477 else if (unformat (input, "2r3c-2698"))
478 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
479 else if (unformat (input, "2r3c-4115"))
480 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
481 else if (unformat (input, "2r3c-mef5cf1"))
482 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
489 unformat_dscp (unformat_input_t * input, va_list * va)
491 u8 *r = va_arg (*va, u8 *);
494 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
503 unformat_policer_action_type (unformat_input_t * input, va_list * va)
505 sse2_qos_pol_action_params_st *a
506 = va_arg (*va, sse2_qos_pol_action_params_st *);
508 if (unformat (input, "drop"))
509 a->action_type = SSE2_QOS_ACTION_DROP;
510 else if (unformat (input, "transmit"))
511 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
512 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
513 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
520 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
522 u32 *r = va_arg (*va, u32 *);
525 if (unformat (input, "ip4"))
526 tid = POLICER_CLASSIFY_TABLE_IP4;
527 else if (unformat (input, "ip6"))
528 tid = POLICER_CLASSIFY_TABLE_IP6;
529 else if (unformat (input, "l2"))
530 tid = POLICER_CLASSIFY_TABLE_L2;
539 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
541 u32 *r = va_arg (*va, u32 *);
544 if (unformat (input, "ip4"))
545 tid = FLOW_CLASSIFY_TABLE_IP4;
546 else if (unformat (input, "ip6"))
547 tid = FLOW_CLASSIFY_TABLE_IP6;
555 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
556 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
557 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
558 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
560 #if (VPP_API_TEST_BUILTIN==0)
562 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
564 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
565 mfib_itf_attribute_t attr;
568 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
570 if (unformat (input, mfib_itf_flag_long_names[attr]))
571 *iflags |= (1 << attr);
573 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
575 if (unformat (input, mfib_itf_flag_names[attr]))
576 *iflags |= (1 << attr);
579 return (old == *iflags ? 0 : 1);
583 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
585 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
586 mfib_entry_attribute_t attr;
589 FOR_EACH_MFIB_ATTRIBUTE (attr)
591 if (unformat (input, mfib_flag_long_names[attr]))
592 *eflags |= (1 << attr);
594 FOR_EACH_MFIB_ATTRIBUTE (attr)
596 if (unformat (input, mfib_flag_names[attr]))
597 *eflags |= (1 << attr);
600 return (old == *eflags ? 0 : 1);
604 format_ip4_address (u8 * s, va_list * args)
606 u8 *a = va_arg (*args, u8 *);
607 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
611 format_ip6_address (u8 * s, va_list * args)
613 ip6_address_t *a = va_arg (*args, ip6_address_t *);
614 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
616 i_max_n_zero = ARRAY_LEN (a->as_u16);
618 i_first_zero = i_max_n_zero;
620 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
622 u32 is_zero = a->as_u16[i] == 0;
623 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
629 if ((!is_zero && n_zeros > max_n_zeros)
630 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
632 i_max_n_zero = i_first_zero;
633 max_n_zeros = n_zeros;
634 i_first_zero = ARRAY_LEN (a->as_u16);
639 last_double_colon = 0;
640 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
642 if (i == i_max_n_zero && max_n_zeros > 1)
644 s = format (s, "::");
645 i += max_n_zeros - 1;
646 last_double_colon = 1;
650 s = format (s, "%s%x",
651 (last_double_colon || i == 0) ? "" : ":",
652 clib_net_to_host_u16 (a->as_u16[i]));
653 last_double_colon = 0;
660 /* Format an IP46 address. */
662 format_ip46_address (u8 * s, va_list * args)
664 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
665 ip46_type_t type = va_arg (*args, ip46_type_t);
671 is_ip4 = ip46_address_is_ip4 (ip46);
682 format (s, "%U", format_ip4_address, &ip46->ip4) :
683 format (s, "%U", format_ip6_address, &ip46->ip6);
687 format_ethernet_address (u8 * s, va_list * args)
689 u8 *a = va_arg (*args, u8 *);
691 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
692 a[0], a[1], a[2], a[3], a[4], a[5]);
697 increment_v4_address (ip4_address_t * a)
701 v = ntohl (a->as_u32) + 1;
702 a->as_u32 = ntohl (v);
706 increment_v6_address (ip6_address_t * a)
710 v0 = clib_net_to_host_u64 (a->as_u64[0]);
711 v1 = clib_net_to_host_u64 (a->as_u64[1]);
716 a->as_u64[0] = clib_net_to_host_u64 (v0);
717 a->as_u64[1] = clib_net_to_host_u64 (v1);
721 increment_mac_address (u8 * mac)
723 u64 tmp = *((u64 *) mac);
724 tmp = clib_net_to_host_u64 (tmp);
725 tmp += 1 << 16; /* skip unused (least significant) octets */
726 tmp = clib_host_to_net_u64 (tmp);
728 clib_memcpy (mac, &tmp, 6);
731 static void vl_api_create_loopback_reply_t_handler
732 (vl_api_create_loopback_reply_t * mp)
734 vat_main_t *vam = &vat_main;
735 i32 retval = ntohl (mp->retval);
737 vam->retval = retval;
738 vam->regenerate_interface_table = 1;
739 vam->sw_if_index = ntohl (mp->sw_if_index);
740 vam->result_ready = 1;
743 static void vl_api_create_loopback_reply_t_handler_json
744 (vl_api_create_loopback_reply_t * mp)
746 vat_main_t *vam = &vat_main;
747 vat_json_node_t node;
749 vat_json_init_object (&node);
750 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
751 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
753 vat_json_print (vam->ofp, &node);
754 vat_json_free (&node);
755 vam->retval = ntohl (mp->retval);
756 vam->result_ready = 1;
759 static void vl_api_create_loopback_instance_reply_t_handler
760 (vl_api_create_loopback_instance_reply_t * mp)
762 vat_main_t *vam = &vat_main;
763 i32 retval = ntohl (mp->retval);
765 vam->retval = retval;
766 vam->regenerate_interface_table = 1;
767 vam->sw_if_index = ntohl (mp->sw_if_index);
768 vam->result_ready = 1;
771 static void vl_api_create_loopback_instance_reply_t_handler_json
772 (vl_api_create_loopback_instance_reply_t * mp)
774 vat_main_t *vam = &vat_main;
775 vat_json_node_t node;
777 vat_json_init_object (&node);
778 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
779 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
781 vat_json_print (vam->ofp, &node);
782 vat_json_free (&node);
783 vam->retval = ntohl (mp->retval);
784 vam->result_ready = 1;
787 static void vl_api_af_packet_create_reply_t_handler
788 (vl_api_af_packet_create_reply_t * mp)
790 vat_main_t *vam = &vat_main;
791 i32 retval = ntohl (mp->retval);
793 vam->retval = retval;
794 vam->regenerate_interface_table = 1;
795 vam->sw_if_index = ntohl (mp->sw_if_index);
796 vam->result_ready = 1;
799 static void vl_api_af_packet_create_reply_t_handler_json
800 (vl_api_af_packet_create_reply_t * mp)
802 vat_main_t *vam = &vat_main;
803 vat_json_node_t node;
805 vat_json_init_object (&node);
806 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
807 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
809 vat_json_print (vam->ofp, &node);
810 vat_json_free (&node);
812 vam->retval = ntohl (mp->retval);
813 vam->result_ready = 1;
816 static void vl_api_create_vlan_subif_reply_t_handler
817 (vl_api_create_vlan_subif_reply_t * mp)
819 vat_main_t *vam = &vat_main;
820 i32 retval = ntohl (mp->retval);
822 vam->retval = retval;
823 vam->regenerate_interface_table = 1;
824 vam->sw_if_index = ntohl (mp->sw_if_index);
825 vam->result_ready = 1;
828 static void vl_api_create_vlan_subif_reply_t_handler_json
829 (vl_api_create_vlan_subif_reply_t * mp)
831 vat_main_t *vam = &vat_main;
832 vat_json_node_t node;
834 vat_json_init_object (&node);
835 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
836 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
838 vat_json_print (vam->ofp, &node);
839 vat_json_free (&node);
841 vam->retval = ntohl (mp->retval);
842 vam->result_ready = 1;
845 static void vl_api_create_subif_reply_t_handler
846 (vl_api_create_subif_reply_t * mp)
848 vat_main_t *vam = &vat_main;
849 i32 retval = ntohl (mp->retval);
851 vam->retval = retval;
852 vam->regenerate_interface_table = 1;
853 vam->sw_if_index = ntohl (mp->sw_if_index);
854 vam->result_ready = 1;
857 static void vl_api_create_subif_reply_t_handler_json
858 (vl_api_create_subif_reply_t * mp)
860 vat_main_t *vam = &vat_main;
861 vat_json_node_t node;
863 vat_json_init_object (&node);
864 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
865 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
867 vat_json_print (vam->ofp, &node);
868 vat_json_free (&node);
870 vam->retval = ntohl (mp->retval);
871 vam->result_ready = 1;
874 static void vl_api_interface_name_renumber_reply_t_handler
875 (vl_api_interface_name_renumber_reply_t * mp)
877 vat_main_t *vam = &vat_main;
878 i32 retval = ntohl (mp->retval);
880 vam->retval = retval;
881 vam->regenerate_interface_table = 1;
882 vam->result_ready = 1;
885 static void vl_api_interface_name_renumber_reply_t_handler_json
886 (vl_api_interface_name_renumber_reply_t * mp)
888 vat_main_t *vam = &vat_main;
889 vat_json_node_t node;
891 vat_json_init_object (&node);
892 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
894 vat_json_print (vam->ofp, &node);
895 vat_json_free (&node);
897 vam->retval = ntohl (mp->retval);
898 vam->result_ready = 1;
902 * Special-case: build the interface table, maintain
903 * the next loopback sw_if_index vbl.
905 static void vl_api_sw_interface_details_t_handler
906 (vl_api_sw_interface_details_t * mp)
908 vat_main_t *vam = &vat_main;
909 u8 *s = format (0, "%s%c", mp->interface_name, 0);
911 hash_set_mem (vam->sw_if_index_by_interface_name, s,
912 ntohl (mp->sw_if_index));
914 /* In sub interface case, fill the sub interface table entry */
915 if (mp->sw_if_index != mp->sup_sw_if_index)
917 sw_interface_subif_t *sub = NULL;
919 vec_add2 (vam->sw_if_subif_table, sub, 1);
921 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
922 strncpy ((char *) sub->interface_name, (char *) s,
923 vec_len (sub->interface_name));
924 sub->sw_if_index = ntohl (mp->sw_if_index);
925 sub->sub_id = ntohl (mp->sub_id);
927 sub->sub_dot1ad = mp->sub_dot1ad;
928 sub->sub_number_of_tags = mp->sub_number_of_tags;
929 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
930 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
931 sub->sub_exact_match = mp->sub_exact_match;
932 sub->sub_default = mp->sub_default;
933 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
934 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
936 /* vlan tag rewrite */
937 sub->vtr_op = ntohl (mp->vtr_op);
938 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
939 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
940 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
944 static void vl_api_sw_interface_details_t_handler_json
945 (vl_api_sw_interface_details_t * mp)
947 vat_main_t *vam = &vat_main;
948 vat_json_node_t *node = NULL;
950 if (VAT_JSON_ARRAY != vam->json_tree.type)
952 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
953 vat_json_init_array (&vam->json_tree);
955 node = vat_json_array_add (&vam->json_tree);
957 vat_json_init_object (node);
958 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
959 vat_json_object_add_uint (node, "sup_sw_if_index",
960 ntohl (mp->sup_sw_if_index));
961 vat_json_object_add_uint (node, "l2_address_length",
962 ntohl (mp->l2_address_length));
963 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
964 sizeof (mp->l2_address));
965 vat_json_object_add_string_copy (node, "interface_name",
967 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
968 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
969 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
970 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
971 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
972 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
973 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
974 vat_json_object_add_uint (node, "sub_number_of_tags",
975 mp->sub_number_of_tags);
976 vat_json_object_add_uint (node, "sub_outer_vlan_id",
977 ntohs (mp->sub_outer_vlan_id));
978 vat_json_object_add_uint (node, "sub_inner_vlan_id",
979 ntohs (mp->sub_inner_vlan_id));
980 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
981 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
982 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
983 mp->sub_outer_vlan_id_any);
984 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
985 mp->sub_inner_vlan_id_any);
986 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
987 vat_json_object_add_uint (node, "vtr_push_dot1q",
988 ntohl (mp->vtr_push_dot1q));
989 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
990 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
993 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
995 format_ethernet_address,
997 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
999 format_ethernet_address,
1001 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1002 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1006 #if VPP_API_TEST_BUILTIN == 0
1007 static void vl_api_sw_interface_event_t_handler
1008 (vl_api_sw_interface_event_t * mp)
1010 vat_main_t *vam = &vat_main;
1011 if (vam->interface_event_display)
1012 errmsg ("interface flags: sw_if_index %d %s %s",
1013 ntohl (mp->sw_if_index),
1014 mp->admin_up_down ? "admin-up" : "admin-down",
1015 mp->link_up_down ? "link-up" : "link-down");
1019 static void vl_api_sw_interface_event_t_handler_json
1020 (vl_api_sw_interface_event_t * mp)
1022 /* JSON output not supported */
1026 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1028 vat_main_t *vam = &vat_main;
1029 i32 retval = ntohl (mp->retval);
1031 vam->retval = retval;
1032 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1033 vam->result_ready = 1;
1037 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1039 vat_main_t *vam = &vat_main;
1040 vat_json_node_t node;
1041 api_main_t *am = &api_main;
1045 vat_json_init_object (&node);
1046 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1047 vat_json_object_add_uint (&node, "reply_in_shmem",
1048 ntohl (mp->reply_in_shmem));
1049 /* Toss the shared-memory original... */
1050 pthread_mutex_lock (&am->vlib_rp->mutex);
1051 oldheap = svm_push_data_heap (am->vlib_rp);
1053 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1056 svm_pop_heap (oldheap);
1057 pthread_mutex_unlock (&am->vlib_rp->mutex);
1059 vat_json_print (vam->ofp, &node);
1060 vat_json_free (&node);
1062 vam->retval = ntohl (mp->retval);
1063 vam->result_ready = 1;
1067 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1069 vat_main_t *vam = &vat_main;
1070 i32 retval = ntohl (mp->retval);
1071 u32 length = ntohl (mp->length);
1073 vec_reset_length (vam->cmd_reply);
1075 vam->retval = retval;
1078 vec_validate (vam->cmd_reply, length);
1079 clib_memcpy ((char *) (vam->cmd_reply), mp->reply, length);
1080 vam->cmd_reply[length] = 0;
1082 vam->result_ready = 1;
1086 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1088 vat_main_t *vam = &vat_main;
1089 vat_json_node_t node;
1091 vec_reset_length (vam->cmd_reply);
1093 vat_json_init_object (&node);
1094 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1095 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1097 vat_json_print (vam->ofp, &node);
1098 vat_json_free (&node);
1100 vam->retval = ntohl (mp->retval);
1101 vam->result_ready = 1;
1104 static void vl_api_classify_add_del_table_reply_t_handler
1105 (vl_api_classify_add_del_table_reply_t * mp)
1107 vat_main_t *vam = &vat_main;
1108 i32 retval = ntohl (mp->retval);
1109 if (vam->async_mode)
1111 vam->async_errors += (retval < 0);
1115 vam->retval = retval;
1117 ((mp->new_table_index != 0xFFFFFFFF) ||
1118 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1119 (mp->match_n_vectors != 0xFFFFFFFF)))
1121 * Note: this is just barely thread-safe, depends on
1122 * the main thread spinning waiting for an answer...
1124 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1125 ntohl (mp->new_table_index),
1126 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1127 vam->result_ready = 1;
1131 static void vl_api_classify_add_del_table_reply_t_handler_json
1132 (vl_api_classify_add_del_table_reply_t * mp)
1134 vat_main_t *vam = &vat_main;
1135 vat_json_node_t node;
1137 vat_json_init_object (&node);
1138 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1139 vat_json_object_add_uint (&node, "new_table_index",
1140 ntohl (mp->new_table_index));
1141 vat_json_object_add_uint (&node, "skip_n_vectors",
1142 ntohl (mp->skip_n_vectors));
1143 vat_json_object_add_uint (&node, "match_n_vectors",
1144 ntohl (mp->match_n_vectors));
1146 vat_json_print (vam->ofp, &node);
1147 vat_json_free (&node);
1149 vam->retval = ntohl (mp->retval);
1150 vam->result_ready = 1;
1153 static void vl_api_get_node_index_reply_t_handler
1154 (vl_api_get_node_index_reply_t * mp)
1156 vat_main_t *vam = &vat_main;
1157 i32 retval = ntohl (mp->retval);
1158 if (vam->async_mode)
1160 vam->async_errors += (retval < 0);
1164 vam->retval = retval;
1166 errmsg ("node index %d", ntohl (mp->node_index));
1167 vam->result_ready = 1;
1171 static void vl_api_get_node_index_reply_t_handler_json
1172 (vl_api_get_node_index_reply_t * mp)
1174 vat_main_t *vam = &vat_main;
1175 vat_json_node_t node;
1177 vat_json_init_object (&node);
1178 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1179 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1181 vat_json_print (vam->ofp, &node);
1182 vat_json_free (&node);
1184 vam->retval = ntohl (mp->retval);
1185 vam->result_ready = 1;
1188 static void vl_api_get_next_index_reply_t_handler
1189 (vl_api_get_next_index_reply_t * mp)
1191 vat_main_t *vam = &vat_main;
1192 i32 retval = ntohl (mp->retval);
1193 if (vam->async_mode)
1195 vam->async_errors += (retval < 0);
1199 vam->retval = retval;
1201 errmsg ("next node index %d", ntohl (mp->next_index));
1202 vam->result_ready = 1;
1206 static void vl_api_get_next_index_reply_t_handler_json
1207 (vl_api_get_next_index_reply_t * mp)
1209 vat_main_t *vam = &vat_main;
1210 vat_json_node_t node;
1212 vat_json_init_object (&node);
1213 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1214 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1216 vat_json_print (vam->ofp, &node);
1217 vat_json_free (&node);
1219 vam->retval = ntohl (mp->retval);
1220 vam->result_ready = 1;
1223 static void vl_api_add_node_next_reply_t_handler
1224 (vl_api_add_node_next_reply_t * mp)
1226 vat_main_t *vam = &vat_main;
1227 i32 retval = ntohl (mp->retval);
1228 if (vam->async_mode)
1230 vam->async_errors += (retval < 0);
1234 vam->retval = retval;
1236 errmsg ("next index %d", ntohl (mp->next_index));
1237 vam->result_ready = 1;
1241 static void vl_api_add_node_next_reply_t_handler_json
1242 (vl_api_add_node_next_reply_t * mp)
1244 vat_main_t *vam = &vat_main;
1245 vat_json_node_t node;
1247 vat_json_init_object (&node);
1248 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1249 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1251 vat_json_print (vam->ofp, &node);
1252 vat_json_free (&node);
1254 vam->retval = ntohl (mp->retval);
1255 vam->result_ready = 1;
1258 static void vl_api_show_version_reply_t_handler
1259 (vl_api_show_version_reply_t * mp)
1261 vat_main_t *vam = &vat_main;
1262 i32 retval = ntohl (mp->retval);
1266 errmsg (" program: %s", mp->program);
1267 errmsg (" version: %s", mp->version);
1268 errmsg (" build date: %s", mp->build_date);
1269 errmsg ("build directory: %s", mp->build_directory);
1271 vam->retval = retval;
1272 vam->result_ready = 1;
1275 static void vl_api_show_version_reply_t_handler_json
1276 (vl_api_show_version_reply_t * mp)
1278 vat_main_t *vam = &vat_main;
1279 vat_json_node_t node;
1281 vat_json_init_object (&node);
1282 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1283 vat_json_object_add_string_copy (&node, "program", mp->program);
1284 vat_json_object_add_string_copy (&node, "version", mp->version);
1285 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1286 vat_json_object_add_string_copy (&node, "build_directory",
1287 mp->build_directory);
1289 vat_json_print (vam->ofp, &node);
1290 vat_json_free (&node);
1292 vam->retval = ntohl (mp->retval);
1293 vam->result_ready = 1;
1297 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1299 u32 sw_if_index = ntohl (mp->sw_if_index);
1300 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1301 mp->mac_ip ? "mac/ip binding" : "address resolution",
1302 ntohl (mp->pid), format_ip4_address, &mp->address,
1303 format_ethernet_address, mp->new_mac, sw_if_index);
1307 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1309 /* JSON output not supported */
1313 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1315 u32 sw_if_index = ntohl (mp->sw_if_index);
1316 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1317 mp->mac_ip ? "mac/ip binding" : "address resolution",
1318 ntohl (mp->pid), format_ip6_address, mp->address,
1319 format_ethernet_address, mp->new_mac, sw_if_index);
1323 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1325 /* JSON output not supported */
1329 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1331 u32 n_macs = ntohl (mp->n_macs);
1332 errmsg ("L2MAC event recived with pid %d cl-idx %d for %d macs: \n",
1333 ntohl (mp->pid), mp->client_index, n_macs);
1335 for (i = 0; i < n_macs; i++)
1337 vl_api_mac_entry_t *mac = &mp->mac[i];
1338 errmsg (" [%d] sw_if_index %d mac_addr %U is_del %d \n",
1339 i + 1, ntohl (mac->sw_if_index),
1340 format_ethernet_address, mac->mac_addr, mac->is_del);
1347 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1349 /* JSON output not supported */
1352 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1353 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1356 * Special-case: build the bridge domain table, maintain
1357 * the next bd id vbl.
1359 static void vl_api_bridge_domain_details_t_handler
1360 (vl_api_bridge_domain_details_t * mp)
1362 vat_main_t *vam = &vat_main;
1363 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1366 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1367 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1369 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1370 ntohl (mp->bd_id), mp->learn, mp->forward,
1371 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1375 vl_api_bridge_domain_sw_if_t *sw_ifs;
1376 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1379 sw_ifs = mp->sw_if_details;
1380 for (i = 0; i < n_sw_ifs; i++)
1386 sw_if_index = ntohl (sw_ifs->sw_if_index);
1389 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1391 if ((u32) p->value[0] == sw_if_index)
1393 sw_if_name = (u8 *)(p->key);
1398 print (vam->ofp, "%7d %3d %s", sw_if_index,
1399 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1400 "sw_if_index not found!");
1407 static void vl_api_bridge_domain_details_t_handler_json
1408 (vl_api_bridge_domain_details_t * mp)
1410 vat_main_t *vam = &vat_main;
1411 vat_json_node_t *node, *array = NULL;
1412 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1414 if (VAT_JSON_ARRAY != vam->json_tree.type)
1416 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1417 vat_json_init_array (&vam->json_tree);
1419 node = vat_json_array_add (&vam->json_tree);
1421 vat_json_init_object (node);
1422 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1423 vat_json_object_add_uint (node, "flood", mp->flood);
1424 vat_json_object_add_uint (node, "forward", mp->forward);
1425 vat_json_object_add_uint (node, "learn", mp->learn);
1426 vat_json_object_add_uint (node, "bvi_sw_if_index",
1427 ntohl (mp->bvi_sw_if_index));
1428 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1429 array = vat_json_object_add (node, "sw_if");
1430 vat_json_init_array (array);
1436 vl_api_bridge_domain_sw_if_t *sw_ifs;
1439 sw_ifs = mp->sw_if_details;
1440 for (i = 0; i < n_sw_ifs; i++)
1442 node = vat_json_array_add (array);
1443 vat_json_init_object (node);
1444 vat_json_object_add_uint (node, "sw_if_index",
1445 ntohl (sw_ifs->sw_if_index));
1446 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1452 static void vl_api_control_ping_reply_t_handler
1453 (vl_api_control_ping_reply_t * mp)
1455 vat_main_t *vam = &vat_main;
1456 i32 retval = ntohl (mp->retval);
1457 if (vam->async_mode)
1459 vam->async_errors += (retval < 0);
1463 vam->retval = retval;
1464 vam->result_ready = 1;
1466 vam->socket_client_main.control_pings_outstanding--;
1469 static void vl_api_control_ping_reply_t_handler_json
1470 (vl_api_control_ping_reply_t * mp)
1472 vat_main_t *vam = &vat_main;
1473 i32 retval = ntohl (mp->retval);
1475 if (VAT_JSON_NONE != vam->json_tree.type)
1477 vat_json_print (vam->ofp, &vam->json_tree);
1478 vat_json_free (&vam->json_tree);
1479 vam->json_tree.type = VAT_JSON_NONE;
1484 vat_json_init_array (&vam->json_tree);
1485 vat_json_print (vam->ofp, &vam->json_tree);
1486 vam->json_tree.type = VAT_JSON_NONE;
1489 vam->retval = retval;
1490 vam->result_ready = 1;
1494 vl_api_bridge_domain_set_mac_age_reply_t_handler
1495 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1497 vat_main_t *vam = &vat_main;
1498 i32 retval = ntohl (mp->retval);
1499 if (vam->async_mode)
1501 vam->async_errors += (retval < 0);
1505 vam->retval = retval;
1506 vam->result_ready = 1;
1510 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1511 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1513 vat_main_t *vam = &vat_main;
1514 vat_json_node_t node;
1516 vat_json_init_object (&node);
1517 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1519 vat_json_print (vam->ofp, &node);
1520 vat_json_free (&node);
1522 vam->retval = ntohl (mp->retval);
1523 vam->result_ready = 1;
1527 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1529 vat_main_t *vam = &vat_main;
1530 i32 retval = ntohl (mp->retval);
1531 if (vam->async_mode)
1533 vam->async_errors += (retval < 0);
1537 vam->retval = retval;
1538 vam->result_ready = 1;
1542 static void vl_api_l2_flags_reply_t_handler_json
1543 (vl_api_l2_flags_reply_t * mp)
1545 vat_main_t *vam = &vat_main;
1546 vat_json_node_t node;
1548 vat_json_init_object (&node);
1549 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1550 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1551 ntohl (mp->resulting_feature_bitmap));
1553 vat_json_print (vam->ofp, &node);
1554 vat_json_free (&node);
1556 vam->retval = ntohl (mp->retval);
1557 vam->result_ready = 1;
1560 static void vl_api_bridge_flags_reply_t_handler
1561 (vl_api_bridge_flags_reply_t * mp)
1563 vat_main_t *vam = &vat_main;
1564 i32 retval = ntohl (mp->retval);
1565 if (vam->async_mode)
1567 vam->async_errors += (retval < 0);
1571 vam->retval = retval;
1572 vam->result_ready = 1;
1576 static void vl_api_bridge_flags_reply_t_handler_json
1577 (vl_api_bridge_flags_reply_t * mp)
1579 vat_main_t *vam = &vat_main;
1580 vat_json_node_t node;
1582 vat_json_init_object (&node);
1583 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1584 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1585 ntohl (mp->resulting_feature_bitmap));
1587 vat_json_print (vam->ofp, &node);
1588 vat_json_free (&node);
1590 vam->retval = ntohl (mp->retval);
1591 vam->result_ready = 1;
1594 static void vl_api_tap_connect_reply_t_handler
1595 (vl_api_tap_connect_reply_t * mp)
1597 vat_main_t *vam = &vat_main;
1598 i32 retval = ntohl (mp->retval);
1599 if (vam->async_mode)
1601 vam->async_errors += (retval < 0);
1605 vam->retval = retval;
1606 vam->sw_if_index = ntohl (mp->sw_if_index);
1607 vam->result_ready = 1;
1612 static void vl_api_tap_connect_reply_t_handler_json
1613 (vl_api_tap_connect_reply_t * mp)
1615 vat_main_t *vam = &vat_main;
1616 vat_json_node_t node;
1618 vat_json_init_object (&node);
1619 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1620 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1622 vat_json_print (vam->ofp, &node);
1623 vat_json_free (&node);
1625 vam->retval = ntohl (mp->retval);
1626 vam->result_ready = 1;
1631 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1633 vat_main_t *vam = &vat_main;
1634 i32 retval = ntohl (mp->retval);
1635 if (vam->async_mode)
1637 vam->async_errors += (retval < 0);
1641 vam->retval = retval;
1642 vam->sw_if_index = ntohl (mp->sw_if_index);
1643 vam->result_ready = 1;
1647 static void vl_api_tap_modify_reply_t_handler_json
1648 (vl_api_tap_modify_reply_t * mp)
1650 vat_main_t *vam = &vat_main;
1651 vat_json_node_t node;
1653 vat_json_init_object (&node);
1654 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1655 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1657 vat_json_print (vam->ofp, &node);
1658 vat_json_free (&node);
1660 vam->retval = ntohl (mp->retval);
1661 vam->result_ready = 1;
1665 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1667 vat_main_t *vam = &vat_main;
1668 i32 retval = ntohl (mp->retval);
1669 if (vam->async_mode)
1671 vam->async_errors += (retval < 0);
1675 vam->retval = retval;
1676 vam->result_ready = 1;
1680 static void vl_api_tap_delete_reply_t_handler_json
1681 (vl_api_tap_delete_reply_t * mp)
1683 vat_main_t *vam = &vat_main;
1684 vat_json_node_t node;
1686 vat_json_init_object (&node);
1687 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1689 vat_json_print (vam->ofp, &node);
1690 vat_json_free (&node);
1692 vam->retval = ntohl (mp->retval);
1693 vam->result_ready = 1;
1696 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1697 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1699 vat_main_t *vam = &vat_main;
1700 i32 retval = ntohl (mp->retval);
1701 if (vam->async_mode)
1703 vam->async_errors += (retval < 0);
1707 vam->retval = retval;
1708 vam->result_ready = 1;
1712 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1713 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1715 vat_main_t *vam = &vat_main;
1716 vat_json_node_t node;
1718 vat_json_init_object (&node);
1719 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1720 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1721 ntohl (mp->sw_if_index));
1723 vat_json_print (vam->ofp, &node);
1724 vat_json_free (&node);
1726 vam->retval = ntohl (mp->retval);
1727 vam->result_ready = 1;
1730 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1731 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1733 vat_main_t *vam = &vat_main;
1734 i32 retval = ntohl (mp->retval);
1735 if (vam->async_mode)
1737 vam->async_errors += (retval < 0);
1741 vam->retval = retval;
1742 vam->sw_if_index = ntohl (mp->sw_if_index);
1743 vam->result_ready = 1;
1747 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1748 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1750 vat_main_t *vam = &vat_main;
1751 vat_json_node_t node;
1753 vat_json_init_object (&node);
1754 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1755 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1757 vat_json_print (vam->ofp, &node);
1758 vat_json_free (&node);
1760 vam->retval = ntohl (mp->retval);
1761 vam->result_ready = 1;
1764 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
1765 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1767 vat_main_t *vam = &vat_main;
1768 i32 retval = ntohl (mp->retval);
1769 if (vam->async_mode)
1771 vam->async_errors += (retval < 0);
1775 vam->retval = retval;
1776 vam->result_ready = 1;
1780 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
1781 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1783 vat_main_t *vam = &vat_main;
1784 vat_json_node_t node;
1786 vat_json_init_object (&node);
1787 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1788 vat_json_object_add_uint (&node, "fwd_entry_index",
1789 clib_net_to_host_u32 (mp->fwd_entry_index));
1791 vat_json_print (vam->ofp, &node);
1792 vat_json_free (&node);
1794 vam->retval = ntohl (mp->retval);
1795 vam->result_ready = 1;
1799 format_lisp_transport_protocol (u8 * s, va_list * args)
1801 u32 proto = va_arg (*args, u32);
1806 return format (s, "udp");
1808 return format (s, "api");
1815 static void vl_api_one_get_transport_protocol_reply_t_handler
1816 (vl_api_one_get_transport_protocol_reply_t * mp)
1818 vat_main_t *vam = &vat_main;
1819 i32 retval = ntohl (mp->retval);
1820 if (vam->async_mode)
1822 vam->async_errors += (retval < 0);
1826 u32 proto = mp->protocol;
1827 print (vam->ofp, "Transport protocol: %U",
1828 format_lisp_transport_protocol, proto);
1829 vam->retval = retval;
1830 vam->result_ready = 1;
1834 static void vl_api_one_get_transport_protocol_reply_t_handler_json
1835 (vl_api_one_get_transport_protocol_reply_t * mp)
1837 vat_main_t *vam = &vat_main;
1838 vat_json_node_t node;
1841 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
1844 vat_json_init_object (&node);
1845 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1846 vat_json_object_add_string_copy (&node, "transport-protocol", s);
1849 vat_json_print (vam->ofp, &node);
1850 vat_json_free (&node);
1852 vam->retval = ntohl (mp->retval);
1853 vam->result_ready = 1;
1856 static void vl_api_one_add_del_locator_set_reply_t_handler
1857 (vl_api_one_add_del_locator_set_reply_t * mp)
1859 vat_main_t *vam = &vat_main;
1860 i32 retval = ntohl (mp->retval);
1861 if (vam->async_mode)
1863 vam->async_errors += (retval < 0);
1867 vam->retval = retval;
1868 vam->result_ready = 1;
1872 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1873 (vl_api_one_add_del_locator_set_reply_t * mp)
1875 vat_main_t *vam = &vat_main;
1876 vat_json_node_t node;
1878 vat_json_init_object (&node);
1879 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1880 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1882 vat_json_print (vam->ofp, &node);
1883 vat_json_free (&node);
1885 vam->retval = ntohl (mp->retval);
1886 vam->result_ready = 1;
1889 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1890 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1892 vat_main_t *vam = &vat_main;
1893 i32 retval = ntohl (mp->retval);
1894 if (vam->async_mode)
1896 vam->async_errors += (retval < 0);
1900 vam->retval = retval;
1901 vam->sw_if_index = ntohl (mp->sw_if_index);
1902 vam->result_ready = 1;
1906 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1907 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1909 vat_main_t *vam = &vat_main;
1910 vat_json_node_t node;
1912 vat_json_init_object (&node);
1913 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1914 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1916 vat_json_print (vam->ofp, &node);
1917 vat_json_free (&node);
1919 vam->retval = ntohl (mp->retval);
1920 vam->result_ready = 1;
1923 static void vl_api_geneve_add_del_tunnel_reply_t_handler
1924 (vl_api_geneve_add_del_tunnel_reply_t * mp)
1926 vat_main_t *vam = &vat_main;
1927 i32 retval = ntohl (mp->retval);
1928 if (vam->async_mode)
1930 vam->async_errors += (retval < 0);
1934 vam->retval = retval;
1935 vam->sw_if_index = ntohl (mp->sw_if_index);
1936 vam->result_ready = 1;
1940 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
1941 (vl_api_geneve_add_del_tunnel_reply_t * mp)
1943 vat_main_t *vam = &vat_main;
1944 vat_json_node_t node;
1946 vat_json_init_object (&node);
1947 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1948 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1950 vat_json_print (vam->ofp, &node);
1951 vat_json_free (&node);
1953 vam->retval = ntohl (mp->retval);
1954 vam->result_ready = 1;
1957 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
1958 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1960 vat_main_t *vam = &vat_main;
1961 i32 retval = ntohl (mp->retval);
1962 if (vam->async_mode)
1964 vam->async_errors += (retval < 0);
1968 vam->retval = retval;
1969 vam->sw_if_index = ntohl (mp->sw_if_index);
1970 vam->result_ready = 1;
1974 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
1975 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1977 vat_main_t *vam = &vat_main;
1978 vat_json_node_t node;
1980 vat_json_init_object (&node);
1981 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1982 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1984 vat_json_print (vam->ofp, &node);
1985 vat_json_free (&node);
1987 vam->retval = ntohl (mp->retval);
1988 vam->result_ready = 1;
1991 static void vl_api_gre_add_del_tunnel_reply_t_handler
1992 (vl_api_gre_add_del_tunnel_reply_t * mp)
1994 vat_main_t *vam = &vat_main;
1995 i32 retval = ntohl (mp->retval);
1996 if (vam->async_mode)
1998 vam->async_errors += (retval < 0);
2002 vam->retval = retval;
2003 vam->sw_if_index = ntohl (mp->sw_if_index);
2004 vam->result_ready = 1;
2008 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2009 (vl_api_gre_add_del_tunnel_reply_t * mp)
2011 vat_main_t *vam = &vat_main;
2012 vat_json_node_t node;
2014 vat_json_init_object (&node);
2015 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2016 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2018 vat_json_print (vam->ofp, &node);
2019 vat_json_free (&node);
2021 vam->retval = ntohl (mp->retval);
2022 vam->result_ready = 1;
2025 static void vl_api_create_vhost_user_if_reply_t_handler
2026 (vl_api_create_vhost_user_if_reply_t * mp)
2028 vat_main_t *vam = &vat_main;
2029 i32 retval = ntohl (mp->retval);
2030 if (vam->async_mode)
2032 vam->async_errors += (retval < 0);
2036 vam->retval = retval;
2037 vam->sw_if_index = ntohl (mp->sw_if_index);
2038 vam->result_ready = 1;
2042 static void vl_api_create_vhost_user_if_reply_t_handler_json
2043 (vl_api_create_vhost_user_if_reply_t * mp)
2045 vat_main_t *vam = &vat_main;
2046 vat_json_node_t node;
2048 vat_json_init_object (&node);
2049 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2050 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2052 vat_json_print (vam->ofp, &node);
2053 vat_json_free (&node);
2055 vam->retval = ntohl (mp->retval);
2056 vam->result_ready = 1;
2059 static clib_error_t *
2060 receive_fd_msg (int socket_fd, int *my_fd)
2063 char ctl[CMSG_SPACE (sizeof (int)) + CMSG_SPACE (sizeof (struct ucred))];
2064 struct msghdr mh = { 0 };
2065 struct iovec iov[1];
2067 struct ucred *cr = 0;
2068 struct cmsghdr *cmsg;
2069 pid_t pid __attribute__ ((unused));
2070 uid_t uid __attribute__ ((unused));
2071 gid_t gid __attribute__ ((unused));
2073 iov[0].iov_base = msgbuf;
2077 mh.msg_control = ctl;
2078 mh.msg_controllen = sizeof (ctl);
2080 memset (ctl, 0, sizeof (ctl));
2082 /* receive the incoming message */
2083 size = recvmsg (socket_fd, &mh, 0);
2086 return (size == 0) ? clib_error_return (0, "disconnected") :
2087 clib_error_return_unix (0, "recvmsg: malformed message (fd %d)",
2091 cmsg = CMSG_FIRSTHDR (&mh);
2094 if (cmsg->cmsg_level == SOL_SOCKET)
2096 if (cmsg->cmsg_type == SCM_CREDENTIALS)
2098 cr = (struct ucred *) CMSG_DATA (cmsg);
2103 else if (cmsg->cmsg_type == SCM_RIGHTS)
2105 clib_memcpy (my_fd, CMSG_DATA (cmsg), sizeof (int));
2108 cmsg = CMSG_NXTHDR (&mh, cmsg);
2113 static void vl_api_memfd_segment_create_reply_t_handler
2114 (vl_api_memfd_segment_create_reply_t * mp)
2116 /* Dont bother in the builtin version */
2117 #if VPP_API_TEST_BUILTIN == 0
2118 vat_main_t *vam = &vat_main;
2119 api_main_t *am = &api_main;
2120 socket_client_main_t *scm = &vam->socket_client_main;
2122 clib_error_t *error;
2123 memfd_private_t memfd;
2124 i32 retval = ntohl (mp->retval);
2128 error = receive_fd_msg (scm->socket_fd, &my_fd);
2135 memset (&memfd, 0, sizeof (memfd));
2138 vam->client_index_invalid = 1;
2140 /* Note: this closes memfd.fd */
2141 retval = memfd_slave_init (&memfd);
2143 clib_warning ("WARNING: segment map returned %d", retval);
2145 /* Pivot to the memory client segment that vpp just created */
2147 am->vlib_rp = (void *) (memfd.requested_va + MMAP_PAGESIZE);
2149 am->shmem_hdr = (void *) am->vlib_rp->user_ctx;
2151 vl_client_install_client_message_handlers ();
2153 vl_client_connect_to_vlib_no_map ("pvt",
2155 32 /* input_queue_length */ );
2156 vam->vl_input_queue = am->shmem_hdr->vl_input_queue;
2158 vl_socket_client_enable_disable (&vam->socket_client_main,
2159 0 /* disable socket */ );
2163 if (vam->async_mode)
2165 vam->async_errors += (retval < 0);
2169 vam->retval = retval;
2170 vam->result_ready = 1;
2175 static void vl_api_memfd_segment_create_reply_t_handler_json
2176 (vl_api_memfd_segment_create_reply_t * mp)
2178 clib_warning ("no");
2181 static void vl_api_dns_resolve_name_reply_t_handler
2182 (vl_api_dns_resolve_name_reply_t * mp)
2184 vat_main_t *vam = &vat_main;
2185 i32 retval = ntohl (mp->retval);
2186 if (vam->async_mode)
2188 vam->async_errors += (retval < 0);
2192 vam->retval = retval;
2193 vam->result_ready = 1;
2198 clib_warning ("ip4 address %U", format_ip4_address,
2199 (ip4_address_t *) mp->ip4_address);
2201 clib_warning ("ip6 address %U", format_ip6_address,
2202 (ip6_address_t *) mp->ip6_address);
2205 clib_warning ("retval %d", retval);
2209 static void vl_api_dns_resolve_name_reply_t_handler_json
2210 (vl_api_dns_resolve_name_reply_t * mp)
2212 clib_warning ("not implemented");
2215 static void vl_api_dns_resolve_ip_reply_t_handler
2216 (vl_api_dns_resolve_ip_reply_t * mp)
2218 vat_main_t *vam = &vat_main;
2219 i32 retval = ntohl (mp->retval);
2220 if (vam->async_mode)
2222 vam->async_errors += (retval < 0);
2226 vam->retval = retval;
2227 vam->result_ready = 1;
2231 clib_warning ("canonical name %s", mp->name);
2234 clib_warning ("retval %d", retval);
2238 static void vl_api_dns_resolve_ip_reply_t_handler_json
2239 (vl_api_dns_resolve_ip_reply_t * mp)
2241 clib_warning ("not implemented");
2245 static void vl_api_ip_address_details_t_handler
2246 (vl_api_ip_address_details_t * mp)
2248 vat_main_t *vam = &vat_main;
2249 static ip_address_details_t empty_ip_address_details = { {0} };
2250 ip_address_details_t *address = NULL;
2251 ip_details_t *current_ip_details = NULL;
2252 ip_details_t *details = NULL;
2254 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2256 if (!details || vam->current_sw_if_index >= vec_len (details)
2257 || !details[vam->current_sw_if_index].present)
2259 errmsg ("ip address details arrived but not stored");
2260 errmsg ("ip_dump should be called first");
2264 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2266 #define addresses (current_ip_details->addr)
2268 vec_validate_init_empty (addresses, vec_len (addresses),
2269 empty_ip_address_details);
2271 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2273 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2274 address->prefix_length = mp->prefix_length;
2278 static void vl_api_ip_address_details_t_handler_json
2279 (vl_api_ip_address_details_t * mp)
2281 vat_main_t *vam = &vat_main;
2282 vat_json_node_t *node = NULL;
2283 struct in6_addr ip6;
2286 if (VAT_JSON_ARRAY != vam->json_tree.type)
2288 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2289 vat_json_init_array (&vam->json_tree);
2291 node = vat_json_array_add (&vam->json_tree);
2293 vat_json_init_object (node);
2296 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2297 vat_json_object_add_ip6 (node, "ip", ip6);
2301 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2302 vat_json_object_add_ip4 (node, "ip", ip4);
2304 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2308 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2310 vat_main_t *vam = &vat_main;
2311 static ip_details_t empty_ip_details = { 0 };
2312 ip_details_t *ip = NULL;
2313 u32 sw_if_index = ~0;
2315 sw_if_index = ntohl (mp->sw_if_index);
2317 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2318 sw_if_index, empty_ip_details);
2320 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2327 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2329 vat_main_t *vam = &vat_main;
2331 if (VAT_JSON_ARRAY != vam->json_tree.type)
2333 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2334 vat_json_init_array (&vam->json_tree);
2336 vat_json_array_add_uint (&vam->json_tree,
2337 clib_net_to_host_u32 (mp->sw_if_index));
2340 static void vl_api_map_domain_details_t_handler_json
2341 (vl_api_map_domain_details_t * mp)
2343 vat_json_node_t *node = NULL;
2344 vat_main_t *vam = &vat_main;
2345 struct in6_addr ip6;
2348 if (VAT_JSON_ARRAY != vam->json_tree.type)
2350 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2351 vat_json_init_array (&vam->json_tree);
2354 node = vat_json_array_add (&vam->json_tree);
2355 vat_json_init_object (node);
2357 vat_json_object_add_uint (node, "domain_index",
2358 clib_net_to_host_u32 (mp->domain_index));
2359 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2360 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2361 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2362 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2363 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2364 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2365 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2366 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2367 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2368 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2369 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2370 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2371 vat_json_object_add_uint (node, "flags", mp->flags);
2372 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2373 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2376 static void vl_api_map_domain_details_t_handler
2377 (vl_api_map_domain_details_t * mp)
2379 vat_main_t *vam = &vat_main;
2381 if (mp->is_translation)
2384 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2385 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2386 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2387 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2388 clib_net_to_host_u32 (mp->domain_index));
2393 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2394 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2395 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2396 format_ip6_address, mp->ip6_src,
2397 clib_net_to_host_u32 (mp->domain_index));
2399 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2400 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2401 mp->is_translation ? "map-t" : "");
2404 static void vl_api_map_rule_details_t_handler_json
2405 (vl_api_map_rule_details_t * mp)
2407 struct in6_addr ip6;
2408 vat_json_node_t *node = NULL;
2409 vat_main_t *vam = &vat_main;
2411 if (VAT_JSON_ARRAY != vam->json_tree.type)
2413 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2414 vat_json_init_array (&vam->json_tree);
2417 node = vat_json_array_add (&vam->json_tree);
2418 vat_json_init_object (node);
2420 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2421 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2422 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2426 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2428 vat_main_t *vam = &vat_main;
2429 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2430 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2434 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2436 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2437 "router_addr %U host_mac %U",
2438 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2439 format_ip4_address, &mp->host_address,
2440 format_ip4_address, &mp->router_address,
2441 format_ethernet_address, mp->host_mac);
2444 static void vl_api_dhcp_compl_event_t_handler_json
2445 (vl_api_dhcp_compl_event_t * mp)
2447 /* JSON output not supported */
2451 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2454 vat_main_t *vam = &vat_main;
2455 static u64 default_counter = 0;
2457 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2459 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2460 sw_if_index, default_counter);
2461 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2465 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2466 interface_counter_t counter)
2468 vat_main_t *vam = &vat_main;
2469 static interface_counter_t default_counter = { 0, };
2471 vec_validate_init_empty (vam->combined_interface_counters,
2472 vnet_counter_type, NULL);
2473 vec_validate_init_empty (vam->combined_interface_counters
2474 [vnet_counter_type], sw_if_index, default_counter);
2475 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2478 static void vl_api_vnet_interface_simple_counters_t_handler
2479 (vl_api_vnet_interface_simple_counters_t * mp)
2484 static void vl_api_vnet_interface_combined_counters_t_handler
2485 (vl_api_vnet_interface_combined_counters_t * mp)
2490 static void vl_api_vnet_interface_simple_counters_t_handler_json
2491 (vl_api_vnet_interface_simple_counters_t * mp)
2496 u32 first_sw_if_index;
2499 count = ntohl (mp->count);
2500 first_sw_if_index = ntohl (mp->first_sw_if_index);
2502 v_packets = (u64 *) & mp->data;
2503 for (i = 0; i < count; i++)
2505 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2506 set_simple_interface_counter (mp->vnet_counter_type,
2507 first_sw_if_index + i, packets);
2512 static void vl_api_vnet_interface_combined_counters_t_handler_json
2513 (vl_api_vnet_interface_combined_counters_t * mp)
2515 interface_counter_t counter;
2517 u32 first_sw_if_index;
2521 count = ntohl (mp->count);
2522 first_sw_if_index = ntohl (mp->first_sw_if_index);
2524 v = (vlib_counter_t *) & mp->data;
2525 for (i = 0; i < count; i++)
2528 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2530 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2531 set_combined_interface_counter (mp->vnet_counter_type,
2532 first_sw_if_index + i, counter);
2538 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2540 vat_main_t *vam = &vat_main;
2543 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2545 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2554 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2556 vat_main_t *vam = &vat_main;
2559 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2561 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2569 static void vl_api_vnet_ip4_fib_counters_t_handler
2570 (vl_api_vnet_ip4_fib_counters_t * mp)
2575 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2576 (vl_api_vnet_ip4_fib_counters_t * mp)
2578 vat_main_t *vam = &vat_main;
2579 vl_api_ip4_fib_counter_t *v;
2580 ip4_fib_counter_t *counter;
2587 vrf_id = ntohl (mp->vrf_id);
2588 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2589 if (~0 == vrf_index)
2591 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2592 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2593 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2594 vec_validate (vam->ip4_fib_counters, vrf_index);
2595 vam->ip4_fib_counters[vrf_index] = NULL;
2598 vec_free (vam->ip4_fib_counters[vrf_index]);
2599 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2600 count = ntohl (mp->count);
2601 for (i = 0; i < count; i++)
2603 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2604 counter = &vam->ip4_fib_counters[vrf_index][i];
2605 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2606 counter->address = ip4;
2607 counter->address_length = v->address_length;
2608 counter->packets = clib_net_to_host_u64 (v->packets);
2609 counter->bytes = clib_net_to_host_u64 (v->bytes);
2614 static void vl_api_vnet_ip4_nbr_counters_t_handler
2615 (vl_api_vnet_ip4_nbr_counters_t * mp)
2620 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2621 (vl_api_vnet_ip4_nbr_counters_t * mp)
2623 vat_main_t *vam = &vat_main;
2624 vl_api_ip4_nbr_counter_t *v;
2625 ip4_nbr_counter_t *counter;
2630 sw_if_index = ntohl (mp->sw_if_index);
2631 count = ntohl (mp->count);
2632 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2635 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2637 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2638 for (i = 0; i < count; i++)
2640 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2641 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2642 counter->address.s_addr = v->address;
2643 counter->packets = clib_net_to_host_u64 (v->packets);
2644 counter->bytes = clib_net_to_host_u64 (v->bytes);
2645 counter->linkt = v->link_type;
2650 static void vl_api_vnet_ip6_fib_counters_t_handler
2651 (vl_api_vnet_ip6_fib_counters_t * mp)
2656 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2657 (vl_api_vnet_ip6_fib_counters_t * mp)
2659 vat_main_t *vam = &vat_main;
2660 vl_api_ip6_fib_counter_t *v;
2661 ip6_fib_counter_t *counter;
2662 struct in6_addr ip6;
2668 vrf_id = ntohl (mp->vrf_id);
2669 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2670 if (~0 == vrf_index)
2672 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2673 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2674 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2675 vec_validate (vam->ip6_fib_counters, vrf_index);
2676 vam->ip6_fib_counters[vrf_index] = NULL;
2679 vec_free (vam->ip6_fib_counters[vrf_index]);
2680 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2681 count = ntohl (mp->count);
2682 for (i = 0; i < count; i++)
2684 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2685 counter = &vam->ip6_fib_counters[vrf_index][i];
2686 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2687 counter->address = ip6;
2688 counter->address_length = v->address_length;
2689 counter->packets = clib_net_to_host_u64 (v->packets);
2690 counter->bytes = clib_net_to_host_u64 (v->bytes);
2695 static void vl_api_vnet_ip6_nbr_counters_t_handler
2696 (vl_api_vnet_ip6_nbr_counters_t * mp)
2701 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2702 (vl_api_vnet_ip6_nbr_counters_t * mp)
2704 vat_main_t *vam = &vat_main;
2705 vl_api_ip6_nbr_counter_t *v;
2706 ip6_nbr_counter_t *counter;
2707 struct in6_addr ip6;
2712 sw_if_index = ntohl (mp->sw_if_index);
2713 count = ntohl (mp->count);
2714 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2717 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2719 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2720 for (i = 0; i < count; i++)
2722 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2723 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2724 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2725 counter->address = ip6;
2726 counter->packets = clib_net_to_host_u64 (v->packets);
2727 counter->bytes = clib_net_to_host_u64 (v->bytes);
2732 static void vl_api_get_first_msg_id_reply_t_handler
2733 (vl_api_get_first_msg_id_reply_t * mp)
2735 vat_main_t *vam = &vat_main;
2736 i32 retval = ntohl (mp->retval);
2738 if (vam->async_mode)
2740 vam->async_errors += (retval < 0);
2744 vam->retval = retval;
2745 vam->result_ready = 1;
2749 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2753 static void vl_api_get_first_msg_id_reply_t_handler_json
2754 (vl_api_get_first_msg_id_reply_t * mp)
2756 vat_main_t *vam = &vat_main;
2757 vat_json_node_t node;
2759 vat_json_init_object (&node);
2760 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2761 vat_json_object_add_uint (&node, "first_msg_id",
2762 (uint) ntohs (mp->first_msg_id));
2764 vat_json_print (vam->ofp, &node);
2765 vat_json_free (&node);
2767 vam->retval = ntohl (mp->retval);
2768 vam->result_ready = 1;
2771 static void vl_api_get_node_graph_reply_t_handler
2772 (vl_api_get_node_graph_reply_t * mp)
2774 vat_main_t *vam = &vat_main;
2775 api_main_t *am = &api_main;
2776 i32 retval = ntohl (mp->retval);
2777 u8 *pvt_copy, *reply;
2782 if (vam->async_mode)
2784 vam->async_errors += (retval < 0);
2788 vam->retval = retval;
2789 vam->result_ready = 1;
2792 /* "Should never happen..." */
2796 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2797 pvt_copy = vec_dup (reply);
2799 /* Toss the shared-memory original... */
2800 pthread_mutex_lock (&am->vlib_rp->mutex);
2801 oldheap = svm_push_data_heap (am->vlib_rp);
2805 svm_pop_heap (oldheap);
2806 pthread_mutex_unlock (&am->vlib_rp->mutex);
2808 if (vam->graph_nodes)
2810 hash_free (vam->graph_node_index_by_name);
2812 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2814 node = vam->graph_nodes[i];
2815 vec_free (node->name);
2816 vec_free (node->next_nodes);
2819 vec_free (vam->graph_nodes);
2822 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2823 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2824 vec_free (pvt_copy);
2826 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2828 node = vam->graph_nodes[i];
2829 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2833 static void vl_api_get_node_graph_reply_t_handler_json
2834 (vl_api_get_node_graph_reply_t * mp)
2836 vat_main_t *vam = &vat_main;
2837 api_main_t *am = &api_main;
2839 vat_json_node_t node;
2842 /* $$$$ make this real? */
2843 vat_json_init_object (&node);
2844 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2845 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2847 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2849 /* Toss the shared-memory original... */
2850 pthread_mutex_lock (&am->vlib_rp->mutex);
2851 oldheap = svm_push_data_heap (am->vlib_rp);
2855 svm_pop_heap (oldheap);
2856 pthread_mutex_unlock (&am->vlib_rp->mutex);
2858 vat_json_print (vam->ofp, &node);
2859 vat_json_free (&node);
2861 vam->retval = ntohl (mp->retval);
2862 vam->result_ready = 1;
2866 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2868 vat_main_t *vam = &vat_main;
2873 s = format (s, "%=16d%=16d%=16d",
2874 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2878 s = format (s, "%=16U%=16d%=16d",
2879 mp->is_ipv6 ? format_ip6_address :
2881 mp->ip_address, mp->priority, mp->weight);
2884 print (vam->ofp, "%v", s);
2889 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2891 vat_main_t *vam = &vat_main;
2892 vat_json_node_t *node = NULL;
2893 struct in6_addr ip6;
2896 if (VAT_JSON_ARRAY != vam->json_tree.type)
2898 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2899 vat_json_init_array (&vam->json_tree);
2901 node = vat_json_array_add (&vam->json_tree);
2902 vat_json_init_object (node);
2904 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2905 vat_json_object_add_uint (node, "priority", mp->priority);
2906 vat_json_object_add_uint (node, "weight", mp->weight);
2909 vat_json_object_add_uint (node, "sw_if_index",
2910 clib_net_to_host_u32 (mp->sw_if_index));
2915 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2916 vat_json_object_add_ip6 (node, "address", ip6);
2920 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2921 vat_json_object_add_ip4 (node, "address", ip4);
2927 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2930 vat_main_t *vam = &vat_main;
2933 ls_name = format (0, "%s", mp->ls_name);
2935 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2941 vl_api_one_locator_set_details_t_handler_json
2942 (vl_api_one_locator_set_details_t * mp)
2944 vat_main_t *vam = &vat_main;
2945 vat_json_node_t *node = 0;
2948 ls_name = format (0, "%s", mp->ls_name);
2949 vec_add1 (ls_name, 0);
2951 if (VAT_JSON_ARRAY != vam->json_tree.type)
2953 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2954 vat_json_init_array (&vam->json_tree);
2956 node = vat_json_array_add (&vam->json_tree);
2958 vat_json_init_object (node);
2959 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2960 vat_json_object_add_uint (node, "ls_index",
2961 clib_net_to_host_u32 (mp->ls_index));
2969 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2972 unformat_nsh_address (unformat_input_t * input, va_list * args)
2974 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2975 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2979 format_nsh_address_vat (u8 * s, va_list * args)
2981 nsh_t *a = va_arg (*args, nsh_t *);
2982 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2986 format_lisp_flat_eid (u8 * s, va_list * args)
2988 u32 type = va_arg (*args, u32);
2989 u8 *eid = va_arg (*args, u8 *);
2990 u32 eid_len = va_arg (*args, u32);
2995 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2997 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2999 return format (s, "%U", format_ethernet_address, eid);
3001 return format (s, "%U", format_nsh_address_vat, eid);
3007 format_lisp_eid_vat (u8 * s, va_list * args)
3009 u32 type = va_arg (*args, u32);
3010 u8 *eid = va_arg (*args, u8 *);
3011 u32 eid_len = va_arg (*args, u32);
3012 u8 *seid = va_arg (*args, u8 *);
3013 u32 seid_len = va_arg (*args, u32);
3014 u32 is_src_dst = va_arg (*args, u32);
3017 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3019 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3025 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3027 vat_main_t *vam = &vat_main;
3028 u8 *s = 0, *eid = 0;
3030 if (~0 == mp->locator_set_index)
3031 s = format (0, "action: %d", mp->action);
3033 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3035 eid = format (0, "%U", format_lisp_eid_vat,
3039 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3042 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3043 clib_net_to_host_u32 (mp->vni),
3045 mp->is_local ? "local" : "remote",
3046 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3047 clib_net_to_host_u16 (mp->key_id), mp->key);
3054 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3057 vat_main_t *vam = &vat_main;
3058 vat_json_node_t *node = 0;
3061 if (VAT_JSON_ARRAY != vam->json_tree.type)
3063 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3064 vat_json_init_array (&vam->json_tree);
3066 node = vat_json_array_add (&vam->json_tree);
3068 vat_json_init_object (node);
3069 if (~0 == mp->locator_set_index)
3070 vat_json_object_add_uint (node, "action", mp->action);
3072 vat_json_object_add_uint (node, "locator_set_index",
3073 clib_net_to_host_u32 (mp->locator_set_index));
3075 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3076 if (mp->eid_type == 3)
3078 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3079 vat_json_init_object (nsh_json);
3080 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3081 vat_json_object_add_uint (nsh_json, "spi",
3082 clib_net_to_host_u32 (nsh->spi));
3083 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3087 eid = format (0, "%U", format_lisp_eid_vat,
3091 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3093 vat_json_object_add_string_copy (node, "eid", eid);
3096 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3097 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3098 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3102 vat_json_object_add_uint (node, "key_id",
3103 clib_net_to_host_u16 (mp->key_id));
3104 vat_json_object_add_string_copy (node, "key", mp->key);
3109 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3111 vat_main_t *vam = &vat_main;
3112 u8 *seid = 0, *deid = 0;
3113 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3115 deid = format (0, "%U", format_lisp_eid_vat,
3116 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3118 seid = format (0, "%U", format_lisp_eid_vat,
3119 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3125 format_ip_address_fcn = format_ip4_address;
3127 format_ip_address_fcn = format_ip6_address;
3130 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3131 clib_net_to_host_u32 (mp->vni),
3133 format_ip_address_fcn, mp->lloc,
3134 format_ip_address_fcn, mp->rloc,
3135 clib_net_to_host_u32 (mp->pkt_count),
3136 clib_net_to_host_u32 (mp->bytes));
3143 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3145 struct in6_addr ip6;
3147 vat_main_t *vam = &vat_main;
3148 vat_json_node_t *node = 0;
3149 u8 *deid = 0, *seid = 0;
3151 if (VAT_JSON_ARRAY != vam->json_tree.type)
3153 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3154 vat_json_init_array (&vam->json_tree);
3156 node = vat_json_array_add (&vam->json_tree);
3158 vat_json_init_object (node);
3159 deid = format (0, "%U", format_lisp_eid_vat,
3160 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3162 seid = format (0, "%U", format_lisp_eid_vat,
3163 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3168 vat_json_object_add_string_copy (node, "seid", seid);
3169 vat_json_object_add_string_copy (node, "deid", deid);
3170 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3174 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3175 vat_json_object_add_ip4 (node, "lloc", ip4);
3176 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3177 vat_json_object_add_ip4 (node, "rloc", ip4);
3181 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3182 vat_json_object_add_ip6 (node, "lloc", ip6);
3183 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3184 vat_json_object_add_ip6 (node, "rloc", ip6);
3186 vat_json_object_add_uint (node, "pkt_count",
3187 clib_net_to_host_u32 (mp->pkt_count));
3188 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3195 vl_api_one_eid_table_map_details_t_handler
3196 (vl_api_one_eid_table_map_details_t * mp)
3198 vat_main_t *vam = &vat_main;
3200 u8 *line = format (0, "%=10d%=10d",
3201 clib_net_to_host_u32 (mp->vni),
3202 clib_net_to_host_u32 (mp->dp_table));
3203 print (vam->ofp, "%v", line);
3208 vl_api_one_eid_table_map_details_t_handler_json
3209 (vl_api_one_eid_table_map_details_t * mp)
3211 vat_main_t *vam = &vat_main;
3212 vat_json_node_t *node = NULL;
3214 if (VAT_JSON_ARRAY != vam->json_tree.type)
3216 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3217 vat_json_init_array (&vam->json_tree);
3219 node = vat_json_array_add (&vam->json_tree);
3220 vat_json_init_object (node);
3221 vat_json_object_add_uint (node, "dp_table",
3222 clib_net_to_host_u32 (mp->dp_table));
3223 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3227 vl_api_one_eid_table_vni_details_t_handler
3228 (vl_api_one_eid_table_vni_details_t * mp)
3230 vat_main_t *vam = &vat_main;
3232 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3233 print (vam->ofp, "%v", line);
3238 vl_api_one_eid_table_vni_details_t_handler_json
3239 (vl_api_one_eid_table_vni_details_t * mp)
3241 vat_main_t *vam = &vat_main;
3242 vat_json_node_t *node = NULL;
3244 if (VAT_JSON_ARRAY != vam->json_tree.type)
3246 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3247 vat_json_init_array (&vam->json_tree);
3249 node = vat_json_array_add (&vam->json_tree);
3250 vat_json_init_object (node);
3251 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3255 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3256 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3258 vat_main_t *vam = &vat_main;
3259 int retval = clib_net_to_host_u32 (mp->retval);
3261 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3262 print (vam->ofp, "fallback threshold value: %d", mp->value);
3264 vam->retval = retval;
3265 vam->result_ready = 1;
3269 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3270 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3272 vat_main_t *vam = &vat_main;
3273 vat_json_node_t _node, *node = &_node;
3274 int retval = clib_net_to_host_u32 (mp->retval);
3276 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3277 vat_json_init_object (node);
3278 vat_json_object_add_uint (node, "value", mp->value);
3280 vat_json_print (vam->ofp, node);
3281 vat_json_free (node);
3283 vam->retval = retval;
3284 vam->result_ready = 1;
3288 vl_api_show_one_map_register_state_reply_t_handler
3289 (vl_api_show_one_map_register_state_reply_t * mp)
3291 vat_main_t *vam = &vat_main;
3292 int retval = clib_net_to_host_u32 (mp->retval);
3294 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3296 vam->retval = retval;
3297 vam->result_ready = 1;
3301 vl_api_show_one_map_register_state_reply_t_handler_json
3302 (vl_api_show_one_map_register_state_reply_t * mp)
3304 vat_main_t *vam = &vat_main;
3305 vat_json_node_t _node, *node = &_node;
3306 int retval = clib_net_to_host_u32 (mp->retval);
3308 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3310 vat_json_init_object (node);
3311 vat_json_object_add_string_copy (node, "state", s);
3313 vat_json_print (vam->ofp, node);
3314 vat_json_free (node);
3316 vam->retval = retval;
3317 vam->result_ready = 1;
3322 vl_api_show_one_rloc_probe_state_reply_t_handler
3323 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3325 vat_main_t *vam = &vat_main;
3326 int retval = clib_net_to_host_u32 (mp->retval);
3331 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3333 vam->retval = retval;
3334 vam->result_ready = 1;
3338 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3339 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3341 vat_main_t *vam = &vat_main;
3342 vat_json_node_t _node, *node = &_node;
3343 int retval = clib_net_to_host_u32 (mp->retval);
3345 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3346 vat_json_init_object (node);
3347 vat_json_object_add_string_copy (node, "state", s);
3349 vat_json_print (vam->ofp, node);
3350 vat_json_free (node);
3352 vam->retval = retval;
3353 vam->result_ready = 1;
3358 vl_api_show_one_stats_enable_disable_reply_t_handler
3359 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3361 vat_main_t *vam = &vat_main;
3362 int retval = clib_net_to_host_u32 (mp->retval);
3367 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3369 vam->retval = retval;
3370 vam->result_ready = 1;
3374 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3375 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3377 vat_main_t *vam = &vat_main;
3378 vat_json_node_t _node, *node = &_node;
3379 int retval = clib_net_to_host_u32 (mp->retval);
3381 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3382 vat_json_init_object (node);
3383 vat_json_object_add_string_copy (node, "state", s);
3385 vat_json_print (vam->ofp, node);
3386 vat_json_free (node);
3388 vam->retval = retval;
3389 vam->result_ready = 1;
3394 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3396 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3397 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3398 e->vni = clib_net_to_host_u32 (e->vni);
3402 gpe_fwd_entries_get_reply_t_net_to_host
3403 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3407 mp->count = clib_net_to_host_u32 (mp->count);
3408 for (i = 0; i < mp->count; i++)
3410 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3415 format_gpe_encap_mode (u8 * s, va_list * args)
3417 u32 mode = va_arg (*args, u32);
3422 return format (s, "lisp");
3424 return format (s, "vxlan");
3430 vl_api_gpe_get_encap_mode_reply_t_handler
3431 (vl_api_gpe_get_encap_mode_reply_t * mp)
3433 vat_main_t *vam = &vat_main;
3435 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3436 vam->retval = ntohl (mp->retval);
3437 vam->result_ready = 1;
3441 vl_api_gpe_get_encap_mode_reply_t_handler_json
3442 (vl_api_gpe_get_encap_mode_reply_t * mp)
3444 vat_main_t *vam = &vat_main;
3445 vat_json_node_t node;
3447 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3448 vec_add1 (encap_mode, 0);
3450 vat_json_init_object (&node);
3451 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3453 vec_free (encap_mode);
3454 vat_json_print (vam->ofp, &node);
3455 vat_json_free (&node);
3457 vam->retval = ntohl (mp->retval);
3458 vam->result_ready = 1;
3462 vl_api_gpe_fwd_entry_path_details_t_handler
3463 (vl_api_gpe_fwd_entry_path_details_t * mp)
3465 vat_main_t *vam = &vat_main;
3466 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3468 if (mp->lcl_loc.is_ip4)
3469 format_ip_address_fcn = format_ip4_address;
3471 format_ip_address_fcn = format_ip6_address;
3473 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3474 format_ip_address_fcn, &mp->lcl_loc,
3475 format_ip_address_fcn, &mp->rmt_loc);
3479 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3481 struct in6_addr ip6;
3486 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3487 vat_json_object_add_ip4 (n, "address", ip4);
3491 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3492 vat_json_object_add_ip6 (n, "address", ip6);
3494 vat_json_object_add_uint (n, "weight", loc->weight);
3498 vl_api_gpe_fwd_entry_path_details_t_handler_json
3499 (vl_api_gpe_fwd_entry_path_details_t * mp)
3501 vat_main_t *vam = &vat_main;
3502 vat_json_node_t *node = NULL;
3503 vat_json_node_t *loc_node;
3505 if (VAT_JSON_ARRAY != vam->json_tree.type)
3507 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3508 vat_json_init_array (&vam->json_tree);
3510 node = vat_json_array_add (&vam->json_tree);
3511 vat_json_init_object (node);
3513 loc_node = vat_json_object_add (node, "local_locator");
3514 vat_json_init_object (loc_node);
3515 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3517 loc_node = vat_json_object_add (node, "remote_locator");
3518 vat_json_init_object (loc_node);
3519 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3523 vl_api_gpe_fwd_entries_get_reply_t_handler
3524 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3526 vat_main_t *vam = &vat_main;
3528 int retval = clib_net_to_host_u32 (mp->retval);
3529 vl_api_gpe_fwd_entry_t *e;
3534 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3536 for (i = 0; i < mp->count; i++)
3538 e = &mp->entries[i];
3539 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3540 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3541 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3545 vam->retval = retval;
3546 vam->result_ready = 1;
3550 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3551 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3554 vat_main_t *vam = &vat_main;
3555 vat_json_node_t *e = 0, root;
3557 int retval = clib_net_to_host_u32 (mp->retval);
3558 vl_api_gpe_fwd_entry_t *fwd;
3563 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3564 vat_json_init_array (&root);
3566 for (i = 0; i < mp->count; i++)
3568 e = vat_json_array_add (&root);
3569 fwd = &mp->entries[i];
3571 vat_json_init_object (e);
3572 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3573 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3574 vat_json_object_add_int (e, "vni", fwd->vni);
3575 vat_json_object_add_int (e, "action", fwd->action);
3577 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3578 fwd->leid_prefix_len);
3580 vat_json_object_add_string_copy (e, "leid", s);
3583 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3584 fwd->reid_prefix_len);
3586 vat_json_object_add_string_copy (e, "reid", s);
3590 vat_json_print (vam->ofp, &root);
3591 vat_json_free (&root);
3594 vam->retval = retval;
3595 vam->result_ready = 1;
3599 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3600 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3602 vat_main_t *vam = &vat_main;
3604 int retval = clib_net_to_host_u32 (mp->retval);
3605 vl_api_gpe_native_fwd_rpath_t *r;
3610 n = clib_net_to_host_u32 (mp->count);
3612 for (i = 0; i < n; i++)
3614 r = &mp->entries[i];
3615 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3616 clib_net_to_host_u32 (r->fib_index),
3617 clib_net_to_host_u32 (r->nh_sw_if_index),
3618 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3622 vam->retval = retval;
3623 vam->result_ready = 1;
3627 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3628 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3630 vat_main_t *vam = &vat_main;
3631 vat_json_node_t root, *e;
3633 int retval = clib_net_to_host_u32 (mp->retval);
3634 vl_api_gpe_native_fwd_rpath_t *r;
3640 n = clib_net_to_host_u32 (mp->count);
3641 vat_json_init_array (&root);
3643 for (i = 0; i < n; i++)
3645 e = vat_json_array_add (&root);
3646 vat_json_init_object (e);
3647 r = &mp->entries[i];
3649 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3652 vat_json_object_add_string_copy (e, "ip4", s);
3655 vat_json_object_add_uint (e, "fib_index",
3656 clib_net_to_host_u32 (r->fib_index));
3657 vat_json_object_add_uint (e, "nh_sw_if_index",
3658 clib_net_to_host_u32 (r->nh_sw_if_index));
3661 vat_json_print (vam->ofp, &root);
3662 vat_json_free (&root);
3665 vam->retval = retval;
3666 vam->result_ready = 1;
3670 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3671 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3673 vat_main_t *vam = &vat_main;
3675 int retval = clib_net_to_host_u32 (mp->retval);
3680 n = clib_net_to_host_u32 (mp->count);
3682 for (i = 0; i < n; i++)
3683 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3686 vam->retval = retval;
3687 vam->result_ready = 1;
3691 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3692 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3694 vat_main_t *vam = &vat_main;
3695 vat_json_node_t root;
3697 int retval = clib_net_to_host_u32 (mp->retval);
3702 n = clib_net_to_host_u32 (mp->count);
3703 vat_json_init_array (&root);
3705 for (i = 0; i < n; i++)
3706 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3708 vat_json_print (vam->ofp, &root);
3709 vat_json_free (&root);
3712 vam->retval = retval;
3713 vam->result_ready = 1;
3717 vl_api_one_ndp_entries_get_reply_t_handler
3718 (vl_api_one_ndp_entries_get_reply_t * mp)
3720 vat_main_t *vam = &vat_main;
3722 int retval = clib_net_to_host_u32 (mp->retval);
3727 n = clib_net_to_host_u32 (mp->count);
3729 for (i = 0; i < n; i++)
3730 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3731 format_ethernet_address, mp->entries[i].mac);
3734 vam->retval = retval;
3735 vam->result_ready = 1;
3739 vl_api_one_ndp_entries_get_reply_t_handler_json
3740 (vl_api_one_ndp_entries_get_reply_t * mp)
3743 vat_main_t *vam = &vat_main;
3744 vat_json_node_t *e = 0, root;
3746 int retval = clib_net_to_host_u32 (mp->retval);
3747 vl_api_one_ndp_entry_t *arp_entry;
3752 n = clib_net_to_host_u32 (mp->count);
3753 vat_json_init_array (&root);
3755 for (i = 0; i < n; i++)
3757 e = vat_json_array_add (&root);
3758 arp_entry = &mp->entries[i];
3760 vat_json_init_object (e);
3761 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3764 vat_json_object_add_string_copy (e, "mac", s);
3767 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3769 vat_json_object_add_string_copy (e, "ip6", s);
3773 vat_json_print (vam->ofp, &root);
3774 vat_json_free (&root);
3777 vam->retval = retval;
3778 vam->result_ready = 1;
3782 vl_api_one_l2_arp_entries_get_reply_t_handler
3783 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3785 vat_main_t *vam = &vat_main;
3787 int retval = clib_net_to_host_u32 (mp->retval);
3792 n = clib_net_to_host_u32 (mp->count);
3794 for (i = 0; i < n; i++)
3795 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3796 format_ethernet_address, mp->entries[i].mac);
3799 vam->retval = retval;
3800 vam->result_ready = 1;
3804 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3805 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3808 vat_main_t *vam = &vat_main;
3809 vat_json_node_t *e = 0, root;
3811 int retval = clib_net_to_host_u32 (mp->retval);
3812 vl_api_one_l2_arp_entry_t *arp_entry;
3817 n = clib_net_to_host_u32 (mp->count);
3818 vat_json_init_array (&root);
3820 for (i = 0; i < n; i++)
3822 e = vat_json_array_add (&root);
3823 arp_entry = &mp->entries[i];
3825 vat_json_init_object (e);
3826 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3829 vat_json_object_add_string_copy (e, "mac", s);
3832 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3834 vat_json_object_add_string_copy (e, "ip4", s);
3838 vat_json_print (vam->ofp, &root);
3839 vat_json_free (&root);
3842 vam->retval = retval;
3843 vam->result_ready = 1;
3847 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3849 vat_main_t *vam = &vat_main;
3851 int retval = clib_net_to_host_u32 (mp->retval);
3856 n = clib_net_to_host_u32 (mp->count);
3858 for (i = 0; i < n; i++)
3860 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3864 vam->retval = retval;
3865 vam->result_ready = 1;
3869 vl_api_one_ndp_bd_get_reply_t_handler_json
3870 (vl_api_one_ndp_bd_get_reply_t * mp)
3872 vat_main_t *vam = &vat_main;
3873 vat_json_node_t root;
3875 int retval = clib_net_to_host_u32 (mp->retval);
3880 n = clib_net_to_host_u32 (mp->count);
3881 vat_json_init_array (&root);
3883 for (i = 0; i < n; i++)
3885 vat_json_array_add_uint (&root,
3886 clib_net_to_host_u32 (mp->bridge_domains[i]));
3889 vat_json_print (vam->ofp, &root);
3890 vat_json_free (&root);
3893 vam->retval = retval;
3894 vam->result_ready = 1;
3898 vl_api_one_l2_arp_bd_get_reply_t_handler
3899 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3901 vat_main_t *vam = &vat_main;
3903 int retval = clib_net_to_host_u32 (mp->retval);
3908 n = clib_net_to_host_u32 (mp->count);
3910 for (i = 0; i < n; i++)
3912 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3916 vam->retval = retval;
3917 vam->result_ready = 1;
3921 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3922 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3924 vat_main_t *vam = &vat_main;
3925 vat_json_node_t root;
3927 int retval = clib_net_to_host_u32 (mp->retval);
3932 n = clib_net_to_host_u32 (mp->count);
3933 vat_json_init_array (&root);
3935 for (i = 0; i < n; i++)
3937 vat_json_array_add_uint (&root,
3938 clib_net_to_host_u32 (mp->bridge_domains[i]));
3941 vat_json_print (vam->ofp, &root);
3942 vat_json_free (&root);
3945 vam->retval = retval;
3946 vam->result_ready = 1;
3950 vl_api_one_adjacencies_get_reply_t_handler
3951 (vl_api_one_adjacencies_get_reply_t * mp)
3953 vat_main_t *vam = &vat_main;
3955 int retval = clib_net_to_host_u32 (mp->retval);
3956 vl_api_one_adjacency_t *a;
3961 n = clib_net_to_host_u32 (mp->count);
3963 for (i = 0; i < n; i++)
3965 a = &mp->adjacencies[i];
3966 print (vam->ofp, "%U %40U",
3967 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3968 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3972 vam->retval = retval;
3973 vam->result_ready = 1;
3977 vl_api_one_adjacencies_get_reply_t_handler_json
3978 (vl_api_one_adjacencies_get_reply_t * mp)
3981 vat_main_t *vam = &vat_main;
3982 vat_json_node_t *e = 0, root;
3984 int retval = clib_net_to_host_u32 (mp->retval);
3985 vl_api_one_adjacency_t *a;
3990 n = clib_net_to_host_u32 (mp->count);
3991 vat_json_init_array (&root);
3993 for (i = 0; i < n; i++)
3995 e = vat_json_array_add (&root);
3996 a = &mp->adjacencies[i];
3998 vat_json_init_object (e);
3999 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4000 a->leid_prefix_len);
4002 vat_json_object_add_string_copy (e, "leid", s);
4005 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4006 a->reid_prefix_len);
4008 vat_json_object_add_string_copy (e, "reid", s);
4012 vat_json_print (vam->ofp, &root);
4013 vat_json_free (&root);
4016 vam->retval = retval;
4017 vam->result_ready = 1;
4021 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4023 vat_main_t *vam = &vat_main;
4025 print (vam->ofp, "%=20U",
4026 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4031 vl_api_one_map_server_details_t_handler_json
4032 (vl_api_one_map_server_details_t * mp)
4034 vat_main_t *vam = &vat_main;
4035 vat_json_node_t *node = NULL;
4036 struct in6_addr ip6;
4039 if (VAT_JSON_ARRAY != vam->json_tree.type)
4041 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4042 vat_json_init_array (&vam->json_tree);
4044 node = vat_json_array_add (&vam->json_tree);
4046 vat_json_init_object (node);
4049 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4050 vat_json_object_add_ip6 (node, "map-server", ip6);
4054 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4055 vat_json_object_add_ip4 (node, "map-server", ip4);
4060 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4063 vat_main_t *vam = &vat_main;
4065 print (vam->ofp, "%=20U",
4066 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4071 vl_api_one_map_resolver_details_t_handler_json
4072 (vl_api_one_map_resolver_details_t * mp)
4074 vat_main_t *vam = &vat_main;
4075 vat_json_node_t *node = NULL;
4076 struct in6_addr ip6;
4079 if (VAT_JSON_ARRAY != vam->json_tree.type)
4081 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4082 vat_json_init_array (&vam->json_tree);
4084 node = vat_json_array_add (&vam->json_tree);
4086 vat_json_init_object (node);
4089 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4090 vat_json_object_add_ip6 (node, "map resolver", ip6);
4094 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4095 vat_json_object_add_ip4 (node, "map resolver", ip4);
4100 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4102 vat_main_t *vam = &vat_main;
4103 i32 retval = ntohl (mp->retval);
4107 print (vam->ofp, "feature: %s\ngpe: %s",
4108 mp->feature_status ? "enabled" : "disabled",
4109 mp->gpe_status ? "enabled" : "disabled");
4112 vam->retval = retval;
4113 vam->result_ready = 1;
4117 vl_api_show_one_status_reply_t_handler_json
4118 (vl_api_show_one_status_reply_t * mp)
4120 vat_main_t *vam = &vat_main;
4121 vat_json_node_t node;
4122 u8 *gpe_status = NULL;
4123 u8 *feature_status = NULL;
4125 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4126 feature_status = format (0, "%s",
4127 mp->feature_status ? "enabled" : "disabled");
4128 vec_add1 (gpe_status, 0);
4129 vec_add1 (feature_status, 0);
4131 vat_json_init_object (&node);
4132 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4133 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4135 vec_free (gpe_status);
4136 vec_free (feature_status);
4138 vat_json_print (vam->ofp, &node);
4139 vat_json_free (&node);
4141 vam->retval = ntohl (mp->retval);
4142 vam->result_ready = 1;
4146 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4147 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4149 vat_main_t *vam = &vat_main;
4150 i32 retval = ntohl (mp->retval);
4154 print (vam->ofp, "%=20s", mp->locator_set_name);
4157 vam->retval = retval;
4158 vam->result_ready = 1;
4162 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4163 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4165 vat_main_t *vam = &vat_main;
4166 vat_json_node_t *node = NULL;
4168 if (VAT_JSON_ARRAY != vam->json_tree.type)
4170 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4171 vat_json_init_array (&vam->json_tree);
4173 node = vat_json_array_add (&vam->json_tree);
4175 vat_json_init_object (node);
4176 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4178 vat_json_print (vam->ofp, node);
4179 vat_json_free (node);
4181 vam->retval = ntohl (mp->retval);
4182 vam->result_ready = 1;
4186 format_lisp_map_request_mode (u8 * s, va_list * args)
4188 u32 mode = va_arg (*args, u32);
4193 return format (0, "dst-only");
4195 return format (0, "src-dst");
4201 vl_api_show_one_map_request_mode_reply_t_handler
4202 (vl_api_show_one_map_request_mode_reply_t * mp)
4204 vat_main_t *vam = &vat_main;
4205 i32 retval = ntohl (mp->retval);
4209 u32 mode = mp->mode;
4210 print (vam->ofp, "map_request_mode: %U",
4211 format_lisp_map_request_mode, mode);
4214 vam->retval = retval;
4215 vam->result_ready = 1;
4219 vl_api_show_one_map_request_mode_reply_t_handler_json
4220 (vl_api_show_one_map_request_mode_reply_t * mp)
4222 vat_main_t *vam = &vat_main;
4223 vat_json_node_t node;
4228 s = format (0, "%U", format_lisp_map_request_mode, mode);
4231 vat_json_init_object (&node);
4232 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4233 vat_json_print (vam->ofp, &node);
4234 vat_json_free (&node);
4237 vam->retval = ntohl (mp->retval);
4238 vam->result_ready = 1;
4242 vl_api_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_rx_mode_reply) \
5048 _(sw_interface_set_table_reply) \
5049 _(sw_interface_set_mpls_enable_reply) \
5050 _(sw_interface_set_vpath_reply) \
5051 _(sw_interface_set_vxlan_bypass_reply) \
5052 _(sw_interface_set_geneve_bypass_reply) \
5053 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5054 _(sw_interface_set_l2_bridge_reply) \
5055 _(bridge_domain_add_del_reply) \
5056 _(sw_interface_set_l2_xconnect_reply) \
5057 _(l2fib_add_del_reply) \
5058 _(l2fib_flush_int_reply) \
5059 _(l2fib_flush_bd_reply) \
5060 _(ip_add_del_route_reply) \
5061 _(ip_table_add_del_reply) \
5062 _(ip_mroute_add_del_reply) \
5063 _(mpls_route_add_del_reply) \
5064 _(mpls_table_add_del_reply) \
5065 _(mpls_ip_bind_unbind_reply) \
5066 _(proxy_arp_add_del_reply) \
5067 _(proxy_arp_intfc_enable_disable_reply) \
5068 _(sw_interface_set_unnumbered_reply) \
5069 _(ip_neighbor_add_del_reply) \
5070 _(reset_vrf_reply) \
5071 _(oam_add_del_reply) \
5072 _(reset_fib_reply) \
5073 _(dhcp_proxy_config_reply) \
5074 _(dhcp_proxy_set_vss_reply) \
5075 _(dhcp_client_config_reply) \
5076 _(set_ip_flow_hash_reply) \
5077 _(sw_interface_ip6_enable_disable_reply) \
5078 _(sw_interface_ip6_set_link_local_address_reply) \
5079 _(ip6nd_proxy_add_del_reply) \
5080 _(sw_interface_ip6nd_ra_prefix_reply) \
5081 _(sw_interface_ip6nd_ra_config_reply) \
5082 _(set_arp_neighbor_limit_reply) \
5083 _(l2_patch_add_del_reply) \
5084 _(sr_policy_add_reply) \
5085 _(sr_policy_mod_reply) \
5086 _(sr_policy_del_reply) \
5087 _(sr_localsid_add_del_reply) \
5088 _(sr_steering_add_del_reply) \
5089 _(classify_add_del_session_reply) \
5090 _(classify_set_interface_ip_table_reply) \
5091 _(classify_set_interface_l2_tables_reply) \
5092 _(l2tpv3_set_tunnel_cookies_reply) \
5093 _(l2tpv3_interface_enable_disable_reply) \
5094 _(l2tpv3_set_lookup_key_reply) \
5095 _(l2_fib_clear_table_reply) \
5096 _(l2_interface_efp_filter_reply) \
5097 _(l2_interface_vlan_tag_rewrite_reply) \
5098 _(modify_vhost_user_if_reply) \
5099 _(delete_vhost_user_if_reply) \
5100 _(want_ip4_arp_events_reply) \
5101 _(want_ip6_nd_events_reply) \
5102 _(want_l2_macs_events_reply) \
5103 _(input_acl_set_interface_reply) \
5104 _(ipsec_spd_add_del_reply) \
5105 _(ipsec_interface_add_del_spd_reply) \
5106 _(ipsec_spd_add_del_entry_reply) \
5107 _(ipsec_sad_add_del_entry_reply) \
5108 _(ipsec_sa_set_key_reply) \
5109 _(ipsec_tunnel_if_add_del_reply) \
5110 _(ipsec_tunnel_if_set_key_reply) \
5111 _(ipsec_tunnel_if_set_sa_reply) \
5112 _(ikev2_profile_add_del_reply) \
5113 _(ikev2_profile_set_auth_reply) \
5114 _(ikev2_profile_set_id_reply) \
5115 _(ikev2_profile_set_ts_reply) \
5116 _(ikev2_set_local_key_reply) \
5117 _(ikev2_set_responder_reply) \
5118 _(ikev2_set_ike_transforms_reply) \
5119 _(ikev2_set_esp_transforms_reply) \
5120 _(ikev2_set_sa_lifetime_reply) \
5121 _(ikev2_initiate_sa_init_reply) \
5122 _(ikev2_initiate_del_ike_sa_reply) \
5123 _(ikev2_initiate_del_child_sa_reply) \
5124 _(ikev2_initiate_rekey_child_sa_reply) \
5125 _(delete_loopback_reply) \
5126 _(bd_ip_mac_add_del_reply) \
5127 _(map_del_domain_reply) \
5128 _(map_add_del_rule_reply) \
5129 _(want_interface_events_reply) \
5130 _(want_stats_reply) \
5131 _(cop_interface_enable_disable_reply) \
5132 _(cop_whitelist_enable_disable_reply) \
5133 _(sw_interface_clear_stats_reply) \
5134 _(ioam_enable_reply) \
5135 _(ioam_disable_reply) \
5136 _(one_add_del_locator_reply) \
5137 _(one_add_del_local_eid_reply) \
5138 _(one_add_del_remote_mapping_reply) \
5139 _(one_add_del_adjacency_reply) \
5140 _(one_add_del_map_resolver_reply) \
5141 _(one_add_del_map_server_reply) \
5142 _(one_enable_disable_reply) \
5143 _(one_rloc_probe_enable_disable_reply) \
5144 _(one_map_register_enable_disable_reply) \
5145 _(one_map_register_set_ttl_reply) \
5146 _(one_set_transport_protocol_reply) \
5147 _(one_map_register_fallback_threshold_reply) \
5148 _(one_pitr_set_locator_set_reply) \
5149 _(one_map_request_mode_reply) \
5150 _(one_add_del_map_request_itr_rlocs_reply) \
5151 _(one_eid_table_add_del_map_reply) \
5152 _(one_use_petr_reply) \
5153 _(one_stats_enable_disable_reply) \
5154 _(one_add_del_l2_arp_entry_reply) \
5155 _(one_add_del_ndp_entry_reply) \
5156 _(one_stats_flush_reply) \
5157 _(gpe_enable_disable_reply) \
5158 _(gpe_set_encap_mode_reply) \
5159 _(gpe_add_del_iface_reply) \
5160 _(gpe_add_del_native_fwd_rpath_reply) \
5161 _(af_packet_delete_reply) \
5162 _(policer_classify_set_interface_reply) \
5163 _(netmap_create_reply) \
5164 _(netmap_delete_reply) \
5165 _(set_ipfix_exporter_reply) \
5166 _(set_ipfix_classify_stream_reply) \
5167 _(ipfix_classify_table_add_del_reply) \
5168 _(flow_classify_set_interface_reply) \
5169 _(sw_interface_span_enable_disable_reply) \
5170 _(pg_capture_reply) \
5171 _(pg_enable_disable_reply) \
5172 _(ip_source_and_port_range_check_add_del_reply) \
5173 _(ip_source_and_port_range_check_interface_add_del_reply)\
5174 _(delete_subif_reply) \
5175 _(l2_interface_pbb_tag_rewrite_reply) \
5177 _(feature_enable_disable_reply) \
5178 _(sw_interface_tag_add_del_reply) \
5179 _(sw_interface_set_mtu_reply) \
5180 _(p2p_ethernet_add_reply) \
5181 _(p2p_ethernet_del_reply) \
5182 _(lldp_config_reply) \
5183 _(sw_interface_set_lldp_reply) \
5184 _(tcp_configure_src_addresses_reply) \
5185 _(app_namespace_add_del_reply) \
5186 _(dns_enable_disable_reply) \
5187 _(dns_name_server_add_del_reply) \
5188 _(session_rule_add_del_reply)
5191 static void vl_api_##n##_t_handler \
5192 (vl_api_##n##_t * mp) \
5194 vat_main_t * vam = &vat_main; \
5195 i32 retval = ntohl(mp->retval); \
5196 if (vam->async_mode) { \
5197 vam->async_errors += (retval < 0); \
5199 vam->retval = retval; \
5200 vam->result_ready = 1; \
5203 foreach_standard_reply_retval_handler;
5207 static void vl_api_##n##_t_handler_json \
5208 (vl_api_##n##_t * mp) \
5210 vat_main_t * vam = &vat_main; \
5211 vat_json_node_t node; \
5212 vat_json_init_object(&node); \
5213 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5214 vat_json_print(vam->ofp, &node); \
5215 vam->retval = ntohl(mp->retval); \
5216 vam->result_ready = 1; \
5218 foreach_standard_reply_retval_handler;
5222 * Table of message reply handlers, must include boilerplate handlers
5226 #define foreach_vpe_api_reply_msg \
5227 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5228 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5229 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5230 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5231 _(CONTROL_PING_REPLY, control_ping_reply) \
5232 _(CLI_REPLY, cli_reply) \
5233 _(CLI_INBAND_REPLY, cli_inband_reply) \
5234 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5235 sw_interface_add_del_address_reply) \
5236 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5237 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5238 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5239 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5240 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5241 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5242 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5243 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5244 sw_interface_set_l2_xconnect_reply) \
5245 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5246 sw_interface_set_l2_bridge_reply) \
5247 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5248 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5249 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5250 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5251 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5252 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5253 _(L2_FLAGS_REPLY, l2_flags_reply) \
5254 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5255 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5256 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5257 _(TAP_DELETE_REPLY, tap_delete_reply) \
5258 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5259 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5260 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5261 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5262 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5263 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5264 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5265 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5266 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5267 proxy_arp_intfc_enable_disable_reply) \
5268 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5269 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5270 sw_interface_set_unnumbered_reply) \
5271 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5272 _(RESET_VRF_REPLY, reset_vrf_reply) \
5273 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5274 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5275 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5276 _(RESET_FIB_REPLY, reset_fib_reply) \
5277 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5278 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5279 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5280 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5281 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5282 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5283 sw_interface_ip6_enable_disable_reply) \
5284 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5285 sw_interface_ip6_set_link_local_address_reply) \
5286 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5287 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5288 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5289 sw_interface_ip6nd_ra_prefix_reply) \
5290 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5291 sw_interface_ip6nd_ra_config_reply) \
5292 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5293 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5294 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5295 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5296 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5297 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5298 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5299 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5300 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5301 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5302 classify_set_interface_ip_table_reply) \
5303 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5304 classify_set_interface_l2_tables_reply) \
5305 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5306 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5307 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5308 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5309 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5310 l2tpv3_interface_enable_disable_reply) \
5311 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5312 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5313 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5314 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5315 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5316 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5317 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5318 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5319 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5320 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5321 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5322 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5323 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5324 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5325 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5326 _(SHOW_VERSION_REPLY, show_version_reply) \
5327 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5328 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5329 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5330 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5331 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5332 _(IP4_ARP_EVENT, ip4_arp_event) \
5333 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5334 _(IP6_ND_EVENT, ip6_nd_event) \
5335 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5336 _(L2_MACS_EVENT, l2_macs_event) \
5337 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5338 _(IP_ADDRESS_DETAILS, ip_address_details) \
5339 _(IP_DETAILS, ip_details) \
5340 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5341 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5342 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5343 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5344 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5345 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5346 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5347 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5348 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5349 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5350 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5351 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5352 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5353 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5354 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5355 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5356 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5357 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5358 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5359 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5360 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5361 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5362 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5363 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5364 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5365 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5366 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5367 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5368 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5369 _(MAP_RULE_DETAILS, map_rule_details) \
5370 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5371 _(WANT_STATS_REPLY, want_stats_reply) \
5372 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5373 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5374 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5375 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5376 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5377 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5378 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5379 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5380 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5381 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5382 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5383 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5384 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5385 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5386 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5387 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5388 one_map_register_enable_disable_reply) \
5389 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5390 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5391 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5392 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5393 one_map_register_fallback_threshold_reply) \
5394 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5395 one_rloc_probe_enable_disable_reply) \
5396 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5397 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5398 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5399 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5400 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5401 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5402 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5403 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5404 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5405 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5406 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5407 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5408 _(ONE_STATS_DETAILS, one_stats_details) \
5409 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5410 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5411 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5412 show_one_stats_enable_disable_reply) \
5413 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5414 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5415 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5416 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5417 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5418 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5419 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5420 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5421 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5422 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5423 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5424 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5425 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5426 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5427 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5428 gpe_add_del_native_fwd_rpath_reply) \
5429 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5430 gpe_fwd_entry_path_details) \
5431 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5432 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5433 one_add_del_map_request_itr_rlocs_reply) \
5434 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5435 one_get_map_request_itr_rlocs_reply) \
5436 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5437 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5438 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5439 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5440 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5441 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5442 show_one_map_register_state_reply) \
5443 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5444 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5445 show_one_map_register_fallback_threshold_reply) \
5446 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5447 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5448 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5449 _(POLICER_DETAILS, policer_details) \
5450 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5451 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5452 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5453 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5454 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5455 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5456 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5457 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5458 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5459 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5460 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5461 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5462 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5463 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5464 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5465 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5466 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5467 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5468 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5469 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5470 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5471 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5472 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5473 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5474 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5475 ip_source_and_port_range_check_add_del_reply) \
5476 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5477 ip_source_and_port_range_check_interface_add_del_reply) \
5478 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5479 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5480 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5481 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5482 _(PUNT_REPLY, punt_reply) \
5483 _(IP_FIB_DETAILS, ip_fib_details) \
5484 _(IP6_FIB_DETAILS, ip6_fib_details) \
5485 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5486 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5487 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5488 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5489 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5490 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5491 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5492 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5493 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5494 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5495 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5496 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5497 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5498 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5499 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5500 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5501 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply)
5503 #define foreach_standalone_reply_msg \
5504 _(SW_INTERFACE_EVENT, sw_interface_event) \
5505 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5506 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5507 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5508 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5509 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5510 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
5511 _(MEMFD_SEGMENT_CREATE_REPLY, memfd_segment_create_reply) \
5520 #define STR_VTR_OP_CASE(op) \
5521 case L2_VTR_ ## op: \
5525 str_vtr_op (u32 vtr_op)
5529 STR_VTR_OP_CASE (DISABLED);
5530 STR_VTR_OP_CASE (PUSH_1);
5531 STR_VTR_OP_CASE (PUSH_2);
5532 STR_VTR_OP_CASE (POP_1);
5533 STR_VTR_OP_CASE (POP_2);
5534 STR_VTR_OP_CASE (TRANSLATE_1_1);
5535 STR_VTR_OP_CASE (TRANSLATE_1_2);
5536 STR_VTR_OP_CASE (TRANSLATE_2_1);
5537 STR_VTR_OP_CASE (TRANSLATE_2_2);
5544 dump_sub_interface_table (vat_main_t * vam)
5546 const sw_interface_subif_t *sub = NULL;
5548 if (vam->json_output)
5551 ("JSON output supported only for VPE API calls and dump_stats_table");
5556 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5557 "Interface", "sw_if_index",
5558 "sub id", "dot1ad", "tags", "outer id",
5559 "inner id", "exact", "default", "outer any", "inner any");
5561 vec_foreach (sub, vam->sw_if_subif_table)
5564 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5565 sub->interface_name,
5567 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5568 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5569 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5570 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5571 if (sub->vtr_op != L2_VTR_DISABLED)
5574 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5575 "tag1: %d tag2: %d ]",
5576 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5577 sub->vtr_tag1, sub->vtr_tag2);
5585 name_sort_cmp (void *a1, void *a2)
5587 name_sort_t *n1 = a1;
5588 name_sort_t *n2 = a2;
5590 return strcmp ((char *) n1->name, (char *) n2->name);
5594 dump_interface_table (vat_main_t * vam)
5597 name_sort_t *nses = 0, *ns;
5599 if (vam->json_output)
5602 ("JSON output supported only for VPE API calls and dump_stats_table");
5607 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5609 vec_add2 (nses, ns, 1);
5610 ns->name = (u8 *)(p->key);
5611 ns->value = (u32) p->value[0];
5615 vec_sort_with_function (nses, name_sort_cmp);
5617 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5618 vec_foreach (ns, nses)
5620 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5627 dump_ip_table (vat_main_t * vam, int is_ipv6)
5629 const ip_details_t *det = NULL;
5630 const ip_address_details_t *address = NULL;
5633 print (vam->ofp, "%-12s", "sw_if_index");
5635 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5642 print (vam->ofp, "%-12d", i);
5643 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5648 vec_foreach (address, det->addr)
5652 is_ipv6 ? format_ip6_address : format_ip4_address,
5653 address->ip, address->prefix_length);
5661 dump_ipv4_table (vat_main_t * vam)
5663 if (vam->json_output)
5666 ("JSON output supported only for VPE API calls and dump_stats_table");
5670 return dump_ip_table (vam, 0);
5674 dump_ipv6_table (vat_main_t * vam)
5676 if (vam->json_output)
5679 ("JSON output supported only for VPE API calls and dump_stats_table");
5683 return dump_ip_table (vam, 1);
5687 counter_type_to_str (u8 counter_type, u8 is_combined)
5691 switch (counter_type)
5693 case VNET_INTERFACE_COUNTER_DROP:
5695 case VNET_INTERFACE_COUNTER_PUNT:
5697 case VNET_INTERFACE_COUNTER_IP4:
5699 case VNET_INTERFACE_COUNTER_IP6:
5701 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5703 case VNET_INTERFACE_COUNTER_RX_MISS:
5705 case VNET_INTERFACE_COUNTER_RX_ERROR:
5707 case VNET_INTERFACE_COUNTER_TX_ERROR:
5710 return "INVALID-COUNTER-TYPE";
5715 switch (counter_type)
5717 case VNET_INTERFACE_COUNTER_RX:
5719 case VNET_INTERFACE_COUNTER_TX:
5722 return "INVALID-COUNTER-TYPE";
5728 dump_stats_table (vat_main_t * vam)
5730 vat_json_node_t node;
5731 vat_json_node_t *msg_array;
5732 vat_json_node_t *msg;
5733 vat_json_node_t *counter_array;
5734 vat_json_node_t *counter;
5735 interface_counter_t c;
5737 ip4_fib_counter_t *c4;
5738 ip6_fib_counter_t *c6;
5739 ip4_nbr_counter_t *n4;
5740 ip6_nbr_counter_t *n6;
5743 if (!vam->json_output)
5745 clib_warning ("dump_stats_table supported only in JSON format");
5749 vat_json_init_object (&node);
5751 /* interface counters */
5752 msg_array = vat_json_object_add (&node, "interface_counters");
5753 vat_json_init_array (msg_array);
5754 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5756 msg = vat_json_array_add (msg_array);
5757 vat_json_init_object (msg);
5758 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5759 (u8 *) counter_type_to_str (i, 0));
5760 vat_json_object_add_int (msg, "is_combined", 0);
5761 counter_array = vat_json_object_add (msg, "data");
5762 vat_json_init_array (counter_array);
5763 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5765 packets = vam->simple_interface_counters[i][j];
5766 vat_json_array_add_uint (counter_array, packets);
5769 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5771 msg = vat_json_array_add (msg_array);
5772 vat_json_init_object (msg);
5773 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5774 (u8 *) counter_type_to_str (i, 1));
5775 vat_json_object_add_int (msg, "is_combined", 1);
5776 counter_array = vat_json_object_add (msg, "data");
5777 vat_json_init_array (counter_array);
5778 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5780 c = vam->combined_interface_counters[i][j];
5781 counter = vat_json_array_add (counter_array);
5782 vat_json_init_object (counter);
5783 vat_json_object_add_uint (counter, "packets", c.packets);
5784 vat_json_object_add_uint (counter, "bytes", c.bytes);
5788 /* ip4 fib counters */
5789 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5790 vat_json_init_array (msg_array);
5791 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5793 msg = vat_json_array_add (msg_array);
5794 vat_json_init_object (msg);
5795 vat_json_object_add_uint (msg, "vrf_id",
5796 vam->ip4_fib_counters_vrf_id_by_index[i]);
5797 counter_array = vat_json_object_add (msg, "c");
5798 vat_json_init_array (counter_array);
5799 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5801 counter = vat_json_array_add (counter_array);
5802 vat_json_init_object (counter);
5803 c4 = &vam->ip4_fib_counters[i][j];
5804 vat_json_object_add_ip4 (counter, "address", c4->address);
5805 vat_json_object_add_uint (counter, "address_length",
5806 c4->address_length);
5807 vat_json_object_add_uint (counter, "packets", c4->packets);
5808 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5812 /* ip6 fib counters */
5813 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5814 vat_json_init_array (msg_array);
5815 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5817 msg = vat_json_array_add (msg_array);
5818 vat_json_init_object (msg);
5819 vat_json_object_add_uint (msg, "vrf_id",
5820 vam->ip6_fib_counters_vrf_id_by_index[i]);
5821 counter_array = vat_json_object_add (msg, "c");
5822 vat_json_init_array (counter_array);
5823 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5825 counter = vat_json_array_add (counter_array);
5826 vat_json_init_object (counter);
5827 c6 = &vam->ip6_fib_counters[i][j];
5828 vat_json_object_add_ip6 (counter, "address", c6->address);
5829 vat_json_object_add_uint (counter, "address_length",
5830 c6->address_length);
5831 vat_json_object_add_uint (counter, "packets", c6->packets);
5832 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5836 /* ip4 nbr counters */
5837 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5838 vat_json_init_array (msg_array);
5839 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5841 msg = vat_json_array_add (msg_array);
5842 vat_json_init_object (msg);
5843 vat_json_object_add_uint (msg, "sw_if_index", i);
5844 counter_array = vat_json_object_add (msg, "c");
5845 vat_json_init_array (counter_array);
5846 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5848 counter = vat_json_array_add (counter_array);
5849 vat_json_init_object (counter);
5850 n4 = &vam->ip4_nbr_counters[i][j];
5851 vat_json_object_add_ip4 (counter, "address", n4->address);
5852 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5853 vat_json_object_add_uint (counter, "packets", n4->packets);
5854 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5858 /* ip6 nbr counters */
5859 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5860 vat_json_init_array (msg_array);
5861 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5863 msg = vat_json_array_add (msg_array);
5864 vat_json_init_object (msg);
5865 vat_json_object_add_uint (msg, "sw_if_index", i);
5866 counter_array = vat_json_object_add (msg, "c");
5867 vat_json_init_array (counter_array);
5868 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5870 counter = vat_json_array_add (counter_array);
5871 vat_json_init_object (counter);
5872 n6 = &vam->ip6_nbr_counters[i][j];
5873 vat_json_object_add_ip6 (counter, "address", n6->address);
5874 vat_json_object_add_uint (counter, "packets", n6->packets);
5875 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5879 vat_json_print (vam->ofp, &node);
5880 vat_json_free (&node);
5886 * Pass CLI buffers directly in the CLI_INBAND API message,
5887 * instead of an additional shared memory area.
5890 exec_inband (vat_main_t * vam)
5892 vl_api_cli_inband_t *mp;
5893 unformat_input_t *i = vam->input;
5896 if (vec_len (i->buffer) == 0)
5899 if (vam->exec_mode == 0 && unformat (i, "mode"))
5904 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5911 * In order for the CLI command to work, it
5912 * must be a vector ending in \n, not a C-string ending
5915 u32 len = vec_len (vam->input->buffer);
5916 M2 (CLI_INBAND, mp, len);
5917 clib_memcpy (mp->cmd, vam->input->buffer, len);
5918 mp->length = htonl (len);
5922 /* json responses may or may not include a useful reply... */
5923 if (vec_len (vam->cmd_reply))
5924 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5929 exec (vat_main_t * vam)
5931 return exec_inband (vam);
5935 api_create_loopback (vat_main_t * vam)
5937 unformat_input_t *i = vam->input;
5938 vl_api_create_loopback_t *mp;
5939 vl_api_create_loopback_instance_t *mp_lbi;
5942 u8 is_specified = 0;
5943 u32 user_instance = 0;
5946 memset (mac_address, 0, sizeof (mac_address));
5948 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5950 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5952 if (unformat (i, "instance %d", &user_instance))
5960 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5961 mp_lbi->is_specified = is_specified;
5963 mp_lbi->user_instance = htonl (user_instance);
5965 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5970 /* Construct the API message */
5971 M (CREATE_LOOPBACK, mp);
5973 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5982 api_delete_loopback (vat_main_t * vam)
5984 unformat_input_t *i = vam->input;
5985 vl_api_delete_loopback_t *mp;
5986 u32 sw_if_index = ~0;
5989 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5991 if (unformat (i, "sw_if_index %d", &sw_if_index))
5997 if (sw_if_index == ~0)
5999 errmsg ("missing sw_if_index");
6003 /* Construct the API message */
6004 M (DELETE_LOOPBACK, mp);
6005 mp->sw_if_index = ntohl (sw_if_index);
6013 api_want_stats (vat_main_t * vam)
6015 unformat_input_t *i = vam->input;
6016 vl_api_want_stats_t *mp;
6020 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6022 if (unformat (i, "enable"))
6024 else if (unformat (i, "disable"))
6032 errmsg ("missing enable|disable");
6037 mp->enable_disable = enable;
6045 api_want_interface_events (vat_main_t * vam)
6047 unformat_input_t *i = vam->input;
6048 vl_api_want_interface_events_t *mp;
6052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6054 if (unformat (i, "enable"))
6056 else if (unformat (i, "disable"))
6064 errmsg ("missing enable|disable");
6068 M (WANT_INTERFACE_EVENTS, mp);
6069 mp->enable_disable = enable;
6071 vam->interface_event_display = enable;
6079 /* Note: non-static, called once to set up the initial intfc table */
6081 api_sw_interface_dump (vat_main_t * vam)
6083 vl_api_sw_interface_dump_t *mp;
6084 vl_api_control_ping_t *mp_ping;
6086 name_sort_t *nses = 0, *ns;
6087 sw_interface_subif_t *sub = NULL;
6090 /* Toss the old name table */
6092 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6094 vec_add2 (nses, ns, 1);
6095 ns->name = (u8 *)(p->key);
6096 ns->value = (u32) p->value[0];
6100 hash_free (vam->sw_if_index_by_interface_name);
6102 vec_foreach (ns, nses) vec_free (ns->name);
6106 vec_foreach (sub, vam->sw_if_subif_table)
6108 vec_free (sub->interface_name);
6110 vec_free (vam->sw_if_subif_table);
6112 /* recreate the interface name hash table */
6113 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6115 /* Get list of ethernets */
6116 M (SW_INTERFACE_DUMP, mp);
6117 mp->name_filter_valid = 1;
6118 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
6121 /* and local / loopback interfaces */
6122 M (SW_INTERFACE_DUMP, mp);
6123 mp->name_filter_valid = 1;
6124 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
6127 /* and packet-generator interfaces */
6128 M (SW_INTERFACE_DUMP, mp);
6129 mp->name_filter_valid = 1;
6130 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
6133 /* and vxlan-gpe tunnel interfaces */
6134 M (SW_INTERFACE_DUMP, mp);
6135 mp->name_filter_valid = 1;
6136 strncpy ((char *) mp->name_filter, "vxlan_gpe",
6137 sizeof (mp->name_filter) - 1);
6140 /* and vxlan tunnel interfaces */
6141 M (SW_INTERFACE_DUMP, mp);
6142 mp->name_filter_valid = 1;
6143 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
6146 /* and geneve tunnel interfaces */
6147 M (SW_INTERFACE_DUMP, mp);
6148 mp->name_filter_valid = 1;
6149 strncpy ((char *) mp->name_filter, "geneve", sizeof (mp->name_filter) - 1);
6152 /* and host (af_packet) interfaces */
6153 M (SW_INTERFACE_DUMP, mp);
6154 mp->name_filter_valid = 1;
6155 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
6158 /* and l2tpv3 tunnel interfaces */
6159 M (SW_INTERFACE_DUMP, mp);
6160 mp->name_filter_valid = 1;
6161 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
6162 sizeof (mp->name_filter) - 1);
6165 /* and GRE tunnel interfaces */
6166 M (SW_INTERFACE_DUMP, mp);
6167 mp->name_filter_valid = 1;
6168 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
6171 /* and LISP-GPE interfaces */
6172 M (SW_INTERFACE_DUMP, mp);
6173 mp->name_filter_valid = 1;
6174 strncpy ((char *) mp->name_filter, "lisp_gpe",
6175 sizeof (mp->name_filter) - 1);
6178 /* and IPSEC tunnel interfaces */
6179 M (SW_INTERFACE_DUMP, mp);
6180 mp->name_filter_valid = 1;
6181 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
6184 /* Use a control ping for synchronization */
6185 MPING (CONTROL_PING, mp_ping);
6193 api_sw_interface_set_flags (vat_main_t * vam)
6195 unformat_input_t *i = vam->input;
6196 vl_api_sw_interface_set_flags_t *mp;
6198 u8 sw_if_index_set = 0;
6202 /* Parse args required to build the message */
6203 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6205 if (unformat (i, "admin-up"))
6207 else if (unformat (i, "admin-down"))
6210 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6211 sw_if_index_set = 1;
6212 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6213 sw_if_index_set = 1;
6218 if (sw_if_index_set == 0)
6220 errmsg ("missing interface name or sw_if_index");
6224 /* Construct the API message */
6225 M (SW_INTERFACE_SET_FLAGS, mp);
6226 mp->sw_if_index = ntohl (sw_if_index);
6227 mp->admin_up_down = admin_up;
6232 /* Wait for a reply, return the good/bad news... */
6238 api_sw_interface_set_rx_mode (vat_main_t * vam)
6240 unformat_input_t *i = vam->input;
6241 vl_api_sw_interface_set_rx_mode_t *mp;
6243 u8 sw_if_index_set = 0;
6245 u8 queue_id_valid = 0;
6247 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6249 /* Parse args required to build the message */
6250 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6252 if (unformat (i, "queue %d", &queue_id))
6254 else if (unformat (i, "polling"))
6255 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6256 else if (unformat (i, "interrupt"))
6257 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6258 else if (unformat (i, "adaptive"))
6259 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6261 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6262 sw_if_index_set = 1;
6263 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6264 sw_if_index_set = 1;
6269 if (sw_if_index_set == 0)
6271 errmsg ("missing interface name or sw_if_index");
6274 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6276 errmsg ("missing rx-mode");
6280 /* Construct the API message */
6281 M (SW_INTERFACE_SET_RX_MODE, mp);
6282 mp->sw_if_index = ntohl (sw_if_index);
6284 mp->queue_id_valid = queue_id_valid;
6285 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6290 /* Wait for a reply, return the good/bad news... */
6296 api_sw_interface_clear_stats (vat_main_t * vam)
6298 unformat_input_t *i = vam->input;
6299 vl_api_sw_interface_clear_stats_t *mp;
6301 u8 sw_if_index_set = 0;
6304 /* Parse args required to build the message */
6305 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6307 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6308 sw_if_index_set = 1;
6309 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6310 sw_if_index_set = 1;
6315 /* Construct the API message */
6316 M (SW_INTERFACE_CLEAR_STATS, mp);
6318 if (sw_if_index_set == 1)
6319 mp->sw_if_index = ntohl (sw_if_index);
6321 mp->sw_if_index = ~0;
6326 /* Wait for a reply, return the good/bad news... */
6332 api_sw_interface_add_del_address (vat_main_t * vam)
6334 unformat_input_t *i = vam->input;
6335 vl_api_sw_interface_add_del_address_t *mp;
6337 u8 sw_if_index_set = 0;
6338 u8 is_add = 1, del_all = 0;
6339 u32 address_length = 0;
6340 u8 v4_address_set = 0;
6341 u8 v6_address_set = 0;
6342 ip4_address_t v4address;
6343 ip6_address_t v6address;
6346 /* Parse args required to build the message */
6347 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6349 if (unformat (i, "del-all"))
6351 else if (unformat (i, "del"))
6354 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6355 sw_if_index_set = 1;
6356 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6357 sw_if_index_set = 1;
6358 else if (unformat (i, "%U/%d",
6359 unformat_ip4_address, &v4address, &address_length))
6361 else if (unformat (i, "%U/%d",
6362 unformat_ip6_address, &v6address, &address_length))
6368 if (sw_if_index_set == 0)
6370 errmsg ("missing interface name or sw_if_index");
6373 if (v4_address_set && v6_address_set)
6375 errmsg ("both v4 and v6 addresses set");
6378 if (!v4_address_set && !v6_address_set && !del_all)
6380 errmsg ("no addresses set");
6384 /* Construct the API message */
6385 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6387 mp->sw_if_index = ntohl (sw_if_index);
6388 mp->is_add = is_add;
6389 mp->del_all = del_all;
6393 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6397 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6399 mp->address_length = address_length;
6404 /* Wait for a reply, return good/bad news */
6410 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6412 unformat_input_t *i = vam->input;
6413 vl_api_sw_interface_set_mpls_enable_t *mp;
6415 u8 sw_if_index_set = 0;
6419 /* Parse args required to build the message */
6420 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6422 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6423 sw_if_index_set = 1;
6424 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6425 sw_if_index_set = 1;
6426 else if (unformat (i, "disable"))
6428 else if (unformat (i, "dis"))
6434 if (sw_if_index_set == 0)
6436 errmsg ("missing interface name or sw_if_index");
6440 /* Construct the API message */
6441 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6443 mp->sw_if_index = ntohl (sw_if_index);
6444 mp->enable = enable;
6449 /* Wait for a reply... */
6455 api_sw_interface_set_table (vat_main_t * vam)
6457 unformat_input_t *i = vam->input;
6458 vl_api_sw_interface_set_table_t *mp;
6459 u32 sw_if_index, vrf_id = 0;
6460 u8 sw_if_index_set = 0;
6464 /* Parse args required to build the message */
6465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6467 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6468 sw_if_index_set = 1;
6469 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6470 sw_if_index_set = 1;
6471 else if (unformat (i, "vrf %d", &vrf_id))
6473 else if (unformat (i, "ipv6"))
6479 if (sw_if_index_set == 0)
6481 errmsg ("missing interface name or sw_if_index");
6485 /* Construct the API message */
6486 M (SW_INTERFACE_SET_TABLE, mp);
6488 mp->sw_if_index = ntohl (sw_if_index);
6489 mp->is_ipv6 = is_ipv6;
6490 mp->vrf_id = ntohl (vrf_id);
6495 /* Wait for a reply... */
6500 static void vl_api_sw_interface_get_table_reply_t_handler
6501 (vl_api_sw_interface_get_table_reply_t * mp)
6503 vat_main_t *vam = &vat_main;
6505 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6507 vam->retval = ntohl (mp->retval);
6508 vam->result_ready = 1;
6512 static void vl_api_sw_interface_get_table_reply_t_handler_json
6513 (vl_api_sw_interface_get_table_reply_t * mp)
6515 vat_main_t *vam = &vat_main;
6516 vat_json_node_t node;
6518 vat_json_init_object (&node);
6519 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6520 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6522 vat_json_print (vam->ofp, &node);
6523 vat_json_free (&node);
6525 vam->retval = ntohl (mp->retval);
6526 vam->result_ready = 1;
6530 api_sw_interface_get_table (vat_main_t * vam)
6532 unformat_input_t *i = vam->input;
6533 vl_api_sw_interface_get_table_t *mp;
6535 u8 sw_if_index_set = 0;
6539 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6541 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6542 sw_if_index_set = 1;
6543 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6544 sw_if_index_set = 1;
6545 else if (unformat (i, "ipv6"))
6551 if (sw_if_index_set == 0)
6553 errmsg ("missing interface name or sw_if_index");
6557 M (SW_INTERFACE_GET_TABLE, mp);
6558 mp->sw_if_index = htonl (sw_if_index);
6559 mp->is_ipv6 = is_ipv6;
6567 api_sw_interface_set_vpath (vat_main_t * vam)
6569 unformat_input_t *i = vam->input;
6570 vl_api_sw_interface_set_vpath_t *mp;
6571 u32 sw_if_index = 0;
6572 u8 sw_if_index_set = 0;
6576 /* Parse args required to build the message */
6577 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6579 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6580 sw_if_index_set = 1;
6581 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6582 sw_if_index_set = 1;
6583 else if (unformat (i, "enable"))
6585 else if (unformat (i, "disable"))
6591 if (sw_if_index_set == 0)
6593 errmsg ("missing interface name or sw_if_index");
6597 /* Construct the API message */
6598 M (SW_INTERFACE_SET_VPATH, mp);
6600 mp->sw_if_index = ntohl (sw_if_index);
6601 mp->enable = is_enable;
6606 /* Wait for a reply... */
6612 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6614 unformat_input_t *i = vam->input;
6615 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6616 u32 sw_if_index = 0;
6617 u8 sw_if_index_set = 0;
6622 /* Parse args required to build the message */
6623 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6625 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6626 sw_if_index_set = 1;
6627 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6628 sw_if_index_set = 1;
6629 else if (unformat (i, "enable"))
6631 else if (unformat (i, "disable"))
6633 else if (unformat (i, "ip4"))
6635 else if (unformat (i, "ip6"))
6641 if (sw_if_index_set == 0)
6643 errmsg ("missing interface name or sw_if_index");
6647 /* Construct the API message */
6648 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6650 mp->sw_if_index = ntohl (sw_if_index);
6651 mp->enable = is_enable;
6652 mp->is_ipv6 = is_ipv6;
6657 /* Wait for a reply... */
6663 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6665 unformat_input_t *i = vam->input;
6666 vl_api_sw_interface_set_geneve_bypass_t *mp;
6667 u32 sw_if_index = 0;
6668 u8 sw_if_index_set = 0;
6673 /* Parse args required to build the message */
6674 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6676 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6677 sw_if_index_set = 1;
6678 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6679 sw_if_index_set = 1;
6680 else if (unformat (i, "enable"))
6682 else if (unformat (i, "disable"))
6684 else if (unformat (i, "ip4"))
6686 else if (unformat (i, "ip6"))
6692 if (sw_if_index_set == 0)
6694 errmsg ("missing interface name or sw_if_index");
6698 /* Construct the API message */
6699 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6701 mp->sw_if_index = ntohl (sw_if_index);
6702 mp->enable = is_enable;
6703 mp->is_ipv6 = is_ipv6;
6708 /* Wait for a reply... */
6714 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6716 unformat_input_t *i = vam->input;
6717 vl_api_sw_interface_set_l2_xconnect_t *mp;
6719 u8 rx_sw_if_index_set = 0;
6721 u8 tx_sw_if_index_set = 0;
6725 /* Parse args required to build the message */
6726 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6728 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6729 rx_sw_if_index_set = 1;
6730 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6731 tx_sw_if_index_set = 1;
6732 else if (unformat (i, "rx"))
6734 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6736 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6738 rx_sw_if_index_set = 1;
6743 else if (unformat (i, "tx"))
6745 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6747 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6749 tx_sw_if_index_set = 1;
6754 else if (unformat (i, "enable"))
6756 else if (unformat (i, "disable"))
6762 if (rx_sw_if_index_set == 0)
6764 errmsg ("missing rx interface name or rx_sw_if_index");
6768 if (enable && (tx_sw_if_index_set == 0))
6770 errmsg ("missing tx interface name or tx_sw_if_index");
6774 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6776 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6777 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6778 mp->enable = enable;
6786 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6788 unformat_input_t *i = vam->input;
6789 vl_api_sw_interface_set_l2_bridge_t *mp;
6791 u8 rx_sw_if_index_set = 0;
6799 /* Parse args required to build the message */
6800 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6802 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6803 rx_sw_if_index_set = 1;
6804 else if (unformat (i, "bd_id %d", &bd_id))
6808 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6809 rx_sw_if_index_set = 1;
6810 else if (unformat (i, "shg %d", &shg))
6812 else if (unformat (i, "bvi"))
6814 else if (unformat (i, "enable"))
6816 else if (unformat (i, "disable"))
6822 if (rx_sw_if_index_set == 0)
6824 errmsg ("missing rx interface name or sw_if_index");
6828 if (enable && (bd_id_set == 0))
6830 errmsg ("missing bridge domain");
6834 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6836 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6837 mp->bd_id = ntohl (bd_id);
6840 mp->enable = enable;
6848 api_bridge_domain_dump (vat_main_t * vam)
6850 unformat_input_t *i = vam->input;
6851 vl_api_bridge_domain_dump_t *mp;
6852 vl_api_control_ping_t *mp_ping;
6856 /* Parse args required to build the message */
6857 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6859 if (unformat (i, "bd_id %d", &bd_id))
6865 M (BRIDGE_DOMAIN_DUMP, mp);
6866 mp->bd_id = ntohl (bd_id);
6869 /* Use a control ping for synchronization */
6870 MPING (CONTROL_PING, mp_ping);
6878 api_bridge_domain_add_del (vat_main_t * vam)
6880 unformat_input_t *i = vam->input;
6881 vl_api_bridge_domain_add_del_t *mp;
6884 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6889 /* Parse args required to build the message */
6890 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6892 if (unformat (i, "bd_id %d", &bd_id))
6894 else if (unformat (i, "flood %d", &flood))
6896 else if (unformat (i, "uu-flood %d", &uu_flood))
6898 else if (unformat (i, "forward %d", &forward))
6900 else if (unformat (i, "learn %d", &learn))
6902 else if (unformat (i, "arp-term %d", &arp_term))
6904 else if (unformat (i, "mac-age %d", &mac_age))
6906 else if (unformat (i, "bd-tag %s", &bd_tag))
6908 else if (unformat (i, "del"))
6911 flood = uu_flood = forward = learn = 0;
6919 errmsg ("missing bridge domain");
6926 errmsg ("mac age must be less than 256 ");
6931 if ((bd_tag) && (strlen ((char *) bd_tag) > 63))
6933 errmsg ("bd-tag cannot be longer than 63");
6938 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6940 mp->bd_id = ntohl (bd_id);
6942 mp->uu_flood = uu_flood;
6943 mp->forward = forward;
6945 mp->arp_term = arp_term;
6946 mp->is_add = is_add;
6947 mp->mac_age = (u8) mac_age;
6949 strcpy ((char *) mp->bd_tag, (char *) bd_tag);
6960 api_l2fib_flush_bd (vat_main_t * vam)
6962 unformat_input_t *i = vam->input;
6963 vl_api_l2fib_flush_bd_t *mp;
6967 /* Parse args required to build the message */
6968 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6970 if (unformat (i, "bd_id %d", &bd_id));
6977 errmsg ("missing bridge domain");
6981 M (L2FIB_FLUSH_BD, mp);
6983 mp->bd_id = htonl (bd_id);
6991 api_l2fib_flush_int (vat_main_t * vam)
6993 unformat_input_t *i = vam->input;
6994 vl_api_l2fib_flush_int_t *mp;
6995 u32 sw_if_index = ~0;
6998 /* Parse args required to build the message */
6999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7001 if (unformat (i, "sw_if_index %d", &sw_if_index));
7003 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7008 if (sw_if_index == ~0)
7010 errmsg ("missing interface name or sw_if_index");
7014 M (L2FIB_FLUSH_INT, mp);
7016 mp->sw_if_index = ntohl (sw_if_index);
7024 api_l2fib_add_del (vat_main_t * vam)
7026 unformat_input_t *i = vam->input;
7027 vl_api_l2fib_add_del_t *mp;
7033 u32 sw_if_index = ~0;
7034 u8 sw_if_index_set = 0;
7043 /* Parse args required to build the message */
7044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7046 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7048 else if (unformat (i, "bd_id %d", &bd_id))
7050 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7051 sw_if_index_set = 1;
7052 else if (unformat (i, "sw_if"))
7054 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7057 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7058 sw_if_index_set = 1;
7063 else if (unformat (i, "static"))
7065 else if (unformat (i, "filter"))
7070 else if (unformat (i, "bvi"))
7075 else if (unformat (i, "del"))
7077 else if (unformat (i, "count %d", &count))
7085 errmsg ("missing mac address");
7091 errmsg ("missing bridge domain");
7095 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7097 errmsg ("missing interface name or sw_if_index");
7103 /* Turn on async mode */
7104 vam->async_mode = 1;
7105 vam->async_errors = 0;
7106 before = vat_time_now (vam);
7109 for (j = 0; j < count; j++)
7111 M (L2FIB_ADD_DEL, mp);
7113 clib_memcpy (mp->mac, mac, 6);
7114 mp->bd_id = ntohl (bd_id);
7115 mp->is_add = is_add;
7119 mp->sw_if_index = ntohl (sw_if_index);
7120 mp->static_mac = static_mac;
7121 mp->filter_mac = filter_mac;
7122 mp->bvi_mac = bvi_mac;
7124 increment_mac_address (mac);
7131 vl_api_control_ping_t *mp_ping;
7134 /* Shut off async mode */
7135 vam->async_mode = 0;
7137 MPING (CONTROL_PING, mp_ping);
7140 timeout = vat_time_now (vam) + 1.0;
7141 while (vat_time_now (vam) < timeout)
7142 if (vam->result_ready == 1)
7147 if (vam->retval == -99)
7150 if (vam->async_errors > 0)
7152 errmsg ("%d asynchronous errors", vam->async_errors);
7155 vam->async_errors = 0;
7156 after = vat_time_now (vam);
7158 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7159 count, after - before, count / (after - before));
7165 /* Wait for a reply... */
7169 /* Return the good/bad news */
7170 return (vam->retval);
7174 api_bridge_domain_set_mac_age (vat_main_t * vam)
7176 unformat_input_t *i = vam->input;
7177 vl_api_bridge_domain_set_mac_age_t *mp;
7182 /* Parse args required to build the message */
7183 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7185 if (unformat (i, "bd_id %d", &bd_id));
7186 else if (unformat (i, "mac-age %d", &mac_age));
7193 errmsg ("missing bridge domain");
7199 errmsg ("mac age must be less than 256 ");
7203 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7205 mp->bd_id = htonl (bd_id);
7206 mp->mac_age = (u8) mac_age;
7214 api_l2_flags (vat_main_t * vam)
7216 unformat_input_t *i = vam->input;
7217 vl_api_l2_flags_t *mp;
7220 u8 sw_if_index_set = 0;
7224 /* Parse args required to build the message */
7225 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7227 if (unformat (i, "sw_if_index %d", &sw_if_index))
7228 sw_if_index_set = 1;
7229 else if (unformat (i, "sw_if"))
7231 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7234 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7235 sw_if_index_set = 1;
7240 else if (unformat (i, "learn"))
7242 else if (unformat (i, "forward"))
7244 else if (unformat (i, "flood"))
7246 else if (unformat (i, "uu-flood"))
7247 flags |= L2_UU_FLOOD;
7248 else if (unformat (i, "arp-term"))
7249 flags |= L2_ARP_TERM;
7250 else if (unformat (i, "off"))
7252 else if (unformat (i, "disable"))
7258 if (sw_if_index_set == 0)
7260 errmsg ("missing interface name or sw_if_index");
7266 mp->sw_if_index = ntohl (sw_if_index);
7267 mp->feature_bitmap = ntohl (flags);
7268 mp->is_set = is_set;
7276 api_bridge_flags (vat_main_t * vam)
7278 unformat_input_t *i = vam->input;
7279 vl_api_bridge_flags_t *mp;
7286 /* Parse args required to build the message */
7287 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7289 if (unformat (i, "bd_id %d", &bd_id))
7291 else if (unformat (i, "learn"))
7293 else if (unformat (i, "forward"))
7295 else if (unformat (i, "flood"))
7297 else if (unformat (i, "uu-flood"))
7298 flags |= L2_UU_FLOOD;
7299 else if (unformat (i, "arp-term"))
7300 flags |= L2_ARP_TERM;
7301 else if (unformat (i, "off"))
7303 else if (unformat (i, "disable"))
7311 errmsg ("missing bridge domain");
7315 M (BRIDGE_FLAGS, mp);
7317 mp->bd_id = ntohl (bd_id);
7318 mp->feature_bitmap = ntohl (flags);
7319 mp->is_set = is_set;
7327 api_bd_ip_mac_add_del (vat_main_t * vam)
7329 unformat_input_t *i = vam->input;
7330 vl_api_bd_ip_mac_add_del_t *mp;
7337 ip4_address_t v4addr;
7338 ip6_address_t v6addr;
7343 /* Parse args required to build the message */
7344 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7346 if (unformat (i, "bd_id %d", &bd_id))
7350 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7354 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7359 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7363 else if (unformat (i, "del"))
7371 errmsg ("missing bridge domain");
7374 else if (ip_set == 0)
7376 errmsg ("missing IP address");
7379 else if (mac_set == 0)
7381 errmsg ("missing MAC address");
7385 M (BD_IP_MAC_ADD_DEL, mp);
7387 mp->bd_id = ntohl (bd_id);
7388 mp->is_ipv6 = is_ipv6;
7389 mp->is_add = is_add;
7391 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7393 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7394 clib_memcpy (mp->mac_address, macaddr, 6);
7401 api_tap_connect (vat_main_t * vam)
7403 unformat_input_t *i = vam->input;
7404 vl_api_tap_connect_t *mp;
7410 ip4_address_t ip4_address;
7412 int ip4_address_set = 0;
7413 ip6_address_t ip6_address;
7415 int ip6_address_set = 0;
7418 memset (mac_address, 0, sizeof (mac_address));
7420 /* Parse args required to build the message */
7421 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7423 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7427 else if (unformat (i, "random-mac"))
7429 else if (unformat (i, "tapname %s", &tap_name))
7431 else if (unformat (i, "tag %s", &tag))
7433 else if (unformat (i, "address %U/%d",
7434 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7435 ip4_address_set = 1;
7436 else if (unformat (i, "address %U/%d",
7437 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7438 ip6_address_set = 1;
7445 errmsg ("missing tap name");
7448 if (vec_len (tap_name) > 63)
7450 errmsg ("tap name too long");
7453 vec_add1 (tap_name, 0);
7455 if (vec_len (tag) > 63)
7457 errmsg ("tag too long");
7461 /* Construct the API message */
7462 M (TAP_CONNECT, mp);
7464 mp->use_random_mac = random_mac;
7465 clib_memcpy (mp->mac_address, mac_address, 6);
7466 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7468 clib_memcpy (mp->tag, tag, vec_len (tag));
7470 if (ip4_address_set)
7472 mp->ip4_address_set = 1;
7473 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7474 mp->ip4_mask_width = ip4_mask_width;
7476 if (ip6_address_set)
7478 mp->ip6_address_set = 1;
7479 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7480 mp->ip6_mask_width = ip6_mask_width;
7483 vec_free (tap_name);
7489 /* Wait for a reply... */
7495 api_tap_modify (vat_main_t * vam)
7497 unformat_input_t *i = vam->input;
7498 vl_api_tap_modify_t *mp;
7503 u32 sw_if_index = ~0;
7504 u8 sw_if_index_set = 0;
7507 memset (mac_address, 0, sizeof (mac_address));
7509 /* Parse args required to build the message */
7510 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7512 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7513 sw_if_index_set = 1;
7514 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7515 sw_if_index_set = 1;
7516 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7520 else if (unformat (i, "random-mac"))
7522 else if (unformat (i, "tapname %s", &tap_name))
7528 if (sw_if_index_set == 0)
7530 errmsg ("missing vpp interface name");
7535 errmsg ("missing tap name");
7538 if (vec_len (tap_name) > 63)
7540 errmsg ("tap name too long");
7542 vec_add1 (tap_name, 0);
7544 /* Construct the API message */
7547 mp->use_random_mac = random_mac;
7548 mp->sw_if_index = ntohl (sw_if_index);
7549 clib_memcpy (mp->mac_address, mac_address, 6);
7550 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7551 vec_free (tap_name);
7556 /* Wait for a reply... */
7562 api_tap_delete (vat_main_t * vam)
7564 unformat_input_t *i = vam->input;
7565 vl_api_tap_delete_t *mp;
7566 u32 sw_if_index = ~0;
7567 u8 sw_if_index_set = 0;
7570 /* Parse args required to build the message */
7571 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7573 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7574 sw_if_index_set = 1;
7575 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7576 sw_if_index_set = 1;
7581 if (sw_if_index_set == 0)
7583 errmsg ("missing vpp interface name");
7587 /* Construct the API message */
7590 mp->sw_if_index = ntohl (sw_if_index);
7595 /* Wait for a reply... */
7601 api_ip_table_add_del (vat_main_t * vam)
7603 unformat_input_t *i = vam->input;
7604 vl_api_ip_table_add_del_t *mp;
7610 /* Parse args required to build the message */
7611 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7613 if (unformat (i, "ipv6"))
7615 else if (unformat (i, "del"))
7617 else if (unformat (i, "add"))
7619 else if (unformat (i, "table %d", &table_id))
7623 clib_warning ("parse error '%U'", format_unformat_error, i);
7630 errmsg ("missing table-ID");
7634 /* Construct the API message */
7635 M (IP_TABLE_ADD_DEL, mp);
7637 mp->table_id = ntohl (table_id);
7638 mp->is_ipv6 = is_ipv6;
7639 mp->is_add = is_add;
7644 /* Wait for a reply... */
7651 api_ip_add_del_route (vat_main_t * vam)
7653 unformat_input_t *i = vam->input;
7654 vl_api_ip_add_del_route_t *mp;
7655 u32 sw_if_index = ~0, vrf_id = 0;
7657 u8 is_local = 0, is_drop = 0;
7658 u8 is_unreach = 0, is_prohibit = 0;
7659 u8 create_vrf_if_needed = 0;
7661 u32 next_hop_weight = 1;
7662 u8 is_multipath = 0;
7664 u8 address_length_set = 0;
7665 u32 next_hop_table_id = 0;
7666 u32 resolve_attempts = 0;
7667 u32 dst_address_length = 0;
7668 u8 next_hop_set = 0;
7669 ip4_address_t v4_dst_address, v4_next_hop_address;
7670 ip6_address_t v6_dst_address, v6_next_hop_address;
7674 u32 random_add_del = 0;
7675 u32 *random_vector = 0;
7677 u32 random_seed = 0xdeaddabe;
7678 u32 classify_table_index = ~0;
7680 u8 resolve_host = 0, resolve_attached = 0;
7681 mpls_label_t *next_hop_out_label_stack = NULL;
7682 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7683 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7685 /* Parse args required to build the message */
7686 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7688 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7690 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7692 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
7697 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
7702 else if (unformat (i, "/%d", &dst_address_length))
7704 address_length_set = 1;
7707 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
7708 &v4_next_hop_address))
7712 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7713 &v6_next_hop_address))
7717 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7719 else if (unformat (i, "weight %d", &next_hop_weight))
7721 else if (unformat (i, "drop"))
7725 else if (unformat (i, "null-send-unreach"))
7729 else if (unformat (i, "null-send-prohibit"))
7733 else if (unformat (i, "local"))
7737 else if (unformat (i, "classify %d", &classify_table_index))
7741 else if (unformat (i, "del"))
7743 else if (unformat (i, "add"))
7745 else if (unformat (i, "resolve-via-host"))
7747 else if (unformat (i, "resolve-via-attached"))
7748 resolve_attached = 1;
7749 else if (unformat (i, "multipath"))
7751 else if (unformat (i, "vrf %d", &vrf_id))
7753 else if (unformat (i, "create-vrf"))
7754 create_vrf_if_needed = 1;
7755 else if (unformat (i, "count %d", &count))
7757 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7759 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7761 else if (unformat (i, "out-label %d", &next_hop_out_label))
7762 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7763 else if (unformat (i, "via-label %d", &next_hop_via_label))
7765 else if (unformat (i, "random"))
7767 else if (unformat (i, "seed %d", &random_seed))
7771 clib_warning ("parse error '%U'", format_unformat_error, i);
7776 if (!next_hop_set && !is_drop && !is_local &&
7777 !is_classify && !is_unreach && !is_prohibit &&
7778 MPLS_LABEL_INVALID == next_hop_via_label)
7781 ("next hop / local / drop / unreach / prohibit / classify not set");
7785 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7787 errmsg ("next hop and next-hop via label set");
7790 if (address_set == 0)
7792 errmsg ("missing addresses");
7796 if (address_length_set == 0)
7798 errmsg ("missing address length");
7802 /* Generate a pile of unique, random routes */
7805 u32 this_random_address;
7806 random_hash = hash_create (count, sizeof (uword));
7808 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7809 for (j = 0; j <= count; j++)
7813 this_random_address = random_u32 (&random_seed);
7814 this_random_address =
7815 clib_host_to_net_u32 (this_random_address);
7817 while (hash_get (random_hash, this_random_address));
7818 vec_add1 (random_vector, this_random_address);
7819 hash_set (random_hash, this_random_address, 1);
7821 hash_free (random_hash);
7822 v4_dst_address.as_u32 = random_vector[0];
7827 /* Turn on async mode */
7828 vam->async_mode = 1;
7829 vam->async_errors = 0;
7830 before = vat_time_now (vam);
7833 for (j = 0; j < count; j++)
7835 /* Construct the API message */
7836 M2 (IP_ADD_DEL_ROUTE, mp,
7837 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7839 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7840 mp->table_id = ntohl (vrf_id);
7841 mp->create_vrf_if_needed = create_vrf_if_needed;
7843 mp->is_add = is_add;
7844 mp->is_drop = is_drop;
7845 mp->is_unreach = is_unreach;
7846 mp->is_prohibit = is_prohibit;
7847 mp->is_ipv6 = is_ipv6;
7848 mp->is_local = is_local;
7849 mp->is_classify = is_classify;
7850 mp->is_multipath = is_multipath;
7851 mp->is_resolve_host = resolve_host;
7852 mp->is_resolve_attached = resolve_attached;
7853 mp->next_hop_weight = next_hop_weight;
7854 mp->dst_address_length = dst_address_length;
7855 mp->next_hop_table_id = ntohl (next_hop_table_id);
7856 mp->classify_table_index = ntohl (classify_table_index);
7857 mp->next_hop_via_label = ntohl (next_hop_via_label);
7858 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7859 if (0 != mp->next_hop_n_out_labels)
7861 memcpy (mp->next_hop_out_label_stack,
7862 next_hop_out_label_stack,
7863 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7864 vec_free (next_hop_out_label_stack);
7869 clib_memcpy (mp->dst_address, &v6_dst_address,
7870 sizeof (v6_dst_address));
7872 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
7873 sizeof (v6_next_hop_address));
7874 increment_v6_address (&v6_dst_address);
7878 clib_memcpy (mp->dst_address, &v4_dst_address,
7879 sizeof (v4_dst_address));
7881 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
7882 sizeof (v4_next_hop_address));
7884 v4_dst_address.as_u32 = random_vector[j + 1];
7886 increment_v4_address (&v4_dst_address);
7890 /* If we receive SIGTERM, stop now... */
7895 /* When testing multiple add/del ops, use a control-ping to sync */
7898 vl_api_control_ping_t *mp_ping;
7902 /* Shut off async mode */
7903 vam->async_mode = 0;
7905 MPING (CONTROL_PING, mp_ping);
7908 timeout = vat_time_now (vam) + 1.0;
7909 while (vat_time_now (vam) < timeout)
7910 if (vam->result_ready == 1)
7915 if (vam->retval == -99)
7918 if (vam->async_errors > 0)
7920 errmsg ("%d asynchronous errors", vam->async_errors);
7923 vam->async_errors = 0;
7924 after = vat_time_now (vam);
7926 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7930 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7931 count, after - before, count / (after - before));
7937 /* Wait for a reply... */
7942 /* Return the good/bad news */
7943 return (vam->retval);
7947 api_ip_mroute_add_del (vat_main_t * vam)
7949 unformat_input_t *i = vam->input;
7950 vl_api_ip_mroute_add_del_t *mp;
7951 u32 sw_if_index = ~0, vrf_id = 0;
7954 u8 create_vrf_if_needed = 0;
7957 u32 grp_address_length = 0;
7958 ip4_address_t v4_grp_address, v4_src_address;
7959 ip6_address_t v6_grp_address, v6_src_address;
7960 mfib_itf_flags_t iflags = 0;
7961 mfib_entry_flags_t eflags = 0;
7964 /* Parse args required to build the message */
7965 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7967 if (unformat (i, "sw_if_index %d", &sw_if_index))
7969 else if (unformat (i, "%U %U",
7970 unformat_ip4_address, &v4_src_address,
7971 unformat_ip4_address, &v4_grp_address))
7973 grp_address_length = 64;
7977 else if (unformat (i, "%U %U",
7978 unformat_ip6_address, &v6_src_address,
7979 unformat_ip6_address, &v6_grp_address))
7981 grp_address_length = 256;
7985 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7987 memset (&v4_src_address, 0, sizeof (v4_src_address));
7988 grp_address_length = 32;
7992 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7994 memset (&v6_src_address, 0, sizeof (v6_src_address));
7995 grp_address_length = 128;
7999 else if (unformat (i, "/%d", &grp_address_length))
8001 else if (unformat (i, "local"))
8005 else if (unformat (i, "del"))
8007 else if (unformat (i, "add"))
8009 else if (unformat (i, "vrf %d", &vrf_id))
8011 else if (unformat (i, "create-vrf"))
8012 create_vrf_if_needed = 1;
8013 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8015 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8019 clib_warning ("parse error '%U'", format_unformat_error, i);
8024 if (address_set == 0)
8026 errmsg ("missing addresses\n");
8030 /* Construct the API message */
8031 M (IP_MROUTE_ADD_DEL, mp);
8033 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8034 mp->table_id = ntohl (vrf_id);
8035 mp->create_vrf_if_needed = create_vrf_if_needed;
8037 mp->is_add = is_add;
8038 mp->is_ipv6 = is_ipv6;
8039 mp->is_local = is_local;
8040 mp->itf_flags = ntohl (iflags);
8041 mp->entry_flags = ntohl (eflags);
8042 mp->grp_address_length = grp_address_length;
8043 mp->grp_address_length = ntohs (mp->grp_address_length);
8047 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8048 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8052 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8053 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8059 /* Wait for a reply... */
8065 api_mpls_table_add_del (vat_main_t * vam)
8067 unformat_input_t *i = vam->input;
8068 vl_api_mpls_table_add_del_t *mp;
8073 /* Parse args required to build the message */
8074 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8076 if (unformat (i, "table %d", &table_id))
8078 else if (unformat (i, "del"))
8080 else if (unformat (i, "add"))
8084 clib_warning ("parse error '%U'", format_unformat_error, i);
8091 errmsg ("missing table-ID");
8095 /* Construct the API message */
8096 M (MPLS_TABLE_ADD_DEL, mp);
8098 mp->mt_table_id = ntohl (table_id);
8099 mp->mt_is_add = is_add;
8104 /* Wait for a reply... */
8111 api_mpls_route_add_del (vat_main_t * vam)
8113 unformat_input_t *i = vam->input;
8114 vl_api_mpls_route_add_del_t *mp;
8115 u32 sw_if_index = ~0, table_id = 0;
8116 u8 create_table_if_needed = 0;
8118 u32 next_hop_weight = 1;
8119 u8 is_multipath = 0;
8120 u32 next_hop_table_id = 0;
8121 u8 next_hop_set = 0;
8122 ip4_address_t v4_next_hop_address = {
8125 ip6_address_t v6_next_hop_address = { {0} };
8129 u32 classify_table_index = ~0;
8131 u8 resolve_host = 0, resolve_attached = 0;
8132 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8133 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8134 mpls_label_t *next_hop_out_label_stack = NULL;
8135 mpls_label_t local_label = MPLS_LABEL_INVALID;
8137 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8139 /* Parse args required to build the message */
8140 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8142 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8144 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8146 else if (unformat (i, "%d", &local_label))
8148 else if (unformat (i, "eos"))
8150 else if (unformat (i, "non-eos"))
8152 else if (unformat (i, "via %U", unformat_ip4_address,
8153 &v4_next_hop_address))
8156 next_hop_proto = DPO_PROTO_IP4;
8158 else if (unformat (i, "via %U", unformat_ip6_address,
8159 &v6_next_hop_address))
8162 next_hop_proto = DPO_PROTO_IP6;
8164 else if (unformat (i, "weight %d", &next_hop_weight))
8166 else if (unformat (i, "create-table"))
8167 create_table_if_needed = 1;
8168 else if (unformat (i, "classify %d", &classify_table_index))
8172 else if (unformat (i, "del"))
8174 else if (unformat (i, "add"))
8176 else if (unformat (i, "resolve-via-host"))
8178 else if (unformat (i, "resolve-via-attached"))
8179 resolve_attached = 1;
8180 else if (unformat (i, "multipath"))
8182 else if (unformat (i, "count %d", &count))
8184 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8187 next_hop_proto = DPO_PROTO_IP4;
8189 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8192 next_hop_proto = DPO_PROTO_IP6;
8194 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8196 else if (unformat (i, "via-label %d", &next_hop_via_label))
8198 else if (unformat (i, "out-label %d", &next_hop_out_label))
8199 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8202 clib_warning ("parse error '%U'", format_unformat_error, i);
8207 if (!next_hop_set && !is_classify)
8209 errmsg ("next hop / classify not set");
8213 if (MPLS_LABEL_INVALID == local_label)
8215 errmsg ("missing label");
8221 /* Turn on async mode */
8222 vam->async_mode = 1;
8223 vam->async_errors = 0;
8224 before = vat_time_now (vam);
8227 for (j = 0; j < count; j++)
8229 /* Construct the API message */
8230 M2 (MPLS_ROUTE_ADD_DEL, mp,
8231 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8233 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8234 mp->mr_table_id = ntohl (table_id);
8235 mp->mr_create_table_if_needed = create_table_if_needed;
8237 mp->mr_is_add = is_add;
8238 mp->mr_next_hop_proto = next_hop_proto;
8239 mp->mr_is_classify = is_classify;
8240 mp->mr_is_multipath = is_multipath;
8241 mp->mr_is_resolve_host = resolve_host;
8242 mp->mr_is_resolve_attached = resolve_attached;
8243 mp->mr_next_hop_weight = next_hop_weight;
8244 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8245 mp->mr_classify_table_index = ntohl (classify_table_index);
8246 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8247 mp->mr_label = ntohl (local_label);
8248 mp->mr_eos = is_eos;
8250 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8251 if (0 != mp->mr_next_hop_n_out_labels)
8253 memcpy (mp->mr_next_hop_out_label_stack,
8254 next_hop_out_label_stack,
8255 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8256 vec_free (next_hop_out_label_stack);
8261 if (DPO_PROTO_IP4 == next_hop_proto)
8263 clib_memcpy (mp->mr_next_hop,
8264 &v4_next_hop_address,
8265 sizeof (v4_next_hop_address));
8267 else if (DPO_PROTO_IP6 == next_hop_proto)
8270 clib_memcpy (mp->mr_next_hop,
8271 &v6_next_hop_address,
8272 sizeof (v6_next_hop_address));
8279 /* If we receive SIGTERM, stop now... */
8284 /* When testing multiple add/del ops, use a control-ping to sync */
8287 vl_api_control_ping_t *mp_ping;
8291 /* Shut off async mode */
8292 vam->async_mode = 0;
8294 MPING (CONTROL_PING, mp_ping);
8297 timeout = vat_time_now (vam) + 1.0;
8298 while (vat_time_now (vam) < timeout)
8299 if (vam->result_ready == 1)
8304 if (vam->retval == -99)
8307 if (vam->async_errors > 0)
8309 errmsg ("%d asynchronous errors", vam->async_errors);
8312 vam->async_errors = 0;
8313 after = vat_time_now (vam);
8315 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8319 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8320 count, after - before, count / (after - before));
8326 /* Wait for a reply... */
8331 /* Return the good/bad news */
8332 return (vam->retval);
8336 api_mpls_ip_bind_unbind (vat_main_t * vam)
8338 unformat_input_t *i = vam->input;
8339 vl_api_mpls_ip_bind_unbind_t *mp;
8340 u32 ip_table_id = 0;
8341 u8 create_table_if_needed = 0;
8344 ip4_address_t v4_address;
8345 ip6_address_t v6_address;
8348 mpls_label_t local_label = MPLS_LABEL_INVALID;
8351 /* Parse args required to build the message */
8352 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8354 if (unformat (i, "%U/%d", unformat_ip4_address,
8355 &v4_address, &address_length))
8360 else if (unformat (i, "%U/%d", unformat_ip6_address,
8361 &v6_address, &address_length))
8366 else if (unformat (i, "%d", &local_label))
8368 else if (unformat (i, "create-table"))
8369 create_table_if_needed = 1;
8370 else if (unformat (i, "table-id %d", &ip_table_id))
8372 else if (unformat (i, "unbind"))
8374 else if (unformat (i, "bind"))
8378 clib_warning ("parse error '%U'", format_unformat_error, i);
8385 errmsg ("IP addres not set");
8389 if (MPLS_LABEL_INVALID == local_label)
8391 errmsg ("missing label");
8395 /* Construct the API message */
8396 M (MPLS_IP_BIND_UNBIND, mp);
8398 mp->mb_create_table_if_needed = create_table_if_needed;
8399 mp->mb_is_bind = is_bind;
8400 mp->mb_is_ip4 = is_ip4;
8401 mp->mb_ip_table_id = ntohl (ip_table_id);
8402 mp->mb_mpls_table_id = 0;
8403 mp->mb_label = ntohl (local_label);
8404 mp->mb_address_length = address_length;
8407 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8409 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8414 /* Wait for a reply... */
8420 api_proxy_arp_add_del (vat_main_t * vam)
8422 unformat_input_t *i = vam->input;
8423 vl_api_proxy_arp_add_del_t *mp;
8426 ip4_address_t lo, hi;
8430 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8432 if (unformat (i, "vrf %d", &vrf_id))
8434 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
8435 unformat_ip4_address, &hi))
8437 else if (unformat (i, "del"))
8441 clib_warning ("parse error '%U'", format_unformat_error, i);
8448 errmsg ("address range not set");
8452 M (PROXY_ARP_ADD_DEL, mp);
8454 mp->vrf_id = ntohl (vrf_id);
8455 mp->is_add = is_add;
8456 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
8457 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
8465 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8467 unformat_input_t *i = vam->input;
8468 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8471 u8 sw_if_index_set = 0;
8474 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8476 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8477 sw_if_index_set = 1;
8478 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8479 sw_if_index_set = 1;
8480 else if (unformat (i, "enable"))
8482 else if (unformat (i, "disable"))
8486 clib_warning ("parse error '%U'", format_unformat_error, i);
8491 if (sw_if_index_set == 0)
8493 errmsg ("missing interface name or sw_if_index");
8497 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8499 mp->sw_if_index = ntohl (sw_if_index);
8500 mp->enable_disable = enable;
8508 api_mpls_tunnel_add_del (vat_main_t * vam)
8510 unformat_input_t *i = vam->input;
8511 vl_api_mpls_tunnel_add_del_t *mp;
8515 u32 sw_if_index = ~0;
8516 u32 next_hop_sw_if_index = ~0;
8517 u32 next_hop_proto_is_ip4 = 1;
8519 u32 next_hop_table_id = 0;
8520 ip4_address_t v4_next_hop_address = {
8523 ip6_address_t v6_next_hop_address = { {0} };
8524 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
8527 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8529 if (unformat (i, "add"))
8531 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8533 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
8535 else if (unformat (i, "via %U",
8536 unformat_ip4_address, &v4_next_hop_address))
8538 next_hop_proto_is_ip4 = 1;
8540 else if (unformat (i, "via %U",
8541 unformat_ip6_address, &v6_next_hop_address))
8543 next_hop_proto_is_ip4 = 0;
8545 else if (unformat (i, "l2-only"))
8547 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8549 else if (unformat (i, "out-label %d", &next_hop_out_label))
8550 vec_add1 (labels, ntohl (next_hop_out_label));
8553 clib_warning ("parse error '%U'", format_unformat_error, i);
8558 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
8560 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
8561 mp->mt_sw_if_index = ntohl (sw_if_index);
8562 mp->mt_is_add = is_add;
8563 mp->mt_l2_only = l2_only;
8564 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
8565 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
8567 mp->mt_next_hop_n_out_labels = vec_len (labels);
8569 if (0 != mp->mt_next_hop_n_out_labels)
8571 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
8572 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
8576 if (next_hop_proto_is_ip4)
8578 clib_memcpy (mp->mt_next_hop,
8579 &v4_next_hop_address, sizeof (v4_next_hop_address));
8583 clib_memcpy (mp->mt_next_hop,
8584 &v6_next_hop_address, sizeof (v6_next_hop_address));
8593 api_sw_interface_set_unnumbered (vat_main_t * vam)
8595 unformat_input_t *i = vam->input;
8596 vl_api_sw_interface_set_unnumbered_t *mp;
8598 u32 unnum_sw_index = ~0;
8600 u8 sw_if_index_set = 0;
8603 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8605 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8606 sw_if_index_set = 1;
8607 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8608 sw_if_index_set = 1;
8609 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8611 else if (unformat (i, "del"))
8615 clib_warning ("parse error '%U'", format_unformat_error, i);
8620 if (sw_if_index_set == 0)
8622 errmsg ("missing interface name or sw_if_index");
8626 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8628 mp->sw_if_index = ntohl (sw_if_index);
8629 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8630 mp->is_add = is_add;
8638 api_ip_neighbor_add_del (vat_main_t * vam)
8640 unformat_input_t *i = vam->input;
8641 vl_api_ip_neighbor_add_del_t *mp;
8643 u8 sw_if_index_set = 0;
8646 u8 is_no_fib_entry = 0;
8649 u8 v4_address_set = 0;
8650 u8 v6_address_set = 0;
8651 ip4_address_t v4address;
8652 ip6_address_t v6address;
8655 memset (mac_address, 0, sizeof (mac_address));
8657 /* Parse args required to build the message */
8658 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8660 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8664 else if (unformat (i, "del"))
8667 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8668 sw_if_index_set = 1;
8669 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8670 sw_if_index_set = 1;
8671 else if (unformat (i, "is_static"))
8673 else if (unformat (i, "no-fib-entry"))
8674 is_no_fib_entry = 1;
8675 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
8677 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
8681 clib_warning ("parse error '%U'", format_unformat_error, i);
8686 if (sw_if_index_set == 0)
8688 errmsg ("missing interface name or sw_if_index");
8691 if (v4_address_set && v6_address_set)
8693 errmsg ("both v4 and v6 addresses set");
8696 if (!v4_address_set && !v6_address_set)
8698 errmsg ("no address set");
8702 /* Construct the API message */
8703 M (IP_NEIGHBOR_ADD_DEL, mp);
8705 mp->sw_if_index = ntohl (sw_if_index);
8706 mp->is_add = is_add;
8707 mp->is_static = is_static;
8708 mp->is_no_adj_fib = is_no_fib_entry;
8710 clib_memcpy (mp->mac_address, mac_address, 6);
8714 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
8718 /* mp->is_ipv6 = 0; via memset in M macro above */
8719 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
8725 /* Wait for a reply, return good/bad news */
8731 api_reset_vrf (vat_main_t * vam)
8733 unformat_input_t *i = vam->input;
8734 vl_api_reset_vrf_t *mp;
8740 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8742 if (unformat (i, "vrf %d", &vrf_id))
8744 else if (unformat (i, "ipv6"))
8748 clib_warning ("parse error '%U'", format_unformat_error, i);
8753 if (vrf_id_set == 0)
8755 errmsg ("missing vrf id");
8761 mp->vrf_id = ntohl (vrf_id);
8762 mp->is_ipv6 = is_ipv6;
8770 api_create_vlan_subif (vat_main_t * vam)
8772 unformat_input_t *i = vam->input;
8773 vl_api_create_vlan_subif_t *mp;
8775 u8 sw_if_index_set = 0;
8780 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8782 if (unformat (i, "sw_if_index %d", &sw_if_index))
8783 sw_if_index_set = 1;
8785 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8786 sw_if_index_set = 1;
8787 else if (unformat (i, "vlan %d", &vlan_id))
8791 clib_warning ("parse error '%U'", format_unformat_error, i);
8796 if (sw_if_index_set == 0)
8798 errmsg ("missing interface name or sw_if_index");
8802 if (vlan_id_set == 0)
8804 errmsg ("missing vlan_id");
8807 M (CREATE_VLAN_SUBIF, mp);
8809 mp->sw_if_index = ntohl (sw_if_index);
8810 mp->vlan_id = ntohl (vlan_id);
8817 #define foreach_create_subif_bit \
8824 _(outer_vlan_id_any) \
8825 _(inner_vlan_id_any)
8828 api_create_subif (vat_main_t * vam)
8830 unformat_input_t *i = vam->input;
8831 vl_api_create_subif_t *mp;
8833 u8 sw_if_index_set = 0;
8840 u32 exact_match = 0;
8841 u32 default_sub = 0;
8842 u32 outer_vlan_id_any = 0;
8843 u32 inner_vlan_id_any = 0;
8845 u16 outer_vlan_id = 0;
8846 u16 inner_vlan_id = 0;
8849 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8851 if (unformat (i, "sw_if_index %d", &sw_if_index))
8852 sw_if_index_set = 1;
8854 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8855 sw_if_index_set = 1;
8856 else if (unformat (i, "sub_id %d", &sub_id))
8858 else if (unformat (i, "outer_vlan_id %d", &tmp))
8859 outer_vlan_id = tmp;
8860 else if (unformat (i, "inner_vlan_id %d", &tmp))
8861 inner_vlan_id = tmp;
8863 #define _(a) else if (unformat (i, #a)) a = 1 ;
8864 foreach_create_subif_bit
8868 clib_warning ("parse error '%U'", format_unformat_error, i);
8873 if (sw_if_index_set == 0)
8875 errmsg ("missing interface name or sw_if_index");
8879 if (sub_id_set == 0)
8881 errmsg ("missing sub_id");
8884 M (CREATE_SUBIF, mp);
8886 mp->sw_if_index = ntohl (sw_if_index);
8887 mp->sub_id = ntohl (sub_id);
8889 #define _(a) mp->a = a;
8890 foreach_create_subif_bit;
8893 mp->outer_vlan_id = ntohs (outer_vlan_id);
8894 mp->inner_vlan_id = ntohs (inner_vlan_id);
8902 api_oam_add_del (vat_main_t * vam)
8904 unformat_input_t *i = vam->input;
8905 vl_api_oam_add_del_t *mp;
8908 ip4_address_t src, dst;
8913 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8915 if (unformat (i, "vrf %d", &vrf_id))
8917 else if (unformat (i, "src %U", unformat_ip4_address, &src))
8919 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
8921 else if (unformat (i, "del"))
8925 clib_warning ("parse error '%U'", format_unformat_error, i);
8932 errmsg ("missing src addr");
8938 errmsg ("missing dst addr");
8942 M (OAM_ADD_DEL, mp);
8944 mp->vrf_id = ntohl (vrf_id);
8945 mp->is_add = is_add;
8946 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
8947 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
8955 api_reset_fib (vat_main_t * vam)
8957 unformat_input_t *i = vam->input;
8958 vl_api_reset_fib_t *mp;
8964 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8966 if (unformat (i, "vrf %d", &vrf_id))
8968 else if (unformat (i, "ipv6"))
8972 clib_warning ("parse error '%U'", format_unformat_error, i);
8977 if (vrf_id_set == 0)
8979 errmsg ("missing vrf id");
8985 mp->vrf_id = ntohl (vrf_id);
8986 mp->is_ipv6 = is_ipv6;
8994 api_dhcp_proxy_config (vat_main_t * vam)
8996 unformat_input_t *i = vam->input;
8997 vl_api_dhcp_proxy_config_t *mp;
8999 u32 server_vrf_id = 0;
9001 u8 v4_address_set = 0;
9002 u8 v6_address_set = 0;
9003 ip4_address_t v4address;
9004 ip6_address_t v6address;
9005 u8 v4_src_address_set = 0;
9006 u8 v6_src_address_set = 0;
9007 ip4_address_t v4srcaddress;
9008 ip6_address_t v6srcaddress;
9011 /* Parse args required to build the message */
9012 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9014 if (unformat (i, "del"))
9016 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9018 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9020 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9022 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9024 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9025 v4_src_address_set = 1;
9026 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9027 v6_src_address_set = 1;
9032 if (v4_address_set && v6_address_set)
9034 errmsg ("both v4 and v6 server addresses set");
9037 if (!v4_address_set && !v6_address_set)
9039 errmsg ("no server addresses set");
9043 if (v4_src_address_set && v6_src_address_set)
9045 errmsg ("both v4 and v6 src addresses set");
9048 if (!v4_src_address_set && !v6_src_address_set)
9050 errmsg ("no src addresses set");
9054 if (!(v4_src_address_set && v4_address_set) &&
9055 !(v6_src_address_set && v6_address_set))
9057 errmsg ("no matching server and src addresses set");
9061 /* Construct the API message */
9062 M (DHCP_PROXY_CONFIG, mp);
9064 mp->is_add = is_add;
9065 mp->rx_vrf_id = ntohl (rx_vrf_id);
9066 mp->server_vrf_id = ntohl (server_vrf_id);
9070 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9071 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9075 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9076 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9082 /* Wait for a reply, return good/bad news */
9087 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9088 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9091 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9093 vat_main_t *vam = &vat_main;
9094 u32 i, count = mp->count;
9095 vl_api_dhcp_server_t *s;
9099 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
9100 ntohl (mp->rx_vrf_id),
9101 format_ip6_address, mp->dhcp_src_address,
9102 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9105 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
9106 ntohl (mp->rx_vrf_id),
9107 format_ip4_address, mp->dhcp_src_address,
9108 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9110 for (i = 0; i < count; i++)
9112 s = &mp->servers[i];
9116 " Server Table-ID %d, Server Address %U",
9117 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9120 " Server Table-ID %d, Server Address %U",
9121 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9125 static void vl_api_dhcp_proxy_details_t_handler_json
9126 (vl_api_dhcp_proxy_details_t * mp)
9128 vat_main_t *vam = &vat_main;
9129 vat_json_node_t *node = NULL;
9130 u32 i, count = mp->count;
9132 struct in6_addr ip6;
9133 vl_api_dhcp_server_t *s;
9135 if (VAT_JSON_ARRAY != vam->json_tree.type)
9137 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9138 vat_json_init_array (&vam->json_tree);
9140 node = vat_json_array_add (&vam->json_tree);
9142 vat_json_init_object (node);
9143 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9144 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9145 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9149 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9150 vat_json_object_add_ip6 (node, "src_address", ip6);
9154 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9155 vat_json_object_add_ip4 (node, "src_address", ip4);
9158 for (i = 0; i < count; i++)
9160 s = &mp->servers[i];
9162 vat_json_object_add_uint (node, "server-table-id",
9163 ntohl (s->server_vrf_id));
9167 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9168 vat_json_object_add_ip4 (node, "src_address", ip4);
9172 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9173 vat_json_object_add_ip6 (node, "server_address", ip6);
9179 api_dhcp_proxy_dump (vat_main_t * vam)
9181 unformat_input_t *i = vam->input;
9182 vl_api_control_ping_t *mp_ping;
9183 vl_api_dhcp_proxy_dump_t *mp;
9187 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9189 if (unformat (i, "ipv6"))
9193 clib_warning ("parse error '%U'", format_unformat_error, i);
9198 M (DHCP_PROXY_DUMP, mp);
9200 mp->is_ip6 = is_ipv6;
9203 /* Use a control ping for synchronization */
9204 MPING (CONTROL_PING, mp_ping);
9212 api_dhcp_proxy_set_vss (vat_main_t * vam)
9214 unformat_input_t *i = vam->input;
9215 vl_api_dhcp_proxy_set_vss_t *mp;
9226 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9228 if (unformat (i, "tbl_id %d", &tbl_id))
9230 if (unformat (i, "fib_id %d", &fib_id))
9232 if (unformat (i, "oui %d", &oui))
9234 else if (unformat (i, "ipv6"))
9236 else if (unformat (i, "del"))
9240 clib_warning ("parse error '%U'", format_unformat_error, i);
9245 if (tbl_id_set == 0)
9247 errmsg ("missing tbl id");
9251 if (fib_id_set == 0)
9253 errmsg ("missing fib id");
9258 errmsg ("missing oui");
9262 M (DHCP_PROXY_SET_VSS, mp);
9263 mp->tbl_id = ntohl (tbl_id);
9264 mp->fib_id = ntohl (fib_id);
9265 mp->oui = ntohl (oui);
9266 mp->is_ipv6 = is_ipv6;
9267 mp->is_add = is_add;
9275 api_dhcp_client_config (vat_main_t * vam)
9277 unformat_input_t *i = vam->input;
9278 vl_api_dhcp_client_config_t *mp;
9280 u8 sw_if_index_set = 0;
9283 u8 disable_event = 0;
9286 /* Parse args required to build the message */
9287 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9289 if (unformat (i, "del"))
9292 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9293 sw_if_index_set = 1;
9294 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9295 sw_if_index_set = 1;
9296 else if (unformat (i, "hostname %s", &hostname))
9298 else if (unformat (i, "disable_event"))
9304 if (sw_if_index_set == 0)
9306 errmsg ("missing interface name or sw_if_index");
9310 if (vec_len (hostname) > 63)
9312 errmsg ("hostname too long");
9314 vec_add1 (hostname, 0);
9316 /* Construct the API message */
9317 M (DHCP_CLIENT_CONFIG, mp);
9319 mp->sw_if_index = htonl (sw_if_index);
9320 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
9321 vec_free (hostname);
9322 mp->is_add = is_add;
9323 mp->want_dhcp_event = disable_event ? 0 : 1;
9324 mp->pid = htonl (getpid ());
9329 /* Wait for a reply, return good/bad news */
9335 api_set_ip_flow_hash (vat_main_t * vam)
9337 unformat_input_t *i = vam->input;
9338 vl_api_set_ip_flow_hash_t *mp;
9350 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9352 if (unformat (i, "vrf %d", &vrf_id))
9354 else if (unformat (i, "ipv6"))
9356 else if (unformat (i, "src"))
9358 else if (unformat (i, "dst"))
9360 else if (unformat (i, "sport"))
9362 else if (unformat (i, "dport"))
9364 else if (unformat (i, "proto"))
9366 else if (unformat (i, "reverse"))
9371 clib_warning ("parse error '%U'", format_unformat_error, i);
9376 if (vrf_id_set == 0)
9378 errmsg ("missing vrf id");
9382 M (SET_IP_FLOW_HASH, mp);
9388 mp->reverse = reverse;
9389 mp->vrf_id = ntohl (vrf_id);
9390 mp->is_ipv6 = is_ipv6;
9398 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9400 unformat_input_t *i = vam->input;
9401 vl_api_sw_interface_ip6_enable_disable_t *mp;
9403 u8 sw_if_index_set = 0;
9407 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9409 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9410 sw_if_index_set = 1;
9411 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9412 sw_if_index_set = 1;
9413 else if (unformat (i, "enable"))
9415 else if (unformat (i, "disable"))
9419 clib_warning ("parse error '%U'", format_unformat_error, i);
9424 if (sw_if_index_set == 0)
9426 errmsg ("missing interface name or sw_if_index");
9430 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9432 mp->sw_if_index = ntohl (sw_if_index);
9433 mp->enable = enable;
9441 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
9443 unformat_input_t *i = vam->input;
9444 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
9446 u8 sw_if_index_set = 0;
9447 u8 v6_address_set = 0;
9448 ip6_address_t v6address;
9451 /* Parse args required to build the message */
9452 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9454 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9455 sw_if_index_set = 1;
9456 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9457 sw_if_index_set = 1;
9458 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9464 if (sw_if_index_set == 0)
9466 errmsg ("missing interface name or sw_if_index");
9469 if (!v6_address_set)
9471 errmsg ("no address set");
9475 /* Construct the API message */
9476 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
9478 mp->sw_if_index = ntohl (sw_if_index);
9479 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9484 /* Wait for a reply, return good/bad news */
9490 api_ip6nd_proxy_add_del (vat_main_t * vam)
9492 unformat_input_t *i = vam->input;
9493 vl_api_ip6nd_proxy_add_del_t *mp;
9494 u32 sw_if_index = ~0;
9495 u8 v6_address_set = 0;
9496 ip6_address_t v6address;
9500 /* Parse args required to build the message */
9501 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9503 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9505 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9507 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9509 if (unformat (i, "del"))
9513 clib_warning ("parse error '%U'", format_unformat_error, i);
9518 if (sw_if_index == ~0)
9520 errmsg ("missing interface name or sw_if_index");
9523 if (!v6_address_set)
9525 errmsg ("no address set");
9529 /* Construct the API message */
9530 M (IP6ND_PROXY_ADD_DEL, mp);
9532 mp->is_del = is_del;
9533 mp->sw_if_index = ntohl (sw_if_index);
9534 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9539 /* Wait for a reply, return good/bad news */
9545 api_ip6nd_proxy_dump (vat_main_t * vam)
9547 vl_api_ip6nd_proxy_dump_t *mp;
9548 vl_api_control_ping_t *mp_ping;
9551 M (IP6ND_PROXY_DUMP, mp);
9555 /* Use a control ping for synchronization */
9556 MPING (CONTROL_PING, mp_ping);
9563 static void vl_api_ip6nd_proxy_details_t_handler
9564 (vl_api_ip6nd_proxy_details_t * mp)
9566 vat_main_t *vam = &vat_main;
9568 print (vam->ofp, "host %U sw_if_index %d",
9569 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
9572 static void vl_api_ip6nd_proxy_details_t_handler_json
9573 (vl_api_ip6nd_proxy_details_t * mp)
9575 vat_main_t *vam = &vat_main;
9576 struct in6_addr ip6;
9577 vat_json_node_t *node = NULL;
9579 if (VAT_JSON_ARRAY != vam->json_tree.type)
9581 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9582 vat_json_init_array (&vam->json_tree);
9584 node = vat_json_array_add (&vam->json_tree);
9586 vat_json_init_object (node);
9587 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9589 clib_memcpy (&ip6, mp->address, sizeof (ip6));
9590 vat_json_object_add_ip6 (node, "host", ip6);
9594 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9596 unformat_input_t *i = vam->input;
9597 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9599 u8 sw_if_index_set = 0;
9600 u32 address_length = 0;
9601 u8 v6_address_set = 0;
9602 ip6_address_t v6address;
9604 u8 no_advertise = 0;
9606 u8 no_autoconfig = 0;
9609 u32 val_lifetime = 0;
9610 u32 pref_lifetime = 0;
9613 /* Parse args required to build the message */
9614 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9616 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9617 sw_if_index_set = 1;
9618 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9619 sw_if_index_set = 1;
9620 else if (unformat (i, "%U/%d",
9621 unformat_ip6_address, &v6address, &address_length))
9623 else if (unformat (i, "val_life %d", &val_lifetime))
9625 else if (unformat (i, "pref_life %d", &pref_lifetime))
9627 else if (unformat (i, "def"))
9629 else if (unformat (i, "noadv"))
9631 else if (unformat (i, "offl"))
9633 else if (unformat (i, "noauto"))
9635 else if (unformat (i, "nolink"))
9637 else if (unformat (i, "isno"))
9641 clib_warning ("parse error '%U'", format_unformat_error, i);
9646 if (sw_if_index_set == 0)
9648 errmsg ("missing interface name or sw_if_index");
9651 if (!v6_address_set)
9653 errmsg ("no address set");
9657 /* Construct the API message */
9658 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9660 mp->sw_if_index = ntohl (sw_if_index);
9661 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9662 mp->address_length = address_length;
9663 mp->use_default = use_default;
9664 mp->no_advertise = no_advertise;
9665 mp->off_link = off_link;
9666 mp->no_autoconfig = no_autoconfig;
9667 mp->no_onlink = no_onlink;
9669 mp->val_lifetime = ntohl (val_lifetime);
9670 mp->pref_lifetime = ntohl (pref_lifetime);
9675 /* Wait for a reply, return good/bad news */
9681 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9683 unformat_input_t *i = vam->input;
9684 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9686 u8 sw_if_index_set = 0;
9691 u8 send_unicast = 0;
9694 u8 default_router = 0;
9695 u32 max_interval = 0;
9696 u32 min_interval = 0;
9698 u32 initial_count = 0;
9699 u32 initial_interval = 0;
9703 /* Parse args required to build the message */
9704 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9706 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9707 sw_if_index_set = 1;
9708 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9709 sw_if_index_set = 1;
9710 else if (unformat (i, "maxint %d", &max_interval))
9712 else if (unformat (i, "minint %d", &min_interval))
9714 else if (unformat (i, "life %d", &lifetime))
9716 else if (unformat (i, "count %d", &initial_count))
9718 else if (unformat (i, "interval %d", &initial_interval))
9720 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9722 else if (unformat (i, "managed"))
9724 else if (unformat (i, "other"))
9726 else if (unformat (i, "ll"))
9728 else if (unformat (i, "send"))
9730 else if (unformat (i, "cease"))
9732 else if (unformat (i, "isno"))
9734 else if (unformat (i, "def"))
9738 clib_warning ("parse error '%U'", format_unformat_error, i);
9743 if (sw_if_index_set == 0)
9745 errmsg ("missing interface name or sw_if_index");
9749 /* Construct the API message */
9750 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9752 mp->sw_if_index = ntohl (sw_if_index);
9753 mp->max_interval = ntohl (max_interval);
9754 mp->min_interval = ntohl (min_interval);
9755 mp->lifetime = ntohl (lifetime);
9756 mp->initial_count = ntohl (initial_count);
9757 mp->initial_interval = ntohl (initial_interval);
9758 mp->suppress = suppress;
9759 mp->managed = managed;
9761 mp->ll_option = ll_option;
9762 mp->send_unicast = send_unicast;
9765 mp->default_router = default_router;
9770 /* Wait for a reply, return good/bad news */
9776 api_set_arp_neighbor_limit (vat_main_t * vam)
9778 unformat_input_t *i = vam->input;
9779 vl_api_set_arp_neighbor_limit_t *mp;
9785 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9787 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9789 else if (unformat (i, "ipv6"))
9793 clib_warning ("parse error '%U'", format_unformat_error, i);
9800 errmsg ("missing limit value");
9804 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9806 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9807 mp->is_ipv6 = is_ipv6;
9815 api_l2_patch_add_del (vat_main_t * vam)
9817 unformat_input_t *i = vam->input;
9818 vl_api_l2_patch_add_del_t *mp;
9820 u8 rx_sw_if_index_set = 0;
9822 u8 tx_sw_if_index_set = 0;
9826 /* Parse args required to build the message */
9827 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9829 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9830 rx_sw_if_index_set = 1;
9831 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9832 tx_sw_if_index_set = 1;
9833 else if (unformat (i, "rx"))
9835 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9837 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9839 rx_sw_if_index_set = 1;
9844 else if (unformat (i, "tx"))
9846 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9848 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9850 tx_sw_if_index_set = 1;
9855 else if (unformat (i, "del"))
9861 if (rx_sw_if_index_set == 0)
9863 errmsg ("missing rx interface name or rx_sw_if_index");
9867 if (tx_sw_if_index_set == 0)
9869 errmsg ("missing tx interface name or tx_sw_if_index");
9873 M (L2_PATCH_ADD_DEL, mp);
9875 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9876 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9877 mp->is_add = is_add;
9885 u8 localsid_addr[16];
9894 api_sr_localsid_add_del (vat_main_t * vam)
9896 unformat_input_t *i = vam->input;
9897 vl_api_sr_localsid_add_del_t *mp;
9900 ip6_address_t localsid;
9904 u32 fib_table = ~(u32) 0;
9905 ip6_address_t next_hop;
9907 bool nexthop_set = 0;
9911 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9913 if (unformat (i, "del"))
9915 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9916 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
9918 else if (unformat (i, "behavior %u", &behavior));
9919 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9920 else if (unformat (i, "fib-table %u", &fib_table));
9921 else if (unformat (i, "end.psp %u", &behavior));
9926 M (SR_LOCALSID_ADD_DEL, mp);
9928 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
9930 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
9931 mp->behavior = behavior;
9932 mp->sw_if_index = ntohl (sw_if_index);
9933 mp->fib_table = ntohl (fib_table);
9934 mp->end_psp = end_psp;
9935 mp->is_del = is_del;
9943 api_ioam_enable (vat_main_t * vam)
9945 unformat_input_t *input = vam->input;
9946 vl_api_ioam_enable_t *mp;
9948 int has_trace_option = 0;
9949 int has_pot_option = 0;
9950 int has_seqno_option = 0;
9951 int has_analyse_option = 0;
9954 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9956 if (unformat (input, "trace"))
9957 has_trace_option = 1;
9958 else if (unformat (input, "pot"))
9960 else if (unformat (input, "seqno"))
9961 has_seqno_option = 1;
9962 else if (unformat (input, "analyse"))
9963 has_analyse_option = 1;
9967 M (IOAM_ENABLE, mp);
9968 mp->id = htons (id);
9969 mp->seqno = has_seqno_option;
9970 mp->analyse = has_analyse_option;
9971 mp->pot_enable = has_pot_option;
9972 mp->trace_enable = has_trace_option;
9981 api_ioam_disable (vat_main_t * vam)
9983 vl_api_ioam_disable_t *mp;
9986 M (IOAM_DISABLE, mp);
9992 #define foreach_tcp_proto_field \
9996 #define foreach_udp_proto_field \
10000 #define foreach_ip4_proto_field \
10012 u16 src_port, dst_port;
10015 #if VPP_API_TEST_BUILTIN == 0
10017 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10019 u8 **maskp = va_arg (*args, u8 **);
10021 u8 found_something = 0;
10024 #define _(a) u8 a=0;
10025 foreach_tcp_proto_field;
10028 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10031 #define _(a) else if (unformat (input, #a)) a=1;
10032 foreach_tcp_proto_field
10038 #define _(a) found_something += a;
10039 foreach_tcp_proto_field;
10042 if (found_something == 0)
10045 vec_validate (mask, sizeof (*tcp) - 1);
10047 tcp = (tcp_header_t *) mask;
10049 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
10050 foreach_tcp_proto_field;
10058 unformat_udp_mask (unformat_input_t * input, va_list * args)
10060 u8 **maskp = va_arg (*args, u8 **);
10062 u8 found_something = 0;
10065 #define _(a) u8 a=0;
10066 foreach_udp_proto_field;
10069 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10072 #define _(a) else if (unformat (input, #a)) a=1;
10073 foreach_udp_proto_field
10079 #define _(a) found_something += a;
10080 foreach_udp_proto_field;
10083 if (found_something == 0)
10086 vec_validate (mask, sizeof (*udp) - 1);
10088 udp = (udp_header_t *) mask;
10090 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
10091 foreach_udp_proto_field;
10099 unformat_l4_mask (unformat_input_t * input, va_list * args)
10101 u8 **maskp = va_arg (*args, u8 **);
10102 u16 src_port = 0, dst_port = 0;
10103 tcpudp_header_t *tcpudp;
10105 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10107 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10109 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10111 else if (unformat (input, "src_port"))
10113 else if (unformat (input, "dst_port"))
10119 if (!src_port && !dst_port)
10123 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10125 tcpudp = (tcpudp_header_t *) mask;
10126 tcpudp->src_port = src_port;
10127 tcpudp->dst_port = dst_port;
10135 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10137 u8 **maskp = va_arg (*args, u8 **);
10139 u8 found_something = 0;
10142 #define _(a) u8 a=0;
10143 foreach_ip4_proto_field;
10149 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10151 if (unformat (input, "version"))
10153 else if (unformat (input, "hdr_length"))
10155 else if (unformat (input, "src"))
10157 else if (unformat (input, "dst"))
10159 else if (unformat (input, "proto"))
10162 #define _(a) else if (unformat (input, #a)) a=1;
10163 foreach_ip4_proto_field
10169 #define _(a) found_something += a;
10170 foreach_ip4_proto_field;
10173 if (found_something == 0)
10176 vec_validate (mask, sizeof (*ip) - 1);
10178 ip = (ip4_header_t *) mask;
10180 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10181 foreach_ip4_proto_field;
10184 ip->ip_version_and_header_length = 0;
10187 ip->ip_version_and_header_length |= 0xF0;
10190 ip->ip_version_and_header_length |= 0x0F;
10196 #define foreach_ip6_proto_field \
10199 _(payload_length) \
10204 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10206 u8 **maskp = va_arg (*args, u8 **);
10208 u8 found_something = 0;
10210 u32 ip_version_traffic_class_and_flow_label;
10212 #define _(a) u8 a=0;
10213 foreach_ip6_proto_field;
10216 u8 traffic_class = 0;
10219 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10221 if (unformat (input, "version"))
10223 else if (unformat (input, "traffic-class"))
10225 else if (unformat (input, "flow-label"))
10227 else if (unformat (input, "src"))
10229 else if (unformat (input, "dst"))
10231 else if (unformat (input, "proto"))
10234 #define _(a) else if (unformat (input, #a)) a=1;
10235 foreach_ip6_proto_field
10241 #define _(a) found_something += a;
10242 foreach_ip6_proto_field;
10245 if (found_something == 0)
10248 vec_validate (mask, sizeof (*ip) - 1);
10250 ip = (ip6_header_t *) mask;
10252 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10253 foreach_ip6_proto_field;
10256 ip_version_traffic_class_and_flow_label = 0;
10259 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10262 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10265 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10267 ip->ip_version_traffic_class_and_flow_label =
10268 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10275 unformat_l3_mask (unformat_input_t * input, va_list * args)
10277 u8 **maskp = va_arg (*args, u8 **);
10279 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10281 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10283 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10292 unformat_l2_mask (unformat_input_t * input, va_list * args)
10294 u8 **maskp = va_arg (*args, u8 **);
10301 u8 ignore_tag1 = 0;
10302 u8 ignore_tag2 = 0;
10309 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10311 if (unformat (input, "src"))
10313 else if (unformat (input, "dst"))
10315 else if (unformat (input, "proto"))
10317 else if (unformat (input, "tag1"))
10319 else if (unformat (input, "tag2"))
10321 else if (unformat (input, "ignore-tag1"))
10323 else if (unformat (input, "ignore-tag2"))
10325 else if (unformat (input, "cos1"))
10327 else if (unformat (input, "cos2"))
10329 else if (unformat (input, "dot1q"))
10331 else if (unformat (input, "dot1ad"))
10336 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10337 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10340 if (tag1 || ignore_tag1 || cos1 || dot1q)
10342 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10345 vec_validate (mask, len - 1);
10348 memset (mask, 0xff, 6);
10351 memset (mask + 6, 0xff, 6);
10353 if (tag2 || dot1ad)
10355 /* inner vlan tag */
10364 mask[21] = mask[20] = 0xff;
10385 mask[16] = mask[17] = 0xff;
10395 mask[12] = mask[13] = 0xff;
10402 unformat_classify_mask (unformat_input_t * input, va_list * args)
10404 u8 **maskp = va_arg (*args, u8 **);
10405 u32 *skipp = va_arg (*args, u32 *);
10406 u32 *matchp = va_arg (*args, u32 *);
10414 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10416 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10418 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10420 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10422 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10436 if (mask || l2 || l3 || l4)
10438 if (l2 || l3 || l4)
10440 /* "With a free Ethernet header in every package" */
10442 vec_validate (l2, 13);
10446 vec_append (mask, l3);
10451 vec_append (mask, l4);
10456 /* Scan forward looking for the first significant mask octet */
10457 for (i = 0; i < vec_len (mask); i++)
10461 /* compute (skip, match) params */
10462 *skipp = i / sizeof (u32x4);
10463 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10465 /* Pad mask to an even multiple of the vector size */
10466 while (vec_len (mask) % sizeof (u32x4))
10467 vec_add1 (mask, 0);
10469 match = vec_len (mask) / sizeof (u32x4);
10471 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10473 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10474 if (*tmp || *(tmp + 1))
10479 clib_warning ("BUG: match 0");
10481 _vec_len (mask) = match * sizeof (u32x4);
10491 #endif /* VPP_API_TEST_BUILTIN */
10493 #define foreach_l2_next \
10495 _(ethernet, ETHERNET_INPUT) \
10496 _(ip4, IP4_INPUT) \
10500 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10502 u32 *miss_next_indexp = va_arg (*args, u32 *);
10503 u32 next_index = 0;
10507 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10511 if (unformat (input, "%d", &tmp))
10520 *miss_next_indexp = next_index;
10524 #define foreach_ip_next \
10527 _(rewrite, REWRITE)
10530 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10532 u32 *miss_next_indexp = va_arg (*args, u32 *);
10533 u32 next_index = 0;
10537 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10541 if (unformat (input, "%d", &tmp))
10550 *miss_next_indexp = next_index;
10554 #define foreach_acl_next \
10558 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10560 u32 *miss_next_indexp = va_arg (*args, u32 *);
10561 u32 next_index = 0;
10565 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10569 if (unformat (input, "permit"))
10574 else if (unformat (input, "%d", &tmp))
10583 *miss_next_indexp = next_index;
10588 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10590 u32 *r = va_arg (*args, u32 *);
10592 if (unformat (input, "conform-color"))
10593 *r = POLICE_CONFORM;
10594 else if (unformat (input, "exceed-color"))
10595 *r = POLICE_EXCEED;
10603 api_classify_add_del_table (vat_main_t * vam)
10605 unformat_input_t *i = vam->input;
10606 vl_api_classify_add_del_table_t *mp;
10613 u32 table_index = ~0;
10614 u32 next_table_index = ~0;
10615 u32 miss_next_index = ~0;
10616 u32 memory_size = 32 << 20;
10618 u32 current_data_flag = 0;
10619 int current_data_offset = 0;
10622 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10624 if (unformat (i, "del"))
10626 else if (unformat (i, "del-chain"))
10631 else if (unformat (i, "buckets %d", &nbuckets))
10633 else if (unformat (i, "memory_size %d", &memory_size))
10635 else if (unformat (i, "skip %d", &skip))
10637 else if (unformat (i, "match %d", &match))
10639 else if (unformat (i, "table %d", &table_index))
10641 else if (unformat (i, "mask %U", unformat_classify_mask,
10642 &mask, &skip, &match))
10644 else if (unformat (i, "next-table %d", &next_table_index))
10646 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10649 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10652 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10655 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10657 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10663 if (is_add && mask == 0)
10665 errmsg ("Mask required");
10669 if (is_add && skip == ~0)
10671 errmsg ("skip count required");
10675 if (is_add && match == ~0)
10677 errmsg ("match count required");
10681 if (!is_add && table_index == ~0)
10683 errmsg ("table index required for delete");
10687 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10689 mp->is_add = is_add;
10690 mp->del_chain = del_chain;
10691 mp->table_index = ntohl (table_index);
10692 mp->nbuckets = ntohl (nbuckets);
10693 mp->memory_size = ntohl (memory_size);
10694 mp->skip_n_vectors = ntohl (skip);
10695 mp->match_n_vectors = ntohl (match);
10696 mp->next_table_index = ntohl (next_table_index);
10697 mp->miss_next_index = ntohl (miss_next_index);
10698 mp->current_data_flag = ntohl (current_data_flag);
10699 mp->current_data_offset = ntohl (current_data_offset);
10700 clib_memcpy (mp->mask, mask, vec_len (mask));
10709 #if VPP_API_TEST_BUILTIN == 0
10711 unformat_l4_match (unformat_input_t * input, va_list * args)
10713 u8 **matchp = va_arg (*args, u8 **);
10715 u8 *proto_header = 0;
10721 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10723 if (unformat (input, "src_port %d", &src_port))
10725 else if (unformat (input, "dst_port %d", &dst_port))
10731 h.src_port = clib_host_to_net_u16 (src_port);
10732 h.dst_port = clib_host_to_net_u16 (dst_port);
10733 vec_validate (proto_header, sizeof (h) - 1);
10734 memcpy (proto_header, &h, sizeof (h));
10736 *matchp = proto_header;
10742 unformat_ip4_match (unformat_input_t * input, va_list * args)
10744 u8 **matchp = va_arg (*args, u8 **);
10749 int hdr_length = 0;
10750 u32 hdr_length_val;
10751 int src = 0, dst = 0;
10752 ip4_address_t src_val, dst_val;
10759 int fragment_id = 0;
10760 u32 fragment_id_val;
10766 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10768 if (unformat (input, "version %d", &version_val))
10770 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10772 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10774 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10776 else if (unformat (input, "proto %d", &proto_val))
10778 else if (unformat (input, "tos %d", &tos_val))
10780 else if (unformat (input, "length %d", &length_val))
10782 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10784 else if (unformat (input, "ttl %d", &ttl_val))
10786 else if (unformat (input, "checksum %d", &checksum_val))
10792 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10793 + ttl + checksum == 0)
10797 * Aligned because we use the real comparison functions
10799 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10801 ip = (ip4_header_t *) match;
10803 /* These are realistically matched in practice */
10805 ip->src_address.as_u32 = src_val.as_u32;
10808 ip->dst_address.as_u32 = dst_val.as_u32;
10811 ip->protocol = proto_val;
10814 /* These are not, but they're included for completeness */
10816 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10819 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10825 ip->length = clib_host_to_net_u16 (length_val);
10831 ip->checksum = clib_host_to_net_u16 (checksum_val);
10838 unformat_ip6_match (unformat_input_t * input, va_list * args)
10840 u8 **matchp = va_arg (*args, u8 **);
10845 u8 traffic_class = 0;
10846 u32 traffic_class_val = 0;
10849 int src = 0, dst = 0;
10850 ip6_address_t src_val, dst_val;
10853 int payload_length = 0;
10854 u32 payload_length_val;
10857 u32 ip_version_traffic_class_and_flow_label;
10859 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10861 if (unformat (input, "version %d", &version_val))
10863 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10865 else if (unformat (input, "flow_label %d", &flow_label_val))
10867 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10869 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10871 else if (unformat (input, "proto %d", &proto_val))
10873 else if (unformat (input, "payload_length %d", &payload_length_val))
10874 payload_length = 1;
10875 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10881 if (version + traffic_class + flow_label + src + dst + proto +
10882 payload_length + hop_limit == 0)
10886 * Aligned because we use the real comparison functions
10888 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10890 ip = (ip6_header_t *) match;
10893 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10896 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10899 ip->protocol = proto_val;
10901 ip_version_traffic_class_and_flow_label = 0;
10904 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10907 ip_version_traffic_class_and_flow_label |=
10908 (traffic_class_val & 0xFF) << 20;
10911 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10913 ip->ip_version_traffic_class_and_flow_label =
10914 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10916 if (payload_length)
10917 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10920 ip->hop_limit = hop_limit_val;
10927 unformat_l3_match (unformat_input_t * input, va_list * args)
10929 u8 **matchp = va_arg (*args, u8 **);
10931 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10933 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10935 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10944 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10946 u8 *tagp = va_arg (*args, u8 *);
10949 if (unformat (input, "%d", &tag))
10951 tagp[0] = (tag >> 8) & 0x0F;
10952 tagp[1] = tag & 0xFF;
10960 unformat_l2_match (unformat_input_t * input, va_list * args)
10962 u8 **matchp = va_arg (*args, u8 **);
10975 u8 ignore_tag1 = 0;
10976 u8 ignore_tag2 = 0;
10982 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10984 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10987 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10989 else if (unformat (input, "proto %U",
10990 unformat_ethernet_type_host_byte_order, &proto_val))
10992 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10994 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10996 else if (unformat (input, "ignore-tag1"))
10998 else if (unformat (input, "ignore-tag2"))
11000 else if (unformat (input, "cos1 %d", &cos1_val))
11002 else if (unformat (input, "cos2 %d", &cos2_val))
11007 if ((src + dst + proto + tag1 + tag2 +
11008 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11011 if (tag1 || ignore_tag1 || cos1)
11013 if (tag2 || ignore_tag2 || cos2)
11016 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11019 clib_memcpy (match, dst_val, 6);
11022 clib_memcpy (match + 6, src_val, 6);
11026 /* inner vlan tag */
11027 match[19] = tag2_val[1];
11028 match[18] = tag2_val[0];
11030 match[18] |= (cos2_val & 0x7) << 5;
11033 match[21] = proto_val & 0xff;
11034 match[20] = proto_val >> 8;
11038 match[15] = tag1_val[1];
11039 match[14] = tag1_val[0];
11042 match[14] |= (cos1_val & 0x7) << 5;
11048 match[15] = tag1_val[1];
11049 match[14] = tag1_val[0];
11052 match[17] = proto_val & 0xff;
11053 match[16] = proto_val >> 8;
11056 match[14] |= (cos1_val & 0x7) << 5;
11062 match[18] |= (cos2_val & 0x7) << 5;
11064 match[14] |= (cos1_val & 0x7) << 5;
11067 match[13] = proto_val & 0xff;
11068 match[12] = proto_val >> 8;
11077 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11079 u8 **matchp = va_arg (*args, u8 **);
11080 u32 skip_n_vectors = va_arg (*args, u32);
11081 u32 match_n_vectors = va_arg (*args, u32);
11088 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11090 if (unformat (input, "hex %U", unformat_hex_string, &match))
11092 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11094 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11096 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11110 if (match || l2 || l3 || l4)
11112 if (l2 || l3 || l4)
11114 /* "Win a free Ethernet header in every packet" */
11116 vec_validate_aligned (l2, 13, sizeof (u32x4));
11120 vec_append_aligned (match, l3, sizeof (u32x4));
11125 vec_append_aligned (match, l4, sizeof (u32x4));
11130 /* Make sure the vector is big enough even if key is all 0's */
11131 vec_validate_aligned
11132 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11135 /* Set size, include skipped vectors */
11136 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11147 api_classify_add_del_session (vat_main_t * vam)
11149 unformat_input_t *i = vam->input;
11150 vl_api_classify_add_del_session_t *mp;
11152 u32 table_index = ~0;
11153 u32 hit_next_index = ~0;
11154 u32 opaque_index = ~0;
11157 u32 skip_n_vectors = 0;
11158 u32 match_n_vectors = 0;
11164 * Warning: you have to supply skip_n and match_n
11165 * because the API client cant simply look at the classify
11169 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11171 if (unformat (i, "del"))
11173 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11176 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11179 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11182 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11184 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11186 else if (unformat (i, "opaque-index %d", &opaque_index))
11188 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11190 else if (unformat (i, "match_n %d", &match_n_vectors))
11192 else if (unformat (i, "match %U", api_unformat_classify_match,
11193 &match, skip_n_vectors, match_n_vectors))
11195 else if (unformat (i, "advance %d", &advance))
11197 else if (unformat (i, "table-index %d", &table_index))
11199 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11201 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11203 else if (unformat (i, "action %d", &action))
11205 else if (unformat (i, "metadata %d", &metadata))
11211 if (table_index == ~0)
11213 errmsg ("Table index required");
11217 if (is_add && match == 0)
11219 errmsg ("Match value required");
11223 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11225 mp->is_add = is_add;
11226 mp->table_index = ntohl (table_index);
11227 mp->hit_next_index = ntohl (hit_next_index);
11228 mp->opaque_index = ntohl (opaque_index);
11229 mp->advance = ntohl (advance);
11230 mp->action = action;
11231 mp->metadata = ntohl (metadata);
11232 clib_memcpy (mp->match, match, vec_len (match));
11241 api_classify_set_interface_ip_table (vat_main_t * vam)
11243 unformat_input_t *i = vam->input;
11244 vl_api_classify_set_interface_ip_table_t *mp;
11246 int sw_if_index_set;
11247 u32 table_index = ~0;
11251 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11253 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11254 sw_if_index_set = 1;
11255 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11256 sw_if_index_set = 1;
11257 else if (unformat (i, "table %d", &table_index))
11261 clib_warning ("parse error '%U'", format_unformat_error, i);
11266 if (sw_if_index_set == 0)
11268 errmsg ("missing interface name or sw_if_index");
11273 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11275 mp->sw_if_index = ntohl (sw_if_index);
11276 mp->table_index = ntohl (table_index);
11277 mp->is_ipv6 = is_ipv6;
11285 api_classify_set_interface_l2_tables (vat_main_t * vam)
11287 unformat_input_t *i = vam->input;
11288 vl_api_classify_set_interface_l2_tables_t *mp;
11290 int sw_if_index_set;
11291 u32 ip4_table_index = ~0;
11292 u32 ip6_table_index = ~0;
11293 u32 other_table_index = ~0;
11297 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11299 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11300 sw_if_index_set = 1;
11301 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11302 sw_if_index_set = 1;
11303 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11305 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11307 else if (unformat (i, "other-table %d", &other_table_index))
11309 else if (unformat (i, "is-input %d", &is_input))
11313 clib_warning ("parse error '%U'", format_unformat_error, i);
11318 if (sw_if_index_set == 0)
11320 errmsg ("missing interface name or sw_if_index");
11325 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11327 mp->sw_if_index = ntohl (sw_if_index);
11328 mp->ip4_table_index = ntohl (ip4_table_index);
11329 mp->ip6_table_index = ntohl (ip6_table_index);
11330 mp->other_table_index = ntohl (other_table_index);
11331 mp->is_input = (u8) is_input;
11339 api_set_ipfix_exporter (vat_main_t * vam)
11341 unformat_input_t *i = vam->input;
11342 vl_api_set_ipfix_exporter_t *mp;
11343 ip4_address_t collector_address;
11344 u8 collector_address_set = 0;
11345 u32 collector_port = ~0;
11346 ip4_address_t src_address;
11347 u8 src_address_set = 0;
11350 u32 template_interval = ~0;
11351 u8 udp_checksum = 0;
11354 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11356 if (unformat (i, "collector_address %U", unformat_ip4_address,
11357 &collector_address))
11358 collector_address_set = 1;
11359 else if (unformat (i, "collector_port %d", &collector_port))
11361 else if (unformat (i, "src_address %U", unformat_ip4_address,
11363 src_address_set = 1;
11364 else if (unformat (i, "vrf_id %d", &vrf_id))
11366 else if (unformat (i, "path_mtu %d", &path_mtu))
11368 else if (unformat (i, "template_interval %d", &template_interval))
11370 else if (unformat (i, "udp_checksum"))
11376 if (collector_address_set == 0)
11378 errmsg ("collector_address required");
11382 if (src_address_set == 0)
11384 errmsg ("src_address required");
11388 M (SET_IPFIX_EXPORTER, mp);
11390 memcpy (mp->collector_address, collector_address.data,
11391 sizeof (collector_address.data));
11392 mp->collector_port = htons ((u16) collector_port);
11393 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11394 mp->vrf_id = htonl (vrf_id);
11395 mp->path_mtu = htonl (path_mtu);
11396 mp->template_interval = htonl (template_interval);
11397 mp->udp_checksum = udp_checksum;
11405 api_set_ipfix_classify_stream (vat_main_t * vam)
11407 unformat_input_t *i = vam->input;
11408 vl_api_set_ipfix_classify_stream_t *mp;
11410 u32 src_port = UDP_DST_PORT_ipfix;
11413 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11415 if (unformat (i, "domain %d", &domain_id))
11417 else if (unformat (i, "src_port %d", &src_port))
11421 errmsg ("unknown input `%U'", format_unformat_error, i);
11426 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11428 mp->domain_id = htonl (domain_id);
11429 mp->src_port = htons ((u16) src_port);
11437 api_ipfix_classify_table_add_del (vat_main_t * vam)
11439 unformat_input_t *i = vam->input;
11440 vl_api_ipfix_classify_table_add_del_t *mp;
11442 u32 classify_table_index = ~0;
11444 u8 transport_protocol = 255;
11447 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11449 if (unformat (i, "add"))
11451 else if (unformat (i, "del"))
11453 else if (unformat (i, "table %d", &classify_table_index))
11455 else if (unformat (i, "ip4"))
11457 else if (unformat (i, "ip6"))
11459 else if (unformat (i, "tcp"))
11460 transport_protocol = 6;
11461 else if (unformat (i, "udp"))
11462 transport_protocol = 17;
11465 errmsg ("unknown input `%U'", format_unformat_error, i);
11472 errmsg ("expecting: add|del");
11475 if (classify_table_index == ~0)
11477 errmsg ("classifier table not specified");
11480 if (ip_version == 0)
11482 errmsg ("IP version not specified");
11486 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11488 mp->is_add = is_add;
11489 mp->table_id = htonl (classify_table_index);
11490 mp->ip_version = ip_version;
11491 mp->transport_protocol = transport_protocol;
11499 api_get_node_index (vat_main_t * vam)
11501 unformat_input_t *i = vam->input;
11502 vl_api_get_node_index_t *mp;
11506 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11508 if (unformat (i, "node %s", &name))
11515 errmsg ("node name required");
11518 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11520 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11524 M (GET_NODE_INDEX, mp);
11525 clib_memcpy (mp->node_name, name, vec_len (name));
11534 api_get_next_index (vat_main_t * vam)
11536 unformat_input_t *i = vam->input;
11537 vl_api_get_next_index_t *mp;
11538 u8 *node_name = 0, *next_node_name = 0;
11541 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11543 if (unformat (i, "node-name %s", &node_name))
11545 else if (unformat (i, "next-node-name %s", &next_node_name))
11549 if (node_name == 0)
11551 errmsg ("node name required");
11554 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11556 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11560 if (next_node_name == 0)
11562 errmsg ("next node name required");
11565 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11567 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11571 M (GET_NEXT_INDEX, mp);
11572 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11573 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11574 vec_free (node_name);
11575 vec_free (next_node_name);
11583 api_add_node_next (vat_main_t * vam)
11585 unformat_input_t *i = vam->input;
11586 vl_api_add_node_next_t *mp;
11591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11593 if (unformat (i, "node %s", &name))
11595 else if (unformat (i, "next %s", &next))
11602 errmsg ("node name required");
11605 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11607 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11612 errmsg ("next node required");
11615 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11617 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11621 M (ADD_NODE_NEXT, mp);
11622 clib_memcpy (mp->node_name, name, vec_len (name));
11623 clib_memcpy (mp->next_name, next, vec_len (next));
11633 api_l2tpv3_create_tunnel (vat_main_t * vam)
11635 unformat_input_t *i = vam->input;
11636 ip6_address_t client_address, our_address;
11637 int client_address_set = 0;
11638 int our_address_set = 0;
11639 u32 local_session_id = 0;
11640 u32 remote_session_id = 0;
11641 u64 local_cookie = 0;
11642 u64 remote_cookie = 0;
11643 u8 l2_sublayer_present = 0;
11644 vl_api_l2tpv3_create_tunnel_t *mp;
11647 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11649 if (unformat (i, "client_address %U", unformat_ip6_address,
11651 client_address_set = 1;
11652 else if (unformat (i, "our_address %U", unformat_ip6_address,
11654 our_address_set = 1;
11655 else if (unformat (i, "local_session_id %d", &local_session_id))
11657 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11659 else if (unformat (i, "local_cookie %lld", &local_cookie))
11661 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11663 else if (unformat (i, "l2-sublayer-present"))
11664 l2_sublayer_present = 1;
11669 if (client_address_set == 0)
11671 errmsg ("client_address required");
11675 if (our_address_set == 0)
11677 errmsg ("our_address required");
11681 M (L2TPV3_CREATE_TUNNEL, mp);
11683 clib_memcpy (mp->client_address, client_address.as_u8,
11684 sizeof (mp->client_address));
11686 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11688 mp->local_session_id = ntohl (local_session_id);
11689 mp->remote_session_id = ntohl (remote_session_id);
11690 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11691 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11692 mp->l2_sublayer_present = l2_sublayer_present;
11701 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11703 unformat_input_t *i = vam->input;
11705 u8 sw_if_index_set = 0;
11706 u64 new_local_cookie = 0;
11707 u64 new_remote_cookie = 0;
11708 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11711 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11713 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11714 sw_if_index_set = 1;
11715 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11716 sw_if_index_set = 1;
11717 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11719 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11725 if (sw_if_index_set == 0)
11727 errmsg ("missing interface name or sw_if_index");
11731 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11733 mp->sw_if_index = ntohl (sw_if_index);
11734 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11735 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11743 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11745 unformat_input_t *i = vam->input;
11746 vl_api_l2tpv3_interface_enable_disable_t *mp;
11748 u8 sw_if_index_set = 0;
11749 u8 enable_disable = 1;
11752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11754 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11755 sw_if_index_set = 1;
11756 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11757 sw_if_index_set = 1;
11758 else if (unformat (i, "enable"))
11759 enable_disable = 1;
11760 else if (unformat (i, "disable"))
11761 enable_disable = 0;
11766 if (sw_if_index_set == 0)
11768 errmsg ("missing interface name or sw_if_index");
11772 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11774 mp->sw_if_index = ntohl (sw_if_index);
11775 mp->enable_disable = enable_disable;
11783 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11785 unformat_input_t *i = vam->input;
11786 vl_api_l2tpv3_set_lookup_key_t *mp;
11790 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11792 if (unformat (i, "lookup_v6_src"))
11793 key = L2T_LOOKUP_SRC_ADDRESS;
11794 else if (unformat (i, "lookup_v6_dst"))
11795 key = L2T_LOOKUP_DST_ADDRESS;
11796 else if (unformat (i, "lookup_session_id"))
11797 key = L2T_LOOKUP_SESSION_ID;
11802 if (key == (u8) ~ 0)
11804 errmsg ("l2tp session lookup key unset");
11808 M (L2TPV3_SET_LOOKUP_KEY, mp);
11817 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11818 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11820 vat_main_t *vam = &vat_main;
11822 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11823 format_ip6_address, mp->our_address,
11824 format_ip6_address, mp->client_address,
11825 clib_net_to_host_u32 (mp->sw_if_index));
11828 " local cookies %016llx %016llx remote cookie %016llx",
11829 clib_net_to_host_u64 (mp->local_cookie[0]),
11830 clib_net_to_host_u64 (mp->local_cookie[1]),
11831 clib_net_to_host_u64 (mp->remote_cookie));
11833 print (vam->ofp, " local session-id %d remote session-id %d",
11834 clib_net_to_host_u32 (mp->local_session_id),
11835 clib_net_to_host_u32 (mp->remote_session_id));
11837 print (vam->ofp, " l2 specific sublayer %s\n",
11838 mp->l2_sublayer_present ? "preset" : "absent");
11842 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11843 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11845 vat_main_t *vam = &vat_main;
11846 vat_json_node_t *node = NULL;
11847 struct in6_addr addr;
11849 if (VAT_JSON_ARRAY != vam->json_tree.type)
11851 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11852 vat_json_init_array (&vam->json_tree);
11854 node = vat_json_array_add (&vam->json_tree);
11856 vat_json_init_object (node);
11858 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11859 vat_json_object_add_ip6 (node, "our_address", addr);
11860 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11861 vat_json_object_add_ip6 (node, "client_address", addr);
11863 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11864 vat_json_init_array (lc);
11865 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11866 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11867 vat_json_object_add_uint (node, "remote_cookie",
11868 clib_net_to_host_u64 (mp->remote_cookie));
11870 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11871 vat_json_object_add_uint (node, "local_session_id",
11872 clib_net_to_host_u32 (mp->local_session_id));
11873 vat_json_object_add_uint (node, "remote_session_id",
11874 clib_net_to_host_u32 (mp->remote_session_id));
11875 vat_json_object_add_string_copy (node, "l2_sublayer",
11876 mp->l2_sublayer_present ? (u8 *) "present"
11877 : (u8 *) "absent");
11881 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11883 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11884 vl_api_control_ping_t *mp_ping;
11887 /* Get list of l2tpv3-tunnel interfaces */
11888 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11891 /* Use a control ping for synchronization */
11892 MPING (CONTROL_PING, mp_ping);
11900 static void vl_api_sw_interface_tap_details_t_handler
11901 (vl_api_sw_interface_tap_details_t * mp)
11903 vat_main_t *vam = &vat_main;
11905 print (vam->ofp, "%-16s %d",
11906 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
11909 static void vl_api_sw_interface_tap_details_t_handler_json
11910 (vl_api_sw_interface_tap_details_t * mp)
11912 vat_main_t *vam = &vat_main;
11913 vat_json_node_t *node = NULL;
11915 if (VAT_JSON_ARRAY != vam->json_tree.type)
11917 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11918 vat_json_init_array (&vam->json_tree);
11920 node = vat_json_array_add (&vam->json_tree);
11922 vat_json_init_object (node);
11923 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11924 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11928 api_sw_interface_tap_dump (vat_main_t * vam)
11930 vl_api_sw_interface_tap_dump_t *mp;
11931 vl_api_control_ping_t *mp_ping;
11934 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
11935 /* Get list of tap interfaces */
11936 M (SW_INTERFACE_TAP_DUMP, mp);
11939 /* Use a control ping for synchronization */
11940 MPING (CONTROL_PING, mp_ping);
11947 static uword unformat_vxlan_decap_next
11948 (unformat_input_t * input, va_list * args)
11950 u32 *result = va_arg (*args, u32 *);
11953 if (unformat (input, "l2"))
11954 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11955 else if (unformat (input, "%d", &tmp))
11963 api_vxlan_add_del_tunnel (vat_main_t * vam)
11965 unformat_input_t *line_input = vam->input;
11966 vl_api_vxlan_add_del_tunnel_t *mp;
11967 ip46_address_t src, dst;
11969 u8 ipv4_set = 0, ipv6_set = 0;
11973 u32 mcast_sw_if_index = ~0;
11974 u32 encap_vrf_id = 0;
11975 u32 decap_next_index = ~0;
11979 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11980 memset (&src, 0, sizeof src);
11981 memset (&dst, 0, sizeof dst);
11983 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11985 if (unformat (line_input, "del"))
11988 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11994 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12000 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12006 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12011 else if (unformat (line_input, "group %U %U",
12012 unformat_ip4_address, &dst.ip4,
12013 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12015 grp_set = dst_set = 1;
12018 else if (unformat (line_input, "group %U",
12019 unformat_ip4_address, &dst.ip4))
12021 grp_set = dst_set = 1;
12024 else if (unformat (line_input, "group %U %U",
12025 unformat_ip6_address, &dst.ip6,
12026 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12028 grp_set = dst_set = 1;
12031 else if (unformat (line_input, "group %U",
12032 unformat_ip6_address, &dst.ip6))
12034 grp_set = dst_set = 1;
12038 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12040 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12042 else if (unformat (line_input, "decap-next %U",
12043 unformat_vxlan_decap_next, &decap_next_index))
12045 else if (unformat (line_input, "vni %d", &vni))
12049 errmsg ("parse error '%U'", format_unformat_error, line_input);
12056 errmsg ("tunnel src address not specified");
12061 errmsg ("tunnel dst address not specified");
12065 if (grp_set && !ip46_address_is_multicast (&dst))
12067 errmsg ("tunnel group address not multicast");
12070 if (grp_set && mcast_sw_if_index == ~0)
12072 errmsg ("tunnel nonexistent multicast device");
12075 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12077 errmsg ("tunnel dst address must be unicast");
12082 if (ipv4_set && ipv6_set)
12084 errmsg ("both IPv4 and IPv6 addresses specified");
12088 if ((vni == 0) || (vni >> 24))
12090 errmsg ("vni not specified or out of range");
12094 M (VXLAN_ADD_DEL_TUNNEL, mp);
12098 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12099 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12103 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12104 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12106 mp->encap_vrf_id = ntohl (encap_vrf_id);
12107 mp->decap_next_index = ntohl (decap_next_index);
12108 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12109 mp->vni = ntohl (vni);
12110 mp->is_add = is_add;
12111 mp->is_ipv6 = ipv6_set;
12118 static void vl_api_vxlan_tunnel_details_t_handler
12119 (vl_api_vxlan_tunnel_details_t * mp)
12121 vat_main_t *vam = &vat_main;
12122 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12123 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12125 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12126 ntohl (mp->sw_if_index),
12127 format_ip46_address, &src, IP46_TYPE_ANY,
12128 format_ip46_address, &dst, IP46_TYPE_ANY,
12129 ntohl (mp->encap_vrf_id),
12130 ntohl (mp->decap_next_index), ntohl (mp->vni),
12131 ntohl (mp->mcast_sw_if_index));
12134 static void vl_api_vxlan_tunnel_details_t_handler_json
12135 (vl_api_vxlan_tunnel_details_t * mp)
12137 vat_main_t *vam = &vat_main;
12138 vat_json_node_t *node = NULL;
12140 if (VAT_JSON_ARRAY != vam->json_tree.type)
12142 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12143 vat_json_init_array (&vam->json_tree);
12145 node = vat_json_array_add (&vam->json_tree);
12147 vat_json_init_object (node);
12148 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12151 struct in6_addr ip6;
12153 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12154 vat_json_object_add_ip6 (node, "src_address", ip6);
12155 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12156 vat_json_object_add_ip6 (node, "dst_address", ip6);
12160 struct in_addr ip4;
12162 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12163 vat_json_object_add_ip4 (node, "src_address", ip4);
12164 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12165 vat_json_object_add_ip4 (node, "dst_address", ip4);
12167 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12168 vat_json_object_add_uint (node, "decap_next_index",
12169 ntohl (mp->decap_next_index));
12170 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12171 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12172 vat_json_object_add_uint (node, "mcast_sw_if_index",
12173 ntohl (mp->mcast_sw_if_index));
12177 api_vxlan_tunnel_dump (vat_main_t * vam)
12179 unformat_input_t *i = vam->input;
12180 vl_api_vxlan_tunnel_dump_t *mp;
12181 vl_api_control_ping_t *mp_ping;
12183 u8 sw_if_index_set = 0;
12186 /* Parse args required to build the message */
12187 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12189 if (unformat (i, "sw_if_index %d", &sw_if_index))
12190 sw_if_index_set = 1;
12195 if (sw_if_index_set == 0)
12200 if (!vam->json_output)
12202 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12203 "sw_if_index", "src_address", "dst_address",
12204 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12207 /* Get list of vxlan-tunnel interfaces */
12208 M (VXLAN_TUNNEL_DUMP, mp);
12210 mp->sw_if_index = htonl (sw_if_index);
12214 /* Use a control ping for synchronization */
12215 MPING (CONTROL_PING, mp_ping);
12222 static uword unformat_geneve_decap_next
12223 (unformat_input_t * input, va_list * args)
12225 u32 *result = va_arg (*args, u32 *);
12228 if (unformat (input, "l2"))
12229 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12230 else if (unformat (input, "%d", &tmp))
12238 api_geneve_add_del_tunnel (vat_main_t * vam)
12240 unformat_input_t *line_input = vam->input;
12241 vl_api_geneve_add_del_tunnel_t *mp;
12242 ip46_address_t src, dst;
12244 u8 ipv4_set = 0, ipv6_set = 0;
12248 u32 mcast_sw_if_index = ~0;
12249 u32 encap_vrf_id = 0;
12250 u32 decap_next_index = ~0;
12254 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12255 memset (&src, 0, sizeof src);
12256 memset (&dst, 0, sizeof dst);
12258 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12260 if (unformat (line_input, "del"))
12263 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12269 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12275 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12281 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12286 else if (unformat (line_input, "group %U %U",
12287 unformat_ip4_address, &dst.ip4,
12288 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12290 grp_set = dst_set = 1;
12293 else if (unformat (line_input, "group %U",
12294 unformat_ip4_address, &dst.ip4))
12296 grp_set = dst_set = 1;
12299 else if (unformat (line_input, "group %U %U",
12300 unformat_ip6_address, &dst.ip6,
12301 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12303 grp_set = dst_set = 1;
12306 else if (unformat (line_input, "group %U",
12307 unformat_ip6_address, &dst.ip6))
12309 grp_set = dst_set = 1;
12313 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12315 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12317 else if (unformat (line_input, "decap-next %U",
12318 unformat_geneve_decap_next, &decap_next_index))
12320 else if (unformat (line_input, "vni %d", &vni))
12324 errmsg ("parse error '%U'", format_unformat_error, line_input);
12331 errmsg ("tunnel src address not specified");
12336 errmsg ("tunnel dst address not specified");
12340 if (grp_set && !ip46_address_is_multicast (&dst))
12342 errmsg ("tunnel group address not multicast");
12345 if (grp_set && mcast_sw_if_index == ~0)
12347 errmsg ("tunnel nonexistent multicast device");
12350 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12352 errmsg ("tunnel dst address must be unicast");
12357 if (ipv4_set && ipv6_set)
12359 errmsg ("both IPv4 and IPv6 addresses specified");
12363 if ((vni == 0) || (vni >> 24))
12365 errmsg ("vni not specified or out of range");
12369 M (GENEVE_ADD_DEL_TUNNEL, mp);
12373 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12374 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12378 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12379 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12381 mp->encap_vrf_id = ntohl (encap_vrf_id);
12382 mp->decap_next_index = ntohl (decap_next_index);
12383 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12384 mp->vni = ntohl (vni);
12385 mp->is_add = is_add;
12386 mp->is_ipv6 = ipv6_set;
12393 static void vl_api_geneve_tunnel_details_t_handler
12394 (vl_api_geneve_tunnel_details_t * mp)
12396 vat_main_t *vam = &vat_main;
12397 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12398 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12400 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12401 ntohl (mp->sw_if_index),
12402 format_ip46_address, &src, IP46_TYPE_ANY,
12403 format_ip46_address, &dst, IP46_TYPE_ANY,
12404 ntohl (mp->encap_vrf_id),
12405 ntohl (mp->decap_next_index), ntohl (mp->vni),
12406 ntohl (mp->mcast_sw_if_index));
12409 static void vl_api_geneve_tunnel_details_t_handler_json
12410 (vl_api_geneve_tunnel_details_t * mp)
12412 vat_main_t *vam = &vat_main;
12413 vat_json_node_t *node = NULL;
12415 if (VAT_JSON_ARRAY != vam->json_tree.type)
12417 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12418 vat_json_init_array (&vam->json_tree);
12420 node = vat_json_array_add (&vam->json_tree);
12422 vat_json_init_object (node);
12423 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12426 struct in6_addr ip6;
12428 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12429 vat_json_object_add_ip6 (node, "src_address", ip6);
12430 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12431 vat_json_object_add_ip6 (node, "dst_address", ip6);
12435 struct in_addr ip4;
12437 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12438 vat_json_object_add_ip4 (node, "src_address", ip4);
12439 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12440 vat_json_object_add_ip4 (node, "dst_address", ip4);
12442 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12443 vat_json_object_add_uint (node, "decap_next_index",
12444 ntohl (mp->decap_next_index));
12445 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12446 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12447 vat_json_object_add_uint (node, "mcast_sw_if_index",
12448 ntohl (mp->mcast_sw_if_index));
12452 api_geneve_tunnel_dump (vat_main_t * vam)
12454 unformat_input_t *i = vam->input;
12455 vl_api_geneve_tunnel_dump_t *mp;
12456 vl_api_control_ping_t *mp_ping;
12458 u8 sw_if_index_set = 0;
12461 /* Parse args required to build the message */
12462 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12464 if (unformat (i, "sw_if_index %d", &sw_if_index))
12465 sw_if_index_set = 1;
12470 if (sw_if_index_set == 0)
12475 if (!vam->json_output)
12477 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12478 "sw_if_index", "local_address", "remote_address",
12479 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12482 /* Get list of geneve-tunnel interfaces */
12483 M (GENEVE_TUNNEL_DUMP, mp);
12485 mp->sw_if_index = htonl (sw_if_index);
12489 /* Use a control ping for synchronization */
12490 M (CONTROL_PING, mp_ping);
12498 api_gre_add_del_tunnel (vat_main_t * vam)
12500 unformat_input_t *line_input = vam->input;
12501 vl_api_gre_add_del_tunnel_t *mp;
12502 ip4_address_t src4, dst4;
12503 ip6_address_t src6, dst6;
12510 u32 outer_fib_id = 0;
12513 memset (&src4, 0, sizeof src4);
12514 memset (&dst4, 0, sizeof dst4);
12515 memset (&src6, 0, sizeof src6);
12516 memset (&dst6, 0, sizeof dst6);
12518 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12520 if (unformat (line_input, "del"))
12522 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
12527 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
12532 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
12537 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
12542 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12544 else if (unformat (line_input, "teb"))
12548 errmsg ("parse error '%U'", format_unformat_error, line_input);
12555 errmsg ("tunnel src address not specified");
12560 errmsg ("tunnel dst address not specified");
12563 if (ipv4_set && ipv6_set)
12565 errmsg ("both IPv4 and IPv6 addresses specified");
12570 M (GRE_ADD_DEL_TUNNEL, mp);
12574 clib_memcpy (&mp->src_address, &src4, 4);
12575 clib_memcpy (&mp->dst_address, &dst4, 4);
12579 clib_memcpy (&mp->src_address, &src6, 16);
12580 clib_memcpy (&mp->dst_address, &dst6, 16);
12582 mp->outer_fib_id = ntohl (outer_fib_id);
12583 mp->is_add = is_add;
12585 mp->is_ipv6 = ipv6_set;
12592 static void vl_api_gre_tunnel_details_t_handler
12593 (vl_api_gre_tunnel_details_t * mp)
12595 vat_main_t *vam = &vat_main;
12596 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
12597 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
12599 print (vam->ofp, "%11d%24U%24U%6d%14d",
12600 ntohl (mp->sw_if_index),
12601 format_ip46_address, &src, IP46_TYPE_ANY,
12602 format_ip46_address, &dst, IP46_TYPE_ANY,
12603 mp->teb, ntohl (mp->outer_fib_id));
12606 static void vl_api_gre_tunnel_details_t_handler_json
12607 (vl_api_gre_tunnel_details_t * mp)
12609 vat_main_t *vam = &vat_main;
12610 vat_json_node_t *node = NULL;
12611 struct in_addr ip4;
12612 struct in6_addr ip6;
12614 if (VAT_JSON_ARRAY != vam->json_tree.type)
12616 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12617 vat_json_init_array (&vam->json_tree);
12619 node = vat_json_array_add (&vam->json_tree);
12621 vat_json_init_object (node);
12622 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12625 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
12626 vat_json_object_add_ip4 (node, "src_address", ip4);
12627 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
12628 vat_json_object_add_ip4 (node, "dst_address", ip4);
12632 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
12633 vat_json_object_add_ip6 (node, "src_address", ip6);
12634 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
12635 vat_json_object_add_ip6 (node, "dst_address", ip6);
12637 vat_json_object_add_uint (node, "teb", mp->teb);
12638 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
12639 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
12643 api_gre_tunnel_dump (vat_main_t * vam)
12645 unformat_input_t *i = vam->input;
12646 vl_api_gre_tunnel_dump_t *mp;
12647 vl_api_control_ping_t *mp_ping;
12649 u8 sw_if_index_set = 0;
12652 /* Parse args required to build the message */
12653 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12655 if (unformat (i, "sw_if_index %d", &sw_if_index))
12656 sw_if_index_set = 1;
12661 if (sw_if_index_set == 0)
12666 if (!vam->json_output)
12668 print (vam->ofp, "%11s%24s%24s%6s%14s",
12669 "sw_if_index", "src_address", "dst_address", "teb",
12673 /* Get list of gre-tunnel interfaces */
12674 M (GRE_TUNNEL_DUMP, mp);
12676 mp->sw_if_index = htonl (sw_if_index);
12680 /* Use a control ping for synchronization */
12681 MPING (CONTROL_PING, mp_ping);
12689 api_l2_fib_clear_table (vat_main_t * vam)
12691 // unformat_input_t * i = vam->input;
12692 vl_api_l2_fib_clear_table_t *mp;
12695 M (L2_FIB_CLEAR_TABLE, mp);
12703 api_l2_interface_efp_filter (vat_main_t * vam)
12705 unformat_input_t *i = vam->input;
12706 vl_api_l2_interface_efp_filter_t *mp;
12709 u8 sw_if_index_set = 0;
12712 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12714 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12715 sw_if_index_set = 1;
12716 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12717 sw_if_index_set = 1;
12718 else if (unformat (i, "enable"))
12720 else if (unformat (i, "disable"))
12724 clib_warning ("parse error '%U'", format_unformat_error, i);
12729 if (sw_if_index_set == 0)
12731 errmsg ("missing sw_if_index");
12735 M (L2_INTERFACE_EFP_FILTER, mp);
12737 mp->sw_if_index = ntohl (sw_if_index);
12738 mp->enable_disable = enable;
12745 #define foreach_vtr_op \
12746 _("disable", L2_VTR_DISABLED) \
12747 _("push-1", L2_VTR_PUSH_1) \
12748 _("push-2", L2_VTR_PUSH_2) \
12749 _("pop-1", L2_VTR_POP_1) \
12750 _("pop-2", L2_VTR_POP_2) \
12751 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12752 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12753 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12754 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12757 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12759 unformat_input_t *i = vam->input;
12760 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12762 u8 sw_if_index_set = 0;
12765 u32 push_dot1q = 1;
12770 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12772 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12773 sw_if_index_set = 1;
12774 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12775 sw_if_index_set = 1;
12776 else if (unformat (i, "vtr_op %d", &vtr_op))
12778 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12781 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12783 else if (unformat (i, "tag1 %d", &tag1))
12785 else if (unformat (i, "tag2 %d", &tag2))
12789 clib_warning ("parse error '%U'", format_unformat_error, i);
12794 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12796 errmsg ("missing vtr operation or sw_if_index");
12800 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12801 mp->sw_if_index = ntohl (sw_if_index);
12802 mp->vtr_op = ntohl (vtr_op);
12803 mp->push_dot1q = ntohl (push_dot1q);
12804 mp->tag1 = ntohl (tag1);
12805 mp->tag2 = ntohl (tag2);
12813 api_create_vhost_user_if (vat_main_t * vam)
12815 unformat_input_t *i = vam->input;
12816 vl_api_create_vhost_user_if_t *mp;
12819 u8 file_name_set = 0;
12820 u32 custom_dev_instance = ~0;
12822 u8 use_custom_mac = 0;
12826 /* Shut up coverity */
12827 memset (hwaddr, 0, sizeof (hwaddr));
12829 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12831 if (unformat (i, "socket %s", &file_name))
12835 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12837 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12838 use_custom_mac = 1;
12839 else if (unformat (i, "server"))
12841 else if (unformat (i, "tag %s", &tag))
12847 if (file_name_set == 0)
12849 errmsg ("missing socket file name");
12853 if (vec_len (file_name) > 255)
12855 errmsg ("socket file name too long");
12858 vec_add1 (file_name, 0);
12860 M (CREATE_VHOST_USER_IF, mp);
12862 mp->is_server = is_server;
12863 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12864 vec_free (file_name);
12865 if (custom_dev_instance != ~0)
12868 mp->custom_dev_instance = ntohl (custom_dev_instance);
12870 mp->use_custom_mac = use_custom_mac;
12871 clib_memcpy (mp->mac_address, hwaddr, 6);
12873 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12882 api_modify_vhost_user_if (vat_main_t * vam)
12884 unformat_input_t *i = vam->input;
12885 vl_api_modify_vhost_user_if_t *mp;
12888 u8 file_name_set = 0;
12889 u32 custom_dev_instance = ~0;
12890 u8 sw_if_index_set = 0;
12891 u32 sw_if_index = (u32) ~ 0;
12894 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12896 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12897 sw_if_index_set = 1;
12898 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12899 sw_if_index_set = 1;
12900 else if (unformat (i, "socket %s", &file_name))
12904 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12906 else if (unformat (i, "server"))
12912 if (sw_if_index_set == 0)
12914 errmsg ("missing sw_if_index or interface name");
12918 if (file_name_set == 0)
12920 errmsg ("missing socket file name");
12924 if (vec_len (file_name) > 255)
12926 errmsg ("socket file name too long");
12929 vec_add1 (file_name, 0);
12931 M (MODIFY_VHOST_USER_IF, mp);
12933 mp->sw_if_index = ntohl (sw_if_index);
12934 mp->is_server = is_server;
12935 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12936 vec_free (file_name);
12937 if (custom_dev_instance != ~0)
12940 mp->custom_dev_instance = ntohl (custom_dev_instance);
12949 api_delete_vhost_user_if (vat_main_t * vam)
12951 unformat_input_t *i = vam->input;
12952 vl_api_delete_vhost_user_if_t *mp;
12953 u32 sw_if_index = ~0;
12954 u8 sw_if_index_set = 0;
12957 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12959 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12960 sw_if_index_set = 1;
12961 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12962 sw_if_index_set = 1;
12967 if (sw_if_index_set == 0)
12969 errmsg ("missing sw_if_index or interface name");
12974 M (DELETE_VHOST_USER_IF, mp);
12976 mp->sw_if_index = ntohl (sw_if_index);
12983 static void vl_api_sw_interface_vhost_user_details_t_handler
12984 (vl_api_sw_interface_vhost_user_details_t * mp)
12986 vat_main_t *vam = &vat_main;
12988 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12989 (char *) mp->interface_name,
12990 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12991 clib_net_to_host_u64 (mp->features), mp->is_server,
12992 ntohl (mp->num_regions), (char *) mp->sock_filename);
12993 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12996 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12997 (vl_api_sw_interface_vhost_user_details_t * mp)
12999 vat_main_t *vam = &vat_main;
13000 vat_json_node_t *node = NULL;
13002 if (VAT_JSON_ARRAY != vam->json_tree.type)
13004 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13005 vat_json_init_array (&vam->json_tree);
13007 node = vat_json_array_add (&vam->json_tree);
13009 vat_json_init_object (node);
13010 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13011 vat_json_object_add_string_copy (node, "interface_name",
13012 mp->interface_name);
13013 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13014 ntohl (mp->virtio_net_hdr_sz));
13015 vat_json_object_add_uint (node, "features",
13016 clib_net_to_host_u64 (mp->features));
13017 vat_json_object_add_uint (node, "is_server", mp->is_server);
13018 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13019 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13020 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13024 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13026 vl_api_sw_interface_vhost_user_dump_t *mp;
13027 vl_api_control_ping_t *mp_ping;
13030 "Interface name idx hdr_sz features server regions filename");
13032 /* Get list of vhost-user interfaces */
13033 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13036 /* Use a control ping for synchronization */
13037 MPING (CONTROL_PING, mp_ping);
13045 api_show_version (vat_main_t * vam)
13047 vl_api_show_version_t *mp;
13050 M (SHOW_VERSION, mp);
13059 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13061 unformat_input_t *line_input = vam->input;
13062 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13063 ip4_address_t local4, remote4;
13064 ip6_address_t local6, remote6;
13066 u8 ipv4_set = 0, ipv6_set = 0;
13070 u32 mcast_sw_if_index = ~0;
13071 u32 encap_vrf_id = 0;
13072 u32 decap_vrf_id = 0;
13078 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13079 memset (&local4, 0, sizeof local4);
13080 memset (&remote4, 0, sizeof remote4);
13081 memset (&local6, 0, sizeof local6);
13082 memset (&remote6, 0, sizeof remote6);
13084 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13086 if (unformat (line_input, "del"))
13088 else if (unformat (line_input, "local %U",
13089 unformat_ip4_address, &local4))
13094 else if (unformat (line_input, "remote %U",
13095 unformat_ip4_address, &remote4))
13100 else if (unformat (line_input, "local %U",
13101 unformat_ip6_address, &local6))
13106 else if (unformat (line_input, "remote %U",
13107 unformat_ip6_address, &remote6))
13112 else if (unformat (line_input, "group %U %U",
13113 unformat_ip4_address, &remote4,
13114 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13116 grp_set = remote_set = 1;
13119 else if (unformat (line_input, "group %U",
13120 unformat_ip4_address, &remote4))
13122 grp_set = remote_set = 1;
13125 else if (unformat (line_input, "group %U %U",
13126 unformat_ip6_address, &remote6,
13127 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13129 grp_set = remote_set = 1;
13132 else if (unformat (line_input, "group %U",
13133 unformat_ip6_address, &remote6))
13135 grp_set = remote_set = 1;
13139 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13141 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13143 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13145 else if (unformat (line_input, "vni %d", &vni))
13147 else if (unformat (line_input, "next-ip4"))
13149 else if (unformat (line_input, "next-ip6"))
13151 else if (unformat (line_input, "next-ethernet"))
13153 else if (unformat (line_input, "next-nsh"))
13157 errmsg ("parse error '%U'", format_unformat_error, line_input);
13162 if (local_set == 0)
13164 errmsg ("tunnel local address not specified");
13167 if (remote_set == 0)
13169 errmsg ("tunnel remote address not specified");
13172 if (grp_set && mcast_sw_if_index == ~0)
13174 errmsg ("tunnel nonexistent multicast device");
13177 if (ipv4_set && ipv6_set)
13179 errmsg ("both IPv4 and IPv6 addresses specified");
13185 errmsg ("vni not specified");
13189 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13194 clib_memcpy (&mp->local, &local6, sizeof (local6));
13195 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13199 clib_memcpy (&mp->local, &local4, sizeof (local4));
13200 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13203 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13204 mp->encap_vrf_id = ntohl (encap_vrf_id);
13205 mp->decap_vrf_id = ntohl (decap_vrf_id);
13206 mp->protocol = protocol;
13207 mp->vni = ntohl (vni);
13208 mp->is_add = is_add;
13209 mp->is_ipv6 = ipv6_set;
13216 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13217 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13219 vat_main_t *vam = &vat_main;
13220 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13221 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13223 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13224 ntohl (mp->sw_if_index),
13225 format_ip46_address, &local, IP46_TYPE_ANY,
13226 format_ip46_address, &remote, IP46_TYPE_ANY,
13227 ntohl (mp->vni), mp->protocol,
13228 ntohl (mp->mcast_sw_if_index),
13229 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13233 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13234 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13236 vat_main_t *vam = &vat_main;
13237 vat_json_node_t *node = NULL;
13238 struct in_addr ip4;
13239 struct in6_addr ip6;
13241 if (VAT_JSON_ARRAY != vam->json_tree.type)
13243 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13244 vat_json_init_array (&vam->json_tree);
13246 node = vat_json_array_add (&vam->json_tree);
13248 vat_json_init_object (node);
13249 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13252 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13253 vat_json_object_add_ip6 (node, "local", ip6);
13254 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13255 vat_json_object_add_ip6 (node, "remote", ip6);
13259 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13260 vat_json_object_add_ip4 (node, "local", ip4);
13261 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13262 vat_json_object_add_ip4 (node, "remote", ip4);
13264 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13265 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13266 vat_json_object_add_uint (node, "mcast_sw_if_index",
13267 ntohl (mp->mcast_sw_if_index));
13268 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13269 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13270 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13274 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13276 unformat_input_t *i = vam->input;
13277 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13278 vl_api_control_ping_t *mp_ping;
13280 u8 sw_if_index_set = 0;
13283 /* Parse args required to build the message */
13284 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13286 if (unformat (i, "sw_if_index %d", &sw_if_index))
13287 sw_if_index_set = 1;
13292 if (sw_if_index_set == 0)
13297 if (!vam->json_output)
13299 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13300 "sw_if_index", "local", "remote", "vni",
13301 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13304 /* Get list of vxlan-tunnel interfaces */
13305 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13307 mp->sw_if_index = htonl (sw_if_index);
13311 /* Use a control ping for synchronization */
13312 MPING (CONTROL_PING, mp_ping);
13319 static void vl_api_l2_fib_table_details_t_handler
13320 (vl_api_l2_fib_table_details_t * mp)
13322 vat_main_t *vam = &vat_main;
13324 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13326 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
13327 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13331 static void vl_api_l2_fib_table_details_t_handler_json
13332 (vl_api_l2_fib_table_details_t * mp)
13334 vat_main_t *vam = &vat_main;
13335 vat_json_node_t *node = NULL;
13337 if (VAT_JSON_ARRAY != vam->json_tree.type)
13339 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13340 vat_json_init_array (&vam->json_tree);
13342 node = vat_json_array_add (&vam->json_tree);
13344 vat_json_init_object (node);
13345 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13346 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
13347 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13348 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13349 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13350 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13354 api_l2_fib_table_dump (vat_main_t * vam)
13356 unformat_input_t *i = vam->input;
13357 vl_api_l2_fib_table_dump_t *mp;
13358 vl_api_control_ping_t *mp_ping;
13363 /* Parse args required to build the message */
13364 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13366 if (unformat (i, "bd_id %d", &bd_id))
13372 if (bd_id_set == 0)
13374 errmsg ("missing bridge domain");
13378 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13380 /* Get list of l2 fib entries */
13381 M (L2_FIB_TABLE_DUMP, mp);
13383 mp->bd_id = ntohl (bd_id);
13386 /* Use a control ping for synchronization */
13387 MPING (CONTROL_PING, mp_ping);
13396 api_interface_name_renumber (vat_main_t * vam)
13398 unformat_input_t *line_input = vam->input;
13399 vl_api_interface_name_renumber_t *mp;
13400 u32 sw_if_index = ~0;
13401 u32 new_show_dev_instance = ~0;
13404 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13406 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13409 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13411 else if (unformat (line_input, "new_show_dev_instance %d",
13412 &new_show_dev_instance))
13418 if (sw_if_index == ~0)
13420 errmsg ("missing interface name or sw_if_index");
13424 if (new_show_dev_instance == ~0)
13426 errmsg ("missing new_show_dev_instance");
13430 M (INTERFACE_NAME_RENUMBER, mp);
13432 mp->sw_if_index = ntohl (sw_if_index);
13433 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13441 api_want_ip4_arp_events (vat_main_t * vam)
13443 unformat_input_t *line_input = vam->input;
13444 vl_api_want_ip4_arp_events_t *mp;
13445 ip4_address_t address;
13446 int address_set = 0;
13447 u32 enable_disable = 1;
13450 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13452 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
13454 else if (unformat (line_input, "del"))
13455 enable_disable = 0;
13460 if (address_set == 0)
13462 errmsg ("missing addresses");
13466 M (WANT_IP4_ARP_EVENTS, mp);
13467 mp->enable_disable = enable_disable;
13468 mp->pid = htonl (getpid ());
13469 mp->address = address.as_u32;
13477 api_want_ip6_nd_events (vat_main_t * vam)
13479 unformat_input_t *line_input = vam->input;
13480 vl_api_want_ip6_nd_events_t *mp;
13481 ip6_address_t address;
13482 int address_set = 0;
13483 u32 enable_disable = 1;
13486 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13488 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
13490 else if (unformat (line_input, "del"))
13491 enable_disable = 0;
13496 if (address_set == 0)
13498 errmsg ("missing addresses");
13502 M (WANT_IP6_ND_EVENTS, mp);
13503 mp->enable_disable = enable_disable;
13504 mp->pid = htonl (getpid ());
13505 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
13513 api_want_l2_macs_events (vat_main_t * vam)
13515 unformat_input_t *line_input = vam->input;
13516 vl_api_want_l2_macs_events_t *mp;
13517 u8 enable_disable = 1;
13518 u32 scan_delay = 0;
13519 u32 max_macs_in_event = 0;
13520 u32 learn_limit = 0;
13523 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13525 if (unformat (line_input, "learn-limit %d", &learn_limit))
13527 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13529 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13531 else if (unformat (line_input, "disable"))
13532 enable_disable = 0;
13537 M (WANT_L2_MACS_EVENTS, mp);
13538 mp->enable_disable = enable_disable;
13539 mp->pid = htonl (getpid ());
13540 mp->learn_limit = htonl (learn_limit);
13541 mp->scan_delay = (u8) scan_delay;
13542 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13549 api_input_acl_set_interface (vat_main_t * vam)
13551 unformat_input_t *i = vam->input;
13552 vl_api_input_acl_set_interface_t *mp;
13554 int sw_if_index_set;
13555 u32 ip4_table_index = ~0;
13556 u32 ip6_table_index = ~0;
13557 u32 l2_table_index = ~0;
13561 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13563 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13564 sw_if_index_set = 1;
13565 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13566 sw_if_index_set = 1;
13567 else if (unformat (i, "del"))
13569 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13571 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13573 else if (unformat (i, "l2-table %d", &l2_table_index))
13577 clib_warning ("parse error '%U'", format_unformat_error, i);
13582 if (sw_if_index_set == 0)
13584 errmsg ("missing interface name or sw_if_index");
13588 M (INPUT_ACL_SET_INTERFACE, mp);
13590 mp->sw_if_index = ntohl (sw_if_index);
13591 mp->ip4_table_index = ntohl (ip4_table_index);
13592 mp->ip6_table_index = ntohl (ip6_table_index);
13593 mp->l2_table_index = ntohl (l2_table_index);
13594 mp->is_add = is_add;
13602 api_ip_address_dump (vat_main_t * vam)
13604 unformat_input_t *i = vam->input;
13605 vl_api_ip_address_dump_t *mp;
13606 vl_api_control_ping_t *mp_ping;
13607 u32 sw_if_index = ~0;
13608 u8 sw_if_index_set = 0;
13613 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13615 if (unformat (i, "sw_if_index %d", &sw_if_index))
13616 sw_if_index_set = 1;
13618 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13619 sw_if_index_set = 1;
13620 else if (unformat (i, "ipv4"))
13622 else if (unformat (i, "ipv6"))
13628 if (ipv4_set && ipv6_set)
13630 errmsg ("ipv4 and ipv6 flags cannot be both set");
13634 if ((!ipv4_set) && (!ipv6_set))
13636 errmsg ("no ipv4 nor ipv6 flag set");
13640 if (sw_if_index_set == 0)
13642 errmsg ("missing interface name or sw_if_index");
13646 vam->current_sw_if_index = sw_if_index;
13647 vam->is_ipv6 = ipv6_set;
13649 M (IP_ADDRESS_DUMP, mp);
13650 mp->sw_if_index = ntohl (sw_if_index);
13651 mp->is_ipv6 = ipv6_set;
13654 /* Use a control ping for synchronization */
13655 MPING (CONTROL_PING, mp_ping);
13663 api_ip_dump (vat_main_t * vam)
13665 vl_api_ip_dump_t *mp;
13666 vl_api_control_ping_t *mp_ping;
13667 unformat_input_t *in = vam->input;
13674 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13676 if (unformat (in, "ipv4"))
13678 else if (unformat (in, "ipv6"))
13684 if (ipv4_set && ipv6_set)
13686 errmsg ("ipv4 and ipv6 flags cannot be both set");
13690 if ((!ipv4_set) && (!ipv6_set))
13692 errmsg ("no ipv4 nor ipv6 flag set");
13696 is_ipv6 = ipv6_set;
13697 vam->is_ipv6 = is_ipv6;
13699 /* free old data */
13700 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13702 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13704 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13707 mp->is_ipv6 = ipv6_set;
13710 /* Use a control ping for synchronization */
13711 MPING (CONTROL_PING, mp_ping);
13719 api_ipsec_spd_add_del (vat_main_t * vam)
13721 unformat_input_t *i = vam->input;
13722 vl_api_ipsec_spd_add_del_t *mp;
13727 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13729 if (unformat (i, "spd_id %d", &spd_id))
13731 else if (unformat (i, "del"))
13735 clib_warning ("parse error '%U'", format_unformat_error, i);
13741 errmsg ("spd_id must be set");
13745 M (IPSEC_SPD_ADD_DEL, mp);
13747 mp->spd_id = ntohl (spd_id);
13748 mp->is_add = is_add;
13756 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13758 unformat_input_t *i = vam->input;
13759 vl_api_ipsec_interface_add_del_spd_t *mp;
13761 u8 sw_if_index_set = 0;
13762 u32 spd_id = (u32) ~ 0;
13766 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13768 if (unformat (i, "del"))
13770 else if (unformat (i, "spd_id %d", &spd_id))
13773 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13774 sw_if_index_set = 1;
13775 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13776 sw_if_index_set = 1;
13779 clib_warning ("parse error '%U'", format_unformat_error, i);
13785 if (spd_id == (u32) ~ 0)
13787 errmsg ("spd_id must be set");
13791 if (sw_if_index_set == 0)
13793 errmsg ("missing interface name or sw_if_index");
13797 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13799 mp->spd_id = ntohl (spd_id);
13800 mp->sw_if_index = ntohl (sw_if_index);
13801 mp->is_add = is_add;
13809 api_ipsec_spd_add_del_entry (vat_main_t * vam)
13811 unformat_input_t *i = vam->input;
13812 vl_api_ipsec_spd_add_del_entry_t *mp;
13813 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
13814 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13816 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13817 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13818 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
13819 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
13822 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
13823 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
13824 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
13825 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
13826 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
13827 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
13829 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13831 if (unformat (i, "del"))
13833 if (unformat (i, "outbound"))
13835 if (unformat (i, "inbound"))
13837 else if (unformat (i, "spd_id %d", &spd_id))
13839 else if (unformat (i, "sa_id %d", &sa_id))
13841 else if (unformat (i, "priority %d", &priority))
13843 else if (unformat (i, "protocol %d", &protocol))
13845 else if (unformat (i, "lport_start %d", &lport_start))
13847 else if (unformat (i, "lport_stop %d", &lport_stop))
13849 else if (unformat (i, "rport_start %d", &rport_start))
13851 else if (unformat (i, "rport_stop %d", &rport_stop))
13855 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
13861 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
13868 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
13874 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
13881 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
13887 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
13894 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
13900 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
13906 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13908 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13910 clib_warning ("unsupported action: 'resolve'");
13916 clib_warning ("parse error '%U'", format_unformat_error, i);
13922 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
13924 mp->spd_id = ntohl (spd_id);
13925 mp->priority = ntohl (priority);
13926 mp->is_outbound = is_outbound;
13928 mp->is_ipv6 = is_ipv6;
13929 if (is_ipv6 || is_ip_any)
13931 clib_memcpy (mp->remote_address_start, &raddr6_start,
13932 sizeof (ip6_address_t));
13933 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
13934 sizeof (ip6_address_t));
13935 clib_memcpy (mp->local_address_start, &laddr6_start,
13936 sizeof (ip6_address_t));
13937 clib_memcpy (mp->local_address_stop, &laddr6_stop,
13938 sizeof (ip6_address_t));
13942 clib_memcpy (mp->remote_address_start, &raddr4_start,
13943 sizeof (ip4_address_t));
13944 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
13945 sizeof (ip4_address_t));
13946 clib_memcpy (mp->local_address_start, &laddr4_start,
13947 sizeof (ip4_address_t));
13948 clib_memcpy (mp->local_address_stop, &laddr4_stop,
13949 sizeof (ip4_address_t));
13951 mp->protocol = (u8) protocol;
13952 mp->local_port_start = ntohs ((u16) lport_start);
13953 mp->local_port_stop = ntohs ((u16) lport_stop);
13954 mp->remote_port_start = ntohs ((u16) rport_start);
13955 mp->remote_port_stop = ntohs ((u16) rport_stop);
13956 mp->policy = (u8) policy;
13957 mp->sa_id = ntohl (sa_id);
13958 mp->is_add = is_add;
13959 mp->is_ip_any = is_ip_any;
13966 api_ipsec_sad_add_del_entry (vat_main_t * vam)
13968 unformat_input_t *i = vam->input;
13969 vl_api_ipsec_sad_add_del_entry_t *mp;
13970 u32 sad_id = 0, spi = 0;
13971 u8 *ck = 0, *ik = 0;
13974 u8 protocol = IPSEC_PROTOCOL_AH;
13975 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
13976 u32 crypto_alg = 0, integ_alg = 0;
13977 ip4_address_t tun_src4;
13978 ip4_address_t tun_dst4;
13979 ip6_address_t tun_src6;
13980 ip6_address_t tun_dst6;
13983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13985 if (unformat (i, "del"))
13987 else if (unformat (i, "sad_id %d", &sad_id))
13989 else if (unformat (i, "spi %d", &spi))
13991 else if (unformat (i, "esp"))
13992 protocol = IPSEC_PROTOCOL_ESP;
13993 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
13996 is_tunnel_ipv6 = 0;
13998 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
14001 is_tunnel_ipv6 = 0;
14003 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
14006 is_tunnel_ipv6 = 1;
14008 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
14011 is_tunnel_ipv6 = 1;
14015 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14017 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14018 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14020 clib_warning ("unsupported crypto-alg: '%U'",
14021 format_ipsec_crypto_alg, crypto_alg);
14025 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14029 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14031 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14032 integ_alg >= IPSEC_INTEG_N_ALG)
14034 clib_warning ("unsupported integ-alg: '%U'",
14035 format_ipsec_integ_alg, integ_alg);
14039 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14043 clib_warning ("parse error '%U'", format_unformat_error, i);
14049 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
14051 mp->sad_id = ntohl (sad_id);
14052 mp->is_add = is_add;
14053 mp->protocol = protocol;
14054 mp->spi = ntohl (spi);
14055 mp->is_tunnel = is_tunnel;
14056 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
14057 mp->crypto_algorithm = crypto_alg;
14058 mp->integrity_algorithm = integ_alg;
14059 mp->crypto_key_length = vec_len (ck);
14060 mp->integrity_key_length = vec_len (ik);
14062 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14063 mp->crypto_key_length = sizeof (mp->crypto_key);
14065 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14066 mp->integrity_key_length = sizeof (mp->integrity_key);
14069 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14071 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14075 if (is_tunnel_ipv6)
14077 clib_memcpy (mp->tunnel_src_address, &tun_src6,
14078 sizeof (ip6_address_t));
14079 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
14080 sizeof (ip6_address_t));
14084 clib_memcpy (mp->tunnel_src_address, &tun_src4,
14085 sizeof (ip4_address_t));
14086 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
14087 sizeof (ip4_address_t));
14097 api_ipsec_sa_set_key (vat_main_t * vam)
14099 unformat_input_t *i = vam->input;
14100 vl_api_ipsec_sa_set_key_t *mp;
14102 u8 *ck = 0, *ik = 0;
14105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14107 if (unformat (i, "sa_id %d", &sa_id))
14109 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14111 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14115 clib_warning ("parse error '%U'", format_unformat_error, i);
14120 M (IPSEC_SA_SET_KEY, mp);
14122 mp->sa_id = ntohl (sa_id);
14123 mp->crypto_key_length = vec_len (ck);
14124 mp->integrity_key_length = vec_len (ik);
14126 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14127 mp->crypto_key_length = sizeof (mp->crypto_key);
14129 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14130 mp->integrity_key_length = sizeof (mp->integrity_key);
14133 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14135 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14143 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14145 unformat_input_t *i = vam->input;
14146 vl_api_ipsec_tunnel_if_add_del_t *mp;
14147 u32 local_spi = 0, remote_spi = 0;
14148 u32 crypto_alg = 0, integ_alg = 0;
14149 u8 *lck = NULL, *rck = NULL;
14150 u8 *lik = NULL, *rik = NULL;
14151 ip4_address_t local_ip = { {0} };
14152 ip4_address_t remote_ip = { {0} };
14155 u8 anti_replay = 0;
14158 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14160 if (unformat (i, "del"))
14162 else if (unformat (i, "esn"))
14164 else if (unformat (i, "anti_replay"))
14166 else if (unformat (i, "local_spi %d", &local_spi))
14168 else if (unformat (i, "remote_spi %d", &remote_spi))
14170 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
14172 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
14174 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14177 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14179 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14181 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14185 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14187 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14188 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14190 errmsg ("unsupported crypto-alg: '%U'\n",
14191 format_ipsec_crypto_alg, crypto_alg);
14197 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14199 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14200 integ_alg >= IPSEC_INTEG_N_ALG)
14202 errmsg ("unsupported integ-alg: '%U'\n",
14203 format_ipsec_integ_alg, integ_alg);
14209 errmsg ("parse error '%U'\n", format_unformat_error, i);
14214 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14216 mp->is_add = is_add;
14218 mp->anti_replay = anti_replay;
14220 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
14221 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
14223 mp->local_spi = htonl (local_spi);
14224 mp->remote_spi = htonl (remote_spi);
14225 mp->crypto_alg = (u8) crypto_alg;
14227 mp->local_crypto_key_len = 0;
14230 mp->local_crypto_key_len = vec_len (lck);
14231 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14232 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14233 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14236 mp->remote_crypto_key_len = 0;
14239 mp->remote_crypto_key_len = vec_len (rck);
14240 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14241 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14242 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14245 mp->integ_alg = (u8) integ_alg;
14247 mp->local_integ_key_len = 0;
14250 mp->local_integ_key_len = vec_len (lik);
14251 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14252 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14253 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14256 mp->remote_integ_key_len = 0;
14259 mp->remote_integ_key_len = vec_len (rik);
14260 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14261 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14262 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14271 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14273 vat_main_t *vam = &vat_main;
14275 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14276 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
14277 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
14278 "tunnel_src_addr %U tunnel_dst_addr %U "
14279 "salt %u seq_outbound %lu last_seq_inbound %lu "
14280 "replay_window %lu total_data_size %lu\n",
14281 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
14283 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
14284 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
14285 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
14286 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14287 mp->tunnel_src_addr,
14288 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14289 mp->tunnel_dst_addr,
14291 clib_net_to_host_u64 (mp->seq_outbound),
14292 clib_net_to_host_u64 (mp->last_seq_inbound),
14293 clib_net_to_host_u64 (mp->replay_window),
14294 clib_net_to_host_u64 (mp->total_data_size));
14297 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14298 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14300 static void vl_api_ipsec_sa_details_t_handler_json
14301 (vl_api_ipsec_sa_details_t * mp)
14303 vat_main_t *vam = &vat_main;
14304 vat_json_node_t *node = NULL;
14305 struct in_addr src_ip4, dst_ip4;
14306 struct in6_addr src_ip6, dst_ip6;
14308 if (VAT_JSON_ARRAY != vam->json_tree.type)
14310 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14311 vat_json_init_array (&vam->json_tree);
14313 node = vat_json_array_add (&vam->json_tree);
14315 vat_json_init_object (node);
14316 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
14317 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14318 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
14319 vat_json_object_add_uint (node, "proto", mp->protocol);
14320 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
14321 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
14322 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
14323 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
14324 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
14325 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
14326 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
14327 mp->crypto_key_len);
14328 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
14329 mp->integ_key_len);
14330 if (mp->is_tunnel_ip6)
14332 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
14333 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
14334 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
14335 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
14339 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
14340 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
14341 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
14342 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
14344 vat_json_object_add_uint (node, "replay_window",
14345 clib_net_to_host_u64 (mp->replay_window));
14346 vat_json_object_add_uint (node, "total_data_size",
14347 clib_net_to_host_u64 (mp->total_data_size));
14352 api_ipsec_sa_dump (vat_main_t * vam)
14354 unformat_input_t *i = vam->input;
14355 vl_api_ipsec_sa_dump_t *mp;
14356 vl_api_control_ping_t *mp_ping;
14360 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14362 if (unformat (i, "sa_id %d", &sa_id))
14366 clib_warning ("parse error '%U'", format_unformat_error, i);
14371 M (IPSEC_SA_DUMP, mp);
14373 mp->sa_id = ntohl (sa_id);
14377 /* Use a control ping for synchronization */
14378 M (CONTROL_PING, mp_ping);
14386 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
14388 unformat_input_t *i = vam->input;
14389 vl_api_ipsec_tunnel_if_set_key_t *mp;
14390 u32 sw_if_index = ~0;
14391 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
14396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14398 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14401 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
14402 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
14404 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
14405 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
14406 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
14407 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
14409 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
14410 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
14411 else if (unformat (i, "%U", unformat_hex_string, &key))
14415 clib_warning ("parse error '%U'", format_unformat_error, i);
14420 if (sw_if_index == ~0)
14422 errmsg ("interface must be specified");
14426 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
14428 errmsg ("key type must be specified");
14434 errmsg ("algorithm must be specified");
14438 if (vec_len (key) == 0)
14440 errmsg ("key must be specified");
14444 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
14446 mp->sw_if_index = htonl (sw_if_index);
14448 mp->key_type = key_type;
14449 mp->key_len = vec_len (key);
14450 clib_memcpy (mp->key, key, vec_len (key));
14459 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
14461 unformat_input_t *i = vam->input;
14462 vl_api_ipsec_tunnel_if_set_sa_t *mp;
14463 u32 sw_if_index = ~0;
14465 u8 is_outbound = (u8) ~ 0;
14468 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14470 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14472 else if (unformat (i, "sa_id %d", &sa_id))
14474 else if (unformat (i, "outbound"))
14476 else if (unformat (i, "inbound"))
14480 clib_warning ("parse error '%U'", format_unformat_error, i);
14485 if (sw_if_index == ~0)
14487 errmsg ("interface must be specified");
14493 errmsg ("SA ID must be specified");
14497 M (IPSEC_TUNNEL_IF_SET_SA, mp);
14499 mp->sw_if_index = htonl (sw_if_index);
14500 mp->sa_id = htonl (sa_id);
14501 mp->is_outbound = is_outbound;
14510 api_ikev2_profile_add_del (vat_main_t * vam)
14512 unformat_input_t *i = vam->input;
14513 vl_api_ikev2_profile_add_del_t *mp;
14518 const char *valid_chars = "a-zA-Z0-9_";
14520 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14522 if (unformat (i, "del"))
14524 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14525 vec_add1 (name, 0);
14528 errmsg ("parse error '%U'", format_unformat_error, i);
14533 if (!vec_len (name))
14535 errmsg ("profile name must be specified");
14539 if (vec_len (name) > 64)
14541 errmsg ("profile name too long");
14545 M (IKEV2_PROFILE_ADD_DEL, mp);
14547 clib_memcpy (mp->name, name, vec_len (name));
14548 mp->is_add = is_add;
14557 api_ikev2_profile_set_auth (vat_main_t * vam)
14559 unformat_input_t *i = vam->input;
14560 vl_api_ikev2_profile_set_auth_t *mp;
14563 u32 auth_method = 0;
14567 const char *valid_chars = "a-zA-Z0-9_";
14569 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14571 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14572 vec_add1 (name, 0);
14573 else if (unformat (i, "auth_method %U",
14574 unformat_ikev2_auth_method, &auth_method))
14576 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
14578 else if (unformat (i, "auth_data %v", &data))
14582 errmsg ("parse error '%U'", format_unformat_error, i);
14587 if (!vec_len (name))
14589 errmsg ("profile name must be specified");
14593 if (vec_len (name) > 64)
14595 errmsg ("profile name too long");
14599 if (!vec_len (data))
14601 errmsg ("auth_data must be specified");
14607 errmsg ("auth_method must be specified");
14611 M (IKEV2_PROFILE_SET_AUTH, mp);
14613 mp->is_hex = is_hex;
14614 mp->auth_method = (u8) auth_method;
14615 mp->data_len = vec_len (data);
14616 clib_memcpy (mp->name, name, vec_len (name));
14617 clib_memcpy (mp->data, data, vec_len (data));
14627 api_ikev2_profile_set_id (vat_main_t * vam)
14629 unformat_input_t *i = vam->input;
14630 vl_api_ikev2_profile_set_id_t *mp;
14638 const char *valid_chars = "a-zA-Z0-9_";
14640 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14642 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14643 vec_add1 (name, 0);
14644 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
14646 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
14648 data = vec_new (u8, 4);
14649 clib_memcpy (data, ip4.as_u8, 4);
14651 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
14653 else if (unformat (i, "id_data %v", &data))
14655 else if (unformat (i, "local"))
14657 else if (unformat (i, "remote"))
14661 errmsg ("parse error '%U'", format_unformat_error, i);
14666 if (!vec_len (name))
14668 errmsg ("profile name must be specified");
14672 if (vec_len (name) > 64)
14674 errmsg ("profile name too long");
14678 if (!vec_len (data))
14680 errmsg ("id_data must be specified");
14686 errmsg ("id_type must be specified");
14690 M (IKEV2_PROFILE_SET_ID, mp);
14692 mp->is_local = is_local;
14693 mp->id_type = (u8) id_type;
14694 mp->data_len = vec_len (data);
14695 clib_memcpy (mp->name, name, vec_len (name));
14696 clib_memcpy (mp->data, data, vec_len (data));
14706 api_ikev2_profile_set_ts (vat_main_t * vam)
14708 unformat_input_t *i = vam->input;
14709 vl_api_ikev2_profile_set_ts_t *mp;
14712 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
14713 ip4_address_t start_addr, end_addr;
14715 const char *valid_chars = "a-zA-Z0-9_";
14718 start_addr.as_u32 = 0;
14719 end_addr.as_u32 = (u32) ~ 0;
14721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14723 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14724 vec_add1 (name, 0);
14725 else if (unformat (i, "protocol %d", &proto))
14727 else if (unformat (i, "start_port %d", &start_port))
14729 else if (unformat (i, "end_port %d", &end_port))
14732 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
14734 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
14736 else if (unformat (i, "local"))
14738 else if (unformat (i, "remote"))
14742 errmsg ("parse error '%U'", format_unformat_error, i);
14747 if (!vec_len (name))
14749 errmsg ("profile name must be specified");
14753 if (vec_len (name) > 64)
14755 errmsg ("profile name too long");
14759 M (IKEV2_PROFILE_SET_TS, mp);
14761 mp->is_local = is_local;
14762 mp->proto = (u8) proto;
14763 mp->start_port = (u16) start_port;
14764 mp->end_port = (u16) end_port;
14765 mp->start_addr = start_addr.as_u32;
14766 mp->end_addr = end_addr.as_u32;
14767 clib_memcpy (mp->name, name, vec_len (name));
14776 api_ikev2_set_local_key (vat_main_t * vam)
14778 unformat_input_t *i = vam->input;
14779 vl_api_ikev2_set_local_key_t *mp;
14783 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14785 if (unformat (i, "file %v", &file))
14786 vec_add1 (file, 0);
14789 errmsg ("parse error '%U'", format_unformat_error, i);
14794 if (!vec_len (file))
14796 errmsg ("RSA key file must be specified");
14800 if (vec_len (file) > 256)
14802 errmsg ("file name too long");
14806 M (IKEV2_SET_LOCAL_KEY, mp);
14808 clib_memcpy (mp->key_file, file, vec_len (file));
14817 api_ikev2_set_responder (vat_main_t * vam)
14819 unformat_input_t *i = vam->input;
14820 vl_api_ikev2_set_responder_t *mp;
14823 u32 sw_if_index = ~0;
14824 ip4_address_t address;
14826 const char *valid_chars = "a-zA-Z0-9_";
14828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14831 (i, "%U interface %d address %U", unformat_token, valid_chars,
14832 &name, &sw_if_index, unformat_ip4_address, &address))
14833 vec_add1 (name, 0);
14836 errmsg ("parse error '%U'", format_unformat_error, i);
14841 if (!vec_len (name))
14843 errmsg ("profile name must be specified");
14847 if (vec_len (name) > 64)
14849 errmsg ("profile name too long");
14853 M (IKEV2_SET_RESPONDER, mp);
14855 clib_memcpy (mp->name, name, vec_len (name));
14858 mp->sw_if_index = sw_if_index;
14859 clib_memcpy (mp->address, &address, sizeof (address));
14867 api_ikev2_set_ike_transforms (vat_main_t * vam)
14869 unformat_input_t *i = vam->input;
14870 vl_api_ikev2_set_ike_transforms_t *mp;
14873 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14875 const char *valid_chars = "a-zA-Z0-9_";
14877 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14879 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14880 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14881 vec_add1 (name, 0);
14884 errmsg ("parse error '%U'", format_unformat_error, i);
14889 if (!vec_len (name))
14891 errmsg ("profile name must be specified");
14895 if (vec_len (name) > 64)
14897 errmsg ("profile name too long");
14901 M (IKEV2_SET_IKE_TRANSFORMS, mp);
14903 clib_memcpy (mp->name, name, vec_len (name));
14905 mp->crypto_alg = crypto_alg;
14906 mp->crypto_key_size = crypto_key_size;
14907 mp->integ_alg = integ_alg;
14908 mp->dh_group = dh_group;
14917 api_ikev2_set_esp_transforms (vat_main_t * vam)
14919 unformat_input_t *i = vam->input;
14920 vl_api_ikev2_set_esp_transforms_t *mp;
14923 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14925 const char *valid_chars = "a-zA-Z0-9_";
14927 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14929 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14930 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14931 vec_add1 (name, 0);
14934 errmsg ("parse error '%U'", format_unformat_error, i);
14939 if (!vec_len (name))
14941 errmsg ("profile name must be specified");
14945 if (vec_len (name) > 64)
14947 errmsg ("profile name too long");
14951 M (IKEV2_SET_ESP_TRANSFORMS, mp);
14953 clib_memcpy (mp->name, name, vec_len (name));
14955 mp->crypto_alg = crypto_alg;
14956 mp->crypto_key_size = crypto_key_size;
14957 mp->integ_alg = integ_alg;
14958 mp->dh_group = dh_group;
14966 api_ikev2_set_sa_lifetime (vat_main_t * vam)
14968 unformat_input_t *i = vam->input;
14969 vl_api_ikev2_set_sa_lifetime_t *mp;
14972 u64 lifetime, lifetime_maxdata;
14973 u32 lifetime_jitter, handover;
14975 const char *valid_chars = "a-zA-Z0-9_";
14977 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14979 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
14980 &lifetime, &lifetime_jitter, &handover,
14981 &lifetime_maxdata))
14982 vec_add1 (name, 0);
14985 errmsg ("parse error '%U'", format_unformat_error, i);
14990 if (!vec_len (name))
14992 errmsg ("profile name must be specified");
14996 if (vec_len (name) > 64)
14998 errmsg ("profile name too long");
15002 M (IKEV2_SET_SA_LIFETIME, mp);
15004 clib_memcpy (mp->name, name, vec_len (name));
15006 mp->lifetime = lifetime;
15007 mp->lifetime_jitter = lifetime_jitter;
15008 mp->handover = handover;
15009 mp->lifetime_maxdata = lifetime_maxdata;
15017 api_ikev2_initiate_sa_init (vat_main_t * vam)
15019 unformat_input_t *i = vam->input;
15020 vl_api_ikev2_initiate_sa_init_t *mp;
15024 const char *valid_chars = "a-zA-Z0-9_";
15026 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15028 if (unformat (i, "%U", unformat_token, valid_chars, &name))
15029 vec_add1 (name, 0);
15032 errmsg ("parse error '%U'", format_unformat_error, i);
15037 if (!vec_len (name))
15039 errmsg ("profile name must be specified");
15043 if (vec_len (name) > 64)
15045 errmsg ("profile name too long");
15049 M (IKEV2_INITIATE_SA_INIT, mp);
15051 clib_memcpy (mp->name, name, vec_len (name));
15060 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
15062 unformat_input_t *i = vam->input;
15063 vl_api_ikev2_initiate_del_ike_sa_t *mp;
15068 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15070 if (unformat (i, "%lx", &ispi))
15074 errmsg ("parse error '%U'", format_unformat_error, i);
15079 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
15089 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
15091 unformat_input_t *i = vam->input;
15092 vl_api_ikev2_initiate_del_child_sa_t *mp;
15097 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15099 if (unformat (i, "%x", &ispi))
15103 errmsg ("parse error '%U'", format_unformat_error, i);
15108 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
15118 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
15120 unformat_input_t *i = vam->input;
15121 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
15126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15128 if (unformat (i, "%x", &ispi))
15132 errmsg ("parse error '%U'", format_unformat_error, i);
15137 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
15150 api_map_add_domain (vat_main_t * vam)
15152 unformat_input_t *i = vam->input;
15153 vl_api_map_add_domain_t *mp;
15155 ip4_address_t ip4_prefix;
15156 ip6_address_t ip6_prefix;
15157 ip6_address_t ip6_src;
15158 u32 num_m_args = 0;
15159 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
15160 0, psid_length = 0;
15161 u8 is_translation = 0;
15163 u32 ip6_src_len = 128;
15166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15168 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
15169 &ip4_prefix, &ip4_prefix_len))
15171 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
15172 &ip6_prefix, &ip6_prefix_len))
15176 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
15179 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
15181 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
15183 else if (unformat (i, "psid-offset %d", &psid_offset))
15185 else if (unformat (i, "psid-len %d", &psid_length))
15187 else if (unformat (i, "mtu %d", &mtu))
15189 else if (unformat (i, "map-t"))
15190 is_translation = 1;
15193 clib_warning ("parse error '%U'", format_unformat_error, i);
15198 if (num_m_args < 3)
15200 errmsg ("mandatory argument(s) missing");
15204 /* Construct the API message */
15205 M (MAP_ADD_DOMAIN, mp);
15207 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
15208 mp->ip4_prefix_len = ip4_prefix_len;
15210 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
15211 mp->ip6_prefix_len = ip6_prefix_len;
15213 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
15214 mp->ip6_src_prefix_len = ip6_src_len;
15216 mp->ea_bits_len = ea_bits_len;
15217 mp->psid_offset = psid_offset;
15218 mp->psid_length = psid_length;
15219 mp->is_translation = is_translation;
15220 mp->mtu = htons (mtu);
15225 /* Wait for a reply, return good/bad news */
15231 api_map_del_domain (vat_main_t * vam)
15233 unformat_input_t *i = vam->input;
15234 vl_api_map_del_domain_t *mp;
15236 u32 num_m_args = 0;
15240 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15242 if (unformat (i, "index %d", &index))
15246 clib_warning ("parse error '%U'", format_unformat_error, i);
15251 if (num_m_args != 1)
15253 errmsg ("mandatory argument(s) missing");
15257 /* Construct the API message */
15258 M (MAP_DEL_DOMAIN, mp);
15260 mp->index = ntohl (index);
15265 /* Wait for a reply, return good/bad news */
15271 api_map_add_del_rule (vat_main_t * vam)
15273 unformat_input_t *i = vam->input;
15274 vl_api_map_add_del_rule_t *mp;
15276 ip6_address_t ip6_dst;
15277 u32 num_m_args = 0, index, psid = 0;
15280 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15282 if (unformat (i, "index %d", &index))
15284 else if (unformat (i, "psid %d", &psid))
15286 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
15288 else if (unformat (i, "del"))
15294 clib_warning ("parse error '%U'", format_unformat_error, i);
15299 /* Construct the API message */
15300 M (MAP_ADD_DEL_RULE, mp);
15302 mp->index = ntohl (index);
15303 mp->is_add = is_add;
15304 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
15305 mp->psid = ntohs (psid);
15310 /* Wait for a reply, return good/bad news */
15316 api_map_domain_dump (vat_main_t * vam)
15318 vl_api_map_domain_dump_t *mp;
15319 vl_api_control_ping_t *mp_ping;
15322 /* Construct the API message */
15323 M (MAP_DOMAIN_DUMP, mp);
15328 /* Use a control ping for synchronization */
15329 MPING (CONTROL_PING, mp_ping);
15337 api_map_rule_dump (vat_main_t * vam)
15339 unformat_input_t *i = vam->input;
15340 vl_api_map_rule_dump_t *mp;
15341 vl_api_control_ping_t *mp_ping;
15342 u32 domain_index = ~0;
15345 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15347 if (unformat (i, "index %u", &domain_index))
15353 if (domain_index == ~0)
15355 clib_warning ("parse error: domain index expected");
15359 /* Construct the API message */
15360 M (MAP_RULE_DUMP, mp);
15362 mp->domain_index = htonl (domain_index);
15367 /* Use a control ping for synchronization */
15368 MPING (CONTROL_PING, mp_ping);
15375 static void vl_api_map_add_domain_reply_t_handler
15376 (vl_api_map_add_domain_reply_t * mp)
15378 vat_main_t *vam = &vat_main;
15379 i32 retval = ntohl (mp->retval);
15381 if (vam->async_mode)
15383 vam->async_errors += (retval < 0);
15387 vam->retval = retval;
15388 vam->result_ready = 1;
15392 static void vl_api_map_add_domain_reply_t_handler_json
15393 (vl_api_map_add_domain_reply_t * mp)
15395 vat_main_t *vam = &vat_main;
15396 vat_json_node_t node;
15398 vat_json_init_object (&node);
15399 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
15400 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
15402 vat_json_print (vam->ofp, &node);
15403 vat_json_free (&node);
15405 vam->retval = ntohl (mp->retval);
15406 vam->result_ready = 1;
15410 api_get_first_msg_id (vat_main_t * vam)
15412 vl_api_get_first_msg_id_t *mp;
15413 unformat_input_t *i = vam->input;
15418 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15420 if (unformat (i, "client %s", &name))
15428 errmsg ("missing client name");
15431 vec_add1 (name, 0);
15433 if (vec_len (name) > 63)
15435 errmsg ("client name too long");
15439 M (GET_FIRST_MSG_ID, mp);
15440 clib_memcpy (mp->name, name, vec_len (name));
15447 api_cop_interface_enable_disable (vat_main_t * vam)
15449 unformat_input_t *line_input = vam->input;
15450 vl_api_cop_interface_enable_disable_t *mp;
15451 u32 sw_if_index = ~0;
15452 u8 enable_disable = 1;
15455 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15457 if (unformat (line_input, "disable"))
15458 enable_disable = 0;
15459 if (unformat (line_input, "enable"))
15460 enable_disable = 1;
15461 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15462 vam, &sw_if_index))
15464 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15470 if (sw_if_index == ~0)
15472 errmsg ("missing interface name or sw_if_index");
15476 /* Construct the API message */
15477 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15478 mp->sw_if_index = ntohl (sw_if_index);
15479 mp->enable_disable = enable_disable;
15483 /* Wait for the reply */
15489 api_cop_whitelist_enable_disable (vat_main_t * vam)
15491 unformat_input_t *line_input = vam->input;
15492 vl_api_cop_whitelist_enable_disable_t *mp;
15493 u32 sw_if_index = ~0;
15494 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15498 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15500 if (unformat (line_input, "ip4"))
15502 else if (unformat (line_input, "ip6"))
15504 else if (unformat (line_input, "default"))
15506 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15507 vam, &sw_if_index))
15509 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15511 else if (unformat (line_input, "fib-id %d", &fib_id))
15517 if (sw_if_index == ~0)
15519 errmsg ("missing interface name or sw_if_index");
15523 /* Construct the API message */
15524 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15525 mp->sw_if_index = ntohl (sw_if_index);
15526 mp->fib_id = ntohl (fib_id);
15529 mp->default_cop = default_cop;
15533 /* Wait for the reply */
15539 api_get_node_graph (vat_main_t * vam)
15541 vl_api_get_node_graph_t *mp;
15544 M (GET_NODE_GRAPH, mp);
15548 /* Wait for the reply */
15554 /** Used for parsing LISP eids */
15555 typedef CLIB_PACKED(struct{
15556 u8 addr[16]; /**< eid address */
15557 u32 len; /**< prefix length if IP */
15558 u8 type; /**< type of eid */
15563 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15565 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15567 memset (a, 0, sizeof (a[0]));
15569 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15571 a->type = 0; /* ipv4 type */
15573 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15575 a->type = 1; /* ipv6 type */
15577 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15579 a->type = 2; /* mac type */
15581 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15583 a->type = 3; /* NSH type */
15584 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15585 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15592 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15601 lisp_eid_size_vat (u8 type)
15618 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15620 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15624 api_one_add_del_locator_set (vat_main_t * vam)
15626 unformat_input_t *input = vam->input;
15627 vl_api_one_add_del_locator_set_t *mp;
15629 u8 *locator_set_name = NULL;
15630 u8 locator_set_name_set = 0;
15631 vl_api_local_locator_t locator, *locators = 0;
15632 u32 sw_if_index, priority, weight;
15636 /* Parse args required to build the message */
15637 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15639 if (unformat (input, "del"))
15643 else if (unformat (input, "locator-set %s", &locator_set_name))
15645 locator_set_name_set = 1;
15647 else if (unformat (input, "sw_if_index %u p %u w %u",
15648 &sw_if_index, &priority, &weight))
15650 locator.sw_if_index = htonl (sw_if_index);
15651 locator.priority = priority;
15652 locator.weight = weight;
15653 vec_add1 (locators, locator);
15657 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15658 &sw_if_index, &priority, &weight))
15660 locator.sw_if_index = htonl (sw_if_index);
15661 locator.priority = priority;
15662 locator.weight = weight;
15663 vec_add1 (locators, locator);
15669 if (locator_set_name_set == 0)
15671 errmsg ("missing locator-set name");
15672 vec_free (locators);
15676 if (vec_len (locator_set_name) > 64)
15678 errmsg ("locator-set name too long");
15679 vec_free (locator_set_name);
15680 vec_free (locators);
15683 vec_add1 (locator_set_name, 0);
15685 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15687 /* Construct the API message */
15688 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15690 mp->is_add = is_add;
15691 clib_memcpy (mp->locator_set_name, locator_set_name,
15692 vec_len (locator_set_name));
15693 vec_free (locator_set_name);
15695 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15697 clib_memcpy (mp->locators, locators, data_len);
15698 vec_free (locators);
15703 /* Wait for a reply... */
15708 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15711 api_one_add_del_locator (vat_main_t * vam)
15713 unformat_input_t *input = vam->input;
15714 vl_api_one_add_del_locator_t *mp;
15715 u32 tmp_if_index = ~0;
15716 u32 sw_if_index = ~0;
15717 u8 sw_if_index_set = 0;
15718 u8 sw_if_index_if_name_set = 0;
15720 u8 priority_set = 0;
15724 u8 *locator_set_name = NULL;
15725 u8 locator_set_name_set = 0;
15728 /* Parse args required to build the message */
15729 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15731 if (unformat (input, "del"))
15735 else if (unformat (input, "locator-set %s", &locator_set_name))
15737 locator_set_name_set = 1;
15739 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15742 sw_if_index_if_name_set = 1;
15743 sw_if_index = tmp_if_index;
15745 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15747 sw_if_index_set = 1;
15748 sw_if_index = tmp_if_index;
15750 else if (unformat (input, "p %d", &priority))
15754 else if (unformat (input, "w %d", &weight))
15762 if (locator_set_name_set == 0)
15764 errmsg ("missing locator-set name");
15768 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15770 errmsg ("missing sw_if_index");
15771 vec_free (locator_set_name);
15775 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15777 errmsg ("cannot use both params interface name and sw_if_index");
15778 vec_free (locator_set_name);
15782 if (priority_set == 0)
15784 errmsg ("missing locator-set priority");
15785 vec_free (locator_set_name);
15789 if (weight_set == 0)
15791 errmsg ("missing locator-set weight");
15792 vec_free (locator_set_name);
15796 if (vec_len (locator_set_name) > 64)
15798 errmsg ("locator-set name too long");
15799 vec_free (locator_set_name);
15802 vec_add1 (locator_set_name, 0);
15804 /* Construct the API message */
15805 M (ONE_ADD_DEL_LOCATOR, mp);
15807 mp->is_add = is_add;
15808 mp->sw_if_index = ntohl (sw_if_index);
15809 mp->priority = priority;
15810 mp->weight = weight;
15811 clib_memcpy (mp->locator_set_name, locator_set_name,
15812 vec_len (locator_set_name));
15813 vec_free (locator_set_name);
15818 /* Wait for a reply... */
15823 #define api_lisp_add_del_locator api_one_add_del_locator
15826 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15828 u32 *key_id = va_arg (*args, u32 *);
15831 if (unformat (input, "%s", &s))
15833 if (!strcmp ((char *) s, "sha1"))
15834 key_id[0] = HMAC_SHA_1_96;
15835 else if (!strcmp ((char *) s, "sha256"))
15836 key_id[0] = HMAC_SHA_256_128;
15839 clib_warning ("invalid key_id: '%s'", s);
15840 key_id[0] = HMAC_NO_KEY;
15851 api_one_add_del_local_eid (vat_main_t * vam)
15853 unformat_input_t *input = vam->input;
15854 vl_api_one_add_del_local_eid_t *mp;
15857 lisp_eid_vat_t _eid, *eid = &_eid;
15858 u8 *locator_set_name = 0;
15859 u8 locator_set_name_set = 0;
15865 /* Parse args required to build the message */
15866 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15868 if (unformat (input, "del"))
15872 else if (unformat (input, "vni %d", &vni))
15876 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15880 else if (unformat (input, "locator-set %s", &locator_set_name))
15882 locator_set_name_set = 1;
15884 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15886 else if (unformat (input, "secret-key %_%v%_", &key))
15892 if (locator_set_name_set == 0)
15894 errmsg ("missing locator-set name");
15900 errmsg ("EID address not set!");
15901 vec_free (locator_set_name);
15905 if (key && (0 == key_id))
15907 errmsg ("invalid key_id!");
15911 if (vec_len (key) > 64)
15913 errmsg ("key too long");
15918 if (vec_len (locator_set_name) > 64)
15920 errmsg ("locator-set name too long");
15921 vec_free (locator_set_name);
15924 vec_add1 (locator_set_name, 0);
15926 /* Construct the API message */
15927 M (ONE_ADD_DEL_LOCAL_EID, mp);
15929 mp->is_add = is_add;
15930 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15931 mp->eid_type = eid->type;
15932 mp->prefix_len = eid->len;
15933 mp->vni = clib_host_to_net_u32 (vni);
15934 mp->key_id = clib_host_to_net_u16 (key_id);
15935 clib_memcpy (mp->locator_set_name, locator_set_name,
15936 vec_len (locator_set_name));
15937 clib_memcpy (mp->key, key, vec_len (key));
15939 vec_free (locator_set_name);
15945 /* Wait for a reply... */
15950 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15953 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15955 u32 dp_table = 0, vni = 0;;
15956 unformat_input_t *input = vam->input;
15957 vl_api_gpe_add_del_fwd_entry_t *mp;
15959 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15960 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15961 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15962 u32 action = ~0, w;
15963 ip4_address_t rmt_rloc4, lcl_rloc4;
15964 ip6_address_t rmt_rloc6, lcl_rloc6;
15965 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15968 memset (&rloc, 0, sizeof (rloc));
15970 /* Parse args required to build the message */
15971 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15973 if (unformat (input, "del"))
15975 else if (unformat (input, "add"))
15977 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15981 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15985 else if (unformat (input, "vrf %d", &dp_table))
15987 else if (unformat (input, "bd %d", &dp_table))
15989 else if (unformat (input, "vni %d", &vni))
15991 else if (unformat (input, "w %d", &w))
15995 errmsg ("No RLOC configured for setting priority/weight!");
15998 curr_rloc->weight = w;
16000 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
16001 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
16005 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
16007 vec_add1 (lcl_locs, rloc);
16009 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
16010 vec_add1 (rmt_locs, rloc);
16011 /* weight saved in rmt loc */
16012 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16014 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
16015 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
16018 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
16020 vec_add1 (lcl_locs, rloc);
16022 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
16023 vec_add1 (rmt_locs, rloc);
16024 /* weight saved in rmt loc */
16025 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16027 else if (unformat (input, "action %d", &action))
16033 clib_warning ("parse error '%U'", format_unformat_error, input);
16040 errmsg ("remote eid addresses not set");
16044 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
16046 errmsg ("eid types don't match");
16050 if (0 == rmt_locs && (u32) ~ 0 == action)
16052 errmsg ("action not set for negative mapping");
16056 /* Construct the API message */
16057 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
16058 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
16060 mp->is_add = is_add;
16061 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
16062 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
16063 mp->eid_type = rmt_eid->type;
16064 mp->dp_table = clib_host_to_net_u32 (dp_table);
16065 mp->vni = clib_host_to_net_u32 (vni);
16066 mp->rmt_len = rmt_eid->len;
16067 mp->lcl_len = lcl_eid->len;
16068 mp->action = action;
16070 if (0 != rmt_locs && 0 != lcl_locs)
16072 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
16073 clib_memcpy (mp->locs, lcl_locs,
16074 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
16076 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
16077 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
16078 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
16080 vec_free (lcl_locs);
16081 vec_free (rmt_locs);
16086 /* Wait for a reply... */
16092 api_one_add_del_map_server (vat_main_t * vam)
16094 unformat_input_t *input = vam->input;
16095 vl_api_one_add_del_map_server_t *mp;
16099 ip4_address_t ipv4;
16100 ip6_address_t ipv6;
16103 /* Parse args required to build the message */
16104 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16106 if (unformat (input, "del"))
16110 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16114 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16122 if (ipv4_set && ipv6_set)
16124 errmsg ("both eid v4 and v6 addresses set");
16128 if (!ipv4_set && !ipv6_set)
16130 errmsg ("eid addresses not set");
16134 /* Construct the API message */
16135 M (ONE_ADD_DEL_MAP_SERVER, mp);
16137 mp->is_add = is_add;
16141 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16146 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16152 /* Wait for a reply... */
16157 #define api_lisp_add_del_map_server api_one_add_del_map_server
16160 api_one_add_del_map_resolver (vat_main_t * vam)
16162 unformat_input_t *input = vam->input;
16163 vl_api_one_add_del_map_resolver_t *mp;
16167 ip4_address_t ipv4;
16168 ip6_address_t ipv6;
16171 /* Parse args required to build the message */
16172 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16174 if (unformat (input, "del"))
16178 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16182 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16190 if (ipv4_set && ipv6_set)
16192 errmsg ("both eid v4 and v6 addresses set");
16196 if (!ipv4_set && !ipv6_set)
16198 errmsg ("eid addresses not set");
16202 /* Construct the API message */
16203 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
16205 mp->is_add = is_add;
16209 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16214 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16220 /* Wait for a reply... */
16225 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
16228 api_lisp_gpe_enable_disable (vat_main_t * vam)
16230 unformat_input_t *input = vam->input;
16231 vl_api_gpe_enable_disable_t *mp;
16236 /* Parse args required to build the message */
16237 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16239 if (unformat (input, "enable"))
16244 else if (unformat (input, "disable"))
16255 errmsg ("Value not set");
16259 /* Construct the API message */
16260 M (GPE_ENABLE_DISABLE, mp);
16267 /* Wait for a reply... */
16273 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16275 unformat_input_t *input = vam->input;
16276 vl_api_one_rloc_probe_enable_disable_t *mp;
16281 /* Parse args required to build the message */
16282 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16284 if (unformat (input, "enable"))
16289 else if (unformat (input, "disable"))
16297 errmsg ("Value not set");
16301 /* Construct the API message */
16302 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16304 mp->is_enabled = is_en;
16309 /* Wait for a reply... */
16314 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16317 api_one_map_register_enable_disable (vat_main_t * vam)
16319 unformat_input_t *input = vam->input;
16320 vl_api_one_map_register_enable_disable_t *mp;
16325 /* Parse args required to build the message */
16326 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16328 if (unformat (input, "enable"))
16333 else if (unformat (input, "disable"))
16341 errmsg ("Value not set");
16345 /* Construct the API message */
16346 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16348 mp->is_enabled = is_en;
16353 /* Wait for a reply... */
16358 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16361 api_one_enable_disable (vat_main_t * vam)
16363 unformat_input_t *input = vam->input;
16364 vl_api_one_enable_disable_t *mp;
16369 /* Parse args required to build the message */
16370 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16372 if (unformat (input, "enable"))
16377 else if (unformat (input, "disable"))
16387 errmsg ("Value not set");
16391 /* Construct the API message */
16392 M (ONE_ENABLE_DISABLE, mp);
16399 /* Wait for a reply... */
16404 #define api_lisp_enable_disable api_one_enable_disable
16407 api_show_one_map_register_state (vat_main_t * vam)
16409 vl_api_show_one_map_register_state_t *mp;
16412 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16417 /* wait for reply */
16422 #define api_show_lisp_map_register_state api_show_one_map_register_state
16425 api_show_one_rloc_probe_state (vat_main_t * vam)
16427 vl_api_show_one_rloc_probe_state_t *mp;
16430 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16435 /* wait for reply */
16440 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16443 api_one_add_del_ndp_entry (vat_main_t * vam)
16445 vl_api_one_add_del_ndp_entry_t *mp;
16446 unformat_input_t *input = vam->input;
16451 u8 mac[6] = { 0, };
16452 u8 ip6[16] = { 0, };
16456 /* Parse args required to build the message */
16457 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16459 if (unformat (input, "del"))
16461 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16463 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16465 else if (unformat (input, "bd %d", &bd))
16469 errmsg ("parse error '%U'", format_unformat_error, input);
16474 if (!bd_set || !ip_set || (!mac_set && is_add))
16476 errmsg ("Missing BD, IP or MAC!");
16480 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16481 mp->is_add = is_add;
16482 clib_memcpy (mp->mac, mac, 6);
16483 mp->bd = clib_host_to_net_u32 (bd);
16484 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16489 /* wait for reply */
16495 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16497 vl_api_one_add_del_l2_arp_entry_t *mp;
16498 unformat_input_t *input = vam->input;
16503 u8 mac[6] = { 0, };
16504 u32 ip4 = 0, bd = ~0;
16507 /* Parse args required to build the message */
16508 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16510 if (unformat (input, "del"))
16512 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16514 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16516 else if (unformat (input, "bd %d", &bd))
16520 errmsg ("parse error '%U'", format_unformat_error, input);
16525 if (!bd_set || !ip_set || (!mac_set && is_add))
16527 errmsg ("Missing BD, IP or MAC!");
16531 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16532 mp->is_add = is_add;
16533 clib_memcpy (mp->mac, mac, 6);
16534 mp->bd = clib_host_to_net_u32 (bd);
16540 /* wait for reply */
16546 api_one_ndp_bd_get (vat_main_t * vam)
16548 vl_api_one_ndp_bd_get_t *mp;
16551 M (ONE_NDP_BD_GET, mp);
16556 /* wait for reply */
16562 api_one_ndp_entries_get (vat_main_t * vam)
16564 vl_api_one_ndp_entries_get_t *mp;
16565 unformat_input_t *input = vam->input;
16570 /* Parse args required to build the message */
16571 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16573 if (unformat (input, "bd %d", &bd))
16577 errmsg ("parse error '%U'", format_unformat_error, input);
16584 errmsg ("Expected bridge domain!");
16588 M (ONE_NDP_ENTRIES_GET, mp);
16589 mp->bd = clib_host_to_net_u32 (bd);
16594 /* wait for reply */
16600 api_one_l2_arp_bd_get (vat_main_t * vam)
16602 vl_api_one_l2_arp_bd_get_t *mp;
16605 M (ONE_L2_ARP_BD_GET, mp);
16610 /* wait for reply */
16616 api_one_l2_arp_entries_get (vat_main_t * vam)
16618 vl_api_one_l2_arp_entries_get_t *mp;
16619 unformat_input_t *input = vam->input;
16624 /* Parse args required to build the message */
16625 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16627 if (unformat (input, "bd %d", &bd))
16631 errmsg ("parse error '%U'", format_unformat_error, input);
16638 errmsg ("Expected bridge domain!");
16642 M (ONE_L2_ARP_ENTRIES_GET, mp);
16643 mp->bd = clib_host_to_net_u32 (bd);
16648 /* wait for reply */
16654 api_one_stats_enable_disable (vat_main_t * vam)
16656 vl_api_one_stats_enable_disable_t *mp;
16657 unformat_input_t *input = vam->input;
16662 /* Parse args required to build the message */
16663 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16665 if (unformat (input, "enable"))
16670 else if (unformat (input, "disable"))
16680 errmsg ("Value not set");
16684 M (ONE_STATS_ENABLE_DISABLE, mp);
16690 /* wait for reply */
16696 api_show_one_stats_enable_disable (vat_main_t * vam)
16698 vl_api_show_one_stats_enable_disable_t *mp;
16701 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16706 /* wait for reply */
16712 api_show_one_map_request_mode (vat_main_t * vam)
16714 vl_api_show_one_map_request_mode_t *mp;
16717 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16722 /* wait for reply */
16727 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16730 api_one_map_request_mode (vat_main_t * vam)
16732 unformat_input_t *input = vam->input;
16733 vl_api_one_map_request_mode_t *mp;
16737 /* Parse args required to build the message */
16738 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16740 if (unformat (input, "dst-only"))
16742 else if (unformat (input, "src-dst"))
16746 errmsg ("parse error '%U'", format_unformat_error, input);
16751 M (ONE_MAP_REQUEST_MODE, mp);
16758 /* wait for reply */
16763 #define api_lisp_map_request_mode api_one_map_request_mode
16766 * Enable/disable ONE proxy ITR.
16768 * @param vam vpp API test context
16769 * @return return code
16772 api_one_pitr_set_locator_set (vat_main_t * vam)
16774 u8 ls_name_set = 0;
16775 unformat_input_t *input = vam->input;
16776 vl_api_one_pitr_set_locator_set_t *mp;
16781 /* Parse args required to build the message */
16782 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16784 if (unformat (input, "del"))
16786 else if (unformat (input, "locator-set %s", &ls_name))
16790 errmsg ("parse error '%U'", format_unformat_error, input);
16797 errmsg ("locator-set name not set!");
16801 M (ONE_PITR_SET_LOCATOR_SET, mp);
16803 mp->is_add = is_add;
16804 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16805 vec_free (ls_name);
16810 /* wait for reply */
16815 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16818 api_one_nsh_set_locator_set (vat_main_t * vam)
16820 u8 ls_name_set = 0;
16821 unformat_input_t *input = vam->input;
16822 vl_api_one_nsh_set_locator_set_t *mp;
16827 /* Parse args required to build the message */
16828 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16830 if (unformat (input, "del"))
16832 else if (unformat (input, "ls %s", &ls_name))
16836 errmsg ("parse error '%U'", format_unformat_error, input);
16841 if (!ls_name_set && is_add)
16843 errmsg ("locator-set name not set!");
16847 M (ONE_NSH_SET_LOCATOR_SET, mp);
16849 mp->is_add = is_add;
16850 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16851 vec_free (ls_name);
16856 /* wait for reply */
16862 api_show_one_pitr (vat_main_t * vam)
16864 vl_api_show_one_pitr_t *mp;
16867 if (!vam->json_output)
16869 print (vam->ofp, "%=20s", "lisp status:");
16872 M (SHOW_ONE_PITR, mp);
16876 /* Wait for a reply... */
16881 #define api_show_lisp_pitr api_show_one_pitr
16884 api_one_use_petr (vat_main_t * vam)
16886 unformat_input_t *input = vam->input;
16887 vl_api_one_use_petr_t *mp;
16892 memset (&ip, 0, sizeof (ip));
16894 /* Parse args required to build the message */
16895 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16897 if (unformat (input, "disable"))
16900 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16903 ip_addr_version (&ip) = IP4;
16906 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16909 ip_addr_version (&ip) = IP6;
16913 errmsg ("parse error '%U'", format_unformat_error, input);
16918 M (ONE_USE_PETR, mp);
16920 mp->is_add = is_add;
16923 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16925 clib_memcpy (mp->address, &ip, 4);
16927 clib_memcpy (mp->address, &ip, 16);
16933 /* wait for reply */
16938 #define api_lisp_use_petr api_one_use_petr
16941 api_show_one_nsh_mapping (vat_main_t * vam)
16943 vl_api_show_one_use_petr_t *mp;
16946 if (!vam->json_output)
16948 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16951 M (SHOW_ONE_NSH_MAPPING, mp);
16955 /* Wait for a reply... */
16961 api_show_one_use_petr (vat_main_t * vam)
16963 vl_api_show_one_use_petr_t *mp;
16966 if (!vam->json_output)
16968 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16971 M (SHOW_ONE_USE_PETR, mp);
16975 /* Wait for a reply... */
16980 #define api_show_lisp_use_petr api_show_one_use_petr
16983 * Add/delete mapping between vni and vrf
16986 api_one_eid_table_add_del_map (vat_main_t * vam)
16988 unformat_input_t *input = vam->input;
16989 vl_api_one_eid_table_add_del_map_t *mp;
16990 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16991 u32 vni, vrf, bd_index;
16994 /* Parse args required to build the message */
16995 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16997 if (unformat (input, "del"))
16999 else if (unformat (input, "vrf %d", &vrf))
17001 else if (unformat (input, "bd_index %d", &bd_index))
17003 else if (unformat (input, "vni %d", &vni))
17009 if (!vni_set || (!vrf_set && !bd_index_set))
17011 errmsg ("missing arguments!");
17015 if (vrf_set && bd_index_set)
17017 errmsg ("error: both vrf and bd entered!");
17021 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
17023 mp->is_add = is_add;
17024 mp->vni = htonl (vni);
17025 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
17026 mp->is_l2 = bd_index_set;
17031 /* wait for reply */
17036 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
17039 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
17041 u32 *action = va_arg (*args, u32 *);
17044 if (unformat (input, "%s", &s))
17046 if (!strcmp ((char *) s, "no-action"))
17048 else if (!strcmp ((char *) s, "natively-forward"))
17050 else if (!strcmp ((char *) s, "send-map-request"))
17052 else if (!strcmp ((char *) s, "drop"))
17056 clib_warning ("invalid action: '%s'", s);
17068 * Add/del remote mapping to/from ONE control plane
17070 * @param vam vpp API test context
17071 * @return return code
17074 api_one_add_del_remote_mapping (vat_main_t * vam)
17076 unformat_input_t *input = vam->input;
17077 vl_api_one_add_del_remote_mapping_t *mp;
17079 lisp_eid_vat_t _eid, *eid = &_eid;
17080 lisp_eid_vat_t _seid, *seid = &_seid;
17081 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
17082 u32 action = ~0, p, w, data_len;
17083 ip4_address_t rloc4;
17084 ip6_address_t rloc6;
17085 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
17088 memset (&rloc, 0, sizeof (rloc));
17090 /* Parse args required to build the message */
17091 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17093 if (unformat (input, "del-all"))
17097 else if (unformat (input, "del"))
17101 else if (unformat (input, "add"))
17105 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17109 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
17113 else if (unformat (input, "vni %d", &vni))
17117 else if (unformat (input, "p %d w %d", &p, &w))
17121 errmsg ("No RLOC configured for setting priority/weight!");
17124 curr_rloc->priority = p;
17125 curr_rloc->weight = w;
17127 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
17130 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
17131 vec_add1 (rlocs, rloc);
17132 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17134 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
17137 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
17138 vec_add1 (rlocs, rloc);
17139 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17141 else if (unformat (input, "action %U",
17142 unformat_negative_mapping_action, &action))
17148 clib_warning ("parse error '%U'", format_unformat_error, input);
17155 errmsg ("missing params!");
17159 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
17161 errmsg ("no action set for negative map-reply!");
17165 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
17167 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
17168 mp->is_add = is_add;
17169 mp->vni = htonl (vni);
17170 mp->action = (u8) action;
17171 mp->is_src_dst = seid_set;
17172 mp->eid_len = eid->len;
17173 mp->seid_len = seid->len;
17174 mp->del_all = del_all;
17175 mp->eid_type = eid->type;
17176 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17177 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
17179 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
17180 clib_memcpy (mp->rlocs, rlocs, data_len);
17186 /* Wait for a reply... */
17191 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
17194 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
17195 * forwarding entries in data-plane accordingly.
17197 * @param vam vpp API test context
17198 * @return return code
17201 api_one_add_del_adjacency (vat_main_t * vam)
17203 unformat_input_t *input = vam->input;
17204 vl_api_one_add_del_adjacency_t *mp;
17206 ip4_address_t leid4, reid4;
17207 ip6_address_t leid6, reid6;
17208 u8 reid_mac[6] = { 0 };
17209 u8 leid_mac[6] = { 0 };
17210 u8 reid_type, leid_type;
17211 u32 leid_len = 0, reid_len = 0, len;
17215 leid_type = reid_type = (u8) ~ 0;
17217 /* Parse args required to build the message */
17218 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17220 if (unformat (input, "del"))
17224 else if (unformat (input, "add"))
17228 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17231 reid_type = 0; /* ipv4 */
17234 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17237 reid_type = 1; /* ipv6 */
17240 else if (unformat (input, "reid %U", unformat_ethernet_address,
17243 reid_type = 2; /* mac */
17245 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17248 leid_type = 0; /* ipv4 */
17251 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17254 leid_type = 1; /* ipv6 */
17257 else if (unformat (input, "leid %U", unformat_ethernet_address,
17260 leid_type = 2; /* mac */
17262 else if (unformat (input, "vni %d", &vni))
17268 errmsg ("parse error '%U'", format_unformat_error, input);
17273 if ((u8) ~ 0 == reid_type)
17275 errmsg ("missing params!");
17279 if (leid_type != reid_type)
17281 errmsg ("remote and local EIDs are of different types!");
17285 M (ONE_ADD_DEL_ADJACENCY, mp);
17286 mp->is_add = is_add;
17287 mp->vni = htonl (vni);
17288 mp->leid_len = leid_len;
17289 mp->reid_len = reid_len;
17290 mp->eid_type = reid_type;
17292 switch (mp->eid_type)
17295 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17296 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17299 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17300 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17303 clib_memcpy (mp->leid, leid_mac, 6);
17304 clib_memcpy (mp->reid, reid_mac, 6);
17307 errmsg ("unknown EID type %d!", mp->eid_type);
17314 /* Wait for a reply... */
17319 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17322 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17324 u32 *mode = va_arg (*args, u32 *);
17326 if (unformat (input, "lisp"))
17328 else if (unformat (input, "vxlan"))
17337 api_gpe_get_encap_mode (vat_main_t * vam)
17339 vl_api_gpe_get_encap_mode_t *mp;
17342 /* Construct the API message */
17343 M (GPE_GET_ENCAP_MODE, mp);
17348 /* Wait for a reply... */
17354 api_gpe_set_encap_mode (vat_main_t * vam)
17356 unformat_input_t *input = vam->input;
17357 vl_api_gpe_set_encap_mode_t *mp;
17361 /* Parse args required to build the message */
17362 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17364 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17370 /* Construct the API message */
17371 M (GPE_SET_ENCAP_MODE, mp);
17378 /* Wait for a reply... */
17384 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17386 unformat_input_t *input = vam->input;
17387 vl_api_gpe_add_del_iface_t *mp;
17388 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17389 u32 dp_table = 0, vni = 0;
17392 /* Parse args required to build the message */
17393 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17395 if (unformat (input, "up"))
17400 else if (unformat (input, "down"))
17405 else if (unformat (input, "table_id %d", &dp_table))
17409 else if (unformat (input, "bd_id %d", &dp_table))
17414 else if (unformat (input, "vni %d", &vni))
17422 if (action_set == 0)
17424 errmsg ("Action not set");
17427 if (dp_table_set == 0 || vni_set == 0)
17429 errmsg ("vni and dp_table must be set");
17433 /* Construct the API message */
17434 M (GPE_ADD_DEL_IFACE, mp);
17436 mp->is_add = is_add;
17437 mp->dp_table = clib_host_to_net_u32 (dp_table);
17439 mp->vni = clib_host_to_net_u32 (vni);
17444 /* Wait for a reply... */
17450 api_one_map_register_fallback_threshold (vat_main_t * vam)
17452 unformat_input_t *input = vam->input;
17453 vl_api_one_map_register_fallback_threshold_t *mp;
17458 /* Parse args required to build the message */
17459 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17461 if (unformat (input, "%u", &value))
17465 clib_warning ("parse error '%U'", format_unformat_error, input);
17472 errmsg ("fallback threshold value is missing!");
17476 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17477 mp->value = clib_host_to_net_u32 (value);
17482 /* Wait for a reply... */
17488 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17490 vl_api_show_one_map_register_fallback_threshold_t *mp;
17493 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17498 /* Wait for a reply... */
17504 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17506 u32 *proto = va_arg (*args, u32 *);
17508 if (unformat (input, "udp"))
17510 else if (unformat (input, "api"))
17519 api_one_set_transport_protocol (vat_main_t * vam)
17521 unformat_input_t *input = vam->input;
17522 vl_api_one_set_transport_protocol_t *mp;
17527 /* Parse args required to build the message */
17528 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17530 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17534 clib_warning ("parse error '%U'", format_unformat_error, input);
17541 errmsg ("Transport protocol missing!");
17545 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17546 mp->protocol = (u8) protocol;
17551 /* Wait for a reply... */
17557 api_one_get_transport_protocol (vat_main_t * vam)
17559 vl_api_one_get_transport_protocol_t *mp;
17562 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17567 /* Wait for a reply... */
17573 api_one_map_register_set_ttl (vat_main_t * vam)
17575 unformat_input_t *input = vam->input;
17576 vl_api_one_map_register_set_ttl_t *mp;
17581 /* Parse args required to build the message */
17582 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17584 if (unformat (input, "%u", &ttl))
17588 clib_warning ("parse error '%U'", format_unformat_error, input);
17595 errmsg ("TTL value missing!");
17599 M (ONE_MAP_REGISTER_SET_TTL, mp);
17600 mp->ttl = clib_host_to_net_u32 (ttl);
17605 /* Wait for a reply... */
17611 api_show_one_map_register_ttl (vat_main_t * vam)
17613 vl_api_show_one_map_register_ttl_t *mp;
17616 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17621 /* Wait for a reply... */
17627 * Add/del map request itr rlocs from ONE control plane and updates
17629 * @param vam vpp API test context
17630 * @return return code
17633 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17635 unformat_input_t *input = vam->input;
17636 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17637 u8 *locator_set_name = 0;
17638 u8 locator_set_name_set = 0;
17642 /* Parse args required to build the message */
17643 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17645 if (unformat (input, "del"))
17649 else if (unformat (input, "%_%v%_", &locator_set_name))
17651 locator_set_name_set = 1;
17655 clib_warning ("parse error '%U'", format_unformat_error, input);
17660 if (is_add && !locator_set_name_set)
17662 errmsg ("itr-rloc is not set!");
17666 if (is_add && vec_len (locator_set_name) > 64)
17668 errmsg ("itr-rloc locator-set name too long");
17669 vec_free (locator_set_name);
17673 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17674 mp->is_add = is_add;
17677 clib_memcpy (mp->locator_set_name, locator_set_name,
17678 vec_len (locator_set_name));
17682 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17684 vec_free (locator_set_name);
17689 /* Wait for a reply... */
17694 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17697 api_one_locator_dump (vat_main_t * vam)
17699 unformat_input_t *input = vam->input;
17700 vl_api_one_locator_dump_t *mp;
17701 vl_api_control_ping_t *mp_ping;
17702 u8 is_index_set = 0, is_name_set = 0;
17707 /* Parse args required to build the message */
17708 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17710 if (unformat (input, "ls_name %_%v%_", &ls_name))
17714 else if (unformat (input, "ls_index %d", &ls_index))
17720 errmsg ("parse error '%U'", format_unformat_error, input);
17725 if (!is_index_set && !is_name_set)
17727 errmsg ("error: expected one of index or name!");
17731 if (is_index_set && is_name_set)
17733 errmsg ("error: only one param expected!");
17737 if (vec_len (ls_name) > 62)
17739 errmsg ("error: locator set name too long!");
17743 if (!vam->json_output)
17745 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17748 M (ONE_LOCATOR_DUMP, mp);
17749 mp->is_index_set = is_index_set;
17752 mp->ls_index = clib_host_to_net_u32 (ls_index);
17755 vec_add1 (ls_name, 0);
17756 strncpy ((char *) mp->ls_name, (char *) ls_name,
17757 sizeof (mp->ls_name) - 1);
17763 /* Use a control ping for synchronization */
17764 MPING (CONTROL_PING, mp_ping);
17767 /* Wait for a reply... */
17772 #define api_lisp_locator_dump api_one_locator_dump
17775 api_one_locator_set_dump (vat_main_t * vam)
17777 vl_api_one_locator_set_dump_t *mp;
17778 vl_api_control_ping_t *mp_ping;
17779 unformat_input_t *input = vam->input;
17783 /* Parse args required to build the message */
17784 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17786 if (unformat (input, "local"))
17790 else if (unformat (input, "remote"))
17796 errmsg ("parse error '%U'", format_unformat_error, input);
17801 if (!vam->json_output)
17803 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17806 M (ONE_LOCATOR_SET_DUMP, mp);
17808 mp->filter = filter;
17813 /* Use a control ping for synchronization */
17814 MPING (CONTROL_PING, mp_ping);
17817 /* Wait for a reply... */
17822 #define api_lisp_locator_set_dump api_one_locator_set_dump
17825 api_one_eid_table_map_dump (vat_main_t * vam)
17829 unformat_input_t *input = vam->input;
17830 vl_api_one_eid_table_map_dump_t *mp;
17831 vl_api_control_ping_t *mp_ping;
17834 /* Parse args required to build the message */
17835 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17837 if (unformat (input, "l2"))
17842 else if (unformat (input, "l3"))
17849 errmsg ("parse error '%U'", format_unformat_error, input);
17856 errmsg ("expected one of 'l2' or 'l3' parameter!");
17860 if (!vam->json_output)
17862 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17865 M (ONE_EID_TABLE_MAP_DUMP, mp);
17871 /* Use a control ping for synchronization */
17872 MPING (CONTROL_PING, mp_ping);
17875 /* Wait for a reply... */
17880 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17883 api_one_eid_table_vni_dump (vat_main_t * vam)
17885 vl_api_one_eid_table_vni_dump_t *mp;
17886 vl_api_control_ping_t *mp_ping;
17889 if (!vam->json_output)
17891 print (vam->ofp, "VNI");
17894 M (ONE_EID_TABLE_VNI_DUMP, mp);
17899 /* Use a control ping for synchronization */
17900 MPING (CONTROL_PING, mp_ping);
17903 /* Wait for a reply... */
17908 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17911 api_one_eid_table_dump (vat_main_t * vam)
17913 unformat_input_t *i = vam->input;
17914 vl_api_one_eid_table_dump_t *mp;
17915 vl_api_control_ping_t *mp_ping;
17916 struct in_addr ip4;
17917 struct in6_addr ip6;
17919 u8 eid_type = ~0, eid_set = 0;
17920 u32 prefix_length = ~0, t, vni = 0;
17923 lisp_nsh_api_t nsh;
17925 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17927 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17933 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17939 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17944 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17949 else if (unformat (i, "vni %d", &t))
17953 else if (unformat (i, "local"))
17957 else if (unformat (i, "remote"))
17963 errmsg ("parse error '%U'", format_unformat_error, i);
17968 if (!vam->json_output)
17970 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17971 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17974 M (ONE_EID_TABLE_DUMP, mp);
17976 mp->filter = filter;
17980 mp->vni = htonl (vni);
17981 mp->eid_type = eid_type;
17985 mp->prefix_length = prefix_length;
17986 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17989 mp->prefix_length = prefix_length;
17990 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17993 clib_memcpy (mp->eid, mac, sizeof (mac));
17996 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17999 errmsg ("unknown EID type %d!", eid_type);
18007 /* Use a control ping for synchronization */
18008 MPING (CONTROL_PING, mp_ping);
18011 /* Wait for a reply... */
18016 #define api_lisp_eid_table_dump api_one_eid_table_dump
18019 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
18021 unformat_input_t *i = vam->input;
18022 vl_api_gpe_fwd_entries_get_t *mp;
18027 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18029 if (unformat (i, "vni %d", &vni))
18035 errmsg ("parse error '%U'", format_unformat_error, i);
18042 errmsg ("vni not set!");
18046 if (!vam->json_output)
18048 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
18052 M (GPE_FWD_ENTRIES_GET, mp);
18053 mp->vni = clib_host_to_net_u32 (vni);
18058 /* Wait for a reply... */
18063 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
18064 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
18065 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
18066 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
18067 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
18068 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
18069 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
18070 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
18073 api_one_adjacencies_get (vat_main_t * vam)
18075 unformat_input_t *i = vam->input;
18076 vl_api_one_adjacencies_get_t *mp;
18081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18083 if (unformat (i, "vni %d", &vni))
18089 errmsg ("parse error '%U'", format_unformat_error, i);
18096 errmsg ("vni not set!");
18100 if (!vam->json_output)
18102 print (vam->ofp, "%s %40s", "leid", "reid");
18105 M (ONE_ADJACENCIES_GET, mp);
18106 mp->vni = clib_host_to_net_u32 (vni);
18111 /* Wait for a reply... */
18116 #define api_lisp_adjacencies_get api_one_adjacencies_get
18119 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
18121 unformat_input_t *i = vam->input;
18122 vl_api_gpe_native_fwd_rpaths_get_t *mp;
18124 u8 ip_family_set = 0, is_ip4 = 1;
18126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18128 if (unformat (i, "ip4"))
18133 else if (unformat (i, "ip6"))
18140 errmsg ("parse error '%U'", format_unformat_error, i);
18145 if (!ip_family_set)
18147 errmsg ("ip family not set!");
18151 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
18152 mp->is_ip4 = is_ip4;
18157 /* Wait for a reply... */
18163 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
18165 vl_api_gpe_fwd_entry_vnis_get_t *mp;
18168 if (!vam->json_output)
18170 print (vam->ofp, "VNIs");
18173 M (GPE_FWD_ENTRY_VNIS_GET, mp);
18178 /* Wait for a reply... */
18184 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
18186 unformat_input_t *i = vam->input;
18187 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
18189 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
18190 struct in_addr ip4;
18191 struct in6_addr ip6;
18192 u32 table_id = 0, nh_sw_if_index = ~0;
18194 memset (&ip4, 0, sizeof (ip4));
18195 memset (&ip6, 0, sizeof (ip6));
18197 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18199 if (unformat (i, "del"))
18201 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
18202 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18207 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
18208 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18213 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18217 nh_sw_if_index = ~0;
18219 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18223 nh_sw_if_index = ~0;
18225 else if (unformat (i, "table %d", &table_id))
18229 errmsg ("parse error '%U'", format_unformat_error, i);
18236 errmsg ("nh addr not set!");
18240 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18241 mp->is_add = is_add;
18242 mp->table_id = clib_host_to_net_u32 (table_id);
18243 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18244 mp->is_ip4 = is_ip4;
18246 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18248 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18253 /* Wait for a reply... */
18259 api_one_map_server_dump (vat_main_t * vam)
18261 vl_api_one_map_server_dump_t *mp;
18262 vl_api_control_ping_t *mp_ping;
18265 if (!vam->json_output)
18267 print (vam->ofp, "%=20s", "Map server");
18270 M (ONE_MAP_SERVER_DUMP, mp);
18274 /* Use a control ping for synchronization */
18275 MPING (CONTROL_PING, mp_ping);
18278 /* Wait for a reply... */
18283 #define api_lisp_map_server_dump api_one_map_server_dump
18286 api_one_map_resolver_dump (vat_main_t * vam)
18288 vl_api_one_map_resolver_dump_t *mp;
18289 vl_api_control_ping_t *mp_ping;
18292 if (!vam->json_output)
18294 print (vam->ofp, "%=20s", "Map resolver");
18297 M (ONE_MAP_RESOLVER_DUMP, mp);
18301 /* Use a control ping for synchronization */
18302 MPING (CONTROL_PING, mp_ping);
18305 /* Wait for a reply... */
18310 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18313 api_one_stats_flush (vat_main_t * vam)
18315 vl_api_one_stats_flush_t *mp;
18318 M (ONE_STATS_FLUSH, mp);
18325 api_one_stats_dump (vat_main_t * vam)
18327 vl_api_one_stats_dump_t *mp;
18328 vl_api_control_ping_t *mp_ping;
18331 M (ONE_STATS_DUMP, mp);
18335 /* Use a control ping for synchronization */
18336 MPING (CONTROL_PING, mp_ping);
18339 /* Wait for a reply... */
18345 api_show_one_status (vat_main_t * vam)
18347 vl_api_show_one_status_t *mp;
18350 if (!vam->json_output)
18352 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18355 M (SHOW_ONE_STATUS, mp);
18358 /* Wait for a reply... */
18363 #define api_show_lisp_status api_show_one_status
18366 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18368 vl_api_gpe_fwd_entry_path_dump_t *mp;
18369 vl_api_control_ping_t *mp_ping;
18370 unformat_input_t *i = vam->input;
18371 u32 fwd_entry_index = ~0;
18374 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18376 if (unformat (i, "index %d", &fwd_entry_index))
18382 if (~0 == fwd_entry_index)
18384 errmsg ("no index specified!");
18388 if (!vam->json_output)
18390 print (vam->ofp, "first line");
18393 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18397 /* Use a control ping for synchronization */
18398 MPING (CONTROL_PING, mp_ping);
18401 /* Wait for a reply... */
18407 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18409 vl_api_one_get_map_request_itr_rlocs_t *mp;
18412 if (!vam->json_output)
18414 print (vam->ofp, "%=20s", "itr-rlocs:");
18417 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18420 /* Wait for a reply... */
18425 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18428 api_af_packet_create (vat_main_t * vam)
18430 unformat_input_t *i = vam->input;
18431 vl_api_af_packet_create_t *mp;
18432 u8 *host_if_name = 0;
18434 u8 random_hw_addr = 1;
18437 memset (hw_addr, 0, sizeof (hw_addr));
18439 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18441 if (unformat (i, "name %s", &host_if_name))
18442 vec_add1 (host_if_name, 0);
18443 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18444 random_hw_addr = 0;
18449 if (!vec_len (host_if_name))
18451 errmsg ("host-interface name must be specified");
18455 if (vec_len (host_if_name) > 64)
18457 errmsg ("host-interface name too long");
18461 M (AF_PACKET_CREATE, mp);
18463 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18464 clib_memcpy (mp->hw_addr, hw_addr, 6);
18465 mp->use_random_hw_addr = random_hw_addr;
18466 vec_free (host_if_name);
18474 fprintf (vam->ofp ? vam->ofp : stderr,
18475 " new sw_if_index = %d\n", vam->sw_if_index);
18482 api_af_packet_delete (vat_main_t * vam)
18484 unformat_input_t *i = vam->input;
18485 vl_api_af_packet_delete_t *mp;
18486 u8 *host_if_name = 0;
18489 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18491 if (unformat (i, "name %s", &host_if_name))
18492 vec_add1 (host_if_name, 0);
18497 if (!vec_len (host_if_name))
18499 errmsg ("host-interface name must be specified");
18503 if (vec_len (host_if_name) > 64)
18505 errmsg ("host-interface name too long");
18509 M (AF_PACKET_DELETE, mp);
18511 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18512 vec_free (host_if_name);
18520 api_policer_add_del (vat_main_t * vam)
18522 unformat_input_t *i = vam->input;
18523 vl_api_policer_add_del_t *mp;
18533 u8 color_aware = 0;
18534 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18537 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18538 conform_action.dscp = 0;
18539 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18540 exceed_action.dscp = 0;
18541 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18542 violate_action.dscp = 0;
18544 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18546 if (unformat (i, "del"))
18548 else if (unformat (i, "name %s", &name))
18549 vec_add1 (name, 0);
18550 else if (unformat (i, "cir %u", &cir))
18552 else if (unformat (i, "eir %u", &eir))
18554 else if (unformat (i, "cb %u", &cb))
18556 else if (unformat (i, "eb %u", &eb))
18558 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18561 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18564 else if (unformat (i, "type %U", unformat_policer_type, &type))
18566 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18569 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18572 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18575 else if (unformat (i, "color-aware"))
18581 if (!vec_len (name))
18583 errmsg ("policer name must be specified");
18587 if (vec_len (name) > 64)
18589 errmsg ("policer name too long");
18593 M (POLICER_ADD_DEL, mp);
18595 clib_memcpy (mp->name, name, vec_len (name));
18597 mp->is_add = is_add;
18598 mp->cir = ntohl (cir);
18599 mp->eir = ntohl (eir);
18600 mp->cb = clib_net_to_host_u64 (cb);
18601 mp->eb = clib_net_to_host_u64 (eb);
18602 mp->rate_type = rate_type;
18603 mp->round_type = round_type;
18605 mp->conform_action_type = conform_action.action_type;
18606 mp->conform_dscp = conform_action.dscp;
18607 mp->exceed_action_type = exceed_action.action_type;
18608 mp->exceed_dscp = exceed_action.dscp;
18609 mp->violate_action_type = violate_action.action_type;
18610 mp->violate_dscp = violate_action.dscp;
18611 mp->color_aware = color_aware;
18619 api_policer_dump (vat_main_t * vam)
18621 unformat_input_t *i = vam->input;
18622 vl_api_policer_dump_t *mp;
18623 vl_api_control_ping_t *mp_ping;
18624 u8 *match_name = 0;
18625 u8 match_name_valid = 0;
18628 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18630 if (unformat (i, "name %s", &match_name))
18632 vec_add1 (match_name, 0);
18633 match_name_valid = 1;
18639 M (POLICER_DUMP, mp);
18640 mp->match_name_valid = match_name_valid;
18641 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18642 vec_free (match_name);
18646 /* Use a control ping for synchronization */
18647 MPING (CONTROL_PING, mp_ping);
18650 /* Wait for a reply... */
18656 api_policer_classify_set_interface (vat_main_t * vam)
18658 unformat_input_t *i = vam->input;
18659 vl_api_policer_classify_set_interface_t *mp;
18661 int sw_if_index_set;
18662 u32 ip4_table_index = ~0;
18663 u32 ip6_table_index = ~0;
18664 u32 l2_table_index = ~0;
18668 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18670 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18671 sw_if_index_set = 1;
18672 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18673 sw_if_index_set = 1;
18674 else if (unformat (i, "del"))
18676 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18678 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18680 else if (unformat (i, "l2-table %d", &l2_table_index))
18684 clib_warning ("parse error '%U'", format_unformat_error, i);
18689 if (sw_if_index_set == 0)
18691 errmsg ("missing interface name or sw_if_index");
18695 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18697 mp->sw_if_index = ntohl (sw_if_index);
18698 mp->ip4_table_index = ntohl (ip4_table_index);
18699 mp->ip6_table_index = ntohl (ip6_table_index);
18700 mp->l2_table_index = ntohl (l2_table_index);
18701 mp->is_add = is_add;
18709 api_policer_classify_dump (vat_main_t * vam)
18711 unformat_input_t *i = vam->input;
18712 vl_api_policer_classify_dump_t *mp;
18713 vl_api_control_ping_t *mp_ping;
18714 u8 type = POLICER_CLASSIFY_N_TABLES;
18717 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18721 errmsg ("classify table type must be specified");
18725 if (!vam->json_output)
18727 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18730 M (POLICER_CLASSIFY_DUMP, mp);
18735 /* Use a control ping for synchronization */
18736 MPING (CONTROL_PING, mp_ping);
18739 /* Wait for a reply... */
18745 api_netmap_create (vat_main_t * vam)
18747 unformat_input_t *i = vam->input;
18748 vl_api_netmap_create_t *mp;
18751 u8 random_hw_addr = 1;
18756 memset (hw_addr, 0, sizeof (hw_addr));
18758 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18760 if (unformat (i, "name %s", &if_name))
18761 vec_add1 (if_name, 0);
18762 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18763 random_hw_addr = 0;
18764 else if (unformat (i, "pipe"))
18766 else if (unformat (i, "master"))
18768 else if (unformat (i, "slave"))
18774 if (!vec_len (if_name))
18776 errmsg ("interface name must be specified");
18780 if (vec_len (if_name) > 64)
18782 errmsg ("interface name too long");
18786 M (NETMAP_CREATE, mp);
18788 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18789 clib_memcpy (mp->hw_addr, hw_addr, 6);
18790 mp->use_random_hw_addr = random_hw_addr;
18791 mp->is_pipe = is_pipe;
18792 mp->is_master = is_master;
18793 vec_free (if_name);
18801 api_netmap_delete (vat_main_t * vam)
18803 unformat_input_t *i = vam->input;
18804 vl_api_netmap_delete_t *mp;
18808 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18810 if (unformat (i, "name %s", &if_name))
18811 vec_add1 (if_name, 0);
18816 if (!vec_len (if_name))
18818 errmsg ("interface name must be specified");
18822 if (vec_len (if_name) > 64)
18824 errmsg ("interface name too long");
18828 M (NETMAP_DELETE, mp);
18830 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18831 vec_free (if_name);
18839 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
18841 if (fp->afi == IP46_TYPE_IP6)
18843 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18844 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18845 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18846 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18847 format_ip6_address, fp->next_hop);
18848 else if (fp->afi == IP46_TYPE_IP4)
18850 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18851 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18852 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18853 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18854 format_ip4_address, fp->next_hop);
18858 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18859 vl_api_fib_path2_t * fp)
18861 struct in_addr ip4;
18862 struct in6_addr ip6;
18864 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18865 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18866 vat_json_object_add_uint (node, "is_local", fp->is_local);
18867 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18868 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18869 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18870 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18871 if (fp->afi == IP46_TYPE_IP4)
18873 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18874 vat_json_object_add_ip4 (node, "next_hop", ip4);
18876 else if (fp->afi == IP46_TYPE_IP6)
18878 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18879 vat_json_object_add_ip6 (node, "next_hop", ip6);
18884 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18886 vat_main_t *vam = &vat_main;
18887 int count = ntohl (mp->mt_count);
18888 vl_api_fib_path2_t *fp;
18891 print (vam->ofp, "[%d]: sw_if_index %d via:",
18892 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
18894 for (i = 0; i < count; i++)
18896 vl_api_mpls_fib_path_print (vam, fp);
18900 print (vam->ofp, "");
18903 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18904 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18907 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18909 vat_main_t *vam = &vat_main;
18910 vat_json_node_t *node = NULL;
18911 int count = ntohl (mp->mt_count);
18912 vl_api_fib_path2_t *fp;
18915 if (VAT_JSON_ARRAY != vam->json_tree.type)
18917 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18918 vat_json_init_array (&vam->json_tree);
18920 node = vat_json_array_add (&vam->json_tree);
18922 vat_json_init_object (node);
18923 vat_json_object_add_uint (node, "tunnel_index",
18924 ntohl (mp->mt_tunnel_index));
18925 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
18927 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
18930 for (i = 0; i < count; i++)
18932 vl_api_mpls_fib_path_json_print (node, fp);
18938 api_mpls_tunnel_dump (vat_main_t * vam)
18940 vl_api_mpls_tunnel_dump_t *mp;
18941 vl_api_control_ping_t *mp_ping;
18945 /* Parse args required to build the message */
18946 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
18948 if (!unformat (vam->input, "tunnel_index %d", &index))
18955 print (vam->ofp, " tunnel_index %d", index);
18957 M (MPLS_TUNNEL_DUMP, mp);
18958 mp->tunnel_index = htonl (index);
18961 /* Use a control ping for synchronization */
18962 MPING (CONTROL_PING, mp_ping);
18969 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
18970 #define vl_api_mpls_fib_details_t_print vl_noop_handler
18974 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
18976 vat_main_t *vam = &vat_main;
18977 int count = ntohl (mp->count);
18978 vl_api_fib_path2_t *fp;
18982 "table-id %d, label %u, ess_bit %u",
18983 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
18985 for (i = 0; i < count; i++)
18987 vl_api_mpls_fib_path_print (vam, fp);
18992 static void vl_api_mpls_fib_details_t_handler_json
18993 (vl_api_mpls_fib_details_t * mp)
18995 vat_main_t *vam = &vat_main;
18996 int count = ntohl (mp->count);
18997 vat_json_node_t *node = NULL;
18998 vl_api_fib_path2_t *fp;
19001 if (VAT_JSON_ARRAY != vam->json_tree.type)
19003 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19004 vat_json_init_array (&vam->json_tree);
19006 node = vat_json_array_add (&vam->json_tree);
19008 vat_json_init_object (node);
19009 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19010 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
19011 vat_json_object_add_uint (node, "label", ntohl (mp->label));
19012 vat_json_object_add_uint (node, "path_count", count);
19014 for (i = 0; i < count; i++)
19016 vl_api_mpls_fib_path_json_print (node, fp);
19022 api_mpls_fib_dump (vat_main_t * vam)
19024 vl_api_mpls_fib_dump_t *mp;
19025 vl_api_control_ping_t *mp_ping;
19028 M (MPLS_FIB_DUMP, mp);
19031 /* Use a control ping for synchronization */
19032 MPING (CONTROL_PING, mp_ping);
19039 #define vl_api_ip_fib_details_t_endian vl_noop_handler
19040 #define vl_api_ip_fib_details_t_print vl_noop_handler
19043 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
19045 vat_main_t *vam = &vat_main;
19046 int count = ntohl (mp->count);
19047 vl_api_fib_path_t *fp;
19051 "table-id %d, prefix %U/%d",
19052 ntohl (mp->table_id), format_ip4_address, mp->address,
19053 mp->address_length);
19055 for (i = 0; i < count; i++)
19057 if (fp->afi == IP46_TYPE_IP6)
19059 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19060 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19061 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19062 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19063 format_ip6_address, fp->next_hop);
19064 else if (fp->afi == IP46_TYPE_IP4)
19066 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19067 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19068 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19069 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19070 format_ip4_address, fp->next_hop);
19075 static void vl_api_ip_fib_details_t_handler_json
19076 (vl_api_ip_fib_details_t * mp)
19078 vat_main_t *vam = &vat_main;
19079 int count = ntohl (mp->count);
19080 vat_json_node_t *node = NULL;
19081 struct in_addr ip4;
19082 struct in6_addr ip6;
19083 vl_api_fib_path_t *fp;
19086 if (VAT_JSON_ARRAY != vam->json_tree.type)
19088 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19089 vat_json_init_array (&vam->json_tree);
19091 node = vat_json_array_add (&vam->json_tree);
19093 vat_json_init_object (node);
19094 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19095 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
19096 vat_json_object_add_ip4 (node, "prefix", ip4);
19097 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19098 vat_json_object_add_uint (node, "path_count", count);
19100 for (i = 0; i < count; i++)
19102 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19103 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19104 vat_json_object_add_uint (node, "is_local", fp->is_local);
19105 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19106 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19107 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19108 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19109 if (fp->afi == IP46_TYPE_IP4)
19111 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19112 vat_json_object_add_ip4 (node, "next_hop", ip4);
19114 else if (fp->afi == IP46_TYPE_IP6)
19116 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19117 vat_json_object_add_ip6 (node, "next_hop", ip6);
19123 api_ip_fib_dump (vat_main_t * vam)
19125 vl_api_ip_fib_dump_t *mp;
19126 vl_api_control_ping_t *mp_ping;
19129 M (IP_FIB_DUMP, mp);
19132 /* Use a control ping for synchronization */
19133 MPING (CONTROL_PING, mp_ping);
19141 api_ip_mfib_dump (vat_main_t * vam)
19143 vl_api_ip_mfib_dump_t *mp;
19144 vl_api_control_ping_t *mp_ping;
19147 M (IP_MFIB_DUMP, mp);
19150 /* Use a control ping for synchronization */
19151 MPING (CONTROL_PING, mp_ping);
19158 static void vl_api_ip_neighbor_details_t_handler
19159 (vl_api_ip_neighbor_details_t * mp)
19161 vat_main_t *vam = &vat_main;
19163 print (vam->ofp, "%c %U %U",
19164 (mp->is_static) ? 'S' : 'D',
19165 format_ethernet_address, &mp->mac_address,
19166 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
19170 static void vl_api_ip_neighbor_details_t_handler_json
19171 (vl_api_ip_neighbor_details_t * mp)
19174 vat_main_t *vam = &vat_main;
19175 vat_json_node_t *node;
19176 struct in_addr ip4;
19177 struct in6_addr ip6;
19179 if (VAT_JSON_ARRAY != vam->json_tree.type)
19181 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19182 vat_json_init_array (&vam->json_tree);
19184 node = vat_json_array_add (&vam->json_tree);
19186 vat_json_init_object (node);
19187 vat_json_object_add_string_copy (node, "flag",
19188 (mp->is_static) ? (u8 *) "static" : (u8 *)
19191 vat_json_object_add_string_copy (node, "link_layer",
19192 format (0, "%U", format_ethernet_address,
19193 &mp->mac_address));
19197 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
19198 vat_json_object_add_ip6 (node, "ip_address", ip6);
19202 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
19203 vat_json_object_add_ip4 (node, "ip_address", ip4);
19208 api_ip_neighbor_dump (vat_main_t * vam)
19210 unformat_input_t *i = vam->input;
19211 vl_api_ip_neighbor_dump_t *mp;
19212 vl_api_control_ping_t *mp_ping;
19214 u32 sw_if_index = ~0;
19217 /* Parse args required to build the message */
19218 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19220 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19222 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19224 else if (unformat (i, "ip6"))
19230 if (sw_if_index == ~0)
19232 errmsg ("missing interface name or sw_if_index");
19236 M (IP_NEIGHBOR_DUMP, mp);
19237 mp->is_ipv6 = (u8) is_ipv6;
19238 mp->sw_if_index = ntohl (sw_if_index);
19241 /* Use a control ping for synchronization */
19242 MPING (CONTROL_PING, mp_ping);
19249 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
19250 #define vl_api_ip6_fib_details_t_print vl_noop_handler
19253 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
19255 vat_main_t *vam = &vat_main;
19256 int count = ntohl (mp->count);
19257 vl_api_fib_path_t *fp;
19261 "table-id %d, prefix %U/%d",
19262 ntohl (mp->table_id), format_ip6_address, mp->address,
19263 mp->address_length);
19265 for (i = 0; i < count; i++)
19267 if (fp->afi == IP46_TYPE_IP6)
19269 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19270 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19271 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19272 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19273 format_ip6_address, fp->next_hop);
19274 else if (fp->afi == IP46_TYPE_IP4)
19276 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19277 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19278 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19279 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19280 format_ip4_address, fp->next_hop);
19285 static void vl_api_ip6_fib_details_t_handler_json
19286 (vl_api_ip6_fib_details_t * mp)
19288 vat_main_t *vam = &vat_main;
19289 int count = ntohl (mp->count);
19290 vat_json_node_t *node = NULL;
19291 struct in_addr ip4;
19292 struct in6_addr ip6;
19293 vl_api_fib_path_t *fp;
19296 if (VAT_JSON_ARRAY != vam->json_tree.type)
19298 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19299 vat_json_init_array (&vam->json_tree);
19301 node = vat_json_array_add (&vam->json_tree);
19303 vat_json_init_object (node);
19304 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19305 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
19306 vat_json_object_add_ip6 (node, "prefix", ip6);
19307 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19308 vat_json_object_add_uint (node, "path_count", count);
19310 for (i = 0; i < count; i++)
19312 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19313 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19314 vat_json_object_add_uint (node, "is_local", fp->is_local);
19315 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19316 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19317 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19318 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19319 if (fp->afi == IP46_TYPE_IP4)
19321 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19322 vat_json_object_add_ip4 (node, "next_hop", ip4);
19324 else if (fp->afi == IP46_TYPE_IP6)
19326 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19327 vat_json_object_add_ip6 (node, "next_hop", ip6);
19333 api_ip6_fib_dump (vat_main_t * vam)
19335 vl_api_ip6_fib_dump_t *mp;
19336 vl_api_control_ping_t *mp_ping;
19339 M (IP6_FIB_DUMP, mp);
19342 /* Use a control ping for synchronization */
19343 MPING (CONTROL_PING, mp_ping);
19351 api_ip6_mfib_dump (vat_main_t * vam)
19353 vl_api_ip6_mfib_dump_t *mp;
19354 vl_api_control_ping_t *mp_ping;
19357 M (IP6_MFIB_DUMP, mp);
19360 /* Use a control ping for synchronization */
19361 MPING (CONTROL_PING, mp_ping);
19369 api_classify_table_ids (vat_main_t * vam)
19371 vl_api_classify_table_ids_t *mp;
19374 /* Construct the API message */
19375 M (CLASSIFY_TABLE_IDS, mp);
19384 api_classify_table_by_interface (vat_main_t * vam)
19386 unformat_input_t *input = vam->input;
19387 vl_api_classify_table_by_interface_t *mp;
19389 u32 sw_if_index = ~0;
19391 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19393 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19395 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19400 if (sw_if_index == ~0)
19402 errmsg ("missing interface name or sw_if_index");
19406 /* Construct the API message */
19407 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19409 mp->sw_if_index = ntohl (sw_if_index);
19417 api_classify_table_info (vat_main_t * vam)
19419 unformat_input_t *input = vam->input;
19420 vl_api_classify_table_info_t *mp;
19424 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19426 if (unformat (input, "table_id %d", &table_id))
19431 if (table_id == ~0)
19433 errmsg ("missing table id");
19437 /* Construct the API message */
19438 M (CLASSIFY_TABLE_INFO, mp);
19440 mp->table_id = ntohl (table_id);
19448 api_classify_session_dump (vat_main_t * vam)
19450 unformat_input_t *input = vam->input;
19451 vl_api_classify_session_dump_t *mp;
19452 vl_api_control_ping_t *mp_ping;
19456 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19458 if (unformat (input, "table_id %d", &table_id))
19463 if (table_id == ~0)
19465 errmsg ("missing table id");
19469 /* Construct the API message */
19470 M (CLASSIFY_SESSION_DUMP, mp);
19472 mp->table_id = ntohl (table_id);
19475 /* Use a control ping for synchronization */
19476 MPING (CONTROL_PING, mp_ping);
19484 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19486 vat_main_t *vam = &vat_main;
19488 print (vam->ofp, "collector_address %U, collector_port %d, "
19489 "src_address %U, vrf_id %d, path_mtu %u, "
19490 "template_interval %u, udp_checksum %d",
19491 format_ip4_address, mp->collector_address,
19492 ntohs (mp->collector_port),
19493 format_ip4_address, mp->src_address,
19494 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19495 ntohl (mp->template_interval), mp->udp_checksum);
19498 vam->result_ready = 1;
19502 vl_api_ipfix_exporter_details_t_handler_json
19503 (vl_api_ipfix_exporter_details_t * mp)
19505 vat_main_t *vam = &vat_main;
19506 vat_json_node_t node;
19507 struct in_addr collector_address;
19508 struct in_addr src_address;
19510 vat_json_init_object (&node);
19511 clib_memcpy (&collector_address, &mp->collector_address,
19512 sizeof (collector_address));
19513 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19514 vat_json_object_add_uint (&node, "collector_port",
19515 ntohs (mp->collector_port));
19516 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19517 vat_json_object_add_ip4 (&node, "src_address", src_address);
19518 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19519 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19520 vat_json_object_add_uint (&node, "template_interval",
19521 ntohl (mp->template_interval));
19522 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19524 vat_json_print (vam->ofp, &node);
19525 vat_json_free (&node);
19527 vam->result_ready = 1;
19531 api_ipfix_exporter_dump (vat_main_t * vam)
19533 vl_api_ipfix_exporter_dump_t *mp;
19536 /* Construct the API message */
19537 M (IPFIX_EXPORTER_DUMP, mp);
19546 api_ipfix_classify_stream_dump (vat_main_t * vam)
19548 vl_api_ipfix_classify_stream_dump_t *mp;
19551 /* Construct the API message */
19552 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19563 vl_api_ipfix_classify_stream_details_t_handler
19564 (vl_api_ipfix_classify_stream_details_t * mp)
19566 vat_main_t *vam = &vat_main;
19567 print (vam->ofp, "domain_id %d, src_port %d",
19568 ntohl (mp->domain_id), ntohs (mp->src_port));
19570 vam->result_ready = 1;
19574 vl_api_ipfix_classify_stream_details_t_handler_json
19575 (vl_api_ipfix_classify_stream_details_t * mp)
19577 vat_main_t *vam = &vat_main;
19578 vat_json_node_t node;
19580 vat_json_init_object (&node);
19581 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19582 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19584 vat_json_print (vam->ofp, &node);
19585 vat_json_free (&node);
19587 vam->result_ready = 1;
19591 api_ipfix_classify_table_dump (vat_main_t * vam)
19593 vl_api_ipfix_classify_table_dump_t *mp;
19594 vl_api_control_ping_t *mp_ping;
19597 if (!vam->json_output)
19599 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19600 "transport_protocol");
19603 /* Construct the API message */
19604 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19609 /* Use a control ping for synchronization */
19610 MPING (CONTROL_PING, mp_ping);
19618 vl_api_ipfix_classify_table_details_t_handler
19619 (vl_api_ipfix_classify_table_details_t * mp)
19621 vat_main_t *vam = &vat_main;
19622 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19623 mp->transport_protocol);
19627 vl_api_ipfix_classify_table_details_t_handler_json
19628 (vl_api_ipfix_classify_table_details_t * mp)
19630 vat_json_node_t *node = NULL;
19631 vat_main_t *vam = &vat_main;
19633 if (VAT_JSON_ARRAY != vam->json_tree.type)
19635 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19636 vat_json_init_array (&vam->json_tree);
19639 node = vat_json_array_add (&vam->json_tree);
19640 vat_json_init_object (node);
19642 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19643 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19644 vat_json_object_add_uint (node, "transport_protocol",
19645 mp->transport_protocol);
19649 api_sw_interface_span_enable_disable (vat_main_t * vam)
19651 unformat_input_t *i = vam->input;
19652 vl_api_sw_interface_span_enable_disable_t *mp;
19653 u32 src_sw_if_index = ~0;
19654 u32 dst_sw_if_index = ~0;
19659 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19662 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19664 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19668 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19670 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19672 else if (unformat (i, "disable"))
19674 else if (unformat (i, "rx"))
19676 else if (unformat (i, "tx"))
19678 else if (unformat (i, "both"))
19680 else if (unformat (i, "l2"))
19686 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19688 mp->sw_if_index_from = htonl (src_sw_if_index);
19689 mp->sw_if_index_to = htonl (dst_sw_if_index);
19699 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19702 vat_main_t *vam = &vat_main;
19703 u8 *sw_if_from_name = 0;
19704 u8 *sw_if_to_name = 0;
19705 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19706 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19707 char *states[] = { "none", "rx", "tx", "both" };
19711 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19713 if ((u32) p->value[0] == sw_if_index_from)
19715 sw_if_from_name = (u8 *)(p->key);
19719 if ((u32) p->value[0] == sw_if_index_to)
19721 sw_if_to_name = (u8 *)(p->key);
19722 if (sw_if_from_name)
19727 print (vam->ofp, "%20s => %20s (%s)",
19728 sw_if_from_name, sw_if_to_name, states[mp->state]);
19732 vl_api_sw_interface_span_details_t_handler_json
19733 (vl_api_sw_interface_span_details_t * mp)
19735 vat_main_t *vam = &vat_main;
19736 vat_json_node_t *node = NULL;
19737 u8 *sw_if_from_name = 0;
19738 u8 *sw_if_to_name = 0;
19739 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19740 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19744 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19746 if ((u32) p->value[0] == sw_if_index_from)
19748 sw_if_from_name = (u8 *)(p->key);
19752 if ((u32) p->value[0] == sw_if_index_to)
19754 sw_if_to_name = (u8 *)(p->key);
19755 if (sw_if_from_name)
19761 if (VAT_JSON_ARRAY != vam->json_tree.type)
19763 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19764 vat_json_init_array (&vam->json_tree);
19766 node = vat_json_array_add (&vam->json_tree);
19768 vat_json_init_object (node);
19769 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19770 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19771 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19772 if (0 != sw_if_to_name)
19774 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19776 vat_json_object_add_uint (node, "state", mp->state);
19780 api_sw_interface_span_dump (vat_main_t * vam)
19782 unformat_input_t *input = vam->input;
19783 vl_api_sw_interface_span_dump_t *mp;
19784 vl_api_control_ping_t *mp_ping;
19788 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19790 if (unformat (input, "l2"))
19796 M (SW_INTERFACE_SPAN_DUMP, mp);
19800 /* Use a control ping for synchronization */
19801 MPING (CONTROL_PING, mp_ping);
19809 api_pg_create_interface (vat_main_t * vam)
19811 unformat_input_t *input = vam->input;
19812 vl_api_pg_create_interface_t *mp;
19816 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19818 if (unformat (input, "if_id %d", &if_id))
19825 errmsg ("missing pg interface index");
19829 /* Construct the API message */
19830 M (PG_CREATE_INTERFACE, mp);
19832 mp->interface_id = ntohl (if_id);
19840 api_pg_capture (vat_main_t * vam)
19842 unformat_input_t *input = vam->input;
19843 vl_api_pg_capture_t *mp;
19848 u8 pcap_file_set = 0;
19851 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19853 if (unformat (input, "if_id %d", &if_id))
19855 else if (unformat (input, "pcap %s", &pcap_file))
19857 else if (unformat (input, "count %d", &count))
19859 else if (unformat (input, "disable"))
19866 errmsg ("missing pg interface index");
19869 if (pcap_file_set > 0)
19871 if (vec_len (pcap_file) > 255)
19873 errmsg ("pcap file name is too long");
19878 u32 name_len = vec_len (pcap_file);
19879 /* Construct the API message */
19880 M (PG_CAPTURE, mp);
19882 mp->interface_id = ntohl (if_id);
19883 mp->is_enabled = enable;
19884 mp->count = ntohl (count);
19885 mp->pcap_name_length = ntohl (name_len);
19886 if (pcap_file_set != 0)
19888 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19890 vec_free (pcap_file);
19898 api_pg_enable_disable (vat_main_t * vam)
19900 unformat_input_t *input = vam->input;
19901 vl_api_pg_enable_disable_t *mp;
19904 u8 stream_name_set = 0;
19905 u8 *stream_name = 0;
19907 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19909 if (unformat (input, "stream %s", &stream_name))
19910 stream_name_set = 1;
19911 else if (unformat (input, "disable"))
19917 if (stream_name_set > 0)
19919 if (vec_len (stream_name) > 255)
19921 errmsg ("stream name too long");
19926 u32 name_len = vec_len (stream_name);
19927 /* Construct the API message */
19928 M (PG_ENABLE_DISABLE, mp);
19930 mp->is_enabled = enable;
19931 if (stream_name_set != 0)
19933 mp->stream_name_length = ntohl (name_len);
19934 clib_memcpy (mp->stream_name, stream_name, name_len);
19936 vec_free (stream_name);
19944 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19946 unformat_input_t *input = vam->input;
19947 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19949 u16 *low_ports = 0;
19950 u16 *high_ports = 0;
19953 ip4_address_t ip4_addr;
19954 ip6_address_t ip6_addr;
19963 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19965 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
19971 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
19976 else if (unformat (input, "vrf %d", &vrf_id))
19978 else if (unformat (input, "del"))
19980 else if (unformat (input, "port %d", &tmp))
19982 if (tmp == 0 || tmp > 65535)
19984 errmsg ("port %d out of range", tmp);
19988 this_hi = this_low + 1;
19989 vec_add1 (low_ports, this_low);
19990 vec_add1 (high_ports, this_hi);
19992 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19994 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19996 errmsg ("incorrect range parameters");
20000 /* Note: in debug CLI +1 is added to high before
20001 passing to real fn that does "the work"
20002 (ip_source_and_port_range_check_add_del).
20003 This fn is a wrapper around the binary API fn a
20004 control plane will call, which expects this increment
20005 to have occurred. Hence letting the binary API control
20006 plane fn do the increment for consistency between VAT
20007 and other control planes.
20010 vec_add1 (low_ports, this_low);
20011 vec_add1 (high_ports, this_hi);
20017 if (prefix_set == 0)
20019 errmsg ("<address>/<mask> not specified");
20025 errmsg ("VRF ID required, not specified");
20032 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20036 if (vec_len (low_ports) == 0)
20038 errmsg ("At least one port or port range required");
20042 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
20044 mp->is_add = is_add;
20049 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
20054 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
20057 mp->mask_length = length;
20058 mp->number_of_ranges = vec_len (low_ports);
20060 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
20061 vec_free (low_ports);
20063 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
20064 vec_free (high_ports);
20066 mp->vrf_id = ntohl (vrf_id);
20074 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
20076 unformat_input_t *input = vam->input;
20077 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
20078 u32 sw_if_index = ~0;
20080 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
20081 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
20085 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20087 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20089 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20091 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
20093 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
20095 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
20097 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
20099 else if (unformat (input, "del"))
20105 if (sw_if_index == ~0)
20107 errmsg ("Interface required but not specified");
20113 errmsg ("VRF ID required but not specified");
20117 if (tcp_out_vrf_id == 0
20118 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
20121 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20125 /* Construct the API message */
20126 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
20128 mp->sw_if_index = ntohl (sw_if_index);
20129 mp->is_add = is_add;
20130 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20131 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20132 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20133 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20138 /* Wait for a reply... */
20144 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
20146 unformat_input_t *i = vam->input;
20147 vl_api_ipsec_gre_add_del_tunnel_t *mp;
20148 u32 local_sa_id = 0;
20149 u32 remote_sa_id = 0;
20150 ip4_address_t src_address;
20151 ip4_address_t dst_address;
20155 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20157 if (unformat (i, "local_sa %d", &local_sa_id))
20159 else if (unformat (i, "remote_sa %d", &remote_sa_id))
20161 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
20163 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
20165 else if (unformat (i, "del"))
20169 clib_warning ("parse error '%U'", format_unformat_error, i);
20174 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
20176 mp->local_sa_id = ntohl (local_sa_id);
20177 mp->remote_sa_id = ntohl (remote_sa_id);
20178 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
20179 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
20180 mp->is_add = is_add;
20188 api_punt (vat_main_t * vam)
20190 unformat_input_t *i = vam->input;
20198 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20200 if (unformat (i, "ip %d", &ipv))
20202 else if (unformat (i, "protocol %d", &protocol))
20204 else if (unformat (i, "port %d", &port))
20206 else if (unformat (i, "del"))
20210 clib_warning ("parse error '%U'", format_unformat_error, i);
20217 mp->is_add = (u8) is_add;
20218 mp->ipv = (u8) ipv;
20219 mp->l4_protocol = (u8) protocol;
20220 mp->l4_port = htons ((u16) port);
20227 static void vl_api_ipsec_gre_tunnel_details_t_handler
20228 (vl_api_ipsec_gre_tunnel_details_t * mp)
20230 vat_main_t *vam = &vat_main;
20232 print (vam->ofp, "%11d%15U%15U%14d%14d",
20233 ntohl (mp->sw_if_index),
20234 format_ip4_address, &mp->src_address,
20235 format_ip4_address, &mp->dst_address,
20236 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
20239 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
20240 (vl_api_ipsec_gre_tunnel_details_t * mp)
20242 vat_main_t *vam = &vat_main;
20243 vat_json_node_t *node = NULL;
20244 struct in_addr ip4;
20246 if (VAT_JSON_ARRAY != vam->json_tree.type)
20248 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20249 vat_json_init_array (&vam->json_tree);
20251 node = vat_json_array_add (&vam->json_tree);
20253 vat_json_init_object (node);
20254 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20255 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
20256 vat_json_object_add_ip4 (node, "src_address", ip4);
20257 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
20258 vat_json_object_add_ip4 (node, "dst_address", ip4);
20259 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
20260 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
20264 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
20266 unformat_input_t *i = vam->input;
20267 vl_api_ipsec_gre_tunnel_dump_t *mp;
20268 vl_api_control_ping_t *mp_ping;
20270 u8 sw_if_index_set = 0;
20273 /* Parse args required to build the message */
20274 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20276 if (unformat (i, "sw_if_index %d", &sw_if_index))
20277 sw_if_index_set = 1;
20282 if (sw_if_index_set == 0)
20287 if (!vam->json_output)
20289 print (vam->ofp, "%11s%15s%15s%14s%14s",
20290 "sw_if_index", "src_address", "dst_address",
20291 "local_sa_id", "remote_sa_id");
20294 /* Get list of gre-tunnel interfaces */
20295 M (IPSEC_GRE_TUNNEL_DUMP, mp);
20297 mp->sw_if_index = htonl (sw_if_index);
20301 /* Use a control ping for synchronization */
20302 MPING (CONTROL_PING, mp_ping);
20310 api_delete_subif (vat_main_t * vam)
20312 unformat_input_t *i = vam->input;
20313 vl_api_delete_subif_t *mp;
20314 u32 sw_if_index = ~0;
20317 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20319 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20321 if (unformat (i, "sw_if_index %d", &sw_if_index))
20327 if (sw_if_index == ~0)
20329 errmsg ("missing sw_if_index");
20333 /* Construct the API message */
20334 M (DELETE_SUBIF, mp);
20335 mp->sw_if_index = ntohl (sw_if_index);
20342 #define foreach_pbb_vtr_op \
20343 _("disable", L2_VTR_DISABLED) \
20344 _("pop", L2_VTR_POP_2) \
20345 _("push", L2_VTR_PUSH_2)
20348 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20350 unformat_input_t *i = vam->input;
20351 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20352 u32 sw_if_index = ~0, vtr_op = ~0;
20353 u16 outer_tag = ~0;
20354 u8 dmac[6], smac[6];
20355 u8 dmac_set = 0, smac_set = 0;
20361 /* Shut up coverity */
20362 memset (dmac, 0, sizeof (dmac));
20363 memset (smac, 0, sizeof (smac));
20365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20367 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20369 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20371 else if (unformat (i, "vtr_op %d", &vtr_op))
20373 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20376 else if (unformat (i, "translate_pbb_stag"))
20378 if (unformat (i, "%d", &tmp))
20380 vtr_op = L2_VTR_TRANSLATE_2_1;
20386 ("translate_pbb_stag operation requires outer tag definition");
20390 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20392 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20394 else if (unformat (i, "sid %d", &sid))
20396 else if (unformat (i, "vlanid %d", &tmp))
20400 clib_warning ("parse error '%U'", format_unformat_error, i);
20405 if ((sw_if_index == ~0) || (vtr_op == ~0))
20407 errmsg ("missing sw_if_index or vtr operation");
20410 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20411 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20414 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20418 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20419 mp->sw_if_index = ntohl (sw_if_index);
20420 mp->vtr_op = ntohl (vtr_op);
20421 mp->outer_tag = ntohs (outer_tag);
20422 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20423 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20424 mp->b_vlanid = ntohs (vlanid);
20425 mp->i_sid = ntohl (sid);
20433 api_flow_classify_set_interface (vat_main_t * vam)
20435 unformat_input_t *i = vam->input;
20436 vl_api_flow_classify_set_interface_t *mp;
20438 int sw_if_index_set;
20439 u32 ip4_table_index = ~0;
20440 u32 ip6_table_index = ~0;
20444 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20446 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20447 sw_if_index_set = 1;
20448 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20449 sw_if_index_set = 1;
20450 else if (unformat (i, "del"))
20452 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20454 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20458 clib_warning ("parse error '%U'", format_unformat_error, i);
20463 if (sw_if_index_set == 0)
20465 errmsg ("missing interface name or sw_if_index");
20469 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20471 mp->sw_if_index = ntohl (sw_if_index);
20472 mp->ip4_table_index = ntohl (ip4_table_index);
20473 mp->ip6_table_index = ntohl (ip6_table_index);
20474 mp->is_add = is_add;
20482 api_flow_classify_dump (vat_main_t * vam)
20484 unformat_input_t *i = vam->input;
20485 vl_api_flow_classify_dump_t *mp;
20486 vl_api_control_ping_t *mp_ping;
20487 u8 type = FLOW_CLASSIFY_N_TABLES;
20490 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20494 errmsg ("classify table type must be specified");
20498 if (!vam->json_output)
20500 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20503 M (FLOW_CLASSIFY_DUMP, mp);
20508 /* Use a control ping for synchronization */
20509 MPING (CONTROL_PING, mp_ping);
20512 /* Wait for a reply... */
20518 api_feature_enable_disable (vat_main_t * vam)
20520 unformat_input_t *i = vam->input;
20521 vl_api_feature_enable_disable_t *mp;
20523 u8 *feature_name = 0;
20524 u32 sw_if_index = ~0;
20528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20530 if (unformat (i, "arc_name %s", &arc_name))
20532 else if (unformat (i, "feature_name %s", &feature_name))
20535 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20537 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20539 else if (unformat (i, "disable"))
20547 errmsg ("missing arc name");
20550 if (vec_len (arc_name) > 63)
20552 errmsg ("arc name too long");
20555 if (feature_name == 0)
20557 errmsg ("missing feature name");
20560 if (vec_len (feature_name) > 63)
20562 errmsg ("feature name too long");
20565 if (sw_if_index == ~0)
20567 errmsg ("missing interface name or sw_if_index");
20571 /* Construct the API message */
20572 M (FEATURE_ENABLE_DISABLE, mp);
20573 mp->sw_if_index = ntohl (sw_if_index);
20574 mp->enable = enable;
20575 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20576 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20577 vec_free (arc_name);
20578 vec_free (feature_name);
20586 api_sw_interface_tag_add_del (vat_main_t * vam)
20588 unformat_input_t *i = vam->input;
20589 vl_api_sw_interface_tag_add_del_t *mp;
20590 u32 sw_if_index = ~0;
20595 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20597 if (unformat (i, "tag %s", &tag))
20599 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20601 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20603 else if (unformat (i, "del"))
20609 if (sw_if_index == ~0)
20611 errmsg ("missing interface name or sw_if_index");
20615 if (enable && (tag == 0))
20617 errmsg ("no tag specified");
20621 /* Construct the API message */
20622 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20623 mp->sw_if_index = ntohl (sw_if_index);
20624 mp->is_add = enable;
20626 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20634 static void vl_api_l2_xconnect_details_t_handler
20635 (vl_api_l2_xconnect_details_t * mp)
20637 vat_main_t *vam = &vat_main;
20639 print (vam->ofp, "%15d%15d",
20640 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20643 static void vl_api_l2_xconnect_details_t_handler_json
20644 (vl_api_l2_xconnect_details_t * mp)
20646 vat_main_t *vam = &vat_main;
20647 vat_json_node_t *node = NULL;
20649 if (VAT_JSON_ARRAY != vam->json_tree.type)
20651 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20652 vat_json_init_array (&vam->json_tree);
20654 node = vat_json_array_add (&vam->json_tree);
20656 vat_json_init_object (node);
20657 vat_json_object_add_uint (node, "rx_sw_if_index",
20658 ntohl (mp->rx_sw_if_index));
20659 vat_json_object_add_uint (node, "tx_sw_if_index",
20660 ntohl (mp->tx_sw_if_index));
20664 api_l2_xconnect_dump (vat_main_t * vam)
20666 vl_api_l2_xconnect_dump_t *mp;
20667 vl_api_control_ping_t *mp_ping;
20670 if (!vam->json_output)
20672 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20675 M (L2_XCONNECT_DUMP, mp);
20679 /* Use a control ping for synchronization */
20680 MPING (CONTROL_PING, mp_ping);
20688 api_sw_interface_set_mtu (vat_main_t * vam)
20690 unformat_input_t *i = vam->input;
20691 vl_api_sw_interface_set_mtu_t *mp;
20692 u32 sw_if_index = ~0;
20696 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20698 if (unformat (i, "mtu %d", &mtu))
20700 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20702 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20708 if (sw_if_index == ~0)
20710 errmsg ("missing interface name or sw_if_index");
20716 errmsg ("no mtu specified");
20720 /* Construct the API message */
20721 M (SW_INTERFACE_SET_MTU, mp);
20722 mp->sw_if_index = ntohl (sw_if_index);
20723 mp->mtu = ntohs ((u16) mtu);
20731 api_p2p_ethernet_add (vat_main_t * vam)
20733 unformat_input_t *i = vam->input;
20734 vl_api_p2p_ethernet_add_t *mp;
20735 u32 parent_if_index = ~0;
20741 memset (remote_mac, 0, sizeof (remote_mac));
20742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20744 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20746 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20750 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20752 else if (unformat (i, "sub_id %d", &sub_id))
20756 clib_warning ("parse error '%U'", format_unformat_error, i);
20761 if (parent_if_index == ~0)
20763 errmsg ("missing interface name or sw_if_index");
20768 errmsg ("missing remote mac address");
20773 errmsg ("missing sub-interface id");
20777 M (P2P_ETHERNET_ADD, mp);
20778 mp->parent_if_index = ntohl (parent_if_index);
20779 mp->subif_id = ntohl (sub_id);
20780 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20788 api_p2p_ethernet_del (vat_main_t * vam)
20790 unformat_input_t *i = vam->input;
20791 vl_api_p2p_ethernet_del_t *mp;
20792 u32 parent_if_index = ~0;
20797 memset (remote_mac, 0, sizeof (remote_mac));
20798 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20800 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20802 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20806 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20810 clib_warning ("parse error '%U'", format_unformat_error, i);
20815 if (parent_if_index == ~0)
20817 errmsg ("missing interface name or sw_if_index");
20822 errmsg ("missing remote mac address");
20826 M (P2P_ETHERNET_DEL, mp);
20827 mp->parent_if_index = ntohl (parent_if_index);
20828 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20836 api_lldp_config (vat_main_t * vam)
20838 unformat_input_t *i = vam->input;
20839 vl_api_lldp_config_t *mp;
20841 int tx_interval = 0;
20842 u8 *sys_name = NULL;
20845 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20847 if (unformat (i, "system-name %s", &sys_name))
20849 else if (unformat (i, "tx-hold %d", &tx_hold))
20851 else if (unformat (i, "tx-interval %d", &tx_interval))
20855 clib_warning ("parse error '%U'", format_unformat_error, i);
20860 vec_add1 (sys_name, 0);
20862 M (LLDP_CONFIG, mp);
20863 mp->tx_hold = htonl (tx_hold);
20864 mp->tx_interval = htonl (tx_interval);
20865 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20866 vec_free (sys_name);
20874 api_sw_interface_set_lldp (vat_main_t * vam)
20876 unformat_input_t *i = vam->input;
20877 vl_api_sw_interface_set_lldp_t *mp;
20878 u32 sw_if_index = ~0;
20880 u8 *port_desc = NULL, *mgmt_oid = NULL;
20881 ip4_address_t ip4_addr;
20882 ip6_address_t ip6_addr;
20885 memset (&ip4_addr, 0, sizeof (ip4_addr));
20886 memset (&ip6_addr, 0, sizeof (ip6_addr));
20888 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20890 if (unformat (i, "disable"))
20893 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20895 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20897 else if (unformat (i, "port-desc %s", &port_desc))
20899 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
20901 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
20903 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
20909 if (sw_if_index == ~0)
20911 errmsg ("missing interface name or sw_if_index");
20915 /* Construct the API message */
20916 vec_add1 (port_desc, 0);
20917 vec_add1 (mgmt_oid, 0);
20918 M (SW_INTERFACE_SET_LLDP, mp);
20919 mp->sw_if_index = ntohl (sw_if_index);
20920 mp->enable = enable;
20921 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20922 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
20923 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
20924 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
20925 vec_free (port_desc);
20926 vec_free (mgmt_oid);
20934 api_tcp_configure_src_addresses (vat_main_t * vam)
20936 vl_api_tcp_configure_src_addresses_t *mp;
20937 unformat_input_t *i = vam->input;
20938 ip4_address_t v4first, v4last;
20939 ip6_address_t v6first, v6last;
20944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20946 if (unformat (i, "%U - %U",
20947 unformat_ip4_address, &v4first,
20948 unformat_ip4_address, &v4last))
20952 errmsg ("one range per message (range already set)");
20957 else if (unformat (i, "%U - %U",
20958 unformat_ip6_address, &v6first,
20959 unformat_ip6_address, &v6last))
20963 errmsg ("one range per message (range already set)");
20968 else if (unformat (i, "vrf %d", &vrf_id))
20974 if (range_set == 0)
20976 errmsg ("address range not set");
20980 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20981 mp->vrf_id = ntohl (vrf_id);
20983 if (range_set == 2)
20986 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20987 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20992 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20993 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
21001 api_app_namespace_add_del (vat_main_t * vam)
21003 vl_api_app_namespace_add_del_t *mp;
21004 unformat_input_t *i = vam->input;
21005 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
21006 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
21010 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21012 if (unformat (i, "id %_%v%_", &ns_id))
21014 else if (unformat (i, "secret %lu", &secret))
21016 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21017 sw_if_index_set = 1;
21018 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
21020 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
21025 if (!ns_id || !secret_set || !sw_if_index_set)
21027 errmsg ("namespace id, secret and sw_if_index must be set");
21030 if (vec_len (ns_id) > 64)
21032 errmsg ("namespace id too long");
21035 M (APP_NAMESPACE_ADD_DEL, mp);
21037 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
21038 mp->namespace_id_len = vec_len (ns_id);
21039 mp->secret = clib_host_to_net_u64 (secret);
21040 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21041 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
21042 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
21050 api_memfd_segment_create (vat_main_t * vam)
21052 #if VPP_API_TEST_BUILTIN == 0
21053 unformat_input_t *i = vam->input;
21054 vl_api_memfd_segment_create_t *mp;
21055 u64 size = 64 << 20;
21058 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21060 if (unformat (i, "size %U", unformat_memory_size, &size))
21066 M (MEMFD_SEGMENT_CREATE, mp);
21067 mp->requested_size = size;
21073 errmsg ("memfd_segment_create (builtin) not supported");
21079 api_dns_enable_disable (vat_main_t * vam)
21081 unformat_input_t *line_input = vam->input;
21082 vl_api_dns_enable_disable_t *mp;
21083 u8 enable_disable = 1;
21086 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21088 if (unformat (line_input, "disable"))
21089 enable_disable = 0;
21090 if (unformat (line_input, "enable"))
21091 enable_disable = 1;
21096 /* Construct the API message */
21097 M (DNS_ENABLE_DISABLE, mp);
21098 mp->enable = enable_disable;
21102 /* Wait for the reply */
21108 api_dns_resolve_name (vat_main_t * vam)
21110 unformat_input_t *line_input = vam->input;
21111 vl_api_dns_resolve_name_t *mp;
21115 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21117 if (unformat (line_input, "%s", &name))
21123 if (vec_len (name) > 127)
21125 errmsg ("name too long");
21129 /* Construct the API message */
21130 M (DNS_RESOLVE_NAME, mp);
21131 memcpy (mp->name, name, vec_len (name));
21136 /* Wait for the reply */
21142 api_dns_resolve_ip (vat_main_t * vam)
21144 unformat_input_t *line_input = vam->input;
21145 vl_api_dns_resolve_ip_t *mp;
21147 ip4_address_t addr4;
21148 ip6_address_t addr6;
21151 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21153 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
21155 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
21163 errmsg ("missing address");
21167 /* Construct the API message */
21168 M (DNS_RESOLVE_IP, mp);
21169 mp->is_ip6 = is_ip6;
21171 memcpy (mp->address, &addr6, sizeof (addr6));
21173 memcpy (mp->address, &addr4, sizeof (addr4));
21177 /* Wait for the reply */
21183 api_dns_name_server_add_del (vat_main_t * vam)
21185 unformat_input_t *i = vam->input;
21186 vl_api_dns_name_server_add_del_t *mp;
21188 ip6_address_t ip6_server;
21189 ip4_address_t ip4_server;
21194 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21196 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
21198 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
21200 else if (unformat (i, "del"))
21204 clib_warning ("parse error '%U'", format_unformat_error, i);
21209 if (ip4_set && ip6_set)
21211 errmsg ("Only one server address allowed per message");
21214 if ((ip4_set + ip6_set) == 0)
21216 errmsg ("Server address required");
21220 /* Construct the API message */
21221 M (DNS_NAME_SERVER_ADD_DEL, mp);
21225 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
21230 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
21234 mp->is_add = is_add;
21239 /* Wait for a reply, return good/bad news */
21245 api_session_rule_add_del (vat_main_t * vam)
21247 vl_api_session_rule_add_del_t *mp;
21248 unformat_input_t *i = vam->input;
21249 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
21250 u32 appns_index = 0, scope = 0;
21251 ip4_address_t lcl_ip4, rmt_ip4;
21252 ip6_address_t lcl_ip6, rmt_ip6;
21253 u8 is_ip4 = 1, conn_set = 0;
21257 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21259 if (unformat (i, "del"))
21261 else if (unformat (i, "add"))
21263 else if (unformat (i, "proto tcp"))
21265 else if (unformat (i, "proto udp"))
21267 else if (unformat (i, "appns %d", &appns_index))
21269 else if (unformat (i, "scope %d", &scope))
21273 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
21274 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
21282 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
21283 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
21289 else if (unformat (i, "action %d", &action))
21294 if (proto == ~0 || !conn_set || action == ~0)
21296 errmsg ("transport proto, connection and action must be set");
21302 errmsg ("scope should be 0-3");
21306 M (SESSION_RULE_ADD_DEL, mp);
21308 mp->is_ip4 = is_ip4;
21309 mp->transport_proto = proto;
21310 mp->lcl_plen = clib_host_to_net_u16 (lcl_plen);
21311 mp->rmt_plen = clib_host_to_net_u16 (rmt_plen);
21312 mp->action_index = clib_host_to_net_u32 (action);
21313 mp->appns_index = clib_host_to_net_u32 (appns_index);
21315 mp->is_add = is_add;
21318 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
21319 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
21323 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
21324 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
21333 q_or_quit (vat_main_t * vam)
21335 #if VPP_API_TEST_BUILTIN == 0
21336 longjmp (vam->jump_buf, 1);
21338 return 0; /* not so much */
21342 q (vat_main_t * vam)
21344 return q_or_quit (vam);
21348 quit (vat_main_t * vam)
21350 return q_or_quit (vam);
21354 comment (vat_main_t * vam)
21360 cmd_cmp (void *a1, void *a2)
21365 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21369 help (vat_main_t * vam)
21374 unformat_input_t *i = vam->input;
21377 if (unformat (i, "%s", &name))
21381 vec_add1 (name, 0);
21383 hs = hash_get_mem (vam->help_by_name, name);
21385 print (vam->ofp, "usage: %s %s", name, hs[0]);
21387 print (vam->ofp, "No such msg / command '%s'", name);
21392 print (vam->ofp, "Help is available for the following:");
21395 hash_foreach_pair (p, vam->function_by_name,
21397 vec_add1 (cmds, (u8 *)(p->key));
21401 vec_sort_with_function (cmds, cmd_cmp);
21403 for (j = 0; j < vec_len (cmds); j++)
21404 print (vam->ofp, "%s", cmds[j]);
21411 set (vat_main_t * vam)
21413 u8 *name = 0, *value = 0;
21414 unformat_input_t *i = vam->input;
21416 if (unformat (i, "%s", &name))
21418 /* The input buffer is a vector, not a string. */
21419 value = vec_dup (i->buffer);
21420 vec_delete (value, i->index, 0);
21421 /* Almost certainly has a trailing newline */
21422 if (value[vec_len (value) - 1] == '\n')
21423 value[vec_len (value) - 1] = 0;
21424 /* Make sure it's a proper string, one way or the other */
21425 vec_add1 (value, 0);
21426 (void) clib_macro_set_value (&vam->macro_main,
21427 (char *) name, (char *) value);
21430 errmsg ("usage: set <name> <value>");
21438 unset (vat_main_t * vam)
21442 if (unformat (vam->input, "%s", &name))
21443 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21444 errmsg ("unset: %s wasn't set", name);
21457 macro_sort_cmp (void *a1, void *a2)
21459 macro_sort_t *s1 = a1;
21460 macro_sort_t *s2 = a2;
21462 return strcmp ((char *) (s1->name), (char *) (s2->name));
21466 dump_macro_table (vat_main_t * vam)
21468 macro_sort_t *sort_me = 0, *sm;
21473 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21475 vec_add2 (sort_me, sm, 1);
21476 sm->name = (u8 *)(p->key);
21477 sm->value = (u8 *) (p->value[0]);
21481 vec_sort_with_function (sort_me, macro_sort_cmp);
21483 if (vec_len (sort_me))
21484 print (vam->ofp, "%-15s%s", "Name", "Value");
21486 print (vam->ofp, "The macro table is empty...");
21488 for (i = 0; i < vec_len (sort_me); i++)
21489 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21494 dump_node_table (vat_main_t * vam)
21497 vlib_node_t *node, *next_node;
21499 if (vec_len (vam->graph_nodes) == 0)
21501 print (vam->ofp, "Node table empty, issue get_node_graph...");
21505 for (i = 0; i < vec_len (vam->graph_nodes); i++)
21507 node = vam->graph_nodes[i];
21508 print (vam->ofp, "[%d] %s", i, node->name);
21509 for (j = 0; j < vec_len (node->next_nodes); j++)
21511 if (node->next_nodes[j] != ~0)
21513 next_node = vam->graph_nodes[node->next_nodes[j]];
21514 print (vam->ofp, " [%d] %s", j, next_node->name);
21522 value_sort_cmp (void *a1, void *a2)
21524 name_sort_t *n1 = a1;
21525 name_sort_t *n2 = a2;
21527 if (n1->value < n2->value)
21529 if (n1->value > n2->value)
21536 dump_msg_api_table (vat_main_t * vam)
21538 api_main_t *am = &api_main;
21539 name_sort_t *nses = 0, *ns;
21544 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21546 vec_add2 (nses, ns, 1);
21547 ns->name = (u8 *)(hp->key);
21548 ns->value = (u32) hp->value[0];
21552 vec_sort_with_function (nses, value_sort_cmp);
21554 for (i = 0; i < vec_len (nses); i++)
21555 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21561 get_msg_id (vat_main_t * vam)
21566 if (unformat (vam->input, "%s", &name_and_crc))
21568 message_index = vl_api_get_msg_index (name_and_crc);
21569 if (message_index == ~0)
21571 print (vam->ofp, " '%s' not found", name_and_crc);
21574 print (vam->ofp, " '%s' has message index %d",
21575 name_and_crc, message_index);
21578 errmsg ("name_and_crc required...");
21583 search_node_table (vat_main_t * vam)
21585 unformat_input_t *line_input = vam->input;
21588 vlib_node_t *node, *next_node;
21591 if (vam->graph_node_index_by_name == 0)
21593 print (vam->ofp, "Node table empty, issue get_node_graph...");
21597 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21599 if (unformat (line_input, "%s", &node_to_find))
21601 vec_add1 (node_to_find, 0);
21602 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21605 print (vam->ofp, "%s not found...", node_to_find);
21608 node = vam->graph_nodes[p[0]];
21609 print (vam->ofp, "[%d] %s", p[0], node->name);
21610 for (j = 0; j < vec_len (node->next_nodes); j++)
21612 if (node->next_nodes[j] != ~0)
21614 next_node = vam->graph_nodes[node->next_nodes[j]];
21615 print (vam->ofp, " [%d] %s", j, next_node->name);
21622 clib_warning ("parse error '%U'", format_unformat_error,
21628 vec_free (node_to_find);
21637 script (vat_main_t * vam)
21639 #if (VPP_API_TEST_BUILTIN==0)
21641 char *save_current_file;
21642 unformat_input_t save_input;
21643 jmp_buf save_jump_buf;
21644 u32 save_line_number;
21646 FILE *new_fp, *save_ifp;
21648 if (unformat (vam->input, "%s", &s))
21650 new_fp = fopen ((char *) s, "r");
21653 errmsg ("Couldn't open script file %s", s);
21660 errmsg ("Missing script name");
21664 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21665 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21666 save_ifp = vam->ifp;
21667 save_line_number = vam->input_line_number;
21668 save_current_file = (char *) vam->current_file;
21670 vam->input_line_number = 0;
21672 vam->current_file = s;
21675 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
21676 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21677 vam->ifp = save_ifp;
21678 vam->input_line_number = save_line_number;
21679 vam->current_file = (u8 *) save_current_file;
21684 clib_warning ("use the exec command...");
21690 echo (vat_main_t * vam)
21692 print (vam->ofp, "%v", vam->input->buffer);
21696 /* List of API message constructors, CLI names map to api_xxx */
21697 #define foreach_vpe_api_msg \
21698 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21699 _(sw_interface_dump,"") \
21700 _(sw_interface_set_flags, \
21701 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21702 _(sw_interface_add_del_address, \
21703 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21704 _(sw_interface_set_rx_mode, \
21705 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
21706 _(sw_interface_set_table, \
21707 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21708 _(sw_interface_set_mpls_enable, \
21709 "<intfc> | sw_if_index [disable | dis]") \
21710 _(sw_interface_set_vpath, \
21711 "<intfc> | sw_if_index <id> enable | disable") \
21712 _(sw_interface_set_vxlan_bypass, \
21713 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21714 _(sw_interface_set_geneve_bypass, \
21715 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21716 _(sw_interface_set_l2_xconnect, \
21717 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21718 "enable | disable") \
21719 _(sw_interface_set_l2_bridge, \
21720 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21721 "[shg <split-horizon-group>] [bvi]\n" \
21722 "enable | disable") \
21723 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21724 _(bridge_domain_add_del, \
21725 "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") \
21726 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21728 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21729 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21730 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21732 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21734 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21736 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
21738 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
21740 "<vpp-if-name> | sw_if_index <id>") \
21741 _(sw_interface_tap_dump, "") \
21742 _(ip_table_add_del, \
21743 "table-id <n> [ipv6]\n") \
21744 _(ip_add_del_route, \
21745 "<addr>/<mask> via <addr> [table-id <n>]\n" \
21746 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
21747 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
21748 "[multipath] [count <n>]") \
21749 _(ip_mroute_add_del, \
21750 "<src> <grp>/<mask> [table-id <n>]\n" \
21751 "[<intfc> | sw_if_index <id>] [local] [del]") \
21752 _(mpls_table_add_del, \
21753 "table-id <n>\n") \
21754 _(mpls_route_add_del, \
21755 "<label> <eos> via <addr> [table-id <n>]\n" \
21756 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
21757 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
21758 "[multipath] [count <n>]") \
21759 _(mpls_ip_bind_unbind, \
21760 "<label> <addr/len>") \
21761 _(mpls_tunnel_add_del, \
21762 " via <addr> [table-id <n>]\n" \
21763 "sw_if_index <id>] [l2] [del]") \
21764 _(proxy_arp_add_del, \
21765 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
21766 _(proxy_arp_intfc_enable_disable, \
21767 "<intfc> | sw_if_index <id> enable | disable") \
21768 _(sw_interface_set_unnumbered, \
21769 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
21770 _(ip_neighbor_add_del, \
21771 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
21772 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
21773 _(reset_vrf, "vrf <id> [ipv6]") \
21774 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
21775 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
21776 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
21777 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
21778 "[outer_vlan_id_any][inner_vlan_id_any]") \
21779 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
21780 _(reset_fib, "vrf <n> [ipv6]") \
21781 _(dhcp_proxy_config, \
21782 "svr <v46-address> src <v46-address>\n" \
21783 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
21784 _(dhcp_proxy_set_vss, \
21785 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
21786 _(dhcp_proxy_dump, "ip6") \
21787 _(dhcp_client_config, \
21788 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
21789 _(set_ip_flow_hash, \
21790 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
21791 _(sw_interface_ip6_enable_disable, \
21792 "<intfc> | sw_if_index <id> enable | disable") \
21793 _(sw_interface_ip6_set_link_local_address, \
21794 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
21795 _(ip6nd_proxy_add_del, \
21796 "<intfc> | sw_if_index <id> <ip6-address>") \
21797 _(ip6nd_proxy_dump, "") \
21798 _(sw_interface_ip6nd_ra_prefix, \
21799 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
21800 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
21801 "[nolink] [isno]") \
21802 _(sw_interface_ip6nd_ra_config, \
21803 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
21804 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
21805 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
21806 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
21807 _(l2_patch_add_del, \
21808 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21809 "enable | disable") \
21810 _(sr_localsid_add_del, \
21811 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
21812 "fib-table <num> (end.psp) sw_if_index <num>") \
21813 _(classify_add_del_table, \
21814 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
21815 " [del] [del-chain] mask <mask-value>\n" \
21816 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
21817 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
21818 _(classify_add_del_session, \
21819 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
21820 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
21821 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
21822 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
21823 _(classify_set_interface_ip_table, \
21824 "<intfc> | sw_if_index <nn> table <nn>") \
21825 _(classify_set_interface_l2_tables, \
21826 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21827 " [other-table <nn>]") \
21828 _(get_node_index, "node <node-name") \
21829 _(add_node_next, "node <node-name> next <next-node-name>") \
21830 _(l2tpv3_create_tunnel, \
21831 "client_address <ip6-addr> our_address <ip6-addr>\n" \
21832 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
21833 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
21834 _(l2tpv3_set_tunnel_cookies, \
21835 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
21836 "[new_remote_cookie <nn>]\n") \
21837 _(l2tpv3_interface_enable_disable, \
21838 "<intfc> | sw_if_index <nn> enable | disable") \
21839 _(l2tpv3_set_lookup_key, \
21840 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
21841 _(sw_if_l2tpv3_tunnel_dump, "") \
21842 _(vxlan_add_del_tunnel, \
21843 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21844 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21845 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21846 _(geneve_add_del_tunnel, \
21847 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21848 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21849 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21850 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21851 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21852 _(gre_add_del_tunnel, \
21853 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
21854 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21855 _(l2_fib_clear_table, "") \
21856 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
21857 _(l2_interface_vlan_tag_rewrite, \
21858 "<intfc> | sw_if_index <nn> \n" \
21859 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
21860 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
21861 _(create_vhost_user_if, \
21862 "socket <filename> [server] [renumber <dev_instance>] " \
21863 "[mac <mac_address>]") \
21864 _(modify_vhost_user_if, \
21865 "<intfc> | sw_if_index <nn> socket <filename>\n" \
21866 "[server] [renumber <dev_instance>]") \
21867 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
21868 _(sw_interface_vhost_user_dump, "") \
21869 _(show_version, "") \
21870 _(vxlan_gpe_add_del_tunnel, \
21871 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
21872 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21873 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
21874 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
21875 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21876 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
21877 _(interface_name_renumber, \
21878 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
21879 _(input_acl_set_interface, \
21880 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21881 " [l2-table <nn>] [del]") \
21882 _(want_ip4_arp_events, "address <ip4-address> [del]") \
21883 _(want_ip6_nd_events, "address <ip6-address> [del]") \
21884 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
21885 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
21886 _(ip_dump, "ipv4 | ipv6") \
21887 _(ipsec_spd_add_del, "spd_id <n> [del]") \
21888 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
21890 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
21891 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
21892 " integ_alg <alg> integ_key <hex>") \
21893 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
21894 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
21895 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
21896 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
21897 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
21898 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
21899 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
21900 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
21901 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
21902 _(ipsec_sa_dump, "[sa_id <n>]") \
21903 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
21904 " <alg> <hex>\n") \
21905 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
21906 _(ikev2_profile_add_del, "name <profile_name> [del]") \
21907 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
21908 "(auth_data 0x<data> | auth_data <data>)") \
21909 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
21910 "(id_data 0x<data> | id_data <data>) (local|remote)") \
21911 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
21912 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
21913 "(local|remote)") \
21914 _(ikev2_set_local_key, "file <absolute_file_path>") \
21915 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
21916 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
21917 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
21918 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
21919 _(ikev2_initiate_sa_init, "<profile_name>") \
21920 _(ikev2_initiate_del_ike_sa, "<ispi>") \
21921 _(ikev2_initiate_del_child_sa, "<ispi>") \
21922 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
21923 _(delete_loopback,"sw_if_index <nn>") \
21924 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
21925 _(map_add_domain, \
21926 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
21927 "ip6-src <ip6addr> " \
21928 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
21929 _(map_del_domain, "index <n>") \
21930 _(map_add_del_rule, \
21931 "index <n> psid <n> dst <ip6addr> [del]") \
21932 _(map_domain_dump, "") \
21933 _(map_rule_dump, "index <map-domain>") \
21934 _(want_interface_events, "enable|disable") \
21935 _(want_stats,"enable|disable") \
21936 _(get_first_msg_id, "client <name>") \
21937 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
21938 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
21939 "fib-id <nn> [ip4][ip6][default]") \
21940 _(get_node_graph, " ") \
21941 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
21942 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
21943 _(ioam_disable, "") \
21944 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
21945 " sw_if_index <sw_if_index> p <priority> " \
21946 "w <weight>] [del]") \
21947 _(one_add_del_locator, "locator-set <locator_name> " \
21948 "iface <intf> | sw_if_index <sw_if_index> " \
21949 "p <priority> w <weight> [del]") \
21950 _(one_add_del_local_eid,"vni <vni> eid " \
21951 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21952 "locator-set <locator_name> [del]" \
21953 "[key-id sha1|sha256 secret-key <secret-key>]")\
21954 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
21955 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
21956 _(one_enable_disable, "enable|disable") \
21957 _(one_map_register_enable_disable, "enable|disable") \
21958 _(one_map_register_fallback_threshold, "<value>") \
21959 _(one_rloc_probe_enable_disable, "enable|disable") \
21960 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21962 "rloc <locator> p <prio> " \
21963 "w <weight> [rloc <loc> ... ] " \
21964 "action <action> [del-all]") \
21965 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21967 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21968 _(one_use_petr, "ip-address> | disable") \
21969 _(one_map_request_mode, "src-dst|dst-only") \
21970 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21971 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21972 _(one_locator_set_dump, "[local | remote]") \
21973 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
21974 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21975 "[local] | [remote]") \
21976 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
21977 _(one_ndp_bd_get, "") \
21978 _(one_ndp_entries_get, "bd <bridge-domain>") \
21979 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
21980 _(one_l2_arp_bd_get, "") \
21981 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
21982 _(one_stats_enable_disable, "enable|disalbe") \
21983 _(show_one_stats_enable_disable, "") \
21984 _(one_eid_table_vni_dump, "") \
21985 _(one_eid_table_map_dump, "l2|l3") \
21986 _(one_map_resolver_dump, "") \
21987 _(one_map_server_dump, "") \
21988 _(one_adjacencies_get, "vni <vni>") \
21989 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
21990 _(show_one_rloc_probe_state, "") \
21991 _(show_one_map_register_state, "") \
21992 _(show_one_status, "") \
21993 _(one_stats_dump, "") \
21994 _(one_stats_flush, "") \
21995 _(one_get_map_request_itr_rlocs, "") \
21996 _(one_map_register_set_ttl, "<ttl>") \
21997 _(one_set_transport_protocol, "udp|api") \
21998 _(one_get_transport_protocol, "") \
21999 _(show_one_nsh_mapping, "") \
22000 _(show_one_pitr, "") \
22001 _(show_one_use_petr, "") \
22002 _(show_one_map_request_mode, "") \
22003 _(show_one_map_register_ttl, "") \
22004 _(show_one_map_register_fallback_threshold, "") \
22005 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
22006 " sw_if_index <sw_if_index> p <priority> " \
22007 "w <weight>] [del]") \
22008 _(lisp_add_del_locator, "locator-set <locator_name> " \
22009 "iface <intf> | sw_if_index <sw_if_index> " \
22010 "p <priority> w <weight> [del]") \
22011 _(lisp_add_del_local_eid,"vni <vni> eid " \
22012 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22013 "locator-set <locator_name> [del]" \
22014 "[key-id sha1|sha256 secret-key <secret-key>]") \
22015 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
22016 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
22017 _(lisp_enable_disable, "enable|disable") \
22018 _(lisp_map_register_enable_disable, "enable|disable") \
22019 _(lisp_rloc_probe_enable_disable, "enable|disable") \
22020 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22022 "rloc <locator> p <prio> " \
22023 "w <weight> [rloc <loc> ... ] " \
22024 "action <action> [del-all]") \
22025 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22027 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22028 _(lisp_use_petr, "<ip-address> | disable") \
22029 _(lisp_map_request_mode, "src-dst|dst-only") \
22030 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22031 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22032 _(lisp_locator_set_dump, "[local | remote]") \
22033 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
22034 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22035 "[local] | [remote]") \
22036 _(lisp_eid_table_vni_dump, "") \
22037 _(lisp_eid_table_map_dump, "l2|l3") \
22038 _(lisp_map_resolver_dump, "") \
22039 _(lisp_map_server_dump, "") \
22040 _(lisp_adjacencies_get, "vni <vni>") \
22041 _(gpe_fwd_entry_vnis_get, "") \
22042 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
22043 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
22044 "[table <table-id>]") \
22045 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
22046 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
22047 _(gpe_set_encap_mode, "lisp|vxlan") \
22048 _(gpe_get_encap_mode, "") \
22049 _(lisp_gpe_add_del_iface, "up|down") \
22050 _(lisp_gpe_enable_disable, "enable|disable") \
22051 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
22052 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
22053 _(show_lisp_rloc_probe_state, "") \
22054 _(show_lisp_map_register_state, "") \
22055 _(show_lisp_status, "") \
22056 _(lisp_get_map_request_itr_rlocs, "") \
22057 _(show_lisp_pitr, "") \
22058 _(show_lisp_use_petr, "") \
22059 _(show_lisp_map_request_mode, "") \
22060 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
22061 _(af_packet_delete, "name <host interface name>") \
22062 _(policer_add_del, "name <policer name> <params> [del]") \
22063 _(policer_dump, "[name <policer name>]") \
22064 _(policer_classify_set_interface, \
22065 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22066 " [l2-table <nn>] [del]") \
22067 _(policer_classify_dump, "type [ip4|ip6|l2]") \
22068 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
22069 "[master|slave]") \
22070 _(netmap_delete, "name <interface name>") \
22071 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
22072 _(mpls_fib_dump, "") \
22073 _(classify_table_ids, "") \
22074 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
22075 _(classify_table_info, "table_id <nn>") \
22076 _(classify_session_dump, "table_id <nn>") \
22077 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
22078 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
22079 "[template_interval <nn>] [udp_checksum]") \
22080 _(ipfix_exporter_dump, "") \
22081 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
22082 _(ipfix_classify_stream_dump, "") \
22083 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
22084 _(ipfix_classify_table_dump, "") \
22085 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
22086 _(sw_interface_span_dump, "[l2]") \
22087 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
22088 _(pg_create_interface, "if_id <nn>") \
22089 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
22090 _(pg_enable_disable, "[stream <id>] disable") \
22091 _(ip_source_and_port_range_check_add_del, \
22092 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
22093 _(ip_source_and_port_range_check_interface_add_del, \
22094 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
22095 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
22096 _(ipsec_gre_add_del_tunnel, \
22097 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
22098 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
22099 _(delete_subif,"<intfc> | sw_if_index <nn>") \
22100 _(l2_interface_pbb_tag_rewrite, \
22101 "<intfc> | sw_if_index <nn> \n" \
22102 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
22103 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
22104 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
22105 _(flow_classify_set_interface, \
22106 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
22107 _(flow_classify_dump, "type [ip4|ip6]") \
22108 _(ip_fib_dump, "") \
22109 _(ip_mfib_dump, "") \
22110 _(ip6_fib_dump, "") \
22111 _(ip6_mfib_dump, "") \
22112 _(feature_enable_disable, "arc_name <arc_name> " \
22113 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
22114 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
22116 _(l2_xconnect_dump, "") \
22117 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
22118 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
22119 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
22120 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
22121 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
22122 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
22123 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
22124 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
22125 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
22126 _(memfd_segment_create,"size <nnn>") \
22127 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
22128 _(dns_enable_disable, "[enable][disable]") \
22129 _(dns_name_server_add_del, "<ip-address> [del]") \
22130 _(dns_resolve_name, "<hostname>") \
22131 _(dns_resolve_ip, "<ip4|ip6>") \
22132 _(dns_name_server_add_del, "<ip-address> [del]") \
22133 _(dns_resolve_name, "<hostname>") \
22134 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
22135 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
22137 /* List of command functions, CLI names map directly to functions */
22138 #define foreach_cli_function \
22139 _(comment, "usage: comment <ignore-rest-of-line>") \
22140 _(dump_interface_table, "usage: dump_interface_table") \
22141 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
22142 _(dump_ipv4_table, "usage: dump_ipv4_table") \
22143 _(dump_ipv6_table, "usage: dump_ipv6_table") \
22144 _(dump_stats_table, "usage: dump_stats_table") \
22145 _(dump_macro_table, "usage: dump_macro_table ") \
22146 _(dump_node_table, "usage: dump_node_table") \
22147 _(dump_msg_api_table, "usage: dump_msg_api_table") \
22148 _(get_msg_id, "usage: get_msg_id name_and_crc") \
22149 _(echo, "usage: echo <message>") \
22150 _(exec, "usage: exec <vpe-debug-CLI-command>") \
22151 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
22152 _(help, "usage: help") \
22153 _(q, "usage: quit") \
22154 _(quit, "usage: quit") \
22155 _(search_node_table, "usage: search_node_table <name>...") \
22156 _(set, "usage: set <variable-name> <value>") \
22157 _(script, "usage: script <file-name>") \
22158 _(unset, "usage: unset <variable-name>")
22160 static void vl_api_##n##_t_handler_uni \
22161 (vl_api_##n##_t * mp) \
22163 vat_main_t * vam = &vat_main; \
22164 if (vam->json_output) { \
22165 vl_api_##n##_t_handler_json(mp); \
22167 vl_api_##n##_t_handler(mp); \
22170 foreach_vpe_api_reply_msg;
22171 #if VPP_API_TEST_BUILTIN == 0
22172 foreach_standalone_reply_msg;
22177 vat_api_hookup (vat_main_t * vam)
22180 vl_msg_api_set_handlers(VL_API_##N, #n, \
22181 vl_api_##n##_t_handler_uni, \
22183 vl_api_##n##_t_endian, \
22184 vl_api_##n##_t_print, \
22185 sizeof(vl_api_##n##_t), 1);
22186 foreach_vpe_api_reply_msg;
22187 #if VPP_API_TEST_BUILTIN == 0
22188 foreach_standalone_reply_msg;
22192 #if (VPP_API_TEST_BUILTIN==0)
22193 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
22195 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
22197 vam->function_by_name = hash_create_string (0, sizeof (uword));
22199 vam->help_by_name = hash_create_string (0, sizeof (uword));
22202 /* API messages we can send */
22203 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
22204 foreach_vpe_api_msg;
22208 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22209 foreach_vpe_api_msg;
22212 /* CLI functions */
22213 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
22214 foreach_cli_function;
22218 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22219 foreach_cli_function;
22223 #if VPP_API_TEST_BUILTIN
22224 static clib_error_t *
22225 vat_api_hookup_shim (vlib_main_t * vm)
22227 vat_api_hookup (&vat_main);
22231 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
22235 * fd.io coding-style-patch-verification: ON
22238 * eval: (c-set-style "gnu")