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 _(ipsec_tunnel_if_set_key_reply) \
5081 _(ikev2_profile_add_del_reply) \
5082 _(ikev2_profile_set_auth_reply) \
5083 _(ikev2_profile_set_id_reply) \
5084 _(ikev2_profile_set_ts_reply) \
5085 _(ikev2_set_local_key_reply) \
5086 _(ikev2_set_responder_reply) \
5087 _(ikev2_set_ike_transforms_reply) \
5088 _(ikev2_set_esp_transforms_reply) \
5089 _(ikev2_set_sa_lifetime_reply) \
5090 _(ikev2_initiate_sa_init_reply) \
5091 _(ikev2_initiate_del_ike_sa_reply) \
5092 _(ikev2_initiate_del_child_sa_reply) \
5093 _(ikev2_initiate_rekey_child_sa_reply) \
5094 _(delete_loopback_reply) \
5095 _(bd_ip_mac_add_del_reply) \
5096 _(map_del_domain_reply) \
5097 _(map_add_del_rule_reply) \
5098 _(want_interface_events_reply) \
5099 _(want_stats_reply) \
5100 _(cop_interface_enable_disable_reply) \
5101 _(cop_whitelist_enable_disable_reply) \
5102 _(sw_interface_clear_stats_reply) \
5103 _(ioam_enable_reply) \
5104 _(ioam_disable_reply) \
5105 _(one_add_del_locator_reply) \
5106 _(one_add_del_local_eid_reply) \
5107 _(one_add_del_remote_mapping_reply) \
5108 _(one_add_del_adjacency_reply) \
5109 _(one_add_del_map_resolver_reply) \
5110 _(one_add_del_map_server_reply) \
5111 _(one_enable_disable_reply) \
5112 _(one_rloc_probe_enable_disable_reply) \
5113 _(one_map_register_enable_disable_reply) \
5114 _(one_map_register_set_ttl_reply) \
5115 _(one_set_transport_protocol_reply) \
5116 _(one_map_register_fallback_threshold_reply) \
5117 _(one_pitr_set_locator_set_reply) \
5118 _(one_map_request_mode_reply) \
5119 _(one_add_del_map_request_itr_rlocs_reply) \
5120 _(one_eid_table_add_del_map_reply) \
5121 _(one_use_petr_reply) \
5122 _(one_stats_enable_disable_reply) \
5123 _(one_add_del_l2_arp_entry_reply) \
5124 _(one_add_del_ndp_entry_reply) \
5125 _(one_stats_flush_reply) \
5126 _(gpe_enable_disable_reply) \
5127 _(gpe_set_encap_mode_reply) \
5128 _(gpe_add_del_iface_reply) \
5129 _(gpe_add_del_native_fwd_rpath_reply) \
5130 _(af_packet_delete_reply) \
5131 _(policer_classify_set_interface_reply) \
5132 _(netmap_create_reply) \
5133 _(netmap_delete_reply) \
5134 _(set_ipfix_exporter_reply) \
5135 _(set_ipfix_classify_stream_reply) \
5136 _(ipfix_classify_table_add_del_reply) \
5137 _(flow_classify_set_interface_reply) \
5138 _(sw_interface_span_enable_disable_reply) \
5139 _(pg_capture_reply) \
5140 _(pg_enable_disable_reply) \
5141 _(ip_source_and_port_range_check_add_del_reply) \
5142 _(ip_source_and_port_range_check_interface_add_del_reply)\
5143 _(delete_subif_reply) \
5144 _(l2_interface_pbb_tag_rewrite_reply) \
5146 _(feature_enable_disable_reply) \
5147 _(sw_interface_tag_add_del_reply) \
5148 _(sw_interface_set_mtu_reply) \
5149 _(p2p_ethernet_add_reply) \
5150 _(p2p_ethernet_del_reply) \
5151 _(lldp_config_reply) \
5152 _(sw_interface_set_lldp_reply) \
5153 _(tcp_configure_src_addresses_reply) \
5154 _(app_namespace_add_del_reply) \
5155 _(dns_enable_disable_reply) \
5156 _(dns_name_server_add_del_reply)
5159 static void vl_api_##n##_t_handler \
5160 (vl_api_##n##_t * mp) \
5162 vat_main_t * vam = &vat_main; \
5163 i32 retval = ntohl(mp->retval); \
5164 if (vam->async_mode) { \
5165 vam->async_errors += (retval < 0); \
5167 vam->retval = retval; \
5168 vam->result_ready = 1; \
5171 foreach_standard_reply_retval_handler;
5175 static void vl_api_##n##_t_handler_json \
5176 (vl_api_##n##_t * mp) \
5178 vat_main_t * vam = &vat_main; \
5179 vat_json_node_t node; \
5180 vat_json_init_object(&node); \
5181 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5182 vat_json_print(vam->ofp, &node); \
5183 vam->retval = ntohl(mp->retval); \
5184 vam->result_ready = 1; \
5186 foreach_standard_reply_retval_handler;
5190 * Table of message reply handlers, must include boilerplate handlers
5194 #define foreach_vpe_api_reply_msg \
5195 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5196 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5197 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5198 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5199 _(CONTROL_PING_REPLY, control_ping_reply) \
5200 _(CLI_REPLY, cli_reply) \
5201 _(CLI_INBAND_REPLY, cli_inband_reply) \
5202 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5203 sw_interface_add_del_address_reply) \
5204 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5205 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5206 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5207 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5208 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5209 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5210 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5211 sw_interface_set_l2_xconnect_reply) \
5212 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5213 sw_interface_set_l2_bridge_reply) \
5214 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5215 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5216 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5217 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5218 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5219 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5220 _(L2_FLAGS_REPLY, l2_flags_reply) \
5221 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5222 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5223 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5224 _(TAP_DELETE_REPLY, tap_delete_reply) \
5225 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5226 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5227 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5228 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5229 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5230 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5231 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5232 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5233 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5234 proxy_arp_intfc_enable_disable_reply) \
5235 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5236 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5237 sw_interface_set_unnumbered_reply) \
5238 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5239 _(RESET_VRF_REPLY, reset_vrf_reply) \
5240 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5241 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5242 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5243 _(RESET_FIB_REPLY, reset_fib_reply) \
5244 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5245 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5246 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5247 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5248 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5249 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5250 sw_interface_ip6_enable_disable_reply) \
5251 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5252 sw_interface_ip6_set_link_local_address_reply) \
5253 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5254 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5255 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5256 sw_interface_ip6nd_ra_prefix_reply) \
5257 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5258 sw_interface_ip6nd_ra_config_reply) \
5259 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5260 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5261 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5262 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5263 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5264 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5265 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5266 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5267 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5268 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5269 classify_set_interface_ip_table_reply) \
5270 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5271 classify_set_interface_l2_tables_reply) \
5272 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5273 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5274 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5275 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5276 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5277 l2tpv3_interface_enable_disable_reply) \
5278 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5279 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5280 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5281 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5282 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5283 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5284 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5285 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5286 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5287 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5288 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5289 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5290 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5291 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5292 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5293 _(SHOW_VERSION_REPLY, show_version_reply) \
5294 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5295 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5296 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5297 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5298 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5299 _(IP4_ARP_EVENT, ip4_arp_event) \
5300 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5301 _(IP6_ND_EVENT, ip6_nd_event) \
5302 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5303 _(L2_MACS_EVENT, l2_macs_event) \
5304 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5305 _(IP_ADDRESS_DETAILS, ip_address_details) \
5306 _(IP_DETAILS, ip_details) \
5307 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5308 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5309 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5310 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5311 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5312 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5313 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5314 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5315 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5316 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5317 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5318 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5319 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5320 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5321 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5322 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5323 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5324 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5325 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5326 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5327 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5328 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5329 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5330 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5331 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5332 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5333 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5334 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5335 _(MAP_RULE_DETAILS, map_rule_details) \
5336 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5337 _(WANT_STATS_REPLY, want_stats_reply) \
5338 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5339 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5340 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5341 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5342 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5343 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5344 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5345 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5346 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5347 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5348 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5349 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5350 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5351 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5352 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5353 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5354 one_map_register_enable_disable_reply) \
5355 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5356 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5357 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5358 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5359 one_map_register_fallback_threshold_reply) \
5360 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5361 one_rloc_probe_enable_disable_reply) \
5362 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5363 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5364 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5365 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5366 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5367 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5368 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5369 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5370 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5371 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5372 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5373 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5374 _(ONE_STATS_DETAILS, one_stats_details) \
5375 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5376 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5377 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5378 show_one_stats_enable_disable_reply) \
5379 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5380 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5381 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5382 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5383 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5384 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5385 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5386 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5387 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5388 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5389 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5390 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5391 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5392 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5393 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5394 gpe_add_del_native_fwd_rpath_reply) \
5395 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5396 gpe_fwd_entry_path_details) \
5397 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5398 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5399 one_add_del_map_request_itr_rlocs_reply) \
5400 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5401 one_get_map_request_itr_rlocs_reply) \
5402 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5403 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5404 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5405 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5406 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5407 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5408 show_one_map_register_state_reply) \
5409 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5410 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5411 show_one_map_register_fallback_threshold_reply) \
5412 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5413 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5414 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5415 _(POLICER_DETAILS, policer_details) \
5416 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5417 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5418 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5419 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5420 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5421 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5422 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5423 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5424 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5425 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5426 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5427 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5428 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5429 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5430 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5431 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5432 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5433 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5434 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5435 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5436 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5437 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5438 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5439 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5440 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5441 ip_source_and_port_range_check_add_del_reply) \
5442 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5443 ip_source_and_port_range_check_interface_add_del_reply) \
5444 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5445 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5446 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5447 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5448 _(PUNT_REPLY, punt_reply) \
5449 _(IP_FIB_DETAILS, ip_fib_details) \
5450 _(IP6_FIB_DETAILS, ip6_fib_details) \
5451 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5452 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5453 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5454 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5455 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5456 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5457 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5458 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5459 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5460 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5461 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5462 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5463 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5464 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5465 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply)
5467 #define foreach_standalone_reply_msg \
5468 _(SW_INTERFACE_EVENT, sw_interface_event) \
5469 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5470 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5471 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5472 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5473 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5474 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
5475 _(MEMFD_SEGMENT_CREATE_REPLY, memfd_segment_create_reply) \
5484 #define STR_VTR_OP_CASE(op) \
5485 case L2_VTR_ ## op: \
5489 str_vtr_op (u32 vtr_op)
5493 STR_VTR_OP_CASE (DISABLED);
5494 STR_VTR_OP_CASE (PUSH_1);
5495 STR_VTR_OP_CASE (PUSH_2);
5496 STR_VTR_OP_CASE (POP_1);
5497 STR_VTR_OP_CASE (POP_2);
5498 STR_VTR_OP_CASE (TRANSLATE_1_1);
5499 STR_VTR_OP_CASE (TRANSLATE_1_2);
5500 STR_VTR_OP_CASE (TRANSLATE_2_1);
5501 STR_VTR_OP_CASE (TRANSLATE_2_2);
5508 dump_sub_interface_table (vat_main_t * vam)
5510 const sw_interface_subif_t *sub = NULL;
5512 if (vam->json_output)
5515 ("JSON output supported only for VPE API calls and dump_stats_table");
5520 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5521 "Interface", "sw_if_index",
5522 "sub id", "dot1ad", "tags", "outer id",
5523 "inner id", "exact", "default", "outer any", "inner any");
5525 vec_foreach (sub, vam->sw_if_subif_table)
5528 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5529 sub->interface_name,
5531 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5532 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5533 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5534 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5535 if (sub->vtr_op != L2_VTR_DISABLED)
5538 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5539 "tag1: %d tag2: %d ]",
5540 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5541 sub->vtr_tag1, sub->vtr_tag2);
5549 name_sort_cmp (void *a1, void *a2)
5551 name_sort_t *n1 = a1;
5552 name_sort_t *n2 = a2;
5554 return strcmp ((char *) n1->name, (char *) n2->name);
5558 dump_interface_table (vat_main_t * vam)
5561 name_sort_t *nses = 0, *ns;
5563 if (vam->json_output)
5566 ("JSON output supported only for VPE API calls and dump_stats_table");
5571 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5573 vec_add2 (nses, ns, 1);
5574 ns->name = (u8 *)(p->key);
5575 ns->value = (u32) p->value[0];
5579 vec_sort_with_function (nses, name_sort_cmp);
5581 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5582 vec_foreach (ns, nses)
5584 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5591 dump_ip_table (vat_main_t * vam, int is_ipv6)
5593 const ip_details_t *det = NULL;
5594 const ip_address_details_t *address = NULL;
5597 print (vam->ofp, "%-12s", "sw_if_index");
5599 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5606 print (vam->ofp, "%-12d", i);
5607 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5612 vec_foreach (address, det->addr)
5616 is_ipv6 ? format_ip6_address : format_ip4_address,
5617 address->ip, address->prefix_length);
5625 dump_ipv4_table (vat_main_t * vam)
5627 if (vam->json_output)
5630 ("JSON output supported only for VPE API calls and dump_stats_table");
5634 return dump_ip_table (vam, 0);
5638 dump_ipv6_table (vat_main_t * vam)
5640 if (vam->json_output)
5643 ("JSON output supported only for VPE API calls and dump_stats_table");
5647 return dump_ip_table (vam, 1);
5651 counter_type_to_str (u8 counter_type, u8 is_combined)
5655 switch (counter_type)
5657 case VNET_INTERFACE_COUNTER_DROP:
5659 case VNET_INTERFACE_COUNTER_PUNT:
5661 case VNET_INTERFACE_COUNTER_IP4:
5663 case VNET_INTERFACE_COUNTER_IP6:
5665 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5667 case VNET_INTERFACE_COUNTER_RX_MISS:
5669 case VNET_INTERFACE_COUNTER_RX_ERROR:
5671 case VNET_INTERFACE_COUNTER_TX_ERROR:
5674 return "INVALID-COUNTER-TYPE";
5679 switch (counter_type)
5681 case VNET_INTERFACE_COUNTER_RX:
5683 case VNET_INTERFACE_COUNTER_TX:
5686 return "INVALID-COUNTER-TYPE";
5692 dump_stats_table (vat_main_t * vam)
5694 vat_json_node_t node;
5695 vat_json_node_t *msg_array;
5696 vat_json_node_t *msg;
5697 vat_json_node_t *counter_array;
5698 vat_json_node_t *counter;
5699 interface_counter_t c;
5701 ip4_fib_counter_t *c4;
5702 ip6_fib_counter_t *c6;
5703 ip4_nbr_counter_t *n4;
5704 ip6_nbr_counter_t *n6;
5707 if (!vam->json_output)
5709 clib_warning ("dump_stats_table supported only in JSON format");
5713 vat_json_init_object (&node);
5715 /* interface counters */
5716 msg_array = vat_json_object_add (&node, "interface_counters");
5717 vat_json_init_array (msg_array);
5718 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5720 msg = vat_json_array_add (msg_array);
5721 vat_json_init_object (msg);
5722 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5723 (u8 *) counter_type_to_str (i, 0));
5724 vat_json_object_add_int (msg, "is_combined", 0);
5725 counter_array = vat_json_object_add (msg, "data");
5726 vat_json_init_array (counter_array);
5727 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5729 packets = vam->simple_interface_counters[i][j];
5730 vat_json_array_add_uint (counter_array, packets);
5733 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5735 msg = vat_json_array_add (msg_array);
5736 vat_json_init_object (msg);
5737 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5738 (u8 *) counter_type_to_str (i, 1));
5739 vat_json_object_add_int (msg, "is_combined", 1);
5740 counter_array = vat_json_object_add (msg, "data");
5741 vat_json_init_array (counter_array);
5742 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5744 c = vam->combined_interface_counters[i][j];
5745 counter = vat_json_array_add (counter_array);
5746 vat_json_init_object (counter);
5747 vat_json_object_add_uint (counter, "packets", c.packets);
5748 vat_json_object_add_uint (counter, "bytes", c.bytes);
5752 /* ip4 fib counters */
5753 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5754 vat_json_init_array (msg_array);
5755 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5757 msg = vat_json_array_add (msg_array);
5758 vat_json_init_object (msg);
5759 vat_json_object_add_uint (msg, "vrf_id",
5760 vam->ip4_fib_counters_vrf_id_by_index[i]);
5761 counter_array = vat_json_object_add (msg, "c");
5762 vat_json_init_array (counter_array);
5763 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5765 counter = vat_json_array_add (counter_array);
5766 vat_json_init_object (counter);
5767 c4 = &vam->ip4_fib_counters[i][j];
5768 vat_json_object_add_ip4 (counter, "address", c4->address);
5769 vat_json_object_add_uint (counter, "address_length",
5770 c4->address_length);
5771 vat_json_object_add_uint (counter, "packets", c4->packets);
5772 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5776 /* ip6 fib counters */
5777 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5778 vat_json_init_array (msg_array);
5779 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5781 msg = vat_json_array_add (msg_array);
5782 vat_json_init_object (msg);
5783 vat_json_object_add_uint (msg, "vrf_id",
5784 vam->ip6_fib_counters_vrf_id_by_index[i]);
5785 counter_array = vat_json_object_add (msg, "c");
5786 vat_json_init_array (counter_array);
5787 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5789 counter = vat_json_array_add (counter_array);
5790 vat_json_init_object (counter);
5791 c6 = &vam->ip6_fib_counters[i][j];
5792 vat_json_object_add_ip6 (counter, "address", c6->address);
5793 vat_json_object_add_uint (counter, "address_length",
5794 c6->address_length);
5795 vat_json_object_add_uint (counter, "packets", c6->packets);
5796 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5800 /* ip4 nbr counters */
5801 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5802 vat_json_init_array (msg_array);
5803 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5805 msg = vat_json_array_add (msg_array);
5806 vat_json_init_object (msg);
5807 vat_json_object_add_uint (msg, "sw_if_index", i);
5808 counter_array = vat_json_object_add (msg, "c");
5809 vat_json_init_array (counter_array);
5810 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5812 counter = vat_json_array_add (counter_array);
5813 vat_json_init_object (counter);
5814 n4 = &vam->ip4_nbr_counters[i][j];
5815 vat_json_object_add_ip4 (counter, "address", n4->address);
5816 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5817 vat_json_object_add_uint (counter, "packets", n4->packets);
5818 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5822 /* ip6 nbr counters */
5823 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5824 vat_json_init_array (msg_array);
5825 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5827 msg = vat_json_array_add (msg_array);
5828 vat_json_init_object (msg);
5829 vat_json_object_add_uint (msg, "sw_if_index", i);
5830 counter_array = vat_json_object_add (msg, "c");
5831 vat_json_init_array (counter_array);
5832 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5834 counter = vat_json_array_add (counter_array);
5835 vat_json_init_object (counter);
5836 n6 = &vam->ip6_nbr_counters[i][j];
5837 vat_json_object_add_ip6 (counter, "address", n6->address);
5838 vat_json_object_add_uint (counter, "packets", n6->packets);
5839 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5843 vat_json_print (vam->ofp, &node);
5844 vat_json_free (&node);
5850 * Pass CLI buffers directly in the CLI_INBAND API message,
5851 * instead of an additional shared memory area.
5854 exec_inband (vat_main_t * vam)
5856 vl_api_cli_inband_t *mp;
5857 unformat_input_t *i = vam->input;
5860 if (vec_len (i->buffer) == 0)
5863 if (vam->exec_mode == 0 && unformat (i, "mode"))
5868 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5875 * In order for the CLI command to work, it
5876 * must be a vector ending in \n, not a C-string ending
5879 u32 len = vec_len (vam->input->buffer);
5880 M2 (CLI_INBAND, mp, len);
5881 clib_memcpy (mp->cmd, vam->input->buffer, len);
5882 mp->length = htonl (len);
5886 /* json responses may or may not include a useful reply... */
5887 if (vec_len (vam->cmd_reply))
5888 print (vam->ofp, (char *) (vam->cmd_reply));
5893 exec (vat_main_t * vam)
5895 return exec_inband (vam);
5899 api_create_loopback (vat_main_t * vam)
5901 unformat_input_t *i = vam->input;
5902 vl_api_create_loopback_t *mp;
5903 vl_api_create_loopback_instance_t *mp_lbi;
5906 u8 is_specified = 0;
5907 u32 user_instance = 0;
5910 memset (mac_address, 0, sizeof (mac_address));
5912 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5914 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5916 if (unformat (i, "instance %d", &user_instance))
5924 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5925 mp_lbi->is_specified = is_specified;
5927 mp_lbi->user_instance = htonl (user_instance);
5929 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5934 /* Construct the API message */
5935 M (CREATE_LOOPBACK, mp);
5937 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5946 api_delete_loopback (vat_main_t * vam)
5948 unformat_input_t *i = vam->input;
5949 vl_api_delete_loopback_t *mp;
5950 u32 sw_if_index = ~0;
5953 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5955 if (unformat (i, "sw_if_index %d", &sw_if_index))
5961 if (sw_if_index == ~0)
5963 errmsg ("missing sw_if_index");
5967 /* Construct the API message */
5968 M (DELETE_LOOPBACK, mp);
5969 mp->sw_if_index = ntohl (sw_if_index);
5977 api_want_stats (vat_main_t * vam)
5979 unformat_input_t *i = vam->input;
5980 vl_api_want_stats_t *mp;
5984 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5986 if (unformat (i, "enable"))
5988 else if (unformat (i, "disable"))
5996 errmsg ("missing enable|disable");
6001 mp->enable_disable = enable;
6009 api_want_interface_events (vat_main_t * vam)
6011 unformat_input_t *i = vam->input;
6012 vl_api_want_interface_events_t *mp;
6016 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6018 if (unformat (i, "enable"))
6020 else if (unformat (i, "disable"))
6028 errmsg ("missing enable|disable");
6032 M (WANT_INTERFACE_EVENTS, mp);
6033 mp->enable_disable = enable;
6035 vam->interface_event_display = enable;
6043 /* Note: non-static, called once to set up the initial intfc table */
6045 api_sw_interface_dump (vat_main_t * vam)
6047 vl_api_sw_interface_dump_t *mp;
6048 vl_api_control_ping_t *mp_ping;
6050 name_sort_t *nses = 0, *ns;
6051 sw_interface_subif_t *sub = NULL;
6054 /* Toss the old name table */
6056 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6058 vec_add2 (nses, ns, 1);
6059 ns->name = (u8 *)(p->key);
6060 ns->value = (u32) p->value[0];
6064 hash_free (vam->sw_if_index_by_interface_name);
6066 vec_foreach (ns, nses) vec_free (ns->name);
6070 vec_foreach (sub, vam->sw_if_subif_table)
6072 vec_free (sub->interface_name);
6074 vec_free (vam->sw_if_subif_table);
6076 /* recreate the interface name hash table */
6077 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6079 /* Get list of ethernets */
6080 M (SW_INTERFACE_DUMP, mp);
6081 mp->name_filter_valid = 1;
6082 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
6085 /* and local / loopback interfaces */
6086 M (SW_INTERFACE_DUMP, mp);
6087 mp->name_filter_valid = 1;
6088 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
6091 /* and packet-generator interfaces */
6092 M (SW_INTERFACE_DUMP, mp);
6093 mp->name_filter_valid = 1;
6094 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
6097 /* and vxlan-gpe tunnel interfaces */
6098 M (SW_INTERFACE_DUMP, mp);
6099 mp->name_filter_valid = 1;
6100 strncpy ((char *) mp->name_filter, "vxlan_gpe",
6101 sizeof (mp->name_filter) - 1);
6104 /* and vxlan tunnel interfaces */
6105 M (SW_INTERFACE_DUMP, mp);
6106 mp->name_filter_valid = 1;
6107 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
6110 /* and geneve tunnel interfaces */
6111 M (SW_INTERFACE_DUMP, mp);
6112 mp->name_filter_valid = 1;
6113 strncpy ((char *) mp->name_filter, "geneve", sizeof (mp->name_filter) - 1);
6116 /* and host (af_packet) interfaces */
6117 M (SW_INTERFACE_DUMP, mp);
6118 mp->name_filter_valid = 1;
6119 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
6122 /* and l2tpv3 tunnel interfaces */
6123 M (SW_INTERFACE_DUMP, mp);
6124 mp->name_filter_valid = 1;
6125 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
6126 sizeof (mp->name_filter) - 1);
6129 /* and GRE tunnel interfaces */
6130 M (SW_INTERFACE_DUMP, mp);
6131 mp->name_filter_valid = 1;
6132 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
6135 /* and LISP-GPE interfaces */
6136 M (SW_INTERFACE_DUMP, mp);
6137 mp->name_filter_valid = 1;
6138 strncpy ((char *) mp->name_filter, "lisp_gpe",
6139 sizeof (mp->name_filter) - 1);
6142 /* and IPSEC tunnel interfaces */
6143 M (SW_INTERFACE_DUMP, mp);
6144 mp->name_filter_valid = 1;
6145 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
6148 /* Use a control ping for synchronization */
6149 MPING (CONTROL_PING, mp_ping);
6157 api_sw_interface_set_flags (vat_main_t * vam)
6159 unformat_input_t *i = vam->input;
6160 vl_api_sw_interface_set_flags_t *mp;
6162 u8 sw_if_index_set = 0;
6166 /* Parse args required to build the message */
6167 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6169 if (unformat (i, "admin-up"))
6171 else if (unformat (i, "admin-down"))
6174 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6175 sw_if_index_set = 1;
6176 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6177 sw_if_index_set = 1;
6182 if (sw_if_index_set == 0)
6184 errmsg ("missing interface name or sw_if_index");
6188 /* Construct the API message */
6189 M (SW_INTERFACE_SET_FLAGS, mp);
6190 mp->sw_if_index = ntohl (sw_if_index);
6191 mp->admin_up_down = admin_up;
6196 /* Wait for a reply, return the good/bad news... */
6202 api_sw_interface_clear_stats (vat_main_t * vam)
6204 unformat_input_t *i = vam->input;
6205 vl_api_sw_interface_clear_stats_t *mp;
6207 u8 sw_if_index_set = 0;
6210 /* Parse args required to build the message */
6211 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6213 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6214 sw_if_index_set = 1;
6215 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6216 sw_if_index_set = 1;
6221 /* Construct the API message */
6222 M (SW_INTERFACE_CLEAR_STATS, mp);
6224 if (sw_if_index_set == 1)
6225 mp->sw_if_index = ntohl (sw_if_index);
6227 mp->sw_if_index = ~0;
6232 /* Wait for a reply, return the good/bad news... */
6238 api_sw_interface_add_del_address (vat_main_t * vam)
6240 unformat_input_t *i = vam->input;
6241 vl_api_sw_interface_add_del_address_t *mp;
6243 u8 sw_if_index_set = 0;
6244 u8 is_add = 1, del_all = 0;
6245 u32 address_length = 0;
6246 u8 v4_address_set = 0;
6247 u8 v6_address_set = 0;
6248 ip4_address_t v4address;
6249 ip6_address_t v6address;
6252 /* Parse args required to build the message */
6253 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6255 if (unformat (i, "del-all"))
6257 else if (unformat (i, "del"))
6260 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6261 sw_if_index_set = 1;
6262 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6263 sw_if_index_set = 1;
6264 else if (unformat (i, "%U/%d",
6265 unformat_ip4_address, &v4address, &address_length))
6267 else if (unformat (i, "%U/%d",
6268 unformat_ip6_address, &v6address, &address_length))
6274 if (sw_if_index_set == 0)
6276 errmsg ("missing interface name or sw_if_index");
6279 if (v4_address_set && v6_address_set)
6281 errmsg ("both v4 and v6 addresses set");
6284 if (!v4_address_set && !v6_address_set && !del_all)
6286 errmsg ("no addresses set");
6290 /* Construct the API message */
6291 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6293 mp->sw_if_index = ntohl (sw_if_index);
6294 mp->is_add = is_add;
6295 mp->del_all = del_all;
6299 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6303 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6305 mp->address_length = address_length;
6310 /* Wait for a reply, return good/bad news */
6316 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6318 unformat_input_t *i = vam->input;
6319 vl_api_sw_interface_set_mpls_enable_t *mp;
6321 u8 sw_if_index_set = 0;
6325 /* Parse args required to build the message */
6326 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6328 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6329 sw_if_index_set = 1;
6330 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6331 sw_if_index_set = 1;
6332 else if (unformat (i, "disable"))
6334 else if (unformat (i, "dis"))
6340 if (sw_if_index_set == 0)
6342 errmsg ("missing interface name or sw_if_index");
6346 /* Construct the API message */
6347 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6349 mp->sw_if_index = ntohl (sw_if_index);
6350 mp->enable = enable;
6355 /* Wait for a reply... */
6361 api_sw_interface_set_table (vat_main_t * vam)
6363 unformat_input_t *i = vam->input;
6364 vl_api_sw_interface_set_table_t *mp;
6365 u32 sw_if_index, vrf_id = 0;
6366 u8 sw_if_index_set = 0;
6370 /* Parse args required to build the message */
6371 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6373 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6374 sw_if_index_set = 1;
6375 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6376 sw_if_index_set = 1;
6377 else if (unformat (i, "vrf %d", &vrf_id))
6379 else if (unformat (i, "ipv6"))
6385 if (sw_if_index_set == 0)
6387 errmsg ("missing interface name or sw_if_index");
6391 /* Construct the API message */
6392 M (SW_INTERFACE_SET_TABLE, mp);
6394 mp->sw_if_index = ntohl (sw_if_index);
6395 mp->is_ipv6 = is_ipv6;
6396 mp->vrf_id = ntohl (vrf_id);
6401 /* Wait for a reply... */
6406 static void vl_api_sw_interface_get_table_reply_t_handler
6407 (vl_api_sw_interface_get_table_reply_t * mp)
6409 vat_main_t *vam = &vat_main;
6411 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6413 vam->retval = ntohl (mp->retval);
6414 vam->result_ready = 1;
6418 static void vl_api_sw_interface_get_table_reply_t_handler_json
6419 (vl_api_sw_interface_get_table_reply_t * mp)
6421 vat_main_t *vam = &vat_main;
6422 vat_json_node_t node;
6424 vat_json_init_object (&node);
6425 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6426 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6428 vat_json_print (vam->ofp, &node);
6429 vat_json_free (&node);
6431 vam->retval = ntohl (mp->retval);
6432 vam->result_ready = 1;
6436 api_sw_interface_get_table (vat_main_t * vam)
6438 unformat_input_t *i = vam->input;
6439 vl_api_sw_interface_get_table_t *mp;
6441 u8 sw_if_index_set = 0;
6445 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6447 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6448 sw_if_index_set = 1;
6449 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6450 sw_if_index_set = 1;
6451 else if (unformat (i, "ipv6"))
6457 if (sw_if_index_set == 0)
6459 errmsg ("missing interface name or sw_if_index");
6463 M (SW_INTERFACE_GET_TABLE, mp);
6464 mp->sw_if_index = htonl (sw_if_index);
6465 mp->is_ipv6 = is_ipv6;
6473 api_sw_interface_set_vpath (vat_main_t * vam)
6475 unformat_input_t *i = vam->input;
6476 vl_api_sw_interface_set_vpath_t *mp;
6477 u32 sw_if_index = 0;
6478 u8 sw_if_index_set = 0;
6482 /* Parse args required to build the message */
6483 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6485 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6486 sw_if_index_set = 1;
6487 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6488 sw_if_index_set = 1;
6489 else if (unformat (i, "enable"))
6491 else if (unformat (i, "disable"))
6497 if (sw_if_index_set == 0)
6499 errmsg ("missing interface name or sw_if_index");
6503 /* Construct the API message */
6504 M (SW_INTERFACE_SET_VPATH, mp);
6506 mp->sw_if_index = ntohl (sw_if_index);
6507 mp->enable = is_enable;
6512 /* Wait for a reply... */
6518 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6520 unformat_input_t *i = vam->input;
6521 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6522 u32 sw_if_index = 0;
6523 u8 sw_if_index_set = 0;
6528 /* Parse args required to build the message */
6529 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6531 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6532 sw_if_index_set = 1;
6533 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6534 sw_if_index_set = 1;
6535 else if (unformat (i, "enable"))
6537 else if (unformat (i, "disable"))
6539 else if (unformat (i, "ip4"))
6541 else if (unformat (i, "ip6"))
6547 if (sw_if_index_set == 0)
6549 errmsg ("missing interface name or sw_if_index");
6553 /* Construct the API message */
6554 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6556 mp->sw_if_index = ntohl (sw_if_index);
6557 mp->enable = is_enable;
6558 mp->is_ipv6 = is_ipv6;
6563 /* Wait for a reply... */
6569 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6571 unformat_input_t *i = vam->input;
6572 vl_api_sw_interface_set_geneve_bypass_t *mp;
6573 u32 sw_if_index = 0;
6574 u8 sw_if_index_set = 0;
6579 /* Parse args required to build the message */
6580 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6582 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6583 sw_if_index_set = 1;
6584 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6585 sw_if_index_set = 1;
6586 else if (unformat (i, "enable"))
6588 else if (unformat (i, "disable"))
6590 else if (unformat (i, "ip4"))
6592 else if (unformat (i, "ip6"))
6598 if (sw_if_index_set == 0)
6600 errmsg ("missing interface name or sw_if_index");
6604 /* Construct the API message */
6605 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6607 mp->sw_if_index = ntohl (sw_if_index);
6608 mp->enable = is_enable;
6609 mp->is_ipv6 = is_ipv6;
6614 /* Wait for a reply... */
6620 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6622 unformat_input_t *i = vam->input;
6623 vl_api_sw_interface_set_l2_xconnect_t *mp;
6625 u8 rx_sw_if_index_set = 0;
6627 u8 tx_sw_if_index_set = 0;
6631 /* Parse args required to build the message */
6632 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6634 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6635 rx_sw_if_index_set = 1;
6636 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6637 tx_sw_if_index_set = 1;
6638 else if (unformat (i, "rx"))
6640 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6642 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6644 rx_sw_if_index_set = 1;
6649 else if (unformat (i, "tx"))
6651 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6653 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6655 tx_sw_if_index_set = 1;
6660 else if (unformat (i, "enable"))
6662 else if (unformat (i, "disable"))
6668 if (rx_sw_if_index_set == 0)
6670 errmsg ("missing rx interface name or rx_sw_if_index");
6674 if (enable && (tx_sw_if_index_set == 0))
6676 errmsg ("missing tx interface name or tx_sw_if_index");
6680 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6682 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6683 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6684 mp->enable = enable;
6692 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6694 unformat_input_t *i = vam->input;
6695 vl_api_sw_interface_set_l2_bridge_t *mp;
6697 u8 rx_sw_if_index_set = 0;
6705 /* Parse args required to build the message */
6706 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6708 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6709 rx_sw_if_index_set = 1;
6710 else if (unformat (i, "bd_id %d", &bd_id))
6714 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6715 rx_sw_if_index_set = 1;
6716 else if (unformat (i, "shg %d", &shg))
6718 else if (unformat (i, "bvi"))
6720 else if (unformat (i, "enable"))
6722 else if (unformat (i, "disable"))
6728 if (rx_sw_if_index_set == 0)
6730 errmsg ("missing rx interface name or sw_if_index");
6734 if (enable && (bd_id_set == 0))
6736 errmsg ("missing bridge domain");
6740 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6742 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6743 mp->bd_id = ntohl (bd_id);
6746 mp->enable = enable;
6754 api_bridge_domain_dump (vat_main_t * vam)
6756 unformat_input_t *i = vam->input;
6757 vl_api_bridge_domain_dump_t *mp;
6758 vl_api_control_ping_t *mp_ping;
6762 /* Parse args required to build the message */
6763 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6765 if (unformat (i, "bd_id %d", &bd_id))
6771 M (BRIDGE_DOMAIN_DUMP, mp);
6772 mp->bd_id = ntohl (bd_id);
6775 /* Use a control ping for synchronization */
6776 MPING (CONTROL_PING, mp_ping);
6784 api_bridge_domain_add_del (vat_main_t * vam)
6786 unformat_input_t *i = vam->input;
6787 vl_api_bridge_domain_add_del_t *mp;
6790 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6795 /* Parse args required to build the message */
6796 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6798 if (unformat (i, "bd_id %d", &bd_id))
6800 else if (unformat (i, "flood %d", &flood))
6802 else if (unformat (i, "uu-flood %d", &uu_flood))
6804 else if (unformat (i, "forward %d", &forward))
6806 else if (unformat (i, "learn %d", &learn))
6808 else if (unformat (i, "arp-term %d", &arp_term))
6810 else if (unformat (i, "mac-age %d", &mac_age))
6812 else if (unformat (i, "bd-tag %s", &bd_tag))
6814 else if (unformat (i, "del"))
6817 flood = uu_flood = forward = learn = 0;
6825 errmsg ("missing bridge domain");
6832 errmsg ("mac age must be less than 256 ");
6837 if ((bd_tag) && (strlen ((char *) bd_tag) > 63))
6839 errmsg ("bd-tag cannot be longer than 63");
6844 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6846 mp->bd_id = ntohl (bd_id);
6848 mp->uu_flood = uu_flood;
6849 mp->forward = forward;
6851 mp->arp_term = arp_term;
6852 mp->is_add = is_add;
6853 mp->mac_age = (u8) mac_age;
6855 strcpy ((char *) mp->bd_tag, (char *) bd_tag);
6866 api_l2fib_flush_bd (vat_main_t * vam)
6868 unformat_input_t *i = vam->input;
6869 vl_api_l2fib_flush_bd_t *mp;
6873 /* Parse args required to build the message */
6874 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6876 if (unformat (i, "bd_id %d", &bd_id));
6883 errmsg ("missing bridge domain");
6887 M (L2FIB_FLUSH_BD, mp);
6889 mp->bd_id = htonl (bd_id);
6897 api_l2fib_flush_int (vat_main_t * vam)
6899 unformat_input_t *i = vam->input;
6900 vl_api_l2fib_flush_int_t *mp;
6901 u32 sw_if_index = ~0;
6904 /* Parse args required to build the message */
6905 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6907 if (unformat (i, "sw_if_index %d", &sw_if_index));
6909 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6914 if (sw_if_index == ~0)
6916 errmsg ("missing interface name or sw_if_index");
6920 M (L2FIB_FLUSH_INT, mp);
6922 mp->sw_if_index = ntohl (sw_if_index);
6930 api_l2fib_add_del (vat_main_t * vam)
6932 unformat_input_t *i = vam->input;
6933 vl_api_l2fib_add_del_t *mp;
6939 u32 sw_if_index = ~0;
6940 u8 sw_if_index_set = 0;
6949 /* Parse args required to build the message */
6950 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6952 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6954 else if (unformat (i, "bd_id %d", &bd_id))
6956 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6957 sw_if_index_set = 1;
6958 else if (unformat (i, "sw_if"))
6960 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6963 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6964 sw_if_index_set = 1;
6969 else if (unformat (i, "static"))
6971 else if (unformat (i, "filter"))
6976 else if (unformat (i, "bvi"))
6981 else if (unformat (i, "del"))
6983 else if (unformat (i, "count %d", &count))
6991 errmsg ("missing mac address");
6997 errmsg ("missing bridge domain");
7001 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7003 errmsg ("missing interface name or sw_if_index");
7009 /* Turn on async mode */
7010 vam->async_mode = 1;
7011 vam->async_errors = 0;
7012 before = vat_time_now (vam);
7015 for (j = 0; j < count; j++)
7017 M (L2FIB_ADD_DEL, mp);
7020 mp->bd_id = ntohl (bd_id);
7021 mp->is_add = is_add;
7025 mp->sw_if_index = ntohl (sw_if_index);
7026 mp->static_mac = static_mac;
7027 mp->filter_mac = filter_mac;
7028 mp->bvi_mac = bvi_mac;
7030 increment_mac_address (&mac);
7037 vl_api_control_ping_t *mp_ping;
7040 /* Shut off async mode */
7041 vam->async_mode = 0;
7043 MPING (CONTROL_PING, mp_ping);
7046 timeout = vat_time_now (vam) + 1.0;
7047 while (vat_time_now (vam) < timeout)
7048 if (vam->result_ready == 1)
7053 if (vam->retval == -99)
7056 if (vam->async_errors > 0)
7058 errmsg ("%d asynchronous errors", vam->async_errors);
7061 vam->async_errors = 0;
7062 after = vat_time_now (vam);
7064 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7065 count, after - before, count / (after - before));
7071 /* Wait for a reply... */
7075 /* Return the good/bad news */
7076 return (vam->retval);
7080 api_bridge_domain_set_mac_age (vat_main_t * vam)
7082 unformat_input_t *i = vam->input;
7083 vl_api_bridge_domain_set_mac_age_t *mp;
7088 /* Parse args required to build the message */
7089 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7091 if (unformat (i, "bd_id %d", &bd_id));
7092 else if (unformat (i, "mac-age %d", &mac_age));
7099 errmsg ("missing bridge domain");
7105 errmsg ("mac age must be less than 256 ");
7109 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7111 mp->bd_id = htonl (bd_id);
7112 mp->mac_age = (u8) mac_age;
7120 api_l2_flags (vat_main_t * vam)
7122 unformat_input_t *i = vam->input;
7123 vl_api_l2_flags_t *mp;
7126 u8 sw_if_index_set = 0;
7130 /* Parse args required to build the message */
7131 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7133 if (unformat (i, "sw_if_index %d", &sw_if_index))
7134 sw_if_index_set = 1;
7135 else if (unformat (i, "sw_if"))
7137 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7140 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7141 sw_if_index_set = 1;
7146 else if (unformat (i, "learn"))
7148 else if (unformat (i, "forward"))
7150 else if (unformat (i, "flood"))
7152 else if (unformat (i, "uu-flood"))
7153 flags |= L2_UU_FLOOD;
7154 else if (unformat (i, "arp-term"))
7155 flags |= L2_ARP_TERM;
7156 else if (unformat (i, "off"))
7158 else if (unformat (i, "disable"))
7164 if (sw_if_index_set == 0)
7166 errmsg ("missing interface name or sw_if_index");
7172 mp->sw_if_index = ntohl (sw_if_index);
7173 mp->feature_bitmap = ntohl (flags);
7174 mp->is_set = is_set;
7182 api_bridge_flags (vat_main_t * vam)
7184 unformat_input_t *i = vam->input;
7185 vl_api_bridge_flags_t *mp;
7192 /* Parse args required to build the message */
7193 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7195 if (unformat (i, "bd_id %d", &bd_id))
7197 else if (unformat (i, "learn"))
7199 else if (unformat (i, "forward"))
7201 else if (unformat (i, "flood"))
7203 else if (unformat (i, "uu-flood"))
7204 flags |= L2_UU_FLOOD;
7205 else if (unformat (i, "arp-term"))
7206 flags |= L2_ARP_TERM;
7207 else if (unformat (i, "off"))
7209 else if (unformat (i, "disable"))
7217 errmsg ("missing bridge domain");
7221 M (BRIDGE_FLAGS, mp);
7223 mp->bd_id = ntohl (bd_id);
7224 mp->feature_bitmap = ntohl (flags);
7225 mp->is_set = is_set;
7233 api_bd_ip_mac_add_del (vat_main_t * vam)
7235 unformat_input_t *i = vam->input;
7236 vl_api_bd_ip_mac_add_del_t *mp;
7243 ip4_address_t v4addr;
7244 ip6_address_t v6addr;
7249 /* Parse args required to build the message */
7250 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7252 if (unformat (i, "bd_id %d", &bd_id))
7256 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7260 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7265 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7269 else if (unformat (i, "del"))
7277 errmsg ("missing bridge domain");
7280 else if (ip_set == 0)
7282 errmsg ("missing IP address");
7285 else if (mac_set == 0)
7287 errmsg ("missing MAC address");
7291 M (BD_IP_MAC_ADD_DEL, mp);
7293 mp->bd_id = ntohl (bd_id);
7294 mp->is_ipv6 = is_ipv6;
7295 mp->is_add = is_add;
7297 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7299 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7300 clib_memcpy (mp->mac_address, macaddr, 6);
7307 api_tap_connect (vat_main_t * vam)
7309 unformat_input_t *i = vam->input;
7310 vl_api_tap_connect_t *mp;
7316 ip4_address_t ip4_address;
7318 int ip4_address_set = 0;
7319 ip6_address_t ip6_address;
7321 int ip6_address_set = 0;
7324 memset (mac_address, 0, sizeof (mac_address));
7326 /* Parse args required to build the message */
7327 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7329 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7333 else if (unformat (i, "random-mac"))
7335 else if (unformat (i, "tapname %s", &tap_name))
7337 else if (unformat (i, "tag %s", &tag))
7339 else if (unformat (i, "address %U/%d",
7340 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7341 ip4_address_set = 1;
7342 else if (unformat (i, "address %U/%d",
7343 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7344 ip6_address_set = 1;
7351 errmsg ("missing tap name");
7354 if (vec_len (tap_name) > 63)
7356 errmsg ("tap name too long");
7359 vec_add1 (tap_name, 0);
7361 if (vec_len (tag) > 63)
7363 errmsg ("tag too long");
7367 /* Construct the API message */
7368 M (TAP_CONNECT, mp);
7370 mp->use_random_mac = random_mac;
7371 clib_memcpy (mp->mac_address, mac_address, 6);
7372 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7374 clib_memcpy (mp->tag, tag, vec_len (tag));
7376 if (ip4_address_set)
7378 mp->ip4_address_set = 1;
7379 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7380 mp->ip4_mask_width = ip4_mask_width;
7382 if (ip6_address_set)
7384 mp->ip6_address_set = 1;
7385 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7386 mp->ip6_mask_width = ip6_mask_width;
7389 vec_free (tap_name);
7395 /* Wait for a reply... */
7401 api_tap_modify (vat_main_t * vam)
7403 unformat_input_t *i = vam->input;
7404 vl_api_tap_modify_t *mp;
7409 u32 sw_if_index = ~0;
7410 u8 sw_if_index_set = 0;
7413 memset (mac_address, 0, sizeof (mac_address));
7415 /* Parse args required to build the message */
7416 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7418 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7419 sw_if_index_set = 1;
7420 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7421 sw_if_index_set = 1;
7422 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7426 else if (unformat (i, "random-mac"))
7428 else if (unformat (i, "tapname %s", &tap_name))
7434 if (sw_if_index_set == 0)
7436 errmsg ("missing vpp interface name");
7441 errmsg ("missing tap name");
7444 if (vec_len (tap_name) > 63)
7446 errmsg ("tap name too long");
7448 vec_add1 (tap_name, 0);
7450 /* Construct the API message */
7453 mp->use_random_mac = random_mac;
7454 mp->sw_if_index = ntohl (sw_if_index);
7455 clib_memcpy (mp->mac_address, mac_address, 6);
7456 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7457 vec_free (tap_name);
7462 /* Wait for a reply... */
7468 api_tap_delete (vat_main_t * vam)
7470 unformat_input_t *i = vam->input;
7471 vl_api_tap_delete_t *mp;
7472 u32 sw_if_index = ~0;
7473 u8 sw_if_index_set = 0;
7476 /* Parse args required to build the message */
7477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7479 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7480 sw_if_index_set = 1;
7481 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7482 sw_if_index_set = 1;
7487 if (sw_if_index_set == 0)
7489 errmsg ("missing vpp interface name");
7493 /* Construct the API message */
7496 mp->sw_if_index = ntohl (sw_if_index);
7501 /* Wait for a reply... */
7507 api_ip_table_add_del (vat_main_t * vam)
7509 unformat_input_t *i = vam->input;
7510 vl_api_ip_table_add_del_t *mp;
7516 /* Parse args required to build the message */
7517 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7519 if (unformat (i, "ipv6"))
7521 else if (unformat (i, "del"))
7523 else if (unformat (i, "add"))
7525 else if (unformat (i, "table %d", &table_id))
7529 clib_warning ("parse error '%U'", format_unformat_error, i);
7536 errmsg ("missing table-ID");
7540 /* Construct the API message */
7541 M (IP_TABLE_ADD_DEL, mp);
7543 mp->table_id = ntohl (table_id);
7544 mp->is_ipv6 = is_ipv6;
7545 mp->is_add = is_add;
7550 /* Wait for a reply... */
7557 api_ip_add_del_route (vat_main_t * vam)
7559 unformat_input_t *i = vam->input;
7560 vl_api_ip_add_del_route_t *mp;
7561 u32 sw_if_index = ~0, vrf_id = 0;
7563 u8 is_local = 0, is_drop = 0;
7564 u8 is_unreach = 0, is_prohibit = 0;
7565 u8 create_vrf_if_needed = 0;
7567 u32 next_hop_weight = 1;
7569 u8 is_multipath = 0;
7571 u8 address_length_set = 0;
7572 u32 next_hop_table_id = 0;
7573 u32 resolve_attempts = 0;
7574 u32 dst_address_length = 0;
7575 u8 next_hop_set = 0;
7576 ip4_address_t v4_dst_address, v4_next_hop_address;
7577 ip6_address_t v6_dst_address, v6_next_hop_address;
7581 u32 random_add_del = 0;
7582 u32 *random_vector = 0;
7584 u32 random_seed = 0xdeaddabe;
7585 u32 classify_table_index = ~0;
7587 u8 resolve_host = 0, resolve_attached = 0;
7588 mpls_label_t *next_hop_out_label_stack = NULL;
7589 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7590 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7592 /* Parse args required to build the message */
7593 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7595 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7597 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7599 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
7604 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
7609 else if (unformat (i, "/%d", &dst_address_length))
7611 address_length_set = 1;
7614 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
7615 &v4_next_hop_address))
7619 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7620 &v6_next_hop_address))
7624 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7626 else if (unformat (i, "weight %d", &next_hop_weight))
7628 else if (unformat (i, "drop"))
7632 else if (unformat (i, "null-send-unreach"))
7636 else if (unformat (i, "null-send-prohibit"))
7640 else if (unformat (i, "local"))
7644 else if (unformat (i, "classify %d", &classify_table_index))
7648 else if (unformat (i, "del"))
7650 else if (unformat (i, "add"))
7652 else if (unformat (i, "not-last"))
7654 else if (unformat (i, "resolve-via-host"))
7656 else if (unformat (i, "resolve-via-attached"))
7657 resolve_attached = 1;
7658 else if (unformat (i, "multipath"))
7660 else if (unformat (i, "vrf %d", &vrf_id))
7662 else if (unformat (i, "create-vrf"))
7663 create_vrf_if_needed = 1;
7664 else if (unformat (i, "count %d", &count))
7666 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7668 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7670 else if (unformat (i, "out-label %d", &next_hop_out_label))
7671 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7672 else if (unformat (i, "via-label %d", &next_hop_via_label))
7674 else if (unformat (i, "random"))
7676 else if (unformat (i, "seed %d", &random_seed))
7680 clib_warning ("parse error '%U'", format_unformat_error, i);
7685 if (!next_hop_set && !is_drop && !is_local &&
7686 !is_classify && !is_unreach && !is_prohibit &&
7687 MPLS_LABEL_INVALID == next_hop_via_label)
7690 ("next hop / local / drop / unreach / prohibit / classify not set");
7694 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7696 errmsg ("next hop and next-hop via label set");
7699 if (address_set == 0)
7701 errmsg ("missing addresses");
7705 if (address_length_set == 0)
7707 errmsg ("missing address length");
7711 /* Generate a pile of unique, random routes */
7714 u32 this_random_address;
7715 random_hash = hash_create (count, sizeof (uword));
7717 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7718 for (j = 0; j <= count; j++)
7722 this_random_address = random_u32 (&random_seed);
7723 this_random_address =
7724 clib_host_to_net_u32 (this_random_address);
7726 while (hash_get (random_hash, this_random_address));
7727 vec_add1 (random_vector, this_random_address);
7728 hash_set (random_hash, this_random_address, 1);
7730 hash_free (random_hash);
7731 v4_dst_address.as_u32 = random_vector[0];
7736 /* Turn on async mode */
7737 vam->async_mode = 1;
7738 vam->async_errors = 0;
7739 before = vat_time_now (vam);
7742 for (j = 0; j < count; j++)
7744 /* Construct the API message */
7745 M2 (IP_ADD_DEL_ROUTE, mp,
7746 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7748 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7749 mp->table_id = ntohl (vrf_id);
7750 mp->create_vrf_if_needed = create_vrf_if_needed;
7752 mp->is_add = is_add;
7753 mp->is_drop = is_drop;
7754 mp->is_unreach = is_unreach;
7755 mp->is_prohibit = is_prohibit;
7756 mp->is_ipv6 = is_ipv6;
7757 mp->is_local = is_local;
7758 mp->is_classify = is_classify;
7759 mp->is_multipath = is_multipath;
7760 mp->is_resolve_host = resolve_host;
7761 mp->is_resolve_attached = resolve_attached;
7762 mp->not_last = not_last;
7763 mp->next_hop_weight = next_hop_weight;
7764 mp->dst_address_length = dst_address_length;
7765 mp->next_hop_table_id = ntohl (next_hop_table_id);
7766 mp->classify_table_index = ntohl (classify_table_index);
7767 mp->next_hop_via_label = ntohl (next_hop_via_label);
7768 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7769 if (0 != mp->next_hop_n_out_labels)
7771 memcpy (mp->next_hop_out_label_stack,
7772 next_hop_out_label_stack,
7773 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7774 vec_free (next_hop_out_label_stack);
7779 clib_memcpy (mp->dst_address, &v6_dst_address,
7780 sizeof (v6_dst_address));
7782 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
7783 sizeof (v6_next_hop_address));
7784 increment_v6_address (&v6_dst_address);
7788 clib_memcpy (mp->dst_address, &v4_dst_address,
7789 sizeof (v4_dst_address));
7791 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
7792 sizeof (v4_next_hop_address));
7794 v4_dst_address.as_u32 = random_vector[j + 1];
7796 increment_v4_address (&v4_dst_address);
7800 /* If we receive SIGTERM, stop now... */
7805 /* When testing multiple add/del ops, use a control-ping to sync */
7808 vl_api_control_ping_t *mp_ping;
7812 /* Shut off async mode */
7813 vam->async_mode = 0;
7815 MPING (CONTROL_PING, mp_ping);
7818 timeout = vat_time_now (vam) + 1.0;
7819 while (vat_time_now (vam) < timeout)
7820 if (vam->result_ready == 1)
7825 if (vam->retval == -99)
7828 if (vam->async_errors > 0)
7830 errmsg ("%d asynchronous errors", vam->async_errors);
7833 vam->async_errors = 0;
7834 after = vat_time_now (vam);
7836 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7840 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7841 count, after - before, count / (after - before));
7847 /* Wait for a reply... */
7852 /* Return the good/bad news */
7853 return (vam->retval);
7857 api_ip_mroute_add_del (vat_main_t * vam)
7859 unformat_input_t *i = vam->input;
7860 vl_api_ip_mroute_add_del_t *mp;
7861 u32 sw_if_index = ~0, vrf_id = 0;
7864 u8 create_vrf_if_needed = 0;
7867 u32 grp_address_length = 0;
7868 ip4_address_t v4_grp_address, v4_src_address;
7869 ip6_address_t v6_grp_address, v6_src_address;
7870 mfib_itf_flags_t iflags = 0;
7871 mfib_entry_flags_t eflags = 0;
7874 /* Parse args required to build the message */
7875 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7877 if (unformat (i, "sw_if_index %d", &sw_if_index))
7879 else if (unformat (i, "%U %U",
7880 unformat_ip4_address, &v4_src_address,
7881 unformat_ip4_address, &v4_grp_address))
7883 grp_address_length = 64;
7887 else if (unformat (i, "%U %U",
7888 unformat_ip6_address, &v6_src_address,
7889 unformat_ip6_address, &v6_grp_address))
7891 grp_address_length = 256;
7895 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7897 memset (&v4_src_address, 0, sizeof (v4_src_address));
7898 grp_address_length = 32;
7902 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7904 memset (&v6_src_address, 0, sizeof (v6_src_address));
7905 grp_address_length = 128;
7909 else if (unformat (i, "/%d", &grp_address_length))
7911 else if (unformat (i, "local"))
7915 else if (unformat (i, "del"))
7917 else if (unformat (i, "add"))
7919 else if (unformat (i, "vrf %d", &vrf_id))
7921 else if (unformat (i, "create-vrf"))
7922 create_vrf_if_needed = 1;
7923 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
7925 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7929 clib_warning ("parse error '%U'", format_unformat_error, i);
7934 if (address_set == 0)
7936 errmsg ("missing addresses\n");
7940 /* Construct the API message */
7941 M (IP_MROUTE_ADD_DEL, mp);
7943 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7944 mp->table_id = ntohl (vrf_id);
7945 mp->create_vrf_if_needed = create_vrf_if_needed;
7947 mp->is_add = is_add;
7948 mp->is_ipv6 = is_ipv6;
7949 mp->is_local = is_local;
7950 mp->itf_flags = ntohl (iflags);
7951 mp->entry_flags = ntohl (eflags);
7952 mp->grp_address_length = grp_address_length;
7953 mp->grp_address_length = ntohs (mp->grp_address_length);
7957 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7958 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7962 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7963 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7969 /* Wait for a reply... */
7975 api_mpls_table_add_del (vat_main_t * vam)
7977 unformat_input_t *i = vam->input;
7978 vl_api_mpls_table_add_del_t *mp;
7983 /* Parse args required to build the message */
7984 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7986 if (unformat (i, "table %d", &table_id))
7988 else if (unformat (i, "del"))
7990 else if (unformat (i, "add"))
7994 clib_warning ("parse error '%U'", format_unformat_error, i);
8001 errmsg ("missing table-ID");
8005 /* Construct the API message */
8006 M (MPLS_TABLE_ADD_DEL, mp);
8008 mp->mt_table_id = ntohl (table_id);
8009 mp->mt_is_add = is_add;
8014 /* Wait for a reply... */
8021 api_mpls_route_add_del (vat_main_t * vam)
8023 unformat_input_t *i = vam->input;
8024 vl_api_mpls_route_add_del_t *mp;
8025 u32 sw_if_index = ~0, table_id = 0;
8026 u8 create_table_if_needed = 0;
8028 u32 next_hop_weight = 1;
8029 u8 is_multipath = 0;
8030 u32 next_hop_table_id = 0;
8031 u8 next_hop_set = 0;
8032 ip4_address_t v4_next_hop_address = {
8035 ip6_address_t v6_next_hop_address = { {0} };
8039 u32 classify_table_index = ~0;
8041 u8 resolve_host = 0, resolve_attached = 0;
8042 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8043 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8044 mpls_label_t *next_hop_out_label_stack = NULL;
8045 mpls_label_t local_label = MPLS_LABEL_INVALID;
8047 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8049 /* Parse args required to build the message */
8050 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8052 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8054 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8056 else if (unformat (i, "%d", &local_label))
8058 else if (unformat (i, "eos"))
8060 else if (unformat (i, "non-eos"))
8062 else if (unformat (i, "via %U", unformat_ip4_address,
8063 &v4_next_hop_address))
8066 next_hop_proto = DPO_PROTO_IP4;
8068 else if (unformat (i, "via %U", unformat_ip6_address,
8069 &v6_next_hop_address))
8072 next_hop_proto = DPO_PROTO_IP6;
8074 else if (unformat (i, "weight %d", &next_hop_weight))
8076 else if (unformat (i, "create-table"))
8077 create_table_if_needed = 1;
8078 else if (unformat (i, "classify %d", &classify_table_index))
8082 else if (unformat (i, "del"))
8084 else if (unformat (i, "add"))
8086 else if (unformat (i, "resolve-via-host"))
8088 else if (unformat (i, "resolve-via-attached"))
8089 resolve_attached = 1;
8090 else if (unformat (i, "multipath"))
8092 else if (unformat (i, "count %d", &count))
8094 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8097 next_hop_proto = DPO_PROTO_IP4;
8099 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8102 next_hop_proto = DPO_PROTO_IP6;
8104 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8106 else if (unformat (i, "via-label %d", &next_hop_via_label))
8108 else if (unformat (i, "out-label %d", &next_hop_out_label))
8109 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8112 clib_warning ("parse error '%U'", format_unformat_error, i);
8117 if (!next_hop_set && !is_classify)
8119 errmsg ("next hop / classify not set");
8123 if (MPLS_LABEL_INVALID == local_label)
8125 errmsg ("missing label");
8131 /* Turn on async mode */
8132 vam->async_mode = 1;
8133 vam->async_errors = 0;
8134 before = vat_time_now (vam);
8137 for (j = 0; j < count; j++)
8139 /* Construct the API message */
8140 M2 (MPLS_ROUTE_ADD_DEL, mp,
8141 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8143 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8144 mp->mr_table_id = ntohl (table_id);
8145 mp->mr_create_table_if_needed = create_table_if_needed;
8147 mp->mr_is_add = is_add;
8148 mp->mr_next_hop_proto = next_hop_proto;
8149 mp->mr_is_classify = is_classify;
8150 mp->mr_is_multipath = is_multipath;
8151 mp->mr_is_resolve_host = resolve_host;
8152 mp->mr_is_resolve_attached = resolve_attached;
8153 mp->mr_next_hop_weight = next_hop_weight;
8154 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8155 mp->mr_classify_table_index = ntohl (classify_table_index);
8156 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8157 mp->mr_label = ntohl (local_label);
8158 mp->mr_eos = is_eos;
8160 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8161 if (0 != mp->mr_next_hop_n_out_labels)
8163 memcpy (mp->mr_next_hop_out_label_stack,
8164 next_hop_out_label_stack,
8165 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8166 vec_free (next_hop_out_label_stack);
8171 if (DPO_PROTO_IP4 == next_hop_proto)
8173 clib_memcpy (mp->mr_next_hop,
8174 &v4_next_hop_address,
8175 sizeof (v4_next_hop_address));
8177 else if (DPO_PROTO_IP6 == next_hop_proto)
8180 clib_memcpy (mp->mr_next_hop,
8181 &v6_next_hop_address,
8182 sizeof (v6_next_hop_address));
8189 /* If we receive SIGTERM, stop now... */
8194 /* When testing multiple add/del ops, use a control-ping to sync */
8197 vl_api_control_ping_t *mp_ping;
8201 /* Shut off async mode */
8202 vam->async_mode = 0;
8204 MPING (CONTROL_PING, mp_ping);
8207 timeout = vat_time_now (vam) + 1.0;
8208 while (vat_time_now (vam) < timeout)
8209 if (vam->result_ready == 1)
8214 if (vam->retval == -99)
8217 if (vam->async_errors > 0)
8219 errmsg ("%d asynchronous errors", vam->async_errors);
8222 vam->async_errors = 0;
8223 after = vat_time_now (vam);
8225 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8229 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8230 count, after - before, count / (after - before));
8236 /* Wait for a reply... */
8241 /* Return the good/bad news */
8242 return (vam->retval);
8246 api_mpls_ip_bind_unbind (vat_main_t * vam)
8248 unformat_input_t *i = vam->input;
8249 vl_api_mpls_ip_bind_unbind_t *mp;
8250 u32 ip_table_id = 0;
8251 u8 create_table_if_needed = 0;
8254 ip4_address_t v4_address;
8255 ip6_address_t v6_address;
8258 mpls_label_t local_label = MPLS_LABEL_INVALID;
8261 /* Parse args required to build the message */
8262 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8264 if (unformat (i, "%U/%d", unformat_ip4_address,
8265 &v4_address, &address_length))
8270 else if (unformat (i, "%U/%d", unformat_ip6_address,
8271 &v6_address, &address_length))
8276 else if (unformat (i, "%d", &local_label))
8278 else if (unformat (i, "create-table"))
8279 create_table_if_needed = 1;
8280 else if (unformat (i, "table-id %d", &ip_table_id))
8282 else if (unformat (i, "unbind"))
8284 else if (unformat (i, "bind"))
8288 clib_warning ("parse error '%U'", format_unformat_error, i);
8295 errmsg ("IP addres not set");
8299 if (MPLS_LABEL_INVALID == local_label)
8301 errmsg ("missing label");
8305 /* Construct the API message */
8306 M (MPLS_IP_BIND_UNBIND, mp);
8308 mp->mb_create_table_if_needed = create_table_if_needed;
8309 mp->mb_is_bind = is_bind;
8310 mp->mb_is_ip4 = is_ip4;
8311 mp->mb_ip_table_id = ntohl (ip_table_id);
8312 mp->mb_mpls_table_id = 0;
8313 mp->mb_label = ntohl (local_label);
8314 mp->mb_address_length = address_length;
8317 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8319 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8324 /* Wait for a reply... */
8330 api_proxy_arp_add_del (vat_main_t * vam)
8332 unformat_input_t *i = vam->input;
8333 vl_api_proxy_arp_add_del_t *mp;
8336 ip4_address_t lo, hi;
8340 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8342 if (unformat (i, "vrf %d", &vrf_id))
8344 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
8345 unformat_ip4_address, &hi))
8347 else if (unformat (i, "del"))
8351 clib_warning ("parse error '%U'", format_unformat_error, i);
8358 errmsg ("address range not set");
8362 M (PROXY_ARP_ADD_DEL, mp);
8364 mp->vrf_id = ntohl (vrf_id);
8365 mp->is_add = is_add;
8366 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
8367 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
8375 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8377 unformat_input_t *i = vam->input;
8378 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8381 u8 sw_if_index_set = 0;
8384 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8386 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8387 sw_if_index_set = 1;
8388 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8389 sw_if_index_set = 1;
8390 else if (unformat (i, "enable"))
8392 else if (unformat (i, "disable"))
8396 clib_warning ("parse error '%U'", format_unformat_error, i);
8401 if (sw_if_index_set == 0)
8403 errmsg ("missing interface name or sw_if_index");
8407 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8409 mp->sw_if_index = ntohl (sw_if_index);
8410 mp->enable_disable = enable;
8418 api_mpls_tunnel_add_del (vat_main_t * vam)
8420 unformat_input_t *i = vam->input;
8421 vl_api_mpls_tunnel_add_del_t *mp;
8425 u32 sw_if_index = ~0;
8426 u32 next_hop_sw_if_index = ~0;
8427 u32 next_hop_proto_is_ip4 = 1;
8429 u32 next_hop_table_id = 0;
8430 ip4_address_t v4_next_hop_address = {
8433 ip6_address_t v6_next_hop_address = { {0} };
8434 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
8437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8439 if (unformat (i, "add"))
8441 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8443 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
8445 else if (unformat (i, "via %U",
8446 unformat_ip4_address, &v4_next_hop_address))
8448 next_hop_proto_is_ip4 = 1;
8450 else if (unformat (i, "via %U",
8451 unformat_ip6_address, &v6_next_hop_address))
8453 next_hop_proto_is_ip4 = 0;
8455 else if (unformat (i, "l2-only"))
8457 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8459 else if (unformat (i, "out-label %d", &next_hop_out_label))
8460 vec_add1 (labels, ntohl (next_hop_out_label));
8463 clib_warning ("parse error '%U'", format_unformat_error, i);
8468 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
8470 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
8471 mp->mt_sw_if_index = ntohl (sw_if_index);
8472 mp->mt_is_add = is_add;
8473 mp->mt_l2_only = l2_only;
8474 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
8475 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
8477 mp->mt_next_hop_n_out_labels = vec_len (labels);
8479 if (0 != mp->mt_next_hop_n_out_labels)
8481 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
8482 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
8486 if (next_hop_proto_is_ip4)
8488 clib_memcpy (mp->mt_next_hop,
8489 &v4_next_hop_address, sizeof (v4_next_hop_address));
8493 clib_memcpy (mp->mt_next_hop,
8494 &v6_next_hop_address, sizeof (v6_next_hop_address));
8503 api_sw_interface_set_unnumbered (vat_main_t * vam)
8505 unformat_input_t *i = vam->input;
8506 vl_api_sw_interface_set_unnumbered_t *mp;
8508 u32 unnum_sw_index = ~0;
8510 u8 sw_if_index_set = 0;
8513 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8515 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8516 sw_if_index_set = 1;
8517 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8518 sw_if_index_set = 1;
8519 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8521 else if (unformat (i, "del"))
8525 clib_warning ("parse error '%U'", format_unformat_error, i);
8530 if (sw_if_index_set == 0)
8532 errmsg ("missing interface name or sw_if_index");
8536 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8538 mp->sw_if_index = ntohl (sw_if_index);
8539 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8540 mp->is_add = is_add;
8548 api_ip_neighbor_add_del (vat_main_t * vam)
8550 unformat_input_t *i = vam->input;
8551 vl_api_ip_neighbor_add_del_t *mp;
8553 u8 sw_if_index_set = 0;
8556 u8 is_no_fib_entry = 0;
8559 u8 v4_address_set = 0;
8560 u8 v6_address_set = 0;
8561 ip4_address_t v4address;
8562 ip6_address_t v6address;
8565 memset (mac_address, 0, sizeof (mac_address));
8567 /* Parse args required to build the message */
8568 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8570 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8574 else if (unformat (i, "del"))
8577 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8578 sw_if_index_set = 1;
8579 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8580 sw_if_index_set = 1;
8581 else if (unformat (i, "is_static"))
8583 else if (unformat (i, "no-fib-entry"))
8584 is_no_fib_entry = 1;
8585 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
8587 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
8591 clib_warning ("parse error '%U'", format_unformat_error, i);
8596 if (sw_if_index_set == 0)
8598 errmsg ("missing interface name or sw_if_index");
8601 if (v4_address_set && v6_address_set)
8603 errmsg ("both v4 and v6 addresses set");
8606 if (!v4_address_set && !v6_address_set)
8608 errmsg ("no address set");
8612 /* Construct the API message */
8613 M (IP_NEIGHBOR_ADD_DEL, mp);
8615 mp->sw_if_index = ntohl (sw_if_index);
8616 mp->is_add = is_add;
8617 mp->is_static = is_static;
8618 mp->is_no_adj_fib = is_no_fib_entry;
8620 clib_memcpy (mp->mac_address, mac_address, 6);
8624 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
8628 /* mp->is_ipv6 = 0; via memset in M macro above */
8629 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
8635 /* Wait for a reply, return good/bad news */
8641 api_reset_vrf (vat_main_t * vam)
8643 unformat_input_t *i = vam->input;
8644 vl_api_reset_vrf_t *mp;
8650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8652 if (unformat (i, "vrf %d", &vrf_id))
8654 else if (unformat (i, "ipv6"))
8658 clib_warning ("parse error '%U'", format_unformat_error, i);
8663 if (vrf_id_set == 0)
8665 errmsg ("missing vrf id");
8671 mp->vrf_id = ntohl (vrf_id);
8672 mp->is_ipv6 = is_ipv6;
8680 api_create_vlan_subif (vat_main_t * vam)
8682 unformat_input_t *i = vam->input;
8683 vl_api_create_vlan_subif_t *mp;
8685 u8 sw_if_index_set = 0;
8690 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8692 if (unformat (i, "sw_if_index %d", &sw_if_index))
8693 sw_if_index_set = 1;
8695 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8696 sw_if_index_set = 1;
8697 else if (unformat (i, "vlan %d", &vlan_id))
8701 clib_warning ("parse error '%U'", format_unformat_error, i);
8706 if (sw_if_index_set == 0)
8708 errmsg ("missing interface name or sw_if_index");
8712 if (vlan_id_set == 0)
8714 errmsg ("missing vlan_id");
8717 M (CREATE_VLAN_SUBIF, mp);
8719 mp->sw_if_index = ntohl (sw_if_index);
8720 mp->vlan_id = ntohl (vlan_id);
8727 #define foreach_create_subif_bit \
8734 _(outer_vlan_id_any) \
8735 _(inner_vlan_id_any)
8738 api_create_subif (vat_main_t * vam)
8740 unformat_input_t *i = vam->input;
8741 vl_api_create_subif_t *mp;
8743 u8 sw_if_index_set = 0;
8750 u32 exact_match = 0;
8751 u32 default_sub = 0;
8752 u32 outer_vlan_id_any = 0;
8753 u32 inner_vlan_id_any = 0;
8755 u16 outer_vlan_id = 0;
8756 u16 inner_vlan_id = 0;
8759 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8761 if (unformat (i, "sw_if_index %d", &sw_if_index))
8762 sw_if_index_set = 1;
8764 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8765 sw_if_index_set = 1;
8766 else if (unformat (i, "sub_id %d", &sub_id))
8768 else if (unformat (i, "outer_vlan_id %d", &tmp))
8769 outer_vlan_id = tmp;
8770 else if (unformat (i, "inner_vlan_id %d", &tmp))
8771 inner_vlan_id = tmp;
8773 #define _(a) else if (unformat (i, #a)) a = 1 ;
8774 foreach_create_subif_bit
8778 clib_warning ("parse error '%U'", format_unformat_error, i);
8783 if (sw_if_index_set == 0)
8785 errmsg ("missing interface name or sw_if_index");
8789 if (sub_id_set == 0)
8791 errmsg ("missing sub_id");
8794 M (CREATE_SUBIF, mp);
8796 mp->sw_if_index = ntohl (sw_if_index);
8797 mp->sub_id = ntohl (sub_id);
8799 #define _(a) mp->a = a;
8800 foreach_create_subif_bit;
8803 mp->outer_vlan_id = ntohs (outer_vlan_id);
8804 mp->inner_vlan_id = ntohs (inner_vlan_id);
8812 api_oam_add_del (vat_main_t * vam)
8814 unformat_input_t *i = vam->input;
8815 vl_api_oam_add_del_t *mp;
8818 ip4_address_t src, dst;
8823 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8825 if (unformat (i, "vrf %d", &vrf_id))
8827 else if (unformat (i, "src %U", unformat_ip4_address, &src))
8829 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
8831 else if (unformat (i, "del"))
8835 clib_warning ("parse error '%U'", format_unformat_error, i);
8842 errmsg ("missing src addr");
8848 errmsg ("missing dst addr");
8852 M (OAM_ADD_DEL, mp);
8854 mp->vrf_id = ntohl (vrf_id);
8855 mp->is_add = is_add;
8856 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
8857 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
8865 api_reset_fib (vat_main_t * vam)
8867 unformat_input_t *i = vam->input;
8868 vl_api_reset_fib_t *mp;
8874 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8876 if (unformat (i, "vrf %d", &vrf_id))
8878 else if (unformat (i, "ipv6"))
8882 clib_warning ("parse error '%U'", format_unformat_error, i);
8887 if (vrf_id_set == 0)
8889 errmsg ("missing vrf id");
8895 mp->vrf_id = ntohl (vrf_id);
8896 mp->is_ipv6 = is_ipv6;
8904 api_dhcp_proxy_config (vat_main_t * vam)
8906 unformat_input_t *i = vam->input;
8907 vl_api_dhcp_proxy_config_t *mp;
8909 u32 server_vrf_id = 0;
8911 u8 v4_address_set = 0;
8912 u8 v6_address_set = 0;
8913 ip4_address_t v4address;
8914 ip6_address_t v6address;
8915 u8 v4_src_address_set = 0;
8916 u8 v6_src_address_set = 0;
8917 ip4_address_t v4srcaddress;
8918 ip6_address_t v6srcaddress;
8921 /* Parse args required to build the message */
8922 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8924 if (unformat (i, "del"))
8926 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
8928 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
8930 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
8932 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
8934 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
8935 v4_src_address_set = 1;
8936 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
8937 v6_src_address_set = 1;
8942 if (v4_address_set && v6_address_set)
8944 errmsg ("both v4 and v6 server addresses set");
8947 if (!v4_address_set && !v6_address_set)
8949 errmsg ("no server addresses set");
8953 if (v4_src_address_set && v6_src_address_set)
8955 errmsg ("both v4 and v6 src addresses set");
8958 if (!v4_src_address_set && !v6_src_address_set)
8960 errmsg ("no src addresses set");
8964 if (!(v4_src_address_set && v4_address_set) &&
8965 !(v6_src_address_set && v6_address_set))
8967 errmsg ("no matching server and src addresses set");
8971 /* Construct the API message */
8972 M (DHCP_PROXY_CONFIG, mp);
8974 mp->is_add = is_add;
8975 mp->rx_vrf_id = ntohl (rx_vrf_id);
8976 mp->server_vrf_id = ntohl (server_vrf_id);
8980 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
8981 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
8985 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
8986 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
8992 /* Wait for a reply, return good/bad news */
8997 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
8998 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9001 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9003 vat_main_t *vam = &vat_main;
9004 u32 i, count = mp->count;
9005 vl_api_dhcp_server_t *s;
9009 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
9010 ntohl (mp->rx_vrf_id),
9011 format_ip6_address, mp->dhcp_src_address,
9012 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9015 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
9016 ntohl (mp->rx_vrf_id),
9017 format_ip4_address, mp->dhcp_src_address,
9018 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9020 for (i = 0; i < count; i++)
9022 s = &mp->servers[i];
9026 " Server Table-ID %d, Server Address %U",
9027 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9030 " Server Table-ID %d, Server Address %U",
9031 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9035 static void vl_api_dhcp_proxy_details_t_handler_json
9036 (vl_api_dhcp_proxy_details_t * mp)
9038 vat_main_t *vam = &vat_main;
9039 vat_json_node_t *node = NULL;
9040 u32 i, count = mp->count;
9042 struct in6_addr ip6;
9043 vl_api_dhcp_server_t *s;
9045 if (VAT_JSON_ARRAY != vam->json_tree.type)
9047 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9048 vat_json_init_array (&vam->json_tree);
9050 node = vat_json_array_add (&vam->json_tree);
9052 vat_json_init_object (node);
9053 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9054 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9055 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9059 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9060 vat_json_object_add_ip6 (node, "src_address", ip6);
9064 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9065 vat_json_object_add_ip4 (node, "src_address", ip4);
9068 for (i = 0; i < count; i++)
9070 s = &mp->servers[i];
9072 vat_json_object_add_uint (node, "server-table-id",
9073 ntohl (s->server_vrf_id));
9077 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9078 vat_json_object_add_ip4 (node, "src_address", ip4);
9082 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9083 vat_json_object_add_ip6 (node, "server_address", ip6);
9089 api_dhcp_proxy_dump (vat_main_t * vam)
9091 unformat_input_t *i = vam->input;
9092 vl_api_control_ping_t *mp_ping;
9093 vl_api_dhcp_proxy_dump_t *mp;
9097 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9099 if (unformat (i, "ipv6"))
9103 clib_warning ("parse error '%U'", format_unformat_error, i);
9108 M (DHCP_PROXY_DUMP, mp);
9110 mp->is_ip6 = is_ipv6;
9113 /* Use a control ping for synchronization */
9114 MPING (CONTROL_PING, mp_ping);
9122 api_dhcp_proxy_set_vss (vat_main_t * vam)
9124 unformat_input_t *i = vam->input;
9125 vl_api_dhcp_proxy_set_vss_t *mp;
9136 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9138 if (unformat (i, "tbl_id %d", &tbl_id))
9140 if (unformat (i, "fib_id %d", &fib_id))
9142 if (unformat (i, "oui %d", &oui))
9144 else if (unformat (i, "ipv6"))
9146 else if (unformat (i, "del"))
9150 clib_warning ("parse error '%U'", format_unformat_error, i);
9155 if (tbl_id_set == 0)
9157 errmsg ("missing tbl id");
9161 if (fib_id_set == 0)
9163 errmsg ("missing fib id");
9168 errmsg ("missing oui");
9172 M (DHCP_PROXY_SET_VSS, mp);
9173 mp->tbl_id = ntohl (tbl_id);
9174 mp->fib_id = ntohl (fib_id);
9175 mp->oui = ntohl (oui);
9176 mp->is_ipv6 = is_ipv6;
9177 mp->is_add = is_add;
9185 api_dhcp_client_config (vat_main_t * vam)
9187 unformat_input_t *i = vam->input;
9188 vl_api_dhcp_client_config_t *mp;
9190 u8 sw_if_index_set = 0;
9193 u8 disable_event = 0;
9196 /* Parse args required to build the message */
9197 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9199 if (unformat (i, "del"))
9202 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9203 sw_if_index_set = 1;
9204 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9205 sw_if_index_set = 1;
9206 else if (unformat (i, "hostname %s", &hostname))
9208 else if (unformat (i, "disable_event"))
9214 if (sw_if_index_set == 0)
9216 errmsg ("missing interface name or sw_if_index");
9220 if (vec_len (hostname) > 63)
9222 errmsg ("hostname too long");
9224 vec_add1 (hostname, 0);
9226 /* Construct the API message */
9227 M (DHCP_CLIENT_CONFIG, mp);
9229 mp->sw_if_index = htonl (sw_if_index);
9230 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
9231 vec_free (hostname);
9232 mp->is_add = is_add;
9233 mp->want_dhcp_event = disable_event ? 0 : 1;
9234 mp->pid = htonl (getpid ());
9239 /* Wait for a reply, return good/bad news */
9245 api_set_ip_flow_hash (vat_main_t * vam)
9247 unformat_input_t *i = vam->input;
9248 vl_api_set_ip_flow_hash_t *mp;
9260 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9262 if (unformat (i, "vrf %d", &vrf_id))
9264 else if (unformat (i, "ipv6"))
9266 else if (unformat (i, "src"))
9268 else if (unformat (i, "dst"))
9270 else if (unformat (i, "sport"))
9272 else if (unformat (i, "dport"))
9274 else if (unformat (i, "proto"))
9276 else if (unformat (i, "reverse"))
9281 clib_warning ("parse error '%U'", format_unformat_error, i);
9286 if (vrf_id_set == 0)
9288 errmsg ("missing vrf id");
9292 M (SET_IP_FLOW_HASH, mp);
9298 mp->reverse = reverse;
9299 mp->vrf_id = ntohl (vrf_id);
9300 mp->is_ipv6 = is_ipv6;
9308 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9310 unformat_input_t *i = vam->input;
9311 vl_api_sw_interface_ip6_enable_disable_t *mp;
9313 u8 sw_if_index_set = 0;
9317 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9319 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9320 sw_if_index_set = 1;
9321 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9322 sw_if_index_set = 1;
9323 else if (unformat (i, "enable"))
9325 else if (unformat (i, "disable"))
9329 clib_warning ("parse error '%U'", format_unformat_error, i);
9334 if (sw_if_index_set == 0)
9336 errmsg ("missing interface name or sw_if_index");
9340 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9342 mp->sw_if_index = ntohl (sw_if_index);
9343 mp->enable = enable;
9351 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
9353 unformat_input_t *i = vam->input;
9354 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
9356 u8 sw_if_index_set = 0;
9357 u8 v6_address_set = 0;
9358 ip6_address_t v6address;
9361 /* Parse args required to build the message */
9362 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9364 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9365 sw_if_index_set = 1;
9366 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9367 sw_if_index_set = 1;
9368 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9374 if (sw_if_index_set == 0)
9376 errmsg ("missing interface name or sw_if_index");
9379 if (!v6_address_set)
9381 errmsg ("no address set");
9385 /* Construct the API message */
9386 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
9388 mp->sw_if_index = ntohl (sw_if_index);
9389 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9394 /* Wait for a reply, return good/bad news */
9400 api_ip6nd_proxy_add_del (vat_main_t * vam)
9402 unformat_input_t *i = vam->input;
9403 vl_api_ip6nd_proxy_add_del_t *mp;
9404 u32 sw_if_index = ~0;
9405 u8 v6_address_set = 0;
9406 ip6_address_t v6address;
9410 /* Parse args required to build the message */
9411 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9413 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9415 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9417 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9419 if (unformat (i, "del"))
9423 clib_warning ("parse error '%U'", format_unformat_error, i);
9428 if (sw_if_index == ~0)
9430 errmsg ("missing interface name or sw_if_index");
9433 if (!v6_address_set)
9435 errmsg ("no address set");
9439 /* Construct the API message */
9440 M (IP6ND_PROXY_ADD_DEL, mp);
9442 mp->is_del = is_del;
9443 mp->sw_if_index = ntohl (sw_if_index);
9444 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9449 /* Wait for a reply, return good/bad news */
9455 api_ip6nd_proxy_dump (vat_main_t * vam)
9457 vl_api_ip6nd_proxy_dump_t *mp;
9458 vl_api_control_ping_t *mp_ping;
9461 M (IP6ND_PROXY_DUMP, mp);
9465 /* Use a control ping for synchronization */
9466 MPING (CONTROL_PING, mp_ping);
9473 static void vl_api_ip6nd_proxy_details_t_handler
9474 (vl_api_ip6nd_proxy_details_t * mp)
9476 vat_main_t *vam = &vat_main;
9478 print (vam->ofp, "host %U sw_if_index %d",
9479 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
9482 static void vl_api_ip6nd_proxy_details_t_handler_json
9483 (vl_api_ip6nd_proxy_details_t * mp)
9485 vat_main_t *vam = &vat_main;
9486 struct in6_addr ip6;
9487 vat_json_node_t *node = NULL;
9489 if (VAT_JSON_ARRAY != vam->json_tree.type)
9491 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9492 vat_json_init_array (&vam->json_tree);
9494 node = vat_json_array_add (&vam->json_tree);
9496 vat_json_init_object (node);
9497 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9499 clib_memcpy (&ip6, mp->address, sizeof (ip6));
9500 vat_json_object_add_ip6 (node, "host", ip6);
9504 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9506 unformat_input_t *i = vam->input;
9507 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9509 u8 sw_if_index_set = 0;
9510 u32 address_length = 0;
9511 u8 v6_address_set = 0;
9512 ip6_address_t v6address;
9514 u8 no_advertise = 0;
9516 u8 no_autoconfig = 0;
9519 u32 val_lifetime = 0;
9520 u32 pref_lifetime = 0;
9523 /* Parse args required to build the message */
9524 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9526 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9527 sw_if_index_set = 1;
9528 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9529 sw_if_index_set = 1;
9530 else if (unformat (i, "%U/%d",
9531 unformat_ip6_address, &v6address, &address_length))
9533 else if (unformat (i, "val_life %d", &val_lifetime))
9535 else if (unformat (i, "pref_life %d", &pref_lifetime))
9537 else if (unformat (i, "def"))
9539 else if (unformat (i, "noadv"))
9541 else if (unformat (i, "offl"))
9543 else if (unformat (i, "noauto"))
9545 else if (unformat (i, "nolink"))
9547 else if (unformat (i, "isno"))
9551 clib_warning ("parse error '%U'", format_unformat_error, i);
9556 if (sw_if_index_set == 0)
9558 errmsg ("missing interface name or sw_if_index");
9561 if (!v6_address_set)
9563 errmsg ("no address set");
9567 /* Construct the API message */
9568 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9570 mp->sw_if_index = ntohl (sw_if_index);
9571 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9572 mp->address_length = address_length;
9573 mp->use_default = use_default;
9574 mp->no_advertise = no_advertise;
9575 mp->off_link = off_link;
9576 mp->no_autoconfig = no_autoconfig;
9577 mp->no_onlink = no_onlink;
9579 mp->val_lifetime = ntohl (val_lifetime);
9580 mp->pref_lifetime = ntohl (pref_lifetime);
9585 /* Wait for a reply, return good/bad news */
9591 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9593 unformat_input_t *i = vam->input;
9594 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9596 u8 sw_if_index_set = 0;
9601 u8 send_unicast = 0;
9604 u8 default_router = 0;
9605 u32 max_interval = 0;
9606 u32 min_interval = 0;
9608 u32 initial_count = 0;
9609 u32 initial_interval = 0;
9613 /* Parse args required to build the message */
9614 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9616 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9617 sw_if_index_set = 1;
9618 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9619 sw_if_index_set = 1;
9620 else if (unformat (i, "maxint %d", &max_interval))
9622 else if (unformat (i, "minint %d", &min_interval))
9624 else if (unformat (i, "life %d", &lifetime))
9626 else if (unformat (i, "count %d", &initial_count))
9628 else if (unformat (i, "interval %d", &initial_interval))
9630 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9632 else if (unformat (i, "managed"))
9634 else if (unformat (i, "other"))
9636 else if (unformat (i, "ll"))
9638 else if (unformat (i, "send"))
9640 else if (unformat (i, "cease"))
9642 else if (unformat (i, "isno"))
9644 else if (unformat (i, "def"))
9648 clib_warning ("parse error '%U'", format_unformat_error, i);
9653 if (sw_if_index_set == 0)
9655 errmsg ("missing interface name or sw_if_index");
9659 /* Construct the API message */
9660 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9662 mp->sw_if_index = ntohl (sw_if_index);
9663 mp->max_interval = ntohl (max_interval);
9664 mp->min_interval = ntohl (min_interval);
9665 mp->lifetime = ntohl (lifetime);
9666 mp->initial_count = ntohl (initial_count);
9667 mp->initial_interval = ntohl (initial_interval);
9668 mp->suppress = suppress;
9669 mp->managed = managed;
9671 mp->ll_option = ll_option;
9672 mp->send_unicast = send_unicast;
9675 mp->default_router = default_router;
9680 /* Wait for a reply, return good/bad news */
9686 api_set_arp_neighbor_limit (vat_main_t * vam)
9688 unformat_input_t *i = vam->input;
9689 vl_api_set_arp_neighbor_limit_t *mp;
9695 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9697 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9699 else if (unformat (i, "ipv6"))
9703 clib_warning ("parse error '%U'", format_unformat_error, i);
9710 errmsg ("missing limit value");
9714 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9716 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9717 mp->is_ipv6 = is_ipv6;
9725 api_l2_patch_add_del (vat_main_t * vam)
9727 unformat_input_t *i = vam->input;
9728 vl_api_l2_patch_add_del_t *mp;
9730 u8 rx_sw_if_index_set = 0;
9732 u8 tx_sw_if_index_set = 0;
9736 /* Parse args required to build the message */
9737 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9739 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9740 rx_sw_if_index_set = 1;
9741 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9742 tx_sw_if_index_set = 1;
9743 else if (unformat (i, "rx"))
9745 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9747 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9749 rx_sw_if_index_set = 1;
9754 else if (unformat (i, "tx"))
9756 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9758 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9760 tx_sw_if_index_set = 1;
9765 else if (unformat (i, "del"))
9771 if (rx_sw_if_index_set == 0)
9773 errmsg ("missing rx interface name or rx_sw_if_index");
9777 if (tx_sw_if_index_set == 0)
9779 errmsg ("missing tx interface name or tx_sw_if_index");
9783 M (L2_PATCH_ADD_DEL, mp);
9785 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9786 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9787 mp->is_add = is_add;
9795 u8 localsid_addr[16];
9804 api_sr_localsid_add_del (vat_main_t * vam)
9806 unformat_input_t *i = vam->input;
9807 vl_api_sr_localsid_add_del_t *mp;
9810 ip6_address_t localsid;
9814 u32 fib_table = ~(u32) 0;
9815 ip6_address_t next_hop;
9817 bool nexthop_set = 0;
9821 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9823 if (unformat (i, "del"))
9825 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9826 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
9828 else if (unformat (i, "behavior %u", &behavior));
9829 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9830 else if (unformat (i, "fib-table %u", &fib_table));
9831 else if (unformat (i, "end.psp %u", &behavior));
9836 M (SR_LOCALSID_ADD_DEL, mp);
9838 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
9840 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
9841 mp->behavior = behavior;
9842 mp->sw_if_index = ntohl (sw_if_index);
9843 mp->fib_table = ntohl (fib_table);
9844 mp->end_psp = end_psp;
9845 mp->is_del = is_del;
9853 api_ioam_enable (vat_main_t * vam)
9855 unformat_input_t *input = vam->input;
9856 vl_api_ioam_enable_t *mp;
9858 int has_trace_option = 0;
9859 int has_pot_option = 0;
9860 int has_seqno_option = 0;
9861 int has_analyse_option = 0;
9864 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9866 if (unformat (input, "trace"))
9867 has_trace_option = 1;
9868 else if (unformat (input, "pot"))
9870 else if (unformat (input, "seqno"))
9871 has_seqno_option = 1;
9872 else if (unformat (input, "analyse"))
9873 has_analyse_option = 1;
9877 M (IOAM_ENABLE, mp);
9878 mp->id = htons (id);
9879 mp->seqno = has_seqno_option;
9880 mp->analyse = has_analyse_option;
9881 mp->pot_enable = has_pot_option;
9882 mp->trace_enable = has_trace_option;
9891 api_ioam_disable (vat_main_t * vam)
9893 vl_api_ioam_disable_t *mp;
9896 M (IOAM_DISABLE, mp);
9902 #define foreach_tcp_proto_field \
9906 #define foreach_udp_proto_field \
9910 #define foreach_ip4_proto_field \
9922 u16 src_port, dst_port;
9925 #if VPP_API_TEST_BUILTIN == 0
9927 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9929 u8 **maskp = va_arg (*args, u8 **);
9931 u8 found_something = 0;
9934 #define _(a) u8 a=0;
9935 foreach_tcp_proto_field;
9938 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9941 #define _(a) else if (unformat (input, #a)) a=1;
9942 foreach_tcp_proto_field
9948 #define _(a) found_something += a;
9949 foreach_tcp_proto_field;
9952 if (found_something == 0)
9955 vec_validate (mask, sizeof (*tcp) - 1);
9957 tcp = (tcp_header_t *) mask;
9959 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
9960 foreach_tcp_proto_field;
9968 unformat_udp_mask (unformat_input_t * input, va_list * args)
9970 u8 **maskp = va_arg (*args, u8 **);
9972 u8 found_something = 0;
9975 #define _(a) u8 a=0;
9976 foreach_udp_proto_field;
9979 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9982 #define _(a) else if (unformat (input, #a)) a=1;
9983 foreach_udp_proto_field
9989 #define _(a) found_something += a;
9990 foreach_udp_proto_field;
9993 if (found_something == 0)
9996 vec_validate (mask, sizeof (*udp) - 1);
9998 udp = (udp_header_t *) mask;
10000 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
10001 foreach_udp_proto_field;
10009 unformat_l4_mask (unformat_input_t * input, va_list * args)
10011 u8 **maskp = va_arg (*args, u8 **);
10012 u16 src_port = 0, dst_port = 0;
10013 tcpudp_header_t *tcpudp;
10015 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10017 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10019 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10021 else if (unformat (input, "src_port"))
10023 else if (unformat (input, "dst_port"))
10029 if (!src_port && !dst_port)
10033 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10035 tcpudp = (tcpudp_header_t *) mask;
10036 tcpudp->src_port = src_port;
10037 tcpudp->dst_port = dst_port;
10045 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10047 u8 **maskp = va_arg (*args, u8 **);
10049 u8 found_something = 0;
10052 #define _(a) u8 a=0;
10053 foreach_ip4_proto_field;
10059 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10061 if (unformat (input, "version"))
10063 else if (unformat (input, "hdr_length"))
10065 else if (unformat (input, "src"))
10067 else if (unformat (input, "dst"))
10069 else if (unformat (input, "proto"))
10072 #define _(a) else if (unformat (input, #a)) a=1;
10073 foreach_ip4_proto_field
10079 #define _(a) found_something += a;
10080 foreach_ip4_proto_field;
10083 if (found_something == 0)
10086 vec_validate (mask, sizeof (*ip) - 1);
10088 ip = (ip4_header_t *) mask;
10090 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10091 foreach_ip4_proto_field;
10094 ip->ip_version_and_header_length = 0;
10097 ip->ip_version_and_header_length |= 0xF0;
10100 ip->ip_version_and_header_length |= 0x0F;
10106 #define foreach_ip6_proto_field \
10109 _(payload_length) \
10114 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10116 u8 **maskp = va_arg (*args, u8 **);
10118 u8 found_something = 0;
10120 u32 ip_version_traffic_class_and_flow_label;
10122 #define _(a) u8 a=0;
10123 foreach_ip6_proto_field;
10126 u8 traffic_class = 0;
10129 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10131 if (unformat (input, "version"))
10133 else if (unformat (input, "traffic-class"))
10135 else if (unformat (input, "flow-label"))
10137 else if (unformat (input, "src"))
10139 else if (unformat (input, "dst"))
10141 else if (unformat (input, "proto"))
10144 #define _(a) else if (unformat (input, #a)) a=1;
10145 foreach_ip6_proto_field
10151 #define _(a) found_something += a;
10152 foreach_ip6_proto_field;
10155 if (found_something == 0)
10158 vec_validate (mask, sizeof (*ip) - 1);
10160 ip = (ip6_header_t *) mask;
10162 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10163 foreach_ip6_proto_field;
10166 ip_version_traffic_class_and_flow_label = 0;
10169 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10172 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10175 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10177 ip->ip_version_traffic_class_and_flow_label =
10178 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10185 unformat_l3_mask (unformat_input_t * input, va_list * args)
10187 u8 **maskp = va_arg (*args, u8 **);
10189 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10191 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10193 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10202 unformat_l2_mask (unformat_input_t * input, va_list * args)
10204 u8 **maskp = va_arg (*args, u8 **);
10211 u8 ignore_tag1 = 0;
10212 u8 ignore_tag2 = 0;
10219 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10221 if (unformat (input, "src"))
10223 else if (unformat (input, "dst"))
10225 else if (unformat (input, "proto"))
10227 else if (unformat (input, "tag1"))
10229 else if (unformat (input, "tag2"))
10231 else if (unformat (input, "ignore-tag1"))
10233 else if (unformat (input, "ignore-tag2"))
10235 else if (unformat (input, "cos1"))
10237 else if (unformat (input, "cos2"))
10239 else if (unformat (input, "dot1q"))
10241 else if (unformat (input, "dot1ad"))
10246 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10247 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10250 if (tag1 || ignore_tag1 || cos1 || dot1q)
10252 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10255 vec_validate (mask, len - 1);
10258 memset (mask, 0xff, 6);
10261 memset (mask + 6, 0xff, 6);
10263 if (tag2 || dot1ad)
10265 /* inner vlan tag */
10274 mask[21] = mask[20] = 0xff;
10295 mask[16] = mask[17] = 0xff;
10305 mask[12] = mask[13] = 0xff;
10312 unformat_classify_mask (unformat_input_t * input, va_list * args)
10314 u8 **maskp = va_arg (*args, u8 **);
10315 u32 *skipp = va_arg (*args, u32 *);
10316 u32 *matchp = va_arg (*args, u32 *);
10324 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10326 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10328 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10330 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10332 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10346 if (mask || l2 || l3 || l4)
10348 if (l2 || l3 || l4)
10350 /* "With a free Ethernet header in every package" */
10352 vec_validate (l2, 13);
10356 vec_append (mask, l3);
10361 vec_append (mask, l4);
10366 /* Scan forward looking for the first significant mask octet */
10367 for (i = 0; i < vec_len (mask); i++)
10371 /* compute (skip, match) params */
10372 *skipp = i / sizeof (u32x4);
10373 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10375 /* Pad mask to an even multiple of the vector size */
10376 while (vec_len (mask) % sizeof (u32x4))
10377 vec_add1 (mask, 0);
10379 match = vec_len (mask) / sizeof (u32x4);
10381 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10383 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10384 if (*tmp || *(tmp + 1))
10389 clib_warning ("BUG: match 0");
10391 _vec_len (mask) = match * sizeof (u32x4);
10401 #endif /* VPP_API_TEST_BUILTIN */
10403 #define foreach_l2_next \
10405 _(ethernet, ETHERNET_INPUT) \
10406 _(ip4, IP4_INPUT) \
10410 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10412 u32 *miss_next_indexp = va_arg (*args, u32 *);
10413 u32 next_index = 0;
10417 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10421 if (unformat (input, "%d", &tmp))
10430 *miss_next_indexp = next_index;
10434 #define foreach_ip_next \
10437 _(rewrite, REWRITE)
10440 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10442 u32 *miss_next_indexp = va_arg (*args, u32 *);
10443 u32 next_index = 0;
10447 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10451 if (unformat (input, "%d", &tmp))
10460 *miss_next_indexp = next_index;
10464 #define foreach_acl_next \
10468 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10470 u32 *miss_next_indexp = va_arg (*args, u32 *);
10471 u32 next_index = 0;
10475 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10479 if (unformat (input, "permit"))
10484 else if (unformat (input, "%d", &tmp))
10493 *miss_next_indexp = next_index;
10498 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10500 u32 *r = va_arg (*args, u32 *);
10502 if (unformat (input, "conform-color"))
10503 *r = POLICE_CONFORM;
10504 else if (unformat (input, "exceed-color"))
10505 *r = POLICE_EXCEED;
10513 api_classify_add_del_table (vat_main_t * vam)
10515 unformat_input_t *i = vam->input;
10516 vl_api_classify_add_del_table_t *mp;
10523 u32 table_index = ~0;
10524 u32 next_table_index = ~0;
10525 u32 miss_next_index = ~0;
10526 u32 memory_size = 32 << 20;
10528 u32 current_data_flag = 0;
10529 int current_data_offset = 0;
10532 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10534 if (unformat (i, "del"))
10536 else if (unformat (i, "del-chain"))
10541 else if (unformat (i, "buckets %d", &nbuckets))
10543 else if (unformat (i, "memory_size %d", &memory_size))
10545 else if (unformat (i, "skip %d", &skip))
10547 else if (unformat (i, "match %d", &match))
10549 else if (unformat (i, "table %d", &table_index))
10551 else if (unformat (i, "mask %U", unformat_classify_mask,
10552 &mask, &skip, &match))
10554 else if (unformat (i, "next-table %d", &next_table_index))
10556 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10559 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10562 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10565 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10567 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10573 if (is_add && mask == 0)
10575 errmsg ("Mask required");
10579 if (is_add && skip == ~0)
10581 errmsg ("skip count required");
10585 if (is_add && match == ~0)
10587 errmsg ("match count required");
10591 if (!is_add && table_index == ~0)
10593 errmsg ("table index required for delete");
10597 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10599 mp->is_add = is_add;
10600 mp->del_chain = del_chain;
10601 mp->table_index = ntohl (table_index);
10602 mp->nbuckets = ntohl (nbuckets);
10603 mp->memory_size = ntohl (memory_size);
10604 mp->skip_n_vectors = ntohl (skip);
10605 mp->match_n_vectors = ntohl (match);
10606 mp->next_table_index = ntohl (next_table_index);
10607 mp->miss_next_index = ntohl (miss_next_index);
10608 mp->current_data_flag = ntohl (current_data_flag);
10609 mp->current_data_offset = ntohl (current_data_offset);
10610 clib_memcpy (mp->mask, mask, vec_len (mask));
10619 #if VPP_API_TEST_BUILTIN == 0
10621 unformat_l4_match (unformat_input_t * input, va_list * args)
10623 u8 **matchp = va_arg (*args, u8 **);
10625 u8 *proto_header = 0;
10631 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10633 if (unformat (input, "src_port %d", &src_port))
10635 else if (unformat (input, "dst_port %d", &dst_port))
10641 h.src_port = clib_host_to_net_u16 (src_port);
10642 h.dst_port = clib_host_to_net_u16 (dst_port);
10643 vec_validate (proto_header, sizeof (h) - 1);
10644 memcpy (proto_header, &h, sizeof (h));
10646 *matchp = proto_header;
10652 unformat_ip4_match (unformat_input_t * input, va_list * args)
10654 u8 **matchp = va_arg (*args, u8 **);
10659 int hdr_length = 0;
10660 u32 hdr_length_val;
10661 int src = 0, dst = 0;
10662 ip4_address_t src_val, dst_val;
10669 int fragment_id = 0;
10670 u32 fragment_id_val;
10676 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10678 if (unformat (input, "version %d", &version_val))
10680 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10682 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10684 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10686 else if (unformat (input, "proto %d", &proto_val))
10688 else if (unformat (input, "tos %d", &tos_val))
10690 else if (unformat (input, "length %d", &length_val))
10692 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10694 else if (unformat (input, "ttl %d", &ttl_val))
10696 else if (unformat (input, "checksum %d", &checksum_val))
10702 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10703 + ttl + checksum == 0)
10707 * Aligned because we use the real comparison functions
10709 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10711 ip = (ip4_header_t *) match;
10713 /* These are realistically matched in practice */
10715 ip->src_address.as_u32 = src_val.as_u32;
10718 ip->dst_address.as_u32 = dst_val.as_u32;
10721 ip->protocol = proto_val;
10724 /* These are not, but they're included for completeness */
10726 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10729 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10735 ip->length = clib_host_to_net_u16 (length_val);
10741 ip->checksum = clib_host_to_net_u16 (checksum_val);
10748 unformat_ip6_match (unformat_input_t * input, va_list * args)
10750 u8 **matchp = va_arg (*args, u8 **);
10755 u8 traffic_class = 0;
10756 u32 traffic_class_val = 0;
10759 int src = 0, dst = 0;
10760 ip6_address_t src_val, dst_val;
10763 int payload_length = 0;
10764 u32 payload_length_val;
10767 u32 ip_version_traffic_class_and_flow_label;
10769 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10771 if (unformat (input, "version %d", &version_val))
10773 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10775 else if (unformat (input, "flow_label %d", &flow_label_val))
10777 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10779 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10781 else if (unformat (input, "proto %d", &proto_val))
10783 else if (unformat (input, "payload_length %d", &payload_length_val))
10784 payload_length = 1;
10785 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10791 if (version + traffic_class + flow_label + src + dst + proto +
10792 payload_length + hop_limit == 0)
10796 * Aligned because we use the real comparison functions
10798 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10800 ip = (ip6_header_t *) match;
10803 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10806 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10809 ip->protocol = proto_val;
10811 ip_version_traffic_class_and_flow_label = 0;
10814 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10817 ip_version_traffic_class_and_flow_label |=
10818 (traffic_class_val & 0xFF) << 20;
10821 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10823 ip->ip_version_traffic_class_and_flow_label =
10824 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10826 if (payload_length)
10827 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10830 ip->hop_limit = hop_limit_val;
10837 unformat_l3_match (unformat_input_t * input, va_list * args)
10839 u8 **matchp = va_arg (*args, u8 **);
10841 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10843 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10845 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10854 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10856 u8 *tagp = va_arg (*args, u8 *);
10859 if (unformat (input, "%d", &tag))
10861 tagp[0] = (tag >> 8) & 0x0F;
10862 tagp[1] = tag & 0xFF;
10870 unformat_l2_match (unformat_input_t * input, va_list * args)
10872 u8 **matchp = va_arg (*args, u8 **);
10885 u8 ignore_tag1 = 0;
10886 u8 ignore_tag2 = 0;
10892 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10894 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10897 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10899 else if (unformat (input, "proto %U",
10900 unformat_ethernet_type_host_byte_order, &proto_val))
10902 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10904 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10906 else if (unformat (input, "ignore-tag1"))
10908 else if (unformat (input, "ignore-tag2"))
10910 else if (unformat (input, "cos1 %d", &cos1_val))
10912 else if (unformat (input, "cos2 %d", &cos2_val))
10917 if ((src + dst + proto + tag1 + tag2 +
10918 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10921 if (tag1 || ignore_tag1 || cos1)
10923 if (tag2 || ignore_tag2 || cos2)
10926 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10929 clib_memcpy (match, dst_val, 6);
10932 clib_memcpy (match + 6, src_val, 6);
10936 /* inner vlan tag */
10937 match[19] = tag2_val[1];
10938 match[18] = tag2_val[0];
10940 match[18] |= (cos2_val & 0x7) << 5;
10943 match[21] = proto_val & 0xff;
10944 match[20] = proto_val >> 8;
10948 match[15] = tag1_val[1];
10949 match[14] = tag1_val[0];
10952 match[14] |= (cos1_val & 0x7) << 5;
10958 match[15] = tag1_val[1];
10959 match[14] = tag1_val[0];
10962 match[17] = proto_val & 0xff;
10963 match[16] = proto_val >> 8;
10966 match[14] |= (cos1_val & 0x7) << 5;
10972 match[18] |= (cos2_val & 0x7) << 5;
10974 match[14] |= (cos1_val & 0x7) << 5;
10977 match[13] = proto_val & 0xff;
10978 match[12] = proto_val >> 8;
10987 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10989 u8 **matchp = va_arg (*args, u8 **);
10990 u32 skip_n_vectors = va_arg (*args, u32);
10991 u32 match_n_vectors = va_arg (*args, u32);
10998 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11000 if (unformat (input, "hex %U", unformat_hex_string, &match))
11002 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11004 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11006 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11020 if (match || l2 || l3 || l4)
11022 if (l2 || l3 || l4)
11024 /* "Win a free Ethernet header in every packet" */
11026 vec_validate_aligned (l2, 13, sizeof (u32x4));
11030 vec_append_aligned (match, l3, sizeof (u32x4));
11035 vec_append_aligned (match, l4, sizeof (u32x4));
11040 /* Make sure the vector is big enough even if key is all 0's */
11041 vec_validate_aligned
11042 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11045 /* Set size, include skipped vectors */
11046 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11057 api_classify_add_del_session (vat_main_t * vam)
11059 unformat_input_t *i = vam->input;
11060 vl_api_classify_add_del_session_t *mp;
11062 u32 table_index = ~0;
11063 u32 hit_next_index = ~0;
11064 u32 opaque_index = ~0;
11067 u32 skip_n_vectors = 0;
11068 u32 match_n_vectors = 0;
11074 * Warning: you have to supply skip_n and match_n
11075 * because the API client cant simply look at the classify
11079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11081 if (unformat (i, "del"))
11083 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11086 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11089 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11092 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11094 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11096 else if (unformat (i, "opaque-index %d", &opaque_index))
11098 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11100 else if (unformat (i, "match_n %d", &match_n_vectors))
11102 else if (unformat (i, "match %U", api_unformat_classify_match,
11103 &match, skip_n_vectors, match_n_vectors))
11105 else if (unformat (i, "advance %d", &advance))
11107 else if (unformat (i, "table-index %d", &table_index))
11109 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11111 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11113 else if (unformat (i, "action %d", &action))
11115 else if (unformat (i, "metadata %d", &metadata))
11121 if (table_index == ~0)
11123 errmsg ("Table index required");
11127 if (is_add && match == 0)
11129 errmsg ("Match value required");
11133 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11135 mp->is_add = is_add;
11136 mp->table_index = ntohl (table_index);
11137 mp->hit_next_index = ntohl (hit_next_index);
11138 mp->opaque_index = ntohl (opaque_index);
11139 mp->advance = ntohl (advance);
11140 mp->action = action;
11141 mp->metadata = ntohl (metadata);
11142 clib_memcpy (mp->match, match, vec_len (match));
11151 api_classify_set_interface_ip_table (vat_main_t * vam)
11153 unformat_input_t *i = vam->input;
11154 vl_api_classify_set_interface_ip_table_t *mp;
11156 int sw_if_index_set;
11157 u32 table_index = ~0;
11161 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11163 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11164 sw_if_index_set = 1;
11165 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11166 sw_if_index_set = 1;
11167 else if (unformat (i, "table %d", &table_index))
11171 clib_warning ("parse error '%U'", format_unformat_error, i);
11176 if (sw_if_index_set == 0)
11178 errmsg ("missing interface name or sw_if_index");
11183 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11185 mp->sw_if_index = ntohl (sw_if_index);
11186 mp->table_index = ntohl (table_index);
11187 mp->is_ipv6 = is_ipv6;
11195 api_classify_set_interface_l2_tables (vat_main_t * vam)
11197 unformat_input_t *i = vam->input;
11198 vl_api_classify_set_interface_l2_tables_t *mp;
11200 int sw_if_index_set;
11201 u32 ip4_table_index = ~0;
11202 u32 ip6_table_index = ~0;
11203 u32 other_table_index = ~0;
11207 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11209 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11210 sw_if_index_set = 1;
11211 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11212 sw_if_index_set = 1;
11213 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11215 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11217 else if (unformat (i, "other-table %d", &other_table_index))
11219 else if (unformat (i, "is-input %d", &is_input))
11223 clib_warning ("parse error '%U'", format_unformat_error, i);
11228 if (sw_if_index_set == 0)
11230 errmsg ("missing interface name or sw_if_index");
11235 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11237 mp->sw_if_index = ntohl (sw_if_index);
11238 mp->ip4_table_index = ntohl (ip4_table_index);
11239 mp->ip6_table_index = ntohl (ip6_table_index);
11240 mp->other_table_index = ntohl (other_table_index);
11241 mp->is_input = (u8) is_input;
11249 api_set_ipfix_exporter (vat_main_t * vam)
11251 unformat_input_t *i = vam->input;
11252 vl_api_set_ipfix_exporter_t *mp;
11253 ip4_address_t collector_address;
11254 u8 collector_address_set = 0;
11255 u32 collector_port = ~0;
11256 ip4_address_t src_address;
11257 u8 src_address_set = 0;
11260 u32 template_interval = ~0;
11261 u8 udp_checksum = 0;
11264 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11266 if (unformat (i, "collector_address %U", unformat_ip4_address,
11267 &collector_address))
11268 collector_address_set = 1;
11269 else if (unformat (i, "collector_port %d", &collector_port))
11271 else if (unformat (i, "src_address %U", unformat_ip4_address,
11273 src_address_set = 1;
11274 else if (unformat (i, "vrf_id %d", &vrf_id))
11276 else if (unformat (i, "path_mtu %d", &path_mtu))
11278 else if (unformat (i, "template_interval %d", &template_interval))
11280 else if (unformat (i, "udp_checksum"))
11286 if (collector_address_set == 0)
11288 errmsg ("collector_address required");
11292 if (src_address_set == 0)
11294 errmsg ("src_address required");
11298 M (SET_IPFIX_EXPORTER, mp);
11300 memcpy (mp->collector_address, collector_address.data,
11301 sizeof (collector_address.data));
11302 mp->collector_port = htons ((u16) collector_port);
11303 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11304 mp->vrf_id = htonl (vrf_id);
11305 mp->path_mtu = htonl (path_mtu);
11306 mp->template_interval = htonl (template_interval);
11307 mp->udp_checksum = udp_checksum;
11315 api_set_ipfix_classify_stream (vat_main_t * vam)
11317 unformat_input_t *i = vam->input;
11318 vl_api_set_ipfix_classify_stream_t *mp;
11320 u32 src_port = UDP_DST_PORT_ipfix;
11323 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11325 if (unformat (i, "domain %d", &domain_id))
11327 else if (unformat (i, "src_port %d", &src_port))
11331 errmsg ("unknown input `%U'", format_unformat_error, i);
11336 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11338 mp->domain_id = htonl (domain_id);
11339 mp->src_port = htons ((u16) src_port);
11347 api_ipfix_classify_table_add_del (vat_main_t * vam)
11349 unformat_input_t *i = vam->input;
11350 vl_api_ipfix_classify_table_add_del_t *mp;
11352 u32 classify_table_index = ~0;
11354 u8 transport_protocol = 255;
11357 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11359 if (unformat (i, "add"))
11361 else if (unformat (i, "del"))
11363 else if (unformat (i, "table %d", &classify_table_index))
11365 else if (unformat (i, "ip4"))
11367 else if (unformat (i, "ip6"))
11369 else if (unformat (i, "tcp"))
11370 transport_protocol = 6;
11371 else if (unformat (i, "udp"))
11372 transport_protocol = 17;
11375 errmsg ("unknown input `%U'", format_unformat_error, i);
11382 errmsg ("expecting: add|del");
11385 if (classify_table_index == ~0)
11387 errmsg ("classifier table not specified");
11390 if (ip_version == 0)
11392 errmsg ("IP version not specified");
11396 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11398 mp->is_add = is_add;
11399 mp->table_id = htonl (classify_table_index);
11400 mp->ip_version = ip_version;
11401 mp->transport_protocol = transport_protocol;
11409 api_get_node_index (vat_main_t * vam)
11411 unformat_input_t *i = vam->input;
11412 vl_api_get_node_index_t *mp;
11416 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11418 if (unformat (i, "node %s", &name))
11425 errmsg ("node name required");
11428 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11430 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11434 M (GET_NODE_INDEX, mp);
11435 clib_memcpy (mp->node_name, name, vec_len (name));
11444 api_get_next_index (vat_main_t * vam)
11446 unformat_input_t *i = vam->input;
11447 vl_api_get_next_index_t *mp;
11448 u8 *node_name = 0, *next_node_name = 0;
11451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11453 if (unformat (i, "node-name %s", &node_name))
11455 else if (unformat (i, "next-node-name %s", &next_node_name))
11459 if (node_name == 0)
11461 errmsg ("node name required");
11464 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11466 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11470 if (next_node_name == 0)
11472 errmsg ("next node name required");
11475 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11477 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11481 M (GET_NEXT_INDEX, mp);
11482 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11483 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11484 vec_free (node_name);
11485 vec_free (next_node_name);
11493 api_add_node_next (vat_main_t * vam)
11495 unformat_input_t *i = vam->input;
11496 vl_api_add_node_next_t *mp;
11501 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11503 if (unformat (i, "node %s", &name))
11505 else if (unformat (i, "next %s", &next))
11512 errmsg ("node name required");
11515 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11517 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11522 errmsg ("next node required");
11525 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11527 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11531 M (ADD_NODE_NEXT, mp);
11532 clib_memcpy (mp->node_name, name, vec_len (name));
11533 clib_memcpy (mp->next_name, next, vec_len (next));
11543 api_l2tpv3_create_tunnel (vat_main_t * vam)
11545 unformat_input_t *i = vam->input;
11546 ip6_address_t client_address, our_address;
11547 int client_address_set = 0;
11548 int our_address_set = 0;
11549 u32 local_session_id = 0;
11550 u32 remote_session_id = 0;
11551 u64 local_cookie = 0;
11552 u64 remote_cookie = 0;
11553 u8 l2_sublayer_present = 0;
11554 vl_api_l2tpv3_create_tunnel_t *mp;
11557 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11559 if (unformat (i, "client_address %U", unformat_ip6_address,
11561 client_address_set = 1;
11562 else if (unformat (i, "our_address %U", unformat_ip6_address,
11564 our_address_set = 1;
11565 else if (unformat (i, "local_session_id %d", &local_session_id))
11567 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11569 else if (unformat (i, "local_cookie %lld", &local_cookie))
11571 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11573 else if (unformat (i, "l2-sublayer-present"))
11574 l2_sublayer_present = 1;
11579 if (client_address_set == 0)
11581 errmsg ("client_address required");
11585 if (our_address_set == 0)
11587 errmsg ("our_address required");
11591 M (L2TPV3_CREATE_TUNNEL, mp);
11593 clib_memcpy (mp->client_address, client_address.as_u8,
11594 sizeof (mp->client_address));
11596 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11598 mp->local_session_id = ntohl (local_session_id);
11599 mp->remote_session_id = ntohl (remote_session_id);
11600 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11601 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11602 mp->l2_sublayer_present = l2_sublayer_present;
11611 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11613 unformat_input_t *i = vam->input;
11615 u8 sw_if_index_set = 0;
11616 u64 new_local_cookie = 0;
11617 u64 new_remote_cookie = 0;
11618 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11621 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11623 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11624 sw_if_index_set = 1;
11625 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11626 sw_if_index_set = 1;
11627 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11629 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11635 if (sw_if_index_set == 0)
11637 errmsg ("missing interface name or sw_if_index");
11641 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11643 mp->sw_if_index = ntohl (sw_if_index);
11644 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11645 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11653 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11655 unformat_input_t *i = vam->input;
11656 vl_api_l2tpv3_interface_enable_disable_t *mp;
11658 u8 sw_if_index_set = 0;
11659 u8 enable_disable = 1;
11662 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11664 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11665 sw_if_index_set = 1;
11666 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11667 sw_if_index_set = 1;
11668 else if (unformat (i, "enable"))
11669 enable_disable = 1;
11670 else if (unformat (i, "disable"))
11671 enable_disable = 0;
11676 if (sw_if_index_set == 0)
11678 errmsg ("missing interface name or sw_if_index");
11682 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11684 mp->sw_if_index = ntohl (sw_if_index);
11685 mp->enable_disable = enable_disable;
11693 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11695 unformat_input_t *i = vam->input;
11696 vl_api_l2tpv3_set_lookup_key_t *mp;
11700 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11702 if (unformat (i, "lookup_v6_src"))
11703 key = L2T_LOOKUP_SRC_ADDRESS;
11704 else if (unformat (i, "lookup_v6_dst"))
11705 key = L2T_LOOKUP_DST_ADDRESS;
11706 else if (unformat (i, "lookup_session_id"))
11707 key = L2T_LOOKUP_SESSION_ID;
11712 if (key == (u8) ~ 0)
11714 errmsg ("l2tp session lookup key unset");
11718 M (L2TPV3_SET_LOOKUP_KEY, mp);
11727 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11728 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11730 vat_main_t *vam = &vat_main;
11732 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11733 format_ip6_address, mp->our_address,
11734 format_ip6_address, mp->client_address,
11735 clib_net_to_host_u32 (mp->sw_if_index));
11738 " local cookies %016llx %016llx remote cookie %016llx",
11739 clib_net_to_host_u64 (mp->local_cookie[0]),
11740 clib_net_to_host_u64 (mp->local_cookie[1]),
11741 clib_net_to_host_u64 (mp->remote_cookie));
11743 print (vam->ofp, " local session-id %d remote session-id %d",
11744 clib_net_to_host_u32 (mp->local_session_id),
11745 clib_net_to_host_u32 (mp->remote_session_id));
11747 print (vam->ofp, " l2 specific sublayer %s\n",
11748 mp->l2_sublayer_present ? "preset" : "absent");
11752 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11753 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11755 vat_main_t *vam = &vat_main;
11756 vat_json_node_t *node = NULL;
11757 struct in6_addr addr;
11759 if (VAT_JSON_ARRAY != vam->json_tree.type)
11761 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11762 vat_json_init_array (&vam->json_tree);
11764 node = vat_json_array_add (&vam->json_tree);
11766 vat_json_init_object (node);
11768 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11769 vat_json_object_add_ip6 (node, "our_address", addr);
11770 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11771 vat_json_object_add_ip6 (node, "client_address", addr);
11773 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11774 vat_json_init_array (lc);
11775 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11776 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11777 vat_json_object_add_uint (node, "remote_cookie",
11778 clib_net_to_host_u64 (mp->remote_cookie));
11780 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11781 vat_json_object_add_uint (node, "local_session_id",
11782 clib_net_to_host_u32 (mp->local_session_id));
11783 vat_json_object_add_uint (node, "remote_session_id",
11784 clib_net_to_host_u32 (mp->remote_session_id));
11785 vat_json_object_add_string_copy (node, "l2_sublayer",
11786 mp->l2_sublayer_present ? (u8 *) "present"
11787 : (u8 *) "absent");
11791 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11793 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11794 vl_api_control_ping_t *mp_ping;
11797 /* Get list of l2tpv3-tunnel interfaces */
11798 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11801 /* Use a control ping for synchronization */
11802 MPING (CONTROL_PING, mp_ping);
11810 static void vl_api_sw_interface_tap_details_t_handler
11811 (vl_api_sw_interface_tap_details_t * mp)
11813 vat_main_t *vam = &vat_main;
11815 print (vam->ofp, "%-16s %d",
11816 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
11819 static void vl_api_sw_interface_tap_details_t_handler_json
11820 (vl_api_sw_interface_tap_details_t * mp)
11822 vat_main_t *vam = &vat_main;
11823 vat_json_node_t *node = NULL;
11825 if (VAT_JSON_ARRAY != vam->json_tree.type)
11827 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11828 vat_json_init_array (&vam->json_tree);
11830 node = vat_json_array_add (&vam->json_tree);
11832 vat_json_init_object (node);
11833 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11834 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11838 api_sw_interface_tap_dump (vat_main_t * vam)
11840 vl_api_sw_interface_tap_dump_t *mp;
11841 vl_api_control_ping_t *mp_ping;
11844 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
11845 /* Get list of tap interfaces */
11846 M (SW_INTERFACE_TAP_DUMP, mp);
11849 /* Use a control ping for synchronization */
11850 MPING (CONTROL_PING, mp_ping);
11857 static uword unformat_vxlan_decap_next
11858 (unformat_input_t * input, va_list * args)
11860 u32 *result = va_arg (*args, u32 *);
11863 if (unformat (input, "l2"))
11864 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11865 else if (unformat (input, "%d", &tmp))
11873 api_vxlan_add_del_tunnel (vat_main_t * vam)
11875 unformat_input_t *line_input = vam->input;
11876 vl_api_vxlan_add_del_tunnel_t *mp;
11877 ip46_address_t src, dst;
11879 u8 ipv4_set = 0, ipv6_set = 0;
11883 u32 mcast_sw_if_index = ~0;
11884 u32 encap_vrf_id = 0;
11885 u32 decap_next_index = ~0;
11889 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11890 memset (&src, 0, sizeof src);
11891 memset (&dst, 0, sizeof dst);
11893 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11895 if (unformat (line_input, "del"))
11898 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11904 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11910 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11916 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11921 else if (unformat (line_input, "group %U %U",
11922 unformat_ip4_address, &dst.ip4,
11923 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11925 grp_set = dst_set = 1;
11928 else if (unformat (line_input, "group %U",
11929 unformat_ip4_address, &dst.ip4))
11931 grp_set = dst_set = 1;
11934 else if (unformat (line_input, "group %U %U",
11935 unformat_ip6_address, &dst.ip6,
11936 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11938 grp_set = dst_set = 1;
11941 else if (unformat (line_input, "group %U",
11942 unformat_ip6_address, &dst.ip6))
11944 grp_set = dst_set = 1;
11948 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11950 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11952 else if (unformat (line_input, "decap-next %U",
11953 unformat_vxlan_decap_next, &decap_next_index))
11955 else if (unformat (line_input, "vni %d", &vni))
11959 errmsg ("parse error '%U'", format_unformat_error, line_input);
11966 errmsg ("tunnel src address not specified");
11971 errmsg ("tunnel dst address not specified");
11975 if (grp_set && !ip46_address_is_multicast (&dst))
11977 errmsg ("tunnel group address not multicast");
11980 if (grp_set && mcast_sw_if_index == ~0)
11982 errmsg ("tunnel nonexistent multicast device");
11985 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11987 errmsg ("tunnel dst address must be unicast");
11992 if (ipv4_set && ipv6_set)
11994 errmsg ("both IPv4 and IPv6 addresses specified");
11998 if ((vni == 0) || (vni >> 24))
12000 errmsg ("vni not specified or out of range");
12004 M (VXLAN_ADD_DEL_TUNNEL, mp);
12008 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12009 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12013 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12014 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12016 mp->encap_vrf_id = ntohl (encap_vrf_id);
12017 mp->decap_next_index = ntohl (decap_next_index);
12018 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12019 mp->vni = ntohl (vni);
12020 mp->is_add = is_add;
12021 mp->is_ipv6 = ipv6_set;
12028 static void vl_api_vxlan_tunnel_details_t_handler
12029 (vl_api_vxlan_tunnel_details_t * mp)
12031 vat_main_t *vam = &vat_main;
12032 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12033 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12035 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12036 ntohl (mp->sw_if_index),
12037 format_ip46_address, &src, IP46_TYPE_ANY,
12038 format_ip46_address, &dst, IP46_TYPE_ANY,
12039 ntohl (mp->encap_vrf_id),
12040 ntohl (mp->decap_next_index), ntohl (mp->vni),
12041 ntohl (mp->mcast_sw_if_index));
12044 static void vl_api_vxlan_tunnel_details_t_handler_json
12045 (vl_api_vxlan_tunnel_details_t * mp)
12047 vat_main_t *vam = &vat_main;
12048 vat_json_node_t *node = NULL;
12050 if (VAT_JSON_ARRAY != vam->json_tree.type)
12052 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12053 vat_json_init_array (&vam->json_tree);
12055 node = vat_json_array_add (&vam->json_tree);
12057 vat_json_init_object (node);
12058 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12061 struct in6_addr ip6;
12063 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12064 vat_json_object_add_ip6 (node, "src_address", ip6);
12065 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12066 vat_json_object_add_ip6 (node, "dst_address", ip6);
12070 struct in_addr ip4;
12072 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12073 vat_json_object_add_ip4 (node, "src_address", ip4);
12074 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12075 vat_json_object_add_ip4 (node, "dst_address", ip4);
12077 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12078 vat_json_object_add_uint (node, "decap_next_index",
12079 ntohl (mp->decap_next_index));
12080 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12081 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12082 vat_json_object_add_uint (node, "mcast_sw_if_index",
12083 ntohl (mp->mcast_sw_if_index));
12087 api_vxlan_tunnel_dump (vat_main_t * vam)
12089 unformat_input_t *i = vam->input;
12090 vl_api_vxlan_tunnel_dump_t *mp;
12091 vl_api_control_ping_t *mp_ping;
12093 u8 sw_if_index_set = 0;
12096 /* Parse args required to build the message */
12097 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12099 if (unformat (i, "sw_if_index %d", &sw_if_index))
12100 sw_if_index_set = 1;
12105 if (sw_if_index_set == 0)
12110 if (!vam->json_output)
12112 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12113 "sw_if_index", "src_address", "dst_address",
12114 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12117 /* Get list of vxlan-tunnel interfaces */
12118 M (VXLAN_TUNNEL_DUMP, mp);
12120 mp->sw_if_index = htonl (sw_if_index);
12124 /* Use a control ping for synchronization */
12125 MPING (CONTROL_PING, mp_ping);
12132 static uword unformat_geneve_decap_next
12133 (unformat_input_t * input, va_list * args)
12135 u32 *result = va_arg (*args, u32 *);
12138 if (unformat (input, "l2"))
12139 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12140 else if (unformat (input, "%d", &tmp))
12148 api_geneve_add_del_tunnel (vat_main_t * vam)
12150 unformat_input_t *line_input = vam->input;
12151 vl_api_geneve_add_del_tunnel_t *mp;
12152 ip46_address_t src, dst;
12154 u8 ipv4_set = 0, ipv6_set = 0;
12158 u32 mcast_sw_if_index = ~0;
12159 u32 encap_vrf_id = 0;
12160 u32 decap_next_index = ~0;
12164 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12165 memset (&src, 0, sizeof src);
12166 memset (&dst, 0, sizeof dst);
12168 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12170 if (unformat (line_input, "del"))
12173 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12179 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12185 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12191 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12196 else if (unformat (line_input, "group %U %U",
12197 unformat_ip4_address, &dst.ip4,
12198 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12200 grp_set = dst_set = 1;
12203 else if (unformat (line_input, "group %U",
12204 unformat_ip4_address, &dst.ip4))
12206 grp_set = dst_set = 1;
12209 else if (unformat (line_input, "group %U %U",
12210 unformat_ip6_address, &dst.ip6,
12211 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12213 grp_set = dst_set = 1;
12216 else if (unformat (line_input, "group %U",
12217 unformat_ip6_address, &dst.ip6))
12219 grp_set = dst_set = 1;
12223 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12225 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12227 else if (unformat (line_input, "decap-next %U",
12228 unformat_geneve_decap_next, &decap_next_index))
12230 else if (unformat (line_input, "vni %d", &vni))
12234 errmsg ("parse error '%U'", format_unformat_error, line_input);
12241 errmsg ("tunnel src address not specified");
12246 errmsg ("tunnel dst address not specified");
12250 if (grp_set && !ip46_address_is_multicast (&dst))
12252 errmsg ("tunnel group address not multicast");
12255 if (grp_set && mcast_sw_if_index == ~0)
12257 errmsg ("tunnel nonexistent multicast device");
12260 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12262 errmsg ("tunnel dst address must be unicast");
12267 if (ipv4_set && ipv6_set)
12269 errmsg ("both IPv4 and IPv6 addresses specified");
12273 if ((vni == 0) || (vni >> 24))
12275 errmsg ("vni not specified or out of range");
12279 M (GENEVE_ADD_DEL_TUNNEL, mp);
12283 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12284 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12288 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12289 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12291 mp->encap_vrf_id = ntohl (encap_vrf_id);
12292 mp->decap_next_index = ntohl (decap_next_index);
12293 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12294 mp->vni = ntohl (vni);
12295 mp->is_add = is_add;
12296 mp->is_ipv6 = ipv6_set;
12303 static void vl_api_geneve_tunnel_details_t_handler
12304 (vl_api_geneve_tunnel_details_t * mp)
12306 vat_main_t *vam = &vat_main;
12307 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12308 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12310 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12311 ntohl (mp->sw_if_index),
12312 format_ip46_address, &src, IP46_TYPE_ANY,
12313 format_ip46_address, &dst, IP46_TYPE_ANY,
12314 ntohl (mp->encap_vrf_id),
12315 ntohl (mp->decap_next_index), ntohl (mp->vni),
12316 ntohl (mp->mcast_sw_if_index));
12319 static void vl_api_geneve_tunnel_details_t_handler_json
12320 (vl_api_geneve_tunnel_details_t * mp)
12322 vat_main_t *vam = &vat_main;
12323 vat_json_node_t *node = NULL;
12325 if (VAT_JSON_ARRAY != vam->json_tree.type)
12327 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12328 vat_json_init_array (&vam->json_tree);
12330 node = vat_json_array_add (&vam->json_tree);
12332 vat_json_init_object (node);
12333 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12336 struct in6_addr ip6;
12338 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12339 vat_json_object_add_ip6 (node, "src_address", ip6);
12340 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12341 vat_json_object_add_ip6 (node, "dst_address", ip6);
12345 struct in_addr ip4;
12347 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12348 vat_json_object_add_ip4 (node, "src_address", ip4);
12349 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12350 vat_json_object_add_ip4 (node, "dst_address", ip4);
12352 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12353 vat_json_object_add_uint (node, "decap_next_index",
12354 ntohl (mp->decap_next_index));
12355 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12356 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12357 vat_json_object_add_uint (node, "mcast_sw_if_index",
12358 ntohl (mp->mcast_sw_if_index));
12362 api_geneve_tunnel_dump (vat_main_t * vam)
12364 unformat_input_t *i = vam->input;
12365 vl_api_geneve_tunnel_dump_t *mp;
12366 vl_api_control_ping_t *mp_ping;
12368 u8 sw_if_index_set = 0;
12371 /* Parse args required to build the message */
12372 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12374 if (unformat (i, "sw_if_index %d", &sw_if_index))
12375 sw_if_index_set = 1;
12380 if (sw_if_index_set == 0)
12385 if (!vam->json_output)
12387 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12388 "sw_if_index", "local_address", "remote_address",
12389 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12392 /* Get list of geneve-tunnel interfaces */
12393 M (GENEVE_TUNNEL_DUMP, mp);
12395 mp->sw_if_index = htonl (sw_if_index);
12399 /* Use a control ping for synchronization */
12400 M (CONTROL_PING, mp_ping);
12408 api_gre_add_del_tunnel (vat_main_t * vam)
12410 unformat_input_t *line_input = vam->input;
12411 vl_api_gre_add_del_tunnel_t *mp;
12412 ip4_address_t src4, dst4;
12413 ip6_address_t src6, dst6;
12420 u32 outer_fib_id = 0;
12423 memset (&src4, 0, sizeof src4);
12424 memset (&dst4, 0, sizeof dst4);
12425 memset (&src6, 0, sizeof src6);
12426 memset (&dst6, 0, sizeof dst6);
12428 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12430 if (unformat (line_input, "del"))
12432 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
12437 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
12442 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
12447 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
12452 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12454 else if (unformat (line_input, "teb"))
12458 errmsg ("parse error '%U'", format_unformat_error, line_input);
12465 errmsg ("tunnel src address not specified");
12470 errmsg ("tunnel dst address not specified");
12473 if (ipv4_set && ipv6_set)
12475 errmsg ("both IPv4 and IPv6 addresses specified");
12480 M (GRE_ADD_DEL_TUNNEL, mp);
12484 clib_memcpy (&mp->src_address, &src4, 4);
12485 clib_memcpy (&mp->dst_address, &dst4, 4);
12489 clib_memcpy (&mp->src_address, &src6, 16);
12490 clib_memcpy (&mp->dst_address, &dst6, 16);
12492 mp->outer_fib_id = ntohl (outer_fib_id);
12493 mp->is_add = is_add;
12495 mp->is_ipv6 = ipv6_set;
12502 static void vl_api_gre_tunnel_details_t_handler
12503 (vl_api_gre_tunnel_details_t * mp)
12505 vat_main_t *vam = &vat_main;
12506 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
12507 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
12509 print (vam->ofp, "%11d%24U%24U%6d%14d",
12510 ntohl (mp->sw_if_index),
12511 format_ip46_address, &src, IP46_TYPE_ANY,
12512 format_ip46_address, &dst, IP46_TYPE_ANY,
12513 mp->teb, ntohl (mp->outer_fib_id));
12516 static void vl_api_gre_tunnel_details_t_handler_json
12517 (vl_api_gre_tunnel_details_t * mp)
12519 vat_main_t *vam = &vat_main;
12520 vat_json_node_t *node = NULL;
12521 struct in_addr ip4;
12522 struct in6_addr ip6;
12524 if (VAT_JSON_ARRAY != vam->json_tree.type)
12526 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12527 vat_json_init_array (&vam->json_tree);
12529 node = vat_json_array_add (&vam->json_tree);
12531 vat_json_init_object (node);
12532 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12535 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
12536 vat_json_object_add_ip4 (node, "src_address", ip4);
12537 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
12538 vat_json_object_add_ip4 (node, "dst_address", ip4);
12542 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
12543 vat_json_object_add_ip6 (node, "src_address", ip6);
12544 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
12545 vat_json_object_add_ip6 (node, "dst_address", ip6);
12547 vat_json_object_add_uint (node, "teb", mp->teb);
12548 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
12549 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
12553 api_gre_tunnel_dump (vat_main_t * vam)
12555 unformat_input_t *i = vam->input;
12556 vl_api_gre_tunnel_dump_t *mp;
12557 vl_api_control_ping_t *mp_ping;
12559 u8 sw_if_index_set = 0;
12562 /* Parse args required to build the message */
12563 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12565 if (unformat (i, "sw_if_index %d", &sw_if_index))
12566 sw_if_index_set = 1;
12571 if (sw_if_index_set == 0)
12576 if (!vam->json_output)
12578 print (vam->ofp, "%11s%24s%24s%6s%14s",
12579 "sw_if_index", "src_address", "dst_address", "teb",
12583 /* Get list of gre-tunnel interfaces */
12584 M (GRE_TUNNEL_DUMP, mp);
12586 mp->sw_if_index = htonl (sw_if_index);
12590 /* Use a control ping for synchronization */
12591 MPING (CONTROL_PING, mp_ping);
12599 api_l2_fib_clear_table (vat_main_t * vam)
12601 // unformat_input_t * i = vam->input;
12602 vl_api_l2_fib_clear_table_t *mp;
12605 M (L2_FIB_CLEAR_TABLE, mp);
12613 api_l2_interface_efp_filter (vat_main_t * vam)
12615 unformat_input_t *i = vam->input;
12616 vl_api_l2_interface_efp_filter_t *mp;
12619 u8 sw_if_index_set = 0;
12622 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12624 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12625 sw_if_index_set = 1;
12626 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12627 sw_if_index_set = 1;
12628 else if (unformat (i, "enable"))
12630 else if (unformat (i, "disable"))
12634 clib_warning ("parse error '%U'", format_unformat_error, i);
12639 if (sw_if_index_set == 0)
12641 errmsg ("missing sw_if_index");
12645 M (L2_INTERFACE_EFP_FILTER, mp);
12647 mp->sw_if_index = ntohl (sw_if_index);
12648 mp->enable_disable = enable;
12655 #define foreach_vtr_op \
12656 _("disable", L2_VTR_DISABLED) \
12657 _("push-1", L2_VTR_PUSH_1) \
12658 _("push-2", L2_VTR_PUSH_2) \
12659 _("pop-1", L2_VTR_POP_1) \
12660 _("pop-2", L2_VTR_POP_2) \
12661 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12662 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12663 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12664 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12667 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12669 unformat_input_t *i = vam->input;
12670 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12672 u8 sw_if_index_set = 0;
12675 u32 push_dot1q = 1;
12680 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12682 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12683 sw_if_index_set = 1;
12684 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12685 sw_if_index_set = 1;
12686 else if (unformat (i, "vtr_op %d", &vtr_op))
12688 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12691 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12693 else if (unformat (i, "tag1 %d", &tag1))
12695 else if (unformat (i, "tag2 %d", &tag2))
12699 clib_warning ("parse error '%U'", format_unformat_error, i);
12704 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12706 errmsg ("missing vtr operation or sw_if_index");
12710 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12711 mp->sw_if_index = ntohl (sw_if_index);
12712 mp->vtr_op = ntohl (vtr_op);
12713 mp->push_dot1q = ntohl (push_dot1q);
12714 mp->tag1 = ntohl (tag1);
12715 mp->tag2 = ntohl (tag2);
12723 api_create_vhost_user_if (vat_main_t * vam)
12725 unformat_input_t *i = vam->input;
12726 vl_api_create_vhost_user_if_t *mp;
12729 u8 file_name_set = 0;
12730 u32 custom_dev_instance = ~0;
12732 u8 use_custom_mac = 0;
12736 /* Shut up coverity */
12737 memset (hwaddr, 0, sizeof (hwaddr));
12739 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12741 if (unformat (i, "socket %s", &file_name))
12745 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12747 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12748 use_custom_mac = 1;
12749 else if (unformat (i, "server"))
12751 else if (unformat (i, "tag %s", &tag))
12757 if (file_name_set == 0)
12759 errmsg ("missing socket file name");
12763 if (vec_len (file_name) > 255)
12765 errmsg ("socket file name too long");
12768 vec_add1 (file_name, 0);
12770 M (CREATE_VHOST_USER_IF, mp);
12772 mp->is_server = is_server;
12773 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12774 vec_free (file_name);
12775 if (custom_dev_instance != ~0)
12778 mp->custom_dev_instance = ntohl (custom_dev_instance);
12780 mp->use_custom_mac = use_custom_mac;
12781 clib_memcpy (mp->mac_address, hwaddr, 6);
12783 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12792 api_modify_vhost_user_if (vat_main_t * vam)
12794 unformat_input_t *i = vam->input;
12795 vl_api_modify_vhost_user_if_t *mp;
12798 u8 file_name_set = 0;
12799 u32 custom_dev_instance = ~0;
12800 u8 sw_if_index_set = 0;
12801 u32 sw_if_index = (u32) ~ 0;
12804 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12806 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12807 sw_if_index_set = 1;
12808 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12809 sw_if_index_set = 1;
12810 else if (unformat (i, "socket %s", &file_name))
12814 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12816 else if (unformat (i, "server"))
12822 if (sw_if_index_set == 0)
12824 errmsg ("missing sw_if_index or interface name");
12828 if (file_name_set == 0)
12830 errmsg ("missing socket file name");
12834 if (vec_len (file_name) > 255)
12836 errmsg ("socket file name too long");
12839 vec_add1 (file_name, 0);
12841 M (MODIFY_VHOST_USER_IF, mp);
12843 mp->sw_if_index = ntohl (sw_if_index);
12844 mp->is_server = is_server;
12845 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12846 vec_free (file_name);
12847 if (custom_dev_instance != ~0)
12850 mp->custom_dev_instance = ntohl (custom_dev_instance);
12859 api_delete_vhost_user_if (vat_main_t * vam)
12861 unformat_input_t *i = vam->input;
12862 vl_api_delete_vhost_user_if_t *mp;
12863 u32 sw_if_index = ~0;
12864 u8 sw_if_index_set = 0;
12867 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12869 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12870 sw_if_index_set = 1;
12871 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12872 sw_if_index_set = 1;
12877 if (sw_if_index_set == 0)
12879 errmsg ("missing sw_if_index or interface name");
12884 M (DELETE_VHOST_USER_IF, mp);
12886 mp->sw_if_index = ntohl (sw_if_index);
12893 static void vl_api_sw_interface_vhost_user_details_t_handler
12894 (vl_api_sw_interface_vhost_user_details_t * mp)
12896 vat_main_t *vam = &vat_main;
12898 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12899 (char *) mp->interface_name,
12900 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12901 clib_net_to_host_u64 (mp->features), mp->is_server,
12902 ntohl (mp->num_regions), (char *) mp->sock_filename);
12903 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12906 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12907 (vl_api_sw_interface_vhost_user_details_t * mp)
12909 vat_main_t *vam = &vat_main;
12910 vat_json_node_t *node = NULL;
12912 if (VAT_JSON_ARRAY != vam->json_tree.type)
12914 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12915 vat_json_init_array (&vam->json_tree);
12917 node = vat_json_array_add (&vam->json_tree);
12919 vat_json_init_object (node);
12920 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12921 vat_json_object_add_string_copy (node, "interface_name",
12922 mp->interface_name);
12923 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12924 ntohl (mp->virtio_net_hdr_sz));
12925 vat_json_object_add_uint (node, "features",
12926 clib_net_to_host_u64 (mp->features));
12927 vat_json_object_add_uint (node, "is_server", mp->is_server);
12928 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12929 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12930 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12934 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12936 vl_api_sw_interface_vhost_user_dump_t *mp;
12937 vl_api_control_ping_t *mp_ping;
12940 "Interface name idx hdr_sz features server regions filename");
12942 /* Get list of vhost-user interfaces */
12943 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12946 /* Use a control ping for synchronization */
12947 MPING (CONTROL_PING, mp_ping);
12955 api_show_version (vat_main_t * vam)
12957 vl_api_show_version_t *mp;
12960 M (SHOW_VERSION, mp);
12969 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12971 unformat_input_t *line_input = vam->input;
12972 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12973 ip4_address_t local4, remote4;
12974 ip6_address_t local6, remote6;
12976 u8 ipv4_set = 0, ipv6_set = 0;
12980 u32 mcast_sw_if_index = ~0;
12981 u32 encap_vrf_id = 0;
12982 u32 decap_vrf_id = 0;
12988 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12989 memset (&local4, 0, sizeof local4);
12990 memset (&remote4, 0, sizeof remote4);
12991 memset (&local6, 0, sizeof local6);
12992 memset (&remote6, 0, sizeof remote6);
12994 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12996 if (unformat (line_input, "del"))
12998 else if (unformat (line_input, "local %U",
12999 unformat_ip4_address, &local4))
13004 else if (unformat (line_input, "remote %U",
13005 unformat_ip4_address, &remote4))
13010 else if (unformat (line_input, "local %U",
13011 unformat_ip6_address, &local6))
13016 else if (unformat (line_input, "remote %U",
13017 unformat_ip6_address, &remote6))
13022 else if (unformat (line_input, "group %U %U",
13023 unformat_ip4_address, &remote4,
13024 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13026 grp_set = remote_set = 1;
13029 else if (unformat (line_input, "group %U",
13030 unformat_ip4_address, &remote4))
13032 grp_set = remote_set = 1;
13035 else if (unformat (line_input, "group %U %U",
13036 unformat_ip6_address, &remote6,
13037 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13039 grp_set = remote_set = 1;
13042 else if (unformat (line_input, "group %U",
13043 unformat_ip6_address, &remote6))
13045 grp_set = remote_set = 1;
13049 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13051 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13053 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13055 else if (unformat (line_input, "vni %d", &vni))
13057 else if (unformat (line_input, "next-ip4"))
13059 else if (unformat (line_input, "next-ip6"))
13061 else if (unformat (line_input, "next-ethernet"))
13063 else if (unformat (line_input, "next-nsh"))
13067 errmsg ("parse error '%U'", format_unformat_error, line_input);
13072 if (local_set == 0)
13074 errmsg ("tunnel local address not specified");
13077 if (remote_set == 0)
13079 errmsg ("tunnel remote address not specified");
13082 if (grp_set && mcast_sw_if_index == ~0)
13084 errmsg ("tunnel nonexistent multicast device");
13087 if (ipv4_set && ipv6_set)
13089 errmsg ("both IPv4 and IPv6 addresses specified");
13095 errmsg ("vni not specified");
13099 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13104 clib_memcpy (&mp->local, &local6, sizeof (local6));
13105 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13109 clib_memcpy (&mp->local, &local4, sizeof (local4));
13110 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13113 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13114 mp->encap_vrf_id = ntohl (encap_vrf_id);
13115 mp->decap_vrf_id = ntohl (decap_vrf_id);
13116 mp->protocol = protocol;
13117 mp->vni = ntohl (vni);
13118 mp->is_add = is_add;
13119 mp->is_ipv6 = ipv6_set;
13126 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13127 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13129 vat_main_t *vam = &vat_main;
13130 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13131 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13133 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13134 ntohl (mp->sw_if_index),
13135 format_ip46_address, &local, IP46_TYPE_ANY,
13136 format_ip46_address, &remote, IP46_TYPE_ANY,
13137 ntohl (mp->vni), mp->protocol,
13138 ntohl (mp->mcast_sw_if_index),
13139 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13143 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13144 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13146 vat_main_t *vam = &vat_main;
13147 vat_json_node_t *node = NULL;
13148 struct in_addr ip4;
13149 struct in6_addr ip6;
13151 if (VAT_JSON_ARRAY != vam->json_tree.type)
13153 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13154 vat_json_init_array (&vam->json_tree);
13156 node = vat_json_array_add (&vam->json_tree);
13158 vat_json_init_object (node);
13159 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13162 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13163 vat_json_object_add_ip6 (node, "local", ip6);
13164 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13165 vat_json_object_add_ip6 (node, "remote", ip6);
13169 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13170 vat_json_object_add_ip4 (node, "local", ip4);
13171 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13172 vat_json_object_add_ip4 (node, "remote", ip4);
13174 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13175 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13176 vat_json_object_add_uint (node, "mcast_sw_if_index",
13177 ntohl (mp->mcast_sw_if_index));
13178 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13179 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13180 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13184 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13186 unformat_input_t *i = vam->input;
13187 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13188 vl_api_control_ping_t *mp_ping;
13190 u8 sw_if_index_set = 0;
13193 /* Parse args required to build the message */
13194 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13196 if (unformat (i, "sw_if_index %d", &sw_if_index))
13197 sw_if_index_set = 1;
13202 if (sw_if_index_set == 0)
13207 if (!vam->json_output)
13209 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13210 "sw_if_index", "local", "remote", "vni",
13211 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13214 /* Get list of vxlan-tunnel interfaces */
13215 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13217 mp->sw_if_index = htonl (sw_if_index);
13221 /* Use a control ping for synchronization */
13222 MPING (CONTROL_PING, mp_ping);
13231 format_l2_fib_mac_address (u8 * s, va_list * args)
13233 u8 *a = va_arg (*args, u8 *);
13235 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
13236 a[2], a[3], a[4], a[5], a[6], a[7]);
13239 static void vl_api_l2_fib_table_details_t_handler
13240 (vl_api_l2_fib_table_details_t * mp)
13242 vat_main_t *vam = &vat_main;
13244 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13246 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
13247 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13251 static void vl_api_l2_fib_table_details_t_handler_json
13252 (vl_api_l2_fib_table_details_t * mp)
13254 vat_main_t *vam = &vat_main;
13255 vat_json_node_t *node = NULL;
13257 if (VAT_JSON_ARRAY != vam->json_tree.type)
13259 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13260 vat_json_init_array (&vam->json_tree);
13262 node = vat_json_array_add (&vam->json_tree);
13264 vat_json_init_object (node);
13265 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13266 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
13267 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13268 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13269 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13270 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13274 api_l2_fib_table_dump (vat_main_t * vam)
13276 unformat_input_t *i = vam->input;
13277 vl_api_l2_fib_table_dump_t *mp;
13278 vl_api_control_ping_t *mp_ping;
13283 /* Parse args required to build the message */
13284 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13286 if (unformat (i, "bd_id %d", &bd_id))
13292 if (bd_id_set == 0)
13294 errmsg ("missing bridge domain");
13298 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13300 /* Get list of l2 fib entries */
13301 M (L2_FIB_TABLE_DUMP, mp);
13303 mp->bd_id = ntohl (bd_id);
13306 /* Use a control ping for synchronization */
13307 MPING (CONTROL_PING, mp_ping);
13316 api_interface_name_renumber (vat_main_t * vam)
13318 unformat_input_t *line_input = vam->input;
13319 vl_api_interface_name_renumber_t *mp;
13320 u32 sw_if_index = ~0;
13321 u32 new_show_dev_instance = ~0;
13324 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13326 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13329 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13331 else if (unformat (line_input, "new_show_dev_instance %d",
13332 &new_show_dev_instance))
13338 if (sw_if_index == ~0)
13340 errmsg ("missing interface name or sw_if_index");
13344 if (new_show_dev_instance == ~0)
13346 errmsg ("missing new_show_dev_instance");
13350 M (INTERFACE_NAME_RENUMBER, mp);
13352 mp->sw_if_index = ntohl (sw_if_index);
13353 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13361 api_want_ip4_arp_events (vat_main_t * vam)
13363 unformat_input_t *line_input = vam->input;
13364 vl_api_want_ip4_arp_events_t *mp;
13365 ip4_address_t address;
13366 int address_set = 0;
13367 u32 enable_disable = 1;
13370 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13372 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
13374 else if (unformat (line_input, "del"))
13375 enable_disable = 0;
13380 if (address_set == 0)
13382 errmsg ("missing addresses");
13386 M (WANT_IP4_ARP_EVENTS, mp);
13387 mp->enable_disable = enable_disable;
13388 mp->pid = htonl (getpid ());
13389 mp->address = address.as_u32;
13397 api_want_ip6_nd_events (vat_main_t * vam)
13399 unformat_input_t *line_input = vam->input;
13400 vl_api_want_ip6_nd_events_t *mp;
13401 ip6_address_t address;
13402 int address_set = 0;
13403 u32 enable_disable = 1;
13406 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13408 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
13410 else if (unformat (line_input, "del"))
13411 enable_disable = 0;
13416 if (address_set == 0)
13418 errmsg ("missing addresses");
13422 M (WANT_IP6_ND_EVENTS, mp);
13423 mp->enable_disable = enable_disable;
13424 mp->pid = htonl (getpid ());
13425 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
13433 api_want_l2_macs_events (vat_main_t * vam)
13435 unformat_input_t *line_input = vam->input;
13436 vl_api_want_l2_macs_events_t *mp;
13437 u8 enable_disable = 1;
13438 u32 scan_delay = 0;
13439 u32 max_macs_in_event = 0;
13440 u32 learn_limit = 0;
13443 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13445 if (unformat (line_input, "learn-limit %d", &learn_limit))
13447 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13449 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13451 else if (unformat (line_input, "disable"))
13452 enable_disable = 0;
13457 M (WANT_L2_MACS_EVENTS, mp);
13458 mp->enable_disable = enable_disable;
13459 mp->pid = htonl (getpid ());
13460 mp->learn_limit = htonl (learn_limit);
13461 mp->scan_delay = (u8) scan_delay;
13462 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13469 api_input_acl_set_interface (vat_main_t * vam)
13471 unformat_input_t *i = vam->input;
13472 vl_api_input_acl_set_interface_t *mp;
13474 int sw_if_index_set;
13475 u32 ip4_table_index = ~0;
13476 u32 ip6_table_index = ~0;
13477 u32 l2_table_index = ~0;
13481 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13483 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13484 sw_if_index_set = 1;
13485 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13486 sw_if_index_set = 1;
13487 else if (unformat (i, "del"))
13489 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13491 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13493 else if (unformat (i, "l2-table %d", &l2_table_index))
13497 clib_warning ("parse error '%U'", format_unformat_error, i);
13502 if (sw_if_index_set == 0)
13504 errmsg ("missing interface name or sw_if_index");
13508 M (INPUT_ACL_SET_INTERFACE, mp);
13510 mp->sw_if_index = ntohl (sw_if_index);
13511 mp->ip4_table_index = ntohl (ip4_table_index);
13512 mp->ip6_table_index = ntohl (ip6_table_index);
13513 mp->l2_table_index = ntohl (l2_table_index);
13514 mp->is_add = is_add;
13522 api_ip_address_dump (vat_main_t * vam)
13524 unformat_input_t *i = vam->input;
13525 vl_api_ip_address_dump_t *mp;
13526 vl_api_control_ping_t *mp_ping;
13527 u32 sw_if_index = ~0;
13528 u8 sw_if_index_set = 0;
13533 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13535 if (unformat (i, "sw_if_index %d", &sw_if_index))
13536 sw_if_index_set = 1;
13538 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13539 sw_if_index_set = 1;
13540 else if (unformat (i, "ipv4"))
13542 else if (unformat (i, "ipv6"))
13548 if (ipv4_set && ipv6_set)
13550 errmsg ("ipv4 and ipv6 flags cannot be both set");
13554 if ((!ipv4_set) && (!ipv6_set))
13556 errmsg ("no ipv4 nor ipv6 flag set");
13560 if (sw_if_index_set == 0)
13562 errmsg ("missing interface name or sw_if_index");
13566 vam->current_sw_if_index = sw_if_index;
13567 vam->is_ipv6 = ipv6_set;
13569 M (IP_ADDRESS_DUMP, mp);
13570 mp->sw_if_index = ntohl (sw_if_index);
13571 mp->is_ipv6 = ipv6_set;
13574 /* Use a control ping for synchronization */
13575 MPING (CONTROL_PING, mp_ping);
13583 api_ip_dump (vat_main_t * vam)
13585 vl_api_ip_dump_t *mp;
13586 vl_api_control_ping_t *mp_ping;
13587 unformat_input_t *in = vam->input;
13594 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13596 if (unformat (in, "ipv4"))
13598 else if (unformat (in, "ipv6"))
13604 if (ipv4_set && ipv6_set)
13606 errmsg ("ipv4 and ipv6 flags cannot be both set");
13610 if ((!ipv4_set) && (!ipv6_set))
13612 errmsg ("no ipv4 nor ipv6 flag set");
13616 is_ipv6 = ipv6_set;
13617 vam->is_ipv6 = is_ipv6;
13619 /* free old data */
13620 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13622 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13624 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13627 mp->is_ipv6 = ipv6_set;
13630 /* Use a control ping for synchronization */
13631 MPING (CONTROL_PING, mp_ping);
13639 api_ipsec_spd_add_del (vat_main_t * vam)
13641 unformat_input_t *i = vam->input;
13642 vl_api_ipsec_spd_add_del_t *mp;
13647 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13649 if (unformat (i, "spd_id %d", &spd_id))
13651 else if (unformat (i, "del"))
13655 clib_warning ("parse error '%U'", format_unformat_error, i);
13661 errmsg ("spd_id must be set");
13665 M (IPSEC_SPD_ADD_DEL, mp);
13667 mp->spd_id = ntohl (spd_id);
13668 mp->is_add = is_add;
13676 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13678 unformat_input_t *i = vam->input;
13679 vl_api_ipsec_interface_add_del_spd_t *mp;
13681 u8 sw_if_index_set = 0;
13682 u32 spd_id = (u32) ~ 0;
13686 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13688 if (unformat (i, "del"))
13690 else if (unformat (i, "spd_id %d", &spd_id))
13693 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13694 sw_if_index_set = 1;
13695 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13696 sw_if_index_set = 1;
13699 clib_warning ("parse error '%U'", format_unformat_error, i);
13705 if (spd_id == (u32) ~ 0)
13707 errmsg ("spd_id must be set");
13711 if (sw_if_index_set == 0)
13713 errmsg ("missing interface name or sw_if_index");
13717 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13719 mp->spd_id = ntohl (spd_id);
13720 mp->sw_if_index = ntohl (sw_if_index);
13721 mp->is_add = is_add;
13729 api_ipsec_spd_add_del_entry (vat_main_t * vam)
13731 unformat_input_t *i = vam->input;
13732 vl_api_ipsec_spd_add_del_entry_t *mp;
13733 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
13734 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13736 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13737 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13738 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
13739 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
13742 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
13743 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
13744 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
13745 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
13746 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
13747 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
13749 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13751 if (unformat (i, "del"))
13753 if (unformat (i, "outbound"))
13755 if (unformat (i, "inbound"))
13757 else if (unformat (i, "spd_id %d", &spd_id))
13759 else if (unformat (i, "sa_id %d", &sa_id))
13761 else if (unformat (i, "priority %d", &priority))
13763 else if (unformat (i, "protocol %d", &protocol))
13765 else if (unformat (i, "lport_start %d", &lport_start))
13767 else if (unformat (i, "lport_stop %d", &lport_stop))
13769 else if (unformat (i, "rport_start %d", &rport_start))
13771 else if (unformat (i, "rport_stop %d", &rport_stop))
13775 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
13781 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
13788 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
13794 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
13801 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
13807 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
13814 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
13820 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
13826 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13828 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13830 clib_warning ("unsupported action: 'resolve'");
13836 clib_warning ("parse error '%U'", format_unformat_error, i);
13842 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
13844 mp->spd_id = ntohl (spd_id);
13845 mp->priority = ntohl (priority);
13846 mp->is_outbound = is_outbound;
13848 mp->is_ipv6 = is_ipv6;
13849 if (is_ipv6 || is_ip_any)
13851 clib_memcpy (mp->remote_address_start, &raddr6_start,
13852 sizeof (ip6_address_t));
13853 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
13854 sizeof (ip6_address_t));
13855 clib_memcpy (mp->local_address_start, &laddr6_start,
13856 sizeof (ip6_address_t));
13857 clib_memcpy (mp->local_address_stop, &laddr6_stop,
13858 sizeof (ip6_address_t));
13862 clib_memcpy (mp->remote_address_start, &raddr4_start,
13863 sizeof (ip4_address_t));
13864 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
13865 sizeof (ip4_address_t));
13866 clib_memcpy (mp->local_address_start, &laddr4_start,
13867 sizeof (ip4_address_t));
13868 clib_memcpy (mp->local_address_stop, &laddr4_stop,
13869 sizeof (ip4_address_t));
13871 mp->protocol = (u8) protocol;
13872 mp->local_port_start = ntohs ((u16) lport_start);
13873 mp->local_port_stop = ntohs ((u16) lport_stop);
13874 mp->remote_port_start = ntohs ((u16) rport_start);
13875 mp->remote_port_stop = ntohs ((u16) rport_stop);
13876 mp->policy = (u8) policy;
13877 mp->sa_id = ntohl (sa_id);
13878 mp->is_add = is_add;
13879 mp->is_ip_any = is_ip_any;
13886 api_ipsec_sad_add_del_entry (vat_main_t * vam)
13888 unformat_input_t *i = vam->input;
13889 vl_api_ipsec_sad_add_del_entry_t *mp;
13890 u32 sad_id = 0, spi = 0;
13891 u8 *ck = 0, *ik = 0;
13894 u8 protocol = IPSEC_PROTOCOL_AH;
13895 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
13896 u32 crypto_alg = 0, integ_alg = 0;
13897 ip4_address_t tun_src4;
13898 ip4_address_t tun_dst4;
13899 ip6_address_t tun_src6;
13900 ip6_address_t tun_dst6;
13903 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13905 if (unformat (i, "del"))
13907 else if (unformat (i, "sad_id %d", &sad_id))
13909 else if (unformat (i, "spi %d", &spi))
13911 else if (unformat (i, "esp"))
13912 protocol = IPSEC_PROTOCOL_ESP;
13913 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
13916 is_tunnel_ipv6 = 0;
13918 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
13921 is_tunnel_ipv6 = 0;
13923 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
13926 is_tunnel_ipv6 = 1;
13928 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
13931 is_tunnel_ipv6 = 1;
13935 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13937 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13938 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13940 clib_warning ("unsupported crypto-alg: '%U'",
13941 format_ipsec_crypto_alg, crypto_alg);
13945 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13949 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13951 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13952 integ_alg >= IPSEC_INTEG_N_ALG)
13954 clib_warning ("unsupported integ-alg: '%U'",
13955 format_ipsec_integ_alg, integ_alg);
13959 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13963 clib_warning ("parse error '%U'", format_unformat_error, i);
13969 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
13971 mp->sad_id = ntohl (sad_id);
13972 mp->is_add = is_add;
13973 mp->protocol = protocol;
13974 mp->spi = ntohl (spi);
13975 mp->is_tunnel = is_tunnel;
13976 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
13977 mp->crypto_algorithm = crypto_alg;
13978 mp->integrity_algorithm = integ_alg;
13979 mp->crypto_key_length = vec_len (ck);
13980 mp->integrity_key_length = vec_len (ik);
13982 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13983 mp->crypto_key_length = sizeof (mp->crypto_key);
13985 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13986 mp->integrity_key_length = sizeof (mp->integrity_key);
13989 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13991 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13995 if (is_tunnel_ipv6)
13997 clib_memcpy (mp->tunnel_src_address, &tun_src6,
13998 sizeof (ip6_address_t));
13999 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
14000 sizeof (ip6_address_t));
14004 clib_memcpy (mp->tunnel_src_address, &tun_src4,
14005 sizeof (ip4_address_t));
14006 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
14007 sizeof (ip4_address_t));
14017 api_ipsec_sa_set_key (vat_main_t * vam)
14019 unformat_input_t *i = vam->input;
14020 vl_api_ipsec_sa_set_key_t *mp;
14022 u8 *ck = 0, *ik = 0;
14025 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14027 if (unformat (i, "sa_id %d", &sa_id))
14029 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14031 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14035 clib_warning ("parse error '%U'", format_unformat_error, i);
14040 M (IPSEC_SA_SET_KEY, mp);
14042 mp->sa_id = ntohl (sa_id);
14043 mp->crypto_key_length = vec_len (ck);
14044 mp->integrity_key_length = vec_len (ik);
14046 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14047 mp->crypto_key_length = sizeof (mp->crypto_key);
14049 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14050 mp->integrity_key_length = sizeof (mp->integrity_key);
14053 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14055 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14063 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14065 unformat_input_t *i = vam->input;
14066 vl_api_ipsec_tunnel_if_add_del_t *mp;
14067 u32 local_spi = 0, remote_spi = 0;
14068 u32 crypto_alg = 0, integ_alg = 0;
14069 u8 *lck = NULL, *rck = NULL;
14070 u8 *lik = NULL, *rik = NULL;
14071 ip4_address_t local_ip = { {0} };
14072 ip4_address_t remote_ip = { {0} };
14075 u8 anti_replay = 0;
14078 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14080 if (unformat (i, "del"))
14082 else if (unformat (i, "esn"))
14084 else if (unformat (i, "anti_replay"))
14086 else if (unformat (i, "local_spi %d", &local_spi))
14088 else if (unformat (i, "remote_spi %d", &remote_spi))
14090 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
14092 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
14094 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14097 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14099 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14101 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14105 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14107 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14108 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14110 errmsg ("unsupported crypto-alg: '%U'\n",
14111 format_ipsec_crypto_alg, crypto_alg);
14117 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14119 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14120 integ_alg >= IPSEC_INTEG_N_ALG)
14122 errmsg ("unsupported integ-alg: '%U'\n",
14123 format_ipsec_integ_alg, integ_alg);
14129 errmsg ("parse error '%U'\n", format_unformat_error, i);
14134 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14136 mp->is_add = is_add;
14138 mp->anti_replay = anti_replay;
14140 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
14141 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
14143 mp->local_spi = htonl (local_spi);
14144 mp->remote_spi = htonl (remote_spi);
14145 mp->crypto_alg = (u8) crypto_alg;
14147 mp->local_crypto_key_len = 0;
14150 mp->local_crypto_key_len = vec_len (lck);
14151 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14152 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14153 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14156 mp->remote_crypto_key_len = 0;
14159 mp->remote_crypto_key_len = vec_len (rck);
14160 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14161 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14162 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14165 mp->integ_alg = (u8) integ_alg;
14167 mp->local_integ_key_len = 0;
14170 mp->local_integ_key_len = vec_len (lik);
14171 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14172 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14173 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14176 mp->remote_integ_key_len = 0;
14179 mp->remote_integ_key_len = vec_len (rik);
14180 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14181 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14182 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14191 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14193 vat_main_t *vam = &vat_main;
14195 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14196 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
14197 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
14198 "tunnel_src_addr %U tunnel_dst_addr %U "
14199 "salt %u seq_outbound %lu last_seq_inbound %lu "
14200 "replay_window %lu total_data_size %lu\n",
14201 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
14203 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
14204 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
14205 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
14206 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14207 mp->tunnel_src_addr,
14208 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14209 mp->tunnel_dst_addr,
14211 clib_net_to_host_u64 (mp->seq_outbound),
14212 clib_net_to_host_u64 (mp->last_seq_inbound),
14213 clib_net_to_host_u64 (mp->replay_window),
14214 clib_net_to_host_u64 (mp->total_data_size));
14217 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14218 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14220 static void vl_api_ipsec_sa_details_t_handler_json
14221 (vl_api_ipsec_sa_details_t * mp)
14223 vat_main_t *vam = &vat_main;
14224 vat_json_node_t *node = NULL;
14225 struct in_addr src_ip4, dst_ip4;
14226 struct in6_addr src_ip6, dst_ip6;
14228 if (VAT_JSON_ARRAY != vam->json_tree.type)
14230 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14231 vat_json_init_array (&vam->json_tree);
14233 node = vat_json_array_add (&vam->json_tree);
14235 vat_json_init_object (node);
14236 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
14237 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14238 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
14239 vat_json_object_add_uint (node, "proto", mp->protocol);
14240 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
14241 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
14242 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
14243 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
14244 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
14245 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
14246 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
14247 mp->crypto_key_len);
14248 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
14249 mp->integ_key_len);
14250 if (mp->is_tunnel_ip6)
14252 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
14253 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
14254 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
14255 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
14259 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
14260 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
14261 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
14262 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
14264 vat_json_object_add_uint (node, "replay_window",
14265 clib_net_to_host_u64 (mp->replay_window));
14266 vat_json_object_add_uint (node, "total_data_size",
14267 clib_net_to_host_u64 (mp->total_data_size));
14272 api_ipsec_sa_dump (vat_main_t * vam)
14274 unformat_input_t *i = vam->input;
14275 vl_api_ipsec_sa_dump_t *mp;
14276 vl_api_control_ping_t *mp_ping;
14280 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14282 if (unformat (i, "sa_id %d", &sa_id))
14286 clib_warning ("parse error '%U'", format_unformat_error, i);
14291 M (IPSEC_SA_DUMP, mp);
14293 mp->sa_id = ntohl (sa_id);
14297 /* Use a control ping for synchronization */
14298 M (CONTROL_PING, mp_ping);
14306 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
14308 unformat_input_t *i = vam->input;
14309 vl_api_ipsec_tunnel_if_set_key_t *mp;
14310 u32 sw_if_index = ~0;
14311 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
14316 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14318 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14321 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
14322 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
14324 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
14325 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
14326 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
14327 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
14329 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
14330 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
14331 else if (unformat (i, "%U", unformat_hex_string, &key))
14335 clib_warning ("parse error '%U'", format_unformat_error, i);
14340 if (sw_if_index == ~0)
14342 errmsg ("interface must be specified");
14346 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
14348 errmsg ("key type must be specified");
14354 errmsg ("algorithm must be specified");
14358 if (vec_len (key) == 0)
14360 errmsg ("key must be specified");
14364 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
14366 mp->sw_if_index = htonl (sw_if_index);
14368 mp->key_type = key_type;
14369 mp->key_len = vec_len (key);
14370 clib_memcpy (mp->key, key, vec_len (key));
14379 api_ikev2_profile_add_del (vat_main_t * vam)
14381 unformat_input_t *i = vam->input;
14382 vl_api_ikev2_profile_add_del_t *mp;
14387 const char *valid_chars = "a-zA-Z0-9_";
14389 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14391 if (unformat (i, "del"))
14393 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14394 vec_add1 (name, 0);
14397 errmsg ("parse error '%U'", format_unformat_error, i);
14402 if (!vec_len (name))
14404 errmsg ("profile name must be specified");
14408 if (vec_len (name) > 64)
14410 errmsg ("profile name too long");
14414 M (IKEV2_PROFILE_ADD_DEL, mp);
14416 clib_memcpy (mp->name, name, vec_len (name));
14417 mp->is_add = is_add;
14426 api_ikev2_profile_set_auth (vat_main_t * vam)
14428 unformat_input_t *i = vam->input;
14429 vl_api_ikev2_profile_set_auth_t *mp;
14432 u32 auth_method = 0;
14436 const char *valid_chars = "a-zA-Z0-9_";
14438 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14440 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14441 vec_add1 (name, 0);
14442 else if (unformat (i, "auth_method %U",
14443 unformat_ikev2_auth_method, &auth_method))
14445 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
14447 else if (unformat (i, "auth_data %v", &data))
14451 errmsg ("parse error '%U'", format_unformat_error, i);
14456 if (!vec_len (name))
14458 errmsg ("profile name must be specified");
14462 if (vec_len (name) > 64)
14464 errmsg ("profile name too long");
14468 if (!vec_len (data))
14470 errmsg ("auth_data must be specified");
14476 errmsg ("auth_method must be specified");
14480 M (IKEV2_PROFILE_SET_AUTH, mp);
14482 mp->is_hex = is_hex;
14483 mp->auth_method = (u8) auth_method;
14484 mp->data_len = vec_len (data);
14485 clib_memcpy (mp->name, name, vec_len (name));
14486 clib_memcpy (mp->data, data, vec_len (data));
14496 api_ikev2_profile_set_id (vat_main_t * vam)
14498 unformat_input_t *i = vam->input;
14499 vl_api_ikev2_profile_set_id_t *mp;
14507 const char *valid_chars = "a-zA-Z0-9_";
14509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14511 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14512 vec_add1 (name, 0);
14513 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
14515 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
14517 data = vec_new (u8, 4);
14518 clib_memcpy (data, ip4.as_u8, 4);
14520 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
14522 else if (unformat (i, "id_data %v", &data))
14524 else if (unformat (i, "local"))
14526 else if (unformat (i, "remote"))
14530 errmsg ("parse error '%U'", format_unformat_error, i);
14535 if (!vec_len (name))
14537 errmsg ("profile name must be specified");
14541 if (vec_len (name) > 64)
14543 errmsg ("profile name too long");
14547 if (!vec_len (data))
14549 errmsg ("id_data must be specified");
14555 errmsg ("id_type must be specified");
14559 M (IKEV2_PROFILE_SET_ID, mp);
14561 mp->is_local = is_local;
14562 mp->id_type = (u8) id_type;
14563 mp->data_len = vec_len (data);
14564 clib_memcpy (mp->name, name, vec_len (name));
14565 clib_memcpy (mp->data, data, vec_len (data));
14575 api_ikev2_profile_set_ts (vat_main_t * vam)
14577 unformat_input_t *i = vam->input;
14578 vl_api_ikev2_profile_set_ts_t *mp;
14581 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
14582 ip4_address_t start_addr, end_addr;
14584 const char *valid_chars = "a-zA-Z0-9_";
14587 start_addr.as_u32 = 0;
14588 end_addr.as_u32 = (u32) ~ 0;
14590 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14592 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14593 vec_add1 (name, 0);
14594 else if (unformat (i, "protocol %d", &proto))
14596 else if (unformat (i, "start_port %d", &start_port))
14598 else if (unformat (i, "end_port %d", &end_port))
14601 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
14603 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
14605 else if (unformat (i, "local"))
14607 else if (unformat (i, "remote"))
14611 errmsg ("parse error '%U'", format_unformat_error, i);
14616 if (!vec_len (name))
14618 errmsg ("profile name must be specified");
14622 if (vec_len (name) > 64)
14624 errmsg ("profile name too long");
14628 M (IKEV2_PROFILE_SET_TS, mp);
14630 mp->is_local = is_local;
14631 mp->proto = (u8) proto;
14632 mp->start_port = (u16) start_port;
14633 mp->end_port = (u16) end_port;
14634 mp->start_addr = start_addr.as_u32;
14635 mp->end_addr = end_addr.as_u32;
14636 clib_memcpy (mp->name, name, vec_len (name));
14645 api_ikev2_set_local_key (vat_main_t * vam)
14647 unformat_input_t *i = vam->input;
14648 vl_api_ikev2_set_local_key_t *mp;
14652 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14654 if (unformat (i, "file %v", &file))
14655 vec_add1 (file, 0);
14658 errmsg ("parse error '%U'", format_unformat_error, i);
14663 if (!vec_len (file))
14665 errmsg ("RSA key file must be specified");
14669 if (vec_len (file) > 256)
14671 errmsg ("file name too long");
14675 M (IKEV2_SET_LOCAL_KEY, mp);
14677 clib_memcpy (mp->key_file, file, vec_len (file));
14686 api_ikev2_set_responder (vat_main_t * vam)
14688 unformat_input_t *i = vam->input;
14689 vl_api_ikev2_set_responder_t *mp;
14692 u32 sw_if_index = ~0;
14693 ip4_address_t address;
14695 const char *valid_chars = "a-zA-Z0-9_";
14697 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14700 (i, "%U interface %d address %U", unformat_token, valid_chars,
14701 &name, &sw_if_index, unformat_ip4_address, &address))
14702 vec_add1 (name, 0);
14705 errmsg ("parse error '%U'", format_unformat_error, i);
14710 if (!vec_len (name))
14712 errmsg ("profile name must be specified");
14716 if (vec_len (name) > 64)
14718 errmsg ("profile name too long");
14722 M (IKEV2_SET_RESPONDER, mp);
14724 clib_memcpy (mp->name, name, vec_len (name));
14727 mp->sw_if_index = sw_if_index;
14728 clib_memcpy (mp->address, &address, sizeof (address));
14736 api_ikev2_set_ike_transforms (vat_main_t * vam)
14738 unformat_input_t *i = vam->input;
14739 vl_api_ikev2_set_ike_transforms_t *mp;
14742 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14744 const char *valid_chars = "a-zA-Z0-9_";
14746 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14748 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14749 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14750 vec_add1 (name, 0);
14753 errmsg ("parse error '%U'", format_unformat_error, i);
14758 if (!vec_len (name))
14760 errmsg ("profile name must be specified");
14764 if (vec_len (name) > 64)
14766 errmsg ("profile name too long");
14770 M (IKEV2_SET_IKE_TRANSFORMS, mp);
14772 clib_memcpy (mp->name, name, vec_len (name));
14774 mp->crypto_alg = crypto_alg;
14775 mp->crypto_key_size = crypto_key_size;
14776 mp->integ_alg = integ_alg;
14777 mp->dh_group = dh_group;
14786 api_ikev2_set_esp_transforms (vat_main_t * vam)
14788 unformat_input_t *i = vam->input;
14789 vl_api_ikev2_set_esp_transforms_t *mp;
14792 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14794 const char *valid_chars = "a-zA-Z0-9_";
14796 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14798 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14799 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14800 vec_add1 (name, 0);
14803 errmsg ("parse error '%U'", format_unformat_error, i);
14808 if (!vec_len (name))
14810 errmsg ("profile name must be specified");
14814 if (vec_len (name) > 64)
14816 errmsg ("profile name too long");
14820 M (IKEV2_SET_ESP_TRANSFORMS, mp);
14822 clib_memcpy (mp->name, name, vec_len (name));
14824 mp->crypto_alg = crypto_alg;
14825 mp->crypto_key_size = crypto_key_size;
14826 mp->integ_alg = integ_alg;
14827 mp->dh_group = dh_group;
14835 api_ikev2_set_sa_lifetime (vat_main_t * vam)
14837 unformat_input_t *i = vam->input;
14838 vl_api_ikev2_set_sa_lifetime_t *mp;
14841 u64 lifetime, lifetime_maxdata;
14842 u32 lifetime_jitter, handover;
14844 const char *valid_chars = "a-zA-Z0-9_";
14846 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14848 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
14849 &lifetime, &lifetime_jitter, &handover,
14850 &lifetime_maxdata))
14851 vec_add1 (name, 0);
14854 errmsg ("parse error '%U'", format_unformat_error, i);
14859 if (!vec_len (name))
14861 errmsg ("profile name must be specified");
14865 if (vec_len (name) > 64)
14867 errmsg ("profile name too long");
14871 M (IKEV2_SET_SA_LIFETIME, mp);
14873 clib_memcpy (mp->name, name, vec_len (name));
14875 mp->lifetime = lifetime;
14876 mp->lifetime_jitter = lifetime_jitter;
14877 mp->handover = handover;
14878 mp->lifetime_maxdata = lifetime_maxdata;
14886 api_ikev2_initiate_sa_init (vat_main_t * vam)
14888 unformat_input_t *i = vam->input;
14889 vl_api_ikev2_initiate_sa_init_t *mp;
14893 const char *valid_chars = "a-zA-Z0-9_";
14895 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14897 if (unformat (i, "%U", unformat_token, valid_chars, &name))
14898 vec_add1 (name, 0);
14901 errmsg ("parse error '%U'", format_unformat_error, i);
14906 if (!vec_len (name))
14908 errmsg ("profile name must be specified");
14912 if (vec_len (name) > 64)
14914 errmsg ("profile name too long");
14918 M (IKEV2_INITIATE_SA_INIT, mp);
14920 clib_memcpy (mp->name, name, vec_len (name));
14929 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
14931 unformat_input_t *i = vam->input;
14932 vl_api_ikev2_initiate_del_ike_sa_t *mp;
14937 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14939 if (unformat (i, "%lx", &ispi))
14943 errmsg ("parse error '%U'", format_unformat_error, i);
14948 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
14958 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
14960 unformat_input_t *i = vam->input;
14961 vl_api_ikev2_initiate_del_child_sa_t *mp;
14966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14968 if (unformat (i, "%x", &ispi))
14972 errmsg ("parse error '%U'", format_unformat_error, i);
14977 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
14987 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
14989 unformat_input_t *i = vam->input;
14990 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
14995 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14997 if (unformat (i, "%x", &ispi))
15001 errmsg ("parse error '%U'", format_unformat_error, i);
15006 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
15019 api_map_add_domain (vat_main_t * vam)
15021 unformat_input_t *i = vam->input;
15022 vl_api_map_add_domain_t *mp;
15024 ip4_address_t ip4_prefix;
15025 ip6_address_t ip6_prefix;
15026 ip6_address_t ip6_src;
15027 u32 num_m_args = 0;
15028 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
15029 0, psid_length = 0;
15030 u8 is_translation = 0;
15032 u32 ip6_src_len = 128;
15035 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15037 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
15038 &ip4_prefix, &ip4_prefix_len))
15040 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
15041 &ip6_prefix, &ip6_prefix_len))
15045 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
15048 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
15050 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
15052 else if (unformat (i, "psid-offset %d", &psid_offset))
15054 else if (unformat (i, "psid-len %d", &psid_length))
15056 else if (unformat (i, "mtu %d", &mtu))
15058 else if (unformat (i, "map-t"))
15059 is_translation = 1;
15062 clib_warning ("parse error '%U'", format_unformat_error, i);
15067 if (num_m_args < 3)
15069 errmsg ("mandatory argument(s) missing");
15073 /* Construct the API message */
15074 M (MAP_ADD_DOMAIN, mp);
15076 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
15077 mp->ip4_prefix_len = ip4_prefix_len;
15079 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
15080 mp->ip6_prefix_len = ip6_prefix_len;
15082 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
15083 mp->ip6_src_prefix_len = ip6_src_len;
15085 mp->ea_bits_len = ea_bits_len;
15086 mp->psid_offset = psid_offset;
15087 mp->psid_length = psid_length;
15088 mp->is_translation = is_translation;
15089 mp->mtu = htons (mtu);
15094 /* Wait for a reply, return good/bad news */
15100 api_map_del_domain (vat_main_t * vam)
15102 unformat_input_t *i = vam->input;
15103 vl_api_map_del_domain_t *mp;
15105 u32 num_m_args = 0;
15109 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15111 if (unformat (i, "index %d", &index))
15115 clib_warning ("parse error '%U'", format_unformat_error, i);
15120 if (num_m_args != 1)
15122 errmsg ("mandatory argument(s) missing");
15126 /* Construct the API message */
15127 M (MAP_DEL_DOMAIN, mp);
15129 mp->index = ntohl (index);
15134 /* Wait for a reply, return good/bad news */
15140 api_map_add_del_rule (vat_main_t * vam)
15142 unformat_input_t *i = vam->input;
15143 vl_api_map_add_del_rule_t *mp;
15145 ip6_address_t ip6_dst;
15146 u32 num_m_args = 0, index, psid = 0;
15149 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15151 if (unformat (i, "index %d", &index))
15153 else if (unformat (i, "psid %d", &psid))
15155 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
15157 else if (unformat (i, "del"))
15163 clib_warning ("parse error '%U'", format_unformat_error, i);
15168 /* Construct the API message */
15169 M (MAP_ADD_DEL_RULE, mp);
15171 mp->index = ntohl (index);
15172 mp->is_add = is_add;
15173 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
15174 mp->psid = ntohs (psid);
15179 /* Wait for a reply, return good/bad news */
15185 api_map_domain_dump (vat_main_t * vam)
15187 vl_api_map_domain_dump_t *mp;
15188 vl_api_control_ping_t *mp_ping;
15191 /* Construct the API message */
15192 M (MAP_DOMAIN_DUMP, mp);
15197 /* Use a control ping for synchronization */
15198 MPING (CONTROL_PING, mp_ping);
15206 api_map_rule_dump (vat_main_t * vam)
15208 unformat_input_t *i = vam->input;
15209 vl_api_map_rule_dump_t *mp;
15210 vl_api_control_ping_t *mp_ping;
15211 u32 domain_index = ~0;
15214 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15216 if (unformat (i, "index %u", &domain_index))
15222 if (domain_index == ~0)
15224 clib_warning ("parse error: domain index expected");
15228 /* Construct the API message */
15229 M (MAP_RULE_DUMP, mp);
15231 mp->domain_index = htonl (domain_index);
15236 /* Use a control ping for synchronization */
15237 MPING (CONTROL_PING, mp_ping);
15244 static void vl_api_map_add_domain_reply_t_handler
15245 (vl_api_map_add_domain_reply_t * mp)
15247 vat_main_t *vam = &vat_main;
15248 i32 retval = ntohl (mp->retval);
15250 if (vam->async_mode)
15252 vam->async_errors += (retval < 0);
15256 vam->retval = retval;
15257 vam->result_ready = 1;
15261 static void vl_api_map_add_domain_reply_t_handler_json
15262 (vl_api_map_add_domain_reply_t * mp)
15264 vat_main_t *vam = &vat_main;
15265 vat_json_node_t node;
15267 vat_json_init_object (&node);
15268 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
15269 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
15271 vat_json_print (vam->ofp, &node);
15272 vat_json_free (&node);
15274 vam->retval = ntohl (mp->retval);
15275 vam->result_ready = 1;
15279 api_get_first_msg_id (vat_main_t * vam)
15281 vl_api_get_first_msg_id_t *mp;
15282 unformat_input_t *i = vam->input;
15287 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15289 if (unformat (i, "client %s", &name))
15297 errmsg ("missing client name");
15300 vec_add1 (name, 0);
15302 if (vec_len (name) > 63)
15304 errmsg ("client name too long");
15308 M (GET_FIRST_MSG_ID, mp);
15309 clib_memcpy (mp->name, name, vec_len (name));
15316 api_cop_interface_enable_disable (vat_main_t * vam)
15318 unformat_input_t *line_input = vam->input;
15319 vl_api_cop_interface_enable_disable_t *mp;
15320 u32 sw_if_index = ~0;
15321 u8 enable_disable = 1;
15324 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15326 if (unformat (line_input, "disable"))
15327 enable_disable = 0;
15328 if (unformat (line_input, "enable"))
15329 enable_disable = 1;
15330 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15331 vam, &sw_if_index))
15333 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15339 if (sw_if_index == ~0)
15341 errmsg ("missing interface name or sw_if_index");
15345 /* Construct the API message */
15346 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15347 mp->sw_if_index = ntohl (sw_if_index);
15348 mp->enable_disable = enable_disable;
15352 /* Wait for the reply */
15358 api_cop_whitelist_enable_disable (vat_main_t * vam)
15360 unformat_input_t *line_input = vam->input;
15361 vl_api_cop_whitelist_enable_disable_t *mp;
15362 u32 sw_if_index = ~0;
15363 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15367 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15369 if (unformat (line_input, "ip4"))
15371 else if (unformat (line_input, "ip6"))
15373 else if (unformat (line_input, "default"))
15375 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15376 vam, &sw_if_index))
15378 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15380 else if (unformat (line_input, "fib-id %d", &fib_id))
15386 if (sw_if_index == ~0)
15388 errmsg ("missing interface name or sw_if_index");
15392 /* Construct the API message */
15393 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15394 mp->sw_if_index = ntohl (sw_if_index);
15395 mp->fib_id = ntohl (fib_id);
15398 mp->default_cop = default_cop;
15402 /* Wait for the reply */
15408 api_get_node_graph (vat_main_t * vam)
15410 vl_api_get_node_graph_t *mp;
15413 M (GET_NODE_GRAPH, mp);
15417 /* Wait for the reply */
15423 /** Used for parsing LISP eids */
15424 typedef CLIB_PACKED(struct{
15425 u8 addr[16]; /**< eid address */
15426 u32 len; /**< prefix length if IP */
15427 u8 type; /**< type of eid */
15432 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15434 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15436 memset (a, 0, sizeof (a[0]));
15438 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15440 a->type = 0; /* ipv4 type */
15442 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15444 a->type = 1; /* ipv6 type */
15446 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15448 a->type = 2; /* mac type */
15450 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15452 a->type = 3; /* NSH type */
15453 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15454 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15461 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15470 lisp_eid_size_vat (u8 type)
15487 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15489 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15493 api_one_add_del_locator_set (vat_main_t * vam)
15495 unformat_input_t *input = vam->input;
15496 vl_api_one_add_del_locator_set_t *mp;
15498 u8 *locator_set_name = NULL;
15499 u8 locator_set_name_set = 0;
15500 vl_api_local_locator_t locator, *locators = 0;
15501 u32 sw_if_index, priority, weight;
15505 /* Parse args required to build the message */
15506 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15508 if (unformat (input, "del"))
15512 else if (unformat (input, "locator-set %s", &locator_set_name))
15514 locator_set_name_set = 1;
15516 else if (unformat (input, "sw_if_index %u p %u w %u",
15517 &sw_if_index, &priority, &weight))
15519 locator.sw_if_index = htonl (sw_if_index);
15520 locator.priority = priority;
15521 locator.weight = weight;
15522 vec_add1 (locators, locator);
15526 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15527 &sw_if_index, &priority, &weight))
15529 locator.sw_if_index = htonl (sw_if_index);
15530 locator.priority = priority;
15531 locator.weight = weight;
15532 vec_add1 (locators, locator);
15538 if (locator_set_name_set == 0)
15540 errmsg ("missing locator-set name");
15541 vec_free (locators);
15545 if (vec_len (locator_set_name) > 64)
15547 errmsg ("locator-set name too long");
15548 vec_free (locator_set_name);
15549 vec_free (locators);
15552 vec_add1 (locator_set_name, 0);
15554 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15556 /* Construct the API message */
15557 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15559 mp->is_add = is_add;
15560 clib_memcpy (mp->locator_set_name, locator_set_name,
15561 vec_len (locator_set_name));
15562 vec_free (locator_set_name);
15564 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15566 clib_memcpy (mp->locators, locators, data_len);
15567 vec_free (locators);
15572 /* Wait for a reply... */
15577 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15580 api_one_add_del_locator (vat_main_t * vam)
15582 unformat_input_t *input = vam->input;
15583 vl_api_one_add_del_locator_t *mp;
15584 u32 tmp_if_index = ~0;
15585 u32 sw_if_index = ~0;
15586 u8 sw_if_index_set = 0;
15587 u8 sw_if_index_if_name_set = 0;
15589 u8 priority_set = 0;
15593 u8 *locator_set_name = NULL;
15594 u8 locator_set_name_set = 0;
15597 /* Parse args required to build the message */
15598 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15600 if (unformat (input, "del"))
15604 else if (unformat (input, "locator-set %s", &locator_set_name))
15606 locator_set_name_set = 1;
15608 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15611 sw_if_index_if_name_set = 1;
15612 sw_if_index = tmp_if_index;
15614 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15616 sw_if_index_set = 1;
15617 sw_if_index = tmp_if_index;
15619 else if (unformat (input, "p %d", &priority))
15623 else if (unformat (input, "w %d", &weight))
15631 if (locator_set_name_set == 0)
15633 errmsg ("missing locator-set name");
15637 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15639 errmsg ("missing sw_if_index");
15640 vec_free (locator_set_name);
15644 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15646 errmsg ("cannot use both params interface name and sw_if_index");
15647 vec_free (locator_set_name);
15651 if (priority_set == 0)
15653 errmsg ("missing locator-set priority");
15654 vec_free (locator_set_name);
15658 if (weight_set == 0)
15660 errmsg ("missing locator-set weight");
15661 vec_free (locator_set_name);
15665 if (vec_len (locator_set_name) > 64)
15667 errmsg ("locator-set name too long");
15668 vec_free (locator_set_name);
15671 vec_add1 (locator_set_name, 0);
15673 /* Construct the API message */
15674 M (ONE_ADD_DEL_LOCATOR, mp);
15676 mp->is_add = is_add;
15677 mp->sw_if_index = ntohl (sw_if_index);
15678 mp->priority = priority;
15679 mp->weight = weight;
15680 clib_memcpy (mp->locator_set_name, locator_set_name,
15681 vec_len (locator_set_name));
15682 vec_free (locator_set_name);
15687 /* Wait for a reply... */
15692 #define api_lisp_add_del_locator api_one_add_del_locator
15695 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15697 u32 *key_id = va_arg (*args, u32 *);
15700 if (unformat (input, "%s", &s))
15702 if (!strcmp ((char *) s, "sha1"))
15703 key_id[0] = HMAC_SHA_1_96;
15704 else if (!strcmp ((char *) s, "sha256"))
15705 key_id[0] = HMAC_SHA_256_128;
15708 clib_warning ("invalid key_id: '%s'", s);
15709 key_id[0] = HMAC_NO_KEY;
15720 api_one_add_del_local_eid (vat_main_t * vam)
15722 unformat_input_t *input = vam->input;
15723 vl_api_one_add_del_local_eid_t *mp;
15726 lisp_eid_vat_t _eid, *eid = &_eid;
15727 u8 *locator_set_name = 0;
15728 u8 locator_set_name_set = 0;
15734 /* Parse args required to build the message */
15735 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15737 if (unformat (input, "del"))
15741 else if (unformat (input, "vni %d", &vni))
15745 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15749 else if (unformat (input, "locator-set %s", &locator_set_name))
15751 locator_set_name_set = 1;
15753 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15755 else if (unformat (input, "secret-key %_%v%_", &key))
15761 if (locator_set_name_set == 0)
15763 errmsg ("missing locator-set name");
15769 errmsg ("EID address not set!");
15770 vec_free (locator_set_name);
15774 if (key && (0 == key_id))
15776 errmsg ("invalid key_id!");
15780 if (vec_len (key) > 64)
15782 errmsg ("key too long");
15787 if (vec_len (locator_set_name) > 64)
15789 errmsg ("locator-set name too long");
15790 vec_free (locator_set_name);
15793 vec_add1 (locator_set_name, 0);
15795 /* Construct the API message */
15796 M (ONE_ADD_DEL_LOCAL_EID, mp);
15798 mp->is_add = is_add;
15799 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15800 mp->eid_type = eid->type;
15801 mp->prefix_len = eid->len;
15802 mp->vni = clib_host_to_net_u32 (vni);
15803 mp->key_id = clib_host_to_net_u16 (key_id);
15804 clib_memcpy (mp->locator_set_name, locator_set_name,
15805 vec_len (locator_set_name));
15806 clib_memcpy (mp->key, key, vec_len (key));
15808 vec_free (locator_set_name);
15814 /* Wait for a reply... */
15819 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15822 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15824 u32 dp_table = 0, vni = 0;;
15825 unformat_input_t *input = vam->input;
15826 vl_api_gpe_add_del_fwd_entry_t *mp;
15828 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15829 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15830 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15831 u32 action = ~0, w;
15832 ip4_address_t rmt_rloc4, lcl_rloc4;
15833 ip6_address_t rmt_rloc6, lcl_rloc6;
15834 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15837 memset (&rloc, 0, sizeof (rloc));
15839 /* Parse args required to build the message */
15840 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15842 if (unformat (input, "del"))
15844 else if (unformat (input, "add"))
15846 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15850 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15854 else if (unformat (input, "vrf %d", &dp_table))
15856 else if (unformat (input, "bd %d", &dp_table))
15858 else if (unformat (input, "vni %d", &vni))
15860 else if (unformat (input, "w %d", &w))
15864 errmsg ("No RLOC configured for setting priority/weight!");
15867 curr_rloc->weight = w;
15869 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15870 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15874 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15876 vec_add1 (lcl_locs, rloc);
15878 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15879 vec_add1 (rmt_locs, rloc);
15880 /* weight saved in rmt loc */
15881 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15883 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15884 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15887 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15889 vec_add1 (lcl_locs, rloc);
15891 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15892 vec_add1 (rmt_locs, rloc);
15893 /* weight saved in rmt loc */
15894 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15896 else if (unformat (input, "action %d", &action))
15902 clib_warning ("parse error '%U'", format_unformat_error, input);
15909 errmsg ("remote eid addresses not set");
15913 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15915 errmsg ("eid types don't match");
15919 if (0 == rmt_locs && (u32) ~ 0 == action)
15921 errmsg ("action not set for negative mapping");
15925 /* Construct the API message */
15926 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15927 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15929 mp->is_add = is_add;
15930 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15931 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15932 mp->eid_type = rmt_eid->type;
15933 mp->dp_table = clib_host_to_net_u32 (dp_table);
15934 mp->vni = clib_host_to_net_u32 (vni);
15935 mp->rmt_len = rmt_eid->len;
15936 mp->lcl_len = lcl_eid->len;
15937 mp->action = action;
15939 if (0 != rmt_locs && 0 != lcl_locs)
15941 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15942 clib_memcpy (mp->locs, lcl_locs,
15943 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15945 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15946 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15947 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15949 vec_free (lcl_locs);
15950 vec_free (rmt_locs);
15955 /* Wait for a reply... */
15961 api_one_add_del_map_server (vat_main_t * vam)
15963 unformat_input_t *input = vam->input;
15964 vl_api_one_add_del_map_server_t *mp;
15968 ip4_address_t ipv4;
15969 ip6_address_t ipv6;
15972 /* Parse args required to build the message */
15973 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15975 if (unformat (input, "del"))
15979 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15983 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15991 if (ipv4_set && ipv6_set)
15993 errmsg ("both eid v4 and v6 addresses set");
15997 if (!ipv4_set && !ipv6_set)
15999 errmsg ("eid addresses not set");
16003 /* Construct the API message */
16004 M (ONE_ADD_DEL_MAP_SERVER, mp);
16006 mp->is_add = is_add;
16010 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16015 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16021 /* Wait for a reply... */
16026 #define api_lisp_add_del_map_server api_one_add_del_map_server
16029 api_one_add_del_map_resolver (vat_main_t * vam)
16031 unformat_input_t *input = vam->input;
16032 vl_api_one_add_del_map_resolver_t *mp;
16036 ip4_address_t ipv4;
16037 ip6_address_t ipv6;
16040 /* Parse args required to build the message */
16041 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16043 if (unformat (input, "del"))
16047 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16051 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16059 if (ipv4_set && ipv6_set)
16061 errmsg ("both eid v4 and v6 addresses set");
16065 if (!ipv4_set && !ipv6_set)
16067 errmsg ("eid addresses not set");
16071 /* Construct the API message */
16072 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
16074 mp->is_add = is_add;
16078 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16083 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16089 /* Wait for a reply... */
16094 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
16097 api_lisp_gpe_enable_disable (vat_main_t * vam)
16099 unformat_input_t *input = vam->input;
16100 vl_api_gpe_enable_disable_t *mp;
16105 /* Parse args required to build the message */
16106 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16108 if (unformat (input, "enable"))
16113 else if (unformat (input, "disable"))
16124 errmsg ("Value not set");
16128 /* Construct the API message */
16129 M (GPE_ENABLE_DISABLE, mp);
16136 /* Wait for a reply... */
16142 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16144 unformat_input_t *input = vam->input;
16145 vl_api_one_rloc_probe_enable_disable_t *mp;
16150 /* Parse args required to build the message */
16151 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16153 if (unformat (input, "enable"))
16158 else if (unformat (input, "disable"))
16166 errmsg ("Value not set");
16170 /* Construct the API message */
16171 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16173 mp->is_enabled = is_en;
16178 /* Wait for a reply... */
16183 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16186 api_one_map_register_enable_disable (vat_main_t * vam)
16188 unformat_input_t *input = vam->input;
16189 vl_api_one_map_register_enable_disable_t *mp;
16194 /* Parse args required to build the message */
16195 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16197 if (unformat (input, "enable"))
16202 else if (unformat (input, "disable"))
16210 errmsg ("Value not set");
16214 /* Construct the API message */
16215 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16217 mp->is_enabled = is_en;
16222 /* Wait for a reply... */
16227 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16230 api_one_enable_disable (vat_main_t * vam)
16232 unformat_input_t *input = vam->input;
16233 vl_api_one_enable_disable_t *mp;
16238 /* Parse args required to build the message */
16239 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16241 if (unformat (input, "enable"))
16246 else if (unformat (input, "disable"))
16256 errmsg ("Value not set");
16260 /* Construct the API message */
16261 M (ONE_ENABLE_DISABLE, mp);
16268 /* Wait for a reply... */
16273 #define api_lisp_enable_disable api_one_enable_disable
16276 api_show_one_map_register_state (vat_main_t * vam)
16278 vl_api_show_one_map_register_state_t *mp;
16281 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16286 /* wait for reply */
16291 #define api_show_lisp_map_register_state api_show_one_map_register_state
16294 api_show_one_rloc_probe_state (vat_main_t * vam)
16296 vl_api_show_one_rloc_probe_state_t *mp;
16299 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16304 /* wait for reply */
16309 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16312 api_one_add_del_ndp_entry (vat_main_t * vam)
16314 vl_api_one_add_del_ndp_entry_t *mp;
16315 unformat_input_t *input = vam->input;
16320 u8 mac[6] = { 0, };
16321 u8 ip6[16] = { 0, };
16325 /* Parse args required to build the message */
16326 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16328 if (unformat (input, "del"))
16330 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16332 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16334 else if (unformat (input, "bd %d", &bd))
16338 errmsg ("parse error '%U'", format_unformat_error, input);
16343 if (!bd_set || !ip_set || (!mac_set && is_add))
16345 errmsg ("Missing BD, IP or MAC!");
16349 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16350 mp->is_add = is_add;
16351 clib_memcpy (mp->mac, mac, 6);
16352 mp->bd = clib_host_to_net_u32 (bd);
16353 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16358 /* wait for reply */
16364 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16366 vl_api_one_add_del_l2_arp_entry_t *mp;
16367 unformat_input_t *input = vam->input;
16372 u8 mac[6] = { 0, };
16373 u32 ip4 = 0, bd = ~0;
16376 /* Parse args required to build the message */
16377 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16379 if (unformat (input, "del"))
16381 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16383 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16385 else if (unformat (input, "bd %d", &bd))
16389 errmsg ("parse error '%U'", format_unformat_error, input);
16394 if (!bd_set || !ip_set || (!mac_set && is_add))
16396 errmsg ("Missing BD, IP or MAC!");
16400 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16401 mp->is_add = is_add;
16402 clib_memcpy (mp->mac, mac, 6);
16403 mp->bd = clib_host_to_net_u32 (bd);
16409 /* wait for reply */
16415 api_one_ndp_bd_get (vat_main_t * vam)
16417 vl_api_one_ndp_bd_get_t *mp;
16420 M (ONE_NDP_BD_GET, mp);
16425 /* wait for reply */
16431 api_one_ndp_entries_get (vat_main_t * vam)
16433 vl_api_one_ndp_entries_get_t *mp;
16434 unformat_input_t *input = vam->input;
16439 /* Parse args required to build the message */
16440 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16442 if (unformat (input, "bd %d", &bd))
16446 errmsg ("parse error '%U'", format_unformat_error, input);
16453 errmsg ("Expected bridge domain!");
16457 M (ONE_NDP_ENTRIES_GET, mp);
16458 mp->bd = clib_host_to_net_u32 (bd);
16463 /* wait for reply */
16469 api_one_l2_arp_bd_get (vat_main_t * vam)
16471 vl_api_one_l2_arp_bd_get_t *mp;
16474 M (ONE_L2_ARP_BD_GET, mp);
16479 /* wait for reply */
16485 api_one_l2_arp_entries_get (vat_main_t * vam)
16487 vl_api_one_l2_arp_entries_get_t *mp;
16488 unformat_input_t *input = vam->input;
16493 /* Parse args required to build the message */
16494 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16496 if (unformat (input, "bd %d", &bd))
16500 errmsg ("parse error '%U'", format_unformat_error, input);
16507 errmsg ("Expected bridge domain!");
16511 M (ONE_L2_ARP_ENTRIES_GET, mp);
16512 mp->bd = clib_host_to_net_u32 (bd);
16517 /* wait for reply */
16523 api_one_stats_enable_disable (vat_main_t * vam)
16525 vl_api_one_stats_enable_disable_t *mp;
16526 unformat_input_t *input = vam->input;
16531 /* Parse args required to build the message */
16532 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16534 if (unformat (input, "enable"))
16539 else if (unformat (input, "disable"))
16549 errmsg ("Value not set");
16553 M (ONE_STATS_ENABLE_DISABLE, mp);
16559 /* wait for reply */
16565 api_show_one_stats_enable_disable (vat_main_t * vam)
16567 vl_api_show_one_stats_enable_disable_t *mp;
16570 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16575 /* wait for reply */
16581 api_show_one_map_request_mode (vat_main_t * vam)
16583 vl_api_show_one_map_request_mode_t *mp;
16586 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16591 /* wait for reply */
16596 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16599 api_one_map_request_mode (vat_main_t * vam)
16601 unformat_input_t *input = vam->input;
16602 vl_api_one_map_request_mode_t *mp;
16606 /* Parse args required to build the message */
16607 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16609 if (unformat (input, "dst-only"))
16611 else if (unformat (input, "src-dst"))
16615 errmsg ("parse error '%U'", format_unformat_error, input);
16620 M (ONE_MAP_REQUEST_MODE, mp);
16627 /* wait for reply */
16632 #define api_lisp_map_request_mode api_one_map_request_mode
16635 * Enable/disable ONE proxy ITR.
16637 * @param vam vpp API test context
16638 * @return return code
16641 api_one_pitr_set_locator_set (vat_main_t * vam)
16643 u8 ls_name_set = 0;
16644 unformat_input_t *input = vam->input;
16645 vl_api_one_pitr_set_locator_set_t *mp;
16650 /* Parse args required to build the message */
16651 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16653 if (unformat (input, "del"))
16655 else if (unformat (input, "locator-set %s", &ls_name))
16659 errmsg ("parse error '%U'", format_unformat_error, input);
16666 errmsg ("locator-set name not set!");
16670 M (ONE_PITR_SET_LOCATOR_SET, mp);
16672 mp->is_add = is_add;
16673 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16674 vec_free (ls_name);
16679 /* wait for reply */
16684 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16687 api_one_nsh_set_locator_set (vat_main_t * vam)
16689 u8 ls_name_set = 0;
16690 unformat_input_t *input = vam->input;
16691 vl_api_one_nsh_set_locator_set_t *mp;
16696 /* Parse args required to build the message */
16697 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16699 if (unformat (input, "del"))
16701 else if (unformat (input, "ls %s", &ls_name))
16705 errmsg ("parse error '%U'", format_unformat_error, input);
16710 if (!ls_name_set && is_add)
16712 errmsg ("locator-set name not set!");
16716 M (ONE_NSH_SET_LOCATOR_SET, mp);
16718 mp->is_add = is_add;
16719 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16720 vec_free (ls_name);
16725 /* wait for reply */
16731 api_show_one_pitr (vat_main_t * vam)
16733 vl_api_show_one_pitr_t *mp;
16736 if (!vam->json_output)
16738 print (vam->ofp, "%=20s", "lisp status:");
16741 M (SHOW_ONE_PITR, mp);
16745 /* Wait for a reply... */
16750 #define api_show_lisp_pitr api_show_one_pitr
16753 api_one_use_petr (vat_main_t * vam)
16755 unformat_input_t *input = vam->input;
16756 vl_api_one_use_petr_t *mp;
16761 memset (&ip, 0, sizeof (ip));
16763 /* Parse args required to build the message */
16764 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16766 if (unformat (input, "disable"))
16769 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16772 ip_addr_version (&ip) = IP4;
16775 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16778 ip_addr_version (&ip) = IP6;
16782 errmsg ("parse error '%U'", format_unformat_error, input);
16787 M (ONE_USE_PETR, mp);
16789 mp->is_add = is_add;
16792 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16794 clib_memcpy (mp->address, &ip, 4);
16796 clib_memcpy (mp->address, &ip, 16);
16802 /* wait for reply */
16807 #define api_lisp_use_petr api_one_use_petr
16810 api_show_one_nsh_mapping (vat_main_t * vam)
16812 vl_api_show_one_use_petr_t *mp;
16815 if (!vam->json_output)
16817 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16820 M (SHOW_ONE_NSH_MAPPING, mp);
16824 /* Wait for a reply... */
16830 api_show_one_use_petr (vat_main_t * vam)
16832 vl_api_show_one_use_petr_t *mp;
16835 if (!vam->json_output)
16837 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16840 M (SHOW_ONE_USE_PETR, mp);
16844 /* Wait for a reply... */
16849 #define api_show_lisp_use_petr api_show_one_use_petr
16852 * Add/delete mapping between vni and vrf
16855 api_one_eid_table_add_del_map (vat_main_t * vam)
16857 unformat_input_t *input = vam->input;
16858 vl_api_one_eid_table_add_del_map_t *mp;
16859 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16860 u32 vni, vrf, bd_index;
16863 /* Parse args required to build the message */
16864 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16866 if (unformat (input, "del"))
16868 else if (unformat (input, "vrf %d", &vrf))
16870 else if (unformat (input, "bd_index %d", &bd_index))
16872 else if (unformat (input, "vni %d", &vni))
16878 if (!vni_set || (!vrf_set && !bd_index_set))
16880 errmsg ("missing arguments!");
16884 if (vrf_set && bd_index_set)
16886 errmsg ("error: both vrf and bd entered!");
16890 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16892 mp->is_add = is_add;
16893 mp->vni = htonl (vni);
16894 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16895 mp->is_l2 = bd_index_set;
16900 /* wait for reply */
16905 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16908 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16910 u32 *action = va_arg (*args, u32 *);
16913 if (unformat (input, "%s", &s))
16915 if (!strcmp ((char *) s, "no-action"))
16917 else if (!strcmp ((char *) s, "natively-forward"))
16919 else if (!strcmp ((char *) s, "send-map-request"))
16921 else if (!strcmp ((char *) s, "drop"))
16925 clib_warning ("invalid action: '%s'", s);
16937 * Add/del remote mapping to/from ONE control plane
16939 * @param vam vpp API test context
16940 * @return return code
16943 api_one_add_del_remote_mapping (vat_main_t * vam)
16945 unformat_input_t *input = vam->input;
16946 vl_api_one_add_del_remote_mapping_t *mp;
16948 lisp_eid_vat_t _eid, *eid = &_eid;
16949 lisp_eid_vat_t _seid, *seid = &_seid;
16950 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16951 u32 action = ~0, p, w, data_len;
16952 ip4_address_t rloc4;
16953 ip6_address_t rloc6;
16954 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16957 memset (&rloc, 0, sizeof (rloc));
16959 /* Parse args required to build the message */
16960 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16962 if (unformat (input, "del-all"))
16966 else if (unformat (input, "del"))
16970 else if (unformat (input, "add"))
16974 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16978 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16982 else if (unformat (input, "vni %d", &vni))
16986 else if (unformat (input, "p %d w %d", &p, &w))
16990 errmsg ("No RLOC configured for setting priority/weight!");
16993 curr_rloc->priority = p;
16994 curr_rloc->weight = w;
16996 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16999 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
17000 vec_add1 (rlocs, rloc);
17001 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17003 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
17006 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
17007 vec_add1 (rlocs, rloc);
17008 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17010 else if (unformat (input, "action %U",
17011 unformat_negative_mapping_action, &action))
17017 clib_warning ("parse error '%U'", format_unformat_error, input);
17024 errmsg ("missing params!");
17028 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
17030 errmsg ("no action set for negative map-reply!");
17034 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
17036 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
17037 mp->is_add = is_add;
17038 mp->vni = htonl (vni);
17039 mp->action = (u8) action;
17040 mp->is_src_dst = seid_set;
17041 mp->eid_len = eid->len;
17042 mp->seid_len = seid->len;
17043 mp->del_all = del_all;
17044 mp->eid_type = eid->type;
17045 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17046 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
17048 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
17049 clib_memcpy (mp->rlocs, rlocs, data_len);
17055 /* Wait for a reply... */
17060 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
17063 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
17064 * forwarding entries in data-plane accordingly.
17066 * @param vam vpp API test context
17067 * @return return code
17070 api_one_add_del_adjacency (vat_main_t * vam)
17072 unformat_input_t *input = vam->input;
17073 vl_api_one_add_del_adjacency_t *mp;
17075 ip4_address_t leid4, reid4;
17076 ip6_address_t leid6, reid6;
17077 u8 reid_mac[6] = { 0 };
17078 u8 leid_mac[6] = { 0 };
17079 u8 reid_type, leid_type;
17080 u32 leid_len = 0, reid_len = 0, len;
17084 leid_type = reid_type = (u8) ~ 0;
17086 /* Parse args required to build the message */
17087 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17089 if (unformat (input, "del"))
17093 else if (unformat (input, "add"))
17097 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17100 reid_type = 0; /* ipv4 */
17103 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17106 reid_type = 1; /* ipv6 */
17109 else if (unformat (input, "reid %U", unformat_ethernet_address,
17112 reid_type = 2; /* mac */
17114 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17117 leid_type = 0; /* ipv4 */
17120 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17123 leid_type = 1; /* ipv6 */
17126 else if (unformat (input, "leid %U", unformat_ethernet_address,
17129 leid_type = 2; /* mac */
17131 else if (unformat (input, "vni %d", &vni))
17137 errmsg ("parse error '%U'", format_unformat_error, input);
17142 if ((u8) ~ 0 == reid_type)
17144 errmsg ("missing params!");
17148 if (leid_type != reid_type)
17150 errmsg ("remote and local EIDs are of different types!");
17154 M (ONE_ADD_DEL_ADJACENCY, mp);
17155 mp->is_add = is_add;
17156 mp->vni = htonl (vni);
17157 mp->leid_len = leid_len;
17158 mp->reid_len = reid_len;
17159 mp->eid_type = reid_type;
17161 switch (mp->eid_type)
17164 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17165 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17168 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17169 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17172 clib_memcpy (mp->leid, leid_mac, 6);
17173 clib_memcpy (mp->reid, reid_mac, 6);
17176 errmsg ("unknown EID type %d!", mp->eid_type);
17183 /* Wait for a reply... */
17188 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17191 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17193 u32 *mode = va_arg (*args, u32 *);
17195 if (unformat (input, "lisp"))
17197 else if (unformat (input, "vxlan"))
17206 api_gpe_get_encap_mode (vat_main_t * vam)
17208 vl_api_gpe_get_encap_mode_t *mp;
17211 /* Construct the API message */
17212 M (GPE_GET_ENCAP_MODE, mp);
17217 /* Wait for a reply... */
17223 api_gpe_set_encap_mode (vat_main_t * vam)
17225 unformat_input_t *input = vam->input;
17226 vl_api_gpe_set_encap_mode_t *mp;
17230 /* Parse args required to build the message */
17231 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17233 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17239 /* Construct the API message */
17240 M (GPE_SET_ENCAP_MODE, mp);
17247 /* Wait for a reply... */
17253 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17255 unformat_input_t *input = vam->input;
17256 vl_api_gpe_add_del_iface_t *mp;
17257 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17258 u32 dp_table = 0, vni = 0;
17261 /* Parse args required to build the message */
17262 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17264 if (unformat (input, "up"))
17269 else if (unformat (input, "down"))
17274 else if (unformat (input, "table_id %d", &dp_table))
17278 else if (unformat (input, "bd_id %d", &dp_table))
17283 else if (unformat (input, "vni %d", &vni))
17291 if (action_set == 0)
17293 errmsg ("Action not set");
17296 if (dp_table_set == 0 || vni_set == 0)
17298 errmsg ("vni and dp_table must be set");
17302 /* Construct the API message */
17303 M (GPE_ADD_DEL_IFACE, mp);
17305 mp->is_add = is_add;
17306 mp->dp_table = clib_host_to_net_u32 (dp_table);
17308 mp->vni = clib_host_to_net_u32 (vni);
17313 /* Wait for a reply... */
17319 api_one_map_register_fallback_threshold (vat_main_t * vam)
17321 unformat_input_t *input = vam->input;
17322 vl_api_one_map_register_fallback_threshold_t *mp;
17327 /* Parse args required to build the message */
17328 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17330 if (unformat (input, "%u", &value))
17334 clib_warning ("parse error '%U'", format_unformat_error, input);
17341 errmsg ("fallback threshold value is missing!");
17345 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17346 mp->value = clib_host_to_net_u32 (value);
17351 /* Wait for a reply... */
17357 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17359 vl_api_show_one_map_register_fallback_threshold_t *mp;
17362 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17367 /* Wait for a reply... */
17373 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17375 u32 *proto = va_arg (*args, u32 *);
17377 if (unformat (input, "udp"))
17379 else if (unformat (input, "api"))
17388 api_one_set_transport_protocol (vat_main_t * vam)
17390 unformat_input_t *input = vam->input;
17391 vl_api_one_set_transport_protocol_t *mp;
17396 /* Parse args required to build the message */
17397 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17399 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17403 clib_warning ("parse error '%U'", format_unformat_error, input);
17410 errmsg ("Transport protocol missing!");
17414 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17415 mp->protocol = (u8) protocol;
17420 /* Wait for a reply... */
17426 api_one_get_transport_protocol (vat_main_t * vam)
17428 vl_api_one_get_transport_protocol_t *mp;
17431 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17436 /* Wait for a reply... */
17442 api_one_map_register_set_ttl (vat_main_t * vam)
17444 unformat_input_t *input = vam->input;
17445 vl_api_one_map_register_set_ttl_t *mp;
17450 /* Parse args required to build the message */
17451 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17453 if (unformat (input, "%u", &ttl))
17457 clib_warning ("parse error '%U'", format_unformat_error, input);
17464 errmsg ("TTL value missing!");
17468 M (ONE_MAP_REGISTER_SET_TTL, mp);
17469 mp->ttl = clib_host_to_net_u32 (ttl);
17474 /* Wait for a reply... */
17480 api_show_one_map_register_ttl (vat_main_t * vam)
17482 vl_api_show_one_map_register_ttl_t *mp;
17485 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17490 /* Wait for a reply... */
17496 * Add/del map request itr rlocs from ONE control plane and updates
17498 * @param vam vpp API test context
17499 * @return return code
17502 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17504 unformat_input_t *input = vam->input;
17505 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17506 u8 *locator_set_name = 0;
17507 u8 locator_set_name_set = 0;
17511 /* Parse args required to build the message */
17512 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17514 if (unformat (input, "del"))
17518 else if (unformat (input, "%_%v%_", &locator_set_name))
17520 locator_set_name_set = 1;
17524 clib_warning ("parse error '%U'", format_unformat_error, input);
17529 if (is_add && !locator_set_name_set)
17531 errmsg ("itr-rloc is not set!");
17535 if (is_add && vec_len (locator_set_name) > 64)
17537 errmsg ("itr-rloc locator-set name too long");
17538 vec_free (locator_set_name);
17542 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17543 mp->is_add = is_add;
17546 clib_memcpy (mp->locator_set_name, locator_set_name,
17547 vec_len (locator_set_name));
17551 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17553 vec_free (locator_set_name);
17558 /* Wait for a reply... */
17563 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17566 api_one_locator_dump (vat_main_t * vam)
17568 unformat_input_t *input = vam->input;
17569 vl_api_one_locator_dump_t *mp;
17570 vl_api_control_ping_t *mp_ping;
17571 u8 is_index_set = 0, is_name_set = 0;
17576 /* Parse args required to build the message */
17577 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17579 if (unformat (input, "ls_name %_%v%_", &ls_name))
17583 else if (unformat (input, "ls_index %d", &ls_index))
17589 errmsg ("parse error '%U'", format_unformat_error, input);
17594 if (!is_index_set && !is_name_set)
17596 errmsg ("error: expected one of index or name!");
17600 if (is_index_set && is_name_set)
17602 errmsg ("error: only one param expected!");
17606 if (vec_len (ls_name) > 62)
17608 errmsg ("error: locator set name too long!");
17612 if (!vam->json_output)
17614 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17617 M (ONE_LOCATOR_DUMP, mp);
17618 mp->is_index_set = is_index_set;
17621 mp->ls_index = clib_host_to_net_u32 (ls_index);
17624 vec_add1 (ls_name, 0);
17625 strncpy ((char *) mp->ls_name, (char *) ls_name,
17626 sizeof (mp->ls_name) - 1);
17632 /* Use a control ping for synchronization */
17633 MPING (CONTROL_PING, mp_ping);
17636 /* Wait for a reply... */
17641 #define api_lisp_locator_dump api_one_locator_dump
17644 api_one_locator_set_dump (vat_main_t * vam)
17646 vl_api_one_locator_set_dump_t *mp;
17647 vl_api_control_ping_t *mp_ping;
17648 unformat_input_t *input = vam->input;
17652 /* Parse args required to build the message */
17653 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17655 if (unformat (input, "local"))
17659 else if (unformat (input, "remote"))
17665 errmsg ("parse error '%U'", format_unformat_error, input);
17670 if (!vam->json_output)
17672 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17675 M (ONE_LOCATOR_SET_DUMP, mp);
17677 mp->filter = filter;
17682 /* Use a control ping for synchronization */
17683 MPING (CONTROL_PING, mp_ping);
17686 /* Wait for a reply... */
17691 #define api_lisp_locator_set_dump api_one_locator_set_dump
17694 api_one_eid_table_map_dump (vat_main_t * vam)
17698 unformat_input_t *input = vam->input;
17699 vl_api_one_eid_table_map_dump_t *mp;
17700 vl_api_control_ping_t *mp_ping;
17703 /* Parse args required to build the message */
17704 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17706 if (unformat (input, "l2"))
17711 else if (unformat (input, "l3"))
17718 errmsg ("parse error '%U'", format_unformat_error, input);
17725 errmsg ("expected one of 'l2' or 'l3' parameter!");
17729 if (!vam->json_output)
17731 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17734 M (ONE_EID_TABLE_MAP_DUMP, mp);
17740 /* Use a control ping for synchronization */
17741 MPING (CONTROL_PING, mp_ping);
17744 /* Wait for a reply... */
17749 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17752 api_one_eid_table_vni_dump (vat_main_t * vam)
17754 vl_api_one_eid_table_vni_dump_t *mp;
17755 vl_api_control_ping_t *mp_ping;
17758 if (!vam->json_output)
17760 print (vam->ofp, "VNI");
17763 M (ONE_EID_TABLE_VNI_DUMP, mp);
17768 /* Use a control ping for synchronization */
17769 MPING (CONTROL_PING, mp_ping);
17772 /* Wait for a reply... */
17777 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17780 api_one_eid_table_dump (vat_main_t * vam)
17782 unformat_input_t *i = vam->input;
17783 vl_api_one_eid_table_dump_t *mp;
17784 vl_api_control_ping_t *mp_ping;
17785 struct in_addr ip4;
17786 struct in6_addr ip6;
17788 u8 eid_type = ~0, eid_set = 0;
17789 u32 prefix_length = ~0, t, vni = 0;
17792 lisp_nsh_api_t nsh;
17794 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17796 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17802 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17808 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17813 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17818 else if (unformat (i, "vni %d", &t))
17822 else if (unformat (i, "local"))
17826 else if (unformat (i, "remote"))
17832 errmsg ("parse error '%U'", format_unformat_error, i);
17837 if (!vam->json_output)
17839 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17840 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17843 M (ONE_EID_TABLE_DUMP, mp);
17845 mp->filter = filter;
17849 mp->vni = htonl (vni);
17850 mp->eid_type = eid_type;
17854 mp->prefix_length = prefix_length;
17855 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17858 mp->prefix_length = prefix_length;
17859 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17862 clib_memcpy (mp->eid, mac, sizeof (mac));
17865 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17868 errmsg ("unknown EID type %d!", eid_type);
17876 /* Use a control ping for synchronization */
17877 MPING (CONTROL_PING, mp_ping);
17880 /* Wait for a reply... */
17885 #define api_lisp_eid_table_dump api_one_eid_table_dump
17888 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17890 unformat_input_t *i = vam->input;
17891 vl_api_gpe_fwd_entries_get_t *mp;
17896 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17898 if (unformat (i, "vni %d", &vni))
17904 errmsg ("parse error '%U'", format_unformat_error, i);
17911 errmsg ("vni not set!");
17915 if (!vam->json_output)
17917 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17921 M (GPE_FWD_ENTRIES_GET, mp);
17922 mp->vni = clib_host_to_net_u32 (vni);
17927 /* Wait for a reply... */
17932 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17933 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17934 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17935 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17936 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17937 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17938 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17939 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17942 api_one_adjacencies_get (vat_main_t * vam)
17944 unformat_input_t *i = vam->input;
17945 vl_api_one_adjacencies_get_t *mp;
17950 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17952 if (unformat (i, "vni %d", &vni))
17958 errmsg ("parse error '%U'", format_unformat_error, i);
17965 errmsg ("vni not set!");
17969 if (!vam->json_output)
17971 print (vam->ofp, "%s %40s", "leid", "reid");
17974 M (ONE_ADJACENCIES_GET, mp);
17975 mp->vni = clib_host_to_net_u32 (vni);
17980 /* Wait for a reply... */
17985 #define api_lisp_adjacencies_get api_one_adjacencies_get
17988 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
17990 unformat_input_t *i = vam->input;
17991 vl_api_gpe_native_fwd_rpaths_get_t *mp;
17993 u8 ip_family_set = 0, is_ip4 = 1;
17995 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17997 if (unformat (i, "ip4"))
18002 else if (unformat (i, "ip6"))
18009 errmsg ("parse error '%U'", format_unformat_error, i);
18014 if (!ip_family_set)
18016 errmsg ("ip family not set!");
18020 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
18021 mp->is_ip4 = is_ip4;
18026 /* Wait for a reply... */
18032 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
18034 vl_api_gpe_fwd_entry_vnis_get_t *mp;
18037 if (!vam->json_output)
18039 print (vam->ofp, "VNIs");
18042 M (GPE_FWD_ENTRY_VNIS_GET, mp);
18047 /* Wait for a reply... */
18053 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
18055 unformat_input_t *i = vam->input;
18056 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
18058 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
18059 struct in_addr ip4;
18060 struct in6_addr ip6;
18061 u32 table_id = 0, nh_sw_if_index = ~0;
18063 memset (&ip4, 0, sizeof (ip4));
18064 memset (&ip6, 0, sizeof (ip6));
18066 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18068 if (unformat (i, "del"))
18070 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
18071 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18076 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
18077 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18082 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18086 nh_sw_if_index = ~0;
18088 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18092 nh_sw_if_index = ~0;
18094 else if (unformat (i, "table %d", &table_id))
18098 errmsg ("parse error '%U'", format_unformat_error, i);
18105 errmsg ("nh addr not set!");
18109 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18110 mp->is_add = is_add;
18111 mp->table_id = clib_host_to_net_u32 (table_id);
18112 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18113 mp->is_ip4 = is_ip4;
18115 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18117 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18122 /* Wait for a reply... */
18128 api_one_map_server_dump (vat_main_t * vam)
18130 vl_api_one_map_server_dump_t *mp;
18131 vl_api_control_ping_t *mp_ping;
18134 if (!vam->json_output)
18136 print (vam->ofp, "%=20s", "Map server");
18139 M (ONE_MAP_SERVER_DUMP, mp);
18143 /* Use a control ping for synchronization */
18144 MPING (CONTROL_PING, mp_ping);
18147 /* Wait for a reply... */
18152 #define api_lisp_map_server_dump api_one_map_server_dump
18155 api_one_map_resolver_dump (vat_main_t * vam)
18157 vl_api_one_map_resolver_dump_t *mp;
18158 vl_api_control_ping_t *mp_ping;
18161 if (!vam->json_output)
18163 print (vam->ofp, "%=20s", "Map resolver");
18166 M (ONE_MAP_RESOLVER_DUMP, mp);
18170 /* Use a control ping for synchronization */
18171 MPING (CONTROL_PING, mp_ping);
18174 /* Wait for a reply... */
18179 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18182 api_one_stats_flush (vat_main_t * vam)
18184 vl_api_one_stats_flush_t *mp;
18187 M (ONE_STATS_FLUSH, mp);
18194 api_one_stats_dump (vat_main_t * vam)
18196 vl_api_one_stats_dump_t *mp;
18197 vl_api_control_ping_t *mp_ping;
18200 M (ONE_STATS_DUMP, mp);
18204 /* Use a control ping for synchronization */
18205 MPING (CONTROL_PING, mp_ping);
18208 /* Wait for a reply... */
18214 api_show_one_status (vat_main_t * vam)
18216 vl_api_show_one_status_t *mp;
18219 if (!vam->json_output)
18221 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18224 M (SHOW_ONE_STATUS, mp);
18227 /* Wait for a reply... */
18232 #define api_show_lisp_status api_show_one_status
18235 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18237 vl_api_gpe_fwd_entry_path_dump_t *mp;
18238 vl_api_control_ping_t *mp_ping;
18239 unformat_input_t *i = vam->input;
18240 u32 fwd_entry_index = ~0;
18243 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18245 if (unformat (i, "index %d", &fwd_entry_index))
18251 if (~0 == fwd_entry_index)
18253 errmsg ("no index specified!");
18257 if (!vam->json_output)
18259 print (vam->ofp, "first line");
18262 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18266 /* Use a control ping for synchronization */
18267 MPING (CONTROL_PING, mp_ping);
18270 /* Wait for a reply... */
18276 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18278 vl_api_one_get_map_request_itr_rlocs_t *mp;
18281 if (!vam->json_output)
18283 print (vam->ofp, "%=20s", "itr-rlocs:");
18286 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18289 /* Wait for a reply... */
18294 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18297 api_af_packet_create (vat_main_t * vam)
18299 unformat_input_t *i = vam->input;
18300 vl_api_af_packet_create_t *mp;
18301 u8 *host_if_name = 0;
18303 u8 random_hw_addr = 1;
18306 memset (hw_addr, 0, sizeof (hw_addr));
18308 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18310 if (unformat (i, "name %s", &host_if_name))
18311 vec_add1 (host_if_name, 0);
18312 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18313 random_hw_addr = 0;
18318 if (!vec_len (host_if_name))
18320 errmsg ("host-interface name must be specified");
18324 if (vec_len (host_if_name) > 64)
18326 errmsg ("host-interface name too long");
18330 M (AF_PACKET_CREATE, mp);
18332 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18333 clib_memcpy (mp->hw_addr, hw_addr, 6);
18334 mp->use_random_hw_addr = random_hw_addr;
18335 vec_free (host_if_name);
18343 fprintf (vam->ofp ? vam->ofp : stderr,
18344 " new sw_if_index = %d\n", vam->sw_if_index);
18351 api_af_packet_delete (vat_main_t * vam)
18353 unformat_input_t *i = vam->input;
18354 vl_api_af_packet_delete_t *mp;
18355 u8 *host_if_name = 0;
18358 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18360 if (unformat (i, "name %s", &host_if_name))
18361 vec_add1 (host_if_name, 0);
18366 if (!vec_len (host_if_name))
18368 errmsg ("host-interface name must be specified");
18372 if (vec_len (host_if_name) > 64)
18374 errmsg ("host-interface name too long");
18378 M (AF_PACKET_DELETE, mp);
18380 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18381 vec_free (host_if_name);
18389 api_policer_add_del (vat_main_t * vam)
18391 unformat_input_t *i = vam->input;
18392 vl_api_policer_add_del_t *mp;
18402 u8 color_aware = 0;
18403 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18406 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18407 conform_action.dscp = 0;
18408 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18409 exceed_action.dscp = 0;
18410 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18411 violate_action.dscp = 0;
18413 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18415 if (unformat (i, "del"))
18417 else if (unformat (i, "name %s", &name))
18418 vec_add1 (name, 0);
18419 else if (unformat (i, "cir %u", &cir))
18421 else if (unformat (i, "eir %u", &eir))
18423 else if (unformat (i, "cb %u", &cb))
18425 else if (unformat (i, "eb %u", &eb))
18427 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18430 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18433 else if (unformat (i, "type %U", unformat_policer_type, &type))
18435 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18438 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18441 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18444 else if (unformat (i, "color-aware"))
18450 if (!vec_len (name))
18452 errmsg ("policer name must be specified");
18456 if (vec_len (name) > 64)
18458 errmsg ("policer name too long");
18462 M (POLICER_ADD_DEL, mp);
18464 clib_memcpy (mp->name, name, vec_len (name));
18466 mp->is_add = is_add;
18467 mp->cir = ntohl (cir);
18468 mp->eir = ntohl (eir);
18469 mp->cb = clib_net_to_host_u64 (cb);
18470 mp->eb = clib_net_to_host_u64 (eb);
18471 mp->rate_type = rate_type;
18472 mp->round_type = round_type;
18474 mp->conform_action_type = conform_action.action_type;
18475 mp->conform_dscp = conform_action.dscp;
18476 mp->exceed_action_type = exceed_action.action_type;
18477 mp->exceed_dscp = exceed_action.dscp;
18478 mp->violate_action_type = violate_action.action_type;
18479 mp->violate_dscp = violate_action.dscp;
18480 mp->color_aware = color_aware;
18488 api_policer_dump (vat_main_t * vam)
18490 unformat_input_t *i = vam->input;
18491 vl_api_policer_dump_t *mp;
18492 vl_api_control_ping_t *mp_ping;
18493 u8 *match_name = 0;
18494 u8 match_name_valid = 0;
18497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18499 if (unformat (i, "name %s", &match_name))
18501 vec_add1 (match_name, 0);
18502 match_name_valid = 1;
18508 M (POLICER_DUMP, mp);
18509 mp->match_name_valid = match_name_valid;
18510 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18511 vec_free (match_name);
18515 /* Use a control ping for synchronization */
18516 MPING (CONTROL_PING, mp_ping);
18519 /* Wait for a reply... */
18525 api_policer_classify_set_interface (vat_main_t * vam)
18527 unformat_input_t *i = vam->input;
18528 vl_api_policer_classify_set_interface_t *mp;
18530 int sw_if_index_set;
18531 u32 ip4_table_index = ~0;
18532 u32 ip6_table_index = ~0;
18533 u32 l2_table_index = ~0;
18537 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18539 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18540 sw_if_index_set = 1;
18541 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18542 sw_if_index_set = 1;
18543 else if (unformat (i, "del"))
18545 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18547 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18549 else if (unformat (i, "l2-table %d", &l2_table_index))
18553 clib_warning ("parse error '%U'", format_unformat_error, i);
18558 if (sw_if_index_set == 0)
18560 errmsg ("missing interface name or sw_if_index");
18564 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18566 mp->sw_if_index = ntohl (sw_if_index);
18567 mp->ip4_table_index = ntohl (ip4_table_index);
18568 mp->ip6_table_index = ntohl (ip6_table_index);
18569 mp->l2_table_index = ntohl (l2_table_index);
18570 mp->is_add = is_add;
18578 api_policer_classify_dump (vat_main_t * vam)
18580 unformat_input_t *i = vam->input;
18581 vl_api_policer_classify_dump_t *mp;
18582 vl_api_control_ping_t *mp_ping;
18583 u8 type = POLICER_CLASSIFY_N_TABLES;
18586 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18590 errmsg ("classify table type must be specified");
18594 if (!vam->json_output)
18596 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18599 M (POLICER_CLASSIFY_DUMP, mp);
18604 /* Use a control ping for synchronization */
18605 MPING (CONTROL_PING, mp_ping);
18608 /* Wait for a reply... */
18614 api_netmap_create (vat_main_t * vam)
18616 unformat_input_t *i = vam->input;
18617 vl_api_netmap_create_t *mp;
18620 u8 random_hw_addr = 1;
18625 memset (hw_addr, 0, sizeof (hw_addr));
18627 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18629 if (unformat (i, "name %s", &if_name))
18630 vec_add1 (if_name, 0);
18631 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18632 random_hw_addr = 0;
18633 else if (unformat (i, "pipe"))
18635 else if (unformat (i, "master"))
18637 else if (unformat (i, "slave"))
18643 if (!vec_len (if_name))
18645 errmsg ("interface name must be specified");
18649 if (vec_len (if_name) > 64)
18651 errmsg ("interface name too long");
18655 M (NETMAP_CREATE, mp);
18657 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18658 clib_memcpy (mp->hw_addr, hw_addr, 6);
18659 mp->use_random_hw_addr = random_hw_addr;
18660 mp->is_pipe = is_pipe;
18661 mp->is_master = is_master;
18662 vec_free (if_name);
18670 api_netmap_delete (vat_main_t * vam)
18672 unformat_input_t *i = vam->input;
18673 vl_api_netmap_delete_t *mp;
18677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18679 if (unformat (i, "name %s", &if_name))
18680 vec_add1 (if_name, 0);
18685 if (!vec_len (if_name))
18687 errmsg ("interface name must be specified");
18691 if (vec_len (if_name) > 64)
18693 errmsg ("interface name too long");
18697 M (NETMAP_DELETE, mp);
18699 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18700 vec_free (if_name);
18708 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
18710 if (fp->afi == IP46_TYPE_IP6)
18712 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18713 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18714 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18715 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18716 format_ip6_address, fp->next_hop);
18717 else if (fp->afi == IP46_TYPE_IP4)
18719 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18720 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18721 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18722 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18723 format_ip4_address, fp->next_hop);
18727 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18728 vl_api_fib_path2_t * fp)
18730 struct in_addr ip4;
18731 struct in6_addr ip6;
18733 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18734 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18735 vat_json_object_add_uint (node, "is_local", fp->is_local);
18736 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18737 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18738 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18739 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18740 if (fp->afi == IP46_TYPE_IP4)
18742 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18743 vat_json_object_add_ip4 (node, "next_hop", ip4);
18745 else if (fp->afi == IP46_TYPE_IP6)
18747 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18748 vat_json_object_add_ip6 (node, "next_hop", ip6);
18753 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18755 vat_main_t *vam = &vat_main;
18756 int count = ntohl (mp->mt_count);
18757 vl_api_fib_path2_t *fp;
18760 print (vam->ofp, "[%d]: sw_if_index %d via:",
18761 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
18763 for (i = 0; i < count; i++)
18765 vl_api_mpls_fib_path_print (vam, fp);
18769 print (vam->ofp, "");
18772 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18773 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18776 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18778 vat_main_t *vam = &vat_main;
18779 vat_json_node_t *node = NULL;
18780 int count = ntohl (mp->mt_count);
18781 vl_api_fib_path2_t *fp;
18784 if (VAT_JSON_ARRAY != vam->json_tree.type)
18786 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18787 vat_json_init_array (&vam->json_tree);
18789 node = vat_json_array_add (&vam->json_tree);
18791 vat_json_init_object (node);
18792 vat_json_object_add_uint (node, "tunnel_index",
18793 ntohl (mp->mt_tunnel_index));
18794 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
18796 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
18799 for (i = 0; i < count; i++)
18801 vl_api_mpls_fib_path_json_print (node, fp);
18807 api_mpls_tunnel_dump (vat_main_t * vam)
18809 vl_api_mpls_tunnel_dump_t *mp;
18810 vl_api_control_ping_t *mp_ping;
18814 /* Parse args required to build the message */
18815 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
18817 if (!unformat (vam->input, "tunnel_index %d", &index))
18824 print (vam->ofp, " tunnel_index %d", index);
18826 M (MPLS_TUNNEL_DUMP, mp);
18827 mp->tunnel_index = htonl (index);
18830 /* Use a control ping for synchronization */
18831 MPING (CONTROL_PING, mp_ping);
18838 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
18839 #define vl_api_mpls_fib_details_t_print vl_noop_handler
18843 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
18845 vat_main_t *vam = &vat_main;
18846 int count = ntohl (mp->count);
18847 vl_api_fib_path2_t *fp;
18851 "table-id %d, label %u, ess_bit %u",
18852 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
18854 for (i = 0; i < count; i++)
18856 vl_api_mpls_fib_path_print (vam, fp);
18861 static void vl_api_mpls_fib_details_t_handler_json
18862 (vl_api_mpls_fib_details_t * mp)
18864 vat_main_t *vam = &vat_main;
18865 int count = ntohl (mp->count);
18866 vat_json_node_t *node = NULL;
18867 vl_api_fib_path2_t *fp;
18870 if (VAT_JSON_ARRAY != vam->json_tree.type)
18872 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18873 vat_json_init_array (&vam->json_tree);
18875 node = vat_json_array_add (&vam->json_tree);
18877 vat_json_init_object (node);
18878 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18879 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
18880 vat_json_object_add_uint (node, "label", ntohl (mp->label));
18881 vat_json_object_add_uint (node, "path_count", count);
18883 for (i = 0; i < count; i++)
18885 vl_api_mpls_fib_path_json_print (node, fp);
18891 api_mpls_fib_dump (vat_main_t * vam)
18893 vl_api_mpls_fib_dump_t *mp;
18894 vl_api_control_ping_t *mp_ping;
18897 M (MPLS_FIB_DUMP, mp);
18900 /* Use a control ping for synchronization */
18901 MPING (CONTROL_PING, mp_ping);
18908 #define vl_api_ip_fib_details_t_endian vl_noop_handler
18909 #define vl_api_ip_fib_details_t_print vl_noop_handler
18912 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
18914 vat_main_t *vam = &vat_main;
18915 int count = ntohl (mp->count);
18916 vl_api_fib_path_t *fp;
18920 "table-id %d, prefix %U/%d",
18921 ntohl (mp->table_id), format_ip4_address, mp->address,
18922 mp->address_length);
18924 for (i = 0; i < count; i++)
18926 if (fp->afi == IP46_TYPE_IP6)
18928 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18929 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18930 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18931 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18932 format_ip6_address, fp->next_hop);
18933 else if (fp->afi == IP46_TYPE_IP4)
18935 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18936 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18937 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18938 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18939 format_ip4_address, fp->next_hop);
18944 static void vl_api_ip_fib_details_t_handler_json
18945 (vl_api_ip_fib_details_t * mp)
18947 vat_main_t *vam = &vat_main;
18948 int count = ntohl (mp->count);
18949 vat_json_node_t *node = NULL;
18950 struct in_addr ip4;
18951 struct in6_addr ip6;
18952 vl_api_fib_path_t *fp;
18955 if (VAT_JSON_ARRAY != vam->json_tree.type)
18957 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18958 vat_json_init_array (&vam->json_tree);
18960 node = vat_json_array_add (&vam->json_tree);
18962 vat_json_init_object (node);
18963 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18964 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
18965 vat_json_object_add_ip4 (node, "prefix", ip4);
18966 vat_json_object_add_uint (node, "mask_length", mp->address_length);
18967 vat_json_object_add_uint (node, "path_count", count);
18969 for (i = 0; i < count; i++)
18971 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18972 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18973 vat_json_object_add_uint (node, "is_local", fp->is_local);
18974 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18975 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18976 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18977 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18978 if (fp->afi == IP46_TYPE_IP4)
18980 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18981 vat_json_object_add_ip4 (node, "next_hop", ip4);
18983 else if (fp->afi == IP46_TYPE_IP6)
18985 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18986 vat_json_object_add_ip6 (node, "next_hop", ip6);
18992 api_ip_fib_dump (vat_main_t * vam)
18994 vl_api_ip_fib_dump_t *mp;
18995 vl_api_control_ping_t *mp_ping;
18998 M (IP_FIB_DUMP, mp);
19001 /* Use a control ping for synchronization */
19002 MPING (CONTROL_PING, mp_ping);
19010 api_ip_mfib_dump (vat_main_t * vam)
19012 vl_api_ip_mfib_dump_t *mp;
19013 vl_api_control_ping_t *mp_ping;
19016 M (IP_MFIB_DUMP, mp);
19019 /* Use a control ping for synchronization */
19020 MPING (CONTROL_PING, mp_ping);
19027 static void vl_api_ip_neighbor_details_t_handler
19028 (vl_api_ip_neighbor_details_t * mp)
19030 vat_main_t *vam = &vat_main;
19032 print (vam->ofp, "%c %U %U",
19033 (mp->is_static) ? 'S' : 'D',
19034 format_ethernet_address, &mp->mac_address,
19035 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
19039 static void vl_api_ip_neighbor_details_t_handler_json
19040 (vl_api_ip_neighbor_details_t * mp)
19043 vat_main_t *vam = &vat_main;
19044 vat_json_node_t *node;
19045 struct in_addr ip4;
19046 struct in6_addr ip6;
19048 if (VAT_JSON_ARRAY != vam->json_tree.type)
19050 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19051 vat_json_init_array (&vam->json_tree);
19053 node = vat_json_array_add (&vam->json_tree);
19055 vat_json_init_object (node);
19056 vat_json_object_add_string_copy (node, "flag",
19057 (mp->is_static) ? (u8 *) "static" : (u8 *)
19060 vat_json_object_add_string_copy (node, "link_layer",
19061 format (0, "%U", format_ethernet_address,
19062 &mp->mac_address));
19066 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
19067 vat_json_object_add_ip6 (node, "ip_address", ip6);
19071 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
19072 vat_json_object_add_ip4 (node, "ip_address", ip4);
19077 api_ip_neighbor_dump (vat_main_t * vam)
19079 unformat_input_t *i = vam->input;
19080 vl_api_ip_neighbor_dump_t *mp;
19081 vl_api_control_ping_t *mp_ping;
19083 u32 sw_if_index = ~0;
19086 /* Parse args required to build the message */
19087 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19089 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19091 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19093 else if (unformat (i, "ip6"))
19099 if (sw_if_index == ~0)
19101 errmsg ("missing interface name or sw_if_index");
19105 M (IP_NEIGHBOR_DUMP, mp);
19106 mp->is_ipv6 = (u8) is_ipv6;
19107 mp->sw_if_index = ntohl (sw_if_index);
19110 /* Use a control ping for synchronization */
19111 MPING (CONTROL_PING, mp_ping);
19118 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
19119 #define vl_api_ip6_fib_details_t_print vl_noop_handler
19122 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
19124 vat_main_t *vam = &vat_main;
19125 int count = ntohl (mp->count);
19126 vl_api_fib_path_t *fp;
19130 "table-id %d, prefix %U/%d",
19131 ntohl (mp->table_id), format_ip6_address, mp->address,
19132 mp->address_length);
19134 for (i = 0; i < count; i++)
19136 if (fp->afi == IP46_TYPE_IP6)
19138 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19139 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19140 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19141 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19142 format_ip6_address, fp->next_hop);
19143 else if (fp->afi == IP46_TYPE_IP4)
19145 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19146 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19147 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19148 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19149 format_ip4_address, fp->next_hop);
19154 static void vl_api_ip6_fib_details_t_handler_json
19155 (vl_api_ip6_fib_details_t * mp)
19157 vat_main_t *vam = &vat_main;
19158 int count = ntohl (mp->count);
19159 vat_json_node_t *node = NULL;
19160 struct in_addr ip4;
19161 struct in6_addr ip6;
19162 vl_api_fib_path_t *fp;
19165 if (VAT_JSON_ARRAY != vam->json_tree.type)
19167 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19168 vat_json_init_array (&vam->json_tree);
19170 node = vat_json_array_add (&vam->json_tree);
19172 vat_json_init_object (node);
19173 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19174 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
19175 vat_json_object_add_ip6 (node, "prefix", ip6);
19176 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19177 vat_json_object_add_uint (node, "path_count", count);
19179 for (i = 0; i < count; i++)
19181 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19182 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19183 vat_json_object_add_uint (node, "is_local", fp->is_local);
19184 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19185 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19186 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19187 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19188 if (fp->afi == IP46_TYPE_IP4)
19190 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19191 vat_json_object_add_ip4 (node, "next_hop", ip4);
19193 else if (fp->afi == IP46_TYPE_IP6)
19195 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19196 vat_json_object_add_ip6 (node, "next_hop", ip6);
19202 api_ip6_fib_dump (vat_main_t * vam)
19204 vl_api_ip6_fib_dump_t *mp;
19205 vl_api_control_ping_t *mp_ping;
19208 M (IP6_FIB_DUMP, mp);
19211 /* Use a control ping for synchronization */
19212 MPING (CONTROL_PING, mp_ping);
19220 api_ip6_mfib_dump (vat_main_t * vam)
19222 vl_api_ip6_mfib_dump_t *mp;
19223 vl_api_control_ping_t *mp_ping;
19226 M (IP6_MFIB_DUMP, mp);
19229 /* Use a control ping for synchronization */
19230 MPING (CONTROL_PING, mp_ping);
19238 api_classify_table_ids (vat_main_t * vam)
19240 vl_api_classify_table_ids_t *mp;
19243 /* Construct the API message */
19244 M (CLASSIFY_TABLE_IDS, mp);
19253 api_classify_table_by_interface (vat_main_t * vam)
19255 unformat_input_t *input = vam->input;
19256 vl_api_classify_table_by_interface_t *mp;
19258 u32 sw_if_index = ~0;
19260 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19262 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19264 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19269 if (sw_if_index == ~0)
19271 errmsg ("missing interface name or sw_if_index");
19275 /* Construct the API message */
19276 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19278 mp->sw_if_index = ntohl (sw_if_index);
19286 api_classify_table_info (vat_main_t * vam)
19288 unformat_input_t *input = vam->input;
19289 vl_api_classify_table_info_t *mp;
19293 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19295 if (unformat (input, "table_id %d", &table_id))
19300 if (table_id == ~0)
19302 errmsg ("missing table id");
19306 /* Construct the API message */
19307 M (CLASSIFY_TABLE_INFO, mp);
19309 mp->table_id = ntohl (table_id);
19317 api_classify_session_dump (vat_main_t * vam)
19319 unformat_input_t *input = vam->input;
19320 vl_api_classify_session_dump_t *mp;
19321 vl_api_control_ping_t *mp_ping;
19325 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19327 if (unformat (input, "table_id %d", &table_id))
19332 if (table_id == ~0)
19334 errmsg ("missing table id");
19338 /* Construct the API message */
19339 M (CLASSIFY_SESSION_DUMP, mp);
19341 mp->table_id = ntohl (table_id);
19344 /* Use a control ping for synchronization */
19345 MPING (CONTROL_PING, mp_ping);
19353 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19355 vat_main_t *vam = &vat_main;
19357 print (vam->ofp, "collector_address %U, collector_port %d, "
19358 "src_address %U, vrf_id %d, path_mtu %u, "
19359 "template_interval %u, udp_checksum %d",
19360 format_ip4_address, mp->collector_address,
19361 ntohs (mp->collector_port),
19362 format_ip4_address, mp->src_address,
19363 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19364 ntohl (mp->template_interval), mp->udp_checksum);
19367 vam->result_ready = 1;
19371 vl_api_ipfix_exporter_details_t_handler_json
19372 (vl_api_ipfix_exporter_details_t * mp)
19374 vat_main_t *vam = &vat_main;
19375 vat_json_node_t node;
19376 struct in_addr collector_address;
19377 struct in_addr src_address;
19379 vat_json_init_object (&node);
19380 clib_memcpy (&collector_address, &mp->collector_address,
19381 sizeof (collector_address));
19382 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19383 vat_json_object_add_uint (&node, "collector_port",
19384 ntohs (mp->collector_port));
19385 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19386 vat_json_object_add_ip4 (&node, "src_address", src_address);
19387 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19388 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19389 vat_json_object_add_uint (&node, "template_interval",
19390 ntohl (mp->template_interval));
19391 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19393 vat_json_print (vam->ofp, &node);
19394 vat_json_free (&node);
19396 vam->result_ready = 1;
19400 api_ipfix_exporter_dump (vat_main_t * vam)
19402 vl_api_ipfix_exporter_dump_t *mp;
19405 /* Construct the API message */
19406 M (IPFIX_EXPORTER_DUMP, mp);
19415 api_ipfix_classify_stream_dump (vat_main_t * vam)
19417 vl_api_ipfix_classify_stream_dump_t *mp;
19420 /* Construct the API message */
19421 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19432 vl_api_ipfix_classify_stream_details_t_handler
19433 (vl_api_ipfix_classify_stream_details_t * mp)
19435 vat_main_t *vam = &vat_main;
19436 print (vam->ofp, "domain_id %d, src_port %d",
19437 ntohl (mp->domain_id), ntohs (mp->src_port));
19439 vam->result_ready = 1;
19443 vl_api_ipfix_classify_stream_details_t_handler_json
19444 (vl_api_ipfix_classify_stream_details_t * mp)
19446 vat_main_t *vam = &vat_main;
19447 vat_json_node_t node;
19449 vat_json_init_object (&node);
19450 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19451 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19453 vat_json_print (vam->ofp, &node);
19454 vat_json_free (&node);
19456 vam->result_ready = 1;
19460 api_ipfix_classify_table_dump (vat_main_t * vam)
19462 vl_api_ipfix_classify_table_dump_t *mp;
19463 vl_api_control_ping_t *mp_ping;
19466 if (!vam->json_output)
19468 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19469 "transport_protocol");
19472 /* Construct the API message */
19473 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19478 /* Use a control ping for synchronization */
19479 MPING (CONTROL_PING, mp_ping);
19487 vl_api_ipfix_classify_table_details_t_handler
19488 (vl_api_ipfix_classify_table_details_t * mp)
19490 vat_main_t *vam = &vat_main;
19491 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19492 mp->transport_protocol);
19496 vl_api_ipfix_classify_table_details_t_handler_json
19497 (vl_api_ipfix_classify_table_details_t * mp)
19499 vat_json_node_t *node = NULL;
19500 vat_main_t *vam = &vat_main;
19502 if (VAT_JSON_ARRAY != vam->json_tree.type)
19504 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19505 vat_json_init_array (&vam->json_tree);
19508 node = vat_json_array_add (&vam->json_tree);
19509 vat_json_init_object (node);
19511 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19512 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19513 vat_json_object_add_uint (node, "transport_protocol",
19514 mp->transport_protocol);
19518 api_sw_interface_span_enable_disable (vat_main_t * vam)
19520 unformat_input_t *i = vam->input;
19521 vl_api_sw_interface_span_enable_disable_t *mp;
19522 u32 src_sw_if_index = ~0;
19523 u32 dst_sw_if_index = ~0;
19528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19531 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19533 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19537 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19539 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19541 else if (unformat (i, "disable"))
19543 else if (unformat (i, "rx"))
19545 else if (unformat (i, "tx"))
19547 else if (unformat (i, "both"))
19549 else if (unformat (i, "l2"))
19555 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19557 mp->sw_if_index_from = htonl (src_sw_if_index);
19558 mp->sw_if_index_to = htonl (dst_sw_if_index);
19568 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19571 vat_main_t *vam = &vat_main;
19572 u8 *sw_if_from_name = 0;
19573 u8 *sw_if_to_name = 0;
19574 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19575 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19576 char *states[] = { "none", "rx", "tx", "both" };
19580 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19582 if ((u32) p->value[0] == sw_if_index_from)
19584 sw_if_from_name = (u8 *)(p->key);
19588 if ((u32) p->value[0] == sw_if_index_to)
19590 sw_if_to_name = (u8 *)(p->key);
19591 if (sw_if_from_name)
19596 print (vam->ofp, "%20s => %20s (%s)",
19597 sw_if_from_name, sw_if_to_name, states[mp->state]);
19601 vl_api_sw_interface_span_details_t_handler_json
19602 (vl_api_sw_interface_span_details_t * mp)
19604 vat_main_t *vam = &vat_main;
19605 vat_json_node_t *node = NULL;
19606 u8 *sw_if_from_name = 0;
19607 u8 *sw_if_to_name = 0;
19608 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19609 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19613 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19615 if ((u32) p->value[0] == sw_if_index_from)
19617 sw_if_from_name = (u8 *)(p->key);
19621 if ((u32) p->value[0] == sw_if_index_to)
19623 sw_if_to_name = (u8 *)(p->key);
19624 if (sw_if_from_name)
19630 if (VAT_JSON_ARRAY != vam->json_tree.type)
19632 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19633 vat_json_init_array (&vam->json_tree);
19635 node = vat_json_array_add (&vam->json_tree);
19637 vat_json_init_object (node);
19638 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19639 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19640 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19641 if (0 != sw_if_to_name)
19643 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19645 vat_json_object_add_uint (node, "state", mp->state);
19649 api_sw_interface_span_dump (vat_main_t * vam)
19651 unformat_input_t *input = vam->input;
19652 vl_api_sw_interface_span_dump_t *mp;
19653 vl_api_control_ping_t *mp_ping;
19657 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19659 if (unformat (input, "l2"))
19665 M (SW_INTERFACE_SPAN_DUMP, mp);
19669 /* Use a control ping for synchronization */
19670 MPING (CONTROL_PING, mp_ping);
19678 api_pg_create_interface (vat_main_t * vam)
19680 unformat_input_t *input = vam->input;
19681 vl_api_pg_create_interface_t *mp;
19685 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19687 if (unformat (input, "if_id %d", &if_id))
19694 errmsg ("missing pg interface index");
19698 /* Construct the API message */
19699 M (PG_CREATE_INTERFACE, mp);
19701 mp->interface_id = ntohl (if_id);
19709 api_pg_capture (vat_main_t * vam)
19711 unformat_input_t *input = vam->input;
19712 vl_api_pg_capture_t *mp;
19717 u8 pcap_file_set = 0;
19720 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19722 if (unformat (input, "if_id %d", &if_id))
19724 else if (unformat (input, "pcap %s", &pcap_file))
19726 else if (unformat (input, "count %d", &count))
19728 else if (unformat (input, "disable"))
19735 errmsg ("missing pg interface index");
19738 if (pcap_file_set > 0)
19740 if (vec_len (pcap_file) > 255)
19742 errmsg ("pcap file name is too long");
19747 u32 name_len = vec_len (pcap_file);
19748 /* Construct the API message */
19749 M (PG_CAPTURE, mp);
19751 mp->interface_id = ntohl (if_id);
19752 mp->is_enabled = enable;
19753 mp->count = ntohl (count);
19754 mp->pcap_name_length = ntohl (name_len);
19755 if (pcap_file_set != 0)
19757 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19759 vec_free (pcap_file);
19767 api_pg_enable_disable (vat_main_t * vam)
19769 unformat_input_t *input = vam->input;
19770 vl_api_pg_enable_disable_t *mp;
19773 u8 stream_name_set = 0;
19774 u8 *stream_name = 0;
19776 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19778 if (unformat (input, "stream %s", &stream_name))
19779 stream_name_set = 1;
19780 else if (unformat (input, "disable"))
19786 if (stream_name_set > 0)
19788 if (vec_len (stream_name) > 255)
19790 errmsg ("stream name too long");
19795 u32 name_len = vec_len (stream_name);
19796 /* Construct the API message */
19797 M (PG_ENABLE_DISABLE, mp);
19799 mp->is_enabled = enable;
19800 if (stream_name_set != 0)
19802 mp->stream_name_length = ntohl (name_len);
19803 clib_memcpy (mp->stream_name, stream_name, name_len);
19805 vec_free (stream_name);
19813 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19815 unformat_input_t *input = vam->input;
19816 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19818 u16 *low_ports = 0;
19819 u16 *high_ports = 0;
19822 ip4_address_t ip4_addr;
19823 ip6_address_t ip6_addr;
19832 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19834 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
19840 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
19845 else if (unformat (input, "vrf %d", &vrf_id))
19847 else if (unformat (input, "del"))
19849 else if (unformat (input, "port %d", &tmp))
19851 if (tmp == 0 || tmp > 65535)
19853 errmsg ("port %d out of range", tmp);
19857 this_hi = this_low + 1;
19858 vec_add1 (low_ports, this_low);
19859 vec_add1 (high_ports, this_hi);
19861 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19863 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19865 errmsg ("incorrect range parameters");
19869 /* Note: in debug CLI +1 is added to high before
19870 passing to real fn that does "the work"
19871 (ip_source_and_port_range_check_add_del).
19872 This fn is a wrapper around the binary API fn a
19873 control plane will call, which expects this increment
19874 to have occurred. Hence letting the binary API control
19875 plane fn do the increment for consistency between VAT
19876 and other control planes.
19879 vec_add1 (low_ports, this_low);
19880 vec_add1 (high_ports, this_hi);
19886 if (prefix_set == 0)
19888 errmsg ("<address>/<mask> not specified");
19894 errmsg ("VRF ID required, not specified");
19901 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19905 if (vec_len (low_ports) == 0)
19907 errmsg ("At least one port or port range required");
19911 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19913 mp->is_add = is_add;
19918 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
19923 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
19926 mp->mask_length = length;
19927 mp->number_of_ranges = vec_len (low_ports);
19929 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
19930 vec_free (low_ports);
19932 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
19933 vec_free (high_ports);
19935 mp->vrf_id = ntohl (vrf_id);
19943 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
19945 unformat_input_t *input = vam->input;
19946 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
19947 u32 sw_if_index = ~0;
19949 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
19950 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
19954 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19956 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19958 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19960 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
19962 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
19964 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
19966 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
19968 else if (unformat (input, "del"))
19974 if (sw_if_index == ~0)
19976 errmsg ("Interface required but not specified");
19982 errmsg ("VRF ID required but not specified");
19986 if (tcp_out_vrf_id == 0
19987 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
19990 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19994 /* Construct the API message */
19995 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
19997 mp->sw_if_index = ntohl (sw_if_index);
19998 mp->is_add = is_add;
19999 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20000 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20001 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20002 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20007 /* Wait for a reply... */
20013 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
20015 unformat_input_t *i = vam->input;
20016 vl_api_ipsec_gre_add_del_tunnel_t *mp;
20017 u32 local_sa_id = 0;
20018 u32 remote_sa_id = 0;
20019 ip4_address_t src_address;
20020 ip4_address_t dst_address;
20024 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20026 if (unformat (i, "local_sa %d", &local_sa_id))
20028 else if (unformat (i, "remote_sa %d", &remote_sa_id))
20030 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
20032 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
20034 else if (unformat (i, "del"))
20038 clib_warning ("parse error '%U'", format_unformat_error, i);
20043 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
20045 mp->local_sa_id = ntohl (local_sa_id);
20046 mp->remote_sa_id = ntohl (remote_sa_id);
20047 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
20048 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
20049 mp->is_add = is_add;
20057 api_punt (vat_main_t * vam)
20059 unformat_input_t *i = vam->input;
20067 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20069 if (unformat (i, "ip %d", &ipv))
20071 else if (unformat (i, "protocol %d", &protocol))
20073 else if (unformat (i, "port %d", &port))
20075 else if (unformat (i, "del"))
20079 clib_warning ("parse error '%U'", format_unformat_error, i);
20086 mp->is_add = (u8) is_add;
20087 mp->ipv = (u8) ipv;
20088 mp->l4_protocol = (u8) protocol;
20089 mp->l4_port = htons ((u16) port);
20096 static void vl_api_ipsec_gre_tunnel_details_t_handler
20097 (vl_api_ipsec_gre_tunnel_details_t * mp)
20099 vat_main_t *vam = &vat_main;
20101 print (vam->ofp, "%11d%15U%15U%14d%14d",
20102 ntohl (mp->sw_if_index),
20103 format_ip4_address, &mp->src_address,
20104 format_ip4_address, &mp->dst_address,
20105 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
20108 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
20109 (vl_api_ipsec_gre_tunnel_details_t * mp)
20111 vat_main_t *vam = &vat_main;
20112 vat_json_node_t *node = NULL;
20113 struct in_addr ip4;
20115 if (VAT_JSON_ARRAY != vam->json_tree.type)
20117 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20118 vat_json_init_array (&vam->json_tree);
20120 node = vat_json_array_add (&vam->json_tree);
20122 vat_json_init_object (node);
20123 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20124 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
20125 vat_json_object_add_ip4 (node, "src_address", ip4);
20126 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
20127 vat_json_object_add_ip4 (node, "dst_address", ip4);
20128 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
20129 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
20133 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
20135 unformat_input_t *i = vam->input;
20136 vl_api_ipsec_gre_tunnel_dump_t *mp;
20137 vl_api_control_ping_t *mp_ping;
20139 u8 sw_if_index_set = 0;
20142 /* Parse args required to build the message */
20143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20145 if (unformat (i, "sw_if_index %d", &sw_if_index))
20146 sw_if_index_set = 1;
20151 if (sw_if_index_set == 0)
20156 if (!vam->json_output)
20158 print (vam->ofp, "%11s%15s%15s%14s%14s",
20159 "sw_if_index", "src_address", "dst_address",
20160 "local_sa_id", "remote_sa_id");
20163 /* Get list of gre-tunnel interfaces */
20164 M (IPSEC_GRE_TUNNEL_DUMP, mp);
20166 mp->sw_if_index = htonl (sw_if_index);
20170 /* Use a control ping for synchronization */
20171 MPING (CONTROL_PING, mp_ping);
20179 api_delete_subif (vat_main_t * vam)
20181 unformat_input_t *i = vam->input;
20182 vl_api_delete_subif_t *mp;
20183 u32 sw_if_index = ~0;
20186 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20188 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20190 if (unformat (i, "sw_if_index %d", &sw_if_index))
20196 if (sw_if_index == ~0)
20198 errmsg ("missing sw_if_index");
20202 /* Construct the API message */
20203 M (DELETE_SUBIF, mp);
20204 mp->sw_if_index = ntohl (sw_if_index);
20211 #define foreach_pbb_vtr_op \
20212 _("disable", L2_VTR_DISABLED) \
20213 _("pop", L2_VTR_POP_2) \
20214 _("push", L2_VTR_PUSH_2)
20217 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20219 unformat_input_t *i = vam->input;
20220 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20221 u32 sw_if_index = ~0, vtr_op = ~0;
20222 u16 outer_tag = ~0;
20223 u8 dmac[6], smac[6];
20224 u8 dmac_set = 0, smac_set = 0;
20230 /* Shut up coverity */
20231 memset (dmac, 0, sizeof (dmac));
20232 memset (smac, 0, sizeof (smac));
20234 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20236 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20238 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20240 else if (unformat (i, "vtr_op %d", &vtr_op))
20242 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20245 else if (unformat (i, "translate_pbb_stag"))
20247 if (unformat (i, "%d", &tmp))
20249 vtr_op = L2_VTR_TRANSLATE_2_1;
20255 ("translate_pbb_stag operation requires outer tag definition");
20259 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20261 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20263 else if (unformat (i, "sid %d", &sid))
20265 else if (unformat (i, "vlanid %d", &tmp))
20269 clib_warning ("parse error '%U'", format_unformat_error, i);
20274 if ((sw_if_index == ~0) || (vtr_op == ~0))
20276 errmsg ("missing sw_if_index or vtr operation");
20279 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20280 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20283 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20287 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20288 mp->sw_if_index = ntohl (sw_if_index);
20289 mp->vtr_op = ntohl (vtr_op);
20290 mp->outer_tag = ntohs (outer_tag);
20291 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20292 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20293 mp->b_vlanid = ntohs (vlanid);
20294 mp->i_sid = ntohl (sid);
20302 api_flow_classify_set_interface (vat_main_t * vam)
20304 unformat_input_t *i = vam->input;
20305 vl_api_flow_classify_set_interface_t *mp;
20307 int sw_if_index_set;
20308 u32 ip4_table_index = ~0;
20309 u32 ip6_table_index = ~0;
20313 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20315 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20316 sw_if_index_set = 1;
20317 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20318 sw_if_index_set = 1;
20319 else if (unformat (i, "del"))
20321 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20323 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20327 clib_warning ("parse error '%U'", format_unformat_error, i);
20332 if (sw_if_index_set == 0)
20334 errmsg ("missing interface name or sw_if_index");
20338 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20340 mp->sw_if_index = ntohl (sw_if_index);
20341 mp->ip4_table_index = ntohl (ip4_table_index);
20342 mp->ip6_table_index = ntohl (ip6_table_index);
20343 mp->is_add = is_add;
20351 api_flow_classify_dump (vat_main_t * vam)
20353 unformat_input_t *i = vam->input;
20354 vl_api_flow_classify_dump_t *mp;
20355 vl_api_control_ping_t *mp_ping;
20356 u8 type = FLOW_CLASSIFY_N_TABLES;
20359 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20363 errmsg ("classify table type must be specified");
20367 if (!vam->json_output)
20369 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20372 M (FLOW_CLASSIFY_DUMP, mp);
20377 /* Use a control ping for synchronization */
20378 MPING (CONTROL_PING, mp_ping);
20381 /* Wait for a reply... */
20387 api_feature_enable_disable (vat_main_t * vam)
20389 unformat_input_t *i = vam->input;
20390 vl_api_feature_enable_disable_t *mp;
20392 u8 *feature_name = 0;
20393 u32 sw_if_index = ~0;
20397 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20399 if (unformat (i, "arc_name %s", &arc_name))
20401 else if (unformat (i, "feature_name %s", &feature_name))
20404 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20406 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20408 else if (unformat (i, "disable"))
20416 errmsg ("missing arc name");
20419 if (vec_len (arc_name) > 63)
20421 errmsg ("arc name too long");
20424 if (feature_name == 0)
20426 errmsg ("missing feature name");
20429 if (vec_len (feature_name) > 63)
20431 errmsg ("feature name too long");
20434 if (sw_if_index == ~0)
20436 errmsg ("missing interface name or sw_if_index");
20440 /* Construct the API message */
20441 M (FEATURE_ENABLE_DISABLE, mp);
20442 mp->sw_if_index = ntohl (sw_if_index);
20443 mp->enable = enable;
20444 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20445 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20446 vec_free (arc_name);
20447 vec_free (feature_name);
20455 api_sw_interface_tag_add_del (vat_main_t * vam)
20457 unformat_input_t *i = vam->input;
20458 vl_api_sw_interface_tag_add_del_t *mp;
20459 u32 sw_if_index = ~0;
20464 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20466 if (unformat (i, "tag %s", &tag))
20468 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20470 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20472 else if (unformat (i, "del"))
20478 if (sw_if_index == ~0)
20480 errmsg ("missing interface name or sw_if_index");
20484 if (enable && (tag == 0))
20486 errmsg ("no tag specified");
20490 /* Construct the API message */
20491 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20492 mp->sw_if_index = ntohl (sw_if_index);
20493 mp->is_add = enable;
20495 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20503 static void vl_api_l2_xconnect_details_t_handler
20504 (vl_api_l2_xconnect_details_t * mp)
20506 vat_main_t *vam = &vat_main;
20508 print (vam->ofp, "%15d%15d",
20509 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20512 static void vl_api_l2_xconnect_details_t_handler_json
20513 (vl_api_l2_xconnect_details_t * mp)
20515 vat_main_t *vam = &vat_main;
20516 vat_json_node_t *node = NULL;
20518 if (VAT_JSON_ARRAY != vam->json_tree.type)
20520 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20521 vat_json_init_array (&vam->json_tree);
20523 node = vat_json_array_add (&vam->json_tree);
20525 vat_json_init_object (node);
20526 vat_json_object_add_uint (node, "rx_sw_if_index",
20527 ntohl (mp->rx_sw_if_index));
20528 vat_json_object_add_uint (node, "tx_sw_if_index",
20529 ntohl (mp->tx_sw_if_index));
20533 api_l2_xconnect_dump (vat_main_t * vam)
20535 vl_api_l2_xconnect_dump_t *mp;
20536 vl_api_control_ping_t *mp_ping;
20539 if (!vam->json_output)
20541 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20544 M (L2_XCONNECT_DUMP, mp);
20548 /* Use a control ping for synchronization */
20549 MPING (CONTROL_PING, mp_ping);
20557 api_sw_interface_set_mtu (vat_main_t * vam)
20559 unformat_input_t *i = vam->input;
20560 vl_api_sw_interface_set_mtu_t *mp;
20561 u32 sw_if_index = ~0;
20565 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20567 if (unformat (i, "mtu %d", &mtu))
20569 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20571 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20577 if (sw_if_index == ~0)
20579 errmsg ("missing interface name or sw_if_index");
20585 errmsg ("no mtu specified");
20589 /* Construct the API message */
20590 M (SW_INTERFACE_SET_MTU, mp);
20591 mp->sw_if_index = ntohl (sw_if_index);
20592 mp->mtu = ntohs ((u16) mtu);
20600 api_p2p_ethernet_add (vat_main_t * vam)
20602 unformat_input_t *i = vam->input;
20603 vl_api_p2p_ethernet_add_t *mp;
20604 u32 parent_if_index = ~0;
20610 memset (remote_mac, 0, sizeof (remote_mac));
20611 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20613 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20615 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20619 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20621 else if (unformat (i, "sub_id %d", &sub_id))
20625 clib_warning ("parse error '%U'", format_unformat_error, i);
20630 if (parent_if_index == ~0)
20632 errmsg ("missing interface name or sw_if_index");
20637 errmsg ("missing remote mac address");
20642 errmsg ("missing sub-interface id");
20646 M (P2P_ETHERNET_ADD, mp);
20647 mp->parent_if_index = ntohl (parent_if_index);
20648 mp->subif_id = ntohl (sub_id);
20649 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20657 api_p2p_ethernet_del (vat_main_t * vam)
20659 unformat_input_t *i = vam->input;
20660 vl_api_p2p_ethernet_del_t *mp;
20661 u32 parent_if_index = ~0;
20666 memset (remote_mac, 0, sizeof (remote_mac));
20667 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20669 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20671 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20675 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20679 clib_warning ("parse error '%U'", format_unformat_error, i);
20684 if (parent_if_index == ~0)
20686 errmsg ("missing interface name or sw_if_index");
20691 errmsg ("missing remote mac address");
20695 M (P2P_ETHERNET_DEL, mp);
20696 mp->parent_if_index = ntohl (parent_if_index);
20697 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20705 api_lldp_config (vat_main_t * vam)
20707 unformat_input_t *i = vam->input;
20708 vl_api_lldp_config_t *mp;
20710 int tx_interval = 0;
20711 u8 *sys_name = NULL;
20714 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20716 if (unformat (i, "system-name %s", &sys_name))
20718 else if (unformat (i, "tx-hold %d", &tx_hold))
20720 else if (unformat (i, "tx-interval %d", &tx_interval))
20724 clib_warning ("parse error '%U'", format_unformat_error, i);
20729 vec_add1 (sys_name, 0);
20731 M (LLDP_CONFIG, mp);
20732 mp->tx_hold = htonl (tx_hold);
20733 mp->tx_interval = htonl (tx_interval);
20734 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20735 vec_free (sys_name);
20743 api_sw_interface_set_lldp (vat_main_t * vam)
20745 unformat_input_t *i = vam->input;
20746 vl_api_sw_interface_set_lldp_t *mp;
20747 u32 sw_if_index = ~0;
20749 u8 *port_desc = NULL, *mgmt_oid = NULL;
20750 ip4_address_t ip4_addr;
20751 ip6_address_t ip6_addr;
20754 memset (&ip4_addr, 0, sizeof (ip4_addr));
20755 memset (&ip6_addr, 0, sizeof (ip6_addr));
20757 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20759 if (unformat (i, "disable"))
20762 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20764 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20766 else if (unformat (i, "port-desc %s", &port_desc))
20768 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
20770 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
20772 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
20778 if (sw_if_index == ~0)
20780 errmsg ("missing interface name or sw_if_index");
20784 /* Construct the API message */
20785 vec_add1 (port_desc, 0);
20786 vec_add1 (mgmt_oid, 0);
20787 M (SW_INTERFACE_SET_LLDP, mp);
20788 mp->sw_if_index = ntohl (sw_if_index);
20789 mp->enable = enable;
20790 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20791 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
20792 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
20793 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
20794 vec_free (port_desc);
20795 vec_free (mgmt_oid);
20803 api_tcp_configure_src_addresses (vat_main_t * vam)
20805 vl_api_tcp_configure_src_addresses_t *mp;
20806 unformat_input_t *i = vam->input;
20807 ip4_address_t v4first, v4last;
20808 ip6_address_t v6first, v6last;
20813 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20815 if (unformat (i, "%U - %U",
20816 unformat_ip4_address, &v4first,
20817 unformat_ip4_address, &v4last))
20821 errmsg ("one range per message (range already set)");
20826 else if (unformat (i, "%U - %U",
20827 unformat_ip6_address, &v6first,
20828 unformat_ip6_address, &v6last))
20832 errmsg ("one range per message (range already set)");
20837 else if (unformat (i, "vrf %d", &vrf_id))
20843 if (range_set == 0)
20845 errmsg ("address range not set");
20849 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20850 mp->vrf_id = ntohl (vrf_id);
20852 if (range_set == 2)
20855 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20856 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20861 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20862 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20870 api_app_namespace_add_del (vat_main_t * vam)
20872 vl_api_app_namespace_add_del_t *mp;
20873 unformat_input_t *i = vam->input;
20874 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
20875 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
20879 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20881 if (unformat (i, "id %_%v%_", &ns_id))
20883 else if (unformat (i, "secret %lu", &secret))
20885 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20886 sw_if_index_set = 1;
20887 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
20889 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
20894 if (!ns_id || !secret_set || !sw_if_index_set)
20896 errmsg ("namespace id, secret and sw_if_index must be set");
20899 if (vec_len (ns_id) > 64)
20901 errmsg ("namespace id too long");
20904 M (APP_NAMESPACE_ADD_DEL, mp);
20906 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
20907 mp->namespace_id_len = vec_len (ns_id);
20908 mp->secret = secret;
20909 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20910 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
20911 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
20919 api_memfd_segment_create (vat_main_t * vam)
20921 unformat_input_t *i = vam->input;
20922 vl_api_memfd_segment_create_t *mp;
20923 u64 size = 64 << 20;
20926 #if VPP_API_TEST_BUILTIN == 1
20927 errmsg ("memfd_segment_create (builtin) not supported");
20931 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20933 if (unformat (i, "size %U", unformat_memory_size, &size))
20939 M (MEMFD_SEGMENT_CREATE, mp);
20940 mp->requested_size = size;
20947 api_dns_enable_disable (vat_main_t * vam)
20949 unformat_input_t *line_input = vam->input;
20950 vl_api_dns_enable_disable_t *mp;
20951 u8 enable_disable = 1;
20954 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20956 if (unformat (line_input, "disable"))
20957 enable_disable = 0;
20958 if (unformat (line_input, "enable"))
20959 enable_disable = 1;
20964 /* Construct the API message */
20965 M (DNS_ENABLE_DISABLE, mp);
20966 mp->enable = enable_disable;
20970 /* Wait for the reply */
20976 api_dns_resolve_name (vat_main_t * vam)
20978 unformat_input_t *line_input = vam->input;
20979 vl_api_dns_resolve_name_t *mp;
20983 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20985 if (unformat (line_input, "%s", &name))
20991 if (vec_len (name) > 127)
20993 errmsg ("name too long");
20997 /* Construct the API message */
20998 M (DNS_RESOLVE_NAME, mp);
20999 memcpy (mp->name, name, vec_len (name));
21004 /* Wait for the reply */
21010 api_dns_name_server_add_del (vat_main_t * vam)
21012 unformat_input_t *i = vam->input;
21013 vl_api_dns_name_server_add_del_t *mp;
21015 ip6_address_t ip6_server;
21016 ip4_address_t ip4_server;
21021 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21023 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
21025 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
21027 else if (unformat (i, "del"))
21031 clib_warning ("parse error '%U'", format_unformat_error, i);
21036 if (ip4_set && ip6_set)
21038 errmsg ("Only one server address allowed per message");
21041 if ((ip4_set + ip6_set) == 0)
21043 errmsg ("Server address required");
21047 /* Construct the API message */
21048 M (DNS_NAME_SERVER_ADD_DEL, mp);
21052 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
21057 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
21061 mp->is_add = is_add;
21066 /* Wait for a reply, return good/bad news */
21073 q_or_quit (vat_main_t * vam)
21075 #if VPP_API_TEST_BUILTIN == 0
21076 longjmp (vam->jump_buf, 1);
21078 return 0; /* not so much */
21082 q (vat_main_t * vam)
21084 return q_or_quit (vam);
21088 quit (vat_main_t * vam)
21090 return q_or_quit (vam);
21094 comment (vat_main_t * vam)
21100 cmd_cmp (void *a1, void *a2)
21105 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21109 help (vat_main_t * vam)
21114 unformat_input_t *i = vam->input;
21117 if (unformat (i, "%s", &name))
21121 vec_add1 (name, 0);
21123 hs = hash_get_mem (vam->help_by_name, name);
21125 print (vam->ofp, "usage: %s %s", name, hs[0]);
21127 print (vam->ofp, "No such msg / command '%s'", name);
21132 print (vam->ofp, "Help is available for the following:");
21135 hash_foreach_pair (p, vam->function_by_name,
21137 vec_add1 (cmds, (u8 *)(p->key));
21141 vec_sort_with_function (cmds, cmd_cmp);
21143 for (j = 0; j < vec_len (cmds); j++)
21144 print (vam->ofp, "%s", cmds[j]);
21151 set (vat_main_t * vam)
21153 u8 *name = 0, *value = 0;
21154 unformat_input_t *i = vam->input;
21156 if (unformat (i, "%s", &name))
21158 /* The input buffer is a vector, not a string. */
21159 value = vec_dup (i->buffer);
21160 vec_delete (value, i->index, 0);
21161 /* Almost certainly has a trailing newline */
21162 if (value[vec_len (value) - 1] == '\n')
21163 value[vec_len (value) - 1] = 0;
21164 /* Make sure it's a proper string, one way or the other */
21165 vec_add1 (value, 0);
21166 (void) clib_macro_set_value (&vam->macro_main,
21167 (char *) name, (char *) value);
21170 errmsg ("usage: set <name> <value>");
21178 unset (vat_main_t * vam)
21182 if (unformat (vam->input, "%s", &name))
21183 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21184 errmsg ("unset: %s wasn't set", name);
21197 macro_sort_cmp (void *a1, void *a2)
21199 macro_sort_t *s1 = a1;
21200 macro_sort_t *s2 = a2;
21202 return strcmp ((char *) (s1->name), (char *) (s2->name));
21206 dump_macro_table (vat_main_t * vam)
21208 macro_sort_t *sort_me = 0, *sm;
21213 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21215 vec_add2 (sort_me, sm, 1);
21216 sm->name = (u8 *)(p->key);
21217 sm->value = (u8 *) (p->value[0]);
21221 vec_sort_with_function (sort_me, macro_sort_cmp);
21223 if (vec_len (sort_me))
21224 print (vam->ofp, "%-15s%s", "Name", "Value");
21226 print (vam->ofp, "The macro table is empty...");
21228 for (i = 0; i < vec_len (sort_me); i++)
21229 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21234 dump_node_table (vat_main_t * vam)
21237 vlib_node_t *node, *next_node;
21239 if (vec_len (vam->graph_nodes) == 0)
21241 print (vam->ofp, "Node table empty, issue get_node_graph...");
21245 for (i = 0; i < vec_len (vam->graph_nodes); i++)
21247 node = vam->graph_nodes[i];
21248 print (vam->ofp, "[%d] %s", i, node->name);
21249 for (j = 0; j < vec_len (node->next_nodes); j++)
21251 if (node->next_nodes[j] != ~0)
21253 next_node = vam->graph_nodes[node->next_nodes[j]];
21254 print (vam->ofp, " [%d] %s", j, next_node->name);
21262 value_sort_cmp (void *a1, void *a2)
21264 name_sort_t *n1 = a1;
21265 name_sort_t *n2 = a2;
21267 if (n1->value < n2->value)
21269 if (n1->value > n2->value)
21276 dump_msg_api_table (vat_main_t * vam)
21278 api_main_t *am = &api_main;
21279 name_sort_t *nses = 0, *ns;
21284 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21286 vec_add2 (nses, ns, 1);
21287 ns->name = (u8 *)(hp->key);
21288 ns->value = (u32) hp->value[0];
21292 vec_sort_with_function (nses, value_sort_cmp);
21294 for (i = 0; i < vec_len (nses); i++)
21295 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21301 get_msg_id (vat_main_t * vam)
21306 if (unformat (vam->input, "%s", &name_and_crc))
21308 message_index = vl_api_get_msg_index (name_and_crc);
21309 if (message_index == ~0)
21311 print (vam->ofp, " '%s' not found", name_and_crc);
21314 print (vam->ofp, " '%s' has message index %d",
21315 name_and_crc, message_index);
21318 errmsg ("name_and_crc required...");
21323 search_node_table (vat_main_t * vam)
21325 unformat_input_t *line_input = vam->input;
21328 vlib_node_t *node, *next_node;
21331 if (vam->graph_node_index_by_name == 0)
21333 print (vam->ofp, "Node table empty, issue get_node_graph...");
21337 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21339 if (unformat (line_input, "%s", &node_to_find))
21341 vec_add1 (node_to_find, 0);
21342 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21345 print (vam->ofp, "%s not found...", node_to_find);
21348 node = vam->graph_nodes[p[0]];
21349 print (vam->ofp, "[%d] %s", p[0], node->name);
21350 for (j = 0; j < vec_len (node->next_nodes); j++)
21352 if (node->next_nodes[j] != ~0)
21354 next_node = vam->graph_nodes[node->next_nodes[j]];
21355 print (vam->ofp, " [%d] %s", j, next_node->name);
21362 clib_warning ("parse error '%U'", format_unformat_error,
21368 vec_free (node_to_find);
21377 script (vat_main_t * vam)
21379 #if (VPP_API_TEST_BUILTIN==0)
21381 char *save_current_file;
21382 unformat_input_t save_input;
21383 jmp_buf save_jump_buf;
21384 u32 save_line_number;
21386 FILE *new_fp, *save_ifp;
21388 if (unformat (vam->input, "%s", &s))
21390 new_fp = fopen ((char *) s, "r");
21393 errmsg ("Couldn't open script file %s", s);
21400 errmsg ("Missing script name");
21404 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21405 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21406 save_ifp = vam->ifp;
21407 save_line_number = vam->input_line_number;
21408 save_current_file = (char *) vam->current_file;
21410 vam->input_line_number = 0;
21412 vam->current_file = s;
21415 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
21416 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21417 vam->ifp = save_ifp;
21418 vam->input_line_number = save_line_number;
21419 vam->current_file = (u8 *) save_current_file;
21424 clib_warning ("use the exec command...");
21430 echo (vat_main_t * vam)
21432 print (vam->ofp, "%v", vam->input->buffer);
21436 /* List of API message constructors, CLI names map to api_xxx */
21437 #define foreach_vpe_api_msg \
21438 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21439 _(sw_interface_dump,"") \
21440 _(sw_interface_set_flags, \
21441 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21442 _(sw_interface_add_del_address, \
21443 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21444 _(sw_interface_set_table, \
21445 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21446 _(sw_interface_set_mpls_enable, \
21447 "<intfc> | sw_if_index [disable | dis]") \
21448 _(sw_interface_set_vpath, \
21449 "<intfc> | sw_if_index <id> enable | disable") \
21450 _(sw_interface_set_vxlan_bypass, \
21451 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21452 _(sw_interface_set_geneve_bypass, \
21453 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21454 _(sw_interface_set_l2_xconnect, \
21455 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21456 "enable | disable") \
21457 _(sw_interface_set_l2_bridge, \
21458 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21459 "[shg <split-horizon-group>] [bvi]\n" \
21460 "enable | disable") \
21461 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21462 _(bridge_domain_add_del, \
21463 "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") \
21464 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21466 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21467 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21468 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21470 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21472 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21474 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
21476 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
21478 "<vpp-if-name> | sw_if_index <id>") \
21479 _(sw_interface_tap_dump, "") \
21480 _(ip_table_add_del, \
21481 "table-id <n> [ipv6]\n") \
21482 _(ip_add_del_route, \
21483 "<addr>/<mask> via <addr> [table-id <n>]\n" \
21484 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
21485 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
21486 "[multipath] [count <n>]") \
21487 _(ip_mroute_add_del, \
21488 "<src> <grp>/<mask> [table-id <n>]\n" \
21489 "[<intfc> | sw_if_index <id>] [local] [del]") \
21490 _(mpls_table_add_del, \
21491 "table-id <n>\n") \
21492 _(mpls_route_add_del, \
21493 "<label> <eos> via <addr> [table-id <n>]\n" \
21494 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
21495 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
21496 "[multipath] [count <n>]") \
21497 _(mpls_ip_bind_unbind, \
21498 "<label> <addr/len>") \
21499 _(mpls_tunnel_add_del, \
21500 " via <addr> [table-id <n>]\n" \
21501 "sw_if_index <id>] [l2] [del]") \
21502 _(proxy_arp_add_del, \
21503 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
21504 _(proxy_arp_intfc_enable_disable, \
21505 "<intfc> | sw_if_index <id> enable | disable") \
21506 _(sw_interface_set_unnumbered, \
21507 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
21508 _(ip_neighbor_add_del, \
21509 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
21510 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
21511 _(reset_vrf, "vrf <id> [ipv6]") \
21512 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
21513 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
21514 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
21515 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
21516 "[outer_vlan_id_any][inner_vlan_id_any]") \
21517 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
21518 _(reset_fib, "vrf <n> [ipv6]") \
21519 _(dhcp_proxy_config, \
21520 "svr <v46-address> src <v46-address>\n" \
21521 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
21522 _(dhcp_proxy_set_vss, \
21523 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
21524 _(dhcp_proxy_dump, "ip6") \
21525 _(dhcp_client_config, \
21526 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
21527 _(set_ip_flow_hash, \
21528 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
21529 _(sw_interface_ip6_enable_disable, \
21530 "<intfc> | sw_if_index <id> enable | disable") \
21531 _(sw_interface_ip6_set_link_local_address, \
21532 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
21533 _(ip6nd_proxy_add_del, \
21534 "<intfc> | sw_if_index <id> <ip6-address>") \
21535 _(ip6nd_proxy_dump, "") \
21536 _(sw_interface_ip6nd_ra_prefix, \
21537 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
21538 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
21539 "[nolink] [isno]") \
21540 _(sw_interface_ip6nd_ra_config, \
21541 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
21542 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
21543 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
21544 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
21545 _(l2_patch_add_del, \
21546 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21547 "enable | disable") \
21548 _(sr_localsid_add_del, \
21549 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
21550 "fib-table <num> (end.psp) sw_if_index <num>") \
21551 _(classify_add_del_table, \
21552 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
21553 " [del] [del-chain] mask <mask-value>\n" \
21554 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
21555 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
21556 _(classify_add_del_session, \
21557 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
21558 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
21559 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
21560 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
21561 _(classify_set_interface_ip_table, \
21562 "<intfc> | sw_if_index <nn> table <nn>") \
21563 _(classify_set_interface_l2_tables, \
21564 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21565 " [other-table <nn>]") \
21566 _(get_node_index, "node <node-name") \
21567 _(add_node_next, "node <node-name> next <next-node-name>") \
21568 _(l2tpv3_create_tunnel, \
21569 "client_address <ip6-addr> our_address <ip6-addr>\n" \
21570 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
21571 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
21572 _(l2tpv3_set_tunnel_cookies, \
21573 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
21574 "[new_remote_cookie <nn>]\n") \
21575 _(l2tpv3_interface_enable_disable, \
21576 "<intfc> | sw_if_index <nn> enable | disable") \
21577 _(l2tpv3_set_lookup_key, \
21578 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
21579 _(sw_if_l2tpv3_tunnel_dump, "") \
21580 _(vxlan_add_del_tunnel, \
21581 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21582 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21583 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21584 _(geneve_add_del_tunnel, \
21585 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21586 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21587 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21588 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21589 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21590 _(gre_add_del_tunnel, \
21591 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
21592 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21593 _(l2_fib_clear_table, "") \
21594 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
21595 _(l2_interface_vlan_tag_rewrite, \
21596 "<intfc> | sw_if_index <nn> \n" \
21597 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
21598 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
21599 _(create_vhost_user_if, \
21600 "socket <filename> [server] [renumber <dev_instance>] " \
21601 "[mac <mac_address>]") \
21602 _(modify_vhost_user_if, \
21603 "<intfc> | sw_if_index <nn> socket <filename>\n" \
21604 "[server] [renumber <dev_instance>]") \
21605 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
21606 _(sw_interface_vhost_user_dump, "") \
21607 _(show_version, "") \
21608 _(vxlan_gpe_add_del_tunnel, \
21609 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
21610 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21611 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
21612 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
21613 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21614 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
21615 _(interface_name_renumber, \
21616 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
21617 _(input_acl_set_interface, \
21618 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21619 " [l2-table <nn>] [del]") \
21620 _(want_ip4_arp_events, "address <ip4-address> [del]") \
21621 _(want_ip6_nd_events, "address <ip6-address> [del]") \
21622 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
21623 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
21624 _(ip_dump, "ipv4 | ipv6") \
21625 _(ipsec_spd_add_del, "spd_id <n> [del]") \
21626 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
21628 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
21629 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
21630 " integ_alg <alg> integ_key <hex>") \
21631 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
21632 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
21633 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
21634 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
21635 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
21636 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
21637 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
21638 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
21639 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
21640 _(ipsec_sa_dump, "[sa_id <n>]") \
21641 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
21642 " <alg> <hex>\n") \
21643 _(ikev2_profile_add_del, "name <profile_name> [del]") \
21644 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
21645 "(auth_data 0x<data> | auth_data <data>)") \
21646 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
21647 "(id_data 0x<data> | id_data <data>) (local|remote)") \
21648 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
21649 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
21650 "(local|remote)") \
21651 _(ikev2_set_local_key, "file <absolute_file_path>") \
21652 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
21653 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
21654 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
21655 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
21656 _(ikev2_initiate_sa_init, "<profile_name>") \
21657 _(ikev2_initiate_del_ike_sa, "<ispi>") \
21658 _(ikev2_initiate_del_child_sa, "<ispi>") \
21659 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
21660 _(delete_loopback,"sw_if_index <nn>") \
21661 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
21662 _(map_add_domain, \
21663 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
21664 "ip6-src <ip6addr> " \
21665 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
21666 _(map_del_domain, "index <n>") \
21667 _(map_add_del_rule, \
21668 "index <n> psid <n> dst <ip6addr> [del]") \
21669 _(map_domain_dump, "") \
21670 _(map_rule_dump, "index <map-domain>") \
21671 _(want_interface_events, "enable|disable") \
21672 _(want_stats,"enable|disable") \
21673 _(get_first_msg_id, "client <name>") \
21674 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
21675 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
21676 "fib-id <nn> [ip4][ip6][default]") \
21677 _(get_node_graph, " ") \
21678 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
21679 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
21680 _(ioam_disable, "") \
21681 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
21682 " sw_if_index <sw_if_index> p <priority> " \
21683 "w <weight>] [del]") \
21684 _(one_add_del_locator, "locator-set <locator_name> " \
21685 "iface <intf> | sw_if_index <sw_if_index> " \
21686 "p <priority> w <weight> [del]") \
21687 _(one_add_del_local_eid,"vni <vni> eid " \
21688 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21689 "locator-set <locator_name> [del]" \
21690 "[key-id sha1|sha256 secret-key <secret-key>]")\
21691 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
21692 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
21693 _(one_enable_disable, "enable|disable") \
21694 _(one_map_register_enable_disable, "enable|disable") \
21695 _(one_map_register_fallback_threshold, "<value>") \
21696 _(one_rloc_probe_enable_disable, "enable|disable") \
21697 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21699 "rloc <locator> p <prio> " \
21700 "w <weight> [rloc <loc> ... ] " \
21701 "action <action> [del-all]") \
21702 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21704 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21705 _(one_use_petr, "ip-address> | disable") \
21706 _(one_map_request_mode, "src-dst|dst-only") \
21707 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21708 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21709 _(one_locator_set_dump, "[local | remote]") \
21710 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
21711 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21712 "[local] | [remote]") \
21713 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
21714 _(one_ndp_bd_get, "") \
21715 _(one_ndp_entries_get, "bd <bridge-domain>") \
21716 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
21717 _(one_l2_arp_bd_get, "") \
21718 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
21719 _(one_stats_enable_disable, "enable|disalbe") \
21720 _(show_one_stats_enable_disable, "") \
21721 _(one_eid_table_vni_dump, "") \
21722 _(one_eid_table_map_dump, "l2|l3") \
21723 _(one_map_resolver_dump, "") \
21724 _(one_map_server_dump, "") \
21725 _(one_adjacencies_get, "vni <vni>") \
21726 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
21727 _(show_one_rloc_probe_state, "") \
21728 _(show_one_map_register_state, "") \
21729 _(show_one_status, "") \
21730 _(one_stats_dump, "") \
21731 _(one_stats_flush, "") \
21732 _(one_get_map_request_itr_rlocs, "") \
21733 _(one_map_register_set_ttl, "<ttl>") \
21734 _(one_set_transport_protocol, "udp|api") \
21735 _(one_get_transport_protocol, "") \
21736 _(show_one_nsh_mapping, "") \
21737 _(show_one_pitr, "") \
21738 _(show_one_use_petr, "") \
21739 _(show_one_map_request_mode, "") \
21740 _(show_one_map_register_ttl, "") \
21741 _(show_one_map_register_fallback_threshold, "") \
21742 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
21743 " sw_if_index <sw_if_index> p <priority> " \
21744 "w <weight>] [del]") \
21745 _(lisp_add_del_locator, "locator-set <locator_name> " \
21746 "iface <intf> | sw_if_index <sw_if_index> " \
21747 "p <priority> w <weight> [del]") \
21748 _(lisp_add_del_local_eid,"vni <vni> eid " \
21749 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21750 "locator-set <locator_name> [del]" \
21751 "[key-id sha1|sha256 secret-key <secret-key>]") \
21752 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
21753 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
21754 _(lisp_enable_disable, "enable|disable") \
21755 _(lisp_map_register_enable_disable, "enable|disable") \
21756 _(lisp_rloc_probe_enable_disable, "enable|disable") \
21757 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21759 "rloc <locator> p <prio> " \
21760 "w <weight> [rloc <loc> ... ] " \
21761 "action <action> [del-all]") \
21762 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21764 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21765 _(lisp_use_petr, "<ip-address> | disable") \
21766 _(lisp_map_request_mode, "src-dst|dst-only") \
21767 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21768 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21769 _(lisp_locator_set_dump, "[local | remote]") \
21770 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
21771 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21772 "[local] | [remote]") \
21773 _(lisp_eid_table_vni_dump, "") \
21774 _(lisp_eid_table_map_dump, "l2|l3") \
21775 _(lisp_map_resolver_dump, "") \
21776 _(lisp_map_server_dump, "") \
21777 _(lisp_adjacencies_get, "vni <vni>") \
21778 _(gpe_fwd_entry_vnis_get, "") \
21779 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
21780 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
21781 "[table <table-id>]") \
21782 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
21783 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
21784 _(gpe_set_encap_mode, "lisp|vxlan") \
21785 _(gpe_get_encap_mode, "") \
21786 _(lisp_gpe_add_del_iface, "up|down") \
21787 _(lisp_gpe_enable_disable, "enable|disable") \
21788 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
21789 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
21790 _(show_lisp_rloc_probe_state, "") \
21791 _(show_lisp_map_register_state, "") \
21792 _(show_lisp_status, "") \
21793 _(lisp_get_map_request_itr_rlocs, "") \
21794 _(show_lisp_pitr, "") \
21795 _(show_lisp_use_petr, "") \
21796 _(show_lisp_map_request_mode, "") \
21797 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
21798 _(af_packet_delete, "name <host interface name>") \
21799 _(policer_add_del, "name <policer name> <params> [del]") \
21800 _(policer_dump, "[name <policer name>]") \
21801 _(policer_classify_set_interface, \
21802 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21803 " [l2-table <nn>] [del]") \
21804 _(policer_classify_dump, "type [ip4|ip6|l2]") \
21805 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
21806 "[master|slave]") \
21807 _(netmap_delete, "name <interface name>") \
21808 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
21809 _(mpls_fib_dump, "") \
21810 _(classify_table_ids, "") \
21811 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
21812 _(classify_table_info, "table_id <nn>") \
21813 _(classify_session_dump, "table_id <nn>") \
21814 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
21815 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
21816 "[template_interval <nn>] [udp_checksum]") \
21817 _(ipfix_exporter_dump, "") \
21818 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
21819 _(ipfix_classify_stream_dump, "") \
21820 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
21821 _(ipfix_classify_table_dump, "") \
21822 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
21823 _(sw_interface_span_dump, "[l2]") \
21824 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
21825 _(pg_create_interface, "if_id <nn>") \
21826 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
21827 _(pg_enable_disable, "[stream <id>] disable") \
21828 _(ip_source_and_port_range_check_add_del, \
21829 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
21830 _(ip_source_and_port_range_check_interface_add_del, \
21831 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
21832 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
21833 _(ipsec_gre_add_del_tunnel, \
21834 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
21835 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
21836 _(delete_subif,"<intfc> | sw_if_index <nn>") \
21837 _(l2_interface_pbb_tag_rewrite, \
21838 "<intfc> | sw_if_index <nn> \n" \
21839 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
21840 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
21841 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
21842 _(flow_classify_set_interface, \
21843 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
21844 _(flow_classify_dump, "type [ip4|ip6]") \
21845 _(ip_fib_dump, "") \
21846 _(ip_mfib_dump, "") \
21847 _(ip6_fib_dump, "") \
21848 _(ip6_mfib_dump, "") \
21849 _(feature_enable_disable, "arc_name <arc_name> " \
21850 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
21851 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
21853 _(l2_xconnect_dump, "") \
21854 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
21855 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
21856 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
21857 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
21858 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
21859 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
21860 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
21861 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
21862 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
21863 _(memfd_segment_create,"size <nnn>") \
21864 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
21865 _(dns_enable_disable, "[enable][disable]") \
21866 _(dns_name_server_add_del, "<ip-address> [del]") \
21867 _(dns_resolve_name, "<hostname>")
21869 /* List of command functions, CLI names map directly to functions */
21870 #define foreach_cli_function \
21871 _(comment, "usage: comment <ignore-rest-of-line>") \
21872 _(dump_interface_table, "usage: dump_interface_table") \
21873 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
21874 _(dump_ipv4_table, "usage: dump_ipv4_table") \
21875 _(dump_ipv6_table, "usage: dump_ipv6_table") \
21876 _(dump_stats_table, "usage: dump_stats_table") \
21877 _(dump_macro_table, "usage: dump_macro_table ") \
21878 _(dump_node_table, "usage: dump_node_table") \
21879 _(dump_msg_api_table, "usage: dump_msg_api_table") \
21880 _(get_msg_id, "usage: get_msg_id name_and_crc") \
21881 _(echo, "usage: echo <message>") \
21882 _(exec, "usage: exec <vpe-debug-CLI-command>") \
21883 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
21884 _(help, "usage: help") \
21885 _(q, "usage: quit") \
21886 _(quit, "usage: quit") \
21887 _(search_node_table, "usage: search_node_table <name>...") \
21888 _(set, "usage: set <variable-name> <value>") \
21889 _(script, "usage: script <file-name>") \
21890 _(unset, "usage: unset <variable-name>")
21892 static void vl_api_##n##_t_handler_uni \
21893 (vl_api_##n##_t * mp) \
21895 vat_main_t * vam = &vat_main; \
21896 if (vam->json_output) { \
21897 vl_api_##n##_t_handler_json(mp); \
21899 vl_api_##n##_t_handler(mp); \
21902 foreach_vpe_api_reply_msg;
21903 #if VPP_API_TEST_BUILTIN == 0
21904 foreach_standalone_reply_msg;
21909 vat_api_hookup (vat_main_t * vam)
21912 vl_msg_api_set_handlers(VL_API_##N, #n, \
21913 vl_api_##n##_t_handler_uni, \
21915 vl_api_##n##_t_endian, \
21916 vl_api_##n##_t_print, \
21917 sizeof(vl_api_##n##_t), 1);
21918 foreach_vpe_api_reply_msg;
21919 #if VPP_API_TEST_BUILTIN == 0
21920 foreach_standalone_reply_msg;
21924 #if (VPP_API_TEST_BUILTIN==0)
21925 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
21927 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
21929 vam->function_by_name = hash_create_string (0, sizeof (uword));
21931 vam->help_by_name = hash_create_string (0, sizeof (uword));
21934 /* API messages we can send */
21935 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
21936 foreach_vpe_api_msg;
21940 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21941 foreach_vpe_api_msg;
21944 /* CLI functions */
21945 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
21946 foreach_cli_function;
21950 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21951 foreach_cli_function;
21955 #if VPP_API_TEST_BUILTIN
21956 static clib_error_t *
21957 vat_api_hookup_shim (vlib_main_t * vm)
21959 vat_api_hookup (&vat_main);
21963 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
21967 * fd.io coding-style-patch-verification: ON
21970 * eval: (c-set-style "gnu")