2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vppinfra/socket.h>
22 #include <svm/memfd.h>
23 #include <vlibapi/api.h>
24 #include <vlibmemory/api.h>
25 #include <vnet/ip/ip.h>
26 #include <vnet/l2/l2_input.h>
27 #include <vnet/l2tp/l2tp.h>
28 #include <vnet/vxlan/vxlan.h>
29 #include <vnet/geneve/geneve.h>
30 #include <vnet/gre/gre.h>
31 #include <vnet/vxlan-gpe/vxlan_gpe.h>
32 #include <vnet/lisp-gpe/lisp_gpe.h>
34 #include <vpp/api/vpe_msg_enum.h>
35 #include <vnet/l2/l2_classify.h>
36 #include <vnet/l2/l2_vtr.h>
37 #include <vnet/classify/input_acl.h>
38 #include <vnet/classify/policer_classify.h>
39 #include <vnet/classify/flow_classify.h>
40 #include <vnet/mpls/mpls.h>
41 #include <vnet/ipsec/ipsec.h>
42 #include <vnet/ipsec/ikev2.h>
44 #include <vnet/map/map.h>
45 #include <vnet/cop/cop.h>
46 #include <vnet/ip/ip6_hop_by_hop.h>
47 #include <vnet/ip/ip_source_and_port_range_check.h>
48 #include <vnet/policer/xlate.h>
49 #include <vnet/span/span.h>
50 #include <vnet/policer/policer.h>
51 #include <vnet/policer/police.h>
52 #include <vnet/mfib/mfib_types.h>
54 #include "vat/json_format.h"
59 #define vl_typedefs /* define message structures */
60 #include <vpp/api/vpe_all_api_h.h>
63 /* declare message handlers for each api */
65 #define vl_endianfun /* define message structures */
66 #include <vpp/api/vpe_all_api_h.h>
69 /* instantiate all the print functions we know about */
70 #define vl_print(handle, ...)
72 #include <vpp/api/vpe_all_api_h.h>
75 #define __plugin_msg_base 0
76 #include <vlibapi/vat_helper_macros.h>
78 #if VPP_API_TEST_BUILTIN == 0
88 vat_socket_connect (vat_main_t * vam)
90 return vl_socket_client_connect
91 (&vam->socket_client_main, (char *) vam->socket_name,
92 "vpp_api_test(s)", 0 /* default socket rx, tx buffer */ );
94 #else /* vpp built-in case, we don't do sockets... */
96 vat_socket_connect (vat_main_t * vam)
102 vl_socket_client_read_reply (socket_client_main_t * scm)
109 vat_time_now (vat_main_t * vam)
111 #if VPP_API_TEST_BUILTIN
112 return vlib_time_now (vam->vlib_main);
114 return clib_time_now (&vam->clib_time);
119 errmsg (char *fmt, ...)
121 vat_main_t *vam = &vat_main;
126 s = va_format (0, fmt, &va);
131 #if VPP_API_TEST_BUILTIN
132 vlib_cli_output (vam->vlib_main, (char *) s);
135 if (vam->ifp != stdin)
136 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
137 vam->input_line_number);
138 fformat (vam->ofp, (char *) s);
146 #if VPP_API_TEST_BUILTIN == 0
148 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
150 vat_main_t *vam = va_arg (*args, vat_main_t *);
151 u32 *result = va_arg (*args, u32 *);
155 if (!unformat (input, "%s", &if_name))
158 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
165 /* Parse an IP4 address %d.%d.%d.%d. */
167 unformat_ip4_address (unformat_input_t * input, va_list * args)
169 u8 *result = va_arg (*args, u8 *);
172 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
175 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
187 unformat_ethernet_address (unformat_input_t * input, va_list * args)
189 u8 *result = va_arg (*args, u8 *);
192 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
193 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
197 for (i = 0; i < 6; i++)
198 if (a[i] >= (1 << 8))
201 for (i = 0; i < 6; i++)
207 /* Returns ethernet type as an int in host byte order. */
209 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
212 u16 *result = va_arg (*args, u16 *);
216 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
218 if (type >= (1 << 16))
226 /* Parse an IP6 address. */
228 unformat_ip6_address (unformat_input_t * input, va_list * args)
230 ip6_address_t *result = va_arg (*args, ip6_address_t *);
232 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
233 uword c, n_colon, double_colon_index;
235 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
236 double_colon_index = ARRAY_LEN (hex_quads);
237 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
240 if (c >= '0' && c <= '9')
242 else if (c >= 'a' && c <= 'f')
243 hex_digit = c + 10 - 'a';
244 else if (c >= 'A' && c <= 'F')
245 hex_digit = c + 10 - 'A';
246 else if (c == ':' && n_colon < 2)
250 unformat_put_input (input);
254 /* Too many hex quads. */
255 if (n_hex_quads >= ARRAY_LEN (hex_quads))
260 hex_quad = (hex_quad << 4) | hex_digit;
262 /* Hex quad must fit in 16 bits. */
263 if (n_hex_digits >= 4)
270 /* Save position of :: */
273 /* More than one :: ? */
274 if (double_colon_index < ARRAY_LEN (hex_quads))
276 double_colon_index = n_hex_quads;
279 if (n_colon > 0 && n_hex_digits > 0)
281 hex_quads[n_hex_quads++] = hex_quad;
287 if (n_hex_digits > 0)
288 hex_quads[n_hex_quads++] = hex_quad;
293 /* Expand :: to appropriate number of zero hex quads. */
294 if (double_colon_index < ARRAY_LEN (hex_quads))
296 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
298 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
299 hex_quads[n_zero + i] = hex_quads[i];
301 for (i = 0; i < n_zero; i++)
302 hex_quads[double_colon_index + i] = 0;
304 n_hex_quads = ARRAY_LEN (hex_quads);
307 /* Too few hex quads given. */
308 if (n_hex_quads < ARRAY_LEN (hex_quads))
311 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
312 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
319 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
321 u32 *r = va_arg (*args, u32 *);
324 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
325 foreach_ipsec_policy_action
333 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
335 u32 *r = va_arg (*args, u32 *);
338 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
339 foreach_ipsec_crypto_alg
347 format_ipsec_crypto_alg (u8 * s, va_list * args)
349 u32 i = va_arg (*args, u32);
354 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
355 foreach_ipsec_crypto_alg
358 return format (s, "unknown");
360 return format (s, "%s", t);
364 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
366 u32 *r = va_arg (*args, u32 *);
369 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
370 foreach_ipsec_integ_alg
378 format_ipsec_integ_alg (u8 * s, va_list * args)
380 u32 i = va_arg (*args, u32);
385 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
386 foreach_ipsec_integ_alg
389 return format (s, "unknown");
391 return format (s, "%s", t);
395 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
397 u32 *r = va_arg (*args, u32 *);
400 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
401 foreach_ikev2_auth_method
409 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
411 u32 *r = va_arg (*args, u32 *);
414 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
415 foreach_ikev2_id_type
421 #else /* VPP_API_TEST_BUILTIN == 1 */
423 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
425 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
426 vnet_main_t *vnm = vnet_get_main ();
427 u32 *result = va_arg (*args, u32 *);
430 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
433 *result = sw_if_index;
436 #endif /* VPP_API_TEST_BUILTIN */
439 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
441 u8 *r = va_arg (*args, u8 *);
443 if (unformat (input, "kbps"))
444 *r = SSE2_QOS_RATE_KBPS;
445 else if (unformat (input, "pps"))
446 *r = SSE2_QOS_RATE_PPS;
453 unformat_policer_round_type (unformat_input_t * input, va_list * args)
455 u8 *r = va_arg (*args, u8 *);
457 if (unformat (input, "closest"))
458 *r = SSE2_QOS_ROUND_TO_CLOSEST;
459 else if (unformat (input, "up"))
460 *r = SSE2_QOS_ROUND_TO_UP;
461 else if (unformat (input, "down"))
462 *r = SSE2_QOS_ROUND_TO_DOWN;
469 unformat_policer_type (unformat_input_t * input, va_list * args)
471 u8 *r = va_arg (*args, u8 *);
473 if (unformat (input, "1r2c"))
474 *r = SSE2_QOS_POLICER_TYPE_1R2C;
475 else if (unformat (input, "1r3c"))
476 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
477 else if (unformat (input, "2r3c-2698"))
478 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
479 else if (unformat (input, "2r3c-4115"))
480 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
481 else if (unformat (input, "2r3c-mef5cf1"))
482 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
489 unformat_dscp (unformat_input_t * input, va_list * va)
491 u8 *r = va_arg (*va, u8 *);
494 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
503 unformat_policer_action_type (unformat_input_t * input, va_list * va)
505 sse2_qos_pol_action_params_st *a
506 = va_arg (*va, sse2_qos_pol_action_params_st *);
508 if (unformat (input, "drop"))
509 a->action_type = SSE2_QOS_ACTION_DROP;
510 else if (unformat (input, "transmit"))
511 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
512 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
513 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
520 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
522 u32 *r = va_arg (*va, u32 *);
525 if (unformat (input, "ip4"))
526 tid = POLICER_CLASSIFY_TABLE_IP4;
527 else if (unformat (input, "ip6"))
528 tid = POLICER_CLASSIFY_TABLE_IP6;
529 else if (unformat (input, "l2"))
530 tid = POLICER_CLASSIFY_TABLE_L2;
539 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
541 u32 *r = va_arg (*va, u32 *);
544 if (unformat (input, "ip4"))
545 tid = FLOW_CLASSIFY_TABLE_IP4;
546 else if (unformat (input, "ip6"))
547 tid = FLOW_CLASSIFY_TABLE_IP6;
555 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
556 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
557 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
558 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
560 #if (VPP_API_TEST_BUILTIN==0)
562 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
564 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
565 mfib_itf_attribute_t attr;
568 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
570 if (unformat (input, mfib_itf_flag_long_names[attr]))
571 *iflags |= (1 << attr);
573 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
575 if (unformat (input, mfib_itf_flag_names[attr]))
576 *iflags |= (1 << attr);
579 return (old == *iflags ? 0 : 1);
583 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
585 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
586 mfib_entry_attribute_t attr;
589 FOR_EACH_MFIB_ATTRIBUTE (attr)
591 if (unformat (input, mfib_flag_long_names[attr]))
592 *eflags |= (1 << attr);
594 FOR_EACH_MFIB_ATTRIBUTE (attr)
596 if (unformat (input, mfib_flag_names[attr]))
597 *eflags |= (1 << attr);
600 return (old == *eflags ? 0 : 1);
604 format_ip4_address (u8 * s, va_list * args)
606 u8 *a = va_arg (*args, u8 *);
607 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
611 format_ip6_address (u8 * s, va_list * args)
613 ip6_address_t *a = va_arg (*args, ip6_address_t *);
614 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
616 i_max_n_zero = ARRAY_LEN (a->as_u16);
618 i_first_zero = i_max_n_zero;
620 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
622 u32 is_zero = a->as_u16[i] == 0;
623 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
629 if ((!is_zero && n_zeros > max_n_zeros)
630 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
632 i_max_n_zero = i_first_zero;
633 max_n_zeros = n_zeros;
634 i_first_zero = ARRAY_LEN (a->as_u16);
639 last_double_colon = 0;
640 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
642 if (i == i_max_n_zero && max_n_zeros > 1)
644 s = format (s, "::");
645 i += max_n_zeros - 1;
646 last_double_colon = 1;
650 s = format (s, "%s%x",
651 (last_double_colon || i == 0) ? "" : ":",
652 clib_net_to_host_u16 (a->as_u16[i]));
653 last_double_colon = 0;
660 /* Format an IP46 address. */
662 format_ip46_address (u8 * s, va_list * args)
664 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
665 ip46_type_t type = va_arg (*args, ip46_type_t);
671 is_ip4 = ip46_address_is_ip4 (ip46);
682 format (s, "%U", format_ip4_address, &ip46->ip4) :
683 format (s, "%U", format_ip6_address, &ip46->ip6);
687 format_ethernet_address (u8 * s, va_list * args)
689 u8 *a = va_arg (*args, u8 *);
691 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
692 a[0], a[1], a[2], a[3], a[4], a[5]);
697 increment_v4_address (ip4_address_t * a)
701 v = ntohl (a->as_u32) + 1;
702 a->as_u32 = ntohl (v);
706 increment_v6_address (ip6_address_t * a)
710 v0 = clib_net_to_host_u64 (a->as_u64[0]);
711 v1 = clib_net_to_host_u64 (a->as_u64[1]);
716 a->as_u64[0] = clib_net_to_host_u64 (v0);
717 a->as_u64[1] = clib_net_to_host_u64 (v1);
721 increment_mac_address (u64 * mac)
725 tmp = clib_net_to_host_u64 (tmp);
726 tmp += 1 << 16; /* skip unused (least significant) octets */
727 tmp = clib_host_to_net_u64 (tmp);
731 static void vl_api_create_loopback_reply_t_handler
732 (vl_api_create_loopback_reply_t * mp)
734 vat_main_t *vam = &vat_main;
735 i32 retval = ntohl (mp->retval);
737 vam->retval = retval;
738 vam->regenerate_interface_table = 1;
739 vam->sw_if_index = ntohl (mp->sw_if_index);
740 vam->result_ready = 1;
743 static void vl_api_create_loopback_reply_t_handler_json
744 (vl_api_create_loopback_reply_t * mp)
746 vat_main_t *vam = &vat_main;
747 vat_json_node_t node;
749 vat_json_init_object (&node);
750 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
751 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
753 vat_json_print (vam->ofp, &node);
754 vat_json_free (&node);
755 vam->retval = ntohl (mp->retval);
756 vam->result_ready = 1;
759 static void vl_api_create_loopback_instance_reply_t_handler
760 (vl_api_create_loopback_instance_reply_t * mp)
762 vat_main_t *vam = &vat_main;
763 i32 retval = ntohl (mp->retval);
765 vam->retval = retval;
766 vam->regenerate_interface_table = 1;
767 vam->sw_if_index = ntohl (mp->sw_if_index);
768 vam->result_ready = 1;
771 static void vl_api_create_loopback_instance_reply_t_handler_json
772 (vl_api_create_loopback_instance_reply_t * mp)
774 vat_main_t *vam = &vat_main;
775 vat_json_node_t node;
777 vat_json_init_object (&node);
778 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
779 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
781 vat_json_print (vam->ofp, &node);
782 vat_json_free (&node);
783 vam->retval = ntohl (mp->retval);
784 vam->result_ready = 1;
787 static void vl_api_af_packet_create_reply_t_handler
788 (vl_api_af_packet_create_reply_t * mp)
790 vat_main_t *vam = &vat_main;
791 i32 retval = ntohl (mp->retval);
793 vam->retval = retval;
794 vam->regenerate_interface_table = 1;
795 vam->sw_if_index = ntohl (mp->sw_if_index);
796 vam->result_ready = 1;
799 static void vl_api_af_packet_create_reply_t_handler_json
800 (vl_api_af_packet_create_reply_t * mp)
802 vat_main_t *vam = &vat_main;
803 vat_json_node_t node;
805 vat_json_init_object (&node);
806 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
807 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
809 vat_json_print (vam->ofp, &node);
810 vat_json_free (&node);
812 vam->retval = ntohl (mp->retval);
813 vam->result_ready = 1;
816 static void vl_api_create_vlan_subif_reply_t_handler
817 (vl_api_create_vlan_subif_reply_t * mp)
819 vat_main_t *vam = &vat_main;
820 i32 retval = ntohl (mp->retval);
822 vam->retval = retval;
823 vam->regenerate_interface_table = 1;
824 vam->sw_if_index = ntohl (mp->sw_if_index);
825 vam->result_ready = 1;
828 static void vl_api_create_vlan_subif_reply_t_handler_json
829 (vl_api_create_vlan_subif_reply_t * mp)
831 vat_main_t *vam = &vat_main;
832 vat_json_node_t node;
834 vat_json_init_object (&node);
835 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
836 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
838 vat_json_print (vam->ofp, &node);
839 vat_json_free (&node);
841 vam->retval = ntohl (mp->retval);
842 vam->result_ready = 1;
845 static void vl_api_create_subif_reply_t_handler
846 (vl_api_create_subif_reply_t * mp)
848 vat_main_t *vam = &vat_main;
849 i32 retval = ntohl (mp->retval);
851 vam->retval = retval;
852 vam->regenerate_interface_table = 1;
853 vam->sw_if_index = ntohl (mp->sw_if_index);
854 vam->result_ready = 1;
857 static void vl_api_create_subif_reply_t_handler_json
858 (vl_api_create_subif_reply_t * mp)
860 vat_main_t *vam = &vat_main;
861 vat_json_node_t node;
863 vat_json_init_object (&node);
864 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
865 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
867 vat_json_print (vam->ofp, &node);
868 vat_json_free (&node);
870 vam->retval = ntohl (mp->retval);
871 vam->result_ready = 1;
874 static void vl_api_interface_name_renumber_reply_t_handler
875 (vl_api_interface_name_renumber_reply_t * mp)
877 vat_main_t *vam = &vat_main;
878 i32 retval = ntohl (mp->retval);
880 vam->retval = retval;
881 vam->regenerate_interface_table = 1;
882 vam->result_ready = 1;
885 static void vl_api_interface_name_renumber_reply_t_handler_json
886 (vl_api_interface_name_renumber_reply_t * mp)
888 vat_main_t *vam = &vat_main;
889 vat_json_node_t node;
891 vat_json_init_object (&node);
892 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
894 vat_json_print (vam->ofp, &node);
895 vat_json_free (&node);
897 vam->retval = ntohl (mp->retval);
898 vam->result_ready = 1;
902 * Special-case: build the interface table, maintain
903 * the next loopback sw_if_index vbl.
905 static void vl_api_sw_interface_details_t_handler
906 (vl_api_sw_interface_details_t * mp)
908 vat_main_t *vam = &vat_main;
909 u8 *s = format (0, "%s%c", mp->interface_name, 0);
911 hash_set_mem (vam->sw_if_index_by_interface_name, s,
912 ntohl (mp->sw_if_index));
914 /* In sub interface case, fill the sub interface table entry */
915 if (mp->sw_if_index != mp->sup_sw_if_index)
917 sw_interface_subif_t *sub = NULL;
919 vec_add2 (vam->sw_if_subif_table, sub, 1);
921 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
922 strncpy ((char *) sub->interface_name, (char *) s,
923 vec_len (sub->interface_name));
924 sub->sw_if_index = ntohl (mp->sw_if_index);
925 sub->sub_id = ntohl (mp->sub_id);
927 sub->sub_dot1ad = mp->sub_dot1ad;
928 sub->sub_number_of_tags = mp->sub_number_of_tags;
929 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
930 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
931 sub->sub_exact_match = mp->sub_exact_match;
932 sub->sub_default = mp->sub_default;
933 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
934 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
936 /* vlan tag rewrite */
937 sub->vtr_op = ntohl (mp->vtr_op);
938 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
939 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
940 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
944 static void vl_api_sw_interface_details_t_handler_json
945 (vl_api_sw_interface_details_t * mp)
947 vat_main_t *vam = &vat_main;
948 vat_json_node_t *node = NULL;
950 if (VAT_JSON_ARRAY != vam->json_tree.type)
952 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
953 vat_json_init_array (&vam->json_tree);
955 node = vat_json_array_add (&vam->json_tree);
957 vat_json_init_object (node);
958 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
959 vat_json_object_add_uint (node, "sup_sw_if_index",
960 ntohl (mp->sup_sw_if_index));
961 vat_json_object_add_uint (node, "l2_address_length",
962 ntohl (mp->l2_address_length));
963 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
964 sizeof (mp->l2_address));
965 vat_json_object_add_string_copy (node, "interface_name",
967 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
968 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
969 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
970 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
971 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
972 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
973 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
974 vat_json_object_add_uint (node, "sub_number_of_tags",
975 mp->sub_number_of_tags);
976 vat_json_object_add_uint (node, "sub_outer_vlan_id",
977 ntohs (mp->sub_outer_vlan_id));
978 vat_json_object_add_uint (node, "sub_inner_vlan_id",
979 ntohs (mp->sub_inner_vlan_id));
980 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
981 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
982 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
983 mp->sub_outer_vlan_id_any);
984 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
985 mp->sub_inner_vlan_id_any);
986 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
987 vat_json_object_add_uint (node, "vtr_push_dot1q",
988 ntohl (mp->vtr_push_dot1q));
989 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
990 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
993 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
995 format_ethernet_address,
997 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
999 format_ethernet_address,
1001 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1002 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1006 #if VPP_API_TEST_BUILTIN == 0
1007 static void vl_api_sw_interface_event_t_handler
1008 (vl_api_sw_interface_event_t * mp)
1010 vat_main_t *vam = &vat_main;
1011 if (vam->interface_event_display)
1012 errmsg ("interface flags: sw_if_index %d %s %s",
1013 ntohl (mp->sw_if_index),
1014 mp->admin_up_down ? "admin-up" : "admin-down",
1015 mp->link_up_down ? "link-up" : "link-down");
1019 static void vl_api_sw_interface_event_t_handler_json
1020 (vl_api_sw_interface_event_t * mp)
1022 /* JSON output not supported */
1026 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1028 vat_main_t *vam = &vat_main;
1029 i32 retval = ntohl (mp->retval);
1031 vam->retval = retval;
1032 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1033 vam->result_ready = 1;
1037 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1039 vat_main_t *vam = &vat_main;
1040 vat_json_node_t node;
1041 api_main_t *am = &api_main;
1045 vat_json_init_object (&node);
1046 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1047 vat_json_object_add_uint (&node, "reply_in_shmem",
1048 ntohl (mp->reply_in_shmem));
1049 /* Toss the shared-memory original... */
1050 pthread_mutex_lock (&am->vlib_rp->mutex);
1051 oldheap = svm_push_data_heap (am->vlib_rp);
1053 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1056 svm_pop_heap (oldheap);
1057 pthread_mutex_unlock (&am->vlib_rp->mutex);
1059 vat_json_print (vam->ofp, &node);
1060 vat_json_free (&node);
1062 vam->retval = ntohl (mp->retval);
1063 vam->result_ready = 1;
1067 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1069 vat_main_t *vam = &vat_main;
1070 i32 retval = ntohl (mp->retval);
1071 u32 length = ntohl (mp->length);
1073 vec_reset_length (vam->cmd_reply);
1075 vam->retval = retval;
1078 vec_validate (vam->cmd_reply, length);
1079 clib_memcpy ((char *) (vam->cmd_reply), mp->reply, length);
1080 vam->cmd_reply[length] = 0;
1082 vam->result_ready = 1;
1086 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1088 vat_main_t *vam = &vat_main;
1089 vat_json_node_t node;
1091 vec_reset_length (vam->cmd_reply);
1093 vat_json_init_object (&node);
1094 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1095 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1097 vat_json_print (vam->ofp, &node);
1098 vat_json_free (&node);
1100 vam->retval = ntohl (mp->retval);
1101 vam->result_ready = 1;
1104 static void vl_api_classify_add_del_table_reply_t_handler
1105 (vl_api_classify_add_del_table_reply_t * mp)
1107 vat_main_t *vam = &vat_main;
1108 i32 retval = ntohl (mp->retval);
1109 if (vam->async_mode)
1111 vam->async_errors += (retval < 0);
1115 vam->retval = retval;
1117 ((mp->new_table_index != 0xFFFFFFFF) ||
1118 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1119 (mp->match_n_vectors != 0xFFFFFFFF)))
1121 * Note: this is just barely thread-safe, depends on
1122 * the main thread spinning waiting for an answer...
1124 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1125 ntohl (mp->new_table_index),
1126 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1127 vam->result_ready = 1;
1131 static void vl_api_classify_add_del_table_reply_t_handler_json
1132 (vl_api_classify_add_del_table_reply_t * mp)
1134 vat_main_t *vam = &vat_main;
1135 vat_json_node_t node;
1137 vat_json_init_object (&node);
1138 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1139 vat_json_object_add_uint (&node, "new_table_index",
1140 ntohl (mp->new_table_index));
1141 vat_json_object_add_uint (&node, "skip_n_vectors",
1142 ntohl (mp->skip_n_vectors));
1143 vat_json_object_add_uint (&node, "match_n_vectors",
1144 ntohl (mp->match_n_vectors));
1146 vat_json_print (vam->ofp, &node);
1147 vat_json_free (&node);
1149 vam->retval = ntohl (mp->retval);
1150 vam->result_ready = 1;
1153 static void vl_api_get_node_index_reply_t_handler
1154 (vl_api_get_node_index_reply_t * mp)
1156 vat_main_t *vam = &vat_main;
1157 i32 retval = ntohl (mp->retval);
1158 if (vam->async_mode)
1160 vam->async_errors += (retval < 0);
1164 vam->retval = retval;
1166 errmsg ("node index %d", ntohl (mp->node_index));
1167 vam->result_ready = 1;
1171 static void vl_api_get_node_index_reply_t_handler_json
1172 (vl_api_get_node_index_reply_t * mp)
1174 vat_main_t *vam = &vat_main;
1175 vat_json_node_t node;
1177 vat_json_init_object (&node);
1178 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1179 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1181 vat_json_print (vam->ofp, &node);
1182 vat_json_free (&node);
1184 vam->retval = ntohl (mp->retval);
1185 vam->result_ready = 1;
1188 static void vl_api_get_next_index_reply_t_handler
1189 (vl_api_get_next_index_reply_t * mp)
1191 vat_main_t *vam = &vat_main;
1192 i32 retval = ntohl (mp->retval);
1193 if (vam->async_mode)
1195 vam->async_errors += (retval < 0);
1199 vam->retval = retval;
1201 errmsg ("next node index %d", ntohl (mp->next_index));
1202 vam->result_ready = 1;
1206 static void vl_api_get_next_index_reply_t_handler_json
1207 (vl_api_get_next_index_reply_t * mp)
1209 vat_main_t *vam = &vat_main;
1210 vat_json_node_t node;
1212 vat_json_init_object (&node);
1213 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1214 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1216 vat_json_print (vam->ofp, &node);
1217 vat_json_free (&node);
1219 vam->retval = ntohl (mp->retval);
1220 vam->result_ready = 1;
1223 static void vl_api_add_node_next_reply_t_handler
1224 (vl_api_add_node_next_reply_t * mp)
1226 vat_main_t *vam = &vat_main;
1227 i32 retval = ntohl (mp->retval);
1228 if (vam->async_mode)
1230 vam->async_errors += (retval < 0);
1234 vam->retval = retval;
1236 errmsg ("next index %d", ntohl (mp->next_index));
1237 vam->result_ready = 1;
1241 static void vl_api_add_node_next_reply_t_handler_json
1242 (vl_api_add_node_next_reply_t * mp)
1244 vat_main_t *vam = &vat_main;
1245 vat_json_node_t node;
1247 vat_json_init_object (&node);
1248 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1249 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1251 vat_json_print (vam->ofp, &node);
1252 vat_json_free (&node);
1254 vam->retval = ntohl (mp->retval);
1255 vam->result_ready = 1;
1258 static void vl_api_show_version_reply_t_handler
1259 (vl_api_show_version_reply_t * mp)
1261 vat_main_t *vam = &vat_main;
1262 i32 retval = ntohl (mp->retval);
1266 errmsg (" program: %s", mp->program);
1267 errmsg (" version: %s", mp->version);
1268 errmsg (" build date: %s", mp->build_date);
1269 errmsg ("build directory: %s", mp->build_directory);
1271 vam->retval = retval;
1272 vam->result_ready = 1;
1275 static void vl_api_show_version_reply_t_handler_json
1276 (vl_api_show_version_reply_t * mp)
1278 vat_main_t *vam = &vat_main;
1279 vat_json_node_t node;
1281 vat_json_init_object (&node);
1282 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1283 vat_json_object_add_string_copy (&node, "program", mp->program);
1284 vat_json_object_add_string_copy (&node, "version", mp->version);
1285 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1286 vat_json_object_add_string_copy (&node, "build_directory",
1287 mp->build_directory);
1289 vat_json_print (vam->ofp, &node);
1290 vat_json_free (&node);
1292 vam->retval = ntohl (mp->retval);
1293 vam->result_ready = 1;
1297 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1299 u32 sw_if_index = ntohl (mp->sw_if_index);
1300 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1301 mp->mac_ip ? "mac/ip binding" : "address resolution",
1302 ntohl (mp->pid), format_ip4_address, &mp->address,
1303 format_ethernet_address, mp->new_mac, sw_if_index);
1307 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1309 /* JSON output not supported */
1313 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1315 u32 sw_if_index = ntohl (mp->sw_if_index);
1316 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1317 mp->mac_ip ? "mac/ip binding" : "address resolution",
1318 ntohl (mp->pid), format_ip6_address, mp->address,
1319 format_ethernet_address, mp->new_mac, sw_if_index);
1323 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1325 /* JSON output not supported */
1329 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1331 u32 n_macs = ntohl (mp->n_macs);
1332 errmsg ("L2MAC event recived with pid %d cl-idx %d for %d macs: \n",
1333 ntohl (mp->pid), mp->client_index, n_macs);
1335 for (i = 0; i < n_macs; i++)
1337 vl_api_mac_entry_t *mac = &mp->mac[i];
1338 errmsg (" [%d] sw_if_index %d mac_addr %U is_del %d \n",
1339 i + 1, ntohl (mac->sw_if_index),
1340 format_ethernet_address, mac->mac_addr, mac->is_del);
1347 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1349 /* JSON output not supported */
1352 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1353 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1356 * Special-case: build the bridge domain table, maintain
1357 * the next bd id vbl.
1359 static void vl_api_bridge_domain_details_t_handler
1360 (vl_api_bridge_domain_details_t * mp)
1362 vat_main_t *vam = &vat_main;
1363 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1366 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1367 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1369 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1370 ntohl (mp->bd_id), mp->learn, mp->forward,
1371 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1375 vl_api_bridge_domain_sw_if_t *sw_ifs;
1376 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1379 sw_ifs = mp->sw_if_details;
1380 for (i = 0; i < n_sw_ifs; i++)
1386 sw_if_index = ntohl (sw_ifs->sw_if_index);
1389 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1391 if ((u32) p->value[0] == sw_if_index)
1393 sw_if_name = (u8 *)(p->key);
1398 print (vam->ofp, "%7d %3d %s", sw_if_index,
1399 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1400 "sw_if_index not found!");
1407 static void vl_api_bridge_domain_details_t_handler_json
1408 (vl_api_bridge_domain_details_t * mp)
1410 vat_main_t *vam = &vat_main;
1411 vat_json_node_t *node, *array = NULL;
1412 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1414 if (VAT_JSON_ARRAY != vam->json_tree.type)
1416 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1417 vat_json_init_array (&vam->json_tree);
1419 node = vat_json_array_add (&vam->json_tree);
1421 vat_json_init_object (node);
1422 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1423 vat_json_object_add_uint (node, "flood", mp->flood);
1424 vat_json_object_add_uint (node, "forward", mp->forward);
1425 vat_json_object_add_uint (node, "learn", mp->learn);
1426 vat_json_object_add_uint (node, "bvi_sw_if_index",
1427 ntohl (mp->bvi_sw_if_index));
1428 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1429 array = vat_json_object_add (node, "sw_if");
1430 vat_json_init_array (array);
1436 vl_api_bridge_domain_sw_if_t *sw_ifs;
1439 sw_ifs = mp->sw_if_details;
1440 for (i = 0; i < n_sw_ifs; i++)
1442 node = vat_json_array_add (array);
1443 vat_json_init_object (node);
1444 vat_json_object_add_uint (node, "sw_if_index",
1445 ntohl (sw_ifs->sw_if_index));
1446 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1452 static void vl_api_control_ping_reply_t_handler
1453 (vl_api_control_ping_reply_t * mp)
1455 vat_main_t *vam = &vat_main;
1456 i32 retval = ntohl (mp->retval);
1457 if (vam->async_mode)
1459 vam->async_errors += (retval < 0);
1463 vam->retval = retval;
1464 vam->result_ready = 1;
1466 vam->socket_client_main.control_pings_outstanding--;
1469 static void vl_api_control_ping_reply_t_handler_json
1470 (vl_api_control_ping_reply_t * mp)
1472 vat_main_t *vam = &vat_main;
1473 i32 retval = ntohl (mp->retval);
1475 if (VAT_JSON_NONE != vam->json_tree.type)
1477 vat_json_print (vam->ofp, &vam->json_tree);
1478 vat_json_free (&vam->json_tree);
1479 vam->json_tree.type = VAT_JSON_NONE;
1484 vat_json_init_array (&vam->json_tree);
1485 vat_json_print (vam->ofp, &vam->json_tree);
1486 vam->json_tree.type = VAT_JSON_NONE;
1489 vam->retval = retval;
1490 vam->result_ready = 1;
1494 vl_api_bridge_domain_set_mac_age_reply_t_handler
1495 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1497 vat_main_t *vam = &vat_main;
1498 i32 retval = ntohl (mp->retval);
1499 if (vam->async_mode)
1501 vam->async_errors += (retval < 0);
1505 vam->retval = retval;
1506 vam->result_ready = 1;
1510 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1511 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1513 vat_main_t *vam = &vat_main;
1514 vat_json_node_t node;
1516 vat_json_init_object (&node);
1517 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1519 vat_json_print (vam->ofp, &node);
1520 vat_json_free (&node);
1522 vam->retval = ntohl (mp->retval);
1523 vam->result_ready = 1;
1527 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1529 vat_main_t *vam = &vat_main;
1530 i32 retval = ntohl (mp->retval);
1531 if (vam->async_mode)
1533 vam->async_errors += (retval < 0);
1537 vam->retval = retval;
1538 vam->result_ready = 1;
1542 static void vl_api_l2_flags_reply_t_handler_json
1543 (vl_api_l2_flags_reply_t * mp)
1545 vat_main_t *vam = &vat_main;
1546 vat_json_node_t node;
1548 vat_json_init_object (&node);
1549 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1550 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1551 ntohl (mp->resulting_feature_bitmap));
1553 vat_json_print (vam->ofp, &node);
1554 vat_json_free (&node);
1556 vam->retval = ntohl (mp->retval);
1557 vam->result_ready = 1;
1560 static void vl_api_bridge_flags_reply_t_handler
1561 (vl_api_bridge_flags_reply_t * mp)
1563 vat_main_t *vam = &vat_main;
1564 i32 retval = ntohl (mp->retval);
1565 if (vam->async_mode)
1567 vam->async_errors += (retval < 0);
1571 vam->retval = retval;
1572 vam->result_ready = 1;
1576 static void vl_api_bridge_flags_reply_t_handler_json
1577 (vl_api_bridge_flags_reply_t * mp)
1579 vat_main_t *vam = &vat_main;
1580 vat_json_node_t node;
1582 vat_json_init_object (&node);
1583 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1584 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1585 ntohl (mp->resulting_feature_bitmap));
1587 vat_json_print (vam->ofp, &node);
1588 vat_json_free (&node);
1590 vam->retval = ntohl (mp->retval);
1591 vam->result_ready = 1;
1594 static void vl_api_tap_connect_reply_t_handler
1595 (vl_api_tap_connect_reply_t * mp)
1597 vat_main_t *vam = &vat_main;
1598 i32 retval = ntohl (mp->retval);
1599 if (vam->async_mode)
1601 vam->async_errors += (retval < 0);
1605 vam->retval = retval;
1606 vam->sw_if_index = ntohl (mp->sw_if_index);
1607 vam->result_ready = 1;
1612 static void vl_api_tap_connect_reply_t_handler_json
1613 (vl_api_tap_connect_reply_t * mp)
1615 vat_main_t *vam = &vat_main;
1616 vat_json_node_t node;
1618 vat_json_init_object (&node);
1619 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1620 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1622 vat_json_print (vam->ofp, &node);
1623 vat_json_free (&node);
1625 vam->retval = ntohl (mp->retval);
1626 vam->result_ready = 1;
1631 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1633 vat_main_t *vam = &vat_main;
1634 i32 retval = ntohl (mp->retval);
1635 if (vam->async_mode)
1637 vam->async_errors += (retval < 0);
1641 vam->retval = retval;
1642 vam->sw_if_index = ntohl (mp->sw_if_index);
1643 vam->result_ready = 1;
1647 static void vl_api_tap_modify_reply_t_handler_json
1648 (vl_api_tap_modify_reply_t * mp)
1650 vat_main_t *vam = &vat_main;
1651 vat_json_node_t node;
1653 vat_json_init_object (&node);
1654 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1655 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1657 vat_json_print (vam->ofp, &node);
1658 vat_json_free (&node);
1660 vam->retval = ntohl (mp->retval);
1661 vam->result_ready = 1;
1665 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1667 vat_main_t *vam = &vat_main;
1668 i32 retval = ntohl (mp->retval);
1669 if (vam->async_mode)
1671 vam->async_errors += (retval < 0);
1675 vam->retval = retval;
1676 vam->result_ready = 1;
1680 static void vl_api_tap_delete_reply_t_handler_json
1681 (vl_api_tap_delete_reply_t * mp)
1683 vat_main_t *vam = &vat_main;
1684 vat_json_node_t node;
1686 vat_json_init_object (&node);
1687 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1689 vat_json_print (vam->ofp, &node);
1690 vat_json_free (&node);
1692 vam->retval = ntohl (mp->retval);
1693 vam->result_ready = 1;
1696 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1697 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1699 vat_main_t *vam = &vat_main;
1700 i32 retval = ntohl (mp->retval);
1701 if (vam->async_mode)
1703 vam->async_errors += (retval < 0);
1707 vam->retval = retval;
1708 vam->result_ready = 1;
1712 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1713 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1715 vat_main_t *vam = &vat_main;
1716 vat_json_node_t node;
1718 vat_json_init_object (&node);
1719 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1720 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1721 ntohl (mp->sw_if_index));
1723 vat_json_print (vam->ofp, &node);
1724 vat_json_free (&node);
1726 vam->retval = ntohl (mp->retval);
1727 vam->result_ready = 1;
1730 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1731 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1733 vat_main_t *vam = &vat_main;
1734 i32 retval = ntohl (mp->retval);
1735 if (vam->async_mode)
1737 vam->async_errors += (retval < 0);
1741 vam->retval = retval;
1742 vam->sw_if_index = ntohl (mp->sw_if_index);
1743 vam->result_ready = 1;
1747 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1748 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1750 vat_main_t *vam = &vat_main;
1751 vat_json_node_t node;
1753 vat_json_init_object (&node);
1754 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1755 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1757 vat_json_print (vam->ofp, &node);
1758 vat_json_free (&node);
1760 vam->retval = ntohl (mp->retval);
1761 vam->result_ready = 1;
1764 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
1765 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1767 vat_main_t *vam = &vat_main;
1768 i32 retval = ntohl (mp->retval);
1769 if (vam->async_mode)
1771 vam->async_errors += (retval < 0);
1775 vam->retval = retval;
1776 vam->result_ready = 1;
1780 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
1781 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1783 vat_main_t *vam = &vat_main;
1784 vat_json_node_t node;
1786 vat_json_init_object (&node);
1787 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1788 vat_json_object_add_uint (&node, "fwd_entry_index",
1789 clib_net_to_host_u32 (mp->fwd_entry_index));
1791 vat_json_print (vam->ofp, &node);
1792 vat_json_free (&node);
1794 vam->retval = ntohl (mp->retval);
1795 vam->result_ready = 1;
1799 format_lisp_transport_protocol (u8 * s, va_list * args)
1801 u32 proto = va_arg (*args, u32);
1806 return format (s, "udp");
1808 return format (s, "api");
1815 static void vl_api_one_get_transport_protocol_reply_t_handler
1816 (vl_api_one_get_transport_protocol_reply_t * mp)
1818 vat_main_t *vam = &vat_main;
1819 i32 retval = ntohl (mp->retval);
1820 if (vam->async_mode)
1822 vam->async_errors += (retval < 0);
1826 u32 proto = mp->protocol;
1827 print (vam->ofp, "Transport protocol: %U",
1828 format_lisp_transport_protocol, proto);
1829 vam->retval = retval;
1830 vam->result_ready = 1;
1834 static void vl_api_one_get_transport_protocol_reply_t_handler_json
1835 (vl_api_one_get_transport_protocol_reply_t * mp)
1837 vat_main_t *vam = &vat_main;
1838 vat_json_node_t node;
1841 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
1844 vat_json_init_object (&node);
1845 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1846 vat_json_object_add_string_copy (&node, "transport-protocol", s);
1849 vat_json_print (vam->ofp, &node);
1850 vat_json_free (&node);
1852 vam->retval = ntohl (mp->retval);
1853 vam->result_ready = 1;
1856 static void vl_api_one_add_del_locator_set_reply_t_handler
1857 (vl_api_one_add_del_locator_set_reply_t * mp)
1859 vat_main_t *vam = &vat_main;
1860 i32 retval = ntohl (mp->retval);
1861 if (vam->async_mode)
1863 vam->async_errors += (retval < 0);
1867 vam->retval = retval;
1868 vam->result_ready = 1;
1872 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1873 (vl_api_one_add_del_locator_set_reply_t * mp)
1875 vat_main_t *vam = &vat_main;
1876 vat_json_node_t node;
1878 vat_json_init_object (&node);
1879 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1880 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1882 vat_json_print (vam->ofp, &node);
1883 vat_json_free (&node);
1885 vam->retval = ntohl (mp->retval);
1886 vam->result_ready = 1;
1889 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1890 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1892 vat_main_t *vam = &vat_main;
1893 i32 retval = ntohl (mp->retval);
1894 if (vam->async_mode)
1896 vam->async_errors += (retval < 0);
1900 vam->retval = retval;
1901 vam->sw_if_index = ntohl (mp->sw_if_index);
1902 vam->result_ready = 1;
1906 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1907 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1909 vat_main_t *vam = &vat_main;
1910 vat_json_node_t node;
1912 vat_json_init_object (&node);
1913 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1914 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1916 vat_json_print (vam->ofp, &node);
1917 vat_json_free (&node);
1919 vam->retval = ntohl (mp->retval);
1920 vam->result_ready = 1;
1923 static void vl_api_geneve_add_del_tunnel_reply_t_handler
1924 (vl_api_geneve_add_del_tunnel_reply_t * mp)
1926 vat_main_t *vam = &vat_main;
1927 i32 retval = ntohl (mp->retval);
1928 if (vam->async_mode)
1930 vam->async_errors += (retval < 0);
1934 vam->retval = retval;
1935 vam->sw_if_index = ntohl (mp->sw_if_index);
1936 vam->result_ready = 1;
1940 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
1941 (vl_api_geneve_add_del_tunnel_reply_t * mp)
1943 vat_main_t *vam = &vat_main;
1944 vat_json_node_t node;
1946 vat_json_init_object (&node);
1947 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1948 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1950 vat_json_print (vam->ofp, &node);
1951 vat_json_free (&node);
1953 vam->retval = ntohl (mp->retval);
1954 vam->result_ready = 1;
1957 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
1958 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1960 vat_main_t *vam = &vat_main;
1961 i32 retval = ntohl (mp->retval);
1962 if (vam->async_mode)
1964 vam->async_errors += (retval < 0);
1968 vam->retval = retval;
1969 vam->sw_if_index = ntohl (mp->sw_if_index);
1970 vam->result_ready = 1;
1974 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
1975 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1977 vat_main_t *vam = &vat_main;
1978 vat_json_node_t node;
1980 vat_json_init_object (&node);
1981 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1982 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1984 vat_json_print (vam->ofp, &node);
1985 vat_json_free (&node);
1987 vam->retval = ntohl (mp->retval);
1988 vam->result_ready = 1;
1991 static void vl_api_gre_add_del_tunnel_reply_t_handler
1992 (vl_api_gre_add_del_tunnel_reply_t * mp)
1994 vat_main_t *vam = &vat_main;
1995 i32 retval = ntohl (mp->retval);
1996 if (vam->async_mode)
1998 vam->async_errors += (retval < 0);
2002 vam->retval = retval;
2003 vam->sw_if_index = ntohl (mp->sw_if_index);
2004 vam->result_ready = 1;
2008 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2009 (vl_api_gre_add_del_tunnel_reply_t * mp)
2011 vat_main_t *vam = &vat_main;
2012 vat_json_node_t node;
2014 vat_json_init_object (&node);
2015 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2016 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2018 vat_json_print (vam->ofp, &node);
2019 vat_json_free (&node);
2021 vam->retval = ntohl (mp->retval);
2022 vam->result_ready = 1;
2025 static void vl_api_create_vhost_user_if_reply_t_handler
2026 (vl_api_create_vhost_user_if_reply_t * mp)
2028 vat_main_t *vam = &vat_main;
2029 i32 retval = ntohl (mp->retval);
2030 if (vam->async_mode)
2032 vam->async_errors += (retval < 0);
2036 vam->retval = retval;
2037 vam->sw_if_index = ntohl (mp->sw_if_index);
2038 vam->result_ready = 1;
2042 static void vl_api_create_vhost_user_if_reply_t_handler_json
2043 (vl_api_create_vhost_user_if_reply_t * mp)
2045 vat_main_t *vam = &vat_main;
2046 vat_json_node_t node;
2048 vat_json_init_object (&node);
2049 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2050 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2052 vat_json_print (vam->ofp, &node);
2053 vat_json_free (&node);
2055 vam->retval = ntohl (mp->retval);
2056 vam->result_ready = 1;
2059 static clib_error_t *
2060 receive_fd_msg (int socket_fd, int *my_fd)
2063 char ctl[CMSG_SPACE (sizeof (int)) + CMSG_SPACE (sizeof (struct ucred))];
2064 struct msghdr mh = { 0 };
2065 struct iovec iov[1];
2067 struct ucred *cr = 0;
2068 struct cmsghdr *cmsg;
2069 pid_t pid __attribute__ ((unused));
2070 uid_t uid __attribute__ ((unused));
2071 gid_t gid __attribute__ ((unused));
2073 iov[0].iov_base = msgbuf;
2077 mh.msg_control = ctl;
2078 mh.msg_controllen = sizeof (ctl);
2080 memset (ctl, 0, sizeof (ctl));
2082 /* receive the incoming message */
2083 size = recvmsg (socket_fd, &mh, 0);
2086 return (size == 0) ? clib_error_return (0, "disconnected") :
2087 clib_error_return_unix (0, "recvmsg: malformed message (fd %d)",
2091 cmsg = CMSG_FIRSTHDR (&mh);
2094 if (cmsg->cmsg_level == SOL_SOCKET)
2096 if (cmsg->cmsg_type == SCM_CREDENTIALS)
2098 cr = (struct ucred *) CMSG_DATA (cmsg);
2103 else if (cmsg->cmsg_type == SCM_RIGHTS)
2105 clib_memcpy (my_fd, CMSG_DATA (cmsg), sizeof (int));
2108 cmsg = CMSG_NXTHDR (&mh, cmsg);
2113 static void vl_api_memfd_segment_create_reply_t_handler
2114 (vl_api_memfd_segment_create_reply_t * mp)
2116 /* Dont bother in the builtin version */
2117 #if VPP_API_TEST_BUILTIN == 0
2118 vat_main_t *vam = &vat_main;
2119 api_main_t *am = &api_main;
2120 socket_client_main_t *scm = &vam->socket_client_main;
2122 clib_error_t *error;
2123 memfd_private_t memfd;
2124 i32 retval = ntohl (mp->retval);
2128 error = receive_fd_msg (scm->socket_fd, &my_fd);
2135 memset (&memfd, 0, sizeof (memfd));
2138 vam->client_index_invalid = 1;
2140 retval = memfd_slave_init (&memfd);
2142 clib_warning ("WARNING: segment map returned %d", retval);
2144 /* Pivot to the memory client segment that vpp just created */
2146 am->vlib_rp = (void *) (memfd.requested_va + MMAP_PAGESIZE);
2148 am->shmem_hdr = (void *) am->vlib_rp->user_ctx;
2150 vl_client_install_client_message_handlers ();
2152 vl_client_connect_to_vlib_no_map ("pvt",
2154 32 /* input_queue_length */ );
2155 if (close (my_fd) < 0)
2156 clib_unix_warning ("close memfd fd pivot");
2157 vam->vl_input_queue = am->shmem_hdr->vl_input_queue;
2159 vl_socket_client_enable_disable (&vam->socket_client_main,
2160 0 /* disable socket */ );
2164 if (vam->async_mode)
2166 vam->async_errors += (retval < 0);
2170 vam->retval = retval;
2171 vam->result_ready = 1;
2176 static void vl_api_memfd_segment_create_reply_t_handler_json
2177 (vl_api_memfd_segment_create_reply_t * mp)
2179 clib_warning ("no");
2182 static void vl_api_dns_resolve_name_reply_t_handler
2183 (vl_api_dns_resolve_name_reply_t * mp)
2185 vat_main_t *vam = &vat_main;
2186 i32 retval = ntohl (mp->retval);
2187 if (vam->async_mode)
2189 vam->async_errors += (retval < 0);
2193 vam->retval = retval;
2194 vam->result_ready = 1;
2199 clib_warning ("ip4 address %U", format_ip4_address,
2200 (ip4_address_t *) mp->ip4_address);
2202 clib_warning ("ip6 address %U", format_ip6_address,
2203 (ip6_address_t *) mp->ip6_address);
2206 clib_warning ("retval %d", retval);
2210 static void vl_api_dns_resolve_name_reply_t_handler_json
2211 (vl_api_dns_resolve_name_reply_t * mp)
2213 clib_warning ("no");
2216 static void vl_api_ip_address_details_t_handler
2217 (vl_api_ip_address_details_t * mp)
2219 vat_main_t *vam = &vat_main;
2220 static ip_address_details_t empty_ip_address_details = { {0} };
2221 ip_address_details_t *address = NULL;
2222 ip_details_t *current_ip_details = NULL;
2223 ip_details_t *details = NULL;
2225 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2227 if (!details || vam->current_sw_if_index >= vec_len (details)
2228 || !details[vam->current_sw_if_index].present)
2230 errmsg ("ip address details arrived but not stored");
2231 errmsg ("ip_dump should be called first");
2235 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2237 #define addresses (current_ip_details->addr)
2239 vec_validate_init_empty (addresses, vec_len (addresses),
2240 empty_ip_address_details);
2242 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2244 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2245 address->prefix_length = mp->prefix_length;
2249 static void vl_api_ip_address_details_t_handler_json
2250 (vl_api_ip_address_details_t * mp)
2252 vat_main_t *vam = &vat_main;
2253 vat_json_node_t *node = NULL;
2254 struct in6_addr ip6;
2257 if (VAT_JSON_ARRAY != vam->json_tree.type)
2259 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2260 vat_json_init_array (&vam->json_tree);
2262 node = vat_json_array_add (&vam->json_tree);
2264 vat_json_init_object (node);
2267 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2268 vat_json_object_add_ip6 (node, "ip", ip6);
2272 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2273 vat_json_object_add_ip4 (node, "ip", ip4);
2275 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2279 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2281 vat_main_t *vam = &vat_main;
2282 static ip_details_t empty_ip_details = { 0 };
2283 ip_details_t *ip = NULL;
2284 u32 sw_if_index = ~0;
2286 sw_if_index = ntohl (mp->sw_if_index);
2288 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2289 sw_if_index, empty_ip_details);
2291 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2298 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2300 vat_main_t *vam = &vat_main;
2302 if (VAT_JSON_ARRAY != vam->json_tree.type)
2304 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2305 vat_json_init_array (&vam->json_tree);
2307 vat_json_array_add_uint (&vam->json_tree,
2308 clib_net_to_host_u32 (mp->sw_if_index));
2311 static void vl_api_map_domain_details_t_handler_json
2312 (vl_api_map_domain_details_t * mp)
2314 vat_json_node_t *node = NULL;
2315 vat_main_t *vam = &vat_main;
2316 struct in6_addr ip6;
2319 if (VAT_JSON_ARRAY != vam->json_tree.type)
2321 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2322 vat_json_init_array (&vam->json_tree);
2325 node = vat_json_array_add (&vam->json_tree);
2326 vat_json_init_object (node);
2328 vat_json_object_add_uint (node, "domain_index",
2329 clib_net_to_host_u32 (mp->domain_index));
2330 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2331 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2332 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2333 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2334 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2335 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2336 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2337 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2338 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2339 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2340 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2341 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2342 vat_json_object_add_uint (node, "flags", mp->flags);
2343 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2344 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2347 static void vl_api_map_domain_details_t_handler
2348 (vl_api_map_domain_details_t * mp)
2350 vat_main_t *vam = &vat_main;
2352 if (mp->is_translation)
2355 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2356 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2357 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2358 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2359 clib_net_to_host_u32 (mp->domain_index));
2364 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2365 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2366 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2367 format_ip6_address, mp->ip6_src,
2368 clib_net_to_host_u32 (mp->domain_index));
2370 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2371 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2372 mp->is_translation ? "map-t" : "");
2375 static void vl_api_map_rule_details_t_handler_json
2376 (vl_api_map_rule_details_t * mp)
2378 struct in6_addr ip6;
2379 vat_json_node_t *node = NULL;
2380 vat_main_t *vam = &vat_main;
2382 if (VAT_JSON_ARRAY != vam->json_tree.type)
2384 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2385 vat_json_init_array (&vam->json_tree);
2388 node = vat_json_array_add (&vam->json_tree);
2389 vat_json_init_object (node);
2391 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2392 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2393 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2397 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2399 vat_main_t *vam = &vat_main;
2400 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2401 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2405 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2407 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2408 "router_addr %U host_mac %U",
2409 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2410 format_ip4_address, &mp->host_address,
2411 format_ip4_address, &mp->router_address,
2412 format_ethernet_address, mp->host_mac);
2415 static void vl_api_dhcp_compl_event_t_handler_json
2416 (vl_api_dhcp_compl_event_t * mp)
2418 /* JSON output not supported */
2422 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2425 vat_main_t *vam = &vat_main;
2426 static u64 default_counter = 0;
2428 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2430 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2431 sw_if_index, default_counter);
2432 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2436 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2437 interface_counter_t counter)
2439 vat_main_t *vam = &vat_main;
2440 static interface_counter_t default_counter = { 0, };
2442 vec_validate_init_empty (vam->combined_interface_counters,
2443 vnet_counter_type, NULL);
2444 vec_validate_init_empty (vam->combined_interface_counters
2445 [vnet_counter_type], sw_if_index, default_counter);
2446 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2449 static void vl_api_vnet_interface_simple_counters_t_handler
2450 (vl_api_vnet_interface_simple_counters_t * mp)
2455 static void vl_api_vnet_interface_combined_counters_t_handler
2456 (vl_api_vnet_interface_combined_counters_t * mp)
2461 static void vl_api_vnet_interface_simple_counters_t_handler_json
2462 (vl_api_vnet_interface_simple_counters_t * mp)
2467 u32 first_sw_if_index;
2470 count = ntohl (mp->count);
2471 first_sw_if_index = ntohl (mp->first_sw_if_index);
2473 v_packets = (u64 *) & mp->data;
2474 for (i = 0; i < count; i++)
2476 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2477 set_simple_interface_counter (mp->vnet_counter_type,
2478 first_sw_if_index + i, packets);
2483 static void vl_api_vnet_interface_combined_counters_t_handler_json
2484 (vl_api_vnet_interface_combined_counters_t * mp)
2486 interface_counter_t counter;
2488 u32 first_sw_if_index;
2492 count = ntohl (mp->count);
2493 first_sw_if_index = ntohl (mp->first_sw_if_index);
2495 v = (vlib_counter_t *) & mp->data;
2496 for (i = 0; i < count; i++)
2499 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2501 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2502 set_combined_interface_counter (mp->vnet_counter_type,
2503 first_sw_if_index + i, counter);
2509 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2511 vat_main_t *vam = &vat_main;
2514 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2516 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2525 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2527 vat_main_t *vam = &vat_main;
2530 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2532 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2540 static void vl_api_vnet_ip4_fib_counters_t_handler
2541 (vl_api_vnet_ip4_fib_counters_t * mp)
2546 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2547 (vl_api_vnet_ip4_fib_counters_t * mp)
2549 vat_main_t *vam = &vat_main;
2550 vl_api_ip4_fib_counter_t *v;
2551 ip4_fib_counter_t *counter;
2558 vrf_id = ntohl (mp->vrf_id);
2559 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2560 if (~0 == vrf_index)
2562 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2563 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2564 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2565 vec_validate (vam->ip4_fib_counters, vrf_index);
2566 vam->ip4_fib_counters[vrf_index] = NULL;
2569 vec_free (vam->ip4_fib_counters[vrf_index]);
2570 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2571 count = ntohl (mp->count);
2572 for (i = 0; i < count; i++)
2574 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2575 counter = &vam->ip4_fib_counters[vrf_index][i];
2576 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2577 counter->address = ip4;
2578 counter->address_length = v->address_length;
2579 counter->packets = clib_net_to_host_u64 (v->packets);
2580 counter->bytes = clib_net_to_host_u64 (v->bytes);
2585 static void vl_api_vnet_ip4_nbr_counters_t_handler
2586 (vl_api_vnet_ip4_nbr_counters_t * mp)
2591 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2592 (vl_api_vnet_ip4_nbr_counters_t * mp)
2594 vat_main_t *vam = &vat_main;
2595 vl_api_ip4_nbr_counter_t *v;
2596 ip4_nbr_counter_t *counter;
2601 sw_if_index = ntohl (mp->sw_if_index);
2602 count = ntohl (mp->count);
2603 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2606 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2608 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2609 for (i = 0; i < count; i++)
2611 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2612 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2613 counter->address.s_addr = v->address;
2614 counter->packets = clib_net_to_host_u64 (v->packets);
2615 counter->bytes = clib_net_to_host_u64 (v->bytes);
2616 counter->linkt = v->link_type;
2621 static void vl_api_vnet_ip6_fib_counters_t_handler
2622 (vl_api_vnet_ip6_fib_counters_t * mp)
2627 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2628 (vl_api_vnet_ip6_fib_counters_t * mp)
2630 vat_main_t *vam = &vat_main;
2631 vl_api_ip6_fib_counter_t *v;
2632 ip6_fib_counter_t *counter;
2633 struct in6_addr ip6;
2639 vrf_id = ntohl (mp->vrf_id);
2640 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2641 if (~0 == vrf_index)
2643 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2644 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2645 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2646 vec_validate (vam->ip6_fib_counters, vrf_index);
2647 vam->ip6_fib_counters[vrf_index] = NULL;
2650 vec_free (vam->ip6_fib_counters[vrf_index]);
2651 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2652 count = ntohl (mp->count);
2653 for (i = 0; i < count; i++)
2655 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2656 counter = &vam->ip6_fib_counters[vrf_index][i];
2657 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2658 counter->address = ip6;
2659 counter->address_length = v->address_length;
2660 counter->packets = clib_net_to_host_u64 (v->packets);
2661 counter->bytes = clib_net_to_host_u64 (v->bytes);
2666 static void vl_api_vnet_ip6_nbr_counters_t_handler
2667 (vl_api_vnet_ip6_nbr_counters_t * mp)
2672 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2673 (vl_api_vnet_ip6_nbr_counters_t * mp)
2675 vat_main_t *vam = &vat_main;
2676 vl_api_ip6_nbr_counter_t *v;
2677 ip6_nbr_counter_t *counter;
2678 struct in6_addr ip6;
2683 sw_if_index = ntohl (mp->sw_if_index);
2684 count = ntohl (mp->count);
2685 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2688 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2690 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2691 for (i = 0; i < count; i++)
2693 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2694 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2695 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2696 counter->address = ip6;
2697 counter->packets = clib_net_to_host_u64 (v->packets);
2698 counter->bytes = clib_net_to_host_u64 (v->bytes);
2703 static void vl_api_get_first_msg_id_reply_t_handler
2704 (vl_api_get_first_msg_id_reply_t * mp)
2706 vat_main_t *vam = &vat_main;
2707 i32 retval = ntohl (mp->retval);
2709 if (vam->async_mode)
2711 vam->async_errors += (retval < 0);
2715 vam->retval = retval;
2716 vam->result_ready = 1;
2720 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2724 static void vl_api_get_first_msg_id_reply_t_handler_json
2725 (vl_api_get_first_msg_id_reply_t * mp)
2727 vat_main_t *vam = &vat_main;
2728 vat_json_node_t node;
2730 vat_json_init_object (&node);
2731 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2732 vat_json_object_add_uint (&node, "first_msg_id",
2733 (uint) ntohs (mp->first_msg_id));
2735 vat_json_print (vam->ofp, &node);
2736 vat_json_free (&node);
2738 vam->retval = ntohl (mp->retval);
2739 vam->result_ready = 1;
2742 static void vl_api_get_node_graph_reply_t_handler
2743 (vl_api_get_node_graph_reply_t * mp)
2745 vat_main_t *vam = &vat_main;
2746 api_main_t *am = &api_main;
2747 i32 retval = ntohl (mp->retval);
2748 u8 *pvt_copy, *reply;
2753 if (vam->async_mode)
2755 vam->async_errors += (retval < 0);
2759 vam->retval = retval;
2760 vam->result_ready = 1;
2763 /* "Should never happen..." */
2767 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2768 pvt_copy = vec_dup (reply);
2770 /* Toss the shared-memory original... */
2771 pthread_mutex_lock (&am->vlib_rp->mutex);
2772 oldheap = svm_push_data_heap (am->vlib_rp);
2776 svm_pop_heap (oldheap);
2777 pthread_mutex_unlock (&am->vlib_rp->mutex);
2779 if (vam->graph_nodes)
2781 hash_free (vam->graph_node_index_by_name);
2783 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2785 node = vam->graph_nodes[i];
2786 vec_free (node->name);
2787 vec_free (node->next_nodes);
2790 vec_free (vam->graph_nodes);
2793 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2794 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2795 vec_free (pvt_copy);
2797 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2799 node = vam->graph_nodes[i];
2800 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2804 static void vl_api_get_node_graph_reply_t_handler_json
2805 (vl_api_get_node_graph_reply_t * mp)
2807 vat_main_t *vam = &vat_main;
2808 api_main_t *am = &api_main;
2810 vat_json_node_t node;
2813 /* $$$$ make this real? */
2814 vat_json_init_object (&node);
2815 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2816 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2818 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2820 /* Toss the shared-memory original... */
2821 pthread_mutex_lock (&am->vlib_rp->mutex);
2822 oldheap = svm_push_data_heap (am->vlib_rp);
2826 svm_pop_heap (oldheap);
2827 pthread_mutex_unlock (&am->vlib_rp->mutex);
2829 vat_json_print (vam->ofp, &node);
2830 vat_json_free (&node);
2832 vam->retval = ntohl (mp->retval);
2833 vam->result_ready = 1;
2837 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2839 vat_main_t *vam = &vat_main;
2844 s = format (s, "%=16d%=16d%=16d",
2845 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2849 s = format (s, "%=16U%=16d%=16d",
2850 mp->is_ipv6 ? format_ip6_address :
2852 mp->ip_address, mp->priority, mp->weight);
2855 print (vam->ofp, "%v", s);
2860 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2862 vat_main_t *vam = &vat_main;
2863 vat_json_node_t *node = NULL;
2864 struct in6_addr ip6;
2867 if (VAT_JSON_ARRAY != vam->json_tree.type)
2869 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2870 vat_json_init_array (&vam->json_tree);
2872 node = vat_json_array_add (&vam->json_tree);
2873 vat_json_init_object (node);
2875 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2876 vat_json_object_add_uint (node, "priority", mp->priority);
2877 vat_json_object_add_uint (node, "weight", mp->weight);
2880 vat_json_object_add_uint (node, "sw_if_index",
2881 clib_net_to_host_u32 (mp->sw_if_index));
2886 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2887 vat_json_object_add_ip6 (node, "address", ip6);
2891 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2892 vat_json_object_add_ip4 (node, "address", ip4);
2898 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2901 vat_main_t *vam = &vat_main;
2904 ls_name = format (0, "%s", mp->ls_name);
2906 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2912 vl_api_one_locator_set_details_t_handler_json
2913 (vl_api_one_locator_set_details_t * mp)
2915 vat_main_t *vam = &vat_main;
2916 vat_json_node_t *node = 0;
2919 ls_name = format (0, "%s", mp->ls_name);
2920 vec_add1 (ls_name, 0);
2922 if (VAT_JSON_ARRAY != vam->json_tree.type)
2924 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2925 vat_json_init_array (&vam->json_tree);
2927 node = vat_json_array_add (&vam->json_tree);
2929 vat_json_init_object (node);
2930 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2931 vat_json_object_add_uint (node, "ls_index",
2932 clib_net_to_host_u32 (mp->ls_index));
2940 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2943 unformat_nsh_address (unformat_input_t * input, va_list * args)
2945 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2946 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2950 format_nsh_address_vat (u8 * s, va_list * args)
2952 nsh_t *a = va_arg (*args, nsh_t *);
2953 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2957 format_lisp_flat_eid (u8 * s, va_list * args)
2959 u32 type = va_arg (*args, u32);
2960 u8 *eid = va_arg (*args, u8 *);
2961 u32 eid_len = va_arg (*args, u32);
2966 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2968 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2970 return format (s, "%U", format_ethernet_address, eid);
2972 return format (s, "%U", format_nsh_address_vat, eid);
2978 format_lisp_eid_vat (u8 * s, va_list * args)
2980 u32 type = va_arg (*args, u32);
2981 u8 *eid = va_arg (*args, u8 *);
2982 u32 eid_len = va_arg (*args, u32);
2983 u8 *seid = va_arg (*args, u8 *);
2984 u32 seid_len = va_arg (*args, u32);
2985 u32 is_src_dst = va_arg (*args, u32);
2988 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2990 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2996 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2998 vat_main_t *vam = &vat_main;
2999 u8 *s = 0, *eid = 0;
3001 if (~0 == mp->locator_set_index)
3002 s = format (0, "action: %d", mp->action);
3004 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3006 eid = format (0, "%U", format_lisp_eid_vat,
3010 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3013 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3014 clib_net_to_host_u32 (mp->vni),
3016 mp->is_local ? "local" : "remote",
3017 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3018 clib_net_to_host_u16 (mp->key_id), mp->key);
3025 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3028 vat_main_t *vam = &vat_main;
3029 vat_json_node_t *node = 0;
3032 if (VAT_JSON_ARRAY != vam->json_tree.type)
3034 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3035 vat_json_init_array (&vam->json_tree);
3037 node = vat_json_array_add (&vam->json_tree);
3039 vat_json_init_object (node);
3040 if (~0 == mp->locator_set_index)
3041 vat_json_object_add_uint (node, "action", mp->action);
3043 vat_json_object_add_uint (node, "locator_set_index",
3044 clib_net_to_host_u32 (mp->locator_set_index));
3046 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3047 if (mp->eid_type == 3)
3049 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3050 vat_json_init_object (nsh_json);
3051 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3052 vat_json_object_add_uint (nsh_json, "spi",
3053 clib_net_to_host_u32 (nsh->spi));
3054 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3058 eid = format (0, "%U", format_lisp_eid_vat,
3062 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3064 vat_json_object_add_string_copy (node, "eid", eid);
3067 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3068 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3069 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3073 vat_json_object_add_uint (node, "key_id",
3074 clib_net_to_host_u16 (mp->key_id));
3075 vat_json_object_add_string_copy (node, "key", mp->key);
3080 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3082 vat_main_t *vam = &vat_main;
3083 u8 *seid = 0, *deid = 0;
3084 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3086 deid = format (0, "%U", format_lisp_eid_vat,
3087 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3089 seid = format (0, "%U", format_lisp_eid_vat,
3090 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3096 format_ip_address_fcn = format_ip4_address;
3098 format_ip_address_fcn = format_ip6_address;
3101 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3102 clib_net_to_host_u32 (mp->vni),
3104 format_ip_address_fcn, mp->lloc,
3105 format_ip_address_fcn, mp->rloc,
3106 clib_net_to_host_u32 (mp->pkt_count),
3107 clib_net_to_host_u32 (mp->bytes));
3114 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3116 struct in6_addr ip6;
3118 vat_main_t *vam = &vat_main;
3119 vat_json_node_t *node = 0;
3120 u8 *deid = 0, *seid = 0;
3122 if (VAT_JSON_ARRAY != vam->json_tree.type)
3124 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3125 vat_json_init_array (&vam->json_tree);
3127 node = vat_json_array_add (&vam->json_tree);
3129 vat_json_init_object (node);
3130 deid = format (0, "%U", format_lisp_eid_vat,
3131 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3133 seid = format (0, "%U", format_lisp_eid_vat,
3134 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3139 vat_json_object_add_string_copy (node, "seid", seid);
3140 vat_json_object_add_string_copy (node, "deid", deid);
3141 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3145 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3146 vat_json_object_add_ip4 (node, "lloc", ip4);
3147 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3148 vat_json_object_add_ip4 (node, "rloc", ip4);
3152 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3153 vat_json_object_add_ip6 (node, "lloc", ip6);
3154 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3155 vat_json_object_add_ip6 (node, "rloc", ip6);
3157 vat_json_object_add_uint (node, "pkt_count",
3158 clib_net_to_host_u32 (mp->pkt_count));
3159 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3166 vl_api_one_eid_table_map_details_t_handler
3167 (vl_api_one_eid_table_map_details_t * mp)
3169 vat_main_t *vam = &vat_main;
3171 u8 *line = format (0, "%=10d%=10d",
3172 clib_net_to_host_u32 (mp->vni),
3173 clib_net_to_host_u32 (mp->dp_table));
3174 print (vam->ofp, "%v", line);
3179 vl_api_one_eid_table_map_details_t_handler_json
3180 (vl_api_one_eid_table_map_details_t * mp)
3182 vat_main_t *vam = &vat_main;
3183 vat_json_node_t *node = NULL;
3185 if (VAT_JSON_ARRAY != vam->json_tree.type)
3187 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3188 vat_json_init_array (&vam->json_tree);
3190 node = vat_json_array_add (&vam->json_tree);
3191 vat_json_init_object (node);
3192 vat_json_object_add_uint (node, "dp_table",
3193 clib_net_to_host_u32 (mp->dp_table));
3194 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3198 vl_api_one_eid_table_vni_details_t_handler
3199 (vl_api_one_eid_table_vni_details_t * mp)
3201 vat_main_t *vam = &vat_main;
3203 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3204 print (vam->ofp, "%v", line);
3209 vl_api_one_eid_table_vni_details_t_handler_json
3210 (vl_api_one_eid_table_vni_details_t * mp)
3212 vat_main_t *vam = &vat_main;
3213 vat_json_node_t *node = NULL;
3215 if (VAT_JSON_ARRAY != vam->json_tree.type)
3217 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3218 vat_json_init_array (&vam->json_tree);
3220 node = vat_json_array_add (&vam->json_tree);
3221 vat_json_init_object (node);
3222 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3226 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3227 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3229 vat_main_t *vam = &vat_main;
3230 int retval = clib_net_to_host_u32 (mp->retval);
3232 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3233 print (vam->ofp, "fallback threshold value: %d", mp->value);
3235 vam->retval = retval;
3236 vam->result_ready = 1;
3240 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3241 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3243 vat_main_t *vam = &vat_main;
3244 vat_json_node_t _node, *node = &_node;
3245 int retval = clib_net_to_host_u32 (mp->retval);
3247 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3248 vat_json_init_object (node);
3249 vat_json_object_add_uint (node, "value", mp->value);
3251 vat_json_print (vam->ofp, node);
3252 vat_json_free (node);
3254 vam->retval = retval;
3255 vam->result_ready = 1;
3259 vl_api_show_one_map_register_state_reply_t_handler
3260 (vl_api_show_one_map_register_state_reply_t * mp)
3262 vat_main_t *vam = &vat_main;
3263 int retval = clib_net_to_host_u32 (mp->retval);
3265 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3267 vam->retval = retval;
3268 vam->result_ready = 1;
3272 vl_api_show_one_map_register_state_reply_t_handler_json
3273 (vl_api_show_one_map_register_state_reply_t * mp)
3275 vat_main_t *vam = &vat_main;
3276 vat_json_node_t _node, *node = &_node;
3277 int retval = clib_net_to_host_u32 (mp->retval);
3279 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3281 vat_json_init_object (node);
3282 vat_json_object_add_string_copy (node, "state", s);
3284 vat_json_print (vam->ofp, node);
3285 vat_json_free (node);
3287 vam->retval = retval;
3288 vam->result_ready = 1;
3293 vl_api_show_one_rloc_probe_state_reply_t_handler
3294 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3296 vat_main_t *vam = &vat_main;
3297 int retval = clib_net_to_host_u32 (mp->retval);
3302 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3304 vam->retval = retval;
3305 vam->result_ready = 1;
3309 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3310 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3312 vat_main_t *vam = &vat_main;
3313 vat_json_node_t _node, *node = &_node;
3314 int retval = clib_net_to_host_u32 (mp->retval);
3316 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3317 vat_json_init_object (node);
3318 vat_json_object_add_string_copy (node, "state", s);
3320 vat_json_print (vam->ofp, node);
3321 vat_json_free (node);
3323 vam->retval = retval;
3324 vam->result_ready = 1;
3329 vl_api_show_one_stats_enable_disable_reply_t_handler
3330 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3332 vat_main_t *vam = &vat_main;
3333 int retval = clib_net_to_host_u32 (mp->retval);
3338 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3340 vam->retval = retval;
3341 vam->result_ready = 1;
3345 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3346 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3348 vat_main_t *vam = &vat_main;
3349 vat_json_node_t _node, *node = &_node;
3350 int retval = clib_net_to_host_u32 (mp->retval);
3352 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3353 vat_json_init_object (node);
3354 vat_json_object_add_string_copy (node, "state", s);
3356 vat_json_print (vam->ofp, node);
3357 vat_json_free (node);
3359 vam->retval = retval;
3360 vam->result_ready = 1;
3365 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3367 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3368 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3369 e->vni = clib_net_to_host_u32 (e->vni);
3373 gpe_fwd_entries_get_reply_t_net_to_host
3374 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3378 mp->count = clib_net_to_host_u32 (mp->count);
3379 for (i = 0; i < mp->count; i++)
3381 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3386 format_gpe_encap_mode (u8 * s, va_list * args)
3388 u32 mode = va_arg (*args, u32);
3393 return format (s, "lisp");
3395 return format (s, "vxlan");
3401 vl_api_gpe_get_encap_mode_reply_t_handler
3402 (vl_api_gpe_get_encap_mode_reply_t * mp)
3404 vat_main_t *vam = &vat_main;
3406 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3407 vam->retval = ntohl (mp->retval);
3408 vam->result_ready = 1;
3412 vl_api_gpe_get_encap_mode_reply_t_handler_json
3413 (vl_api_gpe_get_encap_mode_reply_t * mp)
3415 vat_main_t *vam = &vat_main;
3416 vat_json_node_t node;
3418 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3419 vec_add1 (encap_mode, 0);
3421 vat_json_init_object (&node);
3422 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3424 vec_free (encap_mode);
3425 vat_json_print (vam->ofp, &node);
3426 vat_json_free (&node);
3428 vam->retval = ntohl (mp->retval);
3429 vam->result_ready = 1;
3433 vl_api_gpe_fwd_entry_path_details_t_handler
3434 (vl_api_gpe_fwd_entry_path_details_t * mp)
3436 vat_main_t *vam = &vat_main;
3437 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3439 if (mp->lcl_loc.is_ip4)
3440 format_ip_address_fcn = format_ip4_address;
3442 format_ip_address_fcn = format_ip6_address;
3444 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3445 format_ip_address_fcn, &mp->lcl_loc,
3446 format_ip_address_fcn, &mp->rmt_loc);
3450 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3452 struct in6_addr ip6;
3457 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3458 vat_json_object_add_ip4 (n, "address", ip4);
3462 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3463 vat_json_object_add_ip6 (n, "address", ip6);
3465 vat_json_object_add_uint (n, "weight", loc->weight);
3469 vl_api_gpe_fwd_entry_path_details_t_handler_json
3470 (vl_api_gpe_fwd_entry_path_details_t * mp)
3472 vat_main_t *vam = &vat_main;
3473 vat_json_node_t *node = NULL;
3474 vat_json_node_t *loc_node;
3476 if (VAT_JSON_ARRAY != vam->json_tree.type)
3478 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3479 vat_json_init_array (&vam->json_tree);
3481 node = vat_json_array_add (&vam->json_tree);
3482 vat_json_init_object (node);
3484 loc_node = vat_json_object_add (node, "local_locator");
3485 vat_json_init_object (loc_node);
3486 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3488 loc_node = vat_json_object_add (node, "remote_locator");
3489 vat_json_init_object (loc_node);
3490 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3494 vl_api_gpe_fwd_entries_get_reply_t_handler
3495 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3497 vat_main_t *vam = &vat_main;
3499 int retval = clib_net_to_host_u32 (mp->retval);
3500 vl_api_gpe_fwd_entry_t *e;
3505 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3507 for (i = 0; i < mp->count; i++)
3509 e = &mp->entries[i];
3510 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3511 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3512 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3516 vam->retval = retval;
3517 vam->result_ready = 1;
3521 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3522 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3525 vat_main_t *vam = &vat_main;
3526 vat_json_node_t *e = 0, root;
3528 int retval = clib_net_to_host_u32 (mp->retval);
3529 vl_api_gpe_fwd_entry_t *fwd;
3534 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3535 vat_json_init_array (&root);
3537 for (i = 0; i < mp->count; i++)
3539 e = vat_json_array_add (&root);
3540 fwd = &mp->entries[i];
3542 vat_json_init_object (e);
3543 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3544 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3545 vat_json_object_add_int (e, "vni", fwd->vni);
3546 vat_json_object_add_int (e, "action", fwd->action);
3548 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3549 fwd->leid_prefix_len);
3551 vat_json_object_add_string_copy (e, "leid", s);
3554 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3555 fwd->reid_prefix_len);
3557 vat_json_object_add_string_copy (e, "reid", s);
3561 vat_json_print (vam->ofp, &root);
3562 vat_json_free (&root);
3565 vam->retval = retval;
3566 vam->result_ready = 1;
3570 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3571 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3573 vat_main_t *vam = &vat_main;
3575 int retval = clib_net_to_host_u32 (mp->retval);
3576 vl_api_gpe_native_fwd_rpath_t *r;
3581 n = clib_net_to_host_u32 (mp->count);
3583 for (i = 0; i < n; i++)
3585 r = &mp->entries[i];
3586 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3587 clib_net_to_host_u32 (r->fib_index),
3588 clib_net_to_host_u32 (r->nh_sw_if_index),
3589 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3593 vam->retval = retval;
3594 vam->result_ready = 1;
3598 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3599 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3601 vat_main_t *vam = &vat_main;
3602 vat_json_node_t root, *e;
3604 int retval = clib_net_to_host_u32 (mp->retval);
3605 vl_api_gpe_native_fwd_rpath_t *r;
3611 n = clib_net_to_host_u32 (mp->count);
3612 vat_json_init_array (&root);
3614 for (i = 0; i < n; i++)
3616 e = vat_json_array_add (&root);
3617 vat_json_init_object (e);
3618 r = &mp->entries[i];
3620 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3623 vat_json_object_add_string_copy (e, "ip4", s);
3626 vat_json_object_add_uint (e, "fib_index",
3627 clib_net_to_host_u32 (r->fib_index));
3628 vat_json_object_add_uint (e, "nh_sw_if_index",
3629 clib_net_to_host_u32 (r->nh_sw_if_index));
3632 vat_json_print (vam->ofp, &root);
3633 vat_json_free (&root);
3636 vam->retval = retval;
3637 vam->result_ready = 1;
3641 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3642 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3644 vat_main_t *vam = &vat_main;
3646 int retval = clib_net_to_host_u32 (mp->retval);
3651 n = clib_net_to_host_u32 (mp->count);
3653 for (i = 0; i < n; i++)
3654 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3657 vam->retval = retval;
3658 vam->result_ready = 1;
3662 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3663 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3665 vat_main_t *vam = &vat_main;
3666 vat_json_node_t root;
3668 int retval = clib_net_to_host_u32 (mp->retval);
3673 n = clib_net_to_host_u32 (mp->count);
3674 vat_json_init_array (&root);
3676 for (i = 0; i < n; i++)
3677 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3679 vat_json_print (vam->ofp, &root);
3680 vat_json_free (&root);
3683 vam->retval = retval;
3684 vam->result_ready = 1;
3688 vl_api_one_ndp_entries_get_reply_t_handler
3689 (vl_api_one_ndp_entries_get_reply_t * mp)
3691 vat_main_t *vam = &vat_main;
3693 int retval = clib_net_to_host_u32 (mp->retval);
3698 n = clib_net_to_host_u32 (mp->count);
3700 for (i = 0; i < n; i++)
3701 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3702 format_ethernet_address, mp->entries[i].mac);
3705 vam->retval = retval;
3706 vam->result_ready = 1;
3710 vl_api_one_ndp_entries_get_reply_t_handler_json
3711 (vl_api_one_ndp_entries_get_reply_t * mp)
3714 vat_main_t *vam = &vat_main;
3715 vat_json_node_t *e = 0, root;
3717 int retval = clib_net_to_host_u32 (mp->retval);
3718 vl_api_one_ndp_entry_t *arp_entry;
3723 n = clib_net_to_host_u32 (mp->count);
3724 vat_json_init_array (&root);
3726 for (i = 0; i < n; i++)
3728 e = vat_json_array_add (&root);
3729 arp_entry = &mp->entries[i];
3731 vat_json_init_object (e);
3732 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3735 vat_json_object_add_string_copy (e, "mac", s);
3738 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3740 vat_json_object_add_string_copy (e, "ip6", s);
3744 vat_json_print (vam->ofp, &root);
3745 vat_json_free (&root);
3748 vam->retval = retval;
3749 vam->result_ready = 1;
3753 vl_api_one_l2_arp_entries_get_reply_t_handler
3754 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3756 vat_main_t *vam = &vat_main;
3758 int retval = clib_net_to_host_u32 (mp->retval);
3763 n = clib_net_to_host_u32 (mp->count);
3765 for (i = 0; i < n; i++)
3766 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3767 format_ethernet_address, mp->entries[i].mac);
3770 vam->retval = retval;
3771 vam->result_ready = 1;
3775 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3776 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3779 vat_main_t *vam = &vat_main;
3780 vat_json_node_t *e = 0, root;
3782 int retval = clib_net_to_host_u32 (mp->retval);
3783 vl_api_one_l2_arp_entry_t *arp_entry;
3788 n = clib_net_to_host_u32 (mp->count);
3789 vat_json_init_array (&root);
3791 for (i = 0; i < n; i++)
3793 e = vat_json_array_add (&root);
3794 arp_entry = &mp->entries[i];
3796 vat_json_init_object (e);
3797 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3800 vat_json_object_add_string_copy (e, "mac", s);
3803 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3805 vat_json_object_add_string_copy (e, "ip4", s);
3809 vat_json_print (vam->ofp, &root);
3810 vat_json_free (&root);
3813 vam->retval = retval;
3814 vam->result_ready = 1;
3818 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3820 vat_main_t *vam = &vat_main;
3822 int retval = clib_net_to_host_u32 (mp->retval);
3827 n = clib_net_to_host_u32 (mp->count);
3829 for (i = 0; i < n; i++)
3831 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3835 vam->retval = retval;
3836 vam->result_ready = 1;
3840 vl_api_one_ndp_bd_get_reply_t_handler_json
3841 (vl_api_one_ndp_bd_get_reply_t * mp)
3843 vat_main_t *vam = &vat_main;
3844 vat_json_node_t root;
3846 int retval = clib_net_to_host_u32 (mp->retval);
3851 n = clib_net_to_host_u32 (mp->count);
3852 vat_json_init_array (&root);
3854 for (i = 0; i < n; i++)
3856 vat_json_array_add_uint (&root,
3857 clib_net_to_host_u32 (mp->bridge_domains[i]));
3860 vat_json_print (vam->ofp, &root);
3861 vat_json_free (&root);
3864 vam->retval = retval;
3865 vam->result_ready = 1;
3869 vl_api_one_l2_arp_bd_get_reply_t_handler
3870 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3872 vat_main_t *vam = &vat_main;
3874 int retval = clib_net_to_host_u32 (mp->retval);
3879 n = clib_net_to_host_u32 (mp->count);
3881 for (i = 0; i < n; i++)
3883 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3887 vam->retval = retval;
3888 vam->result_ready = 1;
3892 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3893 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3895 vat_main_t *vam = &vat_main;
3896 vat_json_node_t root;
3898 int retval = clib_net_to_host_u32 (mp->retval);
3903 n = clib_net_to_host_u32 (mp->count);
3904 vat_json_init_array (&root);
3906 for (i = 0; i < n; i++)
3908 vat_json_array_add_uint (&root,
3909 clib_net_to_host_u32 (mp->bridge_domains[i]));
3912 vat_json_print (vam->ofp, &root);
3913 vat_json_free (&root);
3916 vam->retval = retval;
3917 vam->result_ready = 1;
3921 vl_api_one_adjacencies_get_reply_t_handler
3922 (vl_api_one_adjacencies_get_reply_t * mp)
3924 vat_main_t *vam = &vat_main;
3926 int retval = clib_net_to_host_u32 (mp->retval);
3927 vl_api_one_adjacency_t *a;
3932 n = clib_net_to_host_u32 (mp->count);
3934 for (i = 0; i < n; i++)
3936 a = &mp->adjacencies[i];
3937 print (vam->ofp, "%U %40U",
3938 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3939 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3943 vam->retval = retval;
3944 vam->result_ready = 1;
3948 vl_api_one_adjacencies_get_reply_t_handler_json
3949 (vl_api_one_adjacencies_get_reply_t * mp)
3952 vat_main_t *vam = &vat_main;
3953 vat_json_node_t *e = 0, root;
3955 int retval = clib_net_to_host_u32 (mp->retval);
3956 vl_api_one_adjacency_t *a;
3961 n = clib_net_to_host_u32 (mp->count);
3962 vat_json_init_array (&root);
3964 for (i = 0; i < n; i++)
3966 e = vat_json_array_add (&root);
3967 a = &mp->adjacencies[i];
3969 vat_json_init_object (e);
3970 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3971 a->leid_prefix_len);
3973 vat_json_object_add_string_copy (e, "leid", s);
3976 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3977 a->reid_prefix_len);
3979 vat_json_object_add_string_copy (e, "reid", s);
3983 vat_json_print (vam->ofp, &root);
3984 vat_json_free (&root);
3987 vam->retval = retval;
3988 vam->result_ready = 1;
3992 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3994 vat_main_t *vam = &vat_main;
3996 print (vam->ofp, "%=20U",
3997 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4002 vl_api_one_map_server_details_t_handler_json
4003 (vl_api_one_map_server_details_t * mp)
4005 vat_main_t *vam = &vat_main;
4006 vat_json_node_t *node = NULL;
4007 struct in6_addr ip6;
4010 if (VAT_JSON_ARRAY != vam->json_tree.type)
4012 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4013 vat_json_init_array (&vam->json_tree);
4015 node = vat_json_array_add (&vam->json_tree);
4017 vat_json_init_object (node);
4020 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4021 vat_json_object_add_ip6 (node, "map-server", ip6);
4025 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4026 vat_json_object_add_ip4 (node, "map-server", ip4);
4031 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4034 vat_main_t *vam = &vat_main;
4036 print (vam->ofp, "%=20U",
4037 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4042 vl_api_one_map_resolver_details_t_handler_json
4043 (vl_api_one_map_resolver_details_t * mp)
4045 vat_main_t *vam = &vat_main;
4046 vat_json_node_t *node = NULL;
4047 struct in6_addr ip6;
4050 if (VAT_JSON_ARRAY != vam->json_tree.type)
4052 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4053 vat_json_init_array (&vam->json_tree);
4055 node = vat_json_array_add (&vam->json_tree);
4057 vat_json_init_object (node);
4060 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4061 vat_json_object_add_ip6 (node, "map resolver", ip6);
4065 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4066 vat_json_object_add_ip4 (node, "map resolver", ip4);
4071 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4073 vat_main_t *vam = &vat_main;
4074 i32 retval = ntohl (mp->retval);
4078 print (vam->ofp, "feature: %s\ngpe: %s",
4079 mp->feature_status ? "enabled" : "disabled",
4080 mp->gpe_status ? "enabled" : "disabled");
4083 vam->retval = retval;
4084 vam->result_ready = 1;
4088 vl_api_show_one_status_reply_t_handler_json
4089 (vl_api_show_one_status_reply_t * mp)
4091 vat_main_t *vam = &vat_main;
4092 vat_json_node_t node;
4093 u8 *gpe_status = NULL;
4094 u8 *feature_status = NULL;
4096 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4097 feature_status = format (0, "%s",
4098 mp->feature_status ? "enabled" : "disabled");
4099 vec_add1 (gpe_status, 0);
4100 vec_add1 (feature_status, 0);
4102 vat_json_init_object (&node);
4103 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4104 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4106 vec_free (gpe_status);
4107 vec_free (feature_status);
4109 vat_json_print (vam->ofp, &node);
4110 vat_json_free (&node);
4112 vam->retval = ntohl (mp->retval);
4113 vam->result_ready = 1;
4117 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4118 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4120 vat_main_t *vam = &vat_main;
4121 i32 retval = ntohl (mp->retval);
4125 print (vam->ofp, "%=20s", mp->locator_set_name);
4128 vam->retval = retval;
4129 vam->result_ready = 1;
4133 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4134 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4136 vat_main_t *vam = &vat_main;
4137 vat_json_node_t *node = NULL;
4139 if (VAT_JSON_ARRAY != vam->json_tree.type)
4141 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4142 vat_json_init_array (&vam->json_tree);
4144 node = vat_json_array_add (&vam->json_tree);
4146 vat_json_init_object (node);
4147 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4149 vat_json_print (vam->ofp, node);
4150 vat_json_free (node);
4152 vam->retval = ntohl (mp->retval);
4153 vam->result_ready = 1;
4157 format_lisp_map_request_mode (u8 * s, va_list * args)
4159 u32 mode = va_arg (*args, u32);
4164 return format (0, "dst-only");
4166 return format (0, "src-dst");
4172 vl_api_show_one_map_request_mode_reply_t_handler
4173 (vl_api_show_one_map_request_mode_reply_t * mp)
4175 vat_main_t *vam = &vat_main;
4176 i32 retval = ntohl (mp->retval);
4180 u32 mode = mp->mode;
4181 print (vam->ofp, "map_request_mode: %U",
4182 format_lisp_map_request_mode, mode);
4185 vam->retval = retval;
4186 vam->result_ready = 1;
4190 vl_api_show_one_map_request_mode_reply_t_handler_json
4191 (vl_api_show_one_map_request_mode_reply_t * mp)
4193 vat_main_t *vam = &vat_main;
4194 vat_json_node_t node;
4199 s = format (0, "%U", format_lisp_map_request_mode, mode);
4202 vat_json_init_object (&node);
4203 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4204 vat_json_print (vam->ofp, &node);
4205 vat_json_free (&node);
4208 vam->retval = ntohl (mp->retval);
4209 vam->result_ready = 1;
4213 vl_api_show_one_use_petr_reply_t_handler
4214 (vl_api_show_one_use_petr_reply_t * mp)
4216 vat_main_t *vam = &vat_main;
4217 i32 retval = ntohl (mp->retval);
4221 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4224 print (vam->ofp, "Proxy-ETR address; %U",
4225 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4230 vam->retval = retval;
4231 vam->result_ready = 1;
4235 vl_api_show_one_use_petr_reply_t_handler_json
4236 (vl_api_show_one_use_petr_reply_t * mp)
4238 vat_main_t *vam = &vat_main;
4239 vat_json_node_t node;
4242 struct in6_addr ip6;
4244 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4245 vec_add1 (status, 0);
4247 vat_json_init_object (&node);
4248 vat_json_object_add_string_copy (&node, "status", status);
4253 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4254 vat_json_object_add_ip6 (&node, "address", ip6);
4258 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4259 vat_json_object_add_ip4 (&node, "address", ip4);
4265 vat_json_print (vam->ofp, &node);
4266 vat_json_free (&node);
4268 vam->retval = ntohl (mp->retval);
4269 vam->result_ready = 1;
4273 vl_api_show_one_nsh_mapping_reply_t_handler
4274 (vl_api_show_one_nsh_mapping_reply_t * mp)
4276 vat_main_t *vam = &vat_main;
4277 i32 retval = ntohl (mp->retval);
4281 print (vam->ofp, "%-20s%-16s",
4282 mp->is_set ? "set" : "not-set",
4283 mp->is_set ? (char *) mp->locator_set_name : "");
4286 vam->retval = retval;
4287 vam->result_ready = 1;
4291 vl_api_show_one_nsh_mapping_reply_t_handler_json
4292 (vl_api_show_one_nsh_mapping_reply_t * mp)
4294 vat_main_t *vam = &vat_main;
4295 vat_json_node_t node;
4298 status = format (0, "%s", mp->is_set ? "yes" : "no");
4299 vec_add1 (status, 0);
4301 vat_json_init_object (&node);
4302 vat_json_object_add_string_copy (&node, "is_set", status);
4305 vat_json_object_add_string_copy (&node, "locator_set",
4306 mp->locator_set_name);
4311 vat_json_print (vam->ofp, &node);
4312 vat_json_free (&node);
4314 vam->retval = ntohl (mp->retval);
4315 vam->result_ready = 1;
4319 vl_api_show_one_map_register_ttl_reply_t_handler
4320 (vl_api_show_one_map_register_ttl_reply_t * mp)
4322 vat_main_t *vam = &vat_main;
4323 i32 retval = ntohl (mp->retval);
4325 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4329 print (vam->ofp, "ttl: %u", mp->ttl);
4332 vam->retval = retval;
4333 vam->result_ready = 1;
4337 vl_api_show_one_map_register_ttl_reply_t_handler_json
4338 (vl_api_show_one_map_register_ttl_reply_t * mp)
4340 vat_main_t *vam = &vat_main;
4341 vat_json_node_t node;
4343 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4344 vat_json_init_object (&node);
4345 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4347 vat_json_print (vam->ofp, &node);
4348 vat_json_free (&node);
4350 vam->retval = ntohl (mp->retval);
4351 vam->result_ready = 1;
4355 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4357 vat_main_t *vam = &vat_main;
4358 i32 retval = ntohl (mp->retval);
4362 print (vam->ofp, "%-20s%-16s",
4363 mp->status ? "enabled" : "disabled",
4364 mp->status ? (char *) mp->locator_set_name : "");
4367 vam->retval = retval;
4368 vam->result_ready = 1;
4372 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4374 vat_main_t *vam = &vat_main;
4375 vat_json_node_t node;
4378 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4379 vec_add1 (status, 0);
4381 vat_json_init_object (&node);
4382 vat_json_object_add_string_copy (&node, "status", status);
4385 vat_json_object_add_string_copy (&node, "locator_set",
4386 mp->locator_set_name);
4391 vat_json_print (vam->ofp, &node);
4392 vat_json_free (&node);
4394 vam->retval = ntohl (mp->retval);
4395 vam->result_ready = 1;
4399 format_policer_type (u8 * s, va_list * va)
4401 u32 i = va_arg (*va, u32);
4403 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4404 s = format (s, "1r2c");
4405 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4406 s = format (s, "1r3c");
4407 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4408 s = format (s, "2r3c-2698");
4409 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4410 s = format (s, "2r3c-4115");
4411 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4412 s = format (s, "2r3c-mef5cf1");
4414 s = format (s, "ILLEGAL");
4419 format_policer_rate_type (u8 * s, va_list * va)
4421 u32 i = va_arg (*va, u32);
4423 if (i == SSE2_QOS_RATE_KBPS)
4424 s = format (s, "kbps");
4425 else if (i == SSE2_QOS_RATE_PPS)
4426 s = format (s, "pps");
4428 s = format (s, "ILLEGAL");
4433 format_policer_round_type (u8 * s, va_list * va)
4435 u32 i = va_arg (*va, u32);
4437 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4438 s = format (s, "closest");
4439 else if (i == SSE2_QOS_ROUND_TO_UP)
4440 s = format (s, "up");
4441 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4442 s = format (s, "down");
4444 s = format (s, "ILLEGAL");
4449 format_policer_action_type (u8 * s, va_list * va)
4451 u32 i = va_arg (*va, u32);
4453 if (i == SSE2_QOS_ACTION_DROP)
4454 s = format (s, "drop");
4455 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4456 s = format (s, "transmit");
4457 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4458 s = format (s, "mark-and-transmit");
4460 s = format (s, "ILLEGAL");
4465 format_dscp (u8 * s, va_list * va)
4467 u32 i = va_arg (*va, u32);
4472 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4476 return format (s, "ILLEGAL");
4478 s = format (s, "%s", t);
4483 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4485 vat_main_t *vam = &vat_main;
4486 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4488 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4489 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4491 conform_dscp_str = format (0, "");
4493 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4494 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4496 exceed_dscp_str = format (0, "");
4498 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4499 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4501 violate_dscp_str = format (0, "");
4503 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4504 "rate type %U, round type %U, %s rate, %s color-aware, "
4505 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4506 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4507 "conform action %U%s, exceed action %U%s, violate action %U%s",
4509 format_policer_type, mp->type,
4512 clib_net_to_host_u64 (mp->cb),
4513 clib_net_to_host_u64 (mp->eb),
4514 format_policer_rate_type, mp->rate_type,
4515 format_policer_round_type, mp->round_type,
4516 mp->single_rate ? "single" : "dual",
4517 mp->color_aware ? "is" : "not",
4518 ntohl (mp->cir_tokens_per_period),
4519 ntohl (mp->pir_tokens_per_period),
4521 ntohl (mp->current_limit),
4522 ntohl (mp->current_bucket),
4523 ntohl (mp->extended_limit),
4524 ntohl (mp->extended_bucket),
4525 clib_net_to_host_u64 (mp->last_update_time),
4526 format_policer_action_type, mp->conform_action_type,
4528 format_policer_action_type, mp->exceed_action_type,
4530 format_policer_action_type, mp->violate_action_type,
4533 vec_free (conform_dscp_str);
4534 vec_free (exceed_dscp_str);
4535 vec_free (violate_dscp_str);
4538 static void vl_api_policer_details_t_handler_json
4539 (vl_api_policer_details_t * mp)
4541 vat_main_t *vam = &vat_main;
4542 vat_json_node_t *node;
4543 u8 *rate_type_str, *round_type_str, *type_str;
4544 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4546 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4548 format (0, "%U", format_policer_round_type, mp->round_type);
4549 type_str = format (0, "%U", format_policer_type, mp->type);
4550 conform_action_str = format (0, "%U", format_policer_action_type,
4551 mp->conform_action_type);
4552 exceed_action_str = format (0, "%U", format_policer_action_type,
4553 mp->exceed_action_type);
4554 violate_action_str = format (0, "%U", format_policer_action_type,
4555 mp->violate_action_type);
4557 if (VAT_JSON_ARRAY != vam->json_tree.type)
4559 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4560 vat_json_init_array (&vam->json_tree);
4562 node = vat_json_array_add (&vam->json_tree);
4564 vat_json_init_object (node);
4565 vat_json_object_add_string_copy (node, "name", mp->name);
4566 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4567 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4568 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4569 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4570 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4571 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4572 vat_json_object_add_string_copy (node, "type", type_str);
4573 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4574 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4575 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4576 vat_json_object_add_uint (node, "cir_tokens_per_period",
4577 ntohl (mp->cir_tokens_per_period));
4578 vat_json_object_add_uint (node, "eir_tokens_per_period",
4579 ntohl (mp->pir_tokens_per_period));
4580 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4581 vat_json_object_add_uint (node, "current_bucket",
4582 ntohl (mp->current_bucket));
4583 vat_json_object_add_uint (node, "extended_limit",
4584 ntohl (mp->extended_limit));
4585 vat_json_object_add_uint (node, "extended_bucket",
4586 ntohl (mp->extended_bucket));
4587 vat_json_object_add_uint (node, "last_update_time",
4588 ntohl (mp->last_update_time));
4589 vat_json_object_add_string_copy (node, "conform_action",
4590 conform_action_str);
4591 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4593 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4594 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4595 vec_free (dscp_str);
4597 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4598 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4600 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4601 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4602 vec_free (dscp_str);
4604 vat_json_object_add_string_copy (node, "violate_action",
4605 violate_action_str);
4606 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4608 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4609 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4610 vec_free (dscp_str);
4613 vec_free (rate_type_str);
4614 vec_free (round_type_str);
4615 vec_free (type_str);
4616 vec_free (conform_action_str);
4617 vec_free (exceed_action_str);
4618 vec_free (violate_action_str);
4622 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4625 vat_main_t *vam = &vat_main;
4626 int i, count = ntohl (mp->count);
4629 print (vam->ofp, "classify table ids (%d) : ", count);
4630 for (i = 0; i < count; i++)
4632 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4633 print (vam->ofp, (i < count - 1) ? "," : "");
4635 vam->retval = ntohl (mp->retval);
4636 vam->result_ready = 1;
4640 vl_api_classify_table_ids_reply_t_handler_json
4641 (vl_api_classify_table_ids_reply_t * mp)
4643 vat_main_t *vam = &vat_main;
4644 int i, count = ntohl (mp->count);
4648 vat_json_node_t node;
4650 vat_json_init_object (&node);
4651 for (i = 0; i < count; i++)
4653 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4655 vat_json_print (vam->ofp, &node);
4656 vat_json_free (&node);
4658 vam->retval = ntohl (mp->retval);
4659 vam->result_ready = 1;
4663 vl_api_classify_table_by_interface_reply_t_handler
4664 (vl_api_classify_table_by_interface_reply_t * mp)
4666 vat_main_t *vam = &vat_main;
4669 table_id = ntohl (mp->l2_table_id);
4671 print (vam->ofp, "l2 table id : %d", table_id);
4673 print (vam->ofp, "l2 table id : No input ACL tables configured");
4674 table_id = ntohl (mp->ip4_table_id);
4676 print (vam->ofp, "ip4 table id : %d", table_id);
4678 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4679 table_id = ntohl (mp->ip6_table_id);
4681 print (vam->ofp, "ip6 table id : %d", table_id);
4683 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4684 vam->retval = ntohl (mp->retval);
4685 vam->result_ready = 1;
4689 vl_api_classify_table_by_interface_reply_t_handler_json
4690 (vl_api_classify_table_by_interface_reply_t * mp)
4692 vat_main_t *vam = &vat_main;
4693 vat_json_node_t node;
4695 vat_json_init_object (&node);
4697 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4698 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4699 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4701 vat_json_print (vam->ofp, &node);
4702 vat_json_free (&node);
4704 vam->retval = ntohl (mp->retval);
4705 vam->result_ready = 1;
4708 static void vl_api_policer_add_del_reply_t_handler
4709 (vl_api_policer_add_del_reply_t * mp)
4711 vat_main_t *vam = &vat_main;
4712 i32 retval = ntohl (mp->retval);
4713 if (vam->async_mode)
4715 vam->async_errors += (retval < 0);
4719 vam->retval = retval;
4720 vam->result_ready = 1;
4721 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4723 * Note: this is just barely thread-safe, depends on
4724 * the main thread spinning waiting for an answer...
4726 errmsg ("policer index %d", ntohl (mp->policer_index));
4730 static void vl_api_policer_add_del_reply_t_handler_json
4731 (vl_api_policer_add_del_reply_t * mp)
4733 vat_main_t *vam = &vat_main;
4734 vat_json_node_t node;
4736 vat_json_init_object (&node);
4737 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4738 vat_json_object_add_uint (&node, "policer_index",
4739 ntohl (mp->policer_index));
4741 vat_json_print (vam->ofp, &node);
4742 vat_json_free (&node);
4744 vam->retval = ntohl (mp->retval);
4745 vam->result_ready = 1;
4748 /* Format hex dump. */
4750 format_hex_bytes (u8 * s, va_list * va)
4752 u8 *bytes = va_arg (*va, u8 *);
4753 int n_bytes = va_arg (*va, int);
4756 /* Print short or long form depending on byte count. */
4757 uword short_form = n_bytes <= 32;
4758 u32 indent = format_get_indent (s);
4763 for (i = 0; i < n_bytes; i++)
4765 if (!short_form && (i % 32) == 0)
4766 s = format (s, "%08x: ", i);
4767 s = format (s, "%02x", bytes[i]);
4768 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4769 s = format (s, "\n%U", format_white_space, indent);
4776 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4779 vat_main_t *vam = &vat_main;
4780 i32 retval = ntohl (mp->retval);
4783 print (vam->ofp, "classify table info :");
4784 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4785 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4786 ntohl (mp->miss_next_index));
4787 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4788 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4789 ntohl (mp->match_n_vectors));
4790 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4791 ntohl (mp->mask_length));
4793 vam->retval = retval;
4794 vam->result_ready = 1;
4798 vl_api_classify_table_info_reply_t_handler_json
4799 (vl_api_classify_table_info_reply_t * mp)
4801 vat_main_t *vam = &vat_main;
4802 vat_json_node_t node;
4804 i32 retval = ntohl (mp->retval);
4807 vat_json_init_object (&node);
4809 vat_json_object_add_int (&node, "sessions",
4810 ntohl (mp->active_sessions));
4811 vat_json_object_add_int (&node, "nexttbl",
4812 ntohl (mp->next_table_index));
4813 vat_json_object_add_int (&node, "nextnode",
4814 ntohl (mp->miss_next_index));
4815 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4816 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4817 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4818 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4819 ntohl (mp->mask_length), 0);
4820 vat_json_object_add_string_copy (&node, "mask", s);
4822 vat_json_print (vam->ofp, &node);
4823 vat_json_free (&node);
4825 vam->retval = ntohl (mp->retval);
4826 vam->result_ready = 1;
4830 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4833 vat_main_t *vam = &vat_main;
4835 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4836 ntohl (mp->hit_next_index), ntohl (mp->advance),
4837 ntohl (mp->opaque_index));
4838 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4839 ntohl (mp->match_length));
4843 vl_api_classify_session_details_t_handler_json
4844 (vl_api_classify_session_details_t * mp)
4846 vat_main_t *vam = &vat_main;
4847 vat_json_node_t *node = NULL;
4849 if (VAT_JSON_ARRAY != vam->json_tree.type)
4851 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4852 vat_json_init_array (&vam->json_tree);
4854 node = vat_json_array_add (&vam->json_tree);
4856 vat_json_init_object (node);
4857 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4858 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4859 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4861 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4863 vat_json_object_add_string_copy (node, "match", s);
4866 static void vl_api_pg_create_interface_reply_t_handler
4867 (vl_api_pg_create_interface_reply_t * mp)
4869 vat_main_t *vam = &vat_main;
4871 vam->retval = ntohl (mp->retval);
4872 vam->result_ready = 1;
4875 static void vl_api_pg_create_interface_reply_t_handler_json
4876 (vl_api_pg_create_interface_reply_t * mp)
4878 vat_main_t *vam = &vat_main;
4879 vat_json_node_t node;
4881 i32 retval = ntohl (mp->retval);
4884 vat_json_init_object (&node);
4886 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4888 vat_json_print (vam->ofp, &node);
4889 vat_json_free (&node);
4891 vam->retval = ntohl (mp->retval);
4892 vam->result_ready = 1;
4895 static void vl_api_policer_classify_details_t_handler
4896 (vl_api_policer_classify_details_t * mp)
4898 vat_main_t *vam = &vat_main;
4900 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4901 ntohl (mp->table_index));
4904 static void vl_api_policer_classify_details_t_handler_json
4905 (vl_api_policer_classify_details_t * mp)
4907 vat_main_t *vam = &vat_main;
4908 vat_json_node_t *node;
4910 if (VAT_JSON_ARRAY != vam->json_tree.type)
4912 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4913 vat_json_init_array (&vam->json_tree);
4915 node = vat_json_array_add (&vam->json_tree);
4917 vat_json_init_object (node);
4918 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4919 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4922 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4923 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4925 vat_main_t *vam = &vat_main;
4926 i32 retval = ntohl (mp->retval);
4927 if (vam->async_mode)
4929 vam->async_errors += (retval < 0);
4933 vam->retval = retval;
4934 vam->sw_if_index = ntohl (mp->sw_if_index);
4935 vam->result_ready = 1;
4939 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4940 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4942 vat_main_t *vam = &vat_main;
4943 vat_json_node_t node;
4945 vat_json_init_object (&node);
4946 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4947 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4949 vat_json_print (vam->ofp, &node);
4950 vat_json_free (&node);
4952 vam->retval = ntohl (mp->retval);
4953 vam->result_ready = 1;
4956 static void vl_api_flow_classify_details_t_handler
4957 (vl_api_flow_classify_details_t * mp)
4959 vat_main_t *vam = &vat_main;
4961 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4962 ntohl (mp->table_index));
4965 static void vl_api_flow_classify_details_t_handler_json
4966 (vl_api_flow_classify_details_t * mp)
4968 vat_main_t *vam = &vat_main;
4969 vat_json_node_t *node;
4971 if (VAT_JSON_ARRAY != vam->json_tree.type)
4973 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4974 vat_json_init_array (&vam->json_tree);
4976 node = vat_json_array_add (&vam->json_tree);
4978 vat_json_init_object (node);
4979 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4980 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4983 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
4984 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
4985 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
4986 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
4987 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
4988 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
4989 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
4990 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
4991 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
4992 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
4993 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
4994 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
4995 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4996 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4997 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
4998 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
4999 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5000 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5001 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5002 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5003 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5004 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5007 * Generate boilerplate reply handlers, which
5008 * dig the return value out of the xxx_reply_t API message,
5009 * stick it into vam->retval, and set vam->result_ready
5011 * Could also do this by pointing N message decode slots at
5012 * a single function, but that could break in subtle ways.
5015 #define foreach_standard_reply_retval_handler \
5016 _(sw_interface_set_flags_reply) \
5017 _(sw_interface_add_del_address_reply) \
5018 _(sw_interface_set_table_reply) \
5019 _(sw_interface_set_mpls_enable_reply) \
5020 _(sw_interface_set_vpath_reply) \
5021 _(sw_interface_set_vxlan_bypass_reply) \
5022 _(sw_interface_set_geneve_bypass_reply) \
5023 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5024 _(sw_interface_set_l2_bridge_reply) \
5025 _(bridge_domain_add_del_reply) \
5026 _(sw_interface_set_l2_xconnect_reply) \
5027 _(l2fib_add_del_reply) \
5028 _(l2fib_flush_int_reply) \
5029 _(l2fib_flush_bd_reply) \
5030 _(ip_add_del_route_reply) \
5031 _(ip_table_add_del_reply) \
5032 _(ip_mroute_add_del_reply) \
5033 _(mpls_route_add_del_reply) \
5034 _(mpls_table_add_del_reply) \
5035 _(mpls_ip_bind_unbind_reply) \
5036 _(proxy_arp_add_del_reply) \
5037 _(proxy_arp_intfc_enable_disable_reply) \
5038 _(sw_interface_set_unnumbered_reply) \
5039 _(ip_neighbor_add_del_reply) \
5040 _(reset_vrf_reply) \
5041 _(oam_add_del_reply) \
5042 _(reset_fib_reply) \
5043 _(dhcp_proxy_config_reply) \
5044 _(dhcp_proxy_set_vss_reply) \
5045 _(dhcp_client_config_reply) \
5046 _(set_ip_flow_hash_reply) \
5047 _(sw_interface_ip6_enable_disable_reply) \
5048 _(sw_interface_ip6_set_link_local_address_reply) \
5049 _(ip6nd_proxy_add_del_reply) \
5050 _(sw_interface_ip6nd_ra_prefix_reply) \
5051 _(sw_interface_ip6nd_ra_config_reply) \
5052 _(set_arp_neighbor_limit_reply) \
5053 _(l2_patch_add_del_reply) \
5054 _(sr_policy_add_reply) \
5055 _(sr_policy_mod_reply) \
5056 _(sr_policy_del_reply) \
5057 _(sr_localsid_add_del_reply) \
5058 _(sr_steering_add_del_reply) \
5059 _(classify_add_del_session_reply) \
5060 _(classify_set_interface_ip_table_reply) \
5061 _(classify_set_interface_l2_tables_reply) \
5062 _(l2tpv3_set_tunnel_cookies_reply) \
5063 _(l2tpv3_interface_enable_disable_reply) \
5064 _(l2tpv3_set_lookup_key_reply) \
5065 _(l2_fib_clear_table_reply) \
5066 _(l2_interface_efp_filter_reply) \
5067 _(l2_interface_vlan_tag_rewrite_reply) \
5068 _(modify_vhost_user_if_reply) \
5069 _(delete_vhost_user_if_reply) \
5070 _(want_ip4_arp_events_reply) \
5071 _(want_ip6_nd_events_reply) \
5072 _(want_l2_macs_events_reply) \
5073 _(input_acl_set_interface_reply) \
5074 _(ipsec_spd_add_del_reply) \
5075 _(ipsec_interface_add_del_spd_reply) \
5076 _(ipsec_spd_add_del_entry_reply) \
5077 _(ipsec_sad_add_del_entry_reply) \
5078 _(ipsec_sa_set_key_reply) \
5079 _(ipsec_tunnel_if_add_del_reply) \
5080 _(ikev2_profile_add_del_reply) \
5081 _(ikev2_profile_set_auth_reply) \
5082 _(ikev2_profile_set_id_reply) \
5083 _(ikev2_profile_set_ts_reply) \
5084 _(ikev2_set_local_key_reply) \
5085 _(ikev2_set_responder_reply) \
5086 _(ikev2_set_ike_transforms_reply) \
5087 _(ikev2_set_esp_transforms_reply) \
5088 _(ikev2_set_sa_lifetime_reply) \
5089 _(ikev2_initiate_sa_init_reply) \
5090 _(ikev2_initiate_del_ike_sa_reply) \
5091 _(ikev2_initiate_del_child_sa_reply) \
5092 _(ikev2_initiate_rekey_child_sa_reply) \
5093 _(delete_loopback_reply) \
5094 _(bd_ip_mac_add_del_reply) \
5095 _(map_del_domain_reply) \
5096 _(map_add_del_rule_reply) \
5097 _(want_interface_events_reply) \
5098 _(want_stats_reply) \
5099 _(cop_interface_enable_disable_reply) \
5100 _(cop_whitelist_enable_disable_reply) \
5101 _(sw_interface_clear_stats_reply) \
5102 _(ioam_enable_reply) \
5103 _(ioam_disable_reply) \
5104 _(one_add_del_locator_reply) \
5105 _(one_add_del_local_eid_reply) \
5106 _(one_add_del_remote_mapping_reply) \
5107 _(one_add_del_adjacency_reply) \
5108 _(one_add_del_map_resolver_reply) \
5109 _(one_add_del_map_server_reply) \
5110 _(one_enable_disable_reply) \
5111 _(one_rloc_probe_enable_disable_reply) \
5112 _(one_map_register_enable_disable_reply) \
5113 _(one_map_register_set_ttl_reply) \
5114 _(one_set_transport_protocol_reply) \
5115 _(one_map_register_fallback_threshold_reply) \
5116 _(one_pitr_set_locator_set_reply) \
5117 _(one_map_request_mode_reply) \
5118 _(one_add_del_map_request_itr_rlocs_reply) \
5119 _(one_eid_table_add_del_map_reply) \
5120 _(one_use_petr_reply) \
5121 _(one_stats_enable_disable_reply) \
5122 _(one_add_del_l2_arp_entry_reply) \
5123 _(one_add_del_ndp_entry_reply) \
5124 _(one_stats_flush_reply) \
5125 _(gpe_enable_disable_reply) \
5126 _(gpe_set_encap_mode_reply) \
5127 _(gpe_add_del_iface_reply) \
5128 _(gpe_add_del_native_fwd_rpath_reply) \
5129 _(af_packet_delete_reply) \
5130 _(policer_classify_set_interface_reply) \
5131 _(netmap_create_reply) \
5132 _(netmap_delete_reply) \
5133 _(set_ipfix_exporter_reply) \
5134 _(set_ipfix_classify_stream_reply) \
5135 _(ipfix_classify_table_add_del_reply) \
5136 _(flow_classify_set_interface_reply) \
5137 _(sw_interface_span_enable_disable_reply) \
5138 _(pg_capture_reply) \
5139 _(pg_enable_disable_reply) \
5140 _(ip_source_and_port_range_check_add_del_reply) \
5141 _(ip_source_and_port_range_check_interface_add_del_reply)\
5142 _(delete_subif_reply) \
5143 _(l2_interface_pbb_tag_rewrite_reply) \
5145 _(feature_enable_disable_reply) \
5146 _(sw_interface_tag_add_del_reply) \
5147 _(sw_interface_set_mtu_reply) \
5148 _(p2p_ethernet_add_reply) \
5149 _(p2p_ethernet_del_reply) \
5150 _(lldp_config_reply) \
5151 _(sw_interface_set_lldp_reply) \
5152 _(tcp_configure_src_addresses_reply) \
5153 _(app_namespace_add_del_reply) \
5154 _(dns_enable_disable_reply) \
5155 _(dns_name_server_add_del_reply)
5158 static void vl_api_##n##_t_handler \
5159 (vl_api_##n##_t * mp) \
5161 vat_main_t * vam = &vat_main; \
5162 i32 retval = ntohl(mp->retval); \
5163 if (vam->async_mode) { \
5164 vam->async_errors += (retval < 0); \
5166 vam->retval = retval; \
5167 vam->result_ready = 1; \
5170 foreach_standard_reply_retval_handler;
5174 static void vl_api_##n##_t_handler_json \
5175 (vl_api_##n##_t * mp) \
5177 vat_main_t * vam = &vat_main; \
5178 vat_json_node_t node; \
5179 vat_json_init_object(&node); \
5180 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5181 vat_json_print(vam->ofp, &node); \
5182 vam->retval = ntohl(mp->retval); \
5183 vam->result_ready = 1; \
5185 foreach_standard_reply_retval_handler;
5189 * Table of message reply handlers, must include boilerplate handlers
5193 #define foreach_vpe_api_reply_msg \
5194 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5195 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5196 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5197 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5198 _(CONTROL_PING_REPLY, control_ping_reply) \
5199 _(CLI_REPLY, cli_reply) \
5200 _(CLI_INBAND_REPLY, cli_inband_reply) \
5201 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5202 sw_interface_add_del_address_reply) \
5203 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5204 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5205 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5206 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5207 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5208 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5209 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5210 sw_interface_set_l2_xconnect_reply) \
5211 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5212 sw_interface_set_l2_bridge_reply) \
5213 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5214 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5215 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5216 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5217 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5218 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5219 _(L2_FLAGS_REPLY, l2_flags_reply) \
5220 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5221 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5222 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5223 _(TAP_DELETE_REPLY, tap_delete_reply) \
5224 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5225 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5226 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5227 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5228 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5229 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5230 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5231 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5232 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5233 proxy_arp_intfc_enable_disable_reply) \
5234 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5235 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5236 sw_interface_set_unnumbered_reply) \
5237 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5238 _(RESET_VRF_REPLY, reset_vrf_reply) \
5239 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5240 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5241 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5242 _(RESET_FIB_REPLY, reset_fib_reply) \
5243 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5244 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5245 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5246 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5247 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5248 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5249 sw_interface_ip6_enable_disable_reply) \
5250 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5251 sw_interface_ip6_set_link_local_address_reply) \
5252 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5253 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5254 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5255 sw_interface_ip6nd_ra_prefix_reply) \
5256 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5257 sw_interface_ip6nd_ra_config_reply) \
5258 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5259 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5260 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5261 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5262 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5263 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5264 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5265 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5266 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5267 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5268 classify_set_interface_ip_table_reply) \
5269 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5270 classify_set_interface_l2_tables_reply) \
5271 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5272 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5273 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5274 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5275 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5276 l2tpv3_interface_enable_disable_reply) \
5277 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5278 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5279 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5280 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5281 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5282 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5283 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5284 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5285 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5286 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5287 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5288 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5289 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5290 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5291 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5292 _(SHOW_VERSION_REPLY, show_version_reply) \
5293 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5294 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5295 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5296 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5297 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5298 _(IP4_ARP_EVENT, ip4_arp_event) \
5299 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5300 _(IP6_ND_EVENT, ip6_nd_event) \
5301 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5302 _(L2_MACS_EVENT, l2_macs_event) \
5303 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5304 _(IP_ADDRESS_DETAILS, ip_address_details) \
5305 _(IP_DETAILS, ip_details) \
5306 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5307 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5308 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5309 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5310 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5311 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5312 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5313 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5314 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5315 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5316 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5317 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5318 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5319 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5320 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5321 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5322 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5323 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5324 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5325 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5326 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5327 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5328 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5329 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5330 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5331 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5332 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5333 _(MAP_RULE_DETAILS, map_rule_details) \
5334 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5335 _(WANT_STATS_REPLY, want_stats_reply) \
5336 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5337 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5338 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5339 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5340 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5341 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5342 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5343 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5344 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5345 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5346 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5347 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5348 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5349 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5350 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5351 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5352 one_map_register_enable_disable_reply) \
5353 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5354 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5355 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5356 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5357 one_map_register_fallback_threshold_reply) \
5358 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5359 one_rloc_probe_enable_disable_reply) \
5360 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5361 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5362 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5363 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5364 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5365 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5366 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5367 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5368 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5369 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5370 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5371 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5372 _(ONE_STATS_DETAILS, one_stats_details) \
5373 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5374 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5375 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5376 show_one_stats_enable_disable_reply) \
5377 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5378 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5379 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5380 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5381 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5382 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5383 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5384 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5385 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5386 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5387 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5388 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5389 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5390 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5391 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5392 gpe_add_del_native_fwd_rpath_reply) \
5393 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5394 gpe_fwd_entry_path_details) \
5395 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5396 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5397 one_add_del_map_request_itr_rlocs_reply) \
5398 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5399 one_get_map_request_itr_rlocs_reply) \
5400 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5401 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5402 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5403 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5404 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5405 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5406 show_one_map_register_state_reply) \
5407 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5408 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5409 show_one_map_register_fallback_threshold_reply) \
5410 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5411 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5412 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5413 _(POLICER_DETAILS, policer_details) \
5414 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5415 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5416 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5417 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5418 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5419 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5420 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5421 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5422 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5423 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5424 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5425 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5426 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5427 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5428 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5429 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5430 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5431 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5432 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5433 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5434 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5435 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5436 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5437 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5438 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5439 ip_source_and_port_range_check_add_del_reply) \
5440 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5441 ip_source_and_port_range_check_interface_add_del_reply) \
5442 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5443 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5444 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5445 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5446 _(PUNT_REPLY, punt_reply) \
5447 _(IP_FIB_DETAILS, ip_fib_details) \
5448 _(IP6_FIB_DETAILS, ip6_fib_details) \
5449 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5450 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5451 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5452 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5453 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5454 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5455 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5456 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5457 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5458 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5459 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5460 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5461 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5462 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5463 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply)
5465 #define foreach_standalone_reply_msg \
5466 _(SW_INTERFACE_EVENT, sw_interface_event) \
5467 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5468 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5469 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5470 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5471 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5472 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
5473 _(MEMFD_SEGMENT_CREATE_REPLY, memfd_segment_create_reply) \
5482 #define STR_VTR_OP_CASE(op) \
5483 case L2_VTR_ ## op: \
5487 str_vtr_op (u32 vtr_op)
5491 STR_VTR_OP_CASE (DISABLED);
5492 STR_VTR_OP_CASE (PUSH_1);
5493 STR_VTR_OP_CASE (PUSH_2);
5494 STR_VTR_OP_CASE (POP_1);
5495 STR_VTR_OP_CASE (POP_2);
5496 STR_VTR_OP_CASE (TRANSLATE_1_1);
5497 STR_VTR_OP_CASE (TRANSLATE_1_2);
5498 STR_VTR_OP_CASE (TRANSLATE_2_1);
5499 STR_VTR_OP_CASE (TRANSLATE_2_2);
5506 dump_sub_interface_table (vat_main_t * vam)
5508 const sw_interface_subif_t *sub = NULL;
5510 if (vam->json_output)
5513 ("JSON output supported only for VPE API calls and dump_stats_table");
5518 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5519 "Interface", "sw_if_index",
5520 "sub id", "dot1ad", "tags", "outer id",
5521 "inner id", "exact", "default", "outer any", "inner any");
5523 vec_foreach (sub, vam->sw_if_subif_table)
5526 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5527 sub->interface_name,
5529 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5530 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5531 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5532 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5533 if (sub->vtr_op != L2_VTR_DISABLED)
5536 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5537 "tag1: %d tag2: %d ]",
5538 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5539 sub->vtr_tag1, sub->vtr_tag2);
5547 name_sort_cmp (void *a1, void *a2)
5549 name_sort_t *n1 = a1;
5550 name_sort_t *n2 = a2;
5552 return strcmp ((char *) n1->name, (char *) n2->name);
5556 dump_interface_table (vat_main_t * vam)
5559 name_sort_t *nses = 0, *ns;
5561 if (vam->json_output)
5564 ("JSON output supported only for VPE API calls and dump_stats_table");
5569 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5571 vec_add2 (nses, ns, 1);
5572 ns->name = (u8 *)(p->key);
5573 ns->value = (u32) p->value[0];
5577 vec_sort_with_function (nses, name_sort_cmp);
5579 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5580 vec_foreach (ns, nses)
5582 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5589 dump_ip_table (vat_main_t * vam, int is_ipv6)
5591 const ip_details_t *det = NULL;
5592 const ip_address_details_t *address = NULL;
5595 print (vam->ofp, "%-12s", "sw_if_index");
5597 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5604 print (vam->ofp, "%-12d", i);
5605 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5610 vec_foreach (address, det->addr)
5614 is_ipv6 ? format_ip6_address : format_ip4_address,
5615 address->ip, address->prefix_length);
5623 dump_ipv4_table (vat_main_t * vam)
5625 if (vam->json_output)
5628 ("JSON output supported only for VPE API calls and dump_stats_table");
5632 return dump_ip_table (vam, 0);
5636 dump_ipv6_table (vat_main_t * vam)
5638 if (vam->json_output)
5641 ("JSON output supported only for VPE API calls and dump_stats_table");
5645 return dump_ip_table (vam, 1);
5649 counter_type_to_str (u8 counter_type, u8 is_combined)
5653 switch (counter_type)
5655 case VNET_INTERFACE_COUNTER_DROP:
5657 case VNET_INTERFACE_COUNTER_PUNT:
5659 case VNET_INTERFACE_COUNTER_IP4:
5661 case VNET_INTERFACE_COUNTER_IP6:
5663 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5665 case VNET_INTERFACE_COUNTER_RX_MISS:
5667 case VNET_INTERFACE_COUNTER_RX_ERROR:
5669 case VNET_INTERFACE_COUNTER_TX_ERROR:
5672 return "INVALID-COUNTER-TYPE";
5677 switch (counter_type)
5679 case VNET_INTERFACE_COUNTER_RX:
5681 case VNET_INTERFACE_COUNTER_TX:
5684 return "INVALID-COUNTER-TYPE";
5690 dump_stats_table (vat_main_t * vam)
5692 vat_json_node_t node;
5693 vat_json_node_t *msg_array;
5694 vat_json_node_t *msg;
5695 vat_json_node_t *counter_array;
5696 vat_json_node_t *counter;
5697 interface_counter_t c;
5699 ip4_fib_counter_t *c4;
5700 ip6_fib_counter_t *c6;
5701 ip4_nbr_counter_t *n4;
5702 ip6_nbr_counter_t *n6;
5705 if (!vam->json_output)
5707 clib_warning ("dump_stats_table supported only in JSON format");
5711 vat_json_init_object (&node);
5713 /* interface counters */
5714 msg_array = vat_json_object_add (&node, "interface_counters");
5715 vat_json_init_array (msg_array);
5716 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5718 msg = vat_json_array_add (msg_array);
5719 vat_json_init_object (msg);
5720 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5721 (u8 *) counter_type_to_str (i, 0));
5722 vat_json_object_add_int (msg, "is_combined", 0);
5723 counter_array = vat_json_object_add (msg, "data");
5724 vat_json_init_array (counter_array);
5725 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5727 packets = vam->simple_interface_counters[i][j];
5728 vat_json_array_add_uint (counter_array, packets);
5731 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5733 msg = vat_json_array_add (msg_array);
5734 vat_json_init_object (msg);
5735 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5736 (u8 *) counter_type_to_str (i, 1));
5737 vat_json_object_add_int (msg, "is_combined", 1);
5738 counter_array = vat_json_object_add (msg, "data");
5739 vat_json_init_array (counter_array);
5740 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5742 c = vam->combined_interface_counters[i][j];
5743 counter = vat_json_array_add (counter_array);
5744 vat_json_init_object (counter);
5745 vat_json_object_add_uint (counter, "packets", c.packets);
5746 vat_json_object_add_uint (counter, "bytes", c.bytes);
5750 /* ip4 fib counters */
5751 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5752 vat_json_init_array (msg_array);
5753 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5755 msg = vat_json_array_add (msg_array);
5756 vat_json_init_object (msg);
5757 vat_json_object_add_uint (msg, "vrf_id",
5758 vam->ip4_fib_counters_vrf_id_by_index[i]);
5759 counter_array = vat_json_object_add (msg, "c");
5760 vat_json_init_array (counter_array);
5761 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5763 counter = vat_json_array_add (counter_array);
5764 vat_json_init_object (counter);
5765 c4 = &vam->ip4_fib_counters[i][j];
5766 vat_json_object_add_ip4 (counter, "address", c4->address);
5767 vat_json_object_add_uint (counter, "address_length",
5768 c4->address_length);
5769 vat_json_object_add_uint (counter, "packets", c4->packets);
5770 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5774 /* ip6 fib counters */
5775 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5776 vat_json_init_array (msg_array);
5777 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5779 msg = vat_json_array_add (msg_array);
5780 vat_json_init_object (msg);
5781 vat_json_object_add_uint (msg, "vrf_id",
5782 vam->ip6_fib_counters_vrf_id_by_index[i]);
5783 counter_array = vat_json_object_add (msg, "c");
5784 vat_json_init_array (counter_array);
5785 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5787 counter = vat_json_array_add (counter_array);
5788 vat_json_init_object (counter);
5789 c6 = &vam->ip6_fib_counters[i][j];
5790 vat_json_object_add_ip6 (counter, "address", c6->address);
5791 vat_json_object_add_uint (counter, "address_length",
5792 c6->address_length);
5793 vat_json_object_add_uint (counter, "packets", c6->packets);
5794 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5798 /* ip4 nbr counters */
5799 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5800 vat_json_init_array (msg_array);
5801 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5803 msg = vat_json_array_add (msg_array);
5804 vat_json_init_object (msg);
5805 vat_json_object_add_uint (msg, "sw_if_index", i);
5806 counter_array = vat_json_object_add (msg, "c");
5807 vat_json_init_array (counter_array);
5808 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5810 counter = vat_json_array_add (counter_array);
5811 vat_json_init_object (counter);
5812 n4 = &vam->ip4_nbr_counters[i][j];
5813 vat_json_object_add_ip4 (counter, "address", n4->address);
5814 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5815 vat_json_object_add_uint (counter, "packets", n4->packets);
5816 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5820 /* ip6 nbr counters */
5821 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5822 vat_json_init_array (msg_array);
5823 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5825 msg = vat_json_array_add (msg_array);
5826 vat_json_init_object (msg);
5827 vat_json_object_add_uint (msg, "sw_if_index", i);
5828 counter_array = vat_json_object_add (msg, "c");
5829 vat_json_init_array (counter_array);
5830 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5832 counter = vat_json_array_add (counter_array);
5833 vat_json_init_object (counter);
5834 n6 = &vam->ip6_nbr_counters[i][j];
5835 vat_json_object_add_ip6 (counter, "address", n6->address);
5836 vat_json_object_add_uint (counter, "packets", n6->packets);
5837 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5841 vat_json_print (vam->ofp, &node);
5842 vat_json_free (&node);
5848 * Pass CLI buffers directly in the CLI_INBAND API message,
5849 * instead of an additional shared memory area.
5852 exec_inband (vat_main_t * vam)
5854 vl_api_cli_inband_t *mp;
5855 unformat_input_t *i = vam->input;
5858 if (vec_len (i->buffer) == 0)
5861 if (vam->exec_mode == 0 && unformat (i, "mode"))
5866 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5873 * In order for the CLI command to work, it
5874 * must be a vector ending in \n, not a C-string ending
5877 u32 len = vec_len (vam->input->buffer);
5878 M2 (CLI_INBAND, mp, len);
5879 clib_memcpy (mp->cmd, vam->input->buffer, len);
5880 mp->length = htonl (len);
5884 /* json responses may or may not include a useful reply... */
5885 if (vec_len (vam->cmd_reply))
5886 print (vam->ofp, (char *) (vam->cmd_reply));
5891 exec (vat_main_t * vam)
5893 return exec_inband (vam);
5897 api_create_loopback (vat_main_t * vam)
5899 unformat_input_t *i = vam->input;
5900 vl_api_create_loopback_t *mp;
5901 vl_api_create_loopback_instance_t *mp_lbi;
5904 u8 is_specified = 0;
5905 u32 user_instance = 0;
5908 memset (mac_address, 0, sizeof (mac_address));
5910 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5912 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5914 if (unformat (i, "instance %d", &user_instance))
5922 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5923 mp_lbi->is_specified = is_specified;
5925 mp_lbi->user_instance = htonl (user_instance);
5927 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5932 /* Construct the API message */
5933 M (CREATE_LOOPBACK, mp);
5935 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5944 api_delete_loopback (vat_main_t * vam)
5946 unformat_input_t *i = vam->input;
5947 vl_api_delete_loopback_t *mp;
5948 u32 sw_if_index = ~0;
5951 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5953 if (unformat (i, "sw_if_index %d", &sw_if_index))
5959 if (sw_if_index == ~0)
5961 errmsg ("missing sw_if_index");
5965 /* Construct the API message */
5966 M (DELETE_LOOPBACK, mp);
5967 mp->sw_if_index = ntohl (sw_if_index);
5975 api_want_stats (vat_main_t * vam)
5977 unformat_input_t *i = vam->input;
5978 vl_api_want_stats_t *mp;
5982 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5984 if (unformat (i, "enable"))
5986 else if (unformat (i, "disable"))
5994 errmsg ("missing enable|disable");
5999 mp->enable_disable = enable;
6007 api_want_interface_events (vat_main_t * vam)
6009 unformat_input_t *i = vam->input;
6010 vl_api_want_interface_events_t *mp;
6014 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6016 if (unformat (i, "enable"))
6018 else if (unformat (i, "disable"))
6026 errmsg ("missing enable|disable");
6030 M (WANT_INTERFACE_EVENTS, mp);
6031 mp->enable_disable = enable;
6033 vam->interface_event_display = enable;
6041 /* Note: non-static, called once to set up the initial intfc table */
6043 api_sw_interface_dump (vat_main_t * vam)
6045 vl_api_sw_interface_dump_t *mp;
6046 vl_api_control_ping_t *mp_ping;
6048 name_sort_t *nses = 0, *ns;
6049 sw_interface_subif_t *sub = NULL;
6052 /* Toss the old name table */
6054 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6056 vec_add2 (nses, ns, 1);
6057 ns->name = (u8 *)(p->key);
6058 ns->value = (u32) p->value[0];
6062 hash_free (vam->sw_if_index_by_interface_name);
6064 vec_foreach (ns, nses) vec_free (ns->name);
6068 vec_foreach (sub, vam->sw_if_subif_table)
6070 vec_free (sub->interface_name);
6072 vec_free (vam->sw_if_subif_table);
6074 /* recreate the interface name hash table */
6075 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6077 /* Get list of ethernets */
6078 M (SW_INTERFACE_DUMP, mp);
6079 mp->name_filter_valid = 1;
6080 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
6083 /* and local / loopback interfaces */
6084 M (SW_INTERFACE_DUMP, mp);
6085 mp->name_filter_valid = 1;
6086 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
6089 /* and packet-generator interfaces */
6090 M (SW_INTERFACE_DUMP, mp);
6091 mp->name_filter_valid = 1;
6092 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
6095 /* and vxlan-gpe tunnel interfaces */
6096 M (SW_INTERFACE_DUMP, mp);
6097 mp->name_filter_valid = 1;
6098 strncpy ((char *) mp->name_filter, "vxlan_gpe",
6099 sizeof (mp->name_filter) - 1);
6102 /* and vxlan tunnel interfaces */
6103 M (SW_INTERFACE_DUMP, mp);
6104 mp->name_filter_valid = 1;
6105 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
6108 /* and geneve tunnel interfaces */
6109 M (SW_INTERFACE_DUMP, mp);
6110 mp->name_filter_valid = 1;
6111 strncpy ((char *) mp->name_filter, "geneve", sizeof (mp->name_filter) - 1);
6114 /* and host (af_packet) interfaces */
6115 M (SW_INTERFACE_DUMP, mp);
6116 mp->name_filter_valid = 1;
6117 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
6120 /* and l2tpv3 tunnel interfaces */
6121 M (SW_INTERFACE_DUMP, mp);
6122 mp->name_filter_valid = 1;
6123 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
6124 sizeof (mp->name_filter) - 1);
6127 /* and GRE tunnel interfaces */
6128 M (SW_INTERFACE_DUMP, mp);
6129 mp->name_filter_valid = 1;
6130 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
6133 /* and LISP-GPE interfaces */
6134 M (SW_INTERFACE_DUMP, mp);
6135 mp->name_filter_valid = 1;
6136 strncpy ((char *) mp->name_filter, "lisp_gpe",
6137 sizeof (mp->name_filter) - 1);
6140 /* and IPSEC tunnel interfaces */
6141 M (SW_INTERFACE_DUMP, mp);
6142 mp->name_filter_valid = 1;
6143 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
6146 /* Use a control ping for synchronization */
6147 MPING (CONTROL_PING, mp_ping);
6155 api_sw_interface_set_flags (vat_main_t * vam)
6157 unformat_input_t *i = vam->input;
6158 vl_api_sw_interface_set_flags_t *mp;
6160 u8 sw_if_index_set = 0;
6164 /* Parse args required to build the message */
6165 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6167 if (unformat (i, "admin-up"))
6169 else if (unformat (i, "admin-down"))
6172 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6173 sw_if_index_set = 1;
6174 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6175 sw_if_index_set = 1;
6180 if (sw_if_index_set == 0)
6182 errmsg ("missing interface name or sw_if_index");
6186 /* Construct the API message */
6187 M (SW_INTERFACE_SET_FLAGS, mp);
6188 mp->sw_if_index = ntohl (sw_if_index);
6189 mp->admin_up_down = admin_up;
6194 /* Wait for a reply, return the good/bad news... */
6200 api_sw_interface_clear_stats (vat_main_t * vam)
6202 unformat_input_t *i = vam->input;
6203 vl_api_sw_interface_clear_stats_t *mp;
6205 u8 sw_if_index_set = 0;
6208 /* Parse args required to build the message */
6209 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6211 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6212 sw_if_index_set = 1;
6213 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6214 sw_if_index_set = 1;
6219 /* Construct the API message */
6220 M (SW_INTERFACE_CLEAR_STATS, mp);
6222 if (sw_if_index_set == 1)
6223 mp->sw_if_index = ntohl (sw_if_index);
6225 mp->sw_if_index = ~0;
6230 /* Wait for a reply, return the good/bad news... */
6236 api_sw_interface_add_del_address (vat_main_t * vam)
6238 unformat_input_t *i = vam->input;
6239 vl_api_sw_interface_add_del_address_t *mp;
6241 u8 sw_if_index_set = 0;
6242 u8 is_add = 1, del_all = 0;
6243 u32 address_length = 0;
6244 u8 v4_address_set = 0;
6245 u8 v6_address_set = 0;
6246 ip4_address_t v4address;
6247 ip6_address_t v6address;
6250 /* Parse args required to build the message */
6251 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6253 if (unformat (i, "del-all"))
6255 else if (unformat (i, "del"))
6258 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6259 sw_if_index_set = 1;
6260 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6261 sw_if_index_set = 1;
6262 else if (unformat (i, "%U/%d",
6263 unformat_ip4_address, &v4address, &address_length))
6265 else if (unformat (i, "%U/%d",
6266 unformat_ip6_address, &v6address, &address_length))
6272 if (sw_if_index_set == 0)
6274 errmsg ("missing interface name or sw_if_index");
6277 if (v4_address_set && v6_address_set)
6279 errmsg ("both v4 and v6 addresses set");
6282 if (!v4_address_set && !v6_address_set && !del_all)
6284 errmsg ("no addresses set");
6288 /* Construct the API message */
6289 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6291 mp->sw_if_index = ntohl (sw_if_index);
6292 mp->is_add = is_add;
6293 mp->del_all = del_all;
6297 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6301 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6303 mp->address_length = address_length;
6308 /* Wait for a reply, return good/bad news */
6314 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6316 unformat_input_t *i = vam->input;
6317 vl_api_sw_interface_set_mpls_enable_t *mp;
6319 u8 sw_if_index_set = 0;
6323 /* Parse args required to build the message */
6324 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6326 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6327 sw_if_index_set = 1;
6328 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6329 sw_if_index_set = 1;
6330 else if (unformat (i, "disable"))
6332 else if (unformat (i, "dis"))
6338 if (sw_if_index_set == 0)
6340 errmsg ("missing interface name or sw_if_index");
6344 /* Construct the API message */
6345 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6347 mp->sw_if_index = ntohl (sw_if_index);
6348 mp->enable = enable;
6353 /* Wait for a reply... */
6359 api_sw_interface_set_table (vat_main_t * vam)
6361 unformat_input_t *i = vam->input;
6362 vl_api_sw_interface_set_table_t *mp;
6363 u32 sw_if_index, vrf_id = 0;
6364 u8 sw_if_index_set = 0;
6368 /* Parse args required to build the message */
6369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6371 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6372 sw_if_index_set = 1;
6373 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6374 sw_if_index_set = 1;
6375 else if (unformat (i, "vrf %d", &vrf_id))
6377 else if (unformat (i, "ipv6"))
6383 if (sw_if_index_set == 0)
6385 errmsg ("missing interface name or sw_if_index");
6389 /* Construct the API message */
6390 M (SW_INTERFACE_SET_TABLE, mp);
6392 mp->sw_if_index = ntohl (sw_if_index);
6393 mp->is_ipv6 = is_ipv6;
6394 mp->vrf_id = ntohl (vrf_id);
6399 /* Wait for a reply... */
6404 static void vl_api_sw_interface_get_table_reply_t_handler
6405 (vl_api_sw_interface_get_table_reply_t * mp)
6407 vat_main_t *vam = &vat_main;
6409 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6411 vam->retval = ntohl (mp->retval);
6412 vam->result_ready = 1;
6416 static void vl_api_sw_interface_get_table_reply_t_handler_json
6417 (vl_api_sw_interface_get_table_reply_t * mp)
6419 vat_main_t *vam = &vat_main;
6420 vat_json_node_t node;
6422 vat_json_init_object (&node);
6423 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6424 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6426 vat_json_print (vam->ofp, &node);
6427 vat_json_free (&node);
6429 vam->retval = ntohl (mp->retval);
6430 vam->result_ready = 1;
6434 api_sw_interface_get_table (vat_main_t * vam)
6436 unformat_input_t *i = vam->input;
6437 vl_api_sw_interface_get_table_t *mp;
6439 u8 sw_if_index_set = 0;
6443 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6445 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6446 sw_if_index_set = 1;
6447 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6448 sw_if_index_set = 1;
6449 else if (unformat (i, "ipv6"))
6455 if (sw_if_index_set == 0)
6457 errmsg ("missing interface name or sw_if_index");
6461 M (SW_INTERFACE_GET_TABLE, mp);
6462 mp->sw_if_index = htonl (sw_if_index);
6463 mp->is_ipv6 = is_ipv6;
6471 api_sw_interface_set_vpath (vat_main_t * vam)
6473 unformat_input_t *i = vam->input;
6474 vl_api_sw_interface_set_vpath_t *mp;
6475 u32 sw_if_index = 0;
6476 u8 sw_if_index_set = 0;
6480 /* Parse args required to build the message */
6481 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6483 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6484 sw_if_index_set = 1;
6485 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6486 sw_if_index_set = 1;
6487 else if (unformat (i, "enable"))
6489 else if (unformat (i, "disable"))
6495 if (sw_if_index_set == 0)
6497 errmsg ("missing interface name or sw_if_index");
6501 /* Construct the API message */
6502 M (SW_INTERFACE_SET_VPATH, mp);
6504 mp->sw_if_index = ntohl (sw_if_index);
6505 mp->enable = is_enable;
6510 /* Wait for a reply... */
6516 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6518 unformat_input_t *i = vam->input;
6519 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6520 u32 sw_if_index = 0;
6521 u8 sw_if_index_set = 0;
6526 /* Parse args required to build the message */
6527 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6529 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6530 sw_if_index_set = 1;
6531 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6532 sw_if_index_set = 1;
6533 else if (unformat (i, "enable"))
6535 else if (unformat (i, "disable"))
6537 else if (unformat (i, "ip4"))
6539 else if (unformat (i, "ip6"))
6545 if (sw_if_index_set == 0)
6547 errmsg ("missing interface name or sw_if_index");
6551 /* Construct the API message */
6552 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6554 mp->sw_if_index = ntohl (sw_if_index);
6555 mp->enable = is_enable;
6556 mp->is_ipv6 = is_ipv6;
6561 /* Wait for a reply... */
6567 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6569 unformat_input_t *i = vam->input;
6570 vl_api_sw_interface_set_geneve_bypass_t *mp;
6571 u32 sw_if_index = 0;
6572 u8 sw_if_index_set = 0;
6577 /* Parse args required to build the message */
6578 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6580 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6581 sw_if_index_set = 1;
6582 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6583 sw_if_index_set = 1;
6584 else if (unformat (i, "enable"))
6586 else if (unformat (i, "disable"))
6588 else if (unformat (i, "ip4"))
6590 else if (unformat (i, "ip6"))
6596 if (sw_if_index_set == 0)
6598 errmsg ("missing interface name or sw_if_index");
6602 /* Construct the API message */
6603 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6605 mp->sw_if_index = ntohl (sw_if_index);
6606 mp->enable = is_enable;
6607 mp->is_ipv6 = is_ipv6;
6612 /* Wait for a reply... */
6618 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6620 unformat_input_t *i = vam->input;
6621 vl_api_sw_interface_set_l2_xconnect_t *mp;
6623 u8 rx_sw_if_index_set = 0;
6625 u8 tx_sw_if_index_set = 0;
6629 /* Parse args required to build the message */
6630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6632 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6633 rx_sw_if_index_set = 1;
6634 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6635 tx_sw_if_index_set = 1;
6636 else if (unformat (i, "rx"))
6638 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6640 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6642 rx_sw_if_index_set = 1;
6647 else if (unformat (i, "tx"))
6649 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6651 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6653 tx_sw_if_index_set = 1;
6658 else if (unformat (i, "enable"))
6660 else if (unformat (i, "disable"))
6666 if (rx_sw_if_index_set == 0)
6668 errmsg ("missing rx interface name or rx_sw_if_index");
6672 if (enable && (tx_sw_if_index_set == 0))
6674 errmsg ("missing tx interface name or tx_sw_if_index");
6678 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6680 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6681 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6682 mp->enable = enable;
6690 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6692 unformat_input_t *i = vam->input;
6693 vl_api_sw_interface_set_l2_bridge_t *mp;
6695 u8 rx_sw_if_index_set = 0;
6703 /* Parse args required to build the message */
6704 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6706 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6707 rx_sw_if_index_set = 1;
6708 else if (unformat (i, "bd_id %d", &bd_id))
6712 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6713 rx_sw_if_index_set = 1;
6714 else if (unformat (i, "shg %d", &shg))
6716 else if (unformat (i, "bvi"))
6718 else if (unformat (i, "enable"))
6720 else if (unformat (i, "disable"))
6726 if (rx_sw_if_index_set == 0)
6728 errmsg ("missing rx interface name or sw_if_index");
6732 if (enable && (bd_id_set == 0))
6734 errmsg ("missing bridge domain");
6738 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6740 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6741 mp->bd_id = ntohl (bd_id);
6744 mp->enable = enable;
6752 api_bridge_domain_dump (vat_main_t * vam)
6754 unformat_input_t *i = vam->input;
6755 vl_api_bridge_domain_dump_t *mp;
6756 vl_api_control_ping_t *mp_ping;
6760 /* Parse args required to build the message */
6761 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6763 if (unformat (i, "bd_id %d", &bd_id))
6769 M (BRIDGE_DOMAIN_DUMP, mp);
6770 mp->bd_id = ntohl (bd_id);
6773 /* Use a control ping for synchronization */
6774 MPING (CONTROL_PING, mp_ping);
6782 api_bridge_domain_add_del (vat_main_t * vam)
6784 unformat_input_t *i = vam->input;
6785 vl_api_bridge_domain_add_del_t *mp;
6788 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6793 /* Parse args required to build the message */
6794 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6796 if (unformat (i, "bd_id %d", &bd_id))
6798 else if (unformat (i, "flood %d", &flood))
6800 else if (unformat (i, "uu-flood %d", &uu_flood))
6802 else if (unformat (i, "forward %d", &forward))
6804 else if (unformat (i, "learn %d", &learn))
6806 else if (unformat (i, "arp-term %d", &arp_term))
6808 else if (unformat (i, "mac-age %d", &mac_age))
6810 else if (unformat (i, "bd-tag %s", &bd_tag))
6812 else if (unformat (i, "del"))
6815 flood = uu_flood = forward = learn = 0;
6823 errmsg ("missing bridge domain");
6830 errmsg ("mac age must be less than 256 ");
6835 if ((bd_tag) && (strlen ((char *) bd_tag) > 63))
6837 errmsg ("bd-tag cannot be longer than 63");
6842 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6844 mp->bd_id = ntohl (bd_id);
6846 mp->uu_flood = uu_flood;
6847 mp->forward = forward;
6849 mp->arp_term = arp_term;
6850 mp->is_add = is_add;
6851 mp->mac_age = (u8) mac_age;
6853 strcpy ((char *) mp->bd_tag, (char *) bd_tag);
6864 api_l2fib_flush_bd (vat_main_t * vam)
6866 unformat_input_t *i = vam->input;
6867 vl_api_l2fib_flush_bd_t *mp;
6871 /* Parse args required to build the message */
6872 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6874 if (unformat (i, "bd_id %d", &bd_id));
6881 errmsg ("missing bridge domain");
6885 M (L2FIB_FLUSH_BD, mp);
6887 mp->bd_id = htonl (bd_id);
6895 api_l2fib_flush_int (vat_main_t * vam)
6897 unformat_input_t *i = vam->input;
6898 vl_api_l2fib_flush_int_t *mp;
6899 u32 sw_if_index = ~0;
6902 /* Parse args required to build the message */
6903 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6905 if (unformat (i, "sw_if_index %d", &sw_if_index));
6907 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6912 if (sw_if_index == ~0)
6914 errmsg ("missing interface name or sw_if_index");
6918 M (L2FIB_FLUSH_INT, mp);
6920 mp->sw_if_index = ntohl (sw_if_index);
6928 api_l2fib_add_del (vat_main_t * vam)
6930 unformat_input_t *i = vam->input;
6931 vl_api_l2fib_add_del_t *mp;
6937 u32 sw_if_index = ~0;
6938 u8 sw_if_index_set = 0;
6947 /* Parse args required to build the message */
6948 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6950 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6952 else if (unformat (i, "bd_id %d", &bd_id))
6954 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6955 sw_if_index_set = 1;
6956 else if (unformat (i, "sw_if"))
6958 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6961 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6962 sw_if_index_set = 1;
6967 else if (unformat (i, "static"))
6969 else if (unformat (i, "filter"))
6974 else if (unformat (i, "bvi"))
6979 else if (unformat (i, "del"))
6981 else if (unformat (i, "count %d", &count))
6989 errmsg ("missing mac address");
6995 errmsg ("missing bridge domain");
6999 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7001 errmsg ("missing interface name or sw_if_index");
7007 /* Turn on async mode */
7008 vam->async_mode = 1;
7009 vam->async_errors = 0;
7010 before = vat_time_now (vam);
7013 for (j = 0; j < count; j++)
7015 M (L2FIB_ADD_DEL, mp);
7018 mp->bd_id = ntohl (bd_id);
7019 mp->is_add = is_add;
7023 mp->sw_if_index = ntohl (sw_if_index);
7024 mp->static_mac = static_mac;
7025 mp->filter_mac = filter_mac;
7026 mp->bvi_mac = bvi_mac;
7028 increment_mac_address (&mac);
7035 vl_api_control_ping_t *mp_ping;
7038 /* Shut off async mode */
7039 vam->async_mode = 0;
7041 MPING (CONTROL_PING, mp_ping);
7044 timeout = vat_time_now (vam) + 1.0;
7045 while (vat_time_now (vam) < timeout)
7046 if (vam->result_ready == 1)
7051 if (vam->retval == -99)
7054 if (vam->async_errors > 0)
7056 errmsg ("%d asynchronous errors", vam->async_errors);
7059 vam->async_errors = 0;
7060 after = vat_time_now (vam);
7062 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7063 count, after - before, count / (after - before));
7069 /* Wait for a reply... */
7073 /* Return the good/bad news */
7074 return (vam->retval);
7078 api_bridge_domain_set_mac_age (vat_main_t * vam)
7080 unformat_input_t *i = vam->input;
7081 vl_api_bridge_domain_set_mac_age_t *mp;
7086 /* Parse args required to build the message */
7087 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7089 if (unformat (i, "bd_id %d", &bd_id));
7090 else if (unformat (i, "mac-age %d", &mac_age));
7097 errmsg ("missing bridge domain");
7103 errmsg ("mac age must be less than 256 ");
7107 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7109 mp->bd_id = htonl (bd_id);
7110 mp->mac_age = (u8) mac_age;
7118 api_l2_flags (vat_main_t * vam)
7120 unformat_input_t *i = vam->input;
7121 vl_api_l2_flags_t *mp;
7124 u8 sw_if_index_set = 0;
7128 /* Parse args required to build the message */
7129 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7131 if (unformat (i, "sw_if_index %d", &sw_if_index))
7132 sw_if_index_set = 1;
7133 else if (unformat (i, "sw_if"))
7135 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7138 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7139 sw_if_index_set = 1;
7144 else if (unformat (i, "learn"))
7146 else if (unformat (i, "forward"))
7148 else if (unformat (i, "flood"))
7150 else if (unformat (i, "uu-flood"))
7151 flags |= L2_UU_FLOOD;
7152 else if (unformat (i, "arp-term"))
7153 flags |= L2_ARP_TERM;
7154 else if (unformat (i, "off"))
7156 else if (unformat (i, "disable"))
7162 if (sw_if_index_set == 0)
7164 errmsg ("missing interface name or sw_if_index");
7170 mp->sw_if_index = ntohl (sw_if_index);
7171 mp->feature_bitmap = ntohl (flags);
7172 mp->is_set = is_set;
7180 api_bridge_flags (vat_main_t * vam)
7182 unformat_input_t *i = vam->input;
7183 vl_api_bridge_flags_t *mp;
7190 /* Parse args required to build the message */
7191 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7193 if (unformat (i, "bd_id %d", &bd_id))
7195 else if (unformat (i, "learn"))
7197 else if (unformat (i, "forward"))
7199 else if (unformat (i, "flood"))
7201 else if (unformat (i, "uu-flood"))
7202 flags |= L2_UU_FLOOD;
7203 else if (unformat (i, "arp-term"))
7204 flags |= L2_ARP_TERM;
7205 else if (unformat (i, "off"))
7207 else if (unformat (i, "disable"))
7215 errmsg ("missing bridge domain");
7219 M (BRIDGE_FLAGS, mp);
7221 mp->bd_id = ntohl (bd_id);
7222 mp->feature_bitmap = ntohl (flags);
7223 mp->is_set = is_set;
7231 api_bd_ip_mac_add_del (vat_main_t * vam)
7233 unformat_input_t *i = vam->input;
7234 vl_api_bd_ip_mac_add_del_t *mp;
7241 ip4_address_t v4addr;
7242 ip6_address_t v6addr;
7247 /* Parse args required to build the message */
7248 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7250 if (unformat (i, "bd_id %d", &bd_id))
7254 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7258 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7263 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7267 else if (unformat (i, "del"))
7275 errmsg ("missing bridge domain");
7278 else if (ip_set == 0)
7280 errmsg ("missing IP address");
7283 else if (mac_set == 0)
7285 errmsg ("missing MAC address");
7289 M (BD_IP_MAC_ADD_DEL, mp);
7291 mp->bd_id = ntohl (bd_id);
7292 mp->is_ipv6 = is_ipv6;
7293 mp->is_add = is_add;
7295 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7297 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7298 clib_memcpy (mp->mac_address, macaddr, 6);
7305 api_tap_connect (vat_main_t * vam)
7307 unformat_input_t *i = vam->input;
7308 vl_api_tap_connect_t *mp;
7314 ip4_address_t ip4_address;
7316 int ip4_address_set = 0;
7317 ip6_address_t ip6_address;
7319 int ip6_address_set = 0;
7322 memset (mac_address, 0, sizeof (mac_address));
7324 /* Parse args required to build the message */
7325 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7327 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7331 else if (unformat (i, "random-mac"))
7333 else if (unformat (i, "tapname %s", &tap_name))
7335 else if (unformat (i, "tag %s", &tag))
7337 else if (unformat (i, "address %U/%d",
7338 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7339 ip4_address_set = 1;
7340 else if (unformat (i, "address %U/%d",
7341 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7342 ip6_address_set = 1;
7349 errmsg ("missing tap name");
7352 if (vec_len (tap_name) > 63)
7354 errmsg ("tap name too long");
7357 vec_add1 (tap_name, 0);
7359 if (vec_len (tag) > 63)
7361 errmsg ("tag too long");
7365 /* Construct the API message */
7366 M (TAP_CONNECT, mp);
7368 mp->use_random_mac = random_mac;
7369 clib_memcpy (mp->mac_address, mac_address, 6);
7370 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7372 clib_memcpy (mp->tag, tag, vec_len (tag));
7374 if (ip4_address_set)
7376 mp->ip4_address_set = 1;
7377 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7378 mp->ip4_mask_width = ip4_mask_width;
7380 if (ip6_address_set)
7382 mp->ip6_address_set = 1;
7383 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7384 mp->ip6_mask_width = ip6_mask_width;
7387 vec_free (tap_name);
7393 /* Wait for a reply... */
7399 api_tap_modify (vat_main_t * vam)
7401 unformat_input_t *i = vam->input;
7402 vl_api_tap_modify_t *mp;
7407 u32 sw_if_index = ~0;
7408 u8 sw_if_index_set = 0;
7411 memset (mac_address, 0, sizeof (mac_address));
7413 /* Parse args required to build the message */
7414 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7416 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7417 sw_if_index_set = 1;
7418 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7419 sw_if_index_set = 1;
7420 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7424 else if (unformat (i, "random-mac"))
7426 else if (unformat (i, "tapname %s", &tap_name))
7432 if (sw_if_index_set == 0)
7434 errmsg ("missing vpp interface name");
7439 errmsg ("missing tap name");
7442 if (vec_len (tap_name) > 63)
7444 errmsg ("tap name too long");
7446 vec_add1 (tap_name, 0);
7448 /* Construct the API message */
7451 mp->use_random_mac = random_mac;
7452 mp->sw_if_index = ntohl (sw_if_index);
7453 clib_memcpy (mp->mac_address, mac_address, 6);
7454 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7455 vec_free (tap_name);
7460 /* Wait for a reply... */
7466 api_tap_delete (vat_main_t * vam)
7468 unformat_input_t *i = vam->input;
7469 vl_api_tap_delete_t *mp;
7470 u32 sw_if_index = ~0;
7471 u8 sw_if_index_set = 0;
7474 /* Parse args required to build the message */
7475 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7477 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7478 sw_if_index_set = 1;
7479 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7480 sw_if_index_set = 1;
7485 if (sw_if_index_set == 0)
7487 errmsg ("missing vpp interface name");
7491 /* Construct the API message */
7494 mp->sw_if_index = ntohl (sw_if_index);
7499 /* Wait for a reply... */
7505 api_ip_table_add_del (vat_main_t * vam)
7507 unformat_input_t *i = vam->input;
7508 vl_api_ip_table_add_del_t *mp;
7514 /* Parse args required to build the message */
7515 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7517 if (unformat (i, "ipv6"))
7519 else if (unformat (i, "del"))
7521 else if (unformat (i, "add"))
7523 else if (unformat (i, "table %d", &table_id))
7527 clib_warning ("parse error '%U'", format_unformat_error, i);
7534 errmsg ("missing table-ID");
7538 /* Construct the API message */
7539 M (IP_TABLE_ADD_DEL, mp);
7541 mp->table_id = ntohl (table_id);
7542 mp->is_ipv6 = is_ipv6;
7543 mp->is_add = is_add;
7548 /* Wait for a reply... */
7555 api_ip_add_del_route (vat_main_t * vam)
7557 unformat_input_t *i = vam->input;
7558 vl_api_ip_add_del_route_t *mp;
7559 u32 sw_if_index = ~0, vrf_id = 0;
7561 u8 is_local = 0, is_drop = 0;
7562 u8 is_unreach = 0, is_prohibit = 0;
7563 u8 create_vrf_if_needed = 0;
7565 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, "not-last"))
7652 else if (unformat (i, "resolve-via-host"))
7654 else if (unformat (i, "resolve-via-attached"))
7655 resolve_attached = 1;
7656 else if (unformat (i, "multipath"))
7658 else if (unformat (i, "vrf %d", &vrf_id))
7660 else if (unformat (i, "create-vrf"))
7661 create_vrf_if_needed = 1;
7662 else if (unformat (i, "count %d", &count))
7664 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7666 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7668 else if (unformat (i, "out-label %d", &next_hop_out_label))
7669 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7670 else if (unformat (i, "via-label %d", &next_hop_via_label))
7672 else if (unformat (i, "random"))
7674 else if (unformat (i, "seed %d", &random_seed))
7678 clib_warning ("parse error '%U'", format_unformat_error, i);
7683 if (!next_hop_set && !is_drop && !is_local &&
7684 !is_classify && !is_unreach && !is_prohibit &&
7685 MPLS_LABEL_INVALID == next_hop_via_label)
7688 ("next hop / local / drop / unreach / prohibit / classify not set");
7692 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7694 errmsg ("next hop and next-hop via label set");
7697 if (address_set == 0)
7699 errmsg ("missing addresses");
7703 if (address_length_set == 0)
7705 errmsg ("missing address length");
7709 /* Generate a pile of unique, random routes */
7712 u32 this_random_address;
7713 random_hash = hash_create (count, sizeof (uword));
7715 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7716 for (j = 0; j <= count; j++)
7720 this_random_address = random_u32 (&random_seed);
7721 this_random_address =
7722 clib_host_to_net_u32 (this_random_address);
7724 while (hash_get (random_hash, this_random_address));
7725 vec_add1 (random_vector, this_random_address);
7726 hash_set (random_hash, this_random_address, 1);
7728 hash_free (random_hash);
7729 v4_dst_address.as_u32 = random_vector[0];
7734 /* Turn on async mode */
7735 vam->async_mode = 1;
7736 vam->async_errors = 0;
7737 before = vat_time_now (vam);
7740 for (j = 0; j < count; j++)
7742 /* Construct the API message */
7743 M2 (IP_ADD_DEL_ROUTE, mp,
7744 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7746 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7747 mp->table_id = ntohl (vrf_id);
7748 mp->create_vrf_if_needed = create_vrf_if_needed;
7750 mp->is_add = is_add;
7751 mp->is_drop = is_drop;
7752 mp->is_unreach = is_unreach;
7753 mp->is_prohibit = is_prohibit;
7754 mp->is_ipv6 = is_ipv6;
7755 mp->is_local = is_local;
7756 mp->is_classify = is_classify;
7757 mp->is_multipath = is_multipath;
7758 mp->is_resolve_host = resolve_host;
7759 mp->is_resolve_attached = resolve_attached;
7760 mp->not_last = not_last;
7761 mp->next_hop_weight = next_hop_weight;
7762 mp->dst_address_length = dst_address_length;
7763 mp->next_hop_table_id = ntohl (next_hop_table_id);
7764 mp->classify_table_index = ntohl (classify_table_index);
7765 mp->next_hop_via_label = ntohl (next_hop_via_label);
7766 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7767 if (0 != mp->next_hop_n_out_labels)
7769 memcpy (mp->next_hop_out_label_stack,
7770 next_hop_out_label_stack,
7771 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7772 vec_free (next_hop_out_label_stack);
7777 clib_memcpy (mp->dst_address, &v6_dst_address,
7778 sizeof (v6_dst_address));
7780 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
7781 sizeof (v6_next_hop_address));
7782 increment_v6_address (&v6_dst_address);
7786 clib_memcpy (mp->dst_address, &v4_dst_address,
7787 sizeof (v4_dst_address));
7789 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
7790 sizeof (v4_next_hop_address));
7792 v4_dst_address.as_u32 = random_vector[j + 1];
7794 increment_v4_address (&v4_dst_address);
7798 /* If we receive SIGTERM, stop now... */
7803 /* When testing multiple add/del ops, use a control-ping to sync */
7806 vl_api_control_ping_t *mp_ping;
7810 /* Shut off async mode */
7811 vam->async_mode = 0;
7813 MPING (CONTROL_PING, mp_ping);
7816 timeout = vat_time_now (vam) + 1.0;
7817 while (vat_time_now (vam) < timeout)
7818 if (vam->result_ready == 1)
7823 if (vam->retval == -99)
7826 if (vam->async_errors > 0)
7828 errmsg ("%d asynchronous errors", vam->async_errors);
7831 vam->async_errors = 0;
7832 after = vat_time_now (vam);
7834 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7838 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7839 count, after - before, count / (after - before));
7845 /* Wait for a reply... */
7850 /* Return the good/bad news */
7851 return (vam->retval);
7855 api_ip_mroute_add_del (vat_main_t * vam)
7857 unformat_input_t *i = vam->input;
7858 vl_api_ip_mroute_add_del_t *mp;
7859 u32 sw_if_index = ~0, vrf_id = 0;
7862 u8 create_vrf_if_needed = 0;
7865 u32 grp_address_length = 0;
7866 ip4_address_t v4_grp_address, v4_src_address;
7867 ip6_address_t v6_grp_address, v6_src_address;
7868 mfib_itf_flags_t iflags = 0;
7869 mfib_entry_flags_t eflags = 0;
7872 /* Parse args required to build the message */
7873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7875 if (unformat (i, "sw_if_index %d", &sw_if_index))
7877 else if (unformat (i, "%U %U",
7878 unformat_ip4_address, &v4_src_address,
7879 unformat_ip4_address, &v4_grp_address))
7881 grp_address_length = 64;
7885 else if (unformat (i, "%U %U",
7886 unformat_ip6_address, &v6_src_address,
7887 unformat_ip6_address, &v6_grp_address))
7889 grp_address_length = 256;
7893 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7895 memset (&v4_src_address, 0, sizeof (v4_src_address));
7896 grp_address_length = 32;
7900 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7902 memset (&v6_src_address, 0, sizeof (v6_src_address));
7903 grp_address_length = 128;
7907 else if (unformat (i, "/%d", &grp_address_length))
7909 else if (unformat (i, "local"))
7913 else if (unformat (i, "del"))
7915 else if (unformat (i, "add"))
7917 else if (unformat (i, "vrf %d", &vrf_id))
7919 else if (unformat (i, "create-vrf"))
7920 create_vrf_if_needed = 1;
7921 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
7923 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7927 clib_warning ("parse error '%U'", format_unformat_error, i);
7932 if (address_set == 0)
7934 errmsg ("missing addresses\n");
7938 /* Construct the API message */
7939 M (IP_MROUTE_ADD_DEL, mp);
7941 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7942 mp->table_id = ntohl (vrf_id);
7943 mp->create_vrf_if_needed = create_vrf_if_needed;
7945 mp->is_add = is_add;
7946 mp->is_ipv6 = is_ipv6;
7947 mp->is_local = is_local;
7948 mp->itf_flags = ntohl (iflags);
7949 mp->entry_flags = ntohl (eflags);
7950 mp->grp_address_length = grp_address_length;
7951 mp->grp_address_length = ntohs (mp->grp_address_length);
7955 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7956 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7960 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7961 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7967 /* Wait for a reply... */
7973 api_mpls_table_add_del (vat_main_t * vam)
7975 unformat_input_t *i = vam->input;
7976 vl_api_mpls_table_add_del_t *mp;
7981 /* Parse args required to build the message */
7982 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7984 if (unformat (i, "table %d", &table_id))
7986 else if (unformat (i, "del"))
7988 else if (unformat (i, "add"))
7992 clib_warning ("parse error '%U'", format_unformat_error, i);
7999 errmsg ("missing table-ID");
8003 /* Construct the API message */
8004 M (MPLS_TABLE_ADD_DEL, mp);
8006 mp->mt_table_id = ntohl (table_id);
8007 mp->mt_is_add = is_add;
8012 /* Wait for a reply... */
8019 api_mpls_route_add_del (vat_main_t * vam)
8021 unformat_input_t *i = vam->input;
8022 vl_api_mpls_route_add_del_t *mp;
8023 u32 sw_if_index = ~0, table_id = 0;
8024 u8 create_table_if_needed = 0;
8026 u32 next_hop_weight = 1;
8027 u8 is_multipath = 0;
8028 u32 next_hop_table_id = 0;
8029 u8 next_hop_set = 0;
8030 ip4_address_t v4_next_hop_address = {
8033 ip6_address_t v6_next_hop_address = { {0} };
8037 u32 classify_table_index = ~0;
8039 u8 resolve_host = 0, resolve_attached = 0;
8040 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8041 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8042 mpls_label_t *next_hop_out_label_stack = NULL;
8043 mpls_label_t local_label = MPLS_LABEL_INVALID;
8045 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8047 /* Parse args required to build the message */
8048 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8050 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8052 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8054 else if (unformat (i, "%d", &local_label))
8056 else if (unformat (i, "eos"))
8058 else if (unformat (i, "non-eos"))
8060 else if (unformat (i, "via %U", unformat_ip4_address,
8061 &v4_next_hop_address))
8064 next_hop_proto = DPO_PROTO_IP4;
8066 else if (unformat (i, "via %U", unformat_ip6_address,
8067 &v6_next_hop_address))
8070 next_hop_proto = DPO_PROTO_IP6;
8072 else if (unformat (i, "weight %d", &next_hop_weight))
8074 else if (unformat (i, "create-table"))
8075 create_table_if_needed = 1;
8076 else if (unformat (i, "classify %d", &classify_table_index))
8080 else if (unformat (i, "del"))
8082 else if (unformat (i, "add"))
8084 else if (unformat (i, "resolve-via-host"))
8086 else if (unformat (i, "resolve-via-attached"))
8087 resolve_attached = 1;
8088 else if (unformat (i, "multipath"))
8090 else if (unformat (i, "count %d", &count))
8092 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8095 next_hop_proto = DPO_PROTO_IP4;
8097 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8100 next_hop_proto = DPO_PROTO_IP6;
8102 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8104 else if (unformat (i, "via-label %d", &next_hop_via_label))
8106 else if (unformat (i, "out-label %d", &next_hop_out_label))
8107 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8110 clib_warning ("parse error '%U'", format_unformat_error, i);
8115 if (!next_hop_set && !is_classify)
8117 errmsg ("next hop / classify not set");
8121 if (MPLS_LABEL_INVALID == local_label)
8123 errmsg ("missing label");
8129 /* Turn on async mode */
8130 vam->async_mode = 1;
8131 vam->async_errors = 0;
8132 before = vat_time_now (vam);
8135 for (j = 0; j < count; j++)
8137 /* Construct the API message */
8138 M2 (MPLS_ROUTE_ADD_DEL, mp,
8139 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8141 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8142 mp->mr_table_id = ntohl (table_id);
8143 mp->mr_create_table_if_needed = create_table_if_needed;
8145 mp->mr_is_add = is_add;
8146 mp->mr_next_hop_proto = next_hop_proto;
8147 mp->mr_is_classify = is_classify;
8148 mp->mr_is_multipath = is_multipath;
8149 mp->mr_is_resolve_host = resolve_host;
8150 mp->mr_is_resolve_attached = resolve_attached;
8151 mp->mr_next_hop_weight = next_hop_weight;
8152 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8153 mp->mr_classify_table_index = ntohl (classify_table_index);
8154 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8155 mp->mr_label = ntohl (local_label);
8156 mp->mr_eos = is_eos;
8158 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8159 if (0 != mp->mr_next_hop_n_out_labels)
8161 memcpy (mp->mr_next_hop_out_label_stack,
8162 next_hop_out_label_stack,
8163 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8164 vec_free (next_hop_out_label_stack);
8169 if (DPO_PROTO_IP4 == next_hop_proto)
8171 clib_memcpy (mp->mr_next_hop,
8172 &v4_next_hop_address,
8173 sizeof (v4_next_hop_address));
8175 else if (DPO_PROTO_IP6 == next_hop_proto)
8178 clib_memcpy (mp->mr_next_hop,
8179 &v6_next_hop_address,
8180 sizeof (v6_next_hop_address));
8187 /* If we receive SIGTERM, stop now... */
8192 /* When testing multiple add/del ops, use a control-ping to sync */
8195 vl_api_control_ping_t *mp_ping;
8199 /* Shut off async mode */
8200 vam->async_mode = 0;
8202 MPING (CONTROL_PING, mp_ping);
8205 timeout = vat_time_now (vam) + 1.0;
8206 while (vat_time_now (vam) < timeout)
8207 if (vam->result_ready == 1)
8212 if (vam->retval == -99)
8215 if (vam->async_errors > 0)
8217 errmsg ("%d asynchronous errors", vam->async_errors);
8220 vam->async_errors = 0;
8221 after = vat_time_now (vam);
8223 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8227 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8228 count, after - before, count / (after - before));
8234 /* Wait for a reply... */
8239 /* Return the good/bad news */
8240 return (vam->retval);
8244 api_mpls_ip_bind_unbind (vat_main_t * vam)
8246 unformat_input_t *i = vam->input;
8247 vl_api_mpls_ip_bind_unbind_t *mp;
8248 u32 ip_table_id = 0;
8249 u8 create_table_if_needed = 0;
8252 ip4_address_t v4_address;
8253 ip6_address_t v6_address;
8256 mpls_label_t local_label = MPLS_LABEL_INVALID;
8259 /* Parse args required to build the message */
8260 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8262 if (unformat (i, "%U/%d", unformat_ip4_address,
8263 &v4_address, &address_length))
8268 else if (unformat (i, "%U/%d", unformat_ip6_address,
8269 &v6_address, &address_length))
8274 else if (unformat (i, "%d", &local_label))
8276 else if (unformat (i, "create-table"))
8277 create_table_if_needed = 1;
8278 else if (unformat (i, "table-id %d", &ip_table_id))
8280 else if (unformat (i, "unbind"))
8282 else if (unformat (i, "bind"))
8286 clib_warning ("parse error '%U'", format_unformat_error, i);
8293 errmsg ("IP addres not set");
8297 if (MPLS_LABEL_INVALID == local_label)
8299 errmsg ("missing label");
8303 /* Construct the API message */
8304 M (MPLS_IP_BIND_UNBIND, mp);
8306 mp->mb_create_table_if_needed = create_table_if_needed;
8307 mp->mb_is_bind = is_bind;
8308 mp->mb_is_ip4 = is_ip4;
8309 mp->mb_ip_table_id = ntohl (ip_table_id);
8310 mp->mb_mpls_table_id = 0;
8311 mp->mb_label = ntohl (local_label);
8312 mp->mb_address_length = address_length;
8315 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8317 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8322 /* Wait for a reply... */
8328 api_proxy_arp_add_del (vat_main_t * vam)
8330 unformat_input_t *i = vam->input;
8331 vl_api_proxy_arp_add_del_t *mp;
8334 ip4_address_t lo, hi;
8338 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8340 if (unformat (i, "vrf %d", &vrf_id))
8342 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
8343 unformat_ip4_address, &hi))
8345 else if (unformat (i, "del"))
8349 clib_warning ("parse error '%U'", format_unformat_error, i);
8356 errmsg ("address range not set");
8360 M (PROXY_ARP_ADD_DEL, mp);
8362 mp->vrf_id = ntohl (vrf_id);
8363 mp->is_add = is_add;
8364 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
8365 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
8373 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8375 unformat_input_t *i = vam->input;
8376 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8379 u8 sw_if_index_set = 0;
8382 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8384 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8385 sw_if_index_set = 1;
8386 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8387 sw_if_index_set = 1;
8388 else if (unformat (i, "enable"))
8390 else if (unformat (i, "disable"))
8394 clib_warning ("parse error '%U'", format_unformat_error, i);
8399 if (sw_if_index_set == 0)
8401 errmsg ("missing interface name or sw_if_index");
8405 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8407 mp->sw_if_index = ntohl (sw_if_index);
8408 mp->enable_disable = enable;
8416 api_mpls_tunnel_add_del (vat_main_t * vam)
8418 unformat_input_t *i = vam->input;
8419 vl_api_mpls_tunnel_add_del_t *mp;
8423 u32 sw_if_index = ~0;
8424 u32 next_hop_sw_if_index = ~0;
8425 u32 next_hop_proto_is_ip4 = 1;
8427 u32 next_hop_table_id = 0;
8428 ip4_address_t v4_next_hop_address = {
8431 ip6_address_t v6_next_hop_address = { {0} };
8432 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
8435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8437 if (unformat (i, "add"))
8439 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8441 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
8443 else if (unformat (i, "via %U",
8444 unformat_ip4_address, &v4_next_hop_address))
8446 next_hop_proto_is_ip4 = 1;
8448 else if (unformat (i, "via %U",
8449 unformat_ip6_address, &v6_next_hop_address))
8451 next_hop_proto_is_ip4 = 0;
8453 else if (unformat (i, "l2-only"))
8455 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8457 else if (unformat (i, "out-label %d", &next_hop_out_label))
8458 vec_add1 (labels, ntohl (next_hop_out_label));
8461 clib_warning ("parse error '%U'", format_unformat_error, i);
8466 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
8468 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
8469 mp->mt_sw_if_index = ntohl (sw_if_index);
8470 mp->mt_is_add = is_add;
8471 mp->mt_l2_only = l2_only;
8472 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
8473 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
8475 mp->mt_next_hop_n_out_labels = vec_len (labels);
8477 if (0 != mp->mt_next_hop_n_out_labels)
8479 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
8480 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
8484 if (next_hop_proto_is_ip4)
8486 clib_memcpy (mp->mt_next_hop,
8487 &v4_next_hop_address, sizeof (v4_next_hop_address));
8491 clib_memcpy (mp->mt_next_hop,
8492 &v6_next_hop_address, sizeof (v6_next_hop_address));
8501 api_sw_interface_set_unnumbered (vat_main_t * vam)
8503 unformat_input_t *i = vam->input;
8504 vl_api_sw_interface_set_unnumbered_t *mp;
8506 u32 unnum_sw_index = ~0;
8508 u8 sw_if_index_set = 0;
8511 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8513 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8514 sw_if_index_set = 1;
8515 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8516 sw_if_index_set = 1;
8517 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8519 else if (unformat (i, "del"))
8523 clib_warning ("parse error '%U'", format_unformat_error, i);
8528 if (sw_if_index_set == 0)
8530 errmsg ("missing interface name or sw_if_index");
8534 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8536 mp->sw_if_index = ntohl (sw_if_index);
8537 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8538 mp->is_add = is_add;
8546 api_ip_neighbor_add_del (vat_main_t * vam)
8548 unformat_input_t *i = vam->input;
8549 vl_api_ip_neighbor_add_del_t *mp;
8551 u8 sw_if_index_set = 0;
8554 u8 is_no_fib_entry = 0;
8557 u8 v4_address_set = 0;
8558 u8 v6_address_set = 0;
8559 ip4_address_t v4address;
8560 ip6_address_t v6address;
8563 memset (mac_address, 0, sizeof (mac_address));
8565 /* Parse args required to build the message */
8566 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8568 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8572 else if (unformat (i, "del"))
8575 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8576 sw_if_index_set = 1;
8577 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8578 sw_if_index_set = 1;
8579 else if (unformat (i, "is_static"))
8581 else if (unformat (i, "no-fib-entry"))
8582 is_no_fib_entry = 1;
8583 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
8585 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
8589 clib_warning ("parse error '%U'", format_unformat_error, i);
8594 if (sw_if_index_set == 0)
8596 errmsg ("missing interface name or sw_if_index");
8599 if (v4_address_set && v6_address_set)
8601 errmsg ("both v4 and v6 addresses set");
8604 if (!v4_address_set && !v6_address_set)
8606 errmsg ("no address set");
8610 /* Construct the API message */
8611 M (IP_NEIGHBOR_ADD_DEL, mp);
8613 mp->sw_if_index = ntohl (sw_if_index);
8614 mp->is_add = is_add;
8615 mp->is_static = is_static;
8616 mp->is_no_adj_fib = is_no_fib_entry;
8618 clib_memcpy (mp->mac_address, mac_address, 6);
8622 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
8626 /* mp->is_ipv6 = 0; via memset in M macro above */
8627 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
8633 /* Wait for a reply, return good/bad news */
8639 api_reset_vrf (vat_main_t * vam)
8641 unformat_input_t *i = vam->input;
8642 vl_api_reset_vrf_t *mp;
8648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8650 if (unformat (i, "vrf %d", &vrf_id))
8652 else if (unformat (i, "ipv6"))
8656 clib_warning ("parse error '%U'", format_unformat_error, i);
8661 if (vrf_id_set == 0)
8663 errmsg ("missing vrf id");
8669 mp->vrf_id = ntohl (vrf_id);
8670 mp->is_ipv6 = is_ipv6;
8678 api_create_vlan_subif (vat_main_t * vam)
8680 unformat_input_t *i = vam->input;
8681 vl_api_create_vlan_subif_t *mp;
8683 u8 sw_if_index_set = 0;
8688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8690 if (unformat (i, "sw_if_index %d", &sw_if_index))
8691 sw_if_index_set = 1;
8693 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8694 sw_if_index_set = 1;
8695 else if (unformat (i, "vlan %d", &vlan_id))
8699 clib_warning ("parse error '%U'", format_unformat_error, i);
8704 if (sw_if_index_set == 0)
8706 errmsg ("missing interface name or sw_if_index");
8710 if (vlan_id_set == 0)
8712 errmsg ("missing vlan_id");
8715 M (CREATE_VLAN_SUBIF, mp);
8717 mp->sw_if_index = ntohl (sw_if_index);
8718 mp->vlan_id = ntohl (vlan_id);
8725 #define foreach_create_subif_bit \
8732 _(outer_vlan_id_any) \
8733 _(inner_vlan_id_any)
8736 api_create_subif (vat_main_t * vam)
8738 unformat_input_t *i = vam->input;
8739 vl_api_create_subif_t *mp;
8741 u8 sw_if_index_set = 0;
8748 u32 exact_match = 0;
8749 u32 default_sub = 0;
8750 u32 outer_vlan_id_any = 0;
8751 u32 inner_vlan_id_any = 0;
8753 u16 outer_vlan_id = 0;
8754 u16 inner_vlan_id = 0;
8757 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8759 if (unformat (i, "sw_if_index %d", &sw_if_index))
8760 sw_if_index_set = 1;
8762 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8763 sw_if_index_set = 1;
8764 else if (unformat (i, "sub_id %d", &sub_id))
8766 else if (unformat (i, "outer_vlan_id %d", &tmp))
8767 outer_vlan_id = tmp;
8768 else if (unformat (i, "inner_vlan_id %d", &tmp))
8769 inner_vlan_id = tmp;
8771 #define _(a) else if (unformat (i, #a)) a = 1 ;
8772 foreach_create_subif_bit
8776 clib_warning ("parse error '%U'", format_unformat_error, i);
8781 if (sw_if_index_set == 0)
8783 errmsg ("missing interface name or sw_if_index");
8787 if (sub_id_set == 0)
8789 errmsg ("missing sub_id");
8792 M (CREATE_SUBIF, mp);
8794 mp->sw_if_index = ntohl (sw_if_index);
8795 mp->sub_id = ntohl (sub_id);
8797 #define _(a) mp->a = a;
8798 foreach_create_subif_bit;
8801 mp->outer_vlan_id = ntohs (outer_vlan_id);
8802 mp->inner_vlan_id = ntohs (inner_vlan_id);
8810 api_oam_add_del (vat_main_t * vam)
8812 unformat_input_t *i = vam->input;
8813 vl_api_oam_add_del_t *mp;
8816 ip4_address_t src, dst;
8821 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8823 if (unformat (i, "vrf %d", &vrf_id))
8825 else if (unformat (i, "src %U", unformat_ip4_address, &src))
8827 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
8829 else if (unformat (i, "del"))
8833 clib_warning ("parse error '%U'", format_unformat_error, i);
8840 errmsg ("missing src addr");
8846 errmsg ("missing dst addr");
8850 M (OAM_ADD_DEL, mp);
8852 mp->vrf_id = ntohl (vrf_id);
8853 mp->is_add = is_add;
8854 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
8855 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
8863 api_reset_fib (vat_main_t * vam)
8865 unformat_input_t *i = vam->input;
8866 vl_api_reset_fib_t *mp;
8872 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8874 if (unformat (i, "vrf %d", &vrf_id))
8876 else if (unformat (i, "ipv6"))
8880 clib_warning ("parse error '%U'", format_unformat_error, i);
8885 if (vrf_id_set == 0)
8887 errmsg ("missing vrf id");
8893 mp->vrf_id = ntohl (vrf_id);
8894 mp->is_ipv6 = is_ipv6;
8902 api_dhcp_proxy_config (vat_main_t * vam)
8904 unformat_input_t *i = vam->input;
8905 vl_api_dhcp_proxy_config_t *mp;
8907 u32 server_vrf_id = 0;
8909 u8 v4_address_set = 0;
8910 u8 v6_address_set = 0;
8911 ip4_address_t v4address;
8912 ip6_address_t v6address;
8913 u8 v4_src_address_set = 0;
8914 u8 v6_src_address_set = 0;
8915 ip4_address_t v4srcaddress;
8916 ip6_address_t v6srcaddress;
8919 /* Parse args required to build the message */
8920 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8922 if (unformat (i, "del"))
8924 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
8926 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
8928 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
8930 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
8932 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
8933 v4_src_address_set = 1;
8934 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
8935 v6_src_address_set = 1;
8940 if (v4_address_set && v6_address_set)
8942 errmsg ("both v4 and v6 server addresses set");
8945 if (!v4_address_set && !v6_address_set)
8947 errmsg ("no server addresses set");
8951 if (v4_src_address_set && v6_src_address_set)
8953 errmsg ("both v4 and v6 src addresses set");
8956 if (!v4_src_address_set && !v6_src_address_set)
8958 errmsg ("no src addresses set");
8962 if (!(v4_src_address_set && v4_address_set) &&
8963 !(v6_src_address_set && v6_address_set))
8965 errmsg ("no matching server and src addresses set");
8969 /* Construct the API message */
8970 M (DHCP_PROXY_CONFIG, mp);
8972 mp->is_add = is_add;
8973 mp->rx_vrf_id = ntohl (rx_vrf_id);
8974 mp->server_vrf_id = ntohl (server_vrf_id);
8978 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
8979 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
8983 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
8984 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
8990 /* Wait for a reply, return good/bad news */
8995 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
8996 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
8999 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9001 vat_main_t *vam = &vat_main;
9002 u32 i, count = mp->count;
9003 vl_api_dhcp_server_t *s;
9007 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
9008 ntohl (mp->rx_vrf_id),
9009 format_ip6_address, mp->dhcp_src_address,
9010 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9013 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
9014 ntohl (mp->rx_vrf_id),
9015 format_ip4_address, mp->dhcp_src_address,
9016 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9018 for (i = 0; i < count; i++)
9020 s = &mp->servers[i];
9024 " Server Table-ID %d, Server Address %U",
9025 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9028 " Server Table-ID %d, Server Address %U",
9029 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9033 static void vl_api_dhcp_proxy_details_t_handler_json
9034 (vl_api_dhcp_proxy_details_t * mp)
9036 vat_main_t *vam = &vat_main;
9037 vat_json_node_t *node = NULL;
9038 u32 i, count = mp->count;
9040 struct in6_addr ip6;
9041 vl_api_dhcp_server_t *s;
9043 if (VAT_JSON_ARRAY != vam->json_tree.type)
9045 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9046 vat_json_init_array (&vam->json_tree);
9048 node = vat_json_array_add (&vam->json_tree);
9050 vat_json_init_object (node);
9051 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9052 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9053 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9057 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9058 vat_json_object_add_ip6 (node, "src_address", ip6);
9062 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9063 vat_json_object_add_ip4 (node, "src_address", ip4);
9066 for (i = 0; i < count; i++)
9068 s = &mp->servers[i];
9070 vat_json_object_add_uint (node, "server-table-id",
9071 ntohl (s->server_vrf_id));
9075 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9076 vat_json_object_add_ip4 (node, "src_address", ip4);
9080 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9081 vat_json_object_add_ip6 (node, "server_address", ip6);
9087 api_dhcp_proxy_dump (vat_main_t * vam)
9089 unformat_input_t *i = vam->input;
9090 vl_api_control_ping_t *mp_ping;
9091 vl_api_dhcp_proxy_dump_t *mp;
9095 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9097 if (unformat (i, "ipv6"))
9101 clib_warning ("parse error '%U'", format_unformat_error, i);
9106 M (DHCP_PROXY_DUMP, mp);
9108 mp->is_ip6 = is_ipv6;
9111 /* Use a control ping for synchronization */
9112 MPING (CONTROL_PING, mp_ping);
9120 api_dhcp_proxy_set_vss (vat_main_t * vam)
9122 unformat_input_t *i = vam->input;
9123 vl_api_dhcp_proxy_set_vss_t *mp;
9134 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9136 if (unformat (i, "tbl_id %d", &tbl_id))
9138 if (unformat (i, "fib_id %d", &fib_id))
9140 if (unformat (i, "oui %d", &oui))
9142 else if (unformat (i, "ipv6"))
9144 else if (unformat (i, "del"))
9148 clib_warning ("parse error '%U'", format_unformat_error, i);
9153 if (tbl_id_set == 0)
9155 errmsg ("missing tbl id");
9159 if (fib_id_set == 0)
9161 errmsg ("missing fib id");
9166 errmsg ("missing oui");
9170 M (DHCP_PROXY_SET_VSS, mp);
9171 mp->tbl_id = ntohl (tbl_id);
9172 mp->fib_id = ntohl (fib_id);
9173 mp->oui = ntohl (oui);
9174 mp->is_ipv6 = is_ipv6;
9175 mp->is_add = is_add;
9183 api_dhcp_client_config (vat_main_t * vam)
9185 unformat_input_t *i = vam->input;
9186 vl_api_dhcp_client_config_t *mp;
9188 u8 sw_if_index_set = 0;
9191 u8 disable_event = 0;
9194 /* Parse args required to build the message */
9195 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9197 if (unformat (i, "del"))
9200 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9201 sw_if_index_set = 1;
9202 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9203 sw_if_index_set = 1;
9204 else if (unformat (i, "hostname %s", &hostname))
9206 else if (unformat (i, "disable_event"))
9212 if (sw_if_index_set == 0)
9214 errmsg ("missing interface name or sw_if_index");
9218 if (vec_len (hostname) > 63)
9220 errmsg ("hostname too long");
9222 vec_add1 (hostname, 0);
9224 /* Construct the API message */
9225 M (DHCP_CLIENT_CONFIG, mp);
9227 mp->sw_if_index = htonl (sw_if_index);
9228 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
9229 vec_free (hostname);
9230 mp->is_add = is_add;
9231 mp->want_dhcp_event = disable_event ? 0 : 1;
9232 mp->pid = htonl (getpid ());
9237 /* Wait for a reply, return good/bad news */
9243 api_set_ip_flow_hash (vat_main_t * vam)
9245 unformat_input_t *i = vam->input;
9246 vl_api_set_ip_flow_hash_t *mp;
9258 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9260 if (unformat (i, "vrf %d", &vrf_id))
9262 else if (unformat (i, "ipv6"))
9264 else if (unformat (i, "src"))
9266 else if (unformat (i, "dst"))
9268 else if (unformat (i, "sport"))
9270 else if (unformat (i, "dport"))
9272 else if (unformat (i, "proto"))
9274 else if (unformat (i, "reverse"))
9279 clib_warning ("parse error '%U'", format_unformat_error, i);
9284 if (vrf_id_set == 0)
9286 errmsg ("missing vrf id");
9290 M (SET_IP_FLOW_HASH, mp);
9296 mp->reverse = reverse;
9297 mp->vrf_id = ntohl (vrf_id);
9298 mp->is_ipv6 = is_ipv6;
9306 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9308 unformat_input_t *i = vam->input;
9309 vl_api_sw_interface_ip6_enable_disable_t *mp;
9311 u8 sw_if_index_set = 0;
9315 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9317 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9318 sw_if_index_set = 1;
9319 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9320 sw_if_index_set = 1;
9321 else if (unformat (i, "enable"))
9323 else if (unformat (i, "disable"))
9327 clib_warning ("parse error '%U'", format_unformat_error, i);
9332 if (sw_if_index_set == 0)
9334 errmsg ("missing interface name or sw_if_index");
9338 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9340 mp->sw_if_index = ntohl (sw_if_index);
9341 mp->enable = enable;
9349 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
9351 unformat_input_t *i = vam->input;
9352 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
9354 u8 sw_if_index_set = 0;
9355 u8 v6_address_set = 0;
9356 ip6_address_t v6address;
9359 /* Parse args required to build the message */
9360 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9362 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9363 sw_if_index_set = 1;
9364 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9365 sw_if_index_set = 1;
9366 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9372 if (sw_if_index_set == 0)
9374 errmsg ("missing interface name or sw_if_index");
9377 if (!v6_address_set)
9379 errmsg ("no address set");
9383 /* Construct the API message */
9384 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
9386 mp->sw_if_index = ntohl (sw_if_index);
9387 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9392 /* Wait for a reply, return good/bad news */
9398 api_ip6nd_proxy_add_del (vat_main_t * vam)
9400 unformat_input_t *i = vam->input;
9401 vl_api_ip6nd_proxy_add_del_t *mp;
9402 u32 sw_if_index = ~0;
9403 u8 v6_address_set = 0;
9404 ip6_address_t v6address;
9408 /* Parse args required to build the message */
9409 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9411 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9413 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9415 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9417 if (unformat (i, "del"))
9421 clib_warning ("parse error '%U'", format_unformat_error, i);
9426 if (sw_if_index == ~0)
9428 errmsg ("missing interface name or sw_if_index");
9431 if (!v6_address_set)
9433 errmsg ("no address set");
9437 /* Construct the API message */
9438 M (IP6ND_PROXY_ADD_DEL, mp);
9440 mp->is_del = is_del;
9441 mp->sw_if_index = ntohl (sw_if_index);
9442 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9447 /* Wait for a reply, return good/bad news */
9453 api_ip6nd_proxy_dump (vat_main_t * vam)
9455 vl_api_ip6nd_proxy_dump_t *mp;
9456 vl_api_control_ping_t *mp_ping;
9459 M (IP6ND_PROXY_DUMP, mp);
9463 /* Use a control ping for synchronization */
9464 MPING (CONTROL_PING, mp_ping);
9471 static void vl_api_ip6nd_proxy_details_t_handler
9472 (vl_api_ip6nd_proxy_details_t * mp)
9474 vat_main_t *vam = &vat_main;
9476 print (vam->ofp, "host %U sw_if_index %d",
9477 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
9480 static void vl_api_ip6nd_proxy_details_t_handler_json
9481 (vl_api_ip6nd_proxy_details_t * mp)
9483 vat_main_t *vam = &vat_main;
9484 struct in6_addr ip6;
9485 vat_json_node_t *node = NULL;
9487 if (VAT_JSON_ARRAY != vam->json_tree.type)
9489 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9490 vat_json_init_array (&vam->json_tree);
9492 node = vat_json_array_add (&vam->json_tree);
9494 vat_json_init_object (node);
9495 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9497 clib_memcpy (&ip6, mp->address, sizeof (ip6));
9498 vat_json_object_add_ip6 (node, "host", ip6);
9502 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9504 unformat_input_t *i = vam->input;
9505 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9507 u8 sw_if_index_set = 0;
9508 u32 address_length = 0;
9509 u8 v6_address_set = 0;
9510 ip6_address_t v6address;
9512 u8 no_advertise = 0;
9514 u8 no_autoconfig = 0;
9517 u32 val_lifetime = 0;
9518 u32 pref_lifetime = 0;
9521 /* Parse args required to build the message */
9522 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9524 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9525 sw_if_index_set = 1;
9526 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9527 sw_if_index_set = 1;
9528 else if (unformat (i, "%U/%d",
9529 unformat_ip6_address, &v6address, &address_length))
9531 else if (unformat (i, "val_life %d", &val_lifetime))
9533 else if (unformat (i, "pref_life %d", &pref_lifetime))
9535 else if (unformat (i, "def"))
9537 else if (unformat (i, "noadv"))
9539 else if (unformat (i, "offl"))
9541 else if (unformat (i, "noauto"))
9543 else if (unformat (i, "nolink"))
9545 else if (unformat (i, "isno"))
9549 clib_warning ("parse error '%U'", format_unformat_error, i);
9554 if (sw_if_index_set == 0)
9556 errmsg ("missing interface name or sw_if_index");
9559 if (!v6_address_set)
9561 errmsg ("no address set");
9565 /* Construct the API message */
9566 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9568 mp->sw_if_index = ntohl (sw_if_index);
9569 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9570 mp->address_length = address_length;
9571 mp->use_default = use_default;
9572 mp->no_advertise = no_advertise;
9573 mp->off_link = off_link;
9574 mp->no_autoconfig = no_autoconfig;
9575 mp->no_onlink = no_onlink;
9577 mp->val_lifetime = ntohl (val_lifetime);
9578 mp->pref_lifetime = ntohl (pref_lifetime);
9583 /* Wait for a reply, return good/bad news */
9589 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9591 unformat_input_t *i = vam->input;
9592 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9594 u8 sw_if_index_set = 0;
9599 u8 send_unicast = 0;
9602 u8 default_router = 0;
9603 u32 max_interval = 0;
9604 u32 min_interval = 0;
9606 u32 initial_count = 0;
9607 u32 initial_interval = 0;
9611 /* Parse args required to build the message */
9612 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9614 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9615 sw_if_index_set = 1;
9616 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9617 sw_if_index_set = 1;
9618 else if (unformat (i, "maxint %d", &max_interval))
9620 else if (unformat (i, "minint %d", &min_interval))
9622 else if (unformat (i, "life %d", &lifetime))
9624 else if (unformat (i, "count %d", &initial_count))
9626 else if (unformat (i, "interval %d", &initial_interval))
9628 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9630 else if (unformat (i, "managed"))
9632 else if (unformat (i, "other"))
9634 else if (unformat (i, "ll"))
9636 else if (unformat (i, "send"))
9638 else if (unformat (i, "cease"))
9640 else if (unformat (i, "isno"))
9642 else if (unformat (i, "def"))
9646 clib_warning ("parse error '%U'", format_unformat_error, i);
9651 if (sw_if_index_set == 0)
9653 errmsg ("missing interface name or sw_if_index");
9657 /* Construct the API message */
9658 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9660 mp->sw_if_index = ntohl (sw_if_index);
9661 mp->max_interval = ntohl (max_interval);
9662 mp->min_interval = ntohl (min_interval);
9663 mp->lifetime = ntohl (lifetime);
9664 mp->initial_count = ntohl (initial_count);
9665 mp->initial_interval = ntohl (initial_interval);
9666 mp->suppress = suppress;
9667 mp->managed = managed;
9669 mp->ll_option = ll_option;
9670 mp->send_unicast = send_unicast;
9673 mp->default_router = default_router;
9678 /* Wait for a reply, return good/bad news */
9684 api_set_arp_neighbor_limit (vat_main_t * vam)
9686 unformat_input_t *i = vam->input;
9687 vl_api_set_arp_neighbor_limit_t *mp;
9693 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9695 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9697 else if (unformat (i, "ipv6"))
9701 clib_warning ("parse error '%U'", format_unformat_error, i);
9708 errmsg ("missing limit value");
9712 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9714 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9715 mp->is_ipv6 = is_ipv6;
9723 api_l2_patch_add_del (vat_main_t * vam)
9725 unformat_input_t *i = vam->input;
9726 vl_api_l2_patch_add_del_t *mp;
9728 u8 rx_sw_if_index_set = 0;
9730 u8 tx_sw_if_index_set = 0;
9734 /* Parse args required to build the message */
9735 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9737 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9738 rx_sw_if_index_set = 1;
9739 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9740 tx_sw_if_index_set = 1;
9741 else if (unformat (i, "rx"))
9743 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9745 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9747 rx_sw_if_index_set = 1;
9752 else if (unformat (i, "tx"))
9754 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9756 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9758 tx_sw_if_index_set = 1;
9763 else if (unformat (i, "del"))
9769 if (rx_sw_if_index_set == 0)
9771 errmsg ("missing rx interface name or rx_sw_if_index");
9775 if (tx_sw_if_index_set == 0)
9777 errmsg ("missing tx interface name or tx_sw_if_index");
9781 M (L2_PATCH_ADD_DEL, mp);
9783 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9784 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9785 mp->is_add = is_add;
9793 u8 localsid_addr[16];
9802 api_sr_localsid_add_del (vat_main_t * vam)
9804 unformat_input_t *i = vam->input;
9805 vl_api_sr_localsid_add_del_t *mp;
9808 ip6_address_t localsid;
9812 u32 fib_table = ~(u32) 0;
9813 ip6_address_t next_hop;
9815 bool nexthop_set = 0;
9819 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9821 if (unformat (i, "del"))
9823 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9824 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
9826 else if (unformat (i, "behavior %u", &behavior));
9827 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9828 else if (unformat (i, "fib-table %u", &fib_table));
9829 else if (unformat (i, "end.psp %u", &behavior));
9834 M (SR_LOCALSID_ADD_DEL, mp);
9836 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
9838 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
9839 mp->behavior = behavior;
9840 mp->sw_if_index = ntohl (sw_if_index);
9841 mp->fib_table = ntohl (fib_table);
9842 mp->end_psp = end_psp;
9843 mp->is_del = is_del;
9851 api_ioam_enable (vat_main_t * vam)
9853 unformat_input_t *input = vam->input;
9854 vl_api_ioam_enable_t *mp;
9856 int has_trace_option = 0;
9857 int has_pot_option = 0;
9858 int has_seqno_option = 0;
9859 int has_analyse_option = 0;
9862 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9864 if (unformat (input, "trace"))
9865 has_trace_option = 1;
9866 else if (unformat (input, "pot"))
9868 else if (unformat (input, "seqno"))
9869 has_seqno_option = 1;
9870 else if (unformat (input, "analyse"))
9871 has_analyse_option = 1;
9875 M (IOAM_ENABLE, mp);
9876 mp->id = htons (id);
9877 mp->seqno = has_seqno_option;
9878 mp->analyse = has_analyse_option;
9879 mp->pot_enable = has_pot_option;
9880 mp->trace_enable = has_trace_option;
9889 api_ioam_disable (vat_main_t * vam)
9891 vl_api_ioam_disable_t *mp;
9894 M (IOAM_DISABLE, mp);
9900 #define foreach_tcp_proto_field \
9904 #define foreach_udp_proto_field \
9908 #define foreach_ip4_proto_field \
9920 u16 src_port, dst_port;
9923 #if VPP_API_TEST_BUILTIN == 0
9925 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9927 u8 **maskp = va_arg (*args, u8 **);
9929 u8 found_something = 0;
9932 #define _(a) u8 a=0;
9933 foreach_tcp_proto_field;
9936 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9939 #define _(a) else if (unformat (input, #a)) a=1;
9940 foreach_tcp_proto_field
9946 #define _(a) found_something += a;
9947 foreach_tcp_proto_field;
9950 if (found_something == 0)
9953 vec_validate (mask, sizeof (*tcp) - 1);
9955 tcp = (tcp_header_t *) mask;
9957 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
9958 foreach_tcp_proto_field;
9966 unformat_udp_mask (unformat_input_t * input, va_list * args)
9968 u8 **maskp = va_arg (*args, u8 **);
9970 u8 found_something = 0;
9973 #define _(a) u8 a=0;
9974 foreach_udp_proto_field;
9977 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9980 #define _(a) else if (unformat (input, #a)) a=1;
9981 foreach_udp_proto_field
9987 #define _(a) found_something += a;
9988 foreach_udp_proto_field;
9991 if (found_something == 0)
9994 vec_validate (mask, sizeof (*udp) - 1);
9996 udp = (udp_header_t *) mask;
9998 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
9999 foreach_udp_proto_field;
10007 unformat_l4_mask (unformat_input_t * input, va_list * args)
10009 u8 **maskp = va_arg (*args, u8 **);
10010 u16 src_port = 0, dst_port = 0;
10011 tcpudp_header_t *tcpudp;
10013 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10015 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10017 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10019 else if (unformat (input, "src_port"))
10021 else if (unformat (input, "dst_port"))
10027 if (!src_port && !dst_port)
10031 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10033 tcpudp = (tcpudp_header_t *) mask;
10034 tcpudp->src_port = src_port;
10035 tcpudp->dst_port = dst_port;
10043 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10045 u8 **maskp = va_arg (*args, u8 **);
10047 u8 found_something = 0;
10050 #define _(a) u8 a=0;
10051 foreach_ip4_proto_field;
10057 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10059 if (unformat (input, "version"))
10061 else if (unformat (input, "hdr_length"))
10063 else if (unformat (input, "src"))
10065 else if (unformat (input, "dst"))
10067 else if (unformat (input, "proto"))
10070 #define _(a) else if (unformat (input, #a)) a=1;
10071 foreach_ip4_proto_field
10077 #define _(a) found_something += a;
10078 foreach_ip4_proto_field;
10081 if (found_something == 0)
10084 vec_validate (mask, sizeof (*ip) - 1);
10086 ip = (ip4_header_t *) mask;
10088 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10089 foreach_ip4_proto_field;
10092 ip->ip_version_and_header_length = 0;
10095 ip->ip_version_and_header_length |= 0xF0;
10098 ip->ip_version_and_header_length |= 0x0F;
10104 #define foreach_ip6_proto_field \
10107 _(payload_length) \
10112 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10114 u8 **maskp = va_arg (*args, u8 **);
10116 u8 found_something = 0;
10118 u32 ip_version_traffic_class_and_flow_label;
10120 #define _(a) u8 a=0;
10121 foreach_ip6_proto_field;
10124 u8 traffic_class = 0;
10127 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10129 if (unformat (input, "version"))
10131 else if (unformat (input, "traffic-class"))
10133 else if (unformat (input, "flow-label"))
10135 else if (unformat (input, "src"))
10137 else if (unformat (input, "dst"))
10139 else if (unformat (input, "proto"))
10142 #define _(a) else if (unformat (input, #a)) a=1;
10143 foreach_ip6_proto_field
10149 #define _(a) found_something += a;
10150 foreach_ip6_proto_field;
10153 if (found_something == 0)
10156 vec_validate (mask, sizeof (*ip) - 1);
10158 ip = (ip6_header_t *) mask;
10160 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10161 foreach_ip6_proto_field;
10164 ip_version_traffic_class_and_flow_label = 0;
10167 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10170 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10173 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10175 ip->ip_version_traffic_class_and_flow_label =
10176 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10183 unformat_l3_mask (unformat_input_t * input, va_list * args)
10185 u8 **maskp = va_arg (*args, u8 **);
10187 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10189 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10191 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10200 unformat_l2_mask (unformat_input_t * input, va_list * args)
10202 u8 **maskp = va_arg (*args, u8 **);
10209 u8 ignore_tag1 = 0;
10210 u8 ignore_tag2 = 0;
10217 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10219 if (unformat (input, "src"))
10221 else if (unformat (input, "dst"))
10223 else if (unformat (input, "proto"))
10225 else if (unformat (input, "tag1"))
10227 else if (unformat (input, "tag2"))
10229 else if (unformat (input, "ignore-tag1"))
10231 else if (unformat (input, "ignore-tag2"))
10233 else if (unformat (input, "cos1"))
10235 else if (unformat (input, "cos2"))
10237 else if (unformat (input, "dot1q"))
10239 else if (unformat (input, "dot1ad"))
10244 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10245 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10248 if (tag1 || ignore_tag1 || cos1 || dot1q)
10250 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10253 vec_validate (mask, len - 1);
10256 memset (mask, 0xff, 6);
10259 memset (mask + 6, 0xff, 6);
10261 if (tag2 || dot1ad)
10263 /* inner vlan tag */
10272 mask[21] = mask[20] = 0xff;
10293 mask[16] = mask[17] = 0xff;
10303 mask[12] = mask[13] = 0xff;
10310 unformat_classify_mask (unformat_input_t * input, va_list * args)
10312 u8 **maskp = va_arg (*args, u8 **);
10313 u32 *skipp = va_arg (*args, u32 *);
10314 u32 *matchp = va_arg (*args, u32 *);
10322 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10324 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10326 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10328 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10330 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10344 if (mask || l2 || l3 || l4)
10346 if (l2 || l3 || l4)
10348 /* "With a free Ethernet header in every package" */
10350 vec_validate (l2, 13);
10354 vec_append (mask, l3);
10359 vec_append (mask, l4);
10364 /* Scan forward looking for the first significant mask octet */
10365 for (i = 0; i < vec_len (mask); i++)
10369 /* compute (skip, match) params */
10370 *skipp = i / sizeof (u32x4);
10371 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10373 /* Pad mask to an even multiple of the vector size */
10374 while (vec_len (mask) % sizeof (u32x4))
10375 vec_add1 (mask, 0);
10377 match = vec_len (mask) / sizeof (u32x4);
10379 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10381 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10382 if (*tmp || *(tmp + 1))
10387 clib_warning ("BUG: match 0");
10389 _vec_len (mask) = match * sizeof (u32x4);
10399 #endif /* VPP_API_TEST_BUILTIN */
10401 #define foreach_l2_next \
10403 _(ethernet, ETHERNET_INPUT) \
10404 _(ip4, IP4_INPUT) \
10408 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10410 u32 *miss_next_indexp = va_arg (*args, u32 *);
10411 u32 next_index = 0;
10415 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10419 if (unformat (input, "%d", &tmp))
10428 *miss_next_indexp = next_index;
10432 #define foreach_ip_next \
10435 _(rewrite, REWRITE)
10438 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10440 u32 *miss_next_indexp = va_arg (*args, u32 *);
10441 u32 next_index = 0;
10445 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10449 if (unformat (input, "%d", &tmp))
10458 *miss_next_indexp = next_index;
10462 #define foreach_acl_next \
10466 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10468 u32 *miss_next_indexp = va_arg (*args, u32 *);
10469 u32 next_index = 0;
10473 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10477 if (unformat (input, "permit"))
10482 else if (unformat (input, "%d", &tmp))
10491 *miss_next_indexp = next_index;
10496 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10498 u32 *r = va_arg (*args, u32 *);
10500 if (unformat (input, "conform-color"))
10501 *r = POLICE_CONFORM;
10502 else if (unformat (input, "exceed-color"))
10503 *r = POLICE_EXCEED;
10511 api_classify_add_del_table (vat_main_t * vam)
10513 unformat_input_t *i = vam->input;
10514 vl_api_classify_add_del_table_t *mp;
10521 u32 table_index = ~0;
10522 u32 next_table_index = ~0;
10523 u32 miss_next_index = ~0;
10524 u32 memory_size = 32 << 20;
10526 u32 current_data_flag = 0;
10527 int current_data_offset = 0;
10530 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10532 if (unformat (i, "del"))
10534 else if (unformat (i, "del-chain"))
10539 else if (unformat (i, "buckets %d", &nbuckets))
10541 else if (unformat (i, "memory_size %d", &memory_size))
10543 else if (unformat (i, "skip %d", &skip))
10545 else if (unformat (i, "match %d", &match))
10547 else if (unformat (i, "table %d", &table_index))
10549 else if (unformat (i, "mask %U", unformat_classify_mask,
10550 &mask, &skip, &match))
10552 else if (unformat (i, "next-table %d", &next_table_index))
10554 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10557 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10560 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10563 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10565 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10571 if (is_add && mask == 0)
10573 errmsg ("Mask required");
10577 if (is_add && skip == ~0)
10579 errmsg ("skip count required");
10583 if (is_add && match == ~0)
10585 errmsg ("match count required");
10589 if (!is_add && table_index == ~0)
10591 errmsg ("table index required for delete");
10595 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10597 mp->is_add = is_add;
10598 mp->del_chain = del_chain;
10599 mp->table_index = ntohl (table_index);
10600 mp->nbuckets = ntohl (nbuckets);
10601 mp->memory_size = ntohl (memory_size);
10602 mp->skip_n_vectors = ntohl (skip);
10603 mp->match_n_vectors = ntohl (match);
10604 mp->next_table_index = ntohl (next_table_index);
10605 mp->miss_next_index = ntohl (miss_next_index);
10606 mp->current_data_flag = ntohl (current_data_flag);
10607 mp->current_data_offset = ntohl (current_data_offset);
10608 clib_memcpy (mp->mask, mask, vec_len (mask));
10617 #if VPP_API_TEST_BUILTIN == 0
10619 unformat_l4_match (unformat_input_t * input, va_list * args)
10621 u8 **matchp = va_arg (*args, u8 **);
10623 u8 *proto_header = 0;
10629 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10631 if (unformat (input, "src_port %d", &src_port))
10633 else if (unformat (input, "dst_port %d", &dst_port))
10639 h.src_port = clib_host_to_net_u16 (src_port);
10640 h.dst_port = clib_host_to_net_u16 (dst_port);
10641 vec_validate (proto_header, sizeof (h) - 1);
10642 memcpy (proto_header, &h, sizeof (h));
10644 *matchp = proto_header;
10650 unformat_ip4_match (unformat_input_t * input, va_list * args)
10652 u8 **matchp = va_arg (*args, u8 **);
10657 int hdr_length = 0;
10658 u32 hdr_length_val;
10659 int src = 0, dst = 0;
10660 ip4_address_t src_val, dst_val;
10667 int fragment_id = 0;
10668 u32 fragment_id_val;
10674 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10676 if (unformat (input, "version %d", &version_val))
10678 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10680 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10682 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10684 else if (unformat (input, "proto %d", &proto_val))
10686 else if (unformat (input, "tos %d", &tos_val))
10688 else if (unformat (input, "length %d", &length_val))
10690 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10692 else if (unformat (input, "ttl %d", &ttl_val))
10694 else if (unformat (input, "checksum %d", &checksum_val))
10700 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10701 + ttl + checksum == 0)
10705 * Aligned because we use the real comparison functions
10707 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10709 ip = (ip4_header_t *) match;
10711 /* These are realistically matched in practice */
10713 ip->src_address.as_u32 = src_val.as_u32;
10716 ip->dst_address.as_u32 = dst_val.as_u32;
10719 ip->protocol = proto_val;
10722 /* These are not, but they're included for completeness */
10724 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10727 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10733 ip->length = clib_host_to_net_u16 (length_val);
10739 ip->checksum = clib_host_to_net_u16 (checksum_val);
10746 unformat_ip6_match (unformat_input_t * input, va_list * args)
10748 u8 **matchp = va_arg (*args, u8 **);
10753 u8 traffic_class = 0;
10754 u32 traffic_class_val = 0;
10757 int src = 0, dst = 0;
10758 ip6_address_t src_val, dst_val;
10761 int payload_length = 0;
10762 u32 payload_length_val;
10765 u32 ip_version_traffic_class_and_flow_label;
10767 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10769 if (unformat (input, "version %d", &version_val))
10771 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10773 else if (unformat (input, "flow_label %d", &flow_label_val))
10775 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10777 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10779 else if (unformat (input, "proto %d", &proto_val))
10781 else if (unformat (input, "payload_length %d", &payload_length_val))
10782 payload_length = 1;
10783 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10789 if (version + traffic_class + flow_label + src + dst + proto +
10790 payload_length + hop_limit == 0)
10794 * Aligned because we use the real comparison functions
10796 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10798 ip = (ip6_header_t *) match;
10801 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10804 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10807 ip->protocol = proto_val;
10809 ip_version_traffic_class_and_flow_label = 0;
10812 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10815 ip_version_traffic_class_and_flow_label |=
10816 (traffic_class_val & 0xFF) << 20;
10819 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10821 ip->ip_version_traffic_class_and_flow_label =
10822 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10824 if (payload_length)
10825 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10828 ip->hop_limit = hop_limit_val;
10835 unformat_l3_match (unformat_input_t * input, va_list * args)
10837 u8 **matchp = va_arg (*args, u8 **);
10839 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10841 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10843 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10852 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10854 u8 *tagp = va_arg (*args, u8 *);
10857 if (unformat (input, "%d", &tag))
10859 tagp[0] = (tag >> 8) & 0x0F;
10860 tagp[1] = tag & 0xFF;
10868 unformat_l2_match (unformat_input_t * input, va_list * args)
10870 u8 **matchp = va_arg (*args, u8 **);
10883 u8 ignore_tag1 = 0;
10884 u8 ignore_tag2 = 0;
10890 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10892 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10895 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10897 else if (unformat (input, "proto %U",
10898 unformat_ethernet_type_host_byte_order, &proto_val))
10900 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10902 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10904 else if (unformat (input, "ignore-tag1"))
10906 else if (unformat (input, "ignore-tag2"))
10908 else if (unformat (input, "cos1 %d", &cos1_val))
10910 else if (unformat (input, "cos2 %d", &cos2_val))
10915 if ((src + dst + proto + tag1 + tag2 +
10916 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10919 if (tag1 || ignore_tag1 || cos1)
10921 if (tag2 || ignore_tag2 || cos2)
10924 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10927 clib_memcpy (match, dst_val, 6);
10930 clib_memcpy (match + 6, src_val, 6);
10934 /* inner vlan tag */
10935 match[19] = tag2_val[1];
10936 match[18] = tag2_val[0];
10938 match[18] |= (cos2_val & 0x7) << 5;
10941 match[21] = proto_val & 0xff;
10942 match[20] = proto_val >> 8;
10946 match[15] = tag1_val[1];
10947 match[14] = tag1_val[0];
10950 match[14] |= (cos1_val & 0x7) << 5;
10956 match[15] = tag1_val[1];
10957 match[14] = tag1_val[0];
10960 match[17] = proto_val & 0xff;
10961 match[16] = proto_val >> 8;
10964 match[14] |= (cos1_val & 0x7) << 5;
10970 match[18] |= (cos2_val & 0x7) << 5;
10972 match[14] |= (cos1_val & 0x7) << 5;
10975 match[13] = proto_val & 0xff;
10976 match[12] = proto_val >> 8;
10985 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10987 u8 **matchp = va_arg (*args, u8 **);
10988 u32 skip_n_vectors = va_arg (*args, u32);
10989 u32 match_n_vectors = va_arg (*args, u32);
10996 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10998 if (unformat (input, "hex %U", unformat_hex_string, &match))
11000 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11002 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11004 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11018 if (match || l2 || l3 || l4)
11020 if (l2 || l3 || l4)
11022 /* "Win a free Ethernet header in every packet" */
11024 vec_validate_aligned (l2, 13, sizeof (u32x4));
11028 vec_append_aligned (match, l3, sizeof (u32x4));
11033 vec_append_aligned (match, l4, sizeof (u32x4));
11038 /* Make sure the vector is big enough even if key is all 0's */
11039 vec_validate_aligned
11040 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11043 /* Set size, include skipped vectors */
11044 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11055 api_classify_add_del_session (vat_main_t * vam)
11057 unformat_input_t *i = vam->input;
11058 vl_api_classify_add_del_session_t *mp;
11060 u32 table_index = ~0;
11061 u32 hit_next_index = ~0;
11062 u32 opaque_index = ~0;
11065 u32 skip_n_vectors = 0;
11066 u32 match_n_vectors = 0;
11072 * Warning: you have to supply skip_n and match_n
11073 * because the API client cant simply look at the classify
11077 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11079 if (unformat (i, "del"))
11081 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11084 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11087 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11090 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11092 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11094 else if (unformat (i, "opaque-index %d", &opaque_index))
11096 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11098 else if (unformat (i, "match_n %d", &match_n_vectors))
11100 else if (unformat (i, "match %U", api_unformat_classify_match,
11101 &match, skip_n_vectors, match_n_vectors))
11103 else if (unformat (i, "advance %d", &advance))
11105 else if (unformat (i, "table-index %d", &table_index))
11107 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11109 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11111 else if (unformat (i, "action %d", &action))
11113 else if (unformat (i, "metadata %d", &metadata))
11119 if (table_index == ~0)
11121 errmsg ("Table index required");
11125 if (is_add && match == 0)
11127 errmsg ("Match value required");
11131 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11133 mp->is_add = is_add;
11134 mp->table_index = ntohl (table_index);
11135 mp->hit_next_index = ntohl (hit_next_index);
11136 mp->opaque_index = ntohl (opaque_index);
11137 mp->advance = ntohl (advance);
11138 mp->action = action;
11139 mp->metadata = ntohl (metadata);
11140 clib_memcpy (mp->match, match, vec_len (match));
11149 api_classify_set_interface_ip_table (vat_main_t * vam)
11151 unformat_input_t *i = vam->input;
11152 vl_api_classify_set_interface_ip_table_t *mp;
11154 int sw_if_index_set;
11155 u32 table_index = ~0;
11159 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11161 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11162 sw_if_index_set = 1;
11163 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11164 sw_if_index_set = 1;
11165 else if (unformat (i, "table %d", &table_index))
11169 clib_warning ("parse error '%U'", format_unformat_error, i);
11174 if (sw_if_index_set == 0)
11176 errmsg ("missing interface name or sw_if_index");
11181 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11183 mp->sw_if_index = ntohl (sw_if_index);
11184 mp->table_index = ntohl (table_index);
11185 mp->is_ipv6 = is_ipv6;
11193 api_classify_set_interface_l2_tables (vat_main_t * vam)
11195 unformat_input_t *i = vam->input;
11196 vl_api_classify_set_interface_l2_tables_t *mp;
11198 int sw_if_index_set;
11199 u32 ip4_table_index = ~0;
11200 u32 ip6_table_index = ~0;
11201 u32 other_table_index = ~0;
11205 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11207 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11208 sw_if_index_set = 1;
11209 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11210 sw_if_index_set = 1;
11211 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11213 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11215 else if (unformat (i, "other-table %d", &other_table_index))
11217 else if (unformat (i, "is-input %d", &is_input))
11221 clib_warning ("parse error '%U'", format_unformat_error, i);
11226 if (sw_if_index_set == 0)
11228 errmsg ("missing interface name or sw_if_index");
11233 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11235 mp->sw_if_index = ntohl (sw_if_index);
11236 mp->ip4_table_index = ntohl (ip4_table_index);
11237 mp->ip6_table_index = ntohl (ip6_table_index);
11238 mp->other_table_index = ntohl (other_table_index);
11239 mp->is_input = (u8) is_input;
11247 api_set_ipfix_exporter (vat_main_t * vam)
11249 unformat_input_t *i = vam->input;
11250 vl_api_set_ipfix_exporter_t *mp;
11251 ip4_address_t collector_address;
11252 u8 collector_address_set = 0;
11253 u32 collector_port = ~0;
11254 ip4_address_t src_address;
11255 u8 src_address_set = 0;
11258 u32 template_interval = ~0;
11259 u8 udp_checksum = 0;
11262 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11264 if (unformat (i, "collector_address %U", unformat_ip4_address,
11265 &collector_address))
11266 collector_address_set = 1;
11267 else if (unformat (i, "collector_port %d", &collector_port))
11269 else if (unformat (i, "src_address %U", unformat_ip4_address,
11271 src_address_set = 1;
11272 else if (unformat (i, "vrf_id %d", &vrf_id))
11274 else if (unformat (i, "path_mtu %d", &path_mtu))
11276 else if (unformat (i, "template_interval %d", &template_interval))
11278 else if (unformat (i, "udp_checksum"))
11284 if (collector_address_set == 0)
11286 errmsg ("collector_address required");
11290 if (src_address_set == 0)
11292 errmsg ("src_address required");
11296 M (SET_IPFIX_EXPORTER, mp);
11298 memcpy (mp->collector_address, collector_address.data,
11299 sizeof (collector_address.data));
11300 mp->collector_port = htons ((u16) collector_port);
11301 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11302 mp->vrf_id = htonl (vrf_id);
11303 mp->path_mtu = htonl (path_mtu);
11304 mp->template_interval = htonl (template_interval);
11305 mp->udp_checksum = udp_checksum;
11313 api_set_ipfix_classify_stream (vat_main_t * vam)
11315 unformat_input_t *i = vam->input;
11316 vl_api_set_ipfix_classify_stream_t *mp;
11318 u32 src_port = UDP_DST_PORT_ipfix;
11321 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11323 if (unformat (i, "domain %d", &domain_id))
11325 else if (unformat (i, "src_port %d", &src_port))
11329 errmsg ("unknown input `%U'", format_unformat_error, i);
11334 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11336 mp->domain_id = htonl (domain_id);
11337 mp->src_port = htons ((u16) src_port);
11345 api_ipfix_classify_table_add_del (vat_main_t * vam)
11347 unformat_input_t *i = vam->input;
11348 vl_api_ipfix_classify_table_add_del_t *mp;
11350 u32 classify_table_index = ~0;
11352 u8 transport_protocol = 255;
11355 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11357 if (unformat (i, "add"))
11359 else if (unformat (i, "del"))
11361 else if (unformat (i, "table %d", &classify_table_index))
11363 else if (unformat (i, "ip4"))
11365 else if (unformat (i, "ip6"))
11367 else if (unformat (i, "tcp"))
11368 transport_protocol = 6;
11369 else if (unformat (i, "udp"))
11370 transport_protocol = 17;
11373 errmsg ("unknown input `%U'", format_unformat_error, i);
11380 errmsg ("expecting: add|del");
11383 if (classify_table_index == ~0)
11385 errmsg ("classifier table not specified");
11388 if (ip_version == 0)
11390 errmsg ("IP version not specified");
11394 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11396 mp->is_add = is_add;
11397 mp->table_id = htonl (classify_table_index);
11398 mp->ip_version = ip_version;
11399 mp->transport_protocol = transport_protocol;
11407 api_get_node_index (vat_main_t * vam)
11409 unformat_input_t *i = vam->input;
11410 vl_api_get_node_index_t *mp;
11414 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11416 if (unformat (i, "node %s", &name))
11423 errmsg ("node name required");
11426 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11428 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11432 M (GET_NODE_INDEX, mp);
11433 clib_memcpy (mp->node_name, name, vec_len (name));
11442 api_get_next_index (vat_main_t * vam)
11444 unformat_input_t *i = vam->input;
11445 vl_api_get_next_index_t *mp;
11446 u8 *node_name = 0, *next_node_name = 0;
11449 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11451 if (unformat (i, "node-name %s", &node_name))
11453 else if (unformat (i, "next-node-name %s", &next_node_name))
11457 if (node_name == 0)
11459 errmsg ("node name required");
11462 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11464 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11468 if (next_node_name == 0)
11470 errmsg ("next node name required");
11473 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11475 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11479 M (GET_NEXT_INDEX, mp);
11480 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11481 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11482 vec_free (node_name);
11483 vec_free (next_node_name);
11491 api_add_node_next (vat_main_t * vam)
11493 unformat_input_t *i = vam->input;
11494 vl_api_add_node_next_t *mp;
11499 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11501 if (unformat (i, "node %s", &name))
11503 else if (unformat (i, "next %s", &next))
11510 errmsg ("node name required");
11513 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11515 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11520 errmsg ("next node required");
11523 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11525 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11529 M (ADD_NODE_NEXT, mp);
11530 clib_memcpy (mp->node_name, name, vec_len (name));
11531 clib_memcpy (mp->next_name, next, vec_len (next));
11541 api_l2tpv3_create_tunnel (vat_main_t * vam)
11543 unformat_input_t *i = vam->input;
11544 ip6_address_t client_address, our_address;
11545 int client_address_set = 0;
11546 int our_address_set = 0;
11547 u32 local_session_id = 0;
11548 u32 remote_session_id = 0;
11549 u64 local_cookie = 0;
11550 u64 remote_cookie = 0;
11551 u8 l2_sublayer_present = 0;
11552 vl_api_l2tpv3_create_tunnel_t *mp;
11555 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11557 if (unformat (i, "client_address %U", unformat_ip6_address,
11559 client_address_set = 1;
11560 else if (unformat (i, "our_address %U", unformat_ip6_address,
11562 our_address_set = 1;
11563 else if (unformat (i, "local_session_id %d", &local_session_id))
11565 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11567 else if (unformat (i, "local_cookie %lld", &local_cookie))
11569 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11571 else if (unformat (i, "l2-sublayer-present"))
11572 l2_sublayer_present = 1;
11577 if (client_address_set == 0)
11579 errmsg ("client_address required");
11583 if (our_address_set == 0)
11585 errmsg ("our_address required");
11589 M (L2TPV3_CREATE_TUNNEL, mp);
11591 clib_memcpy (mp->client_address, client_address.as_u8,
11592 sizeof (mp->client_address));
11594 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11596 mp->local_session_id = ntohl (local_session_id);
11597 mp->remote_session_id = ntohl (remote_session_id);
11598 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11599 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11600 mp->l2_sublayer_present = l2_sublayer_present;
11609 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11611 unformat_input_t *i = vam->input;
11613 u8 sw_if_index_set = 0;
11614 u64 new_local_cookie = 0;
11615 u64 new_remote_cookie = 0;
11616 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11619 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11621 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11622 sw_if_index_set = 1;
11623 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11624 sw_if_index_set = 1;
11625 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11627 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11633 if (sw_if_index_set == 0)
11635 errmsg ("missing interface name or sw_if_index");
11639 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11641 mp->sw_if_index = ntohl (sw_if_index);
11642 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11643 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11651 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11653 unformat_input_t *i = vam->input;
11654 vl_api_l2tpv3_interface_enable_disable_t *mp;
11656 u8 sw_if_index_set = 0;
11657 u8 enable_disable = 1;
11660 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11662 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11663 sw_if_index_set = 1;
11664 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11665 sw_if_index_set = 1;
11666 else if (unformat (i, "enable"))
11667 enable_disable = 1;
11668 else if (unformat (i, "disable"))
11669 enable_disable = 0;
11674 if (sw_if_index_set == 0)
11676 errmsg ("missing interface name or sw_if_index");
11680 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11682 mp->sw_if_index = ntohl (sw_if_index);
11683 mp->enable_disable = enable_disable;
11691 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11693 unformat_input_t *i = vam->input;
11694 vl_api_l2tpv3_set_lookup_key_t *mp;
11698 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11700 if (unformat (i, "lookup_v6_src"))
11701 key = L2T_LOOKUP_SRC_ADDRESS;
11702 else if (unformat (i, "lookup_v6_dst"))
11703 key = L2T_LOOKUP_DST_ADDRESS;
11704 else if (unformat (i, "lookup_session_id"))
11705 key = L2T_LOOKUP_SESSION_ID;
11710 if (key == (u8) ~ 0)
11712 errmsg ("l2tp session lookup key unset");
11716 M (L2TPV3_SET_LOOKUP_KEY, mp);
11725 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11726 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11728 vat_main_t *vam = &vat_main;
11730 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11731 format_ip6_address, mp->our_address,
11732 format_ip6_address, mp->client_address,
11733 clib_net_to_host_u32 (mp->sw_if_index));
11736 " local cookies %016llx %016llx remote cookie %016llx",
11737 clib_net_to_host_u64 (mp->local_cookie[0]),
11738 clib_net_to_host_u64 (mp->local_cookie[1]),
11739 clib_net_to_host_u64 (mp->remote_cookie));
11741 print (vam->ofp, " local session-id %d remote session-id %d",
11742 clib_net_to_host_u32 (mp->local_session_id),
11743 clib_net_to_host_u32 (mp->remote_session_id));
11745 print (vam->ofp, " l2 specific sublayer %s\n",
11746 mp->l2_sublayer_present ? "preset" : "absent");
11750 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11751 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11753 vat_main_t *vam = &vat_main;
11754 vat_json_node_t *node = NULL;
11755 struct in6_addr addr;
11757 if (VAT_JSON_ARRAY != vam->json_tree.type)
11759 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11760 vat_json_init_array (&vam->json_tree);
11762 node = vat_json_array_add (&vam->json_tree);
11764 vat_json_init_object (node);
11766 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11767 vat_json_object_add_ip6 (node, "our_address", addr);
11768 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11769 vat_json_object_add_ip6 (node, "client_address", addr);
11771 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11772 vat_json_init_array (lc);
11773 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11774 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11775 vat_json_object_add_uint (node, "remote_cookie",
11776 clib_net_to_host_u64 (mp->remote_cookie));
11778 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11779 vat_json_object_add_uint (node, "local_session_id",
11780 clib_net_to_host_u32 (mp->local_session_id));
11781 vat_json_object_add_uint (node, "remote_session_id",
11782 clib_net_to_host_u32 (mp->remote_session_id));
11783 vat_json_object_add_string_copy (node, "l2_sublayer",
11784 mp->l2_sublayer_present ? (u8 *) "present"
11785 : (u8 *) "absent");
11789 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11791 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11792 vl_api_control_ping_t *mp_ping;
11795 /* Get list of l2tpv3-tunnel interfaces */
11796 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11799 /* Use a control ping for synchronization */
11800 MPING (CONTROL_PING, mp_ping);
11808 static void vl_api_sw_interface_tap_details_t_handler
11809 (vl_api_sw_interface_tap_details_t * mp)
11811 vat_main_t *vam = &vat_main;
11813 print (vam->ofp, "%-16s %d",
11814 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
11817 static void vl_api_sw_interface_tap_details_t_handler_json
11818 (vl_api_sw_interface_tap_details_t * mp)
11820 vat_main_t *vam = &vat_main;
11821 vat_json_node_t *node = NULL;
11823 if (VAT_JSON_ARRAY != vam->json_tree.type)
11825 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11826 vat_json_init_array (&vam->json_tree);
11828 node = vat_json_array_add (&vam->json_tree);
11830 vat_json_init_object (node);
11831 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11832 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11836 api_sw_interface_tap_dump (vat_main_t * vam)
11838 vl_api_sw_interface_tap_dump_t *mp;
11839 vl_api_control_ping_t *mp_ping;
11842 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
11843 /* Get list of tap interfaces */
11844 M (SW_INTERFACE_TAP_DUMP, mp);
11847 /* Use a control ping for synchronization */
11848 MPING (CONTROL_PING, mp_ping);
11855 static uword unformat_vxlan_decap_next
11856 (unformat_input_t * input, va_list * args)
11858 u32 *result = va_arg (*args, u32 *);
11861 if (unformat (input, "l2"))
11862 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11863 else if (unformat (input, "%d", &tmp))
11871 api_vxlan_add_del_tunnel (vat_main_t * vam)
11873 unformat_input_t *line_input = vam->input;
11874 vl_api_vxlan_add_del_tunnel_t *mp;
11875 ip46_address_t src, dst;
11877 u8 ipv4_set = 0, ipv6_set = 0;
11881 u32 mcast_sw_if_index = ~0;
11882 u32 encap_vrf_id = 0;
11883 u32 decap_next_index = ~0;
11887 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11888 memset (&src, 0, sizeof src);
11889 memset (&dst, 0, sizeof dst);
11891 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11893 if (unformat (line_input, "del"))
11896 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11902 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11908 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11914 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11919 else if (unformat (line_input, "group %U %U",
11920 unformat_ip4_address, &dst.ip4,
11921 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11923 grp_set = dst_set = 1;
11926 else if (unformat (line_input, "group %U",
11927 unformat_ip4_address, &dst.ip4))
11929 grp_set = dst_set = 1;
11932 else if (unformat (line_input, "group %U %U",
11933 unformat_ip6_address, &dst.ip6,
11934 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11936 grp_set = dst_set = 1;
11939 else if (unformat (line_input, "group %U",
11940 unformat_ip6_address, &dst.ip6))
11942 grp_set = dst_set = 1;
11946 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11948 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11950 else if (unformat (line_input, "decap-next %U",
11951 unformat_vxlan_decap_next, &decap_next_index))
11953 else if (unformat (line_input, "vni %d", &vni))
11957 errmsg ("parse error '%U'", format_unformat_error, line_input);
11964 errmsg ("tunnel src address not specified");
11969 errmsg ("tunnel dst address not specified");
11973 if (grp_set && !ip46_address_is_multicast (&dst))
11975 errmsg ("tunnel group address not multicast");
11978 if (grp_set && mcast_sw_if_index == ~0)
11980 errmsg ("tunnel nonexistent multicast device");
11983 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11985 errmsg ("tunnel dst address must be unicast");
11990 if (ipv4_set && ipv6_set)
11992 errmsg ("both IPv4 and IPv6 addresses specified");
11996 if ((vni == 0) || (vni >> 24))
11998 errmsg ("vni not specified or out of range");
12002 M (VXLAN_ADD_DEL_TUNNEL, mp);
12006 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12007 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12011 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12012 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12014 mp->encap_vrf_id = ntohl (encap_vrf_id);
12015 mp->decap_next_index = ntohl (decap_next_index);
12016 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12017 mp->vni = ntohl (vni);
12018 mp->is_add = is_add;
12019 mp->is_ipv6 = ipv6_set;
12026 static void vl_api_vxlan_tunnel_details_t_handler
12027 (vl_api_vxlan_tunnel_details_t * mp)
12029 vat_main_t *vam = &vat_main;
12030 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12031 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12033 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12034 ntohl (mp->sw_if_index),
12035 format_ip46_address, &src, IP46_TYPE_ANY,
12036 format_ip46_address, &dst, IP46_TYPE_ANY,
12037 ntohl (mp->encap_vrf_id),
12038 ntohl (mp->decap_next_index), ntohl (mp->vni),
12039 ntohl (mp->mcast_sw_if_index));
12042 static void vl_api_vxlan_tunnel_details_t_handler_json
12043 (vl_api_vxlan_tunnel_details_t * mp)
12045 vat_main_t *vam = &vat_main;
12046 vat_json_node_t *node = NULL;
12048 if (VAT_JSON_ARRAY != vam->json_tree.type)
12050 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12051 vat_json_init_array (&vam->json_tree);
12053 node = vat_json_array_add (&vam->json_tree);
12055 vat_json_init_object (node);
12056 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12059 struct in6_addr ip6;
12061 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12062 vat_json_object_add_ip6 (node, "src_address", ip6);
12063 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12064 vat_json_object_add_ip6 (node, "dst_address", ip6);
12068 struct in_addr ip4;
12070 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12071 vat_json_object_add_ip4 (node, "src_address", ip4);
12072 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12073 vat_json_object_add_ip4 (node, "dst_address", ip4);
12075 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12076 vat_json_object_add_uint (node, "decap_next_index",
12077 ntohl (mp->decap_next_index));
12078 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12079 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12080 vat_json_object_add_uint (node, "mcast_sw_if_index",
12081 ntohl (mp->mcast_sw_if_index));
12085 api_vxlan_tunnel_dump (vat_main_t * vam)
12087 unformat_input_t *i = vam->input;
12088 vl_api_vxlan_tunnel_dump_t *mp;
12089 vl_api_control_ping_t *mp_ping;
12091 u8 sw_if_index_set = 0;
12094 /* Parse args required to build the message */
12095 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12097 if (unformat (i, "sw_if_index %d", &sw_if_index))
12098 sw_if_index_set = 1;
12103 if (sw_if_index_set == 0)
12108 if (!vam->json_output)
12110 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12111 "sw_if_index", "src_address", "dst_address",
12112 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12115 /* Get list of vxlan-tunnel interfaces */
12116 M (VXLAN_TUNNEL_DUMP, mp);
12118 mp->sw_if_index = htonl (sw_if_index);
12122 /* Use a control ping for synchronization */
12123 MPING (CONTROL_PING, mp_ping);
12130 static uword unformat_geneve_decap_next
12131 (unformat_input_t * input, va_list * args)
12133 u32 *result = va_arg (*args, u32 *);
12136 if (unformat (input, "l2"))
12137 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12138 else if (unformat (input, "%d", &tmp))
12146 api_geneve_add_del_tunnel (vat_main_t * vam)
12148 unformat_input_t *line_input = vam->input;
12149 vl_api_geneve_add_del_tunnel_t *mp;
12150 ip46_address_t src, dst;
12152 u8 ipv4_set = 0, ipv6_set = 0;
12156 u32 mcast_sw_if_index = ~0;
12157 u32 encap_vrf_id = 0;
12158 u32 decap_next_index = ~0;
12162 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12163 memset (&src, 0, sizeof src);
12164 memset (&dst, 0, sizeof dst);
12166 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12168 if (unformat (line_input, "del"))
12171 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12177 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12183 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12189 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12194 else if (unformat (line_input, "group %U %U",
12195 unformat_ip4_address, &dst.ip4,
12196 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12198 grp_set = dst_set = 1;
12201 else if (unformat (line_input, "group %U",
12202 unformat_ip4_address, &dst.ip4))
12204 grp_set = dst_set = 1;
12207 else if (unformat (line_input, "group %U %U",
12208 unformat_ip6_address, &dst.ip6,
12209 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12211 grp_set = dst_set = 1;
12214 else if (unformat (line_input, "group %U",
12215 unformat_ip6_address, &dst.ip6))
12217 grp_set = dst_set = 1;
12221 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12223 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12225 else if (unformat (line_input, "decap-next %U",
12226 unformat_geneve_decap_next, &decap_next_index))
12228 else if (unformat (line_input, "vni %d", &vni))
12232 errmsg ("parse error '%U'", format_unformat_error, line_input);
12239 errmsg ("tunnel src address not specified");
12244 errmsg ("tunnel dst address not specified");
12248 if (grp_set && !ip46_address_is_multicast (&dst))
12250 errmsg ("tunnel group address not multicast");
12253 if (grp_set && mcast_sw_if_index == ~0)
12255 errmsg ("tunnel nonexistent multicast device");
12258 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12260 errmsg ("tunnel dst address must be unicast");
12265 if (ipv4_set && ipv6_set)
12267 errmsg ("both IPv4 and IPv6 addresses specified");
12271 if ((vni == 0) || (vni >> 24))
12273 errmsg ("vni not specified or out of range");
12277 M (GENEVE_ADD_DEL_TUNNEL, mp);
12281 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12282 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12286 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12287 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12289 mp->encap_vrf_id = ntohl (encap_vrf_id);
12290 mp->decap_next_index = ntohl (decap_next_index);
12291 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12292 mp->vni = ntohl (vni);
12293 mp->is_add = is_add;
12294 mp->is_ipv6 = ipv6_set;
12301 static void vl_api_geneve_tunnel_details_t_handler
12302 (vl_api_geneve_tunnel_details_t * mp)
12304 vat_main_t *vam = &vat_main;
12305 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12306 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12308 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12309 ntohl (mp->sw_if_index),
12310 format_ip46_address, &src, IP46_TYPE_ANY,
12311 format_ip46_address, &dst, IP46_TYPE_ANY,
12312 ntohl (mp->encap_vrf_id),
12313 ntohl (mp->decap_next_index), ntohl (mp->vni),
12314 ntohl (mp->mcast_sw_if_index));
12317 static void vl_api_geneve_tunnel_details_t_handler_json
12318 (vl_api_geneve_tunnel_details_t * mp)
12320 vat_main_t *vam = &vat_main;
12321 vat_json_node_t *node = NULL;
12323 if (VAT_JSON_ARRAY != vam->json_tree.type)
12325 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12326 vat_json_init_array (&vam->json_tree);
12328 node = vat_json_array_add (&vam->json_tree);
12330 vat_json_init_object (node);
12331 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12334 struct in6_addr ip6;
12336 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12337 vat_json_object_add_ip6 (node, "src_address", ip6);
12338 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12339 vat_json_object_add_ip6 (node, "dst_address", ip6);
12343 struct in_addr ip4;
12345 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12346 vat_json_object_add_ip4 (node, "src_address", ip4);
12347 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12348 vat_json_object_add_ip4 (node, "dst_address", ip4);
12350 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12351 vat_json_object_add_uint (node, "decap_next_index",
12352 ntohl (mp->decap_next_index));
12353 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12354 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12355 vat_json_object_add_uint (node, "mcast_sw_if_index",
12356 ntohl (mp->mcast_sw_if_index));
12360 api_geneve_tunnel_dump (vat_main_t * vam)
12362 unformat_input_t *i = vam->input;
12363 vl_api_geneve_tunnel_dump_t *mp;
12364 vl_api_control_ping_t *mp_ping;
12366 u8 sw_if_index_set = 0;
12369 /* Parse args required to build the message */
12370 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12372 if (unformat (i, "sw_if_index %d", &sw_if_index))
12373 sw_if_index_set = 1;
12378 if (sw_if_index_set == 0)
12383 if (!vam->json_output)
12385 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12386 "sw_if_index", "local_address", "remote_address",
12387 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12390 /* Get list of geneve-tunnel interfaces */
12391 M (GENEVE_TUNNEL_DUMP, mp);
12393 mp->sw_if_index = htonl (sw_if_index);
12397 /* Use a control ping for synchronization */
12398 M (CONTROL_PING, mp_ping);
12406 api_gre_add_del_tunnel (vat_main_t * vam)
12408 unformat_input_t *line_input = vam->input;
12409 vl_api_gre_add_del_tunnel_t *mp;
12410 ip4_address_t src4, dst4;
12411 ip6_address_t src6, dst6;
12418 u32 outer_fib_id = 0;
12421 memset (&src4, 0, sizeof src4);
12422 memset (&dst4, 0, sizeof dst4);
12423 memset (&src6, 0, sizeof src6);
12424 memset (&dst6, 0, sizeof dst6);
12426 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12428 if (unformat (line_input, "del"))
12430 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
12435 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
12440 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
12445 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
12450 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12452 else if (unformat (line_input, "teb"))
12456 errmsg ("parse error '%U'", format_unformat_error, line_input);
12463 errmsg ("tunnel src address not specified");
12468 errmsg ("tunnel dst address not specified");
12471 if (ipv4_set && ipv6_set)
12473 errmsg ("both IPv4 and IPv6 addresses specified");
12478 M (GRE_ADD_DEL_TUNNEL, mp);
12482 clib_memcpy (&mp->src_address, &src4, 4);
12483 clib_memcpy (&mp->dst_address, &dst4, 4);
12487 clib_memcpy (&mp->src_address, &src6, 16);
12488 clib_memcpy (&mp->dst_address, &dst6, 16);
12490 mp->outer_fib_id = ntohl (outer_fib_id);
12491 mp->is_add = is_add;
12493 mp->is_ipv6 = ipv6_set;
12500 static void vl_api_gre_tunnel_details_t_handler
12501 (vl_api_gre_tunnel_details_t * mp)
12503 vat_main_t *vam = &vat_main;
12504 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
12505 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
12507 print (vam->ofp, "%11d%24U%24U%6d%14d",
12508 ntohl (mp->sw_if_index),
12509 format_ip46_address, &src, IP46_TYPE_ANY,
12510 format_ip46_address, &dst, IP46_TYPE_ANY,
12511 mp->teb, ntohl (mp->outer_fib_id));
12514 static void vl_api_gre_tunnel_details_t_handler_json
12515 (vl_api_gre_tunnel_details_t * mp)
12517 vat_main_t *vam = &vat_main;
12518 vat_json_node_t *node = NULL;
12519 struct in_addr ip4;
12520 struct in6_addr ip6;
12522 if (VAT_JSON_ARRAY != vam->json_tree.type)
12524 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12525 vat_json_init_array (&vam->json_tree);
12527 node = vat_json_array_add (&vam->json_tree);
12529 vat_json_init_object (node);
12530 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12533 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
12534 vat_json_object_add_ip4 (node, "src_address", ip4);
12535 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
12536 vat_json_object_add_ip4 (node, "dst_address", ip4);
12540 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
12541 vat_json_object_add_ip6 (node, "src_address", ip6);
12542 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
12543 vat_json_object_add_ip6 (node, "dst_address", ip6);
12545 vat_json_object_add_uint (node, "teb", mp->teb);
12546 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
12547 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
12551 api_gre_tunnel_dump (vat_main_t * vam)
12553 unformat_input_t *i = vam->input;
12554 vl_api_gre_tunnel_dump_t *mp;
12555 vl_api_control_ping_t *mp_ping;
12557 u8 sw_if_index_set = 0;
12560 /* Parse args required to build the message */
12561 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12563 if (unformat (i, "sw_if_index %d", &sw_if_index))
12564 sw_if_index_set = 1;
12569 if (sw_if_index_set == 0)
12574 if (!vam->json_output)
12576 print (vam->ofp, "%11s%24s%24s%6s%14s",
12577 "sw_if_index", "src_address", "dst_address", "teb",
12581 /* Get list of gre-tunnel interfaces */
12582 M (GRE_TUNNEL_DUMP, mp);
12584 mp->sw_if_index = htonl (sw_if_index);
12588 /* Use a control ping for synchronization */
12589 MPING (CONTROL_PING, mp_ping);
12597 api_l2_fib_clear_table (vat_main_t * vam)
12599 // unformat_input_t * i = vam->input;
12600 vl_api_l2_fib_clear_table_t *mp;
12603 M (L2_FIB_CLEAR_TABLE, mp);
12611 api_l2_interface_efp_filter (vat_main_t * vam)
12613 unformat_input_t *i = vam->input;
12614 vl_api_l2_interface_efp_filter_t *mp;
12617 u8 sw_if_index_set = 0;
12620 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12622 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12623 sw_if_index_set = 1;
12624 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12625 sw_if_index_set = 1;
12626 else if (unformat (i, "enable"))
12628 else if (unformat (i, "disable"))
12632 clib_warning ("parse error '%U'", format_unformat_error, i);
12637 if (sw_if_index_set == 0)
12639 errmsg ("missing sw_if_index");
12643 M (L2_INTERFACE_EFP_FILTER, mp);
12645 mp->sw_if_index = ntohl (sw_if_index);
12646 mp->enable_disable = enable;
12653 #define foreach_vtr_op \
12654 _("disable", L2_VTR_DISABLED) \
12655 _("push-1", L2_VTR_PUSH_1) \
12656 _("push-2", L2_VTR_PUSH_2) \
12657 _("pop-1", L2_VTR_POP_1) \
12658 _("pop-2", L2_VTR_POP_2) \
12659 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12660 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12661 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12662 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12665 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12667 unformat_input_t *i = vam->input;
12668 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12670 u8 sw_if_index_set = 0;
12673 u32 push_dot1q = 1;
12678 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12680 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12681 sw_if_index_set = 1;
12682 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12683 sw_if_index_set = 1;
12684 else if (unformat (i, "vtr_op %d", &vtr_op))
12686 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12689 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12691 else if (unformat (i, "tag1 %d", &tag1))
12693 else if (unformat (i, "tag2 %d", &tag2))
12697 clib_warning ("parse error '%U'", format_unformat_error, i);
12702 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12704 errmsg ("missing vtr operation or sw_if_index");
12708 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12709 mp->sw_if_index = ntohl (sw_if_index);
12710 mp->vtr_op = ntohl (vtr_op);
12711 mp->push_dot1q = ntohl (push_dot1q);
12712 mp->tag1 = ntohl (tag1);
12713 mp->tag2 = ntohl (tag2);
12721 api_create_vhost_user_if (vat_main_t * vam)
12723 unformat_input_t *i = vam->input;
12724 vl_api_create_vhost_user_if_t *mp;
12727 u8 file_name_set = 0;
12728 u32 custom_dev_instance = ~0;
12730 u8 use_custom_mac = 0;
12734 /* Shut up coverity */
12735 memset (hwaddr, 0, sizeof (hwaddr));
12737 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12739 if (unformat (i, "socket %s", &file_name))
12743 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12745 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12746 use_custom_mac = 1;
12747 else if (unformat (i, "server"))
12749 else if (unformat (i, "tag %s", &tag))
12755 if (file_name_set == 0)
12757 errmsg ("missing socket file name");
12761 if (vec_len (file_name) > 255)
12763 errmsg ("socket file name too long");
12766 vec_add1 (file_name, 0);
12768 M (CREATE_VHOST_USER_IF, mp);
12770 mp->is_server = is_server;
12771 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12772 vec_free (file_name);
12773 if (custom_dev_instance != ~0)
12776 mp->custom_dev_instance = ntohl (custom_dev_instance);
12778 mp->use_custom_mac = use_custom_mac;
12779 clib_memcpy (mp->mac_address, hwaddr, 6);
12781 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12790 api_modify_vhost_user_if (vat_main_t * vam)
12792 unformat_input_t *i = vam->input;
12793 vl_api_modify_vhost_user_if_t *mp;
12796 u8 file_name_set = 0;
12797 u32 custom_dev_instance = ~0;
12798 u8 sw_if_index_set = 0;
12799 u32 sw_if_index = (u32) ~ 0;
12802 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12804 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12805 sw_if_index_set = 1;
12806 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12807 sw_if_index_set = 1;
12808 else if (unformat (i, "socket %s", &file_name))
12812 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12814 else if (unformat (i, "server"))
12820 if (sw_if_index_set == 0)
12822 errmsg ("missing sw_if_index or interface name");
12826 if (file_name_set == 0)
12828 errmsg ("missing socket file name");
12832 if (vec_len (file_name) > 255)
12834 errmsg ("socket file name too long");
12837 vec_add1 (file_name, 0);
12839 M (MODIFY_VHOST_USER_IF, mp);
12841 mp->sw_if_index = ntohl (sw_if_index);
12842 mp->is_server = is_server;
12843 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12844 vec_free (file_name);
12845 if (custom_dev_instance != ~0)
12848 mp->custom_dev_instance = ntohl (custom_dev_instance);
12857 api_delete_vhost_user_if (vat_main_t * vam)
12859 unformat_input_t *i = vam->input;
12860 vl_api_delete_vhost_user_if_t *mp;
12861 u32 sw_if_index = ~0;
12862 u8 sw_if_index_set = 0;
12865 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12867 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12868 sw_if_index_set = 1;
12869 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12870 sw_if_index_set = 1;
12875 if (sw_if_index_set == 0)
12877 errmsg ("missing sw_if_index or interface name");
12882 M (DELETE_VHOST_USER_IF, mp);
12884 mp->sw_if_index = ntohl (sw_if_index);
12891 static void vl_api_sw_interface_vhost_user_details_t_handler
12892 (vl_api_sw_interface_vhost_user_details_t * mp)
12894 vat_main_t *vam = &vat_main;
12896 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12897 (char *) mp->interface_name,
12898 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12899 clib_net_to_host_u64 (mp->features), mp->is_server,
12900 ntohl (mp->num_regions), (char *) mp->sock_filename);
12901 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12904 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12905 (vl_api_sw_interface_vhost_user_details_t * mp)
12907 vat_main_t *vam = &vat_main;
12908 vat_json_node_t *node = NULL;
12910 if (VAT_JSON_ARRAY != vam->json_tree.type)
12912 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12913 vat_json_init_array (&vam->json_tree);
12915 node = vat_json_array_add (&vam->json_tree);
12917 vat_json_init_object (node);
12918 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12919 vat_json_object_add_string_copy (node, "interface_name",
12920 mp->interface_name);
12921 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12922 ntohl (mp->virtio_net_hdr_sz));
12923 vat_json_object_add_uint (node, "features",
12924 clib_net_to_host_u64 (mp->features));
12925 vat_json_object_add_uint (node, "is_server", mp->is_server);
12926 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12927 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12928 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12932 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12934 vl_api_sw_interface_vhost_user_dump_t *mp;
12935 vl_api_control_ping_t *mp_ping;
12938 "Interface name idx hdr_sz features server regions filename");
12940 /* Get list of vhost-user interfaces */
12941 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12944 /* Use a control ping for synchronization */
12945 MPING (CONTROL_PING, mp_ping);
12953 api_show_version (vat_main_t * vam)
12955 vl_api_show_version_t *mp;
12958 M (SHOW_VERSION, mp);
12967 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12969 unformat_input_t *line_input = vam->input;
12970 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12971 ip4_address_t local4, remote4;
12972 ip6_address_t local6, remote6;
12974 u8 ipv4_set = 0, ipv6_set = 0;
12978 u32 mcast_sw_if_index = ~0;
12979 u32 encap_vrf_id = 0;
12980 u32 decap_vrf_id = 0;
12986 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12987 memset (&local4, 0, sizeof local4);
12988 memset (&remote4, 0, sizeof remote4);
12989 memset (&local6, 0, sizeof local6);
12990 memset (&remote6, 0, sizeof remote6);
12992 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12994 if (unformat (line_input, "del"))
12996 else if (unformat (line_input, "local %U",
12997 unformat_ip4_address, &local4))
13002 else if (unformat (line_input, "remote %U",
13003 unformat_ip4_address, &remote4))
13008 else if (unformat (line_input, "local %U",
13009 unformat_ip6_address, &local6))
13014 else if (unformat (line_input, "remote %U",
13015 unformat_ip6_address, &remote6))
13020 else if (unformat (line_input, "group %U %U",
13021 unformat_ip4_address, &remote4,
13022 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13024 grp_set = remote_set = 1;
13027 else if (unformat (line_input, "group %U",
13028 unformat_ip4_address, &remote4))
13030 grp_set = remote_set = 1;
13033 else if (unformat (line_input, "group %U %U",
13034 unformat_ip6_address, &remote6,
13035 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13037 grp_set = remote_set = 1;
13040 else if (unformat (line_input, "group %U",
13041 unformat_ip6_address, &remote6))
13043 grp_set = remote_set = 1;
13047 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13049 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13051 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13053 else if (unformat (line_input, "vni %d", &vni))
13055 else if (unformat (line_input, "next-ip4"))
13057 else if (unformat (line_input, "next-ip6"))
13059 else if (unformat (line_input, "next-ethernet"))
13061 else if (unformat (line_input, "next-nsh"))
13065 errmsg ("parse error '%U'", format_unformat_error, line_input);
13070 if (local_set == 0)
13072 errmsg ("tunnel local address not specified");
13075 if (remote_set == 0)
13077 errmsg ("tunnel remote address not specified");
13080 if (grp_set && mcast_sw_if_index == ~0)
13082 errmsg ("tunnel nonexistent multicast device");
13085 if (ipv4_set && ipv6_set)
13087 errmsg ("both IPv4 and IPv6 addresses specified");
13093 errmsg ("vni not specified");
13097 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13102 clib_memcpy (&mp->local, &local6, sizeof (local6));
13103 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13107 clib_memcpy (&mp->local, &local4, sizeof (local4));
13108 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13111 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13112 mp->encap_vrf_id = ntohl (encap_vrf_id);
13113 mp->decap_vrf_id = ntohl (decap_vrf_id);
13114 mp->protocol = protocol;
13115 mp->vni = ntohl (vni);
13116 mp->is_add = is_add;
13117 mp->is_ipv6 = ipv6_set;
13124 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13125 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13127 vat_main_t *vam = &vat_main;
13128 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13129 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13131 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13132 ntohl (mp->sw_if_index),
13133 format_ip46_address, &local, IP46_TYPE_ANY,
13134 format_ip46_address, &remote, IP46_TYPE_ANY,
13135 ntohl (mp->vni), mp->protocol,
13136 ntohl (mp->mcast_sw_if_index),
13137 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13141 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13142 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13144 vat_main_t *vam = &vat_main;
13145 vat_json_node_t *node = NULL;
13146 struct in_addr ip4;
13147 struct in6_addr ip6;
13149 if (VAT_JSON_ARRAY != vam->json_tree.type)
13151 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13152 vat_json_init_array (&vam->json_tree);
13154 node = vat_json_array_add (&vam->json_tree);
13156 vat_json_init_object (node);
13157 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13160 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13161 vat_json_object_add_ip6 (node, "local", ip6);
13162 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13163 vat_json_object_add_ip6 (node, "remote", ip6);
13167 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13168 vat_json_object_add_ip4 (node, "local", ip4);
13169 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13170 vat_json_object_add_ip4 (node, "remote", ip4);
13172 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13173 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13174 vat_json_object_add_uint (node, "mcast_sw_if_index",
13175 ntohl (mp->mcast_sw_if_index));
13176 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13177 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13178 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13182 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13184 unformat_input_t *i = vam->input;
13185 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13186 vl_api_control_ping_t *mp_ping;
13188 u8 sw_if_index_set = 0;
13191 /* Parse args required to build the message */
13192 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13194 if (unformat (i, "sw_if_index %d", &sw_if_index))
13195 sw_if_index_set = 1;
13200 if (sw_if_index_set == 0)
13205 if (!vam->json_output)
13207 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13208 "sw_if_index", "local", "remote", "vni",
13209 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13212 /* Get list of vxlan-tunnel interfaces */
13213 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13215 mp->sw_if_index = htonl (sw_if_index);
13219 /* Use a control ping for synchronization */
13220 MPING (CONTROL_PING, mp_ping);
13229 format_l2_fib_mac_address (u8 * s, va_list * args)
13231 u8 *a = va_arg (*args, u8 *);
13233 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
13234 a[2], a[3], a[4], a[5], a[6], a[7]);
13237 static void vl_api_l2_fib_table_details_t_handler
13238 (vl_api_l2_fib_table_details_t * mp)
13240 vat_main_t *vam = &vat_main;
13242 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13244 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
13245 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13249 static void vl_api_l2_fib_table_details_t_handler_json
13250 (vl_api_l2_fib_table_details_t * mp)
13252 vat_main_t *vam = &vat_main;
13253 vat_json_node_t *node = NULL;
13255 if (VAT_JSON_ARRAY != vam->json_tree.type)
13257 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13258 vat_json_init_array (&vam->json_tree);
13260 node = vat_json_array_add (&vam->json_tree);
13262 vat_json_init_object (node);
13263 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13264 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
13265 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13266 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13267 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13268 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13272 api_l2_fib_table_dump (vat_main_t * vam)
13274 unformat_input_t *i = vam->input;
13275 vl_api_l2_fib_table_dump_t *mp;
13276 vl_api_control_ping_t *mp_ping;
13281 /* Parse args required to build the message */
13282 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13284 if (unformat (i, "bd_id %d", &bd_id))
13290 if (bd_id_set == 0)
13292 errmsg ("missing bridge domain");
13296 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13298 /* Get list of l2 fib entries */
13299 M (L2_FIB_TABLE_DUMP, mp);
13301 mp->bd_id = ntohl (bd_id);
13304 /* Use a control ping for synchronization */
13305 MPING (CONTROL_PING, mp_ping);
13314 api_interface_name_renumber (vat_main_t * vam)
13316 unformat_input_t *line_input = vam->input;
13317 vl_api_interface_name_renumber_t *mp;
13318 u32 sw_if_index = ~0;
13319 u32 new_show_dev_instance = ~0;
13322 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13324 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13327 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13329 else if (unformat (line_input, "new_show_dev_instance %d",
13330 &new_show_dev_instance))
13336 if (sw_if_index == ~0)
13338 errmsg ("missing interface name or sw_if_index");
13342 if (new_show_dev_instance == ~0)
13344 errmsg ("missing new_show_dev_instance");
13348 M (INTERFACE_NAME_RENUMBER, mp);
13350 mp->sw_if_index = ntohl (sw_if_index);
13351 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13359 api_want_ip4_arp_events (vat_main_t * vam)
13361 unformat_input_t *line_input = vam->input;
13362 vl_api_want_ip4_arp_events_t *mp;
13363 ip4_address_t address;
13364 int address_set = 0;
13365 u32 enable_disable = 1;
13368 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13370 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
13372 else if (unformat (line_input, "del"))
13373 enable_disable = 0;
13378 if (address_set == 0)
13380 errmsg ("missing addresses");
13384 M (WANT_IP4_ARP_EVENTS, mp);
13385 mp->enable_disable = enable_disable;
13386 mp->pid = htonl (getpid ());
13387 mp->address = address.as_u32;
13395 api_want_ip6_nd_events (vat_main_t * vam)
13397 unformat_input_t *line_input = vam->input;
13398 vl_api_want_ip6_nd_events_t *mp;
13399 ip6_address_t address;
13400 int address_set = 0;
13401 u32 enable_disable = 1;
13404 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13406 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
13408 else if (unformat (line_input, "del"))
13409 enable_disable = 0;
13414 if (address_set == 0)
13416 errmsg ("missing addresses");
13420 M (WANT_IP6_ND_EVENTS, mp);
13421 mp->enable_disable = enable_disable;
13422 mp->pid = htonl (getpid ());
13423 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
13431 api_want_l2_macs_events (vat_main_t * vam)
13433 unformat_input_t *line_input = vam->input;
13434 vl_api_want_l2_macs_events_t *mp;
13435 u8 enable_disable = 1;
13436 u32 scan_delay = 0;
13437 u32 max_macs_in_event = 0;
13438 u32 learn_limit = 0;
13441 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13443 if (unformat (line_input, "learn-limit %d", &learn_limit))
13445 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13447 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13449 else if (unformat (line_input, "disable"))
13450 enable_disable = 0;
13455 M (WANT_L2_MACS_EVENTS, mp);
13456 mp->enable_disable = enable_disable;
13457 mp->pid = htonl (getpid ());
13458 mp->learn_limit = htonl (learn_limit);
13459 mp->scan_delay = (u8) scan_delay;
13460 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13467 api_input_acl_set_interface (vat_main_t * vam)
13469 unformat_input_t *i = vam->input;
13470 vl_api_input_acl_set_interface_t *mp;
13472 int sw_if_index_set;
13473 u32 ip4_table_index = ~0;
13474 u32 ip6_table_index = ~0;
13475 u32 l2_table_index = ~0;
13479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13481 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13482 sw_if_index_set = 1;
13483 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13484 sw_if_index_set = 1;
13485 else if (unformat (i, "del"))
13487 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13489 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13491 else if (unformat (i, "l2-table %d", &l2_table_index))
13495 clib_warning ("parse error '%U'", format_unformat_error, i);
13500 if (sw_if_index_set == 0)
13502 errmsg ("missing interface name or sw_if_index");
13506 M (INPUT_ACL_SET_INTERFACE, mp);
13508 mp->sw_if_index = ntohl (sw_if_index);
13509 mp->ip4_table_index = ntohl (ip4_table_index);
13510 mp->ip6_table_index = ntohl (ip6_table_index);
13511 mp->l2_table_index = ntohl (l2_table_index);
13512 mp->is_add = is_add;
13520 api_ip_address_dump (vat_main_t * vam)
13522 unformat_input_t *i = vam->input;
13523 vl_api_ip_address_dump_t *mp;
13524 vl_api_control_ping_t *mp_ping;
13525 u32 sw_if_index = ~0;
13526 u8 sw_if_index_set = 0;
13531 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13533 if (unformat (i, "sw_if_index %d", &sw_if_index))
13534 sw_if_index_set = 1;
13536 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13537 sw_if_index_set = 1;
13538 else if (unformat (i, "ipv4"))
13540 else if (unformat (i, "ipv6"))
13546 if (ipv4_set && ipv6_set)
13548 errmsg ("ipv4 and ipv6 flags cannot be both set");
13552 if ((!ipv4_set) && (!ipv6_set))
13554 errmsg ("no ipv4 nor ipv6 flag set");
13558 if (sw_if_index_set == 0)
13560 errmsg ("missing interface name or sw_if_index");
13564 vam->current_sw_if_index = sw_if_index;
13565 vam->is_ipv6 = ipv6_set;
13567 M (IP_ADDRESS_DUMP, mp);
13568 mp->sw_if_index = ntohl (sw_if_index);
13569 mp->is_ipv6 = ipv6_set;
13572 /* Use a control ping for synchronization */
13573 MPING (CONTROL_PING, mp_ping);
13581 api_ip_dump (vat_main_t * vam)
13583 vl_api_ip_dump_t *mp;
13584 vl_api_control_ping_t *mp_ping;
13585 unformat_input_t *in = vam->input;
13592 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13594 if (unformat (in, "ipv4"))
13596 else if (unformat (in, "ipv6"))
13602 if (ipv4_set && ipv6_set)
13604 errmsg ("ipv4 and ipv6 flags cannot be both set");
13608 if ((!ipv4_set) && (!ipv6_set))
13610 errmsg ("no ipv4 nor ipv6 flag set");
13614 is_ipv6 = ipv6_set;
13615 vam->is_ipv6 = is_ipv6;
13617 /* free old data */
13618 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13620 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13622 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13625 mp->is_ipv6 = ipv6_set;
13628 /* Use a control ping for synchronization */
13629 MPING (CONTROL_PING, mp_ping);
13637 api_ipsec_spd_add_del (vat_main_t * vam)
13639 unformat_input_t *i = vam->input;
13640 vl_api_ipsec_spd_add_del_t *mp;
13645 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13647 if (unformat (i, "spd_id %d", &spd_id))
13649 else if (unformat (i, "del"))
13653 clib_warning ("parse error '%U'", format_unformat_error, i);
13659 errmsg ("spd_id must be set");
13663 M (IPSEC_SPD_ADD_DEL, mp);
13665 mp->spd_id = ntohl (spd_id);
13666 mp->is_add = is_add;
13674 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13676 unformat_input_t *i = vam->input;
13677 vl_api_ipsec_interface_add_del_spd_t *mp;
13679 u8 sw_if_index_set = 0;
13680 u32 spd_id = (u32) ~ 0;
13684 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13686 if (unformat (i, "del"))
13688 else if (unformat (i, "spd_id %d", &spd_id))
13691 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13692 sw_if_index_set = 1;
13693 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13694 sw_if_index_set = 1;
13697 clib_warning ("parse error '%U'", format_unformat_error, i);
13703 if (spd_id == (u32) ~ 0)
13705 errmsg ("spd_id must be set");
13709 if (sw_if_index_set == 0)
13711 errmsg ("missing interface name or sw_if_index");
13715 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13717 mp->spd_id = ntohl (spd_id);
13718 mp->sw_if_index = ntohl (sw_if_index);
13719 mp->is_add = is_add;
13727 api_ipsec_spd_add_del_entry (vat_main_t * vam)
13729 unformat_input_t *i = vam->input;
13730 vl_api_ipsec_spd_add_del_entry_t *mp;
13731 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
13732 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13734 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13735 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13736 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
13737 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
13740 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
13741 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
13742 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
13743 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
13744 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
13745 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
13747 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13749 if (unformat (i, "del"))
13751 if (unformat (i, "outbound"))
13753 if (unformat (i, "inbound"))
13755 else if (unformat (i, "spd_id %d", &spd_id))
13757 else if (unformat (i, "sa_id %d", &sa_id))
13759 else if (unformat (i, "priority %d", &priority))
13761 else if (unformat (i, "protocol %d", &protocol))
13763 else if (unformat (i, "lport_start %d", &lport_start))
13765 else if (unformat (i, "lport_stop %d", &lport_stop))
13767 else if (unformat (i, "rport_start %d", &rport_start))
13769 else if (unformat (i, "rport_stop %d", &rport_stop))
13773 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
13779 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
13786 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
13792 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
13799 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
13805 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
13812 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
13818 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
13824 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13826 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13828 clib_warning ("unsupported action: 'resolve'");
13834 clib_warning ("parse error '%U'", format_unformat_error, i);
13840 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
13842 mp->spd_id = ntohl (spd_id);
13843 mp->priority = ntohl (priority);
13844 mp->is_outbound = is_outbound;
13846 mp->is_ipv6 = is_ipv6;
13847 if (is_ipv6 || is_ip_any)
13849 clib_memcpy (mp->remote_address_start, &raddr6_start,
13850 sizeof (ip6_address_t));
13851 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
13852 sizeof (ip6_address_t));
13853 clib_memcpy (mp->local_address_start, &laddr6_start,
13854 sizeof (ip6_address_t));
13855 clib_memcpy (mp->local_address_stop, &laddr6_stop,
13856 sizeof (ip6_address_t));
13860 clib_memcpy (mp->remote_address_start, &raddr4_start,
13861 sizeof (ip4_address_t));
13862 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
13863 sizeof (ip4_address_t));
13864 clib_memcpy (mp->local_address_start, &laddr4_start,
13865 sizeof (ip4_address_t));
13866 clib_memcpy (mp->local_address_stop, &laddr4_stop,
13867 sizeof (ip4_address_t));
13869 mp->protocol = (u8) protocol;
13870 mp->local_port_start = ntohs ((u16) lport_start);
13871 mp->local_port_stop = ntohs ((u16) lport_stop);
13872 mp->remote_port_start = ntohs ((u16) rport_start);
13873 mp->remote_port_stop = ntohs ((u16) rport_stop);
13874 mp->policy = (u8) policy;
13875 mp->sa_id = ntohl (sa_id);
13876 mp->is_add = is_add;
13877 mp->is_ip_any = is_ip_any;
13884 api_ipsec_sad_add_del_entry (vat_main_t * vam)
13886 unformat_input_t *i = vam->input;
13887 vl_api_ipsec_sad_add_del_entry_t *mp;
13888 u32 sad_id = 0, spi = 0;
13889 u8 *ck = 0, *ik = 0;
13892 u8 protocol = IPSEC_PROTOCOL_AH;
13893 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
13894 u32 crypto_alg = 0, integ_alg = 0;
13895 ip4_address_t tun_src4;
13896 ip4_address_t tun_dst4;
13897 ip6_address_t tun_src6;
13898 ip6_address_t tun_dst6;
13901 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13903 if (unformat (i, "del"))
13905 else if (unformat (i, "sad_id %d", &sad_id))
13907 else if (unformat (i, "spi %d", &spi))
13909 else if (unformat (i, "esp"))
13910 protocol = IPSEC_PROTOCOL_ESP;
13911 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
13914 is_tunnel_ipv6 = 0;
13916 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
13919 is_tunnel_ipv6 = 0;
13921 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
13924 is_tunnel_ipv6 = 1;
13926 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
13929 is_tunnel_ipv6 = 1;
13933 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13935 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13936 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13938 clib_warning ("unsupported crypto-alg: '%U'",
13939 format_ipsec_crypto_alg, crypto_alg);
13943 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13947 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13949 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13950 integ_alg >= IPSEC_INTEG_N_ALG)
13952 clib_warning ("unsupported integ-alg: '%U'",
13953 format_ipsec_integ_alg, integ_alg);
13957 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13961 clib_warning ("parse error '%U'", format_unformat_error, i);
13967 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
13969 mp->sad_id = ntohl (sad_id);
13970 mp->is_add = is_add;
13971 mp->protocol = protocol;
13972 mp->spi = ntohl (spi);
13973 mp->is_tunnel = is_tunnel;
13974 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
13975 mp->crypto_algorithm = crypto_alg;
13976 mp->integrity_algorithm = integ_alg;
13977 mp->crypto_key_length = vec_len (ck);
13978 mp->integrity_key_length = vec_len (ik);
13980 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13981 mp->crypto_key_length = sizeof (mp->crypto_key);
13983 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13984 mp->integrity_key_length = sizeof (mp->integrity_key);
13987 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13989 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13993 if (is_tunnel_ipv6)
13995 clib_memcpy (mp->tunnel_src_address, &tun_src6,
13996 sizeof (ip6_address_t));
13997 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
13998 sizeof (ip6_address_t));
14002 clib_memcpy (mp->tunnel_src_address, &tun_src4,
14003 sizeof (ip4_address_t));
14004 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
14005 sizeof (ip4_address_t));
14015 api_ipsec_sa_set_key (vat_main_t * vam)
14017 unformat_input_t *i = vam->input;
14018 vl_api_ipsec_sa_set_key_t *mp;
14020 u8 *ck = 0, *ik = 0;
14023 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14025 if (unformat (i, "sa_id %d", &sa_id))
14027 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14029 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14033 clib_warning ("parse error '%U'", format_unformat_error, i);
14038 M (IPSEC_SA_SET_KEY, mp);
14040 mp->sa_id = ntohl (sa_id);
14041 mp->crypto_key_length = vec_len (ck);
14042 mp->integrity_key_length = vec_len (ik);
14044 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14045 mp->crypto_key_length = sizeof (mp->crypto_key);
14047 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14048 mp->integrity_key_length = sizeof (mp->integrity_key);
14051 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14053 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14061 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14063 unformat_input_t *i = vam->input;
14064 vl_api_ipsec_tunnel_if_add_del_t *mp;
14065 u32 local_spi = 0, remote_spi = 0;
14066 u32 crypto_alg = 0, integ_alg = 0;
14067 u8 *lck = NULL, *rck = NULL;
14068 u8 *lik = NULL, *rik = NULL;
14069 ip4_address_t local_ip = { {0} };
14070 ip4_address_t remote_ip = { {0} };
14073 u8 anti_replay = 0;
14076 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14078 if (unformat (i, "del"))
14080 else if (unformat (i, "esn"))
14082 else if (unformat (i, "anti_replay"))
14084 else if (unformat (i, "local_spi %d", &local_spi))
14086 else if (unformat (i, "remote_spi %d", &remote_spi))
14088 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
14090 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
14092 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14095 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14097 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14099 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14103 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14105 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14106 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14108 errmsg ("unsupported crypto-alg: '%U'\n",
14109 format_ipsec_crypto_alg, crypto_alg);
14115 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14117 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14118 integ_alg >= IPSEC_INTEG_N_ALG)
14120 errmsg ("unsupported integ-alg: '%U'\n",
14121 format_ipsec_integ_alg, integ_alg);
14127 errmsg ("parse error '%U'\n", format_unformat_error, i);
14132 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14134 mp->is_add = is_add;
14136 mp->anti_replay = anti_replay;
14138 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
14139 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
14141 mp->local_spi = htonl (local_spi);
14142 mp->remote_spi = htonl (remote_spi);
14143 mp->crypto_alg = (u8) crypto_alg;
14145 mp->local_crypto_key_len = 0;
14148 mp->local_crypto_key_len = vec_len (lck);
14149 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14150 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14151 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14154 mp->remote_crypto_key_len = 0;
14157 mp->remote_crypto_key_len = vec_len (rck);
14158 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14159 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14160 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14163 mp->integ_alg = (u8) integ_alg;
14165 mp->local_integ_key_len = 0;
14168 mp->local_integ_key_len = vec_len (lik);
14169 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14170 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14171 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14174 mp->remote_integ_key_len = 0;
14177 mp->remote_integ_key_len = vec_len (rik);
14178 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14179 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14180 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14189 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14191 vat_main_t *vam = &vat_main;
14193 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14194 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
14195 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
14196 "tunnel_src_addr %U tunnel_dst_addr %U "
14197 "salt %u seq_outbound %lu last_seq_inbound %lu "
14198 "replay_window %lu total_data_size %lu\n",
14199 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
14201 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
14202 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
14203 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
14204 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14205 mp->tunnel_src_addr,
14206 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14207 mp->tunnel_dst_addr,
14209 clib_net_to_host_u64 (mp->seq_outbound),
14210 clib_net_to_host_u64 (mp->last_seq_inbound),
14211 clib_net_to_host_u64 (mp->replay_window),
14212 clib_net_to_host_u64 (mp->total_data_size));
14215 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14216 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14218 static void vl_api_ipsec_sa_details_t_handler_json
14219 (vl_api_ipsec_sa_details_t * mp)
14221 vat_main_t *vam = &vat_main;
14222 vat_json_node_t *node = NULL;
14223 struct in_addr src_ip4, dst_ip4;
14224 struct in6_addr src_ip6, dst_ip6;
14226 if (VAT_JSON_ARRAY != vam->json_tree.type)
14228 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14229 vat_json_init_array (&vam->json_tree);
14231 node = vat_json_array_add (&vam->json_tree);
14233 vat_json_init_object (node);
14234 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
14235 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14236 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
14237 vat_json_object_add_uint (node, "proto", mp->protocol);
14238 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
14239 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
14240 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
14241 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
14242 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
14243 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
14244 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
14245 mp->crypto_key_len);
14246 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
14247 mp->integ_key_len);
14248 if (mp->is_tunnel_ip6)
14250 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
14251 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
14252 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
14253 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
14257 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
14258 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
14259 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
14260 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
14262 vat_json_object_add_uint (node, "replay_window",
14263 clib_net_to_host_u64 (mp->replay_window));
14264 vat_json_object_add_uint (node, "total_data_size",
14265 clib_net_to_host_u64 (mp->total_data_size));
14270 api_ipsec_sa_dump (vat_main_t * vam)
14272 unformat_input_t *i = vam->input;
14273 vl_api_ipsec_sa_dump_t *mp;
14274 vl_api_control_ping_t *mp_ping;
14278 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14280 if (unformat (i, "sa_id %d", &sa_id))
14284 clib_warning ("parse error '%U'", format_unformat_error, i);
14289 M (IPSEC_SA_DUMP, mp);
14291 mp->sa_id = ntohl (sa_id);
14295 /* Use a control ping for synchronization */
14296 M (CONTROL_PING, mp_ping);
14304 api_ikev2_profile_add_del (vat_main_t * vam)
14306 unformat_input_t *i = vam->input;
14307 vl_api_ikev2_profile_add_del_t *mp;
14312 const char *valid_chars = "a-zA-Z0-9_";
14314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14316 if (unformat (i, "del"))
14318 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14319 vec_add1 (name, 0);
14322 errmsg ("parse error '%U'", format_unformat_error, i);
14327 if (!vec_len (name))
14329 errmsg ("profile name must be specified");
14333 if (vec_len (name) > 64)
14335 errmsg ("profile name too long");
14339 M (IKEV2_PROFILE_ADD_DEL, mp);
14341 clib_memcpy (mp->name, name, vec_len (name));
14342 mp->is_add = is_add;
14351 api_ikev2_profile_set_auth (vat_main_t * vam)
14353 unformat_input_t *i = vam->input;
14354 vl_api_ikev2_profile_set_auth_t *mp;
14357 u32 auth_method = 0;
14361 const char *valid_chars = "a-zA-Z0-9_";
14363 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14365 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14366 vec_add1 (name, 0);
14367 else if (unformat (i, "auth_method %U",
14368 unformat_ikev2_auth_method, &auth_method))
14370 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
14372 else if (unformat (i, "auth_data %v", &data))
14376 errmsg ("parse error '%U'", format_unformat_error, i);
14381 if (!vec_len (name))
14383 errmsg ("profile name must be specified");
14387 if (vec_len (name) > 64)
14389 errmsg ("profile name too long");
14393 if (!vec_len (data))
14395 errmsg ("auth_data must be specified");
14401 errmsg ("auth_method must be specified");
14405 M (IKEV2_PROFILE_SET_AUTH, mp);
14407 mp->is_hex = is_hex;
14408 mp->auth_method = (u8) auth_method;
14409 mp->data_len = vec_len (data);
14410 clib_memcpy (mp->name, name, vec_len (name));
14411 clib_memcpy (mp->data, data, vec_len (data));
14421 api_ikev2_profile_set_id (vat_main_t * vam)
14423 unformat_input_t *i = vam->input;
14424 vl_api_ikev2_profile_set_id_t *mp;
14432 const char *valid_chars = "a-zA-Z0-9_";
14434 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14436 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14437 vec_add1 (name, 0);
14438 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
14440 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
14442 data = vec_new (u8, 4);
14443 clib_memcpy (data, ip4.as_u8, 4);
14445 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
14447 else if (unformat (i, "id_data %v", &data))
14449 else if (unformat (i, "local"))
14451 else if (unformat (i, "remote"))
14455 errmsg ("parse error '%U'", format_unformat_error, i);
14460 if (!vec_len (name))
14462 errmsg ("profile name must be specified");
14466 if (vec_len (name) > 64)
14468 errmsg ("profile name too long");
14472 if (!vec_len (data))
14474 errmsg ("id_data must be specified");
14480 errmsg ("id_type must be specified");
14484 M (IKEV2_PROFILE_SET_ID, mp);
14486 mp->is_local = is_local;
14487 mp->id_type = (u8) id_type;
14488 mp->data_len = vec_len (data);
14489 clib_memcpy (mp->name, name, vec_len (name));
14490 clib_memcpy (mp->data, data, vec_len (data));
14500 api_ikev2_profile_set_ts (vat_main_t * vam)
14502 unformat_input_t *i = vam->input;
14503 vl_api_ikev2_profile_set_ts_t *mp;
14506 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
14507 ip4_address_t start_addr, end_addr;
14509 const char *valid_chars = "a-zA-Z0-9_";
14512 start_addr.as_u32 = 0;
14513 end_addr.as_u32 = (u32) ~ 0;
14515 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14517 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14518 vec_add1 (name, 0);
14519 else if (unformat (i, "protocol %d", &proto))
14521 else if (unformat (i, "start_port %d", &start_port))
14523 else if (unformat (i, "end_port %d", &end_port))
14526 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
14528 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
14530 else if (unformat (i, "local"))
14532 else if (unformat (i, "remote"))
14536 errmsg ("parse error '%U'", format_unformat_error, i);
14541 if (!vec_len (name))
14543 errmsg ("profile name must be specified");
14547 if (vec_len (name) > 64)
14549 errmsg ("profile name too long");
14553 M (IKEV2_PROFILE_SET_TS, mp);
14555 mp->is_local = is_local;
14556 mp->proto = (u8) proto;
14557 mp->start_port = (u16) start_port;
14558 mp->end_port = (u16) end_port;
14559 mp->start_addr = start_addr.as_u32;
14560 mp->end_addr = end_addr.as_u32;
14561 clib_memcpy (mp->name, name, vec_len (name));
14570 api_ikev2_set_local_key (vat_main_t * vam)
14572 unformat_input_t *i = vam->input;
14573 vl_api_ikev2_set_local_key_t *mp;
14577 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14579 if (unformat (i, "file %v", &file))
14580 vec_add1 (file, 0);
14583 errmsg ("parse error '%U'", format_unformat_error, i);
14588 if (!vec_len (file))
14590 errmsg ("RSA key file must be specified");
14594 if (vec_len (file) > 256)
14596 errmsg ("file name too long");
14600 M (IKEV2_SET_LOCAL_KEY, mp);
14602 clib_memcpy (mp->key_file, file, vec_len (file));
14611 api_ikev2_set_responder (vat_main_t * vam)
14613 unformat_input_t *i = vam->input;
14614 vl_api_ikev2_set_responder_t *mp;
14617 u32 sw_if_index = ~0;
14618 ip4_address_t address;
14620 const char *valid_chars = "a-zA-Z0-9_";
14622 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14625 (i, "%U interface %d address %U", unformat_token, valid_chars,
14626 &name, &sw_if_index, unformat_ip4_address, &address))
14627 vec_add1 (name, 0);
14630 errmsg ("parse error '%U'", format_unformat_error, i);
14635 if (!vec_len (name))
14637 errmsg ("profile name must be specified");
14641 if (vec_len (name) > 64)
14643 errmsg ("profile name too long");
14647 M (IKEV2_SET_RESPONDER, mp);
14649 clib_memcpy (mp->name, name, vec_len (name));
14652 mp->sw_if_index = sw_if_index;
14653 clib_memcpy (mp->address, &address, sizeof (address));
14661 api_ikev2_set_ike_transforms (vat_main_t * vam)
14663 unformat_input_t *i = vam->input;
14664 vl_api_ikev2_set_ike_transforms_t *mp;
14667 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14669 const char *valid_chars = "a-zA-Z0-9_";
14671 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14673 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14674 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14675 vec_add1 (name, 0);
14678 errmsg ("parse error '%U'", format_unformat_error, i);
14683 if (!vec_len (name))
14685 errmsg ("profile name must be specified");
14689 if (vec_len (name) > 64)
14691 errmsg ("profile name too long");
14695 M (IKEV2_SET_IKE_TRANSFORMS, mp);
14697 clib_memcpy (mp->name, name, vec_len (name));
14699 mp->crypto_alg = crypto_alg;
14700 mp->crypto_key_size = crypto_key_size;
14701 mp->integ_alg = integ_alg;
14702 mp->dh_group = dh_group;
14711 api_ikev2_set_esp_transforms (vat_main_t * vam)
14713 unformat_input_t *i = vam->input;
14714 vl_api_ikev2_set_esp_transforms_t *mp;
14717 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14719 const char *valid_chars = "a-zA-Z0-9_";
14721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14723 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14724 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14725 vec_add1 (name, 0);
14728 errmsg ("parse error '%U'", format_unformat_error, i);
14733 if (!vec_len (name))
14735 errmsg ("profile name must be specified");
14739 if (vec_len (name) > 64)
14741 errmsg ("profile name too long");
14745 M (IKEV2_SET_ESP_TRANSFORMS, mp);
14747 clib_memcpy (mp->name, name, vec_len (name));
14749 mp->crypto_alg = crypto_alg;
14750 mp->crypto_key_size = crypto_key_size;
14751 mp->integ_alg = integ_alg;
14752 mp->dh_group = dh_group;
14760 api_ikev2_set_sa_lifetime (vat_main_t * vam)
14762 unformat_input_t *i = vam->input;
14763 vl_api_ikev2_set_sa_lifetime_t *mp;
14766 u64 lifetime, lifetime_maxdata;
14767 u32 lifetime_jitter, handover;
14769 const char *valid_chars = "a-zA-Z0-9_";
14771 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14773 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
14774 &lifetime, &lifetime_jitter, &handover,
14775 &lifetime_maxdata))
14776 vec_add1 (name, 0);
14779 errmsg ("parse error '%U'", format_unformat_error, i);
14784 if (!vec_len (name))
14786 errmsg ("profile name must be specified");
14790 if (vec_len (name) > 64)
14792 errmsg ("profile name too long");
14796 M (IKEV2_SET_SA_LIFETIME, mp);
14798 clib_memcpy (mp->name, name, vec_len (name));
14800 mp->lifetime = lifetime;
14801 mp->lifetime_jitter = lifetime_jitter;
14802 mp->handover = handover;
14803 mp->lifetime_maxdata = lifetime_maxdata;
14811 api_ikev2_initiate_sa_init (vat_main_t * vam)
14813 unformat_input_t *i = vam->input;
14814 vl_api_ikev2_initiate_sa_init_t *mp;
14818 const char *valid_chars = "a-zA-Z0-9_";
14820 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14822 if (unformat (i, "%U", unformat_token, valid_chars, &name))
14823 vec_add1 (name, 0);
14826 errmsg ("parse error '%U'", format_unformat_error, i);
14831 if (!vec_len (name))
14833 errmsg ("profile name must be specified");
14837 if (vec_len (name) > 64)
14839 errmsg ("profile name too long");
14843 M (IKEV2_INITIATE_SA_INIT, mp);
14845 clib_memcpy (mp->name, name, vec_len (name));
14854 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
14856 unformat_input_t *i = vam->input;
14857 vl_api_ikev2_initiate_del_ike_sa_t *mp;
14862 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14864 if (unformat (i, "%lx", &ispi))
14868 errmsg ("parse error '%U'", format_unformat_error, i);
14873 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
14883 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
14885 unformat_input_t *i = vam->input;
14886 vl_api_ikev2_initiate_del_child_sa_t *mp;
14891 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14893 if (unformat (i, "%x", &ispi))
14897 errmsg ("parse error '%U'", format_unformat_error, i);
14902 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
14912 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
14914 unformat_input_t *i = vam->input;
14915 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
14920 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14922 if (unformat (i, "%x", &ispi))
14926 errmsg ("parse error '%U'", format_unformat_error, i);
14931 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
14944 api_map_add_domain (vat_main_t * vam)
14946 unformat_input_t *i = vam->input;
14947 vl_api_map_add_domain_t *mp;
14949 ip4_address_t ip4_prefix;
14950 ip6_address_t ip6_prefix;
14951 ip6_address_t ip6_src;
14952 u32 num_m_args = 0;
14953 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
14954 0, psid_length = 0;
14955 u8 is_translation = 0;
14957 u32 ip6_src_len = 128;
14960 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14962 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
14963 &ip4_prefix, &ip4_prefix_len))
14965 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
14966 &ip6_prefix, &ip6_prefix_len))
14970 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
14973 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
14975 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
14977 else if (unformat (i, "psid-offset %d", &psid_offset))
14979 else if (unformat (i, "psid-len %d", &psid_length))
14981 else if (unformat (i, "mtu %d", &mtu))
14983 else if (unformat (i, "map-t"))
14984 is_translation = 1;
14987 clib_warning ("parse error '%U'", format_unformat_error, i);
14992 if (num_m_args < 3)
14994 errmsg ("mandatory argument(s) missing");
14998 /* Construct the API message */
14999 M (MAP_ADD_DOMAIN, mp);
15001 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
15002 mp->ip4_prefix_len = ip4_prefix_len;
15004 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
15005 mp->ip6_prefix_len = ip6_prefix_len;
15007 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
15008 mp->ip6_src_prefix_len = ip6_src_len;
15010 mp->ea_bits_len = ea_bits_len;
15011 mp->psid_offset = psid_offset;
15012 mp->psid_length = psid_length;
15013 mp->is_translation = is_translation;
15014 mp->mtu = htons (mtu);
15019 /* Wait for a reply, return good/bad news */
15025 api_map_del_domain (vat_main_t * vam)
15027 unformat_input_t *i = vam->input;
15028 vl_api_map_del_domain_t *mp;
15030 u32 num_m_args = 0;
15034 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15036 if (unformat (i, "index %d", &index))
15040 clib_warning ("parse error '%U'", format_unformat_error, i);
15045 if (num_m_args != 1)
15047 errmsg ("mandatory argument(s) missing");
15051 /* Construct the API message */
15052 M (MAP_DEL_DOMAIN, mp);
15054 mp->index = ntohl (index);
15059 /* Wait for a reply, return good/bad news */
15065 api_map_add_del_rule (vat_main_t * vam)
15067 unformat_input_t *i = vam->input;
15068 vl_api_map_add_del_rule_t *mp;
15070 ip6_address_t ip6_dst;
15071 u32 num_m_args = 0, index, psid = 0;
15074 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15076 if (unformat (i, "index %d", &index))
15078 else if (unformat (i, "psid %d", &psid))
15080 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
15082 else if (unformat (i, "del"))
15088 clib_warning ("parse error '%U'", format_unformat_error, i);
15093 /* Construct the API message */
15094 M (MAP_ADD_DEL_RULE, mp);
15096 mp->index = ntohl (index);
15097 mp->is_add = is_add;
15098 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
15099 mp->psid = ntohs (psid);
15104 /* Wait for a reply, return good/bad news */
15110 api_map_domain_dump (vat_main_t * vam)
15112 vl_api_map_domain_dump_t *mp;
15113 vl_api_control_ping_t *mp_ping;
15116 /* Construct the API message */
15117 M (MAP_DOMAIN_DUMP, mp);
15122 /* Use a control ping for synchronization */
15123 MPING (CONTROL_PING, mp_ping);
15131 api_map_rule_dump (vat_main_t * vam)
15133 unformat_input_t *i = vam->input;
15134 vl_api_map_rule_dump_t *mp;
15135 vl_api_control_ping_t *mp_ping;
15136 u32 domain_index = ~0;
15139 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15141 if (unformat (i, "index %u", &domain_index))
15147 if (domain_index == ~0)
15149 clib_warning ("parse error: domain index expected");
15153 /* Construct the API message */
15154 M (MAP_RULE_DUMP, mp);
15156 mp->domain_index = htonl (domain_index);
15161 /* Use a control ping for synchronization */
15162 MPING (CONTROL_PING, mp_ping);
15169 static void vl_api_map_add_domain_reply_t_handler
15170 (vl_api_map_add_domain_reply_t * mp)
15172 vat_main_t *vam = &vat_main;
15173 i32 retval = ntohl (mp->retval);
15175 if (vam->async_mode)
15177 vam->async_errors += (retval < 0);
15181 vam->retval = retval;
15182 vam->result_ready = 1;
15186 static void vl_api_map_add_domain_reply_t_handler_json
15187 (vl_api_map_add_domain_reply_t * mp)
15189 vat_main_t *vam = &vat_main;
15190 vat_json_node_t node;
15192 vat_json_init_object (&node);
15193 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
15194 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
15196 vat_json_print (vam->ofp, &node);
15197 vat_json_free (&node);
15199 vam->retval = ntohl (mp->retval);
15200 vam->result_ready = 1;
15204 api_get_first_msg_id (vat_main_t * vam)
15206 vl_api_get_first_msg_id_t *mp;
15207 unformat_input_t *i = vam->input;
15212 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15214 if (unformat (i, "client %s", &name))
15222 errmsg ("missing client name");
15225 vec_add1 (name, 0);
15227 if (vec_len (name) > 63)
15229 errmsg ("client name too long");
15233 M (GET_FIRST_MSG_ID, mp);
15234 clib_memcpy (mp->name, name, vec_len (name));
15241 api_cop_interface_enable_disable (vat_main_t * vam)
15243 unformat_input_t *line_input = vam->input;
15244 vl_api_cop_interface_enable_disable_t *mp;
15245 u32 sw_if_index = ~0;
15246 u8 enable_disable = 1;
15249 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15251 if (unformat (line_input, "disable"))
15252 enable_disable = 0;
15253 if (unformat (line_input, "enable"))
15254 enable_disable = 1;
15255 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15256 vam, &sw_if_index))
15258 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15264 if (sw_if_index == ~0)
15266 errmsg ("missing interface name or sw_if_index");
15270 /* Construct the API message */
15271 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15272 mp->sw_if_index = ntohl (sw_if_index);
15273 mp->enable_disable = enable_disable;
15277 /* Wait for the reply */
15283 api_cop_whitelist_enable_disable (vat_main_t * vam)
15285 unformat_input_t *line_input = vam->input;
15286 vl_api_cop_whitelist_enable_disable_t *mp;
15287 u32 sw_if_index = ~0;
15288 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15292 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15294 if (unformat (line_input, "ip4"))
15296 else if (unformat (line_input, "ip6"))
15298 else if (unformat (line_input, "default"))
15300 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15301 vam, &sw_if_index))
15303 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15305 else if (unformat (line_input, "fib-id %d", &fib_id))
15311 if (sw_if_index == ~0)
15313 errmsg ("missing interface name or sw_if_index");
15317 /* Construct the API message */
15318 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15319 mp->sw_if_index = ntohl (sw_if_index);
15320 mp->fib_id = ntohl (fib_id);
15323 mp->default_cop = default_cop;
15327 /* Wait for the reply */
15333 api_get_node_graph (vat_main_t * vam)
15335 vl_api_get_node_graph_t *mp;
15338 M (GET_NODE_GRAPH, mp);
15342 /* Wait for the reply */
15348 /** Used for parsing LISP eids */
15349 typedef CLIB_PACKED(struct{
15350 u8 addr[16]; /**< eid address */
15351 u32 len; /**< prefix length if IP */
15352 u8 type; /**< type of eid */
15357 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15359 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15361 memset (a, 0, sizeof (a[0]));
15363 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15365 a->type = 0; /* ipv4 type */
15367 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15369 a->type = 1; /* ipv6 type */
15371 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15373 a->type = 2; /* mac type */
15375 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15377 a->type = 3; /* NSH type */
15378 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15379 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15386 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15395 lisp_eid_size_vat (u8 type)
15412 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15414 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15418 api_one_add_del_locator_set (vat_main_t * vam)
15420 unformat_input_t *input = vam->input;
15421 vl_api_one_add_del_locator_set_t *mp;
15423 u8 *locator_set_name = NULL;
15424 u8 locator_set_name_set = 0;
15425 vl_api_local_locator_t locator, *locators = 0;
15426 u32 sw_if_index, priority, weight;
15430 /* Parse args required to build the message */
15431 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15433 if (unformat (input, "del"))
15437 else if (unformat (input, "locator-set %s", &locator_set_name))
15439 locator_set_name_set = 1;
15441 else if (unformat (input, "sw_if_index %u p %u w %u",
15442 &sw_if_index, &priority, &weight))
15444 locator.sw_if_index = htonl (sw_if_index);
15445 locator.priority = priority;
15446 locator.weight = weight;
15447 vec_add1 (locators, locator);
15451 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15452 &sw_if_index, &priority, &weight))
15454 locator.sw_if_index = htonl (sw_if_index);
15455 locator.priority = priority;
15456 locator.weight = weight;
15457 vec_add1 (locators, locator);
15463 if (locator_set_name_set == 0)
15465 errmsg ("missing locator-set name");
15466 vec_free (locators);
15470 if (vec_len (locator_set_name) > 64)
15472 errmsg ("locator-set name too long");
15473 vec_free (locator_set_name);
15474 vec_free (locators);
15477 vec_add1 (locator_set_name, 0);
15479 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15481 /* Construct the API message */
15482 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15484 mp->is_add = is_add;
15485 clib_memcpy (mp->locator_set_name, locator_set_name,
15486 vec_len (locator_set_name));
15487 vec_free (locator_set_name);
15489 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15491 clib_memcpy (mp->locators, locators, data_len);
15492 vec_free (locators);
15497 /* Wait for a reply... */
15502 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15505 api_one_add_del_locator (vat_main_t * vam)
15507 unformat_input_t *input = vam->input;
15508 vl_api_one_add_del_locator_t *mp;
15509 u32 tmp_if_index = ~0;
15510 u32 sw_if_index = ~0;
15511 u8 sw_if_index_set = 0;
15512 u8 sw_if_index_if_name_set = 0;
15514 u8 priority_set = 0;
15518 u8 *locator_set_name = NULL;
15519 u8 locator_set_name_set = 0;
15522 /* Parse args required to build the message */
15523 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15525 if (unformat (input, "del"))
15529 else if (unformat (input, "locator-set %s", &locator_set_name))
15531 locator_set_name_set = 1;
15533 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15536 sw_if_index_if_name_set = 1;
15537 sw_if_index = tmp_if_index;
15539 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15541 sw_if_index_set = 1;
15542 sw_if_index = tmp_if_index;
15544 else if (unformat (input, "p %d", &priority))
15548 else if (unformat (input, "w %d", &weight))
15556 if (locator_set_name_set == 0)
15558 errmsg ("missing locator-set name");
15562 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15564 errmsg ("missing sw_if_index");
15565 vec_free (locator_set_name);
15569 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15571 errmsg ("cannot use both params interface name and sw_if_index");
15572 vec_free (locator_set_name);
15576 if (priority_set == 0)
15578 errmsg ("missing locator-set priority");
15579 vec_free (locator_set_name);
15583 if (weight_set == 0)
15585 errmsg ("missing locator-set weight");
15586 vec_free (locator_set_name);
15590 if (vec_len (locator_set_name) > 64)
15592 errmsg ("locator-set name too long");
15593 vec_free (locator_set_name);
15596 vec_add1 (locator_set_name, 0);
15598 /* Construct the API message */
15599 M (ONE_ADD_DEL_LOCATOR, mp);
15601 mp->is_add = is_add;
15602 mp->sw_if_index = ntohl (sw_if_index);
15603 mp->priority = priority;
15604 mp->weight = weight;
15605 clib_memcpy (mp->locator_set_name, locator_set_name,
15606 vec_len (locator_set_name));
15607 vec_free (locator_set_name);
15612 /* Wait for a reply... */
15617 #define api_lisp_add_del_locator api_one_add_del_locator
15620 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15622 u32 *key_id = va_arg (*args, u32 *);
15625 if (unformat (input, "%s", &s))
15627 if (!strcmp ((char *) s, "sha1"))
15628 key_id[0] = HMAC_SHA_1_96;
15629 else if (!strcmp ((char *) s, "sha256"))
15630 key_id[0] = HMAC_SHA_256_128;
15633 clib_warning ("invalid key_id: '%s'", s);
15634 key_id[0] = HMAC_NO_KEY;
15645 api_one_add_del_local_eid (vat_main_t * vam)
15647 unformat_input_t *input = vam->input;
15648 vl_api_one_add_del_local_eid_t *mp;
15651 lisp_eid_vat_t _eid, *eid = &_eid;
15652 u8 *locator_set_name = 0;
15653 u8 locator_set_name_set = 0;
15659 /* Parse args required to build the message */
15660 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15662 if (unformat (input, "del"))
15666 else if (unformat (input, "vni %d", &vni))
15670 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15674 else if (unformat (input, "locator-set %s", &locator_set_name))
15676 locator_set_name_set = 1;
15678 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15680 else if (unformat (input, "secret-key %_%v%_", &key))
15686 if (locator_set_name_set == 0)
15688 errmsg ("missing locator-set name");
15694 errmsg ("EID address not set!");
15695 vec_free (locator_set_name);
15699 if (key && (0 == key_id))
15701 errmsg ("invalid key_id!");
15705 if (vec_len (key) > 64)
15707 errmsg ("key too long");
15712 if (vec_len (locator_set_name) > 64)
15714 errmsg ("locator-set name too long");
15715 vec_free (locator_set_name);
15718 vec_add1 (locator_set_name, 0);
15720 /* Construct the API message */
15721 M (ONE_ADD_DEL_LOCAL_EID, mp);
15723 mp->is_add = is_add;
15724 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15725 mp->eid_type = eid->type;
15726 mp->prefix_len = eid->len;
15727 mp->vni = clib_host_to_net_u32 (vni);
15728 mp->key_id = clib_host_to_net_u16 (key_id);
15729 clib_memcpy (mp->locator_set_name, locator_set_name,
15730 vec_len (locator_set_name));
15731 clib_memcpy (mp->key, key, vec_len (key));
15733 vec_free (locator_set_name);
15739 /* Wait for a reply... */
15744 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15747 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15749 u32 dp_table = 0, vni = 0;;
15750 unformat_input_t *input = vam->input;
15751 vl_api_gpe_add_del_fwd_entry_t *mp;
15753 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15754 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15755 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15756 u32 action = ~0, w;
15757 ip4_address_t rmt_rloc4, lcl_rloc4;
15758 ip6_address_t rmt_rloc6, lcl_rloc6;
15759 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15762 memset (&rloc, 0, sizeof (rloc));
15764 /* Parse args required to build the message */
15765 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15767 if (unformat (input, "del"))
15769 else if (unformat (input, "add"))
15771 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15775 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15779 else if (unformat (input, "vrf %d", &dp_table))
15781 else if (unformat (input, "bd %d", &dp_table))
15783 else if (unformat (input, "vni %d", &vni))
15785 else if (unformat (input, "w %d", &w))
15789 errmsg ("No RLOC configured for setting priority/weight!");
15792 curr_rloc->weight = w;
15794 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15795 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15799 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15801 vec_add1 (lcl_locs, rloc);
15803 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15804 vec_add1 (rmt_locs, rloc);
15805 /* weight saved in rmt loc */
15806 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15808 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15809 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15812 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15814 vec_add1 (lcl_locs, rloc);
15816 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15817 vec_add1 (rmt_locs, rloc);
15818 /* weight saved in rmt loc */
15819 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15821 else if (unformat (input, "action %d", &action))
15827 clib_warning ("parse error '%U'", format_unformat_error, input);
15834 errmsg ("remote eid addresses not set");
15838 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15840 errmsg ("eid types don't match");
15844 if (0 == rmt_locs && (u32) ~ 0 == action)
15846 errmsg ("action not set for negative mapping");
15850 /* Construct the API message */
15851 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15852 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15854 mp->is_add = is_add;
15855 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15856 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15857 mp->eid_type = rmt_eid->type;
15858 mp->dp_table = clib_host_to_net_u32 (dp_table);
15859 mp->vni = clib_host_to_net_u32 (vni);
15860 mp->rmt_len = rmt_eid->len;
15861 mp->lcl_len = lcl_eid->len;
15862 mp->action = action;
15864 if (0 != rmt_locs && 0 != lcl_locs)
15866 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15867 clib_memcpy (mp->locs, lcl_locs,
15868 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15870 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15871 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15872 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15874 vec_free (lcl_locs);
15875 vec_free (rmt_locs);
15880 /* Wait for a reply... */
15886 api_one_add_del_map_server (vat_main_t * vam)
15888 unformat_input_t *input = vam->input;
15889 vl_api_one_add_del_map_server_t *mp;
15893 ip4_address_t ipv4;
15894 ip6_address_t ipv6;
15897 /* Parse args required to build the message */
15898 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15900 if (unformat (input, "del"))
15904 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15908 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15916 if (ipv4_set && ipv6_set)
15918 errmsg ("both eid v4 and v6 addresses set");
15922 if (!ipv4_set && !ipv6_set)
15924 errmsg ("eid addresses not set");
15928 /* Construct the API message */
15929 M (ONE_ADD_DEL_MAP_SERVER, mp);
15931 mp->is_add = is_add;
15935 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15940 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15946 /* Wait for a reply... */
15951 #define api_lisp_add_del_map_server api_one_add_del_map_server
15954 api_one_add_del_map_resolver (vat_main_t * vam)
15956 unformat_input_t *input = vam->input;
15957 vl_api_one_add_del_map_resolver_t *mp;
15961 ip4_address_t ipv4;
15962 ip6_address_t ipv6;
15965 /* Parse args required to build the message */
15966 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15968 if (unformat (input, "del"))
15972 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15976 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15984 if (ipv4_set && ipv6_set)
15986 errmsg ("both eid v4 and v6 addresses set");
15990 if (!ipv4_set && !ipv6_set)
15992 errmsg ("eid addresses not set");
15996 /* Construct the API message */
15997 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
15999 mp->is_add = is_add;
16003 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16008 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16014 /* Wait for a reply... */
16019 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
16022 api_lisp_gpe_enable_disable (vat_main_t * vam)
16024 unformat_input_t *input = vam->input;
16025 vl_api_gpe_enable_disable_t *mp;
16030 /* Parse args required to build the message */
16031 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16033 if (unformat (input, "enable"))
16038 else if (unformat (input, "disable"))
16049 errmsg ("Value not set");
16053 /* Construct the API message */
16054 M (GPE_ENABLE_DISABLE, mp);
16061 /* Wait for a reply... */
16067 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16069 unformat_input_t *input = vam->input;
16070 vl_api_one_rloc_probe_enable_disable_t *mp;
16075 /* Parse args required to build the message */
16076 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16078 if (unformat (input, "enable"))
16083 else if (unformat (input, "disable"))
16091 errmsg ("Value not set");
16095 /* Construct the API message */
16096 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16098 mp->is_enabled = is_en;
16103 /* Wait for a reply... */
16108 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16111 api_one_map_register_enable_disable (vat_main_t * vam)
16113 unformat_input_t *input = vam->input;
16114 vl_api_one_map_register_enable_disable_t *mp;
16119 /* Parse args required to build the message */
16120 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16122 if (unformat (input, "enable"))
16127 else if (unformat (input, "disable"))
16135 errmsg ("Value not set");
16139 /* Construct the API message */
16140 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16142 mp->is_enabled = is_en;
16147 /* Wait for a reply... */
16152 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16155 api_one_enable_disable (vat_main_t * vam)
16157 unformat_input_t *input = vam->input;
16158 vl_api_one_enable_disable_t *mp;
16163 /* Parse args required to build the message */
16164 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16166 if (unformat (input, "enable"))
16171 else if (unformat (input, "disable"))
16181 errmsg ("Value not set");
16185 /* Construct the API message */
16186 M (ONE_ENABLE_DISABLE, mp);
16193 /* Wait for a reply... */
16198 #define api_lisp_enable_disable api_one_enable_disable
16201 api_show_one_map_register_state (vat_main_t * vam)
16203 vl_api_show_one_map_register_state_t *mp;
16206 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16211 /* wait for reply */
16216 #define api_show_lisp_map_register_state api_show_one_map_register_state
16219 api_show_one_rloc_probe_state (vat_main_t * vam)
16221 vl_api_show_one_rloc_probe_state_t *mp;
16224 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16229 /* wait for reply */
16234 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16237 api_one_add_del_ndp_entry (vat_main_t * vam)
16239 vl_api_one_add_del_ndp_entry_t *mp;
16240 unformat_input_t *input = vam->input;
16245 u8 mac[6] = { 0, };
16246 u8 ip6[16] = { 0, };
16250 /* Parse args required to build the message */
16251 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16253 if (unformat (input, "del"))
16255 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16257 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16259 else if (unformat (input, "bd %d", &bd))
16263 errmsg ("parse error '%U'", format_unformat_error, input);
16268 if (!bd_set || !ip_set || (!mac_set && is_add))
16270 errmsg ("Missing BD, IP or MAC!");
16274 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16275 mp->is_add = is_add;
16276 clib_memcpy (mp->mac, mac, 6);
16277 mp->bd = clib_host_to_net_u32 (bd);
16278 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16283 /* wait for reply */
16289 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16291 vl_api_one_add_del_l2_arp_entry_t *mp;
16292 unformat_input_t *input = vam->input;
16297 u8 mac[6] = { 0, };
16298 u32 ip4 = 0, bd = ~0;
16301 /* Parse args required to build the message */
16302 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16304 if (unformat (input, "del"))
16306 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16308 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16310 else if (unformat (input, "bd %d", &bd))
16314 errmsg ("parse error '%U'", format_unformat_error, input);
16319 if (!bd_set || !ip_set || (!mac_set && is_add))
16321 errmsg ("Missing BD, IP or MAC!");
16325 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16326 mp->is_add = is_add;
16327 clib_memcpy (mp->mac, mac, 6);
16328 mp->bd = clib_host_to_net_u32 (bd);
16334 /* wait for reply */
16340 api_one_ndp_bd_get (vat_main_t * vam)
16342 vl_api_one_ndp_bd_get_t *mp;
16345 M (ONE_NDP_BD_GET, mp);
16350 /* wait for reply */
16356 api_one_ndp_entries_get (vat_main_t * vam)
16358 vl_api_one_ndp_entries_get_t *mp;
16359 unformat_input_t *input = vam->input;
16364 /* Parse args required to build the message */
16365 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16367 if (unformat (input, "bd %d", &bd))
16371 errmsg ("parse error '%U'", format_unformat_error, input);
16378 errmsg ("Expected bridge domain!");
16382 M (ONE_NDP_ENTRIES_GET, mp);
16383 mp->bd = clib_host_to_net_u32 (bd);
16388 /* wait for reply */
16394 api_one_l2_arp_bd_get (vat_main_t * vam)
16396 vl_api_one_l2_arp_bd_get_t *mp;
16399 M (ONE_L2_ARP_BD_GET, mp);
16404 /* wait for reply */
16410 api_one_l2_arp_entries_get (vat_main_t * vam)
16412 vl_api_one_l2_arp_entries_get_t *mp;
16413 unformat_input_t *input = vam->input;
16418 /* Parse args required to build the message */
16419 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16421 if (unformat (input, "bd %d", &bd))
16425 errmsg ("parse error '%U'", format_unformat_error, input);
16432 errmsg ("Expected bridge domain!");
16436 M (ONE_L2_ARP_ENTRIES_GET, mp);
16437 mp->bd = clib_host_to_net_u32 (bd);
16442 /* wait for reply */
16448 api_one_stats_enable_disable (vat_main_t * vam)
16450 vl_api_one_stats_enable_disable_t *mp;
16451 unformat_input_t *input = vam->input;
16456 /* Parse args required to build the message */
16457 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16459 if (unformat (input, "enable"))
16464 else if (unformat (input, "disable"))
16474 errmsg ("Value not set");
16478 M (ONE_STATS_ENABLE_DISABLE, mp);
16484 /* wait for reply */
16490 api_show_one_stats_enable_disable (vat_main_t * vam)
16492 vl_api_show_one_stats_enable_disable_t *mp;
16495 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16500 /* wait for reply */
16506 api_show_one_map_request_mode (vat_main_t * vam)
16508 vl_api_show_one_map_request_mode_t *mp;
16511 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16516 /* wait for reply */
16521 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16524 api_one_map_request_mode (vat_main_t * vam)
16526 unformat_input_t *input = vam->input;
16527 vl_api_one_map_request_mode_t *mp;
16531 /* Parse args required to build the message */
16532 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16534 if (unformat (input, "dst-only"))
16536 else if (unformat (input, "src-dst"))
16540 errmsg ("parse error '%U'", format_unformat_error, input);
16545 M (ONE_MAP_REQUEST_MODE, mp);
16552 /* wait for reply */
16557 #define api_lisp_map_request_mode api_one_map_request_mode
16560 * Enable/disable ONE proxy ITR.
16562 * @param vam vpp API test context
16563 * @return return code
16566 api_one_pitr_set_locator_set (vat_main_t * vam)
16568 u8 ls_name_set = 0;
16569 unformat_input_t *input = vam->input;
16570 vl_api_one_pitr_set_locator_set_t *mp;
16575 /* Parse args required to build the message */
16576 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16578 if (unformat (input, "del"))
16580 else if (unformat (input, "locator-set %s", &ls_name))
16584 errmsg ("parse error '%U'", format_unformat_error, input);
16591 errmsg ("locator-set name not set!");
16595 M (ONE_PITR_SET_LOCATOR_SET, mp);
16597 mp->is_add = is_add;
16598 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16599 vec_free (ls_name);
16604 /* wait for reply */
16609 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16612 api_one_nsh_set_locator_set (vat_main_t * vam)
16614 u8 ls_name_set = 0;
16615 unformat_input_t *input = vam->input;
16616 vl_api_one_nsh_set_locator_set_t *mp;
16621 /* Parse args required to build the message */
16622 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16624 if (unformat (input, "del"))
16626 else if (unformat (input, "ls %s", &ls_name))
16630 errmsg ("parse error '%U'", format_unformat_error, input);
16635 if (!ls_name_set && is_add)
16637 errmsg ("locator-set name not set!");
16641 M (ONE_NSH_SET_LOCATOR_SET, mp);
16643 mp->is_add = is_add;
16644 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16645 vec_free (ls_name);
16650 /* wait for reply */
16656 api_show_one_pitr (vat_main_t * vam)
16658 vl_api_show_one_pitr_t *mp;
16661 if (!vam->json_output)
16663 print (vam->ofp, "%=20s", "lisp status:");
16666 M (SHOW_ONE_PITR, mp);
16670 /* Wait for a reply... */
16675 #define api_show_lisp_pitr api_show_one_pitr
16678 api_one_use_petr (vat_main_t * vam)
16680 unformat_input_t *input = vam->input;
16681 vl_api_one_use_petr_t *mp;
16686 memset (&ip, 0, sizeof (ip));
16688 /* Parse args required to build the message */
16689 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16691 if (unformat (input, "disable"))
16694 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16697 ip_addr_version (&ip) = IP4;
16700 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16703 ip_addr_version (&ip) = IP6;
16707 errmsg ("parse error '%U'", format_unformat_error, input);
16712 M (ONE_USE_PETR, mp);
16714 mp->is_add = is_add;
16717 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16719 clib_memcpy (mp->address, &ip, 4);
16721 clib_memcpy (mp->address, &ip, 16);
16727 /* wait for reply */
16732 #define api_lisp_use_petr api_one_use_petr
16735 api_show_one_nsh_mapping (vat_main_t * vam)
16737 vl_api_show_one_use_petr_t *mp;
16740 if (!vam->json_output)
16742 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16745 M (SHOW_ONE_NSH_MAPPING, mp);
16749 /* Wait for a reply... */
16755 api_show_one_use_petr (vat_main_t * vam)
16757 vl_api_show_one_use_petr_t *mp;
16760 if (!vam->json_output)
16762 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16765 M (SHOW_ONE_USE_PETR, mp);
16769 /* Wait for a reply... */
16774 #define api_show_lisp_use_petr api_show_one_use_petr
16777 * Add/delete mapping between vni and vrf
16780 api_one_eid_table_add_del_map (vat_main_t * vam)
16782 unformat_input_t *input = vam->input;
16783 vl_api_one_eid_table_add_del_map_t *mp;
16784 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16785 u32 vni, vrf, bd_index;
16788 /* Parse args required to build the message */
16789 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16791 if (unformat (input, "del"))
16793 else if (unformat (input, "vrf %d", &vrf))
16795 else if (unformat (input, "bd_index %d", &bd_index))
16797 else if (unformat (input, "vni %d", &vni))
16803 if (!vni_set || (!vrf_set && !bd_index_set))
16805 errmsg ("missing arguments!");
16809 if (vrf_set && bd_index_set)
16811 errmsg ("error: both vrf and bd entered!");
16815 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16817 mp->is_add = is_add;
16818 mp->vni = htonl (vni);
16819 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16820 mp->is_l2 = bd_index_set;
16825 /* wait for reply */
16830 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16833 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16835 u32 *action = va_arg (*args, u32 *);
16838 if (unformat (input, "%s", &s))
16840 if (!strcmp ((char *) s, "no-action"))
16842 else if (!strcmp ((char *) s, "natively-forward"))
16844 else if (!strcmp ((char *) s, "send-map-request"))
16846 else if (!strcmp ((char *) s, "drop"))
16850 clib_warning ("invalid action: '%s'", s);
16862 * Add/del remote mapping to/from ONE control plane
16864 * @param vam vpp API test context
16865 * @return return code
16868 api_one_add_del_remote_mapping (vat_main_t * vam)
16870 unformat_input_t *input = vam->input;
16871 vl_api_one_add_del_remote_mapping_t *mp;
16873 lisp_eid_vat_t _eid, *eid = &_eid;
16874 lisp_eid_vat_t _seid, *seid = &_seid;
16875 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16876 u32 action = ~0, p, w, data_len;
16877 ip4_address_t rloc4;
16878 ip6_address_t rloc6;
16879 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16882 memset (&rloc, 0, sizeof (rloc));
16884 /* Parse args required to build the message */
16885 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16887 if (unformat (input, "del-all"))
16891 else if (unformat (input, "del"))
16895 else if (unformat (input, "add"))
16899 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16903 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16907 else if (unformat (input, "vni %d", &vni))
16911 else if (unformat (input, "p %d w %d", &p, &w))
16915 errmsg ("No RLOC configured for setting priority/weight!");
16918 curr_rloc->priority = p;
16919 curr_rloc->weight = w;
16921 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16924 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
16925 vec_add1 (rlocs, rloc);
16926 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16928 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
16931 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
16932 vec_add1 (rlocs, rloc);
16933 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16935 else if (unformat (input, "action %U",
16936 unformat_negative_mapping_action, &action))
16942 clib_warning ("parse error '%U'", format_unformat_error, input);
16949 errmsg ("missing params!");
16953 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
16955 errmsg ("no action set for negative map-reply!");
16959 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
16961 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
16962 mp->is_add = is_add;
16963 mp->vni = htonl (vni);
16964 mp->action = (u8) action;
16965 mp->is_src_dst = seid_set;
16966 mp->eid_len = eid->len;
16967 mp->seid_len = seid->len;
16968 mp->del_all = del_all;
16969 mp->eid_type = eid->type;
16970 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16971 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
16973 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
16974 clib_memcpy (mp->rlocs, rlocs, data_len);
16980 /* Wait for a reply... */
16985 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
16988 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
16989 * forwarding entries in data-plane accordingly.
16991 * @param vam vpp API test context
16992 * @return return code
16995 api_one_add_del_adjacency (vat_main_t * vam)
16997 unformat_input_t *input = vam->input;
16998 vl_api_one_add_del_adjacency_t *mp;
17000 ip4_address_t leid4, reid4;
17001 ip6_address_t leid6, reid6;
17002 u8 reid_mac[6] = { 0 };
17003 u8 leid_mac[6] = { 0 };
17004 u8 reid_type, leid_type;
17005 u32 leid_len = 0, reid_len = 0, len;
17009 leid_type = reid_type = (u8) ~ 0;
17011 /* Parse args required to build the message */
17012 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17014 if (unformat (input, "del"))
17018 else if (unformat (input, "add"))
17022 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17025 reid_type = 0; /* ipv4 */
17028 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17031 reid_type = 1; /* ipv6 */
17034 else if (unformat (input, "reid %U", unformat_ethernet_address,
17037 reid_type = 2; /* mac */
17039 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17042 leid_type = 0; /* ipv4 */
17045 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17048 leid_type = 1; /* ipv6 */
17051 else if (unformat (input, "leid %U", unformat_ethernet_address,
17054 leid_type = 2; /* mac */
17056 else if (unformat (input, "vni %d", &vni))
17062 errmsg ("parse error '%U'", format_unformat_error, input);
17067 if ((u8) ~ 0 == reid_type)
17069 errmsg ("missing params!");
17073 if (leid_type != reid_type)
17075 errmsg ("remote and local EIDs are of different types!");
17079 M (ONE_ADD_DEL_ADJACENCY, mp);
17080 mp->is_add = is_add;
17081 mp->vni = htonl (vni);
17082 mp->leid_len = leid_len;
17083 mp->reid_len = reid_len;
17084 mp->eid_type = reid_type;
17086 switch (mp->eid_type)
17089 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17090 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17093 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17094 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17097 clib_memcpy (mp->leid, leid_mac, 6);
17098 clib_memcpy (mp->reid, reid_mac, 6);
17101 errmsg ("unknown EID type %d!", mp->eid_type);
17108 /* Wait for a reply... */
17113 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17116 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17118 u32 *mode = va_arg (*args, u32 *);
17120 if (unformat (input, "lisp"))
17122 else if (unformat (input, "vxlan"))
17131 api_gpe_get_encap_mode (vat_main_t * vam)
17133 vl_api_gpe_get_encap_mode_t *mp;
17136 /* Construct the API message */
17137 M (GPE_GET_ENCAP_MODE, mp);
17142 /* Wait for a reply... */
17148 api_gpe_set_encap_mode (vat_main_t * vam)
17150 unformat_input_t *input = vam->input;
17151 vl_api_gpe_set_encap_mode_t *mp;
17155 /* Parse args required to build the message */
17156 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17158 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17164 /* Construct the API message */
17165 M (GPE_SET_ENCAP_MODE, mp);
17172 /* Wait for a reply... */
17178 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17180 unformat_input_t *input = vam->input;
17181 vl_api_gpe_add_del_iface_t *mp;
17182 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17183 u32 dp_table = 0, vni = 0;
17186 /* Parse args required to build the message */
17187 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17189 if (unformat (input, "up"))
17194 else if (unformat (input, "down"))
17199 else if (unformat (input, "table_id %d", &dp_table))
17203 else if (unformat (input, "bd_id %d", &dp_table))
17208 else if (unformat (input, "vni %d", &vni))
17216 if (action_set == 0)
17218 errmsg ("Action not set");
17221 if (dp_table_set == 0 || vni_set == 0)
17223 errmsg ("vni and dp_table must be set");
17227 /* Construct the API message */
17228 M (GPE_ADD_DEL_IFACE, mp);
17230 mp->is_add = is_add;
17231 mp->dp_table = clib_host_to_net_u32 (dp_table);
17233 mp->vni = clib_host_to_net_u32 (vni);
17238 /* Wait for a reply... */
17244 api_one_map_register_fallback_threshold (vat_main_t * vam)
17246 unformat_input_t *input = vam->input;
17247 vl_api_one_map_register_fallback_threshold_t *mp;
17252 /* Parse args required to build the message */
17253 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17255 if (unformat (input, "%u", &value))
17259 clib_warning ("parse error '%U'", format_unformat_error, input);
17266 errmsg ("fallback threshold value is missing!");
17270 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17271 mp->value = clib_host_to_net_u32 (value);
17276 /* Wait for a reply... */
17282 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17284 vl_api_show_one_map_register_fallback_threshold_t *mp;
17287 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17292 /* Wait for a reply... */
17298 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17300 u32 *proto = va_arg (*args, u32 *);
17302 if (unformat (input, "udp"))
17304 else if (unformat (input, "api"))
17313 api_one_set_transport_protocol (vat_main_t * vam)
17315 unformat_input_t *input = vam->input;
17316 vl_api_one_set_transport_protocol_t *mp;
17321 /* Parse args required to build the message */
17322 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17324 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17328 clib_warning ("parse error '%U'", format_unformat_error, input);
17335 errmsg ("Transport protocol missing!");
17339 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17340 mp->protocol = (u8) protocol;
17345 /* Wait for a reply... */
17351 api_one_get_transport_protocol (vat_main_t * vam)
17353 vl_api_one_get_transport_protocol_t *mp;
17356 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17361 /* Wait for a reply... */
17367 api_one_map_register_set_ttl (vat_main_t * vam)
17369 unformat_input_t *input = vam->input;
17370 vl_api_one_map_register_set_ttl_t *mp;
17375 /* Parse args required to build the message */
17376 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17378 if (unformat (input, "%u", &ttl))
17382 clib_warning ("parse error '%U'", format_unformat_error, input);
17389 errmsg ("TTL value missing!");
17393 M (ONE_MAP_REGISTER_SET_TTL, mp);
17394 mp->ttl = clib_host_to_net_u32 (ttl);
17399 /* Wait for a reply... */
17405 api_show_one_map_register_ttl (vat_main_t * vam)
17407 vl_api_show_one_map_register_ttl_t *mp;
17410 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17415 /* Wait for a reply... */
17421 * Add/del map request itr rlocs from ONE control plane and updates
17423 * @param vam vpp API test context
17424 * @return return code
17427 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17429 unformat_input_t *input = vam->input;
17430 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17431 u8 *locator_set_name = 0;
17432 u8 locator_set_name_set = 0;
17436 /* Parse args required to build the message */
17437 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17439 if (unformat (input, "del"))
17443 else if (unformat (input, "%_%v%_", &locator_set_name))
17445 locator_set_name_set = 1;
17449 clib_warning ("parse error '%U'", format_unformat_error, input);
17454 if (is_add && !locator_set_name_set)
17456 errmsg ("itr-rloc is not set!");
17460 if (is_add && vec_len (locator_set_name) > 64)
17462 errmsg ("itr-rloc locator-set name too long");
17463 vec_free (locator_set_name);
17467 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17468 mp->is_add = is_add;
17471 clib_memcpy (mp->locator_set_name, locator_set_name,
17472 vec_len (locator_set_name));
17476 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17478 vec_free (locator_set_name);
17483 /* Wait for a reply... */
17488 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17491 api_one_locator_dump (vat_main_t * vam)
17493 unformat_input_t *input = vam->input;
17494 vl_api_one_locator_dump_t *mp;
17495 vl_api_control_ping_t *mp_ping;
17496 u8 is_index_set = 0, is_name_set = 0;
17501 /* Parse args required to build the message */
17502 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17504 if (unformat (input, "ls_name %_%v%_", &ls_name))
17508 else if (unformat (input, "ls_index %d", &ls_index))
17514 errmsg ("parse error '%U'", format_unformat_error, input);
17519 if (!is_index_set && !is_name_set)
17521 errmsg ("error: expected one of index or name!");
17525 if (is_index_set && is_name_set)
17527 errmsg ("error: only one param expected!");
17531 if (vec_len (ls_name) > 62)
17533 errmsg ("error: locator set name too long!");
17537 if (!vam->json_output)
17539 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17542 M (ONE_LOCATOR_DUMP, mp);
17543 mp->is_index_set = is_index_set;
17546 mp->ls_index = clib_host_to_net_u32 (ls_index);
17549 vec_add1 (ls_name, 0);
17550 strncpy ((char *) mp->ls_name, (char *) ls_name,
17551 sizeof (mp->ls_name) - 1);
17557 /* Use a control ping for synchronization */
17558 MPING (CONTROL_PING, mp_ping);
17561 /* Wait for a reply... */
17566 #define api_lisp_locator_dump api_one_locator_dump
17569 api_one_locator_set_dump (vat_main_t * vam)
17571 vl_api_one_locator_set_dump_t *mp;
17572 vl_api_control_ping_t *mp_ping;
17573 unformat_input_t *input = vam->input;
17577 /* Parse args required to build the message */
17578 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17580 if (unformat (input, "local"))
17584 else if (unformat (input, "remote"))
17590 errmsg ("parse error '%U'", format_unformat_error, input);
17595 if (!vam->json_output)
17597 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17600 M (ONE_LOCATOR_SET_DUMP, mp);
17602 mp->filter = filter;
17607 /* Use a control ping for synchronization */
17608 MPING (CONTROL_PING, mp_ping);
17611 /* Wait for a reply... */
17616 #define api_lisp_locator_set_dump api_one_locator_set_dump
17619 api_one_eid_table_map_dump (vat_main_t * vam)
17623 unformat_input_t *input = vam->input;
17624 vl_api_one_eid_table_map_dump_t *mp;
17625 vl_api_control_ping_t *mp_ping;
17628 /* Parse args required to build the message */
17629 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17631 if (unformat (input, "l2"))
17636 else if (unformat (input, "l3"))
17643 errmsg ("parse error '%U'", format_unformat_error, input);
17650 errmsg ("expected one of 'l2' or 'l3' parameter!");
17654 if (!vam->json_output)
17656 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17659 M (ONE_EID_TABLE_MAP_DUMP, mp);
17665 /* Use a control ping for synchronization */
17666 MPING (CONTROL_PING, mp_ping);
17669 /* Wait for a reply... */
17674 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17677 api_one_eid_table_vni_dump (vat_main_t * vam)
17679 vl_api_one_eid_table_vni_dump_t *mp;
17680 vl_api_control_ping_t *mp_ping;
17683 if (!vam->json_output)
17685 print (vam->ofp, "VNI");
17688 M (ONE_EID_TABLE_VNI_DUMP, mp);
17693 /* Use a control ping for synchronization */
17694 MPING (CONTROL_PING, mp_ping);
17697 /* Wait for a reply... */
17702 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17705 api_one_eid_table_dump (vat_main_t * vam)
17707 unformat_input_t *i = vam->input;
17708 vl_api_one_eid_table_dump_t *mp;
17709 vl_api_control_ping_t *mp_ping;
17710 struct in_addr ip4;
17711 struct in6_addr ip6;
17713 u8 eid_type = ~0, eid_set = 0;
17714 u32 prefix_length = ~0, t, vni = 0;
17717 lisp_nsh_api_t nsh;
17719 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17721 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17727 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17733 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17738 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17743 else if (unformat (i, "vni %d", &t))
17747 else if (unformat (i, "local"))
17751 else if (unformat (i, "remote"))
17757 errmsg ("parse error '%U'", format_unformat_error, i);
17762 if (!vam->json_output)
17764 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17765 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17768 M (ONE_EID_TABLE_DUMP, mp);
17770 mp->filter = filter;
17774 mp->vni = htonl (vni);
17775 mp->eid_type = eid_type;
17779 mp->prefix_length = prefix_length;
17780 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17783 mp->prefix_length = prefix_length;
17784 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17787 clib_memcpy (mp->eid, mac, sizeof (mac));
17790 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17793 errmsg ("unknown EID type %d!", eid_type);
17801 /* Use a control ping for synchronization */
17802 MPING (CONTROL_PING, mp_ping);
17805 /* Wait for a reply... */
17810 #define api_lisp_eid_table_dump api_one_eid_table_dump
17813 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17815 unformat_input_t *i = vam->input;
17816 vl_api_gpe_fwd_entries_get_t *mp;
17821 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17823 if (unformat (i, "vni %d", &vni))
17829 errmsg ("parse error '%U'", format_unformat_error, i);
17836 errmsg ("vni not set!");
17840 if (!vam->json_output)
17842 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17846 M (GPE_FWD_ENTRIES_GET, mp);
17847 mp->vni = clib_host_to_net_u32 (vni);
17852 /* Wait for a reply... */
17857 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17858 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17859 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17860 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17861 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17862 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17863 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17864 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17867 api_one_adjacencies_get (vat_main_t * vam)
17869 unformat_input_t *i = vam->input;
17870 vl_api_one_adjacencies_get_t *mp;
17875 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17877 if (unformat (i, "vni %d", &vni))
17883 errmsg ("parse error '%U'", format_unformat_error, i);
17890 errmsg ("vni not set!");
17894 if (!vam->json_output)
17896 print (vam->ofp, "%s %40s", "leid", "reid");
17899 M (ONE_ADJACENCIES_GET, mp);
17900 mp->vni = clib_host_to_net_u32 (vni);
17905 /* Wait for a reply... */
17910 #define api_lisp_adjacencies_get api_one_adjacencies_get
17913 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
17915 unformat_input_t *i = vam->input;
17916 vl_api_gpe_native_fwd_rpaths_get_t *mp;
17918 u8 ip_family_set = 0, is_ip4 = 1;
17920 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17922 if (unformat (i, "ip4"))
17927 else if (unformat (i, "ip6"))
17934 errmsg ("parse error '%U'", format_unformat_error, i);
17939 if (!ip_family_set)
17941 errmsg ("ip family not set!");
17945 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
17946 mp->is_ip4 = is_ip4;
17951 /* Wait for a reply... */
17957 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
17959 vl_api_gpe_fwd_entry_vnis_get_t *mp;
17962 if (!vam->json_output)
17964 print (vam->ofp, "VNIs");
17967 M (GPE_FWD_ENTRY_VNIS_GET, mp);
17972 /* Wait for a reply... */
17978 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
17980 unformat_input_t *i = vam->input;
17981 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
17983 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
17984 struct in_addr ip4;
17985 struct in6_addr ip6;
17986 u32 table_id = 0, nh_sw_if_index = ~0;
17988 memset (&ip4, 0, sizeof (ip4));
17989 memset (&ip6, 0, sizeof (ip6));
17991 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17993 if (unformat (i, "del"))
17995 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
17996 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18001 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
18002 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18007 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18011 nh_sw_if_index = ~0;
18013 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18017 nh_sw_if_index = ~0;
18019 else if (unformat (i, "table %d", &table_id))
18023 errmsg ("parse error '%U'", format_unformat_error, i);
18030 errmsg ("nh addr not set!");
18034 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18035 mp->is_add = is_add;
18036 mp->table_id = clib_host_to_net_u32 (table_id);
18037 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18038 mp->is_ip4 = is_ip4;
18040 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18042 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18047 /* Wait for a reply... */
18053 api_one_map_server_dump (vat_main_t * vam)
18055 vl_api_one_map_server_dump_t *mp;
18056 vl_api_control_ping_t *mp_ping;
18059 if (!vam->json_output)
18061 print (vam->ofp, "%=20s", "Map server");
18064 M (ONE_MAP_SERVER_DUMP, mp);
18068 /* Use a control ping for synchronization */
18069 MPING (CONTROL_PING, mp_ping);
18072 /* Wait for a reply... */
18077 #define api_lisp_map_server_dump api_one_map_server_dump
18080 api_one_map_resolver_dump (vat_main_t * vam)
18082 vl_api_one_map_resolver_dump_t *mp;
18083 vl_api_control_ping_t *mp_ping;
18086 if (!vam->json_output)
18088 print (vam->ofp, "%=20s", "Map resolver");
18091 M (ONE_MAP_RESOLVER_DUMP, mp);
18095 /* Use a control ping for synchronization */
18096 MPING (CONTROL_PING, mp_ping);
18099 /* Wait for a reply... */
18104 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18107 api_one_stats_flush (vat_main_t * vam)
18109 vl_api_one_stats_flush_t *mp;
18112 M (ONE_STATS_FLUSH, mp);
18119 api_one_stats_dump (vat_main_t * vam)
18121 vl_api_one_stats_dump_t *mp;
18122 vl_api_control_ping_t *mp_ping;
18125 M (ONE_STATS_DUMP, mp);
18129 /* Use a control ping for synchronization */
18130 MPING (CONTROL_PING, mp_ping);
18133 /* Wait for a reply... */
18139 api_show_one_status (vat_main_t * vam)
18141 vl_api_show_one_status_t *mp;
18144 if (!vam->json_output)
18146 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18149 M (SHOW_ONE_STATUS, mp);
18152 /* Wait for a reply... */
18157 #define api_show_lisp_status api_show_one_status
18160 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18162 vl_api_gpe_fwd_entry_path_dump_t *mp;
18163 vl_api_control_ping_t *mp_ping;
18164 unformat_input_t *i = vam->input;
18165 u32 fwd_entry_index = ~0;
18168 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18170 if (unformat (i, "index %d", &fwd_entry_index))
18176 if (~0 == fwd_entry_index)
18178 errmsg ("no index specified!");
18182 if (!vam->json_output)
18184 print (vam->ofp, "first line");
18187 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18191 /* Use a control ping for synchronization */
18192 MPING (CONTROL_PING, mp_ping);
18195 /* Wait for a reply... */
18201 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18203 vl_api_one_get_map_request_itr_rlocs_t *mp;
18206 if (!vam->json_output)
18208 print (vam->ofp, "%=20s", "itr-rlocs:");
18211 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18214 /* Wait for a reply... */
18219 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18222 api_af_packet_create (vat_main_t * vam)
18224 unformat_input_t *i = vam->input;
18225 vl_api_af_packet_create_t *mp;
18226 u8 *host_if_name = 0;
18228 u8 random_hw_addr = 1;
18231 memset (hw_addr, 0, sizeof (hw_addr));
18233 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18235 if (unformat (i, "name %s", &host_if_name))
18236 vec_add1 (host_if_name, 0);
18237 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18238 random_hw_addr = 0;
18243 if (!vec_len (host_if_name))
18245 errmsg ("host-interface name must be specified");
18249 if (vec_len (host_if_name) > 64)
18251 errmsg ("host-interface name too long");
18255 M (AF_PACKET_CREATE, mp);
18257 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18258 clib_memcpy (mp->hw_addr, hw_addr, 6);
18259 mp->use_random_hw_addr = random_hw_addr;
18260 vec_free (host_if_name);
18268 fprintf (vam->ofp ? vam->ofp : stderr,
18269 " new sw_if_index = %d\n", vam->sw_if_index);
18276 api_af_packet_delete (vat_main_t * vam)
18278 unformat_input_t *i = vam->input;
18279 vl_api_af_packet_delete_t *mp;
18280 u8 *host_if_name = 0;
18283 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18285 if (unformat (i, "name %s", &host_if_name))
18286 vec_add1 (host_if_name, 0);
18291 if (!vec_len (host_if_name))
18293 errmsg ("host-interface name must be specified");
18297 if (vec_len (host_if_name) > 64)
18299 errmsg ("host-interface name too long");
18303 M (AF_PACKET_DELETE, mp);
18305 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18306 vec_free (host_if_name);
18314 api_policer_add_del (vat_main_t * vam)
18316 unformat_input_t *i = vam->input;
18317 vl_api_policer_add_del_t *mp;
18327 u8 color_aware = 0;
18328 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18331 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18332 conform_action.dscp = 0;
18333 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18334 exceed_action.dscp = 0;
18335 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18336 violate_action.dscp = 0;
18338 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18340 if (unformat (i, "del"))
18342 else if (unformat (i, "name %s", &name))
18343 vec_add1 (name, 0);
18344 else if (unformat (i, "cir %u", &cir))
18346 else if (unformat (i, "eir %u", &eir))
18348 else if (unformat (i, "cb %u", &cb))
18350 else if (unformat (i, "eb %u", &eb))
18352 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18355 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18358 else if (unformat (i, "type %U", unformat_policer_type, &type))
18360 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18363 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18366 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18369 else if (unformat (i, "color-aware"))
18375 if (!vec_len (name))
18377 errmsg ("policer name must be specified");
18381 if (vec_len (name) > 64)
18383 errmsg ("policer name too long");
18387 M (POLICER_ADD_DEL, mp);
18389 clib_memcpy (mp->name, name, vec_len (name));
18391 mp->is_add = is_add;
18392 mp->cir = ntohl (cir);
18393 mp->eir = ntohl (eir);
18394 mp->cb = clib_net_to_host_u64 (cb);
18395 mp->eb = clib_net_to_host_u64 (eb);
18396 mp->rate_type = rate_type;
18397 mp->round_type = round_type;
18399 mp->conform_action_type = conform_action.action_type;
18400 mp->conform_dscp = conform_action.dscp;
18401 mp->exceed_action_type = exceed_action.action_type;
18402 mp->exceed_dscp = exceed_action.dscp;
18403 mp->violate_action_type = violate_action.action_type;
18404 mp->violate_dscp = violate_action.dscp;
18405 mp->color_aware = color_aware;
18413 api_policer_dump (vat_main_t * vam)
18415 unformat_input_t *i = vam->input;
18416 vl_api_policer_dump_t *mp;
18417 vl_api_control_ping_t *mp_ping;
18418 u8 *match_name = 0;
18419 u8 match_name_valid = 0;
18422 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18424 if (unformat (i, "name %s", &match_name))
18426 vec_add1 (match_name, 0);
18427 match_name_valid = 1;
18433 M (POLICER_DUMP, mp);
18434 mp->match_name_valid = match_name_valid;
18435 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18436 vec_free (match_name);
18440 /* Use a control ping for synchronization */
18441 MPING (CONTROL_PING, mp_ping);
18444 /* Wait for a reply... */
18450 api_policer_classify_set_interface (vat_main_t * vam)
18452 unformat_input_t *i = vam->input;
18453 vl_api_policer_classify_set_interface_t *mp;
18455 int sw_if_index_set;
18456 u32 ip4_table_index = ~0;
18457 u32 ip6_table_index = ~0;
18458 u32 l2_table_index = ~0;
18462 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18464 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18465 sw_if_index_set = 1;
18466 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18467 sw_if_index_set = 1;
18468 else if (unformat (i, "del"))
18470 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18472 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18474 else if (unformat (i, "l2-table %d", &l2_table_index))
18478 clib_warning ("parse error '%U'", format_unformat_error, i);
18483 if (sw_if_index_set == 0)
18485 errmsg ("missing interface name or sw_if_index");
18489 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18491 mp->sw_if_index = ntohl (sw_if_index);
18492 mp->ip4_table_index = ntohl (ip4_table_index);
18493 mp->ip6_table_index = ntohl (ip6_table_index);
18494 mp->l2_table_index = ntohl (l2_table_index);
18495 mp->is_add = is_add;
18503 api_policer_classify_dump (vat_main_t * vam)
18505 unformat_input_t *i = vam->input;
18506 vl_api_policer_classify_dump_t *mp;
18507 vl_api_control_ping_t *mp_ping;
18508 u8 type = POLICER_CLASSIFY_N_TABLES;
18511 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18515 errmsg ("classify table type must be specified");
18519 if (!vam->json_output)
18521 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18524 M (POLICER_CLASSIFY_DUMP, mp);
18529 /* Use a control ping for synchronization */
18530 MPING (CONTROL_PING, mp_ping);
18533 /* Wait for a reply... */
18539 api_netmap_create (vat_main_t * vam)
18541 unformat_input_t *i = vam->input;
18542 vl_api_netmap_create_t *mp;
18545 u8 random_hw_addr = 1;
18550 memset (hw_addr, 0, sizeof (hw_addr));
18552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18554 if (unformat (i, "name %s", &if_name))
18555 vec_add1 (if_name, 0);
18556 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18557 random_hw_addr = 0;
18558 else if (unformat (i, "pipe"))
18560 else if (unformat (i, "master"))
18562 else if (unformat (i, "slave"))
18568 if (!vec_len (if_name))
18570 errmsg ("interface name must be specified");
18574 if (vec_len (if_name) > 64)
18576 errmsg ("interface name too long");
18580 M (NETMAP_CREATE, mp);
18582 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18583 clib_memcpy (mp->hw_addr, hw_addr, 6);
18584 mp->use_random_hw_addr = random_hw_addr;
18585 mp->is_pipe = is_pipe;
18586 mp->is_master = is_master;
18587 vec_free (if_name);
18595 api_netmap_delete (vat_main_t * vam)
18597 unformat_input_t *i = vam->input;
18598 vl_api_netmap_delete_t *mp;
18602 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18604 if (unformat (i, "name %s", &if_name))
18605 vec_add1 (if_name, 0);
18610 if (!vec_len (if_name))
18612 errmsg ("interface name must be specified");
18616 if (vec_len (if_name) > 64)
18618 errmsg ("interface name too long");
18622 M (NETMAP_DELETE, mp);
18624 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18625 vec_free (if_name);
18633 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
18635 if (fp->afi == IP46_TYPE_IP6)
18637 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18638 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18639 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18640 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18641 format_ip6_address, fp->next_hop);
18642 else if (fp->afi == IP46_TYPE_IP4)
18644 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18645 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18646 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18647 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18648 format_ip4_address, fp->next_hop);
18652 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18653 vl_api_fib_path2_t * fp)
18655 struct in_addr ip4;
18656 struct in6_addr ip6;
18658 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18659 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18660 vat_json_object_add_uint (node, "is_local", fp->is_local);
18661 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18662 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18663 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18664 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18665 if (fp->afi == IP46_TYPE_IP4)
18667 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18668 vat_json_object_add_ip4 (node, "next_hop", ip4);
18670 else if (fp->afi == IP46_TYPE_IP6)
18672 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18673 vat_json_object_add_ip6 (node, "next_hop", ip6);
18678 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18680 vat_main_t *vam = &vat_main;
18681 int count = ntohl (mp->mt_count);
18682 vl_api_fib_path2_t *fp;
18685 print (vam->ofp, "[%d]: sw_if_index %d via:",
18686 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
18688 for (i = 0; i < count; i++)
18690 vl_api_mpls_fib_path_print (vam, fp);
18694 print (vam->ofp, "");
18697 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18698 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18701 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18703 vat_main_t *vam = &vat_main;
18704 vat_json_node_t *node = NULL;
18705 int count = ntohl (mp->mt_count);
18706 vl_api_fib_path2_t *fp;
18709 if (VAT_JSON_ARRAY != vam->json_tree.type)
18711 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18712 vat_json_init_array (&vam->json_tree);
18714 node = vat_json_array_add (&vam->json_tree);
18716 vat_json_init_object (node);
18717 vat_json_object_add_uint (node, "tunnel_index",
18718 ntohl (mp->mt_tunnel_index));
18719 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
18721 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
18724 for (i = 0; i < count; i++)
18726 vl_api_mpls_fib_path_json_print (node, fp);
18732 api_mpls_tunnel_dump (vat_main_t * vam)
18734 vl_api_mpls_tunnel_dump_t *mp;
18735 vl_api_control_ping_t *mp_ping;
18739 /* Parse args required to build the message */
18740 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
18742 if (!unformat (vam->input, "tunnel_index %d", &index))
18749 print (vam->ofp, " tunnel_index %d", index);
18751 M (MPLS_TUNNEL_DUMP, mp);
18752 mp->tunnel_index = htonl (index);
18755 /* Use a control ping for synchronization */
18756 MPING (CONTROL_PING, mp_ping);
18763 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
18764 #define vl_api_mpls_fib_details_t_print vl_noop_handler
18768 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
18770 vat_main_t *vam = &vat_main;
18771 int count = ntohl (mp->count);
18772 vl_api_fib_path2_t *fp;
18776 "table-id %d, label %u, ess_bit %u",
18777 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
18779 for (i = 0; i < count; i++)
18781 vl_api_mpls_fib_path_print (vam, fp);
18786 static void vl_api_mpls_fib_details_t_handler_json
18787 (vl_api_mpls_fib_details_t * mp)
18789 vat_main_t *vam = &vat_main;
18790 int count = ntohl (mp->count);
18791 vat_json_node_t *node = NULL;
18792 vl_api_fib_path2_t *fp;
18795 if (VAT_JSON_ARRAY != vam->json_tree.type)
18797 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18798 vat_json_init_array (&vam->json_tree);
18800 node = vat_json_array_add (&vam->json_tree);
18802 vat_json_init_object (node);
18803 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18804 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
18805 vat_json_object_add_uint (node, "label", ntohl (mp->label));
18806 vat_json_object_add_uint (node, "path_count", count);
18808 for (i = 0; i < count; i++)
18810 vl_api_mpls_fib_path_json_print (node, fp);
18816 api_mpls_fib_dump (vat_main_t * vam)
18818 vl_api_mpls_fib_dump_t *mp;
18819 vl_api_control_ping_t *mp_ping;
18822 M (MPLS_FIB_DUMP, mp);
18825 /* Use a control ping for synchronization */
18826 MPING (CONTROL_PING, mp_ping);
18833 #define vl_api_ip_fib_details_t_endian vl_noop_handler
18834 #define vl_api_ip_fib_details_t_print vl_noop_handler
18837 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
18839 vat_main_t *vam = &vat_main;
18840 int count = ntohl (mp->count);
18841 vl_api_fib_path_t *fp;
18845 "table-id %d, prefix %U/%d",
18846 ntohl (mp->table_id), format_ip4_address, mp->address,
18847 mp->address_length);
18849 for (i = 0; i < count; i++)
18851 if (fp->afi == IP46_TYPE_IP6)
18853 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18854 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18855 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18856 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18857 format_ip6_address, fp->next_hop);
18858 else if (fp->afi == IP46_TYPE_IP4)
18860 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18861 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18862 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18863 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18864 format_ip4_address, fp->next_hop);
18869 static void vl_api_ip_fib_details_t_handler_json
18870 (vl_api_ip_fib_details_t * mp)
18872 vat_main_t *vam = &vat_main;
18873 int count = ntohl (mp->count);
18874 vat_json_node_t *node = NULL;
18875 struct in_addr ip4;
18876 struct in6_addr ip6;
18877 vl_api_fib_path_t *fp;
18880 if (VAT_JSON_ARRAY != vam->json_tree.type)
18882 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18883 vat_json_init_array (&vam->json_tree);
18885 node = vat_json_array_add (&vam->json_tree);
18887 vat_json_init_object (node);
18888 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18889 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
18890 vat_json_object_add_ip4 (node, "prefix", ip4);
18891 vat_json_object_add_uint (node, "mask_length", mp->address_length);
18892 vat_json_object_add_uint (node, "path_count", count);
18894 for (i = 0; i < count; i++)
18896 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18897 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18898 vat_json_object_add_uint (node, "is_local", fp->is_local);
18899 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18900 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18901 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18902 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18903 if (fp->afi == IP46_TYPE_IP4)
18905 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18906 vat_json_object_add_ip4 (node, "next_hop", ip4);
18908 else if (fp->afi == IP46_TYPE_IP6)
18910 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18911 vat_json_object_add_ip6 (node, "next_hop", ip6);
18917 api_ip_fib_dump (vat_main_t * vam)
18919 vl_api_ip_fib_dump_t *mp;
18920 vl_api_control_ping_t *mp_ping;
18923 M (IP_FIB_DUMP, mp);
18926 /* Use a control ping for synchronization */
18927 MPING (CONTROL_PING, mp_ping);
18935 api_ip_mfib_dump (vat_main_t * vam)
18937 vl_api_ip_mfib_dump_t *mp;
18938 vl_api_control_ping_t *mp_ping;
18941 M (IP_MFIB_DUMP, mp);
18944 /* Use a control ping for synchronization */
18945 MPING (CONTROL_PING, mp_ping);
18952 static void vl_api_ip_neighbor_details_t_handler
18953 (vl_api_ip_neighbor_details_t * mp)
18955 vat_main_t *vam = &vat_main;
18957 print (vam->ofp, "%c %U %U",
18958 (mp->is_static) ? 'S' : 'D',
18959 format_ethernet_address, &mp->mac_address,
18960 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
18964 static void vl_api_ip_neighbor_details_t_handler_json
18965 (vl_api_ip_neighbor_details_t * mp)
18968 vat_main_t *vam = &vat_main;
18969 vat_json_node_t *node;
18970 struct in_addr ip4;
18971 struct in6_addr ip6;
18973 if (VAT_JSON_ARRAY != vam->json_tree.type)
18975 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18976 vat_json_init_array (&vam->json_tree);
18978 node = vat_json_array_add (&vam->json_tree);
18980 vat_json_init_object (node);
18981 vat_json_object_add_string_copy (node, "flag",
18982 (mp->is_static) ? (u8 *) "static" : (u8 *)
18985 vat_json_object_add_string_copy (node, "link_layer",
18986 format (0, "%U", format_ethernet_address,
18987 &mp->mac_address));
18991 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
18992 vat_json_object_add_ip6 (node, "ip_address", ip6);
18996 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
18997 vat_json_object_add_ip4 (node, "ip_address", ip4);
19002 api_ip_neighbor_dump (vat_main_t * vam)
19004 unformat_input_t *i = vam->input;
19005 vl_api_ip_neighbor_dump_t *mp;
19006 vl_api_control_ping_t *mp_ping;
19008 u32 sw_if_index = ~0;
19011 /* Parse args required to build the message */
19012 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19014 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19016 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19018 else if (unformat (i, "ip6"))
19024 if (sw_if_index == ~0)
19026 errmsg ("missing interface name or sw_if_index");
19030 M (IP_NEIGHBOR_DUMP, mp);
19031 mp->is_ipv6 = (u8) is_ipv6;
19032 mp->sw_if_index = ntohl (sw_if_index);
19035 /* Use a control ping for synchronization */
19036 MPING (CONTROL_PING, mp_ping);
19043 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
19044 #define vl_api_ip6_fib_details_t_print vl_noop_handler
19047 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
19049 vat_main_t *vam = &vat_main;
19050 int count = ntohl (mp->count);
19051 vl_api_fib_path_t *fp;
19055 "table-id %d, prefix %U/%d",
19056 ntohl (mp->table_id), format_ip6_address, mp->address,
19057 mp->address_length);
19059 for (i = 0; i < count; i++)
19061 if (fp->afi == IP46_TYPE_IP6)
19063 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19064 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19065 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19066 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19067 format_ip6_address, fp->next_hop);
19068 else if (fp->afi == IP46_TYPE_IP4)
19070 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19071 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19072 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19073 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19074 format_ip4_address, fp->next_hop);
19079 static void vl_api_ip6_fib_details_t_handler_json
19080 (vl_api_ip6_fib_details_t * mp)
19082 vat_main_t *vam = &vat_main;
19083 int count = ntohl (mp->count);
19084 vat_json_node_t *node = NULL;
19085 struct in_addr ip4;
19086 struct in6_addr ip6;
19087 vl_api_fib_path_t *fp;
19090 if (VAT_JSON_ARRAY != vam->json_tree.type)
19092 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19093 vat_json_init_array (&vam->json_tree);
19095 node = vat_json_array_add (&vam->json_tree);
19097 vat_json_init_object (node);
19098 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19099 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
19100 vat_json_object_add_ip6 (node, "prefix", ip6);
19101 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19102 vat_json_object_add_uint (node, "path_count", count);
19104 for (i = 0; i < count; i++)
19106 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19107 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19108 vat_json_object_add_uint (node, "is_local", fp->is_local);
19109 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19110 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19111 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19112 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19113 if (fp->afi == IP46_TYPE_IP4)
19115 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19116 vat_json_object_add_ip4 (node, "next_hop", ip4);
19118 else if (fp->afi == IP46_TYPE_IP6)
19120 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19121 vat_json_object_add_ip6 (node, "next_hop", ip6);
19127 api_ip6_fib_dump (vat_main_t * vam)
19129 vl_api_ip6_fib_dump_t *mp;
19130 vl_api_control_ping_t *mp_ping;
19133 M (IP6_FIB_DUMP, mp);
19136 /* Use a control ping for synchronization */
19137 MPING (CONTROL_PING, mp_ping);
19145 api_ip6_mfib_dump (vat_main_t * vam)
19147 vl_api_ip6_mfib_dump_t *mp;
19148 vl_api_control_ping_t *mp_ping;
19151 M (IP6_MFIB_DUMP, mp);
19154 /* Use a control ping for synchronization */
19155 MPING (CONTROL_PING, mp_ping);
19163 api_classify_table_ids (vat_main_t * vam)
19165 vl_api_classify_table_ids_t *mp;
19168 /* Construct the API message */
19169 M (CLASSIFY_TABLE_IDS, mp);
19178 api_classify_table_by_interface (vat_main_t * vam)
19180 unformat_input_t *input = vam->input;
19181 vl_api_classify_table_by_interface_t *mp;
19183 u32 sw_if_index = ~0;
19185 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19187 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19189 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19194 if (sw_if_index == ~0)
19196 errmsg ("missing interface name or sw_if_index");
19200 /* Construct the API message */
19201 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19203 mp->sw_if_index = ntohl (sw_if_index);
19211 api_classify_table_info (vat_main_t * vam)
19213 unformat_input_t *input = vam->input;
19214 vl_api_classify_table_info_t *mp;
19218 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19220 if (unformat (input, "table_id %d", &table_id))
19225 if (table_id == ~0)
19227 errmsg ("missing table id");
19231 /* Construct the API message */
19232 M (CLASSIFY_TABLE_INFO, mp);
19234 mp->table_id = ntohl (table_id);
19242 api_classify_session_dump (vat_main_t * vam)
19244 unformat_input_t *input = vam->input;
19245 vl_api_classify_session_dump_t *mp;
19246 vl_api_control_ping_t *mp_ping;
19250 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19252 if (unformat (input, "table_id %d", &table_id))
19257 if (table_id == ~0)
19259 errmsg ("missing table id");
19263 /* Construct the API message */
19264 M (CLASSIFY_SESSION_DUMP, mp);
19266 mp->table_id = ntohl (table_id);
19269 /* Use a control ping for synchronization */
19270 MPING (CONTROL_PING, mp_ping);
19278 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19280 vat_main_t *vam = &vat_main;
19282 print (vam->ofp, "collector_address %U, collector_port %d, "
19283 "src_address %U, vrf_id %d, path_mtu %u, "
19284 "template_interval %u, udp_checksum %d",
19285 format_ip4_address, mp->collector_address,
19286 ntohs (mp->collector_port),
19287 format_ip4_address, mp->src_address,
19288 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19289 ntohl (mp->template_interval), mp->udp_checksum);
19292 vam->result_ready = 1;
19296 vl_api_ipfix_exporter_details_t_handler_json
19297 (vl_api_ipfix_exporter_details_t * mp)
19299 vat_main_t *vam = &vat_main;
19300 vat_json_node_t node;
19301 struct in_addr collector_address;
19302 struct in_addr src_address;
19304 vat_json_init_object (&node);
19305 clib_memcpy (&collector_address, &mp->collector_address,
19306 sizeof (collector_address));
19307 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19308 vat_json_object_add_uint (&node, "collector_port",
19309 ntohs (mp->collector_port));
19310 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19311 vat_json_object_add_ip4 (&node, "src_address", src_address);
19312 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19313 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19314 vat_json_object_add_uint (&node, "template_interval",
19315 ntohl (mp->template_interval));
19316 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19318 vat_json_print (vam->ofp, &node);
19319 vat_json_free (&node);
19321 vam->result_ready = 1;
19325 api_ipfix_exporter_dump (vat_main_t * vam)
19327 vl_api_ipfix_exporter_dump_t *mp;
19330 /* Construct the API message */
19331 M (IPFIX_EXPORTER_DUMP, mp);
19340 api_ipfix_classify_stream_dump (vat_main_t * vam)
19342 vl_api_ipfix_classify_stream_dump_t *mp;
19345 /* Construct the API message */
19346 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19357 vl_api_ipfix_classify_stream_details_t_handler
19358 (vl_api_ipfix_classify_stream_details_t * mp)
19360 vat_main_t *vam = &vat_main;
19361 print (vam->ofp, "domain_id %d, src_port %d",
19362 ntohl (mp->domain_id), ntohs (mp->src_port));
19364 vam->result_ready = 1;
19368 vl_api_ipfix_classify_stream_details_t_handler_json
19369 (vl_api_ipfix_classify_stream_details_t * mp)
19371 vat_main_t *vam = &vat_main;
19372 vat_json_node_t node;
19374 vat_json_init_object (&node);
19375 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19376 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19378 vat_json_print (vam->ofp, &node);
19379 vat_json_free (&node);
19381 vam->result_ready = 1;
19385 api_ipfix_classify_table_dump (vat_main_t * vam)
19387 vl_api_ipfix_classify_table_dump_t *mp;
19388 vl_api_control_ping_t *mp_ping;
19391 if (!vam->json_output)
19393 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19394 "transport_protocol");
19397 /* Construct the API message */
19398 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19403 /* Use a control ping for synchronization */
19404 MPING (CONTROL_PING, mp_ping);
19412 vl_api_ipfix_classify_table_details_t_handler
19413 (vl_api_ipfix_classify_table_details_t * mp)
19415 vat_main_t *vam = &vat_main;
19416 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19417 mp->transport_protocol);
19421 vl_api_ipfix_classify_table_details_t_handler_json
19422 (vl_api_ipfix_classify_table_details_t * mp)
19424 vat_json_node_t *node = NULL;
19425 vat_main_t *vam = &vat_main;
19427 if (VAT_JSON_ARRAY != vam->json_tree.type)
19429 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19430 vat_json_init_array (&vam->json_tree);
19433 node = vat_json_array_add (&vam->json_tree);
19434 vat_json_init_object (node);
19436 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19437 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19438 vat_json_object_add_uint (node, "transport_protocol",
19439 mp->transport_protocol);
19443 api_sw_interface_span_enable_disable (vat_main_t * vam)
19445 unformat_input_t *i = vam->input;
19446 vl_api_sw_interface_span_enable_disable_t *mp;
19447 u32 src_sw_if_index = ~0;
19448 u32 dst_sw_if_index = ~0;
19453 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19456 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19458 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19462 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19464 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19466 else if (unformat (i, "disable"))
19468 else if (unformat (i, "rx"))
19470 else if (unformat (i, "tx"))
19472 else if (unformat (i, "both"))
19474 else if (unformat (i, "l2"))
19480 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19482 mp->sw_if_index_from = htonl (src_sw_if_index);
19483 mp->sw_if_index_to = htonl (dst_sw_if_index);
19493 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19496 vat_main_t *vam = &vat_main;
19497 u8 *sw_if_from_name = 0;
19498 u8 *sw_if_to_name = 0;
19499 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19500 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19501 char *states[] = { "none", "rx", "tx", "both" };
19505 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19507 if ((u32) p->value[0] == sw_if_index_from)
19509 sw_if_from_name = (u8 *)(p->key);
19513 if ((u32) p->value[0] == sw_if_index_to)
19515 sw_if_to_name = (u8 *)(p->key);
19516 if (sw_if_from_name)
19521 print (vam->ofp, "%20s => %20s (%s)",
19522 sw_if_from_name, sw_if_to_name, states[mp->state]);
19526 vl_api_sw_interface_span_details_t_handler_json
19527 (vl_api_sw_interface_span_details_t * mp)
19529 vat_main_t *vam = &vat_main;
19530 vat_json_node_t *node = NULL;
19531 u8 *sw_if_from_name = 0;
19532 u8 *sw_if_to_name = 0;
19533 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19534 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19538 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19540 if ((u32) p->value[0] == sw_if_index_from)
19542 sw_if_from_name = (u8 *)(p->key);
19546 if ((u32) p->value[0] == sw_if_index_to)
19548 sw_if_to_name = (u8 *)(p->key);
19549 if (sw_if_from_name)
19555 if (VAT_JSON_ARRAY != vam->json_tree.type)
19557 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19558 vat_json_init_array (&vam->json_tree);
19560 node = vat_json_array_add (&vam->json_tree);
19562 vat_json_init_object (node);
19563 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19564 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19565 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19566 if (0 != sw_if_to_name)
19568 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19570 vat_json_object_add_uint (node, "state", mp->state);
19574 api_sw_interface_span_dump (vat_main_t * vam)
19576 unformat_input_t *input = vam->input;
19577 vl_api_sw_interface_span_dump_t *mp;
19578 vl_api_control_ping_t *mp_ping;
19582 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19584 if (unformat (input, "l2"))
19590 M (SW_INTERFACE_SPAN_DUMP, mp);
19594 /* Use a control ping for synchronization */
19595 MPING (CONTROL_PING, mp_ping);
19603 api_pg_create_interface (vat_main_t * vam)
19605 unformat_input_t *input = vam->input;
19606 vl_api_pg_create_interface_t *mp;
19610 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19612 if (unformat (input, "if_id %d", &if_id))
19619 errmsg ("missing pg interface index");
19623 /* Construct the API message */
19624 M (PG_CREATE_INTERFACE, mp);
19626 mp->interface_id = ntohl (if_id);
19634 api_pg_capture (vat_main_t * vam)
19636 unformat_input_t *input = vam->input;
19637 vl_api_pg_capture_t *mp;
19642 u8 pcap_file_set = 0;
19645 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19647 if (unformat (input, "if_id %d", &if_id))
19649 else if (unformat (input, "pcap %s", &pcap_file))
19651 else if (unformat (input, "count %d", &count))
19653 else if (unformat (input, "disable"))
19660 errmsg ("missing pg interface index");
19663 if (pcap_file_set > 0)
19665 if (vec_len (pcap_file) > 255)
19667 errmsg ("pcap file name is too long");
19672 u32 name_len = vec_len (pcap_file);
19673 /* Construct the API message */
19674 M (PG_CAPTURE, mp);
19676 mp->interface_id = ntohl (if_id);
19677 mp->is_enabled = enable;
19678 mp->count = ntohl (count);
19679 mp->pcap_name_length = ntohl (name_len);
19680 if (pcap_file_set != 0)
19682 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19684 vec_free (pcap_file);
19692 api_pg_enable_disable (vat_main_t * vam)
19694 unformat_input_t *input = vam->input;
19695 vl_api_pg_enable_disable_t *mp;
19698 u8 stream_name_set = 0;
19699 u8 *stream_name = 0;
19701 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19703 if (unformat (input, "stream %s", &stream_name))
19704 stream_name_set = 1;
19705 else if (unformat (input, "disable"))
19711 if (stream_name_set > 0)
19713 if (vec_len (stream_name) > 255)
19715 errmsg ("stream name too long");
19720 u32 name_len = vec_len (stream_name);
19721 /* Construct the API message */
19722 M (PG_ENABLE_DISABLE, mp);
19724 mp->is_enabled = enable;
19725 if (stream_name_set != 0)
19727 mp->stream_name_length = ntohl (name_len);
19728 clib_memcpy (mp->stream_name, stream_name, name_len);
19730 vec_free (stream_name);
19738 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19740 unformat_input_t *input = vam->input;
19741 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19743 u16 *low_ports = 0;
19744 u16 *high_ports = 0;
19747 ip4_address_t ip4_addr;
19748 ip6_address_t ip6_addr;
19757 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19759 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
19765 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
19770 else if (unformat (input, "vrf %d", &vrf_id))
19772 else if (unformat (input, "del"))
19774 else if (unformat (input, "port %d", &tmp))
19776 if (tmp == 0 || tmp > 65535)
19778 errmsg ("port %d out of range", tmp);
19782 this_hi = this_low + 1;
19783 vec_add1 (low_ports, this_low);
19784 vec_add1 (high_ports, this_hi);
19786 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19788 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19790 errmsg ("incorrect range parameters");
19794 /* Note: in debug CLI +1 is added to high before
19795 passing to real fn that does "the work"
19796 (ip_source_and_port_range_check_add_del).
19797 This fn is a wrapper around the binary API fn a
19798 control plane will call, which expects this increment
19799 to have occurred. Hence letting the binary API control
19800 plane fn do the increment for consistency between VAT
19801 and other control planes.
19804 vec_add1 (low_ports, this_low);
19805 vec_add1 (high_ports, this_hi);
19811 if (prefix_set == 0)
19813 errmsg ("<address>/<mask> not specified");
19819 errmsg ("VRF ID required, not specified");
19826 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19830 if (vec_len (low_ports) == 0)
19832 errmsg ("At least one port or port range required");
19836 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19838 mp->is_add = is_add;
19843 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
19848 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
19851 mp->mask_length = length;
19852 mp->number_of_ranges = vec_len (low_ports);
19854 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
19855 vec_free (low_ports);
19857 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
19858 vec_free (high_ports);
19860 mp->vrf_id = ntohl (vrf_id);
19868 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
19870 unformat_input_t *input = vam->input;
19871 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
19872 u32 sw_if_index = ~0;
19874 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
19875 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
19879 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19881 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19883 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19885 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
19887 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
19889 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
19891 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
19893 else if (unformat (input, "del"))
19899 if (sw_if_index == ~0)
19901 errmsg ("Interface required but not specified");
19907 errmsg ("VRF ID required but not specified");
19911 if (tcp_out_vrf_id == 0
19912 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
19915 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19919 /* Construct the API message */
19920 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
19922 mp->sw_if_index = ntohl (sw_if_index);
19923 mp->is_add = is_add;
19924 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
19925 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
19926 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
19927 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
19932 /* Wait for a reply... */
19938 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
19940 unformat_input_t *i = vam->input;
19941 vl_api_ipsec_gre_add_del_tunnel_t *mp;
19942 u32 local_sa_id = 0;
19943 u32 remote_sa_id = 0;
19944 ip4_address_t src_address;
19945 ip4_address_t dst_address;
19949 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19951 if (unformat (i, "local_sa %d", &local_sa_id))
19953 else if (unformat (i, "remote_sa %d", &remote_sa_id))
19955 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
19957 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
19959 else if (unformat (i, "del"))
19963 clib_warning ("parse error '%U'", format_unformat_error, i);
19968 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
19970 mp->local_sa_id = ntohl (local_sa_id);
19971 mp->remote_sa_id = ntohl (remote_sa_id);
19972 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
19973 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
19974 mp->is_add = is_add;
19982 api_punt (vat_main_t * vam)
19984 unformat_input_t *i = vam->input;
19992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19994 if (unformat (i, "ip %d", &ipv))
19996 else if (unformat (i, "protocol %d", &protocol))
19998 else if (unformat (i, "port %d", &port))
20000 else if (unformat (i, "del"))
20004 clib_warning ("parse error '%U'", format_unformat_error, i);
20011 mp->is_add = (u8) is_add;
20012 mp->ipv = (u8) ipv;
20013 mp->l4_protocol = (u8) protocol;
20014 mp->l4_port = htons ((u16) port);
20021 static void vl_api_ipsec_gre_tunnel_details_t_handler
20022 (vl_api_ipsec_gre_tunnel_details_t * mp)
20024 vat_main_t *vam = &vat_main;
20026 print (vam->ofp, "%11d%15U%15U%14d%14d",
20027 ntohl (mp->sw_if_index),
20028 format_ip4_address, &mp->src_address,
20029 format_ip4_address, &mp->dst_address,
20030 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
20033 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
20034 (vl_api_ipsec_gre_tunnel_details_t * mp)
20036 vat_main_t *vam = &vat_main;
20037 vat_json_node_t *node = NULL;
20038 struct in_addr ip4;
20040 if (VAT_JSON_ARRAY != vam->json_tree.type)
20042 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20043 vat_json_init_array (&vam->json_tree);
20045 node = vat_json_array_add (&vam->json_tree);
20047 vat_json_init_object (node);
20048 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20049 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
20050 vat_json_object_add_ip4 (node, "src_address", ip4);
20051 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
20052 vat_json_object_add_ip4 (node, "dst_address", ip4);
20053 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
20054 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
20058 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
20060 unformat_input_t *i = vam->input;
20061 vl_api_ipsec_gre_tunnel_dump_t *mp;
20062 vl_api_control_ping_t *mp_ping;
20064 u8 sw_if_index_set = 0;
20067 /* Parse args required to build the message */
20068 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20070 if (unformat (i, "sw_if_index %d", &sw_if_index))
20071 sw_if_index_set = 1;
20076 if (sw_if_index_set == 0)
20081 if (!vam->json_output)
20083 print (vam->ofp, "%11s%15s%15s%14s%14s",
20084 "sw_if_index", "src_address", "dst_address",
20085 "local_sa_id", "remote_sa_id");
20088 /* Get list of gre-tunnel interfaces */
20089 M (IPSEC_GRE_TUNNEL_DUMP, mp);
20091 mp->sw_if_index = htonl (sw_if_index);
20095 /* Use a control ping for synchronization */
20096 MPING (CONTROL_PING, mp_ping);
20104 api_delete_subif (vat_main_t * vam)
20106 unformat_input_t *i = vam->input;
20107 vl_api_delete_subif_t *mp;
20108 u32 sw_if_index = ~0;
20111 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20113 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20115 if (unformat (i, "sw_if_index %d", &sw_if_index))
20121 if (sw_if_index == ~0)
20123 errmsg ("missing sw_if_index");
20127 /* Construct the API message */
20128 M (DELETE_SUBIF, mp);
20129 mp->sw_if_index = ntohl (sw_if_index);
20136 #define foreach_pbb_vtr_op \
20137 _("disable", L2_VTR_DISABLED) \
20138 _("pop", L2_VTR_POP_2) \
20139 _("push", L2_VTR_PUSH_2)
20142 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20144 unformat_input_t *i = vam->input;
20145 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20146 u32 sw_if_index = ~0, vtr_op = ~0;
20147 u16 outer_tag = ~0;
20148 u8 dmac[6], smac[6];
20149 u8 dmac_set = 0, smac_set = 0;
20155 /* Shut up coverity */
20156 memset (dmac, 0, sizeof (dmac));
20157 memset (smac, 0, sizeof (smac));
20159 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20161 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20163 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20165 else if (unformat (i, "vtr_op %d", &vtr_op))
20167 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20170 else if (unformat (i, "translate_pbb_stag"))
20172 if (unformat (i, "%d", &tmp))
20174 vtr_op = L2_VTR_TRANSLATE_2_1;
20180 ("translate_pbb_stag operation requires outer tag definition");
20184 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20186 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20188 else if (unformat (i, "sid %d", &sid))
20190 else if (unformat (i, "vlanid %d", &tmp))
20194 clib_warning ("parse error '%U'", format_unformat_error, i);
20199 if ((sw_if_index == ~0) || (vtr_op == ~0))
20201 errmsg ("missing sw_if_index or vtr operation");
20204 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20205 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20208 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20212 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20213 mp->sw_if_index = ntohl (sw_if_index);
20214 mp->vtr_op = ntohl (vtr_op);
20215 mp->outer_tag = ntohs (outer_tag);
20216 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20217 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20218 mp->b_vlanid = ntohs (vlanid);
20219 mp->i_sid = ntohl (sid);
20227 api_flow_classify_set_interface (vat_main_t * vam)
20229 unformat_input_t *i = vam->input;
20230 vl_api_flow_classify_set_interface_t *mp;
20232 int sw_if_index_set;
20233 u32 ip4_table_index = ~0;
20234 u32 ip6_table_index = ~0;
20238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20240 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20241 sw_if_index_set = 1;
20242 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20243 sw_if_index_set = 1;
20244 else if (unformat (i, "del"))
20246 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20248 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20252 clib_warning ("parse error '%U'", format_unformat_error, i);
20257 if (sw_if_index_set == 0)
20259 errmsg ("missing interface name or sw_if_index");
20263 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20265 mp->sw_if_index = ntohl (sw_if_index);
20266 mp->ip4_table_index = ntohl (ip4_table_index);
20267 mp->ip6_table_index = ntohl (ip6_table_index);
20268 mp->is_add = is_add;
20276 api_flow_classify_dump (vat_main_t * vam)
20278 unformat_input_t *i = vam->input;
20279 vl_api_flow_classify_dump_t *mp;
20280 vl_api_control_ping_t *mp_ping;
20281 u8 type = FLOW_CLASSIFY_N_TABLES;
20284 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20288 errmsg ("classify table type must be specified");
20292 if (!vam->json_output)
20294 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20297 M (FLOW_CLASSIFY_DUMP, mp);
20302 /* Use a control ping for synchronization */
20303 MPING (CONTROL_PING, mp_ping);
20306 /* Wait for a reply... */
20312 api_feature_enable_disable (vat_main_t * vam)
20314 unformat_input_t *i = vam->input;
20315 vl_api_feature_enable_disable_t *mp;
20317 u8 *feature_name = 0;
20318 u32 sw_if_index = ~0;
20322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20324 if (unformat (i, "arc_name %s", &arc_name))
20326 else if (unformat (i, "feature_name %s", &feature_name))
20329 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20331 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20333 else if (unformat (i, "disable"))
20341 errmsg ("missing arc name");
20344 if (vec_len (arc_name) > 63)
20346 errmsg ("arc name too long");
20349 if (feature_name == 0)
20351 errmsg ("missing feature name");
20354 if (vec_len (feature_name) > 63)
20356 errmsg ("feature name too long");
20359 if (sw_if_index == ~0)
20361 errmsg ("missing interface name or sw_if_index");
20365 /* Construct the API message */
20366 M (FEATURE_ENABLE_DISABLE, mp);
20367 mp->sw_if_index = ntohl (sw_if_index);
20368 mp->enable = enable;
20369 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20370 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20371 vec_free (arc_name);
20372 vec_free (feature_name);
20380 api_sw_interface_tag_add_del (vat_main_t * vam)
20382 unformat_input_t *i = vam->input;
20383 vl_api_sw_interface_tag_add_del_t *mp;
20384 u32 sw_if_index = ~0;
20389 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20391 if (unformat (i, "tag %s", &tag))
20393 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20395 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20397 else if (unformat (i, "del"))
20403 if (sw_if_index == ~0)
20405 errmsg ("missing interface name or sw_if_index");
20409 if (enable && (tag == 0))
20411 errmsg ("no tag specified");
20415 /* Construct the API message */
20416 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20417 mp->sw_if_index = ntohl (sw_if_index);
20418 mp->is_add = enable;
20420 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20428 static void vl_api_l2_xconnect_details_t_handler
20429 (vl_api_l2_xconnect_details_t * mp)
20431 vat_main_t *vam = &vat_main;
20433 print (vam->ofp, "%15d%15d",
20434 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20437 static void vl_api_l2_xconnect_details_t_handler_json
20438 (vl_api_l2_xconnect_details_t * mp)
20440 vat_main_t *vam = &vat_main;
20441 vat_json_node_t *node = NULL;
20443 if (VAT_JSON_ARRAY != vam->json_tree.type)
20445 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20446 vat_json_init_array (&vam->json_tree);
20448 node = vat_json_array_add (&vam->json_tree);
20450 vat_json_init_object (node);
20451 vat_json_object_add_uint (node, "rx_sw_if_index",
20452 ntohl (mp->rx_sw_if_index));
20453 vat_json_object_add_uint (node, "tx_sw_if_index",
20454 ntohl (mp->tx_sw_if_index));
20458 api_l2_xconnect_dump (vat_main_t * vam)
20460 vl_api_l2_xconnect_dump_t *mp;
20461 vl_api_control_ping_t *mp_ping;
20464 if (!vam->json_output)
20466 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20469 M (L2_XCONNECT_DUMP, mp);
20473 /* Use a control ping for synchronization */
20474 MPING (CONTROL_PING, mp_ping);
20482 api_sw_interface_set_mtu (vat_main_t * vam)
20484 unformat_input_t *i = vam->input;
20485 vl_api_sw_interface_set_mtu_t *mp;
20486 u32 sw_if_index = ~0;
20490 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20492 if (unformat (i, "mtu %d", &mtu))
20494 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20496 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20502 if (sw_if_index == ~0)
20504 errmsg ("missing interface name or sw_if_index");
20510 errmsg ("no mtu specified");
20514 /* Construct the API message */
20515 M (SW_INTERFACE_SET_MTU, mp);
20516 mp->sw_if_index = ntohl (sw_if_index);
20517 mp->mtu = ntohs ((u16) mtu);
20525 api_p2p_ethernet_add (vat_main_t * vam)
20527 unformat_input_t *i = vam->input;
20528 vl_api_p2p_ethernet_add_t *mp;
20529 u32 parent_if_index = ~0;
20535 memset (remote_mac, 0, sizeof (remote_mac));
20536 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20538 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20540 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20544 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20546 else if (unformat (i, "sub_id %d", &sub_id))
20550 clib_warning ("parse error '%U'", format_unformat_error, i);
20555 if (parent_if_index == ~0)
20557 errmsg ("missing interface name or sw_if_index");
20562 errmsg ("missing remote mac address");
20567 errmsg ("missing sub-interface id");
20571 M (P2P_ETHERNET_ADD, mp);
20572 mp->parent_if_index = ntohl (parent_if_index);
20573 mp->subif_id = ntohl (sub_id);
20574 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20582 api_p2p_ethernet_del (vat_main_t * vam)
20584 unformat_input_t *i = vam->input;
20585 vl_api_p2p_ethernet_del_t *mp;
20586 u32 parent_if_index = ~0;
20591 memset (remote_mac, 0, sizeof (remote_mac));
20592 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20594 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20596 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20600 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20604 clib_warning ("parse error '%U'", format_unformat_error, i);
20609 if (parent_if_index == ~0)
20611 errmsg ("missing interface name or sw_if_index");
20616 errmsg ("missing remote mac address");
20620 M (P2P_ETHERNET_DEL, mp);
20621 mp->parent_if_index = ntohl (parent_if_index);
20622 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20630 api_lldp_config (vat_main_t * vam)
20632 unformat_input_t *i = vam->input;
20633 vl_api_lldp_config_t *mp;
20635 int tx_interval = 0;
20636 u8 *sys_name = NULL;
20639 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20641 if (unformat (i, "system-name %s", &sys_name))
20643 else if (unformat (i, "tx-hold %d", &tx_hold))
20645 else if (unformat (i, "tx-interval %d", &tx_interval))
20649 clib_warning ("parse error '%U'", format_unformat_error, i);
20654 vec_add1 (sys_name, 0);
20656 M (LLDP_CONFIG, mp);
20657 mp->tx_hold = htonl (tx_hold);
20658 mp->tx_interval = htonl (tx_interval);
20659 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20660 vec_free (sys_name);
20668 api_sw_interface_set_lldp (vat_main_t * vam)
20670 unformat_input_t *i = vam->input;
20671 vl_api_sw_interface_set_lldp_t *mp;
20672 u32 sw_if_index = ~0;
20674 u8 *port_desc = NULL, *mgmt_oid = NULL;
20675 ip4_address_t ip4_addr;
20676 ip6_address_t ip6_addr;
20679 memset (&ip4_addr, 0, sizeof (ip4_addr));
20680 memset (&ip6_addr, 0, sizeof (ip6_addr));
20682 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20684 if (unformat (i, "disable"))
20687 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20689 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20691 else if (unformat (i, "port-desc %s", &port_desc))
20693 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
20695 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
20697 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
20703 if (sw_if_index == ~0)
20705 errmsg ("missing interface name or sw_if_index");
20709 /* Construct the API message */
20710 vec_add1 (port_desc, 0);
20711 vec_add1 (mgmt_oid, 0);
20712 M (SW_INTERFACE_SET_LLDP, mp);
20713 mp->sw_if_index = ntohl (sw_if_index);
20714 mp->enable = enable;
20715 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20716 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
20717 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
20718 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
20719 vec_free (port_desc);
20720 vec_free (mgmt_oid);
20728 api_tcp_configure_src_addresses (vat_main_t * vam)
20730 vl_api_tcp_configure_src_addresses_t *mp;
20731 unformat_input_t *i = vam->input;
20732 ip4_address_t v4first, v4last;
20733 ip6_address_t v6first, v6last;
20738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20740 if (unformat (i, "%U - %U",
20741 unformat_ip4_address, &v4first,
20742 unformat_ip4_address, &v4last))
20746 errmsg ("one range per message (range already set)");
20751 else if (unformat (i, "%U - %U",
20752 unformat_ip6_address, &v6first,
20753 unformat_ip6_address, &v6last))
20757 errmsg ("one range per message (range already set)");
20762 else if (unformat (i, "vrf %d", &vrf_id))
20768 if (range_set == 0)
20770 errmsg ("address range not set");
20774 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20775 mp->vrf_id = ntohl (vrf_id);
20777 if (range_set == 2)
20780 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20781 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20786 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20787 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20795 api_app_namespace_add_del (vat_main_t * vam)
20797 vl_api_app_namespace_add_del_t *mp;
20798 unformat_input_t *i = vam->input;
20799 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
20800 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
20804 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20806 if (unformat (i, "id %_%v%_", &ns_id))
20808 else if (unformat (i, "secret %lu", &secret))
20810 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20811 sw_if_index_set = 1;
20812 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
20814 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
20819 if (!ns_id || !secret_set || !sw_if_index_set)
20821 errmsg ("namespace id, secret and sw_if_index must be set");
20824 if (vec_len (ns_id) > 64)
20826 errmsg ("namespace id too long");
20829 M (APP_NAMESPACE_ADD_DEL, mp);
20831 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
20832 mp->namespace_id_len = vec_len (ns_id);
20833 mp->secret = secret;
20834 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20835 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
20836 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
20844 api_memfd_segment_create (vat_main_t * vam)
20846 unformat_input_t *i = vam->input;
20847 vl_api_memfd_segment_create_t *mp;
20848 u64 size = 64 << 20;
20851 #if VPP_API_TEST_BUILTIN == 1
20852 errmsg ("memfd_segment_create (builtin) not supported");
20856 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20858 if (unformat (i, "size %U", unformat_memory_size, &size))
20864 M (MEMFD_SEGMENT_CREATE, mp);
20865 mp->requested_size = size;
20872 api_dns_enable_disable (vat_main_t * vam)
20874 unformat_input_t *line_input = vam->input;
20875 vl_api_dns_enable_disable_t *mp;
20876 u8 enable_disable = 1;
20879 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20881 if (unformat (line_input, "disable"))
20882 enable_disable = 0;
20883 if (unformat (line_input, "enable"))
20884 enable_disable = 1;
20889 /* Construct the API message */
20890 M (DNS_ENABLE_DISABLE, mp);
20891 mp->enable = enable_disable;
20895 /* Wait for the reply */
20901 api_dns_resolve_name (vat_main_t * vam)
20903 unformat_input_t *line_input = vam->input;
20904 vl_api_dns_resolve_name_t *mp;
20908 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20910 if (unformat (line_input, "%s", &name))
20916 if (vec_len (name) > 127)
20918 errmsg ("name too long");
20922 /* Construct the API message */
20923 M (DNS_RESOLVE_NAME, mp);
20924 memcpy (mp->name, name, vec_len (name));
20929 /* Wait for the reply */
20935 api_dns_name_server_add_del (vat_main_t * vam)
20937 unformat_input_t *i = vam->input;
20938 vl_api_dns_name_server_add_del_t *mp;
20940 ip6_address_t ip6_server;
20941 ip4_address_t ip4_server;
20946 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20948 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
20950 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
20952 else if (unformat (i, "del"))
20956 clib_warning ("parse error '%U'", format_unformat_error, i);
20961 if (ip4_set && ip6_set)
20963 errmsg ("Only one server address allowed per message");
20966 if ((ip4_set + ip6_set) == 0)
20968 errmsg ("Server address required");
20972 /* Construct the API message */
20973 M (DNS_NAME_SERVER_ADD_DEL, mp);
20977 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
20982 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
20986 mp->is_add = is_add;
20991 /* Wait for a reply, return good/bad news */
20998 q_or_quit (vat_main_t * vam)
21000 #if VPP_API_TEST_BUILTIN == 0
21001 longjmp (vam->jump_buf, 1);
21003 return 0; /* not so much */
21007 q (vat_main_t * vam)
21009 return q_or_quit (vam);
21013 quit (vat_main_t * vam)
21015 return q_or_quit (vam);
21019 comment (vat_main_t * vam)
21025 cmd_cmp (void *a1, void *a2)
21030 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21034 help (vat_main_t * vam)
21039 unformat_input_t *i = vam->input;
21042 if (unformat (i, "%s", &name))
21046 vec_add1 (name, 0);
21048 hs = hash_get_mem (vam->help_by_name, name);
21050 print (vam->ofp, "usage: %s %s", name, hs[0]);
21052 print (vam->ofp, "No such msg / command '%s'", name);
21057 print (vam->ofp, "Help is available for the following:");
21060 hash_foreach_pair (p, vam->function_by_name,
21062 vec_add1 (cmds, (u8 *)(p->key));
21066 vec_sort_with_function (cmds, cmd_cmp);
21068 for (j = 0; j < vec_len (cmds); j++)
21069 print (vam->ofp, "%s", cmds[j]);
21076 set (vat_main_t * vam)
21078 u8 *name = 0, *value = 0;
21079 unformat_input_t *i = vam->input;
21081 if (unformat (i, "%s", &name))
21083 /* The input buffer is a vector, not a string. */
21084 value = vec_dup (i->buffer);
21085 vec_delete (value, i->index, 0);
21086 /* Almost certainly has a trailing newline */
21087 if (value[vec_len (value) - 1] == '\n')
21088 value[vec_len (value) - 1] = 0;
21089 /* Make sure it's a proper string, one way or the other */
21090 vec_add1 (value, 0);
21091 (void) clib_macro_set_value (&vam->macro_main,
21092 (char *) name, (char *) value);
21095 errmsg ("usage: set <name> <value>");
21103 unset (vat_main_t * vam)
21107 if (unformat (vam->input, "%s", &name))
21108 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21109 errmsg ("unset: %s wasn't set", name);
21122 macro_sort_cmp (void *a1, void *a2)
21124 macro_sort_t *s1 = a1;
21125 macro_sort_t *s2 = a2;
21127 return strcmp ((char *) (s1->name), (char *) (s2->name));
21131 dump_macro_table (vat_main_t * vam)
21133 macro_sort_t *sort_me = 0, *sm;
21138 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21140 vec_add2 (sort_me, sm, 1);
21141 sm->name = (u8 *)(p->key);
21142 sm->value = (u8 *) (p->value[0]);
21146 vec_sort_with_function (sort_me, macro_sort_cmp);
21148 if (vec_len (sort_me))
21149 print (vam->ofp, "%-15s%s", "Name", "Value");
21151 print (vam->ofp, "The macro table is empty...");
21153 for (i = 0; i < vec_len (sort_me); i++)
21154 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21159 dump_node_table (vat_main_t * vam)
21162 vlib_node_t *node, *next_node;
21164 if (vec_len (vam->graph_nodes) == 0)
21166 print (vam->ofp, "Node table empty, issue get_node_graph...");
21170 for (i = 0; i < vec_len (vam->graph_nodes); i++)
21172 node = vam->graph_nodes[i];
21173 print (vam->ofp, "[%d] %s", i, node->name);
21174 for (j = 0; j < vec_len (node->next_nodes); j++)
21176 if (node->next_nodes[j] != ~0)
21178 next_node = vam->graph_nodes[node->next_nodes[j]];
21179 print (vam->ofp, " [%d] %s", j, next_node->name);
21187 value_sort_cmp (void *a1, void *a2)
21189 name_sort_t *n1 = a1;
21190 name_sort_t *n2 = a2;
21192 if (n1->value < n2->value)
21194 if (n1->value > n2->value)
21201 dump_msg_api_table (vat_main_t * vam)
21203 api_main_t *am = &api_main;
21204 name_sort_t *nses = 0, *ns;
21209 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21211 vec_add2 (nses, ns, 1);
21212 ns->name = (u8 *)(hp->key);
21213 ns->value = (u32) hp->value[0];
21217 vec_sort_with_function (nses, value_sort_cmp);
21219 for (i = 0; i < vec_len (nses); i++)
21220 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21226 get_msg_id (vat_main_t * vam)
21231 if (unformat (vam->input, "%s", &name_and_crc))
21233 message_index = vl_api_get_msg_index (name_and_crc);
21234 if (message_index == ~0)
21236 print (vam->ofp, " '%s' not found", name_and_crc);
21239 print (vam->ofp, " '%s' has message index %d",
21240 name_and_crc, message_index);
21243 errmsg ("name_and_crc required...");
21248 search_node_table (vat_main_t * vam)
21250 unformat_input_t *line_input = vam->input;
21253 vlib_node_t *node, *next_node;
21256 if (vam->graph_node_index_by_name == 0)
21258 print (vam->ofp, "Node table empty, issue get_node_graph...");
21262 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21264 if (unformat (line_input, "%s", &node_to_find))
21266 vec_add1 (node_to_find, 0);
21267 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21270 print (vam->ofp, "%s not found...", node_to_find);
21273 node = vam->graph_nodes[p[0]];
21274 print (vam->ofp, "[%d] %s", p[0], node->name);
21275 for (j = 0; j < vec_len (node->next_nodes); j++)
21277 if (node->next_nodes[j] != ~0)
21279 next_node = vam->graph_nodes[node->next_nodes[j]];
21280 print (vam->ofp, " [%d] %s", j, next_node->name);
21287 clib_warning ("parse error '%U'", format_unformat_error,
21293 vec_free (node_to_find);
21302 script (vat_main_t * vam)
21304 #if (VPP_API_TEST_BUILTIN==0)
21306 char *save_current_file;
21307 unformat_input_t save_input;
21308 jmp_buf save_jump_buf;
21309 u32 save_line_number;
21311 FILE *new_fp, *save_ifp;
21313 if (unformat (vam->input, "%s", &s))
21315 new_fp = fopen ((char *) s, "r");
21318 errmsg ("Couldn't open script file %s", s);
21325 errmsg ("Missing script name");
21329 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21330 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21331 save_ifp = vam->ifp;
21332 save_line_number = vam->input_line_number;
21333 save_current_file = (char *) vam->current_file;
21335 vam->input_line_number = 0;
21337 vam->current_file = s;
21340 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
21341 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21342 vam->ifp = save_ifp;
21343 vam->input_line_number = save_line_number;
21344 vam->current_file = (u8 *) save_current_file;
21349 clib_warning ("use the exec command...");
21355 echo (vat_main_t * vam)
21357 print (vam->ofp, "%v", vam->input->buffer);
21361 /* List of API message constructors, CLI names map to api_xxx */
21362 #define foreach_vpe_api_msg \
21363 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21364 _(sw_interface_dump,"") \
21365 _(sw_interface_set_flags, \
21366 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21367 _(sw_interface_add_del_address, \
21368 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21369 _(sw_interface_set_table, \
21370 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21371 _(sw_interface_set_mpls_enable, \
21372 "<intfc> | sw_if_index [disable | dis]") \
21373 _(sw_interface_set_vpath, \
21374 "<intfc> | sw_if_index <id> enable | disable") \
21375 _(sw_interface_set_vxlan_bypass, \
21376 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21377 _(sw_interface_set_geneve_bypass, \
21378 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21379 _(sw_interface_set_l2_xconnect, \
21380 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21381 "enable | disable") \
21382 _(sw_interface_set_l2_bridge, \
21383 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21384 "[shg <split-horizon-group>] [bvi]\n" \
21385 "enable | disable") \
21386 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21387 _(bridge_domain_add_del, \
21388 "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") \
21389 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21391 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21392 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21393 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21395 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21397 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21399 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
21401 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
21403 "<vpp-if-name> | sw_if_index <id>") \
21404 _(sw_interface_tap_dump, "") \
21405 _(ip_table_add_del, \
21406 "table-id <n> [ipv6]\n") \
21407 _(ip_add_del_route, \
21408 "<addr>/<mask> via <addr> [table-id <n>]\n" \
21409 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
21410 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
21411 "[multipath] [count <n>]") \
21412 _(ip_mroute_add_del, \
21413 "<src> <grp>/<mask> [table-id <n>]\n" \
21414 "[<intfc> | sw_if_index <id>] [local] [del]") \
21415 _(mpls_table_add_del, \
21416 "table-id <n>\n") \
21417 _(mpls_route_add_del, \
21418 "<label> <eos> via <addr> [table-id <n>]\n" \
21419 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
21420 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
21421 "[multipath] [count <n>]") \
21422 _(mpls_ip_bind_unbind, \
21423 "<label> <addr/len>") \
21424 _(mpls_tunnel_add_del, \
21425 " via <addr> [table-id <n>]\n" \
21426 "sw_if_index <id>] [l2] [del]") \
21427 _(proxy_arp_add_del, \
21428 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
21429 _(proxy_arp_intfc_enable_disable, \
21430 "<intfc> | sw_if_index <id> enable | disable") \
21431 _(sw_interface_set_unnumbered, \
21432 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
21433 _(ip_neighbor_add_del, \
21434 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
21435 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
21436 _(reset_vrf, "vrf <id> [ipv6]") \
21437 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
21438 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
21439 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
21440 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
21441 "[outer_vlan_id_any][inner_vlan_id_any]") \
21442 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
21443 _(reset_fib, "vrf <n> [ipv6]") \
21444 _(dhcp_proxy_config, \
21445 "svr <v46-address> src <v46-address>\n" \
21446 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
21447 _(dhcp_proxy_set_vss, \
21448 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
21449 _(dhcp_proxy_dump, "ip6") \
21450 _(dhcp_client_config, \
21451 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
21452 _(set_ip_flow_hash, \
21453 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
21454 _(sw_interface_ip6_enable_disable, \
21455 "<intfc> | sw_if_index <id> enable | disable") \
21456 _(sw_interface_ip6_set_link_local_address, \
21457 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
21458 _(ip6nd_proxy_add_del, \
21459 "<intfc> | sw_if_index <id> <ip6-address>") \
21460 _(ip6nd_proxy_dump, "") \
21461 _(sw_interface_ip6nd_ra_prefix, \
21462 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
21463 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
21464 "[nolink] [isno]") \
21465 _(sw_interface_ip6nd_ra_config, \
21466 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
21467 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
21468 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
21469 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
21470 _(l2_patch_add_del, \
21471 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21472 "enable | disable") \
21473 _(sr_localsid_add_del, \
21474 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
21475 "fib-table <num> (end.psp) sw_if_index <num>") \
21476 _(classify_add_del_table, \
21477 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
21478 " [del] [del-chain] mask <mask-value>\n" \
21479 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
21480 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
21481 _(classify_add_del_session, \
21482 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
21483 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
21484 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
21485 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
21486 _(classify_set_interface_ip_table, \
21487 "<intfc> | sw_if_index <nn> table <nn>") \
21488 _(classify_set_interface_l2_tables, \
21489 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21490 " [other-table <nn>]") \
21491 _(get_node_index, "node <node-name") \
21492 _(add_node_next, "node <node-name> next <next-node-name>") \
21493 _(l2tpv3_create_tunnel, \
21494 "client_address <ip6-addr> our_address <ip6-addr>\n" \
21495 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
21496 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
21497 _(l2tpv3_set_tunnel_cookies, \
21498 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
21499 "[new_remote_cookie <nn>]\n") \
21500 _(l2tpv3_interface_enable_disable, \
21501 "<intfc> | sw_if_index <nn> enable | disable") \
21502 _(l2tpv3_set_lookup_key, \
21503 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
21504 _(sw_if_l2tpv3_tunnel_dump, "") \
21505 _(vxlan_add_del_tunnel, \
21506 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21507 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21508 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21509 _(geneve_add_del_tunnel, \
21510 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21511 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21512 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21513 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21514 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21515 _(gre_add_del_tunnel, \
21516 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
21517 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21518 _(l2_fib_clear_table, "") \
21519 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
21520 _(l2_interface_vlan_tag_rewrite, \
21521 "<intfc> | sw_if_index <nn> \n" \
21522 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
21523 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
21524 _(create_vhost_user_if, \
21525 "socket <filename> [server] [renumber <dev_instance>] " \
21526 "[mac <mac_address>]") \
21527 _(modify_vhost_user_if, \
21528 "<intfc> | sw_if_index <nn> socket <filename>\n" \
21529 "[server] [renumber <dev_instance>]") \
21530 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
21531 _(sw_interface_vhost_user_dump, "") \
21532 _(show_version, "") \
21533 _(vxlan_gpe_add_del_tunnel, \
21534 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
21535 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21536 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
21537 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
21538 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21539 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
21540 _(interface_name_renumber, \
21541 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
21542 _(input_acl_set_interface, \
21543 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21544 " [l2-table <nn>] [del]") \
21545 _(want_ip4_arp_events, "address <ip4-address> [del]") \
21546 _(want_ip6_nd_events, "address <ip6-address> [del]") \
21547 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
21548 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
21549 _(ip_dump, "ipv4 | ipv6") \
21550 _(ipsec_spd_add_del, "spd_id <n> [del]") \
21551 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
21553 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
21554 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
21555 " integ_alg <alg> integ_key <hex>") \
21556 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
21557 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
21558 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
21559 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
21560 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
21561 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
21562 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
21563 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
21564 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
21565 _(ipsec_sa_dump, "[sa_id <n>]") \
21566 _(ikev2_profile_add_del, "name <profile_name> [del]") \
21567 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
21568 "(auth_data 0x<data> | auth_data <data>)") \
21569 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
21570 "(id_data 0x<data> | id_data <data>) (local|remote)") \
21571 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
21572 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
21573 "(local|remote)") \
21574 _(ikev2_set_local_key, "file <absolute_file_path>") \
21575 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
21576 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
21577 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
21578 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
21579 _(ikev2_initiate_sa_init, "<profile_name>") \
21580 _(ikev2_initiate_del_ike_sa, "<ispi>") \
21581 _(ikev2_initiate_del_child_sa, "<ispi>") \
21582 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
21583 _(delete_loopback,"sw_if_index <nn>") \
21584 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
21585 _(map_add_domain, \
21586 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
21587 "ip6-src <ip6addr> " \
21588 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
21589 _(map_del_domain, "index <n>") \
21590 _(map_add_del_rule, \
21591 "index <n> psid <n> dst <ip6addr> [del]") \
21592 _(map_domain_dump, "") \
21593 _(map_rule_dump, "index <map-domain>") \
21594 _(want_interface_events, "enable|disable") \
21595 _(want_stats,"enable|disable") \
21596 _(get_first_msg_id, "client <name>") \
21597 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
21598 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
21599 "fib-id <nn> [ip4][ip6][default]") \
21600 _(get_node_graph, " ") \
21601 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
21602 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
21603 _(ioam_disable, "") \
21604 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
21605 " sw_if_index <sw_if_index> p <priority> " \
21606 "w <weight>] [del]") \
21607 _(one_add_del_locator, "locator-set <locator_name> " \
21608 "iface <intf> | sw_if_index <sw_if_index> " \
21609 "p <priority> w <weight> [del]") \
21610 _(one_add_del_local_eid,"vni <vni> eid " \
21611 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21612 "locator-set <locator_name> [del]" \
21613 "[key-id sha1|sha256 secret-key <secret-key>]")\
21614 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
21615 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
21616 _(one_enable_disable, "enable|disable") \
21617 _(one_map_register_enable_disable, "enable|disable") \
21618 _(one_map_register_fallback_threshold, "<value>") \
21619 _(one_rloc_probe_enable_disable, "enable|disable") \
21620 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21622 "rloc <locator> p <prio> " \
21623 "w <weight> [rloc <loc> ... ] " \
21624 "action <action> [del-all]") \
21625 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21627 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21628 _(one_use_petr, "ip-address> | disable") \
21629 _(one_map_request_mode, "src-dst|dst-only") \
21630 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21631 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21632 _(one_locator_set_dump, "[local | remote]") \
21633 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
21634 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21635 "[local] | [remote]") \
21636 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
21637 _(one_ndp_bd_get, "") \
21638 _(one_ndp_entries_get, "bd <bridge-domain>") \
21639 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
21640 _(one_l2_arp_bd_get, "") \
21641 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
21642 _(one_stats_enable_disable, "enable|disalbe") \
21643 _(show_one_stats_enable_disable, "") \
21644 _(one_eid_table_vni_dump, "") \
21645 _(one_eid_table_map_dump, "l2|l3") \
21646 _(one_map_resolver_dump, "") \
21647 _(one_map_server_dump, "") \
21648 _(one_adjacencies_get, "vni <vni>") \
21649 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
21650 _(show_one_rloc_probe_state, "") \
21651 _(show_one_map_register_state, "") \
21652 _(show_one_status, "") \
21653 _(one_stats_dump, "") \
21654 _(one_stats_flush, "") \
21655 _(one_get_map_request_itr_rlocs, "") \
21656 _(one_map_register_set_ttl, "<ttl>") \
21657 _(one_set_transport_protocol, "udp|api") \
21658 _(one_get_transport_protocol, "") \
21659 _(show_one_nsh_mapping, "") \
21660 _(show_one_pitr, "") \
21661 _(show_one_use_petr, "") \
21662 _(show_one_map_request_mode, "") \
21663 _(show_one_map_register_ttl, "") \
21664 _(show_one_map_register_fallback_threshold, "") \
21665 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
21666 " sw_if_index <sw_if_index> p <priority> " \
21667 "w <weight>] [del]") \
21668 _(lisp_add_del_locator, "locator-set <locator_name> " \
21669 "iface <intf> | sw_if_index <sw_if_index> " \
21670 "p <priority> w <weight> [del]") \
21671 _(lisp_add_del_local_eid,"vni <vni> eid " \
21672 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21673 "locator-set <locator_name> [del]" \
21674 "[key-id sha1|sha256 secret-key <secret-key>]") \
21675 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
21676 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
21677 _(lisp_enable_disable, "enable|disable") \
21678 _(lisp_map_register_enable_disable, "enable|disable") \
21679 _(lisp_rloc_probe_enable_disable, "enable|disable") \
21680 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21682 "rloc <locator> p <prio> " \
21683 "w <weight> [rloc <loc> ... ] " \
21684 "action <action> [del-all]") \
21685 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21687 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21688 _(lisp_use_petr, "<ip-address> | disable") \
21689 _(lisp_map_request_mode, "src-dst|dst-only") \
21690 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21691 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21692 _(lisp_locator_set_dump, "[local | remote]") \
21693 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
21694 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21695 "[local] | [remote]") \
21696 _(lisp_eid_table_vni_dump, "") \
21697 _(lisp_eid_table_map_dump, "l2|l3") \
21698 _(lisp_map_resolver_dump, "") \
21699 _(lisp_map_server_dump, "") \
21700 _(lisp_adjacencies_get, "vni <vni>") \
21701 _(gpe_fwd_entry_vnis_get, "") \
21702 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
21703 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
21704 "[table <table-id>]") \
21705 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
21706 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
21707 _(gpe_set_encap_mode, "lisp|vxlan") \
21708 _(gpe_get_encap_mode, "") \
21709 _(lisp_gpe_add_del_iface, "up|down") \
21710 _(lisp_gpe_enable_disable, "enable|disable") \
21711 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
21712 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
21713 _(show_lisp_rloc_probe_state, "") \
21714 _(show_lisp_map_register_state, "") \
21715 _(show_lisp_status, "") \
21716 _(lisp_get_map_request_itr_rlocs, "") \
21717 _(show_lisp_pitr, "") \
21718 _(show_lisp_use_petr, "") \
21719 _(show_lisp_map_request_mode, "") \
21720 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
21721 _(af_packet_delete, "name <host interface name>") \
21722 _(policer_add_del, "name <policer name> <params> [del]") \
21723 _(policer_dump, "[name <policer name>]") \
21724 _(policer_classify_set_interface, \
21725 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21726 " [l2-table <nn>] [del]") \
21727 _(policer_classify_dump, "type [ip4|ip6|l2]") \
21728 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
21729 "[master|slave]") \
21730 _(netmap_delete, "name <interface name>") \
21731 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
21732 _(mpls_fib_dump, "") \
21733 _(classify_table_ids, "") \
21734 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
21735 _(classify_table_info, "table_id <nn>") \
21736 _(classify_session_dump, "table_id <nn>") \
21737 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
21738 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
21739 "[template_interval <nn>] [udp_checksum]") \
21740 _(ipfix_exporter_dump, "") \
21741 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
21742 _(ipfix_classify_stream_dump, "") \
21743 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
21744 _(ipfix_classify_table_dump, "") \
21745 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
21746 _(sw_interface_span_dump, "[l2]") \
21747 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
21748 _(pg_create_interface, "if_id <nn>") \
21749 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
21750 _(pg_enable_disable, "[stream <id>] disable") \
21751 _(ip_source_and_port_range_check_add_del, \
21752 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
21753 _(ip_source_and_port_range_check_interface_add_del, \
21754 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
21755 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
21756 _(ipsec_gre_add_del_tunnel, \
21757 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
21758 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
21759 _(delete_subif,"<intfc> | sw_if_index <nn>") \
21760 _(l2_interface_pbb_tag_rewrite, \
21761 "<intfc> | sw_if_index <nn> \n" \
21762 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
21763 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
21764 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
21765 _(flow_classify_set_interface, \
21766 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
21767 _(flow_classify_dump, "type [ip4|ip6]") \
21768 _(ip_fib_dump, "") \
21769 _(ip_mfib_dump, "") \
21770 _(ip6_fib_dump, "") \
21771 _(ip6_mfib_dump, "") \
21772 _(feature_enable_disable, "arc_name <arc_name> " \
21773 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
21774 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
21776 _(l2_xconnect_dump, "") \
21777 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
21778 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
21779 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
21780 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
21781 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
21782 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
21783 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
21784 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
21785 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
21786 _(memfd_segment_create,"size <nnn>") \
21787 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
21788 _(dns_enable_disable, "[enable][disable]") \
21789 _(dns_name_server_add_del, "<ip-address> [del]") \
21790 _(dns_resolve_name, "<hostname>")
21792 /* List of command functions, CLI names map directly to functions */
21793 #define foreach_cli_function \
21794 _(comment, "usage: comment <ignore-rest-of-line>") \
21795 _(dump_interface_table, "usage: dump_interface_table") \
21796 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
21797 _(dump_ipv4_table, "usage: dump_ipv4_table") \
21798 _(dump_ipv6_table, "usage: dump_ipv6_table") \
21799 _(dump_stats_table, "usage: dump_stats_table") \
21800 _(dump_macro_table, "usage: dump_macro_table ") \
21801 _(dump_node_table, "usage: dump_node_table") \
21802 _(dump_msg_api_table, "usage: dump_msg_api_table") \
21803 _(get_msg_id, "usage: get_msg_id name_and_crc") \
21804 _(echo, "usage: echo <message>") \
21805 _(exec, "usage: exec <vpe-debug-CLI-command>") \
21806 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
21807 _(help, "usage: help") \
21808 _(q, "usage: quit") \
21809 _(quit, "usage: quit") \
21810 _(search_node_table, "usage: search_node_table <name>...") \
21811 _(set, "usage: set <variable-name> <value>") \
21812 _(script, "usage: script <file-name>") \
21813 _(unset, "usage: unset <variable-name>")
21815 static void vl_api_##n##_t_handler_uni \
21816 (vl_api_##n##_t * mp) \
21818 vat_main_t * vam = &vat_main; \
21819 if (vam->json_output) { \
21820 vl_api_##n##_t_handler_json(mp); \
21822 vl_api_##n##_t_handler(mp); \
21825 foreach_vpe_api_reply_msg;
21826 #if VPP_API_TEST_BUILTIN == 0
21827 foreach_standalone_reply_msg;
21832 vat_api_hookup (vat_main_t * vam)
21835 vl_msg_api_set_handlers(VL_API_##N, #n, \
21836 vl_api_##n##_t_handler_uni, \
21838 vl_api_##n##_t_endian, \
21839 vl_api_##n##_t_print, \
21840 sizeof(vl_api_##n##_t), 1);
21841 foreach_vpe_api_reply_msg;
21842 #if VPP_API_TEST_BUILTIN == 0
21843 foreach_standalone_reply_msg;
21847 #if (VPP_API_TEST_BUILTIN==0)
21848 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
21850 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
21852 vam->function_by_name = hash_create_string (0, sizeof (uword));
21854 vam->help_by_name = hash_create_string (0, sizeof (uword));
21857 /* API messages we can send */
21858 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
21859 foreach_vpe_api_msg;
21863 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21864 foreach_vpe_api_msg;
21867 /* CLI functions */
21868 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
21869 foreach_cli_function;
21873 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21874 foreach_cli_function;
21878 #if VPP_API_TEST_BUILTIN
21879 static clib_error_t *
21880 vat_api_hookup_shim (vlib_main_t * vm)
21882 vat_api_hookup (&vat_main);
21886 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
21890 * fd.io coding-style-patch-verification: ON
21893 * eval: (c-set-style "gnu")