2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vppinfra/socket.h>
22 #include <svm/memfd.h>
23 #include <vlibapi/api.h>
24 #include <vlibmemory/api.h>
25 #include <vnet/ip/ip.h>
26 #include <vnet/l2/l2_input.h>
27 #include <vnet/l2tp/l2tp.h>
28 #include <vnet/vxlan/vxlan.h>
29 #include <vnet/geneve/geneve.h>
30 #include <vnet/gre/gre.h>
31 #include <vnet/vxlan-gpe/vxlan_gpe.h>
32 #include <vnet/lisp-gpe/lisp_gpe.h>
34 #include <vpp/api/vpe_msg_enum.h>
35 #include <vnet/l2/l2_classify.h>
36 #include <vnet/l2/l2_vtr.h>
37 #include <vnet/classify/input_acl.h>
38 #include <vnet/classify/policer_classify.h>
39 #include <vnet/classify/flow_classify.h>
40 #include <vnet/mpls/mpls.h>
41 #include <vnet/ipsec/ipsec.h>
42 #include <vnet/ipsec/ikev2.h>
44 #include <vnet/map/map.h>
45 #include <vnet/cop/cop.h>
46 #include <vnet/ip/ip6_hop_by_hop.h>
47 #include <vnet/ip/ip_source_and_port_range_check.h>
48 #include <vnet/policer/xlate.h>
49 #include <vnet/span/span.h>
50 #include <vnet/policer/policer.h>
51 #include <vnet/policer/police.h>
52 #include <vnet/mfib/mfib_types.h>
54 #include "vat/json_format.h"
59 #define vl_typedefs /* define message structures */
60 #include <vpp/api/vpe_all_api_h.h>
63 /* declare message handlers for each api */
65 #define vl_endianfun /* define message structures */
66 #include <vpp/api/vpe_all_api_h.h>
69 /* instantiate all the print functions we know about */
70 #define vl_print(handle, ...)
72 #include <vpp/api/vpe_all_api_h.h>
75 #define __plugin_msg_base 0
76 #include <vlibapi/vat_helper_macros.h>
78 #if VPP_API_TEST_BUILTIN == 0
88 vat_socket_connect (vat_main_t * vam)
90 return vl_socket_client_connect
91 (&vam->socket_client_main, (char *) vam->socket_name,
92 "vpp_api_test(s)", 0 /* default socket rx, tx buffer */ );
94 #else /* vpp built-in case, we don't do sockets... */
96 vat_socket_connect (vat_main_t * vam)
102 vl_socket_client_read_reply (socket_client_main_t * scm)
109 vat_time_now (vat_main_t * vam)
111 #if VPP_API_TEST_BUILTIN
112 return vlib_time_now (vam->vlib_main);
114 return clib_time_now (&vam->clib_time);
119 errmsg (char *fmt, ...)
121 vat_main_t *vam = &vat_main;
126 s = va_format (0, fmt, &va);
131 #if VPP_API_TEST_BUILTIN
132 vlib_cli_output (vam->vlib_main, (char *) s);
135 if (vam->ifp != stdin)
136 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
137 vam->input_line_number);
138 fformat (vam->ofp, (char *) s);
146 #if VPP_API_TEST_BUILTIN == 0
148 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
150 vat_main_t *vam = va_arg (*args, vat_main_t *);
151 u32 *result = va_arg (*args, u32 *);
155 if (!unformat (input, "%s", &if_name))
158 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
165 /* Parse an IP4 address %d.%d.%d.%d. */
167 unformat_ip4_address (unformat_input_t * input, va_list * args)
169 u8 *result = va_arg (*args, u8 *);
172 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
175 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
187 unformat_ethernet_address (unformat_input_t * input, va_list * args)
189 u8 *result = va_arg (*args, u8 *);
192 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
193 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
197 for (i = 0; i < 6; i++)
198 if (a[i] >= (1 << 8))
201 for (i = 0; i < 6; i++)
207 /* Returns ethernet type as an int in host byte order. */
209 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
212 u16 *result = va_arg (*args, u16 *);
216 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
218 if (type >= (1 << 16))
226 /* Parse an IP6 address. */
228 unformat_ip6_address (unformat_input_t * input, va_list * args)
230 ip6_address_t *result = va_arg (*args, ip6_address_t *);
232 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
233 uword c, n_colon, double_colon_index;
235 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
236 double_colon_index = ARRAY_LEN (hex_quads);
237 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
240 if (c >= '0' && c <= '9')
242 else if (c >= 'a' && c <= 'f')
243 hex_digit = c + 10 - 'a';
244 else if (c >= 'A' && c <= 'F')
245 hex_digit = c + 10 - 'A';
246 else if (c == ':' && n_colon < 2)
250 unformat_put_input (input);
254 /* Too many hex quads. */
255 if (n_hex_quads >= ARRAY_LEN (hex_quads))
260 hex_quad = (hex_quad << 4) | hex_digit;
262 /* Hex quad must fit in 16 bits. */
263 if (n_hex_digits >= 4)
270 /* Save position of :: */
273 /* More than one :: ? */
274 if (double_colon_index < ARRAY_LEN (hex_quads))
276 double_colon_index = n_hex_quads;
279 if (n_colon > 0 && n_hex_digits > 0)
281 hex_quads[n_hex_quads++] = hex_quad;
287 if (n_hex_digits > 0)
288 hex_quads[n_hex_quads++] = hex_quad;
293 /* Expand :: to appropriate number of zero hex quads. */
294 if (double_colon_index < ARRAY_LEN (hex_quads))
296 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
298 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
299 hex_quads[n_zero + i] = hex_quads[i];
301 for (i = 0; i < n_zero; i++)
302 hex_quads[double_colon_index + i] = 0;
304 n_hex_quads = ARRAY_LEN (hex_quads);
307 /* Too few hex quads given. */
308 if (n_hex_quads < ARRAY_LEN (hex_quads))
311 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
312 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
319 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
321 u32 *r = va_arg (*args, u32 *);
324 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
325 foreach_ipsec_policy_action
333 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
335 u32 *r = va_arg (*args, u32 *);
338 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
339 foreach_ipsec_crypto_alg
347 format_ipsec_crypto_alg (u8 * s, va_list * args)
349 u32 i = va_arg (*args, u32);
354 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
355 foreach_ipsec_crypto_alg
358 return format (s, "unknown");
360 return format (s, "%s", t);
364 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
366 u32 *r = va_arg (*args, u32 *);
369 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
370 foreach_ipsec_integ_alg
378 format_ipsec_integ_alg (u8 * s, va_list * args)
380 u32 i = va_arg (*args, u32);
385 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
386 foreach_ipsec_integ_alg
389 return format (s, "unknown");
391 return format (s, "%s", t);
395 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
397 u32 *r = va_arg (*args, u32 *);
400 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
401 foreach_ikev2_auth_method
409 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
411 u32 *r = va_arg (*args, u32 *);
414 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
415 foreach_ikev2_id_type
421 #else /* VPP_API_TEST_BUILTIN == 1 */
423 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
425 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
426 vnet_main_t *vnm = vnet_get_main ();
427 u32 *result = va_arg (*args, u32 *);
430 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
433 *result = sw_if_index;
436 #endif /* VPP_API_TEST_BUILTIN */
439 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
441 u8 *r = va_arg (*args, u8 *);
443 if (unformat (input, "kbps"))
444 *r = SSE2_QOS_RATE_KBPS;
445 else if (unformat (input, "pps"))
446 *r = SSE2_QOS_RATE_PPS;
453 unformat_policer_round_type (unformat_input_t * input, va_list * args)
455 u8 *r = va_arg (*args, u8 *);
457 if (unformat (input, "closest"))
458 *r = SSE2_QOS_ROUND_TO_CLOSEST;
459 else if (unformat (input, "up"))
460 *r = SSE2_QOS_ROUND_TO_UP;
461 else if (unformat (input, "down"))
462 *r = SSE2_QOS_ROUND_TO_DOWN;
469 unformat_policer_type (unformat_input_t * input, va_list * args)
471 u8 *r = va_arg (*args, u8 *);
473 if (unformat (input, "1r2c"))
474 *r = SSE2_QOS_POLICER_TYPE_1R2C;
475 else if (unformat (input, "1r3c"))
476 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
477 else if (unformat (input, "2r3c-2698"))
478 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
479 else if (unformat (input, "2r3c-4115"))
480 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
481 else if (unformat (input, "2r3c-mef5cf1"))
482 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
489 unformat_dscp (unformat_input_t * input, va_list * va)
491 u8 *r = va_arg (*va, u8 *);
494 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
503 unformat_policer_action_type (unformat_input_t * input, va_list * va)
505 sse2_qos_pol_action_params_st *a
506 = va_arg (*va, sse2_qos_pol_action_params_st *);
508 if (unformat (input, "drop"))
509 a->action_type = SSE2_QOS_ACTION_DROP;
510 else if (unformat (input, "transmit"))
511 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
512 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
513 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
520 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
522 u32 *r = va_arg (*va, u32 *);
525 if (unformat (input, "ip4"))
526 tid = POLICER_CLASSIFY_TABLE_IP4;
527 else if (unformat (input, "ip6"))
528 tid = POLICER_CLASSIFY_TABLE_IP6;
529 else if (unformat (input, "l2"))
530 tid = POLICER_CLASSIFY_TABLE_L2;
539 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
541 u32 *r = va_arg (*va, u32 *);
544 if (unformat (input, "ip4"))
545 tid = FLOW_CLASSIFY_TABLE_IP4;
546 else if (unformat (input, "ip6"))
547 tid = FLOW_CLASSIFY_TABLE_IP6;
555 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
556 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
557 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
558 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
560 #if (VPP_API_TEST_BUILTIN==0)
562 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
564 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
565 mfib_itf_attribute_t attr;
568 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
570 if (unformat (input, mfib_itf_flag_long_names[attr]))
571 *iflags |= (1 << attr);
573 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
575 if (unformat (input, mfib_itf_flag_names[attr]))
576 *iflags |= (1 << attr);
579 return (old == *iflags ? 0 : 1);
583 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
585 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
586 mfib_entry_attribute_t attr;
589 FOR_EACH_MFIB_ATTRIBUTE (attr)
591 if (unformat (input, mfib_flag_long_names[attr]))
592 *eflags |= (1 << attr);
594 FOR_EACH_MFIB_ATTRIBUTE (attr)
596 if (unformat (input, mfib_flag_names[attr]))
597 *eflags |= (1 << attr);
600 return (old == *eflags ? 0 : 1);
604 format_ip4_address (u8 * s, va_list * args)
606 u8 *a = va_arg (*args, u8 *);
607 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
611 format_ip6_address (u8 * s, va_list * args)
613 ip6_address_t *a = va_arg (*args, ip6_address_t *);
614 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
616 i_max_n_zero = ARRAY_LEN (a->as_u16);
618 i_first_zero = i_max_n_zero;
620 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
622 u32 is_zero = a->as_u16[i] == 0;
623 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
629 if ((!is_zero && n_zeros > max_n_zeros)
630 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
632 i_max_n_zero = i_first_zero;
633 max_n_zeros = n_zeros;
634 i_first_zero = ARRAY_LEN (a->as_u16);
639 last_double_colon = 0;
640 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
642 if (i == i_max_n_zero && max_n_zeros > 1)
644 s = format (s, "::");
645 i += max_n_zeros - 1;
646 last_double_colon = 1;
650 s = format (s, "%s%x",
651 (last_double_colon || i == 0) ? "" : ":",
652 clib_net_to_host_u16 (a->as_u16[i]));
653 last_double_colon = 0;
660 /* Format an IP46 address. */
662 format_ip46_address (u8 * s, va_list * args)
664 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
665 ip46_type_t type = va_arg (*args, ip46_type_t);
671 is_ip4 = ip46_address_is_ip4 (ip46);
682 format (s, "%U", format_ip4_address, &ip46->ip4) :
683 format (s, "%U", format_ip6_address, &ip46->ip6);
687 format_ethernet_address (u8 * s, va_list * args)
689 u8 *a = va_arg (*args, u8 *);
691 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
692 a[0], a[1], a[2], a[3], a[4], a[5]);
697 increment_v4_address (ip4_address_t * a)
701 v = ntohl (a->as_u32) + 1;
702 a->as_u32 = ntohl (v);
706 increment_v6_address (ip6_address_t * a)
710 v0 = clib_net_to_host_u64 (a->as_u64[0]);
711 v1 = clib_net_to_host_u64 (a->as_u64[1]);
716 a->as_u64[0] = clib_net_to_host_u64 (v0);
717 a->as_u64[1] = clib_net_to_host_u64 (v1);
721 increment_mac_address (u64 * mac)
725 tmp = clib_net_to_host_u64 (tmp);
726 tmp += 1 << 16; /* skip unused (least significant) octets */
727 tmp = clib_host_to_net_u64 (tmp);
731 static void vl_api_create_loopback_reply_t_handler
732 (vl_api_create_loopback_reply_t * mp)
734 vat_main_t *vam = &vat_main;
735 i32 retval = ntohl (mp->retval);
737 vam->retval = retval;
738 vam->regenerate_interface_table = 1;
739 vam->sw_if_index = ntohl (mp->sw_if_index);
740 vam->result_ready = 1;
743 static void vl_api_create_loopback_reply_t_handler_json
744 (vl_api_create_loopback_reply_t * mp)
746 vat_main_t *vam = &vat_main;
747 vat_json_node_t node;
749 vat_json_init_object (&node);
750 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
751 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
753 vat_json_print (vam->ofp, &node);
754 vat_json_free (&node);
755 vam->retval = ntohl (mp->retval);
756 vam->result_ready = 1;
759 static void vl_api_create_loopback_instance_reply_t_handler
760 (vl_api_create_loopback_instance_reply_t * mp)
762 vat_main_t *vam = &vat_main;
763 i32 retval = ntohl (mp->retval);
765 vam->retval = retval;
766 vam->regenerate_interface_table = 1;
767 vam->sw_if_index = ntohl (mp->sw_if_index);
768 vam->result_ready = 1;
771 static void vl_api_create_loopback_instance_reply_t_handler_json
772 (vl_api_create_loopback_instance_reply_t * mp)
774 vat_main_t *vam = &vat_main;
775 vat_json_node_t node;
777 vat_json_init_object (&node);
778 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
779 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
781 vat_json_print (vam->ofp, &node);
782 vat_json_free (&node);
783 vam->retval = ntohl (mp->retval);
784 vam->result_ready = 1;
787 static void vl_api_af_packet_create_reply_t_handler
788 (vl_api_af_packet_create_reply_t * mp)
790 vat_main_t *vam = &vat_main;
791 i32 retval = ntohl (mp->retval);
793 vam->retval = retval;
794 vam->regenerate_interface_table = 1;
795 vam->sw_if_index = ntohl (mp->sw_if_index);
796 vam->result_ready = 1;
799 static void vl_api_af_packet_create_reply_t_handler_json
800 (vl_api_af_packet_create_reply_t * mp)
802 vat_main_t *vam = &vat_main;
803 vat_json_node_t node;
805 vat_json_init_object (&node);
806 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
807 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
809 vat_json_print (vam->ofp, &node);
810 vat_json_free (&node);
812 vam->retval = ntohl (mp->retval);
813 vam->result_ready = 1;
816 static void vl_api_create_vlan_subif_reply_t_handler
817 (vl_api_create_vlan_subif_reply_t * mp)
819 vat_main_t *vam = &vat_main;
820 i32 retval = ntohl (mp->retval);
822 vam->retval = retval;
823 vam->regenerate_interface_table = 1;
824 vam->sw_if_index = ntohl (mp->sw_if_index);
825 vam->result_ready = 1;
828 static void vl_api_create_vlan_subif_reply_t_handler_json
829 (vl_api_create_vlan_subif_reply_t * mp)
831 vat_main_t *vam = &vat_main;
832 vat_json_node_t node;
834 vat_json_init_object (&node);
835 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
836 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
838 vat_json_print (vam->ofp, &node);
839 vat_json_free (&node);
841 vam->retval = ntohl (mp->retval);
842 vam->result_ready = 1;
845 static void vl_api_create_subif_reply_t_handler
846 (vl_api_create_subif_reply_t * mp)
848 vat_main_t *vam = &vat_main;
849 i32 retval = ntohl (mp->retval);
851 vam->retval = retval;
852 vam->regenerate_interface_table = 1;
853 vam->sw_if_index = ntohl (mp->sw_if_index);
854 vam->result_ready = 1;
857 static void vl_api_create_subif_reply_t_handler_json
858 (vl_api_create_subif_reply_t * mp)
860 vat_main_t *vam = &vat_main;
861 vat_json_node_t node;
863 vat_json_init_object (&node);
864 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
865 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
867 vat_json_print (vam->ofp, &node);
868 vat_json_free (&node);
870 vam->retval = ntohl (mp->retval);
871 vam->result_ready = 1;
874 static void vl_api_interface_name_renumber_reply_t_handler
875 (vl_api_interface_name_renumber_reply_t * mp)
877 vat_main_t *vam = &vat_main;
878 i32 retval = ntohl (mp->retval);
880 vam->retval = retval;
881 vam->regenerate_interface_table = 1;
882 vam->result_ready = 1;
885 static void vl_api_interface_name_renumber_reply_t_handler_json
886 (vl_api_interface_name_renumber_reply_t * mp)
888 vat_main_t *vam = &vat_main;
889 vat_json_node_t node;
891 vat_json_init_object (&node);
892 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
894 vat_json_print (vam->ofp, &node);
895 vat_json_free (&node);
897 vam->retval = ntohl (mp->retval);
898 vam->result_ready = 1;
902 * Special-case: build the interface table, maintain
903 * the next loopback sw_if_index vbl.
905 static void vl_api_sw_interface_details_t_handler
906 (vl_api_sw_interface_details_t * mp)
908 vat_main_t *vam = &vat_main;
909 u8 *s = format (0, "%s%c", mp->interface_name, 0);
911 hash_set_mem (vam->sw_if_index_by_interface_name, s,
912 ntohl (mp->sw_if_index));
914 /* In sub interface case, fill the sub interface table entry */
915 if (mp->sw_if_index != mp->sup_sw_if_index)
917 sw_interface_subif_t *sub = NULL;
919 vec_add2 (vam->sw_if_subif_table, sub, 1);
921 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
922 strncpy ((char *) sub->interface_name, (char *) s,
923 vec_len (sub->interface_name));
924 sub->sw_if_index = ntohl (mp->sw_if_index);
925 sub->sub_id = ntohl (mp->sub_id);
927 sub->sub_dot1ad = mp->sub_dot1ad;
928 sub->sub_number_of_tags = mp->sub_number_of_tags;
929 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
930 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
931 sub->sub_exact_match = mp->sub_exact_match;
932 sub->sub_default = mp->sub_default;
933 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
934 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
936 /* vlan tag rewrite */
937 sub->vtr_op = ntohl (mp->vtr_op);
938 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
939 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
940 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
944 static void vl_api_sw_interface_details_t_handler_json
945 (vl_api_sw_interface_details_t * mp)
947 vat_main_t *vam = &vat_main;
948 vat_json_node_t *node = NULL;
950 if (VAT_JSON_ARRAY != vam->json_tree.type)
952 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
953 vat_json_init_array (&vam->json_tree);
955 node = vat_json_array_add (&vam->json_tree);
957 vat_json_init_object (node);
958 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
959 vat_json_object_add_uint (node, "sup_sw_if_index",
960 ntohl (mp->sup_sw_if_index));
961 vat_json_object_add_uint (node, "l2_address_length",
962 ntohl (mp->l2_address_length));
963 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
964 sizeof (mp->l2_address));
965 vat_json_object_add_string_copy (node, "interface_name",
967 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
968 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
969 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
970 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
971 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
972 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
973 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
974 vat_json_object_add_uint (node, "sub_number_of_tags",
975 mp->sub_number_of_tags);
976 vat_json_object_add_uint (node, "sub_outer_vlan_id",
977 ntohs (mp->sub_outer_vlan_id));
978 vat_json_object_add_uint (node, "sub_inner_vlan_id",
979 ntohs (mp->sub_inner_vlan_id));
980 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
981 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
982 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
983 mp->sub_outer_vlan_id_any);
984 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
985 mp->sub_inner_vlan_id_any);
986 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
987 vat_json_object_add_uint (node, "vtr_push_dot1q",
988 ntohl (mp->vtr_push_dot1q));
989 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
990 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
993 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
995 format_ethernet_address,
997 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
999 format_ethernet_address,
1001 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1002 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1006 #if VPP_API_TEST_BUILTIN == 0
1007 static void vl_api_sw_interface_event_t_handler
1008 (vl_api_sw_interface_event_t * mp)
1010 vat_main_t *vam = &vat_main;
1011 if (vam->interface_event_display)
1012 errmsg ("interface flags: sw_if_index %d %s %s",
1013 ntohl (mp->sw_if_index),
1014 mp->admin_up_down ? "admin-up" : "admin-down",
1015 mp->link_up_down ? "link-up" : "link-down");
1019 static void vl_api_sw_interface_event_t_handler_json
1020 (vl_api_sw_interface_event_t * mp)
1022 /* JSON output not supported */
1026 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1028 vat_main_t *vam = &vat_main;
1029 i32 retval = ntohl (mp->retval);
1031 vam->retval = retval;
1032 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1033 vam->result_ready = 1;
1037 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1039 vat_main_t *vam = &vat_main;
1040 vat_json_node_t node;
1041 api_main_t *am = &api_main;
1045 vat_json_init_object (&node);
1046 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1047 vat_json_object_add_uint (&node, "reply_in_shmem",
1048 ntohl (mp->reply_in_shmem));
1049 /* Toss the shared-memory original... */
1050 pthread_mutex_lock (&am->vlib_rp->mutex);
1051 oldheap = svm_push_data_heap (am->vlib_rp);
1053 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1056 svm_pop_heap (oldheap);
1057 pthread_mutex_unlock (&am->vlib_rp->mutex);
1059 vat_json_print (vam->ofp, &node);
1060 vat_json_free (&node);
1062 vam->retval = ntohl (mp->retval);
1063 vam->result_ready = 1;
1067 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1069 vat_main_t *vam = &vat_main;
1070 i32 retval = ntohl (mp->retval);
1071 u32 length = ntohl (mp->length);
1073 vec_reset_length (vam->cmd_reply);
1075 vam->retval = retval;
1078 vec_validate (vam->cmd_reply, length);
1079 clib_memcpy ((char *) (vam->cmd_reply), mp->reply, length);
1080 vam->cmd_reply[length] = 0;
1082 vam->result_ready = 1;
1086 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1088 vat_main_t *vam = &vat_main;
1089 vat_json_node_t node;
1091 vec_reset_length (vam->cmd_reply);
1093 vat_json_init_object (&node);
1094 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1095 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1097 vat_json_print (vam->ofp, &node);
1098 vat_json_free (&node);
1100 vam->retval = ntohl (mp->retval);
1101 vam->result_ready = 1;
1104 static void vl_api_classify_add_del_table_reply_t_handler
1105 (vl_api_classify_add_del_table_reply_t * mp)
1107 vat_main_t *vam = &vat_main;
1108 i32 retval = ntohl (mp->retval);
1109 if (vam->async_mode)
1111 vam->async_errors += (retval < 0);
1115 vam->retval = retval;
1117 ((mp->new_table_index != 0xFFFFFFFF) ||
1118 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1119 (mp->match_n_vectors != 0xFFFFFFFF)))
1121 * Note: this is just barely thread-safe, depends on
1122 * the main thread spinning waiting for an answer...
1124 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1125 ntohl (mp->new_table_index),
1126 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1127 vam->result_ready = 1;
1131 static void vl_api_classify_add_del_table_reply_t_handler_json
1132 (vl_api_classify_add_del_table_reply_t * mp)
1134 vat_main_t *vam = &vat_main;
1135 vat_json_node_t node;
1137 vat_json_init_object (&node);
1138 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1139 vat_json_object_add_uint (&node, "new_table_index",
1140 ntohl (mp->new_table_index));
1141 vat_json_object_add_uint (&node, "skip_n_vectors",
1142 ntohl (mp->skip_n_vectors));
1143 vat_json_object_add_uint (&node, "match_n_vectors",
1144 ntohl (mp->match_n_vectors));
1146 vat_json_print (vam->ofp, &node);
1147 vat_json_free (&node);
1149 vam->retval = ntohl (mp->retval);
1150 vam->result_ready = 1;
1153 static void vl_api_get_node_index_reply_t_handler
1154 (vl_api_get_node_index_reply_t * mp)
1156 vat_main_t *vam = &vat_main;
1157 i32 retval = ntohl (mp->retval);
1158 if (vam->async_mode)
1160 vam->async_errors += (retval < 0);
1164 vam->retval = retval;
1166 errmsg ("node index %d", ntohl (mp->node_index));
1167 vam->result_ready = 1;
1171 static void vl_api_get_node_index_reply_t_handler_json
1172 (vl_api_get_node_index_reply_t * mp)
1174 vat_main_t *vam = &vat_main;
1175 vat_json_node_t node;
1177 vat_json_init_object (&node);
1178 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1179 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1181 vat_json_print (vam->ofp, &node);
1182 vat_json_free (&node);
1184 vam->retval = ntohl (mp->retval);
1185 vam->result_ready = 1;
1188 static void vl_api_get_next_index_reply_t_handler
1189 (vl_api_get_next_index_reply_t * mp)
1191 vat_main_t *vam = &vat_main;
1192 i32 retval = ntohl (mp->retval);
1193 if (vam->async_mode)
1195 vam->async_errors += (retval < 0);
1199 vam->retval = retval;
1201 errmsg ("next node index %d", ntohl (mp->next_index));
1202 vam->result_ready = 1;
1206 static void vl_api_get_next_index_reply_t_handler_json
1207 (vl_api_get_next_index_reply_t * mp)
1209 vat_main_t *vam = &vat_main;
1210 vat_json_node_t node;
1212 vat_json_init_object (&node);
1213 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1214 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1216 vat_json_print (vam->ofp, &node);
1217 vat_json_free (&node);
1219 vam->retval = ntohl (mp->retval);
1220 vam->result_ready = 1;
1223 static void vl_api_add_node_next_reply_t_handler
1224 (vl_api_add_node_next_reply_t * mp)
1226 vat_main_t *vam = &vat_main;
1227 i32 retval = ntohl (mp->retval);
1228 if (vam->async_mode)
1230 vam->async_errors += (retval < 0);
1234 vam->retval = retval;
1236 errmsg ("next index %d", ntohl (mp->next_index));
1237 vam->result_ready = 1;
1241 static void vl_api_add_node_next_reply_t_handler_json
1242 (vl_api_add_node_next_reply_t * mp)
1244 vat_main_t *vam = &vat_main;
1245 vat_json_node_t node;
1247 vat_json_init_object (&node);
1248 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1249 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1251 vat_json_print (vam->ofp, &node);
1252 vat_json_free (&node);
1254 vam->retval = ntohl (mp->retval);
1255 vam->result_ready = 1;
1258 static void vl_api_show_version_reply_t_handler
1259 (vl_api_show_version_reply_t * mp)
1261 vat_main_t *vam = &vat_main;
1262 i32 retval = ntohl (mp->retval);
1266 errmsg (" program: %s", mp->program);
1267 errmsg (" version: %s", mp->version);
1268 errmsg (" build date: %s", mp->build_date);
1269 errmsg ("build directory: %s", mp->build_directory);
1271 vam->retval = retval;
1272 vam->result_ready = 1;
1275 static void vl_api_show_version_reply_t_handler_json
1276 (vl_api_show_version_reply_t * mp)
1278 vat_main_t *vam = &vat_main;
1279 vat_json_node_t node;
1281 vat_json_init_object (&node);
1282 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1283 vat_json_object_add_string_copy (&node, "program", mp->program);
1284 vat_json_object_add_string_copy (&node, "version", mp->version);
1285 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1286 vat_json_object_add_string_copy (&node, "build_directory",
1287 mp->build_directory);
1289 vat_json_print (vam->ofp, &node);
1290 vat_json_free (&node);
1292 vam->retval = ntohl (mp->retval);
1293 vam->result_ready = 1;
1297 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1299 u32 sw_if_index = ntohl (mp->sw_if_index);
1300 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1301 mp->mac_ip ? "mac/ip binding" : "address resolution",
1302 ntohl (mp->pid), format_ip4_address, &mp->address,
1303 format_ethernet_address, mp->new_mac, sw_if_index);
1307 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1309 /* JSON output not supported */
1313 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1315 u32 sw_if_index = ntohl (mp->sw_if_index);
1316 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1317 mp->mac_ip ? "mac/ip binding" : "address resolution",
1318 ntohl (mp->pid), format_ip6_address, mp->address,
1319 format_ethernet_address, mp->new_mac, sw_if_index);
1323 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1325 /* JSON output not supported */
1329 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1331 u32 n_macs = ntohl (mp->n_macs);
1332 errmsg ("L2MAC event recived with pid %d cl-idx %d for %d macs: \n",
1333 ntohl (mp->pid), mp->client_index, n_macs);
1335 for (i = 0; i < n_macs; i++)
1337 vl_api_mac_entry_t *mac = &mp->mac[i];
1338 errmsg (" [%d] sw_if_index %d mac_addr %U is_del %d \n",
1339 i + 1, ntohl (mac->sw_if_index),
1340 format_ethernet_address, mac->mac_addr, mac->is_del);
1347 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1349 /* JSON output not supported */
1352 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1353 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1356 * Special-case: build the bridge domain table, maintain
1357 * the next bd id vbl.
1359 static void vl_api_bridge_domain_details_t_handler
1360 (vl_api_bridge_domain_details_t * mp)
1362 vat_main_t *vam = &vat_main;
1363 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1366 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1367 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1369 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1370 ntohl (mp->bd_id), mp->learn, mp->forward,
1371 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1375 vl_api_bridge_domain_sw_if_t *sw_ifs;
1376 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1379 sw_ifs = mp->sw_if_details;
1380 for (i = 0; i < n_sw_ifs; i++)
1386 sw_if_index = ntohl (sw_ifs->sw_if_index);
1389 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1391 if ((u32) p->value[0] == sw_if_index)
1393 sw_if_name = (u8 *)(p->key);
1398 print (vam->ofp, "%7d %3d %s", sw_if_index,
1399 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1400 "sw_if_index not found!");
1407 static void vl_api_bridge_domain_details_t_handler_json
1408 (vl_api_bridge_domain_details_t * mp)
1410 vat_main_t *vam = &vat_main;
1411 vat_json_node_t *node, *array = NULL;
1412 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1414 if (VAT_JSON_ARRAY != vam->json_tree.type)
1416 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1417 vat_json_init_array (&vam->json_tree);
1419 node = vat_json_array_add (&vam->json_tree);
1421 vat_json_init_object (node);
1422 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1423 vat_json_object_add_uint (node, "flood", mp->flood);
1424 vat_json_object_add_uint (node, "forward", mp->forward);
1425 vat_json_object_add_uint (node, "learn", mp->learn);
1426 vat_json_object_add_uint (node, "bvi_sw_if_index",
1427 ntohl (mp->bvi_sw_if_index));
1428 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1429 array = vat_json_object_add (node, "sw_if");
1430 vat_json_init_array (array);
1436 vl_api_bridge_domain_sw_if_t *sw_ifs;
1439 sw_ifs = mp->sw_if_details;
1440 for (i = 0; i < n_sw_ifs; i++)
1442 node = vat_json_array_add (array);
1443 vat_json_init_object (node);
1444 vat_json_object_add_uint (node, "sw_if_index",
1445 ntohl (sw_ifs->sw_if_index));
1446 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1452 static void vl_api_control_ping_reply_t_handler
1453 (vl_api_control_ping_reply_t * mp)
1455 vat_main_t *vam = &vat_main;
1456 i32 retval = ntohl (mp->retval);
1457 if (vam->async_mode)
1459 vam->async_errors += (retval < 0);
1463 vam->retval = retval;
1464 vam->result_ready = 1;
1466 vam->socket_client_main.control_pings_outstanding--;
1469 static void vl_api_control_ping_reply_t_handler_json
1470 (vl_api_control_ping_reply_t * mp)
1472 vat_main_t *vam = &vat_main;
1473 i32 retval = ntohl (mp->retval);
1475 if (VAT_JSON_NONE != vam->json_tree.type)
1477 vat_json_print (vam->ofp, &vam->json_tree);
1478 vat_json_free (&vam->json_tree);
1479 vam->json_tree.type = VAT_JSON_NONE;
1484 vat_json_init_array (&vam->json_tree);
1485 vat_json_print (vam->ofp, &vam->json_tree);
1486 vam->json_tree.type = VAT_JSON_NONE;
1489 vam->retval = retval;
1490 vam->result_ready = 1;
1494 vl_api_bridge_domain_set_mac_age_reply_t_handler
1495 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1497 vat_main_t *vam = &vat_main;
1498 i32 retval = ntohl (mp->retval);
1499 if (vam->async_mode)
1501 vam->async_errors += (retval < 0);
1505 vam->retval = retval;
1506 vam->result_ready = 1;
1510 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1511 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1513 vat_main_t *vam = &vat_main;
1514 vat_json_node_t node;
1516 vat_json_init_object (&node);
1517 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1519 vat_json_print (vam->ofp, &node);
1520 vat_json_free (&node);
1522 vam->retval = ntohl (mp->retval);
1523 vam->result_ready = 1;
1527 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1529 vat_main_t *vam = &vat_main;
1530 i32 retval = ntohl (mp->retval);
1531 if (vam->async_mode)
1533 vam->async_errors += (retval < 0);
1537 vam->retval = retval;
1538 vam->result_ready = 1;
1542 static void vl_api_l2_flags_reply_t_handler_json
1543 (vl_api_l2_flags_reply_t * mp)
1545 vat_main_t *vam = &vat_main;
1546 vat_json_node_t node;
1548 vat_json_init_object (&node);
1549 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1550 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1551 ntohl (mp->resulting_feature_bitmap));
1553 vat_json_print (vam->ofp, &node);
1554 vat_json_free (&node);
1556 vam->retval = ntohl (mp->retval);
1557 vam->result_ready = 1;
1560 static void vl_api_bridge_flags_reply_t_handler
1561 (vl_api_bridge_flags_reply_t * mp)
1563 vat_main_t *vam = &vat_main;
1564 i32 retval = ntohl (mp->retval);
1565 if (vam->async_mode)
1567 vam->async_errors += (retval < 0);
1571 vam->retval = retval;
1572 vam->result_ready = 1;
1576 static void vl_api_bridge_flags_reply_t_handler_json
1577 (vl_api_bridge_flags_reply_t * mp)
1579 vat_main_t *vam = &vat_main;
1580 vat_json_node_t node;
1582 vat_json_init_object (&node);
1583 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1584 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1585 ntohl (mp->resulting_feature_bitmap));
1587 vat_json_print (vam->ofp, &node);
1588 vat_json_free (&node);
1590 vam->retval = ntohl (mp->retval);
1591 vam->result_ready = 1;
1594 static void vl_api_tap_connect_reply_t_handler
1595 (vl_api_tap_connect_reply_t * mp)
1597 vat_main_t *vam = &vat_main;
1598 i32 retval = ntohl (mp->retval);
1599 if (vam->async_mode)
1601 vam->async_errors += (retval < 0);
1605 vam->retval = retval;
1606 vam->sw_if_index = ntohl (mp->sw_if_index);
1607 vam->result_ready = 1;
1612 static void vl_api_tap_connect_reply_t_handler_json
1613 (vl_api_tap_connect_reply_t * mp)
1615 vat_main_t *vam = &vat_main;
1616 vat_json_node_t node;
1618 vat_json_init_object (&node);
1619 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1620 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1622 vat_json_print (vam->ofp, &node);
1623 vat_json_free (&node);
1625 vam->retval = ntohl (mp->retval);
1626 vam->result_ready = 1;
1631 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1633 vat_main_t *vam = &vat_main;
1634 i32 retval = ntohl (mp->retval);
1635 if (vam->async_mode)
1637 vam->async_errors += (retval < 0);
1641 vam->retval = retval;
1642 vam->sw_if_index = ntohl (mp->sw_if_index);
1643 vam->result_ready = 1;
1647 static void vl_api_tap_modify_reply_t_handler_json
1648 (vl_api_tap_modify_reply_t * mp)
1650 vat_main_t *vam = &vat_main;
1651 vat_json_node_t node;
1653 vat_json_init_object (&node);
1654 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1655 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1657 vat_json_print (vam->ofp, &node);
1658 vat_json_free (&node);
1660 vam->retval = ntohl (mp->retval);
1661 vam->result_ready = 1;
1665 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1667 vat_main_t *vam = &vat_main;
1668 i32 retval = ntohl (mp->retval);
1669 if (vam->async_mode)
1671 vam->async_errors += (retval < 0);
1675 vam->retval = retval;
1676 vam->result_ready = 1;
1680 static void vl_api_tap_delete_reply_t_handler_json
1681 (vl_api_tap_delete_reply_t * mp)
1683 vat_main_t *vam = &vat_main;
1684 vat_json_node_t node;
1686 vat_json_init_object (&node);
1687 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1689 vat_json_print (vam->ofp, &node);
1690 vat_json_free (&node);
1692 vam->retval = ntohl (mp->retval);
1693 vam->result_ready = 1;
1696 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1697 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1699 vat_main_t *vam = &vat_main;
1700 i32 retval = ntohl (mp->retval);
1701 if (vam->async_mode)
1703 vam->async_errors += (retval < 0);
1707 vam->retval = retval;
1708 vam->result_ready = 1;
1712 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1713 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1715 vat_main_t *vam = &vat_main;
1716 vat_json_node_t node;
1718 vat_json_init_object (&node);
1719 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1720 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1721 ntohl (mp->sw_if_index));
1723 vat_json_print (vam->ofp, &node);
1724 vat_json_free (&node);
1726 vam->retval = ntohl (mp->retval);
1727 vam->result_ready = 1;
1730 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1731 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1733 vat_main_t *vam = &vat_main;
1734 i32 retval = ntohl (mp->retval);
1735 if (vam->async_mode)
1737 vam->async_errors += (retval < 0);
1741 vam->retval = retval;
1742 vam->sw_if_index = ntohl (mp->sw_if_index);
1743 vam->result_ready = 1;
1747 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1748 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1750 vat_main_t *vam = &vat_main;
1751 vat_json_node_t node;
1753 vat_json_init_object (&node);
1754 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1755 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1757 vat_json_print (vam->ofp, &node);
1758 vat_json_free (&node);
1760 vam->retval = ntohl (mp->retval);
1761 vam->result_ready = 1;
1764 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
1765 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1767 vat_main_t *vam = &vat_main;
1768 i32 retval = ntohl (mp->retval);
1769 if (vam->async_mode)
1771 vam->async_errors += (retval < 0);
1775 vam->retval = retval;
1776 vam->result_ready = 1;
1780 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
1781 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1783 vat_main_t *vam = &vat_main;
1784 vat_json_node_t node;
1786 vat_json_init_object (&node);
1787 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1788 vat_json_object_add_uint (&node, "fwd_entry_index",
1789 clib_net_to_host_u32 (mp->fwd_entry_index));
1791 vat_json_print (vam->ofp, &node);
1792 vat_json_free (&node);
1794 vam->retval = ntohl (mp->retval);
1795 vam->result_ready = 1;
1799 format_lisp_transport_protocol (u8 * s, va_list * args)
1801 u32 proto = va_arg (*args, u32);
1806 return format (s, "udp");
1808 return format (s, "api");
1815 static void vl_api_one_get_transport_protocol_reply_t_handler
1816 (vl_api_one_get_transport_protocol_reply_t * mp)
1818 vat_main_t *vam = &vat_main;
1819 i32 retval = ntohl (mp->retval);
1820 if (vam->async_mode)
1822 vam->async_errors += (retval < 0);
1826 u32 proto = mp->protocol;
1827 print (vam->ofp, "Transport protocol: %U",
1828 format_lisp_transport_protocol, proto);
1829 vam->retval = retval;
1830 vam->result_ready = 1;
1834 static void vl_api_one_get_transport_protocol_reply_t_handler_json
1835 (vl_api_one_get_transport_protocol_reply_t * mp)
1837 vat_main_t *vam = &vat_main;
1838 vat_json_node_t node;
1841 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
1844 vat_json_init_object (&node);
1845 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1846 vat_json_object_add_string_copy (&node, "transport-protocol", s);
1849 vat_json_print (vam->ofp, &node);
1850 vat_json_free (&node);
1852 vam->retval = ntohl (mp->retval);
1853 vam->result_ready = 1;
1856 static void vl_api_one_add_del_locator_set_reply_t_handler
1857 (vl_api_one_add_del_locator_set_reply_t * mp)
1859 vat_main_t *vam = &vat_main;
1860 i32 retval = ntohl (mp->retval);
1861 if (vam->async_mode)
1863 vam->async_errors += (retval < 0);
1867 vam->retval = retval;
1868 vam->result_ready = 1;
1872 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1873 (vl_api_one_add_del_locator_set_reply_t * mp)
1875 vat_main_t *vam = &vat_main;
1876 vat_json_node_t node;
1878 vat_json_init_object (&node);
1879 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1880 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1882 vat_json_print (vam->ofp, &node);
1883 vat_json_free (&node);
1885 vam->retval = ntohl (mp->retval);
1886 vam->result_ready = 1;
1889 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1890 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1892 vat_main_t *vam = &vat_main;
1893 i32 retval = ntohl (mp->retval);
1894 if (vam->async_mode)
1896 vam->async_errors += (retval < 0);
1900 vam->retval = retval;
1901 vam->sw_if_index = ntohl (mp->sw_if_index);
1902 vam->result_ready = 1;
1906 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1907 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1909 vat_main_t *vam = &vat_main;
1910 vat_json_node_t node;
1912 vat_json_init_object (&node);
1913 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1914 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1916 vat_json_print (vam->ofp, &node);
1917 vat_json_free (&node);
1919 vam->retval = ntohl (mp->retval);
1920 vam->result_ready = 1;
1923 static void vl_api_geneve_add_del_tunnel_reply_t_handler
1924 (vl_api_geneve_add_del_tunnel_reply_t * mp)
1926 vat_main_t *vam = &vat_main;
1927 i32 retval = ntohl (mp->retval);
1928 if (vam->async_mode)
1930 vam->async_errors += (retval < 0);
1934 vam->retval = retval;
1935 vam->sw_if_index = ntohl (mp->sw_if_index);
1936 vam->result_ready = 1;
1940 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
1941 (vl_api_geneve_add_del_tunnel_reply_t * mp)
1943 vat_main_t *vam = &vat_main;
1944 vat_json_node_t node;
1946 vat_json_init_object (&node);
1947 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1948 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1950 vat_json_print (vam->ofp, &node);
1951 vat_json_free (&node);
1953 vam->retval = ntohl (mp->retval);
1954 vam->result_ready = 1;
1957 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
1958 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1960 vat_main_t *vam = &vat_main;
1961 i32 retval = ntohl (mp->retval);
1962 if (vam->async_mode)
1964 vam->async_errors += (retval < 0);
1968 vam->retval = retval;
1969 vam->sw_if_index = ntohl (mp->sw_if_index);
1970 vam->result_ready = 1;
1974 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
1975 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1977 vat_main_t *vam = &vat_main;
1978 vat_json_node_t node;
1980 vat_json_init_object (&node);
1981 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1982 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1984 vat_json_print (vam->ofp, &node);
1985 vat_json_free (&node);
1987 vam->retval = ntohl (mp->retval);
1988 vam->result_ready = 1;
1991 static void vl_api_gre_add_del_tunnel_reply_t_handler
1992 (vl_api_gre_add_del_tunnel_reply_t * mp)
1994 vat_main_t *vam = &vat_main;
1995 i32 retval = ntohl (mp->retval);
1996 if (vam->async_mode)
1998 vam->async_errors += (retval < 0);
2002 vam->retval = retval;
2003 vam->sw_if_index = ntohl (mp->sw_if_index);
2004 vam->result_ready = 1;
2008 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2009 (vl_api_gre_add_del_tunnel_reply_t * mp)
2011 vat_main_t *vam = &vat_main;
2012 vat_json_node_t node;
2014 vat_json_init_object (&node);
2015 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2016 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2018 vat_json_print (vam->ofp, &node);
2019 vat_json_free (&node);
2021 vam->retval = ntohl (mp->retval);
2022 vam->result_ready = 1;
2025 static void vl_api_create_vhost_user_if_reply_t_handler
2026 (vl_api_create_vhost_user_if_reply_t * mp)
2028 vat_main_t *vam = &vat_main;
2029 i32 retval = ntohl (mp->retval);
2030 if (vam->async_mode)
2032 vam->async_errors += (retval < 0);
2036 vam->retval = retval;
2037 vam->sw_if_index = ntohl (mp->sw_if_index);
2038 vam->result_ready = 1;
2042 static void vl_api_create_vhost_user_if_reply_t_handler_json
2043 (vl_api_create_vhost_user_if_reply_t * mp)
2045 vat_main_t *vam = &vat_main;
2046 vat_json_node_t node;
2048 vat_json_init_object (&node);
2049 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2050 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2052 vat_json_print (vam->ofp, &node);
2053 vat_json_free (&node);
2055 vam->retval = ntohl (mp->retval);
2056 vam->result_ready = 1;
2059 static clib_error_t *
2060 receive_fd_msg (int socket_fd, int *my_fd)
2063 char ctl[CMSG_SPACE (sizeof (int)) + CMSG_SPACE (sizeof (struct ucred))];
2064 struct msghdr mh = { 0 };
2065 struct iovec iov[1];
2067 struct ucred *cr = 0;
2068 struct cmsghdr *cmsg;
2069 pid_t pid __attribute__ ((unused));
2070 uid_t uid __attribute__ ((unused));
2071 gid_t gid __attribute__ ((unused));
2073 iov[0].iov_base = msgbuf;
2077 mh.msg_control = ctl;
2078 mh.msg_controllen = sizeof (ctl);
2080 memset (ctl, 0, sizeof (ctl));
2082 /* receive the incoming message */
2083 size = recvmsg (socket_fd, &mh, 0);
2086 return (size == 0) ? clib_error_return (0, "disconnected") :
2087 clib_error_return_unix (0, "recvmsg: malformed message (fd %d)",
2091 cmsg = CMSG_FIRSTHDR (&mh);
2094 if (cmsg->cmsg_level == SOL_SOCKET)
2096 if (cmsg->cmsg_type == SCM_CREDENTIALS)
2098 cr = (struct ucred *) CMSG_DATA (cmsg);
2103 else if (cmsg->cmsg_type == SCM_RIGHTS)
2105 clib_memcpy (my_fd, CMSG_DATA (cmsg), sizeof (int));
2108 cmsg = CMSG_NXTHDR (&mh, cmsg);
2113 static void vl_api_memfd_segment_create_reply_t_handler
2114 (vl_api_memfd_segment_create_reply_t * mp)
2116 /* Dont bother in the builtin version */
2117 #if VPP_API_TEST_BUILTIN == 0
2118 vat_main_t *vam = &vat_main;
2119 api_main_t *am = &api_main;
2120 socket_client_main_t *scm = &vam->socket_client_main;
2122 clib_error_t *error;
2123 memfd_private_t memfd;
2124 i32 retval = ntohl (mp->retval);
2128 error = receive_fd_msg (scm->socket_fd, &my_fd);
2135 memset (&memfd, 0, sizeof (memfd));
2138 vam->client_index_invalid = 1;
2140 /* Note: this closes memfd.fd */
2141 retval = memfd_slave_init (&memfd);
2143 clib_warning ("WARNING: segment map returned %d", retval);
2145 /* Pivot to the memory client segment that vpp just created */
2147 am->vlib_rp = (void *) (memfd.requested_va + MMAP_PAGESIZE);
2149 am->shmem_hdr = (void *) am->vlib_rp->user_ctx;
2151 vl_client_install_client_message_handlers ();
2153 vl_client_connect_to_vlib_no_map ("pvt",
2155 32 /* input_queue_length */ );
2156 vam->vl_input_queue = am->shmem_hdr->vl_input_queue;
2158 vl_socket_client_enable_disable (&vam->socket_client_main,
2159 0 /* disable socket */ );
2163 if (vam->async_mode)
2165 vam->async_errors += (retval < 0);
2169 vam->retval = retval;
2170 vam->result_ready = 1;
2175 static void vl_api_memfd_segment_create_reply_t_handler_json
2176 (vl_api_memfd_segment_create_reply_t * mp)
2178 clib_warning ("no");
2181 static void vl_api_dns_resolve_name_reply_t_handler
2182 (vl_api_dns_resolve_name_reply_t * mp)
2184 vat_main_t *vam = &vat_main;
2185 i32 retval = ntohl (mp->retval);
2186 if (vam->async_mode)
2188 vam->async_errors += (retval < 0);
2192 vam->retval = retval;
2193 vam->result_ready = 1;
2198 clib_warning ("ip4 address %U", format_ip4_address,
2199 (ip4_address_t *) mp->ip4_address);
2201 clib_warning ("ip6 address %U", format_ip6_address,
2202 (ip6_address_t *) mp->ip6_address);
2205 clib_warning ("retval %d", retval);
2209 static void vl_api_dns_resolve_name_reply_t_handler_json
2210 (vl_api_dns_resolve_name_reply_t * mp)
2212 clib_warning ("no");
2215 static void vl_api_ip_address_details_t_handler
2216 (vl_api_ip_address_details_t * mp)
2218 vat_main_t *vam = &vat_main;
2219 static ip_address_details_t empty_ip_address_details = { {0} };
2220 ip_address_details_t *address = NULL;
2221 ip_details_t *current_ip_details = NULL;
2222 ip_details_t *details = NULL;
2224 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2226 if (!details || vam->current_sw_if_index >= vec_len (details)
2227 || !details[vam->current_sw_if_index].present)
2229 errmsg ("ip address details arrived but not stored");
2230 errmsg ("ip_dump should be called first");
2234 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2236 #define addresses (current_ip_details->addr)
2238 vec_validate_init_empty (addresses, vec_len (addresses),
2239 empty_ip_address_details);
2241 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2243 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2244 address->prefix_length = mp->prefix_length;
2248 static void vl_api_ip_address_details_t_handler_json
2249 (vl_api_ip_address_details_t * mp)
2251 vat_main_t *vam = &vat_main;
2252 vat_json_node_t *node = NULL;
2253 struct in6_addr ip6;
2256 if (VAT_JSON_ARRAY != vam->json_tree.type)
2258 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2259 vat_json_init_array (&vam->json_tree);
2261 node = vat_json_array_add (&vam->json_tree);
2263 vat_json_init_object (node);
2266 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2267 vat_json_object_add_ip6 (node, "ip", ip6);
2271 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2272 vat_json_object_add_ip4 (node, "ip", ip4);
2274 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2278 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2280 vat_main_t *vam = &vat_main;
2281 static ip_details_t empty_ip_details = { 0 };
2282 ip_details_t *ip = NULL;
2283 u32 sw_if_index = ~0;
2285 sw_if_index = ntohl (mp->sw_if_index);
2287 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2288 sw_if_index, empty_ip_details);
2290 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2297 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2299 vat_main_t *vam = &vat_main;
2301 if (VAT_JSON_ARRAY != vam->json_tree.type)
2303 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2304 vat_json_init_array (&vam->json_tree);
2306 vat_json_array_add_uint (&vam->json_tree,
2307 clib_net_to_host_u32 (mp->sw_if_index));
2310 static void vl_api_map_domain_details_t_handler_json
2311 (vl_api_map_domain_details_t * mp)
2313 vat_json_node_t *node = NULL;
2314 vat_main_t *vam = &vat_main;
2315 struct in6_addr ip6;
2318 if (VAT_JSON_ARRAY != vam->json_tree.type)
2320 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2321 vat_json_init_array (&vam->json_tree);
2324 node = vat_json_array_add (&vam->json_tree);
2325 vat_json_init_object (node);
2327 vat_json_object_add_uint (node, "domain_index",
2328 clib_net_to_host_u32 (mp->domain_index));
2329 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2330 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2331 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2332 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2333 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2334 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2335 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2336 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2337 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2338 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2339 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2340 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2341 vat_json_object_add_uint (node, "flags", mp->flags);
2342 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2343 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2346 static void vl_api_map_domain_details_t_handler
2347 (vl_api_map_domain_details_t * mp)
2349 vat_main_t *vam = &vat_main;
2351 if (mp->is_translation)
2354 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2355 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2356 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2357 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2358 clib_net_to_host_u32 (mp->domain_index));
2363 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2364 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2365 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2366 format_ip6_address, mp->ip6_src,
2367 clib_net_to_host_u32 (mp->domain_index));
2369 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2370 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2371 mp->is_translation ? "map-t" : "");
2374 static void vl_api_map_rule_details_t_handler_json
2375 (vl_api_map_rule_details_t * mp)
2377 struct in6_addr ip6;
2378 vat_json_node_t *node = NULL;
2379 vat_main_t *vam = &vat_main;
2381 if (VAT_JSON_ARRAY != vam->json_tree.type)
2383 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2384 vat_json_init_array (&vam->json_tree);
2387 node = vat_json_array_add (&vam->json_tree);
2388 vat_json_init_object (node);
2390 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2391 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2392 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2396 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2398 vat_main_t *vam = &vat_main;
2399 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2400 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2404 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2406 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2407 "router_addr %U host_mac %U",
2408 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2409 format_ip4_address, &mp->host_address,
2410 format_ip4_address, &mp->router_address,
2411 format_ethernet_address, mp->host_mac);
2414 static void vl_api_dhcp_compl_event_t_handler_json
2415 (vl_api_dhcp_compl_event_t * mp)
2417 /* JSON output not supported */
2421 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2424 vat_main_t *vam = &vat_main;
2425 static u64 default_counter = 0;
2427 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2429 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2430 sw_if_index, default_counter);
2431 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2435 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2436 interface_counter_t counter)
2438 vat_main_t *vam = &vat_main;
2439 static interface_counter_t default_counter = { 0, };
2441 vec_validate_init_empty (vam->combined_interface_counters,
2442 vnet_counter_type, NULL);
2443 vec_validate_init_empty (vam->combined_interface_counters
2444 [vnet_counter_type], sw_if_index, default_counter);
2445 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2448 static void vl_api_vnet_interface_simple_counters_t_handler
2449 (vl_api_vnet_interface_simple_counters_t * mp)
2454 static void vl_api_vnet_interface_combined_counters_t_handler
2455 (vl_api_vnet_interface_combined_counters_t * mp)
2460 static void vl_api_vnet_interface_simple_counters_t_handler_json
2461 (vl_api_vnet_interface_simple_counters_t * mp)
2466 u32 first_sw_if_index;
2469 count = ntohl (mp->count);
2470 first_sw_if_index = ntohl (mp->first_sw_if_index);
2472 v_packets = (u64 *) & mp->data;
2473 for (i = 0; i < count; i++)
2475 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2476 set_simple_interface_counter (mp->vnet_counter_type,
2477 first_sw_if_index + i, packets);
2482 static void vl_api_vnet_interface_combined_counters_t_handler_json
2483 (vl_api_vnet_interface_combined_counters_t * mp)
2485 interface_counter_t counter;
2487 u32 first_sw_if_index;
2491 count = ntohl (mp->count);
2492 first_sw_if_index = ntohl (mp->first_sw_if_index);
2494 v = (vlib_counter_t *) & mp->data;
2495 for (i = 0; i < count; i++)
2498 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2500 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2501 set_combined_interface_counter (mp->vnet_counter_type,
2502 first_sw_if_index + i, counter);
2508 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2510 vat_main_t *vam = &vat_main;
2513 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2515 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2524 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2526 vat_main_t *vam = &vat_main;
2529 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2531 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2539 static void vl_api_vnet_ip4_fib_counters_t_handler
2540 (vl_api_vnet_ip4_fib_counters_t * mp)
2545 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2546 (vl_api_vnet_ip4_fib_counters_t * mp)
2548 vat_main_t *vam = &vat_main;
2549 vl_api_ip4_fib_counter_t *v;
2550 ip4_fib_counter_t *counter;
2557 vrf_id = ntohl (mp->vrf_id);
2558 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2559 if (~0 == vrf_index)
2561 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2562 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2563 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2564 vec_validate (vam->ip4_fib_counters, vrf_index);
2565 vam->ip4_fib_counters[vrf_index] = NULL;
2568 vec_free (vam->ip4_fib_counters[vrf_index]);
2569 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2570 count = ntohl (mp->count);
2571 for (i = 0; i < count; i++)
2573 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2574 counter = &vam->ip4_fib_counters[vrf_index][i];
2575 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2576 counter->address = ip4;
2577 counter->address_length = v->address_length;
2578 counter->packets = clib_net_to_host_u64 (v->packets);
2579 counter->bytes = clib_net_to_host_u64 (v->bytes);
2584 static void vl_api_vnet_ip4_nbr_counters_t_handler
2585 (vl_api_vnet_ip4_nbr_counters_t * mp)
2590 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2591 (vl_api_vnet_ip4_nbr_counters_t * mp)
2593 vat_main_t *vam = &vat_main;
2594 vl_api_ip4_nbr_counter_t *v;
2595 ip4_nbr_counter_t *counter;
2600 sw_if_index = ntohl (mp->sw_if_index);
2601 count = ntohl (mp->count);
2602 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2605 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2607 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2608 for (i = 0; i < count; i++)
2610 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2611 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2612 counter->address.s_addr = v->address;
2613 counter->packets = clib_net_to_host_u64 (v->packets);
2614 counter->bytes = clib_net_to_host_u64 (v->bytes);
2615 counter->linkt = v->link_type;
2620 static void vl_api_vnet_ip6_fib_counters_t_handler
2621 (vl_api_vnet_ip6_fib_counters_t * mp)
2626 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2627 (vl_api_vnet_ip6_fib_counters_t * mp)
2629 vat_main_t *vam = &vat_main;
2630 vl_api_ip6_fib_counter_t *v;
2631 ip6_fib_counter_t *counter;
2632 struct in6_addr ip6;
2638 vrf_id = ntohl (mp->vrf_id);
2639 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2640 if (~0 == vrf_index)
2642 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2643 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2644 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2645 vec_validate (vam->ip6_fib_counters, vrf_index);
2646 vam->ip6_fib_counters[vrf_index] = NULL;
2649 vec_free (vam->ip6_fib_counters[vrf_index]);
2650 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2651 count = ntohl (mp->count);
2652 for (i = 0; i < count; i++)
2654 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2655 counter = &vam->ip6_fib_counters[vrf_index][i];
2656 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2657 counter->address = ip6;
2658 counter->address_length = v->address_length;
2659 counter->packets = clib_net_to_host_u64 (v->packets);
2660 counter->bytes = clib_net_to_host_u64 (v->bytes);
2665 static void vl_api_vnet_ip6_nbr_counters_t_handler
2666 (vl_api_vnet_ip6_nbr_counters_t * mp)
2671 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2672 (vl_api_vnet_ip6_nbr_counters_t * mp)
2674 vat_main_t *vam = &vat_main;
2675 vl_api_ip6_nbr_counter_t *v;
2676 ip6_nbr_counter_t *counter;
2677 struct in6_addr ip6;
2682 sw_if_index = ntohl (mp->sw_if_index);
2683 count = ntohl (mp->count);
2684 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2687 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2689 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2690 for (i = 0; i < count; i++)
2692 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2693 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2694 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2695 counter->address = ip6;
2696 counter->packets = clib_net_to_host_u64 (v->packets);
2697 counter->bytes = clib_net_to_host_u64 (v->bytes);
2702 static void vl_api_get_first_msg_id_reply_t_handler
2703 (vl_api_get_first_msg_id_reply_t * mp)
2705 vat_main_t *vam = &vat_main;
2706 i32 retval = ntohl (mp->retval);
2708 if (vam->async_mode)
2710 vam->async_errors += (retval < 0);
2714 vam->retval = retval;
2715 vam->result_ready = 1;
2719 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2723 static void vl_api_get_first_msg_id_reply_t_handler_json
2724 (vl_api_get_first_msg_id_reply_t * mp)
2726 vat_main_t *vam = &vat_main;
2727 vat_json_node_t node;
2729 vat_json_init_object (&node);
2730 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2731 vat_json_object_add_uint (&node, "first_msg_id",
2732 (uint) ntohs (mp->first_msg_id));
2734 vat_json_print (vam->ofp, &node);
2735 vat_json_free (&node);
2737 vam->retval = ntohl (mp->retval);
2738 vam->result_ready = 1;
2741 static void vl_api_get_node_graph_reply_t_handler
2742 (vl_api_get_node_graph_reply_t * mp)
2744 vat_main_t *vam = &vat_main;
2745 api_main_t *am = &api_main;
2746 i32 retval = ntohl (mp->retval);
2747 u8 *pvt_copy, *reply;
2752 if (vam->async_mode)
2754 vam->async_errors += (retval < 0);
2758 vam->retval = retval;
2759 vam->result_ready = 1;
2762 /* "Should never happen..." */
2766 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2767 pvt_copy = vec_dup (reply);
2769 /* Toss the shared-memory original... */
2770 pthread_mutex_lock (&am->vlib_rp->mutex);
2771 oldheap = svm_push_data_heap (am->vlib_rp);
2775 svm_pop_heap (oldheap);
2776 pthread_mutex_unlock (&am->vlib_rp->mutex);
2778 if (vam->graph_nodes)
2780 hash_free (vam->graph_node_index_by_name);
2782 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2784 node = vam->graph_nodes[i];
2785 vec_free (node->name);
2786 vec_free (node->next_nodes);
2789 vec_free (vam->graph_nodes);
2792 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2793 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2794 vec_free (pvt_copy);
2796 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2798 node = vam->graph_nodes[i];
2799 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2803 static void vl_api_get_node_graph_reply_t_handler_json
2804 (vl_api_get_node_graph_reply_t * mp)
2806 vat_main_t *vam = &vat_main;
2807 api_main_t *am = &api_main;
2809 vat_json_node_t node;
2812 /* $$$$ make this real? */
2813 vat_json_init_object (&node);
2814 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2815 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2817 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2819 /* Toss the shared-memory original... */
2820 pthread_mutex_lock (&am->vlib_rp->mutex);
2821 oldheap = svm_push_data_heap (am->vlib_rp);
2825 svm_pop_heap (oldheap);
2826 pthread_mutex_unlock (&am->vlib_rp->mutex);
2828 vat_json_print (vam->ofp, &node);
2829 vat_json_free (&node);
2831 vam->retval = ntohl (mp->retval);
2832 vam->result_ready = 1;
2836 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2838 vat_main_t *vam = &vat_main;
2843 s = format (s, "%=16d%=16d%=16d",
2844 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2848 s = format (s, "%=16U%=16d%=16d",
2849 mp->is_ipv6 ? format_ip6_address :
2851 mp->ip_address, mp->priority, mp->weight);
2854 print (vam->ofp, "%v", s);
2859 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2861 vat_main_t *vam = &vat_main;
2862 vat_json_node_t *node = NULL;
2863 struct in6_addr ip6;
2866 if (VAT_JSON_ARRAY != vam->json_tree.type)
2868 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2869 vat_json_init_array (&vam->json_tree);
2871 node = vat_json_array_add (&vam->json_tree);
2872 vat_json_init_object (node);
2874 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2875 vat_json_object_add_uint (node, "priority", mp->priority);
2876 vat_json_object_add_uint (node, "weight", mp->weight);
2879 vat_json_object_add_uint (node, "sw_if_index",
2880 clib_net_to_host_u32 (mp->sw_if_index));
2885 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2886 vat_json_object_add_ip6 (node, "address", ip6);
2890 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2891 vat_json_object_add_ip4 (node, "address", ip4);
2897 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2900 vat_main_t *vam = &vat_main;
2903 ls_name = format (0, "%s", mp->ls_name);
2905 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2911 vl_api_one_locator_set_details_t_handler_json
2912 (vl_api_one_locator_set_details_t * mp)
2914 vat_main_t *vam = &vat_main;
2915 vat_json_node_t *node = 0;
2918 ls_name = format (0, "%s", mp->ls_name);
2919 vec_add1 (ls_name, 0);
2921 if (VAT_JSON_ARRAY != vam->json_tree.type)
2923 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2924 vat_json_init_array (&vam->json_tree);
2926 node = vat_json_array_add (&vam->json_tree);
2928 vat_json_init_object (node);
2929 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2930 vat_json_object_add_uint (node, "ls_index",
2931 clib_net_to_host_u32 (mp->ls_index));
2939 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2942 unformat_nsh_address (unformat_input_t * input, va_list * args)
2944 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2945 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2949 format_nsh_address_vat (u8 * s, va_list * args)
2951 nsh_t *a = va_arg (*args, nsh_t *);
2952 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2956 format_lisp_flat_eid (u8 * s, va_list * args)
2958 u32 type = va_arg (*args, u32);
2959 u8 *eid = va_arg (*args, u8 *);
2960 u32 eid_len = va_arg (*args, u32);
2965 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2967 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2969 return format (s, "%U", format_ethernet_address, eid);
2971 return format (s, "%U", format_nsh_address_vat, eid);
2977 format_lisp_eid_vat (u8 * s, va_list * args)
2979 u32 type = va_arg (*args, u32);
2980 u8 *eid = va_arg (*args, u8 *);
2981 u32 eid_len = va_arg (*args, u32);
2982 u8 *seid = va_arg (*args, u8 *);
2983 u32 seid_len = va_arg (*args, u32);
2984 u32 is_src_dst = va_arg (*args, u32);
2987 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2989 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2995 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2997 vat_main_t *vam = &vat_main;
2998 u8 *s = 0, *eid = 0;
3000 if (~0 == mp->locator_set_index)
3001 s = format (0, "action: %d", mp->action);
3003 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3005 eid = format (0, "%U", format_lisp_eid_vat,
3009 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3012 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3013 clib_net_to_host_u32 (mp->vni),
3015 mp->is_local ? "local" : "remote",
3016 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3017 clib_net_to_host_u16 (mp->key_id), mp->key);
3024 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3027 vat_main_t *vam = &vat_main;
3028 vat_json_node_t *node = 0;
3031 if (VAT_JSON_ARRAY != vam->json_tree.type)
3033 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3034 vat_json_init_array (&vam->json_tree);
3036 node = vat_json_array_add (&vam->json_tree);
3038 vat_json_init_object (node);
3039 if (~0 == mp->locator_set_index)
3040 vat_json_object_add_uint (node, "action", mp->action);
3042 vat_json_object_add_uint (node, "locator_set_index",
3043 clib_net_to_host_u32 (mp->locator_set_index));
3045 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3046 if (mp->eid_type == 3)
3048 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3049 vat_json_init_object (nsh_json);
3050 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3051 vat_json_object_add_uint (nsh_json, "spi",
3052 clib_net_to_host_u32 (nsh->spi));
3053 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3057 eid = format (0, "%U", format_lisp_eid_vat,
3061 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3063 vat_json_object_add_string_copy (node, "eid", eid);
3066 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3067 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3068 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3072 vat_json_object_add_uint (node, "key_id",
3073 clib_net_to_host_u16 (mp->key_id));
3074 vat_json_object_add_string_copy (node, "key", mp->key);
3079 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3081 vat_main_t *vam = &vat_main;
3082 u8 *seid = 0, *deid = 0;
3083 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3085 deid = format (0, "%U", format_lisp_eid_vat,
3086 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3088 seid = format (0, "%U", format_lisp_eid_vat,
3089 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3095 format_ip_address_fcn = format_ip4_address;
3097 format_ip_address_fcn = format_ip6_address;
3100 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3101 clib_net_to_host_u32 (mp->vni),
3103 format_ip_address_fcn, mp->lloc,
3104 format_ip_address_fcn, mp->rloc,
3105 clib_net_to_host_u32 (mp->pkt_count),
3106 clib_net_to_host_u32 (mp->bytes));
3113 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3115 struct in6_addr ip6;
3117 vat_main_t *vam = &vat_main;
3118 vat_json_node_t *node = 0;
3119 u8 *deid = 0, *seid = 0;
3121 if (VAT_JSON_ARRAY != vam->json_tree.type)
3123 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3124 vat_json_init_array (&vam->json_tree);
3126 node = vat_json_array_add (&vam->json_tree);
3128 vat_json_init_object (node);
3129 deid = format (0, "%U", format_lisp_eid_vat,
3130 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3132 seid = format (0, "%U", format_lisp_eid_vat,
3133 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3138 vat_json_object_add_string_copy (node, "seid", seid);
3139 vat_json_object_add_string_copy (node, "deid", deid);
3140 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3144 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3145 vat_json_object_add_ip4 (node, "lloc", ip4);
3146 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3147 vat_json_object_add_ip4 (node, "rloc", ip4);
3151 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3152 vat_json_object_add_ip6 (node, "lloc", ip6);
3153 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3154 vat_json_object_add_ip6 (node, "rloc", ip6);
3156 vat_json_object_add_uint (node, "pkt_count",
3157 clib_net_to_host_u32 (mp->pkt_count));
3158 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3165 vl_api_one_eid_table_map_details_t_handler
3166 (vl_api_one_eid_table_map_details_t * mp)
3168 vat_main_t *vam = &vat_main;
3170 u8 *line = format (0, "%=10d%=10d",
3171 clib_net_to_host_u32 (mp->vni),
3172 clib_net_to_host_u32 (mp->dp_table));
3173 print (vam->ofp, "%v", line);
3178 vl_api_one_eid_table_map_details_t_handler_json
3179 (vl_api_one_eid_table_map_details_t * mp)
3181 vat_main_t *vam = &vat_main;
3182 vat_json_node_t *node = NULL;
3184 if (VAT_JSON_ARRAY != vam->json_tree.type)
3186 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3187 vat_json_init_array (&vam->json_tree);
3189 node = vat_json_array_add (&vam->json_tree);
3190 vat_json_init_object (node);
3191 vat_json_object_add_uint (node, "dp_table",
3192 clib_net_to_host_u32 (mp->dp_table));
3193 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3197 vl_api_one_eid_table_vni_details_t_handler
3198 (vl_api_one_eid_table_vni_details_t * mp)
3200 vat_main_t *vam = &vat_main;
3202 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3203 print (vam->ofp, "%v", line);
3208 vl_api_one_eid_table_vni_details_t_handler_json
3209 (vl_api_one_eid_table_vni_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, "vni", clib_net_to_host_u32 (mp->vni));
3225 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3226 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3228 vat_main_t *vam = &vat_main;
3229 int retval = clib_net_to_host_u32 (mp->retval);
3231 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3232 print (vam->ofp, "fallback threshold value: %d", mp->value);
3234 vam->retval = retval;
3235 vam->result_ready = 1;
3239 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3240 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3242 vat_main_t *vam = &vat_main;
3243 vat_json_node_t _node, *node = &_node;
3244 int retval = clib_net_to_host_u32 (mp->retval);
3246 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3247 vat_json_init_object (node);
3248 vat_json_object_add_uint (node, "value", mp->value);
3250 vat_json_print (vam->ofp, node);
3251 vat_json_free (node);
3253 vam->retval = retval;
3254 vam->result_ready = 1;
3258 vl_api_show_one_map_register_state_reply_t_handler
3259 (vl_api_show_one_map_register_state_reply_t * mp)
3261 vat_main_t *vam = &vat_main;
3262 int retval = clib_net_to_host_u32 (mp->retval);
3264 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3266 vam->retval = retval;
3267 vam->result_ready = 1;
3271 vl_api_show_one_map_register_state_reply_t_handler_json
3272 (vl_api_show_one_map_register_state_reply_t * mp)
3274 vat_main_t *vam = &vat_main;
3275 vat_json_node_t _node, *node = &_node;
3276 int retval = clib_net_to_host_u32 (mp->retval);
3278 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3280 vat_json_init_object (node);
3281 vat_json_object_add_string_copy (node, "state", s);
3283 vat_json_print (vam->ofp, node);
3284 vat_json_free (node);
3286 vam->retval = retval;
3287 vam->result_ready = 1;
3292 vl_api_show_one_rloc_probe_state_reply_t_handler
3293 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3295 vat_main_t *vam = &vat_main;
3296 int retval = clib_net_to_host_u32 (mp->retval);
3301 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3303 vam->retval = retval;
3304 vam->result_ready = 1;
3308 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3309 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3311 vat_main_t *vam = &vat_main;
3312 vat_json_node_t _node, *node = &_node;
3313 int retval = clib_net_to_host_u32 (mp->retval);
3315 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3316 vat_json_init_object (node);
3317 vat_json_object_add_string_copy (node, "state", s);
3319 vat_json_print (vam->ofp, node);
3320 vat_json_free (node);
3322 vam->retval = retval;
3323 vam->result_ready = 1;
3328 vl_api_show_one_stats_enable_disable_reply_t_handler
3329 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3331 vat_main_t *vam = &vat_main;
3332 int retval = clib_net_to_host_u32 (mp->retval);
3337 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3339 vam->retval = retval;
3340 vam->result_ready = 1;
3344 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3345 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3347 vat_main_t *vam = &vat_main;
3348 vat_json_node_t _node, *node = &_node;
3349 int retval = clib_net_to_host_u32 (mp->retval);
3351 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3352 vat_json_init_object (node);
3353 vat_json_object_add_string_copy (node, "state", s);
3355 vat_json_print (vam->ofp, node);
3356 vat_json_free (node);
3358 vam->retval = retval;
3359 vam->result_ready = 1;
3364 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3366 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3367 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3368 e->vni = clib_net_to_host_u32 (e->vni);
3372 gpe_fwd_entries_get_reply_t_net_to_host
3373 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3377 mp->count = clib_net_to_host_u32 (mp->count);
3378 for (i = 0; i < mp->count; i++)
3380 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3385 format_gpe_encap_mode (u8 * s, va_list * args)
3387 u32 mode = va_arg (*args, u32);
3392 return format (s, "lisp");
3394 return format (s, "vxlan");
3400 vl_api_gpe_get_encap_mode_reply_t_handler
3401 (vl_api_gpe_get_encap_mode_reply_t * mp)
3403 vat_main_t *vam = &vat_main;
3405 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3406 vam->retval = ntohl (mp->retval);
3407 vam->result_ready = 1;
3411 vl_api_gpe_get_encap_mode_reply_t_handler_json
3412 (vl_api_gpe_get_encap_mode_reply_t * mp)
3414 vat_main_t *vam = &vat_main;
3415 vat_json_node_t node;
3417 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3418 vec_add1 (encap_mode, 0);
3420 vat_json_init_object (&node);
3421 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3423 vec_free (encap_mode);
3424 vat_json_print (vam->ofp, &node);
3425 vat_json_free (&node);
3427 vam->retval = ntohl (mp->retval);
3428 vam->result_ready = 1;
3432 vl_api_gpe_fwd_entry_path_details_t_handler
3433 (vl_api_gpe_fwd_entry_path_details_t * mp)
3435 vat_main_t *vam = &vat_main;
3436 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3438 if (mp->lcl_loc.is_ip4)
3439 format_ip_address_fcn = format_ip4_address;
3441 format_ip_address_fcn = format_ip6_address;
3443 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3444 format_ip_address_fcn, &mp->lcl_loc,
3445 format_ip_address_fcn, &mp->rmt_loc);
3449 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3451 struct in6_addr ip6;
3456 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3457 vat_json_object_add_ip4 (n, "address", ip4);
3461 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3462 vat_json_object_add_ip6 (n, "address", ip6);
3464 vat_json_object_add_uint (n, "weight", loc->weight);
3468 vl_api_gpe_fwd_entry_path_details_t_handler_json
3469 (vl_api_gpe_fwd_entry_path_details_t * mp)
3471 vat_main_t *vam = &vat_main;
3472 vat_json_node_t *node = NULL;
3473 vat_json_node_t *loc_node;
3475 if (VAT_JSON_ARRAY != vam->json_tree.type)
3477 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3478 vat_json_init_array (&vam->json_tree);
3480 node = vat_json_array_add (&vam->json_tree);
3481 vat_json_init_object (node);
3483 loc_node = vat_json_object_add (node, "local_locator");
3484 vat_json_init_object (loc_node);
3485 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3487 loc_node = vat_json_object_add (node, "remote_locator");
3488 vat_json_init_object (loc_node);
3489 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3493 vl_api_gpe_fwd_entries_get_reply_t_handler
3494 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3496 vat_main_t *vam = &vat_main;
3498 int retval = clib_net_to_host_u32 (mp->retval);
3499 vl_api_gpe_fwd_entry_t *e;
3504 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3506 for (i = 0; i < mp->count; i++)
3508 e = &mp->entries[i];
3509 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3510 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3511 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3515 vam->retval = retval;
3516 vam->result_ready = 1;
3520 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3521 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3524 vat_main_t *vam = &vat_main;
3525 vat_json_node_t *e = 0, root;
3527 int retval = clib_net_to_host_u32 (mp->retval);
3528 vl_api_gpe_fwd_entry_t *fwd;
3533 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3534 vat_json_init_array (&root);
3536 for (i = 0; i < mp->count; i++)
3538 e = vat_json_array_add (&root);
3539 fwd = &mp->entries[i];
3541 vat_json_init_object (e);
3542 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3543 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3544 vat_json_object_add_int (e, "vni", fwd->vni);
3545 vat_json_object_add_int (e, "action", fwd->action);
3547 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3548 fwd->leid_prefix_len);
3550 vat_json_object_add_string_copy (e, "leid", s);
3553 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3554 fwd->reid_prefix_len);
3556 vat_json_object_add_string_copy (e, "reid", s);
3560 vat_json_print (vam->ofp, &root);
3561 vat_json_free (&root);
3564 vam->retval = retval;
3565 vam->result_ready = 1;
3569 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3570 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3572 vat_main_t *vam = &vat_main;
3574 int retval = clib_net_to_host_u32 (mp->retval);
3575 vl_api_gpe_native_fwd_rpath_t *r;
3580 n = clib_net_to_host_u32 (mp->count);
3582 for (i = 0; i < n; i++)
3584 r = &mp->entries[i];
3585 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3586 clib_net_to_host_u32 (r->fib_index),
3587 clib_net_to_host_u32 (r->nh_sw_if_index),
3588 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3592 vam->retval = retval;
3593 vam->result_ready = 1;
3597 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3598 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3600 vat_main_t *vam = &vat_main;
3601 vat_json_node_t root, *e;
3603 int retval = clib_net_to_host_u32 (mp->retval);
3604 vl_api_gpe_native_fwd_rpath_t *r;
3610 n = clib_net_to_host_u32 (mp->count);
3611 vat_json_init_array (&root);
3613 for (i = 0; i < n; i++)
3615 e = vat_json_array_add (&root);
3616 vat_json_init_object (e);
3617 r = &mp->entries[i];
3619 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3622 vat_json_object_add_string_copy (e, "ip4", s);
3625 vat_json_object_add_uint (e, "fib_index",
3626 clib_net_to_host_u32 (r->fib_index));
3627 vat_json_object_add_uint (e, "nh_sw_if_index",
3628 clib_net_to_host_u32 (r->nh_sw_if_index));
3631 vat_json_print (vam->ofp, &root);
3632 vat_json_free (&root);
3635 vam->retval = retval;
3636 vam->result_ready = 1;
3640 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3641 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3643 vat_main_t *vam = &vat_main;
3645 int retval = clib_net_to_host_u32 (mp->retval);
3650 n = clib_net_to_host_u32 (mp->count);
3652 for (i = 0; i < n; i++)
3653 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3656 vam->retval = retval;
3657 vam->result_ready = 1;
3661 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3662 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3664 vat_main_t *vam = &vat_main;
3665 vat_json_node_t root;
3667 int retval = clib_net_to_host_u32 (mp->retval);
3672 n = clib_net_to_host_u32 (mp->count);
3673 vat_json_init_array (&root);
3675 for (i = 0; i < n; i++)
3676 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3678 vat_json_print (vam->ofp, &root);
3679 vat_json_free (&root);
3682 vam->retval = retval;
3683 vam->result_ready = 1;
3687 vl_api_one_ndp_entries_get_reply_t_handler
3688 (vl_api_one_ndp_entries_get_reply_t * mp)
3690 vat_main_t *vam = &vat_main;
3692 int retval = clib_net_to_host_u32 (mp->retval);
3697 n = clib_net_to_host_u32 (mp->count);
3699 for (i = 0; i < n; i++)
3700 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3701 format_ethernet_address, mp->entries[i].mac);
3704 vam->retval = retval;
3705 vam->result_ready = 1;
3709 vl_api_one_ndp_entries_get_reply_t_handler_json
3710 (vl_api_one_ndp_entries_get_reply_t * mp)
3713 vat_main_t *vam = &vat_main;
3714 vat_json_node_t *e = 0, root;
3716 int retval = clib_net_to_host_u32 (mp->retval);
3717 vl_api_one_ndp_entry_t *arp_entry;
3722 n = clib_net_to_host_u32 (mp->count);
3723 vat_json_init_array (&root);
3725 for (i = 0; i < n; i++)
3727 e = vat_json_array_add (&root);
3728 arp_entry = &mp->entries[i];
3730 vat_json_init_object (e);
3731 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3734 vat_json_object_add_string_copy (e, "mac", s);
3737 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3739 vat_json_object_add_string_copy (e, "ip6", s);
3743 vat_json_print (vam->ofp, &root);
3744 vat_json_free (&root);
3747 vam->retval = retval;
3748 vam->result_ready = 1;
3752 vl_api_one_l2_arp_entries_get_reply_t_handler
3753 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3755 vat_main_t *vam = &vat_main;
3757 int retval = clib_net_to_host_u32 (mp->retval);
3762 n = clib_net_to_host_u32 (mp->count);
3764 for (i = 0; i < n; i++)
3765 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3766 format_ethernet_address, mp->entries[i].mac);
3769 vam->retval = retval;
3770 vam->result_ready = 1;
3774 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3775 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3778 vat_main_t *vam = &vat_main;
3779 vat_json_node_t *e = 0, root;
3781 int retval = clib_net_to_host_u32 (mp->retval);
3782 vl_api_one_l2_arp_entry_t *arp_entry;
3787 n = clib_net_to_host_u32 (mp->count);
3788 vat_json_init_array (&root);
3790 for (i = 0; i < n; i++)
3792 e = vat_json_array_add (&root);
3793 arp_entry = &mp->entries[i];
3795 vat_json_init_object (e);
3796 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3799 vat_json_object_add_string_copy (e, "mac", s);
3802 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3804 vat_json_object_add_string_copy (e, "ip4", s);
3808 vat_json_print (vam->ofp, &root);
3809 vat_json_free (&root);
3812 vam->retval = retval;
3813 vam->result_ready = 1;
3817 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3819 vat_main_t *vam = &vat_main;
3821 int retval = clib_net_to_host_u32 (mp->retval);
3826 n = clib_net_to_host_u32 (mp->count);
3828 for (i = 0; i < n; i++)
3830 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3834 vam->retval = retval;
3835 vam->result_ready = 1;
3839 vl_api_one_ndp_bd_get_reply_t_handler_json
3840 (vl_api_one_ndp_bd_get_reply_t * mp)
3842 vat_main_t *vam = &vat_main;
3843 vat_json_node_t root;
3845 int retval = clib_net_to_host_u32 (mp->retval);
3850 n = clib_net_to_host_u32 (mp->count);
3851 vat_json_init_array (&root);
3853 for (i = 0; i < n; i++)
3855 vat_json_array_add_uint (&root,
3856 clib_net_to_host_u32 (mp->bridge_domains[i]));
3859 vat_json_print (vam->ofp, &root);
3860 vat_json_free (&root);
3863 vam->retval = retval;
3864 vam->result_ready = 1;
3868 vl_api_one_l2_arp_bd_get_reply_t_handler
3869 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3871 vat_main_t *vam = &vat_main;
3873 int retval = clib_net_to_host_u32 (mp->retval);
3878 n = clib_net_to_host_u32 (mp->count);
3880 for (i = 0; i < n; i++)
3882 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3886 vam->retval = retval;
3887 vam->result_ready = 1;
3891 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3892 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3894 vat_main_t *vam = &vat_main;
3895 vat_json_node_t root;
3897 int retval = clib_net_to_host_u32 (mp->retval);
3902 n = clib_net_to_host_u32 (mp->count);
3903 vat_json_init_array (&root);
3905 for (i = 0; i < n; i++)
3907 vat_json_array_add_uint (&root,
3908 clib_net_to_host_u32 (mp->bridge_domains[i]));
3911 vat_json_print (vam->ofp, &root);
3912 vat_json_free (&root);
3915 vam->retval = retval;
3916 vam->result_ready = 1;
3920 vl_api_one_adjacencies_get_reply_t_handler
3921 (vl_api_one_adjacencies_get_reply_t * mp)
3923 vat_main_t *vam = &vat_main;
3925 int retval = clib_net_to_host_u32 (mp->retval);
3926 vl_api_one_adjacency_t *a;
3931 n = clib_net_to_host_u32 (mp->count);
3933 for (i = 0; i < n; i++)
3935 a = &mp->adjacencies[i];
3936 print (vam->ofp, "%U %40U",
3937 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3938 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3942 vam->retval = retval;
3943 vam->result_ready = 1;
3947 vl_api_one_adjacencies_get_reply_t_handler_json
3948 (vl_api_one_adjacencies_get_reply_t * mp)
3951 vat_main_t *vam = &vat_main;
3952 vat_json_node_t *e = 0, root;
3954 int retval = clib_net_to_host_u32 (mp->retval);
3955 vl_api_one_adjacency_t *a;
3960 n = clib_net_to_host_u32 (mp->count);
3961 vat_json_init_array (&root);
3963 for (i = 0; i < n; i++)
3965 e = vat_json_array_add (&root);
3966 a = &mp->adjacencies[i];
3968 vat_json_init_object (e);
3969 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3970 a->leid_prefix_len);
3972 vat_json_object_add_string_copy (e, "leid", s);
3975 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3976 a->reid_prefix_len);
3978 vat_json_object_add_string_copy (e, "reid", s);
3982 vat_json_print (vam->ofp, &root);
3983 vat_json_free (&root);
3986 vam->retval = retval;
3987 vam->result_ready = 1;
3991 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3993 vat_main_t *vam = &vat_main;
3995 print (vam->ofp, "%=20U",
3996 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4001 vl_api_one_map_server_details_t_handler_json
4002 (vl_api_one_map_server_details_t * mp)
4004 vat_main_t *vam = &vat_main;
4005 vat_json_node_t *node = NULL;
4006 struct in6_addr ip6;
4009 if (VAT_JSON_ARRAY != vam->json_tree.type)
4011 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4012 vat_json_init_array (&vam->json_tree);
4014 node = vat_json_array_add (&vam->json_tree);
4016 vat_json_init_object (node);
4019 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4020 vat_json_object_add_ip6 (node, "map-server", ip6);
4024 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4025 vat_json_object_add_ip4 (node, "map-server", ip4);
4030 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4033 vat_main_t *vam = &vat_main;
4035 print (vam->ofp, "%=20U",
4036 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4041 vl_api_one_map_resolver_details_t_handler_json
4042 (vl_api_one_map_resolver_details_t * mp)
4044 vat_main_t *vam = &vat_main;
4045 vat_json_node_t *node = NULL;
4046 struct in6_addr ip6;
4049 if (VAT_JSON_ARRAY != vam->json_tree.type)
4051 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4052 vat_json_init_array (&vam->json_tree);
4054 node = vat_json_array_add (&vam->json_tree);
4056 vat_json_init_object (node);
4059 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4060 vat_json_object_add_ip6 (node, "map resolver", ip6);
4064 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4065 vat_json_object_add_ip4 (node, "map resolver", ip4);
4070 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4072 vat_main_t *vam = &vat_main;
4073 i32 retval = ntohl (mp->retval);
4077 print (vam->ofp, "feature: %s\ngpe: %s",
4078 mp->feature_status ? "enabled" : "disabled",
4079 mp->gpe_status ? "enabled" : "disabled");
4082 vam->retval = retval;
4083 vam->result_ready = 1;
4087 vl_api_show_one_status_reply_t_handler_json
4088 (vl_api_show_one_status_reply_t * mp)
4090 vat_main_t *vam = &vat_main;
4091 vat_json_node_t node;
4092 u8 *gpe_status = NULL;
4093 u8 *feature_status = NULL;
4095 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4096 feature_status = format (0, "%s",
4097 mp->feature_status ? "enabled" : "disabled");
4098 vec_add1 (gpe_status, 0);
4099 vec_add1 (feature_status, 0);
4101 vat_json_init_object (&node);
4102 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4103 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4105 vec_free (gpe_status);
4106 vec_free (feature_status);
4108 vat_json_print (vam->ofp, &node);
4109 vat_json_free (&node);
4111 vam->retval = ntohl (mp->retval);
4112 vam->result_ready = 1;
4116 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4117 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4119 vat_main_t *vam = &vat_main;
4120 i32 retval = ntohl (mp->retval);
4124 print (vam->ofp, "%=20s", mp->locator_set_name);
4127 vam->retval = retval;
4128 vam->result_ready = 1;
4132 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4133 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4135 vat_main_t *vam = &vat_main;
4136 vat_json_node_t *node = NULL;
4138 if (VAT_JSON_ARRAY != vam->json_tree.type)
4140 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4141 vat_json_init_array (&vam->json_tree);
4143 node = vat_json_array_add (&vam->json_tree);
4145 vat_json_init_object (node);
4146 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4148 vat_json_print (vam->ofp, node);
4149 vat_json_free (node);
4151 vam->retval = ntohl (mp->retval);
4152 vam->result_ready = 1;
4156 format_lisp_map_request_mode (u8 * s, va_list * args)
4158 u32 mode = va_arg (*args, u32);
4163 return format (0, "dst-only");
4165 return format (0, "src-dst");
4171 vl_api_show_one_map_request_mode_reply_t_handler
4172 (vl_api_show_one_map_request_mode_reply_t * mp)
4174 vat_main_t *vam = &vat_main;
4175 i32 retval = ntohl (mp->retval);
4179 u32 mode = mp->mode;
4180 print (vam->ofp, "map_request_mode: %U",
4181 format_lisp_map_request_mode, mode);
4184 vam->retval = retval;
4185 vam->result_ready = 1;
4189 vl_api_show_one_map_request_mode_reply_t_handler_json
4190 (vl_api_show_one_map_request_mode_reply_t * mp)
4192 vat_main_t *vam = &vat_main;
4193 vat_json_node_t node;
4198 s = format (0, "%U", format_lisp_map_request_mode, mode);
4201 vat_json_init_object (&node);
4202 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4203 vat_json_print (vam->ofp, &node);
4204 vat_json_free (&node);
4207 vam->retval = ntohl (mp->retval);
4208 vam->result_ready = 1;
4212 vl_api_show_one_use_petr_reply_t_handler
4213 (vl_api_show_one_use_petr_reply_t * mp)
4215 vat_main_t *vam = &vat_main;
4216 i32 retval = ntohl (mp->retval);
4220 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4223 print (vam->ofp, "Proxy-ETR address; %U",
4224 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4229 vam->retval = retval;
4230 vam->result_ready = 1;
4234 vl_api_show_one_use_petr_reply_t_handler_json
4235 (vl_api_show_one_use_petr_reply_t * mp)
4237 vat_main_t *vam = &vat_main;
4238 vat_json_node_t node;
4241 struct in6_addr ip6;
4243 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4244 vec_add1 (status, 0);
4246 vat_json_init_object (&node);
4247 vat_json_object_add_string_copy (&node, "status", status);
4252 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4253 vat_json_object_add_ip6 (&node, "address", ip6);
4257 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4258 vat_json_object_add_ip4 (&node, "address", ip4);
4264 vat_json_print (vam->ofp, &node);
4265 vat_json_free (&node);
4267 vam->retval = ntohl (mp->retval);
4268 vam->result_ready = 1;
4272 vl_api_show_one_nsh_mapping_reply_t_handler
4273 (vl_api_show_one_nsh_mapping_reply_t * mp)
4275 vat_main_t *vam = &vat_main;
4276 i32 retval = ntohl (mp->retval);
4280 print (vam->ofp, "%-20s%-16s",
4281 mp->is_set ? "set" : "not-set",
4282 mp->is_set ? (char *) mp->locator_set_name : "");
4285 vam->retval = retval;
4286 vam->result_ready = 1;
4290 vl_api_show_one_nsh_mapping_reply_t_handler_json
4291 (vl_api_show_one_nsh_mapping_reply_t * mp)
4293 vat_main_t *vam = &vat_main;
4294 vat_json_node_t node;
4297 status = format (0, "%s", mp->is_set ? "yes" : "no");
4298 vec_add1 (status, 0);
4300 vat_json_init_object (&node);
4301 vat_json_object_add_string_copy (&node, "is_set", status);
4304 vat_json_object_add_string_copy (&node, "locator_set",
4305 mp->locator_set_name);
4310 vat_json_print (vam->ofp, &node);
4311 vat_json_free (&node);
4313 vam->retval = ntohl (mp->retval);
4314 vam->result_ready = 1;
4318 vl_api_show_one_map_register_ttl_reply_t_handler
4319 (vl_api_show_one_map_register_ttl_reply_t * mp)
4321 vat_main_t *vam = &vat_main;
4322 i32 retval = ntohl (mp->retval);
4324 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4328 print (vam->ofp, "ttl: %u", mp->ttl);
4331 vam->retval = retval;
4332 vam->result_ready = 1;
4336 vl_api_show_one_map_register_ttl_reply_t_handler_json
4337 (vl_api_show_one_map_register_ttl_reply_t * mp)
4339 vat_main_t *vam = &vat_main;
4340 vat_json_node_t node;
4342 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4343 vat_json_init_object (&node);
4344 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4346 vat_json_print (vam->ofp, &node);
4347 vat_json_free (&node);
4349 vam->retval = ntohl (mp->retval);
4350 vam->result_ready = 1;
4354 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4356 vat_main_t *vam = &vat_main;
4357 i32 retval = ntohl (mp->retval);
4361 print (vam->ofp, "%-20s%-16s",
4362 mp->status ? "enabled" : "disabled",
4363 mp->status ? (char *) mp->locator_set_name : "");
4366 vam->retval = retval;
4367 vam->result_ready = 1;
4371 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4373 vat_main_t *vam = &vat_main;
4374 vat_json_node_t node;
4377 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4378 vec_add1 (status, 0);
4380 vat_json_init_object (&node);
4381 vat_json_object_add_string_copy (&node, "status", status);
4384 vat_json_object_add_string_copy (&node, "locator_set",
4385 mp->locator_set_name);
4390 vat_json_print (vam->ofp, &node);
4391 vat_json_free (&node);
4393 vam->retval = ntohl (mp->retval);
4394 vam->result_ready = 1;
4398 format_policer_type (u8 * s, va_list * va)
4400 u32 i = va_arg (*va, u32);
4402 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4403 s = format (s, "1r2c");
4404 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4405 s = format (s, "1r3c");
4406 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4407 s = format (s, "2r3c-2698");
4408 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4409 s = format (s, "2r3c-4115");
4410 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4411 s = format (s, "2r3c-mef5cf1");
4413 s = format (s, "ILLEGAL");
4418 format_policer_rate_type (u8 * s, va_list * va)
4420 u32 i = va_arg (*va, u32);
4422 if (i == SSE2_QOS_RATE_KBPS)
4423 s = format (s, "kbps");
4424 else if (i == SSE2_QOS_RATE_PPS)
4425 s = format (s, "pps");
4427 s = format (s, "ILLEGAL");
4432 format_policer_round_type (u8 * s, va_list * va)
4434 u32 i = va_arg (*va, u32);
4436 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4437 s = format (s, "closest");
4438 else if (i == SSE2_QOS_ROUND_TO_UP)
4439 s = format (s, "up");
4440 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4441 s = format (s, "down");
4443 s = format (s, "ILLEGAL");
4448 format_policer_action_type (u8 * s, va_list * va)
4450 u32 i = va_arg (*va, u32);
4452 if (i == SSE2_QOS_ACTION_DROP)
4453 s = format (s, "drop");
4454 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4455 s = format (s, "transmit");
4456 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4457 s = format (s, "mark-and-transmit");
4459 s = format (s, "ILLEGAL");
4464 format_dscp (u8 * s, va_list * va)
4466 u32 i = va_arg (*va, u32);
4471 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4475 return format (s, "ILLEGAL");
4477 s = format (s, "%s", t);
4482 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4484 vat_main_t *vam = &vat_main;
4485 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4487 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4488 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4490 conform_dscp_str = format (0, "");
4492 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4493 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4495 exceed_dscp_str = format (0, "");
4497 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4498 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4500 violate_dscp_str = format (0, "");
4502 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4503 "rate type %U, round type %U, %s rate, %s color-aware, "
4504 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4505 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4506 "conform action %U%s, exceed action %U%s, violate action %U%s",
4508 format_policer_type, mp->type,
4511 clib_net_to_host_u64 (mp->cb),
4512 clib_net_to_host_u64 (mp->eb),
4513 format_policer_rate_type, mp->rate_type,
4514 format_policer_round_type, mp->round_type,
4515 mp->single_rate ? "single" : "dual",
4516 mp->color_aware ? "is" : "not",
4517 ntohl (mp->cir_tokens_per_period),
4518 ntohl (mp->pir_tokens_per_period),
4520 ntohl (mp->current_limit),
4521 ntohl (mp->current_bucket),
4522 ntohl (mp->extended_limit),
4523 ntohl (mp->extended_bucket),
4524 clib_net_to_host_u64 (mp->last_update_time),
4525 format_policer_action_type, mp->conform_action_type,
4527 format_policer_action_type, mp->exceed_action_type,
4529 format_policer_action_type, mp->violate_action_type,
4532 vec_free (conform_dscp_str);
4533 vec_free (exceed_dscp_str);
4534 vec_free (violate_dscp_str);
4537 static void vl_api_policer_details_t_handler_json
4538 (vl_api_policer_details_t * mp)
4540 vat_main_t *vam = &vat_main;
4541 vat_json_node_t *node;
4542 u8 *rate_type_str, *round_type_str, *type_str;
4543 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4545 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4547 format (0, "%U", format_policer_round_type, mp->round_type);
4548 type_str = format (0, "%U", format_policer_type, mp->type);
4549 conform_action_str = format (0, "%U", format_policer_action_type,
4550 mp->conform_action_type);
4551 exceed_action_str = format (0, "%U", format_policer_action_type,
4552 mp->exceed_action_type);
4553 violate_action_str = format (0, "%U", format_policer_action_type,
4554 mp->violate_action_type);
4556 if (VAT_JSON_ARRAY != vam->json_tree.type)
4558 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4559 vat_json_init_array (&vam->json_tree);
4561 node = vat_json_array_add (&vam->json_tree);
4563 vat_json_init_object (node);
4564 vat_json_object_add_string_copy (node, "name", mp->name);
4565 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4566 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4567 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4568 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4569 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4570 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4571 vat_json_object_add_string_copy (node, "type", type_str);
4572 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4573 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4574 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4575 vat_json_object_add_uint (node, "cir_tokens_per_period",
4576 ntohl (mp->cir_tokens_per_period));
4577 vat_json_object_add_uint (node, "eir_tokens_per_period",
4578 ntohl (mp->pir_tokens_per_period));
4579 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4580 vat_json_object_add_uint (node, "current_bucket",
4581 ntohl (mp->current_bucket));
4582 vat_json_object_add_uint (node, "extended_limit",
4583 ntohl (mp->extended_limit));
4584 vat_json_object_add_uint (node, "extended_bucket",
4585 ntohl (mp->extended_bucket));
4586 vat_json_object_add_uint (node, "last_update_time",
4587 ntohl (mp->last_update_time));
4588 vat_json_object_add_string_copy (node, "conform_action",
4589 conform_action_str);
4590 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4592 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4593 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4594 vec_free (dscp_str);
4596 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4597 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4599 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4600 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4601 vec_free (dscp_str);
4603 vat_json_object_add_string_copy (node, "violate_action",
4604 violate_action_str);
4605 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4607 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4608 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4609 vec_free (dscp_str);
4612 vec_free (rate_type_str);
4613 vec_free (round_type_str);
4614 vec_free (type_str);
4615 vec_free (conform_action_str);
4616 vec_free (exceed_action_str);
4617 vec_free (violate_action_str);
4621 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4624 vat_main_t *vam = &vat_main;
4625 int i, count = ntohl (mp->count);
4628 print (vam->ofp, "classify table ids (%d) : ", count);
4629 for (i = 0; i < count; i++)
4631 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4632 print (vam->ofp, (i < count - 1) ? "," : "");
4634 vam->retval = ntohl (mp->retval);
4635 vam->result_ready = 1;
4639 vl_api_classify_table_ids_reply_t_handler_json
4640 (vl_api_classify_table_ids_reply_t * mp)
4642 vat_main_t *vam = &vat_main;
4643 int i, count = ntohl (mp->count);
4647 vat_json_node_t node;
4649 vat_json_init_object (&node);
4650 for (i = 0; i < count; i++)
4652 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4654 vat_json_print (vam->ofp, &node);
4655 vat_json_free (&node);
4657 vam->retval = ntohl (mp->retval);
4658 vam->result_ready = 1;
4662 vl_api_classify_table_by_interface_reply_t_handler
4663 (vl_api_classify_table_by_interface_reply_t * mp)
4665 vat_main_t *vam = &vat_main;
4668 table_id = ntohl (mp->l2_table_id);
4670 print (vam->ofp, "l2 table id : %d", table_id);
4672 print (vam->ofp, "l2 table id : No input ACL tables configured");
4673 table_id = ntohl (mp->ip4_table_id);
4675 print (vam->ofp, "ip4 table id : %d", table_id);
4677 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4678 table_id = ntohl (mp->ip6_table_id);
4680 print (vam->ofp, "ip6 table id : %d", table_id);
4682 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4683 vam->retval = ntohl (mp->retval);
4684 vam->result_ready = 1;
4688 vl_api_classify_table_by_interface_reply_t_handler_json
4689 (vl_api_classify_table_by_interface_reply_t * mp)
4691 vat_main_t *vam = &vat_main;
4692 vat_json_node_t node;
4694 vat_json_init_object (&node);
4696 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4697 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4698 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4700 vat_json_print (vam->ofp, &node);
4701 vat_json_free (&node);
4703 vam->retval = ntohl (mp->retval);
4704 vam->result_ready = 1;
4707 static void vl_api_policer_add_del_reply_t_handler
4708 (vl_api_policer_add_del_reply_t * mp)
4710 vat_main_t *vam = &vat_main;
4711 i32 retval = ntohl (mp->retval);
4712 if (vam->async_mode)
4714 vam->async_errors += (retval < 0);
4718 vam->retval = retval;
4719 vam->result_ready = 1;
4720 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4722 * Note: this is just barely thread-safe, depends on
4723 * the main thread spinning waiting for an answer...
4725 errmsg ("policer index %d", ntohl (mp->policer_index));
4729 static void vl_api_policer_add_del_reply_t_handler_json
4730 (vl_api_policer_add_del_reply_t * mp)
4732 vat_main_t *vam = &vat_main;
4733 vat_json_node_t node;
4735 vat_json_init_object (&node);
4736 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4737 vat_json_object_add_uint (&node, "policer_index",
4738 ntohl (mp->policer_index));
4740 vat_json_print (vam->ofp, &node);
4741 vat_json_free (&node);
4743 vam->retval = ntohl (mp->retval);
4744 vam->result_ready = 1;
4747 /* Format hex dump. */
4749 format_hex_bytes (u8 * s, va_list * va)
4751 u8 *bytes = va_arg (*va, u8 *);
4752 int n_bytes = va_arg (*va, int);
4755 /* Print short or long form depending on byte count. */
4756 uword short_form = n_bytes <= 32;
4757 u32 indent = format_get_indent (s);
4762 for (i = 0; i < n_bytes; i++)
4764 if (!short_form && (i % 32) == 0)
4765 s = format (s, "%08x: ", i);
4766 s = format (s, "%02x", bytes[i]);
4767 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4768 s = format (s, "\n%U", format_white_space, indent);
4775 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4778 vat_main_t *vam = &vat_main;
4779 i32 retval = ntohl (mp->retval);
4782 print (vam->ofp, "classify table info :");
4783 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4784 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4785 ntohl (mp->miss_next_index));
4786 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4787 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4788 ntohl (mp->match_n_vectors));
4789 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4790 ntohl (mp->mask_length));
4792 vam->retval = retval;
4793 vam->result_ready = 1;
4797 vl_api_classify_table_info_reply_t_handler_json
4798 (vl_api_classify_table_info_reply_t * mp)
4800 vat_main_t *vam = &vat_main;
4801 vat_json_node_t node;
4803 i32 retval = ntohl (mp->retval);
4806 vat_json_init_object (&node);
4808 vat_json_object_add_int (&node, "sessions",
4809 ntohl (mp->active_sessions));
4810 vat_json_object_add_int (&node, "nexttbl",
4811 ntohl (mp->next_table_index));
4812 vat_json_object_add_int (&node, "nextnode",
4813 ntohl (mp->miss_next_index));
4814 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4815 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4816 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4817 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4818 ntohl (mp->mask_length), 0);
4819 vat_json_object_add_string_copy (&node, "mask", s);
4821 vat_json_print (vam->ofp, &node);
4822 vat_json_free (&node);
4824 vam->retval = ntohl (mp->retval);
4825 vam->result_ready = 1;
4829 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4832 vat_main_t *vam = &vat_main;
4834 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4835 ntohl (mp->hit_next_index), ntohl (mp->advance),
4836 ntohl (mp->opaque_index));
4837 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4838 ntohl (mp->match_length));
4842 vl_api_classify_session_details_t_handler_json
4843 (vl_api_classify_session_details_t * mp)
4845 vat_main_t *vam = &vat_main;
4846 vat_json_node_t *node = NULL;
4848 if (VAT_JSON_ARRAY != vam->json_tree.type)
4850 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4851 vat_json_init_array (&vam->json_tree);
4853 node = vat_json_array_add (&vam->json_tree);
4855 vat_json_init_object (node);
4856 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4857 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4858 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4860 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4862 vat_json_object_add_string_copy (node, "match", s);
4865 static void vl_api_pg_create_interface_reply_t_handler
4866 (vl_api_pg_create_interface_reply_t * mp)
4868 vat_main_t *vam = &vat_main;
4870 vam->retval = ntohl (mp->retval);
4871 vam->result_ready = 1;
4874 static void vl_api_pg_create_interface_reply_t_handler_json
4875 (vl_api_pg_create_interface_reply_t * mp)
4877 vat_main_t *vam = &vat_main;
4878 vat_json_node_t node;
4880 i32 retval = ntohl (mp->retval);
4883 vat_json_init_object (&node);
4885 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4887 vat_json_print (vam->ofp, &node);
4888 vat_json_free (&node);
4890 vam->retval = ntohl (mp->retval);
4891 vam->result_ready = 1;
4894 static void vl_api_policer_classify_details_t_handler
4895 (vl_api_policer_classify_details_t * mp)
4897 vat_main_t *vam = &vat_main;
4899 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4900 ntohl (mp->table_index));
4903 static void vl_api_policer_classify_details_t_handler_json
4904 (vl_api_policer_classify_details_t * mp)
4906 vat_main_t *vam = &vat_main;
4907 vat_json_node_t *node;
4909 if (VAT_JSON_ARRAY != vam->json_tree.type)
4911 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4912 vat_json_init_array (&vam->json_tree);
4914 node = vat_json_array_add (&vam->json_tree);
4916 vat_json_init_object (node);
4917 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4918 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4921 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4922 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4924 vat_main_t *vam = &vat_main;
4925 i32 retval = ntohl (mp->retval);
4926 if (vam->async_mode)
4928 vam->async_errors += (retval < 0);
4932 vam->retval = retval;
4933 vam->sw_if_index = ntohl (mp->sw_if_index);
4934 vam->result_ready = 1;
4938 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4939 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4941 vat_main_t *vam = &vat_main;
4942 vat_json_node_t node;
4944 vat_json_init_object (&node);
4945 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4946 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4948 vat_json_print (vam->ofp, &node);
4949 vat_json_free (&node);
4951 vam->retval = ntohl (mp->retval);
4952 vam->result_ready = 1;
4955 static void vl_api_flow_classify_details_t_handler
4956 (vl_api_flow_classify_details_t * mp)
4958 vat_main_t *vam = &vat_main;
4960 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4961 ntohl (mp->table_index));
4964 static void vl_api_flow_classify_details_t_handler_json
4965 (vl_api_flow_classify_details_t * mp)
4967 vat_main_t *vam = &vat_main;
4968 vat_json_node_t *node;
4970 if (VAT_JSON_ARRAY != vam->json_tree.type)
4972 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4973 vat_json_init_array (&vam->json_tree);
4975 node = vat_json_array_add (&vam->json_tree);
4977 vat_json_init_object (node);
4978 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4979 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4982 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
4983 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
4984 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
4985 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
4986 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
4987 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
4988 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
4989 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
4990 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
4991 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
4992 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
4993 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
4994 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4995 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4996 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
4997 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
4998 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
4999 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5000 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5001 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5002 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5003 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5006 * Generate boilerplate reply handlers, which
5007 * dig the return value out of the xxx_reply_t API message,
5008 * stick it into vam->retval, and set vam->result_ready
5010 * Could also do this by pointing N message decode slots at
5011 * a single function, but that could break in subtle ways.
5014 #define foreach_standard_reply_retval_handler \
5015 _(sw_interface_set_flags_reply) \
5016 _(sw_interface_add_del_address_reply) \
5017 _(sw_interface_set_table_reply) \
5018 _(sw_interface_set_mpls_enable_reply) \
5019 _(sw_interface_set_vpath_reply) \
5020 _(sw_interface_set_vxlan_bypass_reply) \
5021 _(sw_interface_set_geneve_bypass_reply) \
5022 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5023 _(sw_interface_set_l2_bridge_reply) \
5024 _(bridge_domain_add_del_reply) \
5025 _(sw_interface_set_l2_xconnect_reply) \
5026 _(l2fib_add_del_reply) \
5027 _(l2fib_flush_int_reply) \
5028 _(l2fib_flush_bd_reply) \
5029 _(ip_add_del_route_reply) \
5030 _(ip_table_add_del_reply) \
5031 _(ip_mroute_add_del_reply) \
5032 _(mpls_route_add_del_reply) \
5033 _(mpls_table_add_del_reply) \
5034 _(mpls_ip_bind_unbind_reply) \
5035 _(proxy_arp_add_del_reply) \
5036 _(proxy_arp_intfc_enable_disable_reply) \
5037 _(sw_interface_set_unnumbered_reply) \
5038 _(ip_neighbor_add_del_reply) \
5039 _(reset_vrf_reply) \
5040 _(oam_add_del_reply) \
5041 _(reset_fib_reply) \
5042 _(dhcp_proxy_config_reply) \
5043 _(dhcp_proxy_set_vss_reply) \
5044 _(dhcp_client_config_reply) \
5045 _(set_ip_flow_hash_reply) \
5046 _(sw_interface_ip6_enable_disable_reply) \
5047 _(sw_interface_ip6_set_link_local_address_reply) \
5048 _(ip6nd_proxy_add_del_reply) \
5049 _(sw_interface_ip6nd_ra_prefix_reply) \
5050 _(sw_interface_ip6nd_ra_config_reply) \
5051 _(set_arp_neighbor_limit_reply) \
5052 _(l2_patch_add_del_reply) \
5053 _(sr_policy_add_reply) \
5054 _(sr_policy_mod_reply) \
5055 _(sr_policy_del_reply) \
5056 _(sr_localsid_add_del_reply) \
5057 _(sr_steering_add_del_reply) \
5058 _(classify_add_del_session_reply) \
5059 _(classify_set_interface_ip_table_reply) \
5060 _(classify_set_interface_l2_tables_reply) \
5061 _(l2tpv3_set_tunnel_cookies_reply) \
5062 _(l2tpv3_interface_enable_disable_reply) \
5063 _(l2tpv3_set_lookup_key_reply) \
5064 _(l2_fib_clear_table_reply) \
5065 _(l2_interface_efp_filter_reply) \
5066 _(l2_interface_vlan_tag_rewrite_reply) \
5067 _(modify_vhost_user_if_reply) \
5068 _(delete_vhost_user_if_reply) \
5069 _(want_ip4_arp_events_reply) \
5070 _(want_ip6_nd_events_reply) \
5071 _(want_l2_macs_events_reply) \
5072 _(input_acl_set_interface_reply) \
5073 _(ipsec_spd_add_del_reply) \
5074 _(ipsec_interface_add_del_spd_reply) \
5075 _(ipsec_spd_add_del_entry_reply) \
5076 _(ipsec_sad_add_del_entry_reply) \
5077 _(ipsec_sa_set_key_reply) \
5078 _(ipsec_tunnel_if_add_del_reply) \
5079 _(ipsec_tunnel_if_set_key_reply) \
5080 _(ikev2_profile_add_del_reply) \
5081 _(ikev2_profile_set_auth_reply) \
5082 _(ikev2_profile_set_id_reply) \
5083 _(ikev2_profile_set_ts_reply) \
5084 _(ikev2_set_local_key_reply) \
5085 _(ikev2_set_responder_reply) \
5086 _(ikev2_set_ike_transforms_reply) \
5087 _(ikev2_set_esp_transforms_reply) \
5088 _(ikev2_set_sa_lifetime_reply) \
5089 _(ikev2_initiate_sa_init_reply) \
5090 _(ikev2_initiate_del_ike_sa_reply) \
5091 _(ikev2_initiate_del_child_sa_reply) \
5092 _(ikev2_initiate_rekey_child_sa_reply) \
5093 _(delete_loopback_reply) \
5094 _(bd_ip_mac_add_del_reply) \
5095 _(map_del_domain_reply) \
5096 _(map_add_del_rule_reply) \
5097 _(want_interface_events_reply) \
5098 _(want_stats_reply) \
5099 _(cop_interface_enable_disable_reply) \
5100 _(cop_whitelist_enable_disable_reply) \
5101 _(sw_interface_clear_stats_reply) \
5102 _(ioam_enable_reply) \
5103 _(ioam_disable_reply) \
5104 _(one_add_del_locator_reply) \
5105 _(one_add_del_local_eid_reply) \
5106 _(one_add_del_remote_mapping_reply) \
5107 _(one_add_del_adjacency_reply) \
5108 _(one_add_del_map_resolver_reply) \
5109 _(one_add_del_map_server_reply) \
5110 _(one_enable_disable_reply) \
5111 _(one_rloc_probe_enable_disable_reply) \
5112 _(one_map_register_enable_disable_reply) \
5113 _(one_map_register_set_ttl_reply) \
5114 _(one_set_transport_protocol_reply) \
5115 _(one_map_register_fallback_threshold_reply) \
5116 _(one_pitr_set_locator_set_reply) \
5117 _(one_map_request_mode_reply) \
5118 _(one_add_del_map_request_itr_rlocs_reply) \
5119 _(one_eid_table_add_del_map_reply) \
5120 _(one_use_petr_reply) \
5121 _(one_stats_enable_disable_reply) \
5122 _(one_add_del_l2_arp_entry_reply) \
5123 _(one_add_del_ndp_entry_reply) \
5124 _(one_stats_flush_reply) \
5125 _(gpe_enable_disable_reply) \
5126 _(gpe_set_encap_mode_reply) \
5127 _(gpe_add_del_iface_reply) \
5128 _(gpe_add_del_native_fwd_rpath_reply) \
5129 _(af_packet_delete_reply) \
5130 _(policer_classify_set_interface_reply) \
5131 _(netmap_create_reply) \
5132 _(netmap_delete_reply) \
5133 _(set_ipfix_exporter_reply) \
5134 _(set_ipfix_classify_stream_reply) \
5135 _(ipfix_classify_table_add_del_reply) \
5136 _(flow_classify_set_interface_reply) \
5137 _(sw_interface_span_enable_disable_reply) \
5138 _(pg_capture_reply) \
5139 _(pg_enable_disable_reply) \
5140 _(ip_source_and_port_range_check_add_del_reply) \
5141 _(ip_source_and_port_range_check_interface_add_del_reply)\
5142 _(delete_subif_reply) \
5143 _(l2_interface_pbb_tag_rewrite_reply) \
5145 _(feature_enable_disable_reply) \
5146 _(sw_interface_tag_add_del_reply) \
5147 _(sw_interface_set_mtu_reply) \
5148 _(p2p_ethernet_add_reply) \
5149 _(p2p_ethernet_del_reply) \
5150 _(lldp_config_reply) \
5151 _(sw_interface_set_lldp_reply) \
5152 _(tcp_configure_src_addresses_reply) \
5153 _(app_namespace_add_del_reply) \
5154 _(dns_enable_disable_reply) \
5155 _(dns_name_server_add_del_reply)
5158 static void vl_api_##n##_t_handler \
5159 (vl_api_##n##_t * mp) \
5161 vat_main_t * vam = &vat_main; \
5162 i32 retval = ntohl(mp->retval); \
5163 if (vam->async_mode) { \
5164 vam->async_errors += (retval < 0); \
5166 vam->retval = retval; \
5167 vam->result_ready = 1; \
5170 foreach_standard_reply_retval_handler;
5174 static void vl_api_##n##_t_handler_json \
5175 (vl_api_##n##_t * mp) \
5177 vat_main_t * vam = &vat_main; \
5178 vat_json_node_t node; \
5179 vat_json_init_object(&node); \
5180 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5181 vat_json_print(vam->ofp, &node); \
5182 vam->retval = ntohl(mp->retval); \
5183 vam->result_ready = 1; \
5185 foreach_standard_reply_retval_handler;
5189 * Table of message reply handlers, must include boilerplate handlers
5193 #define foreach_vpe_api_reply_msg \
5194 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5195 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5196 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5197 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5198 _(CONTROL_PING_REPLY, control_ping_reply) \
5199 _(CLI_REPLY, cli_reply) \
5200 _(CLI_INBAND_REPLY, cli_inband_reply) \
5201 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5202 sw_interface_add_del_address_reply) \
5203 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5204 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5205 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5206 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5207 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5208 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5209 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5210 sw_interface_set_l2_xconnect_reply) \
5211 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5212 sw_interface_set_l2_bridge_reply) \
5213 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5214 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5215 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5216 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5217 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5218 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5219 _(L2_FLAGS_REPLY, l2_flags_reply) \
5220 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5221 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5222 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5223 _(TAP_DELETE_REPLY, tap_delete_reply) \
5224 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5225 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5226 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5227 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5228 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5229 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5230 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5231 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5232 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5233 proxy_arp_intfc_enable_disable_reply) \
5234 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5235 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5236 sw_interface_set_unnumbered_reply) \
5237 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5238 _(RESET_VRF_REPLY, reset_vrf_reply) \
5239 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5240 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5241 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5242 _(RESET_FIB_REPLY, reset_fib_reply) \
5243 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5244 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5245 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5246 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5247 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5248 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5249 sw_interface_ip6_enable_disable_reply) \
5250 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5251 sw_interface_ip6_set_link_local_address_reply) \
5252 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5253 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5254 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5255 sw_interface_ip6nd_ra_prefix_reply) \
5256 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5257 sw_interface_ip6nd_ra_config_reply) \
5258 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5259 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5260 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5261 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5262 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5263 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5264 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5265 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5266 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5267 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5268 classify_set_interface_ip_table_reply) \
5269 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5270 classify_set_interface_l2_tables_reply) \
5271 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5272 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5273 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5274 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5275 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5276 l2tpv3_interface_enable_disable_reply) \
5277 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5278 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5279 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5280 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5281 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5282 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5283 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5284 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5285 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5286 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5287 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5288 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5289 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5290 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5291 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5292 _(SHOW_VERSION_REPLY, show_version_reply) \
5293 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5294 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5295 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5296 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5297 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5298 _(IP4_ARP_EVENT, ip4_arp_event) \
5299 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5300 _(IP6_ND_EVENT, ip6_nd_event) \
5301 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5302 _(L2_MACS_EVENT, l2_macs_event) \
5303 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5304 _(IP_ADDRESS_DETAILS, ip_address_details) \
5305 _(IP_DETAILS, ip_details) \
5306 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5307 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5308 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5309 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5310 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5311 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5312 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5313 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5314 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5315 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5316 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5317 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5318 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5319 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5320 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5321 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5322 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5323 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5324 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5325 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5326 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5327 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5328 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5329 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5330 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5331 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5332 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5333 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5334 _(MAP_RULE_DETAILS, map_rule_details) \
5335 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5336 _(WANT_STATS_REPLY, want_stats_reply) \
5337 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5338 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5339 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5340 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5341 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5342 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5343 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5344 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5345 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5346 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5347 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5348 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5349 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5350 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5351 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5352 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5353 one_map_register_enable_disable_reply) \
5354 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5355 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5356 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5357 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5358 one_map_register_fallback_threshold_reply) \
5359 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5360 one_rloc_probe_enable_disable_reply) \
5361 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5362 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5363 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5364 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5365 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5366 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5367 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5368 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5369 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5370 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5371 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5372 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5373 _(ONE_STATS_DETAILS, one_stats_details) \
5374 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5375 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5376 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5377 show_one_stats_enable_disable_reply) \
5378 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5379 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5380 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5381 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5382 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5383 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5384 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5385 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5386 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5387 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5388 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5389 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5390 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5391 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5392 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5393 gpe_add_del_native_fwd_rpath_reply) \
5394 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5395 gpe_fwd_entry_path_details) \
5396 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5397 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5398 one_add_del_map_request_itr_rlocs_reply) \
5399 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5400 one_get_map_request_itr_rlocs_reply) \
5401 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5402 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5403 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5404 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5405 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5406 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5407 show_one_map_register_state_reply) \
5408 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5409 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5410 show_one_map_register_fallback_threshold_reply) \
5411 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5412 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5413 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5414 _(POLICER_DETAILS, policer_details) \
5415 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5416 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5417 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5418 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5419 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5420 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5421 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5422 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5423 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5424 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5425 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5426 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5427 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5428 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5429 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5430 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5431 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5432 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5433 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5434 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5435 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5436 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5437 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5438 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5439 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5440 ip_source_and_port_range_check_add_del_reply) \
5441 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5442 ip_source_and_port_range_check_interface_add_del_reply) \
5443 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5444 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5445 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5446 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5447 _(PUNT_REPLY, punt_reply) \
5448 _(IP_FIB_DETAILS, ip_fib_details) \
5449 _(IP6_FIB_DETAILS, ip6_fib_details) \
5450 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5451 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5452 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5453 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5454 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5455 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5456 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5457 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5458 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5459 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5460 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5461 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5462 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5463 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5464 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply)
5466 #define foreach_standalone_reply_msg \
5467 _(SW_INTERFACE_EVENT, sw_interface_event) \
5468 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5469 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5470 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5471 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5472 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5473 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
5474 _(MEMFD_SEGMENT_CREATE_REPLY, memfd_segment_create_reply) \
5483 #define STR_VTR_OP_CASE(op) \
5484 case L2_VTR_ ## op: \
5488 str_vtr_op (u32 vtr_op)
5492 STR_VTR_OP_CASE (DISABLED);
5493 STR_VTR_OP_CASE (PUSH_1);
5494 STR_VTR_OP_CASE (PUSH_2);
5495 STR_VTR_OP_CASE (POP_1);
5496 STR_VTR_OP_CASE (POP_2);
5497 STR_VTR_OP_CASE (TRANSLATE_1_1);
5498 STR_VTR_OP_CASE (TRANSLATE_1_2);
5499 STR_VTR_OP_CASE (TRANSLATE_2_1);
5500 STR_VTR_OP_CASE (TRANSLATE_2_2);
5507 dump_sub_interface_table (vat_main_t * vam)
5509 const sw_interface_subif_t *sub = NULL;
5511 if (vam->json_output)
5514 ("JSON output supported only for VPE API calls and dump_stats_table");
5519 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5520 "Interface", "sw_if_index",
5521 "sub id", "dot1ad", "tags", "outer id",
5522 "inner id", "exact", "default", "outer any", "inner any");
5524 vec_foreach (sub, vam->sw_if_subif_table)
5527 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5528 sub->interface_name,
5530 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5531 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5532 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5533 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5534 if (sub->vtr_op != L2_VTR_DISABLED)
5537 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5538 "tag1: %d tag2: %d ]",
5539 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5540 sub->vtr_tag1, sub->vtr_tag2);
5548 name_sort_cmp (void *a1, void *a2)
5550 name_sort_t *n1 = a1;
5551 name_sort_t *n2 = a2;
5553 return strcmp ((char *) n1->name, (char *) n2->name);
5557 dump_interface_table (vat_main_t * vam)
5560 name_sort_t *nses = 0, *ns;
5562 if (vam->json_output)
5565 ("JSON output supported only for VPE API calls and dump_stats_table");
5570 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5572 vec_add2 (nses, ns, 1);
5573 ns->name = (u8 *)(p->key);
5574 ns->value = (u32) p->value[0];
5578 vec_sort_with_function (nses, name_sort_cmp);
5580 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5581 vec_foreach (ns, nses)
5583 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5590 dump_ip_table (vat_main_t * vam, int is_ipv6)
5592 const ip_details_t *det = NULL;
5593 const ip_address_details_t *address = NULL;
5596 print (vam->ofp, "%-12s", "sw_if_index");
5598 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5605 print (vam->ofp, "%-12d", i);
5606 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5611 vec_foreach (address, det->addr)
5615 is_ipv6 ? format_ip6_address : format_ip4_address,
5616 address->ip, address->prefix_length);
5624 dump_ipv4_table (vat_main_t * vam)
5626 if (vam->json_output)
5629 ("JSON output supported only for VPE API calls and dump_stats_table");
5633 return dump_ip_table (vam, 0);
5637 dump_ipv6_table (vat_main_t * vam)
5639 if (vam->json_output)
5642 ("JSON output supported only for VPE API calls and dump_stats_table");
5646 return dump_ip_table (vam, 1);
5650 counter_type_to_str (u8 counter_type, u8 is_combined)
5654 switch (counter_type)
5656 case VNET_INTERFACE_COUNTER_DROP:
5658 case VNET_INTERFACE_COUNTER_PUNT:
5660 case VNET_INTERFACE_COUNTER_IP4:
5662 case VNET_INTERFACE_COUNTER_IP6:
5664 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5666 case VNET_INTERFACE_COUNTER_RX_MISS:
5668 case VNET_INTERFACE_COUNTER_RX_ERROR:
5670 case VNET_INTERFACE_COUNTER_TX_ERROR:
5673 return "INVALID-COUNTER-TYPE";
5678 switch (counter_type)
5680 case VNET_INTERFACE_COUNTER_RX:
5682 case VNET_INTERFACE_COUNTER_TX:
5685 return "INVALID-COUNTER-TYPE";
5691 dump_stats_table (vat_main_t * vam)
5693 vat_json_node_t node;
5694 vat_json_node_t *msg_array;
5695 vat_json_node_t *msg;
5696 vat_json_node_t *counter_array;
5697 vat_json_node_t *counter;
5698 interface_counter_t c;
5700 ip4_fib_counter_t *c4;
5701 ip6_fib_counter_t *c6;
5702 ip4_nbr_counter_t *n4;
5703 ip6_nbr_counter_t *n6;
5706 if (!vam->json_output)
5708 clib_warning ("dump_stats_table supported only in JSON format");
5712 vat_json_init_object (&node);
5714 /* interface counters */
5715 msg_array = vat_json_object_add (&node, "interface_counters");
5716 vat_json_init_array (msg_array);
5717 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5719 msg = vat_json_array_add (msg_array);
5720 vat_json_init_object (msg);
5721 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5722 (u8 *) counter_type_to_str (i, 0));
5723 vat_json_object_add_int (msg, "is_combined", 0);
5724 counter_array = vat_json_object_add (msg, "data");
5725 vat_json_init_array (counter_array);
5726 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5728 packets = vam->simple_interface_counters[i][j];
5729 vat_json_array_add_uint (counter_array, packets);
5732 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5734 msg = vat_json_array_add (msg_array);
5735 vat_json_init_object (msg);
5736 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5737 (u8 *) counter_type_to_str (i, 1));
5738 vat_json_object_add_int (msg, "is_combined", 1);
5739 counter_array = vat_json_object_add (msg, "data");
5740 vat_json_init_array (counter_array);
5741 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5743 c = vam->combined_interface_counters[i][j];
5744 counter = vat_json_array_add (counter_array);
5745 vat_json_init_object (counter);
5746 vat_json_object_add_uint (counter, "packets", c.packets);
5747 vat_json_object_add_uint (counter, "bytes", c.bytes);
5751 /* ip4 fib counters */
5752 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5753 vat_json_init_array (msg_array);
5754 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5756 msg = vat_json_array_add (msg_array);
5757 vat_json_init_object (msg);
5758 vat_json_object_add_uint (msg, "vrf_id",
5759 vam->ip4_fib_counters_vrf_id_by_index[i]);
5760 counter_array = vat_json_object_add (msg, "c");
5761 vat_json_init_array (counter_array);
5762 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5764 counter = vat_json_array_add (counter_array);
5765 vat_json_init_object (counter);
5766 c4 = &vam->ip4_fib_counters[i][j];
5767 vat_json_object_add_ip4 (counter, "address", c4->address);
5768 vat_json_object_add_uint (counter, "address_length",
5769 c4->address_length);
5770 vat_json_object_add_uint (counter, "packets", c4->packets);
5771 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5775 /* ip6 fib counters */
5776 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5777 vat_json_init_array (msg_array);
5778 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5780 msg = vat_json_array_add (msg_array);
5781 vat_json_init_object (msg);
5782 vat_json_object_add_uint (msg, "vrf_id",
5783 vam->ip6_fib_counters_vrf_id_by_index[i]);
5784 counter_array = vat_json_object_add (msg, "c");
5785 vat_json_init_array (counter_array);
5786 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5788 counter = vat_json_array_add (counter_array);
5789 vat_json_init_object (counter);
5790 c6 = &vam->ip6_fib_counters[i][j];
5791 vat_json_object_add_ip6 (counter, "address", c6->address);
5792 vat_json_object_add_uint (counter, "address_length",
5793 c6->address_length);
5794 vat_json_object_add_uint (counter, "packets", c6->packets);
5795 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5799 /* ip4 nbr counters */
5800 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5801 vat_json_init_array (msg_array);
5802 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5804 msg = vat_json_array_add (msg_array);
5805 vat_json_init_object (msg);
5806 vat_json_object_add_uint (msg, "sw_if_index", i);
5807 counter_array = vat_json_object_add (msg, "c");
5808 vat_json_init_array (counter_array);
5809 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5811 counter = vat_json_array_add (counter_array);
5812 vat_json_init_object (counter);
5813 n4 = &vam->ip4_nbr_counters[i][j];
5814 vat_json_object_add_ip4 (counter, "address", n4->address);
5815 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5816 vat_json_object_add_uint (counter, "packets", n4->packets);
5817 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5821 /* ip6 nbr counters */
5822 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5823 vat_json_init_array (msg_array);
5824 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5826 msg = vat_json_array_add (msg_array);
5827 vat_json_init_object (msg);
5828 vat_json_object_add_uint (msg, "sw_if_index", i);
5829 counter_array = vat_json_object_add (msg, "c");
5830 vat_json_init_array (counter_array);
5831 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5833 counter = vat_json_array_add (counter_array);
5834 vat_json_init_object (counter);
5835 n6 = &vam->ip6_nbr_counters[i][j];
5836 vat_json_object_add_ip6 (counter, "address", n6->address);
5837 vat_json_object_add_uint (counter, "packets", n6->packets);
5838 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5842 vat_json_print (vam->ofp, &node);
5843 vat_json_free (&node);
5849 * Pass CLI buffers directly in the CLI_INBAND API message,
5850 * instead of an additional shared memory area.
5853 exec_inband (vat_main_t * vam)
5855 vl_api_cli_inband_t *mp;
5856 unformat_input_t *i = vam->input;
5859 if (vec_len (i->buffer) == 0)
5862 if (vam->exec_mode == 0 && unformat (i, "mode"))
5867 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5874 * In order for the CLI command to work, it
5875 * must be a vector ending in \n, not a C-string ending
5878 u32 len = vec_len (vam->input->buffer);
5879 M2 (CLI_INBAND, mp, len);
5880 clib_memcpy (mp->cmd, vam->input->buffer, len);
5881 mp->length = htonl (len);
5885 /* json responses may or may not include a useful reply... */
5886 if (vec_len (vam->cmd_reply))
5887 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5892 exec (vat_main_t * vam)
5894 return exec_inband (vam);
5898 api_create_loopback (vat_main_t * vam)
5900 unformat_input_t *i = vam->input;
5901 vl_api_create_loopback_t *mp;
5902 vl_api_create_loopback_instance_t *mp_lbi;
5905 u8 is_specified = 0;
5906 u32 user_instance = 0;
5909 memset (mac_address, 0, sizeof (mac_address));
5911 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5913 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5915 if (unformat (i, "instance %d", &user_instance))
5923 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5924 mp_lbi->is_specified = is_specified;
5926 mp_lbi->user_instance = htonl (user_instance);
5928 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5933 /* Construct the API message */
5934 M (CREATE_LOOPBACK, mp);
5936 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5945 api_delete_loopback (vat_main_t * vam)
5947 unformat_input_t *i = vam->input;
5948 vl_api_delete_loopback_t *mp;
5949 u32 sw_if_index = ~0;
5952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5954 if (unformat (i, "sw_if_index %d", &sw_if_index))
5960 if (sw_if_index == ~0)
5962 errmsg ("missing sw_if_index");
5966 /* Construct the API message */
5967 M (DELETE_LOOPBACK, mp);
5968 mp->sw_if_index = ntohl (sw_if_index);
5976 api_want_stats (vat_main_t * vam)
5978 unformat_input_t *i = vam->input;
5979 vl_api_want_stats_t *mp;
5983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5985 if (unformat (i, "enable"))
5987 else if (unformat (i, "disable"))
5995 errmsg ("missing enable|disable");
6000 mp->enable_disable = enable;
6008 api_want_interface_events (vat_main_t * vam)
6010 unformat_input_t *i = vam->input;
6011 vl_api_want_interface_events_t *mp;
6015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6017 if (unformat (i, "enable"))
6019 else if (unformat (i, "disable"))
6027 errmsg ("missing enable|disable");
6031 M (WANT_INTERFACE_EVENTS, mp);
6032 mp->enable_disable = enable;
6034 vam->interface_event_display = enable;
6042 /* Note: non-static, called once to set up the initial intfc table */
6044 api_sw_interface_dump (vat_main_t * vam)
6046 vl_api_sw_interface_dump_t *mp;
6047 vl_api_control_ping_t *mp_ping;
6049 name_sort_t *nses = 0, *ns;
6050 sw_interface_subif_t *sub = NULL;
6053 /* Toss the old name table */
6055 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6057 vec_add2 (nses, ns, 1);
6058 ns->name = (u8 *)(p->key);
6059 ns->value = (u32) p->value[0];
6063 hash_free (vam->sw_if_index_by_interface_name);
6065 vec_foreach (ns, nses) vec_free (ns->name);
6069 vec_foreach (sub, vam->sw_if_subif_table)
6071 vec_free (sub->interface_name);
6073 vec_free (vam->sw_if_subif_table);
6075 /* recreate the interface name hash table */
6076 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6078 /* Get list of ethernets */
6079 M (SW_INTERFACE_DUMP, mp);
6080 mp->name_filter_valid = 1;
6081 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
6084 /* and local / loopback interfaces */
6085 M (SW_INTERFACE_DUMP, mp);
6086 mp->name_filter_valid = 1;
6087 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
6090 /* and packet-generator interfaces */
6091 M (SW_INTERFACE_DUMP, mp);
6092 mp->name_filter_valid = 1;
6093 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
6096 /* and vxlan-gpe tunnel interfaces */
6097 M (SW_INTERFACE_DUMP, mp);
6098 mp->name_filter_valid = 1;
6099 strncpy ((char *) mp->name_filter, "vxlan_gpe",
6100 sizeof (mp->name_filter) - 1);
6103 /* and vxlan tunnel interfaces */
6104 M (SW_INTERFACE_DUMP, mp);
6105 mp->name_filter_valid = 1;
6106 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
6109 /* and geneve tunnel interfaces */
6110 M (SW_INTERFACE_DUMP, mp);
6111 mp->name_filter_valid = 1;
6112 strncpy ((char *) mp->name_filter, "geneve", sizeof (mp->name_filter) - 1);
6115 /* and host (af_packet) interfaces */
6116 M (SW_INTERFACE_DUMP, mp);
6117 mp->name_filter_valid = 1;
6118 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
6121 /* and l2tpv3 tunnel interfaces */
6122 M (SW_INTERFACE_DUMP, mp);
6123 mp->name_filter_valid = 1;
6124 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
6125 sizeof (mp->name_filter) - 1);
6128 /* and GRE tunnel interfaces */
6129 M (SW_INTERFACE_DUMP, mp);
6130 mp->name_filter_valid = 1;
6131 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
6134 /* and LISP-GPE interfaces */
6135 M (SW_INTERFACE_DUMP, mp);
6136 mp->name_filter_valid = 1;
6137 strncpy ((char *) mp->name_filter, "lisp_gpe",
6138 sizeof (mp->name_filter) - 1);
6141 /* and IPSEC tunnel interfaces */
6142 M (SW_INTERFACE_DUMP, mp);
6143 mp->name_filter_valid = 1;
6144 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
6147 /* Use a control ping for synchronization */
6148 MPING (CONTROL_PING, mp_ping);
6156 api_sw_interface_set_flags (vat_main_t * vam)
6158 unformat_input_t *i = vam->input;
6159 vl_api_sw_interface_set_flags_t *mp;
6161 u8 sw_if_index_set = 0;
6165 /* Parse args required to build the message */
6166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6168 if (unformat (i, "admin-up"))
6170 else if (unformat (i, "admin-down"))
6173 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6174 sw_if_index_set = 1;
6175 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6176 sw_if_index_set = 1;
6181 if (sw_if_index_set == 0)
6183 errmsg ("missing interface name or sw_if_index");
6187 /* Construct the API message */
6188 M (SW_INTERFACE_SET_FLAGS, mp);
6189 mp->sw_if_index = ntohl (sw_if_index);
6190 mp->admin_up_down = admin_up;
6195 /* Wait for a reply, return the good/bad news... */
6201 api_sw_interface_clear_stats (vat_main_t * vam)
6203 unformat_input_t *i = vam->input;
6204 vl_api_sw_interface_clear_stats_t *mp;
6206 u8 sw_if_index_set = 0;
6209 /* Parse args required to build the message */
6210 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6212 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6213 sw_if_index_set = 1;
6214 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6215 sw_if_index_set = 1;
6220 /* Construct the API message */
6221 M (SW_INTERFACE_CLEAR_STATS, mp);
6223 if (sw_if_index_set == 1)
6224 mp->sw_if_index = ntohl (sw_if_index);
6226 mp->sw_if_index = ~0;
6231 /* Wait for a reply, return the good/bad news... */
6237 api_sw_interface_add_del_address (vat_main_t * vam)
6239 unformat_input_t *i = vam->input;
6240 vl_api_sw_interface_add_del_address_t *mp;
6242 u8 sw_if_index_set = 0;
6243 u8 is_add = 1, del_all = 0;
6244 u32 address_length = 0;
6245 u8 v4_address_set = 0;
6246 u8 v6_address_set = 0;
6247 ip4_address_t v4address;
6248 ip6_address_t v6address;
6251 /* Parse args required to build the message */
6252 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6254 if (unformat (i, "del-all"))
6256 else if (unformat (i, "del"))
6259 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6260 sw_if_index_set = 1;
6261 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6262 sw_if_index_set = 1;
6263 else if (unformat (i, "%U/%d",
6264 unformat_ip4_address, &v4address, &address_length))
6266 else if (unformat (i, "%U/%d",
6267 unformat_ip6_address, &v6address, &address_length))
6273 if (sw_if_index_set == 0)
6275 errmsg ("missing interface name or sw_if_index");
6278 if (v4_address_set && v6_address_set)
6280 errmsg ("both v4 and v6 addresses set");
6283 if (!v4_address_set && !v6_address_set && !del_all)
6285 errmsg ("no addresses set");
6289 /* Construct the API message */
6290 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6292 mp->sw_if_index = ntohl (sw_if_index);
6293 mp->is_add = is_add;
6294 mp->del_all = del_all;
6298 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6302 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6304 mp->address_length = address_length;
6309 /* Wait for a reply, return good/bad news */
6315 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6317 unformat_input_t *i = vam->input;
6318 vl_api_sw_interface_set_mpls_enable_t *mp;
6320 u8 sw_if_index_set = 0;
6324 /* Parse args required to build the message */
6325 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6327 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6328 sw_if_index_set = 1;
6329 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6330 sw_if_index_set = 1;
6331 else if (unformat (i, "disable"))
6333 else if (unformat (i, "dis"))
6339 if (sw_if_index_set == 0)
6341 errmsg ("missing interface name or sw_if_index");
6345 /* Construct the API message */
6346 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6348 mp->sw_if_index = ntohl (sw_if_index);
6349 mp->enable = enable;
6354 /* Wait for a reply... */
6360 api_sw_interface_set_table (vat_main_t * vam)
6362 unformat_input_t *i = vam->input;
6363 vl_api_sw_interface_set_table_t *mp;
6364 u32 sw_if_index, vrf_id = 0;
6365 u8 sw_if_index_set = 0;
6369 /* Parse args required to build the message */
6370 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6372 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6373 sw_if_index_set = 1;
6374 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6375 sw_if_index_set = 1;
6376 else if (unformat (i, "vrf %d", &vrf_id))
6378 else if (unformat (i, "ipv6"))
6384 if (sw_if_index_set == 0)
6386 errmsg ("missing interface name or sw_if_index");
6390 /* Construct the API message */
6391 M (SW_INTERFACE_SET_TABLE, mp);
6393 mp->sw_if_index = ntohl (sw_if_index);
6394 mp->is_ipv6 = is_ipv6;
6395 mp->vrf_id = ntohl (vrf_id);
6400 /* Wait for a reply... */
6405 static void vl_api_sw_interface_get_table_reply_t_handler
6406 (vl_api_sw_interface_get_table_reply_t * mp)
6408 vat_main_t *vam = &vat_main;
6410 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6412 vam->retval = ntohl (mp->retval);
6413 vam->result_ready = 1;
6417 static void vl_api_sw_interface_get_table_reply_t_handler_json
6418 (vl_api_sw_interface_get_table_reply_t * mp)
6420 vat_main_t *vam = &vat_main;
6421 vat_json_node_t node;
6423 vat_json_init_object (&node);
6424 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6425 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6427 vat_json_print (vam->ofp, &node);
6428 vat_json_free (&node);
6430 vam->retval = ntohl (mp->retval);
6431 vam->result_ready = 1;
6435 api_sw_interface_get_table (vat_main_t * vam)
6437 unformat_input_t *i = vam->input;
6438 vl_api_sw_interface_get_table_t *mp;
6440 u8 sw_if_index_set = 0;
6444 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6446 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6447 sw_if_index_set = 1;
6448 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6449 sw_if_index_set = 1;
6450 else if (unformat (i, "ipv6"))
6456 if (sw_if_index_set == 0)
6458 errmsg ("missing interface name or sw_if_index");
6462 M (SW_INTERFACE_GET_TABLE, mp);
6463 mp->sw_if_index = htonl (sw_if_index);
6464 mp->is_ipv6 = is_ipv6;
6472 api_sw_interface_set_vpath (vat_main_t * vam)
6474 unformat_input_t *i = vam->input;
6475 vl_api_sw_interface_set_vpath_t *mp;
6476 u32 sw_if_index = 0;
6477 u8 sw_if_index_set = 0;
6481 /* Parse args required to build the message */
6482 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6484 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6485 sw_if_index_set = 1;
6486 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6487 sw_if_index_set = 1;
6488 else if (unformat (i, "enable"))
6490 else if (unformat (i, "disable"))
6496 if (sw_if_index_set == 0)
6498 errmsg ("missing interface name or sw_if_index");
6502 /* Construct the API message */
6503 M (SW_INTERFACE_SET_VPATH, mp);
6505 mp->sw_if_index = ntohl (sw_if_index);
6506 mp->enable = is_enable;
6511 /* Wait for a reply... */
6517 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6519 unformat_input_t *i = vam->input;
6520 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6521 u32 sw_if_index = 0;
6522 u8 sw_if_index_set = 0;
6527 /* Parse args required to build the message */
6528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6530 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6531 sw_if_index_set = 1;
6532 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6533 sw_if_index_set = 1;
6534 else if (unformat (i, "enable"))
6536 else if (unformat (i, "disable"))
6538 else if (unformat (i, "ip4"))
6540 else if (unformat (i, "ip6"))
6546 if (sw_if_index_set == 0)
6548 errmsg ("missing interface name or sw_if_index");
6552 /* Construct the API message */
6553 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6555 mp->sw_if_index = ntohl (sw_if_index);
6556 mp->enable = is_enable;
6557 mp->is_ipv6 = is_ipv6;
6562 /* Wait for a reply... */
6568 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6570 unformat_input_t *i = vam->input;
6571 vl_api_sw_interface_set_geneve_bypass_t *mp;
6572 u32 sw_if_index = 0;
6573 u8 sw_if_index_set = 0;
6578 /* Parse args required to build the message */
6579 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6581 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6582 sw_if_index_set = 1;
6583 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6584 sw_if_index_set = 1;
6585 else if (unformat (i, "enable"))
6587 else if (unformat (i, "disable"))
6589 else if (unformat (i, "ip4"))
6591 else if (unformat (i, "ip6"))
6597 if (sw_if_index_set == 0)
6599 errmsg ("missing interface name or sw_if_index");
6603 /* Construct the API message */
6604 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6606 mp->sw_if_index = ntohl (sw_if_index);
6607 mp->enable = is_enable;
6608 mp->is_ipv6 = is_ipv6;
6613 /* Wait for a reply... */
6619 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6621 unformat_input_t *i = vam->input;
6622 vl_api_sw_interface_set_l2_xconnect_t *mp;
6624 u8 rx_sw_if_index_set = 0;
6626 u8 tx_sw_if_index_set = 0;
6630 /* Parse args required to build the message */
6631 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6633 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6634 rx_sw_if_index_set = 1;
6635 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6636 tx_sw_if_index_set = 1;
6637 else if (unformat (i, "rx"))
6639 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6641 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6643 rx_sw_if_index_set = 1;
6648 else if (unformat (i, "tx"))
6650 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6652 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6654 tx_sw_if_index_set = 1;
6659 else if (unformat (i, "enable"))
6661 else if (unformat (i, "disable"))
6667 if (rx_sw_if_index_set == 0)
6669 errmsg ("missing rx interface name or rx_sw_if_index");
6673 if (enable && (tx_sw_if_index_set == 0))
6675 errmsg ("missing tx interface name or tx_sw_if_index");
6679 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6681 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6682 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6683 mp->enable = enable;
6691 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6693 unformat_input_t *i = vam->input;
6694 vl_api_sw_interface_set_l2_bridge_t *mp;
6696 u8 rx_sw_if_index_set = 0;
6704 /* Parse args required to build the message */
6705 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6707 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6708 rx_sw_if_index_set = 1;
6709 else if (unformat (i, "bd_id %d", &bd_id))
6713 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6714 rx_sw_if_index_set = 1;
6715 else if (unformat (i, "shg %d", &shg))
6717 else if (unformat (i, "bvi"))
6719 else if (unformat (i, "enable"))
6721 else if (unformat (i, "disable"))
6727 if (rx_sw_if_index_set == 0)
6729 errmsg ("missing rx interface name or sw_if_index");
6733 if (enable && (bd_id_set == 0))
6735 errmsg ("missing bridge domain");
6739 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6741 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6742 mp->bd_id = ntohl (bd_id);
6745 mp->enable = enable;
6753 api_bridge_domain_dump (vat_main_t * vam)
6755 unformat_input_t *i = vam->input;
6756 vl_api_bridge_domain_dump_t *mp;
6757 vl_api_control_ping_t *mp_ping;
6761 /* Parse args required to build the message */
6762 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6764 if (unformat (i, "bd_id %d", &bd_id))
6770 M (BRIDGE_DOMAIN_DUMP, mp);
6771 mp->bd_id = ntohl (bd_id);
6774 /* Use a control ping for synchronization */
6775 MPING (CONTROL_PING, mp_ping);
6783 api_bridge_domain_add_del (vat_main_t * vam)
6785 unformat_input_t *i = vam->input;
6786 vl_api_bridge_domain_add_del_t *mp;
6789 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6794 /* Parse args required to build the message */
6795 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6797 if (unformat (i, "bd_id %d", &bd_id))
6799 else if (unformat (i, "flood %d", &flood))
6801 else if (unformat (i, "uu-flood %d", &uu_flood))
6803 else if (unformat (i, "forward %d", &forward))
6805 else if (unformat (i, "learn %d", &learn))
6807 else if (unformat (i, "arp-term %d", &arp_term))
6809 else if (unformat (i, "mac-age %d", &mac_age))
6811 else if (unformat (i, "bd-tag %s", &bd_tag))
6813 else if (unformat (i, "del"))
6816 flood = uu_flood = forward = learn = 0;
6824 errmsg ("missing bridge domain");
6831 errmsg ("mac age must be less than 256 ");
6836 if ((bd_tag) && (strlen ((char *) bd_tag) > 63))
6838 errmsg ("bd-tag cannot be longer than 63");
6843 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6845 mp->bd_id = ntohl (bd_id);
6847 mp->uu_flood = uu_flood;
6848 mp->forward = forward;
6850 mp->arp_term = arp_term;
6851 mp->is_add = is_add;
6852 mp->mac_age = (u8) mac_age;
6854 strcpy ((char *) mp->bd_tag, (char *) bd_tag);
6865 api_l2fib_flush_bd (vat_main_t * vam)
6867 unformat_input_t *i = vam->input;
6868 vl_api_l2fib_flush_bd_t *mp;
6872 /* Parse args required to build the message */
6873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6875 if (unformat (i, "bd_id %d", &bd_id));
6882 errmsg ("missing bridge domain");
6886 M (L2FIB_FLUSH_BD, mp);
6888 mp->bd_id = htonl (bd_id);
6896 api_l2fib_flush_int (vat_main_t * vam)
6898 unformat_input_t *i = vam->input;
6899 vl_api_l2fib_flush_int_t *mp;
6900 u32 sw_if_index = ~0;
6903 /* Parse args required to build the message */
6904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6906 if (unformat (i, "sw_if_index %d", &sw_if_index));
6908 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6913 if (sw_if_index == ~0)
6915 errmsg ("missing interface name or sw_if_index");
6919 M (L2FIB_FLUSH_INT, mp);
6921 mp->sw_if_index = ntohl (sw_if_index);
6929 api_l2fib_add_del (vat_main_t * vam)
6931 unformat_input_t *i = vam->input;
6932 vl_api_l2fib_add_del_t *mp;
6938 u32 sw_if_index = ~0;
6939 u8 sw_if_index_set = 0;
6948 /* Parse args required to build the message */
6949 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6951 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6953 else if (unformat (i, "bd_id %d", &bd_id))
6955 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6956 sw_if_index_set = 1;
6957 else if (unformat (i, "sw_if"))
6959 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6962 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6963 sw_if_index_set = 1;
6968 else if (unformat (i, "static"))
6970 else if (unformat (i, "filter"))
6975 else if (unformat (i, "bvi"))
6980 else if (unformat (i, "del"))
6982 else if (unformat (i, "count %d", &count))
6990 errmsg ("missing mac address");
6996 errmsg ("missing bridge domain");
7000 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7002 errmsg ("missing interface name or sw_if_index");
7008 /* Turn on async mode */
7009 vam->async_mode = 1;
7010 vam->async_errors = 0;
7011 before = vat_time_now (vam);
7014 for (j = 0; j < count; j++)
7016 M (L2FIB_ADD_DEL, mp);
7019 mp->bd_id = ntohl (bd_id);
7020 mp->is_add = is_add;
7024 mp->sw_if_index = ntohl (sw_if_index);
7025 mp->static_mac = static_mac;
7026 mp->filter_mac = filter_mac;
7027 mp->bvi_mac = bvi_mac;
7029 increment_mac_address (&mac);
7036 vl_api_control_ping_t *mp_ping;
7039 /* Shut off async mode */
7040 vam->async_mode = 0;
7042 MPING (CONTROL_PING, mp_ping);
7045 timeout = vat_time_now (vam) + 1.0;
7046 while (vat_time_now (vam) < timeout)
7047 if (vam->result_ready == 1)
7052 if (vam->retval == -99)
7055 if (vam->async_errors > 0)
7057 errmsg ("%d asynchronous errors", vam->async_errors);
7060 vam->async_errors = 0;
7061 after = vat_time_now (vam);
7063 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7064 count, after - before, count / (after - before));
7070 /* Wait for a reply... */
7074 /* Return the good/bad news */
7075 return (vam->retval);
7079 api_bridge_domain_set_mac_age (vat_main_t * vam)
7081 unformat_input_t *i = vam->input;
7082 vl_api_bridge_domain_set_mac_age_t *mp;
7087 /* Parse args required to build the message */
7088 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7090 if (unformat (i, "bd_id %d", &bd_id));
7091 else if (unformat (i, "mac-age %d", &mac_age));
7098 errmsg ("missing bridge domain");
7104 errmsg ("mac age must be less than 256 ");
7108 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7110 mp->bd_id = htonl (bd_id);
7111 mp->mac_age = (u8) mac_age;
7119 api_l2_flags (vat_main_t * vam)
7121 unformat_input_t *i = vam->input;
7122 vl_api_l2_flags_t *mp;
7125 u8 sw_if_index_set = 0;
7129 /* Parse args required to build the message */
7130 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7132 if (unformat (i, "sw_if_index %d", &sw_if_index))
7133 sw_if_index_set = 1;
7134 else if (unformat (i, "sw_if"))
7136 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7139 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7140 sw_if_index_set = 1;
7145 else if (unformat (i, "learn"))
7147 else if (unformat (i, "forward"))
7149 else if (unformat (i, "flood"))
7151 else if (unformat (i, "uu-flood"))
7152 flags |= L2_UU_FLOOD;
7153 else if (unformat (i, "arp-term"))
7154 flags |= L2_ARP_TERM;
7155 else if (unformat (i, "off"))
7157 else if (unformat (i, "disable"))
7163 if (sw_if_index_set == 0)
7165 errmsg ("missing interface name or sw_if_index");
7171 mp->sw_if_index = ntohl (sw_if_index);
7172 mp->feature_bitmap = ntohl (flags);
7173 mp->is_set = is_set;
7181 api_bridge_flags (vat_main_t * vam)
7183 unformat_input_t *i = vam->input;
7184 vl_api_bridge_flags_t *mp;
7191 /* Parse args required to build the message */
7192 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7194 if (unformat (i, "bd_id %d", &bd_id))
7196 else if (unformat (i, "learn"))
7198 else if (unformat (i, "forward"))
7200 else if (unformat (i, "flood"))
7202 else if (unformat (i, "uu-flood"))
7203 flags |= L2_UU_FLOOD;
7204 else if (unformat (i, "arp-term"))
7205 flags |= L2_ARP_TERM;
7206 else if (unformat (i, "off"))
7208 else if (unformat (i, "disable"))
7216 errmsg ("missing bridge domain");
7220 M (BRIDGE_FLAGS, mp);
7222 mp->bd_id = ntohl (bd_id);
7223 mp->feature_bitmap = ntohl (flags);
7224 mp->is_set = is_set;
7232 api_bd_ip_mac_add_del (vat_main_t * vam)
7234 unformat_input_t *i = vam->input;
7235 vl_api_bd_ip_mac_add_del_t *mp;
7242 ip4_address_t v4addr;
7243 ip6_address_t v6addr;
7248 /* Parse args required to build the message */
7249 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7251 if (unformat (i, "bd_id %d", &bd_id))
7255 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7259 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7264 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7268 else if (unformat (i, "del"))
7276 errmsg ("missing bridge domain");
7279 else if (ip_set == 0)
7281 errmsg ("missing IP address");
7284 else if (mac_set == 0)
7286 errmsg ("missing MAC address");
7290 M (BD_IP_MAC_ADD_DEL, mp);
7292 mp->bd_id = ntohl (bd_id);
7293 mp->is_ipv6 = is_ipv6;
7294 mp->is_add = is_add;
7296 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7298 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7299 clib_memcpy (mp->mac_address, macaddr, 6);
7306 api_tap_connect (vat_main_t * vam)
7308 unformat_input_t *i = vam->input;
7309 vl_api_tap_connect_t *mp;
7315 ip4_address_t ip4_address;
7317 int ip4_address_set = 0;
7318 ip6_address_t ip6_address;
7320 int ip6_address_set = 0;
7323 memset (mac_address, 0, sizeof (mac_address));
7325 /* Parse args required to build the message */
7326 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7328 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7332 else if (unformat (i, "random-mac"))
7334 else if (unformat (i, "tapname %s", &tap_name))
7336 else if (unformat (i, "tag %s", &tag))
7338 else if (unformat (i, "address %U/%d",
7339 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7340 ip4_address_set = 1;
7341 else if (unformat (i, "address %U/%d",
7342 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7343 ip6_address_set = 1;
7350 errmsg ("missing tap name");
7353 if (vec_len (tap_name) > 63)
7355 errmsg ("tap name too long");
7358 vec_add1 (tap_name, 0);
7360 if (vec_len (tag) > 63)
7362 errmsg ("tag too long");
7366 /* Construct the API message */
7367 M (TAP_CONNECT, mp);
7369 mp->use_random_mac = random_mac;
7370 clib_memcpy (mp->mac_address, mac_address, 6);
7371 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7373 clib_memcpy (mp->tag, tag, vec_len (tag));
7375 if (ip4_address_set)
7377 mp->ip4_address_set = 1;
7378 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7379 mp->ip4_mask_width = ip4_mask_width;
7381 if (ip6_address_set)
7383 mp->ip6_address_set = 1;
7384 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7385 mp->ip6_mask_width = ip6_mask_width;
7388 vec_free (tap_name);
7394 /* Wait for a reply... */
7400 api_tap_modify (vat_main_t * vam)
7402 unformat_input_t *i = vam->input;
7403 vl_api_tap_modify_t *mp;
7408 u32 sw_if_index = ~0;
7409 u8 sw_if_index_set = 0;
7412 memset (mac_address, 0, sizeof (mac_address));
7414 /* Parse args required to build the message */
7415 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7417 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7418 sw_if_index_set = 1;
7419 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7420 sw_if_index_set = 1;
7421 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7425 else if (unformat (i, "random-mac"))
7427 else if (unformat (i, "tapname %s", &tap_name))
7433 if (sw_if_index_set == 0)
7435 errmsg ("missing vpp interface name");
7440 errmsg ("missing tap name");
7443 if (vec_len (tap_name) > 63)
7445 errmsg ("tap name too long");
7447 vec_add1 (tap_name, 0);
7449 /* Construct the API message */
7452 mp->use_random_mac = random_mac;
7453 mp->sw_if_index = ntohl (sw_if_index);
7454 clib_memcpy (mp->mac_address, mac_address, 6);
7455 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7456 vec_free (tap_name);
7461 /* Wait for a reply... */
7467 api_tap_delete (vat_main_t * vam)
7469 unformat_input_t *i = vam->input;
7470 vl_api_tap_delete_t *mp;
7471 u32 sw_if_index = ~0;
7472 u8 sw_if_index_set = 0;
7475 /* Parse args required to build the message */
7476 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7478 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7479 sw_if_index_set = 1;
7480 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7481 sw_if_index_set = 1;
7486 if (sw_if_index_set == 0)
7488 errmsg ("missing vpp interface name");
7492 /* Construct the API message */
7495 mp->sw_if_index = ntohl (sw_if_index);
7500 /* Wait for a reply... */
7506 api_ip_table_add_del (vat_main_t * vam)
7508 unformat_input_t *i = vam->input;
7509 vl_api_ip_table_add_del_t *mp;
7515 /* Parse args required to build the message */
7516 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7518 if (unformat (i, "ipv6"))
7520 else if (unformat (i, "del"))
7522 else if (unformat (i, "add"))
7524 else if (unformat (i, "table %d", &table_id))
7528 clib_warning ("parse error '%U'", format_unformat_error, i);
7535 errmsg ("missing table-ID");
7539 /* Construct the API message */
7540 M (IP_TABLE_ADD_DEL, mp);
7542 mp->table_id = ntohl (table_id);
7543 mp->is_ipv6 = is_ipv6;
7544 mp->is_add = is_add;
7549 /* Wait for a reply... */
7556 api_ip_add_del_route (vat_main_t * vam)
7558 unformat_input_t *i = vam->input;
7559 vl_api_ip_add_del_route_t *mp;
7560 u32 sw_if_index = ~0, vrf_id = 0;
7562 u8 is_local = 0, is_drop = 0;
7563 u8 is_unreach = 0, is_prohibit = 0;
7564 u8 create_vrf_if_needed = 0;
7566 u32 next_hop_weight = 1;
7567 u8 is_multipath = 0;
7569 u8 address_length_set = 0;
7570 u32 next_hop_table_id = 0;
7571 u32 resolve_attempts = 0;
7572 u32 dst_address_length = 0;
7573 u8 next_hop_set = 0;
7574 ip4_address_t v4_dst_address, v4_next_hop_address;
7575 ip6_address_t v6_dst_address, v6_next_hop_address;
7579 u32 random_add_del = 0;
7580 u32 *random_vector = 0;
7582 u32 random_seed = 0xdeaddabe;
7583 u32 classify_table_index = ~0;
7585 u8 resolve_host = 0, resolve_attached = 0;
7586 mpls_label_t *next_hop_out_label_stack = NULL;
7587 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7588 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7590 /* Parse args required to build the message */
7591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7593 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7595 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7597 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
7602 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
7607 else if (unformat (i, "/%d", &dst_address_length))
7609 address_length_set = 1;
7612 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
7613 &v4_next_hop_address))
7617 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7618 &v6_next_hop_address))
7622 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7624 else if (unformat (i, "weight %d", &next_hop_weight))
7626 else if (unformat (i, "drop"))
7630 else if (unformat (i, "null-send-unreach"))
7634 else if (unformat (i, "null-send-prohibit"))
7638 else if (unformat (i, "local"))
7642 else if (unformat (i, "classify %d", &classify_table_index))
7646 else if (unformat (i, "del"))
7648 else if (unformat (i, "add"))
7650 else if (unformat (i, "resolve-via-host"))
7652 else if (unformat (i, "resolve-via-attached"))
7653 resolve_attached = 1;
7654 else if (unformat (i, "multipath"))
7656 else if (unformat (i, "vrf %d", &vrf_id))
7658 else if (unformat (i, "create-vrf"))
7659 create_vrf_if_needed = 1;
7660 else if (unformat (i, "count %d", &count))
7662 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7664 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7666 else if (unformat (i, "out-label %d", &next_hop_out_label))
7667 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7668 else if (unformat (i, "via-label %d", &next_hop_via_label))
7670 else if (unformat (i, "random"))
7672 else if (unformat (i, "seed %d", &random_seed))
7676 clib_warning ("parse error '%U'", format_unformat_error, i);
7681 if (!next_hop_set && !is_drop && !is_local &&
7682 !is_classify && !is_unreach && !is_prohibit &&
7683 MPLS_LABEL_INVALID == next_hop_via_label)
7686 ("next hop / local / drop / unreach / prohibit / classify not set");
7690 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7692 errmsg ("next hop and next-hop via label set");
7695 if (address_set == 0)
7697 errmsg ("missing addresses");
7701 if (address_length_set == 0)
7703 errmsg ("missing address length");
7707 /* Generate a pile of unique, random routes */
7710 u32 this_random_address;
7711 random_hash = hash_create (count, sizeof (uword));
7713 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7714 for (j = 0; j <= count; j++)
7718 this_random_address = random_u32 (&random_seed);
7719 this_random_address =
7720 clib_host_to_net_u32 (this_random_address);
7722 while (hash_get (random_hash, this_random_address));
7723 vec_add1 (random_vector, this_random_address);
7724 hash_set (random_hash, this_random_address, 1);
7726 hash_free (random_hash);
7727 v4_dst_address.as_u32 = random_vector[0];
7732 /* Turn on async mode */
7733 vam->async_mode = 1;
7734 vam->async_errors = 0;
7735 before = vat_time_now (vam);
7738 for (j = 0; j < count; j++)
7740 /* Construct the API message */
7741 M2 (IP_ADD_DEL_ROUTE, mp,
7742 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7744 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7745 mp->table_id = ntohl (vrf_id);
7746 mp->create_vrf_if_needed = create_vrf_if_needed;
7748 mp->is_add = is_add;
7749 mp->is_drop = is_drop;
7750 mp->is_unreach = is_unreach;
7751 mp->is_prohibit = is_prohibit;
7752 mp->is_ipv6 = is_ipv6;
7753 mp->is_local = is_local;
7754 mp->is_classify = is_classify;
7755 mp->is_multipath = is_multipath;
7756 mp->is_resolve_host = resolve_host;
7757 mp->is_resolve_attached = resolve_attached;
7758 mp->next_hop_weight = next_hop_weight;
7759 mp->dst_address_length = dst_address_length;
7760 mp->next_hop_table_id = ntohl (next_hop_table_id);
7761 mp->classify_table_index = ntohl (classify_table_index);
7762 mp->next_hop_via_label = ntohl (next_hop_via_label);
7763 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7764 if (0 != mp->next_hop_n_out_labels)
7766 memcpy (mp->next_hop_out_label_stack,
7767 next_hop_out_label_stack,
7768 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7769 vec_free (next_hop_out_label_stack);
7774 clib_memcpy (mp->dst_address, &v6_dst_address,
7775 sizeof (v6_dst_address));
7777 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
7778 sizeof (v6_next_hop_address));
7779 increment_v6_address (&v6_dst_address);
7783 clib_memcpy (mp->dst_address, &v4_dst_address,
7784 sizeof (v4_dst_address));
7786 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
7787 sizeof (v4_next_hop_address));
7789 v4_dst_address.as_u32 = random_vector[j + 1];
7791 increment_v4_address (&v4_dst_address);
7795 /* If we receive SIGTERM, stop now... */
7800 /* When testing multiple add/del ops, use a control-ping to sync */
7803 vl_api_control_ping_t *mp_ping;
7807 /* Shut off async mode */
7808 vam->async_mode = 0;
7810 MPING (CONTROL_PING, mp_ping);
7813 timeout = vat_time_now (vam) + 1.0;
7814 while (vat_time_now (vam) < timeout)
7815 if (vam->result_ready == 1)
7820 if (vam->retval == -99)
7823 if (vam->async_errors > 0)
7825 errmsg ("%d asynchronous errors", vam->async_errors);
7828 vam->async_errors = 0;
7829 after = vat_time_now (vam);
7831 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7835 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7836 count, after - before, count / (after - before));
7842 /* Wait for a reply... */
7847 /* Return the good/bad news */
7848 return (vam->retval);
7852 api_ip_mroute_add_del (vat_main_t * vam)
7854 unformat_input_t *i = vam->input;
7855 vl_api_ip_mroute_add_del_t *mp;
7856 u32 sw_if_index = ~0, vrf_id = 0;
7859 u8 create_vrf_if_needed = 0;
7862 u32 grp_address_length = 0;
7863 ip4_address_t v4_grp_address, v4_src_address;
7864 ip6_address_t v6_grp_address, v6_src_address;
7865 mfib_itf_flags_t iflags = 0;
7866 mfib_entry_flags_t eflags = 0;
7869 /* Parse args required to build the message */
7870 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7872 if (unformat (i, "sw_if_index %d", &sw_if_index))
7874 else if (unformat (i, "%U %U",
7875 unformat_ip4_address, &v4_src_address,
7876 unformat_ip4_address, &v4_grp_address))
7878 grp_address_length = 64;
7882 else if (unformat (i, "%U %U",
7883 unformat_ip6_address, &v6_src_address,
7884 unformat_ip6_address, &v6_grp_address))
7886 grp_address_length = 256;
7890 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7892 memset (&v4_src_address, 0, sizeof (v4_src_address));
7893 grp_address_length = 32;
7897 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7899 memset (&v6_src_address, 0, sizeof (v6_src_address));
7900 grp_address_length = 128;
7904 else if (unformat (i, "/%d", &grp_address_length))
7906 else if (unformat (i, "local"))
7910 else if (unformat (i, "del"))
7912 else if (unformat (i, "add"))
7914 else if (unformat (i, "vrf %d", &vrf_id))
7916 else if (unformat (i, "create-vrf"))
7917 create_vrf_if_needed = 1;
7918 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
7920 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7924 clib_warning ("parse error '%U'", format_unformat_error, i);
7929 if (address_set == 0)
7931 errmsg ("missing addresses\n");
7935 /* Construct the API message */
7936 M (IP_MROUTE_ADD_DEL, mp);
7938 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7939 mp->table_id = ntohl (vrf_id);
7940 mp->create_vrf_if_needed = create_vrf_if_needed;
7942 mp->is_add = is_add;
7943 mp->is_ipv6 = is_ipv6;
7944 mp->is_local = is_local;
7945 mp->itf_flags = ntohl (iflags);
7946 mp->entry_flags = ntohl (eflags);
7947 mp->grp_address_length = grp_address_length;
7948 mp->grp_address_length = ntohs (mp->grp_address_length);
7952 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7953 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7957 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7958 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7964 /* Wait for a reply... */
7970 api_mpls_table_add_del (vat_main_t * vam)
7972 unformat_input_t *i = vam->input;
7973 vl_api_mpls_table_add_del_t *mp;
7978 /* Parse args required to build the message */
7979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7981 if (unformat (i, "table %d", &table_id))
7983 else if (unformat (i, "del"))
7985 else if (unformat (i, "add"))
7989 clib_warning ("parse error '%U'", format_unformat_error, i);
7996 errmsg ("missing table-ID");
8000 /* Construct the API message */
8001 M (MPLS_TABLE_ADD_DEL, mp);
8003 mp->mt_table_id = ntohl (table_id);
8004 mp->mt_is_add = is_add;
8009 /* Wait for a reply... */
8016 api_mpls_route_add_del (vat_main_t * vam)
8018 unformat_input_t *i = vam->input;
8019 vl_api_mpls_route_add_del_t *mp;
8020 u32 sw_if_index = ~0, table_id = 0;
8021 u8 create_table_if_needed = 0;
8023 u32 next_hop_weight = 1;
8024 u8 is_multipath = 0;
8025 u32 next_hop_table_id = 0;
8026 u8 next_hop_set = 0;
8027 ip4_address_t v4_next_hop_address = {
8030 ip6_address_t v6_next_hop_address = { {0} };
8034 u32 classify_table_index = ~0;
8036 u8 resolve_host = 0, resolve_attached = 0;
8037 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8038 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8039 mpls_label_t *next_hop_out_label_stack = NULL;
8040 mpls_label_t local_label = MPLS_LABEL_INVALID;
8042 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8044 /* Parse args required to build the message */
8045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8047 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8049 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8051 else if (unformat (i, "%d", &local_label))
8053 else if (unformat (i, "eos"))
8055 else if (unformat (i, "non-eos"))
8057 else if (unformat (i, "via %U", unformat_ip4_address,
8058 &v4_next_hop_address))
8061 next_hop_proto = DPO_PROTO_IP4;
8063 else if (unformat (i, "via %U", unformat_ip6_address,
8064 &v6_next_hop_address))
8067 next_hop_proto = DPO_PROTO_IP6;
8069 else if (unformat (i, "weight %d", &next_hop_weight))
8071 else if (unformat (i, "create-table"))
8072 create_table_if_needed = 1;
8073 else if (unformat (i, "classify %d", &classify_table_index))
8077 else if (unformat (i, "del"))
8079 else if (unformat (i, "add"))
8081 else if (unformat (i, "resolve-via-host"))
8083 else if (unformat (i, "resolve-via-attached"))
8084 resolve_attached = 1;
8085 else if (unformat (i, "multipath"))
8087 else if (unformat (i, "count %d", &count))
8089 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8092 next_hop_proto = DPO_PROTO_IP4;
8094 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8097 next_hop_proto = DPO_PROTO_IP6;
8099 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8101 else if (unformat (i, "via-label %d", &next_hop_via_label))
8103 else if (unformat (i, "out-label %d", &next_hop_out_label))
8104 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8107 clib_warning ("parse error '%U'", format_unformat_error, i);
8112 if (!next_hop_set && !is_classify)
8114 errmsg ("next hop / classify not set");
8118 if (MPLS_LABEL_INVALID == local_label)
8120 errmsg ("missing label");
8126 /* Turn on async mode */
8127 vam->async_mode = 1;
8128 vam->async_errors = 0;
8129 before = vat_time_now (vam);
8132 for (j = 0; j < count; j++)
8134 /* Construct the API message */
8135 M2 (MPLS_ROUTE_ADD_DEL, mp,
8136 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8138 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8139 mp->mr_table_id = ntohl (table_id);
8140 mp->mr_create_table_if_needed = create_table_if_needed;
8142 mp->mr_is_add = is_add;
8143 mp->mr_next_hop_proto = next_hop_proto;
8144 mp->mr_is_classify = is_classify;
8145 mp->mr_is_multipath = is_multipath;
8146 mp->mr_is_resolve_host = resolve_host;
8147 mp->mr_is_resolve_attached = resolve_attached;
8148 mp->mr_next_hop_weight = next_hop_weight;
8149 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8150 mp->mr_classify_table_index = ntohl (classify_table_index);
8151 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8152 mp->mr_label = ntohl (local_label);
8153 mp->mr_eos = is_eos;
8155 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8156 if (0 != mp->mr_next_hop_n_out_labels)
8158 memcpy (mp->mr_next_hop_out_label_stack,
8159 next_hop_out_label_stack,
8160 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8161 vec_free (next_hop_out_label_stack);
8166 if (DPO_PROTO_IP4 == next_hop_proto)
8168 clib_memcpy (mp->mr_next_hop,
8169 &v4_next_hop_address,
8170 sizeof (v4_next_hop_address));
8172 else if (DPO_PROTO_IP6 == next_hop_proto)
8175 clib_memcpy (mp->mr_next_hop,
8176 &v6_next_hop_address,
8177 sizeof (v6_next_hop_address));
8184 /* If we receive SIGTERM, stop now... */
8189 /* When testing multiple add/del ops, use a control-ping to sync */
8192 vl_api_control_ping_t *mp_ping;
8196 /* Shut off async mode */
8197 vam->async_mode = 0;
8199 MPING (CONTROL_PING, mp_ping);
8202 timeout = vat_time_now (vam) + 1.0;
8203 while (vat_time_now (vam) < timeout)
8204 if (vam->result_ready == 1)
8209 if (vam->retval == -99)
8212 if (vam->async_errors > 0)
8214 errmsg ("%d asynchronous errors", vam->async_errors);
8217 vam->async_errors = 0;
8218 after = vat_time_now (vam);
8220 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8224 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8225 count, after - before, count / (after - before));
8231 /* Wait for a reply... */
8236 /* Return the good/bad news */
8237 return (vam->retval);
8241 api_mpls_ip_bind_unbind (vat_main_t * vam)
8243 unformat_input_t *i = vam->input;
8244 vl_api_mpls_ip_bind_unbind_t *mp;
8245 u32 ip_table_id = 0;
8246 u8 create_table_if_needed = 0;
8249 ip4_address_t v4_address;
8250 ip6_address_t v6_address;
8253 mpls_label_t local_label = MPLS_LABEL_INVALID;
8256 /* Parse args required to build the message */
8257 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8259 if (unformat (i, "%U/%d", unformat_ip4_address,
8260 &v4_address, &address_length))
8265 else if (unformat (i, "%U/%d", unformat_ip6_address,
8266 &v6_address, &address_length))
8271 else if (unformat (i, "%d", &local_label))
8273 else if (unformat (i, "create-table"))
8274 create_table_if_needed = 1;
8275 else if (unformat (i, "table-id %d", &ip_table_id))
8277 else if (unformat (i, "unbind"))
8279 else if (unformat (i, "bind"))
8283 clib_warning ("parse error '%U'", format_unformat_error, i);
8290 errmsg ("IP addres not set");
8294 if (MPLS_LABEL_INVALID == local_label)
8296 errmsg ("missing label");
8300 /* Construct the API message */
8301 M (MPLS_IP_BIND_UNBIND, mp);
8303 mp->mb_create_table_if_needed = create_table_if_needed;
8304 mp->mb_is_bind = is_bind;
8305 mp->mb_is_ip4 = is_ip4;
8306 mp->mb_ip_table_id = ntohl (ip_table_id);
8307 mp->mb_mpls_table_id = 0;
8308 mp->mb_label = ntohl (local_label);
8309 mp->mb_address_length = address_length;
8312 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8314 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8319 /* Wait for a reply... */
8325 api_proxy_arp_add_del (vat_main_t * vam)
8327 unformat_input_t *i = vam->input;
8328 vl_api_proxy_arp_add_del_t *mp;
8331 ip4_address_t lo, hi;
8335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8337 if (unformat (i, "vrf %d", &vrf_id))
8339 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
8340 unformat_ip4_address, &hi))
8342 else if (unformat (i, "del"))
8346 clib_warning ("parse error '%U'", format_unformat_error, i);
8353 errmsg ("address range not set");
8357 M (PROXY_ARP_ADD_DEL, mp);
8359 mp->vrf_id = ntohl (vrf_id);
8360 mp->is_add = is_add;
8361 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
8362 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
8370 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8372 unformat_input_t *i = vam->input;
8373 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8376 u8 sw_if_index_set = 0;
8379 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8381 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8382 sw_if_index_set = 1;
8383 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8384 sw_if_index_set = 1;
8385 else if (unformat (i, "enable"))
8387 else if (unformat (i, "disable"))
8391 clib_warning ("parse error '%U'", format_unformat_error, i);
8396 if (sw_if_index_set == 0)
8398 errmsg ("missing interface name or sw_if_index");
8402 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8404 mp->sw_if_index = ntohl (sw_if_index);
8405 mp->enable_disable = enable;
8413 api_mpls_tunnel_add_del (vat_main_t * vam)
8415 unformat_input_t *i = vam->input;
8416 vl_api_mpls_tunnel_add_del_t *mp;
8420 u32 sw_if_index = ~0;
8421 u32 next_hop_sw_if_index = ~0;
8422 u32 next_hop_proto_is_ip4 = 1;
8424 u32 next_hop_table_id = 0;
8425 ip4_address_t v4_next_hop_address = {
8428 ip6_address_t v6_next_hop_address = { {0} };
8429 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
8432 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8434 if (unformat (i, "add"))
8436 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8438 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
8440 else if (unformat (i, "via %U",
8441 unformat_ip4_address, &v4_next_hop_address))
8443 next_hop_proto_is_ip4 = 1;
8445 else if (unformat (i, "via %U",
8446 unformat_ip6_address, &v6_next_hop_address))
8448 next_hop_proto_is_ip4 = 0;
8450 else if (unformat (i, "l2-only"))
8452 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8454 else if (unformat (i, "out-label %d", &next_hop_out_label))
8455 vec_add1 (labels, ntohl (next_hop_out_label));
8458 clib_warning ("parse error '%U'", format_unformat_error, i);
8463 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
8465 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
8466 mp->mt_sw_if_index = ntohl (sw_if_index);
8467 mp->mt_is_add = is_add;
8468 mp->mt_l2_only = l2_only;
8469 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
8470 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
8472 mp->mt_next_hop_n_out_labels = vec_len (labels);
8474 if (0 != mp->mt_next_hop_n_out_labels)
8476 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
8477 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
8481 if (next_hop_proto_is_ip4)
8483 clib_memcpy (mp->mt_next_hop,
8484 &v4_next_hop_address, sizeof (v4_next_hop_address));
8488 clib_memcpy (mp->mt_next_hop,
8489 &v6_next_hop_address, sizeof (v6_next_hop_address));
8498 api_sw_interface_set_unnumbered (vat_main_t * vam)
8500 unformat_input_t *i = vam->input;
8501 vl_api_sw_interface_set_unnumbered_t *mp;
8503 u32 unnum_sw_index = ~0;
8505 u8 sw_if_index_set = 0;
8508 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8510 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8511 sw_if_index_set = 1;
8512 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8513 sw_if_index_set = 1;
8514 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8516 else if (unformat (i, "del"))
8520 clib_warning ("parse error '%U'", format_unformat_error, i);
8525 if (sw_if_index_set == 0)
8527 errmsg ("missing interface name or sw_if_index");
8531 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8533 mp->sw_if_index = ntohl (sw_if_index);
8534 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8535 mp->is_add = is_add;
8543 api_ip_neighbor_add_del (vat_main_t * vam)
8545 unformat_input_t *i = vam->input;
8546 vl_api_ip_neighbor_add_del_t *mp;
8548 u8 sw_if_index_set = 0;
8551 u8 is_no_fib_entry = 0;
8554 u8 v4_address_set = 0;
8555 u8 v6_address_set = 0;
8556 ip4_address_t v4address;
8557 ip6_address_t v6address;
8560 memset (mac_address, 0, sizeof (mac_address));
8562 /* Parse args required to build the message */
8563 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8565 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8569 else if (unformat (i, "del"))
8572 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8573 sw_if_index_set = 1;
8574 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8575 sw_if_index_set = 1;
8576 else if (unformat (i, "is_static"))
8578 else if (unformat (i, "no-fib-entry"))
8579 is_no_fib_entry = 1;
8580 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
8582 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
8586 clib_warning ("parse error '%U'", format_unformat_error, i);
8591 if (sw_if_index_set == 0)
8593 errmsg ("missing interface name or sw_if_index");
8596 if (v4_address_set && v6_address_set)
8598 errmsg ("both v4 and v6 addresses set");
8601 if (!v4_address_set && !v6_address_set)
8603 errmsg ("no address set");
8607 /* Construct the API message */
8608 M (IP_NEIGHBOR_ADD_DEL, mp);
8610 mp->sw_if_index = ntohl (sw_if_index);
8611 mp->is_add = is_add;
8612 mp->is_static = is_static;
8613 mp->is_no_adj_fib = is_no_fib_entry;
8615 clib_memcpy (mp->mac_address, mac_address, 6);
8619 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
8623 /* mp->is_ipv6 = 0; via memset in M macro above */
8624 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
8630 /* Wait for a reply, return good/bad news */
8636 api_reset_vrf (vat_main_t * vam)
8638 unformat_input_t *i = vam->input;
8639 vl_api_reset_vrf_t *mp;
8645 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8647 if (unformat (i, "vrf %d", &vrf_id))
8649 else if (unformat (i, "ipv6"))
8653 clib_warning ("parse error '%U'", format_unformat_error, i);
8658 if (vrf_id_set == 0)
8660 errmsg ("missing vrf id");
8666 mp->vrf_id = ntohl (vrf_id);
8667 mp->is_ipv6 = is_ipv6;
8675 api_create_vlan_subif (vat_main_t * vam)
8677 unformat_input_t *i = vam->input;
8678 vl_api_create_vlan_subif_t *mp;
8680 u8 sw_if_index_set = 0;
8685 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8687 if (unformat (i, "sw_if_index %d", &sw_if_index))
8688 sw_if_index_set = 1;
8690 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8691 sw_if_index_set = 1;
8692 else if (unformat (i, "vlan %d", &vlan_id))
8696 clib_warning ("parse error '%U'", format_unformat_error, i);
8701 if (sw_if_index_set == 0)
8703 errmsg ("missing interface name or sw_if_index");
8707 if (vlan_id_set == 0)
8709 errmsg ("missing vlan_id");
8712 M (CREATE_VLAN_SUBIF, mp);
8714 mp->sw_if_index = ntohl (sw_if_index);
8715 mp->vlan_id = ntohl (vlan_id);
8722 #define foreach_create_subif_bit \
8729 _(outer_vlan_id_any) \
8730 _(inner_vlan_id_any)
8733 api_create_subif (vat_main_t * vam)
8735 unformat_input_t *i = vam->input;
8736 vl_api_create_subif_t *mp;
8738 u8 sw_if_index_set = 0;
8745 u32 exact_match = 0;
8746 u32 default_sub = 0;
8747 u32 outer_vlan_id_any = 0;
8748 u32 inner_vlan_id_any = 0;
8750 u16 outer_vlan_id = 0;
8751 u16 inner_vlan_id = 0;
8754 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8756 if (unformat (i, "sw_if_index %d", &sw_if_index))
8757 sw_if_index_set = 1;
8759 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8760 sw_if_index_set = 1;
8761 else if (unformat (i, "sub_id %d", &sub_id))
8763 else if (unformat (i, "outer_vlan_id %d", &tmp))
8764 outer_vlan_id = tmp;
8765 else if (unformat (i, "inner_vlan_id %d", &tmp))
8766 inner_vlan_id = tmp;
8768 #define _(a) else if (unformat (i, #a)) a = 1 ;
8769 foreach_create_subif_bit
8773 clib_warning ("parse error '%U'", format_unformat_error, i);
8778 if (sw_if_index_set == 0)
8780 errmsg ("missing interface name or sw_if_index");
8784 if (sub_id_set == 0)
8786 errmsg ("missing sub_id");
8789 M (CREATE_SUBIF, mp);
8791 mp->sw_if_index = ntohl (sw_if_index);
8792 mp->sub_id = ntohl (sub_id);
8794 #define _(a) mp->a = a;
8795 foreach_create_subif_bit;
8798 mp->outer_vlan_id = ntohs (outer_vlan_id);
8799 mp->inner_vlan_id = ntohs (inner_vlan_id);
8807 api_oam_add_del (vat_main_t * vam)
8809 unformat_input_t *i = vam->input;
8810 vl_api_oam_add_del_t *mp;
8813 ip4_address_t src, dst;
8818 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8820 if (unformat (i, "vrf %d", &vrf_id))
8822 else if (unformat (i, "src %U", unformat_ip4_address, &src))
8824 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
8826 else if (unformat (i, "del"))
8830 clib_warning ("parse error '%U'", format_unformat_error, i);
8837 errmsg ("missing src addr");
8843 errmsg ("missing dst addr");
8847 M (OAM_ADD_DEL, mp);
8849 mp->vrf_id = ntohl (vrf_id);
8850 mp->is_add = is_add;
8851 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
8852 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
8860 api_reset_fib (vat_main_t * vam)
8862 unformat_input_t *i = vam->input;
8863 vl_api_reset_fib_t *mp;
8869 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8871 if (unformat (i, "vrf %d", &vrf_id))
8873 else if (unformat (i, "ipv6"))
8877 clib_warning ("parse error '%U'", format_unformat_error, i);
8882 if (vrf_id_set == 0)
8884 errmsg ("missing vrf id");
8890 mp->vrf_id = ntohl (vrf_id);
8891 mp->is_ipv6 = is_ipv6;
8899 api_dhcp_proxy_config (vat_main_t * vam)
8901 unformat_input_t *i = vam->input;
8902 vl_api_dhcp_proxy_config_t *mp;
8904 u32 server_vrf_id = 0;
8906 u8 v4_address_set = 0;
8907 u8 v6_address_set = 0;
8908 ip4_address_t v4address;
8909 ip6_address_t v6address;
8910 u8 v4_src_address_set = 0;
8911 u8 v6_src_address_set = 0;
8912 ip4_address_t v4srcaddress;
8913 ip6_address_t v6srcaddress;
8916 /* Parse args required to build the message */
8917 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8919 if (unformat (i, "del"))
8921 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
8923 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
8925 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
8927 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
8929 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
8930 v4_src_address_set = 1;
8931 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
8932 v6_src_address_set = 1;
8937 if (v4_address_set && v6_address_set)
8939 errmsg ("both v4 and v6 server addresses set");
8942 if (!v4_address_set && !v6_address_set)
8944 errmsg ("no server addresses set");
8948 if (v4_src_address_set && v6_src_address_set)
8950 errmsg ("both v4 and v6 src addresses set");
8953 if (!v4_src_address_set && !v6_src_address_set)
8955 errmsg ("no src addresses set");
8959 if (!(v4_src_address_set && v4_address_set) &&
8960 !(v6_src_address_set && v6_address_set))
8962 errmsg ("no matching server and src addresses set");
8966 /* Construct the API message */
8967 M (DHCP_PROXY_CONFIG, mp);
8969 mp->is_add = is_add;
8970 mp->rx_vrf_id = ntohl (rx_vrf_id);
8971 mp->server_vrf_id = ntohl (server_vrf_id);
8975 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
8976 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
8980 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
8981 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
8987 /* Wait for a reply, return good/bad news */
8992 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
8993 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
8996 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
8998 vat_main_t *vam = &vat_main;
8999 u32 i, count = mp->count;
9000 vl_api_dhcp_server_t *s;
9004 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
9005 ntohl (mp->rx_vrf_id),
9006 format_ip6_address, mp->dhcp_src_address,
9007 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9010 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
9011 ntohl (mp->rx_vrf_id),
9012 format_ip4_address, mp->dhcp_src_address,
9013 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9015 for (i = 0; i < count; i++)
9017 s = &mp->servers[i];
9021 " Server Table-ID %d, Server Address %U",
9022 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9025 " Server Table-ID %d, Server Address %U",
9026 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9030 static void vl_api_dhcp_proxy_details_t_handler_json
9031 (vl_api_dhcp_proxy_details_t * mp)
9033 vat_main_t *vam = &vat_main;
9034 vat_json_node_t *node = NULL;
9035 u32 i, count = mp->count;
9037 struct in6_addr ip6;
9038 vl_api_dhcp_server_t *s;
9040 if (VAT_JSON_ARRAY != vam->json_tree.type)
9042 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9043 vat_json_init_array (&vam->json_tree);
9045 node = vat_json_array_add (&vam->json_tree);
9047 vat_json_init_object (node);
9048 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9049 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9050 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9054 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9055 vat_json_object_add_ip6 (node, "src_address", ip6);
9059 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9060 vat_json_object_add_ip4 (node, "src_address", ip4);
9063 for (i = 0; i < count; i++)
9065 s = &mp->servers[i];
9067 vat_json_object_add_uint (node, "server-table-id",
9068 ntohl (s->server_vrf_id));
9072 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9073 vat_json_object_add_ip4 (node, "src_address", ip4);
9077 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9078 vat_json_object_add_ip6 (node, "server_address", ip6);
9084 api_dhcp_proxy_dump (vat_main_t * vam)
9086 unformat_input_t *i = vam->input;
9087 vl_api_control_ping_t *mp_ping;
9088 vl_api_dhcp_proxy_dump_t *mp;
9092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9094 if (unformat (i, "ipv6"))
9098 clib_warning ("parse error '%U'", format_unformat_error, i);
9103 M (DHCP_PROXY_DUMP, mp);
9105 mp->is_ip6 = is_ipv6;
9108 /* Use a control ping for synchronization */
9109 MPING (CONTROL_PING, mp_ping);
9117 api_dhcp_proxy_set_vss (vat_main_t * vam)
9119 unformat_input_t *i = vam->input;
9120 vl_api_dhcp_proxy_set_vss_t *mp;
9131 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9133 if (unformat (i, "tbl_id %d", &tbl_id))
9135 if (unformat (i, "fib_id %d", &fib_id))
9137 if (unformat (i, "oui %d", &oui))
9139 else if (unformat (i, "ipv6"))
9141 else if (unformat (i, "del"))
9145 clib_warning ("parse error '%U'", format_unformat_error, i);
9150 if (tbl_id_set == 0)
9152 errmsg ("missing tbl id");
9156 if (fib_id_set == 0)
9158 errmsg ("missing fib id");
9163 errmsg ("missing oui");
9167 M (DHCP_PROXY_SET_VSS, mp);
9168 mp->tbl_id = ntohl (tbl_id);
9169 mp->fib_id = ntohl (fib_id);
9170 mp->oui = ntohl (oui);
9171 mp->is_ipv6 = is_ipv6;
9172 mp->is_add = is_add;
9180 api_dhcp_client_config (vat_main_t * vam)
9182 unformat_input_t *i = vam->input;
9183 vl_api_dhcp_client_config_t *mp;
9185 u8 sw_if_index_set = 0;
9188 u8 disable_event = 0;
9191 /* Parse args required to build the message */
9192 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9194 if (unformat (i, "del"))
9197 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9198 sw_if_index_set = 1;
9199 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9200 sw_if_index_set = 1;
9201 else if (unformat (i, "hostname %s", &hostname))
9203 else if (unformat (i, "disable_event"))
9209 if (sw_if_index_set == 0)
9211 errmsg ("missing interface name or sw_if_index");
9215 if (vec_len (hostname) > 63)
9217 errmsg ("hostname too long");
9219 vec_add1 (hostname, 0);
9221 /* Construct the API message */
9222 M (DHCP_CLIENT_CONFIG, mp);
9224 mp->sw_if_index = htonl (sw_if_index);
9225 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
9226 vec_free (hostname);
9227 mp->is_add = is_add;
9228 mp->want_dhcp_event = disable_event ? 0 : 1;
9229 mp->pid = htonl (getpid ());
9234 /* Wait for a reply, return good/bad news */
9240 api_set_ip_flow_hash (vat_main_t * vam)
9242 unformat_input_t *i = vam->input;
9243 vl_api_set_ip_flow_hash_t *mp;
9255 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9257 if (unformat (i, "vrf %d", &vrf_id))
9259 else if (unformat (i, "ipv6"))
9261 else if (unformat (i, "src"))
9263 else if (unformat (i, "dst"))
9265 else if (unformat (i, "sport"))
9267 else if (unformat (i, "dport"))
9269 else if (unformat (i, "proto"))
9271 else if (unformat (i, "reverse"))
9276 clib_warning ("parse error '%U'", format_unformat_error, i);
9281 if (vrf_id_set == 0)
9283 errmsg ("missing vrf id");
9287 M (SET_IP_FLOW_HASH, mp);
9293 mp->reverse = reverse;
9294 mp->vrf_id = ntohl (vrf_id);
9295 mp->is_ipv6 = is_ipv6;
9303 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9305 unformat_input_t *i = vam->input;
9306 vl_api_sw_interface_ip6_enable_disable_t *mp;
9308 u8 sw_if_index_set = 0;
9312 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9314 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9315 sw_if_index_set = 1;
9316 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9317 sw_if_index_set = 1;
9318 else if (unformat (i, "enable"))
9320 else if (unformat (i, "disable"))
9324 clib_warning ("parse error '%U'", format_unformat_error, i);
9329 if (sw_if_index_set == 0)
9331 errmsg ("missing interface name or sw_if_index");
9335 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9337 mp->sw_if_index = ntohl (sw_if_index);
9338 mp->enable = enable;
9346 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
9348 unformat_input_t *i = vam->input;
9349 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
9351 u8 sw_if_index_set = 0;
9352 u8 v6_address_set = 0;
9353 ip6_address_t v6address;
9356 /* Parse args required to build the message */
9357 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9359 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9360 sw_if_index_set = 1;
9361 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9362 sw_if_index_set = 1;
9363 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9369 if (sw_if_index_set == 0)
9371 errmsg ("missing interface name or sw_if_index");
9374 if (!v6_address_set)
9376 errmsg ("no address set");
9380 /* Construct the API message */
9381 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
9383 mp->sw_if_index = ntohl (sw_if_index);
9384 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9389 /* Wait for a reply, return good/bad news */
9395 api_ip6nd_proxy_add_del (vat_main_t * vam)
9397 unformat_input_t *i = vam->input;
9398 vl_api_ip6nd_proxy_add_del_t *mp;
9399 u32 sw_if_index = ~0;
9400 u8 v6_address_set = 0;
9401 ip6_address_t v6address;
9405 /* Parse args required to build the message */
9406 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9408 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9410 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9412 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9414 if (unformat (i, "del"))
9418 clib_warning ("parse error '%U'", format_unformat_error, i);
9423 if (sw_if_index == ~0)
9425 errmsg ("missing interface name or sw_if_index");
9428 if (!v6_address_set)
9430 errmsg ("no address set");
9434 /* Construct the API message */
9435 M (IP6ND_PROXY_ADD_DEL, mp);
9437 mp->is_del = is_del;
9438 mp->sw_if_index = ntohl (sw_if_index);
9439 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9444 /* Wait for a reply, return good/bad news */
9450 api_ip6nd_proxy_dump (vat_main_t * vam)
9452 vl_api_ip6nd_proxy_dump_t *mp;
9453 vl_api_control_ping_t *mp_ping;
9456 M (IP6ND_PROXY_DUMP, mp);
9460 /* Use a control ping for synchronization */
9461 MPING (CONTROL_PING, mp_ping);
9468 static void vl_api_ip6nd_proxy_details_t_handler
9469 (vl_api_ip6nd_proxy_details_t * mp)
9471 vat_main_t *vam = &vat_main;
9473 print (vam->ofp, "host %U sw_if_index %d",
9474 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
9477 static void vl_api_ip6nd_proxy_details_t_handler_json
9478 (vl_api_ip6nd_proxy_details_t * mp)
9480 vat_main_t *vam = &vat_main;
9481 struct in6_addr ip6;
9482 vat_json_node_t *node = NULL;
9484 if (VAT_JSON_ARRAY != vam->json_tree.type)
9486 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9487 vat_json_init_array (&vam->json_tree);
9489 node = vat_json_array_add (&vam->json_tree);
9491 vat_json_init_object (node);
9492 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9494 clib_memcpy (&ip6, mp->address, sizeof (ip6));
9495 vat_json_object_add_ip6 (node, "host", ip6);
9499 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9501 unformat_input_t *i = vam->input;
9502 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9504 u8 sw_if_index_set = 0;
9505 u32 address_length = 0;
9506 u8 v6_address_set = 0;
9507 ip6_address_t v6address;
9509 u8 no_advertise = 0;
9511 u8 no_autoconfig = 0;
9514 u32 val_lifetime = 0;
9515 u32 pref_lifetime = 0;
9518 /* Parse args required to build the message */
9519 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9521 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9522 sw_if_index_set = 1;
9523 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9524 sw_if_index_set = 1;
9525 else if (unformat (i, "%U/%d",
9526 unformat_ip6_address, &v6address, &address_length))
9528 else if (unformat (i, "val_life %d", &val_lifetime))
9530 else if (unformat (i, "pref_life %d", &pref_lifetime))
9532 else if (unformat (i, "def"))
9534 else if (unformat (i, "noadv"))
9536 else if (unformat (i, "offl"))
9538 else if (unformat (i, "noauto"))
9540 else if (unformat (i, "nolink"))
9542 else if (unformat (i, "isno"))
9546 clib_warning ("parse error '%U'", format_unformat_error, i);
9551 if (sw_if_index_set == 0)
9553 errmsg ("missing interface name or sw_if_index");
9556 if (!v6_address_set)
9558 errmsg ("no address set");
9562 /* Construct the API message */
9563 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9565 mp->sw_if_index = ntohl (sw_if_index);
9566 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9567 mp->address_length = address_length;
9568 mp->use_default = use_default;
9569 mp->no_advertise = no_advertise;
9570 mp->off_link = off_link;
9571 mp->no_autoconfig = no_autoconfig;
9572 mp->no_onlink = no_onlink;
9574 mp->val_lifetime = ntohl (val_lifetime);
9575 mp->pref_lifetime = ntohl (pref_lifetime);
9580 /* Wait for a reply, return good/bad news */
9586 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9588 unformat_input_t *i = vam->input;
9589 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9591 u8 sw_if_index_set = 0;
9596 u8 send_unicast = 0;
9599 u8 default_router = 0;
9600 u32 max_interval = 0;
9601 u32 min_interval = 0;
9603 u32 initial_count = 0;
9604 u32 initial_interval = 0;
9608 /* Parse args required to build the message */
9609 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9611 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9612 sw_if_index_set = 1;
9613 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9614 sw_if_index_set = 1;
9615 else if (unformat (i, "maxint %d", &max_interval))
9617 else if (unformat (i, "minint %d", &min_interval))
9619 else if (unformat (i, "life %d", &lifetime))
9621 else if (unformat (i, "count %d", &initial_count))
9623 else if (unformat (i, "interval %d", &initial_interval))
9625 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9627 else if (unformat (i, "managed"))
9629 else if (unformat (i, "other"))
9631 else if (unformat (i, "ll"))
9633 else if (unformat (i, "send"))
9635 else if (unformat (i, "cease"))
9637 else if (unformat (i, "isno"))
9639 else if (unformat (i, "def"))
9643 clib_warning ("parse error '%U'", format_unformat_error, i);
9648 if (sw_if_index_set == 0)
9650 errmsg ("missing interface name or sw_if_index");
9654 /* Construct the API message */
9655 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9657 mp->sw_if_index = ntohl (sw_if_index);
9658 mp->max_interval = ntohl (max_interval);
9659 mp->min_interval = ntohl (min_interval);
9660 mp->lifetime = ntohl (lifetime);
9661 mp->initial_count = ntohl (initial_count);
9662 mp->initial_interval = ntohl (initial_interval);
9663 mp->suppress = suppress;
9664 mp->managed = managed;
9666 mp->ll_option = ll_option;
9667 mp->send_unicast = send_unicast;
9670 mp->default_router = default_router;
9675 /* Wait for a reply, return good/bad news */
9681 api_set_arp_neighbor_limit (vat_main_t * vam)
9683 unformat_input_t *i = vam->input;
9684 vl_api_set_arp_neighbor_limit_t *mp;
9690 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9692 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9694 else if (unformat (i, "ipv6"))
9698 clib_warning ("parse error '%U'", format_unformat_error, i);
9705 errmsg ("missing limit value");
9709 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9711 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9712 mp->is_ipv6 = is_ipv6;
9720 api_l2_patch_add_del (vat_main_t * vam)
9722 unformat_input_t *i = vam->input;
9723 vl_api_l2_patch_add_del_t *mp;
9725 u8 rx_sw_if_index_set = 0;
9727 u8 tx_sw_if_index_set = 0;
9731 /* Parse args required to build the message */
9732 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9734 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9735 rx_sw_if_index_set = 1;
9736 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9737 tx_sw_if_index_set = 1;
9738 else if (unformat (i, "rx"))
9740 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9742 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9744 rx_sw_if_index_set = 1;
9749 else if (unformat (i, "tx"))
9751 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9753 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9755 tx_sw_if_index_set = 1;
9760 else if (unformat (i, "del"))
9766 if (rx_sw_if_index_set == 0)
9768 errmsg ("missing rx interface name or rx_sw_if_index");
9772 if (tx_sw_if_index_set == 0)
9774 errmsg ("missing tx interface name or tx_sw_if_index");
9778 M (L2_PATCH_ADD_DEL, mp);
9780 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9781 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9782 mp->is_add = is_add;
9790 u8 localsid_addr[16];
9799 api_sr_localsid_add_del (vat_main_t * vam)
9801 unformat_input_t *i = vam->input;
9802 vl_api_sr_localsid_add_del_t *mp;
9805 ip6_address_t localsid;
9809 u32 fib_table = ~(u32) 0;
9810 ip6_address_t next_hop;
9812 bool nexthop_set = 0;
9816 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9818 if (unformat (i, "del"))
9820 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9821 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
9823 else if (unformat (i, "behavior %u", &behavior));
9824 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9825 else if (unformat (i, "fib-table %u", &fib_table));
9826 else if (unformat (i, "end.psp %u", &behavior));
9831 M (SR_LOCALSID_ADD_DEL, mp);
9833 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
9835 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
9836 mp->behavior = behavior;
9837 mp->sw_if_index = ntohl (sw_if_index);
9838 mp->fib_table = ntohl (fib_table);
9839 mp->end_psp = end_psp;
9840 mp->is_del = is_del;
9848 api_ioam_enable (vat_main_t * vam)
9850 unformat_input_t *input = vam->input;
9851 vl_api_ioam_enable_t *mp;
9853 int has_trace_option = 0;
9854 int has_pot_option = 0;
9855 int has_seqno_option = 0;
9856 int has_analyse_option = 0;
9859 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9861 if (unformat (input, "trace"))
9862 has_trace_option = 1;
9863 else if (unformat (input, "pot"))
9865 else if (unformat (input, "seqno"))
9866 has_seqno_option = 1;
9867 else if (unformat (input, "analyse"))
9868 has_analyse_option = 1;
9872 M (IOAM_ENABLE, mp);
9873 mp->id = htons (id);
9874 mp->seqno = has_seqno_option;
9875 mp->analyse = has_analyse_option;
9876 mp->pot_enable = has_pot_option;
9877 mp->trace_enable = has_trace_option;
9886 api_ioam_disable (vat_main_t * vam)
9888 vl_api_ioam_disable_t *mp;
9891 M (IOAM_DISABLE, mp);
9897 #define foreach_tcp_proto_field \
9901 #define foreach_udp_proto_field \
9905 #define foreach_ip4_proto_field \
9917 u16 src_port, dst_port;
9920 #if VPP_API_TEST_BUILTIN == 0
9922 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9924 u8 **maskp = va_arg (*args, u8 **);
9926 u8 found_something = 0;
9929 #define _(a) u8 a=0;
9930 foreach_tcp_proto_field;
9933 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9936 #define _(a) else if (unformat (input, #a)) a=1;
9937 foreach_tcp_proto_field
9943 #define _(a) found_something += a;
9944 foreach_tcp_proto_field;
9947 if (found_something == 0)
9950 vec_validate (mask, sizeof (*tcp) - 1);
9952 tcp = (tcp_header_t *) mask;
9954 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
9955 foreach_tcp_proto_field;
9963 unformat_udp_mask (unformat_input_t * input, va_list * args)
9965 u8 **maskp = va_arg (*args, u8 **);
9967 u8 found_something = 0;
9970 #define _(a) u8 a=0;
9971 foreach_udp_proto_field;
9974 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9977 #define _(a) else if (unformat (input, #a)) a=1;
9978 foreach_udp_proto_field
9984 #define _(a) found_something += a;
9985 foreach_udp_proto_field;
9988 if (found_something == 0)
9991 vec_validate (mask, sizeof (*udp) - 1);
9993 udp = (udp_header_t *) mask;
9995 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
9996 foreach_udp_proto_field;
10004 unformat_l4_mask (unformat_input_t * input, va_list * args)
10006 u8 **maskp = va_arg (*args, u8 **);
10007 u16 src_port = 0, dst_port = 0;
10008 tcpudp_header_t *tcpudp;
10010 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10012 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10014 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10016 else if (unformat (input, "src_port"))
10018 else if (unformat (input, "dst_port"))
10024 if (!src_port && !dst_port)
10028 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10030 tcpudp = (tcpudp_header_t *) mask;
10031 tcpudp->src_port = src_port;
10032 tcpudp->dst_port = dst_port;
10040 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10042 u8 **maskp = va_arg (*args, u8 **);
10044 u8 found_something = 0;
10047 #define _(a) u8 a=0;
10048 foreach_ip4_proto_field;
10054 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10056 if (unformat (input, "version"))
10058 else if (unformat (input, "hdr_length"))
10060 else if (unformat (input, "src"))
10062 else if (unformat (input, "dst"))
10064 else if (unformat (input, "proto"))
10067 #define _(a) else if (unformat (input, #a)) a=1;
10068 foreach_ip4_proto_field
10074 #define _(a) found_something += a;
10075 foreach_ip4_proto_field;
10078 if (found_something == 0)
10081 vec_validate (mask, sizeof (*ip) - 1);
10083 ip = (ip4_header_t *) mask;
10085 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10086 foreach_ip4_proto_field;
10089 ip->ip_version_and_header_length = 0;
10092 ip->ip_version_and_header_length |= 0xF0;
10095 ip->ip_version_and_header_length |= 0x0F;
10101 #define foreach_ip6_proto_field \
10104 _(payload_length) \
10109 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10111 u8 **maskp = va_arg (*args, u8 **);
10113 u8 found_something = 0;
10115 u32 ip_version_traffic_class_and_flow_label;
10117 #define _(a) u8 a=0;
10118 foreach_ip6_proto_field;
10121 u8 traffic_class = 0;
10124 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10126 if (unformat (input, "version"))
10128 else if (unformat (input, "traffic-class"))
10130 else if (unformat (input, "flow-label"))
10132 else if (unformat (input, "src"))
10134 else if (unformat (input, "dst"))
10136 else if (unformat (input, "proto"))
10139 #define _(a) else if (unformat (input, #a)) a=1;
10140 foreach_ip6_proto_field
10146 #define _(a) found_something += a;
10147 foreach_ip6_proto_field;
10150 if (found_something == 0)
10153 vec_validate (mask, sizeof (*ip) - 1);
10155 ip = (ip6_header_t *) mask;
10157 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10158 foreach_ip6_proto_field;
10161 ip_version_traffic_class_and_flow_label = 0;
10164 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10167 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10170 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10172 ip->ip_version_traffic_class_and_flow_label =
10173 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10180 unformat_l3_mask (unformat_input_t * input, va_list * args)
10182 u8 **maskp = va_arg (*args, u8 **);
10184 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10186 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10188 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10197 unformat_l2_mask (unformat_input_t * input, va_list * args)
10199 u8 **maskp = va_arg (*args, u8 **);
10206 u8 ignore_tag1 = 0;
10207 u8 ignore_tag2 = 0;
10214 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10216 if (unformat (input, "src"))
10218 else if (unformat (input, "dst"))
10220 else if (unformat (input, "proto"))
10222 else if (unformat (input, "tag1"))
10224 else if (unformat (input, "tag2"))
10226 else if (unformat (input, "ignore-tag1"))
10228 else if (unformat (input, "ignore-tag2"))
10230 else if (unformat (input, "cos1"))
10232 else if (unformat (input, "cos2"))
10234 else if (unformat (input, "dot1q"))
10236 else if (unformat (input, "dot1ad"))
10241 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10242 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10245 if (tag1 || ignore_tag1 || cos1 || dot1q)
10247 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10250 vec_validate (mask, len - 1);
10253 memset (mask, 0xff, 6);
10256 memset (mask + 6, 0xff, 6);
10258 if (tag2 || dot1ad)
10260 /* inner vlan tag */
10269 mask[21] = mask[20] = 0xff;
10290 mask[16] = mask[17] = 0xff;
10300 mask[12] = mask[13] = 0xff;
10307 unformat_classify_mask (unformat_input_t * input, va_list * args)
10309 u8 **maskp = va_arg (*args, u8 **);
10310 u32 *skipp = va_arg (*args, u32 *);
10311 u32 *matchp = va_arg (*args, u32 *);
10319 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10321 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10323 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10325 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10327 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10341 if (mask || l2 || l3 || l4)
10343 if (l2 || l3 || l4)
10345 /* "With a free Ethernet header in every package" */
10347 vec_validate (l2, 13);
10351 vec_append (mask, l3);
10356 vec_append (mask, l4);
10361 /* Scan forward looking for the first significant mask octet */
10362 for (i = 0; i < vec_len (mask); i++)
10366 /* compute (skip, match) params */
10367 *skipp = i / sizeof (u32x4);
10368 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10370 /* Pad mask to an even multiple of the vector size */
10371 while (vec_len (mask) % sizeof (u32x4))
10372 vec_add1 (mask, 0);
10374 match = vec_len (mask) / sizeof (u32x4);
10376 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10378 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10379 if (*tmp || *(tmp + 1))
10384 clib_warning ("BUG: match 0");
10386 _vec_len (mask) = match * sizeof (u32x4);
10396 #endif /* VPP_API_TEST_BUILTIN */
10398 #define foreach_l2_next \
10400 _(ethernet, ETHERNET_INPUT) \
10401 _(ip4, IP4_INPUT) \
10405 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10407 u32 *miss_next_indexp = va_arg (*args, u32 *);
10408 u32 next_index = 0;
10412 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10416 if (unformat (input, "%d", &tmp))
10425 *miss_next_indexp = next_index;
10429 #define foreach_ip_next \
10432 _(rewrite, REWRITE)
10435 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10437 u32 *miss_next_indexp = va_arg (*args, u32 *);
10438 u32 next_index = 0;
10442 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10446 if (unformat (input, "%d", &tmp))
10455 *miss_next_indexp = next_index;
10459 #define foreach_acl_next \
10463 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10465 u32 *miss_next_indexp = va_arg (*args, u32 *);
10466 u32 next_index = 0;
10470 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10474 if (unformat (input, "permit"))
10479 else if (unformat (input, "%d", &tmp))
10488 *miss_next_indexp = next_index;
10493 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10495 u32 *r = va_arg (*args, u32 *);
10497 if (unformat (input, "conform-color"))
10498 *r = POLICE_CONFORM;
10499 else if (unformat (input, "exceed-color"))
10500 *r = POLICE_EXCEED;
10508 api_classify_add_del_table (vat_main_t * vam)
10510 unformat_input_t *i = vam->input;
10511 vl_api_classify_add_del_table_t *mp;
10518 u32 table_index = ~0;
10519 u32 next_table_index = ~0;
10520 u32 miss_next_index = ~0;
10521 u32 memory_size = 32 << 20;
10523 u32 current_data_flag = 0;
10524 int current_data_offset = 0;
10527 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10529 if (unformat (i, "del"))
10531 else if (unformat (i, "del-chain"))
10536 else if (unformat (i, "buckets %d", &nbuckets))
10538 else if (unformat (i, "memory_size %d", &memory_size))
10540 else if (unformat (i, "skip %d", &skip))
10542 else if (unformat (i, "match %d", &match))
10544 else if (unformat (i, "table %d", &table_index))
10546 else if (unformat (i, "mask %U", unformat_classify_mask,
10547 &mask, &skip, &match))
10549 else if (unformat (i, "next-table %d", &next_table_index))
10551 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10554 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10557 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10560 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10562 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10568 if (is_add && mask == 0)
10570 errmsg ("Mask required");
10574 if (is_add && skip == ~0)
10576 errmsg ("skip count required");
10580 if (is_add && match == ~0)
10582 errmsg ("match count required");
10586 if (!is_add && table_index == ~0)
10588 errmsg ("table index required for delete");
10592 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10594 mp->is_add = is_add;
10595 mp->del_chain = del_chain;
10596 mp->table_index = ntohl (table_index);
10597 mp->nbuckets = ntohl (nbuckets);
10598 mp->memory_size = ntohl (memory_size);
10599 mp->skip_n_vectors = ntohl (skip);
10600 mp->match_n_vectors = ntohl (match);
10601 mp->next_table_index = ntohl (next_table_index);
10602 mp->miss_next_index = ntohl (miss_next_index);
10603 mp->current_data_flag = ntohl (current_data_flag);
10604 mp->current_data_offset = ntohl (current_data_offset);
10605 clib_memcpy (mp->mask, mask, vec_len (mask));
10614 #if VPP_API_TEST_BUILTIN == 0
10616 unformat_l4_match (unformat_input_t * input, va_list * args)
10618 u8 **matchp = va_arg (*args, u8 **);
10620 u8 *proto_header = 0;
10626 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10628 if (unformat (input, "src_port %d", &src_port))
10630 else if (unformat (input, "dst_port %d", &dst_port))
10636 h.src_port = clib_host_to_net_u16 (src_port);
10637 h.dst_port = clib_host_to_net_u16 (dst_port);
10638 vec_validate (proto_header, sizeof (h) - 1);
10639 memcpy (proto_header, &h, sizeof (h));
10641 *matchp = proto_header;
10647 unformat_ip4_match (unformat_input_t * input, va_list * args)
10649 u8 **matchp = va_arg (*args, u8 **);
10654 int hdr_length = 0;
10655 u32 hdr_length_val;
10656 int src = 0, dst = 0;
10657 ip4_address_t src_val, dst_val;
10664 int fragment_id = 0;
10665 u32 fragment_id_val;
10671 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10673 if (unformat (input, "version %d", &version_val))
10675 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10677 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10679 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10681 else if (unformat (input, "proto %d", &proto_val))
10683 else if (unformat (input, "tos %d", &tos_val))
10685 else if (unformat (input, "length %d", &length_val))
10687 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10689 else if (unformat (input, "ttl %d", &ttl_val))
10691 else if (unformat (input, "checksum %d", &checksum_val))
10697 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10698 + ttl + checksum == 0)
10702 * Aligned because we use the real comparison functions
10704 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10706 ip = (ip4_header_t *) match;
10708 /* These are realistically matched in practice */
10710 ip->src_address.as_u32 = src_val.as_u32;
10713 ip->dst_address.as_u32 = dst_val.as_u32;
10716 ip->protocol = proto_val;
10719 /* These are not, but they're included for completeness */
10721 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10724 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10730 ip->length = clib_host_to_net_u16 (length_val);
10736 ip->checksum = clib_host_to_net_u16 (checksum_val);
10743 unformat_ip6_match (unformat_input_t * input, va_list * args)
10745 u8 **matchp = va_arg (*args, u8 **);
10750 u8 traffic_class = 0;
10751 u32 traffic_class_val = 0;
10754 int src = 0, dst = 0;
10755 ip6_address_t src_val, dst_val;
10758 int payload_length = 0;
10759 u32 payload_length_val;
10762 u32 ip_version_traffic_class_and_flow_label;
10764 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10766 if (unformat (input, "version %d", &version_val))
10768 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10770 else if (unformat (input, "flow_label %d", &flow_label_val))
10772 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10774 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10776 else if (unformat (input, "proto %d", &proto_val))
10778 else if (unformat (input, "payload_length %d", &payload_length_val))
10779 payload_length = 1;
10780 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10786 if (version + traffic_class + flow_label + src + dst + proto +
10787 payload_length + hop_limit == 0)
10791 * Aligned because we use the real comparison functions
10793 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10795 ip = (ip6_header_t *) match;
10798 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10801 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10804 ip->protocol = proto_val;
10806 ip_version_traffic_class_and_flow_label = 0;
10809 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10812 ip_version_traffic_class_and_flow_label |=
10813 (traffic_class_val & 0xFF) << 20;
10816 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10818 ip->ip_version_traffic_class_and_flow_label =
10819 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10821 if (payload_length)
10822 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10825 ip->hop_limit = hop_limit_val;
10832 unformat_l3_match (unformat_input_t * input, va_list * args)
10834 u8 **matchp = va_arg (*args, u8 **);
10836 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10838 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10840 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10849 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10851 u8 *tagp = va_arg (*args, u8 *);
10854 if (unformat (input, "%d", &tag))
10856 tagp[0] = (tag >> 8) & 0x0F;
10857 tagp[1] = tag & 0xFF;
10865 unformat_l2_match (unformat_input_t * input, va_list * args)
10867 u8 **matchp = va_arg (*args, u8 **);
10880 u8 ignore_tag1 = 0;
10881 u8 ignore_tag2 = 0;
10887 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10889 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10892 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10894 else if (unformat (input, "proto %U",
10895 unformat_ethernet_type_host_byte_order, &proto_val))
10897 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10899 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10901 else if (unformat (input, "ignore-tag1"))
10903 else if (unformat (input, "ignore-tag2"))
10905 else if (unformat (input, "cos1 %d", &cos1_val))
10907 else if (unformat (input, "cos2 %d", &cos2_val))
10912 if ((src + dst + proto + tag1 + tag2 +
10913 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10916 if (tag1 || ignore_tag1 || cos1)
10918 if (tag2 || ignore_tag2 || cos2)
10921 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10924 clib_memcpy (match, dst_val, 6);
10927 clib_memcpy (match + 6, src_val, 6);
10931 /* inner vlan tag */
10932 match[19] = tag2_val[1];
10933 match[18] = tag2_val[0];
10935 match[18] |= (cos2_val & 0x7) << 5;
10938 match[21] = proto_val & 0xff;
10939 match[20] = proto_val >> 8;
10943 match[15] = tag1_val[1];
10944 match[14] = tag1_val[0];
10947 match[14] |= (cos1_val & 0x7) << 5;
10953 match[15] = tag1_val[1];
10954 match[14] = tag1_val[0];
10957 match[17] = proto_val & 0xff;
10958 match[16] = proto_val >> 8;
10961 match[14] |= (cos1_val & 0x7) << 5;
10967 match[18] |= (cos2_val & 0x7) << 5;
10969 match[14] |= (cos1_val & 0x7) << 5;
10972 match[13] = proto_val & 0xff;
10973 match[12] = proto_val >> 8;
10982 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10984 u8 **matchp = va_arg (*args, u8 **);
10985 u32 skip_n_vectors = va_arg (*args, u32);
10986 u32 match_n_vectors = va_arg (*args, u32);
10993 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10995 if (unformat (input, "hex %U", unformat_hex_string, &match))
10997 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10999 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11001 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11015 if (match || l2 || l3 || l4)
11017 if (l2 || l3 || l4)
11019 /* "Win a free Ethernet header in every packet" */
11021 vec_validate_aligned (l2, 13, sizeof (u32x4));
11025 vec_append_aligned (match, l3, sizeof (u32x4));
11030 vec_append_aligned (match, l4, sizeof (u32x4));
11035 /* Make sure the vector is big enough even if key is all 0's */
11036 vec_validate_aligned
11037 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11040 /* Set size, include skipped vectors */
11041 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11052 api_classify_add_del_session (vat_main_t * vam)
11054 unformat_input_t *i = vam->input;
11055 vl_api_classify_add_del_session_t *mp;
11057 u32 table_index = ~0;
11058 u32 hit_next_index = ~0;
11059 u32 opaque_index = ~0;
11062 u32 skip_n_vectors = 0;
11063 u32 match_n_vectors = 0;
11069 * Warning: you have to supply skip_n and match_n
11070 * because the API client cant simply look at the classify
11074 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11076 if (unformat (i, "del"))
11078 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11081 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11084 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11087 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11089 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11091 else if (unformat (i, "opaque-index %d", &opaque_index))
11093 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11095 else if (unformat (i, "match_n %d", &match_n_vectors))
11097 else if (unformat (i, "match %U", api_unformat_classify_match,
11098 &match, skip_n_vectors, match_n_vectors))
11100 else if (unformat (i, "advance %d", &advance))
11102 else if (unformat (i, "table-index %d", &table_index))
11104 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11106 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11108 else if (unformat (i, "action %d", &action))
11110 else if (unformat (i, "metadata %d", &metadata))
11116 if (table_index == ~0)
11118 errmsg ("Table index required");
11122 if (is_add && match == 0)
11124 errmsg ("Match value required");
11128 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11130 mp->is_add = is_add;
11131 mp->table_index = ntohl (table_index);
11132 mp->hit_next_index = ntohl (hit_next_index);
11133 mp->opaque_index = ntohl (opaque_index);
11134 mp->advance = ntohl (advance);
11135 mp->action = action;
11136 mp->metadata = ntohl (metadata);
11137 clib_memcpy (mp->match, match, vec_len (match));
11146 api_classify_set_interface_ip_table (vat_main_t * vam)
11148 unformat_input_t *i = vam->input;
11149 vl_api_classify_set_interface_ip_table_t *mp;
11151 int sw_if_index_set;
11152 u32 table_index = ~0;
11156 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11158 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11159 sw_if_index_set = 1;
11160 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11161 sw_if_index_set = 1;
11162 else if (unformat (i, "table %d", &table_index))
11166 clib_warning ("parse error '%U'", format_unformat_error, i);
11171 if (sw_if_index_set == 0)
11173 errmsg ("missing interface name or sw_if_index");
11178 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11180 mp->sw_if_index = ntohl (sw_if_index);
11181 mp->table_index = ntohl (table_index);
11182 mp->is_ipv6 = is_ipv6;
11190 api_classify_set_interface_l2_tables (vat_main_t * vam)
11192 unformat_input_t *i = vam->input;
11193 vl_api_classify_set_interface_l2_tables_t *mp;
11195 int sw_if_index_set;
11196 u32 ip4_table_index = ~0;
11197 u32 ip6_table_index = ~0;
11198 u32 other_table_index = ~0;
11202 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11204 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11205 sw_if_index_set = 1;
11206 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11207 sw_if_index_set = 1;
11208 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11210 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11212 else if (unformat (i, "other-table %d", &other_table_index))
11214 else if (unformat (i, "is-input %d", &is_input))
11218 clib_warning ("parse error '%U'", format_unformat_error, i);
11223 if (sw_if_index_set == 0)
11225 errmsg ("missing interface name or sw_if_index");
11230 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11232 mp->sw_if_index = ntohl (sw_if_index);
11233 mp->ip4_table_index = ntohl (ip4_table_index);
11234 mp->ip6_table_index = ntohl (ip6_table_index);
11235 mp->other_table_index = ntohl (other_table_index);
11236 mp->is_input = (u8) is_input;
11244 api_set_ipfix_exporter (vat_main_t * vam)
11246 unformat_input_t *i = vam->input;
11247 vl_api_set_ipfix_exporter_t *mp;
11248 ip4_address_t collector_address;
11249 u8 collector_address_set = 0;
11250 u32 collector_port = ~0;
11251 ip4_address_t src_address;
11252 u8 src_address_set = 0;
11255 u32 template_interval = ~0;
11256 u8 udp_checksum = 0;
11259 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11261 if (unformat (i, "collector_address %U", unformat_ip4_address,
11262 &collector_address))
11263 collector_address_set = 1;
11264 else if (unformat (i, "collector_port %d", &collector_port))
11266 else if (unformat (i, "src_address %U", unformat_ip4_address,
11268 src_address_set = 1;
11269 else if (unformat (i, "vrf_id %d", &vrf_id))
11271 else if (unformat (i, "path_mtu %d", &path_mtu))
11273 else if (unformat (i, "template_interval %d", &template_interval))
11275 else if (unformat (i, "udp_checksum"))
11281 if (collector_address_set == 0)
11283 errmsg ("collector_address required");
11287 if (src_address_set == 0)
11289 errmsg ("src_address required");
11293 M (SET_IPFIX_EXPORTER, mp);
11295 memcpy (mp->collector_address, collector_address.data,
11296 sizeof (collector_address.data));
11297 mp->collector_port = htons ((u16) collector_port);
11298 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11299 mp->vrf_id = htonl (vrf_id);
11300 mp->path_mtu = htonl (path_mtu);
11301 mp->template_interval = htonl (template_interval);
11302 mp->udp_checksum = udp_checksum;
11310 api_set_ipfix_classify_stream (vat_main_t * vam)
11312 unformat_input_t *i = vam->input;
11313 vl_api_set_ipfix_classify_stream_t *mp;
11315 u32 src_port = UDP_DST_PORT_ipfix;
11318 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11320 if (unformat (i, "domain %d", &domain_id))
11322 else if (unformat (i, "src_port %d", &src_port))
11326 errmsg ("unknown input `%U'", format_unformat_error, i);
11331 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11333 mp->domain_id = htonl (domain_id);
11334 mp->src_port = htons ((u16) src_port);
11342 api_ipfix_classify_table_add_del (vat_main_t * vam)
11344 unformat_input_t *i = vam->input;
11345 vl_api_ipfix_classify_table_add_del_t *mp;
11347 u32 classify_table_index = ~0;
11349 u8 transport_protocol = 255;
11352 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11354 if (unformat (i, "add"))
11356 else if (unformat (i, "del"))
11358 else if (unformat (i, "table %d", &classify_table_index))
11360 else if (unformat (i, "ip4"))
11362 else if (unformat (i, "ip6"))
11364 else if (unformat (i, "tcp"))
11365 transport_protocol = 6;
11366 else if (unformat (i, "udp"))
11367 transport_protocol = 17;
11370 errmsg ("unknown input `%U'", format_unformat_error, i);
11377 errmsg ("expecting: add|del");
11380 if (classify_table_index == ~0)
11382 errmsg ("classifier table not specified");
11385 if (ip_version == 0)
11387 errmsg ("IP version not specified");
11391 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11393 mp->is_add = is_add;
11394 mp->table_id = htonl (classify_table_index);
11395 mp->ip_version = ip_version;
11396 mp->transport_protocol = transport_protocol;
11404 api_get_node_index (vat_main_t * vam)
11406 unformat_input_t *i = vam->input;
11407 vl_api_get_node_index_t *mp;
11411 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11413 if (unformat (i, "node %s", &name))
11420 errmsg ("node name required");
11423 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11425 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11429 M (GET_NODE_INDEX, mp);
11430 clib_memcpy (mp->node_name, name, vec_len (name));
11439 api_get_next_index (vat_main_t * vam)
11441 unformat_input_t *i = vam->input;
11442 vl_api_get_next_index_t *mp;
11443 u8 *node_name = 0, *next_node_name = 0;
11446 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11448 if (unformat (i, "node-name %s", &node_name))
11450 else if (unformat (i, "next-node-name %s", &next_node_name))
11454 if (node_name == 0)
11456 errmsg ("node name required");
11459 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11461 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11465 if (next_node_name == 0)
11467 errmsg ("next node name required");
11470 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11472 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11476 M (GET_NEXT_INDEX, mp);
11477 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11478 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11479 vec_free (node_name);
11480 vec_free (next_node_name);
11488 api_add_node_next (vat_main_t * vam)
11490 unformat_input_t *i = vam->input;
11491 vl_api_add_node_next_t *mp;
11496 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11498 if (unformat (i, "node %s", &name))
11500 else if (unformat (i, "next %s", &next))
11507 errmsg ("node name required");
11510 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11512 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11517 errmsg ("next node required");
11520 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11522 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11526 M (ADD_NODE_NEXT, mp);
11527 clib_memcpy (mp->node_name, name, vec_len (name));
11528 clib_memcpy (mp->next_name, next, vec_len (next));
11538 api_l2tpv3_create_tunnel (vat_main_t * vam)
11540 unformat_input_t *i = vam->input;
11541 ip6_address_t client_address, our_address;
11542 int client_address_set = 0;
11543 int our_address_set = 0;
11544 u32 local_session_id = 0;
11545 u32 remote_session_id = 0;
11546 u64 local_cookie = 0;
11547 u64 remote_cookie = 0;
11548 u8 l2_sublayer_present = 0;
11549 vl_api_l2tpv3_create_tunnel_t *mp;
11552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11554 if (unformat (i, "client_address %U", unformat_ip6_address,
11556 client_address_set = 1;
11557 else if (unformat (i, "our_address %U", unformat_ip6_address,
11559 our_address_set = 1;
11560 else if (unformat (i, "local_session_id %d", &local_session_id))
11562 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11564 else if (unformat (i, "local_cookie %lld", &local_cookie))
11566 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11568 else if (unformat (i, "l2-sublayer-present"))
11569 l2_sublayer_present = 1;
11574 if (client_address_set == 0)
11576 errmsg ("client_address required");
11580 if (our_address_set == 0)
11582 errmsg ("our_address required");
11586 M (L2TPV3_CREATE_TUNNEL, mp);
11588 clib_memcpy (mp->client_address, client_address.as_u8,
11589 sizeof (mp->client_address));
11591 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11593 mp->local_session_id = ntohl (local_session_id);
11594 mp->remote_session_id = ntohl (remote_session_id);
11595 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11596 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11597 mp->l2_sublayer_present = l2_sublayer_present;
11606 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11608 unformat_input_t *i = vam->input;
11610 u8 sw_if_index_set = 0;
11611 u64 new_local_cookie = 0;
11612 u64 new_remote_cookie = 0;
11613 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11616 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11618 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11619 sw_if_index_set = 1;
11620 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11621 sw_if_index_set = 1;
11622 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11624 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11630 if (sw_if_index_set == 0)
11632 errmsg ("missing interface name or sw_if_index");
11636 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11638 mp->sw_if_index = ntohl (sw_if_index);
11639 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11640 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11648 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11650 unformat_input_t *i = vam->input;
11651 vl_api_l2tpv3_interface_enable_disable_t *mp;
11653 u8 sw_if_index_set = 0;
11654 u8 enable_disable = 1;
11657 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11659 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11660 sw_if_index_set = 1;
11661 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11662 sw_if_index_set = 1;
11663 else if (unformat (i, "enable"))
11664 enable_disable = 1;
11665 else if (unformat (i, "disable"))
11666 enable_disable = 0;
11671 if (sw_if_index_set == 0)
11673 errmsg ("missing interface name or sw_if_index");
11677 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11679 mp->sw_if_index = ntohl (sw_if_index);
11680 mp->enable_disable = enable_disable;
11688 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11690 unformat_input_t *i = vam->input;
11691 vl_api_l2tpv3_set_lookup_key_t *mp;
11695 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11697 if (unformat (i, "lookup_v6_src"))
11698 key = L2T_LOOKUP_SRC_ADDRESS;
11699 else if (unformat (i, "lookup_v6_dst"))
11700 key = L2T_LOOKUP_DST_ADDRESS;
11701 else if (unformat (i, "lookup_session_id"))
11702 key = L2T_LOOKUP_SESSION_ID;
11707 if (key == (u8) ~ 0)
11709 errmsg ("l2tp session lookup key unset");
11713 M (L2TPV3_SET_LOOKUP_KEY, mp);
11722 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11723 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11725 vat_main_t *vam = &vat_main;
11727 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11728 format_ip6_address, mp->our_address,
11729 format_ip6_address, mp->client_address,
11730 clib_net_to_host_u32 (mp->sw_if_index));
11733 " local cookies %016llx %016llx remote cookie %016llx",
11734 clib_net_to_host_u64 (mp->local_cookie[0]),
11735 clib_net_to_host_u64 (mp->local_cookie[1]),
11736 clib_net_to_host_u64 (mp->remote_cookie));
11738 print (vam->ofp, " local session-id %d remote session-id %d",
11739 clib_net_to_host_u32 (mp->local_session_id),
11740 clib_net_to_host_u32 (mp->remote_session_id));
11742 print (vam->ofp, " l2 specific sublayer %s\n",
11743 mp->l2_sublayer_present ? "preset" : "absent");
11747 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11748 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11750 vat_main_t *vam = &vat_main;
11751 vat_json_node_t *node = NULL;
11752 struct in6_addr addr;
11754 if (VAT_JSON_ARRAY != vam->json_tree.type)
11756 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11757 vat_json_init_array (&vam->json_tree);
11759 node = vat_json_array_add (&vam->json_tree);
11761 vat_json_init_object (node);
11763 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11764 vat_json_object_add_ip6 (node, "our_address", addr);
11765 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11766 vat_json_object_add_ip6 (node, "client_address", addr);
11768 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11769 vat_json_init_array (lc);
11770 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11771 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11772 vat_json_object_add_uint (node, "remote_cookie",
11773 clib_net_to_host_u64 (mp->remote_cookie));
11775 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11776 vat_json_object_add_uint (node, "local_session_id",
11777 clib_net_to_host_u32 (mp->local_session_id));
11778 vat_json_object_add_uint (node, "remote_session_id",
11779 clib_net_to_host_u32 (mp->remote_session_id));
11780 vat_json_object_add_string_copy (node, "l2_sublayer",
11781 mp->l2_sublayer_present ? (u8 *) "present"
11782 : (u8 *) "absent");
11786 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11788 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11789 vl_api_control_ping_t *mp_ping;
11792 /* Get list of l2tpv3-tunnel interfaces */
11793 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11796 /* Use a control ping for synchronization */
11797 MPING (CONTROL_PING, mp_ping);
11805 static void vl_api_sw_interface_tap_details_t_handler
11806 (vl_api_sw_interface_tap_details_t * mp)
11808 vat_main_t *vam = &vat_main;
11810 print (vam->ofp, "%-16s %d",
11811 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
11814 static void vl_api_sw_interface_tap_details_t_handler_json
11815 (vl_api_sw_interface_tap_details_t * mp)
11817 vat_main_t *vam = &vat_main;
11818 vat_json_node_t *node = NULL;
11820 if (VAT_JSON_ARRAY != vam->json_tree.type)
11822 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11823 vat_json_init_array (&vam->json_tree);
11825 node = vat_json_array_add (&vam->json_tree);
11827 vat_json_init_object (node);
11828 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11829 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11833 api_sw_interface_tap_dump (vat_main_t * vam)
11835 vl_api_sw_interface_tap_dump_t *mp;
11836 vl_api_control_ping_t *mp_ping;
11839 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
11840 /* Get list of tap interfaces */
11841 M (SW_INTERFACE_TAP_DUMP, mp);
11844 /* Use a control ping for synchronization */
11845 MPING (CONTROL_PING, mp_ping);
11852 static uword unformat_vxlan_decap_next
11853 (unformat_input_t * input, va_list * args)
11855 u32 *result = va_arg (*args, u32 *);
11858 if (unformat (input, "l2"))
11859 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11860 else if (unformat (input, "%d", &tmp))
11868 api_vxlan_add_del_tunnel (vat_main_t * vam)
11870 unformat_input_t *line_input = vam->input;
11871 vl_api_vxlan_add_del_tunnel_t *mp;
11872 ip46_address_t src, dst;
11874 u8 ipv4_set = 0, ipv6_set = 0;
11878 u32 mcast_sw_if_index = ~0;
11879 u32 encap_vrf_id = 0;
11880 u32 decap_next_index = ~0;
11884 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11885 memset (&src, 0, sizeof src);
11886 memset (&dst, 0, sizeof dst);
11888 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11890 if (unformat (line_input, "del"))
11893 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11899 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11905 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11911 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11916 else if (unformat (line_input, "group %U %U",
11917 unformat_ip4_address, &dst.ip4,
11918 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11920 grp_set = dst_set = 1;
11923 else if (unformat (line_input, "group %U",
11924 unformat_ip4_address, &dst.ip4))
11926 grp_set = dst_set = 1;
11929 else if (unformat (line_input, "group %U %U",
11930 unformat_ip6_address, &dst.ip6,
11931 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11933 grp_set = dst_set = 1;
11936 else if (unformat (line_input, "group %U",
11937 unformat_ip6_address, &dst.ip6))
11939 grp_set = dst_set = 1;
11943 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11945 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11947 else if (unformat (line_input, "decap-next %U",
11948 unformat_vxlan_decap_next, &decap_next_index))
11950 else if (unformat (line_input, "vni %d", &vni))
11954 errmsg ("parse error '%U'", format_unformat_error, line_input);
11961 errmsg ("tunnel src address not specified");
11966 errmsg ("tunnel dst address not specified");
11970 if (grp_set && !ip46_address_is_multicast (&dst))
11972 errmsg ("tunnel group address not multicast");
11975 if (grp_set && mcast_sw_if_index == ~0)
11977 errmsg ("tunnel nonexistent multicast device");
11980 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11982 errmsg ("tunnel dst address must be unicast");
11987 if (ipv4_set && ipv6_set)
11989 errmsg ("both IPv4 and IPv6 addresses specified");
11993 if ((vni == 0) || (vni >> 24))
11995 errmsg ("vni not specified or out of range");
11999 M (VXLAN_ADD_DEL_TUNNEL, mp);
12003 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12004 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12008 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12009 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12011 mp->encap_vrf_id = ntohl (encap_vrf_id);
12012 mp->decap_next_index = ntohl (decap_next_index);
12013 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12014 mp->vni = ntohl (vni);
12015 mp->is_add = is_add;
12016 mp->is_ipv6 = ipv6_set;
12023 static void vl_api_vxlan_tunnel_details_t_handler
12024 (vl_api_vxlan_tunnel_details_t * mp)
12026 vat_main_t *vam = &vat_main;
12027 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12028 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12030 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12031 ntohl (mp->sw_if_index),
12032 format_ip46_address, &src, IP46_TYPE_ANY,
12033 format_ip46_address, &dst, IP46_TYPE_ANY,
12034 ntohl (mp->encap_vrf_id),
12035 ntohl (mp->decap_next_index), ntohl (mp->vni),
12036 ntohl (mp->mcast_sw_if_index));
12039 static void vl_api_vxlan_tunnel_details_t_handler_json
12040 (vl_api_vxlan_tunnel_details_t * mp)
12042 vat_main_t *vam = &vat_main;
12043 vat_json_node_t *node = NULL;
12045 if (VAT_JSON_ARRAY != vam->json_tree.type)
12047 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12048 vat_json_init_array (&vam->json_tree);
12050 node = vat_json_array_add (&vam->json_tree);
12052 vat_json_init_object (node);
12053 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12056 struct in6_addr ip6;
12058 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12059 vat_json_object_add_ip6 (node, "src_address", ip6);
12060 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12061 vat_json_object_add_ip6 (node, "dst_address", ip6);
12065 struct in_addr ip4;
12067 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12068 vat_json_object_add_ip4 (node, "src_address", ip4);
12069 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12070 vat_json_object_add_ip4 (node, "dst_address", ip4);
12072 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12073 vat_json_object_add_uint (node, "decap_next_index",
12074 ntohl (mp->decap_next_index));
12075 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12076 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12077 vat_json_object_add_uint (node, "mcast_sw_if_index",
12078 ntohl (mp->mcast_sw_if_index));
12082 api_vxlan_tunnel_dump (vat_main_t * vam)
12084 unformat_input_t *i = vam->input;
12085 vl_api_vxlan_tunnel_dump_t *mp;
12086 vl_api_control_ping_t *mp_ping;
12088 u8 sw_if_index_set = 0;
12091 /* Parse args required to build the message */
12092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12094 if (unformat (i, "sw_if_index %d", &sw_if_index))
12095 sw_if_index_set = 1;
12100 if (sw_if_index_set == 0)
12105 if (!vam->json_output)
12107 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12108 "sw_if_index", "src_address", "dst_address",
12109 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12112 /* Get list of vxlan-tunnel interfaces */
12113 M (VXLAN_TUNNEL_DUMP, mp);
12115 mp->sw_if_index = htonl (sw_if_index);
12119 /* Use a control ping for synchronization */
12120 MPING (CONTROL_PING, mp_ping);
12127 static uword unformat_geneve_decap_next
12128 (unformat_input_t * input, va_list * args)
12130 u32 *result = va_arg (*args, u32 *);
12133 if (unformat (input, "l2"))
12134 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12135 else if (unformat (input, "%d", &tmp))
12143 api_geneve_add_del_tunnel (vat_main_t * vam)
12145 unformat_input_t *line_input = vam->input;
12146 vl_api_geneve_add_del_tunnel_t *mp;
12147 ip46_address_t src, dst;
12149 u8 ipv4_set = 0, ipv6_set = 0;
12153 u32 mcast_sw_if_index = ~0;
12154 u32 encap_vrf_id = 0;
12155 u32 decap_next_index = ~0;
12159 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12160 memset (&src, 0, sizeof src);
12161 memset (&dst, 0, sizeof dst);
12163 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12165 if (unformat (line_input, "del"))
12168 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12174 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12180 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12186 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12191 else if (unformat (line_input, "group %U %U",
12192 unformat_ip4_address, &dst.ip4,
12193 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12195 grp_set = dst_set = 1;
12198 else if (unformat (line_input, "group %U",
12199 unformat_ip4_address, &dst.ip4))
12201 grp_set = dst_set = 1;
12204 else if (unformat (line_input, "group %U %U",
12205 unformat_ip6_address, &dst.ip6,
12206 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12208 grp_set = dst_set = 1;
12211 else if (unformat (line_input, "group %U",
12212 unformat_ip6_address, &dst.ip6))
12214 grp_set = dst_set = 1;
12218 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12220 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12222 else if (unformat (line_input, "decap-next %U",
12223 unformat_geneve_decap_next, &decap_next_index))
12225 else if (unformat (line_input, "vni %d", &vni))
12229 errmsg ("parse error '%U'", format_unformat_error, line_input);
12236 errmsg ("tunnel src address not specified");
12241 errmsg ("tunnel dst address not specified");
12245 if (grp_set && !ip46_address_is_multicast (&dst))
12247 errmsg ("tunnel group address not multicast");
12250 if (grp_set && mcast_sw_if_index == ~0)
12252 errmsg ("tunnel nonexistent multicast device");
12255 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12257 errmsg ("tunnel dst address must be unicast");
12262 if (ipv4_set && ipv6_set)
12264 errmsg ("both IPv4 and IPv6 addresses specified");
12268 if ((vni == 0) || (vni >> 24))
12270 errmsg ("vni not specified or out of range");
12274 M (GENEVE_ADD_DEL_TUNNEL, mp);
12278 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12279 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12283 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12284 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12286 mp->encap_vrf_id = ntohl (encap_vrf_id);
12287 mp->decap_next_index = ntohl (decap_next_index);
12288 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12289 mp->vni = ntohl (vni);
12290 mp->is_add = is_add;
12291 mp->is_ipv6 = ipv6_set;
12298 static void vl_api_geneve_tunnel_details_t_handler
12299 (vl_api_geneve_tunnel_details_t * mp)
12301 vat_main_t *vam = &vat_main;
12302 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12303 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12305 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12306 ntohl (mp->sw_if_index),
12307 format_ip46_address, &src, IP46_TYPE_ANY,
12308 format_ip46_address, &dst, IP46_TYPE_ANY,
12309 ntohl (mp->encap_vrf_id),
12310 ntohl (mp->decap_next_index), ntohl (mp->vni),
12311 ntohl (mp->mcast_sw_if_index));
12314 static void vl_api_geneve_tunnel_details_t_handler_json
12315 (vl_api_geneve_tunnel_details_t * mp)
12317 vat_main_t *vam = &vat_main;
12318 vat_json_node_t *node = NULL;
12320 if (VAT_JSON_ARRAY != vam->json_tree.type)
12322 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12323 vat_json_init_array (&vam->json_tree);
12325 node = vat_json_array_add (&vam->json_tree);
12327 vat_json_init_object (node);
12328 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12331 struct in6_addr ip6;
12333 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12334 vat_json_object_add_ip6 (node, "src_address", ip6);
12335 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12336 vat_json_object_add_ip6 (node, "dst_address", ip6);
12340 struct in_addr ip4;
12342 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12343 vat_json_object_add_ip4 (node, "src_address", ip4);
12344 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12345 vat_json_object_add_ip4 (node, "dst_address", ip4);
12347 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12348 vat_json_object_add_uint (node, "decap_next_index",
12349 ntohl (mp->decap_next_index));
12350 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12351 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12352 vat_json_object_add_uint (node, "mcast_sw_if_index",
12353 ntohl (mp->mcast_sw_if_index));
12357 api_geneve_tunnel_dump (vat_main_t * vam)
12359 unformat_input_t *i = vam->input;
12360 vl_api_geneve_tunnel_dump_t *mp;
12361 vl_api_control_ping_t *mp_ping;
12363 u8 sw_if_index_set = 0;
12366 /* Parse args required to build the message */
12367 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12369 if (unformat (i, "sw_if_index %d", &sw_if_index))
12370 sw_if_index_set = 1;
12375 if (sw_if_index_set == 0)
12380 if (!vam->json_output)
12382 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12383 "sw_if_index", "local_address", "remote_address",
12384 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12387 /* Get list of geneve-tunnel interfaces */
12388 M (GENEVE_TUNNEL_DUMP, mp);
12390 mp->sw_if_index = htonl (sw_if_index);
12394 /* Use a control ping for synchronization */
12395 M (CONTROL_PING, mp_ping);
12403 api_gre_add_del_tunnel (vat_main_t * vam)
12405 unformat_input_t *line_input = vam->input;
12406 vl_api_gre_add_del_tunnel_t *mp;
12407 ip4_address_t src4, dst4;
12408 ip6_address_t src6, dst6;
12415 u32 outer_fib_id = 0;
12418 memset (&src4, 0, sizeof src4);
12419 memset (&dst4, 0, sizeof dst4);
12420 memset (&src6, 0, sizeof src6);
12421 memset (&dst6, 0, sizeof dst6);
12423 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12425 if (unformat (line_input, "del"))
12427 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
12432 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
12437 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
12442 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
12447 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12449 else if (unformat (line_input, "teb"))
12453 errmsg ("parse error '%U'", format_unformat_error, line_input);
12460 errmsg ("tunnel src address not specified");
12465 errmsg ("tunnel dst address not specified");
12468 if (ipv4_set && ipv6_set)
12470 errmsg ("both IPv4 and IPv6 addresses specified");
12475 M (GRE_ADD_DEL_TUNNEL, mp);
12479 clib_memcpy (&mp->src_address, &src4, 4);
12480 clib_memcpy (&mp->dst_address, &dst4, 4);
12484 clib_memcpy (&mp->src_address, &src6, 16);
12485 clib_memcpy (&mp->dst_address, &dst6, 16);
12487 mp->outer_fib_id = ntohl (outer_fib_id);
12488 mp->is_add = is_add;
12490 mp->is_ipv6 = ipv6_set;
12497 static void vl_api_gre_tunnel_details_t_handler
12498 (vl_api_gre_tunnel_details_t * mp)
12500 vat_main_t *vam = &vat_main;
12501 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
12502 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
12504 print (vam->ofp, "%11d%24U%24U%6d%14d",
12505 ntohl (mp->sw_if_index),
12506 format_ip46_address, &src, IP46_TYPE_ANY,
12507 format_ip46_address, &dst, IP46_TYPE_ANY,
12508 mp->teb, ntohl (mp->outer_fib_id));
12511 static void vl_api_gre_tunnel_details_t_handler_json
12512 (vl_api_gre_tunnel_details_t * mp)
12514 vat_main_t *vam = &vat_main;
12515 vat_json_node_t *node = NULL;
12516 struct in_addr ip4;
12517 struct in6_addr ip6;
12519 if (VAT_JSON_ARRAY != vam->json_tree.type)
12521 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12522 vat_json_init_array (&vam->json_tree);
12524 node = vat_json_array_add (&vam->json_tree);
12526 vat_json_init_object (node);
12527 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12530 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
12531 vat_json_object_add_ip4 (node, "src_address", ip4);
12532 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
12533 vat_json_object_add_ip4 (node, "dst_address", ip4);
12537 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
12538 vat_json_object_add_ip6 (node, "src_address", ip6);
12539 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
12540 vat_json_object_add_ip6 (node, "dst_address", ip6);
12542 vat_json_object_add_uint (node, "teb", mp->teb);
12543 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
12544 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
12548 api_gre_tunnel_dump (vat_main_t * vam)
12550 unformat_input_t *i = vam->input;
12551 vl_api_gre_tunnel_dump_t *mp;
12552 vl_api_control_ping_t *mp_ping;
12554 u8 sw_if_index_set = 0;
12557 /* Parse args required to build the message */
12558 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12560 if (unformat (i, "sw_if_index %d", &sw_if_index))
12561 sw_if_index_set = 1;
12566 if (sw_if_index_set == 0)
12571 if (!vam->json_output)
12573 print (vam->ofp, "%11s%24s%24s%6s%14s",
12574 "sw_if_index", "src_address", "dst_address", "teb",
12578 /* Get list of gre-tunnel interfaces */
12579 M (GRE_TUNNEL_DUMP, mp);
12581 mp->sw_if_index = htonl (sw_if_index);
12585 /* Use a control ping for synchronization */
12586 MPING (CONTROL_PING, mp_ping);
12594 api_l2_fib_clear_table (vat_main_t * vam)
12596 // unformat_input_t * i = vam->input;
12597 vl_api_l2_fib_clear_table_t *mp;
12600 M (L2_FIB_CLEAR_TABLE, mp);
12608 api_l2_interface_efp_filter (vat_main_t * vam)
12610 unformat_input_t *i = vam->input;
12611 vl_api_l2_interface_efp_filter_t *mp;
12614 u8 sw_if_index_set = 0;
12617 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12619 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12620 sw_if_index_set = 1;
12621 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12622 sw_if_index_set = 1;
12623 else if (unformat (i, "enable"))
12625 else if (unformat (i, "disable"))
12629 clib_warning ("parse error '%U'", format_unformat_error, i);
12634 if (sw_if_index_set == 0)
12636 errmsg ("missing sw_if_index");
12640 M (L2_INTERFACE_EFP_FILTER, mp);
12642 mp->sw_if_index = ntohl (sw_if_index);
12643 mp->enable_disable = enable;
12650 #define foreach_vtr_op \
12651 _("disable", L2_VTR_DISABLED) \
12652 _("push-1", L2_VTR_PUSH_1) \
12653 _("push-2", L2_VTR_PUSH_2) \
12654 _("pop-1", L2_VTR_POP_1) \
12655 _("pop-2", L2_VTR_POP_2) \
12656 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12657 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12658 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12659 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12662 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12664 unformat_input_t *i = vam->input;
12665 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12667 u8 sw_if_index_set = 0;
12670 u32 push_dot1q = 1;
12675 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12677 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12678 sw_if_index_set = 1;
12679 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12680 sw_if_index_set = 1;
12681 else if (unformat (i, "vtr_op %d", &vtr_op))
12683 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12686 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12688 else if (unformat (i, "tag1 %d", &tag1))
12690 else if (unformat (i, "tag2 %d", &tag2))
12694 clib_warning ("parse error '%U'", format_unformat_error, i);
12699 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12701 errmsg ("missing vtr operation or sw_if_index");
12705 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12706 mp->sw_if_index = ntohl (sw_if_index);
12707 mp->vtr_op = ntohl (vtr_op);
12708 mp->push_dot1q = ntohl (push_dot1q);
12709 mp->tag1 = ntohl (tag1);
12710 mp->tag2 = ntohl (tag2);
12718 api_create_vhost_user_if (vat_main_t * vam)
12720 unformat_input_t *i = vam->input;
12721 vl_api_create_vhost_user_if_t *mp;
12724 u8 file_name_set = 0;
12725 u32 custom_dev_instance = ~0;
12727 u8 use_custom_mac = 0;
12731 /* Shut up coverity */
12732 memset (hwaddr, 0, sizeof (hwaddr));
12734 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12736 if (unformat (i, "socket %s", &file_name))
12740 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12742 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12743 use_custom_mac = 1;
12744 else if (unformat (i, "server"))
12746 else if (unformat (i, "tag %s", &tag))
12752 if (file_name_set == 0)
12754 errmsg ("missing socket file name");
12758 if (vec_len (file_name) > 255)
12760 errmsg ("socket file name too long");
12763 vec_add1 (file_name, 0);
12765 M (CREATE_VHOST_USER_IF, mp);
12767 mp->is_server = is_server;
12768 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12769 vec_free (file_name);
12770 if (custom_dev_instance != ~0)
12773 mp->custom_dev_instance = ntohl (custom_dev_instance);
12775 mp->use_custom_mac = use_custom_mac;
12776 clib_memcpy (mp->mac_address, hwaddr, 6);
12778 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12787 api_modify_vhost_user_if (vat_main_t * vam)
12789 unformat_input_t *i = vam->input;
12790 vl_api_modify_vhost_user_if_t *mp;
12793 u8 file_name_set = 0;
12794 u32 custom_dev_instance = ~0;
12795 u8 sw_if_index_set = 0;
12796 u32 sw_if_index = (u32) ~ 0;
12799 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12801 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12802 sw_if_index_set = 1;
12803 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12804 sw_if_index_set = 1;
12805 else if (unformat (i, "socket %s", &file_name))
12809 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12811 else if (unformat (i, "server"))
12817 if (sw_if_index_set == 0)
12819 errmsg ("missing sw_if_index or interface name");
12823 if (file_name_set == 0)
12825 errmsg ("missing socket file name");
12829 if (vec_len (file_name) > 255)
12831 errmsg ("socket file name too long");
12834 vec_add1 (file_name, 0);
12836 M (MODIFY_VHOST_USER_IF, mp);
12838 mp->sw_if_index = ntohl (sw_if_index);
12839 mp->is_server = is_server;
12840 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12841 vec_free (file_name);
12842 if (custom_dev_instance != ~0)
12845 mp->custom_dev_instance = ntohl (custom_dev_instance);
12854 api_delete_vhost_user_if (vat_main_t * vam)
12856 unformat_input_t *i = vam->input;
12857 vl_api_delete_vhost_user_if_t *mp;
12858 u32 sw_if_index = ~0;
12859 u8 sw_if_index_set = 0;
12862 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12864 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12865 sw_if_index_set = 1;
12866 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12867 sw_if_index_set = 1;
12872 if (sw_if_index_set == 0)
12874 errmsg ("missing sw_if_index or interface name");
12879 M (DELETE_VHOST_USER_IF, mp);
12881 mp->sw_if_index = ntohl (sw_if_index);
12888 static void vl_api_sw_interface_vhost_user_details_t_handler
12889 (vl_api_sw_interface_vhost_user_details_t * mp)
12891 vat_main_t *vam = &vat_main;
12893 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12894 (char *) mp->interface_name,
12895 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12896 clib_net_to_host_u64 (mp->features), mp->is_server,
12897 ntohl (mp->num_regions), (char *) mp->sock_filename);
12898 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12901 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12902 (vl_api_sw_interface_vhost_user_details_t * mp)
12904 vat_main_t *vam = &vat_main;
12905 vat_json_node_t *node = NULL;
12907 if (VAT_JSON_ARRAY != vam->json_tree.type)
12909 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12910 vat_json_init_array (&vam->json_tree);
12912 node = vat_json_array_add (&vam->json_tree);
12914 vat_json_init_object (node);
12915 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12916 vat_json_object_add_string_copy (node, "interface_name",
12917 mp->interface_name);
12918 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12919 ntohl (mp->virtio_net_hdr_sz));
12920 vat_json_object_add_uint (node, "features",
12921 clib_net_to_host_u64 (mp->features));
12922 vat_json_object_add_uint (node, "is_server", mp->is_server);
12923 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12924 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12925 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12929 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12931 vl_api_sw_interface_vhost_user_dump_t *mp;
12932 vl_api_control_ping_t *mp_ping;
12935 "Interface name idx hdr_sz features server regions filename");
12937 /* Get list of vhost-user interfaces */
12938 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12941 /* Use a control ping for synchronization */
12942 MPING (CONTROL_PING, mp_ping);
12950 api_show_version (vat_main_t * vam)
12952 vl_api_show_version_t *mp;
12955 M (SHOW_VERSION, mp);
12964 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12966 unformat_input_t *line_input = vam->input;
12967 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12968 ip4_address_t local4, remote4;
12969 ip6_address_t local6, remote6;
12971 u8 ipv4_set = 0, ipv6_set = 0;
12975 u32 mcast_sw_if_index = ~0;
12976 u32 encap_vrf_id = 0;
12977 u32 decap_vrf_id = 0;
12983 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12984 memset (&local4, 0, sizeof local4);
12985 memset (&remote4, 0, sizeof remote4);
12986 memset (&local6, 0, sizeof local6);
12987 memset (&remote6, 0, sizeof remote6);
12989 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12991 if (unformat (line_input, "del"))
12993 else if (unformat (line_input, "local %U",
12994 unformat_ip4_address, &local4))
12999 else if (unformat (line_input, "remote %U",
13000 unformat_ip4_address, &remote4))
13005 else if (unformat (line_input, "local %U",
13006 unformat_ip6_address, &local6))
13011 else if (unformat (line_input, "remote %U",
13012 unformat_ip6_address, &remote6))
13017 else if (unformat (line_input, "group %U %U",
13018 unformat_ip4_address, &remote4,
13019 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13021 grp_set = remote_set = 1;
13024 else if (unformat (line_input, "group %U",
13025 unformat_ip4_address, &remote4))
13027 grp_set = remote_set = 1;
13030 else if (unformat (line_input, "group %U %U",
13031 unformat_ip6_address, &remote6,
13032 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13034 grp_set = remote_set = 1;
13037 else if (unformat (line_input, "group %U",
13038 unformat_ip6_address, &remote6))
13040 grp_set = remote_set = 1;
13044 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13046 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13048 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13050 else if (unformat (line_input, "vni %d", &vni))
13052 else if (unformat (line_input, "next-ip4"))
13054 else if (unformat (line_input, "next-ip6"))
13056 else if (unformat (line_input, "next-ethernet"))
13058 else if (unformat (line_input, "next-nsh"))
13062 errmsg ("parse error '%U'", format_unformat_error, line_input);
13067 if (local_set == 0)
13069 errmsg ("tunnel local address not specified");
13072 if (remote_set == 0)
13074 errmsg ("tunnel remote address not specified");
13077 if (grp_set && mcast_sw_if_index == ~0)
13079 errmsg ("tunnel nonexistent multicast device");
13082 if (ipv4_set && ipv6_set)
13084 errmsg ("both IPv4 and IPv6 addresses specified");
13090 errmsg ("vni not specified");
13094 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13099 clib_memcpy (&mp->local, &local6, sizeof (local6));
13100 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13104 clib_memcpy (&mp->local, &local4, sizeof (local4));
13105 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13108 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13109 mp->encap_vrf_id = ntohl (encap_vrf_id);
13110 mp->decap_vrf_id = ntohl (decap_vrf_id);
13111 mp->protocol = protocol;
13112 mp->vni = ntohl (vni);
13113 mp->is_add = is_add;
13114 mp->is_ipv6 = ipv6_set;
13121 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13122 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13124 vat_main_t *vam = &vat_main;
13125 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13126 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13128 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13129 ntohl (mp->sw_if_index),
13130 format_ip46_address, &local, IP46_TYPE_ANY,
13131 format_ip46_address, &remote, IP46_TYPE_ANY,
13132 ntohl (mp->vni), mp->protocol,
13133 ntohl (mp->mcast_sw_if_index),
13134 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13138 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13139 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13141 vat_main_t *vam = &vat_main;
13142 vat_json_node_t *node = NULL;
13143 struct in_addr ip4;
13144 struct in6_addr ip6;
13146 if (VAT_JSON_ARRAY != vam->json_tree.type)
13148 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13149 vat_json_init_array (&vam->json_tree);
13151 node = vat_json_array_add (&vam->json_tree);
13153 vat_json_init_object (node);
13154 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13157 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13158 vat_json_object_add_ip6 (node, "local", ip6);
13159 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13160 vat_json_object_add_ip6 (node, "remote", ip6);
13164 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13165 vat_json_object_add_ip4 (node, "local", ip4);
13166 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13167 vat_json_object_add_ip4 (node, "remote", ip4);
13169 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13170 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13171 vat_json_object_add_uint (node, "mcast_sw_if_index",
13172 ntohl (mp->mcast_sw_if_index));
13173 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13174 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13175 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13179 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13181 unformat_input_t *i = vam->input;
13182 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13183 vl_api_control_ping_t *mp_ping;
13185 u8 sw_if_index_set = 0;
13188 /* Parse args required to build the message */
13189 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13191 if (unformat (i, "sw_if_index %d", &sw_if_index))
13192 sw_if_index_set = 1;
13197 if (sw_if_index_set == 0)
13202 if (!vam->json_output)
13204 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13205 "sw_if_index", "local", "remote", "vni",
13206 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13209 /* Get list of vxlan-tunnel interfaces */
13210 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13212 mp->sw_if_index = htonl (sw_if_index);
13216 /* Use a control ping for synchronization */
13217 MPING (CONTROL_PING, mp_ping);
13226 format_l2_fib_mac_address (u8 * s, va_list * args)
13228 u8 *a = va_arg (*args, u8 *);
13230 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
13231 a[2], a[3], a[4], a[5], a[6], a[7]);
13234 static void vl_api_l2_fib_table_details_t_handler
13235 (vl_api_l2_fib_table_details_t * mp)
13237 vat_main_t *vam = &vat_main;
13239 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13241 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
13242 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13246 static void vl_api_l2_fib_table_details_t_handler_json
13247 (vl_api_l2_fib_table_details_t * mp)
13249 vat_main_t *vam = &vat_main;
13250 vat_json_node_t *node = NULL;
13252 if (VAT_JSON_ARRAY != vam->json_tree.type)
13254 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13255 vat_json_init_array (&vam->json_tree);
13257 node = vat_json_array_add (&vam->json_tree);
13259 vat_json_init_object (node);
13260 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13261 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
13262 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13263 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13264 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13265 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13269 api_l2_fib_table_dump (vat_main_t * vam)
13271 unformat_input_t *i = vam->input;
13272 vl_api_l2_fib_table_dump_t *mp;
13273 vl_api_control_ping_t *mp_ping;
13278 /* Parse args required to build the message */
13279 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13281 if (unformat (i, "bd_id %d", &bd_id))
13287 if (bd_id_set == 0)
13289 errmsg ("missing bridge domain");
13293 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13295 /* Get list of l2 fib entries */
13296 M (L2_FIB_TABLE_DUMP, mp);
13298 mp->bd_id = ntohl (bd_id);
13301 /* Use a control ping for synchronization */
13302 MPING (CONTROL_PING, mp_ping);
13311 api_interface_name_renumber (vat_main_t * vam)
13313 unformat_input_t *line_input = vam->input;
13314 vl_api_interface_name_renumber_t *mp;
13315 u32 sw_if_index = ~0;
13316 u32 new_show_dev_instance = ~0;
13319 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13321 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13324 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13326 else if (unformat (line_input, "new_show_dev_instance %d",
13327 &new_show_dev_instance))
13333 if (sw_if_index == ~0)
13335 errmsg ("missing interface name or sw_if_index");
13339 if (new_show_dev_instance == ~0)
13341 errmsg ("missing new_show_dev_instance");
13345 M (INTERFACE_NAME_RENUMBER, mp);
13347 mp->sw_if_index = ntohl (sw_if_index);
13348 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13356 api_want_ip4_arp_events (vat_main_t * vam)
13358 unformat_input_t *line_input = vam->input;
13359 vl_api_want_ip4_arp_events_t *mp;
13360 ip4_address_t address;
13361 int address_set = 0;
13362 u32 enable_disable = 1;
13365 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13367 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
13369 else if (unformat (line_input, "del"))
13370 enable_disable = 0;
13375 if (address_set == 0)
13377 errmsg ("missing addresses");
13381 M (WANT_IP4_ARP_EVENTS, mp);
13382 mp->enable_disable = enable_disable;
13383 mp->pid = htonl (getpid ());
13384 mp->address = address.as_u32;
13392 api_want_ip6_nd_events (vat_main_t * vam)
13394 unformat_input_t *line_input = vam->input;
13395 vl_api_want_ip6_nd_events_t *mp;
13396 ip6_address_t address;
13397 int address_set = 0;
13398 u32 enable_disable = 1;
13401 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13403 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
13405 else if (unformat (line_input, "del"))
13406 enable_disable = 0;
13411 if (address_set == 0)
13413 errmsg ("missing addresses");
13417 M (WANT_IP6_ND_EVENTS, mp);
13418 mp->enable_disable = enable_disable;
13419 mp->pid = htonl (getpid ());
13420 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
13428 api_want_l2_macs_events (vat_main_t * vam)
13430 unformat_input_t *line_input = vam->input;
13431 vl_api_want_l2_macs_events_t *mp;
13432 u8 enable_disable = 1;
13433 u32 scan_delay = 0;
13434 u32 max_macs_in_event = 0;
13435 u32 learn_limit = 0;
13438 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13440 if (unformat (line_input, "learn-limit %d", &learn_limit))
13442 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13444 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13446 else if (unformat (line_input, "disable"))
13447 enable_disable = 0;
13452 M (WANT_L2_MACS_EVENTS, mp);
13453 mp->enable_disable = enable_disable;
13454 mp->pid = htonl (getpid ());
13455 mp->learn_limit = htonl (learn_limit);
13456 mp->scan_delay = (u8) scan_delay;
13457 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13464 api_input_acl_set_interface (vat_main_t * vam)
13466 unformat_input_t *i = vam->input;
13467 vl_api_input_acl_set_interface_t *mp;
13469 int sw_if_index_set;
13470 u32 ip4_table_index = ~0;
13471 u32 ip6_table_index = ~0;
13472 u32 l2_table_index = ~0;
13476 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13478 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13479 sw_if_index_set = 1;
13480 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13481 sw_if_index_set = 1;
13482 else if (unformat (i, "del"))
13484 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13486 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13488 else if (unformat (i, "l2-table %d", &l2_table_index))
13492 clib_warning ("parse error '%U'", format_unformat_error, i);
13497 if (sw_if_index_set == 0)
13499 errmsg ("missing interface name or sw_if_index");
13503 M (INPUT_ACL_SET_INTERFACE, mp);
13505 mp->sw_if_index = ntohl (sw_if_index);
13506 mp->ip4_table_index = ntohl (ip4_table_index);
13507 mp->ip6_table_index = ntohl (ip6_table_index);
13508 mp->l2_table_index = ntohl (l2_table_index);
13509 mp->is_add = is_add;
13517 api_ip_address_dump (vat_main_t * vam)
13519 unformat_input_t *i = vam->input;
13520 vl_api_ip_address_dump_t *mp;
13521 vl_api_control_ping_t *mp_ping;
13522 u32 sw_if_index = ~0;
13523 u8 sw_if_index_set = 0;
13528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13530 if (unformat (i, "sw_if_index %d", &sw_if_index))
13531 sw_if_index_set = 1;
13533 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13534 sw_if_index_set = 1;
13535 else if (unformat (i, "ipv4"))
13537 else if (unformat (i, "ipv6"))
13543 if (ipv4_set && ipv6_set)
13545 errmsg ("ipv4 and ipv6 flags cannot be both set");
13549 if ((!ipv4_set) && (!ipv6_set))
13551 errmsg ("no ipv4 nor ipv6 flag set");
13555 if (sw_if_index_set == 0)
13557 errmsg ("missing interface name or sw_if_index");
13561 vam->current_sw_if_index = sw_if_index;
13562 vam->is_ipv6 = ipv6_set;
13564 M (IP_ADDRESS_DUMP, mp);
13565 mp->sw_if_index = ntohl (sw_if_index);
13566 mp->is_ipv6 = ipv6_set;
13569 /* Use a control ping for synchronization */
13570 MPING (CONTROL_PING, mp_ping);
13578 api_ip_dump (vat_main_t * vam)
13580 vl_api_ip_dump_t *mp;
13581 vl_api_control_ping_t *mp_ping;
13582 unformat_input_t *in = vam->input;
13589 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13591 if (unformat (in, "ipv4"))
13593 else if (unformat (in, "ipv6"))
13599 if (ipv4_set && ipv6_set)
13601 errmsg ("ipv4 and ipv6 flags cannot be both set");
13605 if ((!ipv4_set) && (!ipv6_set))
13607 errmsg ("no ipv4 nor ipv6 flag set");
13611 is_ipv6 = ipv6_set;
13612 vam->is_ipv6 = is_ipv6;
13614 /* free old data */
13615 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13617 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13619 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13622 mp->is_ipv6 = ipv6_set;
13625 /* Use a control ping for synchronization */
13626 MPING (CONTROL_PING, mp_ping);
13634 api_ipsec_spd_add_del (vat_main_t * vam)
13636 unformat_input_t *i = vam->input;
13637 vl_api_ipsec_spd_add_del_t *mp;
13642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13644 if (unformat (i, "spd_id %d", &spd_id))
13646 else if (unformat (i, "del"))
13650 clib_warning ("parse error '%U'", format_unformat_error, i);
13656 errmsg ("spd_id must be set");
13660 M (IPSEC_SPD_ADD_DEL, mp);
13662 mp->spd_id = ntohl (spd_id);
13663 mp->is_add = is_add;
13671 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13673 unformat_input_t *i = vam->input;
13674 vl_api_ipsec_interface_add_del_spd_t *mp;
13676 u8 sw_if_index_set = 0;
13677 u32 spd_id = (u32) ~ 0;
13681 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13683 if (unformat (i, "del"))
13685 else if (unformat (i, "spd_id %d", &spd_id))
13688 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13689 sw_if_index_set = 1;
13690 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13691 sw_if_index_set = 1;
13694 clib_warning ("parse error '%U'", format_unformat_error, i);
13700 if (spd_id == (u32) ~ 0)
13702 errmsg ("spd_id must be set");
13706 if (sw_if_index_set == 0)
13708 errmsg ("missing interface name or sw_if_index");
13712 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13714 mp->spd_id = ntohl (spd_id);
13715 mp->sw_if_index = ntohl (sw_if_index);
13716 mp->is_add = is_add;
13724 api_ipsec_spd_add_del_entry (vat_main_t * vam)
13726 unformat_input_t *i = vam->input;
13727 vl_api_ipsec_spd_add_del_entry_t *mp;
13728 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
13729 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13731 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13732 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13733 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
13734 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
13737 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
13738 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
13739 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
13740 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
13741 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
13742 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
13744 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13746 if (unformat (i, "del"))
13748 if (unformat (i, "outbound"))
13750 if (unformat (i, "inbound"))
13752 else if (unformat (i, "spd_id %d", &spd_id))
13754 else if (unformat (i, "sa_id %d", &sa_id))
13756 else if (unformat (i, "priority %d", &priority))
13758 else if (unformat (i, "protocol %d", &protocol))
13760 else if (unformat (i, "lport_start %d", &lport_start))
13762 else if (unformat (i, "lport_stop %d", &lport_stop))
13764 else if (unformat (i, "rport_start %d", &rport_start))
13766 else if (unformat (i, "rport_stop %d", &rport_stop))
13770 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
13776 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
13783 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
13789 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
13796 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
13802 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
13809 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
13815 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
13821 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13823 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13825 clib_warning ("unsupported action: 'resolve'");
13831 clib_warning ("parse error '%U'", format_unformat_error, i);
13837 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
13839 mp->spd_id = ntohl (spd_id);
13840 mp->priority = ntohl (priority);
13841 mp->is_outbound = is_outbound;
13843 mp->is_ipv6 = is_ipv6;
13844 if (is_ipv6 || is_ip_any)
13846 clib_memcpy (mp->remote_address_start, &raddr6_start,
13847 sizeof (ip6_address_t));
13848 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
13849 sizeof (ip6_address_t));
13850 clib_memcpy (mp->local_address_start, &laddr6_start,
13851 sizeof (ip6_address_t));
13852 clib_memcpy (mp->local_address_stop, &laddr6_stop,
13853 sizeof (ip6_address_t));
13857 clib_memcpy (mp->remote_address_start, &raddr4_start,
13858 sizeof (ip4_address_t));
13859 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
13860 sizeof (ip4_address_t));
13861 clib_memcpy (mp->local_address_start, &laddr4_start,
13862 sizeof (ip4_address_t));
13863 clib_memcpy (mp->local_address_stop, &laddr4_stop,
13864 sizeof (ip4_address_t));
13866 mp->protocol = (u8) protocol;
13867 mp->local_port_start = ntohs ((u16) lport_start);
13868 mp->local_port_stop = ntohs ((u16) lport_stop);
13869 mp->remote_port_start = ntohs ((u16) rport_start);
13870 mp->remote_port_stop = ntohs ((u16) rport_stop);
13871 mp->policy = (u8) policy;
13872 mp->sa_id = ntohl (sa_id);
13873 mp->is_add = is_add;
13874 mp->is_ip_any = is_ip_any;
13881 api_ipsec_sad_add_del_entry (vat_main_t * vam)
13883 unformat_input_t *i = vam->input;
13884 vl_api_ipsec_sad_add_del_entry_t *mp;
13885 u32 sad_id = 0, spi = 0;
13886 u8 *ck = 0, *ik = 0;
13889 u8 protocol = IPSEC_PROTOCOL_AH;
13890 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
13891 u32 crypto_alg = 0, integ_alg = 0;
13892 ip4_address_t tun_src4;
13893 ip4_address_t tun_dst4;
13894 ip6_address_t tun_src6;
13895 ip6_address_t tun_dst6;
13898 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13900 if (unformat (i, "del"))
13902 else if (unformat (i, "sad_id %d", &sad_id))
13904 else if (unformat (i, "spi %d", &spi))
13906 else if (unformat (i, "esp"))
13907 protocol = IPSEC_PROTOCOL_ESP;
13908 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
13911 is_tunnel_ipv6 = 0;
13913 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
13916 is_tunnel_ipv6 = 0;
13918 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
13921 is_tunnel_ipv6 = 1;
13923 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
13926 is_tunnel_ipv6 = 1;
13930 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13932 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13933 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13935 clib_warning ("unsupported crypto-alg: '%U'",
13936 format_ipsec_crypto_alg, crypto_alg);
13940 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13944 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13946 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13947 integ_alg >= IPSEC_INTEG_N_ALG)
13949 clib_warning ("unsupported integ-alg: '%U'",
13950 format_ipsec_integ_alg, integ_alg);
13954 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13958 clib_warning ("parse error '%U'", format_unformat_error, i);
13964 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
13966 mp->sad_id = ntohl (sad_id);
13967 mp->is_add = is_add;
13968 mp->protocol = protocol;
13969 mp->spi = ntohl (spi);
13970 mp->is_tunnel = is_tunnel;
13971 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
13972 mp->crypto_algorithm = crypto_alg;
13973 mp->integrity_algorithm = integ_alg;
13974 mp->crypto_key_length = vec_len (ck);
13975 mp->integrity_key_length = vec_len (ik);
13977 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13978 mp->crypto_key_length = sizeof (mp->crypto_key);
13980 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13981 mp->integrity_key_length = sizeof (mp->integrity_key);
13984 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13986 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13990 if (is_tunnel_ipv6)
13992 clib_memcpy (mp->tunnel_src_address, &tun_src6,
13993 sizeof (ip6_address_t));
13994 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
13995 sizeof (ip6_address_t));
13999 clib_memcpy (mp->tunnel_src_address, &tun_src4,
14000 sizeof (ip4_address_t));
14001 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
14002 sizeof (ip4_address_t));
14012 api_ipsec_sa_set_key (vat_main_t * vam)
14014 unformat_input_t *i = vam->input;
14015 vl_api_ipsec_sa_set_key_t *mp;
14017 u8 *ck = 0, *ik = 0;
14020 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14022 if (unformat (i, "sa_id %d", &sa_id))
14024 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14026 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14030 clib_warning ("parse error '%U'", format_unformat_error, i);
14035 M (IPSEC_SA_SET_KEY, mp);
14037 mp->sa_id = ntohl (sa_id);
14038 mp->crypto_key_length = vec_len (ck);
14039 mp->integrity_key_length = vec_len (ik);
14041 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14042 mp->crypto_key_length = sizeof (mp->crypto_key);
14044 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14045 mp->integrity_key_length = sizeof (mp->integrity_key);
14048 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14050 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14058 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14060 unformat_input_t *i = vam->input;
14061 vl_api_ipsec_tunnel_if_add_del_t *mp;
14062 u32 local_spi = 0, remote_spi = 0;
14063 u32 crypto_alg = 0, integ_alg = 0;
14064 u8 *lck = NULL, *rck = NULL;
14065 u8 *lik = NULL, *rik = NULL;
14066 ip4_address_t local_ip = { {0} };
14067 ip4_address_t remote_ip = { {0} };
14070 u8 anti_replay = 0;
14073 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14075 if (unformat (i, "del"))
14077 else if (unformat (i, "esn"))
14079 else if (unformat (i, "anti_replay"))
14081 else if (unformat (i, "local_spi %d", &local_spi))
14083 else if (unformat (i, "remote_spi %d", &remote_spi))
14085 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
14087 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
14089 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14092 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14094 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14096 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14100 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14102 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14103 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14105 errmsg ("unsupported crypto-alg: '%U'\n",
14106 format_ipsec_crypto_alg, crypto_alg);
14112 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14114 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14115 integ_alg >= IPSEC_INTEG_N_ALG)
14117 errmsg ("unsupported integ-alg: '%U'\n",
14118 format_ipsec_integ_alg, integ_alg);
14124 errmsg ("parse error '%U'\n", format_unformat_error, i);
14129 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14131 mp->is_add = is_add;
14133 mp->anti_replay = anti_replay;
14135 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
14136 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
14138 mp->local_spi = htonl (local_spi);
14139 mp->remote_spi = htonl (remote_spi);
14140 mp->crypto_alg = (u8) crypto_alg;
14142 mp->local_crypto_key_len = 0;
14145 mp->local_crypto_key_len = vec_len (lck);
14146 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14147 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14148 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14151 mp->remote_crypto_key_len = 0;
14154 mp->remote_crypto_key_len = vec_len (rck);
14155 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14156 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14157 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14160 mp->integ_alg = (u8) integ_alg;
14162 mp->local_integ_key_len = 0;
14165 mp->local_integ_key_len = vec_len (lik);
14166 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14167 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14168 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14171 mp->remote_integ_key_len = 0;
14174 mp->remote_integ_key_len = vec_len (rik);
14175 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14176 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14177 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14186 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14188 vat_main_t *vam = &vat_main;
14190 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14191 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
14192 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
14193 "tunnel_src_addr %U tunnel_dst_addr %U "
14194 "salt %u seq_outbound %lu last_seq_inbound %lu "
14195 "replay_window %lu total_data_size %lu\n",
14196 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
14198 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
14199 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
14200 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
14201 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14202 mp->tunnel_src_addr,
14203 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14204 mp->tunnel_dst_addr,
14206 clib_net_to_host_u64 (mp->seq_outbound),
14207 clib_net_to_host_u64 (mp->last_seq_inbound),
14208 clib_net_to_host_u64 (mp->replay_window),
14209 clib_net_to_host_u64 (mp->total_data_size));
14212 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14213 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14215 static void vl_api_ipsec_sa_details_t_handler_json
14216 (vl_api_ipsec_sa_details_t * mp)
14218 vat_main_t *vam = &vat_main;
14219 vat_json_node_t *node = NULL;
14220 struct in_addr src_ip4, dst_ip4;
14221 struct in6_addr src_ip6, dst_ip6;
14223 if (VAT_JSON_ARRAY != vam->json_tree.type)
14225 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14226 vat_json_init_array (&vam->json_tree);
14228 node = vat_json_array_add (&vam->json_tree);
14230 vat_json_init_object (node);
14231 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
14232 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14233 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
14234 vat_json_object_add_uint (node, "proto", mp->protocol);
14235 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
14236 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
14237 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
14238 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
14239 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
14240 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
14241 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
14242 mp->crypto_key_len);
14243 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
14244 mp->integ_key_len);
14245 if (mp->is_tunnel_ip6)
14247 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
14248 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
14249 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
14250 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
14254 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
14255 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
14256 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
14257 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
14259 vat_json_object_add_uint (node, "replay_window",
14260 clib_net_to_host_u64 (mp->replay_window));
14261 vat_json_object_add_uint (node, "total_data_size",
14262 clib_net_to_host_u64 (mp->total_data_size));
14267 api_ipsec_sa_dump (vat_main_t * vam)
14269 unformat_input_t *i = vam->input;
14270 vl_api_ipsec_sa_dump_t *mp;
14271 vl_api_control_ping_t *mp_ping;
14275 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14277 if (unformat (i, "sa_id %d", &sa_id))
14281 clib_warning ("parse error '%U'", format_unformat_error, i);
14286 M (IPSEC_SA_DUMP, mp);
14288 mp->sa_id = ntohl (sa_id);
14292 /* Use a control ping for synchronization */
14293 M (CONTROL_PING, mp_ping);
14301 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
14303 unformat_input_t *i = vam->input;
14304 vl_api_ipsec_tunnel_if_set_key_t *mp;
14305 u32 sw_if_index = ~0;
14306 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
14311 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14313 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14316 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
14317 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
14319 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
14320 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
14321 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
14322 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
14324 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
14325 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
14326 else if (unformat (i, "%U", unformat_hex_string, &key))
14330 clib_warning ("parse error '%U'", format_unformat_error, i);
14335 if (sw_if_index == ~0)
14337 errmsg ("interface must be specified");
14341 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
14343 errmsg ("key type must be specified");
14349 errmsg ("algorithm must be specified");
14353 if (vec_len (key) == 0)
14355 errmsg ("key must be specified");
14359 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
14361 mp->sw_if_index = htonl (sw_if_index);
14363 mp->key_type = key_type;
14364 mp->key_len = vec_len (key);
14365 clib_memcpy (mp->key, key, vec_len (key));
14374 api_ikev2_profile_add_del (vat_main_t * vam)
14376 unformat_input_t *i = vam->input;
14377 vl_api_ikev2_profile_add_del_t *mp;
14382 const char *valid_chars = "a-zA-Z0-9_";
14384 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14386 if (unformat (i, "del"))
14388 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14389 vec_add1 (name, 0);
14392 errmsg ("parse error '%U'", format_unformat_error, i);
14397 if (!vec_len (name))
14399 errmsg ("profile name must be specified");
14403 if (vec_len (name) > 64)
14405 errmsg ("profile name too long");
14409 M (IKEV2_PROFILE_ADD_DEL, mp);
14411 clib_memcpy (mp->name, name, vec_len (name));
14412 mp->is_add = is_add;
14421 api_ikev2_profile_set_auth (vat_main_t * vam)
14423 unformat_input_t *i = vam->input;
14424 vl_api_ikev2_profile_set_auth_t *mp;
14427 u32 auth_method = 0;
14431 const char *valid_chars = "a-zA-Z0-9_";
14433 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14435 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14436 vec_add1 (name, 0);
14437 else if (unformat (i, "auth_method %U",
14438 unformat_ikev2_auth_method, &auth_method))
14440 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
14442 else if (unformat (i, "auth_data %v", &data))
14446 errmsg ("parse error '%U'", format_unformat_error, i);
14451 if (!vec_len (name))
14453 errmsg ("profile name must be specified");
14457 if (vec_len (name) > 64)
14459 errmsg ("profile name too long");
14463 if (!vec_len (data))
14465 errmsg ("auth_data must be specified");
14471 errmsg ("auth_method must be specified");
14475 M (IKEV2_PROFILE_SET_AUTH, mp);
14477 mp->is_hex = is_hex;
14478 mp->auth_method = (u8) auth_method;
14479 mp->data_len = vec_len (data);
14480 clib_memcpy (mp->name, name, vec_len (name));
14481 clib_memcpy (mp->data, data, vec_len (data));
14491 api_ikev2_profile_set_id (vat_main_t * vam)
14493 unformat_input_t *i = vam->input;
14494 vl_api_ikev2_profile_set_id_t *mp;
14502 const char *valid_chars = "a-zA-Z0-9_";
14504 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14506 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14507 vec_add1 (name, 0);
14508 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
14510 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
14512 data = vec_new (u8, 4);
14513 clib_memcpy (data, ip4.as_u8, 4);
14515 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
14517 else if (unformat (i, "id_data %v", &data))
14519 else if (unformat (i, "local"))
14521 else if (unformat (i, "remote"))
14525 errmsg ("parse error '%U'", format_unformat_error, i);
14530 if (!vec_len (name))
14532 errmsg ("profile name must be specified");
14536 if (vec_len (name) > 64)
14538 errmsg ("profile name too long");
14542 if (!vec_len (data))
14544 errmsg ("id_data must be specified");
14550 errmsg ("id_type must be specified");
14554 M (IKEV2_PROFILE_SET_ID, mp);
14556 mp->is_local = is_local;
14557 mp->id_type = (u8) id_type;
14558 mp->data_len = vec_len (data);
14559 clib_memcpy (mp->name, name, vec_len (name));
14560 clib_memcpy (mp->data, data, vec_len (data));
14570 api_ikev2_profile_set_ts (vat_main_t * vam)
14572 unformat_input_t *i = vam->input;
14573 vl_api_ikev2_profile_set_ts_t *mp;
14576 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
14577 ip4_address_t start_addr, end_addr;
14579 const char *valid_chars = "a-zA-Z0-9_";
14582 start_addr.as_u32 = 0;
14583 end_addr.as_u32 = (u32) ~ 0;
14585 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14587 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14588 vec_add1 (name, 0);
14589 else if (unformat (i, "protocol %d", &proto))
14591 else if (unformat (i, "start_port %d", &start_port))
14593 else if (unformat (i, "end_port %d", &end_port))
14596 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
14598 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
14600 else if (unformat (i, "local"))
14602 else if (unformat (i, "remote"))
14606 errmsg ("parse error '%U'", format_unformat_error, i);
14611 if (!vec_len (name))
14613 errmsg ("profile name must be specified");
14617 if (vec_len (name) > 64)
14619 errmsg ("profile name too long");
14623 M (IKEV2_PROFILE_SET_TS, mp);
14625 mp->is_local = is_local;
14626 mp->proto = (u8) proto;
14627 mp->start_port = (u16) start_port;
14628 mp->end_port = (u16) end_port;
14629 mp->start_addr = start_addr.as_u32;
14630 mp->end_addr = end_addr.as_u32;
14631 clib_memcpy (mp->name, name, vec_len (name));
14640 api_ikev2_set_local_key (vat_main_t * vam)
14642 unformat_input_t *i = vam->input;
14643 vl_api_ikev2_set_local_key_t *mp;
14647 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14649 if (unformat (i, "file %v", &file))
14650 vec_add1 (file, 0);
14653 errmsg ("parse error '%U'", format_unformat_error, i);
14658 if (!vec_len (file))
14660 errmsg ("RSA key file must be specified");
14664 if (vec_len (file) > 256)
14666 errmsg ("file name too long");
14670 M (IKEV2_SET_LOCAL_KEY, mp);
14672 clib_memcpy (mp->key_file, file, vec_len (file));
14681 api_ikev2_set_responder (vat_main_t * vam)
14683 unformat_input_t *i = vam->input;
14684 vl_api_ikev2_set_responder_t *mp;
14687 u32 sw_if_index = ~0;
14688 ip4_address_t address;
14690 const char *valid_chars = "a-zA-Z0-9_";
14692 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14695 (i, "%U interface %d address %U", unformat_token, valid_chars,
14696 &name, &sw_if_index, unformat_ip4_address, &address))
14697 vec_add1 (name, 0);
14700 errmsg ("parse error '%U'", format_unformat_error, i);
14705 if (!vec_len (name))
14707 errmsg ("profile name must be specified");
14711 if (vec_len (name) > 64)
14713 errmsg ("profile name too long");
14717 M (IKEV2_SET_RESPONDER, mp);
14719 clib_memcpy (mp->name, name, vec_len (name));
14722 mp->sw_if_index = sw_if_index;
14723 clib_memcpy (mp->address, &address, sizeof (address));
14731 api_ikev2_set_ike_transforms (vat_main_t * vam)
14733 unformat_input_t *i = vam->input;
14734 vl_api_ikev2_set_ike_transforms_t *mp;
14737 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14739 const char *valid_chars = "a-zA-Z0-9_";
14741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14743 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14744 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14745 vec_add1 (name, 0);
14748 errmsg ("parse error '%U'", format_unformat_error, i);
14753 if (!vec_len (name))
14755 errmsg ("profile name must be specified");
14759 if (vec_len (name) > 64)
14761 errmsg ("profile name too long");
14765 M (IKEV2_SET_IKE_TRANSFORMS, mp);
14767 clib_memcpy (mp->name, name, vec_len (name));
14769 mp->crypto_alg = crypto_alg;
14770 mp->crypto_key_size = crypto_key_size;
14771 mp->integ_alg = integ_alg;
14772 mp->dh_group = dh_group;
14781 api_ikev2_set_esp_transforms (vat_main_t * vam)
14783 unformat_input_t *i = vam->input;
14784 vl_api_ikev2_set_esp_transforms_t *mp;
14787 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14789 const char *valid_chars = "a-zA-Z0-9_";
14791 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14793 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14794 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14795 vec_add1 (name, 0);
14798 errmsg ("parse error '%U'", format_unformat_error, i);
14803 if (!vec_len (name))
14805 errmsg ("profile name must be specified");
14809 if (vec_len (name) > 64)
14811 errmsg ("profile name too long");
14815 M (IKEV2_SET_ESP_TRANSFORMS, mp);
14817 clib_memcpy (mp->name, name, vec_len (name));
14819 mp->crypto_alg = crypto_alg;
14820 mp->crypto_key_size = crypto_key_size;
14821 mp->integ_alg = integ_alg;
14822 mp->dh_group = dh_group;
14830 api_ikev2_set_sa_lifetime (vat_main_t * vam)
14832 unformat_input_t *i = vam->input;
14833 vl_api_ikev2_set_sa_lifetime_t *mp;
14836 u64 lifetime, lifetime_maxdata;
14837 u32 lifetime_jitter, handover;
14839 const char *valid_chars = "a-zA-Z0-9_";
14841 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14843 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
14844 &lifetime, &lifetime_jitter, &handover,
14845 &lifetime_maxdata))
14846 vec_add1 (name, 0);
14849 errmsg ("parse error '%U'", format_unformat_error, i);
14854 if (!vec_len (name))
14856 errmsg ("profile name must be specified");
14860 if (vec_len (name) > 64)
14862 errmsg ("profile name too long");
14866 M (IKEV2_SET_SA_LIFETIME, mp);
14868 clib_memcpy (mp->name, name, vec_len (name));
14870 mp->lifetime = lifetime;
14871 mp->lifetime_jitter = lifetime_jitter;
14872 mp->handover = handover;
14873 mp->lifetime_maxdata = lifetime_maxdata;
14881 api_ikev2_initiate_sa_init (vat_main_t * vam)
14883 unformat_input_t *i = vam->input;
14884 vl_api_ikev2_initiate_sa_init_t *mp;
14888 const char *valid_chars = "a-zA-Z0-9_";
14890 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14892 if (unformat (i, "%U", unformat_token, valid_chars, &name))
14893 vec_add1 (name, 0);
14896 errmsg ("parse error '%U'", format_unformat_error, i);
14901 if (!vec_len (name))
14903 errmsg ("profile name must be specified");
14907 if (vec_len (name) > 64)
14909 errmsg ("profile name too long");
14913 M (IKEV2_INITIATE_SA_INIT, mp);
14915 clib_memcpy (mp->name, name, vec_len (name));
14924 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
14926 unformat_input_t *i = vam->input;
14927 vl_api_ikev2_initiate_del_ike_sa_t *mp;
14932 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14934 if (unformat (i, "%lx", &ispi))
14938 errmsg ("parse error '%U'", format_unformat_error, i);
14943 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
14953 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
14955 unformat_input_t *i = vam->input;
14956 vl_api_ikev2_initiate_del_child_sa_t *mp;
14961 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14963 if (unformat (i, "%x", &ispi))
14967 errmsg ("parse error '%U'", format_unformat_error, i);
14972 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
14982 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
14984 unformat_input_t *i = vam->input;
14985 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
14990 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14992 if (unformat (i, "%x", &ispi))
14996 errmsg ("parse error '%U'", format_unformat_error, i);
15001 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
15014 api_map_add_domain (vat_main_t * vam)
15016 unformat_input_t *i = vam->input;
15017 vl_api_map_add_domain_t *mp;
15019 ip4_address_t ip4_prefix;
15020 ip6_address_t ip6_prefix;
15021 ip6_address_t ip6_src;
15022 u32 num_m_args = 0;
15023 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
15024 0, psid_length = 0;
15025 u8 is_translation = 0;
15027 u32 ip6_src_len = 128;
15030 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15032 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
15033 &ip4_prefix, &ip4_prefix_len))
15035 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
15036 &ip6_prefix, &ip6_prefix_len))
15040 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
15043 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
15045 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
15047 else if (unformat (i, "psid-offset %d", &psid_offset))
15049 else if (unformat (i, "psid-len %d", &psid_length))
15051 else if (unformat (i, "mtu %d", &mtu))
15053 else if (unformat (i, "map-t"))
15054 is_translation = 1;
15057 clib_warning ("parse error '%U'", format_unformat_error, i);
15062 if (num_m_args < 3)
15064 errmsg ("mandatory argument(s) missing");
15068 /* Construct the API message */
15069 M (MAP_ADD_DOMAIN, mp);
15071 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
15072 mp->ip4_prefix_len = ip4_prefix_len;
15074 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
15075 mp->ip6_prefix_len = ip6_prefix_len;
15077 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
15078 mp->ip6_src_prefix_len = ip6_src_len;
15080 mp->ea_bits_len = ea_bits_len;
15081 mp->psid_offset = psid_offset;
15082 mp->psid_length = psid_length;
15083 mp->is_translation = is_translation;
15084 mp->mtu = htons (mtu);
15089 /* Wait for a reply, return good/bad news */
15095 api_map_del_domain (vat_main_t * vam)
15097 unformat_input_t *i = vam->input;
15098 vl_api_map_del_domain_t *mp;
15100 u32 num_m_args = 0;
15104 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15106 if (unformat (i, "index %d", &index))
15110 clib_warning ("parse error '%U'", format_unformat_error, i);
15115 if (num_m_args != 1)
15117 errmsg ("mandatory argument(s) missing");
15121 /* Construct the API message */
15122 M (MAP_DEL_DOMAIN, mp);
15124 mp->index = ntohl (index);
15129 /* Wait for a reply, return good/bad news */
15135 api_map_add_del_rule (vat_main_t * vam)
15137 unformat_input_t *i = vam->input;
15138 vl_api_map_add_del_rule_t *mp;
15140 ip6_address_t ip6_dst;
15141 u32 num_m_args = 0, index, psid = 0;
15144 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15146 if (unformat (i, "index %d", &index))
15148 else if (unformat (i, "psid %d", &psid))
15150 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
15152 else if (unformat (i, "del"))
15158 clib_warning ("parse error '%U'", format_unformat_error, i);
15163 /* Construct the API message */
15164 M (MAP_ADD_DEL_RULE, mp);
15166 mp->index = ntohl (index);
15167 mp->is_add = is_add;
15168 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
15169 mp->psid = ntohs (psid);
15174 /* Wait for a reply, return good/bad news */
15180 api_map_domain_dump (vat_main_t * vam)
15182 vl_api_map_domain_dump_t *mp;
15183 vl_api_control_ping_t *mp_ping;
15186 /* Construct the API message */
15187 M (MAP_DOMAIN_DUMP, mp);
15192 /* Use a control ping for synchronization */
15193 MPING (CONTROL_PING, mp_ping);
15201 api_map_rule_dump (vat_main_t * vam)
15203 unformat_input_t *i = vam->input;
15204 vl_api_map_rule_dump_t *mp;
15205 vl_api_control_ping_t *mp_ping;
15206 u32 domain_index = ~0;
15209 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15211 if (unformat (i, "index %u", &domain_index))
15217 if (domain_index == ~0)
15219 clib_warning ("parse error: domain index expected");
15223 /* Construct the API message */
15224 M (MAP_RULE_DUMP, mp);
15226 mp->domain_index = htonl (domain_index);
15231 /* Use a control ping for synchronization */
15232 MPING (CONTROL_PING, mp_ping);
15239 static void vl_api_map_add_domain_reply_t_handler
15240 (vl_api_map_add_domain_reply_t * mp)
15242 vat_main_t *vam = &vat_main;
15243 i32 retval = ntohl (mp->retval);
15245 if (vam->async_mode)
15247 vam->async_errors += (retval < 0);
15251 vam->retval = retval;
15252 vam->result_ready = 1;
15256 static void vl_api_map_add_domain_reply_t_handler_json
15257 (vl_api_map_add_domain_reply_t * mp)
15259 vat_main_t *vam = &vat_main;
15260 vat_json_node_t node;
15262 vat_json_init_object (&node);
15263 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
15264 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
15266 vat_json_print (vam->ofp, &node);
15267 vat_json_free (&node);
15269 vam->retval = ntohl (mp->retval);
15270 vam->result_ready = 1;
15274 api_get_first_msg_id (vat_main_t * vam)
15276 vl_api_get_first_msg_id_t *mp;
15277 unformat_input_t *i = vam->input;
15282 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15284 if (unformat (i, "client %s", &name))
15292 errmsg ("missing client name");
15295 vec_add1 (name, 0);
15297 if (vec_len (name) > 63)
15299 errmsg ("client name too long");
15303 M (GET_FIRST_MSG_ID, mp);
15304 clib_memcpy (mp->name, name, vec_len (name));
15311 api_cop_interface_enable_disable (vat_main_t * vam)
15313 unformat_input_t *line_input = vam->input;
15314 vl_api_cop_interface_enable_disable_t *mp;
15315 u32 sw_if_index = ~0;
15316 u8 enable_disable = 1;
15319 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15321 if (unformat (line_input, "disable"))
15322 enable_disable = 0;
15323 if (unformat (line_input, "enable"))
15324 enable_disable = 1;
15325 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15326 vam, &sw_if_index))
15328 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15334 if (sw_if_index == ~0)
15336 errmsg ("missing interface name or sw_if_index");
15340 /* Construct the API message */
15341 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15342 mp->sw_if_index = ntohl (sw_if_index);
15343 mp->enable_disable = enable_disable;
15347 /* Wait for the reply */
15353 api_cop_whitelist_enable_disable (vat_main_t * vam)
15355 unformat_input_t *line_input = vam->input;
15356 vl_api_cop_whitelist_enable_disable_t *mp;
15357 u32 sw_if_index = ~0;
15358 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15362 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15364 if (unformat (line_input, "ip4"))
15366 else if (unformat (line_input, "ip6"))
15368 else if (unformat (line_input, "default"))
15370 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15371 vam, &sw_if_index))
15373 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15375 else if (unformat (line_input, "fib-id %d", &fib_id))
15381 if (sw_if_index == ~0)
15383 errmsg ("missing interface name or sw_if_index");
15387 /* Construct the API message */
15388 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15389 mp->sw_if_index = ntohl (sw_if_index);
15390 mp->fib_id = ntohl (fib_id);
15393 mp->default_cop = default_cop;
15397 /* Wait for the reply */
15403 api_get_node_graph (vat_main_t * vam)
15405 vl_api_get_node_graph_t *mp;
15408 M (GET_NODE_GRAPH, mp);
15412 /* Wait for the reply */
15418 /** Used for parsing LISP eids */
15419 typedef CLIB_PACKED(struct{
15420 u8 addr[16]; /**< eid address */
15421 u32 len; /**< prefix length if IP */
15422 u8 type; /**< type of eid */
15427 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15429 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15431 memset (a, 0, sizeof (a[0]));
15433 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15435 a->type = 0; /* ipv4 type */
15437 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15439 a->type = 1; /* ipv6 type */
15441 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15443 a->type = 2; /* mac type */
15445 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15447 a->type = 3; /* NSH type */
15448 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15449 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15456 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15465 lisp_eid_size_vat (u8 type)
15482 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15484 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15488 api_one_add_del_locator_set (vat_main_t * vam)
15490 unformat_input_t *input = vam->input;
15491 vl_api_one_add_del_locator_set_t *mp;
15493 u8 *locator_set_name = NULL;
15494 u8 locator_set_name_set = 0;
15495 vl_api_local_locator_t locator, *locators = 0;
15496 u32 sw_if_index, priority, weight;
15500 /* Parse args required to build the message */
15501 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15503 if (unformat (input, "del"))
15507 else if (unformat (input, "locator-set %s", &locator_set_name))
15509 locator_set_name_set = 1;
15511 else if (unformat (input, "sw_if_index %u p %u w %u",
15512 &sw_if_index, &priority, &weight))
15514 locator.sw_if_index = htonl (sw_if_index);
15515 locator.priority = priority;
15516 locator.weight = weight;
15517 vec_add1 (locators, locator);
15521 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15522 &sw_if_index, &priority, &weight))
15524 locator.sw_if_index = htonl (sw_if_index);
15525 locator.priority = priority;
15526 locator.weight = weight;
15527 vec_add1 (locators, locator);
15533 if (locator_set_name_set == 0)
15535 errmsg ("missing locator-set name");
15536 vec_free (locators);
15540 if (vec_len (locator_set_name) > 64)
15542 errmsg ("locator-set name too long");
15543 vec_free (locator_set_name);
15544 vec_free (locators);
15547 vec_add1 (locator_set_name, 0);
15549 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15551 /* Construct the API message */
15552 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15554 mp->is_add = is_add;
15555 clib_memcpy (mp->locator_set_name, locator_set_name,
15556 vec_len (locator_set_name));
15557 vec_free (locator_set_name);
15559 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15561 clib_memcpy (mp->locators, locators, data_len);
15562 vec_free (locators);
15567 /* Wait for a reply... */
15572 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15575 api_one_add_del_locator (vat_main_t * vam)
15577 unformat_input_t *input = vam->input;
15578 vl_api_one_add_del_locator_t *mp;
15579 u32 tmp_if_index = ~0;
15580 u32 sw_if_index = ~0;
15581 u8 sw_if_index_set = 0;
15582 u8 sw_if_index_if_name_set = 0;
15584 u8 priority_set = 0;
15588 u8 *locator_set_name = NULL;
15589 u8 locator_set_name_set = 0;
15592 /* Parse args required to build the message */
15593 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15595 if (unformat (input, "del"))
15599 else if (unformat (input, "locator-set %s", &locator_set_name))
15601 locator_set_name_set = 1;
15603 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15606 sw_if_index_if_name_set = 1;
15607 sw_if_index = tmp_if_index;
15609 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15611 sw_if_index_set = 1;
15612 sw_if_index = tmp_if_index;
15614 else if (unformat (input, "p %d", &priority))
15618 else if (unformat (input, "w %d", &weight))
15626 if (locator_set_name_set == 0)
15628 errmsg ("missing locator-set name");
15632 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15634 errmsg ("missing sw_if_index");
15635 vec_free (locator_set_name);
15639 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15641 errmsg ("cannot use both params interface name and sw_if_index");
15642 vec_free (locator_set_name);
15646 if (priority_set == 0)
15648 errmsg ("missing locator-set priority");
15649 vec_free (locator_set_name);
15653 if (weight_set == 0)
15655 errmsg ("missing locator-set weight");
15656 vec_free (locator_set_name);
15660 if (vec_len (locator_set_name) > 64)
15662 errmsg ("locator-set name too long");
15663 vec_free (locator_set_name);
15666 vec_add1 (locator_set_name, 0);
15668 /* Construct the API message */
15669 M (ONE_ADD_DEL_LOCATOR, mp);
15671 mp->is_add = is_add;
15672 mp->sw_if_index = ntohl (sw_if_index);
15673 mp->priority = priority;
15674 mp->weight = weight;
15675 clib_memcpy (mp->locator_set_name, locator_set_name,
15676 vec_len (locator_set_name));
15677 vec_free (locator_set_name);
15682 /* Wait for a reply... */
15687 #define api_lisp_add_del_locator api_one_add_del_locator
15690 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15692 u32 *key_id = va_arg (*args, u32 *);
15695 if (unformat (input, "%s", &s))
15697 if (!strcmp ((char *) s, "sha1"))
15698 key_id[0] = HMAC_SHA_1_96;
15699 else if (!strcmp ((char *) s, "sha256"))
15700 key_id[0] = HMAC_SHA_256_128;
15703 clib_warning ("invalid key_id: '%s'", s);
15704 key_id[0] = HMAC_NO_KEY;
15715 api_one_add_del_local_eid (vat_main_t * vam)
15717 unformat_input_t *input = vam->input;
15718 vl_api_one_add_del_local_eid_t *mp;
15721 lisp_eid_vat_t _eid, *eid = &_eid;
15722 u8 *locator_set_name = 0;
15723 u8 locator_set_name_set = 0;
15729 /* Parse args required to build the message */
15730 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15732 if (unformat (input, "del"))
15736 else if (unformat (input, "vni %d", &vni))
15740 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15744 else if (unformat (input, "locator-set %s", &locator_set_name))
15746 locator_set_name_set = 1;
15748 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15750 else if (unformat (input, "secret-key %_%v%_", &key))
15756 if (locator_set_name_set == 0)
15758 errmsg ("missing locator-set name");
15764 errmsg ("EID address not set!");
15765 vec_free (locator_set_name);
15769 if (key && (0 == key_id))
15771 errmsg ("invalid key_id!");
15775 if (vec_len (key) > 64)
15777 errmsg ("key too long");
15782 if (vec_len (locator_set_name) > 64)
15784 errmsg ("locator-set name too long");
15785 vec_free (locator_set_name);
15788 vec_add1 (locator_set_name, 0);
15790 /* Construct the API message */
15791 M (ONE_ADD_DEL_LOCAL_EID, mp);
15793 mp->is_add = is_add;
15794 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15795 mp->eid_type = eid->type;
15796 mp->prefix_len = eid->len;
15797 mp->vni = clib_host_to_net_u32 (vni);
15798 mp->key_id = clib_host_to_net_u16 (key_id);
15799 clib_memcpy (mp->locator_set_name, locator_set_name,
15800 vec_len (locator_set_name));
15801 clib_memcpy (mp->key, key, vec_len (key));
15803 vec_free (locator_set_name);
15809 /* Wait for a reply... */
15814 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15817 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15819 u32 dp_table = 0, vni = 0;;
15820 unformat_input_t *input = vam->input;
15821 vl_api_gpe_add_del_fwd_entry_t *mp;
15823 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15824 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15825 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15826 u32 action = ~0, w;
15827 ip4_address_t rmt_rloc4, lcl_rloc4;
15828 ip6_address_t rmt_rloc6, lcl_rloc6;
15829 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15832 memset (&rloc, 0, sizeof (rloc));
15834 /* Parse args required to build the message */
15835 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15837 if (unformat (input, "del"))
15839 else if (unformat (input, "add"))
15841 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15845 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15849 else if (unformat (input, "vrf %d", &dp_table))
15851 else if (unformat (input, "bd %d", &dp_table))
15853 else if (unformat (input, "vni %d", &vni))
15855 else if (unformat (input, "w %d", &w))
15859 errmsg ("No RLOC configured for setting priority/weight!");
15862 curr_rloc->weight = w;
15864 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15865 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15869 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15871 vec_add1 (lcl_locs, rloc);
15873 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15874 vec_add1 (rmt_locs, rloc);
15875 /* weight saved in rmt loc */
15876 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15878 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15879 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15882 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15884 vec_add1 (lcl_locs, rloc);
15886 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15887 vec_add1 (rmt_locs, rloc);
15888 /* weight saved in rmt loc */
15889 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15891 else if (unformat (input, "action %d", &action))
15897 clib_warning ("parse error '%U'", format_unformat_error, input);
15904 errmsg ("remote eid addresses not set");
15908 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15910 errmsg ("eid types don't match");
15914 if (0 == rmt_locs && (u32) ~ 0 == action)
15916 errmsg ("action not set for negative mapping");
15920 /* Construct the API message */
15921 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15922 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15924 mp->is_add = is_add;
15925 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15926 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15927 mp->eid_type = rmt_eid->type;
15928 mp->dp_table = clib_host_to_net_u32 (dp_table);
15929 mp->vni = clib_host_to_net_u32 (vni);
15930 mp->rmt_len = rmt_eid->len;
15931 mp->lcl_len = lcl_eid->len;
15932 mp->action = action;
15934 if (0 != rmt_locs && 0 != lcl_locs)
15936 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15937 clib_memcpy (mp->locs, lcl_locs,
15938 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15940 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15941 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15942 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15944 vec_free (lcl_locs);
15945 vec_free (rmt_locs);
15950 /* Wait for a reply... */
15956 api_one_add_del_map_server (vat_main_t * vam)
15958 unformat_input_t *input = vam->input;
15959 vl_api_one_add_del_map_server_t *mp;
15963 ip4_address_t ipv4;
15964 ip6_address_t ipv6;
15967 /* Parse args required to build the message */
15968 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15970 if (unformat (input, "del"))
15974 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15978 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15986 if (ipv4_set && ipv6_set)
15988 errmsg ("both eid v4 and v6 addresses set");
15992 if (!ipv4_set && !ipv6_set)
15994 errmsg ("eid addresses not set");
15998 /* Construct the API message */
15999 M (ONE_ADD_DEL_MAP_SERVER, mp);
16001 mp->is_add = is_add;
16005 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16010 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16016 /* Wait for a reply... */
16021 #define api_lisp_add_del_map_server api_one_add_del_map_server
16024 api_one_add_del_map_resolver (vat_main_t * vam)
16026 unformat_input_t *input = vam->input;
16027 vl_api_one_add_del_map_resolver_t *mp;
16031 ip4_address_t ipv4;
16032 ip6_address_t ipv6;
16035 /* Parse args required to build the message */
16036 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16038 if (unformat (input, "del"))
16042 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16046 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16054 if (ipv4_set && ipv6_set)
16056 errmsg ("both eid v4 and v6 addresses set");
16060 if (!ipv4_set && !ipv6_set)
16062 errmsg ("eid addresses not set");
16066 /* Construct the API message */
16067 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
16069 mp->is_add = is_add;
16073 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16078 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16084 /* Wait for a reply... */
16089 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
16092 api_lisp_gpe_enable_disable (vat_main_t * vam)
16094 unformat_input_t *input = vam->input;
16095 vl_api_gpe_enable_disable_t *mp;
16100 /* Parse args required to build the message */
16101 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16103 if (unformat (input, "enable"))
16108 else if (unformat (input, "disable"))
16119 errmsg ("Value not set");
16123 /* Construct the API message */
16124 M (GPE_ENABLE_DISABLE, mp);
16131 /* Wait for a reply... */
16137 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16139 unformat_input_t *input = vam->input;
16140 vl_api_one_rloc_probe_enable_disable_t *mp;
16145 /* Parse args required to build the message */
16146 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16148 if (unformat (input, "enable"))
16153 else if (unformat (input, "disable"))
16161 errmsg ("Value not set");
16165 /* Construct the API message */
16166 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16168 mp->is_enabled = is_en;
16173 /* Wait for a reply... */
16178 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16181 api_one_map_register_enable_disable (vat_main_t * vam)
16183 unformat_input_t *input = vam->input;
16184 vl_api_one_map_register_enable_disable_t *mp;
16189 /* Parse args required to build the message */
16190 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16192 if (unformat (input, "enable"))
16197 else if (unformat (input, "disable"))
16205 errmsg ("Value not set");
16209 /* Construct the API message */
16210 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16212 mp->is_enabled = is_en;
16217 /* Wait for a reply... */
16222 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16225 api_one_enable_disable (vat_main_t * vam)
16227 unformat_input_t *input = vam->input;
16228 vl_api_one_enable_disable_t *mp;
16233 /* Parse args required to build the message */
16234 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16236 if (unformat (input, "enable"))
16241 else if (unformat (input, "disable"))
16251 errmsg ("Value not set");
16255 /* Construct the API message */
16256 M (ONE_ENABLE_DISABLE, mp);
16263 /* Wait for a reply... */
16268 #define api_lisp_enable_disable api_one_enable_disable
16271 api_show_one_map_register_state (vat_main_t * vam)
16273 vl_api_show_one_map_register_state_t *mp;
16276 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16281 /* wait for reply */
16286 #define api_show_lisp_map_register_state api_show_one_map_register_state
16289 api_show_one_rloc_probe_state (vat_main_t * vam)
16291 vl_api_show_one_rloc_probe_state_t *mp;
16294 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16299 /* wait for reply */
16304 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16307 api_one_add_del_ndp_entry (vat_main_t * vam)
16309 vl_api_one_add_del_ndp_entry_t *mp;
16310 unformat_input_t *input = vam->input;
16315 u8 mac[6] = { 0, };
16316 u8 ip6[16] = { 0, };
16320 /* Parse args required to build the message */
16321 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16323 if (unformat (input, "del"))
16325 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16327 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16329 else if (unformat (input, "bd %d", &bd))
16333 errmsg ("parse error '%U'", format_unformat_error, input);
16338 if (!bd_set || !ip_set || (!mac_set && is_add))
16340 errmsg ("Missing BD, IP or MAC!");
16344 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16345 mp->is_add = is_add;
16346 clib_memcpy (mp->mac, mac, 6);
16347 mp->bd = clib_host_to_net_u32 (bd);
16348 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16353 /* wait for reply */
16359 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16361 vl_api_one_add_del_l2_arp_entry_t *mp;
16362 unformat_input_t *input = vam->input;
16367 u8 mac[6] = { 0, };
16368 u32 ip4 = 0, bd = ~0;
16371 /* Parse args required to build the message */
16372 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16374 if (unformat (input, "del"))
16376 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16378 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16380 else if (unformat (input, "bd %d", &bd))
16384 errmsg ("parse error '%U'", format_unformat_error, input);
16389 if (!bd_set || !ip_set || (!mac_set && is_add))
16391 errmsg ("Missing BD, IP or MAC!");
16395 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16396 mp->is_add = is_add;
16397 clib_memcpy (mp->mac, mac, 6);
16398 mp->bd = clib_host_to_net_u32 (bd);
16404 /* wait for reply */
16410 api_one_ndp_bd_get (vat_main_t * vam)
16412 vl_api_one_ndp_bd_get_t *mp;
16415 M (ONE_NDP_BD_GET, mp);
16420 /* wait for reply */
16426 api_one_ndp_entries_get (vat_main_t * vam)
16428 vl_api_one_ndp_entries_get_t *mp;
16429 unformat_input_t *input = vam->input;
16434 /* Parse args required to build the message */
16435 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16437 if (unformat (input, "bd %d", &bd))
16441 errmsg ("parse error '%U'", format_unformat_error, input);
16448 errmsg ("Expected bridge domain!");
16452 M (ONE_NDP_ENTRIES_GET, mp);
16453 mp->bd = clib_host_to_net_u32 (bd);
16458 /* wait for reply */
16464 api_one_l2_arp_bd_get (vat_main_t * vam)
16466 vl_api_one_l2_arp_bd_get_t *mp;
16469 M (ONE_L2_ARP_BD_GET, mp);
16474 /* wait for reply */
16480 api_one_l2_arp_entries_get (vat_main_t * vam)
16482 vl_api_one_l2_arp_entries_get_t *mp;
16483 unformat_input_t *input = vam->input;
16488 /* Parse args required to build the message */
16489 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16491 if (unformat (input, "bd %d", &bd))
16495 errmsg ("parse error '%U'", format_unformat_error, input);
16502 errmsg ("Expected bridge domain!");
16506 M (ONE_L2_ARP_ENTRIES_GET, mp);
16507 mp->bd = clib_host_to_net_u32 (bd);
16512 /* wait for reply */
16518 api_one_stats_enable_disable (vat_main_t * vam)
16520 vl_api_one_stats_enable_disable_t *mp;
16521 unformat_input_t *input = vam->input;
16526 /* Parse args required to build the message */
16527 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16529 if (unformat (input, "enable"))
16534 else if (unformat (input, "disable"))
16544 errmsg ("Value not set");
16548 M (ONE_STATS_ENABLE_DISABLE, mp);
16554 /* wait for reply */
16560 api_show_one_stats_enable_disable (vat_main_t * vam)
16562 vl_api_show_one_stats_enable_disable_t *mp;
16565 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16570 /* wait for reply */
16576 api_show_one_map_request_mode (vat_main_t * vam)
16578 vl_api_show_one_map_request_mode_t *mp;
16581 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16586 /* wait for reply */
16591 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16594 api_one_map_request_mode (vat_main_t * vam)
16596 unformat_input_t *input = vam->input;
16597 vl_api_one_map_request_mode_t *mp;
16601 /* Parse args required to build the message */
16602 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16604 if (unformat (input, "dst-only"))
16606 else if (unformat (input, "src-dst"))
16610 errmsg ("parse error '%U'", format_unformat_error, input);
16615 M (ONE_MAP_REQUEST_MODE, mp);
16622 /* wait for reply */
16627 #define api_lisp_map_request_mode api_one_map_request_mode
16630 * Enable/disable ONE proxy ITR.
16632 * @param vam vpp API test context
16633 * @return return code
16636 api_one_pitr_set_locator_set (vat_main_t * vam)
16638 u8 ls_name_set = 0;
16639 unformat_input_t *input = vam->input;
16640 vl_api_one_pitr_set_locator_set_t *mp;
16645 /* Parse args required to build the message */
16646 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16648 if (unformat (input, "del"))
16650 else if (unformat (input, "locator-set %s", &ls_name))
16654 errmsg ("parse error '%U'", format_unformat_error, input);
16661 errmsg ("locator-set name not set!");
16665 M (ONE_PITR_SET_LOCATOR_SET, mp);
16667 mp->is_add = is_add;
16668 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16669 vec_free (ls_name);
16674 /* wait for reply */
16679 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16682 api_one_nsh_set_locator_set (vat_main_t * vam)
16684 u8 ls_name_set = 0;
16685 unformat_input_t *input = vam->input;
16686 vl_api_one_nsh_set_locator_set_t *mp;
16691 /* Parse args required to build the message */
16692 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16694 if (unformat (input, "del"))
16696 else if (unformat (input, "ls %s", &ls_name))
16700 errmsg ("parse error '%U'", format_unformat_error, input);
16705 if (!ls_name_set && is_add)
16707 errmsg ("locator-set name not set!");
16711 M (ONE_NSH_SET_LOCATOR_SET, mp);
16713 mp->is_add = is_add;
16714 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16715 vec_free (ls_name);
16720 /* wait for reply */
16726 api_show_one_pitr (vat_main_t * vam)
16728 vl_api_show_one_pitr_t *mp;
16731 if (!vam->json_output)
16733 print (vam->ofp, "%=20s", "lisp status:");
16736 M (SHOW_ONE_PITR, mp);
16740 /* Wait for a reply... */
16745 #define api_show_lisp_pitr api_show_one_pitr
16748 api_one_use_petr (vat_main_t * vam)
16750 unformat_input_t *input = vam->input;
16751 vl_api_one_use_petr_t *mp;
16756 memset (&ip, 0, sizeof (ip));
16758 /* Parse args required to build the message */
16759 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16761 if (unformat (input, "disable"))
16764 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16767 ip_addr_version (&ip) = IP4;
16770 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16773 ip_addr_version (&ip) = IP6;
16777 errmsg ("parse error '%U'", format_unformat_error, input);
16782 M (ONE_USE_PETR, mp);
16784 mp->is_add = is_add;
16787 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16789 clib_memcpy (mp->address, &ip, 4);
16791 clib_memcpy (mp->address, &ip, 16);
16797 /* wait for reply */
16802 #define api_lisp_use_petr api_one_use_petr
16805 api_show_one_nsh_mapping (vat_main_t * vam)
16807 vl_api_show_one_use_petr_t *mp;
16810 if (!vam->json_output)
16812 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16815 M (SHOW_ONE_NSH_MAPPING, mp);
16819 /* Wait for a reply... */
16825 api_show_one_use_petr (vat_main_t * vam)
16827 vl_api_show_one_use_petr_t *mp;
16830 if (!vam->json_output)
16832 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16835 M (SHOW_ONE_USE_PETR, mp);
16839 /* Wait for a reply... */
16844 #define api_show_lisp_use_petr api_show_one_use_petr
16847 * Add/delete mapping between vni and vrf
16850 api_one_eid_table_add_del_map (vat_main_t * vam)
16852 unformat_input_t *input = vam->input;
16853 vl_api_one_eid_table_add_del_map_t *mp;
16854 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16855 u32 vni, vrf, bd_index;
16858 /* Parse args required to build the message */
16859 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16861 if (unformat (input, "del"))
16863 else if (unformat (input, "vrf %d", &vrf))
16865 else if (unformat (input, "bd_index %d", &bd_index))
16867 else if (unformat (input, "vni %d", &vni))
16873 if (!vni_set || (!vrf_set && !bd_index_set))
16875 errmsg ("missing arguments!");
16879 if (vrf_set && bd_index_set)
16881 errmsg ("error: both vrf and bd entered!");
16885 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16887 mp->is_add = is_add;
16888 mp->vni = htonl (vni);
16889 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16890 mp->is_l2 = bd_index_set;
16895 /* wait for reply */
16900 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16903 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16905 u32 *action = va_arg (*args, u32 *);
16908 if (unformat (input, "%s", &s))
16910 if (!strcmp ((char *) s, "no-action"))
16912 else if (!strcmp ((char *) s, "natively-forward"))
16914 else if (!strcmp ((char *) s, "send-map-request"))
16916 else if (!strcmp ((char *) s, "drop"))
16920 clib_warning ("invalid action: '%s'", s);
16932 * Add/del remote mapping to/from ONE control plane
16934 * @param vam vpp API test context
16935 * @return return code
16938 api_one_add_del_remote_mapping (vat_main_t * vam)
16940 unformat_input_t *input = vam->input;
16941 vl_api_one_add_del_remote_mapping_t *mp;
16943 lisp_eid_vat_t _eid, *eid = &_eid;
16944 lisp_eid_vat_t _seid, *seid = &_seid;
16945 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16946 u32 action = ~0, p, w, data_len;
16947 ip4_address_t rloc4;
16948 ip6_address_t rloc6;
16949 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16952 memset (&rloc, 0, sizeof (rloc));
16954 /* Parse args required to build the message */
16955 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16957 if (unformat (input, "del-all"))
16961 else if (unformat (input, "del"))
16965 else if (unformat (input, "add"))
16969 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16973 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16977 else if (unformat (input, "vni %d", &vni))
16981 else if (unformat (input, "p %d w %d", &p, &w))
16985 errmsg ("No RLOC configured for setting priority/weight!");
16988 curr_rloc->priority = p;
16989 curr_rloc->weight = w;
16991 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16994 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
16995 vec_add1 (rlocs, rloc);
16996 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16998 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
17001 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
17002 vec_add1 (rlocs, rloc);
17003 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17005 else if (unformat (input, "action %U",
17006 unformat_negative_mapping_action, &action))
17012 clib_warning ("parse error '%U'", format_unformat_error, input);
17019 errmsg ("missing params!");
17023 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
17025 errmsg ("no action set for negative map-reply!");
17029 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
17031 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
17032 mp->is_add = is_add;
17033 mp->vni = htonl (vni);
17034 mp->action = (u8) action;
17035 mp->is_src_dst = seid_set;
17036 mp->eid_len = eid->len;
17037 mp->seid_len = seid->len;
17038 mp->del_all = del_all;
17039 mp->eid_type = eid->type;
17040 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17041 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
17043 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
17044 clib_memcpy (mp->rlocs, rlocs, data_len);
17050 /* Wait for a reply... */
17055 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
17058 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
17059 * forwarding entries in data-plane accordingly.
17061 * @param vam vpp API test context
17062 * @return return code
17065 api_one_add_del_adjacency (vat_main_t * vam)
17067 unformat_input_t *input = vam->input;
17068 vl_api_one_add_del_adjacency_t *mp;
17070 ip4_address_t leid4, reid4;
17071 ip6_address_t leid6, reid6;
17072 u8 reid_mac[6] = { 0 };
17073 u8 leid_mac[6] = { 0 };
17074 u8 reid_type, leid_type;
17075 u32 leid_len = 0, reid_len = 0, len;
17079 leid_type = reid_type = (u8) ~ 0;
17081 /* Parse args required to build the message */
17082 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17084 if (unformat (input, "del"))
17088 else if (unformat (input, "add"))
17092 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17095 reid_type = 0; /* ipv4 */
17098 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17101 reid_type = 1; /* ipv6 */
17104 else if (unformat (input, "reid %U", unformat_ethernet_address,
17107 reid_type = 2; /* mac */
17109 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17112 leid_type = 0; /* ipv4 */
17115 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17118 leid_type = 1; /* ipv6 */
17121 else if (unformat (input, "leid %U", unformat_ethernet_address,
17124 leid_type = 2; /* mac */
17126 else if (unformat (input, "vni %d", &vni))
17132 errmsg ("parse error '%U'", format_unformat_error, input);
17137 if ((u8) ~ 0 == reid_type)
17139 errmsg ("missing params!");
17143 if (leid_type != reid_type)
17145 errmsg ("remote and local EIDs are of different types!");
17149 M (ONE_ADD_DEL_ADJACENCY, mp);
17150 mp->is_add = is_add;
17151 mp->vni = htonl (vni);
17152 mp->leid_len = leid_len;
17153 mp->reid_len = reid_len;
17154 mp->eid_type = reid_type;
17156 switch (mp->eid_type)
17159 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17160 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17163 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17164 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17167 clib_memcpy (mp->leid, leid_mac, 6);
17168 clib_memcpy (mp->reid, reid_mac, 6);
17171 errmsg ("unknown EID type %d!", mp->eid_type);
17178 /* Wait for a reply... */
17183 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17186 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17188 u32 *mode = va_arg (*args, u32 *);
17190 if (unformat (input, "lisp"))
17192 else if (unformat (input, "vxlan"))
17201 api_gpe_get_encap_mode (vat_main_t * vam)
17203 vl_api_gpe_get_encap_mode_t *mp;
17206 /* Construct the API message */
17207 M (GPE_GET_ENCAP_MODE, mp);
17212 /* Wait for a reply... */
17218 api_gpe_set_encap_mode (vat_main_t * vam)
17220 unformat_input_t *input = vam->input;
17221 vl_api_gpe_set_encap_mode_t *mp;
17225 /* Parse args required to build the message */
17226 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17228 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17234 /* Construct the API message */
17235 M (GPE_SET_ENCAP_MODE, mp);
17242 /* Wait for a reply... */
17248 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17250 unformat_input_t *input = vam->input;
17251 vl_api_gpe_add_del_iface_t *mp;
17252 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17253 u32 dp_table = 0, vni = 0;
17256 /* Parse args required to build the message */
17257 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17259 if (unformat (input, "up"))
17264 else if (unformat (input, "down"))
17269 else if (unformat (input, "table_id %d", &dp_table))
17273 else if (unformat (input, "bd_id %d", &dp_table))
17278 else if (unformat (input, "vni %d", &vni))
17286 if (action_set == 0)
17288 errmsg ("Action not set");
17291 if (dp_table_set == 0 || vni_set == 0)
17293 errmsg ("vni and dp_table must be set");
17297 /* Construct the API message */
17298 M (GPE_ADD_DEL_IFACE, mp);
17300 mp->is_add = is_add;
17301 mp->dp_table = clib_host_to_net_u32 (dp_table);
17303 mp->vni = clib_host_to_net_u32 (vni);
17308 /* Wait for a reply... */
17314 api_one_map_register_fallback_threshold (vat_main_t * vam)
17316 unformat_input_t *input = vam->input;
17317 vl_api_one_map_register_fallback_threshold_t *mp;
17322 /* Parse args required to build the message */
17323 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17325 if (unformat (input, "%u", &value))
17329 clib_warning ("parse error '%U'", format_unformat_error, input);
17336 errmsg ("fallback threshold value is missing!");
17340 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17341 mp->value = clib_host_to_net_u32 (value);
17346 /* Wait for a reply... */
17352 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17354 vl_api_show_one_map_register_fallback_threshold_t *mp;
17357 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17362 /* Wait for a reply... */
17368 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17370 u32 *proto = va_arg (*args, u32 *);
17372 if (unformat (input, "udp"))
17374 else if (unformat (input, "api"))
17383 api_one_set_transport_protocol (vat_main_t * vam)
17385 unformat_input_t *input = vam->input;
17386 vl_api_one_set_transport_protocol_t *mp;
17391 /* Parse args required to build the message */
17392 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17394 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17398 clib_warning ("parse error '%U'", format_unformat_error, input);
17405 errmsg ("Transport protocol missing!");
17409 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17410 mp->protocol = (u8) protocol;
17415 /* Wait for a reply... */
17421 api_one_get_transport_protocol (vat_main_t * vam)
17423 vl_api_one_get_transport_protocol_t *mp;
17426 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17431 /* Wait for a reply... */
17437 api_one_map_register_set_ttl (vat_main_t * vam)
17439 unformat_input_t *input = vam->input;
17440 vl_api_one_map_register_set_ttl_t *mp;
17445 /* Parse args required to build the message */
17446 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17448 if (unformat (input, "%u", &ttl))
17452 clib_warning ("parse error '%U'", format_unformat_error, input);
17459 errmsg ("TTL value missing!");
17463 M (ONE_MAP_REGISTER_SET_TTL, mp);
17464 mp->ttl = clib_host_to_net_u32 (ttl);
17469 /* Wait for a reply... */
17475 api_show_one_map_register_ttl (vat_main_t * vam)
17477 vl_api_show_one_map_register_ttl_t *mp;
17480 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17485 /* Wait for a reply... */
17491 * Add/del map request itr rlocs from ONE control plane and updates
17493 * @param vam vpp API test context
17494 * @return return code
17497 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17499 unformat_input_t *input = vam->input;
17500 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17501 u8 *locator_set_name = 0;
17502 u8 locator_set_name_set = 0;
17506 /* Parse args required to build the message */
17507 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17509 if (unformat (input, "del"))
17513 else if (unformat (input, "%_%v%_", &locator_set_name))
17515 locator_set_name_set = 1;
17519 clib_warning ("parse error '%U'", format_unformat_error, input);
17524 if (is_add && !locator_set_name_set)
17526 errmsg ("itr-rloc is not set!");
17530 if (is_add && vec_len (locator_set_name) > 64)
17532 errmsg ("itr-rloc locator-set name too long");
17533 vec_free (locator_set_name);
17537 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17538 mp->is_add = is_add;
17541 clib_memcpy (mp->locator_set_name, locator_set_name,
17542 vec_len (locator_set_name));
17546 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17548 vec_free (locator_set_name);
17553 /* Wait for a reply... */
17558 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17561 api_one_locator_dump (vat_main_t * vam)
17563 unformat_input_t *input = vam->input;
17564 vl_api_one_locator_dump_t *mp;
17565 vl_api_control_ping_t *mp_ping;
17566 u8 is_index_set = 0, is_name_set = 0;
17571 /* Parse args required to build the message */
17572 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17574 if (unformat (input, "ls_name %_%v%_", &ls_name))
17578 else if (unformat (input, "ls_index %d", &ls_index))
17584 errmsg ("parse error '%U'", format_unformat_error, input);
17589 if (!is_index_set && !is_name_set)
17591 errmsg ("error: expected one of index or name!");
17595 if (is_index_set && is_name_set)
17597 errmsg ("error: only one param expected!");
17601 if (vec_len (ls_name) > 62)
17603 errmsg ("error: locator set name too long!");
17607 if (!vam->json_output)
17609 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17612 M (ONE_LOCATOR_DUMP, mp);
17613 mp->is_index_set = is_index_set;
17616 mp->ls_index = clib_host_to_net_u32 (ls_index);
17619 vec_add1 (ls_name, 0);
17620 strncpy ((char *) mp->ls_name, (char *) ls_name,
17621 sizeof (mp->ls_name) - 1);
17627 /* Use a control ping for synchronization */
17628 MPING (CONTROL_PING, mp_ping);
17631 /* Wait for a reply... */
17636 #define api_lisp_locator_dump api_one_locator_dump
17639 api_one_locator_set_dump (vat_main_t * vam)
17641 vl_api_one_locator_set_dump_t *mp;
17642 vl_api_control_ping_t *mp_ping;
17643 unformat_input_t *input = vam->input;
17647 /* Parse args required to build the message */
17648 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17650 if (unformat (input, "local"))
17654 else if (unformat (input, "remote"))
17660 errmsg ("parse error '%U'", format_unformat_error, input);
17665 if (!vam->json_output)
17667 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17670 M (ONE_LOCATOR_SET_DUMP, mp);
17672 mp->filter = filter;
17677 /* Use a control ping for synchronization */
17678 MPING (CONTROL_PING, mp_ping);
17681 /* Wait for a reply... */
17686 #define api_lisp_locator_set_dump api_one_locator_set_dump
17689 api_one_eid_table_map_dump (vat_main_t * vam)
17693 unformat_input_t *input = vam->input;
17694 vl_api_one_eid_table_map_dump_t *mp;
17695 vl_api_control_ping_t *mp_ping;
17698 /* Parse args required to build the message */
17699 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17701 if (unformat (input, "l2"))
17706 else if (unformat (input, "l3"))
17713 errmsg ("parse error '%U'", format_unformat_error, input);
17720 errmsg ("expected one of 'l2' or 'l3' parameter!");
17724 if (!vam->json_output)
17726 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17729 M (ONE_EID_TABLE_MAP_DUMP, mp);
17735 /* Use a control ping for synchronization */
17736 MPING (CONTROL_PING, mp_ping);
17739 /* Wait for a reply... */
17744 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17747 api_one_eid_table_vni_dump (vat_main_t * vam)
17749 vl_api_one_eid_table_vni_dump_t *mp;
17750 vl_api_control_ping_t *mp_ping;
17753 if (!vam->json_output)
17755 print (vam->ofp, "VNI");
17758 M (ONE_EID_TABLE_VNI_DUMP, mp);
17763 /* Use a control ping for synchronization */
17764 MPING (CONTROL_PING, mp_ping);
17767 /* Wait for a reply... */
17772 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17775 api_one_eid_table_dump (vat_main_t * vam)
17777 unformat_input_t *i = vam->input;
17778 vl_api_one_eid_table_dump_t *mp;
17779 vl_api_control_ping_t *mp_ping;
17780 struct in_addr ip4;
17781 struct in6_addr ip6;
17783 u8 eid_type = ~0, eid_set = 0;
17784 u32 prefix_length = ~0, t, vni = 0;
17787 lisp_nsh_api_t nsh;
17789 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17791 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17797 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17803 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17808 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17813 else if (unformat (i, "vni %d", &t))
17817 else if (unformat (i, "local"))
17821 else if (unformat (i, "remote"))
17827 errmsg ("parse error '%U'", format_unformat_error, i);
17832 if (!vam->json_output)
17834 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17835 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17838 M (ONE_EID_TABLE_DUMP, mp);
17840 mp->filter = filter;
17844 mp->vni = htonl (vni);
17845 mp->eid_type = eid_type;
17849 mp->prefix_length = prefix_length;
17850 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17853 mp->prefix_length = prefix_length;
17854 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17857 clib_memcpy (mp->eid, mac, sizeof (mac));
17860 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17863 errmsg ("unknown EID type %d!", eid_type);
17871 /* Use a control ping for synchronization */
17872 MPING (CONTROL_PING, mp_ping);
17875 /* Wait for a reply... */
17880 #define api_lisp_eid_table_dump api_one_eid_table_dump
17883 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17885 unformat_input_t *i = vam->input;
17886 vl_api_gpe_fwd_entries_get_t *mp;
17891 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17893 if (unformat (i, "vni %d", &vni))
17899 errmsg ("parse error '%U'", format_unformat_error, i);
17906 errmsg ("vni not set!");
17910 if (!vam->json_output)
17912 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17916 M (GPE_FWD_ENTRIES_GET, mp);
17917 mp->vni = clib_host_to_net_u32 (vni);
17922 /* Wait for a reply... */
17927 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17928 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17929 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17930 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17931 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17932 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17933 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17934 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17937 api_one_adjacencies_get (vat_main_t * vam)
17939 unformat_input_t *i = vam->input;
17940 vl_api_one_adjacencies_get_t *mp;
17945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17947 if (unformat (i, "vni %d", &vni))
17953 errmsg ("parse error '%U'", format_unformat_error, i);
17960 errmsg ("vni not set!");
17964 if (!vam->json_output)
17966 print (vam->ofp, "%s %40s", "leid", "reid");
17969 M (ONE_ADJACENCIES_GET, mp);
17970 mp->vni = clib_host_to_net_u32 (vni);
17975 /* Wait for a reply... */
17980 #define api_lisp_adjacencies_get api_one_adjacencies_get
17983 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
17985 unformat_input_t *i = vam->input;
17986 vl_api_gpe_native_fwd_rpaths_get_t *mp;
17988 u8 ip_family_set = 0, is_ip4 = 1;
17990 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17992 if (unformat (i, "ip4"))
17997 else if (unformat (i, "ip6"))
18004 errmsg ("parse error '%U'", format_unformat_error, i);
18009 if (!ip_family_set)
18011 errmsg ("ip family not set!");
18015 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
18016 mp->is_ip4 = is_ip4;
18021 /* Wait for a reply... */
18027 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
18029 vl_api_gpe_fwd_entry_vnis_get_t *mp;
18032 if (!vam->json_output)
18034 print (vam->ofp, "VNIs");
18037 M (GPE_FWD_ENTRY_VNIS_GET, mp);
18042 /* Wait for a reply... */
18048 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
18050 unformat_input_t *i = vam->input;
18051 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
18053 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
18054 struct in_addr ip4;
18055 struct in6_addr ip6;
18056 u32 table_id = 0, nh_sw_if_index = ~0;
18058 memset (&ip4, 0, sizeof (ip4));
18059 memset (&ip6, 0, sizeof (ip6));
18061 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18063 if (unformat (i, "del"))
18065 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
18066 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18071 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
18072 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18077 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18081 nh_sw_if_index = ~0;
18083 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18087 nh_sw_if_index = ~0;
18089 else if (unformat (i, "table %d", &table_id))
18093 errmsg ("parse error '%U'", format_unformat_error, i);
18100 errmsg ("nh addr not set!");
18104 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18105 mp->is_add = is_add;
18106 mp->table_id = clib_host_to_net_u32 (table_id);
18107 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18108 mp->is_ip4 = is_ip4;
18110 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18112 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18117 /* Wait for a reply... */
18123 api_one_map_server_dump (vat_main_t * vam)
18125 vl_api_one_map_server_dump_t *mp;
18126 vl_api_control_ping_t *mp_ping;
18129 if (!vam->json_output)
18131 print (vam->ofp, "%=20s", "Map server");
18134 M (ONE_MAP_SERVER_DUMP, mp);
18138 /* Use a control ping for synchronization */
18139 MPING (CONTROL_PING, mp_ping);
18142 /* Wait for a reply... */
18147 #define api_lisp_map_server_dump api_one_map_server_dump
18150 api_one_map_resolver_dump (vat_main_t * vam)
18152 vl_api_one_map_resolver_dump_t *mp;
18153 vl_api_control_ping_t *mp_ping;
18156 if (!vam->json_output)
18158 print (vam->ofp, "%=20s", "Map resolver");
18161 M (ONE_MAP_RESOLVER_DUMP, mp);
18165 /* Use a control ping for synchronization */
18166 MPING (CONTROL_PING, mp_ping);
18169 /* Wait for a reply... */
18174 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18177 api_one_stats_flush (vat_main_t * vam)
18179 vl_api_one_stats_flush_t *mp;
18182 M (ONE_STATS_FLUSH, mp);
18189 api_one_stats_dump (vat_main_t * vam)
18191 vl_api_one_stats_dump_t *mp;
18192 vl_api_control_ping_t *mp_ping;
18195 M (ONE_STATS_DUMP, mp);
18199 /* Use a control ping for synchronization */
18200 MPING (CONTROL_PING, mp_ping);
18203 /* Wait for a reply... */
18209 api_show_one_status (vat_main_t * vam)
18211 vl_api_show_one_status_t *mp;
18214 if (!vam->json_output)
18216 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18219 M (SHOW_ONE_STATUS, mp);
18222 /* Wait for a reply... */
18227 #define api_show_lisp_status api_show_one_status
18230 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18232 vl_api_gpe_fwd_entry_path_dump_t *mp;
18233 vl_api_control_ping_t *mp_ping;
18234 unformat_input_t *i = vam->input;
18235 u32 fwd_entry_index = ~0;
18238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18240 if (unformat (i, "index %d", &fwd_entry_index))
18246 if (~0 == fwd_entry_index)
18248 errmsg ("no index specified!");
18252 if (!vam->json_output)
18254 print (vam->ofp, "first line");
18257 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18261 /* Use a control ping for synchronization */
18262 MPING (CONTROL_PING, mp_ping);
18265 /* Wait for a reply... */
18271 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18273 vl_api_one_get_map_request_itr_rlocs_t *mp;
18276 if (!vam->json_output)
18278 print (vam->ofp, "%=20s", "itr-rlocs:");
18281 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18284 /* Wait for a reply... */
18289 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18292 api_af_packet_create (vat_main_t * vam)
18294 unformat_input_t *i = vam->input;
18295 vl_api_af_packet_create_t *mp;
18296 u8 *host_if_name = 0;
18298 u8 random_hw_addr = 1;
18301 memset (hw_addr, 0, sizeof (hw_addr));
18303 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18305 if (unformat (i, "name %s", &host_if_name))
18306 vec_add1 (host_if_name, 0);
18307 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18308 random_hw_addr = 0;
18313 if (!vec_len (host_if_name))
18315 errmsg ("host-interface name must be specified");
18319 if (vec_len (host_if_name) > 64)
18321 errmsg ("host-interface name too long");
18325 M (AF_PACKET_CREATE, mp);
18327 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18328 clib_memcpy (mp->hw_addr, hw_addr, 6);
18329 mp->use_random_hw_addr = random_hw_addr;
18330 vec_free (host_if_name);
18338 fprintf (vam->ofp ? vam->ofp : stderr,
18339 " new sw_if_index = %d\n", vam->sw_if_index);
18346 api_af_packet_delete (vat_main_t * vam)
18348 unformat_input_t *i = vam->input;
18349 vl_api_af_packet_delete_t *mp;
18350 u8 *host_if_name = 0;
18353 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18355 if (unformat (i, "name %s", &host_if_name))
18356 vec_add1 (host_if_name, 0);
18361 if (!vec_len (host_if_name))
18363 errmsg ("host-interface name must be specified");
18367 if (vec_len (host_if_name) > 64)
18369 errmsg ("host-interface name too long");
18373 M (AF_PACKET_DELETE, mp);
18375 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18376 vec_free (host_if_name);
18384 api_policer_add_del (vat_main_t * vam)
18386 unformat_input_t *i = vam->input;
18387 vl_api_policer_add_del_t *mp;
18397 u8 color_aware = 0;
18398 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18401 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18402 conform_action.dscp = 0;
18403 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18404 exceed_action.dscp = 0;
18405 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18406 violate_action.dscp = 0;
18408 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18410 if (unformat (i, "del"))
18412 else if (unformat (i, "name %s", &name))
18413 vec_add1 (name, 0);
18414 else if (unformat (i, "cir %u", &cir))
18416 else if (unformat (i, "eir %u", &eir))
18418 else if (unformat (i, "cb %u", &cb))
18420 else if (unformat (i, "eb %u", &eb))
18422 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18425 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18428 else if (unformat (i, "type %U", unformat_policer_type, &type))
18430 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18433 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18436 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18439 else if (unformat (i, "color-aware"))
18445 if (!vec_len (name))
18447 errmsg ("policer name must be specified");
18451 if (vec_len (name) > 64)
18453 errmsg ("policer name too long");
18457 M (POLICER_ADD_DEL, mp);
18459 clib_memcpy (mp->name, name, vec_len (name));
18461 mp->is_add = is_add;
18462 mp->cir = ntohl (cir);
18463 mp->eir = ntohl (eir);
18464 mp->cb = clib_net_to_host_u64 (cb);
18465 mp->eb = clib_net_to_host_u64 (eb);
18466 mp->rate_type = rate_type;
18467 mp->round_type = round_type;
18469 mp->conform_action_type = conform_action.action_type;
18470 mp->conform_dscp = conform_action.dscp;
18471 mp->exceed_action_type = exceed_action.action_type;
18472 mp->exceed_dscp = exceed_action.dscp;
18473 mp->violate_action_type = violate_action.action_type;
18474 mp->violate_dscp = violate_action.dscp;
18475 mp->color_aware = color_aware;
18483 api_policer_dump (vat_main_t * vam)
18485 unformat_input_t *i = vam->input;
18486 vl_api_policer_dump_t *mp;
18487 vl_api_control_ping_t *mp_ping;
18488 u8 *match_name = 0;
18489 u8 match_name_valid = 0;
18492 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18494 if (unformat (i, "name %s", &match_name))
18496 vec_add1 (match_name, 0);
18497 match_name_valid = 1;
18503 M (POLICER_DUMP, mp);
18504 mp->match_name_valid = match_name_valid;
18505 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18506 vec_free (match_name);
18510 /* Use a control ping for synchronization */
18511 MPING (CONTROL_PING, mp_ping);
18514 /* Wait for a reply... */
18520 api_policer_classify_set_interface (vat_main_t * vam)
18522 unformat_input_t *i = vam->input;
18523 vl_api_policer_classify_set_interface_t *mp;
18525 int sw_if_index_set;
18526 u32 ip4_table_index = ~0;
18527 u32 ip6_table_index = ~0;
18528 u32 l2_table_index = ~0;
18532 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18534 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18535 sw_if_index_set = 1;
18536 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18537 sw_if_index_set = 1;
18538 else if (unformat (i, "del"))
18540 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18542 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18544 else if (unformat (i, "l2-table %d", &l2_table_index))
18548 clib_warning ("parse error '%U'", format_unformat_error, i);
18553 if (sw_if_index_set == 0)
18555 errmsg ("missing interface name or sw_if_index");
18559 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18561 mp->sw_if_index = ntohl (sw_if_index);
18562 mp->ip4_table_index = ntohl (ip4_table_index);
18563 mp->ip6_table_index = ntohl (ip6_table_index);
18564 mp->l2_table_index = ntohl (l2_table_index);
18565 mp->is_add = is_add;
18573 api_policer_classify_dump (vat_main_t * vam)
18575 unformat_input_t *i = vam->input;
18576 vl_api_policer_classify_dump_t *mp;
18577 vl_api_control_ping_t *mp_ping;
18578 u8 type = POLICER_CLASSIFY_N_TABLES;
18581 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18585 errmsg ("classify table type must be specified");
18589 if (!vam->json_output)
18591 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18594 M (POLICER_CLASSIFY_DUMP, mp);
18599 /* Use a control ping for synchronization */
18600 MPING (CONTROL_PING, mp_ping);
18603 /* Wait for a reply... */
18609 api_netmap_create (vat_main_t * vam)
18611 unformat_input_t *i = vam->input;
18612 vl_api_netmap_create_t *mp;
18615 u8 random_hw_addr = 1;
18620 memset (hw_addr, 0, sizeof (hw_addr));
18622 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18624 if (unformat (i, "name %s", &if_name))
18625 vec_add1 (if_name, 0);
18626 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18627 random_hw_addr = 0;
18628 else if (unformat (i, "pipe"))
18630 else if (unformat (i, "master"))
18632 else if (unformat (i, "slave"))
18638 if (!vec_len (if_name))
18640 errmsg ("interface name must be specified");
18644 if (vec_len (if_name) > 64)
18646 errmsg ("interface name too long");
18650 M (NETMAP_CREATE, mp);
18652 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18653 clib_memcpy (mp->hw_addr, hw_addr, 6);
18654 mp->use_random_hw_addr = random_hw_addr;
18655 mp->is_pipe = is_pipe;
18656 mp->is_master = is_master;
18657 vec_free (if_name);
18665 api_netmap_delete (vat_main_t * vam)
18667 unformat_input_t *i = vam->input;
18668 vl_api_netmap_delete_t *mp;
18672 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18674 if (unformat (i, "name %s", &if_name))
18675 vec_add1 (if_name, 0);
18680 if (!vec_len (if_name))
18682 errmsg ("interface name must be specified");
18686 if (vec_len (if_name) > 64)
18688 errmsg ("interface name too long");
18692 M (NETMAP_DELETE, mp);
18694 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18695 vec_free (if_name);
18703 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
18705 if (fp->afi == IP46_TYPE_IP6)
18707 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18708 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18709 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18710 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18711 format_ip6_address, fp->next_hop);
18712 else if (fp->afi == IP46_TYPE_IP4)
18714 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18715 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18716 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18717 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18718 format_ip4_address, fp->next_hop);
18722 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18723 vl_api_fib_path2_t * fp)
18725 struct in_addr ip4;
18726 struct in6_addr ip6;
18728 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18729 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18730 vat_json_object_add_uint (node, "is_local", fp->is_local);
18731 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18732 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18733 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18734 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18735 if (fp->afi == IP46_TYPE_IP4)
18737 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18738 vat_json_object_add_ip4 (node, "next_hop", ip4);
18740 else if (fp->afi == IP46_TYPE_IP6)
18742 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18743 vat_json_object_add_ip6 (node, "next_hop", ip6);
18748 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18750 vat_main_t *vam = &vat_main;
18751 int count = ntohl (mp->mt_count);
18752 vl_api_fib_path2_t *fp;
18755 print (vam->ofp, "[%d]: sw_if_index %d via:",
18756 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
18758 for (i = 0; i < count; i++)
18760 vl_api_mpls_fib_path_print (vam, fp);
18764 print (vam->ofp, "");
18767 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18768 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18771 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18773 vat_main_t *vam = &vat_main;
18774 vat_json_node_t *node = NULL;
18775 int count = ntohl (mp->mt_count);
18776 vl_api_fib_path2_t *fp;
18779 if (VAT_JSON_ARRAY != vam->json_tree.type)
18781 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18782 vat_json_init_array (&vam->json_tree);
18784 node = vat_json_array_add (&vam->json_tree);
18786 vat_json_init_object (node);
18787 vat_json_object_add_uint (node, "tunnel_index",
18788 ntohl (mp->mt_tunnel_index));
18789 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
18791 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
18794 for (i = 0; i < count; i++)
18796 vl_api_mpls_fib_path_json_print (node, fp);
18802 api_mpls_tunnel_dump (vat_main_t * vam)
18804 vl_api_mpls_tunnel_dump_t *mp;
18805 vl_api_control_ping_t *mp_ping;
18809 /* Parse args required to build the message */
18810 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
18812 if (!unformat (vam->input, "tunnel_index %d", &index))
18819 print (vam->ofp, " tunnel_index %d", index);
18821 M (MPLS_TUNNEL_DUMP, mp);
18822 mp->tunnel_index = htonl (index);
18825 /* Use a control ping for synchronization */
18826 MPING (CONTROL_PING, mp_ping);
18833 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
18834 #define vl_api_mpls_fib_details_t_print vl_noop_handler
18838 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
18840 vat_main_t *vam = &vat_main;
18841 int count = ntohl (mp->count);
18842 vl_api_fib_path2_t *fp;
18846 "table-id %d, label %u, ess_bit %u",
18847 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
18849 for (i = 0; i < count; i++)
18851 vl_api_mpls_fib_path_print (vam, fp);
18856 static void vl_api_mpls_fib_details_t_handler_json
18857 (vl_api_mpls_fib_details_t * mp)
18859 vat_main_t *vam = &vat_main;
18860 int count = ntohl (mp->count);
18861 vat_json_node_t *node = NULL;
18862 vl_api_fib_path2_t *fp;
18865 if (VAT_JSON_ARRAY != vam->json_tree.type)
18867 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18868 vat_json_init_array (&vam->json_tree);
18870 node = vat_json_array_add (&vam->json_tree);
18872 vat_json_init_object (node);
18873 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18874 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
18875 vat_json_object_add_uint (node, "label", ntohl (mp->label));
18876 vat_json_object_add_uint (node, "path_count", count);
18878 for (i = 0; i < count; i++)
18880 vl_api_mpls_fib_path_json_print (node, fp);
18886 api_mpls_fib_dump (vat_main_t * vam)
18888 vl_api_mpls_fib_dump_t *mp;
18889 vl_api_control_ping_t *mp_ping;
18892 M (MPLS_FIB_DUMP, mp);
18895 /* Use a control ping for synchronization */
18896 MPING (CONTROL_PING, mp_ping);
18903 #define vl_api_ip_fib_details_t_endian vl_noop_handler
18904 #define vl_api_ip_fib_details_t_print vl_noop_handler
18907 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
18909 vat_main_t *vam = &vat_main;
18910 int count = ntohl (mp->count);
18911 vl_api_fib_path_t *fp;
18915 "table-id %d, prefix %U/%d",
18916 ntohl (mp->table_id), format_ip4_address, mp->address,
18917 mp->address_length);
18919 for (i = 0; i < count; i++)
18921 if (fp->afi == IP46_TYPE_IP6)
18923 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18924 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18925 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18926 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18927 format_ip6_address, fp->next_hop);
18928 else if (fp->afi == IP46_TYPE_IP4)
18930 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18931 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18932 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18933 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18934 format_ip4_address, fp->next_hop);
18939 static void vl_api_ip_fib_details_t_handler_json
18940 (vl_api_ip_fib_details_t * mp)
18942 vat_main_t *vam = &vat_main;
18943 int count = ntohl (mp->count);
18944 vat_json_node_t *node = NULL;
18945 struct in_addr ip4;
18946 struct in6_addr ip6;
18947 vl_api_fib_path_t *fp;
18950 if (VAT_JSON_ARRAY != vam->json_tree.type)
18952 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18953 vat_json_init_array (&vam->json_tree);
18955 node = vat_json_array_add (&vam->json_tree);
18957 vat_json_init_object (node);
18958 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18959 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
18960 vat_json_object_add_ip4 (node, "prefix", ip4);
18961 vat_json_object_add_uint (node, "mask_length", mp->address_length);
18962 vat_json_object_add_uint (node, "path_count", count);
18964 for (i = 0; i < count; i++)
18966 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18967 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18968 vat_json_object_add_uint (node, "is_local", fp->is_local);
18969 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18970 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18971 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18972 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18973 if (fp->afi == IP46_TYPE_IP4)
18975 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18976 vat_json_object_add_ip4 (node, "next_hop", ip4);
18978 else if (fp->afi == IP46_TYPE_IP6)
18980 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18981 vat_json_object_add_ip6 (node, "next_hop", ip6);
18987 api_ip_fib_dump (vat_main_t * vam)
18989 vl_api_ip_fib_dump_t *mp;
18990 vl_api_control_ping_t *mp_ping;
18993 M (IP_FIB_DUMP, mp);
18996 /* Use a control ping for synchronization */
18997 MPING (CONTROL_PING, mp_ping);
19005 api_ip_mfib_dump (vat_main_t * vam)
19007 vl_api_ip_mfib_dump_t *mp;
19008 vl_api_control_ping_t *mp_ping;
19011 M (IP_MFIB_DUMP, mp);
19014 /* Use a control ping for synchronization */
19015 MPING (CONTROL_PING, mp_ping);
19022 static void vl_api_ip_neighbor_details_t_handler
19023 (vl_api_ip_neighbor_details_t * mp)
19025 vat_main_t *vam = &vat_main;
19027 print (vam->ofp, "%c %U %U",
19028 (mp->is_static) ? 'S' : 'D',
19029 format_ethernet_address, &mp->mac_address,
19030 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
19034 static void vl_api_ip_neighbor_details_t_handler_json
19035 (vl_api_ip_neighbor_details_t * mp)
19038 vat_main_t *vam = &vat_main;
19039 vat_json_node_t *node;
19040 struct in_addr ip4;
19041 struct in6_addr ip6;
19043 if (VAT_JSON_ARRAY != vam->json_tree.type)
19045 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19046 vat_json_init_array (&vam->json_tree);
19048 node = vat_json_array_add (&vam->json_tree);
19050 vat_json_init_object (node);
19051 vat_json_object_add_string_copy (node, "flag",
19052 (mp->is_static) ? (u8 *) "static" : (u8 *)
19055 vat_json_object_add_string_copy (node, "link_layer",
19056 format (0, "%U", format_ethernet_address,
19057 &mp->mac_address));
19061 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
19062 vat_json_object_add_ip6 (node, "ip_address", ip6);
19066 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
19067 vat_json_object_add_ip4 (node, "ip_address", ip4);
19072 api_ip_neighbor_dump (vat_main_t * vam)
19074 unformat_input_t *i = vam->input;
19075 vl_api_ip_neighbor_dump_t *mp;
19076 vl_api_control_ping_t *mp_ping;
19078 u32 sw_if_index = ~0;
19081 /* Parse args required to build the message */
19082 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19084 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19086 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19088 else if (unformat (i, "ip6"))
19094 if (sw_if_index == ~0)
19096 errmsg ("missing interface name or sw_if_index");
19100 M (IP_NEIGHBOR_DUMP, mp);
19101 mp->is_ipv6 = (u8) is_ipv6;
19102 mp->sw_if_index = ntohl (sw_if_index);
19105 /* Use a control ping for synchronization */
19106 MPING (CONTROL_PING, mp_ping);
19113 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
19114 #define vl_api_ip6_fib_details_t_print vl_noop_handler
19117 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
19119 vat_main_t *vam = &vat_main;
19120 int count = ntohl (mp->count);
19121 vl_api_fib_path_t *fp;
19125 "table-id %d, prefix %U/%d",
19126 ntohl (mp->table_id), format_ip6_address, mp->address,
19127 mp->address_length);
19129 for (i = 0; i < count; i++)
19131 if (fp->afi == IP46_TYPE_IP6)
19133 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19134 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19135 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19136 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19137 format_ip6_address, fp->next_hop);
19138 else if (fp->afi == IP46_TYPE_IP4)
19140 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19141 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19142 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19143 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19144 format_ip4_address, fp->next_hop);
19149 static void vl_api_ip6_fib_details_t_handler_json
19150 (vl_api_ip6_fib_details_t * mp)
19152 vat_main_t *vam = &vat_main;
19153 int count = ntohl (mp->count);
19154 vat_json_node_t *node = NULL;
19155 struct in_addr ip4;
19156 struct in6_addr ip6;
19157 vl_api_fib_path_t *fp;
19160 if (VAT_JSON_ARRAY != vam->json_tree.type)
19162 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19163 vat_json_init_array (&vam->json_tree);
19165 node = vat_json_array_add (&vam->json_tree);
19167 vat_json_init_object (node);
19168 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19169 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
19170 vat_json_object_add_ip6 (node, "prefix", ip6);
19171 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19172 vat_json_object_add_uint (node, "path_count", count);
19174 for (i = 0; i < count; i++)
19176 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19177 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19178 vat_json_object_add_uint (node, "is_local", fp->is_local);
19179 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19180 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19181 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19182 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19183 if (fp->afi == IP46_TYPE_IP4)
19185 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19186 vat_json_object_add_ip4 (node, "next_hop", ip4);
19188 else if (fp->afi == IP46_TYPE_IP6)
19190 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19191 vat_json_object_add_ip6 (node, "next_hop", ip6);
19197 api_ip6_fib_dump (vat_main_t * vam)
19199 vl_api_ip6_fib_dump_t *mp;
19200 vl_api_control_ping_t *mp_ping;
19203 M (IP6_FIB_DUMP, mp);
19206 /* Use a control ping for synchronization */
19207 MPING (CONTROL_PING, mp_ping);
19215 api_ip6_mfib_dump (vat_main_t * vam)
19217 vl_api_ip6_mfib_dump_t *mp;
19218 vl_api_control_ping_t *mp_ping;
19221 M (IP6_MFIB_DUMP, mp);
19224 /* Use a control ping for synchronization */
19225 MPING (CONTROL_PING, mp_ping);
19233 api_classify_table_ids (vat_main_t * vam)
19235 vl_api_classify_table_ids_t *mp;
19238 /* Construct the API message */
19239 M (CLASSIFY_TABLE_IDS, mp);
19248 api_classify_table_by_interface (vat_main_t * vam)
19250 unformat_input_t *input = vam->input;
19251 vl_api_classify_table_by_interface_t *mp;
19253 u32 sw_if_index = ~0;
19255 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19257 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19259 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19264 if (sw_if_index == ~0)
19266 errmsg ("missing interface name or sw_if_index");
19270 /* Construct the API message */
19271 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19273 mp->sw_if_index = ntohl (sw_if_index);
19281 api_classify_table_info (vat_main_t * vam)
19283 unformat_input_t *input = vam->input;
19284 vl_api_classify_table_info_t *mp;
19288 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19290 if (unformat (input, "table_id %d", &table_id))
19295 if (table_id == ~0)
19297 errmsg ("missing table id");
19301 /* Construct the API message */
19302 M (CLASSIFY_TABLE_INFO, mp);
19304 mp->table_id = ntohl (table_id);
19312 api_classify_session_dump (vat_main_t * vam)
19314 unformat_input_t *input = vam->input;
19315 vl_api_classify_session_dump_t *mp;
19316 vl_api_control_ping_t *mp_ping;
19320 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19322 if (unformat (input, "table_id %d", &table_id))
19327 if (table_id == ~0)
19329 errmsg ("missing table id");
19333 /* Construct the API message */
19334 M (CLASSIFY_SESSION_DUMP, mp);
19336 mp->table_id = ntohl (table_id);
19339 /* Use a control ping for synchronization */
19340 MPING (CONTROL_PING, mp_ping);
19348 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19350 vat_main_t *vam = &vat_main;
19352 print (vam->ofp, "collector_address %U, collector_port %d, "
19353 "src_address %U, vrf_id %d, path_mtu %u, "
19354 "template_interval %u, udp_checksum %d",
19355 format_ip4_address, mp->collector_address,
19356 ntohs (mp->collector_port),
19357 format_ip4_address, mp->src_address,
19358 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19359 ntohl (mp->template_interval), mp->udp_checksum);
19362 vam->result_ready = 1;
19366 vl_api_ipfix_exporter_details_t_handler_json
19367 (vl_api_ipfix_exporter_details_t * mp)
19369 vat_main_t *vam = &vat_main;
19370 vat_json_node_t node;
19371 struct in_addr collector_address;
19372 struct in_addr src_address;
19374 vat_json_init_object (&node);
19375 clib_memcpy (&collector_address, &mp->collector_address,
19376 sizeof (collector_address));
19377 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19378 vat_json_object_add_uint (&node, "collector_port",
19379 ntohs (mp->collector_port));
19380 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19381 vat_json_object_add_ip4 (&node, "src_address", src_address);
19382 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19383 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19384 vat_json_object_add_uint (&node, "template_interval",
19385 ntohl (mp->template_interval));
19386 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19388 vat_json_print (vam->ofp, &node);
19389 vat_json_free (&node);
19391 vam->result_ready = 1;
19395 api_ipfix_exporter_dump (vat_main_t * vam)
19397 vl_api_ipfix_exporter_dump_t *mp;
19400 /* Construct the API message */
19401 M (IPFIX_EXPORTER_DUMP, mp);
19410 api_ipfix_classify_stream_dump (vat_main_t * vam)
19412 vl_api_ipfix_classify_stream_dump_t *mp;
19415 /* Construct the API message */
19416 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19427 vl_api_ipfix_classify_stream_details_t_handler
19428 (vl_api_ipfix_classify_stream_details_t * mp)
19430 vat_main_t *vam = &vat_main;
19431 print (vam->ofp, "domain_id %d, src_port %d",
19432 ntohl (mp->domain_id), ntohs (mp->src_port));
19434 vam->result_ready = 1;
19438 vl_api_ipfix_classify_stream_details_t_handler_json
19439 (vl_api_ipfix_classify_stream_details_t * mp)
19441 vat_main_t *vam = &vat_main;
19442 vat_json_node_t node;
19444 vat_json_init_object (&node);
19445 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19446 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19448 vat_json_print (vam->ofp, &node);
19449 vat_json_free (&node);
19451 vam->result_ready = 1;
19455 api_ipfix_classify_table_dump (vat_main_t * vam)
19457 vl_api_ipfix_classify_table_dump_t *mp;
19458 vl_api_control_ping_t *mp_ping;
19461 if (!vam->json_output)
19463 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19464 "transport_protocol");
19467 /* Construct the API message */
19468 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19473 /* Use a control ping for synchronization */
19474 MPING (CONTROL_PING, mp_ping);
19482 vl_api_ipfix_classify_table_details_t_handler
19483 (vl_api_ipfix_classify_table_details_t * mp)
19485 vat_main_t *vam = &vat_main;
19486 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19487 mp->transport_protocol);
19491 vl_api_ipfix_classify_table_details_t_handler_json
19492 (vl_api_ipfix_classify_table_details_t * mp)
19494 vat_json_node_t *node = NULL;
19495 vat_main_t *vam = &vat_main;
19497 if (VAT_JSON_ARRAY != vam->json_tree.type)
19499 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19500 vat_json_init_array (&vam->json_tree);
19503 node = vat_json_array_add (&vam->json_tree);
19504 vat_json_init_object (node);
19506 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19507 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19508 vat_json_object_add_uint (node, "transport_protocol",
19509 mp->transport_protocol);
19513 api_sw_interface_span_enable_disable (vat_main_t * vam)
19515 unformat_input_t *i = vam->input;
19516 vl_api_sw_interface_span_enable_disable_t *mp;
19517 u32 src_sw_if_index = ~0;
19518 u32 dst_sw_if_index = ~0;
19523 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19526 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19528 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19532 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19534 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19536 else if (unformat (i, "disable"))
19538 else if (unformat (i, "rx"))
19540 else if (unformat (i, "tx"))
19542 else if (unformat (i, "both"))
19544 else if (unformat (i, "l2"))
19550 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19552 mp->sw_if_index_from = htonl (src_sw_if_index);
19553 mp->sw_if_index_to = htonl (dst_sw_if_index);
19563 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19566 vat_main_t *vam = &vat_main;
19567 u8 *sw_if_from_name = 0;
19568 u8 *sw_if_to_name = 0;
19569 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19570 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19571 char *states[] = { "none", "rx", "tx", "both" };
19575 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19577 if ((u32) p->value[0] == sw_if_index_from)
19579 sw_if_from_name = (u8 *)(p->key);
19583 if ((u32) p->value[0] == sw_if_index_to)
19585 sw_if_to_name = (u8 *)(p->key);
19586 if (sw_if_from_name)
19591 print (vam->ofp, "%20s => %20s (%s)",
19592 sw_if_from_name, sw_if_to_name, states[mp->state]);
19596 vl_api_sw_interface_span_details_t_handler_json
19597 (vl_api_sw_interface_span_details_t * mp)
19599 vat_main_t *vam = &vat_main;
19600 vat_json_node_t *node = NULL;
19601 u8 *sw_if_from_name = 0;
19602 u8 *sw_if_to_name = 0;
19603 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19604 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19608 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19610 if ((u32) p->value[0] == sw_if_index_from)
19612 sw_if_from_name = (u8 *)(p->key);
19616 if ((u32) p->value[0] == sw_if_index_to)
19618 sw_if_to_name = (u8 *)(p->key);
19619 if (sw_if_from_name)
19625 if (VAT_JSON_ARRAY != vam->json_tree.type)
19627 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19628 vat_json_init_array (&vam->json_tree);
19630 node = vat_json_array_add (&vam->json_tree);
19632 vat_json_init_object (node);
19633 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19634 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19635 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19636 if (0 != sw_if_to_name)
19638 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19640 vat_json_object_add_uint (node, "state", mp->state);
19644 api_sw_interface_span_dump (vat_main_t * vam)
19646 unformat_input_t *input = vam->input;
19647 vl_api_sw_interface_span_dump_t *mp;
19648 vl_api_control_ping_t *mp_ping;
19652 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19654 if (unformat (input, "l2"))
19660 M (SW_INTERFACE_SPAN_DUMP, mp);
19664 /* Use a control ping for synchronization */
19665 MPING (CONTROL_PING, mp_ping);
19673 api_pg_create_interface (vat_main_t * vam)
19675 unformat_input_t *input = vam->input;
19676 vl_api_pg_create_interface_t *mp;
19680 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19682 if (unformat (input, "if_id %d", &if_id))
19689 errmsg ("missing pg interface index");
19693 /* Construct the API message */
19694 M (PG_CREATE_INTERFACE, mp);
19696 mp->interface_id = ntohl (if_id);
19704 api_pg_capture (vat_main_t * vam)
19706 unformat_input_t *input = vam->input;
19707 vl_api_pg_capture_t *mp;
19712 u8 pcap_file_set = 0;
19715 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19717 if (unformat (input, "if_id %d", &if_id))
19719 else if (unformat (input, "pcap %s", &pcap_file))
19721 else if (unformat (input, "count %d", &count))
19723 else if (unformat (input, "disable"))
19730 errmsg ("missing pg interface index");
19733 if (pcap_file_set > 0)
19735 if (vec_len (pcap_file) > 255)
19737 errmsg ("pcap file name is too long");
19742 u32 name_len = vec_len (pcap_file);
19743 /* Construct the API message */
19744 M (PG_CAPTURE, mp);
19746 mp->interface_id = ntohl (if_id);
19747 mp->is_enabled = enable;
19748 mp->count = ntohl (count);
19749 mp->pcap_name_length = ntohl (name_len);
19750 if (pcap_file_set != 0)
19752 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19754 vec_free (pcap_file);
19762 api_pg_enable_disable (vat_main_t * vam)
19764 unformat_input_t *input = vam->input;
19765 vl_api_pg_enable_disable_t *mp;
19768 u8 stream_name_set = 0;
19769 u8 *stream_name = 0;
19771 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19773 if (unformat (input, "stream %s", &stream_name))
19774 stream_name_set = 1;
19775 else if (unformat (input, "disable"))
19781 if (stream_name_set > 0)
19783 if (vec_len (stream_name) > 255)
19785 errmsg ("stream name too long");
19790 u32 name_len = vec_len (stream_name);
19791 /* Construct the API message */
19792 M (PG_ENABLE_DISABLE, mp);
19794 mp->is_enabled = enable;
19795 if (stream_name_set != 0)
19797 mp->stream_name_length = ntohl (name_len);
19798 clib_memcpy (mp->stream_name, stream_name, name_len);
19800 vec_free (stream_name);
19808 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19810 unformat_input_t *input = vam->input;
19811 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19813 u16 *low_ports = 0;
19814 u16 *high_ports = 0;
19817 ip4_address_t ip4_addr;
19818 ip6_address_t ip6_addr;
19827 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19829 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
19835 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
19840 else if (unformat (input, "vrf %d", &vrf_id))
19842 else if (unformat (input, "del"))
19844 else if (unformat (input, "port %d", &tmp))
19846 if (tmp == 0 || tmp > 65535)
19848 errmsg ("port %d out of range", tmp);
19852 this_hi = this_low + 1;
19853 vec_add1 (low_ports, this_low);
19854 vec_add1 (high_ports, this_hi);
19856 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19858 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19860 errmsg ("incorrect range parameters");
19864 /* Note: in debug CLI +1 is added to high before
19865 passing to real fn that does "the work"
19866 (ip_source_and_port_range_check_add_del).
19867 This fn is a wrapper around the binary API fn a
19868 control plane will call, which expects this increment
19869 to have occurred. Hence letting the binary API control
19870 plane fn do the increment for consistency between VAT
19871 and other control planes.
19874 vec_add1 (low_ports, this_low);
19875 vec_add1 (high_ports, this_hi);
19881 if (prefix_set == 0)
19883 errmsg ("<address>/<mask> not specified");
19889 errmsg ("VRF ID required, not specified");
19896 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19900 if (vec_len (low_ports) == 0)
19902 errmsg ("At least one port or port range required");
19906 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19908 mp->is_add = is_add;
19913 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
19918 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
19921 mp->mask_length = length;
19922 mp->number_of_ranges = vec_len (low_ports);
19924 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
19925 vec_free (low_ports);
19927 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
19928 vec_free (high_ports);
19930 mp->vrf_id = ntohl (vrf_id);
19938 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
19940 unformat_input_t *input = vam->input;
19941 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
19942 u32 sw_if_index = ~0;
19944 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
19945 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
19949 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19951 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19953 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19955 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
19957 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
19959 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
19961 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
19963 else if (unformat (input, "del"))
19969 if (sw_if_index == ~0)
19971 errmsg ("Interface required but not specified");
19977 errmsg ("VRF ID required but not specified");
19981 if (tcp_out_vrf_id == 0
19982 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
19985 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19989 /* Construct the API message */
19990 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
19992 mp->sw_if_index = ntohl (sw_if_index);
19993 mp->is_add = is_add;
19994 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
19995 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
19996 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
19997 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20002 /* Wait for a reply... */
20008 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
20010 unformat_input_t *i = vam->input;
20011 vl_api_ipsec_gre_add_del_tunnel_t *mp;
20012 u32 local_sa_id = 0;
20013 u32 remote_sa_id = 0;
20014 ip4_address_t src_address;
20015 ip4_address_t dst_address;
20019 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20021 if (unformat (i, "local_sa %d", &local_sa_id))
20023 else if (unformat (i, "remote_sa %d", &remote_sa_id))
20025 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
20027 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
20029 else if (unformat (i, "del"))
20033 clib_warning ("parse error '%U'", format_unformat_error, i);
20038 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
20040 mp->local_sa_id = ntohl (local_sa_id);
20041 mp->remote_sa_id = ntohl (remote_sa_id);
20042 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
20043 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
20044 mp->is_add = is_add;
20052 api_punt (vat_main_t * vam)
20054 unformat_input_t *i = vam->input;
20062 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20064 if (unformat (i, "ip %d", &ipv))
20066 else if (unformat (i, "protocol %d", &protocol))
20068 else if (unformat (i, "port %d", &port))
20070 else if (unformat (i, "del"))
20074 clib_warning ("parse error '%U'", format_unformat_error, i);
20081 mp->is_add = (u8) is_add;
20082 mp->ipv = (u8) ipv;
20083 mp->l4_protocol = (u8) protocol;
20084 mp->l4_port = htons ((u16) port);
20091 static void vl_api_ipsec_gre_tunnel_details_t_handler
20092 (vl_api_ipsec_gre_tunnel_details_t * mp)
20094 vat_main_t *vam = &vat_main;
20096 print (vam->ofp, "%11d%15U%15U%14d%14d",
20097 ntohl (mp->sw_if_index),
20098 format_ip4_address, &mp->src_address,
20099 format_ip4_address, &mp->dst_address,
20100 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
20103 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
20104 (vl_api_ipsec_gre_tunnel_details_t * mp)
20106 vat_main_t *vam = &vat_main;
20107 vat_json_node_t *node = NULL;
20108 struct in_addr ip4;
20110 if (VAT_JSON_ARRAY != vam->json_tree.type)
20112 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20113 vat_json_init_array (&vam->json_tree);
20115 node = vat_json_array_add (&vam->json_tree);
20117 vat_json_init_object (node);
20118 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20119 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
20120 vat_json_object_add_ip4 (node, "src_address", ip4);
20121 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
20122 vat_json_object_add_ip4 (node, "dst_address", ip4);
20123 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
20124 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
20128 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
20130 unformat_input_t *i = vam->input;
20131 vl_api_ipsec_gre_tunnel_dump_t *mp;
20132 vl_api_control_ping_t *mp_ping;
20134 u8 sw_if_index_set = 0;
20137 /* Parse args required to build the message */
20138 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20140 if (unformat (i, "sw_if_index %d", &sw_if_index))
20141 sw_if_index_set = 1;
20146 if (sw_if_index_set == 0)
20151 if (!vam->json_output)
20153 print (vam->ofp, "%11s%15s%15s%14s%14s",
20154 "sw_if_index", "src_address", "dst_address",
20155 "local_sa_id", "remote_sa_id");
20158 /* Get list of gre-tunnel interfaces */
20159 M (IPSEC_GRE_TUNNEL_DUMP, mp);
20161 mp->sw_if_index = htonl (sw_if_index);
20165 /* Use a control ping for synchronization */
20166 MPING (CONTROL_PING, mp_ping);
20174 api_delete_subif (vat_main_t * vam)
20176 unformat_input_t *i = vam->input;
20177 vl_api_delete_subif_t *mp;
20178 u32 sw_if_index = ~0;
20181 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20183 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20185 if (unformat (i, "sw_if_index %d", &sw_if_index))
20191 if (sw_if_index == ~0)
20193 errmsg ("missing sw_if_index");
20197 /* Construct the API message */
20198 M (DELETE_SUBIF, mp);
20199 mp->sw_if_index = ntohl (sw_if_index);
20206 #define foreach_pbb_vtr_op \
20207 _("disable", L2_VTR_DISABLED) \
20208 _("pop", L2_VTR_POP_2) \
20209 _("push", L2_VTR_PUSH_2)
20212 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20214 unformat_input_t *i = vam->input;
20215 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20216 u32 sw_if_index = ~0, vtr_op = ~0;
20217 u16 outer_tag = ~0;
20218 u8 dmac[6], smac[6];
20219 u8 dmac_set = 0, smac_set = 0;
20225 /* Shut up coverity */
20226 memset (dmac, 0, sizeof (dmac));
20227 memset (smac, 0, sizeof (smac));
20229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20231 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20233 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20235 else if (unformat (i, "vtr_op %d", &vtr_op))
20237 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20240 else if (unformat (i, "translate_pbb_stag"))
20242 if (unformat (i, "%d", &tmp))
20244 vtr_op = L2_VTR_TRANSLATE_2_1;
20250 ("translate_pbb_stag operation requires outer tag definition");
20254 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20256 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20258 else if (unformat (i, "sid %d", &sid))
20260 else if (unformat (i, "vlanid %d", &tmp))
20264 clib_warning ("parse error '%U'", format_unformat_error, i);
20269 if ((sw_if_index == ~0) || (vtr_op == ~0))
20271 errmsg ("missing sw_if_index or vtr operation");
20274 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20275 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20278 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20282 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20283 mp->sw_if_index = ntohl (sw_if_index);
20284 mp->vtr_op = ntohl (vtr_op);
20285 mp->outer_tag = ntohs (outer_tag);
20286 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20287 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20288 mp->b_vlanid = ntohs (vlanid);
20289 mp->i_sid = ntohl (sid);
20297 api_flow_classify_set_interface (vat_main_t * vam)
20299 unformat_input_t *i = vam->input;
20300 vl_api_flow_classify_set_interface_t *mp;
20302 int sw_if_index_set;
20303 u32 ip4_table_index = ~0;
20304 u32 ip6_table_index = ~0;
20308 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20310 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20311 sw_if_index_set = 1;
20312 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20313 sw_if_index_set = 1;
20314 else if (unformat (i, "del"))
20316 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20318 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20322 clib_warning ("parse error '%U'", format_unformat_error, i);
20327 if (sw_if_index_set == 0)
20329 errmsg ("missing interface name or sw_if_index");
20333 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20335 mp->sw_if_index = ntohl (sw_if_index);
20336 mp->ip4_table_index = ntohl (ip4_table_index);
20337 mp->ip6_table_index = ntohl (ip6_table_index);
20338 mp->is_add = is_add;
20346 api_flow_classify_dump (vat_main_t * vam)
20348 unformat_input_t *i = vam->input;
20349 vl_api_flow_classify_dump_t *mp;
20350 vl_api_control_ping_t *mp_ping;
20351 u8 type = FLOW_CLASSIFY_N_TABLES;
20354 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20358 errmsg ("classify table type must be specified");
20362 if (!vam->json_output)
20364 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20367 M (FLOW_CLASSIFY_DUMP, mp);
20372 /* Use a control ping for synchronization */
20373 MPING (CONTROL_PING, mp_ping);
20376 /* Wait for a reply... */
20382 api_feature_enable_disable (vat_main_t * vam)
20384 unformat_input_t *i = vam->input;
20385 vl_api_feature_enable_disable_t *mp;
20387 u8 *feature_name = 0;
20388 u32 sw_if_index = ~0;
20392 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20394 if (unformat (i, "arc_name %s", &arc_name))
20396 else if (unformat (i, "feature_name %s", &feature_name))
20399 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20401 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20403 else if (unformat (i, "disable"))
20411 errmsg ("missing arc name");
20414 if (vec_len (arc_name) > 63)
20416 errmsg ("arc name too long");
20419 if (feature_name == 0)
20421 errmsg ("missing feature name");
20424 if (vec_len (feature_name) > 63)
20426 errmsg ("feature name too long");
20429 if (sw_if_index == ~0)
20431 errmsg ("missing interface name or sw_if_index");
20435 /* Construct the API message */
20436 M (FEATURE_ENABLE_DISABLE, mp);
20437 mp->sw_if_index = ntohl (sw_if_index);
20438 mp->enable = enable;
20439 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20440 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20441 vec_free (arc_name);
20442 vec_free (feature_name);
20450 api_sw_interface_tag_add_del (vat_main_t * vam)
20452 unformat_input_t *i = vam->input;
20453 vl_api_sw_interface_tag_add_del_t *mp;
20454 u32 sw_if_index = ~0;
20459 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20461 if (unformat (i, "tag %s", &tag))
20463 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20465 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20467 else if (unformat (i, "del"))
20473 if (sw_if_index == ~0)
20475 errmsg ("missing interface name or sw_if_index");
20479 if (enable && (tag == 0))
20481 errmsg ("no tag specified");
20485 /* Construct the API message */
20486 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20487 mp->sw_if_index = ntohl (sw_if_index);
20488 mp->is_add = enable;
20490 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20498 static void vl_api_l2_xconnect_details_t_handler
20499 (vl_api_l2_xconnect_details_t * mp)
20501 vat_main_t *vam = &vat_main;
20503 print (vam->ofp, "%15d%15d",
20504 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20507 static void vl_api_l2_xconnect_details_t_handler_json
20508 (vl_api_l2_xconnect_details_t * mp)
20510 vat_main_t *vam = &vat_main;
20511 vat_json_node_t *node = NULL;
20513 if (VAT_JSON_ARRAY != vam->json_tree.type)
20515 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20516 vat_json_init_array (&vam->json_tree);
20518 node = vat_json_array_add (&vam->json_tree);
20520 vat_json_init_object (node);
20521 vat_json_object_add_uint (node, "rx_sw_if_index",
20522 ntohl (mp->rx_sw_if_index));
20523 vat_json_object_add_uint (node, "tx_sw_if_index",
20524 ntohl (mp->tx_sw_if_index));
20528 api_l2_xconnect_dump (vat_main_t * vam)
20530 vl_api_l2_xconnect_dump_t *mp;
20531 vl_api_control_ping_t *mp_ping;
20534 if (!vam->json_output)
20536 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20539 M (L2_XCONNECT_DUMP, mp);
20543 /* Use a control ping for synchronization */
20544 MPING (CONTROL_PING, mp_ping);
20552 api_sw_interface_set_mtu (vat_main_t * vam)
20554 unformat_input_t *i = vam->input;
20555 vl_api_sw_interface_set_mtu_t *mp;
20556 u32 sw_if_index = ~0;
20560 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20562 if (unformat (i, "mtu %d", &mtu))
20564 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20566 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20572 if (sw_if_index == ~0)
20574 errmsg ("missing interface name or sw_if_index");
20580 errmsg ("no mtu specified");
20584 /* Construct the API message */
20585 M (SW_INTERFACE_SET_MTU, mp);
20586 mp->sw_if_index = ntohl (sw_if_index);
20587 mp->mtu = ntohs ((u16) mtu);
20595 api_p2p_ethernet_add (vat_main_t * vam)
20597 unformat_input_t *i = vam->input;
20598 vl_api_p2p_ethernet_add_t *mp;
20599 u32 parent_if_index = ~0;
20605 memset (remote_mac, 0, sizeof (remote_mac));
20606 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20608 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20610 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20614 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20616 else if (unformat (i, "sub_id %d", &sub_id))
20620 clib_warning ("parse error '%U'", format_unformat_error, i);
20625 if (parent_if_index == ~0)
20627 errmsg ("missing interface name or sw_if_index");
20632 errmsg ("missing remote mac address");
20637 errmsg ("missing sub-interface id");
20641 M (P2P_ETHERNET_ADD, mp);
20642 mp->parent_if_index = ntohl (parent_if_index);
20643 mp->subif_id = ntohl (sub_id);
20644 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20652 api_p2p_ethernet_del (vat_main_t * vam)
20654 unformat_input_t *i = vam->input;
20655 vl_api_p2p_ethernet_del_t *mp;
20656 u32 parent_if_index = ~0;
20661 memset (remote_mac, 0, sizeof (remote_mac));
20662 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20664 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20666 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20670 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20674 clib_warning ("parse error '%U'", format_unformat_error, i);
20679 if (parent_if_index == ~0)
20681 errmsg ("missing interface name or sw_if_index");
20686 errmsg ("missing remote mac address");
20690 M (P2P_ETHERNET_DEL, mp);
20691 mp->parent_if_index = ntohl (parent_if_index);
20692 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20700 api_lldp_config (vat_main_t * vam)
20702 unformat_input_t *i = vam->input;
20703 vl_api_lldp_config_t *mp;
20705 int tx_interval = 0;
20706 u8 *sys_name = NULL;
20709 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20711 if (unformat (i, "system-name %s", &sys_name))
20713 else if (unformat (i, "tx-hold %d", &tx_hold))
20715 else if (unformat (i, "tx-interval %d", &tx_interval))
20719 clib_warning ("parse error '%U'", format_unformat_error, i);
20724 vec_add1 (sys_name, 0);
20726 M (LLDP_CONFIG, mp);
20727 mp->tx_hold = htonl (tx_hold);
20728 mp->tx_interval = htonl (tx_interval);
20729 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20730 vec_free (sys_name);
20738 api_sw_interface_set_lldp (vat_main_t * vam)
20740 unformat_input_t *i = vam->input;
20741 vl_api_sw_interface_set_lldp_t *mp;
20742 u32 sw_if_index = ~0;
20744 u8 *port_desc = NULL, *mgmt_oid = NULL;
20745 ip4_address_t ip4_addr;
20746 ip6_address_t ip6_addr;
20749 memset (&ip4_addr, 0, sizeof (ip4_addr));
20750 memset (&ip6_addr, 0, sizeof (ip6_addr));
20752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20754 if (unformat (i, "disable"))
20757 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20759 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20761 else if (unformat (i, "port-desc %s", &port_desc))
20763 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
20765 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
20767 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
20773 if (sw_if_index == ~0)
20775 errmsg ("missing interface name or sw_if_index");
20779 /* Construct the API message */
20780 vec_add1 (port_desc, 0);
20781 vec_add1 (mgmt_oid, 0);
20782 M (SW_INTERFACE_SET_LLDP, mp);
20783 mp->sw_if_index = ntohl (sw_if_index);
20784 mp->enable = enable;
20785 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20786 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
20787 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
20788 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
20789 vec_free (port_desc);
20790 vec_free (mgmt_oid);
20798 api_tcp_configure_src_addresses (vat_main_t * vam)
20800 vl_api_tcp_configure_src_addresses_t *mp;
20801 unformat_input_t *i = vam->input;
20802 ip4_address_t v4first, v4last;
20803 ip6_address_t v6first, v6last;
20808 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20810 if (unformat (i, "%U - %U",
20811 unformat_ip4_address, &v4first,
20812 unformat_ip4_address, &v4last))
20816 errmsg ("one range per message (range already set)");
20821 else if (unformat (i, "%U - %U",
20822 unformat_ip6_address, &v6first,
20823 unformat_ip6_address, &v6last))
20827 errmsg ("one range per message (range already set)");
20832 else if (unformat (i, "vrf %d", &vrf_id))
20838 if (range_set == 0)
20840 errmsg ("address range not set");
20844 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20845 mp->vrf_id = ntohl (vrf_id);
20847 if (range_set == 2)
20850 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20851 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20856 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20857 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20865 api_app_namespace_add_del (vat_main_t * vam)
20867 vl_api_app_namespace_add_del_t *mp;
20868 unformat_input_t *i = vam->input;
20869 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
20870 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
20874 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20876 if (unformat (i, "id %_%v%_", &ns_id))
20878 else if (unformat (i, "secret %lu", &secret))
20880 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20881 sw_if_index_set = 1;
20882 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
20884 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
20889 if (!ns_id || !secret_set || !sw_if_index_set)
20891 errmsg ("namespace id, secret and sw_if_index must be set");
20894 if (vec_len (ns_id) > 64)
20896 errmsg ("namespace id too long");
20899 M (APP_NAMESPACE_ADD_DEL, mp);
20901 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
20902 mp->namespace_id_len = vec_len (ns_id);
20903 mp->secret = secret;
20904 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20905 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
20906 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
20914 api_memfd_segment_create (vat_main_t * vam)
20916 #if VPP_API_TEST_BUILTIN == 0
20917 unformat_input_t *i = vam->input;
20918 vl_api_memfd_segment_create_t *mp;
20919 u64 size = 64 << 20;
20922 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20924 if (unformat (i, "size %U", unformat_memory_size, &size))
20930 M (MEMFD_SEGMENT_CREATE, mp);
20931 mp->requested_size = size;
20937 errmsg ("memfd_segment_create (builtin) not supported");
20943 api_dns_enable_disable (vat_main_t * vam)
20945 unformat_input_t *line_input = vam->input;
20946 vl_api_dns_enable_disable_t *mp;
20947 u8 enable_disable = 1;
20950 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20952 if (unformat (line_input, "disable"))
20953 enable_disable = 0;
20954 if (unformat (line_input, "enable"))
20955 enable_disable = 1;
20960 /* Construct the API message */
20961 M (DNS_ENABLE_DISABLE, mp);
20962 mp->enable = enable_disable;
20966 /* Wait for the reply */
20972 api_dns_resolve_name (vat_main_t * vam)
20974 unformat_input_t *line_input = vam->input;
20975 vl_api_dns_resolve_name_t *mp;
20979 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20981 if (unformat (line_input, "%s", &name))
20987 if (vec_len (name) > 127)
20989 errmsg ("name too long");
20993 /* Construct the API message */
20994 M (DNS_RESOLVE_NAME, mp);
20995 memcpy (mp->name, name, vec_len (name));
21000 /* Wait for the reply */
21006 api_dns_name_server_add_del (vat_main_t * vam)
21008 unformat_input_t *i = vam->input;
21009 vl_api_dns_name_server_add_del_t *mp;
21011 ip6_address_t ip6_server;
21012 ip4_address_t ip4_server;
21017 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21019 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
21021 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
21023 else if (unformat (i, "del"))
21027 clib_warning ("parse error '%U'", format_unformat_error, i);
21032 if (ip4_set && ip6_set)
21034 errmsg ("Only one server address allowed per message");
21037 if ((ip4_set + ip6_set) == 0)
21039 errmsg ("Server address required");
21043 /* Construct the API message */
21044 M (DNS_NAME_SERVER_ADD_DEL, mp);
21048 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
21053 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
21057 mp->is_add = is_add;
21062 /* Wait for a reply, return good/bad news */
21069 q_or_quit (vat_main_t * vam)
21071 #if VPP_API_TEST_BUILTIN == 0
21072 longjmp (vam->jump_buf, 1);
21074 return 0; /* not so much */
21078 q (vat_main_t * vam)
21080 return q_or_quit (vam);
21084 quit (vat_main_t * vam)
21086 return q_or_quit (vam);
21090 comment (vat_main_t * vam)
21096 cmd_cmp (void *a1, void *a2)
21101 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21105 help (vat_main_t * vam)
21110 unformat_input_t *i = vam->input;
21113 if (unformat (i, "%s", &name))
21117 vec_add1 (name, 0);
21119 hs = hash_get_mem (vam->help_by_name, name);
21121 print (vam->ofp, "usage: %s %s", name, hs[0]);
21123 print (vam->ofp, "No such msg / command '%s'", name);
21128 print (vam->ofp, "Help is available for the following:");
21131 hash_foreach_pair (p, vam->function_by_name,
21133 vec_add1 (cmds, (u8 *)(p->key));
21137 vec_sort_with_function (cmds, cmd_cmp);
21139 for (j = 0; j < vec_len (cmds); j++)
21140 print (vam->ofp, "%s", cmds[j]);
21147 set (vat_main_t * vam)
21149 u8 *name = 0, *value = 0;
21150 unformat_input_t *i = vam->input;
21152 if (unformat (i, "%s", &name))
21154 /* The input buffer is a vector, not a string. */
21155 value = vec_dup (i->buffer);
21156 vec_delete (value, i->index, 0);
21157 /* Almost certainly has a trailing newline */
21158 if (value[vec_len (value) - 1] == '\n')
21159 value[vec_len (value) - 1] = 0;
21160 /* Make sure it's a proper string, one way or the other */
21161 vec_add1 (value, 0);
21162 (void) clib_macro_set_value (&vam->macro_main,
21163 (char *) name, (char *) value);
21166 errmsg ("usage: set <name> <value>");
21174 unset (vat_main_t * vam)
21178 if (unformat (vam->input, "%s", &name))
21179 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21180 errmsg ("unset: %s wasn't set", name);
21193 macro_sort_cmp (void *a1, void *a2)
21195 macro_sort_t *s1 = a1;
21196 macro_sort_t *s2 = a2;
21198 return strcmp ((char *) (s1->name), (char *) (s2->name));
21202 dump_macro_table (vat_main_t * vam)
21204 macro_sort_t *sort_me = 0, *sm;
21209 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21211 vec_add2 (sort_me, sm, 1);
21212 sm->name = (u8 *)(p->key);
21213 sm->value = (u8 *) (p->value[0]);
21217 vec_sort_with_function (sort_me, macro_sort_cmp);
21219 if (vec_len (sort_me))
21220 print (vam->ofp, "%-15s%s", "Name", "Value");
21222 print (vam->ofp, "The macro table is empty...");
21224 for (i = 0; i < vec_len (sort_me); i++)
21225 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21230 dump_node_table (vat_main_t * vam)
21233 vlib_node_t *node, *next_node;
21235 if (vec_len (vam->graph_nodes) == 0)
21237 print (vam->ofp, "Node table empty, issue get_node_graph...");
21241 for (i = 0; i < vec_len (vam->graph_nodes); i++)
21243 node = vam->graph_nodes[i];
21244 print (vam->ofp, "[%d] %s", i, node->name);
21245 for (j = 0; j < vec_len (node->next_nodes); j++)
21247 if (node->next_nodes[j] != ~0)
21249 next_node = vam->graph_nodes[node->next_nodes[j]];
21250 print (vam->ofp, " [%d] %s", j, next_node->name);
21258 value_sort_cmp (void *a1, void *a2)
21260 name_sort_t *n1 = a1;
21261 name_sort_t *n2 = a2;
21263 if (n1->value < n2->value)
21265 if (n1->value > n2->value)
21272 dump_msg_api_table (vat_main_t * vam)
21274 api_main_t *am = &api_main;
21275 name_sort_t *nses = 0, *ns;
21280 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21282 vec_add2 (nses, ns, 1);
21283 ns->name = (u8 *)(hp->key);
21284 ns->value = (u32) hp->value[0];
21288 vec_sort_with_function (nses, value_sort_cmp);
21290 for (i = 0; i < vec_len (nses); i++)
21291 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21297 get_msg_id (vat_main_t * vam)
21302 if (unformat (vam->input, "%s", &name_and_crc))
21304 message_index = vl_api_get_msg_index (name_and_crc);
21305 if (message_index == ~0)
21307 print (vam->ofp, " '%s' not found", name_and_crc);
21310 print (vam->ofp, " '%s' has message index %d",
21311 name_and_crc, message_index);
21314 errmsg ("name_and_crc required...");
21319 search_node_table (vat_main_t * vam)
21321 unformat_input_t *line_input = vam->input;
21324 vlib_node_t *node, *next_node;
21327 if (vam->graph_node_index_by_name == 0)
21329 print (vam->ofp, "Node table empty, issue get_node_graph...");
21333 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21335 if (unformat (line_input, "%s", &node_to_find))
21337 vec_add1 (node_to_find, 0);
21338 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21341 print (vam->ofp, "%s not found...", node_to_find);
21344 node = vam->graph_nodes[p[0]];
21345 print (vam->ofp, "[%d] %s", p[0], node->name);
21346 for (j = 0; j < vec_len (node->next_nodes); j++)
21348 if (node->next_nodes[j] != ~0)
21350 next_node = vam->graph_nodes[node->next_nodes[j]];
21351 print (vam->ofp, " [%d] %s", j, next_node->name);
21358 clib_warning ("parse error '%U'", format_unformat_error,
21364 vec_free (node_to_find);
21373 script (vat_main_t * vam)
21375 #if (VPP_API_TEST_BUILTIN==0)
21377 char *save_current_file;
21378 unformat_input_t save_input;
21379 jmp_buf save_jump_buf;
21380 u32 save_line_number;
21382 FILE *new_fp, *save_ifp;
21384 if (unformat (vam->input, "%s", &s))
21386 new_fp = fopen ((char *) s, "r");
21389 errmsg ("Couldn't open script file %s", s);
21396 errmsg ("Missing script name");
21400 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21401 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21402 save_ifp = vam->ifp;
21403 save_line_number = vam->input_line_number;
21404 save_current_file = (char *) vam->current_file;
21406 vam->input_line_number = 0;
21408 vam->current_file = s;
21411 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
21412 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21413 vam->ifp = save_ifp;
21414 vam->input_line_number = save_line_number;
21415 vam->current_file = (u8 *) save_current_file;
21420 clib_warning ("use the exec command...");
21426 echo (vat_main_t * vam)
21428 print (vam->ofp, "%v", vam->input->buffer);
21432 /* List of API message constructors, CLI names map to api_xxx */
21433 #define foreach_vpe_api_msg \
21434 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21435 _(sw_interface_dump,"") \
21436 _(sw_interface_set_flags, \
21437 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21438 _(sw_interface_add_del_address, \
21439 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21440 _(sw_interface_set_table, \
21441 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21442 _(sw_interface_set_mpls_enable, \
21443 "<intfc> | sw_if_index [disable | dis]") \
21444 _(sw_interface_set_vpath, \
21445 "<intfc> | sw_if_index <id> enable | disable") \
21446 _(sw_interface_set_vxlan_bypass, \
21447 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21448 _(sw_interface_set_geneve_bypass, \
21449 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21450 _(sw_interface_set_l2_xconnect, \
21451 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21452 "enable | disable") \
21453 _(sw_interface_set_l2_bridge, \
21454 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21455 "[shg <split-horizon-group>] [bvi]\n" \
21456 "enable | disable") \
21457 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21458 _(bridge_domain_add_del, \
21459 "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") \
21460 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21462 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21463 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21464 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21466 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21468 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21470 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
21472 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
21474 "<vpp-if-name> | sw_if_index <id>") \
21475 _(sw_interface_tap_dump, "") \
21476 _(ip_table_add_del, \
21477 "table-id <n> [ipv6]\n") \
21478 _(ip_add_del_route, \
21479 "<addr>/<mask> via <addr> [table-id <n>]\n" \
21480 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
21481 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
21482 "[multipath] [count <n>]") \
21483 _(ip_mroute_add_del, \
21484 "<src> <grp>/<mask> [table-id <n>]\n" \
21485 "[<intfc> | sw_if_index <id>] [local] [del]") \
21486 _(mpls_table_add_del, \
21487 "table-id <n>\n") \
21488 _(mpls_route_add_del, \
21489 "<label> <eos> via <addr> [table-id <n>]\n" \
21490 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
21491 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
21492 "[multipath] [count <n>]") \
21493 _(mpls_ip_bind_unbind, \
21494 "<label> <addr/len>") \
21495 _(mpls_tunnel_add_del, \
21496 " via <addr> [table-id <n>]\n" \
21497 "sw_if_index <id>] [l2] [del]") \
21498 _(proxy_arp_add_del, \
21499 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
21500 _(proxy_arp_intfc_enable_disable, \
21501 "<intfc> | sw_if_index <id> enable | disable") \
21502 _(sw_interface_set_unnumbered, \
21503 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
21504 _(ip_neighbor_add_del, \
21505 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
21506 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
21507 _(reset_vrf, "vrf <id> [ipv6]") \
21508 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
21509 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
21510 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
21511 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
21512 "[outer_vlan_id_any][inner_vlan_id_any]") \
21513 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
21514 _(reset_fib, "vrf <n> [ipv6]") \
21515 _(dhcp_proxy_config, \
21516 "svr <v46-address> src <v46-address>\n" \
21517 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
21518 _(dhcp_proxy_set_vss, \
21519 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
21520 _(dhcp_proxy_dump, "ip6") \
21521 _(dhcp_client_config, \
21522 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
21523 _(set_ip_flow_hash, \
21524 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
21525 _(sw_interface_ip6_enable_disable, \
21526 "<intfc> | sw_if_index <id> enable | disable") \
21527 _(sw_interface_ip6_set_link_local_address, \
21528 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
21529 _(ip6nd_proxy_add_del, \
21530 "<intfc> | sw_if_index <id> <ip6-address>") \
21531 _(ip6nd_proxy_dump, "") \
21532 _(sw_interface_ip6nd_ra_prefix, \
21533 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
21534 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
21535 "[nolink] [isno]") \
21536 _(sw_interface_ip6nd_ra_config, \
21537 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
21538 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
21539 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
21540 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
21541 _(l2_patch_add_del, \
21542 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21543 "enable | disable") \
21544 _(sr_localsid_add_del, \
21545 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
21546 "fib-table <num> (end.psp) sw_if_index <num>") \
21547 _(classify_add_del_table, \
21548 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
21549 " [del] [del-chain] mask <mask-value>\n" \
21550 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
21551 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
21552 _(classify_add_del_session, \
21553 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
21554 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
21555 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
21556 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
21557 _(classify_set_interface_ip_table, \
21558 "<intfc> | sw_if_index <nn> table <nn>") \
21559 _(classify_set_interface_l2_tables, \
21560 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21561 " [other-table <nn>]") \
21562 _(get_node_index, "node <node-name") \
21563 _(add_node_next, "node <node-name> next <next-node-name>") \
21564 _(l2tpv3_create_tunnel, \
21565 "client_address <ip6-addr> our_address <ip6-addr>\n" \
21566 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
21567 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
21568 _(l2tpv3_set_tunnel_cookies, \
21569 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
21570 "[new_remote_cookie <nn>]\n") \
21571 _(l2tpv3_interface_enable_disable, \
21572 "<intfc> | sw_if_index <nn> enable | disable") \
21573 _(l2tpv3_set_lookup_key, \
21574 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
21575 _(sw_if_l2tpv3_tunnel_dump, "") \
21576 _(vxlan_add_del_tunnel, \
21577 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21578 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21579 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21580 _(geneve_add_del_tunnel, \
21581 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21582 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21583 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21584 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21585 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21586 _(gre_add_del_tunnel, \
21587 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
21588 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21589 _(l2_fib_clear_table, "") \
21590 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
21591 _(l2_interface_vlan_tag_rewrite, \
21592 "<intfc> | sw_if_index <nn> \n" \
21593 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
21594 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
21595 _(create_vhost_user_if, \
21596 "socket <filename> [server] [renumber <dev_instance>] " \
21597 "[mac <mac_address>]") \
21598 _(modify_vhost_user_if, \
21599 "<intfc> | sw_if_index <nn> socket <filename>\n" \
21600 "[server] [renumber <dev_instance>]") \
21601 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
21602 _(sw_interface_vhost_user_dump, "") \
21603 _(show_version, "") \
21604 _(vxlan_gpe_add_del_tunnel, \
21605 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
21606 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21607 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
21608 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
21609 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21610 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
21611 _(interface_name_renumber, \
21612 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
21613 _(input_acl_set_interface, \
21614 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21615 " [l2-table <nn>] [del]") \
21616 _(want_ip4_arp_events, "address <ip4-address> [del]") \
21617 _(want_ip6_nd_events, "address <ip6-address> [del]") \
21618 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
21619 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
21620 _(ip_dump, "ipv4 | ipv6") \
21621 _(ipsec_spd_add_del, "spd_id <n> [del]") \
21622 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
21624 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
21625 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
21626 " integ_alg <alg> integ_key <hex>") \
21627 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
21628 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
21629 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
21630 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
21631 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
21632 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
21633 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
21634 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
21635 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
21636 _(ipsec_sa_dump, "[sa_id <n>]") \
21637 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
21638 " <alg> <hex>\n") \
21639 _(ikev2_profile_add_del, "name <profile_name> [del]") \
21640 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
21641 "(auth_data 0x<data> | auth_data <data>)") \
21642 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
21643 "(id_data 0x<data> | id_data <data>) (local|remote)") \
21644 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
21645 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
21646 "(local|remote)") \
21647 _(ikev2_set_local_key, "file <absolute_file_path>") \
21648 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
21649 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
21650 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
21651 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
21652 _(ikev2_initiate_sa_init, "<profile_name>") \
21653 _(ikev2_initiate_del_ike_sa, "<ispi>") \
21654 _(ikev2_initiate_del_child_sa, "<ispi>") \
21655 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
21656 _(delete_loopback,"sw_if_index <nn>") \
21657 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
21658 _(map_add_domain, \
21659 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
21660 "ip6-src <ip6addr> " \
21661 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
21662 _(map_del_domain, "index <n>") \
21663 _(map_add_del_rule, \
21664 "index <n> psid <n> dst <ip6addr> [del]") \
21665 _(map_domain_dump, "") \
21666 _(map_rule_dump, "index <map-domain>") \
21667 _(want_interface_events, "enable|disable") \
21668 _(want_stats,"enable|disable") \
21669 _(get_first_msg_id, "client <name>") \
21670 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
21671 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
21672 "fib-id <nn> [ip4][ip6][default]") \
21673 _(get_node_graph, " ") \
21674 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
21675 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
21676 _(ioam_disable, "") \
21677 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
21678 " sw_if_index <sw_if_index> p <priority> " \
21679 "w <weight>] [del]") \
21680 _(one_add_del_locator, "locator-set <locator_name> " \
21681 "iface <intf> | sw_if_index <sw_if_index> " \
21682 "p <priority> w <weight> [del]") \
21683 _(one_add_del_local_eid,"vni <vni> eid " \
21684 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21685 "locator-set <locator_name> [del]" \
21686 "[key-id sha1|sha256 secret-key <secret-key>]")\
21687 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
21688 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
21689 _(one_enable_disable, "enable|disable") \
21690 _(one_map_register_enable_disable, "enable|disable") \
21691 _(one_map_register_fallback_threshold, "<value>") \
21692 _(one_rloc_probe_enable_disable, "enable|disable") \
21693 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21695 "rloc <locator> p <prio> " \
21696 "w <weight> [rloc <loc> ... ] " \
21697 "action <action> [del-all]") \
21698 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21700 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21701 _(one_use_petr, "ip-address> | disable") \
21702 _(one_map_request_mode, "src-dst|dst-only") \
21703 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21704 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21705 _(one_locator_set_dump, "[local | remote]") \
21706 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
21707 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21708 "[local] | [remote]") \
21709 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
21710 _(one_ndp_bd_get, "") \
21711 _(one_ndp_entries_get, "bd <bridge-domain>") \
21712 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
21713 _(one_l2_arp_bd_get, "") \
21714 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
21715 _(one_stats_enable_disable, "enable|disalbe") \
21716 _(show_one_stats_enable_disable, "") \
21717 _(one_eid_table_vni_dump, "") \
21718 _(one_eid_table_map_dump, "l2|l3") \
21719 _(one_map_resolver_dump, "") \
21720 _(one_map_server_dump, "") \
21721 _(one_adjacencies_get, "vni <vni>") \
21722 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
21723 _(show_one_rloc_probe_state, "") \
21724 _(show_one_map_register_state, "") \
21725 _(show_one_status, "") \
21726 _(one_stats_dump, "") \
21727 _(one_stats_flush, "") \
21728 _(one_get_map_request_itr_rlocs, "") \
21729 _(one_map_register_set_ttl, "<ttl>") \
21730 _(one_set_transport_protocol, "udp|api") \
21731 _(one_get_transport_protocol, "") \
21732 _(show_one_nsh_mapping, "") \
21733 _(show_one_pitr, "") \
21734 _(show_one_use_petr, "") \
21735 _(show_one_map_request_mode, "") \
21736 _(show_one_map_register_ttl, "") \
21737 _(show_one_map_register_fallback_threshold, "") \
21738 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
21739 " sw_if_index <sw_if_index> p <priority> " \
21740 "w <weight>] [del]") \
21741 _(lisp_add_del_locator, "locator-set <locator_name> " \
21742 "iface <intf> | sw_if_index <sw_if_index> " \
21743 "p <priority> w <weight> [del]") \
21744 _(lisp_add_del_local_eid,"vni <vni> eid " \
21745 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21746 "locator-set <locator_name> [del]" \
21747 "[key-id sha1|sha256 secret-key <secret-key>]") \
21748 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
21749 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
21750 _(lisp_enable_disable, "enable|disable") \
21751 _(lisp_map_register_enable_disable, "enable|disable") \
21752 _(lisp_rloc_probe_enable_disable, "enable|disable") \
21753 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21755 "rloc <locator> p <prio> " \
21756 "w <weight> [rloc <loc> ... ] " \
21757 "action <action> [del-all]") \
21758 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21760 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21761 _(lisp_use_petr, "<ip-address> | disable") \
21762 _(lisp_map_request_mode, "src-dst|dst-only") \
21763 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21764 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21765 _(lisp_locator_set_dump, "[local | remote]") \
21766 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
21767 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21768 "[local] | [remote]") \
21769 _(lisp_eid_table_vni_dump, "") \
21770 _(lisp_eid_table_map_dump, "l2|l3") \
21771 _(lisp_map_resolver_dump, "") \
21772 _(lisp_map_server_dump, "") \
21773 _(lisp_adjacencies_get, "vni <vni>") \
21774 _(gpe_fwd_entry_vnis_get, "") \
21775 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
21776 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
21777 "[table <table-id>]") \
21778 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
21779 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
21780 _(gpe_set_encap_mode, "lisp|vxlan") \
21781 _(gpe_get_encap_mode, "") \
21782 _(lisp_gpe_add_del_iface, "up|down") \
21783 _(lisp_gpe_enable_disable, "enable|disable") \
21784 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
21785 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
21786 _(show_lisp_rloc_probe_state, "") \
21787 _(show_lisp_map_register_state, "") \
21788 _(show_lisp_status, "") \
21789 _(lisp_get_map_request_itr_rlocs, "") \
21790 _(show_lisp_pitr, "") \
21791 _(show_lisp_use_petr, "") \
21792 _(show_lisp_map_request_mode, "") \
21793 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
21794 _(af_packet_delete, "name <host interface name>") \
21795 _(policer_add_del, "name <policer name> <params> [del]") \
21796 _(policer_dump, "[name <policer name>]") \
21797 _(policer_classify_set_interface, \
21798 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21799 " [l2-table <nn>] [del]") \
21800 _(policer_classify_dump, "type [ip4|ip6|l2]") \
21801 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
21802 "[master|slave]") \
21803 _(netmap_delete, "name <interface name>") \
21804 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
21805 _(mpls_fib_dump, "") \
21806 _(classify_table_ids, "") \
21807 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
21808 _(classify_table_info, "table_id <nn>") \
21809 _(classify_session_dump, "table_id <nn>") \
21810 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
21811 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
21812 "[template_interval <nn>] [udp_checksum]") \
21813 _(ipfix_exporter_dump, "") \
21814 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
21815 _(ipfix_classify_stream_dump, "") \
21816 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
21817 _(ipfix_classify_table_dump, "") \
21818 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
21819 _(sw_interface_span_dump, "[l2]") \
21820 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
21821 _(pg_create_interface, "if_id <nn>") \
21822 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
21823 _(pg_enable_disable, "[stream <id>] disable") \
21824 _(ip_source_and_port_range_check_add_del, \
21825 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
21826 _(ip_source_and_port_range_check_interface_add_del, \
21827 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
21828 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
21829 _(ipsec_gre_add_del_tunnel, \
21830 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
21831 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
21832 _(delete_subif,"<intfc> | sw_if_index <nn>") \
21833 _(l2_interface_pbb_tag_rewrite, \
21834 "<intfc> | sw_if_index <nn> \n" \
21835 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
21836 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
21837 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
21838 _(flow_classify_set_interface, \
21839 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
21840 _(flow_classify_dump, "type [ip4|ip6]") \
21841 _(ip_fib_dump, "") \
21842 _(ip_mfib_dump, "") \
21843 _(ip6_fib_dump, "") \
21844 _(ip6_mfib_dump, "") \
21845 _(feature_enable_disable, "arc_name <arc_name> " \
21846 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
21847 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
21849 _(l2_xconnect_dump, "") \
21850 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
21851 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
21852 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
21853 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
21854 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
21855 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
21856 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
21857 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
21858 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
21859 _(memfd_segment_create,"size <nnn>") \
21860 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
21861 _(dns_enable_disable, "[enable][disable]") \
21862 _(dns_name_server_add_del, "<ip-address> [del]") \
21863 _(dns_resolve_name, "<hostname>")
21865 /* List of command functions, CLI names map directly to functions */
21866 #define foreach_cli_function \
21867 _(comment, "usage: comment <ignore-rest-of-line>") \
21868 _(dump_interface_table, "usage: dump_interface_table") \
21869 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
21870 _(dump_ipv4_table, "usage: dump_ipv4_table") \
21871 _(dump_ipv6_table, "usage: dump_ipv6_table") \
21872 _(dump_stats_table, "usage: dump_stats_table") \
21873 _(dump_macro_table, "usage: dump_macro_table ") \
21874 _(dump_node_table, "usage: dump_node_table") \
21875 _(dump_msg_api_table, "usage: dump_msg_api_table") \
21876 _(get_msg_id, "usage: get_msg_id name_and_crc") \
21877 _(echo, "usage: echo <message>") \
21878 _(exec, "usage: exec <vpe-debug-CLI-command>") \
21879 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
21880 _(help, "usage: help") \
21881 _(q, "usage: quit") \
21882 _(quit, "usage: quit") \
21883 _(search_node_table, "usage: search_node_table <name>...") \
21884 _(set, "usage: set <variable-name> <value>") \
21885 _(script, "usage: script <file-name>") \
21886 _(unset, "usage: unset <variable-name>")
21888 static void vl_api_##n##_t_handler_uni \
21889 (vl_api_##n##_t * mp) \
21891 vat_main_t * vam = &vat_main; \
21892 if (vam->json_output) { \
21893 vl_api_##n##_t_handler_json(mp); \
21895 vl_api_##n##_t_handler(mp); \
21898 foreach_vpe_api_reply_msg;
21899 #if VPP_API_TEST_BUILTIN == 0
21900 foreach_standalone_reply_msg;
21905 vat_api_hookup (vat_main_t * vam)
21908 vl_msg_api_set_handlers(VL_API_##N, #n, \
21909 vl_api_##n##_t_handler_uni, \
21911 vl_api_##n##_t_endian, \
21912 vl_api_##n##_t_print, \
21913 sizeof(vl_api_##n##_t), 1);
21914 foreach_vpe_api_reply_msg;
21915 #if VPP_API_TEST_BUILTIN == 0
21916 foreach_standalone_reply_msg;
21920 #if (VPP_API_TEST_BUILTIN==0)
21921 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
21923 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
21925 vam->function_by_name = hash_create_string (0, sizeof (uword));
21927 vam->help_by_name = hash_create_string (0, sizeof (uword));
21930 /* API messages we can send */
21931 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
21932 foreach_vpe_api_msg;
21936 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21937 foreach_vpe_api_msg;
21940 /* CLI functions */
21941 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
21942 foreach_cli_function;
21946 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21947 foreach_cli_function;
21951 #if VPP_API_TEST_BUILTIN
21952 static clib_error_t *
21953 vat_api_hookup_shim (vlib_main_t * vm)
21955 vat_api_hookup (&vat_main);
21959 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
21963 * fd.io coding-style-patch-verification: ON
21966 * eval: (c-set-style "gnu")