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");
2183 static void vl_api_ip_address_details_t_handler
2184 (vl_api_ip_address_details_t * mp)
2186 vat_main_t *vam = &vat_main;
2187 static ip_address_details_t empty_ip_address_details = { {0} };
2188 ip_address_details_t *address = NULL;
2189 ip_details_t *current_ip_details = NULL;
2190 ip_details_t *details = NULL;
2192 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2194 if (!details || vam->current_sw_if_index >= vec_len (details)
2195 || !details[vam->current_sw_if_index].present)
2197 errmsg ("ip address details arrived but not stored");
2198 errmsg ("ip_dump should be called first");
2202 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2204 #define addresses (current_ip_details->addr)
2206 vec_validate_init_empty (addresses, vec_len (addresses),
2207 empty_ip_address_details);
2209 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2211 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2212 address->prefix_length = mp->prefix_length;
2216 static void vl_api_ip_address_details_t_handler_json
2217 (vl_api_ip_address_details_t * mp)
2219 vat_main_t *vam = &vat_main;
2220 vat_json_node_t *node = NULL;
2221 struct in6_addr ip6;
2224 if (VAT_JSON_ARRAY != vam->json_tree.type)
2226 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2227 vat_json_init_array (&vam->json_tree);
2229 node = vat_json_array_add (&vam->json_tree);
2231 vat_json_init_object (node);
2234 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2235 vat_json_object_add_ip6 (node, "ip", ip6);
2239 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2240 vat_json_object_add_ip4 (node, "ip", ip4);
2242 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2246 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2248 vat_main_t *vam = &vat_main;
2249 static ip_details_t empty_ip_details = { 0 };
2250 ip_details_t *ip = NULL;
2251 u32 sw_if_index = ~0;
2253 sw_if_index = ntohl (mp->sw_if_index);
2255 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2256 sw_if_index, empty_ip_details);
2258 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2265 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2267 vat_main_t *vam = &vat_main;
2269 if (VAT_JSON_ARRAY != vam->json_tree.type)
2271 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2272 vat_json_init_array (&vam->json_tree);
2274 vat_json_array_add_uint (&vam->json_tree,
2275 clib_net_to_host_u32 (mp->sw_if_index));
2278 static void vl_api_map_domain_details_t_handler_json
2279 (vl_api_map_domain_details_t * mp)
2281 vat_json_node_t *node = NULL;
2282 vat_main_t *vam = &vat_main;
2283 struct in6_addr ip6;
2286 if (VAT_JSON_ARRAY != vam->json_tree.type)
2288 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2289 vat_json_init_array (&vam->json_tree);
2292 node = vat_json_array_add (&vam->json_tree);
2293 vat_json_init_object (node);
2295 vat_json_object_add_uint (node, "domain_index",
2296 clib_net_to_host_u32 (mp->domain_index));
2297 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2298 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2299 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2300 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2301 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2302 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2303 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2304 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2305 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2306 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2307 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2308 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2309 vat_json_object_add_uint (node, "flags", mp->flags);
2310 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2311 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2314 static void vl_api_map_domain_details_t_handler
2315 (vl_api_map_domain_details_t * mp)
2317 vat_main_t *vam = &vat_main;
2319 if (mp->is_translation)
2322 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2323 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2324 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2325 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2326 clib_net_to_host_u32 (mp->domain_index));
2331 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2332 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2333 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2334 format_ip6_address, mp->ip6_src,
2335 clib_net_to_host_u32 (mp->domain_index));
2337 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2338 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2339 mp->is_translation ? "map-t" : "");
2342 static void vl_api_map_rule_details_t_handler_json
2343 (vl_api_map_rule_details_t * mp)
2345 struct in6_addr ip6;
2346 vat_json_node_t *node = NULL;
2347 vat_main_t *vam = &vat_main;
2349 if (VAT_JSON_ARRAY != vam->json_tree.type)
2351 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2352 vat_json_init_array (&vam->json_tree);
2355 node = vat_json_array_add (&vam->json_tree);
2356 vat_json_init_object (node);
2358 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2359 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2360 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2364 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2366 vat_main_t *vam = &vat_main;
2367 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2368 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2372 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2374 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2375 "router_addr %U host_mac %U",
2376 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2377 format_ip4_address, &mp->host_address,
2378 format_ip4_address, &mp->router_address,
2379 format_ethernet_address, mp->host_mac);
2382 static void vl_api_dhcp_compl_event_t_handler_json
2383 (vl_api_dhcp_compl_event_t * mp)
2385 /* JSON output not supported */
2389 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2392 vat_main_t *vam = &vat_main;
2393 static u64 default_counter = 0;
2395 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2397 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2398 sw_if_index, default_counter);
2399 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2403 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2404 interface_counter_t counter)
2406 vat_main_t *vam = &vat_main;
2407 static interface_counter_t default_counter = { 0, };
2409 vec_validate_init_empty (vam->combined_interface_counters,
2410 vnet_counter_type, NULL);
2411 vec_validate_init_empty (vam->combined_interface_counters
2412 [vnet_counter_type], sw_if_index, default_counter);
2413 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2416 static void vl_api_vnet_interface_simple_counters_t_handler
2417 (vl_api_vnet_interface_simple_counters_t * mp)
2422 static void vl_api_vnet_interface_combined_counters_t_handler
2423 (vl_api_vnet_interface_combined_counters_t * mp)
2428 static void vl_api_vnet_interface_simple_counters_t_handler_json
2429 (vl_api_vnet_interface_simple_counters_t * mp)
2434 u32 first_sw_if_index;
2437 count = ntohl (mp->count);
2438 first_sw_if_index = ntohl (mp->first_sw_if_index);
2440 v_packets = (u64 *) & mp->data;
2441 for (i = 0; i < count; i++)
2443 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2444 set_simple_interface_counter (mp->vnet_counter_type,
2445 first_sw_if_index + i, packets);
2450 static void vl_api_vnet_interface_combined_counters_t_handler_json
2451 (vl_api_vnet_interface_combined_counters_t * mp)
2453 interface_counter_t counter;
2455 u32 first_sw_if_index;
2459 count = ntohl (mp->count);
2460 first_sw_if_index = ntohl (mp->first_sw_if_index);
2462 v = (vlib_counter_t *) & mp->data;
2463 for (i = 0; i < count; i++)
2466 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2468 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2469 set_combined_interface_counter (mp->vnet_counter_type,
2470 first_sw_if_index + i, counter);
2476 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2478 vat_main_t *vam = &vat_main;
2481 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2483 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2492 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2494 vat_main_t *vam = &vat_main;
2497 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2499 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2507 static void vl_api_vnet_ip4_fib_counters_t_handler
2508 (vl_api_vnet_ip4_fib_counters_t * mp)
2513 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2514 (vl_api_vnet_ip4_fib_counters_t * mp)
2516 vat_main_t *vam = &vat_main;
2517 vl_api_ip4_fib_counter_t *v;
2518 ip4_fib_counter_t *counter;
2525 vrf_id = ntohl (mp->vrf_id);
2526 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2527 if (~0 == vrf_index)
2529 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2530 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2531 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2532 vec_validate (vam->ip4_fib_counters, vrf_index);
2533 vam->ip4_fib_counters[vrf_index] = NULL;
2536 vec_free (vam->ip4_fib_counters[vrf_index]);
2537 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2538 count = ntohl (mp->count);
2539 for (i = 0; i < count; i++)
2541 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2542 counter = &vam->ip4_fib_counters[vrf_index][i];
2543 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2544 counter->address = ip4;
2545 counter->address_length = v->address_length;
2546 counter->packets = clib_net_to_host_u64 (v->packets);
2547 counter->bytes = clib_net_to_host_u64 (v->bytes);
2552 static void vl_api_vnet_ip4_nbr_counters_t_handler
2553 (vl_api_vnet_ip4_nbr_counters_t * mp)
2558 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2559 (vl_api_vnet_ip4_nbr_counters_t * mp)
2561 vat_main_t *vam = &vat_main;
2562 vl_api_ip4_nbr_counter_t *v;
2563 ip4_nbr_counter_t *counter;
2568 sw_if_index = ntohl (mp->sw_if_index);
2569 count = ntohl (mp->count);
2570 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2573 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2575 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2576 for (i = 0; i < count; i++)
2578 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2579 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2580 counter->address.s_addr = v->address;
2581 counter->packets = clib_net_to_host_u64 (v->packets);
2582 counter->bytes = clib_net_to_host_u64 (v->bytes);
2583 counter->linkt = v->link_type;
2588 static void vl_api_vnet_ip6_fib_counters_t_handler
2589 (vl_api_vnet_ip6_fib_counters_t * mp)
2594 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2595 (vl_api_vnet_ip6_fib_counters_t * mp)
2597 vat_main_t *vam = &vat_main;
2598 vl_api_ip6_fib_counter_t *v;
2599 ip6_fib_counter_t *counter;
2600 struct in6_addr ip6;
2606 vrf_id = ntohl (mp->vrf_id);
2607 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2608 if (~0 == vrf_index)
2610 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2611 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2612 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2613 vec_validate (vam->ip6_fib_counters, vrf_index);
2614 vam->ip6_fib_counters[vrf_index] = NULL;
2617 vec_free (vam->ip6_fib_counters[vrf_index]);
2618 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2619 count = ntohl (mp->count);
2620 for (i = 0; i < count; i++)
2622 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2623 counter = &vam->ip6_fib_counters[vrf_index][i];
2624 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2625 counter->address = ip6;
2626 counter->address_length = v->address_length;
2627 counter->packets = clib_net_to_host_u64 (v->packets);
2628 counter->bytes = clib_net_to_host_u64 (v->bytes);
2633 static void vl_api_vnet_ip6_nbr_counters_t_handler
2634 (vl_api_vnet_ip6_nbr_counters_t * mp)
2639 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2640 (vl_api_vnet_ip6_nbr_counters_t * mp)
2642 vat_main_t *vam = &vat_main;
2643 vl_api_ip6_nbr_counter_t *v;
2644 ip6_nbr_counter_t *counter;
2645 struct in6_addr ip6;
2650 sw_if_index = ntohl (mp->sw_if_index);
2651 count = ntohl (mp->count);
2652 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2655 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2657 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2658 for (i = 0; i < count; i++)
2660 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2661 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2662 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2663 counter->address = ip6;
2664 counter->packets = clib_net_to_host_u64 (v->packets);
2665 counter->bytes = clib_net_to_host_u64 (v->bytes);
2670 static void vl_api_get_first_msg_id_reply_t_handler
2671 (vl_api_get_first_msg_id_reply_t * mp)
2673 vat_main_t *vam = &vat_main;
2674 i32 retval = ntohl (mp->retval);
2676 if (vam->async_mode)
2678 vam->async_errors += (retval < 0);
2682 vam->retval = retval;
2683 vam->result_ready = 1;
2687 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2691 static void vl_api_get_first_msg_id_reply_t_handler_json
2692 (vl_api_get_first_msg_id_reply_t * mp)
2694 vat_main_t *vam = &vat_main;
2695 vat_json_node_t node;
2697 vat_json_init_object (&node);
2698 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2699 vat_json_object_add_uint (&node, "first_msg_id",
2700 (uint) ntohs (mp->first_msg_id));
2702 vat_json_print (vam->ofp, &node);
2703 vat_json_free (&node);
2705 vam->retval = ntohl (mp->retval);
2706 vam->result_ready = 1;
2709 static void vl_api_get_node_graph_reply_t_handler
2710 (vl_api_get_node_graph_reply_t * mp)
2712 vat_main_t *vam = &vat_main;
2713 api_main_t *am = &api_main;
2714 i32 retval = ntohl (mp->retval);
2715 u8 *pvt_copy, *reply;
2720 if (vam->async_mode)
2722 vam->async_errors += (retval < 0);
2726 vam->retval = retval;
2727 vam->result_ready = 1;
2730 /* "Should never happen..." */
2734 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2735 pvt_copy = vec_dup (reply);
2737 /* Toss the shared-memory original... */
2738 pthread_mutex_lock (&am->vlib_rp->mutex);
2739 oldheap = svm_push_data_heap (am->vlib_rp);
2743 svm_pop_heap (oldheap);
2744 pthread_mutex_unlock (&am->vlib_rp->mutex);
2746 if (vam->graph_nodes)
2748 hash_free (vam->graph_node_index_by_name);
2750 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2752 node = vam->graph_nodes[i];
2753 vec_free (node->name);
2754 vec_free (node->next_nodes);
2757 vec_free (vam->graph_nodes);
2760 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2761 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2762 vec_free (pvt_copy);
2764 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2766 node = vam->graph_nodes[i];
2767 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2771 static void vl_api_get_node_graph_reply_t_handler_json
2772 (vl_api_get_node_graph_reply_t * mp)
2774 vat_main_t *vam = &vat_main;
2775 api_main_t *am = &api_main;
2777 vat_json_node_t node;
2780 /* $$$$ make this real? */
2781 vat_json_init_object (&node);
2782 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2783 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2785 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2787 /* Toss the shared-memory original... */
2788 pthread_mutex_lock (&am->vlib_rp->mutex);
2789 oldheap = svm_push_data_heap (am->vlib_rp);
2793 svm_pop_heap (oldheap);
2794 pthread_mutex_unlock (&am->vlib_rp->mutex);
2796 vat_json_print (vam->ofp, &node);
2797 vat_json_free (&node);
2799 vam->retval = ntohl (mp->retval);
2800 vam->result_ready = 1;
2804 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2806 vat_main_t *vam = &vat_main;
2811 s = format (s, "%=16d%=16d%=16d",
2812 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2816 s = format (s, "%=16U%=16d%=16d",
2817 mp->is_ipv6 ? format_ip6_address :
2819 mp->ip_address, mp->priority, mp->weight);
2822 print (vam->ofp, "%v", s);
2827 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2829 vat_main_t *vam = &vat_main;
2830 vat_json_node_t *node = NULL;
2831 struct in6_addr ip6;
2834 if (VAT_JSON_ARRAY != vam->json_tree.type)
2836 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2837 vat_json_init_array (&vam->json_tree);
2839 node = vat_json_array_add (&vam->json_tree);
2840 vat_json_init_object (node);
2842 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2843 vat_json_object_add_uint (node, "priority", mp->priority);
2844 vat_json_object_add_uint (node, "weight", mp->weight);
2847 vat_json_object_add_uint (node, "sw_if_index",
2848 clib_net_to_host_u32 (mp->sw_if_index));
2853 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2854 vat_json_object_add_ip6 (node, "address", ip6);
2858 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2859 vat_json_object_add_ip4 (node, "address", ip4);
2865 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2868 vat_main_t *vam = &vat_main;
2871 ls_name = format (0, "%s", mp->ls_name);
2873 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2879 vl_api_one_locator_set_details_t_handler_json
2880 (vl_api_one_locator_set_details_t * mp)
2882 vat_main_t *vam = &vat_main;
2883 vat_json_node_t *node = 0;
2886 ls_name = format (0, "%s", mp->ls_name);
2887 vec_add1 (ls_name, 0);
2889 if (VAT_JSON_ARRAY != vam->json_tree.type)
2891 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2892 vat_json_init_array (&vam->json_tree);
2894 node = vat_json_array_add (&vam->json_tree);
2896 vat_json_init_object (node);
2897 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2898 vat_json_object_add_uint (node, "ls_index",
2899 clib_net_to_host_u32 (mp->ls_index));
2907 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2910 unformat_nsh_address (unformat_input_t * input, va_list * args)
2912 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2913 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2917 format_nsh_address_vat (u8 * s, va_list * args)
2919 nsh_t *a = va_arg (*args, nsh_t *);
2920 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2924 format_lisp_flat_eid (u8 * s, va_list * args)
2926 u32 type = va_arg (*args, u32);
2927 u8 *eid = va_arg (*args, u8 *);
2928 u32 eid_len = va_arg (*args, u32);
2933 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2935 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2937 return format (s, "%U", format_ethernet_address, eid);
2939 return format (s, "%U", format_nsh_address_vat, eid);
2945 format_lisp_eid_vat (u8 * s, va_list * args)
2947 u32 type = va_arg (*args, u32);
2948 u8 *eid = va_arg (*args, u8 *);
2949 u32 eid_len = va_arg (*args, u32);
2950 u8 *seid = va_arg (*args, u8 *);
2951 u32 seid_len = va_arg (*args, u32);
2952 u32 is_src_dst = va_arg (*args, u32);
2955 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2957 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2963 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2965 vat_main_t *vam = &vat_main;
2966 u8 *s = 0, *eid = 0;
2968 if (~0 == mp->locator_set_index)
2969 s = format (0, "action: %d", mp->action);
2971 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2973 eid = format (0, "%U", format_lisp_eid_vat,
2977 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2980 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2981 clib_net_to_host_u32 (mp->vni),
2983 mp->is_local ? "local" : "remote",
2984 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2985 clib_net_to_host_u16 (mp->key_id), mp->key);
2992 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2995 vat_main_t *vam = &vat_main;
2996 vat_json_node_t *node = 0;
2999 if (VAT_JSON_ARRAY != vam->json_tree.type)
3001 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3002 vat_json_init_array (&vam->json_tree);
3004 node = vat_json_array_add (&vam->json_tree);
3006 vat_json_init_object (node);
3007 if (~0 == mp->locator_set_index)
3008 vat_json_object_add_uint (node, "action", mp->action);
3010 vat_json_object_add_uint (node, "locator_set_index",
3011 clib_net_to_host_u32 (mp->locator_set_index));
3013 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3014 if (mp->eid_type == 3)
3016 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3017 vat_json_init_object (nsh_json);
3018 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3019 vat_json_object_add_uint (nsh_json, "spi",
3020 clib_net_to_host_u32 (nsh->spi));
3021 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3025 eid = format (0, "%U", format_lisp_eid_vat,
3029 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3031 vat_json_object_add_string_copy (node, "eid", eid);
3034 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3035 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3036 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3040 vat_json_object_add_uint (node, "key_id",
3041 clib_net_to_host_u16 (mp->key_id));
3042 vat_json_object_add_string_copy (node, "key", mp->key);
3047 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3049 vat_main_t *vam = &vat_main;
3050 u8 *seid = 0, *deid = 0;
3051 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3053 deid = format (0, "%U", format_lisp_eid_vat,
3054 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3056 seid = format (0, "%U", format_lisp_eid_vat,
3057 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3063 format_ip_address_fcn = format_ip4_address;
3065 format_ip_address_fcn = format_ip6_address;
3068 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3069 clib_net_to_host_u32 (mp->vni),
3071 format_ip_address_fcn, mp->lloc,
3072 format_ip_address_fcn, mp->rloc,
3073 clib_net_to_host_u32 (mp->pkt_count),
3074 clib_net_to_host_u32 (mp->bytes));
3081 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3083 struct in6_addr ip6;
3085 vat_main_t *vam = &vat_main;
3086 vat_json_node_t *node = 0;
3087 u8 *deid = 0, *seid = 0;
3089 if (VAT_JSON_ARRAY != vam->json_tree.type)
3091 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3092 vat_json_init_array (&vam->json_tree);
3094 node = vat_json_array_add (&vam->json_tree);
3096 vat_json_init_object (node);
3097 deid = format (0, "%U", format_lisp_eid_vat,
3098 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3100 seid = format (0, "%U", format_lisp_eid_vat,
3101 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3106 vat_json_object_add_string_copy (node, "seid", seid);
3107 vat_json_object_add_string_copy (node, "deid", deid);
3108 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3112 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3113 vat_json_object_add_ip4 (node, "lloc", ip4);
3114 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3115 vat_json_object_add_ip4 (node, "rloc", ip4);
3119 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3120 vat_json_object_add_ip6 (node, "lloc", ip6);
3121 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3122 vat_json_object_add_ip6 (node, "rloc", ip6);
3124 vat_json_object_add_uint (node, "pkt_count",
3125 clib_net_to_host_u32 (mp->pkt_count));
3126 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3133 vl_api_one_eid_table_map_details_t_handler
3134 (vl_api_one_eid_table_map_details_t * mp)
3136 vat_main_t *vam = &vat_main;
3138 u8 *line = format (0, "%=10d%=10d",
3139 clib_net_to_host_u32 (mp->vni),
3140 clib_net_to_host_u32 (mp->dp_table));
3141 print (vam->ofp, "%v", line);
3146 vl_api_one_eid_table_map_details_t_handler_json
3147 (vl_api_one_eid_table_map_details_t * mp)
3149 vat_main_t *vam = &vat_main;
3150 vat_json_node_t *node = NULL;
3152 if (VAT_JSON_ARRAY != vam->json_tree.type)
3154 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3155 vat_json_init_array (&vam->json_tree);
3157 node = vat_json_array_add (&vam->json_tree);
3158 vat_json_init_object (node);
3159 vat_json_object_add_uint (node, "dp_table",
3160 clib_net_to_host_u32 (mp->dp_table));
3161 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3165 vl_api_one_eid_table_vni_details_t_handler
3166 (vl_api_one_eid_table_vni_details_t * mp)
3168 vat_main_t *vam = &vat_main;
3170 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3171 print (vam->ofp, "%v", line);
3176 vl_api_one_eid_table_vni_details_t_handler_json
3177 (vl_api_one_eid_table_vni_details_t * mp)
3179 vat_main_t *vam = &vat_main;
3180 vat_json_node_t *node = NULL;
3182 if (VAT_JSON_ARRAY != vam->json_tree.type)
3184 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3185 vat_json_init_array (&vam->json_tree);
3187 node = vat_json_array_add (&vam->json_tree);
3188 vat_json_init_object (node);
3189 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3193 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3194 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3196 vat_main_t *vam = &vat_main;
3197 int retval = clib_net_to_host_u32 (mp->retval);
3199 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3200 print (vam->ofp, "fallback threshold value: %d", mp->value);
3202 vam->retval = retval;
3203 vam->result_ready = 1;
3207 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3208 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3210 vat_main_t *vam = &vat_main;
3211 vat_json_node_t _node, *node = &_node;
3212 int retval = clib_net_to_host_u32 (mp->retval);
3214 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3215 vat_json_init_object (node);
3216 vat_json_object_add_uint (node, "value", mp->value);
3218 vat_json_print (vam->ofp, node);
3219 vat_json_free (node);
3221 vam->retval = retval;
3222 vam->result_ready = 1;
3226 vl_api_show_one_map_register_state_reply_t_handler
3227 (vl_api_show_one_map_register_state_reply_t * mp)
3229 vat_main_t *vam = &vat_main;
3230 int retval = clib_net_to_host_u32 (mp->retval);
3232 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3234 vam->retval = retval;
3235 vam->result_ready = 1;
3239 vl_api_show_one_map_register_state_reply_t_handler_json
3240 (vl_api_show_one_map_register_state_reply_t * mp)
3242 vat_main_t *vam = &vat_main;
3243 vat_json_node_t _node, *node = &_node;
3244 int retval = clib_net_to_host_u32 (mp->retval);
3246 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3248 vat_json_init_object (node);
3249 vat_json_object_add_string_copy (node, "state", s);
3251 vat_json_print (vam->ofp, node);
3252 vat_json_free (node);
3254 vam->retval = retval;
3255 vam->result_ready = 1;
3260 vl_api_show_one_rloc_probe_state_reply_t_handler
3261 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3263 vat_main_t *vam = &vat_main;
3264 int retval = clib_net_to_host_u32 (mp->retval);
3269 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3271 vam->retval = retval;
3272 vam->result_ready = 1;
3276 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3277 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3279 vat_main_t *vam = &vat_main;
3280 vat_json_node_t _node, *node = &_node;
3281 int retval = clib_net_to_host_u32 (mp->retval);
3283 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3284 vat_json_init_object (node);
3285 vat_json_object_add_string_copy (node, "state", s);
3287 vat_json_print (vam->ofp, node);
3288 vat_json_free (node);
3290 vam->retval = retval;
3291 vam->result_ready = 1;
3296 vl_api_show_one_stats_enable_disable_reply_t_handler
3297 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3299 vat_main_t *vam = &vat_main;
3300 int retval = clib_net_to_host_u32 (mp->retval);
3305 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3307 vam->retval = retval;
3308 vam->result_ready = 1;
3312 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3313 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3315 vat_main_t *vam = &vat_main;
3316 vat_json_node_t _node, *node = &_node;
3317 int retval = clib_net_to_host_u32 (mp->retval);
3319 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3320 vat_json_init_object (node);
3321 vat_json_object_add_string_copy (node, "state", s);
3323 vat_json_print (vam->ofp, node);
3324 vat_json_free (node);
3326 vam->retval = retval;
3327 vam->result_ready = 1;
3332 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3334 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3335 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3336 e->vni = clib_net_to_host_u32 (e->vni);
3340 gpe_fwd_entries_get_reply_t_net_to_host
3341 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3345 mp->count = clib_net_to_host_u32 (mp->count);
3346 for (i = 0; i < mp->count; i++)
3348 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3353 format_gpe_encap_mode (u8 * s, va_list * args)
3355 u32 mode = va_arg (*args, u32);
3360 return format (s, "lisp");
3362 return format (s, "vxlan");
3368 vl_api_gpe_get_encap_mode_reply_t_handler
3369 (vl_api_gpe_get_encap_mode_reply_t * mp)
3371 vat_main_t *vam = &vat_main;
3373 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3374 vam->retval = ntohl (mp->retval);
3375 vam->result_ready = 1;
3379 vl_api_gpe_get_encap_mode_reply_t_handler_json
3380 (vl_api_gpe_get_encap_mode_reply_t * mp)
3382 vat_main_t *vam = &vat_main;
3383 vat_json_node_t node;
3385 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3386 vec_add1 (encap_mode, 0);
3388 vat_json_init_object (&node);
3389 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3391 vec_free (encap_mode);
3392 vat_json_print (vam->ofp, &node);
3393 vat_json_free (&node);
3395 vam->retval = ntohl (mp->retval);
3396 vam->result_ready = 1;
3400 vl_api_gpe_fwd_entry_path_details_t_handler
3401 (vl_api_gpe_fwd_entry_path_details_t * mp)
3403 vat_main_t *vam = &vat_main;
3404 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3406 if (mp->lcl_loc.is_ip4)
3407 format_ip_address_fcn = format_ip4_address;
3409 format_ip_address_fcn = format_ip6_address;
3411 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3412 format_ip_address_fcn, &mp->lcl_loc,
3413 format_ip_address_fcn, &mp->rmt_loc);
3417 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3419 struct in6_addr ip6;
3424 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3425 vat_json_object_add_ip4 (n, "address", ip4);
3429 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3430 vat_json_object_add_ip6 (n, "address", ip6);
3432 vat_json_object_add_uint (n, "weight", loc->weight);
3436 vl_api_gpe_fwd_entry_path_details_t_handler_json
3437 (vl_api_gpe_fwd_entry_path_details_t * mp)
3439 vat_main_t *vam = &vat_main;
3440 vat_json_node_t *node = NULL;
3441 vat_json_node_t *loc_node;
3443 if (VAT_JSON_ARRAY != vam->json_tree.type)
3445 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3446 vat_json_init_array (&vam->json_tree);
3448 node = vat_json_array_add (&vam->json_tree);
3449 vat_json_init_object (node);
3451 loc_node = vat_json_object_add (node, "local_locator");
3452 vat_json_init_object (loc_node);
3453 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3455 loc_node = vat_json_object_add (node, "remote_locator");
3456 vat_json_init_object (loc_node);
3457 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3461 vl_api_gpe_fwd_entries_get_reply_t_handler
3462 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3464 vat_main_t *vam = &vat_main;
3466 int retval = clib_net_to_host_u32 (mp->retval);
3467 vl_api_gpe_fwd_entry_t *e;
3472 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3474 for (i = 0; i < mp->count; i++)
3476 e = &mp->entries[i];
3477 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3478 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3479 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3483 vam->retval = retval;
3484 vam->result_ready = 1;
3488 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3489 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3492 vat_main_t *vam = &vat_main;
3493 vat_json_node_t *e = 0, root;
3495 int retval = clib_net_to_host_u32 (mp->retval);
3496 vl_api_gpe_fwd_entry_t *fwd;
3501 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3502 vat_json_init_array (&root);
3504 for (i = 0; i < mp->count; i++)
3506 e = vat_json_array_add (&root);
3507 fwd = &mp->entries[i];
3509 vat_json_init_object (e);
3510 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3511 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3512 vat_json_object_add_int (e, "vni", fwd->vni);
3513 vat_json_object_add_int (e, "action", fwd->action);
3515 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3516 fwd->leid_prefix_len);
3518 vat_json_object_add_string_copy (e, "leid", s);
3521 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3522 fwd->reid_prefix_len);
3524 vat_json_object_add_string_copy (e, "reid", s);
3528 vat_json_print (vam->ofp, &root);
3529 vat_json_free (&root);
3532 vam->retval = retval;
3533 vam->result_ready = 1;
3537 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3538 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3540 vat_main_t *vam = &vat_main;
3542 int retval = clib_net_to_host_u32 (mp->retval);
3543 vl_api_gpe_native_fwd_rpath_t *r;
3548 n = clib_net_to_host_u32 (mp->count);
3550 for (i = 0; i < n; i++)
3552 r = &mp->entries[i];
3553 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3554 clib_net_to_host_u32 (r->fib_index),
3555 clib_net_to_host_u32 (r->nh_sw_if_index),
3556 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3560 vam->retval = retval;
3561 vam->result_ready = 1;
3565 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3566 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3568 vat_main_t *vam = &vat_main;
3569 vat_json_node_t root, *e;
3571 int retval = clib_net_to_host_u32 (mp->retval);
3572 vl_api_gpe_native_fwd_rpath_t *r;
3578 n = clib_net_to_host_u32 (mp->count);
3579 vat_json_init_array (&root);
3581 for (i = 0; i < n; i++)
3583 e = vat_json_array_add (&root);
3584 vat_json_init_object (e);
3585 r = &mp->entries[i];
3587 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3590 vat_json_object_add_string_copy (e, "ip4", s);
3593 vat_json_object_add_uint (e, "fib_index",
3594 clib_net_to_host_u32 (r->fib_index));
3595 vat_json_object_add_uint (e, "nh_sw_if_index",
3596 clib_net_to_host_u32 (r->nh_sw_if_index));
3599 vat_json_print (vam->ofp, &root);
3600 vat_json_free (&root);
3603 vam->retval = retval;
3604 vam->result_ready = 1;
3608 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3609 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3611 vat_main_t *vam = &vat_main;
3613 int retval = clib_net_to_host_u32 (mp->retval);
3618 n = clib_net_to_host_u32 (mp->count);
3620 for (i = 0; i < n; i++)
3621 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3624 vam->retval = retval;
3625 vam->result_ready = 1;
3629 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3630 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3632 vat_main_t *vam = &vat_main;
3633 vat_json_node_t root;
3635 int retval = clib_net_to_host_u32 (mp->retval);
3640 n = clib_net_to_host_u32 (mp->count);
3641 vat_json_init_array (&root);
3643 for (i = 0; i < n; i++)
3644 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3646 vat_json_print (vam->ofp, &root);
3647 vat_json_free (&root);
3650 vam->retval = retval;
3651 vam->result_ready = 1;
3655 vl_api_one_ndp_entries_get_reply_t_handler
3656 (vl_api_one_ndp_entries_get_reply_t * mp)
3658 vat_main_t *vam = &vat_main;
3660 int retval = clib_net_to_host_u32 (mp->retval);
3665 n = clib_net_to_host_u32 (mp->count);
3667 for (i = 0; i < n; i++)
3668 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3669 format_ethernet_address, mp->entries[i].mac);
3672 vam->retval = retval;
3673 vam->result_ready = 1;
3677 vl_api_one_ndp_entries_get_reply_t_handler_json
3678 (vl_api_one_ndp_entries_get_reply_t * mp)
3681 vat_main_t *vam = &vat_main;
3682 vat_json_node_t *e = 0, root;
3684 int retval = clib_net_to_host_u32 (mp->retval);
3685 vl_api_one_ndp_entry_t *arp_entry;
3690 n = clib_net_to_host_u32 (mp->count);
3691 vat_json_init_array (&root);
3693 for (i = 0; i < n; i++)
3695 e = vat_json_array_add (&root);
3696 arp_entry = &mp->entries[i];
3698 vat_json_init_object (e);
3699 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3702 vat_json_object_add_string_copy (e, "mac", s);
3705 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3707 vat_json_object_add_string_copy (e, "ip6", s);
3711 vat_json_print (vam->ofp, &root);
3712 vat_json_free (&root);
3715 vam->retval = retval;
3716 vam->result_ready = 1;
3720 vl_api_one_l2_arp_entries_get_reply_t_handler
3721 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3723 vat_main_t *vam = &vat_main;
3725 int retval = clib_net_to_host_u32 (mp->retval);
3730 n = clib_net_to_host_u32 (mp->count);
3732 for (i = 0; i < n; i++)
3733 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3734 format_ethernet_address, mp->entries[i].mac);
3737 vam->retval = retval;
3738 vam->result_ready = 1;
3742 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3743 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3746 vat_main_t *vam = &vat_main;
3747 vat_json_node_t *e = 0, root;
3749 int retval = clib_net_to_host_u32 (mp->retval);
3750 vl_api_one_l2_arp_entry_t *arp_entry;
3755 n = clib_net_to_host_u32 (mp->count);
3756 vat_json_init_array (&root);
3758 for (i = 0; i < n; i++)
3760 e = vat_json_array_add (&root);
3761 arp_entry = &mp->entries[i];
3763 vat_json_init_object (e);
3764 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3767 vat_json_object_add_string_copy (e, "mac", s);
3770 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3772 vat_json_object_add_string_copy (e, "ip4", s);
3776 vat_json_print (vam->ofp, &root);
3777 vat_json_free (&root);
3780 vam->retval = retval;
3781 vam->result_ready = 1;
3785 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3787 vat_main_t *vam = &vat_main;
3789 int retval = clib_net_to_host_u32 (mp->retval);
3794 n = clib_net_to_host_u32 (mp->count);
3796 for (i = 0; i < n; i++)
3798 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3802 vam->retval = retval;
3803 vam->result_ready = 1;
3807 vl_api_one_ndp_bd_get_reply_t_handler_json
3808 (vl_api_one_ndp_bd_get_reply_t * mp)
3810 vat_main_t *vam = &vat_main;
3811 vat_json_node_t root;
3813 int retval = clib_net_to_host_u32 (mp->retval);
3818 n = clib_net_to_host_u32 (mp->count);
3819 vat_json_init_array (&root);
3821 for (i = 0; i < n; i++)
3823 vat_json_array_add_uint (&root,
3824 clib_net_to_host_u32 (mp->bridge_domains[i]));
3827 vat_json_print (vam->ofp, &root);
3828 vat_json_free (&root);
3831 vam->retval = retval;
3832 vam->result_ready = 1;
3836 vl_api_one_l2_arp_bd_get_reply_t_handler
3837 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3839 vat_main_t *vam = &vat_main;
3841 int retval = clib_net_to_host_u32 (mp->retval);
3846 n = clib_net_to_host_u32 (mp->count);
3848 for (i = 0; i < n; i++)
3850 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3854 vam->retval = retval;
3855 vam->result_ready = 1;
3859 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3860 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3862 vat_main_t *vam = &vat_main;
3863 vat_json_node_t root;
3865 int retval = clib_net_to_host_u32 (mp->retval);
3870 n = clib_net_to_host_u32 (mp->count);
3871 vat_json_init_array (&root);
3873 for (i = 0; i < n; i++)
3875 vat_json_array_add_uint (&root,
3876 clib_net_to_host_u32 (mp->bridge_domains[i]));
3879 vat_json_print (vam->ofp, &root);
3880 vat_json_free (&root);
3883 vam->retval = retval;
3884 vam->result_ready = 1;
3888 vl_api_one_adjacencies_get_reply_t_handler
3889 (vl_api_one_adjacencies_get_reply_t * mp)
3891 vat_main_t *vam = &vat_main;
3893 int retval = clib_net_to_host_u32 (mp->retval);
3894 vl_api_one_adjacency_t *a;
3899 n = clib_net_to_host_u32 (mp->count);
3901 for (i = 0; i < n; i++)
3903 a = &mp->adjacencies[i];
3904 print (vam->ofp, "%U %40U",
3905 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3906 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3910 vam->retval = retval;
3911 vam->result_ready = 1;
3915 vl_api_one_adjacencies_get_reply_t_handler_json
3916 (vl_api_one_adjacencies_get_reply_t * mp)
3919 vat_main_t *vam = &vat_main;
3920 vat_json_node_t *e = 0, root;
3922 int retval = clib_net_to_host_u32 (mp->retval);
3923 vl_api_one_adjacency_t *a;
3928 n = clib_net_to_host_u32 (mp->count);
3929 vat_json_init_array (&root);
3931 for (i = 0; i < n; i++)
3933 e = vat_json_array_add (&root);
3934 a = &mp->adjacencies[i];
3936 vat_json_init_object (e);
3937 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3938 a->leid_prefix_len);
3940 vat_json_object_add_string_copy (e, "leid", s);
3943 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3944 a->reid_prefix_len);
3946 vat_json_object_add_string_copy (e, "reid", s);
3950 vat_json_print (vam->ofp, &root);
3951 vat_json_free (&root);
3954 vam->retval = retval;
3955 vam->result_ready = 1;
3959 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3961 vat_main_t *vam = &vat_main;
3963 print (vam->ofp, "%=20U",
3964 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3969 vl_api_one_map_server_details_t_handler_json
3970 (vl_api_one_map_server_details_t * mp)
3972 vat_main_t *vam = &vat_main;
3973 vat_json_node_t *node = NULL;
3974 struct in6_addr ip6;
3977 if (VAT_JSON_ARRAY != vam->json_tree.type)
3979 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3980 vat_json_init_array (&vam->json_tree);
3982 node = vat_json_array_add (&vam->json_tree);
3984 vat_json_init_object (node);
3987 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3988 vat_json_object_add_ip6 (node, "map-server", ip6);
3992 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3993 vat_json_object_add_ip4 (node, "map-server", ip4);
3998 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4001 vat_main_t *vam = &vat_main;
4003 print (vam->ofp, "%=20U",
4004 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4009 vl_api_one_map_resolver_details_t_handler_json
4010 (vl_api_one_map_resolver_details_t * mp)
4012 vat_main_t *vam = &vat_main;
4013 vat_json_node_t *node = NULL;
4014 struct in6_addr ip6;
4017 if (VAT_JSON_ARRAY != vam->json_tree.type)
4019 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4020 vat_json_init_array (&vam->json_tree);
4022 node = vat_json_array_add (&vam->json_tree);
4024 vat_json_init_object (node);
4027 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4028 vat_json_object_add_ip6 (node, "map resolver", ip6);
4032 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4033 vat_json_object_add_ip4 (node, "map resolver", ip4);
4038 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4040 vat_main_t *vam = &vat_main;
4041 i32 retval = ntohl (mp->retval);
4045 print (vam->ofp, "feature: %s\ngpe: %s",
4046 mp->feature_status ? "enabled" : "disabled",
4047 mp->gpe_status ? "enabled" : "disabled");
4050 vam->retval = retval;
4051 vam->result_ready = 1;
4055 vl_api_show_one_status_reply_t_handler_json
4056 (vl_api_show_one_status_reply_t * mp)
4058 vat_main_t *vam = &vat_main;
4059 vat_json_node_t node;
4060 u8 *gpe_status = NULL;
4061 u8 *feature_status = NULL;
4063 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4064 feature_status = format (0, "%s",
4065 mp->feature_status ? "enabled" : "disabled");
4066 vec_add1 (gpe_status, 0);
4067 vec_add1 (feature_status, 0);
4069 vat_json_init_object (&node);
4070 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4071 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4073 vec_free (gpe_status);
4074 vec_free (feature_status);
4076 vat_json_print (vam->ofp, &node);
4077 vat_json_free (&node);
4079 vam->retval = ntohl (mp->retval);
4080 vam->result_ready = 1;
4084 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4085 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4087 vat_main_t *vam = &vat_main;
4088 i32 retval = ntohl (mp->retval);
4092 print (vam->ofp, "%=20s", mp->locator_set_name);
4095 vam->retval = retval;
4096 vam->result_ready = 1;
4100 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4101 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4103 vat_main_t *vam = &vat_main;
4104 vat_json_node_t *node = NULL;
4106 if (VAT_JSON_ARRAY != vam->json_tree.type)
4108 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4109 vat_json_init_array (&vam->json_tree);
4111 node = vat_json_array_add (&vam->json_tree);
4113 vat_json_init_object (node);
4114 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4116 vat_json_print (vam->ofp, node);
4117 vat_json_free (node);
4119 vam->retval = ntohl (mp->retval);
4120 vam->result_ready = 1;
4124 format_lisp_map_request_mode (u8 * s, va_list * args)
4126 u32 mode = va_arg (*args, u32);
4131 return format (0, "dst-only");
4133 return format (0, "src-dst");
4139 vl_api_show_one_map_request_mode_reply_t_handler
4140 (vl_api_show_one_map_request_mode_reply_t * mp)
4142 vat_main_t *vam = &vat_main;
4143 i32 retval = ntohl (mp->retval);
4147 u32 mode = mp->mode;
4148 print (vam->ofp, "map_request_mode: %U",
4149 format_lisp_map_request_mode, mode);
4152 vam->retval = retval;
4153 vam->result_ready = 1;
4157 vl_api_show_one_map_request_mode_reply_t_handler_json
4158 (vl_api_show_one_map_request_mode_reply_t * mp)
4160 vat_main_t *vam = &vat_main;
4161 vat_json_node_t node;
4166 s = format (0, "%U", format_lisp_map_request_mode, mode);
4169 vat_json_init_object (&node);
4170 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4171 vat_json_print (vam->ofp, &node);
4172 vat_json_free (&node);
4175 vam->retval = ntohl (mp->retval);
4176 vam->result_ready = 1;
4180 vl_api_show_one_use_petr_reply_t_handler
4181 (vl_api_show_one_use_petr_reply_t * mp)
4183 vat_main_t *vam = &vat_main;
4184 i32 retval = ntohl (mp->retval);
4188 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4191 print (vam->ofp, "Proxy-ETR address; %U",
4192 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4197 vam->retval = retval;
4198 vam->result_ready = 1;
4202 vl_api_show_one_use_petr_reply_t_handler_json
4203 (vl_api_show_one_use_petr_reply_t * mp)
4205 vat_main_t *vam = &vat_main;
4206 vat_json_node_t node;
4209 struct in6_addr ip6;
4211 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4212 vec_add1 (status, 0);
4214 vat_json_init_object (&node);
4215 vat_json_object_add_string_copy (&node, "status", status);
4220 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4221 vat_json_object_add_ip6 (&node, "address", ip6);
4225 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4226 vat_json_object_add_ip4 (&node, "address", ip4);
4232 vat_json_print (vam->ofp, &node);
4233 vat_json_free (&node);
4235 vam->retval = ntohl (mp->retval);
4236 vam->result_ready = 1;
4240 vl_api_show_one_nsh_mapping_reply_t_handler
4241 (vl_api_show_one_nsh_mapping_reply_t * mp)
4243 vat_main_t *vam = &vat_main;
4244 i32 retval = ntohl (mp->retval);
4248 print (vam->ofp, "%-20s%-16s",
4249 mp->is_set ? "set" : "not-set",
4250 mp->is_set ? (char *) mp->locator_set_name : "");
4253 vam->retval = retval;
4254 vam->result_ready = 1;
4258 vl_api_show_one_nsh_mapping_reply_t_handler_json
4259 (vl_api_show_one_nsh_mapping_reply_t * mp)
4261 vat_main_t *vam = &vat_main;
4262 vat_json_node_t node;
4265 status = format (0, "%s", mp->is_set ? "yes" : "no");
4266 vec_add1 (status, 0);
4268 vat_json_init_object (&node);
4269 vat_json_object_add_string_copy (&node, "is_set", status);
4272 vat_json_object_add_string_copy (&node, "locator_set",
4273 mp->locator_set_name);
4278 vat_json_print (vam->ofp, &node);
4279 vat_json_free (&node);
4281 vam->retval = ntohl (mp->retval);
4282 vam->result_ready = 1;
4286 vl_api_show_one_map_register_ttl_reply_t_handler
4287 (vl_api_show_one_map_register_ttl_reply_t * mp)
4289 vat_main_t *vam = &vat_main;
4290 i32 retval = ntohl (mp->retval);
4292 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4296 print (vam->ofp, "ttl: %u", mp->ttl);
4299 vam->retval = retval;
4300 vam->result_ready = 1;
4304 vl_api_show_one_map_register_ttl_reply_t_handler_json
4305 (vl_api_show_one_map_register_ttl_reply_t * mp)
4307 vat_main_t *vam = &vat_main;
4308 vat_json_node_t node;
4310 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4311 vat_json_init_object (&node);
4312 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4314 vat_json_print (vam->ofp, &node);
4315 vat_json_free (&node);
4317 vam->retval = ntohl (mp->retval);
4318 vam->result_ready = 1;
4322 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4324 vat_main_t *vam = &vat_main;
4325 i32 retval = ntohl (mp->retval);
4329 print (vam->ofp, "%-20s%-16s",
4330 mp->status ? "enabled" : "disabled",
4331 mp->status ? (char *) mp->locator_set_name : "");
4334 vam->retval = retval;
4335 vam->result_ready = 1;
4339 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4341 vat_main_t *vam = &vat_main;
4342 vat_json_node_t node;
4345 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4346 vec_add1 (status, 0);
4348 vat_json_init_object (&node);
4349 vat_json_object_add_string_copy (&node, "status", status);
4352 vat_json_object_add_string_copy (&node, "locator_set",
4353 mp->locator_set_name);
4358 vat_json_print (vam->ofp, &node);
4359 vat_json_free (&node);
4361 vam->retval = ntohl (mp->retval);
4362 vam->result_ready = 1;
4366 format_policer_type (u8 * s, va_list * va)
4368 u32 i = va_arg (*va, u32);
4370 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4371 s = format (s, "1r2c");
4372 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4373 s = format (s, "1r3c");
4374 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4375 s = format (s, "2r3c-2698");
4376 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4377 s = format (s, "2r3c-4115");
4378 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4379 s = format (s, "2r3c-mef5cf1");
4381 s = format (s, "ILLEGAL");
4386 format_policer_rate_type (u8 * s, va_list * va)
4388 u32 i = va_arg (*va, u32);
4390 if (i == SSE2_QOS_RATE_KBPS)
4391 s = format (s, "kbps");
4392 else if (i == SSE2_QOS_RATE_PPS)
4393 s = format (s, "pps");
4395 s = format (s, "ILLEGAL");
4400 format_policer_round_type (u8 * s, va_list * va)
4402 u32 i = va_arg (*va, u32);
4404 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4405 s = format (s, "closest");
4406 else if (i == SSE2_QOS_ROUND_TO_UP)
4407 s = format (s, "up");
4408 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4409 s = format (s, "down");
4411 s = format (s, "ILLEGAL");
4416 format_policer_action_type (u8 * s, va_list * va)
4418 u32 i = va_arg (*va, u32);
4420 if (i == SSE2_QOS_ACTION_DROP)
4421 s = format (s, "drop");
4422 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4423 s = format (s, "transmit");
4424 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4425 s = format (s, "mark-and-transmit");
4427 s = format (s, "ILLEGAL");
4432 format_dscp (u8 * s, va_list * va)
4434 u32 i = va_arg (*va, u32);
4439 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4443 return format (s, "ILLEGAL");
4445 s = format (s, "%s", t);
4450 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4452 vat_main_t *vam = &vat_main;
4453 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4455 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4456 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4458 conform_dscp_str = format (0, "");
4460 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4461 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4463 exceed_dscp_str = format (0, "");
4465 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4466 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4468 violate_dscp_str = format (0, "");
4470 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4471 "rate type %U, round type %U, %s rate, %s color-aware, "
4472 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4473 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4474 "conform action %U%s, exceed action %U%s, violate action %U%s",
4476 format_policer_type, mp->type,
4479 clib_net_to_host_u64 (mp->cb),
4480 clib_net_to_host_u64 (mp->eb),
4481 format_policer_rate_type, mp->rate_type,
4482 format_policer_round_type, mp->round_type,
4483 mp->single_rate ? "single" : "dual",
4484 mp->color_aware ? "is" : "not",
4485 ntohl (mp->cir_tokens_per_period),
4486 ntohl (mp->pir_tokens_per_period),
4488 ntohl (mp->current_limit),
4489 ntohl (mp->current_bucket),
4490 ntohl (mp->extended_limit),
4491 ntohl (mp->extended_bucket),
4492 clib_net_to_host_u64 (mp->last_update_time),
4493 format_policer_action_type, mp->conform_action_type,
4495 format_policer_action_type, mp->exceed_action_type,
4497 format_policer_action_type, mp->violate_action_type,
4500 vec_free (conform_dscp_str);
4501 vec_free (exceed_dscp_str);
4502 vec_free (violate_dscp_str);
4505 static void vl_api_policer_details_t_handler_json
4506 (vl_api_policer_details_t * mp)
4508 vat_main_t *vam = &vat_main;
4509 vat_json_node_t *node;
4510 u8 *rate_type_str, *round_type_str, *type_str;
4511 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4513 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4515 format (0, "%U", format_policer_round_type, mp->round_type);
4516 type_str = format (0, "%U", format_policer_type, mp->type);
4517 conform_action_str = format (0, "%U", format_policer_action_type,
4518 mp->conform_action_type);
4519 exceed_action_str = format (0, "%U", format_policer_action_type,
4520 mp->exceed_action_type);
4521 violate_action_str = format (0, "%U", format_policer_action_type,
4522 mp->violate_action_type);
4524 if (VAT_JSON_ARRAY != vam->json_tree.type)
4526 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4527 vat_json_init_array (&vam->json_tree);
4529 node = vat_json_array_add (&vam->json_tree);
4531 vat_json_init_object (node);
4532 vat_json_object_add_string_copy (node, "name", mp->name);
4533 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4534 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4535 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4536 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4537 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4538 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4539 vat_json_object_add_string_copy (node, "type", type_str);
4540 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4541 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4542 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4543 vat_json_object_add_uint (node, "cir_tokens_per_period",
4544 ntohl (mp->cir_tokens_per_period));
4545 vat_json_object_add_uint (node, "eir_tokens_per_period",
4546 ntohl (mp->pir_tokens_per_period));
4547 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4548 vat_json_object_add_uint (node, "current_bucket",
4549 ntohl (mp->current_bucket));
4550 vat_json_object_add_uint (node, "extended_limit",
4551 ntohl (mp->extended_limit));
4552 vat_json_object_add_uint (node, "extended_bucket",
4553 ntohl (mp->extended_bucket));
4554 vat_json_object_add_uint (node, "last_update_time",
4555 ntohl (mp->last_update_time));
4556 vat_json_object_add_string_copy (node, "conform_action",
4557 conform_action_str);
4558 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4560 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4561 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4562 vec_free (dscp_str);
4564 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4565 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4567 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4568 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4569 vec_free (dscp_str);
4571 vat_json_object_add_string_copy (node, "violate_action",
4572 violate_action_str);
4573 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4575 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4576 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4577 vec_free (dscp_str);
4580 vec_free (rate_type_str);
4581 vec_free (round_type_str);
4582 vec_free (type_str);
4583 vec_free (conform_action_str);
4584 vec_free (exceed_action_str);
4585 vec_free (violate_action_str);
4589 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4592 vat_main_t *vam = &vat_main;
4593 int i, count = ntohl (mp->count);
4596 print (vam->ofp, "classify table ids (%d) : ", count);
4597 for (i = 0; i < count; i++)
4599 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4600 print (vam->ofp, (i < count - 1) ? "," : "");
4602 vam->retval = ntohl (mp->retval);
4603 vam->result_ready = 1;
4607 vl_api_classify_table_ids_reply_t_handler_json
4608 (vl_api_classify_table_ids_reply_t * mp)
4610 vat_main_t *vam = &vat_main;
4611 int i, count = ntohl (mp->count);
4615 vat_json_node_t node;
4617 vat_json_init_object (&node);
4618 for (i = 0; i < count; i++)
4620 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4622 vat_json_print (vam->ofp, &node);
4623 vat_json_free (&node);
4625 vam->retval = ntohl (mp->retval);
4626 vam->result_ready = 1;
4630 vl_api_classify_table_by_interface_reply_t_handler
4631 (vl_api_classify_table_by_interface_reply_t * mp)
4633 vat_main_t *vam = &vat_main;
4636 table_id = ntohl (mp->l2_table_id);
4638 print (vam->ofp, "l2 table id : %d", table_id);
4640 print (vam->ofp, "l2 table id : No input ACL tables configured");
4641 table_id = ntohl (mp->ip4_table_id);
4643 print (vam->ofp, "ip4 table id : %d", table_id);
4645 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4646 table_id = ntohl (mp->ip6_table_id);
4648 print (vam->ofp, "ip6 table id : %d", table_id);
4650 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4651 vam->retval = ntohl (mp->retval);
4652 vam->result_ready = 1;
4656 vl_api_classify_table_by_interface_reply_t_handler_json
4657 (vl_api_classify_table_by_interface_reply_t * mp)
4659 vat_main_t *vam = &vat_main;
4660 vat_json_node_t node;
4662 vat_json_init_object (&node);
4664 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4665 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4666 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4668 vat_json_print (vam->ofp, &node);
4669 vat_json_free (&node);
4671 vam->retval = ntohl (mp->retval);
4672 vam->result_ready = 1;
4675 static void vl_api_policer_add_del_reply_t_handler
4676 (vl_api_policer_add_del_reply_t * mp)
4678 vat_main_t *vam = &vat_main;
4679 i32 retval = ntohl (mp->retval);
4680 if (vam->async_mode)
4682 vam->async_errors += (retval < 0);
4686 vam->retval = retval;
4687 vam->result_ready = 1;
4688 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4690 * Note: this is just barely thread-safe, depends on
4691 * the main thread spinning waiting for an answer...
4693 errmsg ("policer index %d", ntohl (mp->policer_index));
4697 static void vl_api_policer_add_del_reply_t_handler_json
4698 (vl_api_policer_add_del_reply_t * mp)
4700 vat_main_t *vam = &vat_main;
4701 vat_json_node_t node;
4703 vat_json_init_object (&node);
4704 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4705 vat_json_object_add_uint (&node, "policer_index",
4706 ntohl (mp->policer_index));
4708 vat_json_print (vam->ofp, &node);
4709 vat_json_free (&node);
4711 vam->retval = ntohl (mp->retval);
4712 vam->result_ready = 1;
4715 /* Format hex dump. */
4717 format_hex_bytes (u8 * s, va_list * va)
4719 u8 *bytes = va_arg (*va, u8 *);
4720 int n_bytes = va_arg (*va, int);
4723 /* Print short or long form depending on byte count. */
4724 uword short_form = n_bytes <= 32;
4725 u32 indent = format_get_indent (s);
4730 for (i = 0; i < n_bytes; i++)
4732 if (!short_form && (i % 32) == 0)
4733 s = format (s, "%08x: ", i);
4734 s = format (s, "%02x", bytes[i]);
4735 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4736 s = format (s, "\n%U", format_white_space, indent);
4743 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4746 vat_main_t *vam = &vat_main;
4747 i32 retval = ntohl (mp->retval);
4750 print (vam->ofp, "classify table info :");
4751 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4752 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4753 ntohl (mp->miss_next_index));
4754 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4755 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4756 ntohl (mp->match_n_vectors));
4757 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4758 ntohl (mp->mask_length));
4760 vam->retval = retval;
4761 vam->result_ready = 1;
4765 vl_api_classify_table_info_reply_t_handler_json
4766 (vl_api_classify_table_info_reply_t * mp)
4768 vat_main_t *vam = &vat_main;
4769 vat_json_node_t node;
4771 i32 retval = ntohl (mp->retval);
4774 vat_json_init_object (&node);
4776 vat_json_object_add_int (&node, "sessions",
4777 ntohl (mp->active_sessions));
4778 vat_json_object_add_int (&node, "nexttbl",
4779 ntohl (mp->next_table_index));
4780 vat_json_object_add_int (&node, "nextnode",
4781 ntohl (mp->miss_next_index));
4782 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4783 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4784 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4785 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4786 ntohl (mp->mask_length), 0);
4787 vat_json_object_add_string_copy (&node, "mask", s);
4789 vat_json_print (vam->ofp, &node);
4790 vat_json_free (&node);
4792 vam->retval = ntohl (mp->retval);
4793 vam->result_ready = 1;
4797 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4800 vat_main_t *vam = &vat_main;
4802 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4803 ntohl (mp->hit_next_index), ntohl (mp->advance),
4804 ntohl (mp->opaque_index));
4805 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4806 ntohl (mp->match_length));
4810 vl_api_classify_session_details_t_handler_json
4811 (vl_api_classify_session_details_t * mp)
4813 vat_main_t *vam = &vat_main;
4814 vat_json_node_t *node = NULL;
4816 if (VAT_JSON_ARRAY != vam->json_tree.type)
4818 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4819 vat_json_init_array (&vam->json_tree);
4821 node = vat_json_array_add (&vam->json_tree);
4823 vat_json_init_object (node);
4824 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4825 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4826 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4828 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4830 vat_json_object_add_string_copy (node, "match", s);
4833 static void vl_api_pg_create_interface_reply_t_handler
4834 (vl_api_pg_create_interface_reply_t * mp)
4836 vat_main_t *vam = &vat_main;
4838 vam->retval = ntohl (mp->retval);
4839 vam->result_ready = 1;
4842 static void vl_api_pg_create_interface_reply_t_handler_json
4843 (vl_api_pg_create_interface_reply_t * mp)
4845 vat_main_t *vam = &vat_main;
4846 vat_json_node_t node;
4848 i32 retval = ntohl (mp->retval);
4851 vat_json_init_object (&node);
4853 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4855 vat_json_print (vam->ofp, &node);
4856 vat_json_free (&node);
4858 vam->retval = ntohl (mp->retval);
4859 vam->result_ready = 1;
4862 static void vl_api_policer_classify_details_t_handler
4863 (vl_api_policer_classify_details_t * mp)
4865 vat_main_t *vam = &vat_main;
4867 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4868 ntohl (mp->table_index));
4871 static void vl_api_policer_classify_details_t_handler_json
4872 (vl_api_policer_classify_details_t * mp)
4874 vat_main_t *vam = &vat_main;
4875 vat_json_node_t *node;
4877 if (VAT_JSON_ARRAY != vam->json_tree.type)
4879 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4880 vat_json_init_array (&vam->json_tree);
4882 node = vat_json_array_add (&vam->json_tree);
4884 vat_json_init_object (node);
4885 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4886 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4889 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4890 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4892 vat_main_t *vam = &vat_main;
4893 i32 retval = ntohl (mp->retval);
4894 if (vam->async_mode)
4896 vam->async_errors += (retval < 0);
4900 vam->retval = retval;
4901 vam->sw_if_index = ntohl (mp->sw_if_index);
4902 vam->result_ready = 1;
4906 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4907 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4909 vat_main_t *vam = &vat_main;
4910 vat_json_node_t node;
4912 vat_json_init_object (&node);
4913 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4914 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4916 vat_json_print (vam->ofp, &node);
4917 vat_json_free (&node);
4919 vam->retval = ntohl (mp->retval);
4920 vam->result_ready = 1;
4923 static void vl_api_flow_classify_details_t_handler
4924 (vl_api_flow_classify_details_t * mp)
4926 vat_main_t *vam = &vat_main;
4928 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4929 ntohl (mp->table_index));
4932 static void vl_api_flow_classify_details_t_handler_json
4933 (vl_api_flow_classify_details_t * mp)
4935 vat_main_t *vam = &vat_main;
4936 vat_json_node_t *node;
4938 if (VAT_JSON_ARRAY != vam->json_tree.type)
4940 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4941 vat_json_init_array (&vam->json_tree);
4943 node = vat_json_array_add (&vam->json_tree);
4945 vat_json_init_object (node);
4946 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4947 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4950 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
4951 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
4952 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
4953 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
4954 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
4955 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
4956 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
4957 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
4958 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
4959 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
4960 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
4961 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
4962 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4963 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4964 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
4965 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
4966 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
4967 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
4968 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
4969 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
4970 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
4971 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
4974 * Generate boilerplate reply handlers, which
4975 * dig the return value out of the xxx_reply_t API message,
4976 * stick it into vam->retval, and set vam->result_ready
4978 * Could also do this by pointing N message decode slots at
4979 * a single function, but that could break in subtle ways.
4982 #define foreach_standard_reply_retval_handler \
4983 _(sw_interface_set_flags_reply) \
4984 _(sw_interface_add_del_address_reply) \
4985 _(sw_interface_set_table_reply) \
4986 _(sw_interface_set_mpls_enable_reply) \
4987 _(sw_interface_set_vpath_reply) \
4988 _(sw_interface_set_vxlan_bypass_reply) \
4989 _(sw_interface_set_geneve_bypass_reply) \
4990 _(sw_interface_set_vxlan_gpe_bypass_reply) \
4991 _(sw_interface_set_l2_bridge_reply) \
4992 _(bridge_domain_add_del_reply) \
4993 _(sw_interface_set_l2_xconnect_reply) \
4994 _(l2fib_add_del_reply) \
4995 _(l2fib_flush_int_reply) \
4996 _(l2fib_flush_bd_reply) \
4997 _(ip_add_del_route_reply) \
4998 _(ip_table_add_del_reply) \
4999 _(ip_mroute_add_del_reply) \
5000 _(mpls_route_add_del_reply) \
5001 _(mpls_table_add_del_reply) \
5002 _(mpls_ip_bind_unbind_reply) \
5003 _(proxy_arp_add_del_reply) \
5004 _(proxy_arp_intfc_enable_disable_reply) \
5005 _(sw_interface_set_unnumbered_reply) \
5006 _(ip_neighbor_add_del_reply) \
5007 _(reset_vrf_reply) \
5008 _(oam_add_del_reply) \
5009 _(reset_fib_reply) \
5010 _(dhcp_proxy_config_reply) \
5011 _(dhcp_proxy_set_vss_reply) \
5012 _(dhcp_client_config_reply) \
5013 _(set_ip_flow_hash_reply) \
5014 _(sw_interface_ip6_enable_disable_reply) \
5015 _(sw_interface_ip6_set_link_local_address_reply) \
5016 _(ip6nd_proxy_add_del_reply) \
5017 _(sw_interface_ip6nd_ra_prefix_reply) \
5018 _(sw_interface_ip6nd_ra_config_reply) \
5019 _(set_arp_neighbor_limit_reply) \
5020 _(l2_patch_add_del_reply) \
5021 _(sr_policy_add_reply) \
5022 _(sr_policy_mod_reply) \
5023 _(sr_policy_del_reply) \
5024 _(sr_localsid_add_del_reply) \
5025 _(sr_steering_add_del_reply) \
5026 _(classify_add_del_session_reply) \
5027 _(classify_set_interface_ip_table_reply) \
5028 _(classify_set_interface_l2_tables_reply) \
5029 _(l2tpv3_set_tunnel_cookies_reply) \
5030 _(l2tpv3_interface_enable_disable_reply) \
5031 _(l2tpv3_set_lookup_key_reply) \
5032 _(l2_fib_clear_table_reply) \
5033 _(l2_interface_efp_filter_reply) \
5034 _(l2_interface_vlan_tag_rewrite_reply) \
5035 _(modify_vhost_user_if_reply) \
5036 _(delete_vhost_user_if_reply) \
5037 _(want_ip4_arp_events_reply) \
5038 _(want_ip6_nd_events_reply) \
5039 _(want_l2_macs_events_reply) \
5040 _(input_acl_set_interface_reply) \
5041 _(ipsec_spd_add_del_reply) \
5042 _(ipsec_interface_add_del_spd_reply) \
5043 _(ipsec_spd_add_del_entry_reply) \
5044 _(ipsec_sad_add_del_entry_reply) \
5045 _(ipsec_sa_set_key_reply) \
5046 _(ipsec_tunnel_if_add_del_reply) \
5047 _(ikev2_profile_add_del_reply) \
5048 _(ikev2_profile_set_auth_reply) \
5049 _(ikev2_profile_set_id_reply) \
5050 _(ikev2_profile_set_ts_reply) \
5051 _(ikev2_set_local_key_reply) \
5052 _(ikev2_set_responder_reply) \
5053 _(ikev2_set_ike_transforms_reply) \
5054 _(ikev2_set_esp_transforms_reply) \
5055 _(ikev2_set_sa_lifetime_reply) \
5056 _(ikev2_initiate_sa_init_reply) \
5057 _(ikev2_initiate_del_ike_sa_reply) \
5058 _(ikev2_initiate_del_child_sa_reply) \
5059 _(ikev2_initiate_rekey_child_sa_reply) \
5060 _(delete_loopback_reply) \
5061 _(bd_ip_mac_add_del_reply) \
5062 _(map_del_domain_reply) \
5063 _(map_add_del_rule_reply) \
5064 _(want_interface_events_reply) \
5065 _(want_stats_reply) \
5066 _(cop_interface_enable_disable_reply) \
5067 _(cop_whitelist_enable_disable_reply) \
5068 _(sw_interface_clear_stats_reply) \
5069 _(ioam_enable_reply) \
5070 _(ioam_disable_reply) \
5071 _(one_add_del_locator_reply) \
5072 _(one_add_del_local_eid_reply) \
5073 _(one_add_del_remote_mapping_reply) \
5074 _(one_add_del_adjacency_reply) \
5075 _(one_add_del_map_resolver_reply) \
5076 _(one_add_del_map_server_reply) \
5077 _(one_enable_disable_reply) \
5078 _(one_rloc_probe_enable_disable_reply) \
5079 _(one_map_register_enable_disable_reply) \
5080 _(one_map_register_set_ttl_reply) \
5081 _(one_set_transport_protocol_reply) \
5082 _(one_map_register_fallback_threshold_reply) \
5083 _(one_pitr_set_locator_set_reply) \
5084 _(one_map_request_mode_reply) \
5085 _(one_add_del_map_request_itr_rlocs_reply) \
5086 _(one_eid_table_add_del_map_reply) \
5087 _(one_use_petr_reply) \
5088 _(one_stats_enable_disable_reply) \
5089 _(one_add_del_l2_arp_entry_reply) \
5090 _(one_add_del_ndp_entry_reply) \
5091 _(one_stats_flush_reply) \
5092 _(gpe_enable_disable_reply) \
5093 _(gpe_set_encap_mode_reply) \
5094 _(gpe_add_del_iface_reply) \
5095 _(gpe_add_del_native_fwd_rpath_reply) \
5096 _(af_packet_delete_reply) \
5097 _(policer_classify_set_interface_reply) \
5098 _(netmap_create_reply) \
5099 _(netmap_delete_reply) \
5100 _(set_ipfix_exporter_reply) \
5101 _(set_ipfix_classify_stream_reply) \
5102 _(ipfix_classify_table_add_del_reply) \
5103 _(flow_classify_set_interface_reply) \
5104 _(sw_interface_span_enable_disable_reply) \
5105 _(pg_capture_reply) \
5106 _(pg_enable_disable_reply) \
5107 _(ip_source_and_port_range_check_add_del_reply) \
5108 _(ip_source_and_port_range_check_interface_add_del_reply)\
5109 _(delete_subif_reply) \
5110 _(l2_interface_pbb_tag_rewrite_reply) \
5112 _(feature_enable_disable_reply) \
5113 _(sw_interface_tag_add_del_reply) \
5114 _(sw_interface_set_mtu_reply) \
5115 _(p2p_ethernet_add_reply) \
5116 _(p2p_ethernet_del_reply) \
5117 _(lldp_config_reply) \
5118 _(sw_interface_set_lldp_reply) \
5119 _(tcp_configure_src_addresses_reply) \
5120 _(app_namespace_add_del_reply)
5123 static void vl_api_##n##_t_handler \
5124 (vl_api_##n##_t * mp) \
5126 vat_main_t * vam = &vat_main; \
5127 i32 retval = ntohl(mp->retval); \
5128 if (vam->async_mode) { \
5129 vam->async_errors += (retval < 0); \
5131 vam->retval = retval; \
5132 vam->result_ready = 1; \
5135 foreach_standard_reply_retval_handler;
5139 static void vl_api_##n##_t_handler_json \
5140 (vl_api_##n##_t * mp) \
5142 vat_main_t * vam = &vat_main; \
5143 vat_json_node_t node; \
5144 vat_json_init_object(&node); \
5145 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5146 vat_json_print(vam->ofp, &node); \
5147 vam->retval = ntohl(mp->retval); \
5148 vam->result_ready = 1; \
5150 foreach_standard_reply_retval_handler;
5154 * Table of message reply handlers, must include boilerplate handlers
5158 #define foreach_vpe_api_reply_msg \
5159 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5160 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5161 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5162 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5163 _(CONTROL_PING_REPLY, control_ping_reply) \
5164 _(CLI_REPLY, cli_reply) \
5165 _(CLI_INBAND_REPLY, cli_inband_reply) \
5166 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5167 sw_interface_add_del_address_reply) \
5168 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5169 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5170 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5171 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5172 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5173 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5174 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5175 sw_interface_set_l2_xconnect_reply) \
5176 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5177 sw_interface_set_l2_bridge_reply) \
5178 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5179 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5180 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5181 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5182 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5183 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5184 _(L2_FLAGS_REPLY, l2_flags_reply) \
5185 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5186 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5187 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5188 _(TAP_DELETE_REPLY, tap_delete_reply) \
5189 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5190 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5191 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5192 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5193 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5194 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5195 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5196 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5197 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5198 proxy_arp_intfc_enable_disable_reply) \
5199 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5200 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5201 sw_interface_set_unnumbered_reply) \
5202 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5203 _(RESET_VRF_REPLY, reset_vrf_reply) \
5204 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5205 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5206 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5207 _(RESET_FIB_REPLY, reset_fib_reply) \
5208 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5209 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5210 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5211 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5212 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5213 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5214 sw_interface_ip6_enable_disable_reply) \
5215 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5216 sw_interface_ip6_set_link_local_address_reply) \
5217 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5218 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5219 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5220 sw_interface_ip6nd_ra_prefix_reply) \
5221 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5222 sw_interface_ip6nd_ra_config_reply) \
5223 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5224 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5225 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5226 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5227 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5228 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5229 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5230 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5231 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5232 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5233 classify_set_interface_ip_table_reply) \
5234 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5235 classify_set_interface_l2_tables_reply) \
5236 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5237 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5238 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5239 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5240 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5241 l2tpv3_interface_enable_disable_reply) \
5242 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5243 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5244 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5245 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5246 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5247 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5248 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5249 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5250 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5251 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5252 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5253 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5254 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5255 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5256 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5257 _(SHOW_VERSION_REPLY, show_version_reply) \
5258 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5259 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5260 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5261 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5262 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5263 _(IP4_ARP_EVENT, ip4_arp_event) \
5264 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5265 _(IP6_ND_EVENT, ip6_nd_event) \
5266 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5267 _(L2_MACS_EVENT, l2_macs_event) \
5268 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5269 _(IP_ADDRESS_DETAILS, ip_address_details) \
5270 _(IP_DETAILS, ip_details) \
5271 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5272 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5273 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5274 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5275 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5276 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5277 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5278 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5279 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5280 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5281 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5282 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5283 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5284 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5285 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5286 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5287 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5288 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5289 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5290 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5291 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5292 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5293 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5294 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5295 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5296 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5297 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5298 _(MAP_RULE_DETAILS, map_rule_details) \
5299 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5300 _(WANT_STATS_REPLY, want_stats_reply) \
5301 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5302 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5303 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5304 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5305 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5306 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5307 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5308 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5309 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5310 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5311 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5312 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5313 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5314 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5315 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5316 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5317 one_map_register_enable_disable_reply) \
5318 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5319 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5320 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5321 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5322 one_map_register_fallback_threshold_reply) \
5323 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5324 one_rloc_probe_enable_disable_reply) \
5325 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5326 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5327 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5328 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5329 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5330 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5331 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5332 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5333 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5334 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5335 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5336 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5337 _(ONE_STATS_DETAILS, one_stats_details) \
5338 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5339 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5340 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5341 show_one_stats_enable_disable_reply) \
5342 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5343 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5344 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5345 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5346 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5347 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5348 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5349 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5350 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5351 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5352 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5353 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5354 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5355 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5356 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5357 gpe_add_del_native_fwd_rpath_reply) \
5358 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5359 gpe_fwd_entry_path_details) \
5360 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5361 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5362 one_add_del_map_request_itr_rlocs_reply) \
5363 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5364 one_get_map_request_itr_rlocs_reply) \
5365 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5366 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5367 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5368 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5369 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5370 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5371 show_one_map_register_state_reply) \
5372 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5373 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5374 show_one_map_register_fallback_threshold_reply) \
5375 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5376 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5377 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5378 _(POLICER_DETAILS, policer_details) \
5379 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5380 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5381 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5382 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5383 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5384 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5385 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5386 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5387 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5388 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5389 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5390 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5391 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5392 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5393 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5394 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5395 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5396 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5397 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5398 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5399 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5400 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5401 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5402 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5403 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5404 ip_source_and_port_range_check_add_del_reply) \
5405 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5406 ip_source_and_port_range_check_interface_add_del_reply) \
5407 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5408 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5409 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5410 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5411 _(PUNT_REPLY, punt_reply) \
5412 _(IP_FIB_DETAILS, ip_fib_details) \
5413 _(IP6_FIB_DETAILS, ip6_fib_details) \
5414 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5415 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5416 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5417 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5418 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5419 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5420 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5421 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5422 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5423 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5424 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5425 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply)
5427 #define foreach_standalone_reply_msg \
5428 _(SW_INTERFACE_EVENT, sw_interface_event) \
5429 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5430 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5431 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5432 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5433 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5434 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
5435 _(MEMFD_SEGMENT_CREATE_REPLY, memfd_segment_create_reply)
5444 #define STR_VTR_OP_CASE(op) \
5445 case L2_VTR_ ## op: \
5449 str_vtr_op (u32 vtr_op)
5453 STR_VTR_OP_CASE (DISABLED);
5454 STR_VTR_OP_CASE (PUSH_1);
5455 STR_VTR_OP_CASE (PUSH_2);
5456 STR_VTR_OP_CASE (POP_1);
5457 STR_VTR_OP_CASE (POP_2);
5458 STR_VTR_OP_CASE (TRANSLATE_1_1);
5459 STR_VTR_OP_CASE (TRANSLATE_1_2);
5460 STR_VTR_OP_CASE (TRANSLATE_2_1);
5461 STR_VTR_OP_CASE (TRANSLATE_2_2);
5468 dump_sub_interface_table (vat_main_t * vam)
5470 const sw_interface_subif_t *sub = NULL;
5472 if (vam->json_output)
5475 ("JSON output supported only for VPE API calls and dump_stats_table");
5480 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5481 "Interface", "sw_if_index",
5482 "sub id", "dot1ad", "tags", "outer id",
5483 "inner id", "exact", "default", "outer any", "inner any");
5485 vec_foreach (sub, vam->sw_if_subif_table)
5488 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5489 sub->interface_name,
5491 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5492 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5493 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5494 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5495 if (sub->vtr_op != L2_VTR_DISABLED)
5498 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5499 "tag1: %d tag2: %d ]",
5500 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5501 sub->vtr_tag1, sub->vtr_tag2);
5509 name_sort_cmp (void *a1, void *a2)
5511 name_sort_t *n1 = a1;
5512 name_sort_t *n2 = a2;
5514 return strcmp ((char *) n1->name, (char *) n2->name);
5518 dump_interface_table (vat_main_t * vam)
5521 name_sort_t *nses = 0, *ns;
5523 if (vam->json_output)
5526 ("JSON output supported only for VPE API calls and dump_stats_table");
5531 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5533 vec_add2 (nses, ns, 1);
5534 ns->name = (u8 *)(p->key);
5535 ns->value = (u32) p->value[0];
5539 vec_sort_with_function (nses, name_sort_cmp);
5541 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5542 vec_foreach (ns, nses)
5544 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5551 dump_ip_table (vat_main_t * vam, int is_ipv6)
5553 const ip_details_t *det = NULL;
5554 const ip_address_details_t *address = NULL;
5557 print (vam->ofp, "%-12s", "sw_if_index");
5559 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5566 print (vam->ofp, "%-12d", i);
5567 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5572 vec_foreach (address, det->addr)
5576 is_ipv6 ? format_ip6_address : format_ip4_address,
5577 address->ip, address->prefix_length);
5585 dump_ipv4_table (vat_main_t * vam)
5587 if (vam->json_output)
5590 ("JSON output supported only for VPE API calls and dump_stats_table");
5594 return dump_ip_table (vam, 0);
5598 dump_ipv6_table (vat_main_t * vam)
5600 if (vam->json_output)
5603 ("JSON output supported only for VPE API calls and dump_stats_table");
5607 return dump_ip_table (vam, 1);
5611 counter_type_to_str (u8 counter_type, u8 is_combined)
5615 switch (counter_type)
5617 case VNET_INTERFACE_COUNTER_DROP:
5619 case VNET_INTERFACE_COUNTER_PUNT:
5621 case VNET_INTERFACE_COUNTER_IP4:
5623 case VNET_INTERFACE_COUNTER_IP6:
5625 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5627 case VNET_INTERFACE_COUNTER_RX_MISS:
5629 case VNET_INTERFACE_COUNTER_RX_ERROR:
5631 case VNET_INTERFACE_COUNTER_TX_ERROR:
5634 return "INVALID-COUNTER-TYPE";
5639 switch (counter_type)
5641 case VNET_INTERFACE_COUNTER_RX:
5643 case VNET_INTERFACE_COUNTER_TX:
5646 return "INVALID-COUNTER-TYPE";
5652 dump_stats_table (vat_main_t * vam)
5654 vat_json_node_t node;
5655 vat_json_node_t *msg_array;
5656 vat_json_node_t *msg;
5657 vat_json_node_t *counter_array;
5658 vat_json_node_t *counter;
5659 interface_counter_t c;
5661 ip4_fib_counter_t *c4;
5662 ip6_fib_counter_t *c6;
5663 ip4_nbr_counter_t *n4;
5664 ip6_nbr_counter_t *n6;
5667 if (!vam->json_output)
5669 clib_warning ("dump_stats_table supported only in JSON format");
5673 vat_json_init_object (&node);
5675 /* interface counters */
5676 msg_array = vat_json_object_add (&node, "interface_counters");
5677 vat_json_init_array (msg_array);
5678 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5680 msg = vat_json_array_add (msg_array);
5681 vat_json_init_object (msg);
5682 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5683 (u8 *) counter_type_to_str (i, 0));
5684 vat_json_object_add_int (msg, "is_combined", 0);
5685 counter_array = vat_json_object_add (msg, "data");
5686 vat_json_init_array (counter_array);
5687 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5689 packets = vam->simple_interface_counters[i][j];
5690 vat_json_array_add_uint (counter_array, packets);
5693 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5695 msg = vat_json_array_add (msg_array);
5696 vat_json_init_object (msg);
5697 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5698 (u8 *) counter_type_to_str (i, 1));
5699 vat_json_object_add_int (msg, "is_combined", 1);
5700 counter_array = vat_json_object_add (msg, "data");
5701 vat_json_init_array (counter_array);
5702 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5704 c = vam->combined_interface_counters[i][j];
5705 counter = vat_json_array_add (counter_array);
5706 vat_json_init_object (counter);
5707 vat_json_object_add_uint (counter, "packets", c.packets);
5708 vat_json_object_add_uint (counter, "bytes", c.bytes);
5712 /* ip4 fib counters */
5713 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5714 vat_json_init_array (msg_array);
5715 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5717 msg = vat_json_array_add (msg_array);
5718 vat_json_init_object (msg);
5719 vat_json_object_add_uint (msg, "vrf_id",
5720 vam->ip4_fib_counters_vrf_id_by_index[i]);
5721 counter_array = vat_json_object_add (msg, "c");
5722 vat_json_init_array (counter_array);
5723 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5725 counter = vat_json_array_add (counter_array);
5726 vat_json_init_object (counter);
5727 c4 = &vam->ip4_fib_counters[i][j];
5728 vat_json_object_add_ip4 (counter, "address", c4->address);
5729 vat_json_object_add_uint (counter, "address_length",
5730 c4->address_length);
5731 vat_json_object_add_uint (counter, "packets", c4->packets);
5732 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5736 /* ip6 fib counters */
5737 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5738 vat_json_init_array (msg_array);
5739 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5741 msg = vat_json_array_add (msg_array);
5742 vat_json_init_object (msg);
5743 vat_json_object_add_uint (msg, "vrf_id",
5744 vam->ip6_fib_counters_vrf_id_by_index[i]);
5745 counter_array = vat_json_object_add (msg, "c");
5746 vat_json_init_array (counter_array);
5747 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5749 counter = vat_json_array_add (counter_array);
5750 vat_json_init_object (counter);
5751 c6 = &vam->ip6_fib_counters[i][j];
5752 vat_json_object_add_ip6 (counter, "address", c6->address);
5753 vat_json_object_add_uint (counter, "address_length",
5754 c6->address_length);
5755 vat_json_object_add_uint (counter, "packets", c6->packets);
5756 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5760 /* ip4 nbr counters */
5761 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5762 vat_json_init_array (msg_array);
5763 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5765 msg = vat_json_array_add (msg_array);
5766 vat_json_init_object (msg);
5767 vat_json_object_add_uint (msg, "sw_if_index", i);
5768 counter_array = vat_json_object_add (msg, "c");
5769 vat_json_init_array (counter_array);
5770 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5772 counter = vat_json_array_add (counter_array);
5773 vat_json_init_object (counter);
5774 n4 = &vam->ip4_nbr_counters[i][j];
5775 vat_json_object_add_ip4 (counter, "address", n4->address);
5776 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5777 vat_json_object_add_uint (counter, "packets", n4->packets);
5778 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5782 /* ip6 nbr counters */
5783 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5784 vat_json_init_array (msg_array);
5785 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5787 msg = vat_json_array_add (msg_array);
5788 vat_json_init_object (msg);
5789 vat_json_object_add_uint (msg, "sw_if_index", i);
5790 counter_array = vat_json_object_add (msg, "c");
5791 vat_json_init_array (counter_array);
5792 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5794 counter = vat_json_array_add (counter_array);
5795 vat_json_init_object (counter);
5796 n6 = &vam->ip6_nbr_counters[i][j];
5797 vat_json_object_add_ip6 (counter, "address", n6->address);
5798 vat_json_object_add_uint (counter, "packets", n6->packets);
5799 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5803 vat_json_print (vam->ofp, &node);
5804 vat_json_free (&node);
5810 * Pass CLI buffers directly in the CLI_INBAND API message,
5811 * instead of an additional shared memory area.
5814 exec_inband (vat_main_t * vam)
5816 vl_api_cli_inband_t *mp;
5817 unformat_input_t *i = vam->input;
5820 if (vec_len (i->buffer) == 0)
5823 if (vam->exec_mode == 0 && unformat (i, "mode"))
5828 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5835 * In order for the CLI command to work, it
5836 * must be a vector ending in \n, not a C-string ending
5839 u32 len = vec_len (vam->input->buffer);
5840 M2 (CLI_INBAND, mp, len);
5841 clib_memcpy (mp->cmd, vam->input->buffer, len);
5842 mp->length = htonl (len);
5846 /* json responses may or may not include a useful reply... */
5847 if (vec_len (vam->cmd_reply))
5848 print (vam->ofp, (char *) (vam->cmd_reply));
5853 exec (vat_main_t * vam)
5855 return exec_inband (vam);
5859 api_create_loopback (vat_main_t * vam)
5861 unformat_input_t *i = vam->input;
5862 vl_api_create_loopback_t *mp;
5863 vl_api_create_loopback_instance_t *mp_lbi;
5866 u8 is_specified = 0;
5867 u32 user_instance = 0;
5870 memset (mac_address, 0, sizeof (mac_address));
5872 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5874 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5876 if (unformat (i, "instance %d", &user_instance))
5884 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5885 mp_lbi->is_specified = is_specified;
5887 mp_lbi->user_instance = htonl (user_instance);
5889 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5894 /* Construct the API message */
5895 M (CREATE_LOOPBACK, mp);
5897 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5906 api_delete_loopback (vat_main_t * vam)
5908 unformat_input_t *i = vam->input;
5909 vl_api_delete_loopback_t *mp;
5910 u32 sw_if_index = ~0;
5913 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5915 if (unformat (i, "sw_if_index %d", &sw_if_index))
5921 if (sw_if_index == ~0)
5923 errmsg ("missing sw_if_index");
5927 /* Construct the API message */
5928 M (DELETE_LOOPBACK, mp);
5929 mp->sw_if_index = ntohl (sw_if_index);
5937 api_want_stats (vat_main_t * vam)
5939 unformat_input_t *i = vam->input;
5940 vl_api_want_stats_t *mp;
5944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5946 if (unformat (i, "enable"))
5948 else if (unformat (i, "disable"))
5956 errmsg ("missing enable|disable");
5961 mp->enable_disable = enable;
5969 api_want_interface_events (vat_main_t * vam)
5971 unformat_input_t *i = vam->input;
5972 vl_api_want_interface_events_t *mp;
5976 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5978 if (unformat (i, "enable"))
5980 else if (unformat (i, "disable"))
5988 errmsg ("missing enable|disable");
5992 M (WANT_INTERFACE_EVENTS, mp);
5993 mp->enable_disable = enable;
5995 vam->interface_event_display = enable;
6003 /* Note: non-static, called once to set up the initial intfc table */
6005 api_sw_interface_dump (vat_main_t * vam)
6007 vl_api_sw_interface_dump_t *mp;
6008 vl_api_control_ping_t *mp_ping;
6010 name_sort_t *nses = 0, *ns;
6011 sw_interface_subif_t *sub = NULL;
6014 /* Toss the old name table */
6016 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6018 vec_add2 (nses, ns, 1);
6019 ns->name = (u8 *)(p->key);
6020 ns->value = (u32) p->value[0];
6024 hash_free (vam->sw_if_index_by_interface_name);
6026 vec_foreach (ns, nses) vec_free (ns->name);
6030 vec_foreach (sub, vam->sw_if_subif_table)
6032 vec_free (sub->interface_name);
6034 vec_free (vam->sw_if_subif_table);
6036 /* recreate the interface name hash table */
6037 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6039 /* Get list of ethernets */
6040 M (SW_INTERFACE_DUMP, mp);
6041 mp->name_filter_valid = 1;
6042 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
6045 /* and local / loopback interfaces */
6046 M (SW_INTERFACE_DUMP, mp);
6047 mp->name_filter_valid = 1;
6048 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
6051 /* and packet-generator interfaces */
6052 M (SW_INTERFACE_DUMP, mp);
6053 mp->name_filter_valid = 1;
6054 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
6057 /* and vxlan-gpe tunnel interfaces */
6058 M (SW_INTERFACE_DUMP, mp);
6059 mp->name_filter_valid = 1;
6060 strncpy ((char *) mp->name_filter, "vxlan_gpe",
6061 sizeof (mp->name_filter) - 1);
6064 /* and vxlan tunnel interfaces */
6065 M (SW_INTERFACE_DUMP, mp);
6066 mp->name_filter_valid = 1;
6067 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
6070 /* and geneve tunnel interfaces */
6071 M (SW_INTERFACE_DUMP, mp);
6072 mp->name_filter_valid = 1;
6073 strncpy ((char *) mp->name_filter, "geneve", sizeof (mp->name_filter) - 1);
6076 /* and host (af_packet) interfaces */
6077 M (SW_INTERFACE_DUMP, mp);
6078 mp->name_filter_valid = 1;
6079 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
6082 /* and l2tpv3 tunnel interfaces */
6083 M (SW_INTERFACE_DUMP, mp);
6084 mp->name_filter_valid = 1;
6085 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
6086 sizeof (mp->name_filter) - 1);
6089 /* and GRE tunnel interfaces */
6090 M (SW_INTERFACE_DUMP, mp);
6091 mp->name_filter_valid = 1;
6092 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
6095 /* and LISP-GPE interfaces */
6096 M (SW_INTERFACE_DUMP, mp);
6097 mp->name_filter_valid = 1;
6098 strncpy ((char *) mp->name_filter, "lisp_gpe",
6099 sizeof (mp->name_filter) - 1);
6102 /* and IPSEC tunnel interfaces */
6103 M (SW_INTERFACE_DUMP, mp);
6104 mp->name_filter_valid = 1;
6105 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
6108 /* Use a control ping for synchronization */
6109 MPING (CONTROL_PING, mp_ping);
6117 api_sw_interface_set_flags (vat_main_t * vam)
6119 unformat_input_t *i = vam->input;
6120 vl_api_sw_interface_set_flags_t *mp;
6122 u8 sw_if_index_set = 0;
6126 /* Parse args required to build the message */
6127 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6129 if (unformat (i, "admin-up"))
6131 else if (unformat (i, "admin-down"))
6134 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6135 sw_if_index_set = 1;
6136 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6137 sw_if_index_set = 1;
6142 if (sw_if_index_set == 0)
6144 errmsg ("missing interface name or sw_if_index");
6148 /* Construct the API message */
6149 M (SW_INTERFACE_SET_FLAGS, mp);
6150 mp->sw_if_index = ntohl (sw_if_index);
6151 mp->admin_up_down = admin_up;
6156 /* Wait for a reply, return the good/bad news... */
6162 api_sw_interface_clear_stats (vat_main_t * vam)
6164 unformat_input_t *i = vam->input;
6165 vl_api_sw_interface_clear_stats_t *mp;
6167 u8 sw_if_index_set = 0;
6170 /* Parse args required to build the message */
6171 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6173 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6174 sw_if_index_set = 1;
6175 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6176 sw_if_index_set = 1;
6181 /* Construct the API message */
6182 M (SW_INTERFACE_CLEAR_STATS, mp);
6184 if (sw_if_index_set == 1)
6185 mp->sw_if_index = ntohl (sw_if_index);
6187 mp->sw_if_index = ~0;
6192 /* Wait for a reply, return the good/bad news... */
6198 api_sw_interface_add_del_address (vat_main_t * vam)
6200 unformat_input_t *i = vam->input;
6201 vl_api_sw_interface_add_del_address_t *mp;
6203 u8 sw_if_index_set = 0;
6204 u8 is_add = 1, del_all = 0;
6205 u32 address_length = 0;
6206 u8 v4_address_set = 0;
6207 u8 v6_address_set = 0;
6208 ip4_address_t v4address;
6209 ip6_address_t v6address;
6212 /* Parse args required to build the message */
6213 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6215 if (unformat (i, "del-all"))
6217 else if (unformat (i, "del"))
6220 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6221 sw_if_index_set = 1;
6222 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6223 sw_if_index_set = 1;
6224 else if (unformat (i, "%U/%d",
6225 unformat_ip4_address, &v4address, &address_length))
6227 else if (unformat (i, "%U/%d",
6228 unformat_ip6_address, &v6address, &address_length))
6234 if (sw_if_index_set == 0)
6236 errmsg ("missing interface name or sw_if_index");
6239 if (v4_address_set && v6_address_set)
6241 errmsg ("both v4 and v6 addresses set");
6244 if (!v4_address_set && !v6_address_set && !del_all)
6246 errmsg ("no addresses set");
6250 /* Construct the API message */
6251 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6253 mp->sw_if_index = ntohl (sw_if_index);
6254 mp->is_add = is_add;
6255 mp->del_all = del_all;
6259 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6263 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6265 mp->address_length = address_length;
6270 /* Wait for a reply, return good/bad news */
6276 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6278 unformat_input_t *i = vam->input;
6279 vl_api_sw_interface_set_mpls_enable_t *mp;
6281 u8 sw_if_index_set = 0;
6285 /* Parse args required to build the message */
6286 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6288 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6289 sw_if_index_set = 1;
6290 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6291 sw_if_index_set = 1;
6292 else if (unformat (i, "disable"))
6294 else if (unformat (i, "dis"))
6300 if (sw_if_index_set == 0)
6302 errmsg ("missing interface name or sw_if_index");
6306 /* Construct the API message */
6307 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6309 mp->sw_if_index = ntohl (sw_if_index);
6310 mp->enable = enable;
6315 /* Wait for a reply... */
6321 api_sw_interface_set_table (vat_main_t * vam)
6323 unformat_input_t *i = vam->input;
6324 vl_api_sw_interface_set_table_t *mp;
6325 u32 sw_if_index, vrf_id = 0;
6326 u8 sw_if_index_set = 0;
6330 /* Parse args required to build the message */
6331 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6333 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6334 sw_if_index_set = 1;
6335 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6336 sw_if_index_set = 1;
6337 else if (unformat (i, "vrf %d", &vrf_id))
6339 else if (unformat (i, "ipv6"))
6345 if (sw_if_index_set == 0)
6347 errmsg ("missing interface name or sw_if_index");
6351 /* Construct the API message */
6352 M (SW_INTERFACE_SET_TABLE, mp);
6354 mp->sw_if_index = ntohl (sw_if_index);
6355 mp->is_ipv6 = is_ipv6;
6356 mp->vrf_id = ntohl (vrf_id);
6361 /* Wait for a reply... */
6366 static void vl_api_sw_interface_get_table_reply_t_handler
6367 (vl_api_sw_interface_get_table_reply_t * mp)
6369 vat_main_t *vam = &vat_main;
6371 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6373 vam->retval = ntohl (mp->retval);
6374 vam->result_ready = 1;
6378 static void vl_api_sw_interface_get_table_reply_t_handler_json
6379 (vl_api_sw_interface_get_table_reply_t * mp)
6381 vat_main_t *vam = &vat_main;
6382 vat_json_node_t node;
6384 vat_json_init_object (&node);
6385 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6386 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6388 vat_json_print (vam->ofp, &node);
6389 vat_json_free (&node);
6391 vam->retval = ntohl (mp->retval);
6392 vam->result_ready = 1;
6396 api_sw_interface_get_table (vat_main_t * vam)
6398 unformat_input_t *i = vam->input;
6399 vl_api_sw_interface_get_table_t *mp;
6401 u8 sw_if_index_set = 0;
6405 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6407 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6408 sw_if_index_set = 1;
6409 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6410 sw_if_index_set = 1;
6411 else if (unformat (i, "ipv6"))
6417 if (sw_if_index_set == 0)
6419 errmsg ("missing interface name or sw_if_index");
6423 M (SW_INTERFACE_GET_TABLE, mp);
6424 mp->sw_if_index = htonl (sw_if_index);
6425 mp->is_ipv6 = is_ipv6;
6433 api_sw_interface_set_vpath (vat_main_t * vam)
6435 unformat_input_t *i = vam->input;
6436 vl_api_sw_interface_set_vpath_t *mp;
6437 u32 sw_if_index = 0;
6438 u8 sw_if_index_set = 0;
6442 /* Parse args required to build the message */
6443 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6445 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6446 sw_if_index_set = 1;
6447 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6448 sw_if_index_set = 1;
6449 else if (unformat (i, "enable"))
6451 else if (unformat (i, "disable"))
6457 if (sw_if_index_set == 0)
6459 errmsg ("missing interface name or sw_if_index");
6463 /* Construct the API message */
6464 M (SW_INTERFACE_SET_VPATH, mp);
6466 mp->sw_if_index = ntohl (sw_if_index);
6467 mp->enable = is_enable;
6472 /* Wait for a reply... */
6478 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6480 unformat_input_t *i = vam->input;
6481 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6482 u32 sw_if_index = 0;
6483 u8 sw_if_index_set = 0;
6488 /* Parse args required to build the message */
6489 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6491 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6492 sw_if_index_set = 1;
6493 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6494 sw_if_index_set = 1;
6495 else if (unformat (i, "enable"))
6497 else if (unformat (i, "disable"))
6499 else if (unformat (i, "ip4"))
6501 else if (unformat (i, "ip6"))
6507 if (sw_if_index_set == 0)
6509 errmsg ("missing interface name or sw_if_index");
6513 /* Construct the API message */
6514 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6516 mp->sw_if_index = ntohl (sw_if_index);
6517 mp->enable = is_enable;
6518 mp->is_ipv6 = is_ipv6;
6523 /* Wait for a reply... */
6529 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6531 unformat_input_t *i = vam->input;
6532 vl_api_sw_interface_set_geneve_bypass_t *mp;
6533 u32 sw_if_index = 0;
6534 u8 sw_if_index_set = 0;
6539 /* Parse args required to build the message */
6540 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6542 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6543 sw_if_index_set = 1;
6544 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6545 sw_if_index_set = 1;
6546 else if (unformat (i, "enable"))
6548 else if (unformat (i, "disable"))
6550 else if (unformat (i, "ip4"))
6552 else if (unformat (i, "ip6"))
6558 if (sw_if_index_set == 0)
6560 errmsg ("missing interface name or sw_if_index");
6564 /* Construct the API message */
6565 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6567 mp->sw_if_index = ntohl (sw_if_index);
6568 mp->enable = is_enable;
6569 mp->is_ipv6 = is_ipv6;
6574 /* Wait for a reply... */
6580 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6582 unformat_input_t *i = vam->input;
6583 vl_api_sw_interface_set_l2_xconnect_t *mp;
6585 u8 rx_sw_if_index_set = 0;
6587 u8 tx_sw_if_index_set = 0;
6591 /* Parse args required to build the message */
6592 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6594 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6595 rx_sw_if_index_set = 1;
6596 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6597 tx_sw_if_index_set = 1;
6598 else if (unformat (i, "rx"))
6600 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6602 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6604 rx_sw_if_index_set = 1;
6609 else if (unformat (i, "tx"))
6611 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6613 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6615 tx_sw_if_index_set = 1;
6620 else if (unformat (i, "enable"))
6622 else if (unformat (i, "disable"))
6628 if (rx_sw_if_index_set == 0)
6630 errmsg ("missing rx interface name or rx_sw_if_index");
6634 if (enable && (tx_sw_if_index_set == 0))
6636 errmsg ("missing tx interface name or tx_sw_if_index");
6640 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6642 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6643 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6644 mp->enable = enable;
6652 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6654 unformat_input_t *i = vam->input;
6655 vl_api_sw_interface_set_l2_bridge_t *mp;
6657 u8 rx_sw_if_index_set = 0;
6665 /* Parse args required to build the message */
6666 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6668 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6669 rx_sw_if_index_set = 1;
6670 else if (unformat (i, "bd_id %d", &bd_id))
6674 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6675 rx_sw_if_index_set = 1;
6676 else if (unformat (i, "shg %d", &shg))
6678 else if (unformat (i, "bvi"))
6680 else if (unformat (i, "enable"))
6682 else if (unformat (i, "disable"))
6688 if (rx_sw_if_index_set == 0)
6690 errmsg ("missing rx interface name or sw_if_index");
6694 if (enable && (bd_id_set == 0))
6696 errmsg ("missing bridge domain");
6700 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6702 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6703 mp->bd_id = ntohl (bd_id);
6706 mp->enable = enable;
6714 api_bridge_domain_dump (vat_main_t * vam)
6716 unformat_input_t *i = vam->input;
6717 vl_api_bridge_domain_dump_t *mp;
6718 vl_api_control_ping_t *mp_ping;
6722 /* Parse args required to build the message */
6723 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6725 if (unformat (i, "bd_id %d", &bd_id))
6731 M (BRIDGE_DOMAIN_DUMP, mp);
6732 mp->bd_id = ntohl (bd_id);
6735 /* Use a control ping for synchronization */
6736 MPING (CONTROL_PING, mp_ping);
6744 api_bridge_domain_add_del (vat_main_t * vam)
6746 unformat_input_t *i = vam->input;
6747 vl_api_bridge_domain_add_del_t *mp;
6750 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6755 /* Parse args required to build the message */
6756 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6758 if (unformat (i, "bd_id %d", &bd_id))
6760 else if (unformat (i, "flood %d", &flood))
6762 else if (unformat (i, "uu-flood %d", &uu_flood))
6764 else if (unformat (i, "forward %d", &forward))
6766 else if (unformat (i, "learn %d", &learn))
6768 else if (unformat (i, "arp-term %d", &arp_term))
6770 else if (unformat (i, "mac-age %d", &mac_age))
6772 else if (unformat (i, "bd-tag %s", &bd_tag))
6774 else if (unformat (i, "del"))
6777 flood = uu_flood = forward = learn = 0;
6785 errmsg ("missing bridge domain");
6792 errmsg ("mac age must be less than 256 ");
6797 if ((bd_tag) && (strlen ((char *) bd_tag) > 63))
6799 errmsg ("bd-tag cannot be longer than 63");
6804 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6806 mp->bd_id = ntohl (bd_id);
6808 mp->uu_flood = uu_flood;
6809 mp->forward = forward;
6811 mp->arp_term = arp_term;
6812 mp->is_add = is_add;
6813 mp->mac_age = (u8) mac_age;
6815 strcpy ((char *) mp->bd_tag, (char *) bd_tag);
6826 api_l2fib_flush_bd (vat_main_t * vam)
6828 unformat_input_t *i = vam->input;
6829 vl_api_l2fib_flush_bd_t *mp;
6833 /* Parse args required to build the message */
6834 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6836 if (unformat (i, "bd_id %d", &bd_id));
6843 errmsg ("missing bridge domain");
6847 M (L2FIB_FLUSH_BD, mp);
6849 mp->bd_id = htonl (bd_id);
6857 api_l2fib_flush_int (vat_main_t * vam)
6859 unformat_input_t *i = vam->input;
6860 vl_api_l2fib_flush_int_t *mp;
6861 u32 sw_if_index = ~0;
6864 /* Parse args required to build the message */
6865 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6867 if (unformat (i, "sw_if_index %d", &sw_if_index));
6869 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6874 if (sw_if_index == ~0)
6876 errmsg ("missing interface name or sw_if_index");
6880 M (L2FIB_FLUSH_INT, mp);
6882 mp->sw_if_index = ntohl (sw_if_index);
6890 api_l2fib_add_del (vat_main_t * vam)
6892 unformat_input_t *i = vam->input;
6893 vl_api_l2fib_add_del_t *mp;
6899 u32 sw_if_index = ~0;
6900 u8 sw_if_index_set = 0;
6909 /* Parse args required to build the message */
6910 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6912 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6914 else if (unformat (i, "bd_id %d", &bd_id))
6916 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6917 sw_if_index_set = 1;
6918 else if (unformat (i, "sw_if"))
6920 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6923 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6924 sw_if_index_set = 1;
6929 else if (unformat (i, "static"))
6931 else if (unformat (i, "filter"))
6936 else if (unformat (i, "bvi"))
6941 else if (unformat (i, "del"))
6943 else if (unformat (i, "count %d", &count))
6951 errmsg ("missing mac address");
6957 errmsg ("missing bridge domain");
6961 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6963 errmsg ("missing interface name or sw_if_index");
6969 /* Turn on async mode */
6970 vam->async_mode = 1;
6971 vam->async_errors = 0;
6972 before = vat_time_now (vam);
6975 for (j = 0; j < count; j++)
6977 M (L2FIB_ADD_DEL, mp);
6980 mp->bd_id = ntohl (bd_id);
6981 mp->is_add = is_add;
6985 mp->sw_if_index = ntohl (sw_if_index);
6986 mp->static_mac = static_mac;
6987 mp->filter_mac = filter_mac;
6988 mp->bvi_mac = bvi_mac;
6990 increment_mac_address (&mac);
6997 vl_api_control_ping_t *mp_ping;
7000 /* Shut off async mode */
7001 vam->async_mode = 0;
7003 MPING (CONTROL_PING, mp_ping);
7006 timeout = vat_time_now (vam) + 1.0;
7007 while (vat_time_now (vam) < timeout)
7008 if (vam->result_ready == 1)
7013 if (vam->retval == -99)
7016 if (vam->async_errors > 0)
7018 errmsg ("%d asynchronous errors", vam->async_errors);
7021 vam->async_errors = 0;
7022 after = vat_time_now (vam);
7024 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7025 count, after - before, count / (after - before));
7031 /* Wait for a reply... */
7035 /* Return the good/bad news */
7036 return (vam->retval);
7040 api_bridge_domain_set_mac_age (vat_main_t * vam)
7042 unformat_input_t *i = vam->input;
7043 vl_api_bridge_domain_set_mac_age_t *mp;
7048 /* Parse args required to build the message */
7049 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7051 if (unformat (i, "bd_id %d", &bd_id));
7052 else if (unformat (i, "mac-age %d", &mac_age));
7059 errmsg ("missing bridge domain");
7065 errmsg ("mac age must be less than 256 ");
7069 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7071 mp->bd_id = htonl (bd_id);
7072 mp->mac_age = (u8) mac_age;
7080 api_l2_flags (vat_main_t * vam)
7082 unformat_input_t *i = vam->input;
7083 vl_api_l2_flags_t *mp;
7086 u8 sw_if_index_set = 0;
7090 /* Parse args required to build the message */
7091 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7093 if (unformat (i, "sw_if_index %d", &sw_if_index))
7094 sw_if_index_set = 1;
7095 else if (unformat (i, "sw_if"))
7097 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7100 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7101 sw_if_index_set = 1;
7106 else if (unformat (i, "learn"))
7108 else if (unformat (i, "forward"))
7110 else if (unformat (i, "flood"))
7112 else if (unformat (i, "uu-flood"))
7113 flags |= L2_UU_FLOOD;
7114 else if (unformat (i, "arp-term"))
7115 flags |= L2_ARP_TERM;
7116 else if (unformat (i, "off"))
7118 else if (unformat (i, "disable"))
7124 if (sw_if_index_set == 0)
7126 errmsg ("missing interface name or sw_if_index");
7132 mp->sw_if_index = ntohl (sw_if_index);
7133 mp->feature_bitmap = ntohl (flags);
7134 mp->is_set = is_set;
7142 api_bridge_flags (vat_main_t * vam)
7144 unformat_input_t *i = vam->input;
7145 vl_api_bridge_flags_t *mp;
7152 /* Parse args required to build the message */
7153 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7155 if (unformat (i, "bd_id %d", &bd_id))
7157 else if (unformat (i, "learn"))
7159 else if (unformat (i, "forward"))
7161 else if (unformat (i, "flood"))
7163 else if (unformat (i, "uu-flood"))
7164 flags |= L2_UU_FLOOD;
7165 else if (unformat (i, "arp-term"))
7166 flags |= L2_ARP_TERM;
7167 else if (unformat (i, "off"))
7169 else if (unformat (i, "disable"))
7177 errmsg ("missing bridge domain");
7181 M (BRIDGE_FLAGS, mp);
7183 mp->bd_id = ntohl (bd_id);
7184 mp->feature_bitmap = ntohl (flags);
7185 mp->is_set = is_set;
7193 api_bd_ip_mac_add_del (vat_main_t * vam)
7195 unformat_input_t *i = vam->input;
7196 vl_api_bd_ip_mac_add_del_t *mp;
7203 ip4_address_t v4addr;
7204 ip6_address_t v6addr;
7209 /* Parse args required to build the message */
7210 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7212 if (unformat (i, "bd_id %d", &bd_id))
7216 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7220 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7225 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7229 else if (unformat (i, "del"))
7237 errmsg ("missing bridge domain");
7240 else if (ip_set == 0)
7242 errmsg ("missing IP address");
7245 else if (mac_set == 0)
7247 errmsg ("missing MAC address");
7251 M (BD_IP_MAC_ADD_DEL, mp);
7253 mp->bd_id = ntohl (bd_id);
7254 mp->is_ipv6 = is_ipv6;
7255 mp->is_add = is_add;
7257 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7259 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7260 clib_memcpy (mp->mac_address, macaddr, 6);
7267 api_tap_connect (vat_main_t * vam)
7269 unformat_input_t *i = vam->input;
7270 vl_api_tap_connect_t *mp;
7276 ip4_address_t ip4_address;
7278 int ip4_address_set = 0;
7279 ip6_address_t ip6_address;
7281 int ip6_address_set = 0;
7284 memset (mac_address, 0, sizeof (mac_address));
7286 /* Parse args required to build the message */
7287 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7289 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7293 else if (unformat (i, "random-mac"))
7295 else if (unformat (i, "tapname %s", &tap_name))
7297 else if (unformat (i, "tag %s", &tag))
7299 else if (unformat (i, "address %U/%d",
7300 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7301 ip4_address_set = 1;
7302 else if (unformat (i, "address %U/%d",
7303 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7304 ip6_address_set = 1;
7311 errmsg ("missing tap name");
7314 if (vec_len (tap_name) > 63)
7316 errmsg ("tap name too long");
7319 vec_add1 (tap_name, 0);
7321 if (vec_len (tag) > 63)
7323 errmsg ("tag too long");
7327 /* Construct the API message */
7328 M (TAP_CONNECT, mp);
7330 mp->use_random_mac = random_mac;
7331 clib_memcpy (mp->mac_address, mac_address, 6);
7332 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7334 clib_memcpy (mp->tag, tag, vec_len (tag));
7336 if (ip4_address_set)
7338 mp->ip4_address_set = 1;
7339 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7340 mp->ip4_mask_width = ip4_mask_width;
7342 if (ip6_address_set)
7344 mp->ip6_address_set = 1;
7345 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7346 mp->ip6_mask_width = ip6_mask_width;
7349 vec_free (tap_name);
7355 /* Wait for a reply... */
7361 api_tap_modify (vat_main_t * vam)
7363 unformat_input_t *i = vam->input;
7364 vl_api_tap_modify_t *mp;
7369 u32 sw_if_index = ~0;
7370 u8 sw_if_index_set = 0;
7373 memset (mac_address, 0, sizeof (mac_address));
7375 /* Parse args required to build the message */
7376 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7378 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7379 sw_if_index_set = 1;
7380 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7381 sw_if_index_set = 1;
7382 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7386 else if (unformat (i, "random-mac"))
7388 else if (unformat (i, "tapname %s", &tap_name))
7394 if (sw_if_index_set == 0)
7396 errmsg ("missing vpp interface name");
7401 errmsg ("missing tap name");
7404 if (vec_len (tap_name) > 63)
7406 errmsg ("tap name too long");
7408 vec_add1 (tap_name, 0);
7410 /* Construct the API message */
7413 mp->use_random_mac = random_mac;
7414 mp->sw_if_index = ntohl (sw_if_index);
7415 clib_memcpy (mp->mac_address, mac_address, 6);
7416 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7417 vec_free (tap_name);
7422 /* Wait for a reply... */
7428 api_tap_delete (vat_main_t * vam)
7430 unformat_input_t *i = vam->input;
7431 vl_api_tap_delete_t *mp;
7432 u32 sw_if_index = ~0;
7433 u8 sw_if_index_set = 0;
7436 /* Parse args required to build the message */
7437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7439 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7440 sw_if_index_set = 1;
7441 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7442 sw_if_index_set = 1;
7447 if (sw_if_index_set == 0)
7449 errmsg ("missing vpp interface name");
7453 /* Construct the API message */
7456 mp->sw_if_index = ntohl (sw_if_index);
7461 /* Wait for a reply... */
7467 api_ip_table_add_del (vat_main_t * vam)
7469 unformat_input_t *i = vam->input;
7470 vl_api_ip_table_add_del_t *mp;
7476 /* Parse args required to build the message */
7477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7479 if (unformat (i, "ipv6"))
7481 else if (unformat (i, "del"))
7483 else if (unformat (i, "add"))
7485 else if (unformat (i, "table %d", &table_id))
7489 clib_warning ("parse error '%U'", format_unformat_error, i);
7496 errmsg ("missing table-ID");
7500 /* Construct the API message */
7501 M (IP_TABLE_ADD_DEL, mp);
7503 mp->table_id = ntohl (table_id);
7504 mp->is_ipv6 = is_ipv6;
7505 mp->is_add = is_add;
7510 /* Wait for a reply... */
7517 api_ip_add_del_route (vat_main_t * vam)
7519 unformat_input_t *i = vam->input;
7520 vl_api_ip_add_del_route_t *mp;
7521 u32 sw_if_index = ~0, vrf_id = 0;
7523 u8 is_local = 0, is_drop = 0;
7524 u8 is_unreach = 0, is_prohibit = 0;
7525 u8 create_vrf_if_needed = 0;
7527 u32 next_hop_weight = 1;
7529 u8 is_multipath = 0;
7531 u8 address_length_set = 0;
7532 u32 next_hop_table_id = 0;
7533 u32 resolve_attempts = 0;
7534 u32 dst_address_length = 0;
7535 u8 next_hop_set = 0;
7536 ip4_address_t v4_dst_address, v4_next_hop_address;
7537 ip6_address_t v6_dst_address, v6_next_hop_address;
7541 u32 random_add_del = 0;
7542 u32 *random_vector = 0;
7544 u32 random_seed = 0xdeaddabe;
7545 u32 classify_table_index = ~0;
7547 u8 resolve_host = 0, resolve_attached = 0;
7548 mpls_label_t *next_hop_out_label_stack = NULL;
7549 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7550 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7552 /* Parse args required to build the message */
7553 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7555 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7557 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7559 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
7564 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
7569 else if (unformat (i, "/%d", &dst_address_length))
7571 address_length_set = 1;
7574 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
7575 &v4_next_hop_address))
7579 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7580 &v6_next_hop_address))
7584 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7586 else if (unformat (i, "weight %d", &next_hop_weight))
7588 else if (unformat (i, "drop"))
7592 else if (unformat (i, "null-send-unreach"))
7596 else if (unformat (i, "null-send-prohibit"))
7600 else if (unformat (i, "local"))
7604 else if (unformat (i, "classify %d", &classify_table_index))
7608 else if (unformat (i, "del"))
7610 else if (unformat (i, "add"))
7612 else if (unformat (i, "not-last"))
7614 else if (unformat (i, "resolve-via-host"))
7616 else if (unformat (i, "resolve-via-attached"))
7617 resolve_attached = 1;
7618 else if (unformat (i, "multipath"))
7620 else if (unformat (i, "vrf %d", &vrf_id))
7622 else if (unformat (i, "create-vrf"))
7623 create_vrf_if_needed = 1;
7624 else if (unformat (i, "count %d", &count))
7626 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7628 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7630 else if (unformat (i, "out-label %d", &next_hop_out_label))
7631 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7632 else if (unformat (i, "via-label %d", &next_hop_via_label))
7634 else if (unformat (i, "random"))
7636 else if (unformat (i, "seed %d", &random_seed))
7640 clib_warning ("parse error '%U'", format_unformat_error, i);
7645 if (!next_hop_set && !is_drop && !is_local &&
7646 !is_classify && !is_unreach && !is_prohibit &&
7647 MPLS_LABEL_INVALID == next_hop_via_label)
7650 ("next hop / local / drop / unreach / prohibit / classify not set");
7654 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7656 errmsg ("next hop and next-hop via label set");
7659 if (address_set == 0)
7661 errmsg ("missing addresses");
7665 if (address_length_set == 0)
7667 errmsg ("missing address length");
7671 /* Generate a pile of unique, random routes */
7674 u32 this_random_address;
7675 random_hash = hash_create (count, sizeof (uword));
7677 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7678 for (j = 0; j <= count; j++)
7682 this_random_address = random_u32 (&random_seed);
7683 this_random_address =
7684 clib_host_to_net_u32 (this_random_address);
7686 while (hash_get (random_hash, this_random_address));
7687 vec_add1 (random_vector, this_random_address);
7688 hash_set (random_hash, this_random_address, 1);
7690 hash_free (random_hash);
7691 v4_dst_address.as_u32 = random_vector[0];
7696 /* Turn on async mode */
7697 vam->async_mode = 1;
7698 vam->async_errors = 0;
7699 before = vat_time_now (vam);
7702 for (j = 0; j < count; j++)
7704 /* Construct the API message */
7705 M2 (IP_ADD_DEL_ROUTE, mp,
7706 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7708 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7709 mp->table_id = ntohl (vrf_id);
7710 mp->create_vrf_if_needed = create_vrf_if_needed;
7712 mp->is_add = is_add;
7713 mp->is_drop = is_drop;
7714 mp->is_unreach = is_unreach;
7715 mp->is_prohibit = is_prohibit;
7716 mp->is_ipv6 = is_ipv6;
7717 mp->is_local = is_local;
7718 mp->is_classify = is_classify;
7719 mp->is_multipath = is_multipath;
7720 mp->is_resolve_host = resolve_host;
7721 mp->is_resolve_attached = resolve_attached;
7722 mp->not_last = not_last;
7723 mp->next_hop_weight = next_hop_weight;
7724 mp->dst_address_length = dst_address_length;
7725 mp->next_hop_table_id = ntohl (next_hop_table_id);
7726 mp->classify_table_index = ntohl (classify_table_index);
7727 mp->next_hop_via_label = ntohl (next_hop_via_label);
7728 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7729 if (0 != mp->next_hop_n_out_labels)
7731 memcpy (mp->next_hop_out_label_stack,
7732 next_hop_out_label_stack,
7733 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7734 vec_free (next_hop_out_label_stack);
7739 clib_memcpy (mp->dst_address, &v6_dst_address,
7740 sizeof (v6_dst_address));
7742 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
7743 sizeof (v6_next_hop_address));
7744 increment_v6_address (&v6_dst_address);
7748 clib_memcpy (mp->dst_address, &v4_dst_address,
7749 sizeof (v4_dst_address));
7751 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
7752 sizeof (v4_next_hop_address));
7754 v4_dst_address.as_u32 = random_vector[j + 1];
7756 increment_v4_address (&v4_dst_address);
7760 /* If we receive SIGTERM, stop now... */
7765 /* When testing multiple add/del ops, use a control-ping to sync */
7768 vl_api_control_ping_t *mp_ping;
7772 /* Shut off async mode */
7773 vam->async_mode = 0;
7775 MPING (CONTROL_PING, mp_ping);
7778 timeout = vat_time_now (vam) + 1.0;
7779 while (vat_time_now (vam) < timeout)
7780 if (vam->result_ready == 1)
7785 if (vam->retval == -99)
7788 if (vam->async_errors > 0)
7790 errmsg ("%d asynchronous errors", vam->async_errors);
7793 vam->async_errors = 0;
7794 after = vat_time_now (vam);
7796 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7800 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7801 count, after - before, count / (after - before));
7807 /* Wait for a reply... */
7812 /* Return the good/bad news */
7813 return (vam->retval);
7817 api_ip_mroute_add_del (vat_main_t * vam)
7819 unformat_input_t *i = vam->input;
7820 vl_api_ip_mroute_add_del_t *mp;
7821 u32 sw_if_index = ~0, vrf_id = 0;
7824 u8 create_vrf_if_needed = 0;
7827 u32 grp_address_length = 0;
7828 ip4_address_t v4_grp_address, v4_src_address;
7829 ip6_address_t v6_grp_address, v6_src_address;
7830 mfib_itf_flags_t iflags = 0;
7831 mfib_entry_flags_t eflags = 0;
7834 /* Parse args required to build the message */
7835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7837 if (unformat (i, "sw_if_index %d", &sw_if_index))
7839 else if (unformat (i, "%U %U",
7840 unformat_ip4_address, &v4_src_address,
7841 unformat_ip4_address, &v4_grp_address))
7843 grp_address_length = 64;
7847 else if (unformat (i, "%U %U",
7848 unformat_ip6_address, &v6_src_address,
7849 unformat_ip6_address, &v6_grp_address))
7851 grp_address_length = 256;
7855 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7857 memset (&v4_src_address, 0, sizeof (v4_src_address));
7858 grp_address_length = 32;
7862 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7864 memset (&v6_src_address, 0, sizeof (v6_src_address));
7865 grp_address_length = 128;
7869 else if (unformat (i, "/%d", &grp_address_length))
7871 else if (unformat (i, "local"))
7875 else if (unformat (i, "del"))
7877 else if (unformat (i, "add"))
7879 else if (unformat (i, "vrf %d", &vrf_id))
7881 else if (unformat (i, "create-vrf"))
7882 create_vrf_if_needed = 1;
7883 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
7885 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7889 clib_warning ("parse error '%U'", format_unformat_error, i);
7894 if (address_set == 0)
7896 errmsg ("missing addresses\n");
7900 /* Construct the API message */
7901 M (IP_MROUTE_ADD_DEL, mp);
7903 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7904 mp->table_id = ntohl (vrf_id);
7905 mp->create_vrf_if_needed = create_vrf_if_needed;
7907 mp->is_add = is_add;
7908 mp->is_ipv6 = is_ipv6;
7909 mp->is_local = is_local;
7910 mp->itf_flags = ntohl (iflags);
7911 mp->entry_flags = ntohl (eflags);
7912 mp->grp_address_length = grp_address_length;
7913 mp->grp_address_length = ntohs (mp->grp_address_length);
7917 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7918 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7922 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7923 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7929 /* Wait for a reply... */
7935 api_mpls_table_add_del (vat_main_t * vam)
7937 unformat_input_t *i = vam->input;
7938 vl_api_mpls_table_add_del_t *mp;
7943 /* Parse args required to build the message */
7944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7946 if (unformat (i, "table %d", &table_id))
7948 else if (unformat (i, "del"))
7950 else if (unformat (i, "add"))
7954 clib_warning ("parse error '%U'", format_unformat_error, i);
7961 errmsg ("missing table-ID");
7965 /* Construct the API message */
7966 M (MPLS_TABLE_ADD_DEL, mp);
7968 mp->mt_table_id = ntohl (table_id);
7969 mp->mt_is_add = is_add;
7974 /* Wait for a reply... */
7981 api_mpls_route_add_del (vat_main_t * vam)
7983 unformat_input_t *i = vam->input;
7984 vl_api_mpls_route_add_del_t *mp;
7985 u32 sw_if_index = ~0, table_id = 0;
7986 u8 create_table_if_needed = 0;
7988 u32 next_hop_weight = 1;
7989 u8 is_multipath = 0;
7990 u32 next_hop_table_id = 0;
7991 u8 next_hop_set = 0;
7992 ip4_address_t v4_next_hop_address = {
7995 ip6_address_t v6_next_hop_address = { {0} };
7999 u32 classify_table_index = ~0;
8001 u8 resolve_host = 0, resolve_attached = 0;
8002 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8003 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8004 mpls_label_t *next_hop_out_label_stack = NULL;
8005 mpls_label_t local_label = MPLS_LABEL_INVALID;
8007 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8009 /* Parse args required to build the message */
8010 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8012 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8014 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8016 else if (unformat (i, "%d", &local_label))
8018 else if (unformat (i, "eos"))
8020 else if (unformat (i, "non-eos"))
8022 else if (unformat (i, "via %U", unformat_ip4_address,
8023 &v4_next_hop_address))
8026 next_hop_proto = DPO_PROTO_IP4;
8028 else if (unformat (i, "via %U", unformat_ip6_address,
8029 &v6_next_hop_address))
8032 next_hop_proto = DPO_PROTO_IP6;
8034 else if (unformat (i, "weight %d", &next_hop_weight))
8036 else if (unformat (i, "create-table"))
8037 create_table_if_needed = 1;
8038 else if (unformat (i, "classify %d", &classify_table_index))
8042 else if (unformat (i, "del"))
8044 else if (unformat (i, "add"))
8046 else if (unformat (i, "resolve-via-host"))
8048 else if (unformat (i, "resolve-via-attached"))
8049 resolve_attached = 1;
8050 else if (unformat (i, "multipath"))
8052 else if (unformat (i, "count %d", &count))
8054 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8057 next_hop_proto = DPO_PROTO_IP4;
8059 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8062 next_hop_proto = DPO_PROTO_IP6;
8064 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8066 else if (unformat (i, "via-label %d", &next_hop_via_label))
8068 else if (unformat (i, "out-label %d", &next_hop_out_label))
8069 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8072 clib_warning ("parse error '%U'", format_unformat_error, i);
8077 if (!next_hop_set && !is_classify)
8079 errmsg ("next hop / classify not set");
8083 if (MPLS_LABEL_INVALID == local_label)
8085 errmsg ("missing label");
8091 /* Turn on async mode */
8092 vam->async_mode = 1;
8093 vam->async_errors = 0;
8094 before = vat_time_now (vam);
8097 for (j = 0; j < count; j++)
8099 /* Construct the API message */
8100 M2 (MPLS_ROUTE_ADD_DEL, mp,
8101 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8103 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8104 mp->mr_table_id = ntohl (table_id);
8105 mp->mr_create_table_if_needed = create_table_if_needed;
8107 mp->mr_is_add = is_add;
8108 mp->mr_next_hop_proto = next_hop_proto;
8109 mp->mr_is_classify = is_classify;
8110 mp->mr_is_multipath = is_multipath;
8111 mp->mr_is_resolve_host = resolve_host;
8112 mp->mr_is_resolve_attached = resolve_attached;
8113 mp->mr_next_hop_weight = next_hop_weight;
8114 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8115 mp->mr_classify_table_index = ntohl (classify_table_index);
8116 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8117 mp->mr_label = ntohl (local_label);
8118 mp->mr_eos = is_eos;
8120 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8121 if (0 != mp->mr_next_hop_n_out_labels)
8123 memcpy (mp->mr_next_hop_out_label_stack,
8124 next_hop_out_label_stack,
8125 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8126 vec_free (next_hop_out_label_stack);
8131 if (DPO_PROTO_IP4 == next_hop_proto)
8133 clib_memcpy (mp->mr_next_hop,
8134 &v4_next_hop_address,
8135 sizeof (v4_next_hop_address));
8137 else if (DPO_PROTO_IP6 == next_hop_proto)
8140 clib_memcpy (mp->mr_next_hop,
8141 &v6_next_hop_address,
8142 sizeof (v6_next_hop_address));
8149 /* If we receive SIGTERM, stop now... */
8154 /* When testing multiple add/del ops, use a control-ping to sync */
8157 vl_api_control_ping_t *mp_ping;
8161 /* Shut off async mode */
8162 vam->async_mode = 0;
8164 MPING (CONTROL_PING, mp_ping);
8167 timeout = vat_time_now (vam) + 1.0;
8168 while (vat_time_now (vam) < timeout)
8169 if (vam->result_ready == 1)
8174 if (vam->retval == -99)
8177 if (vam->async_errors > 0)
8179 errmsg ("%d asynchronous errors", vam->async_errors);
8182 vam->async_errors = 0;
8183 after = vat_time_now (vam);
8185 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8189 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8190 count, after - before, count / (after - before));
8196 /* Wait for a reply... */
8201 /* Return the good/bad news */
8202 return (vam->retval);
8206 api_mpls_ip_bind_unbind (vat_main_t * vam)
8208 unformat_input_t *i = vam->input;
8209 vl_api_mpls_ip_bind_unbind_t *mp;
8210 u32 ip_table_id = 0;
8211 u8 create_table_if_needed = 0;
8214 ip4_address_t v4_address;
8215 ip6_address_t v6_address;
8218 mpls_label_t local_label = MPLS_LABEL_INVALID;
8221 /* Parse args required to build the message */
8222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8224 if (unformat (i, "%U/%d", unformat_ip4_address,
8225 &v4_address, &address_length))
8230 else if (unformat (i, "%U/%d", unformat_ip6_address,
8231 &v6_address, &address_length))
8236 else if (unformat (i, "%d", &local_label))
8238 else if (unformat (i, "create-table"))
8239 create_table_if_needed = 1;
8240 else if (unformat (i, "table-id %d", &ip_table_id))
8242 else if (unformat (i, "unbind"))
8244 else if (unformat (i, "bind"))
8248 clib_warning ("parse error '%U'", format_unformat_error, i);
8255 errmsg ("IP addres not set");
8259 if (MPLS_LABEL_INVALID == local_label)
8261 errmsg ("missing label");
8265 /* Construct the API message */
8266 M (MPLS_IP_BIND_UNBIND, mp);
8268 mp->mb_create_table_if_needed = create_table_if_needed;
8269 mp->mb_is_bind = is_bind;
8270 mp->mb_is_ip4 = is_ip4;
8271 mp->mb_ip_table_id = ntohl (ip_table_id);
8272 mp->mb_mpls_table_id = 0;
8273 mp->mb_label = ntohl (local_label);
8274 mp->mb_address_length = address_length;
8277 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8279 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8284 /* Wait for a reply... */
8290 api_proxy_arp_add_del (vat_main_t * vam)
8292 unformat_input_t *i = vam->input;
8293 vl_api_proxy_arp_add_del_t *mp;
8296 ip4_address_t lo, hi;
8300 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8302 if (unformat (i, "vrf %d", &vrf_id))
8304 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
8305 unformat_ip4_address, &hi))
8307 else if (unformat (i, "del"))
8311 clib_warning ("parse error '%U'", format_unformat_error, i);
8318 errmsg ("address range not set");
8322 M (PROXY_ARP_ADD_DEL, mp);
8324 mp->vrf_id = ntohl (vrf_id);
8325 mp->is_add = is_add;
8326 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
8327 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
8335 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8337 unformat_input_t *i = vam->input;
8338 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8341 u8 sw_if_index_set = 0;
8344 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8346 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8347 sw_if_index_set = 1;
8348 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8349 sw_if_index_set = 1;
8350 else if (unformat (i, "enable"))
8352 else if (unformat (i, "disable"))
8356 clib_warning ("parse error '%U'", format_unformat_error, i);
8361 if (sw_if_index_set == 0)
8363 errmsg ("missing interface name or sw_if_index");
8367 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8369 mp->sw_if_index = ntohl (sw_if_index);
8370 mp->enable_disable = enable;
8378 api_mpls_tunnel_add_del (vat_main_t * vam)
8380 unformat_input_t *i = vam->input;
8381 vl_api_mpls_tunnel_add_del_t *mp;
8385 u32 sw_if_index = ~0;
8386 u32 next_hop_sw_if_index = ~0;
8387 u32 next_hop_proto_is_ip4 = 1;
8389 u32 next_hop_table_id = 0;
8390 ip4_address_t v4_next_hop_address = {
8393 ip6_address_t v6_next_hop_address = { {0} };
8394 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
8397 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8399 if (unformat (i, "add"))
8401 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8403 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
8405 else if (unformat (i, "via %U",
8406 unformat_ip4_address, &v4_next_hop_address))
8408 next_hop_proto_is_ip4 = 1;
8410 else if (unformat (i, "via %U",
8411 unformat_ip6_address, &v6_next_hop_address))
8413 next_hop_proto_is_ip4 = 0;
8415 else if (unformat (i, "l2-only"))
8417 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8419 else if (unformat (i, "out-label %d", &next_hop_out_label))
8420 vec_add1 (labels, ntohl (next_hop_out_label));
8423 clib_warning ("parse error '%U'", format_unformat_error, i);
8428 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
8430 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
8431 mp->mt_sw_if_index = ntohl (sw_if_index);
8432 mp->mt_is_add = is_add;
8433 mp->mt_l2_only = l2_only;
8434 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
8435 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
8437 mp->mt_next_hop_n_out_labels = vec_len (labels);
8439 if (0 != mp->mt_next_hop_n_out_labels)
8441 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
8442 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
8446 if (next_hop_proto_is_ip4)
8448 clib_memcpy (mp->mt_next_hop,
8449 &v4_next_hop_address, sizeof (v4_next_hop_address));
8453 clib_memcpy (mp->mt_next_hop,
8454 &v6_next_hop_address, sizeof (v6_next_hop_address));
8463 api_sw_interface_set_unnumbered (vat_main_t * vam)
8465 unformat_input_t *i = vam->input;
8466 vl_api_sw_interface_set_unnumbered_t *mp;
8468 u32 unnum_sw_index = ~0;
8470 u8 sw_if_index_set = 0;
8473 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8475 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8476 sw_if_index_set = 1;
8477 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8478 sw_if_index_set = 1;
8479 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8481 else if (unformat (i, "del"))
8485 clib_warning ("parse error '%U'", format_unformat_error, i);
8490 if (sw_if_index_set == 0)
8492 errmsg ("missing interface name or sw_if_index");
8496 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8498 mp->sw_if_index = ntohl (sw_if_index);
8499 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8500 mp->is_add = is_add;
8508 api_ip_neighbor_add_del (vat_main_t * vam)
8510 unformat_input_t *i = vam->input;
8511 vl_api_ip_neighbor_add_del_t *mp;
8513 u8 sw_if_index_set = 0;
8516 u8 is_no_fib_entry = 0;
8519 u8 v4_address_set = 0;
8520 u8 v6_address_set = 0;
8521 ip4_address_t v4address;
8522 ip6_address_t v6address;
8525 memset (mac_address, 0, sizeof (mac_address));
8527 /* Parse args required to build the message */
8528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8530 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8534 else if (unformat (i, "del"))
8537 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8538 sw_if_index_set = 1;
8539 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8540 sw_if_index_set = 1;
8541 else if (unformat (i, "is_static"))
8543 else if (unformat (i, "no-fib-entry"))
8544 is_no_fib_entry = 1;
8545 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
8547 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
8551 clib_warning ("parse error '%U'", format_unformat_error, i);
8556 if (sw_if_index_set == 0)
8558 errmsg ("missing interface name or sw_if_index");
8561 if (v4_address_set && v6_address_set)
8563 errmsg ("both v4 and v6 addresses set");
8566 if (!v4_address_set && !v6_address_set)
8568 errmsg ("no address set");
8572 /* Construct the API message */
8573 M (IP_NEIGHBOR_ADD_DEL, mp);
8575 mp->sw_if_index = ntohl (sw_if_index);
8576 mp->is_add = is_add;
8577 mp->is_static = is_static;
8578 mp->is_no_adj_fib = is_no_fib_entry;
8580 clib_memcpy (mp->mac_address, mac_address, 6);
8584 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
8588 /* mp->is_ipv6 = 0; via memset in M macro above */
8589 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
8595 /* Wait for a reply, return good/bad news */
8601 api_reset_vrf (vat_main_t * vam)
8603 unformat_input_t *i = vam->input;
8604 vl_api_reset_vrf_t *mp;
8610 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8612 if (unformat (i, "vrf %d", &vrf_id))
8614 else if (unformat (i, "ipv6"))
8618 clib_warning ("parse error '%U'", format_unformat_error, i);
8623 if (vrf_id_set == 0)
8625 errmsg ("missing vrf id");
8631 mp->vrf_id = ntohl (vrf_id);
8632 mp->is_ipv6 = is_ipv6;
8640 api_create_vlan_subif (vat_main_t * vam)
8642 unformat_input_t *i = vam->input;
8643 vl_api_create_vlan_subif_t *mp;
8645 u8 sw_if_index_set = 0;
8650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8652 if (unformat (i, "sw_if_index %d", &sw_if_index))
8653 sw_if_index_set = 1;
8655 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8656 sw_if_index_set = 1;
8657 else if (unformat (i, "vlan %d", &vlan_id))
8661 clib_warning ("parse error '%U'", format_unformat_error, i);
8666 if (sw_if_index_set == 0)
8668 errmsg ("missing interface name or sw_if_index");
8672 if (vlan_id_set == 0)
8674 errmsg ("missing vlan_id");
8677 M (CREATE_VLAN_SUBIF, mp);
8679 mp->sw_if_index = ntohl (sw_if_index);
8680 mp->vlan_id = ntohl (vlan_id);
8687 #define foreach_create_subif_bit \
8694 _(outer_vlan_id_any) \
8695 _(inner_vlan_id_any)
8698 api_create_subif (vat_main_t * vam)
8700 unformat_input_t *i = vam->input;
8701 vl_api_create_subif_t *mp;
8703 u8 sw_if_index_set = 0;
8710 u32 exact_match = 0;
8711 u32 default_sub = 0;
8712 u32 outer_vlan_id_any = 0;
8713 u32 inner_vlan_id_any = 0;
8715 u16 outer_vlan_id = 0;
8716 u16 inner_vlan_id = 0;
8719 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8721 if (unformat (i, "sw_if_index %d", &sw_if_index))
8722 sw_if_index_set = 1;
8724 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8725 sw_if_index_set = 1;
8726 else if (unformat (i, "sub_id %d", &sub_id))
8728 else if (unformat (i, "outer_vlan_id %d", &tmp))
8729 outer_vlan_id = tmp;
8730 else if (unformat (i, "inner_vlan_id %d", &tmp))
8731 inner_vlan_id = tmp;
8733 #define _(a) else if (unformat (i, #a)) a = 1 ;
8734 foreach_create_subif_bit
8738 clib_warning ("parse error '%U'", format_unformat_error, i);
8743 if (sw_if_index_set == 0)
8745 errmsg ("missing interface name or sw_if_index");
8749 if (sub_id_set == 0)
8751 errmsg ("missing sub_id");
8754 M (CREATE_SUBIF, mp);
8756 mp->sw_if_index = ntohl (sw_if_index);
8757 mp->sub_id = ntohl (sub_id);
8759 #define _(a) mp->a = a;
8760 foreach_create_subif_bit;
8763 mp->outer_vlan_id = ntohs (outer_vlan_id);
8764 mp->inner_vlan_id = ntohs (inner_vlan_id);
8772 api_oam_add_del (vat_main_t * vam)
8774 unformat_input_t *i = vam->input;
8775 vl_api_oam_add_del_t *mp;
8778 ip4_address_t src, dst;
8783 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8785 if (unformat (i, "vrf %d", &vrf_id))
8787 else if (unformat (i, "src %U", unformat_ip4_address, &src))
8789 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
8791 else if (unformat (i, "del"))
8795 clib_warning ("parse error '%U'", format_unformat_error, i);
8802 errmsg ("missing src addr");
8808 errmsg ("missing dst addr");
8812 M (OAM_ADD_DEL, mp);
8814 mp->vrf_id = ntohl (vrf_id);
8815 mp->is_add = is_add;
8816 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
8817 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
8825 api_reset_fib (vat_main_t * vam)
8827 unformat_input_t *i = vam->input;
8828 vl_api_reset_fib_t *mp;
8834 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8836 if (unformat (i, "vrf %d", &vrf_id))
8838 else if (unformat (i, "ipv6"))
8842 clib_warning ("parse error '%U'", format_unformat_error, i);
8847 if (vrf_id_set == 0)
8849 errmsg ("missing vrf id");
8855 mp->vrf_id = ntohl (vrf_id);
8856 mp->is_ipv6 = is_ipv6;
8864 api_dhcp_proxy_config (vat_main_t * vam)
8866 unformat_input_t *i = vam->input;
8867 vl_api_dhcp_proxy_config_t *mp;
8869 u32 server_vrf_id = 0;
8871 u8 v4_address_set = 0;
8872 u8 v6_address_set = 0;
8873 ip4_address_t v4address;
8874 ip6_address_t v6address;
8875 u8 v4_src_address_set = 0;
8876 u8 v6_src_address_set = 0;
8877 ip4_address_t v4srcaddress;
8878 ip6_address_t v6srcaddress;
8881 /* Parse args required to build the message */
8882 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8884 if (unformat (i, "del"))
8886 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
8888 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
8890 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
8892 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
8894 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
8895 v4_src_address_set = 1;
8896 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
8897 v6_src_address_set = 1;
8902 if (v4_address_set && v6_address_set)
8904 errmsg ("both v4 and v6 server addresses set");
8907 if (!v4_address_set && !v6_address_set)
8909 errmsg ("no server addresses set");
8913 if (v4_src_address_set && v6_src_address_set)
8915 errmsg ("both v4 and v6 src addresses set");
8918 if (!v4_src_address_set && !v6_src_address_set)
8920 errmsg ("no src addresses set");
8924 if (!(v4_src_address_set && v4_address_set) &&
8925 !(v6_src_address_set && v6_address_set))
8927 errmsg ("no matching server and src addresses set");
8931 /* Construct the API message */
8932 M (DHCP_PROXY_CONFIG, mp);
8934 mp->is_add = is_add;
8935 mp->rx_vrf_id = ntohl (rx_vrf_id);
8936 mp->server_vrf_id = ntohl (server_vrf_id);
8940 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
8941 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
8945 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
8946 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
8952 /* Wait for a reply, return good/bad news */
8957 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
8958 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
8961 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
8963 vat_main_t *vam = &vat_main;
8964 u32 i, count = mp->count;
8965 vl_api_dhcp_server_t *s;
8969 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8970 ntohl (mp->rx_vrf_id),
8971 format_ip6_address, mp->dhcp_src_address,
8972 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8975 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8976 ntohl (mp->rx_vrf_id),
8977 format_ip4_address, mp->dhcp_src_address,
8978 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8980 for (i = 0; i < count; i++)
8982 s = &mp->servers[i];
8986 " Server Table-ID %d, Server Address %U",
8987 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
8990 " Server Table-ID %d, Server Address %U",
8991 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
8995 static void vl_api_dhcp_proxy_details_t_handler_json
8996 (vl_api_dhcp_proxy_details_t * mp)
8998 vat_main_t *vam = &vat_main;
8999 vat_json_node_t *node = NULL;
9000 u32 i, count = mp->count;
9002 struct in6_addr ip6;
9003 vl_api_dhcp_server_t *s;
9005 if (VAT_JSON_ARRAY != vam->json_tree.type)
9007 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9008 vat_json_init_array (&vam->json_tree);
9010 node = vat_json_array_add (&vam->json_tree);
9012 vat_json_init_object (node);
9013 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9014 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9015 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9019 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9020 vat_json_object_add_ip6 (node, "src_address", ip6);
9024 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9025 vat_json_object_add_ip4 (node, "src_address", ip4);
9028 for (i = 0; i < count; i++)
9030 s = &mp->servers[i];
9032 vat_json_object_add_uint (node, "server-table-id",
9033 ntohl (s->server_vrf_id));
9037 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9038 vat_json_object_add_ip4 (node, "src_address", ip4);
9042 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9043 vat_json_object_add_ip6 (node, "server_address", ip6);
9049 api_dhcp_proxy_dump (vat_main_t * vam)
9051 unformat_input_t *i = vam->input;
9052 vl_api_control_ping_t *mp_ping;
9053 vl_api_dhcp_proxy_dump_t *mp;
9057 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9059 if (unformat (i, "ipv6"))
9063 clib_warning ("parse error '%U'", format_unformat_error, i);
9068 M (DHCP_PROXY_DUMP, mp);
9070 mp->is_ip6 = is_ipv6;
9073 /* Use a control ping for synchronization */
9074 MPING (CONTROL_PING, mp_ping);
9082 api_dhcp_proxy_set_vss (vat_main_t * vam)
9084 unformat_input_t *i = vam->input;
9085 vl_api_dhcp_proxy_set_vss_t *mp;
9096 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9098 if (unformat (i, "tbl_id %d", &tbl_id))
9100 if (unformat (i, "fib_id %d", &fib_id))
9102 if (unformat (i, "oui %d", &oui))
9104 else if (unformat (i, "ipv6"))
9106 else if (unformat (i, "del"))
9110 clib_warning ("parse error '%U'", format_unformat_error, i);
9115 if (tbl_id_set == 0)
9117 errmsg ("missing tbl id");
9121 if (fib_id_set == 0)
9123 errmsg ("missing fib id");
9128 errmsg ("missing oui");
9132 M (DHCP_PROXY_SET_VSS, mp);
9133 mp->tbl_id = ntohl (tbl_id);
9134 mp->fib_id = ntohl (fib_id);
9135 mp->oui = ntohl (oui);
9136 mp->is_ipv6 = is_ipv6;
9137 mp->is_add = is_add;
9145 api_dhcp_client_config (vat_main_t * vam)
9147 unformat_input_t *i = vam->input;
9148 vl_api_dhcp_client_config_t *mp;
9150 u8 sw_if_index_set = 0;
9153 u8 disable_event = 0;
9156 /* Parse args required to build the message */
9157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9159 if (unformat (i, "del"))
9162 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9163 sw_if_index_set = 1;
9164 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9165 sw_if_index_set = 1;
9166 else if (unformat (i, "hostname %s", &hostname))
9168 else if (unformat (i, "disable_event"))
9174 if (sw_if_index_set == 0)
9176 errmsg ("missing interface name or sw_if_index");
9180 if (vec_len (hostname) > 63)
9182 errmsg ("hostname too long");
9184 vec_add1 (hostname, 0);
9186 /* Construct the API message */
9187 M (DHCP_CLIENT_CONFIG, mp);
9189 mp->sw_if_index = htonl (sw_if_index);
9190 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
9191 vec_free (hostname);
9192 mp->is_add = is_add;
9193 mp->want_dhcp_event = disable_event ? 0 : 1;
9194 mp->pid = htonl (getpid ());
9199 /* Wait for a reply, return good/bad news */
9205 api_set_ip_flow_hash (vat_main_t * vam)
9207 unformat_input_t *i = vam->input;
9208 vl_api_set_ip_flow_hash_t *mp;
9220 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9222 if (unformat (i, "vrf %d", &vrf_id))
9224 else if (unformat (i, "ipv6"))
9226 else if (unformat (i, "src"))
9228 else if (unformat (i, "dst"))
9230 else if (unformat (i, "sport"))
9232 else if (unformat (i, "dport"))
9234 else if (unformat (i, "proto"))
9236 else if (unformat (i, "reverse"))
9241 clib_warning ("parse error '%U'", format_unformat_error, i);
9246 if (vrf_id_set == 0)
9248 errmsg ("missing vrf id");
9252 M (SET_IP_FLOW_HASH, mp);
9258 mp->reverse = reverse;
9259 mp->vrf_id = ntohl (vrf_id);
9260 mp->is_ipv6 = is_ipv6;
9268 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9270 unformat_input_t *i = vam->input;
9271 vl_api_sw_interface_ip6_enable_disable_t *mp;
9273 u8 sw_if_index_set = 0;
9277 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9279 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9280 sw_if_index_set = 1;
9281 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9282 sw_if_index_set = 1;
9283 else if (unformat (i, "enable"))
9285 else if (unformat (i, "disable"))
9289 clib_warning ("parse error '%U'", format_unformat_error, i);
9294 if (sw_if_index_set == 0)
9296 errmsg ("missing interface name or sw_if_index");
9300 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9302 mp->sw_if_index = ntohl (sw_if_index);
9303 mp->enable = enable;
9311 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
9313 unformat_input_t *i = vam->input;
9314 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
9316 u8 sw_if_index_set = 0;
9317 u8 v6_address_set = 0;
9318 ip6_address_t v6address;
9321 /* Parse args required to build the message */
9322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9324 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9325 sw_if_index_set = 1;
9326 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9327 sw_if_index_set = 1;
9328 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9334 if (sw_if_index_set == 0)
9336 errmsg ("missing interface name or sw_if_index");
9339 if (!v6_address_set)
9341 errmsg ("no address set");
9345 /* Construct the API message */
9346 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
9348 mp->sw_if_index = ntohl (sw_if_index);
9349 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9354 /* Wait for a reply, return good/bad news */
9360 api_ip6nd_proxy_add_del (vat_main_t * vam)
9362 unformat_input_t *i = vam->input;
9363 vl_api_ip6nd_proxy_add_del_t *mp;
9364 u32 sw_if_index = ~0;
9365 u8 v6_address_set = 0;
9366 ip6_address_t v6address;
9370 /* Parse args required to build the message */
9371 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9373 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9375 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9377 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9379 if (unformat (i, "del"))
9383 clib_warning ("parse error '%U'", format_unformat_error, i);
9388 if (sw_if_index == ~0)
9390 errmsg ("missing interface name or sw_if_index");
9393 if (!v6_address_set)
9395 errmsg ("no address set");
9399 /* Construct the API message */
9400 M (IP6ND_PROXY_ADD_DEL, mp);
9402 mp->is_del = is_del;
9403 mp->sw_if_index = ntohl (sw_if_index);
9404 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9409 /* Wait for a reply, return good/bad news */
9415 api_ip6nd_proxy_dump (vat_main_t * vam)
9417 vl_api_ip6nd_proxy_dump_t *mp;
9418 vl_api_control_ping_t *mp_ping;
9421 M (IP6ND_PROXY_DUMP, mp);
9425 /* Use a control ping for synchronization */
9426 MPING (CONTROL_PING, mp_ping);
9433 static void vl_api_ip6nd_proxy_details_t_handler
9434 (vl_api_ip6nd_proxy_details_t * mp)
9436 vat_main_t *vam = &vat_main;
9438 print (vam->ofp, "host %U sw_if_index %d",
9439 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
9442 static void vl_api_ip6nd_proxy_details_t_handler_json
9443 (vl_api_ip6nd_proxy_details_t * mp)
9445 vat_main_t *vam = &vat_main;
9446 struct in6_addr ip6;
9447 vat_json_node_t *node = NULL;
9449 if (VAT_JSON_ARRAY != vam->json_tree.type)
9451 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9452 vat_json_init_array (&vam->json_tree);
9454 node = vat_json_array_add (&vam->json_tree);
9456 vat_json_init_object (node);
9457 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9459 clib_memcpy (&ip6, mp->address, sizeof (ip6));
9460 vat_json_object_add_ip6 (node, "host", ip6);
9464 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9466 unformat_input_t *i = vam->input;
9467 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9469 u8 sw_if_index_set = 0;
9470 u32 address_length = 0;
9471 u8 v6_address_set = 0;
9472 ip6_address_t v6address;
9474 u8 no_advertise = 0;
9476 u8 no_autoconfig = 0;
9479 u32 val_lifetime = 0;
9480 u32 pref_lifetime = 0;
9483 /* Parse args required to build the message */
9484 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9486 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9487 sw_if_index_set = 1;
9488 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9489 sw_if_index_set = 1;
9490 else if (unformat (i, "%U/%d",
9491 unformat_ip6_address, &v6address, &address_length))
9493 else if (unformat (i, "val_life %d", &val_lifetime))
9495 else if (unformat (i, "pref_life %d", &pref_lifetime))
9497 else if (unformat (i, "def"))
9499 else if (unformat (i, "noadv"))
9501 else if (unformat (i, "offl"))
9503 else if (unformat (i, "noauto"))
9505 else if (unformat (i, "nolink"))
9507 else if (unformat (i, "isno"))
9511 clib_warning ("parse error '%U'", format_unformat_error, i);
9516 if (sw_if_index_set == 0)
9518 errmsg ("missing interface name or sw_if_index");
9521 if (!v6_address_set)
9523 errmsg ("no address set");
9527 /* Construct the API message */
9528 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9530 mp->sw_if_index = ntohl (sw_if_index);
9531 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9532 mp->address_length = address_length;
9533 mp->use_default = use_default;
9534 mp->no_advertise = no_advertise;
9535 mp->off_link = off_link;
9536 mp->no_autoconfig = no_autoconfig;
9537 mp->no_onlink = no_onlink;
9539 mp->val_lifetime = ntohl (val_lifetime);
9540 mp->pref_lifetime = ntohl (pref_lifetime);
9545 /* Wait for a reply, return good/bad news */
9551 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9553 unformat_input_t *i = vam->input;
9554 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9556 u8 sw_if_index_set = 0;
9561 u8 send_unicast = 0;
9564 u8 default_router = 0;
9565 u32 max_interval = 0;
9566 u32 min_interval = 0;
9568 u32 initial_count = 0;
9569 u32 initial_interval = 0;
9573 /* Parse args required to build the message */
9574 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9576 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9577 sw_if_index_set = 1;
9578 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9579 sw_if_index_set = 1;
9580 else if (unformat (i, "maxint %d", &max_interval))
9582 else if (unformat (i, "minint %d", &min_interval))
9584 else if (unformat (i, "life %d", &lifetime))
9586 else if (unformat (i, "count %d", &initial_count))
9588 else if (unformat (i, "interval %d", &initial_interval))
9590 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9592 else if (unformat (i, "managed"))
9594 else if (unformat (i, "other"))
9596 else if (unformat (i, "ll"))
9598 else if (unformat (i, "send"))
9600 else if (unformat (i, "cease"))
9602 else if (unformat (i, "isno"))
9604 else if (unformat (i, "def"))
9608 clib_warning ("parse error '%U'", format_unformat_error, i);
9613 if (sw_if_index_set == 0)
9615 errmsg ("missing interface name or sw_if_index");
9619 /* Construct the API message */
9620 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9622 mp->sw_if_index = ntohl (sw_if_index);
9623 mp->max_interval = ntohl (max_interval);
9624 mp->min_interval = ntohl (min_interval);
9625 mp->lifetime = ntohl (lifetime);
9626 mp->initial_count = ntohl (initial_count);
9627 mp->initial_interval = ntohl (initial_interval);
9628 mp->suppress = suppress;
9629 mp->managed = managed;
9631 mp->ll_option = ll_option;
9632 mp->send_unicast = send_unicast;
9635 mp->default_router = default_router;
9640 /* Wait for a reply, return good/bad news */
9646 api_set_arp_neighbor_limit (vat_main_t * vam)
9648 unformat_input_t *i = vam->input;
9649 vl_api_set_arp_neighbor_limit_t *mp;
9655 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9657 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9659 else if (unformat (i, "ipv6"))
9663 clib_warning ("parse error '%U'", format_unformat_error, i);
9670 errmsg ("missing limit value");
9674 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9676 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9677 mp->is_ipv6 = is_ipv6;
9685 api_l2_patch_add_del (vat_main_t * vam)
9687 unformat_input_t *i = vam->input;
9688 vl_api_l2_patch_add_del_t *mp;
9690 u8 rx_sw_if_index_set = 0;
9692 u8 tx_sw_if_index_set = 0;
9696 /* Parse args required to build the message */
9697 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9699 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9700 rx_sw_if_index_set = 1;
9701 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9702 tx_sw_if_index_set = 1;
9703 else if (unformat (i, "rx"))
9705 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9707 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9709 rx_sw_if_index_set = 1;
9714 else if (unformat (i, "tx"))
9716 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9718 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9720 tx_sw_if_index_set = 1;
9725 else if (unformat (i, "del"))
9731 if (rx_sw_if_index_set == 0)
9733 errmsg ("missing rx interface name or rx_sw_if_index");
9737 if (tx_sw_if_index_set == 0)
9739 errmsg ("missing tx interface name or tx_sw_if_index");
9743 M (L2_PATCH_ADD_DEL, mp);
9745 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9746 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9747 mp->is_add = is_add;
9755 u8 localsid_addr[16];
9764 api_sr_localsid_add_del (vat_main_t * vam)
9766 unformat_input_t *i = vam->input;
9767 vl_api_sr_localsid_add_del_t *mp;
9770 ip6_address_t localsid;
9774 u32 fib_table = ~(u32) 0;
9775 ip6_address_t next_hop;
9777 bool nexthop_set = 0;
9781 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9783 if (unformat (i, "del"))
9785 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9786 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
9788 else if (unformat (i, "behavior %u", &behavior));
9789 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9790 else if (unformat (i, "fib-table %u", &fib_table));
9791 else if (unformat (i, "end.psp %u", &behavior));
9796 M (SR_LOCALSID_ADD_DEL, mp);
9798 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
9800 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
9801 mp->behavior = behavior;
9802 mp->sw_if_index = ntohl (sw_if_index);
9803 mp->fib_table = ntohl (fib_table);
9804 mp->end_psp = end_psp;
9805 mp->is_del = is_del;
9813 api_ioam_enable (vat_main_t * vam)
9815 unformat_input_t *input = vam->input;
9816 vl_api_ioam_enable_t *mp;
9818 int has_trace_option = 0;
9819 int has_pot_option = 0;
9820 int has_seqno_option = 0;
9821 int has_analyse_option = 0;
9824 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9826 if (unformat (input, "trace"))
9827 has_trace_option = 1;
9828 else if (unformat (input, "pot"))
9830 else if (unformat (input, "seqno"))
9831 has_seqno_option = 1;
9832 else if (unformat (input, "analyse"))
9833 has_analyse_option = 1;
9837 M (IOAM_ENABLE, mp);
9838 mp->id = htons (id);
9839 mp->seqno = has_seqno_option;
9840 mp->analyse = has_analyse_option;
9841 mp->pot_enable = has_pot_option;
9842 mp->trace_enable = has_trace_option;
9851 api_ioam_disable (vat_main_t * vam)
9853 vl_api_ioam_disable_t *mp;
9856 M (IOAM_DISABLE, mp);
9862 #define foreach_tcp_proto_field \
9866 #define foreach_udp_proto_field \
9870 #define foreach_ip4_proto_field \
9882 u16 src_port, dst_port;
9885 #if VPP_API_TEST_BUILTIN == 0
9887 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9889 u8 **maskp = va_arg (*args, u8 **);
9891 u8 found_something = 0;
9894 #define _(a) u8 a=0;
9895 foreach_tcp_proto_field;
9898 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9901 #define _(a) else if (unformat (input, #a)) a=1;
9902 foreach_tcp_proto_field
9908 #define _(a) found_something += a;
9909 foreach_tcp_proto_field;
9912 if (found_something == 0)
9915 vec_validate (mask, sizeof (*tcp) - 1);
9917 tcp = (tcp_header_t *) mask;
9919 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
9920 foreach_tcp_proto_field;
9928 unformat_udp_mask (unformat_input_t * input, va_list * args)
9930 u8 **maskp = va_arg (*args, u8 **);
9932 u8 found_something = 0;
9935 #define _(a) u8 a=0;
9936 foreach_udp_proto_field;
9939 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9942 #define _(a) else if (unformat (input, #a)) a=1;
9943 foreach_udp_proto_field
9949 #define _(a) found_something += a;
9950 foreach_udp_proto_field;
9953 if (found_something == 0)
9956 vec_validate (mask, sizeof (*udp) - 1);
9958 udp = (udp_header_t *) mask;
9960 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
9961 foreach_udp_proto_field;
9969 unformat_l4_mask (unformat_input_t * input, va_list * args)
9971 u8 **maskp = va_arg (*args, u8 **);
9972 u16 src_port = 0, dst_port = 0;
9973 tcpudp_header_t *tcpudp;
9975 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9977 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9979 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9981 else if (unformat (input, "src_port"))
9983 else if (unformat (input, "dst_port"))
9989 if (!src_port && !dst_port)
9993 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9995 tcpudp = (tcpudp_header_t *) mask;
9996 tcpudp->src_port = src_port;
9997 tcpudp->dst_port = dst_port;
10005 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10007 u8 **maskp = va_arg (*args, u8 **);
10009 u8 found_something = 0;
10012 #define _(a) u8 a=0;
10013 foreach_ip4_proto_field;
10019 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10021 if (unformat (input, "version"))
10023 else if (unformat (input, "hdr_length"))
10025 else if (unformat (input, "src"))
10027 else if (unformat (input, "dst"))
10029 else if (unformat (input, "proto"))
10032 #define _(a) else if (unformat (input, #a)) a=1;
10033 foreach_ip4_proto_field
10039 #define _(a) found_something += a;
10040 foreach_ip4_proto_field;
10043 if (found_something == 0)
10046 vec_validate (mask, sizeof (*ip) - 1);
10048 ip = (ip4_header_t *) mask;
10050 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10051 foreach_ip4_proto_field;
10054 ip->ip_version_and_header_length = 0;
10057 ip->ip_version_and_header_length |= 0xF0;
10060 ip->ip_version_and_header_length |= 0x0F;
10066 #define foreach_ip6_proto_field \
10069 _(payload_length) \
10074 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10076 u8 **maskp = va_arg (*args, u8 **);
10078 u8 found_something = 0;
10080 u32 ip_version_traffic_class_and_flow_label;
10082 #define _(a) u8 a=0;
10083 foreach_ip6_proto_field;
10086 u8 traffic_class = 0;
10089 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10091 if (unformat (input, "version"))
10093 else if (unformat (input, "traffic-class"))
10095 else if (unformat (input, "flow-label"))
10097 else if (unformat (input, "src"))
10099 else if (unformat (input, "dst"))
10101 else if (unformat (input, "proto"))
10104 #define _(a) else if (unformat (input, #a)) a=1;
10105 foreach_ip6_proto_field
10111 #define _(a) found_something += a;
10112 foreach_ip6_proto_field;
10115 if (found_something == 0)
10118 vec_validate (mask, sizeof (*ip) - 1);
10120 ip = (ip6_header_t *) mask;
10122 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10123 foreach_ip6_proto_field;
10126 ip_version_traffic_class_and_flow_label = 0;
10129 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10132 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10135 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10137 ip->ip_version_traffic_class_and_flow_label =
10138 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10145 unformat_l3_mask (unformat_input_t * input, va_list * args)
10147 u8 **maskp = va_arg (*args, u8 **);
10149 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10151 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10153 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10162 unformat_l2_mask (unformat_input_t * input, va_list * args)
10164 u8 **maskp = va_arg (*args, u8 **);
10171 u8 ignore_tag1 = 0;
10172 u8 ignore_tag2 = 0;
10179 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10181 if (unformat (input, "src"))
10183 else if (unformat (input, "dst"))
10185 else if (unformat (input, "proto"))
10187 else if (unformat (input, "tag1"))
10189 else if (unformat (input, "tag2"))
10191 else if (unformat (input, "ignore-tag1"))
10193 else if (unformat (input, "ignore-tag2"))
10195 else if (unformat (input, "cos1"))
10197 else if (unformat (input, "cos2"))
10199 else if (unformat (input, "dot1q"))
10201 else if (unformat (input, "dot1ad"))
10206 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10207 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10210 if (tag1 || ignore_tag1 || cos1 || dot1q)
10212 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10215 vec_validate (mask, len - 1);
10218 memset (mask, 0xff, 6);
10221 memset (mask + 6, 0xff, 6);
10223 if (tag2 || dot1ad)
10225 /* inner vlan tag */
10234 mask[21] = mask[20] = 0xff;
10255 mask[16] = mask[17] = 0xff;
10265 mask[12] = mask[13] = 0xff;
10272 unformat_classify_mask (unformat_input_t * input, va_list * args)
10274 u8 **maskp = va_arg (*args, u8 **);
10275 u32 *skipp = va_arg (*args, u32 *);
10276 u32 *matchp = va_arg (*args, u32 *);
10284 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10286 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10288 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10290 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10292 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10306 if (mask || l2 || l3 || l4)
10308 if (l2 || l3 || l4)
10310 /* "With a free Ethernet header in every package" */
10312 vec_validate (l2, 13);
10316 vec_append (mask, l3);
10321 vec_append (mask, l4);
10326 /* Scan forward looking for the first significant mask octet */
10327 for (i = 0; i < vec_len (mask); i++)
10331 /* compute (skip, match) params */
10332 *skipp = i / sizeof (u32x4);
10333 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10335 /* Pad mask to an even multiple of the vector size */
10336 while (vec_len (mask) % sizeof (u32x4))
10337 vec_add1 (mask, 0);
10339 match = vec_len (mask) / sizeof (u32x4);
10341 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10343 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10344 if (*tmp || *(tmp + 1))
10349 clib_warning ("BUG: match 0");
10351 _vec_len (mask) = match * sizeof (u32x4);
10361 #endif /* VPP_API_TEST_BUILTIN */
10363 #define foreach_l2_next \
10365 _(ethernet, ETHERNET_INPUT) \
10366 _(ip4, IP4_INPUT) \
10370 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10372 u32 *miss_next_indexp = va_arg (*args, u32 *);
10373 u32 next_index = 0;
10377 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10381 if (unformat (input, "%d", &tmp))
10390 *miss_next_indexp = next_index;
10394 #define foreach_ip_next \
10397 _(rewrite, REWRITE)
10400 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10402 u32 *miss_next_indexp = va_arg (*args, u32 *);
10403 u32 next_index = 0;
10407 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10411 if (unformat (input, "%d", &tmp))
10420 *miss_next_indexp = next_index;
10424 #define foreach_acl_next \
10428 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10430 u32 *miss_next_indexp = va_arg (*args, u32 *);
10431 u32 next_index = 0;
10435 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10439 if (unformat (input, "permit"))
10444 else if (unformat (input, "%d", &tmp))
10453 *miss_next_indexp = next_index;
10458 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10460 u32 *r = va_arg (*args, u32 *);
10462 if (unformat (input, "conform-color"))
10463 *r = POLICE_CONFORM;
10464 else if (unformat (input, "exceed-color"))
10465 *r = POLICE_EXCEED;
10473 api_classify_add_del_table (vat_main_t * vam)
10475 unformat_input_t *i = vam->input;
10476 vl_api_classify_add_del_table_t *mp;
10483 u32 table_index = ~0;
10484 u32 next_table_index = ~0;
10485 u32 miss_next_index = ~0;
10486 u32 memory_size = 32 << 20;
10488 u32 current_data_flag = 0;
10489 int current_data_offset = 0;
10492 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10494 if (unformat (i, "del"))
10496 else if (unformat (i, "del-chain"))
10501 else if (unformat (i, "buckets %d", &nbuckets))
10503 else if (unformat (i, "memory_size %d", &memory_size))
10505 else if (unformat (i, "skip %d", &skip))
10507 else if (unformat (i, "match %d", &match))
10509 else if (unformat (i, "table %d", &table_index))
10511 else if (unformat (i, "mask %U", unformat_classify_mask,
10512 &mask, &skip, &match))
10514 else if (unformat (i, "next-table %d", &next_table_index))
10516 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10519 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10522 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10525 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10527 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10533 if (is_add && mask == 0)
10535 errmsg ("Mask required");
10539 if (is_add && skip == ~0)
10541 errmsg ("skip count required");
10545 if (is_add && match == ~0)
10547 errmsg ("match count required");
10551 if (!is_add && table_index == ~0)
10553 errmsg ("table index required for delete");
10557 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10559 mp->is_add = is_add;
10560 mp->del_chain = del_chain;
10561 mp->table_index = ntohl (table_index);
10562 mp->nbuckets = ntohl (nbuckets);
10563 mp->memory_size = ntohl (memory_size);
10564 mp->skip_n_vectors = ntohl (skip);
10565 mp->match_n_vectors = ntohl (match);
10566 mp->next_table_index = ntohl (next_table_index);
10567 mp->miss_next_index = ntohl (miss_next_index);
10568 mp->current_data_flag = ntohl (current_data_flag);
10569 mp->current_data_offset = ntohl (current_data_offset);
10570 clib_memcpy (mp->mask, mask, vec_len (mask));
10579 #if VPP_API_TEST_BUILTIN == 0
10581 unformat_l4_match (unformat_input_t * input, va_list * args)
10583 u8 **matchp = va_arg (*args, u8 **);
10585 u8 *proto_header = 0;
10591 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10593 if (unformat (input, "src_port %d", &src_port))
10595 else if (unformat (input, "dst_port %d", &dst_port))
10601 h.src_port = clib_host_to_net_u16 (src_port);
10602 h.dst_port = clib_host_to_net_u16 (dst_port);
10603 vec_validate (proto_header, sizeof (h) - 1);
10604 memcpy (proto_header, &h, sizeof (h));
10606 *matchp = proto_header;
10612 unformat_ip4_match (unformat_input_t * input, va_list * args)
10614 u8 **matchp = va_arg (*args, u8 **);
10619 int hdr_length = 0;
10620 u32 hdr_length_val;
10621 int src = 0, dst = 0;
10622 ip4_address_t src_val, dst_val;
10629 int fragment_id = 0;
10630 u32 fragment_id_val;
10636 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10638 if (unformat (input, "version %d", &version_val))
10640 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10642 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10644 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10646 else if (unformat (input, "proto %d", &proto_val))
10648 else if (unformat (input, "tos %d", &tos_val))
10650 else if (unformat (input, "length %d", &length_val))
10652 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10654 else if (unformat (input, "ttl %d", &ttl_val))
10656 else if (unformat (input, "checksum %d", &checksum_val))
10662 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10663 + ttl + checksum == 0)
10667 * Aligned because we use the real comparison functions
10669 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10671 ip = (ip4_header_t *) match;
10673 /* These are realistically matched in practice */
10675 ip->src_address.as_u32 = src_val.as_u32;
10678 ip->dst_address.as_u32 = dst_val.as_u32;
10681 ip->protocol = proto_val;
10684 /* These are not, but they're included for completeness */
10686 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10689 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10695 ip->length = clib_host_to_net_u16 (length_val);
10701 ip->checksum = clib_host_to_net_u16 (checksum_val);
10708 unformat_ip6_match (unformat_input_t * input, va_list * args)
10710 u8 **matchp = va_arg (*args, u8 **);
10715 u8 traffic_class = 0;
10716 u32 traffic_class_val = 0;
10719 int src = 0, dst = 0;
10720 ip6_address_t src_val, dst_val;
10723 int payload_length = 0;
10724 u32 payload_length_val;
10727 u32 ip_version_traffic_class_and_flow_label;
10729 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10731 if (unformat (input, "version %d", &version_val))
10733 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10735 else if (unformat (input, "flow_label %d", &flow_label_val))
10737 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10739 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10741 else if (unformat (input, "proto %d", &proto_val))
10743 else if (unformat (input, "payload_length %d", &payload_length_val))
10744 payload_length = 1;
10745 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10751 if (version + traffic_class + flow_label + src + dst + proto +
10752 payload_length + hop_limit == 0)
10756 * Aligned because we use the real comparison functions
10758 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10760 ip = (ip6_header_t *) match;
10763 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10766 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10769 ip->protocol = proto_val;
10771 ip_version_traffic_class_and_flow_label = 0;
10774 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10777 ip_version_traffic_class_and_flow_label |=
10778 (traffic_class_val & 0xFF) << 20;
10781 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10783 ip->ip_version_traffic_class_and_flow_label =
10784 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10786 if (payload_length)
10787 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10790 ip->hop_limit = hop_limit_val;
10797 unformat_l3_match (unformat_input_t * input, va_list * args)
10799 u8 **matchp = va_arg (*args, u8 **);
10801 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10803 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10805 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10814 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10816 u8 *tagp = va_arg (*args, u8 *);
10819 if (unformat (input, "%d", &tag))
10821 tagp[0] = (tag >> 8) & 0x0F;
10822 tagp[1] = tag & 0xFF;
10830 unformat_l2_match (unformat_input_t * input, va_list * args)
10832 u8 **matchp = va_arg (*args, u8 **);
10845 u8 ignore_tag1 = 0;
10846 u8 ignore_tag2 = 0;
10852 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10854 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10857 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10859 else if (unformat (input, "proto %U",
10860 unformat_ethernet_type_host_byte_order, &proto_val))
10862 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10864 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10866 else if (unformat (input, "ignore-tag1"))
10868 else if (unformat (input, "ignore-tag2"))
10870 else if (unformat (input, "cos1 %d", &cos1_val))
10872 else if (unformat (input, "cos2 %d", &cos2_val))
10877 if ((src + dst + proto + tag1 + tag2 +
10878 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10881 if (tag1 || ignore_tag1 || cos1)
10883 if (tag2 || ignore_tag2 || cos2)
10886 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10889 clib_memcpy (match, dst_val, 6);
10892 clib_memcpy (match + 6, src_val, 6);
10896 /* inner vlan tag */
10897 match[19] = tag2_val[1];
10898 match[18] = tag2_val[0];
10900 match[18] |= (cos2_val & 0x7) << 5;
10903 match[21] = proto_val & 0xff;
10904 match[20] = proto_val >> 8;
10908 match[15] = tag1_val[1];
10909 match[14] = tag1_val[0];
10912 match[14] |= (cos1_val & 0x7) << 5;
10918 match[15] = tag1_val[1];
10919 match[14] = tag1_val[0];
10922 match[17] = proto_val & 0xff;
10923 match[16] = proto_val >> 8;
10926 match[14] |= (cos1_val & 0x7) << 5;
10932 match[18] |= (cos2_val & 0x7) << 5;
10934 match[14] |= (cos1_val & 0x7) << 5;
10937 match[13] = proto_val & 0xff;
10938 match[12] = proto_val >> 8;
10947 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10949 u8 **matchp = va_arg (*args, u8 **);
10950 u32 skip_n_vectors = va_arg (*args, u32);
10951 u32 match_n_vectors = va_arg (*args, u32);
10958 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10960 if (unformat (input, "hex %U", unformat_hex_string, &match))
10962 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10964 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10966 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10980 if (match || l2 || l3 || l4)
10982 if (l2 || l3 || l4)
10984 /* "Win a free Ethernet header in every packet" */
10986 vec_validate_aligned (l2, 13, sizeof (u32x4));
10990 vec_append_aligned (match, l3, sizeof (u32x4));
10995 vec_append_aligned (match, l4, sizeof (u32x4));
11000 /* Make sure the vector is big enough even if key is all 0's */
11001 vec_validate_aligned
11002 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11005 /* Set size, include skipped vectors */
11006 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11017 api_classify_add_del_session (vat_main_t * vam)
11019 unformat_input_t *i = vam->input;
11020 vl_api_classify_add_del_session_t *mp;
11022 u32 table_index = ~0;
11023 u32 hit_next_index = ~0;
11024 u32 opaque_index = ~0;
11027 u32 skip_n_vectors = 0;
11028 u32 match_n_vectors = 0;
11034 * Warning: you have to supply skip_n and match_n
11035 * because the API client cant simply look at the classify
11039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11041 if (unformat (i, "del"))
11043 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11046 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11049 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11052 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11054 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11056 else if (unformat (i, "opaque-index %d", &opaque_index))
11058 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11060 else if (unformat (i, "match_n %d", &match_n_vectors))
11062 else if (unformat (i, "match %U", api_unformat_classify_match,
11063 &match, skip_n_vectors, match_n_vectors))
11065 else if (unformat (i, "advance %d", &advance))
11067 else if (unformat (i, "table-index %d", &table_index))
11069 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11071 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11073 else if (unformat (i, "action %d", &action))
11075 else if (unformat (i, "metadata %d", &metadata))
11081 if (table_index == ~0)
11083 errmsg ("Table index required");
11087 if (is_add && match == 0)
11089 errmsg ("Match value required");
11093 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11095 mp->is_add = is_add;
11096 mp->table_index = ntohl (table_index);
11097 mp->hit_next_index = ntohl (hit_next_index);
11098 mp->opaque_index = ntohl (opaque_index);
11099 mp->advance = ntohl (advance);
11100 mp->action = action;
11101 mp->metadata = ntohl (metadata);
11102 clib_memcpy (mp->match, match, vec_len (match));
11111 api_classify_set_interface_ip_table (vat_main_t * vam)
11113 unformat_input_t *i = vam->input;
11114 vl_api_classify_set_interface_ip_table_t *mp;
11116 int sw_if_index_set;
11117 u32 table_index = ~0;
11121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11123 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11124 sw_if_index_set = 1;
11125 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11126 sw_if_index_set = 1;
11127 else if (unformat (i, "table %d", &table_index))
11131 clib_warning ("parse error '%U'", format_unformat_error, i);
11136 if (sw_if_index_set == 0)
11138 errmsg ("missing interface name or sw_if_index");
11143 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11145 mp->sw_if_index = ntohl (sw_if_index);
11146 mp->table_index = ntohl (table_index);
11147 mp->is_ipv6 = is_ipv6;
11155 api_classify_set_interface_l2_tables (vat_main_t * vam)
11157 unformat_input_t *i = vam->input;
11158 vl_api_classify_set_interface_l2_tables_t *mp;
11160 int sw_if_index_set;
11161 u32 ip4_table_index = ~0;
11162 u32 ip6_table_index = ~0;
11163 u32 other_table_index = ~0;
11167 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11169 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11170 sw_if_index_set = 1;
11171 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11172 sw_if_index_set = 1;
11173 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11175 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11177 else if (unformat (i, "other-table %d", &other_table_index))
11179 else if (unformat (i, "is-input %d", &is_input))
11183 clib_warning ("parse error '%U'", format_unformat_error, i);
11188 if (sw_if_index_set == 0)
11190 errmsg ("missing interface name or sw_if_index");
11195 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11197 mp->sw_if_index = ntohl (sw_if_index);
11198 mp->ip4_table_index = ntohl (ip4_table_index);
11199 mp->ip6_table_index = ntohl (ip6_table_index);
11200 mp->other_table_index = ntohl (other_table_index);
11201 mp->is_input = (u8) is_input;
11209 api_set_ipfix_exporter (vat_main_t * vam)
11211 unformat_input_t *i = vam->input;
11212 vl_api_set_ipfix_exporter_t *mp;
11213 ip4_address_t collector_address;
11214 u8 collector_address_set = 0;
11215 u32 collector_port = ~0;
11216 ip4_address_t src_address;
11217 u8 src_address_set = 0;
11220 u32 template_interval = ~0;
11221 u8 udp_checksum = 0;
11224 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11226 if (unformat (i, "collector_address %U", unformat_ip4_address,
11227 &collector_address))
11228 collector_address_set = 1;
11229 else if (unformat (i, "collector_port %d", &collector_port))
11231 else if (unformat (i, "src_address %U", unformat_ip4_address,
11233 src_address_set = 1;
11234 else if (unformat (i, "vrf_id %d", &vrf_id))
11236 else if (unformat (i, "path_mtu %d", &path_mtu))
11238 else if (unformat (i, "template_interval %d", &template_interval))
11240 else if (unformat (i, "udp_checksum"))
11246 if (collector_address_set == 0)
11248 errmsg ("collector_address required");
11252 if (src_address_set == 0)
11254 errmsg ("src_address required");
11258 M (SET_IPFIX_EXPORTER, mp);
11260 memcpy (mp->collector_address, collector_address.data,
11261 sizeof (collector_address.data));
11262 mp->collector_port = htons ((u16) collector_port);
11263 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11264 mp->vrf_id = htonl (vrf_id);
11265 mp->path_mtu = htonl (path_mtu);
11266 mp->template_interval = htonl (template_interval);
11267 mp->udp_checksum = udp_checksum;
11275 api_set_ipfix_classify_stream (vat_main_t * vam)
11277 unformat_input_t *i = vam->input;
11278 vl_api_set_ipfix_classify_stream_t *mp;
11280 u32 src_port = UDP_DST_PORT_ipfix;
11283 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11285 if (unformat (i, "domain %d", &domain_id))
11287 else if (unformat (i, "src_port %d", &src_port))
11291 errmsg ("unknown input `%U'", format_unformat_error, i);
11296 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11298 mp->domain_id = htonl (domain_id);
11299 mp->src_port = htons ((u16) src_port);
11307 api_ipfix_classify_table_add_del (vat_main_t * vam)
11309 unformat_input_t *i = vam->input;
11310 vl_api_ipfix_classify_table_add_del_t *mp;
11312 u32 classify_table_index = ~0;
11314 u8 transport_protocol = 255;
11317 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11319 if (unformat (i, "add"))
11321 else if (unformat (i, "del"))
11323 else if (unformat (i, "table %d", &classify_table_index))
11325 else if (unformat (i, "ip4"))
11327 else if (unformat (i, "ip6"))
11329 else if (unformat (i, "tcp"))
11330 transport_protocol = 6;
11331 else if (unformat (i, "udp"))
11332 transport_protocol = 17;
11335 errmsg ("unknown input `%U'", format_unformat_error, i);
11342 errmsg ("expecting: add|del");
11345 if (classify_table_index == ~0)
11347 errmsg ("classifier table not specified");
11350 if (ip_version == 0)
11352 errmsg ("IP version not specified");
11356 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11358 mp->is_add = is_add;
11359 mp->table_id = htonl (classify_table_index);
11360 mp->ip_version = ip_version;
11361 mp->transport_protocol = transport_protocol;
11369 api_get_node_index (vat_main_t * vam)
11371 unformat_input_t *i = vam->input;
11372 vl_api_get_node_index_t *mp;
11376 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11378 if (unformat (i, "node %s", &name))
11385 errmsg ("node name required");
11388 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11390 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11394 M (GET_NODE_INDEX, mp);
11395 clib_memcpy (mp->node_name, name, vec_len (name));
11404 api_get_next_index (vat_main_t * vam)
11406 unformat_input_t *i = vam->input;
11407 vl_api_get_next_index_t *mp;
11408 u8 *node_name = 0, *next_node_name = 0;
11411 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11413 if (unformat (i, "node-name %s", &node_name))
11415 else if (unformat (i, "next-node-name %s", &next_node_name))
11419 if (node_name == 0)
11421 errmsg ("node name required");
11424 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11426 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11430 if (next_node_name == 0)
11432 errmsg ("next node name required");
11435 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11437 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11441 M (GET_NEXT_INDEX, mp);
11442 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11443 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11444 vec_free (node_name);
11445 vec_free (next_node_name);
11453 api_add_node_next (vat_main_t * vam)
11455 unformat_input_t *i = vam->input;
11456 vl_api_add_node_next_t *mp;
11461 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11463 if (unformat (i, "node %s", &name))
11465 else if (unformat (i, "next %s", &next))
11472 errmsg ("node name required");
11475 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11477 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11482 errmsg ("next node required");
11485 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11487 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11491 M (ADD_NODE_NEXT, mp);
11492 clib_memcpy (mp->node_name, name, vec_len (name));
11493 clib_memcpy (mp->next_name, next, vec_len (next));
11503 api_l2tpv3_create_tunnel (vat_main_t * vam)
11505 unformat_input_t *i = vam->input;
11506 ip6_address_t client_address, our_address;
11507 int client_address_set = 0;
11508 int our_address_set = 0;
11509 u32 local_session_id = 0;
11510 u32 remote_session_id = 0;
11511 u64 local_cookie = 0;
11512 u64 remote_cookie = 0;
11513 u8 l2_sublayer_present = 0;
11514 vl_api_l2tpv3_create_tunnel_t *mp;
11517 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11519 if (unformat (i, "client_address %U", unformat_ip6_address,
11521 client_address_set = 1;
11522 else if (unformat (i, "our_address %U", unformat_ip6_address,
11524 our_address_set = 1;
11525 else if (unformat (i, "local_session_id %d", &local_session_id))
11527 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11529 else if (unformat (i, "local_cookie %lld", &local_cookie))
11531 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11533 else if (unformat (i, "l2-sublayer-present"))
11534 l2_sublayer_present = 1;
11539 if (client_address_set == 0)
11541 errmsg ("client_address required");
11545 if (our_address_set == 0)
11547 errmsg ("our_address required");
11551 M (L2TPV3_CREATE_TUNNEL, mp);
11553 clib_memcpy (mp->client_address, client_address.as_u8,
11554 sizeof (mp->client_address));
11556 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11558 mp->local_session_id = ntohl (local_session_id);
11559 mp->remote_session_id = ntohl (remote_session_id);
11560 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11561 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11562 mp->l2_sublayer_present = l2_sublayer_present;
11571 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11573 unformat_input_t *i = vam->input;
11575 u8 sw_if_index_set = 0;
11576 u64 new_local_cookie = 0;
11577 u64 new_remote_cookie = 0;
11578 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11581 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11583 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11584 sw_if_index_set = 1;
11585 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11586 sw_if_index_set = 1;
11587 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11589 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11595 if (sw_if_index_set == 0)
11597 errmsg ("missing interface name or sw_if_index");
11601 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11603 mp->sw_if_index = ntohl (sw_if_index);
11604 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11605 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11613 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11615 unformat_input_t *i = vam->input;
11616 vl_api_l2tpv3_interface_enable_disable_t *mp;
11618 u8 sw_if_index_set = 0;
11619 u8 enable_disable = 1;
11622 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11624 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11625 sw_if_index_set = 1;
11626 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11627 sw_if_index_set = 1;
11628 else if (unformat (i, "enable"))
11629 enable_disable = 1;
11630 else if (unformat (i, "disable"))
11631 enable_disable = 0;
11636 if (sw_if_index_set == 0)
11638 errmsg ("missing interface name or sw_if_index");
11642 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11644 mp->sw_if_index = ntohl (sw_if_index);
11645 mp->enable_disable = enable_disable;
11653 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11655 unformat_input_t *i = vam->input;
11656 vl_api_l2tpv3_set_lookup_key_t *mp;
11660 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11662 if (unformat (i, "lookup_v6_src"))
11663 key = L2T_LOOKUP_SRC_ADDRESS;
11664 else if (unformat (i, "lookup_v6_dst"))
11665 key = L2T_LOOKUP_DST_ADDRESS;
11666 else if (unformat (i, "lookup_session_id"))
11667 key = L2T_LOOKUP_SESSION_ID;
11672 if (key == (u8) ~ 0)
11674 errmsg ("l2tp session lookup key unset");
11678 M (L2TPV3_SET_LOOKUP_KEY, mp);
11687 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11688 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11690 vat_main_t *vam = &vat_main;
11692 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11693 format_ip6_address, mp->our_address,
11694 format_ip6_address, mp->client_address,
11695 clib_net_to_host_u32 (mp->sw_if_index));
11698 " local cookies %016llx %016llx remote cookie %016llx",
11699 clib_net_to_host_u64 (mp->local_cookie[0]),
11700 clib_net_to_host_u64 (mp->local_cookie[1]),
11701 clib_net_to_host_u64 (mp->remote_cookie));
11703 print (vam->ofp, " local session-id %d remote session-id %d",
11704 clib_net_to_host_u32 (mp->local_session_id),
11705 clib_net_to_host_u32 (mp->remote_session_id));
11707 print (vam->ofp, " l2 specific sublayer %s\n",
11708 mp->l2_sublayer_present ? "preset" : "absent");
11712 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11713 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11715 vat_main_t *vam = &vat_main;
11716 vat_json_node_t *node = NULL;
11717 struct in6_addr addr;
11719 if (VAT_JSON_ARRAY != vam->json_tree.type)
11721 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11722 vat_json_init_array (&vam->json_tree);
11724 node = vat_json_array_add (&vam->json_tree);
11726 vat_json_init_object (node);
11728 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11729 vat_json_object_add_ip6 (node, "our_address", addr);
11730 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11731 vat_json_object_add_ip6 (node, "client_address", addr);
11733 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11734 vat_json_init_array (lc);
11735 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11736 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11737 vat_json_object_add_uint (node, "remote_cookie",
11738 clib_net_to_host_u64 (mp->remote_cookie));
11740 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11741 vat_json_object_add_uint (node, "local_session_id",
11742 clib_net_to_host_u32 (mp->local_session_id));
11743 vat_json_object_add_uint (node, "remote_session_id",
11744 clib_net_to_host_u32 (mp->remote_session_id));
11745 vat_json_object_add_string_copy (node, "l2_sublayer",
11746 mp->l2_sublayer_present ? (u8 *) "present"
11747 : (u8 *) "absent");
11751 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11753 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11754 vl_api_control_ping_t *mp_ping;
11757 /* Get list of l2tpv3-tunnel interfaces */
11758 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11761 /* Use a control ping for synchronization */
11762 MPING (CONTROL_PING, mp_ping);
11770 static void vl_api_sw_interface_tap_details_t_handler
11771 (vl_api_sw_interface_tap_details_t * mp)
11773 vat_main_t *vam = &vat_main;
11775 print (vam->ofp, "%-16s %d",
11776 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
11779 static void vl_api_sw_interface_tap_details_t_handler_json
11780 (vl_api_sw_interface_tap_details_t * mp)
11782 vat_main_t *vam = &vat_main;
11783 vat_json_node_t *node = NULL;
11785 if (VAT_JSON_ARRAY != vam->json_tree.type)
11787 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11788 vat_json_init_array (&vam->json_tree);
11790 node = vat_json_array_add (&vam->json_tree);
11792 vat_json_init_object (node);
11793 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11794 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11798 api_sw_interface_tap_dump (vat_main_t * vam)
11800 vl_api_sw_interface_tap_dump_t *mp;
11801 vl_api_control_ping_t *mp_ping;
11804 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
11805 /* Get list of tap interfaces */
11806 M (SW_INTERFACE_TAP_DUMP, mp);
11809 /* Use a control ping for synchronization */
11810 MPING (CONTROL_PING, mp_ping);
11817 static uword unformat_vxlan_decap_next
11818 (unformat_input_t * input, va_list * args)
11820 u32 *result = va_arg (*args, u32 *);
11823 if (unformat (input, "l2"))
11824 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11825 else if (unformat (input, "%d", &tmp))
11833 api_vxlan_add_del_tunnel (vat_main_t * vam)
11835 unformat_input_t *line_input = vam->input;
11836 vl_api_vxlan_add_del_tunnel_t *mp;
11837 ip46_address_t src, dst;
11839 u8 ipv4_set = 0, ipv6_set = 0;
11843 u32 mcast_sw_if_index = ~0;
11844 u32 encap_vrf_id = 0;
11845 u32 decap_next_index = ~0;
11849 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11850 memset (&src, 0, sizeof src);
11851 memset (&dst, 0, sizeof dst);
11853 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11855 if (unformat (line_input, "del"))
11858 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11864 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11870 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11876 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11881 else if (unformat (line_input, "group %U %U",
11882 unformat_ip4_address, &dst.ip4,
11883 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11885 grp_set = dst_set = 1;
11888 else if (unformat (line_input, "group %U",
11889 unformat_ip4_address, &dst.ip4))
11891 grp_set = dst_set = 1;
11894 else if (unformat (line_input, "group %U %U",
11895 unformat_ip6_address, &dst.ip6,
11896 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11898 grp_set = dst_set = 1;
11901 else if (unformat (line_input, "group %U",
11902 unformat_ip6_address, &dst.ip6))
11904 grp_set = dst_set = 1;
11908 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11910 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11912 else if (unformat (line_input, "decap-next %U",
11913 unformat_vxlan_decap_next, &decap_next_index))
11915 else if (unformat (line_input, "vni %d", &vni))
11919 errmsg ("parse error '%U'", format_unformat_error, line_input);
11926 errmsg ("tunnel src address not specified");
11931 errmsg ("tunnel dst address not specified");
11935 if (grp_set && !ip46_address_is_multicast (&dst))
11937 errmsg ("tunnel group address not multicast");
11940 if (grp_set && mcast_sw_if_index == ~0)
11942 errmsg ("tunnel nonexistent multicast device");
11945 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11947 errmsg ("tunnel dst address must be unicast");
11952 if (ipv4_set && ipv6_set)
11954 errmsg ("both IPv4 and IPv6 addresses specified");
11958 if ((vni == 0) || (vni >> 24))
11960 errmsg ("vni not specified or out of range");
11964 M (VXLAN_ADD_DEL_TUNNEL, mp);
11968 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
11969 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
11973 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
11974 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
11976 mp->encap_vrf_id = ntohl (encap_vrf_id);
11977 mp->decap_next_index = ntohl (decap_next_index);
11978 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11979 mp->vni = ntohl (vni);
11980 mp->is_add = is_add;
11981 mp->is_ipv6 = ipv6_set;
11988 static void vl_api_vxlan_tunnel_details_t_handler
11989 (vl_api_vxlan_tunnel_details_t * mp)
11991 vat_main_t *vam = &vat_main;
11992 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
11993 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
11995 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
11996 ntohl (mp->sw_if_index),
11997 format_ip46_address, &src, IP46_TYPE_ANY,
11998 format_ip46_address, &dst, IP46_TYPE_ANY,
11999 ntohl (mp->encap_vrf_id),
12000 ntohl (mp->decap_next_index), ntohl (mp->vni),
12001 ntohl (mp->mcast_sw_if_index));
12004 static void vl_api_vxlan_tunnel_details_t_handler_json
12005 (vl_api_vxlan_tunnel_details_t * mp)
12007 vat_main_t *vam = &vat_main;
12008 vat_json_node_t *node = NULL;
12010 if (VAT_JSON_ARRAY != vam->json_tree.type)
12012 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12013 vat_json_init_array (&vam->json_tree);
12015 node = vat_json_array_add (&vam->json_tree);
12017 vat_json_init_object (node);
12018 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12021 struct in6_addr ip6;
12023 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12024 vat_json_object_add_ip6 (node, "src_address", ip6);
12025 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12026 vat_json_object_add_ip6 (node, "dst_address", ip6);
12030 struct in_addr ip4;
12032 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12033 vat_json_object_add_ip4 (node, "src_address", ip4);
12034 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12035 vat_json_object_add_ip4 (node, "dst_address", ip4);
12037 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12038 vat_json_object_add_uint (node, "decap_next_index",
12039 ntohl (mp->decap_next_index));
12040 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12041 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12042 vat_json_object_add_uint (node, "mcast_sw_if_index",
12043 ntohl (mp->mcast_sw_if_index));
12047 api_vxlan_tunnel_dump (vat_main_t * vam)
12049 unformat_input_t *i = vam->input;
12050 vl_api_vxlan_tunnel_dump_t *mp;
12051 vl_api_control_ping_t *mp_ping;
12053 u8 sw_if_index_set = 0;
12056 /* Parse args required to build the message */
12057 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12059 if (unformat (i, "sw_if_index %d", &sw_if_index))
12060 sw_if_index_set = 1;
12065 if (sw_if_index_set == 0)
12070 if (!vam->json_output)
12072 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12073 "sw_if_index", "src_address", "dst_address",
12074 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12077 /* Get list of vxlan-tunnel interfaces */
12078 M (VXLAN_TUNNEL_DUMP, mp);
12080 mp->sw_if_index = htonl (sw_if_index);
12084 /* Use a control ping for synchronization */
12085 MPING (CONTROL_PING, mp_ping);
12092 static uword unformat_geneve_decap_next
12093 (unformat_input_t * input, va_list * args)
12095 u32 *result = va_arg (*args, u32 *);
12098 if (unformat (input, "l2"))
12099 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12100 else if (unformat (input, "%d", &tmp))
12108 api_geneve_add_del_tunnel (vat_main_t * vam)
12110 unformat_input_t *line_input = vam->input;
12111 vl_api_geneve_add_del_tunnel_t *mp;
12112 ip46_address_t src, dst;
12114 u8 ipv4_set = 0, ipv6_set = 0;
12118 u32 mcast_sw_if_index = ~0;
12119 u32 encap_vrf_id = 0;
12120 u32 decap_next_index = ~0;
12124 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12125 memset (&src, 0, sizeof src);
12126 memset (&dst, 0, sizeof dst);
12128 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12130 if (unformat (line_input, "del"))
12133 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12139 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12145 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12151 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12156 else if (unformat (line_input, "group %U %U",
12157 unformat_ip4_address, &dst.ip4,
12158 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12160 grp_set = dst_set = 1;
12163 else if (unformat (line_input, "group %U",
12164 unformat_ip4_address, &dst.ip4))
12166 grp_set = dst_set = 1;
12169 else if (unformat (line_input, "group %U %U",
12170 unformat_ip6_address, &dst.ip6,
12171 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12173 grp_set = dst_set = 1;
12176 else if (unformat (line_input, "group %U",
12177 unformat_ip6_address, &dst.ip6))
12179 grp_set = dst_set = 1;
12183 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12185 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12187 else if (unformat (line_input, "decap-next %U",
12188 unformat_geneve_decap_next, &decap_next_index))
12190 else if (unformat (line_input, "vni %d", &vni))
12194 errmsg ("parse error '%U'", format_unformat_error, line_input);
12201 errmsg ("tunnel src address not specified");
12206 errmsg ("tunnel dst address not specified");
12210 if (grp_set && !ip46_address_is_multicast (&dst))
12212 errmsg ("tunnel group address not multicast");
12215 if (grp_set && mcast_sw_if_index == ~0)
12217 errmsg ("tunnel nonexistent multicast device");
12220 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12222 errmsg ("tunnel dst address must be unicast");
12227 if (ipv4_set && ipv6_set)
12229 errmsg ("both IPv4 and IPv6 addresses specified");
12233 if ((vni == 0) || (vni >> 24))
12235 errmsg ("vni not specified or out of range");
12239 M (GENEVE_ADD_DEL_TUNNEL, mp);
12243 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12244 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12248 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12249 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12251 mp->encap_vrf_id = ntohl (encap_vrf_id);
12252 mp->decap_next_index = ntohl (decap_next_index);
12253 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12254 mp->vni = ntohl (vni);
12255 mp->is_add = is_add;
12256 mp->is_ipv6 = ipv6_set;
12263 static void vl_api_geneve_tunnel_details_t_handler
12264 (vl_api_geneve_tunnel_details_t * mp)
12266 vat_main_t *vam = &vat_main;
12267 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12268 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12270 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12271 ntohl (mp->sw_if_index),
12272 format_ip46_address, &src, IP46_TYPE_ANY,
12273 format_ip46_address, &dst, IP46_TYPE_ANY,
12274 ntohl (mp->encap_vrf_id),
12275 ntohl (mp->decap_next_index), ntohl (mp->vni),
12276 ntohl (mp->mcast_sw_if_index));
12279 static void vl_api_geneve_tunnel_details_t_handler_json
12280 (vl_api_geneve_tunnel_details_t * mp)
12282 vat_main_t *vam = &vat_main;
12283 vat_json_node_t *node = NULL;
12285 if (VAT_JSON_ARRAY != vam->json_tree.type)
12287 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12288 vat_json_init_array (&vam->json_tree);
12290 node = vat_json_array_add (&vam->json_tree);
12292 vat_json_init_object (node);
12293 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12296 struct in6_addr ip6;
12298 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12299 vat_json_object_add_ip6 (node, "src_address", ip6);
12300 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12301 vat_json_object_add_ip6 (node, "dst_address", ip6);
12305 struct in_addr ip4;
12307 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12308 vat_json_object_add_ip4 (node, "src_address", ip4);
12309 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12310 vat_json_object_add_ip4 (node, "dst_address", ip4);
12312 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12313 vat_json_object_add_uint (node, "decap_next_index",
12314 ntohl (mp->decap_next_index));
12315 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12316 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12317 vat_json_object_add_uint (node, "mcast_sw_if_index",
12318 ntohl (mp->mcast_sw_if_index));
12322 api_geneve_tunnel_dump (vat_main_t * vam)
12324 unformat_input_t *i = vam->input;
12325 vl_api_geneve_tunnel_dump_t *mp;
12326 vl_api_control_ping_t *mp_ping;
12328 u8 sw_if_index_set = 0;
12331 /* Parse args required to build the message */
12332 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12334 if (unformat (i, "sw_if_index %d", &sw_if_index))
12335 sw_if_index_set = 1;
12340 if (sw_if_index_set == 0)
12345 if (!vam->json_output)
12347 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12348 "sw_if_index", "local_address", "remote_address",
12349 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12352 /* Get list of geneve-tunnel interfaces */
12353 M (GENEVE_TUNNEL_DUMP, mp);
12355 mp->sw_if_index = htonl (sw_if_index);
12359 /* Use a control ping for synchronization */
12360 M (CONTROL_PING, mp_ping);
12368 api_gre_add_del_tunnel (vat_main_t * vam)
12370 unformat_input_t *line_input = vam->input;
12371 vl_api_gre_add_del_tunnel_t *mp;
12372 ip4_address_t src4, dst4;
12373 ip6_address_t src6, dst6;
12380 u32 outer_fib_id = 0;
12383 memset (&src4, 0, sizeof src4);
12384 memset (&dst4, 0, sizeof dst4);
12385 memset (&src6, 0, sizeof src6);
12386 memset (&dst6, 0, sizeof dst6);
12388 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12390 if (unformat (line_input, "del"))
12392 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
12397 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
12402 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
12407 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
12412 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12414 else if (unformat (line_input, "teb"))
12418 errmsg ("parse error '%U'", format_unformat_error, line_input);
12425 errmsg ("tunnel src address not specified");
12430 errmsg ("tunnel dst address not specified");
12433 if (ipv4_set && ipv6_set)
12435 errmsg ("both IPv4 and IPv6 addresses specified");
12440 M (GRE_ADD_DEL_TUNNEL, mp);
12444 clib_memcpy (&mp->src_address, &src4, 4);
12445 clib_memcpy (&mp->dst_address, &dst4, 4);
12449 clib_memcpy (&mp->src_address, &src6, 16);
12450 clib_memcpy (&mp->dst_address, &dst6, 16);
12452 mp->outer_fib_id = ntohl (outer_fib_id);
12453 mp->is_add = is_add;
12455 mp->is_ipv6 = ipv6_set;
12462 static void vl_api_gre_tunnel_details_t_handler
12463 (vl_api_gre_tunnel_details_t * mp)
12465 vat_main_t *vam = &vat_main;
12466 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
12467 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
12469 print (vam->ofp, "%11d%24U%24U%6d%14d",
12470 ntohl (mp->sw_if_index),
12471 format_ip46_address, &src, IP46_TYPE_ANY,
12472 format_ip46_address, &dst, IP46_TYPE_ANY,
12473 mp->teb, ntohl (mp->outer_fib_id));
12476 static void vl_api_gre_tunnel_details_t_handler_json
12477 (vl_api_gre_tunnel_details_t * mp)
12479 vat_main_t *vam = &vat_main;
12480 vat_json_node_t *node = NULL;
12481 struct in_addr ip4;
12482 struct in6_addr ip6;
12484 if (VAT_JSON_ARRAY != vam->json_tree.type)
12486 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12487 vat_json_init_array (&vam->json_tree);
12489 node = vat_json_array_add (&vam->json_tree);
12491 vat_json_init_object (node);
12492 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12495 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
12496 vat_json_object_add_ip4 (node, "src_address", ip4);
12497 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
12498 vat_json_object_add_ip4 (node, "dst_address", ip4);
12502 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
12503 vat_json_object_add_ip6 (node, "src_address", ip6);
12504 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
12505 vat_json_object_add_ip6 (node, "dst_address", ip6);
12507 vat_json_object_add_uint (node, "teb", mp->teb);
12508 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
12509 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
12513 api_gre_tunnel_dump (vat_main_t * vam)
12515 unformat_input_t *i = vam->input;
12516 vl_api_gre_tunnel_dump_t *mp;
12517 vl_api_control_ping_t *mp_ping;
12519 u8 sw_if_index_set = 0;
12522 /* Parse args required to build the message */
12523 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12525 if (unformat (i, "sw_if_index %d", &sw_if_index))
12526 sw_if_index_set = 1;
12531 if (sw_if_index_set == 0)
12536 if (!vam->json_output)
12538 print (vam->ofp, "%11s%24s%24s%6s%14s",
12539 "sw_if_index", "src_address", "dst_address", "teb",
12543 /* Get list of gre-tunnel interfaces */
12544 M (GRE_TUNNEL_DUMP, mp);
12546 mp->sw_if_index = htonl (sw_if_index);
12550 /* Use a control ping for synchronization */
12551 MPING (CONTROL_PING, mp_ping);
12559 api_l2_fib_clear_table (vat_main_t * vam)
12561 // unformat_input_t * i = vam->input;
12562 vl_api_l2_fib_clear_table_t *mp;
12565 M (L2_FIB_CLEAR_TABLE, mp);
12573 api_l2_interface_efp_filter (vat_main_t * vam)
12575 unformat_input_t *i = vam->input;
12576 vl_api_l2_interface_efp_filter_t *mp;
12579 u8 sw_if_index_set = 0;
12582 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12584 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12585 sw_if_index_set = 1;
12586 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12587 sw_if_index_set = 1;
12588 else if (unformat (i, "enable"))
12590 else if (unformat (i, "disable"))
12594 clib_warning ("parse error '%U'", format_unformat_error, i);
12599 if (sw_if_index_set == 0)
12601 errmsg ("missing sw_if_index");
12605 M (L2_INTERFACE_EFP_FILTER, mp);
12607 mp->sw_if_index = ntohl (sw_if_index);
12608 mp->enable_disable = enable;
12615 #define foreach_vtr_op \
12616 _("disable", L2_VTR_DISABLED) \
12617 _("push-1", L2_VTR_PUSH_1) \
12618 _("push-2", L2_VTR_PUSH_2) \
12619 _("pop-1", L2_VTR_POP_1) \
12620 _("pop-2", L2_VTR_POP_2) \
12621 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12622 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12623 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12624 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12627 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12629 unformat_input_t *i = vam->input;
12630 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12632 u8 sw_if_index_set = 0;
12635 u32 push_dot1q = 1;
12640 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12642 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12643 sw_if_index_set = 1;
12644 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12645 sw_if_index_set = 1;
12646 else if (unformat (i, "vtr_op %d", &vtr_op))
12648 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12651 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12653 else if (unformat (i, "tag1 %d", &tag1))
12655 else if (unformat (i, "tag2 %d", &tag2))
12659 clib_warning ("parse error '%U'", format_unformat_error, i);
12664 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12666 errmsg ("missing vtr operation or sw_if_index");
12670 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12671 mp->sw_if_index = ntohl (sw_if_index);
12672 mp->vtr_op = ntohl (vtr_op);
12673 mp->push_dot1q = ntohl (push_dot1q);
12674 mp->tag1 = ntohl (tag1);
12675 mp->tag2 = ntohl (tag2);
12683 api_create_vhost_user_if (vat_main_t * vam)
12685 unformat_input_t *i = vam->input;
12686 vl_api_create_vhost_user_if_t *mp;
12689 u8 file_name_set = 0;
12690 u32 custom_dev_instance = ~0;
12692 u8 use_custom_mac = 0;
12696 /* Shut up coverity */
12697 memset (hwaddr, 0, sizeof (hwaddr));
12699 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12701 if (unformat (i, "socket %s", &file_name))
12705 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12707 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12708 use_custom_mac = 1;
12709 else if (unformat (i, "server"))
12711 else if (unformat (i, "tag %s", &tag))
12717 if (file_name_set == 0)
12719 errmsg ("missing socket file name");
12723 if (vec_len (file_name) > 255)
12725 errmsg ("socket file name too long");
12728 vec_add1 (file_name, 0);
12730 M (CREATE_VHOST_USER_IF, mp);
12732 mp->is_server = is_server;
12733 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12734 vec_free (file_name);
12735 if (custom_dev_instance != ~0)
12738 mp->custom_dev_instance = ntohl (custom_dev_instance);
12740 mp->use_custom_mac = use_custom_mac;
12741 clib_memcpy (mp->mac_address, hwaddr, 6);
12743 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12752 api_modify_vhost_user_if (vat_main_t * vam)
12754 unformat_input_t *i = vam->input;
12755 vl_api_modify_vhost_user_if_t *mp;
12758 u8 file_name_set = 0;
12759 u32 custom_dev_instance = ~0;
12760 u8 sw_if_index_set = 0;
12761 u32 sw_if_index = (u32) ~ 0;
12764 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12766 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12767 sw_if_index_set = 1;
12768 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12769 sw_if_index_set = 1;
12770 else if (unformat (i, "socket %s", &file_name))
12774 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12776 else if (unformat (i, "server"))
12782 if (sw_if_index_set == 0)
12784 errmsg ("missing sw_if_index or interface name");
12788 if (file_name_set == 0)
12790 errmsg ("missing socket file name");
12794 if (vec_len (file_name) > 255)
12796 errmsg ("socket file name too long");
12799 vec_add1 (file_name, 0);
12801 M (MODIFY_VHOST_USER_IF, mp);
12803 mp->sw_if_index = ntohl (sw_if_index);
12804 mp->is_server = is_server;
12805 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12806 vec_free (file_name);
12807 if (custom_dev_instance != ~0)
12810 mp->custom_dev_instance = ntohl (custom_dev_instance);
12819 api_delete_vhost_user_if (vat_main_t * vam)
12821 unformat_input_t *i = vam->input;
12822 vl_api_delete_vhost_user_if_t *mp;
12823 u32 sw_if_index = ~0;
12824 u8 sw_if_index_set = 0;
12827 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12829 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12830 sw_if_index_set = 1;
12831 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12832 sw_if_index_set = 1;
12837 if (sw_if_index_set == 0)
12839 errmsg ("missing sw_if_index or interface name");
12844 M (DELETE_VHOST_USER_IF, mp);
12846 mp->sw_if_index = ntohl (sw_if_index);
12853 static void vl_api_sw_interface_vhost_user_details_t_handler
12854 (vl_api_sw_interface_vhost_user_details_t * mp)
12856 vat_main_t *vam = &vat_main;
12858 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12859 (char *) mp->interface_name,
12860 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12861 clib_net_to_host_u64 (mp->features), mp->is_server,
12862 ntohl (mp->num_regions), (char *) mp->sock_filename);
12863 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12866 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12867 (vl_api_sw_interface_vhost_user_details_t * mp)
12869 vat_main_t *vam = &vat_main;
12870 vat_json_node_t *node = NULL;
12872 if (VAT_JSON_ARRAY != vam->json_tree.type)
12874 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12875 vat_json_init_array (&vam->json_tree);
12877 node = vat_json_array_add (&vam->json_tree);
12879 vat_json_init_object (node);
12880 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12881 vat_json_object_add_string_copy (node, "interface_name",
12882 mp->interface_name);
12883 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12884 ntohl (mp->virtio_net_hdr_sz));
12885 vat_json_object_add_uint (node, "features",
12886 clib_net_to_host_u64 (mp->features));
12887 vat_json_object_add_uint (node, "is_server", mp->is_server);
12888 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12889 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12890 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12894 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12896 vl_api_sw_interface_vhost_user_dump_t *mp;
12897 vl_api_control_ping_t *mp_ping;
12900 "Interface name idx hdr_sz features server regions filename");
12902 /* Get list of vhost-user interfaces */
12903 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12906 /* Use a control ping for synchronization */
12907 MPING (CONTROL_PING, mp_ping);
12915 api_show_version (vat_main_t * vam)
12917 vl_api_show_version_t *mp;
12920 M (SHOW_VERSION, mp);
12929 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12931 unformat_input_t *line_input = vam->input;
12932 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12933 ip4_address_t local4, remote4;
12934 ip6_address_t local6, remote6;
12936 u8 ipv4_set = 0, ipv6_set = 0;
12940 u32 mcast_sw_if_index = ~0;
12941 u32 encap_vrf_id = 0;
12942 u32 decap_vrf_id = 0;
12948 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12949 memset (&local4, 0, sizeof local4);
12950 memset (&remote4, 0, sizeof remote4);
12951 memset (&local6, 0, sizeof local6);
12952 memset (&remote6, 0, sizeof remote6);
12954 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12956 if (unformat (line_input, "del"))
12958 else if (unformat (line_input, "local %U",
12959 unformat_ip4_address, &local4))
12964 else if (unformat (line_input, "remote %U",
12965 unformat_ip4_address, &remote4))
12970 else if (unformat (line_input, "local %U",
12971 unformat_ip6_address, &local6))
12976 else if (unformat (line_input, "remote %U",
12977 unformat_ip6_address, &remote6))
12982 else if (unformat (line_input, "group %U %U",
12983 unformat_ip4_address, &remote4,
12984 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12986 grp_set = remote_set = 1;
12989 else if (unformat (line_input, "group %U",
12990 unformat_ip4_address, &remote4))
12992 grp_set = remote_set = 1;
12995 else if (unformat (line_input, "group %U %U",
12996 unformat_ip6_address, &remote6,
12997 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12999 grp_set = remote_set = 1;
13002 else if (unformat (line_input, "group %U",
13003 unformat_ip6_address, &remote6))
13005 grp_set = remote_set = 1;
13009 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13011 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13013 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13015 else if (unformat (line_input, "vni %d", &vni))
13017 else if (unformat (line_input, "next-ip4"))
13019 else if (unformat (line_input, "next-ip6"))
13021 else if (unformat (line_input, "next-ethernet"))
13023 else if (unformat (line_input, "next-nsh"))
13027 errmsg ("parse error '%U'", format_unformat_error, line_input);
13032 if (local_set == 0)
13034 errmsg ("tunnel local address not specified");
13037 if (remote_set == 0)
13039 errmsg ("tunnel remote address not specified");
13042 if (grp_set && mcast_sw_if_index == ~0)
13044 errmsg ("tunnel nonexistent multicast device");
13047 if (ipv4_set && ipv6_set)
13049 errmsg ("both IPv4 and IPv6 addresses specified");
13055 errmsg ("vni not specified");
13059 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13064 clib_memcpy (&mp->local, &local6, sizeof (local6));
13065 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13069 clib_memcpy (&mp->local, &local4, sizeof (local4));
13070 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13073 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13074 mp->encap_vrf_id = ntohl (encap_vrf_id);
13075 mp->decap_vrf_id = ntohl (decap_vrf_id);
13076 mp->protocol = protocol;
13077 mp->vni = ntohl (vni);
13078 mp->is_add = is_add;
13079 mp->is_ipv6 = ipv6_set;
13086 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13087 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13089 vat_main_t *vam = &vat_main;
13090 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13091 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13093 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13094 ntohl (mp->sw_if_index),
13095 format_ip46_address, &local, IP46_TYPE_ANY,
13096 format_ip46_address, &remote, IP46_TYPE_ANY,
13097 ntohl (mp->vni), mp->protocol,
13098 ntohl (mp->mcast_sw_if_index),
13099 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13103 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13104 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13106 vat_main_t *vam = &vat_main;
13107 vat_json_node_t *node = NULL;
13108 struct in_addr ip4;
13109 struct in6_addr ip6;
13111 if (VAT_JSON_ARRAY != vam->json_tree.type)
13113 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13114 vat_json_init_array (&vam->json_tree);
13116 node = vat_json_array_add (&vam->json_tree);
13118 vat_json_init_object (node);
13119 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13122 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13123 vat_json_object_add_ip6 (node, "local", ip6);
13124 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13125 vat_json_object_add_ip6 (node, "remote", ip6);
13129 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13130 vat_json_object_add_ip4 (node, "local", ip4);
13131 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13132 vat_json_object_add_ip4 (node, "remote", ip4);
13134 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13135 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13136 vat_json_object_add_uint (node, "mcast_sw_if_index",
13137 ntohl (mp->mcast_sw_if_index));
13138 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13139 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13140 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13144 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13146 unformat_input_t *i = vam->input;
13147 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13148 vl_api_control_ping_t *mp_ping;
13150 u8 sw_if_index_set = 0;
13153 /* Parse args required to build the message */
13154 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13156 if (unformat (i, "sw_if_index %d", &sw_if_index))
13157 sw_if_index_set = 1;
13162 if (sw_if_index_set == 0)
13167 if (!vam->json_output)
13169 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13170 "sw_if_index", "local", "remote", "vni",
13171 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13174 /* Get list of vxlan-tunnel interfaces */
13175 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13177 mp->sw_if_index = htonl (sw_if_index);
13181 /* Use a control ping for synchronization */
13182 MPING (CONTROL_PING, mp_ping);
13191 format_l2_fib_mac_address (u8 * s, va_list * args)
13193 u8 *a = va_arg (*args, u8 *);
13195 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
13196 a[2], a[3], a[4], a[5], a[6], a[7]);
13199 static void vl_api_l2_fib_table_details_t_handler
13200 (vl_api_l2_fib_table_details_t * mp)
13202 vat_main_t *vam = &vat_main;
13204 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13206 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
13207 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13211 static void vl_api_l2_fib_table_details_t_handler_json
13212 (vl_api_l2_fib_table_details_t * mp)
13214 vat_main_t *vam = &vat_main;
13215 vat_json_node_t *node = NULL;
13217 if (VAT_JSON_ARRAY != vam->json_tree.type)
13219 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13220 vat_json_init_array (&vam->json_tree);
13222 node = vat_json_array_add (&vam->json_tree);
13224 vat_json_init_object (node);
13225 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13226 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
13227 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13228 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13229 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13230 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13234 api_l2_fib_table_dump (vat_main_t * vam)
13236 unformat_input_t *i = vam->input;
13237 vl_api_l2_fib_table_dump_t *mp;
13238 vl_api_control_ping_t *mp_ping;
13243 /* Parse args required to build the message */
13244 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13246 if (unformat (i, "bd_id %d", &bd_id))
13252 if (bd_id_set == 0)
13254 errmsg ("missing bridge domain");
13258 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13260 /* Get list of l2 fib entries */
13261 M (L2_FIB_TABLE_DUMP, mp);
13263 mp->bd_id = ntohl (bd_id);
13266 /* Use a control ping for synchronization */
13267 MPING (CONTROL_PING, mp_ping);
13276 api_interface_name_renumber (vat_main_t * vam)
13278 unformat_input_t *line_input = vam->input;
13279 vl_api_interface_name_renumber_t *mp;
13280 u32 sw_if_index = ~0;
13281 u32 new_show_dev_instance = ~0;
13284 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13286 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13289 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13291 else if (unformat (line_input, "new_show_dev_instance %d",
13292 &new_show_dev_instance))
13298 if (sw_if_index == ~0)
13300 errmsg ("missing interface name or sw_if_index");
13304 if (new_show_dev_instance == ~0)
13306 errmsg ("missing new_show_dev_instance");
13310 M (INTERFACE_NAME_RENUMBER, mp);
13312 mp->sw_if_index = ntohl (sw_if_index);
13313 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13321 api_want_ip4_arp_events (vat_main_t * vam)
13323 unformat_input_t *line_input = vam->input;
13324 vl_api_want_ip4_arp_events_t *mp;
13325 ip4_address_t address;
13326 int address_set = 0;
13327 u32 enable_disable = 1;
13330 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13332 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
13334 else if (unformat (line_input, "del"))
13335 enable_disable = 0;
13340 if (address_set == 0)
13342 errmsg ("missing addresses");
13346 M (WANT_IP4_ARP_EVENTS, mp);
13347 mp->enable_disable = enable_disable;
13348 mp->pid = htonl (getpid ());
13349 mp->address = address.as_u32;
13357 api_want_ip6_nd_events (vat_main_t * vam)
13359 unformat_input_t *line_input = vam->input;
13360 vl_api_want_ip6_nd_events_t *mp;
13361 ip6_address_t address;
13362 int address_set = 0;
13363 u32 enable_disable = 1;
13366 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13368 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
13370 else if (unformat (line_input, "del"))
13371 enable_disable = 0;
13376 if (address_set == 0)
13378 errmsg ("missing addresses");
13382 M (WANT_IP6_ND_EVENTS, mp);
13383 mp->enable_disable = enable_disable;
13384 mp->pid = htonl (getpid ());
13385 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
13393 api_want_l2_macs_events (vat_main_t * vam)
13395 unformat_input_t *line_input = vam->input;
13396 vl_api_want_l2_macs_events_t *mp;
13397 u8 enable_disable = 1;
13398 u32 scan_delay = 0;
13399 u32 max_macs_in_event = 0;
13400 u32 learn_limit = 0;
13403 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13405 if (unformat (line_input, "learn-limit %d", &learn_limit))
13407 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13409 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13411 else if (unformat (line_input, "disable"))
13412 enable_disable = 0;
13417 M (WANT_L2_MACS_EVENTS, mp);
13418 mp->enable_disable = enable_disable;
13419 mp->pid = htonl (getpid ());
13420 mp->learn_limit = htonl (learn_limit);
13421 mp->scan_delay = (u8) scan_delay;
13422 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13429 api_input_acl_set_interface (vat_main_t * vam)
13431 unformat_input_t *i = vam->input;
13432 vl_api_input_acl_set_interface_t *mp;
13434 int sw_if_index_set;
13435 u32 ip4_table_index = ~0;
13436 u32 ip6_table_index = ~0;
13437 u32 l2_table_index = ~0;
13441 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13443 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13444 sw_if_index_set = 1;
13445 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13446 sw_if_index_set = 1;
13447 else if (unformat (i, "del"))
13449 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13451 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13453 else if (unformat (i, "l2-table %d", &l2_table_index))
13457 clib_warning ("parse error '%U'", format_unformat_error, i);
13462 if (sw_if_index_set == 0)
13464 errmsg ("missing interface name or sw_if_index");
13468 M (INPUT_ACL_SET_INTERFACE, mp);
13470 mp->sw_if_index = ntohl (sw_if_index);
13471 mp->ip4_table_index = ntohl (ip4_table_index);
13472 mp->ip6_table_index = ntohl (ip6_table_index);
13473 mp->l2_table_index = ntohl (l2_table_index);
13474 mp->is_add = is_add;
13482 api_ip_address_dump (vat_main_t * vam)
13484 unformat_input_t *i = vam->input;
13485 vl_api_ip_address_dump_t *mp;
13486 vl_api_control_ping_t *mp_ping;
13487 u32 sw_if_index = ~0;
13488 u8 sw_if_index_set = 0;
13493 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13495 if (unformat (i, "sw_if_index %d", &sw_if_index))
13496 sw_if_index_set = 1;
13498 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13499 sw_if_index_set = 1;
13500 else if (unformat (i, "ipv4"))
13502 else if (unformat (i, "ipv6"))
13508 if (ipv4_set && ipv6_set)
13510 errmsg ("ipv4 and ipv6 flags cannot be both set");
13514 if ((!ipv4_set) && (!ipv6_set))
13516 errmsg ("no ipv4 nor ipv6 flag set");
13520 if (sw_if_index_set == 0)
13522 errmsg ("missing interface name or sw_if_index");
13526 vam->current_sw_if_index = sw_if_index;
13527 vam->is_ipv6 = ipv6_set;
13529 M (IP_ADDRESS_DUMP, mp);
13530 mp->sw_if_index = ntohl (sw_if_index);
13531 mp->is_ipv6 = ipv6_set;
13534 /* Use a control ping for synchronization */
13535 MPING (CONTROL_PING, mp_ping);
13543 api_ip_dump (vat_main_t * vam)
13545 vl_api_ip_dump_t *mp;
13546 vl_api_control_ping_t *mp_ping;
13547 unformat_input_t *in = vam->input;
13554 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13556 if (unformat (in, "ipv4"))
13558 else if (unformat (in, "ipv6"))
13564 if (ipv4_set && ipv6_set)
13566 errmsg ("ipv4 and ipv6 flags cannot be both set");
13570 if ((!ipv4_set) && (!ipv6_set))
13572 errmsg ("no ipv4 nor ipv6 flag set");
13576 is_ipv6 = ipv6_set;
13577 vam->is_ipv6 = is_ipv6;
13579 /* free old data */
13580 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13582 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13584 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13587 mp->is_ipv6 = ipv6_set;
13590 /* Use a control ping for synchronization */
13591 MPING (CONTROL_PING, mp_ping);
13599 api_ipsec_spd_add_del (vat_main_t * vam)
13601 unformat_input_t *i = vam->input;
13602 vl_api_ipsec_spd_add_del_t *mp;
13607 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13609 if (unformat (i, "spd_id %d", &spd_id))
13611 else if (unformat (i, "del"))
13615 clib_warning ("parse error '%U'", format_unformat_error, i);
13621 errmsg ("spd_id must be set");
13625 M (IPSEC_SPD_ADD_DEL, mp);
13627 mp->spd_id = ntohl (spd_id);
13628 mp->is_add = is_add;
13636 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13638 unformat_input_t *i = vam->input;
13639 vl_api_ipsec_interface_add_del_spd_t *mp;
13641 u8 sw_if_index_set = 0;
13642 u32 spd_id = (u32) ~ 0;
13646 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13648 if (unformat (i, "del"))
13650 else if (unformat (i, "spd_id %d", &spd_id))
13653 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13654 sw_if_index_set = 1;
13655 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13656 sw_if_index_set = 1;
13659 clib_warning ("parse error '%U'", format_unformat_error, i);
13665 if (spd_id == (u32) ~ 0)
13667 errmsg ("spd_id must be set");
13671 if (sw_if_index_set == 0)
13673 errmsg ("missing interface name or sw_if_index");
13677 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13679 mp->spd_id = ntohl (spd_id);
13680 mp->sw_if_index = ntohl (sw_if_index);
13681 mp->is_add = is_add;
13689 api_ipsec_spd_add_del_entry (vat_main_t * vam)
13691 unformat_input_t *i = vam->input;
13692 vl_api_ipsec_spd_add_del_entry_t *mp;
13693 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
13694 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13696 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13697 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13698 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
13699 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
13702 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
13703 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
13704 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
13705 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
13706 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
13707 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
13709 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13711 if (unformat (i, "del"))
13713 if (unformat (i, "outbound"))
13715 if (unformat (i, "inbound"))
13717 else if (unformat (i, "spd_id %d", &spd_id))
13719 else if (unformat (i, "sa_id %d", &sa_id))
13721 else if (unformat (i, "priority %d", &priority))
13723 else if (unformat (i, "protocol %d", &protocol))
13725 else if (unformat (i, "lport_start %d", &lport_start))
13727 else if (unformat (i, "lport_stop %d", &lport_stop))
13729 else if (unformat (i, "rport_start %d", &rport_start))
13731 else if (unformat (i, "rport_stop %d", &rport_stop))
13735 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
13741 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
13748 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
13754 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
13761 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
13767 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
13774 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
13780 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
13786 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13788 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13790 clib_warning ("unsupported action: 'resolve'");
13796 clib_warning ("parse error '%U'", format_unformat_error, i);
13802 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
13804 mp->spd_id = ntohl (spd_id);
13805 mp->priority = ntohl (priority);
13806 mp->is_outbound = is_outbound;
13808 mp->is_ipv6 = is_ipv6;
13809 if (is_ipv6 || is_ip_any)
13811 clib_memcpy (mp->remote_address_start, &raddr6_start,
13812 sizeof (ip6_address_t));
13813 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
13814 sizeof (ip6_address_t));
13815 clib_memcpy (mp->local_address_start, &laddr6_start,
13816 sizeof (ip6_address_t));
13817 clib_memcpy (mp->local_address_stop, &laddr6_stop,
13818 sizeof (ip6_address_t));
13822 clib_memcpy (mp->remote_address_start, &raddr4_start,
13823 sizeof (ip4_address_t));
13824 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
13825 sizeof (ip4_address_t));
13826 clib_memcpy (mp->local_address_start, &laddr4_start,
13827 sizeof (ip4_address_t));
13828 clib_memcpy (mp->local_address_stop, &laddr4_stop,
13829 sizeof (ip4_address_t));
13831 mp->protocol = (u8) protocol;
13832 mp->local_port_start = ntohs ((u16) lport_start);
13833 mp->local_port_stop = ntohs ((u16) lport_stop);
13834 mp->remote_port_start = ntohs ((u16) rport_start);
13835 mp->remote_port_stop = ntohs ((u16) rport_stop);
13836 mp->policy = (u8) policy;
13837 mp->sa_id = ntohl (sa_id);
13838 mp->is_add = is_add;
13839 mp->is_ip_any = is_ip_any;
13846 api_ipsec_sad_add_del_entry (vat_main_t * vam)
13848 unformat_input_t *i = vam->input;
13849 vl_api_ipsec_sad_add_del_entry_t *mp;
13850 u32 sad_id = 0, spi = 0;
13851 u8 *ck = 0, *ik = 0;
13854 u8 protocol = IPSEC_PROTOCOL_AH;
13855 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
13856 u32 crypto_alg = 0, integ_alg = 0;
13857 ip4_address_t tun_src4;
13858 ip4_address_t tun_dst4;
13859 ip6_address_t tun_src6;
13860 ip6_address_t tun_dst6;
13863 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13865 if (unformat (i, "del"))
13867 else if (unformat (i, "sad_id %d", &sad_id))
13869 else if (unformat (i, "spi %d", &spi))
13871 else if (unformat (i, "esp"))
13872 protocol = IPSEC_PROTOCOL_ESP;
13873 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
13876 is_tunnel_ipv6 = 0;
13878 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
13881 is_tunnel_ipv6 = 0;
13883 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
13886 is_tunnel_ipv6 = 1;
13888 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
13891 is_tunnel_ipv6 = 1;
13895 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13897 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13898 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13900 clib_warning ("unsupported crypto-alg: '%U'",
13901 format_ipsec_crypto_alg, crypto_alg);
13905 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13909 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13911 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13912 integ_alg >= IPSEC_INTEG_N_ALG)
13914 clib_warning ("unsupported integ-alg: '%U'",
13915 format_ipsec_integ_alg, integ_alg);
13919 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13923 clib_warning ("parse error '%U'", format_unformat_error, i);
13929 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
13931 mp->sad_id = ntohl (sad_id);
13932 mp->is_add = is_add;
13933 mp->protocol = protocol;
13934 mp->spi = ntohl (spi);
13935 mp->is_tunnel = is_tunnel;
13936 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
13937 mp->crypto_algorithm = crypto_alg;
13938 mp->integrity_algorithm = integ_alg;
13939 mp->crypto_key_length = vec_len (ck);
13940 mp->integrity_key_length = vec_len (ik);
13942 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13943 mp->crypto_key_length = sizeof (mp->crypto_key);
13945 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13946 mp->integrity_key_length = sizeof (mp->integrity_key);
13949 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13951 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13955 if (is_tunnel_ipv6)
13957 clib_memcpy (mp->tunnel_src_address, &tun_src6,
13958 sizeof (ip6_address_t));
13959 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
13960 sizeof (ip6_address_t));
13964 clib_memcpy (mp->tunnel_src_address, &tun_src4,
13965 sizeof (ip4_address_t));
13966 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
13967 sizeof (ip4_address_t));
13977 api_ipsec_sa_set_key (vat_main_t * vam)
13979 unformat_input_t *i = vam->input;
13980 vl_api_ipsec_sa_set_key_t *mp;
13982 u8 *ck = 0, *ik = 0;
13985 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13987 if (unformat (i, "sa_id %d", &sa_id))
13989 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13991 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13995 clib_warning ("parse error '%U'", format_unformat_error, i);
14000 M (IPSEC_SA_SET_KEY, mp);
14002 mp->sa_id = ntohl (sa_id);
14003 mp->crypto_key_length = vec_len (ck);
14004 mp->integrity_key_length = vec_len (ik);
14006 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14007 mp->crypto_key_length = sizeof (mp->crypto_key);
14009 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14010 mp->integrity_key_length = sizeof (mp->integrity_key);
14013 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14015 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14023 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14025 unformat_input_t *i = vam->input;
14026 vl_api_ipsec_tunnel_if_add_del_t *mp;
14027 u32 local_spi = 0, remote_spi = 0;
14028 u32 crypto_alg = 0, integ_alg = 0;
14029 u8 *lck = NULL, *rck = NULL;
14030 u8 *lik = NULL, *rik = NULL;
14031 ip4_address_t local_ip = { {0} };
14032 ip4_address_t remote_ip = { {0} };
14035 u8 anti_replay = 0;
14038 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14040 if (unformat (i, "del"))
14042 else if (unformat (i, "esn"))
14044 else if (unformat (i, "anti_replay"))
14046 else if (unformat (i, "local_spi %d", &local_spi))
14048 else if (unformat (i, "remote_spi %d", &remote_spi))
14050 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
14052 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
14054 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14057 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14059 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14061 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14065 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14067 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14068 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14070 errmsg ("unsupported crypto-alg: '%U'\n",
14071 format_ipsec_crypto_alg, crypto_alg);
14077 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14079 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14080 integ_alg >= IPSEC_INTEG_N_ALG)
14082 errmsg ("unsupported integ-alg: '%U'\n",
14083 format_ipsec_integ_alg, integ_alg);
14089 errmsg ("parse error '%U'\n", format_unformat_error, i);
14094 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14096 mp->is_add = is_add;
14098 mp->anti_replay = anti_replay;
14100 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
14101 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
14103 mp->local_spi = htonl (local_spi);
14104 mp->remote_spi = htonl (remote_spi);
14105 mp->crypto_alg = (u8) crypto_alg;
14107 mp->local_crypto_key_len = 0;
14110 mp->local_crypto_key_len = vec_len (lck);
14111 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14112 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14113 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14116 mp->remote_crypto_key_len = 0;
14119 mp->remote_crypto_key_len = vec_len (rck);
14120 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14121 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14122 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14125 mp->integ_alg = (u8) integ_alg;
14127 mp->local_integ_key_len = 0;
14130 mp->local_integ_key_len = vec_len (lik);
14131 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14132 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14133 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14136 mp->remote_integ_key_len = 0;
14139 mp->remote_integ_key_len = vec_len (rik);
14140 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14141 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14142 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14151 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14153 vat_main_t *vam = &vat_main;
14155 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14156 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
14157 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
14158 "tunnel_src_addr %U tunnel_dst_addr %U "
14159 "salt %u seq_outbound %lu last_seq_inbound %lu "
14160 "replay_window %lu total_data_size %lu\n",
14161 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
14163 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
14164 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
14165 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
14166 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14167 mp->tunnel_src_addr,
14168 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14169 mp->tunnel_dst_addr,
14171 clib_net_to_host_u64 (mp->seq_outbound),
14172 clib_net_to_host_u64 (mp->last_seq_inbound),
14173 clib_net_to_host_u64 (mp->replay_window),
14174 clib_net_to_host_u64 (mp->total_data_size));
14177 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14178 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14180 static void vl_api_ipsec_sa_details_t_handler_json
14181 (vl_api_ipsec_sa_details_t * mp)
14183 vat_main_t *vam = &vat_main;
14184 vat_json_node_t *node = NULL;
14185 struct in_addr src_ip4, dst_ip4;
14186 struct in6_addr src_ip6, dst_ip6;
14188 if (VAT_JSON_ARRAY != vam->json_tree.type)
14190 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14191 vat_json_init_array (&vam->json_tree);
14193 node = vat_json_array_add (&vam->json_tree);
14195 vat_json_init_object (node);
14196 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
14197 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14198 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
14199 vat_json_object_add_uint (node, "proto", mp->protocol);
14200 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
14201 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
14202 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
14203 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
14204 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
14205 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
14206 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
14207 mp->crypto_key_len);
14208 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
14209 mp->integ_key_len);
14210 if (mp->is_tunnel_ip6)
14212 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
14213 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
14214 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
14215 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
14219 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
14220 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
14221 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
14222 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
14224 vat_json_object_add_uint (node, "replay_window",
14225 clib_net_to_host_u64 (mp->replay_window));
14226 vat_json_object_add_uint (node, "total_data_size",
14227 clib_net_to_host_u64 (mp->total_data_size));
14232 api_ipsec_sa_dump (vat_main_t * vam)
14234 unformat_input_t *i = vam->input;
14235 vl_api_ipsec_sa_dump_t *mp;
14236 vl_api_control_ping_t *mp_ping;
14240 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14242 if (unformat (i, "sa_id %d", &sa_id))
14246 clib_warning ("parse error '%U'", format_unformat_error, i);
14251 M (IPSEC_SA_DUMP, mp);
14253 mp->sa_id = ntohl (sa_id);
14257 /* Use a control ping for synchronization */
14258 M (CONTROL_PING, mp_ping);
14266 api_ikev2_profile_add_del (vat_main_t * vam)
14268 unformat_input_t *i = vam->input;
14269 vl_api_ikev2_profile_add_del_t *mp;
14274 const char *valid_chars = "a-zA-Z0-9_";
14276 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14278 if (unformat (i, "del"))
14280 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14281 vec_add1 (name, 0);
14284 errmsg ("parse error '%U'", format_unformat_error, i);
14289 if (!vec_len (name))
14291 errmsg ("profile name must be specified");
14295 if (vec_len (name) > 64)
14297 errmsg ("profile name too long");
14301 M (IKEV2_PROFILE_ADD_DEL, mp);
14303 clib_memcpy (mp->name, name, vec_len (name));
14304 mp->is_add = is_add;
14313 api_ikev2_profile_set_auth (vat_main_t * vam)
14315 unformat_input_t *i = vam->input;
14316 vl_api_ikev2_profile_set_auth_t *mp;
14319 u32 auth_method = 0;
14323 const char *valid_chars = "a-zA-Z0-9_";
14325 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14327 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14328 vec_add1 (name, 0);
14329 else if (unformat (i, "auth_method %U",
14330 unformat_ikev2_auth_method, &auth_method))
14332 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
14334 else if (unformat (i, "auth_data %v", &data))
14338 errmsg ("parse error '%U'", format_unformat_error, i);
14343 if (!vec_len (name))
14345 errmsg ("profile name must be specified");
14349 if (vec_len (name) > 64)
14351 errmsg ("profile name too long");
14355 if (!vec_len (data))
14357 errmsg ("auth_data must be specified");
14363 errmsg ("auth_method must be specified");
14367 M (IKEV2_PROFILE_SET_AUTH, mp);
14369 mp->is_hex = is_hex;
14370 mp->auth_method = (u8) auth_method;
14371 mp->data_len = vec_len (data);
14372 clib_memcpy (mp->name, name, vec_len (name));
14373 clib_memcpy (mp->data, data, vec_len (data));
14383 api_ikev2_profile_set_id (vat_main_t * vam)
14385 unformat_input_t *i = vam->input;
14386 vl_api_ikev2_profile_set_id_t *mp;
14394 const char *valid_chars = "a-zA-Z0-9_";
14396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14398 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14399 vec_add1 (name, 0);
14400 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
14402 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
14404 data = vec_new (u8, 4);
14405 clib_memcpy (data, ip4.as_u8, 4);
14407 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
14409 else if (unformat (i, "id_data %v", &data))
14411 else if (unformat (i, "local"))
14413 else if (unformat (i, "remote"))
14417 errmsg ("parse error '%U'", format_unformat_error, i);
14422 if (!vec_len (name))
14424 errmsg ("profile name must be specified");
14428 if (vec_len (name) > 64)
14430 errmsg ("profile name too long");
14434 if (!vec_len (data))
14436 errmsg ("id_data must be specified");
14442 errmsg ("id_type must be specified");
14446 M (IKEV2_PROFILE_SET_ID, mp);
14448 mp->is_local = is_local;
14449 mp->id_type = (u8) id_type;
14450 mp->data_len = vec_len (data);
14451 clib_memcpy (mp->name, name, vec_len (name));
14452 clib_memcpy (mp->data, data, vec_len (data));
14462 api_ikev2_profile_set_ts (vat_main_t * vam)
14464 unformat_input_t *i = vam->input;
14465 vl_api_ikev2_profile_set_ts_t *mp;
14468 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
14469 ip4_address_t start_addr, end_addr;
14471 const char *valid_chars = "a-zA-Z0-9_";
14474 start_addr.as_u32 = 0;
14475 end_addr.as_u32 = (u32) ~ 0;
14477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14479 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14480 vec_add1 (name, 0);
14481 else if (unformat (i, "protocol %d", &proto))
14483 else if (unformat (i, "start_port %d", &start_port))
14485 else if (unformat (i, "end_port %d", &end_port))
14488 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
14490 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
14492 else if (unformat (i, "local"))
14494 else if (unformat (i, "remote"))
14498 errmsg ("parse error '%U'", format_unformat_error, i);
14503 if (!vec_len (name))
14505 errmsg ("profile name must be specified");
14509 if (vec_len (name) > 64)
14511 errmsg ("profile name too long");
14515 M (IKEV2_PROFILE_SET_TS, mp);
14517 mp->is_local = is_local;
14518 mp->proto = (u8) proto;
14519 mp->start_port = (u16) start_port;
14520 mp->end_port = (u16) end_port;
14521 mp->start_addr = start_addr.as_u32;
14522 mp->end_addr = end_addr.as_u32;
14523 clib_memcpy (mp->name, name, vec_len (name));
14532 api_ikev2_set_local_key (vat_main_t * vam)
14534 unformat_input_t *i = vam->input;
14535 vl_api_ikev2_set_local_key_t *mp;
14539 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14541 if (unformat (i, "file %v", &file))
14542 vec_add1 (file, 0);
14545 errmsg ("parse error '%U'", format_unformat_error, i);
14550 if (!vec_len (file))
14552 errmsg ("RSA key file must be specified");
14556 if (vec_len (file) > 256)
14558 errmsg ("file name too long");
14562 M (IKEV2_SET_LOCAL_KEY, mp);
14564 clib_memcpy (mp->key_file, file, vec_len (file));
14573 api_ikev2_set_responder (vat_main_t * vam)
14575 unformat_input_t *i = vam->input;
14576 vl_api_ikev2_set_responder_t *mp;
14579 u32 sw_if_index = ~0;
14580 ip4_address_t address;
14582 const char *valid_chars = "a-zA-Z0-9_";
14584 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14587 (i, "%U interface %d address %U", unformat_token, valid_chars,
14588 &name, &sw_if_index, unformat_ip4_address, &address))
14589 vec_add1 (name, 0);
14592 errmsg ("parse error '%U'", format_unformat_error, i);
14597 if (!vec_len (name))
14599 errmsg ("profile name must be specified");
14603 if (vec_len (name) > 64)
14605 errmsg ("profile name too long");
14609 M (IKEV2_SET_RESPONDER, mp);
14611 clib_memcpy (mp->name, name, vec_len (name));
14614 mp->sw_if_index = sw_if_index;
14615 clib_memcpy (mp->address, &address, sizeof (address));
14623 api_ikev2_set_ike_transforms (vat_main_t * vam)
14625 unformat_input_t *i = vam->input;
14626 vl_api_ikev2_set_ike_transforms_t *mp;
14629 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14631 const char *valid_chars = "a-zA-Z0-9_";
14633 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14635 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14636 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14637 vec_add1 (name, 0);
14640 errmsg ("parse error '%U'", format_unformat_error, i);
14645 if (!vec_len (name))
14647 errmsg ("profile name must be specified");
14651 if (vec_len (name) > 64)
14653 errmsg ("profile name too long");
14657 M (IKEV2_SET_IKE_TRANSFORMS, mp);
14659 clib_memcpy (mp->name, name, vec_len (name));
14661 mp->crypto_alg = crypto_alg;
14662 mp->crypto_key_size = crypto_key_size;
14663 mp->integ_alg = integ_alg;
14664 mp->dh_group = dh_group;
14673 api_ikev2_set_esp_transforms (vat_main_t * vam)
14675 unformat_input_t *i = vam->input;
14676 vl_api_ikev2_set_esp_transforms_t *mp;
14679 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14681 const char *valid_chars = "a-zA-Z0-9_";
14683 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14685 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14686 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14687 vec_add1 (name, 0);
14690 errmsg ("parse error '%U'", format_unformat_error, i);
14695 if (!vec_len (name))
14697 errmsg ("profile name must be specified");
14701 if (vec_len (name) > 64)
14703 errmsg ("profile name too long");
14707 M (IKEV2_SET_ESP_TRANSFORMS, mp);
14709 clib_memcpy (mp->name, name, vec_len (name));
14711 mp->crypto_alg = crypto_alg;
14712 mp->crypto_key_size = crypto_key_size;
14713 mp->integ_alg = integ_alg;
14714 mp->dh_group = dh_group;
14722 api_ikev2_set_sa_lifetime (vat_main_t * vam)
14724 unformat_input_t *i = vam->input;
14725 vl_api_ikev2_set_sa_lifetime_t *mp;
14728 u64 lifetime, lifetime_maxdata;
14729 u32 lifetime_jitter, handover;
14731 const char *valid_chars = "a-zA-Z0-9_";
14733 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14735 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
14736 &lifetime, &lifetime_jitter, &handover,
14737 &lifetime_maxdata))
14738 vec_add1 (name, 0);
14741 errmsg ("parse error '%U'", format_unformat_error, i);
14746 if (!vec_len (name))
14748 errmsg ("profile name must be specified");
14752 if (vec_len (name) > 64)
14754 errmsg ("profile name too long");
14758 M (IKEV2_SET_SA_LIFETIME, mp);
14760 clib_memcpy (mp->name, name, vec_len (name));
14762 mp->lifetime = lifetime;
14763 mp->lifetime_jitter = lifetime_jitter;
14764 mp->handover = handover;
14765 mp->lifetime_maxdata = lifetime_maxdata;
14773 api_ikev2_initiate_sa_init (vat_main_t * vam)
14775 unformat_input_t *i = vam->input;
14776 vl_api_ikev2_initiate_sa_init_t *mp;
14780 const char *valid_chars = "a-zA-Z0-9_";
14782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14784 if (unformat (i, "%U", unformat_token, valid_chars, &name))
14785 vec_add1 (name, 0);
14788 errmsg ("parse error '%U'", format_unformat_error, i);
14793 if (!vec_len (name))
14795 errmsg ("profile name must be specified");
14799 if (vec_len (name) > 64)
14801 errmsg ("profile name too long");
14805 M (IKEV2_INITIATE_SA_INIT, mp);
14807 clib_memcpy (mp->name, name, vec_len (name));
14816 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
14818 unformat_input_t *i = vam->input;
14819 vl_api_ikev2_initiate_del_ike_sa_t *mp;
14824 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14826 if (unformat (i, "%lx", &ispi))
14830 errmsg ("parse error '%U'", format_unformat_error, i);
14835 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
14845 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
14847 unformat_input_t *i = vam->input;
14848 vl_api_ikev2_initiate_del_child_sa_t *mp;
14853 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14855 if (unformat (i, "%x", &ispi))
14859 errmsg ("parse error '%U'", format_unformat_error, i);
14864 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
14874 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
14876 unformat_input_t *i = vam->input;
14877 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
14882 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14884 if (unformat (i, "%x", &ispi))
14888 errmsg ("parse error '%U'", format_unformat_error, i);
14893 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
14906 api_map_add_domain (vat_main_t * vam)
14908 unformat_input_t *i = vam->input;
14909 vl_api_map_add_domain_t *mp;
14911 ip4_address_t ip4_prefix;
14912 ip6_address_t ip6_prefix;
14913 ip6_address_t ip6_src;
14914 u32 num_m_args = 0;
14915 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
14916 0, psid_length = 0;
14917 u8 is_translation = 0;
14919 u32 ip6_src_len = 128;
14922 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14924 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
14925 &ip4_prefix, &ip4_prefix_len))
14927 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
14928 &ip6_prefix, &ip6_prefix_len))
14932 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
14935 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
14937 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
14939 else if (unformat (i, "psid-offset %d", &psid_offset))
14941 else if (unformat (i, "psid-len %d", &psid_length))
14943 else if (unformat (i, "mtu %d", &mtu))
14945 else if (unformat (i, "map-t"))
14946 is_translation = 1;
14949 clib_warning ("parse error '%U'", format_unformat_error, i);
14954 if (num_m_args < 3)
14956 errmsg ("mandatory argument(s) missing");
14960 /* Construct the API message */
14961 M (MAP_ADD_DOMAIN, mp);
14963 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
14964 mp->ip4_prefix_len = ip4_prefix_len;
14966 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
14967 mp->ip6_prefix_len = ip6_prefix_len;
14969 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
14970 mp->ip6_src_prefix_len = ip6_src_len;
14972 mp->ea_bits_len = ea_bits_len;
14973 mp->psid_offset = psid_offset;
14974 mp->psid_length = psid_length;
14975 mp->is_translation = is_translation;
14976 mp->mtu = htons (mtu);
14981 /* Wait for a reply, return good/bad news */
14987 api_map_del_domain (vat_main_t * vam)
14989 unformat_input_t *i = vam->input;
14990 vl_api_map_del_domain_t *mp;
14992 u32 num_m_args = 0;
14996 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14998 if (unformat (i, "index %d", &index))
15002 clib_warning ("parse error '%U'", format_unformat_error, i);
15007 if (num_m_args != 1)
15009 errmsg ("mandatory argument(s) missing");
15013 /* Construct the API message */
15014 M (MAP_DEL_DOMAIN, mp);
15016 mp->index = ntohl (index);
15021 /* Wait for a reply, return good/bad news */
15027 api_map_add_del_rule (vat_main_t * vam)
15029 unformat_input_t *i = vam->input;
15030 vl_api_map_add_del_rule_t *mp;
15032 ip6_address_t ip6_dst;
15033 u32 num_m_args = 0, index, psid = 0;
15036 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15038 if (unformat (i, "index %d", &index))
15040 else if (unformat (i, "psid %d", &psid))
15042 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
15044 else if (unformat (i, "del"))
15050 clib_warning ("parse error '%U'", format_unformat_error, i);
15055 /* Construct the API message */
15056 M (MAP_ADD_DEL_RULE, mp);
15058 mp->index = ntohl (index);
15059 mp->is_add = is_add;
15060 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
15061 mp->psid = ntohs (psid);
15066 /* Wait for a reply, return good/bad news */
15072 api_map_domain_dump (vat_main_t * vam)
15074 vl_api_map_domain_dump_t *mp;
15075 vl_api_control_ping_t *mp_ping;
15078 /* Construct the API message */
15079 M (MAP_DOMAIN_DUMP, mp);
15084 /* Use a control ping for synchronization */
15085 MPING (CONTROL_PING, mp_ping);
15093 api_map_rule_dump (vat_main_t * vam)
15095 unformat_input_t *i = vam->input;
15096 vl_api_map_rule_dump_t *mp;
15097 vl_api_control_ping_t *mp_ping;
15098 u32 domain_index = ~0;
15101 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15103 if (unformat (i, "index %u", &domain_index))
15109 if (domain_index == ~0)
15111 clib_warning ("parse error: domain index expected");
15115 /* Construct the API message */
15116 M (MAP_RULE_DUMP, mp);
15118 mp->domain_index = htonl (domain_index);
15123 /* Use a control ping for synchronization */
15124 MPING (CONTROL_PING, mp_ping);
15131 static void vl_api_map_add_domain_reply_t_handler
15132 (vl_api_map_add_domain_reply_t * mp)
15134 vat_main_t *vam = &vat_main;
15135 i32 retval = ntohl (mp->retval);
15137 if (vam->async_mode)
15139 vam->async_errors += (retval < 0);
15143 vam->retval = retval;
15144 vam->result_ready = 1;
15148 static void vl_api_map_add_domain_reply_t_handler_json
15149 (vl_api_map_add_domain_reply_t * mp)
15151 vat_main_t *vam = &vat_main;
15152 vat_json_node_t node;
15154 vat_json_init_object (&node);
15155 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
15156 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
15158 vat_json_print (vam->ofp, &node);
15159 vat_json_free (&node);
15161 vam->retval = ntohl (mp->retval);
15162 vam->result_ready = 1;
15166 api_get_first_msg_id (vat_main_t * vam)
15168 vl_api_get_first_msg_id_t *mp;
15169 unformat_input_t *i = vam->input;
15174 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15176 if (unformat (i, "client %s", &name))
15184 errmsg ("missing client name");
15187 vec_add1 (name, 0);
15189 if (vec_len (name) > 63)
15191 errmsg ("client name too long");
15195 M (GET_FIRST_MSG_ID, mp);
15196 clib_memcpy (mp->name, name, vec_len (name));
15203 api_cop_interface_enable_disable (vat_main_t * vam)
15205 unformat_input_t *line_input = vam->input;
15206 vl_api_cop_interface_enable_disable_t *mp;
15207 u32 sw_if_index = ~0;
15208 u8 enable_disable = 1;
15211 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15213 if (unformat (line_input, "disable"))
15214 enable_disable = 0;
15215 if (unformat (line_input, "enable"))
15216 enable_disable = 1;
15217 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15218 vam, &sw_if_index))
15220 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15226 if (sw_if_index == ~0)
15228 errmsg ("missing interface name or sw_if_index");
15232 /* Construct the API message */
15233 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15234 mp->sw_if_index = ntohl (sw_if_index);
15235 mp->enable_disable = enable_disable;
15239 /* Wait for the reply */
15245 api_cop_whitelist_enable_disable (vat_main_t * vam)
15247 unformat_input_t *line_input = vam->input;
15248 vl_api_cop_whitelist_enable_disable_t *mp;
15249 u32 sw_if_index = ~0;
15250 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15254 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15256 if (unformat (line_input, "ip4"))
15258 else if (unformat (line_input, "ip6"))
15260 else if (unformat (line_input, "default"))
15262 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15263 vam, &sw_if_index))
15265 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15267 else if (unformat (line_input, "fib-id %d", &fib_id))
15273 if (sw_if_index == ~0)
15275 errmsg ("missing interface name or sw_if_index");
15279 /* Construct the API message */
15280 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15281 mp->sw_if_index = ntohl (sw_if_index);
15282 mp->fib_id = ntohl (fib_id);
15285 mp->default_cop = default_cop;
15289 /* Wait for the reply */
15295 api_get_node_graph (vat_main_t * vam)
15297 vl_api_get_node_graph_t *mp;
15300 M (GET_NODE_GRAPH, mp);
15304 /* Wait for the reply */
15310 /** Used for parsing LISP eids */
15311 typedef CLIB_PACKED(struct{
15312 u8 addr[16]; /**< eid address */
15313 u32 len; /**< prefix length if IP */
15314 u8 type; /**< type of eid */
15319 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15321 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15323 memset (a, 0, sizeof (a[0]));
15325 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15327 a->type = 0; /* ipv4 type */
15329 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15331 a->type = 1; /* ipv6 type */
15333 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15335 a->type = 2; /* mac type */
15337 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15339 a->type = 3; /* NSH type */
15340 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15341 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15348 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15357 lisp_eid_size_vat (u8 type)
15374 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15376 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15380 api_one_add_del_locator_set (vat_main_t * vam)
15382 unformat_input_t *input = vam->input;
15383 vl_api_one_add_del_locator_set_t *mp;
15385 u8 *locator_set_name = NULL;
15386 u8 locator_set_name_set = 0;
15387 vl_api_local_locator_t locator, *locators = 0;
15388 u32 sw_if_index, priority, weight;
15392 /* Parse args required to build the message */
15393 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15395 if (unformat (input, "del"))
15399 else if (unformat (input, "locator-set %s", &locator_set_name))
15401 locator_set_name_set = 1;
15403 else if (unformat (input, "sw_if_index %u p %u w %u",
15404 &sw_if_index, &priority, &weight))
15406 locator.sw_if_index = htonl (sw_if_index);
15407 locator.priority = priority;
15408 locator.weight = weight;
15409 vec_add1 (locators, locator);
15413 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15414 &sw_if_index, &priority, &weight))
15416 locator.sw_if_index = htonl (sw_if_index);
15417 locator.priority = priority;
15418 locator.weight = weight;
15419 vec_add1 (locators, locator);
15425 if (locator_set_name_set == 0)
15427 errmsg ("missing locator-set name");
15428 vec_free (locators);
15432 if (vec_len (locator_set_name) > 64)
15434 errmsg ("locator-set name too long");
15435 vec_free (locator_set_name);
15436 vec_free (locators);
15439 vec_add1 (locator_set_name, 0);
15441 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15443 /* Construct the API message */
15444 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15446 mp->is_add = is_add;
15447 clib_memcpy (mp->locator_set_name, locator_set_name,
15448 vec_len (locator_set_name));
15449 vec_free (locator_set_name);
15451 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15453 clib_memcpy (mp->locators, locators, data_len);
15454 vec_free (locators);
15459 /* Wait for a reply... */
15464 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15467 api_one_add_del_locator (vat_main_t * vam)
15469 unformat_input_t *input = vam->input;
15470 vl_api_one_add_del_locator_t *mp;
15471 u32 tmp_if_index = ~0;
15472 u32 sw_if_index = ~0;
15473 u8 sw_if_index_set = 0;
15474 u8 sw_if_index_if_name_set = 0;
15476 u8 priority_set = 0;
15480 u8 *locator_set_name = NULL;
15481 u8 locator_set_name_set = 0;
15484 /* Parse args required to build the message */
15485 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15487 if (unformat (input, "del"))
15491 else if (unformat (input, "locator-set %s", &locator_set_name))
15493 locator_set_name_set = 1;
15495 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15498 sw_if_index_if_name_set = 1;
15499 sw_if_index = tmp_if_index;
15501 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15503 sw_if_index_set = 1;
15504 sw_if_index = tmp_if_index;
15506 else if (unformat (input, "p %d", &priority))
15510 else if (unformat (input, "w %d", &weight))
15518 if (locator_set_name_set == 0)
15520 errmsg ("missing locator-set name");
15524 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15526 errmsg ("missing sw_if_index");
15527 vec_free (locator_set_name);
15531 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15533 errmsg ("cannot use both params interface name and sw_if_index");
15534 vec_free (locator_set_name);
15538 if (priority_set == 0)
15540 errmsg ("missing locator-set priority");
15541 vec_free (locator_set_name);
15545 if (weight_set == 0)
15547 errmsg ("missing locator-set weight");
15548 vec_free (locator_set_name);
15552 if (vec_len (locator_set_name) > 64)
15554 errmsg ("locator-set name too long");
15555 vec_free (locator_set_name);
15558 vec_add1 (locator_set_name, 0);
15560 /* Construct the API message */
15561 M (ONE_ADD_DEL_LOCATOR, mp);
15563 mp->is_add = is_add;
15564 mp->sw_if_index = ntohl (sw_if_index);
15565 mp->priority = priority;
15566 mp->weight = weight;
15567 clib_memcpy (mp->locator_set_name, locator_set_name,
15568 vec_len (locator_set_name));
15569 vec_free (locator_set_name);
15574 /* Wait for a reply... */
15579 #define api_lisp_add_del_locator api_one_add_del_locator
15582 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15584 u32 *key_id = va_arg (*args, u32 *);
15587 if (unformat (input, "%s", &s))
15589 if (!strcmp ((char *) s, "sha1"))
15590 key_id[0] = HMAC_SHA_1_96;
15591 else if (!strcmp ((char *) s, "sha256"))
15592 key_id[0] = HMAC_SHA_256_128;
15595 clib_warning ("invalid key_id: '%s'", s);
15596 key_id[0] = HMAC_NO_KEY;
15607 api_one_add_del_local_eid (vat_main_t * vam)
15609 unformat_input_t *input = vam->input;
15610 vl_api_one_add_del_local_eid_t *mp;
15613 lisp_eid_vat_t _eid, *eid = &_eid;
15614 u8 *locator_set_name = 0;
15615 u8 locator_set_name_set = 0;
15621 /* Parse args required to build the message */
15622 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15624 if (unformat (input, "del"))
15628 else if (unformat (input, "vni %d", &vni))
15632 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15636 else if (unformat (input, "locator-set %s", &locator_set_name))
15638 locator_set_name_set = 1;
15640 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15642 else if (unformat (input, "secret-key %_%v%_", &key))
15648 if (locator_set_name_set == 0)
15650 errmsg ("missing locator-set name");
15656 errmsg ("EID address not set!");
15657 vec_free (locator_set_name);
15661 if (key && (0 == key_id))
15663 errmsg ("invalid key_id!");
15667 if (vec_len (key) > 64)
15669 errmsg ("key too long");
15674 if (vec_len (locator_set_name) > 64)
15676 errmsg ("locator-set name too long");
15677 vec_free (locator_set_name);
15680 vec_add1 (locator_set_name, 0);
15682 /* Construct the API message */
15683 M (ONE_ADD_DEL_LOCAL_EID, mp);
15685 mp->is_add = is_add;
15686 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15687 mp->eid_type = eid->type;
15688 mp->prefix_len = eid->len;
15689 mp->vni = clib_host_to_net_u32 (vni);
15690 mp->key_id = clib_host_to_net_u16 (key_id);
15691 clib_memcpy (mp->locator_set_name, locator_set_name,
15692 vec_len (locator_set_name));
15693 clib_memcpy (mp->key, key, vec_len (key));
15695 vec_free (locator_set_name);
15701 /* Wait for a reply... */
15706 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15709 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15711 u32 dp_table = 0, vni = 0;;
15712 unformat_input_t *input = vam->input;
15713 vl_api_gpe_add_del_fwd_entry_t *mp;
15715 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15716 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15717 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15718 u32 action = ~0, w;
15719 ip4_address_t rmt_rloc4, lcl_rloc4;
15720 ip6_address_t rmt_rloc6, lcl_rloc6;
15721 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15724 memset (&rloc, 0, sizeof (rloc));
15726 /* Parse args required to build the message */
15727 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15729 if (unformat (input, "del"))
15731 else if (unformat (input, "add"))
15733 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15737 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15741 else if (unformat (input, "vrf %d", &dp_table))
15743 else if (unformat (input, "bd %d", &dp_table))
15745 else if (unformat (input, "vni %d", &vni))
15747 else if (unformat (input, "w %d", &w))
15751 errmsg ("No RLOC configured for setting priority/weight!");
15754 curr_rloc->weight = w;
15756 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15757 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15761 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15763 vec_add1 (lcl_locs, rloc);
15765 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15766 vec_add1 (rmt_locs, rloc);
15767 /* weight saved in rmt loc */
15768 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15770 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15771 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15774 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15776 vec_add1 (lcl_locs, rloc);
15778 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15779 vec_add1 (rmt_locs, rloc);
15780 /* weight saved in rmt loc */
15781 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15783 else if (unformat (input, "action %d", &action))
15789 clib_warning ("parse error '%U'", format_unformat_error, input);
15796 errmsg ("remote eid addresses not set");
15800 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15802 errmsg ("eid types don't match");
15806 if (0 == rmt_locs && (u32) ~ 0 == action)
15808 errmsg ("action not set for negative mapping");
15812 /* Construct the API message */
15813 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15814 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15816 mp->is_add = is_add;
15817 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15818 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15819 mp->eid_type = rmt_eid->type;
15820 mp->dp_table = clib_host_to_net_u32 (dp_table);
15821 mp->vni = clib_host_to_net_u32 (vni);
15822 mp->rmt_len = rmt_eid->len;
15823 mp->lcl_len = lcl_eid->len;
15824 mp->action = action;
15826 if (0 != rmt_locs && 0 != lcl_locs)
15828 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15829 clib_memcpy (mp->locs, lcl_locs,
15830 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15832 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15833 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15834 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15836 vec_free (lcl_locs);
15837 vec_free (rmt_locs);
15842 /* Wait for a reply... */
15848 api_one_add_del_map_server (vat_main_t * vam)
15850 unformat_input_t *input = vam->input;
15851 vl_api_one_add_del_map_server_t *mp;
15855 ip4_address_t ipv4;
15856 ip6_address_t ipv6;
15859 /* Parse args required to build the message */
15860 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15862 if (unformat (input, "del"))
15866 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15870 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15878 if (ipv4_set && ipv6_set)
15880 errmsg ("both eid v4 and v6 addresses set");
15884 if (!ipv4_set && !ipv6_set)
15886 errmsg ("eid addresses not set");
15890 /* Construct the API message */
15891 M (ONE_ADD_DEL_MAP_SERVER, mp);
15893 mp->is_add = is_add;
15897 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15902 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15908 /* Wait for a reply... */
15913 #define api_lisp_add_del_map_server api_one_add_del_map_server
15916 api_one_add_del_map_resolver (vat_main_t * vam)
15918 unformat_input_t *input = vam->input;
15919 vl_api_one_add_del_map_resolver_t *mp;
15923 ip4_address_t ipv4;
15924 ip6_address_t ipv6;
15927 /* Parse args required to build the message */
15928 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15930 if (unformat (input, "del"))
15934 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15938 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15946 if (ipv4_set && ipv6_set)
15948 errmsg ("both eid v4 and v6 addresses set");
15952 if (!ipv4_set && !ipv6_set)
15954 errmsg ("eid addresses not set");
15958 /* Construct the API message */
15959 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
15961 mp->is_add = is_add;
15965 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15970 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15976 /* Wait for a reply... */
15981 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
15984 api_lisp_gpe_enable_disable (vat_main_t * vam)
15986 unformat_input_t *input = vam->input;
15987 vl_api_gpe_enable_disable_t *mp;
15992 /* Parse args required to build the message */
15993 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15995 if (unformat (input, "enable"))
16000 else if (unformat (input, "disable"))
16011 errmsg ("Value not set");
16015 /* Construct the API message */
16016 M (GPE_ENABLE_DISABLE, mp);
16023 /* Wait for a reply... */
16029 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16031 unformat_input_t *input = vam->input;
16032 vl_api_one_rloc_probe_enable_disable_t *mp;
16037 /* Parse args required to build the message */
16038 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16040 if (unformat (input, "enable"))
16045 else if (unformat (input, "disable"))
16053 errmsg ("Value not set");
16057 /* Construct the API message */
16058 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16060 mp->is_enabled = is_en;
16065 /* Wait for a reply... */
16070 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16073 api_one_map_register_enable_disable (vat_main_t * vam)
16075 unformat_input_t *input = vam->input;
16076 vl_api_one_map_register_enable_disable_t *mp;
16081 /* Parse args required to build the message */
16082 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16084 if (unformat (input, "enable"))
16089 else if (unformat (input, "disable"))
16097 errmsg ("Value not set");
16101 /* Construct the API message */
16102 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16104 mp->is_enabled = is_en;
16109 /* Wait for a reply... */
16114 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16117 api_one_enable_disable (vat_main_t * vam)
16119 unformat_input_t *input = vam->input;
16120 vl_api_one_enable_disable_t *mp;
16125 /* Parse args required to build the message */
16126 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16128 if (unformat (input, "enable"))
16133 else if (unformat (input, "disable"))
16143 errmsg ("Value not set");
16147 /* Construct the API message */
16148 M (ONE_ENABLE_DISABLE, mp);
16155 /* Wait for a reply... */
16160 #define api_lisp_enable_disable api_one_enable_disable
16163 api_show_one_map_register_state (vat_main_t * vam)
16165 vl_api_show_one_map_register_state_t *mp;
16168 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16173 /* wait for reply */
16178 #define api_show_lisp_map_register_state api_show_one_map_register_state
16181 api_show_one_rloc_probe_state (vat_main_t * vam)
16183 vl_api_show_one_rloc_probe_state_t *mp;
16186 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16191 /* wait for reply */
16196 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16199 api_one_add_del_ndp_entry (vat_main_t * vam)
16201 vl_api_one_add_del_ndp_entry_t *mp;
16202 unformat_input_t *input = vam->input;
16207 u8 mac[6] = { 0, };
16208 u8 ip6[16] = { 0, };
16212 /* Parse args required to build the message */
16213 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16215 if (unformat (input, "del"))
16217 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16219 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16221 else if (unformat (input, "bd %d", &bd))
16225 errmsg ("parse error '%U'", format_unformat_error, input);
16230 if (!bd_set || !ip_set || (!mac_set && is_add))
16232 errmsg ("Missing BD, IP or MAC!");
16236 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16237 mp->is_add = is_add;
16238 clib_memcpy (mp->mac, mac, 6);
16239 mp->bd = clib_host_to_net_u32 (bd);
16240 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16245 /* wait for reply */
16251 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16253 vl_api_one_add_del_l2_arp_entry_t *mp;
16254 unformat_input_t *input = vam->input;
16259 u8 mac[6] = { 0, };
16260 u32 ip4 = 0, bd = ~0;
16263 /* Parse args required to build the message */
16264 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16266 if (unformat (input, "del"))
16268 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16270 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16272 else if (unformat (input, "bd %d", &bd))
16276 errmsg ("parse error '%U'", format_unformat_error, input);
16281 if (!bd_set || !ip_set || (!mac_set && is_add))
16283 errmsg ("Missing BD, IP or MAC!");
16287 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16288 mp->is_add = is_add;
16289 clib_memcpy (mp->mac, mac, 6);
16290 mp->bd = clib_host_to_net_u32 (bd);
16296 /* wait for reply */
16302 api_one_ndp_bd_get (vat_main_t * vam)
16304 vl_api_one_ndp_bd_get_t *mp;
16307 M (ONE_NDP_BD_GET, mp);
16312 /* wait for reply */
16318 api_one_ndp_entries_get (vat_main_t * vam)
16320 vl_api_one_ndp_entries_get_t *mp;
16321 unformat_input_t *input = vam->input;
16326 /* Parse args required to build the message */
16327 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16329 if (unformat (input, "bd %d", &bd))
16333 errmsg ("parse error '%U'", format_unformat_error, input);
16340 errmsg ("Expected bridge domain!");
16344 M (ONE_NDP_ENTRIES_GET, mp);
16345 mp->bd = clib_host_to_net_u32 (bd);
16350 /* wait for reply */
16356 api_one_l2_arp_bd_get (vat_main_t * vam)
16358 vl_api_one_l2_arp_bd_get_t *mp;
16361 M (ONE_L2_ARP_BD_GET, mp);
16366 /* wait for reply */
16372 api_one_l2_arp_entries_get (vat_main_t * vam)
16374 vl_api_one_l2_arp_entries_get_t *mp;
16375 unformat_input_t *input = vam->input;
16380 /* Parse args required to build the message */
16381 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16383 if (unformat (input, "bd %d", &bd))
16387 errmsg ("parse error '%U'", format_unformat_error, input);
16394 errmsg ("Expected bridge domain!");
16398 M (ONE_L2_ARP_ENTRIES_GET, mp);
16399 mp->bd = clib_host_to_net_u32 (bd);
16404 /* wait for reply */
16410 api_one_stats_enable_disable (vat_main_t * vam)
16412 vl_api_one_stats_enable_disable_t *mp;
16413 unformat_input_t *input = vam->input;
16418 /* Parse args required to build the message */
16419 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16421 if (unformat (input, "enable"))
16426 else if (unformat (input, "disable"))
16436 errmsg ("Value not set");
16440 M (ONE_STATS_ENABLE_DISABLE, mp);
16446 /* wait for reply */
16452 api_show_one_stats_enable_disable (vat_main_t * vam)
16454 vl_api_show_one_stats_enable_disable_t *mp;
16457 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16462 /* wait for reply */
16468 api_show_one_map_request_mode (vat_main_t * vam)
16470 vl_api_show_one_map_request_mode_t *mp;
16473 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16478 /* wait for reply */
16483 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16486 api_one_map_request_mode (vat_main_t * vam)
16488 unformat_input_t *input = vam->input;
16489 vl_api_one_map_request_mode_t *mp;
16493 /* Parse args required to build the message */
16494 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16496 if (unformat (input, "dst-only"))
16498 else if (unformat (input, "src-dst"))
16502 errmsg ("parse error '%U'", format_unformat_error, input);
16507 M (ONE_MAP_REQUEST_MODE, mp);
16514 /* wait for reply */
16519 #define api_lisp_map_request_mode api_one_map_request_mode
16522 * Enable/disable ONE proxy ITR.
16524 * @param vam vpp API test context
16525 * @return return code
16528 api_one_pitr_set_locator_set (vat_main_t * vam)
16530 u8 ls_name_set = 0;
16531 unformat_input_t *input = vam->input;
16532 vl_api_one_pitr_set_locator_set_t *mp;
16537 /* Parse args required to build the message */
16538 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16540 if (unformat (input, "del"))
16542 else if (unformat (input, "locator-set %s", &ls_name))
16546 errmsg ("parse error '%U'", format_unformat_error, input);
16553 errmsg ("locator-set name not set!");
16557 M (ONE_PITR_SET_LOCATOR_SET, mp);
16559 mp->is_add = is_add;
16560 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16561 vec_free (ls_name);
16566 /* wait for reply */
16571 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16574 api_one_nsh_set_locator_set (vat_main_t * vam)
16576 u8 ls_name_set = 0;
16577 unformat_input_t *input = vam->input;
16578 vl_api_one_nsh_set_locator_set_t *mp;
16583 /* Parse args required to build the message */
16584 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16586 if (unformat (input, "del"))
16588 else if (unformat (input, "ls %s", &ls_name))
16592 errmsg ("parse error '%U'", format_unformat_error, input);
16597 if (!ls_name_set && is_add)
16599 errmsg ("locator-set name not set!");
16603 M (ONE_NSH_SET_LOCATOR_SET, mp);
16605 mp->is_add = is_add;
16606 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16607 vec_free (ls_name);
16612 /* wait for reply */
16618 api_show_one_pitr (vat_main_t * vam)
16620 vl_api_show_one_pitr_t *mp;
16623 if (!vam->json_output)
16625 print (vam->ofp, "%=20s", "lisp status:");
16628 M (SHOW_ONE_PITR, mp);
16632 /* Wait for a reply... */
16637 #define api_show_lisp_pitr api_show_one_pitr
16640 api_one_use_petr (vat_main_t * vam)
16642 unformat_input_t *input = vam->input;
16643 vl_api_one_use_petr_t *mp;
16648 memset (&ip, 0, sizeof (ip));
16650 /* Parse args required to build the message */
16651 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16653 if (unformat (input, "disable"))
16656 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16659 ip_addr_version (&ip) = IP4;
16662 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16665 ip_addr_version (&ip) = IP6;
16669 errmsg ("parse error '%U'", format_unformat_error, input);
16674 M (ONE_USE_PETR, mp);
16676 mp->is_add = is_add;
16679 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16681 clib_memcpy (mp->address, &ip, 4);
16683 clib_memcpy (mp->address, &ip, 16);
16689 /* wait for reply */
16694 #define api_lisp_use_petr api_one_use_petr
16697 api_show_one_nsh_mapping (vat_main_t * vam)
16699 vl_api_show_one_use_petr_t *mp;
16702 if (!vam->json_output)
16704 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16707 M (SHOW_ONE_NSH_MAPPING, mp);
16711 /* Wait for a reply... */
16717 api_show_one_use_petr (vat_main_t * vam)
16719 vl_api_show_one_use_petr_t *mp;
16722 if (!vam->json_output)
16724 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16727 M (SHOW_ONE_USE_PETR, mp);
16731 /* Wait for a reply... */
16736 #define api_show_lisp_use_petr api_show_one_use_petr
16739 * Add/delete mapping between vni and vrf
16742 api_one_eid_table_add_del_map (vat_main_t * vam)
16744 unformat_input_t *input = vam->input;
16745 vl_api_one_eid_table_add_del_map_t *mp;
16746 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16747 u32 vni, vrf, bd_index;
16750 /* Parse args required to build the message */
16751 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16753 if (unformat (input, "del"))
16755 else if (unformat (input, "vrf %d", &vrf))
16757 else if (unformat (input, "bd_index %d", &bd_index))
16759 else if (unformat (input, "vni %d", &vni))
16765 if (!vni_set || (!vrf_set && !bd_index_set))
16767 errmsg ("missing arguments!");
16771 if (vrf_set && bd_index_set)
16773 errmsg ("error: both vrf and bd entered!");
16777 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16779 mp->is_add = is_add;
16780 mp->vni = htonl (vni);
16781 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16782 mp->is_l2 = bd_index_set;
16787 /* wait for reply */
16792 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16795 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16797 u32 *action = va_arg (*args, u32 *);
16800 if (unformat (input, "%s", &s))
16802 if (!strcmp ((char *) s, "no-action"))
16804 else if (!strcmp ((char *) s, "natively-forward"))
16806 else if (!strcmp ((char *) s, "send-map-request"))
16808 else if (!strcmp ((char *) s, "drop"))
16812 clib_warning ("invalid action: '%s'", s);
16824 * Add/del remote mapping to/from ONE control plane
16826 * @param vam vpp API test context
16827 * @return return code
16830 api_one_add_del_remote_mapping (vat_main_t * vam)
16832 unformat_input_t *input = vam->input;
16833 vl_api_one_add_del_remote_mapping_t *mp;
16835 lisp_eid_vat_t _eid, *eid = &_eid;
16836 lisp_eid_vat_t _seid, *seid = &_seid;
16837 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16838 u32 action = ~0, p, w, data_len;
16839 ip4_address_t rloc4;
16840 ip6_address_t rloc6;
16841 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16844 memset (&rloc, 0, sizeof (rloc));
16846 /* Parse args required to build the message */
16847 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16849 if (unformat (input, "del-all"))
16853 else if (unformat (input, "del"))
16857 else if (unformat (input, "add"))
16861 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16865 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16869 else if (unformat (input, "vni %d", &vni))
16873 else if (unformat (input, "p %d w %d", &p, &w))
16877 errmsg ("No RLOC configured for setting priority/weight!");
16880 curr_rloc->priority = p;
16881 curr_rloc->weight = w;
16883 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16886 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
16887 vec_add1 (rlocs, rloc);
16888 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16890 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
16893 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
16894 vec_add1 (rlocs, rloc);
16895 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16897 else if (unformat (input, "action %U",
16898 unformat_negative_mapping_action, &action))
16904 clib_warning ("parse error '%U'", format_unformat_error, input);
16911 errmsg ("missing params!");
16915 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
16917 errmsg ("no action set for negative map-reply!");
16921 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
16923 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
16924 mp->is_add = is_add;
16925 mp->vni = htonl (vni);
16926 mp->action = (u8) action;
16927 mp->is_src_dst = seid_set;
16928 mp->eid_len = eid->len;
16929 mp->seid_len = seid->len;
16930 mp->del_all = del_all;
16931 mp->eid_type = eid->type;
16932 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16933 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
16935 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
16936 clib_memcpy (mp->rlocs, rlocs, data_len);
16942 /* Wait for a reply... */
16947 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
16950 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
16951 * forwarding entries in data-plane accordingly.
16953 * @param vam vpp API test context
16954 * @return return code
16957 api_one_add_del_adjacency (vat_main_t * vam)
16959 unformat_input_t *input = vam->input;
16960 vl_api_one_add_del_adjacency_t *mp;
16962 ip4_address_t leid4, reid4;
16963 ip6_address_t leid6, reid6;
16964 u8 reid_mac[6] = { 0 };
16965 u8 leid_mac[6] = { 0 };
16966 u8 reid_type, leid_type;
16967 u32 leid_len = 0, reid_len = 0, len;
16971 leid_type = reid_type = (u8) ~ 0;
16973 /* Parse args required to build the message */
16974 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16976 if (unformat (input, "del"))
16980 else if (unformat (input, "add"))
16984 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
16987 reid_type = 0; /* ipv4 */
16990 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
16993 reid_type = 1; /* ipv6 */
16996 else if (unformat (input, "reid %U", unformat_ethernet_address,
16999 reid_type = 2; /* mac */
17001 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17004 leid_type = 0; /* ipv4 */
17007 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17010 leid_type = 1; /* ipv6 */
17013 else if (unformat (input, "leid %U", unformat_ethernet_address,
17016 leid_type = 2; /* mac */
17018 else if (unformat (input, "vni %d", &vni))
17024 errmsg ("parse error '%U'", format_unformat_error, input);
17029 if ((u8) ~ 0 == reid_type)
17031 errmsg ("missing params!");
17035 if (leid_type != reid_type)
17037 errmsg ("remote and local EIDs are of different types!");
17041 M (ONE_ADD_DEL_ADJACENCY, mp);
17042 mp->is_add = is_add;
17043 mp->vni = htonl (vni);
17044 mp->leid_len = leid_len;
17045 mp->reid_len = reid_len;
17046 mp->eid_type = reid_type;
17048 switch (mp->eid_type)
17051 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17052 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17055 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17056 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17059 clib_memcpy (mp->leid, leid_mac, 6);
17060 clib_memcpy (mp->reid, reid_mac, 6);
17063 errmsg ("unknown EID type %d!", mp->eid_type);
17070 /* Wait for a reply... */
17075 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17078 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17080 u32 *mode = va_arg (*args, u32 *);
17082 if (unformat (input, "lisp"))
17084 else if (unformat (input, "vxlan"))
17093 api_gpe_get_encap_mode (vat_main_t * vam)
17095 vl_api_gpe_get_encap_mode_t *mp;
17098 /* Construct the API message */
17099 M (GPE_GET_ENCAP_MODE, mp);
17104 /* Wait for a reply... */
17110 api_gpe_set_encap_mode (vat_main_t * vam)
17112 unformat_input_t *input = vam->input;
17113 vl_api_gpe_set_encap_mode_t *mp;
17117 /* Parse args required to build the message */
17118 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17120 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17126 /* Construct the API message */
17127 M (GPE_SET_ENCAP_MODE, mp);
17134 /* Wait for a reply... */
17140 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17142 unformat_input_t *input = vam->input;
17143 vl_api_gpe_add_del_iface_t *mp;
17144 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17145 u32 dp_table = 0, vni = 0;
17148 /* Parse args required to build the message */
17149 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17151 if (unformat (input, "up"))
17156 else if (unformat (input, "down"))
17161 else if (unformat (input, "table_id %d", &dp_table))
17165 else if (unformat (input, "bd_id %d", &dp_table))
17170 else if (unformat (input, "vni %d", &vni))
17178 if (action_set == 0)
17180 errmsg ("Action not set");
17183 if (dp_table_set == 0 || vni_set == 0)
17185 errmsg ("vni and dp_table must be set");
17189 /* Construct the API message */
17190 M (GPE_ADD_DEL_IFACE, mp);
17192 mp->is_add = is_add;
17193 mp->dp_table = clib_host_to_net_u32 (dp_table);
17195 mp->vni = clib_host_to_net_u32 (vni);
17200 /* Wait for a reply... */
17206 api_one_map_register_fallback_threshold (vat_main_t * vam)
17208 unformat_input_t *input = vam->input;
17209 vl_api_one_map_register_fallback_threshold_t *mp;
17214 /* Parse args required to build the message */
17215 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17217 if (unformat (input, "%u", &value))
17221 clib_warning ("parse error '%U'", format_unformat_error, input);
17228 errmsg ("fallback threshold value is missing!");
17232 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17233 mp->value = clib_host_to_net_u32 (value);
17238 /* Wait for a reply... */
17244 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17246 vl_api_show_one_map_register_fallback_threshold_t *mp;
17249 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17254 /* Wait for a reply... */
17260 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17262 u32 *proto = va_arg (*args, u32 *);
17264 if (unformat (input, "udp"))
17266 else if (unformat (input, "api"))
17275 api_one_set_transport_protocol (vat_main_t * vam)
17277 unformat_input_t *input = vam->input;
17278 vl_api_one_set_transport_protocol_t *mp;
17283 /* Parse args required to build the message */
17284 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17286 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17290 clib_warning ("parse error '%U'", format_unformat_error, input);
17297 errmsg ("Transport protocol missing!");
17301 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17302 mp->protocol = (u8) protocol;
17307 /* Wait for a reply... */
17313 api_one_get_transport_protocol (vat_main_t * vam)
17315 vl_api_one_get_transport_protocol_t *mp;
17318 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17323 /* Wait for a reply... */
17329 api_one_map_register_set_ttl (vat_main_t * vam)
17331 unformat_input_t *input = vam->input;
17332 vl_api_one_map_register_set_ttl_t *mp;
17337 /* Parse args required to build the message */
17338 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17340 if (unformat (input, "%u", &ttl))
17344 clib_warning ("parse error '%U'", format_unformat_error, input);
17351 errmsg ("TTL value missing!");
17355 M (ONE_MAP_REGISTER_SET_TTL, mp);
17356 mp->ttl = clib_host_to_net_u32 (ttl);
17361 /* Wait for a reply... */
17367 api_show_one_map_register_ttl (vat_main_t * vam)
17369 vl_api_show_one_map_register_ttl_t *mp;
17372 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17377 /* Wait for a reply... */
17383 * Add/del map request itr rlocs from ONE control plane and updates
17385 * @param vam vpp API test context
17386 * @return return code
17389 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17391 unformat_input_t *input = vam->input;
17392 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17393 u8 *locator_set_name = 0;
17394 u8 locator_set_name_set = 0;
17398 /* Parse args required to build the message */
17399 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17401 if (unformat (input, "del"))
17405 else if (unformat (input, "%_%v%_", &locator_set_name))
17407 locator_set_name_set = 1;
17411 clib_warning ("parse error '%U'", format_unformat_error, input);
17416 if (is_add && !locator_set_name_set)
17418 errmsg ("itr-rloc is not set!");
17422 if (is_add && vec_len (locator_set_name) > 64)
17424 errmsg ("itr-rloc locator-set name too long");
17425 vec_free (locator_set_name);
17429 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17430 mp->is_add = is_add;
17433 clib_memcpy (mp->locator_set_name, locator_set_name,
17434 vec_len (locator_set_name));
17438 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17440 vec_free (locator_set_name);
17445 /* Wait for a reply... */
17450 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17453 api_one_locator_dump (vat_main_t * vam)
17455 unformat_input_t *input = vam->input;
17456 vl_api_one_locator_dump_t *mp;
17457 vl_api_control_ping_t *mp_ping;
17458 u8 is_index_set = 0, is_name_set = 0;
17463 /* Parse args required to build the message */
17464 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17466 if (unformat (input, "ls_name %_%v%_", &ls_name))
17470 else if (unformat (input, "ls_index %d", &ls_index))
17476 errmsg ("parse error '%U'", format_unformat_error, input);
17481 if (!is_index_set && !is_name_set)
17483 errmsg ("error: expected one of index or name!");
17487 if (is_index_set && is_name_set)
17489 errmsg ("error: only one param expected!");
17493 if (vec_len (ls_name) > 62)
17495 errmsg ("error: locator set name too long!");
17499 if (!vam->json_output)
17501 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17504 M (ONE_LOCATOR_DUMP, mp);
17505 mp->is_index_set = is_index_set;
17508 mp->ls_index = clib_host_to_net_u32 (ls_index);
17511 vec_add1 (ls_name, 0);
17512 strncpy ((char *) mp->ls_name, (char *) ls_name,
17513 sizeof (mp->ls_name) - 1);
17519 /* Use a control ping for synchronization */
17520 MPING (CONTROL_PING, mp_ping);
17523 /* Wait for a reply... */
17528 #define api_lisp_locator_dump api_one_locator_dump
17531 api_one_locator_set_dump (vat_main_t * vam)
17533 vl_api_one_locator_set_dump_t *mp;
17534 vl_api_control_ping_t *mp_ping;
17535 unformat_input_t *input = vam->input;
17539 /* Parse args required to build the message */
17540 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17542 if (unformat (input, "local"))
17546 else if (unformat (input, "remote"))
17552 errmsg ("parse error '%U'", format_unformat_error, input);
17557 if (!vam->json_output)
17559 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17562 M (ONE_LOCATOR_SET_DUMP, mp);
17564 mp->filter = filter;
17569 /* Use a control ping for synchronization */
17570 MPING (CONTROL_PING, mp_ping);
17573 /* Wait for a reply... */
17578 #define api_lisp_locator_set_dump api_one_locator_set_dump
17581 api_one_eid_table_map_dump (vat_main_t * vam)
17585 unformat_input_t *input = vam->input;
17586 vl_api_one_eid_table_map_dump_t *mp;
17587 vl_api_control_ping_t *mp_ping;
17590 /* Parse args required to build the message */
17591 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17593 if (unformat (input, "l2"))
17598 else if (unformat (input, "l3"))
17605 errmsg ("parse error '%U'", format_unformat_error, input);
17612 errmsg ("expected one of 'l2' or 'l3' parameter!");
17616 if (!vam->json_output)
17618 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17621 M (ONE_EID_TABLE_MAP_DUMP, mp);
17627 /* Use a control ping for synchronization */
17628 MPING (CONTROL_PING, mp_ping);
17631 /* Wait for a reply... */
17636 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17639 api_one_eid_table_vni_dump (vat_main_t * vam)
17641 vl_api_one_eid_table_vni_dump_t *mp;
17642 vl_api_control_ping_t *mp_ping;
17645 if (!vam->json_output)
17647 print (vam->ofp, "VNI");
17650 M (ONE_EID_TABLE_VNI_DUMP, mp);
17655 /* Use a control ping for synchronization */
17656 MPING (CONTROL_PING, mp_ping);
17659 /* Wait for a reply... */
17664 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17667 api_one_eid_table_dump (vat_main_t * vam)
17669 unformat_input_t *i = vam->input;
17670 vl_api_one_eid_table_dump_t *mp;
17671 vl_api_control_ping_t *mp_ping;
17672 struct in_addr ip4;
17673 struct in6_addr ip6;
17675 u8 eid_type = ~0, eid_set = 0;
17676 u32 prefix_length = ~0, t, vni = 0;
17679 lisp_nsh_api_t nsh;
17681 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17683 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17689 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17695 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17700 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17705 else if (unformat (i, "vni %d", &t))
17709 else if (unformat (i, "local"))
17713 else if (unformat (i, "remote"))
17719 errmsg ("parse error '%U'", format_unformat_error, i);
17724 if (!vam->json_output)
17726 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17727 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17730 M (ONE_EID_TABLE_DUMP, mp);
17732 mp->filter = filter;
17736 mp->vni = htonl (vni);
17737 mp->eid_type = eid_type;
17741 mp->prefix_length = prefix_length;
17742 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17745 mp->prefix_length = prefix_length;
17746 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17749 clib_memcpy (mp->eid, mac, sizeof (mac));
17752 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17755 errmsg ("unknown EID type %d!", eid_type);
17763 /* Use a control ping for synchronization */
17764 MPING (CONTROL_PING, mp_ping);
17767 /* Wait for a reply... */
17772 #define api_lisp_eid_table_dump api_one_eid_table_dump
17775 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17777 unformat_input_t *i = vam->input;
17778 vl_api_gpe_fwd_entries_get_t *mp;
17783 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17785 if (unformat (i, "vni %d", &vni))
17791 errmsg ("parse error '%U'", format_unformat_error, i);
17798 errmsg ("vni not set!");
17802 if (!vam->json_output)
17804 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17808 M (GPE_FWD_ENTRIES_GET, mp);
17809 mp->vni = clib_host_to_net_u32 (vni);
17814 /* Wait for a reply... */
17819 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17820 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17821 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17822 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17823 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17824 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17825 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17826 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17829 api_one_adjacencies_get (vat_main_t * vam)
17831 unformat_input_t *i = vam->input;
17832 vl_api_one_adjacencies_get_t *mp;
17837 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17839 if (unformat (i, "vni %d", &vni))
17845 errmsg ("parse error '%U'", format_unformat_error, i);
17852 errmsg ("vni not set!");
17856 if (!vam->json_output)
17858 print (vam->ofp, "%s %40s", "leid", "reid");
17861 M (ONE_ADJACENCIES_GET, mp);
17862 mp->vni = clib_host_to_net_u32 (vni);
17867 /* Wait for a reply... */
17872 #define api_lisp_adjacencies_get api_one_adjacencies_get
17875 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
17877 unformat_input_t *i = vam->input;
17878 vl_api_gpe_native_fwd_rpaths_get_t *mp;
17880 u8 ip_family_set = 0, is_ip4 = 1;
17882 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17884 if (unformat (i, "ip4"))
17889 else if (unformat (i, "ip6"))
17896 errmsg ("parse error '%U'", format_unformat_error, i);
17901 if (!ip_family_set)
17903 errmsg ("ip family not set!");
17907 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
17908 mp->is_ip4 = is_ip4;
17913 /* Wait for a reply... */
17919 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
17921 vl_api_gpe_fwd_entry_vnis_get_t *mp;
17924 if (!vam->json_output)
17926 print (vam->ofp, "VNIs");
17929 M (GPE_FWD_ENTRY_VNIS_GET, mp);
17934 /* Wait for a reply... */
17940 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
17942 unformat_input_t *i = vam->input;
17943 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
17945 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
17946 struct in_addr ip4;
17947 struct in6_addr ip6;
17948 u32 table_id = 0, nh_sw_if_index = ~0;
17950 memset (&ip4, 0, sizeof (ip4));
17951 memset (&ip6, 0, sizeof (ip6));
17953 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17955 if (unformat (i, "del"))
17957 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
17958 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17963 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
17964 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17969 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
17973 nh_sw_if_index = ~0;
17975 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
17979 nh_sw_if_index = ~0;
17981 else if (unformat (i, "table %d", &table_id))
17985 errmsg ("parse error '%U'", format_unformat_error, i);
17992 errmsg ("nh addr not set!");
17996 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
17997 mp->is_add = is_add;
17998 mp->table_id = clib_host_to_net_u32 (table_id);
17999 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18000 mp->is_ip4 = is_ip4;
18002 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18004 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18009 /* Wait for a reply... */
18015 api_one_map_server_dump (vat_main_t * vam)
18017 vl_api_one_map_server_dump_t *mp;
18018 vl_api_control_ping_t *mp_ping;
18021 if (!vam->json_output)
18023 print (vam->ofp, "%=20s", "Map server");
18026 M (ONE_MAP_SERVER_DUMP, mp);
18030 /* Use a control ping for synchronization */
18031 MPING (CONTROL_PING, mp_ping);
18034 /* Wait for a reply... */
18039 #define api_lisp_map_server_dump api_one_map_server_dump
18042 api_one_map_resolver_dump (vat_main_t * vam)
18044 vl_api_one_map_resolver_dump_t *mp;
18045 vl_api_control_ping_t *mp_ping;
18048 if (!vam->json_output)
18050 print (vam->ofp, "%=20s", "Map resolver");
18053 M (ONE_MAP_RESOLVER_DUMP, mp);
18057 /* Use a control ping for synchronization */
18058 MPING (CONTROL_PING, mp_ping);
18061 /* Wait for a reply... */
18066 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18069 api_one_stats_flush (vat_main_t * vam)
18071 vl_api_one_stats_flush_t *mp;
18074 M (ONE_STATS_FLUSH, mp);
18081 api_one_stats_dump (vat_main_t * vam)
18083 vl_api_one_stats_dump_t *mp;
18084 vl_api_control_ping_t *mp_ping;
18087 M (ONE_STATS_DUMP, mp);
18091 /* Use a control ping for synchronization */
18092 MPING (CONTROL_PING, mp_ping);
18095 /* Wait for a reply... */
18101 api_show_one_status (vat_main_t * vam)
18103 vl_api_show_one_status_t *mp;
18106 if (!vam->json_output)
18108 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18111 M (SHOW_ONE_STATUS, mp);
18114 /* Wait for a reply... */
18119 #define api_show_lisp_status api_show_one_status
18122 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18124 vl_api_gpe_fwd_entry_path_dump_t *mp;
18125 vl_api_control_ping_t *mp_ping;
18126 unformat_input_t *i = vam->input;
18127 u32 fwd_entry_index = ~0;
18130 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18132 if (unformat (i, "index %d", &fwd_entry_index))
18138 if (~0 == fwd_entry_index)
18140 errmsg ("no index specified!");
18144 if (!vam->json_output)
18146 print (vam->ofp, "first line");
18149 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18153 /* Use a control ping for synchronization */
18154 MPING (CONTROL_PING, mp_ping);
18157 /* Wait for a reply... */
18163 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18165 vl_api_one_get_map_request_itr_rlocs_t *mp;
18168 if (!vam->json_output)
18170 print (vam->ofp, "%=20s", "itr-rlocs:");
18173 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18176 /* Wait for a reply... */
18181 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18184 api_af_packet_create (vat_main_t * vam)
18186 unformat_input_t *i = vam->input;
18187 vl_api_af_packet_create_t *mp;
18188 u8 *host_if_name = 0;
18190 u8 random_hw_addr = 1;
18193 memset (hw_addr, 0, sizeof (hw_addr));
18195 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18197 if (unformat (i, "name %s", &host_if_name))
18198 vec_add1 (host_if_name, 0);
18199 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18200 random_hw_addr = 0;
18205 if (!vec_len (host_if_name))
18207 errmsg ("host-interface name must be specified");
18211 if (vec_len (host_if_name) > 64)
18213 errmsg ("host-interface name too long");
18217 M (AF_PACKET_CREATE, mp);
18219 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18220 clib_memcpy (mp->hw_addr, hw_addr, 6);
18221 mp->use_random_hw_addr = random_hw_addr;
18222 vec_free (host_if_name);
18230 fprintf (vam->ofp ? vam->ofp : stderr,
18231 " new sw_if_index = %d\n", vam->sw_if_index);
18238 api_af_packet_delete (vat_main_t * vam)
18240 unformat_input_t *i = vam->input;
18241 vl_api_af_packet_delete_t *mp;
18242 u8 *host_if_name = 0;
18245 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18247 if (unformat (i, "name %s", &host_if_name))
18248 vec_add1 (host_if_name, 0);
18253 if (!vec_len (host_if_name))
18255 errmsg ("host-interface name must be specified");
18259 if (vec_len (host_if_name) > 64)
18261 errmsg ("host-interface name too long");
18265 M (AF_PACKET_DELETE, mp);
18267 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18268 vec_free (host_if_name);
18276 api_policer_add_del (vat_main_t * vam)
18278 unformat_input_t *i = vam->input;
18279 vl_api_policer_add_del_t *mp;
18289 u8 color_aware = 0;
18290 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18293 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18294 conform_action.dscp = 0;
18295 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18296 exceed_action.dscp = 0;
18297 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18298 violate_action.dscp = 0;
18300 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18302 if (unformat (i, "del"))
18304 else if (unformat (i, "name %s", &name))
18305 vec_add1 (name, 0);
18306 else if (unformat (i, "cir %u", &cir))
18308 else if (unformat (i, "eir %u", &eir))
18310 else if (unformat (i, "cb %u", &cb))
18312 else if (unformat (i, "eb %u", &eb))
18314 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18317 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18320 else if (unformat (i, "type %U", unformat_policer_type, &type))
18322 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18325 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18328 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18331 else if (unformat (i, "color-aware"))
18337 if (!vec_len (name))
18339 errmsg ("policer name must be specified");
18343 if (vec_len (name) > 64)
18345 errmsg ("policer name too long");
18349 M (POLICER_ADD_DEL, mp);
18351 clib_memcpy (mp->name, name, vec_len (name));
18353 mp->is_add = is_add;
18354 mp->cir = ntohl (cir);
18355 mp->eir = ntohl (eir);
18356 mp->cb = clib_net_to_host_u64 (cb);
18357 mp->eb = clib_net_to_host_u64 (eb);
18358 mp->rate_type = rate_type;
18359 mp->round_type = round_type;
18361 mp->conform_action_type = conform_action.action_type;
18362 mp->conform_dscp = conform_action.dscp;
18363 mp->exceed_action_type = exceed_action.action_type;
18364 mp->exceed_dscp = exceed_action.dscp;
18365 mp->violate_action_type = violate_action.action_type;
18366 mp->violate_dscp = violate_action.dscp;
18367 mp->color_aware = color_aware;
18375 api_policer_dump (vat_main_t * vam)
18377 unformat_input_t *i = vam->input;
18378 vl_api_policer_dump_t *mp;
18379 vl_api_control_ping_t *mp_ping;
18380 u8 *match_name = 0;
18381 u8 match_name_valid = 0;
18384 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18386 if (unformat (i, "name %s", &match_name))
18388 vec_add1 (match_name, 0);
18389 match_name_valid = 1;
18395 M (POLICER_DUMP, mp);
18396 mp->match_name_valid = match_name_valid;
18397 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18398 vec_free (match_name);
18402 /* Use a control ping for synchronization */
18403 MPING (CONTROL_PING, mp_ping);
18406 /* Wait for a reply... */
18412 api_policer_classify_set_interface (vat_main_t * vam)
18414 unformat_input_t *i = vam->input;
18415 vl_api_policer_classify_set_interface_t *mp;
18417 int sw_if_index_set;
18418 u32 ip4_table_index = ~0;
18419 u32 ip6_table_index = ~0;
18420 u32 l2_table_index = ~0;
18424 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18426 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18427 sw_if_index_set = 1;
18428 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18429 sw_if_index_set = 1;
18430 else if (unformat (i, "del"))
18432 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18434 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18436 else if (unformat (i, "l2-table %d", &l2_table_index))
18440 clib_warning ("parse error '%U'", format_unformat_error, i);
18445 if (sw_if_index_set == 0)
18447 errmsg ("missing interface name or sw_if_index");
18451 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18453 mp->sw_if_index = ntohl (sw_if_index);
18454 mp->ip4_table_index = ntohl (ip4_table_index);
18455 mp->ip6_table_index = ntohl (ip6_table_index);
18456 mp->l2_table_index = ntohl (l2_table_index);
18457 mp->is_add = is_add;
18465 api_policer_classify_dump (vat_main_t * vam)
18467 unformat_input_t *i = vam->input;
18468 vl_api_policer_classify_dump_t *mp;
18469 vl_api_control_ping_t *mp_ping;
18470 u8 type = POLICER_CLASSIFY_N_TABLES;
18473 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18477 errmsg ("classify table type must be specified");
18481 if (!vam->json_output)
18483 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18486 M (POLICER_CLASSIFY_DUMP, mp);
18491 /* Use a control ping for synchronization */
18492 MPING (CONTROL_PING, mp_ping);
18495 /* Wait for a reply... */
18501 api_netmap_create (vat_main_t * vam)
18503 unformat_input_t *i = vam->input;
18504 vl_api_netmap_create_t *mp;
18507 u8 random_hw_addr = 1;
18512 memset (hw_addr, 0, sizeof (hw_addr));
18514 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18516 if (unformat (i, "name %s", &if_name))
18517 vec_add1 (if_name, 0);
18518 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18519 random_hw_addr = 0;
18520 else if (unformat (i, "pipe"))
18522 else if (unformat (i, "master"))
18524 else if (unformat (i, "slave"))
18530 if (!vec_len (if_name))
18532 errmsg ("interface name must be specified");
18536 if (vec_len (if_name) > 64)
18538 errmsg ("interface name too long");
18542 M (NETMAP_CREATE, mp);
18544 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18545 clib_memcpy (mp->hw_addr, hw_addr, 6);
18546 mp->use_random_hw_addr = random_hw_addr;
18547 mp->is_pipe = is_pipe;
18548 mp->is_master = is_master;
18549 vec_free (if_name);
18557 api_netmap_delete (vat_main_t * vam)
18559 unformat_input_t *i = vam->input;
18560 vl_api_netmap_delete_t *mp;
18564 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18566 if (unformat (i, "name %s", &if_name))
18567 vec_add1 (if_name, 0);
18572 if (!vec_len (if_name))
18574 errmsg ("interface name must be specified");
18578 if (vec_len (if_name) > 64)
18580 errmsg ("interface name too long");
18584 M (NETMAP_DELETE, mp);
18586 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18587 vec_free (if_name);
18595 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
18597 if (fp->afi == IP46_TYPE_IP6)
18599 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18600 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18601 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18602 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18603 format_ip6_address, fp->next_hop);
18604 else if (fp->afi == IP46_TYPE_IP4)
18606 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18607 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18608 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18609 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18610 format_ip4_address, fp->next_hop);
18614 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18615 vl_api_fib_path2_t * fp)
18617 struct in_addr ip4;
18618 struct in6_addr ip6;
18620 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18621 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18622 vat_json_object_add_uint (node, "is_local", fp->is_local);
18623 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18624 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18625 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18626 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18627 if (fp->afi == IP46_TYPE_IP4)
18629 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18630 vat_json_object_add_ip4 (node, "next_hop", ip4);
18632 else if (fp->afi == IP46_TYPE_IP6)
18634 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18635 vat_json_object_add_ip6 (node, "next_hop", ip6);
18640 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18642 vat_main_t *vam = &vat_main;
18643 int count = ntohl (mp->mt_count);
18644 vl_api_fib_path2_t *fp;
18647 print (vam->ofp, "[%d]: sw_if_index %d via:",
18648 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
18650 for (i = 0; i < count; i++)
18652 vl_api_mpls_fib_path_print (vam, fp);
18656 print (vam->ofp, "");
18659 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18660 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18663 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18665 vat_main_t *vam = &vat_main;
18666 vat_json_node_t *node = NULL;
18667 int count = ntohl (mp->mt_count);
18668 vl_api_fib_path2_t *fp;
18671 if (VAT_JSON_ARRAY != vam->json_tree.type)
18673 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18674 vat_json_init_array (&vam->json_tree);
18676 node = vat_json_array_add (&vam->json_tree);
18678 vat_json_init_object (node);
18679 vat_json_object_add_uint (node, "tunnel_index",
18680 ntohl (mp->mt_tunnel_index));
18681 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
18683 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
18686 for (i = 0; i < count; i++)
18688 vl_api_mpls_fib_path_json_print (node, fp);
18694 api_mpls_tunnel_dump (vat_main_t * vam)
18696 vl_api_mpls_tunnel_dump_t *mp;
18697 vl_api_control_ping_t *mp_ping;
18701 /* Parse args required to build the message */
18702 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
18704 if (!unformat (vam->input, "tunnel_index %d", &index))
18711 print (vam->ofp, " tunnel_index %d", index);
18713 M (MPLS_TUNNEL_DUMP, mp);
18714 mp->tunnel_index = htonl (index);
18717 /* Use a control ping for synchronization */
18718 MPING (CONTROL_PING, mp_ping);
18725 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
18726 #define vl_api_mpls_fib_details_t_print vl_noop_handler
18730 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
18732 vat_main_t *vam = &vat_main;
18733 int count = ntohl (mp->count);
18734 vl_api_fib_path2_t *fp;
18738 "table-id %d, label %u, ess_bit %u",
18739 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
18741 for (i = 0; i < count; i++)
18743 vl_api_mpls_fib_path_print (vam, fp);
18748 static void vl_api_mpls_fib_details_t_handler_json
18749 (vl_api_mpls_fib_details_t * mp)
18751 vat_main_t *vam = &vat_main;
18752 int count = ntohl (mp->count);
18753 vat_json_node_t *node = NULL;
18754 vl_api_fib_path2_t *fp;
18757 if (VAT_JSON_ARRAY != vam->json_tree.type)
18759 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18760 vat_json_init_array (&vam->json_tree);
18762 node = vat_json_array_add (&vam->json_tree);
18764 vat_json_init_object (node);
18765 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18766 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
18767 vat_json_object_add_uint (node, "label", ntohl (mp->label));
18768 vat_json_object_add_uint (node, "path_count", count);
18770 for (i = 0; i < count; i++)
18772 vl_api_mpls_fib_path_json_print (node, fp);
18778 api_mpls_fib_dump (vat_main_t * vam)
18780 vl_api_mpls_fib_dump_t *mp;
18781 vl_api_control_ping_t *mp_ping;
18784 M (MPLS_FIB_DUMP, mp);
18787 /* Use a control ping for synchronization */
18788 MPING (CONTROL_PING, mp_ping);
18795 #define vl_api_ip_fib_details_t_endian vl_noop_handler
18796 #define vl_api_ip_fib_details_t_print vl_noop_handler
18799 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
18801 vat_main_t *vam = &vat_main;
18802 int count = ntohl (mp->count);
18803 vl_api_fib_path_t *fp;
18807 "table-id %d, prefix %U/%d",
18808 ntohl (mp->table_id), format_ip4_address, mp->address,
18809 mp->address_length);
18811 for (i = 0; i < count; i++)
18813 if (fp->afi == IP46_TYPE_IP6)
18815 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18816 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18817 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18818 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18819 format_ip6_address, fp->next_hop);
18820 else if (fp->afi == IP46_TYPE_IP4)
18822 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18823 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18824 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18825 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18826 format_ip4_address, fp->next_hop);
18831 static void vl_api_ip_fib_details_t_handler_json
18832 (vl_api_ip_fib_details_t * mp)
18834 vat_main_t *vam = &vat_main;
18835 int count = ntohl (mp->count);
18836 vat_json_node_t *node = NULL;
18837 struct in_addr ip4;
18838 struct in6_addr ip6;
18839 vl_api_fib_path_t *fp;
18842 if (VAT_JSON_ARRAY != vam->json_tree.type)
18844 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18845 vat_json_init_array (&vam->json_tree);
18847 node = vat_json_array_add (&vam->json_tree);
18849 vat_json_init_object (node);
18850 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18851 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
18852 vat_json_object_add_ip4 (node, "prefix", ip4);
18853 vat_json_object_add_uint (node, "mask_length", mp->address_length);
18854 vat_json_object_add_uint (node, "path_count", count);
18856 for (i = 0; i < count; i++)
18858 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18859 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18860 vat_json_object_add_uint (node, "is_local", fp->is_local);
18861 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18862 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18863 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18864 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18865 if (fp->afi == IP46_TYPE_IP4)
18867 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18868 vat_json_object_add_ip4 (node, "next_hop", ip4);
18870 else if (fp->afi == IP46_TYPE_IP6)
18872 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18873 vat_json_object_add_ip6 (node, "next_hop", ip6);
18879 api_ip_fib_dump (vat_main_t * vam)
18881 vl_api_ip_fib_dump_t *mp;
18882 vl_api_control_ping_t *mp_ping;
18885 M (IP_FIB_DUMP, mp);
18888 /* Use a control ping for synchronization */
18889 MPING (CONTROL_PING, mp_ping);
18897 api_ip_mfib_dump (vat_main_t * vam)
18899 vl_api_ip_mfib_dump_t *mp;
18900 vl_api_control_ping_t *mp_ping;
18903 M (IP_MFIB_DUMP, mp);
18906 /* Use a control ping for synchronization */
18907 MPING (CONTROL_PING, mp_ping);
18914 static void vl_api_ip_neighbor_details_t_handler
18915 (vl_api_ip_neighbor_details_t * mp)
18917 vat_main_t *vam = &vat_main;
18919 print (vam->ofp, "%c %U %U",
18920 (mp->is_static) ? 'S' : 'D',
18921 format_ethernet_address, &mp->mac_address,
18922 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
18926 static void vl_api_ip_neighbor_details_t_handler_json
18927 (vl_api_ip_neighbor_details_t * mp)
18930 vat_main_t *vam = &vat_main;
18931 vat_json_node_t *node;
18932 struct in_addr ip4;
18933 struct in6_addr ip6;
18935 if (VAT_JSON_ARRAY != vam->json_tree.type)
18937 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18938 vat_json_init_array (&vam->json_tree);
18940 node = vat_json_array_add (&vam->json_tree);
18942 vat_json_init_object (node);
18943 vat_json_object_add_string_copy (node, "flag",
18944 (mp->is_static) ? (u8 *) "static" : (u8 *)
18947 vat_json_object_add_string_copy (node, "link_layer",
18948 format (0, "%U", format_ethernet_address,
18949 &mp->mac_address));
18953 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
18954 vat_json_object_add_ip6 (node, "ip_address", ip6);
18958 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
18959 vat_json_object_add_ip4 (node, "ip_address", ip4);
18964 api_ip_neighbor_dump (vat_main_t * vam)
18966 unformat_input_t *i = vam->input;
18967 vl_api_ip_neighbor_dump_t *mp;
18968 vl_api_control_ping_t *mp_ping;
18970 u32 sw_if_index = ~0;
18973 /* Parse args required to build the message */
18974 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18976 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18978 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18980 else if (unformat (i, "ip6"))
18986 if (sw_if_index == ~0)
18988 errmsg ("missing interface name or sw_if_index");
18992 M (IP_NEIGHBOR_DUMP, mp);
18993 mp->is_ipv6 = (u8) is_ipv6;
18994 mp->sw_if_index = ntohl (sw_if_index);
18997 /* Use a control ping for synchronization */
18998 MPING (CONTROL_PING, mp_ping);
19005 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
19006 #define vl_api_ip6_fib_details_t_print vl_noop_handler
19009 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
19011 vat_main_t *vam = &vat_main;
19012 int count = ntohl (mp->count);
19013 vl_api_fib_path_t *fp;
19017 "table-id %d, prefix %U/%d",
19018 ntohl (mp->table_id), format_ip6_address, mp->address,
19019 mp->address_length);
19021 for (i = 0; i < count; i++)
19023 if (fp->afi == IP46_TYPE_IP6)
19025 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19026 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19027 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19028 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19029 format_ip6_address, fp->next_hop);
19030 else if (fp->afi == IP46_TYPE_IP4)
19032 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19033 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19034 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19035 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19036 format_ip4_address, fp->next_hop);
19041 static void vl_api_ip6_fib_details_t_handler_json
19042 (vl_api_ip6_fib_details_t * mp)
19044 vat_main_t *vam = &vat_main;
19045 int count = ntohl (mp->count);
19046 vat_json_node_t *node = NULL;
19047 struct in_addr ip4;
19048 struct in6_addr ip6;
19049 vl_api_fib_path_t *fp;
19052 if (VAT_JSON_ARRAY != vam->json_tree.type)
19054 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19055 vat_json_init_array (&vam->json_tree);
19057 node = vat_json_array_add (&vam->json_tree);
19059 vat_json_init_object (node);
19060 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19061 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
19062 vat_json_object_add_ip6 (node, "prefix", ip6);
19063 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19064 vat_json_object_add_uint (node, "path_count", count);
19066 for (i = 0; i < count; i++)
19068 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19069 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19070 vat_json_object_add_uint (node, "is_local", fp->is_local);
19071 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19072 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19073 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19074 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19075 if (fp->afi == IP46_TYPE_IP4)
19077 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19078 vat_json_object_add_ip4 (node, "next_hop", ip4);
19080 else if (fp->afi == IP46_TYPE_IP6)
19082 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19083 vat_json_object_add_ip6 (node, "next_hop", ip6);
19089 api_ip6_fib_dump (vat_main_t * vam)
19091 vl_api_ip6_fib_dump_t *mp;
19092 vl_api_control_ping_t *mp_ping;
19095 M (IP6_FIB_DUMP, mp);
19098 /* Use a control ping for synchronization */
19099 MPING (CONTROL_PING, mp_ping);
19107 api_ip6_mfib_dump (vat_main_t * vam)
19109 vl_api_ip6_mfib_dump_t *mp;
19110 vl_api_control_ping_t *mp_ping;
19113 M (IP6_MFIB_DUMP, mp);
19116 /* Use a control ping for synchronization */
19117 MPING (CONTROL_PING, mp_ping);
19125 api_classify_table_ids (vat_main_t * vam)
19127 vl_api_classify_table_ids_t *mp;
19130 /* Construct the API message */
19131 M (CLASSIFY_TABLE_IDS, mp);
19140 api_classify_table_by_interface (vat_main_t * vam)
19142 unformat_input_t *input = vam->input;
19143 vl_api_classify_table_by_interface_t *mp;
19145 u32 sw_if_index = ~0;
19147 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19149 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19151 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19156 if (sw_if_index == ~0)
19158 errmsg ("missing interface name or sw_if_index");
19162 /* Construct the API message */
19163 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19165 mp->sw_if_index = ntohl (sw_if_index);
19173 api_classify_table_info (vat_main_t * vam)
19175 unformat_input_t *input = vam->input;
19176 vl_api_classify_table_info_t *mp;
19180 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19182 if (unformat (input, "table_id %d", &table_id))
19187 if (table_id == ~0)
19189 errmsg ("missing table id");
19193 /* Construct the API message */
19194 M (CLASSIFY_TABLE_INFO, mp);
19196 mp->table_id = ntohl (table_id);
19204 api_classify_session_dump (vat_main_t * vam)
19206 unformat_input_t *input = vam->input;
19207 vl_api_classify_session_dump_t *mp;
19208 vl_api_control_ping_t *mp_ping;
19212 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19214 if (unformat (input, "table_id %d", &table_id))
19219 if (table_id == ~0)
19221 errmsg ("missing table id");
19225 /* Construct the API message */
19226 M (CLASSIFY_SESSION_DUMP, mp);
19228 mp->table_id = ntohl (table_id);
19231 /* Use a control ping for synchronization */
19232 MPING (CONTROL_PING, mp_ping);
19240 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19242 vat_main_t *vam = &vat_main;
19244 print (vam->ofp, "collector_address %U, collector_port %d, "
19245 "src_address %U, vrf_id %d, path_mtu %u, "
19246 "template_interval %u, udp_checksum %d",
19247 format_ip4_address, mp->collector_address,
19248 ntohs (mp->collector_port),
19249 format_ip4_address, mp->src_address,
19250 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19251 ntohl (mp->template_interval), mp->udp_checksum);
19254 vam->result_ready = 1;
19258 vl_api_ipfix_exporter_details_t_handler_json
19259 (vl_api_ipfix_exporter_details_t * mp)
19261 vat_main_t *vam = &vat_main;
19262 vat_json_node_t node;
19263 struct in_addr collector_address;
19264 struct in_addr src_address;
19266 vat_json_init_object (&node);
19267 clib_memcpy (&collector_address, &mp->collector_address,
19268 sizeof (collector_address));
19269 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19270 vat_json_object_add_uint (&node, "collector_port",
19271 ntohs (mp->collector_port));
19272 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19273 vat_json_object_add_ip4 (&node, "src_address", src_address);
19274 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19275 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19276 vat_json_object_add_uint (&node, "template_interval",
19277 ntohl (mp->template_interval));
19278 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19280 vat_json_print (vam->ofp, &node);
19281 vat_json_free (&node);
19283 vam->result_ready = 1;
19287 api_ipfix_exporter_dump (vat_main_t * vam)
19289 vl_api_ipfix_exporter_dump_t *mp;
19292 /* Construct the API message */
19293 M (IPFIX_EXPORTER_DUMP, mp);
19302 api_ipfix_classify_stream_dump (vat_main_t * vam)
19304 vl_api_ipfix_classify_stream_dump_t *mp;
19307 /* Construct the API message */
19308 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19319 vl_api_ipfix_classify_stream_details_t_handler
19320 (vl_api_ipfix_classify_stream_details_t * mp)
19322 vat_main_t *vam = &vat_main;
19323 print (vam->ofp, "domain_id %d, src_port %d",
19324 ntohl (mp->domain_id), ntohs (mp->src_port));
19326 vam->result_ready = 1;
19330 vl_api_ipfix_classify_stream_details_t_handler_json
19331 (vl_api_ipfix_classify_stream_details_t * mp)
19333 vat_main_t *vam = &vat_main;
19334 vat_json_node_t node;
19336 vat_json_init_object (&node);
19337 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19338 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19340 vat_json_print (vam->ofp, &node);
19341 vat_json_free (&node);
19343 vam->result_ready = 1;
19347 api_ipfix_classify_table_dump (vat_main_t * vam)
19349 vl_api_ipfix_classify_table_dump_t *mp;
19350 vl_api_control_ping_t *mp_ping;
19353 if (!vam->json_output)
19355 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19356 "transport_protocol");
19359 /* Construct the API message */
19360 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19365 /* Use a control ping for synchronization */
19366 MPING (CONTROL_PING, mp_ping);
19374 vl_api_ipfix_classify_table_details_t_handler
19375 (vl_api_ipfix_classify_table_details_t * mp)
19377 vat_main_t *vam = &vat_main;
19378 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19379 mp->transport_protocol);
19383 vl_api_ipfix_classify_table_details_t_handler_json
19384 (vl_api_ipfix_classify_table_details_t * mp)
19386 vat_json_node_t *node = NULL;
19387 vat_main_t *vam = &vat_main;
19389 if (VAT_JSON_ARRAY != vam->json_tree.type)
19391 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19392 vat_json_init_array (&vam->json_tree);
19395 node = vat_json_array_add (&vam->json_tree);
19396 vat_json_init_object (node);
19398 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19399 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19400 vat_json_object_add_uint (node, "transport_protocol",
19401 mp->transport_protocol);
19405 api_sw_interface_span_enable_disable (vat_main_t * vam)
19407 unformat_input_t *i = vam->input;
19408 vl_api_sw_interface_span_enable_disable_t *mp;
19409 u32 src_sw_if_index = ~0;
19410 u32 dst_sw_if_index = ~0;
19415 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19418 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19420 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19424 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19426 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19428 else if (unformat (i, "disable"))
19430 else if (unformat (i, "rx"))
19432 else if (unformat (i, "tx"))
19434 else if (unformat (i, "both"))
19436 else if (unformat (i, "l2"))
19442 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19444 mp->sw_if_index_from = htonl (src_sw_if_index);
19445 mp->sw_if_index_to = htonl (dst_sw_if_index);
19455 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19458 vat_main_t *vam = &vat_main;
19459 u8 *sw_if_from_name = 0;
19460 u8 *sw_if_to_name = 0;
19461 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19462 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19463 char *states[] = { "none", "rx", "tx", "both" };
19467 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19469 if ((u32) p->value[0] == sw_if_index_from)
19471 sw_if_from_name = (u8 *)(p->key);
19475 if ((u32) p->value[0] == sw_if_index_to)
19477 sw_if_to_name = (u8 *)(p->key);
19478 if (sw_if_from_name)
19483 print (vam->ofp, "%20s => %20s (%s)",
19484 sw_if_from_name, sw_if_to_name, states[mp->state]);
19488 vl_api_sw_interface_span_details_t_handler_json
19489 (vl_api_sw_interface_span_details_t * mp)
19491 vat_main_t *vam = &vat_main;
19492 vat_json_node_t *node = NULL;
19493 u8 *sw_if_from_name = 0;
19494 u8 *sw_if_to_name = 0;
19495 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19496 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19500 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19502 if ((u32) p->value[0] == sw_if_index_from)
19504 sw_if_from_name = (u8 *)(p->key);
19508 if ((u32) p->value[0] == sw_if_index_to)
19510 sw_if_to_name = (u8 *)(p->key);
19511 if (sw_if_from_name)
19517 if (VAT_JSON_ARRAY != vam->json_tree.type)
19519 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19520 vat_json_init_array (&vam->json_tree);
19522 node = vat_json_array_add (&vam->json_tree);
19524 vat_json_init_object (node);
19525 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19526 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19527 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19528 if (0 != sw_if_to_name)
19530 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19532 vat_json_object_add_uint (node, "state", mp->state);
19536 api_sw_interface_span_dump (vat_main_t * vam)
19538 unformat_input_t *input = vam->input;
19539 vl_api_sw_interface_span_dump_t *mp;
19540 vl_api_control_ping_t *mp_ping;
19544 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19546 if (unformat (input, "l2"))
19552 M (SW_INTERFACE_SPAN_DUMP, mp);
19556 /* Use a control ping for synchronization */
19557 MPING (CONTROL_PING, mp_ping);
19565 api_pg_create_interface (vat_main_t * vam)
19567 unformat_input_t *input = vam->input;
19568 vl_api_pg_create_interface_t *mp;
19572 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19574 if (unformat (input, "if_id %d", &if_id))
19581 errmsg ("missing pg interface index");
19585 /* Construct the API message */
19586 M (PG_CREATE_INTERFACE, mp);
19588 mp->interface_id = ntohl (if_id);
19596 api_pg_capture (vat_main_t * vam)
19598 unformat_input_t *input = vam->input;
19599 vl_api_pg_capture_t *mp;
19604 u8 pcap_file_set = 0;
19607 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19609 if (unformat (input, "if_id %d", &if_id))
19611 else if (unformat (input, "pcap %s", &pcap_file))
19613 else if (unformat (input, "count %d", &count))
19615 else if (unformat (input, "disable"))
19622 errmsg ("missing pg interface index");
19625 if (pcap_file_set > 0)
19627 if (vec_len (pcap_file) > 255)
19629 errmsg ("pcap file name is too long");
19634 u32 name_len = vec_len (pcap_file);
19635 /* Construct the API message */
19636 M (PG_CAPTURE, mp);
19638 mp->interface_id = ntohl (if_id);
19639 mp->is_enabled = enable;
19640 mp->count = ntohl (count);
19641 mp->pcap_name_length = ntohl (name_len);
19642 if (pcap_file_set != 0)
19644 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19646 vec_free (pcap_file);
19654 api_pg_enable_disable (vat_main_t * vam)
19656 unformat_input_t *input = vam->input;
19657 vl_api_pg_enable_disable_t *mp;
19660 u8 stream_name_set = 0;
19661 u8 *stream_name = 0;
19663 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19665 if (unformat (input, "stream %s", &stream_name))
19666 stream_name_set = 1;
19667 else if (unformat (input, "disable"))
19673 if (stream_name_set > 0)
19675 if (vec_len (stream_name) > 255)
19677 errmsg ("stream name too long");
19682 u32 name_len = vec_len (stream_name);
19683 /* Construct the API message */
19684 M (PG_ENABLE_DISABLE, mp);
19686 mp->is_enabled = enable;
19687 if (stream_name_set != 0)
19689 mp->stream_name_length = ntohl (name_len);
19690 clib_memcpy (mp->stream_name, stream_name, name_len);
19692 vec_free (stream_name);
19700 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19702 unformat_input_t *input = vam->input;
19703 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19705 u16 *low_ports = 0;
19706 u16 *high_ports = 0;
19709 ip4_address_t ip4_addr;
19710 ip6_address_t ip6_addr;
19719 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19721 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
19727 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
19732 else if (unformat (input, "vrf %d", &vrf_id))
19734 else if (unformat (input, "del"))
19736 else if (unformat (input, "port %d", &tmp))
19738 if (tmp == 0 || tmp > 65535)
19740 errmsg ("port %d out of range", tmp);
19744 this_hi = this_low + 1;
19745 vec_add1 (low_ports, this_low);
19746 vec_add1 (high_ports, this_hi);
19748 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19750 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19752 errmsg ("incorrect range parameters");
19756 /* Note: in debug CLI +1 is added to high before
19757 passing to real fn that does "the work"
19758 (ip_source_and_port_range_check_add_del).
19759 This fn is a wrapper around the binary API fn a
19760 control plane will call, which expects this increment
19761 to have occurred. Hence letting the binary API control
19762 plane fn do the increment for consistency between VAT
19763 and other control planes.
19766 vec_add1 (low_ports, this_low);
19767 vec_add1 (high_ports, this_hi);
19773 if (prefix_set == 0)
19775 errmsg ("<address>/<mask> not specified");
19781 errmsg ("VRF ID required, not specified");
19788 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19792 if (vec_len (low_ports) == 0)
19794 errmsg ("At least one port or port range required");
19798 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19800 mp->is_add = is_add;
19805 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
19810 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
19813 mp->mask_length = length;
19814 mp->number_of_ranges = vec_len (low_ports);
19816 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
19817 vec_free (low_ports);
19819 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
19820 vec_free (high_ports);
19822 mp->vrf_id = ntohl (vrf_id);
19830 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
19832 unformat_input_t *input = vam->input;
19833 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
19834 u32 sw_if_index = ~0;
19836 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
19837 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
19841 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19843 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19845 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19847 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
19849 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
19851 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
19853 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
19855 else if (unformat (input, "del"))
19861 if (sw_if_index == ~0)
19863 errmsg ("Interface required but not specified");
19869 errmsg ("VRF ID required but not specified");
19873 if (tcp_out_vrf_id == 0
19874 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
19877 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19881 /* Construct the API message */
19882 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
19884 mp->sw_if_index = ntohl (sw_if_index);
19885 mp->is_add = is_add;
19886 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
19887 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
19888 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
19889 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
19894 /* Wait for a reply... */
19900 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
19902 unformat_input_t *i = vam->input;
19903 vl_api_ipsec_gre_add_del_tunnel_t *mp;
19904 u32 local_sa_id = 0;
19905 u32 remote_sa_id = 0;
19906 ip4_address_t src_address;
19907 ip4_address_t dst_address;
19911 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19913 if (unformat (i, "local_sa %d", &local_sa_id))
19915 else if (unformat (i, "remote_sa %d", &remote_sa_id))
19917 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
19919 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
19921 else if (unformat (i, "del"))
19925 clib_warning ("parse error '%U'", format_unformat_error, i);
19930 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
19932 mp->local_sa_id = ntohl (local_sa_id);
19933 mp->remote_sa_id = ntohl (remote_sa_id);
19934 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
19935 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
19936 mp->is_add = is_add;
19944 api_punt (vat_main_t * vam)
19946 unformat_input_t *i = vam->input;
19954 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19956 if (unformat (i, "ip %d", &ipv))
19958 else if (unformat (i, "protocol %d", &protocol))
19960 else if (unformat (i, "port %d", &port))
19962 else if (unformat (i, "del"))
19966 clib_warning ("parse error '%U'", format_unformat_error, i);
19973 mp->is_add = (u8) is_add;
19974 mp->ipv = (u8) ipv;
19975 mp->l4_protocol = (u8) protocol;
19976 mp->l4_port = htons ((u16) port);
19983 static void vl_api_ipsec_gre_tunnel_details_t_handler
19984 (vl_api_ipsec_gre_tunnel_details_t * mp)
19986 vat_main_t *vam = &vat_main;
19988 print (vam->ofp, "%11d%15U%15U%14d%14d",
19989 ntohl (mp->sw_if_index),
19990 format_ip4_address, &mp->src_address,
19991 format_ip4_address, &mp->dst_address,
19992 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
19995 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
19996 (vl_api_ipsec_gre_tunnel_details_t * mp)
19998 vat_main_t *vam = &vat_main;
19999 vat_json_node_t *node = NULL;
20000 struct in_addr ip4;
20002 if (VAT_JSON_ARRAY != vam->json_tree.type)
20004 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20005 vat_json_init_array (&vam->json_tree);
20007 node = vat_json_array_add (&vam->json_tree);
20009 vat_json_init_object (node);
20010 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20011 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
20012 vat_json_object_add_ip4 (node, "src_address", ip4);
20013 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
20014 vat_json_object_add_ip4 (node, "dst_address", ip4);
20015 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
20016 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
20020 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
20022 unformat_input_t *i = vam->input;
20023 vl_api_ipsec_gre_tunnel_dump_t *mp;
20024 vl_api_control_ping_t *mp_ping;
20026 u8 sw_if_index_set = 0;
20029 /* Parse args required to build the message */
20030 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20032 if (unformat (i, "sw_if_index %d", &sw_if_index))
20033 sw_if_index_set = 1;
20038 if (sw_if_index_set == 0)
20043 if (!vam->json_output)
20045 print (vam->ofp, "%11s%15s%15s%14s%14s",
20046 "sw_if_index", "src_address", "dst_address",
20047 "local_sa_id", "remote_sa_id");
20050 /* Get list of gre-tunnel interfaces */
20051 M (IPSEC_GRE_TUNNEL_DUMP, mp);
20053 mp->sw_if_index = htonl (sw_if_index);
20057 /* Use a control ping for synchronization */
20058 MPING (CONTROL_PING, mp_ping);
20066 api_delete_subif (vat_main_t * vam)
20068 unformat_input_t *i = vam->input;
20069 vl_api_delete_subif_t *mp;
20070 u32 sw_if_index = ~0;
20073 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20075 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20077 if (unformat (i, "sw_if_index %d", &sw_if_index))
20083 if (sw_if_index == ~0)
20085 errmsg ("missing sw_if_index");
20089 /* Construct the API message */
20090 M (DELETE_SUBIF, mp);
20091 mp->sw_if_index = ntohl (sw_if_index);
20098 #define foreach_pbb_vtr_op \
20099 _("disable", L2_VTR_DISABLED) \
20100 _("pop", L2_VTR_POP_2) \
20101 _("push", L2_VTR_PUSH_2)
20104 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20106 unformat_input_t *i = vam->input;
20107 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20108 u32 sw_if_index = ~0, vtr_op = ~0;
20109 u16 outer_tag = ~0;
20110 u8 dmac[6], smac[6];
20111 u8 dmac_set = 0, smac_set = 0;
20117 /* Shut up coverity */
20118 memset (dmac, 0, sizeof (dmac));
20119 memset (smac, 0, sizeof (smac));
20121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20123 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20125 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20127 else if (unformat (i, "vtr_op %d", &vtr_op))
20129 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20132 else if (unformat (i, "translate_pbb_stag"))
20134 if (unformat (i, "%d", &tmp))
20136 vtr_op = L2_VTR_TRANSLATE_2_1;
20142 ("translate_pbb_stag operation requires outer tag definition");
20146 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20148 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20150 else if (unformat (i, "sid %d", &sid))
20152 else if (unformat (i, "vlanid %d", &tmp))
20156 clib_warning ("parse error '%U'", format_unformat_error, i);
20161 if ((sw_if_index == ~0) || (vtr_op == ~0))
20163 errmsg ("missing sw_if_index or vtr operation");
20166 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20167 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20170 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20174 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20175 mp->sw_if_index = ntohl (sw_if_index);
20176 mp->vtr_op = ntohl (vtr_op);
20177 mp->outer_tag = ntohs (outer_tag);
20178 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20179 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20180 mp->b_vlanid = ntohs (vlanid);
20181 mp->i_sid = ntohl (sid);
20189 api_flow_classify_set_interface (vat_main_t * vam)
20191 unformat_input_t *i = vam->input;
20192 vl_api_flow_classify_set_interface_t *mp;
20194 int sw_if_index_set;
20195 u32 ip4_table_index = ~0;
20196 u32 ip6_table_index = ~0;
20200 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20202 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20203 sw_if_index_set = 1;
20204 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20205 sw_if_index_set = 1;
20206 else if (unformat (i, "del"))
20208 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20210 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20214 clib_warning ("parse error '%U'", format_unformat_error, i);
20219 if (sw_if_index_set == 0)
20221 errmsg ("missing interface name or sw_if_index");
20225 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20227 mp->sw_if_index = ntohl (sw_if_index);
20228 mp->ip4_table_index = ntohl (ip4_table_index);
20229 mp->ip6_table_index = ntohl (ip6_table_index);
20230 mp->is_add = is_add;
20238 api_flow_classify_dump (vat_main_t * vam)
20240 unformat_input_t *i = vam->input;
20241 vl_api_flow_classify_dump_t *mp;
20242 vl_api_control_ping_t *mp_ping;
20243 u8 type = FLOW_CLASSIFY_N_TABLES;
20246 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20250 errmsg ("classify table type must be specified");
20254 if (!vam->json_output)
20256 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20259 M (FLOW_CLASSIFY_DUMP, mp);
20264 /* Use a control ping for synchronization */
20265 MPING (CONTROL_PING, mp_ping);
20268 /* Wait for a reply... */
20274 api_feature_enable_disable (vat_main_t * vam)
20276 unformat_input_t *i = vam->input;
20277 vl_api_feature_enable_disable_t *mp;
20279 u8 *feature_name = 0;
20280 u32 sw_if_index = ~0;
20284 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20286 if (unformat (i, "arc_name %s", &arc_name))
20288 else if (unformat (i, "feature_name %s", &feature_name))
20291 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20293 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20295 else if (unformat (i, "disable"))
20303 errmsg ("missing arc name");
20306 if (vec_len (arc_name) > 63)
20308 errmsg ("arc name too long");
20311 if (feature_name == 0)
20313 errmsg ("missing feature name");
20316 if (vec_len (feature_name) > 63)
20318 errmsg ("feature name too long");
20321 if (sw_if_index == ~0)
20323 errmsg ("missing interface name or sw_if_index");
20327 /* Construct the API message */
20328 M (FEATURE_ENABLE_DISABLE, mp);
20329 mp->sw_if_index = ntohl (sw_if_index);
20330 mp->enable = enable;
20331 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20332 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20333 vec_free (arc_name);
20334 vec_free (feature_name);
20342 api_sw_interface_tag_add_del (vat_main_t * vam)
20344 unformat_input_t *i = vam->input;
20345 vl_api_sw_interface_tag_add_del_t *mp;
20346 u32 sw_if_index = ~0;
20351 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20353 if (unformat (i, "tag %s", &tag))
20355 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20357 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20359 else if (unformat (i, "del"))
20365 if (sw_if_index == ~0)
20367 errmsg ("missing interface name or sw_if_index");
20371 if (enable && (tag == 0))
20373 errmsg ("no tag specified");
20377 /* Construct the API message */
20378 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20379 mp->sw_if_index = ntohl (sw_if_index);
20380 mp->is_add = enable;
20382 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20390 static void vl_api_l2_xconnect_details_t_handler
20391 (vl_api_l2_xconnect_details_t * mp)
20393 vat_main_t *vam = &vat_main;
20395 print (vam->ofp, "%15d%15d",
20396 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20399 static void vl_api_l2_xconnect_details_t_handler_json
20400 (vl_api_l2_xconnect_details_t * mp)
20402 vat_main_t *vam = &vat_main;
20403 vat_json_node_t *node = NULL;
20405 if (VAT_JSON_ARRAY != vam->json_tree.type)
20407 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20408 vat_json_init_array (&vam->json_tree);
20410 node = vat_json_array_add (&vam->json_tree);
20412 vat_json_init_object (node);
20413 vat_json_object_add_uint (node, "rx_sw_if_index",
20414 ntohl (mp->rx_sw_if_index));
20415 vat_json_object_add_uint (node, "tx_sw_if_index",
20416 ntohl (mp->tx_sw_if_index));
20420 api_l2_xconnect_dump (vat_main_t * vam)
20422 vl_api_l2_xconnect_dump_t *mp;
20423 vl_api_control_ping_t *mp_ping;
20426 if (!vam->json_output)
20428 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20431 M (L2_XCONNECT_DUMP, mp);
20435 /* Use a control ping for synchronization */
20436 MPING (CONTROL_PING, mp_ping);
20444 api_sw_interface_set_mtu (vat_main_t * vam)
20446 unformat_input_t *i = vam->input;
20447 vl_api_sw_interface_set_mtu_t *mp;
20448 u32 sw_if_index = ~0;
20452 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20454 if (unformat (i, "mtu %d", &mtu))
20456 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20458 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20464 if (sw_if_index == ~0)
20466 errmsg ("missing interface name or sw_if_index");
20472 errmsg ("no mtu specified");
20476 /* Construct the API message */
20477 M (SW_INTERFACE_SET_MTU, mp);
20478 mp->sw_if_index = ntohl (sw_if_index);
20479 mp->mtu = ntohs ((u16) mtu);
20487 api_p2p_ethernet_add (vat_main_t * vam)
20489 unformat_input_t *i = vam->input;
20490 vl_api_p2p_ethernet_add_t *mp;
20491 u32 parent_if_index = ~0;
20497 memset (remote_mac, 0, sizeof (remote_mac));
20498 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20500 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20502 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20506 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20508 else if (unformat (i, "sub_id %d", &sub_id))
20512 clib_warning ("parse error '%U'", format_unformat_error, i);
20517 if (parent_if_index == ~0)
20519 errmsg ("missing interface name or sw_if_index");
20524 errmsg ("missing remote mac address");
20529 errmsg ("missing sub-interface id");
20533 M (P2P_ETHERNET_ADD, mp);
20534 mp->parent_if_index = ntohl (parent_if_index);
20535 mp->subif_id = ntohl (sub_id);
20536 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20544 api_p2p_ethernet_del (vat_main_t * vam)
20546 unformat_input_t *i = vam->input;
20547 vl_api_p2p_ethernet_del_t *mp;
20548 u32 parent_if_index = ~0;
20553 memset (remote_mac, 0, sizeof (remote_mac));
20554 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20556 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20558 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20562 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20566 clib_warning ("parse error '%U'", format_unformat_error, i);
20571 if (parent_if_index == ~0)
20573 errmsg ("missing interface name or sw_if_index");
20578 errmsg ("missing remote mac address");
20582 M (P2P_ETHERNET_DEL, mp);
20583 mp->parent_if_index = ntohl (parent_if_index);
20584 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20592 api_lldp_config (vat_main_t * vam)
20594 unformat_input_t *i = vam->input;
20595 vl_api_lldp_config_t *mp;
20597 int tx_interval = 0;
20598 u8 *sys_name = NULL;
20601 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20603 if (unformat (i, "system-name %s", &sys_name))
20605 else if (unformat (i, "tx-hold %d", &tx_hold))
20607 else if (unformat (i, "tx-interval %d", &tx_interval))
20611 clib_warning ("parse error '%U'", format_unformat_error, i);
20616 vec_add1 (sys_name, 0);
20618 M (LLDP_CONFIG, mp);
20619 mp->tx_hold = htonl (tx_hold);
20620 mp->tx_interval = htonl (tx_interval);
20621 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20622 vec_free (sys_name);
20630 api_sw_interface_set_lldp (vat_main_t * vam)
20632 unformat_input_t *i = vam->input;
20633 vl_api_sw_interface_set_lldp_t *mp;
20634 u32 sw_if_index = ~0;
20636 u8 *port_desc = NULL;
20639 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20641 if (unformat (i, "disable"))
20644 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20646 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20648 else if (unformat (i, "port-desc %s", &port_desc))
20654 if (sw_if_index == ~0)
20656 errmsg ("missing interface name or sw_if_index");
20660 /* Construct the API message */
20661 vec_add1 (port_desc, 0);
20662 M (SW_INTERFACE_SET_LLDP, mp);
20663 mp->sw_if_index = ntohl (sw_if_index);
20664 mp->enable = enable;
20665 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20666 vec_free (port_desc);
20674 api_tcp_configure_src_addresses (vat_main_t * vam)
20676 vl_api_tcp_configure_src_addresses_t *mp;
20677 unformat_input_t *i = vam->input;
20678 ip4_address_t v4first, v4last;
20679 ip6_address_t v6first, v6last;
20684 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20686 if (unformat (i, "%U - %U",
20687 unformat_ip4_address, &v4first,
20688 unformat_ip4_address, &v4last))
20692 errmsg ("one range per message (range already set)");
20697 else if (unformat (i, "%U - %U",
20698 unformat_ip6_address, &v6first,
20699 unformat_ip6_address, &v6last))
20703 errmsg ("one range per message (range already set)");
20708 else if (unformat (i, "vrf %d", &vrf_id))
20714 if (range_set == 0)
20716 errmsg ("address range not set");
20720 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20721 mp->vrf_id = ntohl (vrf_id);
20723 if (range_set == 2)
20726 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20727 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20732 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20733 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20741 api_app_namespace_add_del (vat_main_t * vam)
20743 vl_api_app_namespace_add_del_t *mp;
20744 unformat_input_t *i = vam->input;
20745 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
20746 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
20750 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20752 if (unformat (i, "id %_%v%_", &ns_id))
20754 else if (unformat (i, "secret %lu", &secret))
20756 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20757 sw_if_index_set = 1;
20758 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
20760 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
20765 if (!ns_id || !secret_set || !sw_if_index_set)
20767 errmsg ("namespace id, secret and sw_if_index must be set");
20770 if (vec_len (ns_id) > 64)
20772 errmsg ("namespace id too long");
20775 M (APP_NAMESPACE_ADD_DEL, mp);
20777 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
20778 mp->namespace_id_len = vec_len (ns_id);
20779 mp->secret = secret;
20780 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20781 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
20782 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
20790 api_memfd_segment_create (vat_main_t * vam)
20792 unformat_input_t *i = vam->input;
20793 vl_api_memfd_segment_create_t *mp;
20794 u64 size = 64 << 20;
20797 #if VPP_API_TEST_BUILTIN == 1
20798 errmsg ("memfd_segment_create (builtin) not supported");
20802 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20804 if (unformat (i, "size %U", unformat_memory_size, &size))
20810 M (MEMFD_SEGMENT_CREATE, mp);
20811 mp->requested_size = size;
20818 q_or_quit (vat_main_t * vam)
20820 #if VPP_API_TEST_BUILTIN == 0
20821 longjmp (vam->jump_buf, 1);
20823 return 0; /* not so much */
20827 q (vat_main_t * vam)
20829 return q_or_quit (vam);
20833 quit (vat_main_t * vam)
20835 return q_or_quit (vam);
20839 comment (vat_main_t * vam)
20845 cmd_cmp (void *a1, void *a2)
20850 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
20854 help (vat_main_t * vam)
20859 unformat_input_t *i = vam->input;
20862 if (unformat (i, "%s", &name))
20866 vec_add1 (name, 0);
20868 hs = hash_get_mem (vam->help_by_name, name);
20870 print (vam->ofp, "usage: %s %s", name, hs[0]);
20872 print (vam->ofp, "No such msg / command '%s'", name);
20877 print (vam->ofp, "Help is available for the following:");
20880 hash_foreach_pair (p, vam->function_by_name,
20882 vec_add1 (cmds, (u8 *)(p->key));
20886 vec_sort_with_function (cmds, cmd_cmp);
20888 for (j = 0; j < vec_len (cmds); j++)
20889 print (vam->ofp, "%s", cmds[j]);
20896 set (vat_main_t * vam)
20898 u8 *name = 0, *value = 0;
20899 unformat_input_t *i = vam->input;
20901 if (unformat (i, "%s", &name))
20903 /* The input buffer is a vector, not a string. */
20904 value = vec_dup (i->buffer);
20905 vec_delete (value, i->index, 0);
20906 /* Almost certainly has a trailing newline */
20907 if (value[vec_len (value) - 1] == '\n')
20908 value[vec_len (value) - 1] = 0;
20909 /* Make sure it's a proper string, one way or the other */
20910 vec_add1 (value, 0);
20911 (void) clib_macro_set_value (&vam->macro_main,
20912 (char *) name, (char *) value);
20915 errmsg ("usage: set <name> <value>");
20923 unset (vat_main_t * vam)
20927 if (unformat (vam->input, "%s", &name))
20928 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
20929 errmsg ("unset: %s wasn't set", name);
20942 macro_sort_cmp (void *a1, void *a2)
20944 macro_sort_t *s1 = a1;
20945 macro_sort_t *s2 = a2;
20947 return strcmp ((char *) (s1->name), (char *) (s2->name));
20951 dump_macro_table (vat_main_t * vam)
20953 macro_sort_t *sort_me = 0, *sm;
20958 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
20960 vec_add2 (sort_me, sm, 1);
20961 sm->name = (u8 *)(p->key);
20962 sm->value = (u8 *) (p->value[0]);
20966 vec_sort_with_function (sort_me, macro_sort_cmp);
20968 if (vec_len (sort_me))
20969 print (vam->ofp, "%-15s%s", "Name", "Value");
20971 print (vam->ofp, "The macro table is empty...");
20973 for (i = 0; i < vec_len (sort_me); i++)
20974 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
20979 dump_node_table (vat_main_t * vam)
20982 vlib_node_t *node, *next_node;
20984 if (vec_len (vam->graph_nodes) == 0)
20986 print (vam->ofp, "Node table empty, issue get_node_graph...");
20990 for (i = 0; i < vec_len (vam->graph_nodes); i++)
20992 node = vam->graph_nodes[i];
20993 print (vam->ofp, "[%d] %s", i, node->name);
20994 for (j = 0; j < vec_len (node->next_nodes); j++)
20996 if (node->next_nodes[j] != ~0)
20998 next_node = vam->graph_nodes[node->next_nodes[j]];
20999 print (vam->ofp, " [%d] %s", j, next_node->name);
21007 value_sort_cmp (void *a1, void *a2)
21009 name_sort_t *n1 = a1;
21010 name_sort_t *n2 = a2;
21012 if (n1->value < n2->value)
21014 if (n1->value > n2->value)
21021 dump_msg_api_table (vat_main_t * vam)
21023 api_main_t *am = &api_main;
21024 name_sort_t *nses = 0, *ns;
21029 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21031 vec_add2 (nses, ns, 1);
21032 ns->name = (u8 *)(hp->key);
21033 ns->value = (u32) hp->value[0];
21037 vec_sort_with_function (nses, value_sort_cmp);
21039 for (i = 0; i < vec_len (nses); i++)
21040 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21046 get_msg_id (vat_main_t * vam)
21051 if (unformat (vam->input, "%s", &name_and_crc))
21053 message_index = vl_api_get_msg_index (name_and_crc);
21054 if (message_index == ~0)
21056 print (vam->ofp, " '%s' not found", name_and_crc);
21059 print (vam->ofp, " '%s' has message index %d",
21060 name_and_crc, message_index);
21063 errmsg ("name_and_crc required...");
21068 search_node_table (vat_main_t * vam)
21070 unformat_input_t *line_input = vam->input;
21073 vlib_node_t *node, *next_node;
21076 if (vam->graph_node_index_by_name == 0)
21078 print (vam->ofp, "Node table empty, issue get_node_graph...");
21082 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21084 if (unformat (line_input, "%s", &node_to_find))
21086 vec_add1 (node_to_find, 0);
21087 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21090 print (vam->ofp, "%s not found...", node_to_find);
21093 node = vam->graph_nodes[p[0]];
21094 print (vam->ofp, "[%d] %s", p[0], node->name);
21095 for (j = 0; j < vec_len (node->next_nodes); j++)
21097 if (node->next_nodes[j] != ~0)
21099 next_node = vam->graph_nodes[node->next_nodes[j]];
21100 print (vam->ofp, " [%d] %s", j, next_node->name);
21107 clib_warning ("parse error '%U'", format_unformat_error,
21113 vec_free (node_to_find);
21122 script (vat_main_t * vam)
21124 #if (VPP_API_TEST_BUILTIN==0)
21126 char *save_current_file;
21127 unformat_input_t save_input;
21128 jmp_buf save_jump_buf;
21129 u32 save_line_number;
21131 FILE *new_fp, *save_ifp;
21133 if (unformat (vam->input, "%s", &s))
21135 new_fp = fopen ((char *) s, "r");
21138 errmsg ("Couldn't open script file %s", s);
21145 errmsg ("Missing script name");
21149 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21150 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21151 save_ifp = vam->ifp;
21152 save_line_number = vam->input_line_number;
21153 save_current_file = (char *) vam->current_file;
21155 vam->input_line_number = 0;
21157 vam->current_file = s;
21160 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
21161 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21162 vam->ifp = save_ifp;
21163 vam->input_line_number = save_line_number;
21164 vam->current_file = (u8 *) save_current_file;
21169 clib_warning ("use the exec command...");
21175 echo (vat_main_t * vam)
21177 print (vam->ofp, "%v", vam->input->buffer);
21181 /* List of API message constructors, CLI names map to api_xxx */
21182 #define foreach_vpe_api_msg \
21183 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21184 _(sw_interface_dump,"") \
21185 _(sw_interface_set_flags, \
21186 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21187 _(sw_interface_add_del_address, \
21188 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21189 _(sw_interface_set_table, \
21190 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21191 _(sw_interface_set_mpls_enable, \
21192 "<intfc> | sw_if_index [disable | dis]") \
21193 _(sw_interface_set_vpath, \
21194 "<intfc> | sw_if_index <id> enable | disable") \
21195 _(sw_interface_set_vxlan_bypass, \
21196 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21197 _(sw_interface_set_geneve_bypass, \
21198 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21199 _(sw_interface_set_l2_xconnect, \
21200 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21201 "enable | disable") \
21202 _(sw_interface_set_l2_bridge, \
21203 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21204 "[shg <split-horizon-group>] [bvi]\n" \
21205 "enable | disable") \
21206 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21207 _(bridge_domain_add_del, \
21208 "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") \
21209 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21211 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21212 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21213 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21215 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21217 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21219 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
21221 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
21223 "<vpp-if-name> | sw_if_index <id>") \
21224 _(sw_interface_tap_dump, "") \
21225 _(ip_table_add_del, \
21226 "table-id <n> [ipv6]\n") \
21227 _(ip_add_del_route, \
21228 "<addr>/<mask> via <addr> [table-id <n>]\n" \
21229 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
21230 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
21231 "[multipath] [count <n>]") \
21232 _(ip_mroute_add_del, \
21233 "<src> <grp>/<mask> [table-id <n>]\n" \
21234 "[<intfc> | sw_if_index <id>] [local] [del]") \
21235 _(mpls_table_add_del, \
21236 "table-id <n>\n") \
21237 _(mpls_route_add_del, \
21238 "<label> <eos> via <addr> [table-id <n>]\n" \
21239 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
21240 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
21241 "[multipath] [count <n>]") \
21242 _(mpls_ip_bind_unbind, \
21243 "<label> <addr/len>") \
21244 _(mpls_tunnel_add_del, \
21245 " via <addr> [table-id <n>]\n" \
21246 "sw_if_index <id>] [l2] [del]") \
21247 _(proxy_arp_add_del, \
21248 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
21249 _(proxy_arp_intfc_enable_disable, \
21250 "<intfc> | sw_if_index <id> enable | disable") \
21251 _(sw_interface_set_unnumbered, \
21252 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
21253 _(ip_neighbor_add_del, \
21254 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
21255 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
21256 _(reset_vrf, "vrf <id> [ipv6]") \
21257 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
21258 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
21259 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
21260 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
21261 "[outer_vlan_id_any][inner_vlan_id_any]") \
21262 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
21263 _(reset_fib, "vrf <n> [ipv6]") \
21264 _(dhcp_proxy_config, \
21265 "svr <v46-address> src <v46-address>\n" \
21266 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
21267 _(dhcp_proxy_set_vss, \
21268 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
21269 _(dhcp_proxy_dump, "ip6") \
21270 _(dhcp_client_config, \
21271 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
21272 _(set_ip_flow_hash, \
21273 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
21274 _(sw_interface_ip6_enable_disable, \
21275 "<intfc> | sw_if_index <id> enable | disable") \
21276 _(sw_interface_ip6_set_link_local_address, \
21277 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
21278 _(ip6nd_proxy_add_del, \
21279 "<intfc> | sw_if_index <id> <ip6-address>") \
21280 _(ip6nd_proxy_dump, "") \
21281 _(sw_interface_ip6nd_ra_prefix, \
21282 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
21283 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
21284 "[nolink] [isno]") \
21285 _(sw_interface_ip6nd_ra_config, \
21286 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
21287 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
21288 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
21289 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
21290 _(l2_patch_add_del, \
21291 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21292 "enable | disable") \
21293 _(sr_localsid_add_del, \
21294 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
21295 "fib-table <num> (end.psp) sw_if_index <num>") \
21296 _(classify_add_del_table, \
21297 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
21298 " [del] [del-chain] mask <mask-value>\n" \
21299 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
21300 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
21301 _(classify_add_del_session, \
21302 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
21303 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
21304 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
21305 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
21306 _(classify_set_interface_ip_table, \
21307 "<intfc> | sw_if_index <nn> table <nn>") \
21308 _(classify_set_interface_l2_tables, \
21309 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21310 " [other-table <nn>]") \
21311 _(get_node_index, "node <node-name") \
21312 _(add_node_next, "node <node-name> next <next-node-name>") \
21313 _(l2tpv3_create_tunnel, \
21314 "client_address <ip6-addr> our_address <ip6-addr>\n" \
21315 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
21316 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
21317 _(l2tpv3_set_tunnel_cookies, \
21318 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
21319 "[new_remote_cookie <nn>]\n") \
21320 _(l2tpv3_interface_enable_disable, \
21321 "<intfc> | sw_if_index <nn> enable | disable") \
21322 _(l2tpv3_set_lookup_key, \
21323 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
21324 _(sw_if_l2tpv3_tunnel_dump, "") \
21325 _(vxlan_add_del_tunnel, \
21326 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21327 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21328 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21329 _(geneve_add_del_tunnel, \
21330 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21331 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21332 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21333 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21334 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21335 _(gre_add_del_tunnel, \
21336 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
21337 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21338 _(l2_fib_clear_table, "") \
21339 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
21340 _(l2_interface_vlan_tag_rewrite, \
21341 "<intfc> | sw_if_index <nn> \n" \
21342 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
21343 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
21344 _(create_vhost_user_if, \
21345 "socket <filename> [server] [renumber <dev_instance>] " \
21346 "[mac <mac_address>]") \
21347 _(modify_vhost_user_if, \
21348 "<intfc> | sw_if_index <nn> socket <filename>\n" \
21349 "[server] [renumber <dev_instance>]") \
21350 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
21351 _(sw_interface_vhost_user_dump, "") \
21352 _(show_version, "") \
21353 _(vxlan_gpe_add_del_tunnel, \
21354 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
21355 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21356 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
21357 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
21358 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21359 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
21360 _(interface_name_renumber, \
21361 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
21362 _(input_acl_set_interface, \
21363 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21364 " [l2-table <nn>] [del]") \
21365 _(want_ip4_arp_events, "address <ip4-address> [del]") \
21366 _(want_ip6_nd_events, "address <ip6-address> [del]") \
21367 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
21368 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
21369 _(ip_dump, "ipv4 | ipv6") \
21370 _(ipsec_spd_add_del, "spd_id <n> [del]") \
21371 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
21373 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
21374 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
21375 " integ_alg <alg> integ_key <hex>") \
21376 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
21377 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
21378 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
21379 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
21380 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
21381 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
21382 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
21383 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
21384 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
21385 _(ipsec_sa_dump, "[sa_id <n>]") \
21386 _(ikev2_profile_add_del, "name <profile_name> [del]") \
21387 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
21388 "(auth_data 0x<data> | auth_data <data>)") \
21389 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
21390 "(id_data 0x<data> | id_data <data>) (local|remote)") \
21391 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
21392 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
21393 "(local|remote)") \
21394 _(ikev2_set_local_key, "file <absolute_file_path>") \
21395 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
21396 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
21397 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
21398 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
21399 _(ikev2_initiate_sa_init, "<profile_name>") \
21400 _(ikev2_initiate_del_ike_sa, "<ispi>") \
21401 _(ikev2_initiate_del_child_sa, "<ispi>") \
21402 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
21403 _(delete_loopback,"sw_if_index <nn>") \
21404 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
21405 _(map_add_domain, \
21406 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
21407 "ip6-src <ip6addr> " \
21408 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
21409 _(map_del_domain, "index <n>") \
21410 _(map_add_del_rule, \
21411 "index <n> psid <n> dst <ip6addr> [del]") \
21412 _(map_domain_dump, "") \
21413 _(map_rule_dump, "index <map-domain>") \
21414 _(want_interface_events, "enable|disable") \
21415 _(want_stats,"enable|disable") \
21416 _(get_first_msg_id, "client <name>") \
21417 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
21418 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
21419 "fib-id <nn> [ip4][ip6][default]") \
21420 _(get_node_graph, " ") \
21421 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
21422 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
21423 _(ioam_disable, "") \
21424 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
21425 " sw_if_index <sw_if_index> p <priority> " \
21426 "w <weight>] [del]") \
21427 _(one_add_del_locator, "locator-set <locator_name> " \
21428 "iface <intf> | sw_if_index <sw_if_index> " \
21429 "p <priority> w <weight> [del]") \
21430 _(one_add_del_local_eid,"vni <vni> eid " \
21431 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21432 "locator-set <locator_name> [del]" \
21433 "[key-id sha1|sha256 secret-key <secret-key>]")\
21434 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
21435 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
21436 _(one_enable_disable, "enable|disable") \
21437 _(one_map_register_enable_disable, "enable|disable") \
21438 _(one_map_register_fallback_threshold, "<value>") \
21439 _(one_rloc_probe_enable_disable, "enable|disable") \
21440 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21442 "rloc <locator> p <prio> " \
21443 "w <weight> [rloc <loc> ... ] " \
21444 "action <action> [del-all]") \
21445 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21447 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21448 _(one_use_petr, "ip-address> | disable") \
21449 _(one_map_request_mode, "src-dst|dst-only") \
21450 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21451 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21452 _(one_locator_set_dump, "[local | remote]") \
21453 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
21454 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21455 "[local] | [remote]") \
21456 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
21457 _(one_ndp_bd_get, "") \
21458 _(one_ndp_entries_get, "bd <bridge-domain>") \
21459 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
21460 _(one_l2_arp_bd_get, "") \
21461 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
21462 _(one_stats_enable_disable, "enable|disalbe") \
21463 _(show_one_stats_enable_disable, "") \
21464 _(one_eid_table_vni_dump, "") \
21465 _(one_eid_table_map_dump, "l2|l3") \
21466 _(one_map_resolver_dump, "") \
21467 _(one_map_server_dump, "") \
21468 _(one_adjacencies_get, "vni <vni>") \
21469 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
21470 _(show_one_rloc_probe_state, "") \
21471 _(show_one_map_register_state, "") \
21472 _(show_one_status, "") \
21473 _(one_stats_dump, "") \
21474 _(one_stats_flush, "") \
21475 _(one_get_map_request_itr_rlocs, "") \
21476 _(one_map_register_set_ttl, "<ttl>") \
21477 _(one_set_transport_protocol, "udp|api") \
21478 _(one_get_transport_protocol, "") \
21479 _(show_one_nsh_mapping, "") \
21480 _(show_one_pitr, "") \
21481 _(show_one_use_petr, "") \
21482 _(show_one_map_request_mode, "") \
21483 _(show_one_map_register_ttl, "") \
21484 _(show_one_map_register_fallback_threshold, "") \
21485 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
21486 " sw_if_index <sw_if_index> p <priority> " \
21487 "w <weight>] [del]") \
21488 _(lisp_add_del_locator, "locator-set <locator_name> " \
21489 "iface <intf> | sw_if_index <sw_if_index> " \
21490 "p <priority> w <weight> [del]") \
21491 _(lisp_add_del_local_eid,"vni <vni> eid " \
21492 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21493 "locator-set <locator_name> [del]" \
21494 "[key-id sha1|sha256 secret-key <secret-key>]") \
21495 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
21496 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
21497 _(lisp_enable_disable, "enable|disable") \
21498 _(lisp_map_register_enable_disable, "enable|disable") \
21499 _(lisp_rloc_probe_enable_disable, "enable|disable") \
21500 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21502 "rloc <locator> p <prio> " \
21503 "w <weight> [rloc <loc> ... ] " \
21504 "action <action> [del-all]") \
21505 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21507 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21508 _(lisp_use_petr, "<ip-address> | disable") \
21509 _(lisp_map_request_mode, "src-dst|dst-only") \
21510 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21511 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21512 _(lisp_locator_set_dump, "[local | remote]") \
21513 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
21514 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21515 "[local] | [remote]") \
21516 _(lisp_eid_table_vni_dump, "") \
21517 _(lisp_eid_table_map_dump, "l2|l3") \
21518 _(lisp_map_resolver_dump, "") \
21519 _(lisp_map_server_dump, "") \
21520 _(lisp_adjacencies_get, "vni <vni>") \
21521 _(gpe_fwd_entry_vnis_get, "") \
21522 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
21523 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
21524 "[table <table-id>]") \
21525 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
21526 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
21527 _(gpe_set_encap_mode, "lisp|vxlan") \
21528 _(gpe_get_encap_mode, "") \
21529 _(lisp_gpe_add_del_iface, "up|down") \
21530 _(lisp_gpe_enable_disable, "enable|disable") \
21531 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
21532 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
21533 _(show_lisp_rloc_probe_state, "") \
21534 _(show_lisp_map_register_state, "") \
21535 _(show_lisp_status, "") \
21536 _(lisp_get_map_request_itr_rlocs, "") \
21537 _(show_lisp_pitr, "") \
21538 _(show_lisp_use_petr, "") \
21539 _(show_lisp_map_request_mode, "") \
21540 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
21541 _(af_packet_delete, "name <host interface name>") \
21542 _(policer_add_del, "name <policer name> <params> [del]") \
21543 _(policer_dump, "[name <policer name>]") \
21544 _(policer_classify_set_interface, \
21545 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21546 " [l2-table <nn>] [del]") \
21547 _(policer_classify_dump, "type [ip4|ip6|l2]") \
21548 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
21549 "[master|slave]") \
21550 _(netmap_delete, "name <interface name>") \
21551 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
21552 _(mpls_fib_dump, "") \
21553 _(classify_table_ids, "") \
21554 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
21555 _(classify_table_info, "table_id <nn>") \
21556 _(classify_session_dump, "table_id <nn>") \
21557 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
21558 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
21559 "[template_interval <nn>] [udp_checksum]") \
21560 _(ipfix_exporter_dump, "") \
21561 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
21562 _(ipfix_classify_stream_dump, "") \
21563 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
21564 _(ipfix_classify_table_dump, "") \
21565 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
21566 _(sw_interface_span_dump, "[l2]") \
21567 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
21568 _(pg_create_interface, "if_id <nn>") \
21569 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
21570 _(pg_enable_disable, "[stream <id>] disable") \
21571 _(ip_source_and_port_range_check_add_del, \
21572 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
21573 _(ip_source_and_port_range_check_interface_add_del, \
21574 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
21575 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
21576 _(ipsec_gre_add_del_tunnel, \
21577 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
21578 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
21579 _(delete_subif,"<intfc> | sw_if_index <nn>") \
21580 _(l2_interface_pbb_tag_rewrite, \
21581 "<intfc> | sw_if_index <nn> \n" \
21582 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
21583 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
21584 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
21585 _(flow_classify_set_interface, \
21586 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
21587 _(flow_classify_dump, "type [ip4|ip6]") \
21588 _(ip_fib_dump, "") \
21589 _(ip_mfib_dump, "") \
21590 _(ip6_fib_dump, "") \
21591 _(ip6_mfib_dump, "") \
21592 _(feature_enable_disable, "arc_name <arc_name> " \
21593 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
21594 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
21596 _(l2_xconnect_dump, "") \
21597 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
21598 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
21599 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
21600 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
21601 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
21602 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
21603 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>] [disable]") \
21604 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
21605 _(memfd_segment_create,"size <nnn>") \
21606 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
21608 /* List of command functions, CLI names map directly to functions */
21609 #define foreach_cli_function \
21610 _(comment, "usage: comment <ignore-rest-of-line>") \
21611 _(dump_interface_table, "usage: dump_interface_table") \
21612 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
21613 _(dump_ipv4_table, "usage: dump_ipv4_table") \
21614 _(dump_ipv6_table, "usage: dump_ipv6_table") \
21615 _(dump_stats_table, "usage: dump_stats_table") \
21616 _(dump_macro_table, "usage: dump_macro_table ") \
21617 _(dump_node_table, "usage: dump_node_table") \
21618 _(dump_msg_api_table, "usage: dump_msg_api_table") \
21619 _(get_msg_id, "usage: get_msg_id name_and_crc") \
21620 _(echo, "usage: echo <message>") \
21621 _(exec, "usage: exec <vpe-debug-CLI-command>") \
21622 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
21623 _(help, "usage: help") \
21624 _(q, "usage: quit") \
21625 _(quit, "usage: quit") \
21626 _(search_node_table, "usage: search_node_table <name>...") \
21627 _(set, "usage: set <variable-name> <value>") \
21628 _(script, "usage: script <file-name>") \
21629 _(unset, "usage: unset <variable-name>")
21631 static void vl_api_##n##_t_handler_uni \
21632 (vl_api_##n##_t * mp) \
21634 vat_main_t * vam = &vat_main; \
21635 if (vam->json_output) { \
21636 vl_api_##n##_t_handler_json(mp); \
21638 vl_api_##n##_t_handler(mp); \
21641 foreach_vpe_api_reply_msg;
21642 #if VPP_API_TEST_BUILTIN == 0
21643 foreach_standalone_reply_msg;
21648 vat_api_hookup (vat_main_t * vam)
21651 vl_msg_api_set_handlers(VL_API_##N, #n, \
21652 vl_api_##n##_t_handler_uni, \
21654 vl_api_##n##_t_endian, \
21655 vl_api_##n##_t_print, \
21656 sizeof(vl_api_##n##_t), 1);
21657 foreach_vpe_api_reply_msg;
21658 #if VPP_API_TEST_BUILTIN == 0
21659 foreach_standalone_reply_msg;
21663 #if (VPP_API_TEST_BUILTIN==0)
21664 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
21666 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
21668 vam->function_by_name = hash_create_string (0, sizeof (uword));
21670 vam->help_by_name = hash_create_string (0, sizeof (uword));
21673 /* API messages we can send */
21674 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
21675 foreach_vpe_api_msg;
21679 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21680 foreach_vpe_api_msg;
21683 /* CLI functions */
21684 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
21685 foreach_cli_function;
21689 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21690 foreach_cli_function;
21694 #if VPP_API_TEST_BUILTIN
21695 static clib_error_t *
21696 vat_api_hookup_shim (vlib_main_t * vm)
21698 vat_api_hookup (&vat_main);
21702 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
21706 * fd.io coding-style-patch-verification: ON
21709 * eval: (c-set-style "gnu")