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)
5122 static void vl_api_##n##_t_handler \
5123 (vl_api_##n##_t * mp) \
5125 vat_main_t * vam = &vat_main; \
5126 i32 retval = ntohl(mp->retval); \
5127 if (vam->async_mode) { \
5128 vam->async_errors += (retval < 0); \
5130 vam->retval = retval; \
5131 vam->result_ready = 1; \
5134 foreach_standard_reply_retval_handler;
5138 static void vl_api_##n##_t_handler_json \
5139 (vl_api_##n##_t * mp) \
5141 vat_main_t * vam = &vat_main; \
5142 vat_json_node_t node; \
5143 vat_json_init_object(&node); \
5144 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5145 vat_json_print(vam->ofp, &node); \
5146 vam->retval = ntohl(mp->retval); \
5147 vam->result_ready = 1; \
5149 foreach_standard_reply_retval_handler;
5153 * Table of message reply handlers, must include boilerplate handlers
5157 #define foreach_vpe_api_reply_msg \
5158 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5159 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5160 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5161 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5162 _(CONTROL_PING_REPLY, control_ping_reply) \
5163 _(CLI_REPLY, cli_reply) \
5164 _(CLI_INBAND_REPLY, cli_inband_reply) \
5165 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5166 sw_interface_add_del_address_reply) \
5167 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5168 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5169 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5170 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5171 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5172 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5173 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5174 sw_interface_set_l2_xconnect_reply) \
5175 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5176 sw_interface_set_l2_bridge_reply) \
5177 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5178 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5179 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5180 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5181 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5182 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5183 _(L2_FLAGS_REPLY, l2_flags_reply) \
5184 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5185 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5186 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5187 _(TAP_DELETE_REPLY, tap_delete_reply) \
5188 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5189 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5190 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5191 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5192 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5193 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5194 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5195 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5196 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5197 proxy_arp_intfc_enable_disable_reply) \
5198 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5199 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5200 sw_interface_set_unnumbered_reply) \
5201 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5202 _(RESET_VRF_REPLY, reset_vrf_reply) \
5203 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5204 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5205 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5206 _(RESET_FIB_REPLY, reset_fib_reply) \
5207 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5208 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5209 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5210 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5211 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5212 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5213 sw_interface_ip6_enable_disable_reply) \
5214 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5215 sw_interface_ip6_set_link_local_address_reply) \
5216 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5217 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5218 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5219 sw_interface_ip6nd_ra_prefix_reply) \
5220 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5221 sw_interface_ip6nd_ra_config_reply) \
5222 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5223 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5224 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5225 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5226 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5227 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5228 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5229 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5230 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5231 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5232 classify_set_interface_ip_table_reply) \
5233 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5234 classify_set_interface_l2_tables_reply) \
5235 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5236 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5237 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5238 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5239 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5240 l2tpv3_interface_enable_disable_reply) \
5241 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5242 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5243 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5244 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5245 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5246 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5247 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5248 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5249 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5250 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5251 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5252 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5253 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5254 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5255 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5256 _(SHOW_VERSION_REPLY, show_version_reply) \
5257 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5258 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5259 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5260 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5261 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5262 _(IP4_ARP_EVENT, ip4_arp_event) \
5263 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5264 _(IP6_ND_EVENT, ip6_nd_event) \
5265 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5266 _(L2_MACS_EVENT, l2_macs_event) \
5267 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5268 _(IP_ADDRESS_DETAILS, ip_address_details) \
5269 _(IP_DETAILS, ip_details) \
5270 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5271 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5272 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5273 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5274 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5275 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5276 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5277 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5278 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5279 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5280 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5281 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5282 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5283 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5284 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5285 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5286 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5287 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5288 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5289 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5290 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5291 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5292 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5293 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5294 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5295 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5296 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5297 _(MAP_RULE_DETAILS, map_rule_details) \
5298 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5299 _(WANT_STATS_REPLY, want_stats_reply) \
5300 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5301 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5302 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5303 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5304 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5305 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5306 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5307 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5308 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5309 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5310 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5311 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5312 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5313 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5314 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5315 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5316 one_map_register_enable_disable_reply) \
5317 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5318 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5319 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5320 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5321 one_map_register_fallback_threshold_reply) \
5322 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5323 one_rloc_probe_enable_disable_reply) \
5324 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5325 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5326 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5327 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5328 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5329 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5330 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5331 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5332 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5333 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5334 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5335 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5336 _(ONE_STATS_DETAILS, one_stats_details) \
5337 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5338 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5339 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5340 show_one_stats_enable_disable_reply) \
5341 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5342 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5343 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5344 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5345 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5346 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5347 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5348 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5349 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5350 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5351 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5352 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5353 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5354 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5355 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5356 gpe_add_del_native_fwd_rpath_reply) \
5357 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5358 gpe_fwd_entry_path_details) \
5359 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5360 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5361 one_add_del_map_request_itr_rlocs_reply) \
5362 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5363 one_get_map_request_itr_rlocs_reply) \
5364 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5365 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5366 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5367 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5368 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5369 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5370 show_one_map_register_state_reply) \
5371 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5372 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5373 show_one_map_register_fallback_threshold_reply) \
5374 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5375 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5376 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5377 _(POLICER_DETAILS, policer_details) \
5378 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5379 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5380 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5381 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5382 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5383 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5384 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5385 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5386 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5387 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5388 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5389 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5390 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5391 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5392 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5393 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5394 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5395 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5396 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5397 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5398 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5399 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5400 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5401 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5402 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5403 ip_source_and_port_range_check_add_del_reply) \
5404 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5405 ip_source_and_port_range_check_interface_add_del_reply) \
5406 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5407 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5408 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5409 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5410 _(PUNT_REPLY, punt_reply) \
5411 _(IP_FIB_DETAILS, ip_fib_details) \
5412 _(IP6_FIB_DETAILS, ip6_fib_details) \
5413 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5414 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5415 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5416 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5417 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5418 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5419 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5420 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5421 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5422 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5423 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply)
5425 #define foreach_standalone_reply_msg \
5426 _(SW_INTERFACE_EVENT, sw_interface_event) \
5427 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5428 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5429 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5430 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5431 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5432 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
5433 _(MEMFD_SEGMENT_CREATE_REPLY, memfd_segment_create_reply)
5442 #define STR_VTR_OP_CASE(op) \
5443 case L2_VTR_ ## op: \
5447 str_vtr_op (u32 vtr_op)
5451 STR_VTR_OP_CASE (DISABLED);
5452 STR_VTR_OP_CASE (PUSH_1);
5453 STR_VTR_OP_CASE (PUSH_2);
5454 STR_VTR_OP_CASE (POP_1);
5455 STR_VTR_OP_CASE (POP_2);
5456 STR_VTR_OP_CASE (TRANSLATE_1_1);
5457 STR_VTR_OP_CASE (TRANSLATE_1_2);
5458 STR_VTR_OP_CASE (TRANSLATE_2_1);
5459 STR_VTR_OP_CASE (TRANSLATE_2_2);
5466 dump_sub_interface_table (vat_main_t * vam)
5468 const sw_interface_subif_t *sub = NULL;
5470 if (vam->json_output)
5473 ("JSON output supported only for VPE API calls and dump_stats_table");
5478 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5479 "Interface", "sw_if_index",
5480 "sub id", "dot1ad", "tags", "outer id",
5481 "inner id", "exact", "default", "outer any", "inner any");
5483 vec_foreach (sub, vam->sw_if_subif_table)
5486 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5487 sub->interface_name,
5489 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5490 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5491 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5492 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5493 if (sub->vtr_op != L2_VTR_DISABLED)
5496 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5497 "tag1: %d tag2: %d ]",
5498 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5499 sub->vtr_tag1, sub->vtr_tag2);
5507 name_sort_cmp (void *a1, void *a2)
5509 name_sort_t *n1 = a1;
5510 name_sort_t *n2 = a2;
5512 return strcmp ((char *) n1->name, (char *) n2->name);
5516 dump_interface_table (vat_main_t * vam)
5519 name_sort_t *nses = 0, *ns;
5521 if (vam->json_output)
5524 ("JSON output supported only for VPE API calls and dump_stats_table");
5529 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5531 vec_add2 (nses, ns, 1);
5532 ns->name = (u8 *)(p->key);
5533 ns->value = (u32) p->value[0];
5537 vec_sort_with_function (nses, name_sort_cmp);
5539 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5540 vec_foreach (ns, nses)
5542 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5549 dump_ip_table (vat_main_t * vam, int is_ipv6)
5551 const ip_details_t *det = NULL;
5552 const ip_address_details_t *address = NULL;
5555 print (vam->ofp, "%-12s", "sw_if_index");
5557 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5564 print (vam->ofp, "%-12d", i);
5565 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5570 vec_foreach (address, det->addr)
5574 is_ipv6 ? format_ip6_address : format_ip4_address,
5575 address->ip, address->prefix_length);
5583 dump_ipv4_table (vat_main_t * vam)
5585 if (vam->json_output)
5588 ("JSON output supported only for VPE API calls and dump_stats_table");
5592 return dump_ip_table (vam, 0);
5596 dump_ipv6_table (vat_main_t * vam)
5598 if (vam->json_output)
5601 ("JSON output supported only for VPE API calls and dump_stats_table");
5605 return dump_ip_table (vam, 1);
5609 counter_type_to_str (u8 counter_type, u8 is_combined)
5613 switch (counter_type)
5615 case VNET_INTERFACE_COUNTER_DROP:
5617 case VNET_INTERFACE_COUNTER_PUNT:
5619 case VNET_INTERFACE_COUNTER_IP4:
5621 case VNET_INTERFACE_COUNTER_IP6:
5623 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5625 case VNET_INTERFACE_COUNTER_RX_MISS:
5627 case VNET_INTERFACE_COUNTER_RX_ERROR:
5629 case VNET_INTERFACE_COUNTER_TX_ERROR:
5632 return "INVALID-COUNTER-TYPE";
5637 switch (counter_type)
5639 case VNET_INTERFACE_COUNTER_RX:
5641 case VNET_INTERFACE_COUNTER_TX:
5644 return "INVALID-COUNTER-TYPE";
5650 dump_stats_table (vat_main_t * vam)
5652 vat_json_node_t node;
5653 vat_json_node_t *msg_array;
5654 vat_json_node_t *msg;
5655 vat_json_node_t *counter_array;
5656 vat_json_node_t *counter;
5657 interface_counter_t c;
5659 ip4_fib_counter_t *c4;
5660 ip6_fib_counter_t *c6;
5661 ip4_nbr_counter_t *n4;
5662 ip6_nbr_counter_t *n6;
5665 if (!vam->json_output)
5667 clib_warning ("dump_stats_table supported only in JSON format");
5671 vat_json_init_object (&node);
5673 /* interface counters */
5674 msg_array = vat_json_object_add (&node, "interface_counters");
5675 vat_json_init_array (msg_array);
5676 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5678 msg = vat_json_array_add (msg_array);
5679 vat_json_init_object (msg);
5680 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5681 (u8 *) counter_type_to_str (i, 0));
5682 vat_json_object_add_int (msg, "is_combined", 0);
5683 counter_array = vat_json_object_add (msg, "data");
5684 vat_json_init_array (counter_array);
5685 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5687 packets = vam->simple_interface_counters[i][j];
5688 vat_json_array_add_uint (counter_array, packets);
5691 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5693 msg = vat_json_array_add (msg_array);
5694 vat_json_init_object (msg);
5695 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5696 (u8 *) counter_type_to_str (i, 1));
5697 vat_json_object_add_int (msg, "is_combined", 1);
5698 counter_array = vat_json_object_add (msg, "data");
5699 vat_json_init_array (counter_array);
5700 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5702 c = vam->combined_interface_counters[i][j];
5703 counter = vat_json_array_add (counter_array);
5704 vat_json_init_object (counter);
5705 vat_json_object_add_uint (counter, "packets", c.packets);
5706 vat_json_object_add_uint (counter, "bytes", c.bytes);
5710 /* ip4 fib counters */
5711 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5712 vat_json_init_array (msg_array);
5713 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5715 msg = vat_json_array_add (msg_array);
5716 vat_json_init_object (msg);
5717 vat_json_object_add_uint (msg, "vrf_id",
5718 vam->ip4_fib_counters_vrf_id_by_index[i]);
5719 counter_array = vat_json_object_add (msg, "c");
5720 vat_json_init_array (counter_array);
5721 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5723 counter = vat_json_array_add (counter_array);
5724 vat_json_init_object (counter);
5725 c4 = &vam->ip4_fib_counters[i][j];
5726 vat_json_object_add_ip4 (counter, "address", c4->address);
5727 vat_json_object_add_uint (counter, "address_length",
5728 c4->address_length);
5729 vat_json_object_add_uint (counter, "packets", c4->packets);
5730 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5734 /* ip6 fib counters */
5735 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5736 vat_json_init_array (msg_array);
5737 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5739 msg = vat_json_array_add (msg_array);
5740 vat_json_init_object (msg);
5741 vat_json_object_add_uint (msg, "vrf_id",
5742 vam->ip6_fib_counters_vrf_id_by_index[i]);
5743 counter_array = vat_json_object_add (msg, "c");
5744 vat_json_init_array (counter_array);
5745 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5747 counter = vat_json_array_add (counter_array);
5748 vat_json_init_object (counter);
5749 c6 = &vam->ip6_fib_counters[i][j];
5750 vat_json_object_add_ip6 (counter, "address", c6->address);
5751 vat_json_object_add_uint (counter, "address_length",
5752 c6->address_length);
5753 vat_json_object_add_uint (counter, "packets", c6->packets);
5754 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5758 /* ip4 nbr counters */
5759 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5760 vat_json_init_array (msg_array);
5761 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5763 msg = vat_json_array_add (msg_array);
5764 vat_json_init_object (msg);
5765 vat_json_object_add_uint (msg, "sw_if_index", i);
5766 counter_array = vat_json_object_add (msg, "c");
5767 vat_json_init_array (counter_array);
5768 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5770 counter = vat_json_array_add (counter_array);
5771 vat_json_init_object (counter);
5772 n4 = &vam->ip4_nbr_counters[i][j];
5773 vat_json_object_add_ip4 (counter, "address", n4->address);
5774 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5775 vat_json_object_add_uint (counter, "packets", n4->packets);
5776 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5780 /* ip6 nbr counters */
5781 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5782 vat_json_init_array (msg_array);
5783 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5785 msg = vat_json_array_add (msg_array);
5786 vat_json_init_object (msg);
5787 vat_json_object_add_uint (msg, "sw_if_index", i);
5788 counter_array = vat_json_object_add (msg, "c");
5789 vat_json_init_array (counter_array);
5790 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5792 counter = vat_json_array_add (counter_array);
5793 vat_json_init_object (counter);
5794 n6 = &vam->ip6_nbr_counters[i][j];
5795 vat_json_object_add_ip6 (counter, "address", n6->address);
5796 vat_json_object_add_uint (counter, "packets", n6->packets);
5797 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5801 vat_json_print (vam->ofp, &node);
5802 vat_json_free (&node);
5808 * Pass CLI buffers directly in the CLI_INBAND API message,
5809 * instead of an additional shared memory area.
5812 exec_inband (vat_main_t * vam)
5814 vl_api_cli_inband_t *mp;
5815 unformat_input_t *i = vam->input;
5818 if (vec_len (i->buffer) == 0)
5821 if (vam->exec_mode == 0 && unformat (i, "mode"))
5826 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5833 * In order for the CLI command to work, it
5834 * must be a vector ending in \n, not a C-string ending
5837 u32 len = vec_len (vam->input->buffer);
5838 M2 (CLI_INBAND, mp, len);
5839 clib_memcpy (mp->cmd, vam->input->buffer, len);
5840 mp->length = htonl (len);
5844 /* json responses may or may not include a useful reply... */
5845 if (vec_len (vam->cmd_reply))
5846 print (vam->ofp, (char *) (vam->cmd_reply));
5851 exec (vat_main_t * vam)
5853 return exec_inband (vam);
5857 api_create_loopback (vat_main_t * vam)
5859 unformat_input_t *i = vam->input;
5860 vl_api_create_loopback_t *mp;
5861 vl_api_create_loopback_instance_t *mp_lbi;
5864 u8 is_specified = 0;
5865 u32 user_instance = 0;
5868 memset (mac_address, 0, sizeof (mac_address));
5870 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5872 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5874 if (unformat (i, "instance %d", &user_instance))
5882 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5883 mp_lbi->is_specified = is_specified;
5885 mp_lbi->user_instance = htonl (user_instance);
5887 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5892 /* Construct the API message */
5893 M (CREATE_LOOPBACK, mp);
5895 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5904 api_delete_loopback (vat_main_t * vam)
5906 unformat_input_t *i = vam->input;
5907 vl_api_delete_loopback_t *mp;
5908 u32 sw_if_index = ~0;
5911 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5913 if (unformat (i, "sw_if_index %d", &sw_if_index))
5919 if (sw_if_index == ~0)
5921 errmsg ("missing sw_if_index");
5925 /* Construct the API message */
5926 M (DELETE_LOOPBACK, mp);
5927 mp->sw_if_index = ntohl (sw_if_index);
5935 api_want_stats (vat_main_t * vam)
5937 unformat_input_t *i = vam->input;
5938 vl_api_want_stats_t *mp;
5942 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5944 if (unformat (i, "enable"))
5946 else if (unformat (i, "disable"))
5954 errmsg ("missing enable|disable");
5959 mp->enable_disable = enable;
5967 api_want_interface_events (vat_main_t * vam)
5969 unformat_input_t *i = vam->input;
5970 vl_api_want_interface_events_t *mp;
5974 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5976 if (unformat (i, "enable"))
5978 else if (unformat (i, "disable"))
5986 errmsg ("missing enable|disable");
5990 M (WANT_INTERFACE_EVENTS, mp);
5991 mp->enable_disable = enable;
5993 vam->interface_event_display = enable;
6001 /* Note: non-static, called once to set up the initial intfc table */
6003 api_sw_interface_dump (vat_main_t * vam)
6005 vl_api_sw_interface_dump_t *mp;
6006 vl_api_control_ping_t *mp_ping;
6008 name_sort_t *nses = 0, *ns;
6009 sw_interface_subif_t *sub = NULL;
6012 /* Toss the old name table */
6014 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6016 vec_add2 (nses, ns, 1);
6017 ns->name = (u8 *)(p->key);
6018 ns->value = (u32) p->value[0];
6022 hash_free (vam->sw_if_index_by_interface_name);
6024 vec_foreach (ns, nses) vec_free (ns->name);
6028 vec_foreach (sub, vam->sw_if_subif_table)
6030 vec_free (sub->interface_name);
6032 vec_free (vam->sw_if_subif_table);
6034 /* recreate the interface name hash table */
6035 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6037 /* Get list of ethernets */
6038 M (SW_INTERFACE_DUMP, mp);
6039 mp->name_filter_valid = 1;
6040 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
6043 /* and local / loopback interfaces */
6044 M (SW_INTERFACE_DUMP, mp);
6045 mp->name_filter_valid = 1;
6046 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
6049 /* and packet-generator interfaces */
6050 M (SW_INTERFACE_DUMP, mp);
6051 mp->name_filter_valid = 1;
6052 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
6055 /* and vxlan-gpe tunnel interfaces */
6056 M (SW_INTERFACE_DUMP, mp);
6057 mp->name_filter_valid = 1;
6058 strncpy ((char *) mp->name_filter, "vxlan_gpe",
6059 sizeof (mp->name_filter) - 1);
6062 /* and vxlan tunnel interfaces */
6063 M (SW_INTERFACE_DUMP, mp);
6064 mp->name_filter_valid = 1;
6065 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
6068 /* and geneve tunnel interfaces */
6069 M (SW_INTERFACE_DUMP, mp);
6070 mp->name_filter_valid = 1;
6071 strncpy ((char *) mp->name_filter, "geneve", sizeof (mp->name_filter) - 1);
6074 /* and host (af_packet) interfaces */
6075 M (SW_INTERFACE_DUMP, mp);
6076 mp->name_filter_valid = 1;
6077 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
6080 /* and l2tpv3 tunnel interfaces */
6081 M (SW_INTERFACE_DUMP, mp);
6082 mp->name_filter_valid = 1;
6083 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
6084 sizeof (mp->name_filter) - 1);
6087 /* and GRE tunnel interfaces */
6088 M (SW_INTERFACE_DUMP, mp);
6089 mp->name_filter_valid = 1;
6090 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
6093 /* and LISP-GPE interfaces */
6094 M (SW_INTERFACE_DUMP, mp);
6095 mp->name_filter_valid = 1;
6096 strncpy ((char *) mp->name_filter, "lisp_gpe",
6097 sizeof (mp->name_filter) - 1);
6100 /* and IPSEC tunnel interfaces */
6101 M (SW_INTERFACE_DUMP, mp);
6102 mp->name_filter_valid = 1;
6103 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
6106 /* Use a control ping for synchronization */
6107 MPING (CONTROL_PING, mp_ping);
6115 api_sw_interface_set_flags (vat_main_t * vam)
6117 unformat_input_t *i = vam->input;
6118 vl_api_sw_interface_set_flags_t *mp;
6120 u8 sw_if_index_set = 0;
6124 /* Parse args required to build the message */
6125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6127 if (unformat (i, "admin-up"))
6129 else if (unformat (i, "admin-down"))
6132 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6133 sw_if_index_set = 1;
6134 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6135 sw_if_index_set = 1;
6140 if (sw_if_index_set == 0)
6142 errmsg ("missing interface name or sw_if_index");
6146 /* Construct the API message */
6147 M (SW_INTERFACE_SET_FLAGS, mp);
6148 mp->sw_if_index = ntohl (sw_if_index);
6149 mp->admin_up_down = admin_up;
6154 /* Wait for a reply, return the good/bad news... */
6160 api_sw_interface_clear_stats (vat_main_t * vam)
6162 unformat_input_t *i = vam->input;
6163 vl_api_sw_interface_clear_stats_t *mp;
6165 u8 sw_if_index_set = 0;
6168 /* Parse args required to build the message */
6169 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6171 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6172 sw_if_index_set = 1;
6173 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6174 sw_if_index_set = 1;
6179 /* Construct the API message */
6180 M (SW_INTERFACE_CLEAR_STATS, mp);
6182 if (sw_if_index_set == 1)
6183 mp->sw_if_index = ntohl (sw_if_index);
6185 mp->sw_if_index = ~0;
6190 /* Wait for a reply, return the good/bad news... */
6196 api_sw_interface_add_del_address (vat_main_t * vam)
6198 unformat_input_t *i = vam->input;
6199 vl_api_sw_interface_add_del_address_t *mp;
6201 u8 sw_if_index_set = 0;
6202 u8 is_add = 1, del_all = 0;
6203 u32 address_length = 0;
6204 u8 v4_address_set = 0;
6205 u8 v6_address_set = 0;
6206 ip4_address_t v4address;
6207 ip6_address_t v6address;
6210 /* Parse args required to build the message */
6211 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6213 if (unformat (i, "del-all"))
6215 else if (unformat (i, "del"))
6218 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6219 sw_if_index_set = 1;
6220 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6221 sw_if_index_set = 1;
6222 else if (unformat (i, "%U/%d",
6223 unformat_ip4_address, &v4address, &address_length))
6225 else if (unformat (i, "%U/%d",
6226 unformat_ip6_address, &v6address, &address_length))
6232 if (sw_if_index_set == 0)
6234 errmsg ("missing interface name or sw_if_index");
6237 if (v4_address_set && v6_address_set)
6239 errmsg ("both v4 and v6 addresses set");
6242 if (!v4_address_set && !v6_address_set && !del_all)
6244 errmsg ("no addresses set");
6248 /* Construct the API message */
6249 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6251 mp->sw_if_index = ntohl (sw_if_index);
6252 mp->is_add = is_add;
6253 mp->del_all = del_all;
6257 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6261 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6263 mp->address_length = address_length;
6268 /* Wait for a reply, return good/bad news */
6274 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6276 unformat_input_t *i = vam->input;
6277 vl_api_sw_interface_set_mpls_enable_t *mp;
6279 u8 sw_if_index_set = 0;
6283 /* Parse args required to build the message */
6284 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6286 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6287 sw_if_index_set = 1;
6288 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6289 sw_if_index_set = 1;
6290 else if (unformat (i, "disable"))
6292 else if (unformat (i, "dis"))
6298 if (sw_if_index_set == 0)
6300 errmsg ("missing interface name or sw_if_index");
6304 /* Construct the API message */
6305 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6307 mp->sw_if_index = ntohl (sw_if_index);
6308 mp->enable = enable;
6313 /* Wait for a reply... */
6319 api_sw_interface_set_table (vat_main_t * vam)
6321 unformat_input_t *i = vam->input;
6322 vl_api_sw_interface_set_table_t *mp;
6323 u32 sw_if_index, vrf_id = 0;
6324 u8 sw_if_index_set = 0;
6328 /* Parse args required to build the message */
6329 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6331 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6332 sw_if_index_set = 1;
6333 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6334 sw_if_index_set = 1;
6335 else if (unformat (i, "vrf %d", &vrf_id))
6337 else if (unformat (i, "ipv6"))
6343 if (sw_if_index_set == 0)
6345 errmsg ("missing interface name or sw_if_index");
6349 /* Construct the API message */
6350 M (SW_INTERFACE_SET_TABLE, mp);
6352 mp->sw_if_index = ntohl (sw_if_index);
6353 mp->is_ipv6 = is_ipv6;
6354 mp->vrf_id = ntohl (vrf_id);
6359 /* Wait for a reply... */
6364 static void vl_api_sw_interface_get_table_reply_t_handler
6365 (vl_api_sw_interface_get_table_reply_t * mp)
6367 vat_main_t *vam = &vat_main;
6369 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6371 vam->retval = ntohl (mp->retval);
6372 vam->result_ready = 1;
6376 static void vl_api_sw_interface_get_table_reply_t_handler_json
6377 (vl_api_sw_interface_get_table_reply_t * mp)
6379 vat_main_t *vam = &vat_main;
6380 vat_json_node_t node;
6382 vat_json_init_object (&node);
6383 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6384 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6386 vat_json_print (vam->ofp, &node);
6387 vat_json_free (&node);
6389 vam->retval = ntohl (mp->retval);
6390 vam->result_ready = 1;
6394 api_sw_interface_get_table (vat_main_t * vam)
6396 unformat_input_t *i = vam->input;
6397 vl_api_sw_interface_get_table_t *mp;
6399 u8 sw_if_index_set = 0;
6403 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6405 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6406 sw_if_index_set = 1;
6407 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6408 sw_if_index_set = 1;
6409 else if (unformat (i, "ipv6"))
6415 if (sw_if_index_set == 0)
6417 errmsg ("missing interface name or sw_if_index");
6421 M (SW_INTERFACE_GET_TABLE, mp);
6422 mp->sw_if_index = htonl (sw_if_index);
6423 mp->is_ipv6 = is_ipv6;
6431 api_sw_interface_set_vpath (vat_main_t * vam)
6433 unformat_input_t *i = vam->input;
6434 vl_api_sw_interface_set_vpath_t *mp;
6435 u32 sw_if_index = 0;
6436 u8 sw_if_index_set = 0;
6440 /* Parse args required to build the message */
6441 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6443 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6444 sw_if_index_set = 1;
6445 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6446 sw_if_index_set = 1;
6447 else if (unformat (i, "enable"))
6449 else if (unformat (i, "disable"))
6455 if (sw_if_index_set == 0)
6457 errmsg ("missing interface name or sw_if_index");
6461 /* Construct the API message */
6462 M (SW_INTERFACE_SET_VPATH, mp);
6464 mp->sw_if_index = ntohl (sw_if_index);
6465 mp->enable = is_enable;
6470 /* Wait for a reply... */
6476 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6478 unformat_input_t *i = vam->input;
6479 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6480 u32 sw_if_index = 0;
6481 u8 sw_if_index_set = 0;
6486 /* Parse args required to build the message */
6487 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6489 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6490 sw_if_index_set = 1;
6491 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6492 sw_if_index_set = 1;
6493 else if (unformat (i, "enable"))
6495 else if (unformat (i, "disable"))
6497 else if (unformat (i, "ip4"))
6499 else if (unformat (i, "ip6"))
6505 if (sw_if_index_set == 0)
6507 errmsg ("missing interface name or sw_if_index");
6511 /* Construct the API message */
6512 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6514 mp->sw_if_index = ntohl (sw_if_index);
6515 mp->enable = is_enable;
6516 mp->is_ipv6 = is_ipv6;
6521 /* Wait for a reply... */
6527 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6529 unformat_input_t *i = vam->input;
6530 vl_api_sw_interface_set_geneve_bypass_t *mp;
6531 u32 sw_if_index = 0;
6532 u8 sw_if_index_set = 0;
6537 /* Parse args required to build the message */
6538 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6540 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6541 sw_if_index_set = 1;
6542 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6543 sw_if_index_set = 1;
6544 else if (unformat (i, "enable"))
6546 else if (unformat (i, "disable"))
6548 else if (unformat (i, "ip4"))
6550 else if (unformat (i, "ip6"))
6556 if (sw_if_index_set == 0)
6558 errmsg ("missing interface name or sw_if_index");
6562 /* Construct the API message */
6563 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6565 mp->sw_if_index = ntohl (sw_if_index);
6566 mp->enable = is_enable;
6567 mp->is_ipv6 = is_ipv6;
6572 /* Wait for a reply... */
6578 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6580 unformat_input_t *i = vam->input;
6581 vl_api_sw_interface_set_l2_xconnect_t *mp;
6583 u8 rx_sw_if_index_set = 0;
6585 u8 tx_sw_if_index_set = 0;
6589 /* Parse args required to build the message */
6590 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6592 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6593 rx_sw_if_index_set = 1;
6594 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6595 tx_sw_if_index_set = 1;
6596 else if (unformat (i, "rx"))
6598 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6600 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6602 rx_sw_if_index_set = 1;
6607 else if (unformat (i, "tx"))
6609 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6611 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6613 tx_sw_if_index_set = 1;
6618 else if (unformat (i, "enable"))
6620 else if (unformat (i, "disable"))
6626 if (rx_sw_if_index_set == 0)
6628 errmsg ("missing rx interface name or rx_sw_if_index");
6632 if (enable && (tx_sw_if_index_set == 0))
6634 errmsg ("missing tx interface name or tx_sw_if_index");
6638 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6640 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6641 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6642 mp->enable = enable;
6650 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6652 unformat_input_t *i = vam->input;
6653 vl_api_sw_interface_set_l2_bridge_t *mp;
6655 u8 rx_sw_if_index_set = 0;
6663 /* Parse args required to build the message */
6664 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6666 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6667 rx_sw_if_index_set = 1;
6668 else if (unformat (i, "bd_id %d", &bd_id))
6672 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6673 rx_sw_if_index_set = 1;
6674 else if (unformat (i, "shg %d", &shg))
6676 else if (unformat (i, "bvi"))
6678 else if (unformat (i, "enable"))
6680 else if (unformat (i, "disable"))
6686 if (rx_sw_if_index_set == 0)
6688 errmsg ("missing rx interface name or sw_if_index");
6692 if (enable && (bd_id_set == 0))
6694 errmsg ("missing bridge domain");
6698 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6700 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6701 mp->bd_id = ntohl (bd_id);
6704 mp->enable = enable;
6712 api_bridge_domain_dump (vat_main_t * vam)
6714 unformat_input_t *i = vam->input;
6715 vl_api_bridge_domain_dump_t *mp;
6716 vl_api_control_ping_t *mp_ping;
6720 /* Parse args required to build the message */
6721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6723 if (unformat (i, "bd_id %d", &bd_id))
6729 M (BRIDGE_DOMAIN_DUMP, mp);
6730 mp->bd_id = ntohl (bd_id);
6733 /* Use a control ping for synchronization */
6734 MPING (CONTROL_PING, mp_ping);
6742 api_bridge_domain_add_del (vat_main_t * vam)
6744 unformat_input_t *i = vam->input;
6745 vl_api_bridge_domain_add_del_t *mp;
6748 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6753 /* Parse args required to build the message */
6754 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6756 if (unformat (i, "bd_id %d", &bd_id))
6758 else if (unformat (i, "flood %d", &flood))
6760 else if (unformat (i, "uu-flood %d", &uu_flood))
6762 else if (unformat (i, "forward %d", &forward))
6764 else if (unformat (i, "learn %d", &learn))
6766 else if (unformat (i, "arp-term %d", &arp_term))
6768 else if (unformat (i, "mac-age %d", &mac_age))
6770 else if (unformat (i, "bd-tag %s", &bd_tag))
6772 else if (unformat (i, "del"))
6775 flood = uu_flood = forward = learn = 0;
6783 errmsg ("missing bridge domain");
6790 errmsg ("mac age must be less than 256 ");
6795 if ((bd_tag) && (strlen ((char *) bd_tag) > 63))
6797 errmsg ("bd-tag cannot be longer than 63");
6802 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6804 mp->bd_id = ntohl (bd_id);
6806 mp->uu_flood = uu_flood;
6807 mp->forward = forward;
6809 mp->arp_term = arp_term;
6810 mp->is_add = is_add;
6811 mp->mac_age = (u8) mac_age;
6813 strcpy ((char *) mp->bd_tag, (char *) bd_tag);
6824 api_l2fib_flush_bd (vat_main_t * vam)
6826 unformat_input_t *i = vam->input;
6827 vl_api_l2fib_flush_bd_t *mp;
6831 /* Parse args required to build the message */
6832 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6834 if (unformat (i, "bd_id %d", &bd_id));
6841 errmsg ("missing bridge domain");
6845 M (L2FIB_FLUSH_BD, mp);
6847 mp->bd_id = htonl (bd_id);
6855 api_l2fib_flush_int (vat_main_t * vam)
6857 unformat_input_t *i = vam->input;
6858 vl_api_l2fib_flush_int_t *mp;
6859 u32 sw_if_index = ~0;
6862 /* Parse args required to build the message */
6863 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6865 if (unformat (i, "sw_if_index %d", &sw_if_index));
6867 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6872 if (sw_if_index == ~0)
6874 errmsg ("missing interface name or sw_if_index");
6878 M (L2FIB_FLUSH_INT, mp);
6880 mp->sw_if_index = ntohl (sw_if_index);
6888 api_l2fib_add_del (vat_main_t * vam)
6890 unformat_input_t *i = vam->input;
6891 vl_api_l2fib_add_del_t *mp;
6897 u32 sw_if_index = ~0;
6898 u8 sw_if_index_set = 0;
6907 /* Parse args required to build the message */
6908 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6910 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6912 else if (unformat (i, "bd_id %d", &bd_id))
6914 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6915 sw_if_index_set = 1;
6916 else if (unformat (i, "sw_if"))
6918 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6921 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6922 sw_if_index_set = 1;
6927 else if (unformat (i, "static"))
6929 else if (unformat (i, "filter"))
6934 else if (unformat (i, "bvi"))
6939 else if (unformat (i, "del"))
6941 else if (unformat (i, "count %d", &count))
6949 errmsg ("missing mac address");
6955 errmsg ("missing bridge domain");
6959 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6961 errmsg ("missing interface name or sw_if_index");
6967 /* Turn on async mode */
6968 vam->async_mode = 1;
6969 vam->async_errors = 0;
6970 before = vat_time_now (vam);
6973 for (j = 0; j < count; j++)
6975 M (L2FIB_ADD_DEL, mp);
6978 mp->bd_id = ntohl (bd_id);
6979 mp->is_add = is_add;
6983 mp->sw_if_index = ntohl (sw_if_index);
6984 mp->static_mac = static_mac;
6985 mp->filter_mac = filter_mac;
6986 mp->bvi_mac = bvi_mac;
6988 increment_mac_address (&mac);
6995 vl_api_control_ping_t *mp_ping;
6998 /* Shut off async mode */
6999 vam->async_mode = 0;
7001 MPING (CONTROL_PING, mp_ping);
7004 timeout = vat_time_now (vam) + 1.0;
7005 while (vat_time_now (vam) < timeout)
7006 if (vam->result_ready == 1)
7011 if (vam->retval == -99)
7014 if (vam->async_errors > 0)
7016 errmsg ("%d asynchronous errors", vam->async_errors);
7019 vam->async_errors = 0;
7020 after = vat_time_now (vam);
7022 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7023 count, after - before, count / (after - before));
7029 /* Wait for a reply... */
7033 /* Return the good/bad news */
7034 return (vam->retval);
7038 api_bridge_domain_set_mac_age (vat_main_t * vam)
7040 unformat_input_t *i = vam->input;
7041 vl_api_bridge_domain_set_mac_age_t *mp;
7046 /* Parse args required to build the message */
7047 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7049 if (unformat (i, "bd_id %d", &bd_id));
7050 else if (unformat (i, "mac-age %d", &mac_age));
7057 errmsg ("missing bridge domain");
7063 errmsg ("mac age must be less than 256 ");
7067 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7069 mp->bd_id = htonl (bd_id);
7070 mp->mac_age = (u8) mac_age;
7078 api_l2_flags (vat_main_t * vam)
7080 unformat_input_t *i = vam->input;
7081 vl_api_l2_flags_t *mp;
7084 u8 sw_if_index_set = 0;
7088 /* Parse args required to build the message */
7089 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7091 if (unformat (i, "sw_if_index %d", &sw_if_index))
7092 sw_if_index_set = 1;
7093 else if (unformat (i, "sw_if"))
7095 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7098 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7099 sw_if_index_set = 1;
7104 else if (unformat (i, "learn"))
7106 else if (unformat (i, "forward"))
7108 else if (unformat (i, "flood"))
7110 else if (unformat (i, "uu-flood"))
7111 flags |= L2_UU_FLOOD;
7112 else if (unformat (i, "arp-term"))
7113 flags |= L2_ARP_TERM;
7114 else if (unformat (i, "off"))
7116 else if (unformat (i, "disable"))
7122 if (sw_if_index_set == 0)
7124 errmsg ("missing interface name or sw_if_index");
7130 mp->sw_if_index = ntohl (sw_if_index);
7131 mp->feature_bitmap = ntohl (flags);
7132 mp->is_set = is_set;
7140 api_bridge_flags (vat_main_t * vam)
7142 unformat_input_t *i = vam->input;
7143 vl_api_bridge_flags_t *mp;
7150 /* Parse args required to build the message */
7151 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7153 if (unformat (i, "bd_id %d", &bd_id))
7155 else if (unformat (i, "learn"))
7157 else if (unformat (i, "forward"))
7159 else if (unformat (i, "flood"))
7161 else if (unformat (i, "uu-flood"))
7162 flags |= L2_UU_FLOOD;
7163 else if (unformat (i, "arp-term"))
7164 flags |= L2_ARP_TERM;
7165 else if (unformat (i, "off"))
7167 else if (unformat (i, "disable"))
7175 errmsg ("missing bridge domain");
7179 M (BRIDGE_FLAGS, mp);
7181 mp->bd_id = ntohl (bd_id);
7182 mp->feature_bitmap = ntohl (flags);
7183 mp->is_set = is_set;
7191 api_bd_ip_mac_add_del (vat_main_t * vam)
7193 unformat_input_t *i = vam->input;
7194 vl_api_bd_ip_mac_add_del_t *mp;
7201 ip4_address_t v4addr;
7202 ip6_address_t v6addr;
7207 /* Parse args required to build the message */
7208 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7210 if (unformat (i, "bd_id %d", &bd_id))
7214 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7218 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7223 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7227 else if (unformat (i, "del"))
7235 errmsg ("missing bridge domain");
7238 else if (ip_set == 0)
7240 errmsg ("missing IP address");
7243 else if (mac_set == 0)
7245 errmsg ("missing MAC address");
7249 M (BD_IP_MAC_ADD_DEL, mp);
7251 mp->bd_id = ntohl (bd_id);
7252 mp->is_ipv6 = is_ipv6;
7253 mp->is_add = is_add;
7255 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7257 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7258 clib_memcpy (mp->mac_address, macaddr, 6);
7265 api_tap_connect (vat_main_t * vam)
7267 unformat_input_t *i = vam->input;
7268 vl_api_tap_connect_t *mp;
7274 ip4_address_t ip4_address;
7276 int ip4_address_set = 0;
7277 ip6_address_t ip6_address;
7279 int ip6_address_set = 0;
7282 memset (mac_address, 0, sizeof (mac_address));
7284 /* Parse args required to build the message */
7285 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7287 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7291 else if (unformat (i, "random-mac"))
7293 else if (unformat (i, "tapname %s", &tap_name))
7295 else if (unformat (i, "tag %s", &tag))
7297 else if (unformat (i, "address %U/%d",
7298 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7299 ip4_address_set = 1;
7300 else if (unformat (i, "address %U/%d",
7301 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7302 ip6_address_set = 1;
7309 errmsg ("missing tap name");
7312 if (vec_len (tap_name) > 63)
7314 errmsg ("tap name too long");
7317 vec_add1 (tap_name, 0);
7319 if (vec_len (tag) > 63)
7321 errmsg ("tag too long");
7325 /* Construct the API message */
7326 M (TAP_CONNECT, mp);
7328 mp->use_random_mac = random_mac;
7329 clib_memcpy (mp->mac_address, mac_address, 6);
7330 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7332 clib_memcpy (mp->tag, tag, vec_len (tag));
7334 if (ip4_address_set)
7336 mp->ip4_address_set = 1;
7337 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7338 mp->ip4_mask_width = ip4_mask_width;
7340 if (ip6_address_set)
7342 mp->ip6_address_set = 1;
7343 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7344 mp->ip6_mask_width = ip6_mask_width;
7347 vec_free (tap_name);
7353 /* Wait for a reply... */
7359 api_tap_modify (vat_main_t * vam)
7361 unformat_input_t *i = vam->input;
7362 vl_api_tap_modify_t *mp;
7367 u32 sw_if_index = ~0;
7368 u8 sw_if_index_set = 0;
7371 memset (mac_address, 0, sizeof (mac_address));
7373 /* Parse args required to build the message */
7374 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7376 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7377 sw_if_index_set = 1;
7378 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7379 sw_if_index_set = 1;
7380 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7384 else if (unformat (i, "random-mac"))
7386 else if (unformat (i, "tapname %s", &tap_name))
7392 if (sw_if_index_set == 0)
7394 errmsg ("missing vpp interface name");
7399 errmsg ("missing tap name");
7402 if (vec_len (tap_name) > 63)
7404 errmsg ("tap name too long");
7406 vec_add1 (tap_name, 0);
7408 /* Construct the API message */
7411 mp->use_random_mac = random_mac;
7412 mp->sw_if_index = ntohl (sw_if_index);
7413 clib_memcpy (mp->mac_address, mac_address, 6);
7414 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7415 vec_free (tap_name);
7420 /* Wait for a reply... */
7426 api_tap_delete (vat_main_t * vam)
7428 unformat_input_t *i = vam->input;
7429 vl_api_tap_delete_t *mp;
7430 u32 sw_if_index = ~0;
7431 u8 sw_if_index_set = 0;
7434 /* Parse args required to build the message */
7435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7437 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7438 sw_if_index_set = 1;
7439 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7440 sw_if_index_set = 1;
7445 if (sw_if_index_set == 0)
7447 errmsg ("missing vpp interface name");
7451 /* Construct the API message */
7454 mp->sw_if_index = ntohl (sw_if_index);
7459 /* Wait for a reply... */
7465 api_ip_table_add_del (vat_main_t * vam)
7467 unformat_input_t *i = vam->input;
7468 vl_api_ip_table_add_del_t *mp;
7474 /* Parse args required to build the message */
7475 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7477 if (unformat (i, "ipv6"))
7479 else if (unformat (i, "del"))
7481 else if (unformat (i, "add"))
7483 else if (unformat (i, "table %d", &table_id))
7487 clib_warning ("parse error '%U'", format_unformat_error, i);
7494 errmsg ("missing table-ID");
7498 /* Construct the API message */
7499 M (IP_TABLE_ADD_DEL, mp);
7501 mp->table_id = ntohl (table_id);
7502 mp->is_ipv6 = is_ipv6;
7503 mp->is_add = is_add;
7508 /* Wait for a reply... */
7515 api_ip_add_del_route (vat_main_t * vam)
7517 unformat_input_t *i = vam->input;
7518 vl_api_ip_add_del_route_t *mp;
7519 u32 sw_if_index = ~0, vrf_id = 0;
7521 u8 is_local = 0, is_drop = 0;
7522 u8 is_unreach = 0, is_prohibit = 0;
7523 u8 create_vrf_if_needed = 0;
7525 u32 next_hop_weight = 1;
7527 u8 is_multipath = 0;
7529 u8 address_length_set = 0;
7530 u32 next_hop_table_id = 0;
7531 u32 resolve_attempts = 0;
7532 u32 dst_address_length = 0;
7533 u8 next_hop_set = 0;
7534 ip4_address_t v4_dst_address, v4_next_hop_address;
7535 ip6_address_t v6_dst_address, v6_next_hop_address;
7539 u32 random_add_del = 0;
7540 u32 *random_vector = 0;
7542 u32 random_seed = 0xdeaddabe;
7543 u32 classify_table_index = ~0;
7545 u8 resolve_host = 0, resolve_attached = 0;
7546 mpls_label_t *next_hop_out_label_stack = NULL;
7547 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7548 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7550 /* Parse args required to build the message */
7551 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7553 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7555 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7557 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
7562 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
7567 else if (unformat (i, "/%d", &dst_address_length))
7569 address_length_set = 1;
7572 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
7573 &v4_next_hop_address))
7577 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7578 &v6_next_hop_address))
7582 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7584 else if (unformat (i, "weight %d", &next_hop_weight))
7586 else if (unformat (i, "drop"))
7590 else if (unformat (i, "null-send-unreach"))
7594 else if (unformat (i, "null-send-prohibit"))
7598 else if (unformat (i, "local"))
7602 else if (unformat (i, "classify %d", &classify_table_index))
7606 else if (unformat (i, "del"))
7608 else if (unformat (i, "add"))
7610 else if (unformat (i, "not-last"))
7612 else if (unformat (i, "resolve-via-host"))
7614 else if (unformat (i, "resolve-via-attached"))
7615 resolve_attached = 1;
7616 else if (unformat (i, "multipath"))
7618 else if (unformat (i, "vrf %d", &vrf_id))
7620 else if (unformat (i, "create-vrf"))
7621 create_vrf_if_needed = 1;
7622 else if (unformat (i, "count %d", &count))
7624 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7626 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7628 else if (unformat (i, "out-label %d", &next_hop_out_label))
7629 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7630 else if (unformat (i, "via-label %d", &next_hop_via_label))
7632 else if (unformat (i, "random"))
7634 else if (unformat (i, "seed %d", &random_seed))
7638 clib_warning ("parse error '%U'", format_unformat_error, i);
7643 if (!next_hop_set && !is_drop && !is_local &&
7644 !is_classify && !is_unreach && !is_prohibit &&
7645 MPLS_LABEL_INVALID == next_hop_via_label)
7648 ("next hop / local / drop / unreach / prohibit / classify not set");
7652 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7654 errmsg ("next hop and next-hop via label set");
7657 if (address_set == 0)
7659 errmsg ("missing addresses");
7663 if (address_length_set == 0)
7665 errmsg ("missing address length");
7669 /* Generate a pile of unique, random routes */
7672 u32 this_random_address;
7673 random_hash = hash_create (count, sizeof (uword));
7675 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7676 for (j = 0; j <= count; j++)
7680 this_random_address = random_u32 (&random_seed);
7681 this_random_address =
7682 clib_host_to_net_u32 (this_random_address);
7684 while (hash_get (random_hash, this_random_address));
7685 vec_add1 (random_vector, this_random_address);
7686 hash_set (random_hash, this_random_address, 1);
7688 hash_free (random_hash);
7689 v4_dst_address.as_u32 = random_vector[0];
7694 /* Turn on async mode */
7695 vam->async_mode = 1;
7696 vam->async_errors = 0;
7697 before = vat_time_now (vam);
7700 for (j = 0; j < count; j++)
7702 /* Construct the API message */
7703 M2 (IP_ADD_DEL_ROUTE, mp,
7704 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7706 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7707 mp->table_id = ntohl (vrf_id);
7708 mp->create_vrf_if_needed = create_vrf_if_needed;
7710 mp->is_add = is_add;
7711 mp->is_drop = is_drop;
7712 mp->is_unreach = is_unreach;
7713 mp->is_prohibit = is_prohibit;
7714 mp->is_ipv6 = is_ipv6;
7715 mp->is_local = is_local;
7716 mp->is_classify = is_classify;
7717 mp->is_multipath = is_multipath;
7718 mp->is_resolve_host = resolve_host;
7719 mp->is_resolve_attached = resolve_attached;
7720 mp->not_last = not_last;
7721 mp->next_hop_weight = next_hop_weight;
7722 mp->dst_address_length = dst_address_length;
7723 mp->next_hop_table_id = ntohl (next_hop_table_id);
7724 mp->classify_table_index = ntohl (classify_table_index);
7725 mp->next_hop_via_label = ntohl (next_hop_via_label);
7726 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7727 if (0 != mp->next_hop_n_out_labels)
7729 memcpy (mp->next_hop_out_label_stack,
7730 next_hop_out_label_stack,
7731 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7732 vec_free (next_hop_out_label_stack);
7737 clib_memcpy (mp->dst_address, &v6_dst_address,
7738 sizeof (v6_dst_address));
7740 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
7741 sizeof (v6_next_hop_address));
7742 increment_v6_address (&v6_dst_address);
7746 clib_memcpy (mp->dst_address, &v4_dst_address,
7747 sizeof (v4_dst_address));
7749 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
7750 sizeof (v4_next_hop_address));
7752 v4_dst_address.as_u32 = random_vector[j + 1];
7754 increment_v4_address (&v4_dst_address);
7758 /* If we receive SIGTERM, stop now... */
7763 /* When testing multiple add/del ops, use a control-ping to sync */
7766 vl_api_control_ping_t *mp_ping;
7770 /* Shut off async mode */
7771 vam->async_mode = 0;
7773 MPING (CONTROL_PING, mp_ping);
7776 timeout = vat_time_now (vam) + 1.0;
7777 while (vat_time_now (vam) < timeout)
7778 if (vam->result_ready == 1)
7783 if (vam->retval == -99)
7786 if (vam->async_errors > 0)
7788 errmsg ("%d asynchronous errors", vam->async_errors);
7791 vam->async_errors = 0;
7792 after = vat_time_now (vam);
7794 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7798 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7799 count, after - before, count / (after - before));
7805 /* Wait for a reply... */
7810 /* Return the good/bad news */
7811 return (vam->retval);
7815 api_ip_mroute_add_del (vat_main_t * vam)
7817 unformat_input_t *i = vam->input;
7818 vl_api_ip_mroute_add_del_t *mp;
7819 u32 sw_if_index = ~0, vrf_id = 0;
7822 u8 create_vrf_if_needed = 0;
7825 u32 grp_address_length = 0;
7826 ip4_address_t v4_grp_address, v4_src_address;
7827 ip6_address_t v6_grp_address, v6_src_address;
7828 mfib_itf_flags_t iflags = 0;
7829 mfib_entry_flags_t eflags = 0;
7832 /* Parse args required to build the message */
7833 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7835 if (unformat (i, "sw_if_index %d", &sw_if_index))
7837 else if (unformat (i, "%U %U",
7838 unformat_ip4_address, &v4_src_address,
7839 unformat_ip4_address, &v4_grp_address))
7841 grp_address_length = 64;
7845 else if (unformat (i, "%U %U",
7846 unformat_ip6_address, &v6_src_address,
7847 unformat_ip6_address, &v6_grp_address))
7849 grp_address_length = 256;
7853 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7855 memset (&v4_src_address, 0, sizeof (v4_src_address));
7856 grp_address_length = 32;
7860 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7862 memset (&v6_src_address, 0, sizeof (v6_src_address));
7863 grp_address_length = 128;
7867 else if (unformat (i, "/%d", &grp_address_length))
7869 else if (unformat (i, "local"))
7873 else if (unformat (i, "del"))
7875 else if (unformat (i, "add"))
7877 else if (unformat (i, "vrf %d", &vrf_id))
7879 else if (unformat (i, "create-vrf"))
7880 create_vrf_if_needed = 1;
7881 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
7883 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7887 clib_warning ("parse error '%U'", format_unformat_error, i);
7892 if (address_set == 0)
7894 errmsg ("missing addresses\n");
7898 /* Construct the API message */
7899 M (IP_MROUTE_ADD_DEL, mp);
7901 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7902 mp->table_id = ntohl (vrf_id);
7903 mp->create_vrf_if_needed = create_vrf_if_needed;
7905 mp->is_add = is_add;
7906 mp->is_ipv6 = is_ipv6;
7907 mp->is_local = is_local;
7908 mp->itf_flags = ntohl (iflags);
7909 mp->entry_flags = ntohl (eflags);
7910 mp->grp_address_length = grp_address_length;
7911 mp->grp_address_length = ntohs (mp->grp_address_length);
7915 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7916 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7920 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7921 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7927 /* Wait for a reply... */
7933 api_mpls_table_add_del (vat_main_t * vam)
7935 unformat_input_t *i = vam->input;
7936 vl_api_mpls_table_add_del_t *mp;
7941 /* Parse args required to build the message */
7942 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7944 if (unformat (i, "table %d", &table_id))
7946 else if (unformat (i, "del"))
7948 else if (unformat (i, "add"))
7952 clib_warning ("parse error '%U'", format_unformat_error, i);
7959 errmsg ("missing table-ID");
7963 /* Construct the API message */
7964 M (MPLS_TABLE_ADD_DEL, mp);
7966 mp->mt_table_id = ntohl (table_id);
7967 mp->mt_is_add = is_add;
7972 /* Wait for a reply... */
7979 api_mpls_route_add_del (vat_main_t * vam)
7981 unformat_input_t *i = vam->input;
7982 vl_api_mpls_route_add_del_t *mp;
7983 u32 sw_if_index = ~0, table_id = 0;
7984 u8 create_table_if_needed = 0;
7986 u32 next_hop_weight = 1;
7987 u8 is_multipath = 0;
7988 u32 next_hop_table_id = 0;
7989 u8 next_hop_set = 0;
7990 ip4_address_t v4_next_hop_address = {
7993 ip6_address_t v6_next_hop_address = { {0} };
7997 u32 classify_table_index = ~0;
7999 u8 resolve_host = 0, resolve_attached = 0;
8000 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8001 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8002 mpls_label_t *next_hop_out_label_stack = NULL;
8003 mpls_label_t local_label = MPLS_LABEL_INVALID;
8005 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8007 /* Parse args required to build the message */
8008 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8010 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8012 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8014 else if (unformat (i, "%d", &local_label))
8016 else if (unformat (i, "eos"))
8018 else if (unformat (i, "non-eos"))
8020 else if (unformat (i, "via %U", unformat_ip4_address,
8021 &v4_next_hop_address))
8024 next_hop_proto = DPO_PROTO_IP4;
8026 else if (unformat (i, "via %U", unformat_ip6_address,
8027 &v6_next_hop_address))
8030 next_hop_proto = DPO_PROTO_IP6;
8032 else if (unformat (i, "weight %d", &next_hop_weight))
8034 else if (unformat (i, "create-table"))
8035 create_table_if_needed = 1;
8036 else if (unformat (i, "classify %d", &classify_table_index))
8040 else if (unformat (i, "del"))
8042 else if (unformat (i, "add"))
8044 else if (unformat (i, "resolve-via-host"))
8046 else if (unformat (i, "resolve-via-attached"))
8047 resolve_attached = 1;
8048 else if (unformat (i, "multipath"))
8050 else if (unformat (i, "count %d", &count))
8052 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8055 next_hop_proto = DPO_PROTO_IP4;
8057 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8060 next_hop_proto = DPO_PROTO_IP6;
8062 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8064 else if (unformat (i, "via-label %d", &next_hop_via_label))
8066 else if (unformat (i, "out-label %d", &next_hop_out_label))
8067 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8070 clib_warning ("parse error '%U'", format_unformat_error, i);
8075 if (!next_hop_set && !is_classify)
8077 errmsg ("next hop / classify not set");
8081 if (MPLS_LABEL_INVALID == local_label)
8083 errmsg ("missing label");
8089 /* Turn on async mode */
8090 vam->async_mode = 1;
8091 vam->async_errors = 0;
8092 before = vat_time_now (vam);
8095 for (j = 0; j < count; j++)
8097 /* Construct the API message */
8098 M2 (MPLS_ROUTE_ADD_DEL, mp,
8099 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8101 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8102 mp->mr_table_id = ntohl (table_id);
8103 mp->mr_create_table_if_needed = create_table_if_needed;
8105 mp->mr_is_add = is_add;
8106 mp->mr_next_hop_proto = next_hop_proto;
8107 mp->mr_is_classify = is_classify;
8108 mp->mr_is_multipath = is_multipath;
8109 mp->mr_is_resolve_host = resolve_host;
8110 mp->mr_is_resolve_attached = resolve_attached;
8111 mp->mr_next_hop_weight = next_hop_weight;
8112 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8113 mp->mr_classify_table_index = ntohl (classify_table_index);
8114 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8115 mp->mr_label = ntohl (local_label);
8116 mp->mr_eos = is_eos;
8118 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8119 if (0 != mp->mr_next_hop_n_out_labels)
8121 memcpy (mp->mr_next_hop_out_label_stack,
8122 next_hop_out_label_stack,
8123 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8124 vec_free (next_hop_out_label_stack);
8129 if (DPO_PROTO_IP4 == next_hop_proto)
8131 clib_memcpy (mp->mr_next_hop,
8132 &v4_next_hop_address,
8133 sizeof (v4_next_hop_address));
8135 else if (DPO_PROTO_IP6 == next_hop_proto)
8138 clib_memcpy (mp->mr_next_hop,
8139 &v6_next_hop_address,
8140 sizeof (v6_next_hop_address));
8147 /* If we receive SIGTERM, stop now... */
8152 /* When testing multiple add/del ops, use a control-ping to sync */
8155 vl_api_control_ping_t *mp_ping;
8159 /* Shut off async mode */
8160 vam->async_mode = 0;
8162 MPING (CONTROL_PING, mp_ping);
8165 timeout = vat_time_now (vam) + 1.0;
8166 while (vat_time_now (vam) < timeout)
8167 if (vam->result_ready == 1)
8172 if (vam->retval == -99)
8175 if (vam->async_errors > 0)
8177 errmsg ("%d asynchronous errors", vam->async_errors);
8180 vam->async_errors = 0;
8181 after = vat_time_now (vam);
8183 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8187 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8188 count, after - before, count / (after - before));
8194 /* Wait for a reply... */
8199 /* Return the good/bad news */
8200 return (vam->retval);
8204 api_mpls_ip_bind_unbind (vat_main_t * vam)
8206 unformat_input_t *i = vam->input;
8207 vl_api_mpls_ip_bind_unbind_t *mp;
8208 u32 ip_table_id = 0;
8209 u8 create_table_if_needed = 0;
8212 ip4_address_t v4_address;
8213 ip6_address_t v6_address;
8216 mpls_label_t local_label = MPLS_LABEL_INVALID;
8219 /* Parse args required to build the message */
8220 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8222 if (unformat (i, "%U/%d", unformat_ip4_address,
8223 &v4_address, &address_length))
8228 else if (unformat (i, "%U/%d", unformat_ip6_address,
8229 &v6_address, &address_length))
8234 else if (unformat (i, "%d", &local_label))
8236 else if (unformat (i, "create-table"))
8237 create_table_if_needed = 1;
8238 else if (unformat (i, "table-id %d", &ip_table_id))
8240 else if (unformat (i, "unbind"))
8242 else if (unformat (i, "bind"))
8246 clib_warning ("parse error '%U'", format_unformat_error, i);
8253 errmsg ("IP addres not set");
8257 if (MPLS_LABEL_INVALID == local_label)
8259 errmsg ("missing label");
8263 /* Construct the API message */
8264 M (MPLS_IP_BIND_UNBIND, mp);
8266 mp->mb_create_table_if_needed = create_table_if_needed;
8267 mp->mb_is_bind = is_bind;
8268 mp->mb_is_ip4 = is_ip4;
8269 mp->mb_ip_table_id = ntohl (ip_table_id);
8270 mp->mb_mpls_table_id = 0;
8271 mp->mb_label = ntohl (local_label);
8272 mp->mb_address_length = address_length;
8275 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8277 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8282 /* Wait for a reply... */
8288 api_proxy_arp_add_del (vat_main_t * vam)
8290 unformat_input_t *i = vam->input;
8291 vl_api_proxy_arp_add_del_t *mp;
8294 ip4_address_t lo, hi;
8298 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8300 if (unformat (i, "vrf %d", &vrf_id))
8302 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
8303 unformat_ip4_address, &hi))
8305 else if (unformat (i, "del"))
8309 clib_warning ("parse error '%U'", format_unformat_error, i);
8316 errmsg ("address range not set");
8320 M (PROXY_ARP_ADD_DEL, mp);
8322 mp->vrf_id = ntohl (vrf_id);
8323 mp->is_add = is_add;
8324 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
8325 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
8333 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8335 unformat_input_t *i = vam->input;
8336 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8339 u8 sw_if_index_set = 0;
8342 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8344 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8345 sw_if_index_set = 1;
8346 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8347 sw_if_index_set = 1;
8348 else if (unformat (i, "enable"))
8350 else if (unformat (i, "disable"))
8354 clib_warning ("parse error '%U'", format_unformat_error, i);
8359 if (sw_if_index_set == 0)
8361 errmsg ("missing interface name or sw_if_index");
8365 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8367 mp->sw_if_index = ntohl (sw_if_index);
8368 mp->enable_disable = enable;
8376 api_mpls_tunnel_add_del (vat_main_t * vam)
8378 unformat_input_t *i = vam->input;
8379 vl_api_mpls_tunnel_add_del_t *mp;
8383 u32 sw_if_index = ~0;
8384 u32 next_hop_sw_if_index = ~0;
8385 u32 next_hop_proto_is_ip4 = 1;
8387 u32 next_hop_table_id = 0;
8388 ip4_address_t v4_next_hop_address = {
8391 ip6_address_t v6_next_hop_address = { {0} };
8392 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
8395 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8397 if (unformat (i, "add"))
8399 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8401 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
8403 else if (unformat (i, "via %U",
8404 unformat_ip4_address, &v4_next_hop_address))
8406 next_hop_proto_is_ip4 = 1;
8408 else if (unformat (i, "via %U",
8409 unformat_ip6_address, &v6_next_hop_address))
8411 next_hop_proto_is_ip4 = 0;
8413 else if (unformat (i, "l2-only"))
8415 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8417 else if (unformat (i, "out-label %d", &next_hop_out_label))
8418 vec_add1 (labels, ntohl (next_hop_out_label));
8421 clib_warning ("parse error '%U'", format_unformat_error, i);
8426 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
8428 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
8429 mp->mt_sw_if_index = ntohl (sw_if_index);
8430 mp->mt_is_add = is_add;
8431 mp->mt_l2_only = l2_only;
8432 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
8433 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
8435 mp->mt_next_hop_n_out_labels = vec_len (labels);
8437 if (0 != mp->mt_next_hop_n_out_labels)
8439 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
8440 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
8444 if (next_hop_proto_is_ip4)
8446 clib_memcpy (mp->mt_next_hop,
8447 &v4_next_hop_address, sizeof (v4_next_hop_address));
8451 clib_memcpy (mp->mt_next_hop,
8452 &v6_next_hop_address, sizeof (v6_next_hop_address));
8461 api_sw_interface_set_unnumbered (vat_main_t * vam)
8463 unformat_input_t *i = vam->input;
8464 vl_api_sw_interface_set_unnumbered_t *mp;
8466 u32 unnum_sw_index = ~0;
8468 u8 sw_if_index_set = 0;
8471 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8473 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8474 sw_if_index_set = 1;
8475 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8476 sw_if_index_set = 1;
8477 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8479 else if (unformat (i, "del"))
8483 clib_warning ("parse error '%U'", format_unformat_error, i);
8488 if (sw_if_index_set == 0)
8490 errmsg ("missing interface name or sw_if_index");
8494 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8496 mp->sw_if_index = ntohl (sw_if_index);
8497 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8498 mp->is_add = is_add;
8506 api_ip_neighbor_add_del (vat_main_t * vam)
8508 unformat_input_t *i = vam->input;
8509 vl_api_ip_neighbor_add_del_t *mp;
8511 u8 sw_if_index_set = 0;
8514 u8 is_no_fib_entry = 0;
8517 u8 v4_address_set = 0;
8518 u8 v6_address_set = 0;
8519 ip4_address_t v4address;
8520 ip6_address_t v6address;
8523 memset (mac_address, 0, sizeof (mac_address));
8525 /* Parse args required to build the message */
8526 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8528 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8532 else if (unformat (i, "del"))
8535 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8536 sw_if_index_set = 1;
8537 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8538 sw_if_index_set = 1;
8539 else if (unformat (i, "is_static"))
8541 else if (unformat (i, "no-fib-entry"))
8542 is_no_fib_entry = 1;
8543 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
8545 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
8549 clib_warning ("parse error '%U'", format_unformat_error, i);
8554 if (sw_if_index_set == 0)
8556 errmsg ("missing interface name or sw_if_index");
8559 if (v4_address_set && v6_address_set)
8561 errmsg ("both v4 and v6 addresses set");
8564 if (!v4_address_set && !v6_address_set)
8566 errmsg ("no address set");
8570 /* Construct the API message */
8571 M (IP_NEIGHBOR_ADD_DEL, mp);
8573 mp->sw_if_index = ntohl (sw_if_index);
8574 mp->is_add = is_add;
8575 mp->is_static = is_static;
8576 mp->is_no_adj_fib = is_no_fib_entry;
8578 clib_memcpy (mp->mac_address, mac_address, 6);
8582 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
8586 /* mp->is_ipv6 = 0; via memset in M macro above */
8587 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
8593 /* Wait for a reply, return good/bad news */
8599 api_reset_vrf (vat_main_t * vam)
8601 unformat_input_t *i = vam->input;
8602 vl_api_reset_vrf_t *mp;
8608 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8610 if (unformat (i, "vrf %d", &vrf_id))
8612 else if (unformat (i, "ipv6"))
8616 clib_warning ("parse error '%U'", format_unformat_error, i);
8621 if (vrf_id_set == 0)
8623 errmsg ("missing vrf id");
8629 mp->vrf_id = ntohl (vrf_id);
8630 mp->is_ipv6 = is_ipv6;
8638 api_create_vlan_subif (vat_main_t * vam)
8640 unformat_input_t *i = vam->input;
8641 vl_api_create_vlan_subif_t *mp;
8643 u8 sw_if_index_set = 0;
8648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8650 if (unformat (i, "sw_if_index %d", &sw_if_index))
8651 sw_if_index_set = 1;
8653 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8654 sw_if_index_set = 1;
8655 else if (unformat (i, "vlan %d", &vlan_id))
8659 clib_warning ("parse error '%U'", format_unformat_error, i);
8664 if (sw_if_index_set == 0)
8666 errmsg ("missing interface name or sw_if_index");
8670 if (vlan_id_set == 0)
8672 errmsg ("missing vlan_id");
8675 M (CREATE_VLAN_SUBIF, mp);
8677 mp->sw_if_index = ntohl (sw_if_index);
8678 mp->vlan_id = ntohl (vlan_id);
8685 #define foreach_create_subif_bit \
8692 _(outer_vlan_id_any) \
8693 _(inner_vlan_id_any)
8696 api_create_subif (vat_main_t * vam)
8698 unformat_input_t *i = vam->input;
8699 vl_api_create_subif_t *mp;
8701 u8 sw_if_index_set = 0;
8708 u32 exact_match = 0;
8709 u32 default_sub = 0;
8710 u32 outer_vlan_id_any = 0;
8711 u32 inner_vlan_id_any = 0;
8713 u16 outer_vlan_id = 0;
8714 u16 inner_vlan_id = 0;
8717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8719 if (unformat (i, "sw_if_index %d", &sw_if_index))
8720 sw_if_index_set = 1;
8722 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8723 sw_if_index_set = 1;
8724 else if (unformat (i, "sub_id %d", &sub_id))
8726 else if (unformat (i, "outer_vlan_id %d", &tmp))
8727 outer_vlan_id = tmp;
8728 else if (unformat (i, "inner_vlan_id %d", &tmp))
8729 inner_vlan_id = tmp;
8731 #define _(a) else if (unformat (i, #a)) a = 1 ;
8732 foreach_create_subif_bit
8736 clib_warning ("parse error '%U'", format_unformat_error, i);
8741 if (sw_if_index_set == 0)
8743 errmsg ("missing interface name or sw_if_index");
8747 if (sub_id_set == 0)
8749 errmsg ("missing sub_id");
8752 M (CREATE_SUBIF, mp);
8754 mp->sw_if_index = ntohl (sw_if_index);
8755 mp->sub_id = ntohl (sub_id);
8757 #define _(a) mp->a = a;
8758 foreach_create_subif_bit;
8761 mp->outer_vlan_id = ntohs (outer_vlan_id);
8762 mp->inner_vlan_id = ntohs (inner_vlan_id);
8770 api_oam_add_del (vat_main_t * vam)
8772 unformat_input_t *i = vam->input;
8773 vl_api_oam_add_del_t *mp;
8776 ip4_address_t src, dst;
8781 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8783 if (unformat (i, "vrf %d", &vrf_id))
8785 else if (unformat (i, "src %U", unformat_ip4_address, &src))
8787 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
8789 else if (unformat (i, "del"))
8793 clib_warning ("parse error '%U'", format_unformat_error, i);
8800 errmsg ("missing src addr");
8806 errmsg ("missing dst addr");
8810 M (OAM_ADD_DEL, mp);
8812 mp->vrf_id = ntohl (vrf_id);
8813 mp->is_add = is_add;
8814 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
8815 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
8823 api_reset_fib (vat_main_t * vam)
8825 unformat_input_t *i = vam->input;
8826 vl_api_reset_fib_t *mp;
8832 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8834 if (unformat (i, "vrf %d", &vrf_id))
8836 else if (unformat (i, "ipv6"))
8840 clib_warning ("parse error '%U'", format_unformat_error, i);
8845 if (vrf_id_set == 0)
8847 errmsg ("missing vrf id");
8853 mp->vrf_id = ntohl (vrf_id);
8854 mp->is_ipv6 = is_ipv6;
8862 api_dhcp_proxy_config (vat_main_t * vam)
8864 unformat_input_t *i = vam->input;
8865 vl_api_dhcp_proxy_config_t *mp;
8867 u32 server_vrf_id = 0;
8869 u8 v4_address_set = 0;
8870 u8 v6_address_set = 0;
8871 ip4_address_t v4address;
8872 ip6_address_t v6address;
8873 u8 v4_src_address_set = 0;
8874 u8 v6_src_address_set = 0;
8875 ip4_address_t v4srcaddress;
8876 ip6_address_t v6srcaddress;
8879 /* Parse args required to build the message */
8880 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8882 if (unformat (i, "del"))
8884 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
8886 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
8888 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
8890 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
8892 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
8893 v4_src_address_set = 1;
8894 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
8895 v6_src_address_set = 1;
8900 if (v4_address_set && v6_address_set)
8902 errmsg ("both v4 and v6 server addresses set");
8905 if (!v4_address_set && !v6_address_set)
8907 errmsg ("no server addresses set");
8911 if (v4_src_address_set && v6_src_address_set)
8913 errmsg ("both v4 and v6 src addresses set");
8916 if (!v4_src_address_set && !v6_src_address_set)
8918 errmsg ("no src addresses set");
8922 if (!(v4_src_address_set && v4_address_set) &&
8923 !(v6_src_address_set && v6_address_set))
8925 errmsg ("no matching server and src addresses set");
8929 /* Construct the API message */
8930 M (DHCP_PROXY_CONFIG, mp);
8932 mp->is_add = is_add;
8933 mp->rx_vrf_id = ntohl (rx_vrf_id);
8934 mp->server_vrf_id = ntohl (server_vrf_id);
8938 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
8939 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
8943 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
8944 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
8950 /* Wait for a reply, return good/bad news */
8955 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
8956 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
8959 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
8961 vat_main_t *vam = &vat_main;
8962 u32 i, count = mp->count;
8963 vl_api_dhcp_server_t *s;
8967 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8968 ntohl (mp->rx_vrf_id),
8969 format_ip6_address, mp->dhcp_src_address,
8970 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8973 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8974 ntohl (mp->rx_vrf_id),
8975 format_ip4_address, mp->dhcp_src_address,
8976 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8978 for (i = 0; i < count; i++)
8980 s = &mp->servers[i];
8984 " Server Table-ID %d, Server Address %U",
8985 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
8988 " Server Table-ID %d, Server Address %U",
8989 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
8993 static void vl_api_dhcp_proxy_details_t_handler_json
8994 (vl_api_dhcp_proxy_details_t * mp)
8996 vat_main_t *vam = &vat_main;
8997 vat_json_node_t *node = NULL;
8998 u32 i, count = mp->count;
9000 struct in6_addr ip6;
9001 vl_api_dhcp_server_t *s;
9003 if (VAT_JSON_ARRAY != vam->json_tree.type)
9005 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9006 vat_json_init_array (&vam->json_tree);
9008 node = vat_json_array_add (&vam->json_tree);
9010 vat_json_init_object (node);
9011 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9012 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9013 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9017 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9018 vat_json_object_add_ip6 (node, "src_address", ip6);
9022 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9023 vat_json_object_add_ip4 (node, "src_address", ip4);
9026 for (i = 0; i < count; i++)
9028 s = &mp->servers[i];
9030 vat_json_object_add_uint (node, "server-table-id",
9031 ntohl (s->server_vrf_id));
9035 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9036 vat_json_object_add_ip4 (node, "src_address", ip4);
9040 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9041 vat_json_object_add_ip6 (node, "server_address", ip6);
9047 api_dhcp_proxy_dump (vat_main_t * vam)
9049 unformat_input_t *i = vam->input;
9050 vl_api_control_ping_t *mp_ping;
9051 vl_api_dhcp_proxy_dump_t *mp;
9055 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9057 if (unformat (i, "ipv6"))
9061 clib_warning ("parse error '%U'", format_unformat_error, i);
9066 M (DHCP_PROXY_DUMP, mp);
9068 mp->is_ip6 = is_ipv6;
9071 /* Use a control ping for synchronization */
9072 MPING (CONTROL_PING, mp_ping);
9080 api_dhcp_proxy_set_vss (vat_main_t * vam)
9082 unformat_input_t *i = vam->input;
9083 vl_api_dhcp_proxy_set_vss_t *mp;
9094 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9096 if (unformat (i, "tbl_id %d", &tbl_id))
9098 if (unformat (i, "fib_id %d", &fib_id))
9100 if (unformat (i, "oui %d", &oui))
9102 else if (unformat (i, "ipv6"))
9104 else if (unformat (i, "del"))
9108 clib_warning ("parse error '%U'", format_unformat_error, i);
9113 if (tbl_id_set == 0)
9115 errmsg ("missing tbl id");
9119 if (fib_id_set == 0)
9121 errmsg ("missing fib id");
9126 errmsg ("missing oui");
9130 M (DHCP_PROXY_SET_VSS, mp);
9131 mp->tbl_id = ntohl (tbl_id);
9132 mp->fib_id = ntohl (fib_id);
9133 mp->oui = ntohl (oui);
9134 mp->is_ipv6 = is_ipv6;
9135 mp->is_add = is_add;
9143 api_dhcp_client_config (vat_main_t * vam)
9145 unformat_input_t *i = vam->input;
9146 vl_api_dhcp_client_config_t *mp;
9148 u8 sw_if_index_set = 0;
9151 u8 disable_event = 0;
9154 /* Parse args required to build the message */
9155 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9157 if (unformat (i, "del"))
9160 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9161 sw_if_index_set = 1;
9162 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9163 sw_if_index_set = 1;
9164 else if (unformat (i, "hostname %s", &hostname))
9166 else if (unformat (i, "disable_event"))
9172 if (sw_if_index_set == 0)
9174 errmsg ("missing interface name or sw_if_index");
9178 if (vec_len (hostname) > 63)
9180 errmsg ("hostname too long");
9182 vec_add1 (hostname, 0);
9184 /* Construct the API message */
9185 M (DHCP_CLIENT_CONFIG, mp);
9187 mp->sw_if_index = htonl (sw_if_index);
9188 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
9189 vec_free (hostname);
9190 mp->is_add = is_add;
9191 mp->want_dhcp_event = disable_event ? 0 : 1;
9192 mp->pid = htonl (getpid ());
9197 /* Wait for a reply, return good/bad news */
9203 api_set_ip_flow_hash (vat_main_t * vam)
9205 unformat_input_t *i = vam->input;
9206 vl_api_set_ip_flow_hash_t *mp;
9218 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9220 if (unformat (i, "vrf %d", &vrf_id))
9222 else if (unformat (i, "ipv6"))
9224 else if (unformat (i, "src"))
9226 else if (unformat (i, "dst"))
9228 else if (unformat (i, "sport"))
9230 else if (unformat (i, "dport"))
9232 else if (unformat (i, "proto"))
9234 else if (unformat (i, "reverse"))
9239 clib_warning ("parse error '%U'", format_unformat_error, i);
9244 if (vrf_id_set == 0)
9246 errmsg ("missing vrf id");
9250 M (SET_IP_FLOW_HASH, mp);
9256 mp->reverse = reverse;
9257 mp->vrf_id = ntohl (vrf_id);
9258 mp->is_ipv6 = is_ipv6;
9266 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9268 unformat_input_t *i = vam->input;
9269 vl_api_sw_interface_ip6_enable_disable_t *mp;
9271 u8 sw_if_index_set = 0;
9275 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9277 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9278 sw_if_index_set = 1;
9279 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9280 sw_if_index_set = 1;
9281 else if (unformat (i, "enable"))
9283 else if (unformat (i, "disable"))
9287 clib_warning ("parse error '%U'", format_unformat_error, i);
9292 if (sw_if_index_set == 0)
9294 errmsg ("missing interface name or sw_if_index");
9298 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9300 mp->sw_if_index = ntohl (sw_if_index);
9301 mp->enable = enable;
9309 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
9311 unformat_input_t *i = vam->input;
9312 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
9314 u8 sw_if_index_set = 0;
9315 u8 v6_address_set = 0;
9316 ip6_address_t v6address;
9319 /* Parse args required to build the message */
9320 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9322 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9323 sw_if_index_set = 1;
9324 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9325 sw_if_index_set = 1;
9326 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9332 if (sw_if_index_set == 0)
9334 errmsg ("missing interface name or sw_if_index");
9337 if (!v6_address_set)
9339 errmsg ("no address set");
9343 /* Construct the API message */
9344 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
9346 mp->sw_if_index = ntohl (sw_if_index);
9347 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9352 /* Wait for a reply, return good/bad news */
9358 api_ip6nd_proxy_add_del (vat_main_t * vam)
9360 unformat_input_t *i = vam->input;
9361 vl_api_ip6nd_proxy_add_del_t *mp;
9362 u32 sw_if_index = ~0;
9363 u8 v6_address_set = 0;
9364 ip6_address_t v6address;
9368 /* Parse args required to build the message */
9369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9371 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9373 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9375 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9377 if (unformat (i, "del"))
9381 clib_warning ("parse error '%U'", format_unformat_error, i);
9386 if (sw_if_index == ~0)
9388 errmsg ("missing interface name or sw_if_index");
9391 if (!v6_address_set)
9393 errmsg ("no address set");
9397 /* Construct the API message */
9398 M (IP6ND_PROXY_ADD_DEL, mp);
9400 mp->is_del = is_del;
9401 mp->sw_if_index = ntohl (sw_if_index);
9402 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9407 /* Wait for a reply, return good/bad news */
9413 api_ip6nd_proxy_dump (vat_main_t * vam)
9415 vl_api_ip6nd_proxy_dump_t *mp;
9416 vl_api_control_ping_t *mp_ping;
9419 M (IP6ND_PROXY_DUMP, mp);
9423 /* Use a control ping for synchronization */
9424 MPING (CONTROL_PING, mp_ping);
9431 static void vl_api_ip6nd_proxy_details_t_handler
9432 (vl_api_ip6nd_proxy_details_t * mp)
9434 vat_main_t *vam = &vat_main;
9436 print (vam->ofp, "host %U sw_if_index %d",
9437 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
9440 static void vl_api_ip6nd_proxy_details_t_handler_json
9441 (vl_api_ip6nd_proxy_details_t * mp)
9443 vat_main_t *vam = &vat_main;
9444 struct in6_addr ip6;
9445 vat_json_node_t *node = NULL;
9447 if (VAT_JSON_ARRAY != vam->json_tree.type)
9449 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9450 vat_json_init_array (&vam->json_tree);
9452 node = vat_json_array_add (&vam->json_tree);
9454 vat_json_init_object (node);
9455 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9457 clib_memcpy (&ip6, mp->address, sizeof (ip6));
9458 vat_json_object_add_ip6 (node, "host", ip6);
9462 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9464 unformat_input_t *i = vam->input;
9465 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9467 u8 sw_if_index_set = 0;
9468 u32 address_length = 0;
9469 u8 v6_address_set = 0;
9470 ip6_address_t v6address;
9472 u8 no_advertise = 0;
9474 u8 no_autoconfig = 0;
9477 u32 val_lifetime = 0;
9478 u32 pref_lifetime = 0;
9481 /* Parse args required to build the message */
9482 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9484 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9485 sw_if_index_set = 1;
9486 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9487 sw_if_index_set = 1;
9488 else if (unformat (i, "%U/%d",
9489 unformat_ip6_address, &v6address, &address_length))
9491 else if (unformat (i, "val_life %d", &val_lifetime))
9493 else if (unformat (i, "pref_life %d", &pref_lifetime))
9495 else if (unformat (i, "def"))
9497 else if (unformat (i, "noadv"))
9499 else if (unformat (i, "offl"))
9501 else if (unformat (i, "noauto"))
9503 else if (unformat (i, "nolink"))
9505 else if (unformat (i, "isno"))
9509 clib_warning ("parse error '%U'", format_unformat_error, i);
9514 if (sw_if_index_set == 0)
9516 errmsg ("missing interface name or sw_if_index");
9519 if (!v6_address_set)
9521 errmsg ("no address set");
9525 /* Construct the API message */
9526 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9528 mp->sw_if_index = ntohl (sw_if_index);
9529 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9530 mp->address_length = address_length;
9531 mp->use_default = use_default;
9532 mp->no_advertise = no_advertise;
9533 mp->off_link = off_link;
9534 mp->no_autoconfig = no_autoconfig;
9535 mp->no_onlink = no_onlink;
9537 mp->val_lifetime = ntohl (val_lifetime);
9538 mp->pref_lifetime = ntohl (pref_lifetime);
9543 /* Wait for a reply, return good/bad news */
9549 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9551 unformat_input_t *i = vam->input;
9552 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9554 u8 sw_if_index_set = 0;
9559 u8 send_unicast = 0;
9562 u8 default_router = 0;
9563 u32 max_interval = 0;
9564 u32 min_interval = 0;
9566 u32 initial_count = 0;
9567 u32 initial_interval = 0;
9571 /* Parse args required to build the message */
9572 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9574 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9575 sw_if_index_set = 1;
9576 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9577 sw_if_index_set = 1;
9578 else if (unformat (i, "maxint %d", &max_interval))
9580 else if (unformat (i, "minint %d", &min_interval))
9582 else if (unformat (i, "life %d", &lifetime))
9584 else if (unformat (i, "count %d", &initial_count))
9586 else if (unformat (i, "interval %d", &initial_interval))
9588 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9590 else if (unformat (i, "managed"))
9592 else if (unformat (i, "other"))
9594 else if (unformat (i, "ll"))
9596 else if (unformat (i, "send"))
9598 else if (unformat (i, "cease"))
9600 else if (unformat (i, "isno"))
9602 else if (unformat (i, "def"))
9606 clib_warning ("parse error '%U'", format_unformat_error, i);
9611 if (sw_if_index_set == 0)
9613 errmsg ("missing interface name or sw_if_index");
9617 /* Construct the API message */
9618 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9620 mp->sw_if_index = ntohl (sw_if_index);
9621 mp->max_interval = ntohl (max_interval);
9622 mp->min_interval = ntohl (min_interval);
9623 mp->lifetime = ntohl (lifetime);
9624 mp->initial_count = ntohl (initial_count);
9625 mp->initial_interval = ntohl (initial_interval);
9626 mp->suppress = suppress;
9627 mp->managed = managed;
9629 mp->ll_option = ll_option;
9630 mp->send_unicast = send_unicast;
9633 mp->default_router = default_router;
9638 /* Wait for a reply, return good/bad news */
9644 api_set_arp_neighbor_limit (vat_main_t * vam)
9646 unformat_input_t *i = vam->input;
9647 vl_api_set_arp_neighbor_limit_t *mp;
9653 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9655 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9657 else if (unformat (i, "ipv6"))
9661 clib_warning ("parse error '%U'", format_unformat_error, i);
9668 errmsg ("missing limit value");
9672 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9674 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9675 mp->is_ipv6 = is_ipv6;
9683 api_l2_patch_add_del (vat_main_t * vam)
9685 unformat_input_t *i = vam->input;
9686 vl_api_l2_patch_add_del_t *mp;
9688 u8 rx_sw_if_index_set = 0;
9690 u8 tx_sw_if_index_set = 0;
9694 /* Parse args required to build the message */
9695 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9697 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9698 rx_sw_if_index_set = 1;
9699 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9700 tx_sw_if_index_set = 1;
9701 else if (unformat (i, "rx"))
9703 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9705 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9707 rx_sw_if_index_set = 1;
9712 else if (unformat (i, "tx"))
9714 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9716 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9718 tx_sw_if_index_set = 1;
9723 else if (unformat (i, "del"))
9729 if (rx_sw_if_index_set == 0)
9731 errmsg ("missing rx interface name or rx_sw_if_index");
9735 if (tx_sw_if_index_set == 0)
9737 errmsg ("missing tx interface name or tx_sw_if_index");
9741 M (L2_PATCH_ADD_DEL, mp);
9743 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9744 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9745 mp->is_add = is_add;
9753 u8 localsid_addr[16];
9762 api_sr_localsid_add_del (vat_main_t * vam)
9764 unformat_input_t *i = vam->input;
9765 vl_api_sr_localsid_add_del_t *mp;
9768 ip6_address_t localsid;
9772 u32 fib_table = ~(u32) 0;
9773 ip6_address_t next_hop;
9775 bool nexthop_set = 0;
9779 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9781 if (unformat (i, "del"))
9783 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9784 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
9786 else if (unformat (i, "behavior %u", &behavior));
9787 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9788 else if (unformat (i, "fib-table %u", &fib_table));
9789 else if (unformat (i, "end.psp %u", &behavior));
9794 M (SR_LOCALSID_ADD_DEL, mp);
9796 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
9798 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
9799 mp->behavior = behavior;
9800 mp->sw_if_index = ntohl (sw_if_index);
9801 mp->fib_table = ntohl (fib_table);
9802 mp->end_psp = end_psp;
9803 mp->is_del = is_del;
9811 api_ioam_enable (vat_main_t * vam)
9813 unformat_input_t *input = vam->input;
9814 vl_api_ioam_enable_t *mp;
9816 int has_trace_option = 0;
9817 int has_pot_option = 0;
9818 int has_seqno_option = 0;
9819 int has_analyse_option = 0;
9822 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9824 if (unformat (input, "trace"))
9825 has_trace_option = 1;
9826 else if (unformat (input, "pot"))
9828 else if (unformat (input, "seqno"))
9829 has_seqno_option = 1;
9830 else if (unformat (input, "analyse"))
9831 has_analyse_option = 1;
9835 M (IOAM_ENABLE, mp);
9836 mp->id = htons (id);
9837 mp->seqno = has_seqno_option;
9838 mp->analyse = has_analyse_option;
9839 mp->pot_enable = has_pot_option;
9840 mp->trace_enable = has_trace_option;
9849 api_ioam_disable (vat_main_t * vam)
9851 vl_api_ioam_disable_t *mp;
9854 M (IOAM_DISABLE, mp);
9860 #define foreach_tcp_proto_field \
9864 #define foreach_udp_proto_field \
9868 #define foreach_ip4_proto_field \
9880 u16 src_port, dst_port;
9883 #if VPP_API_TEST_BUILTIN == 0
9885 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9887 u8 **maskp = va_arg (*args, u8 **);
9889 u8 found_something = 0;
9892 #define _(a) u8 a=0;
9893 foreach_tcp_proto_field;
9896 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9899 #define _(a) else if (unformat (input, #a)) a=1;
9900 foreach_tcp_proto_field
9906 #define _(a) found_something += a;
9907 foreach_tcp_proto_field;
9910 if (found_something == 0)
9913 vec_validate (mask, sizeof (*tcp) - 1);
9915 tcp = (tcp_header_t *) mask;
9917 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
9918 foreach_tcp_proto_field;
9926 unformat_udp_mask (unformat_input_t * input, va_list * args)
9928 u8 **maskp = va_arg (*args, u8 **);
9930 u8 found_something = 0;
9933 #define _(a) u8 a=0;
9934 foreach_udp_proto_field;
9937 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9940 #define _(a) else if (unformat (input, #a)) a=1;
9941 foreach_udp_proto_field
9947 #define _(a) found_something += a;
9948 foreach_udp_proto_field;
9951 if (found_something == 0)
9954 vec_validate (mask, sizeof (*udp) - 1);
9956 udp = (udp_header_t *) mask;
9958 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
9959 foreach_udp_proto_field;
9967 unformat_l4_mask (unformat_input_t * input, va_list * args)
9969 u8 **maskp = va_arg (*args, u8 **);
9970 u16 src_port = 0, dst_port = 0;
9971 tcpudp_header_t *tcpudp;
9973 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9975 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9977 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9979 else if (unformat (input, "src_port"))
9981 else if (unformat (input, "dst_port"))
9987 if (!src_port && !dst_port)
9991 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9993 tcpudp = (tcpudp_header_t *) mask;
9994 tcpudp->src_port = src_port;
9995 tcpudp->dst_port = dst_port;
10003 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10005 u8 **maskp = va_arg (*args, u8 **);
10007 u8 found_something = 0;
10010 #define _(a) u8 a=0;
10011 foreach_ip4_proto_field;
10017 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10019 if (unformat (input, "version"))
10021 else if (unformat (input, "hdr_length"))
10023 else if (unformat (input, "src"))
10025 else if (unformat (input, "dst"))
10027 else if (unformat (input, "proto"))
10030 #define _(a) else if (unformat (input, #a)) a=1;
10031 foreach_ip4_proto_field
10037 #define _(a) found_something += a;
10038 foreach_ip4_proto_field;
10041 if (found_something == 0)
10044 vec_validate (mask, sizeof (*ip) - 1);
10046 ip = (ip4_header_t *) mask;
10048 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10049 foreach_ip4_proto_field;
10052 ip->ip_version_and_header_length = 0;
10055 ip->ip_version_and_header_length |= 0xF0;
10058 ip->ip_version_and_header_length |= 0x0F;
10064 #define foreach_ip6_proto_field \
10067 _(payload_length) \
10072 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10074 u8 **maskp = va_arg (*args, u8 **);
10076 u8 found_something = 0;
10078 u32 ip_version_traffic_class_and_flow_label;
10080 #define _(a) u8 a=0;
10081 foreach_ip6_proto_field;
10084 u8 traffic_class = 0;
10087 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10089 if (unformat (input, "version"))
10091 else if (unformat (input, "traffic-class"))
10093 else if (unformat (input, "flow-label"))
10095 else if (unformat (input, "src"))
10097 else if (unformat (input, "dst"))
10099 else if (unformat (input, "proto"))
10102 #define _(a) else if (unformat (input, #a)) a=1;
10103 foreach_ip6_proto_field
10109 #define _(a) found_something += a;
10110 foreach_ip6_proto_field;
10113 if (found_something == 0)
10116 vec_validate (mask, sizeof (*ip) - 1);
10118 ip = (ip6_header_t *) mask;
10120 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10121 foreach_ip6_proto_field;
10124 ip_version_traffic_class_and_flow_label = 0;
10127 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10130 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10133 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10135 ip->ip_version_traffic_class_and_flow_label =
10136 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10143 unformat_l3_mask (unformat_input_t * input, va_list * args)
10145 u8 **maskp = va_arg (*args, u8 **);
10147 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10149 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10151 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10160 unformat_l2_mask (unformat_input_t * input, va_list * args)
10162 u8 **maskp = va_arg (*args, u8 **);
10169 u8 ignore_tag1 = 0;
10170 u8 ignore_tag2 = 0;
10177 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10179 if (unformat (input, "src"))
10181 else if (unformat (input, "dst"))
10183 else if (unformat (input, "proto"))
10185 else if (unformat (input, "tag1"))
10187 else if (unformat (input, "tag2"))
10189 else if (unformat (input, "ignore-tag1"))
10191 else if (unformat (input, "ignore-tag2"))
10193 else if (unformat (input, "cos1"))
10195 else if (unformat (input, "cos2"))
10197 else if (unformat (input, "dot1q"))
10199 else if (unformat (input, "dot1ad"))
10204 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10205 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10208 if (tag1 || ignore_tag1 || cos1 || dot1q)
10210 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10213 vec_validate (mask, len - 1);
10216 memset (mask, 0xff, 6);
10219 memset (mask + 6, 0xff, 6);
10221 if (tag2 || dot1ad)
10223 /* inner vlan tag */
10232 mask[21] = mask[20] = 0xff;
10253 mask[16] = mask[17] = 0xff;
10263 mask[12] = mask[13] = 0xff;
10270 unformat_classify_mask (unformat_input_t * input, va_list * args)
10272 u8 **maskp = va_arg (*args, u8 **);
10273 u32 *skipp = va_arg (*args, u32 *);
10274 u32 *matchp = va_arg (*args, u32 *);
10282 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10284 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10286 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10288 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10290 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10304 if (mask || l2 || l3 || l4)
10306 if (l2 || l3 || l4)
10308 /* "With a free Ethernet header in every package" */
10310 vec_validate (l2, 13);
10314 vec_append (mask, l3);
10319 vec_append (mask, l4);
10324 /* Scan forward looking for the first significant mask octet */
10325 for (i = 0; i < vec_len (mask); i++)
10329 /* compute (skip, match) params */
10330 *skipp = i / sizeof (u32x4);
10331 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10333 /* Pad mask to an even multiple of the vector size */
10334 while (vec_len (mask) % sizeof (u32x4))
10335 vec_add1 (mask, 0);
10337 match = vec_len (mask) / sizeof (u32x4);
10339 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10341 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10342 if (*tmp || *(tmp + 1))
10347 clib_warning ("BUG: match 0");
10349 _vec_len (mask) = match * sizeof (u32x4);
10359 #endif /* VPP_API_TEST_BUILTIN */
10361 #define foreach_l2_next \
10363 _(ethernet, ETHERNET_INPUT) \
10364 _(ip4, IP4_INPUT) \
10368 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10370 u32 *miss_next_indexp = va_arg (*args, u32 *);
10371 u32 next_index = 0;
10375 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10379 if (unformat (input, "%d", &tmp))
10388 *miss_next_indexp = next_index;
10392 #define foreach_ip_next \
10395 _(rewrite, REWRITE)
10398 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10400 u32 *miss_next_indexp = va_arg (*args, u32 *);
10401 u32 next_index = 0;
10405 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10409 if (unformat (input, "%d", &tmp))
10418 *miss_next_indexp = next_index;
10422 #define foreach_acl_next \
10426 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10428 u32 *miss_next_indexp = va_arg (*args, u32 *);
10429 u32 next_index = 0;
10433 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10437 if (unformat (input, "permit"))
10442 else if (unformat (input, "%d", &tmp))
10451 *miss_next_indexp = next_index;
10456 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10458 u32 *r = va_arg (*args, u32 *);
10460 if (unformat (input, "conform-color"))
10461 *r = POLICE_CONFORM;
10462 else if (unformat (input, "exceed-color"))
10463 *r = POLICE_EXCEED;
10471 api_classify_add_del_table (vat_main_t * vam)
10473 unformat_input_t *i = vam->input;
10474 vl_api_classify_add_del_table_t *mp;
10481 u32 table_index = ~0;
10482 u32 next_table_index = ~0;
10483 u32 miss_next_index = ~0;
10484 u32 memory_size = 32 << 20;
10486 u32 current_data_flag = 0;
10487 int current_data_offset = 0;
10490 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10492 if (unformat (i, "del"))
10494 else if (unformat (i, "del-chain"))
10499 else if (unformat (i, "buckets %d", &nbuckets))
10501 else if (unformat (i, "memory_size %d", &memory_size))
10503 else if (unformat (i, "skip %d", &skip))
10505 else if (unformat (i, "match %d", &match))
10507 else if (unformat (i, "table %d", &table_index))
10509 else if (unformat (i, "mask %U", unformat_classify_mask,
10510 &mask, &skip, &match))
10512 else if (unformat (i, "next-table %d", &next_table_index))
10514 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10517 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10520 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10523 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10525 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10531 if (is_add && mask == 0)
10533 errmsg ("Mask required");
10537 if (is_add && skip == ~0)
10539 errmsg ("skip count required");
10543 if (is_add && match == ~0)
10545 errmsg ("match count required");
10549 if (!is_add && table_index == ~0)
10551 errmsg ("table index required for delete");
10555 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10557 mp->is_add = is_add;
10558 mp->del_chain = del_chain;
10559 mp->table_index = ntohl (table_index);
10560 mp->nbuckets = ntohl (nbuckets);
10561 mp->memory_size = ntohl (memory_size);
10562 mp->skip_n_vectors = ntohl (skip);
10563 mp->match_n_vectors = ntohl (match);
10564 mp->next_table_index = ntohl (next_table_index);
10565 mp->miss_next_index = ntohl (miss_next_index);
10566 mp->current_data_flag = ntohl (current_data_flag);
10567 mp->current_data_offset = ntohl (current_data_offset);
10568 clib_memcpy (mp->mask, mask, vec_len (mask));
10577 #if VPP_API_TEST_BUILTIN == 0
10579 unformat_l4_match (unformat_input_t * input, va_list * args)
10581 u8 **matchp = va_arg (*args, u8 **);
10583 u8 *proto_header = 0;
10589 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10591 if (unformat (input, "src_port %d", &src_port))
10593 else if (unformat (input, "dst_port %d", &dst_port))
10599 h.src_port = clib_host_to_net_u16 (src_port);
10600 h.dst_port = clib_host_to_net_u16 (dst_port);
10601 vec_validate (proto_header, sizeof (h) - 1);
10602 memcpy (proto_header, &h, sizeof (h));
10604 *matchp = proto_header;
10610 unformat_ip4_match (unformat_input_t * input, va_list * args)
10612 u8 **matchp = va_arg (*args, u8 **);
10617 int hdr_length = 0;
10618 u32 hdr_length_val;
10619 int src = 0, dst = 0;
10620 ip4_address_t src_val, dst_val;
10627 int fragment_id = 0;
10628 u32 fragment_id_val;
10634 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10636 if (unformat (input, "version %d", &version_val))
10638 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10640 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10642 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10644 else if (unformat (input, "proto %d", &proto_val))
10646 else if (unformat (input, "tos %d", &tos_val))
10648 else if (unformat (input, "length %d", &length_val))
10650 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10652 else if (unformat (input, "ttl %d", &ttl_val))
10654 else if (unformat (input, "checksum %d", &checksum_val))
10660 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10661 + ttl + checksum == 0)
10665 * Aligned because we use the real comparison functions
10667 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10669 ip = (ip4_header_t *) match;
10671 /* These are realistically matched in practice */
10673 ip->src_address.as_u32 = src_val.as_u32;
10676 ip->dst_address.as_u32 = dst_val.as_u32;
10679 ip->protocol = proto_val;
10682 /* These are not, but they're included for completeness */
10684 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10687 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10693 ip->length = clib_host_to_net_u16 (length_val);
10699 ip->checksum = clib_host_to_net_u16 (checksum_val);
10706 unformat_ip6_match (unformat_input_t * input, va_list * args)
10708 u8 **matchp = va_arg (*args, u8 **);
10713 u8 traffic_class = 0;
10714 u32 traffic_class_val = 0;
10717 int src = 0, dst = 0;
10718 ip6_address_t src_val, dst_val;
10721 int payload_length = 0;
10722 u32 payload_length_val;
10725 u32 ip_version_traffic_class_and_flow_label;
10727 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10729 if (unformat (input, "version %d", &version_val))
10731 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10733 else if (unformat (input, "flow_label %d", &flow_label_val))
10735 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10737 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10739 else if (unformat (input, "proto %d", &proto_val))
10741 else if (unformat (input, "payload_length %d", &payload_length_val))
10742 payload_length = 1;
10743 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10749 if (version + traffic_class + flow_label + src + dst + proto +
10750 payload_length + hop_limit == 0)
10754 * Aligned because we use the real comparison functions
10756 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10758 ip = (ip6_header_t *) match;
10761 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10764 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10767 ip->protocol = proto_val;
10769 ip_version_traffic_class_and_flow_label = 0;
10772 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10775 ip_version_traffic_class_and_flow_label |=
10776 (traffic_class_val & 0xFF) << 20;
10779 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10781 ip->ip_version_traffic_class_and_flow_label =
10782 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10784 if (payload_length)
10785 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10788 ip->hop_limit = hop_limit_val;
10795 unformat_l3_match (unformat_input_t * input, va_list * args)
10797 u8 **matchp = va_arg (*args, u8 **);
10799 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10801 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10803 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10812 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10814 u8 *tagp = va_arg (*args, u8 *);
10817 if (unformat (input, "%d", &tag))
10819 tagp[0] = (tag >> 8) & 0x0F;
10820 tagp[1] = tag & 0xFF;
10828 unformat_l2_match (unformat_input_t * input, va_list * args)
10830 u8 **matchp = va_arg (*args, u8 **);
10843 u8 ignore_tag1 = 0;
10844 u8 ignore_tag2 = 0;
10850 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10852 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10855 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10857 else if (unformat (input, "proto %U",
10858 unformat_ethernet_type_host_byte_order, &proto_val))
10860 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10862 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10864 else if (unformat (input, "ignore-tag1"))
10866 else if (unformat (input, "ignore-tag2"))
10868 else if (unformat (input, "cos1 %d", &cos1_val))
10870 else if (unformat (input, "cos2 %d", &cos2_val))
10875 if ((src + dst + proto + tag1 + tag2 +
10876 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10879 if (tag1 || ignore_tag1 || cos1)
10881 if (tag2 || ignore_tag2 || cos2)
10884 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10887 clib_memcpy (match, dst_val, 6);
10890 clib_memcpy (match + 6, src_val, 6);
10894 /* inner vlan tag */
10895 match[19] = tag2_val[1];
10896 match[18] = tag2_val[0];
10898 match[18] |= (cos2_val & 0x7) << 5;
10901 match[21] = proto_val & 0xff;
10902 match[20] = proto_val >> 8;
10906 match[15] = tag1_val[1];
10907 match[14] = tag1_val[0];
10910 match[14] |= (cos1_val & 0x7) << 5;
10916 match[15] = tag1_val[1];
10917 match[14] = tag1_val[0];
10920 match[17] = proto_val & 0xff;
10921 match[16] = proto_val >> 8;
10924 match[14] |= (cos1_val & 0x7) << 5;
10930 match[18] |= (cos2_val & 0x7) << 5;
10932 match[14] |= (cos1_val & 0x7) << 5;
10935 match[13] = proto_val & 0xff;
10936 match[12] = proto_val >> 8;
10945 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10947 u8 **matchp = va_arg (*args, u8 **);
10948 u32 skip_n_vectors = va_arg (*args, u32);
10949 u32 match_n_vectors = va_arg (*args, u32);
10956 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10958 if (unformat (input, "hex %U", unformat_hex_string, &match))
10960 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10962 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10964 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10978 if (match || l2 || l3 || l4)
10980 if (l2 || l3 || l4)
10982 /* "Win a free Ethernet header in every packet" */
10984 vec_validate_aligned (l2, 13, sizeof (u32x4));
10988 vec_append_aligned (match, l3, sizeof (u32x4));
10993 vec_append_aligned (match, l4, sizeof (u32x4));
10998 /* Make sure the vector is big enough even if key is all 0's */
10999 vec_validate_aligned
11000 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11003 /* Set size, include skipped vectors */
11004 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11015 api_classify_add_del_session (vat_main_t * vam)
11017 unformat_input_t *i = vam->input;
11018 vl_api_classify_add_del_session_t *mp;
11020 u32 table_index = ~0;
11021 u32 hit_next_index = ~0;
11022 u32 opaque_index = ~0;
11025 u32 skip_n_vectors = 0;
11026 u32 match_n_vectors = 0;
11032 * Warning: you have to supply skip_n and match_n
11033 * because the API client cant simply look at the classify
11037 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11039 if (unformat (i, "del"))
11041 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11044 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11047 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11050 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11052 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11054 else if (unformat (i, "opaque-index %d", &opaque_index))
11056 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11058 else if (unformat (i, "match_n %d", &match_n_vectors))
11060 else if (unformat (i, "match %U", api_unformat_classify_match,
11061 &match, skip_n_vectors, match_n_vectors))
11063 else if (unformat (i, "advance %d", &advance))
11065 else if (unformat (i, "table-index %d", &table_index))
11067 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11069 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11071 else if (unformat (i, "action %d", &action))
11073 else if (unformat (i, "metadata %d", &metadata))
11079 if (table_index == ~0)
11081 errmsg ("Table index required");
11085 if (is_add && match == 0)
11087 errmsg ("Match value required");
11091 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11093 mp->is_add = is_add;
11094 mp->table_index = ntohl (table_index);
11095 mp->hit_next_index = ntohl (hit_next_index);
11096 mp->opaque_index = ntohl (opaque_index);
11097 mp->advance = ntohl (advance);
11098 mp->action = action;
11099 mp->metadata = ntohl (metadata);
11100 clib_memcpy (mp->match, match, vec_len (match));
11109 api_classify_set_interface_ip_table (vat_main_t * vam)
11111 unformat_input_t *i = vam->input;
11112 vl_api_classify_set_interface_ip_table_t *mp;
11114 int sw_if_index_set;
11115 u32 table_index = ~0;
11119 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11121 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11122 sw_if_index_set = 1;
11123 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11124 sw_if_index_set = 1;
11125 else if (unformat (i, "table %d", &table_index))
11129 clib_warning ("parse error '%U'", format_unformat_error, i);
11134 if (sw_if_index_set == 0)
11136 errmsg ("missing interface name or sw_if_index");
11141 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11143 mp->sw_if_index = ntohl (sw_if_index);
11144 mp->table_index = ntohl (table_index);
11145 mp->is_ipv6 = is_ipv6;
11153 api_classify_set_interface_l2_tables (vat_main_t * vam)
11155 unformat_input_t *i = vam->input;
11156 vl_api_classify_set_interface_l2_tables_t *mp;
11158 int sw_if_index_set;
11159 u32 ip4_table_index = ~0;
11160 u32 ip6_table_index = ~0;
11161 u32 other_table_index = ~0;
11165 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11167 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11168 sw_if_index_set = 1;
11169 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11170 sw_if_index_set = 1;
11171 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11173 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11175 else if (unformat (i, "other-table %d", &other_table_index))
11177 else if (unformat (i, "is-input %d", &is_input))
11181 clib_warning ("parse error '%U'", format_unformat_error, i);
11186 if (sw_if_index_set == 0)
11188 errmsg ("missing interface name or sw_if_index");
11193 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11195 mp->sw_if_index = ntohl (sw_if_index);
11196 mp->ip4_table_index = ntohl (ip4_table_index);
11197 mp->ip6_table_index = ntohl (ip6_table_index);
11198 mp->other_table_index = ntohl (other_table_index);
11199 mp->is_input = (u8) is_input;
11207 api_set_ipfix_exporter (vat_main_t * vam)
11209 unformat_input_t *i = vam->input;
11210 vl_api_set_ipfix_exporter_t *mp;
11211 ip4_address_t collector_address;
11212 u8 collector_address_set = 0;
11213 u32 collector_port = ~0;
11214 ip4_address_t src_address;
11215 u8 src_address_set = 0;
11218 u32 template_interval = ~0;
11219 u8 udp_checksum = 0;
11222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11224 if (unformat (i, "collector_address %U", unformat_ip4_address,
11225 &collector_address))
11226 collector_address_set = 1;
11227 else if (unformat (i, "collector_port %d", &collector_port))
11229 else if (unformat (i, "src_address %U", unformat_ip4_address,
11231 src_address_set = 1;
11232 else if (unformat (i, "vrf_id %d", &vrf_id))
11234 else if (unformat (i, "path_mtu %d", &path_mtu))
11236 else if (unformat (i, "template_interval %d", &template_interval))
11238 else if (unformat (i, "udp_checksum"))
11244 if (collector_address_set == 0)
11246 errmsg ("collector_address required");
11250 if (src_address_set == 0)
11252 errmsg ("src_address required");
11256 M (SET_IPFIX_EXPORTER, mp);
11258 memcpy (mp->collector_address, collector_address.data,
11259 sizeof (collector_address.data));
11260 mp->collector_port = htons ((u16) collector_port);
11261 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11262 mp->vrf_id = htonl (vrf_id);
11263 mp->path_mtu = htonl (path_mtu);
11264 mp->template_interval = htonl (template_interval);
11265 mp->udp_checksum = udp_checksum;
11273 api_set_ipfix_classify_stream (vat_main_t * vam)
11275 unformat_input_t *i = vam->input;
11276 vl_api_set_ipfix_classify_stream_t *mp;
11278 u32 src_port = UDP_DST_PORT_ipfix;
11281 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11283 if (unformat (i, "domain %d", &domain_id))
11285 else if (unformat (i, "src_port %d", &src_port))
11289 errmsg ("unknown input `%U'", format_unformat_error, i);
11294 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11296 mp->domain_id = htonl (domain_id);
11297 mp->src_port = htons ((u16) src_port);
11305 api_ipfix_classify_table_add_del (vat_main_t * vam)
11307 unformat_input_t *i = vam->input;
11308 vl_api_ipfix_classify_table_add_del_t *mp;
11310 u32 classify_table_index = ~0;
11312 u8 transport_protocol = 255;
11315 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11317 if (unformat (i, "add"))
11319 else if (unformat (i, "del"))
11321 else if (unformat (i, "table %d", &classify_table_index))
11323 else if (unformat (i, "ip4"))
11325 else if (unformat (i, "ip6"))
11327 else if (unformat (i, "tcp"))
11328 transport_protocol = 6;
11329 else if (unformat (i, "udp"))
11330 transport_protocol = 17;
11333 errmsg ("unknown input `%U'", format_unformat_error, i);
11340 errmsg ("expecting: add|del");
11343 if (classify_table_index == ~0)
11345 errmsg ("classifier table not specified");
11348 if (ip_version == 0)
11350 errmsg ("IP version not specified");
11354 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11356 mp->is_add = is_add;
11357 mp->table_id = htonl (classify_table_index);
11358 mp->ip_version = ip_version;
11359 mp->transport_protocol = transport_protocol;
11367 api_get_node_index (vat_main_t * vam)
11369 unformat_input_t *i = vam->input;
11370 vl_api_get_node_index_t *mp;
11374 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11376 if (unformat (i, "node %s", &name))
11383 errmsg ("node name required");
11386 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11388 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11392 M (GET_NODE_INDEX, mp);
11393 clib_memcpy (mp->node_name, name, vec_len (name));
11402 api_get_next_index (vat_main_t * vam)
11404 unformat_input_t *i = vam->input;
11405 vl_api_get_next_index_t *mp;
11406 u8 *node_name = 0, *next_node_name = 0;
11409 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11411 if (unformat (i, "node-name %s", &node_name))
11413 else if (unformat (i, "next-node-name %s", &next_node_name))
11417 if (node_name == 0)
11419 errmsg ("node name required");
11422 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11424 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11428 if (next_node_name == 0)
11430 errmsg ("next node name required");
11433 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11435 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11439 M (GET_NEXT_INDEX, mp);
11440 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11441 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11442 vec_free (node_name);
11443 vec_free (next_node_name);
11451 api_add_node_next (vat_main_t * vam)
11453 unformat_input_t *i = vam->input;
11454 vl_api_add_node_next_t *mp;
11459 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11461 if (unformat (i, "node %s", &name))
11463 else if (unformat (i, "next %s", &next))
11470 errmsg ("node name required");
11473 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11475 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11480 errmsg ("next node required");
11483 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11485 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11489 M (ADD_NODE_NEXT, mp);
11490 clib_memcpy (mp->node_name, name, vec_len (name));
11491 clib_memcpy (mp->next_name, next, vec_len (next));
11501 api_l2tpv3_create_tunnel (vat_main_t * vam)
11503 unformat_input_t *i = vam->input;
11504 ip6_address_t client_address, our_address;
11505 int client_address_set = 0;
11506 int our_address_set = 0;
11507 u32 local_session_id = 0;
11508 u32 remote_session_id = 0;
11509 u64 local_cookie = 0;
11510 u64 remote_cookie = 0;
11511 u8 l2_sublayer_present = 0;
11512 vl_api_l2tpv3_create_tunnel_t *mp;
11515 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11517 if (unformat (i, "client_address %U", unformat_ip6_address,
11519 client_address_set = 1;
11520 else if (unformat (i, "our_address %U", unformat_ip6_address,
11522 our_address_set = 1;
11523 else if (unformat (i, "local_session_id %d", &local_session_id))
11525 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11527 else if (unformat (i, "local_cookie %lld", &local_cookie))
11529 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11531 else if (unformat (i, "l2-sublayer-present"))
11532 l2_sublayer_present = 1;
11537 if (client_address_set == 0)
11539 errmsg ("client_address required");
11543 if (our_address_set == 0)
11545 errmsg ("our_address required");
11549 M (L2TPV3_CREATE_TUNNEL, mp);
11551 clib_memcpy (mp->client_address, client_address.as_u8,
11552 sizeof (mp->client_address));
11554 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11556 mp->local_session_id = ntohl (local_session_id);
11557 mp->remote_session_id = ntohl (remote_session_id);
11558 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11559 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11560 mp->l2_sublayer_present = l2_sublayer_present;
11569 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11571 unformat_input_t *i = vam->input;
11573 u8 sw_if_index_set = 0;
11574 u64 new_local_cookie = 0;
11575 u64 new_remote_cookie = 0;
11576 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11579 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11581 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11582 sw_if_index_set = 1;
11583 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11584 sw_if_index_set = 1;
11585 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11587 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11593 if (sw_if_index_set == 0)
11595 errmsg ("missing interface name or sw_if_index");
11599 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11601 mp->sw_if_index = ntohl (sw_if_index);
11602 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11603 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11611 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11613 unformat_input_t *i = vam->input;
11614 vl_api_l2tpv3_interface_enable_disable_t *mp;
11616 u8 sw_if_index_set = 0;
11617 u8 enable_disable = 1;
11620 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11622 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11623 sw_if_index_set = 1;
11624 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11625 sw_if_index_set = 1;
11626 else if (unformat (i, "enable"))
11627 enable_disable = 1;
11628 else if (unformat (i, "disable"))
11629 enable_disable = 0;
11634 if (sw_if_index_set == 0)
11636 errmsg ("missing interface name or sw_if_index");
11640 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11642 mp->sw_if_index = ntohl (sw_if_index);
11643 mp->enable_disable = enable_disable;
11651 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11653 unformat_input_t *i = vam->input;
11654 vl_api_l2tpv3_set_lookup_key_t *mp;
11658 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11660 if (unformat (i, "lookup_v6_src"))
11661 key = L2T_LOOKUP_SRC_ADDRESS;
11662 else if (unformat (i, "lookup_v6_dst"))
11663 key = L2T_LOOKUP_DST_ADDRESS;
11664 else if (unformat (i, "lookup_session_id"))
11665 key = L2T_LOOKUP_SESSION_ID;
11670 if (key == (u8) ~ 0)
11672 errmsg ("l2tp session lookup key unset");
11676 M (L2TPV3_SET_LOOKUP_KEY, mp);
11685 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11686 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11688 vat_main_t *vam = &vat_main;
11690 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11691 format_ip6_address, mp->our_address,
11692 format_ip6_address, mp->client_address,
11693 clib_net_to_host_u32 (mp->sw_if_index));
11696 " local cookies %016llx %016llx remote cookie %016llx",
11697 clib_net_to_host_u64 (mp->local_cookie[0]),
11698 clib_net_to_host_u64 (mp->local_cookie[1]),
11699 clib_net_to_host_u64 (mp->remote_cookie));
11701 print (vam->ofp, " local session-id %d remote session-id %d",
11702 clib_net_to_host_u32 (mp->local_session_id),
11703 clib_net_to_host_u32 (mp->remote_session_id));
11705 print (vam->ofp, " l2 specific sublayer %s\n",
11706 mp->l2_sublayer_present ? "preset" : "absent");
11710 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11711 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11713 vat_main_t *vam = &vat_main;
11714 vat_json_node_t *node = NULL;
11715 struct in6_addr addr;
11717 if (VAT_JSON_ARRAY != vam->json_tree.type)
11719 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11720 vat_json_init_array (&vam->json_tree);
11722 node = vat_json_array_add (&vam->json_tree);
11724 vat_json_init_object (node);
11726 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11727 vat_json_object_add_ip6 (node, "our_address", addr);
11728 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11729 vat_json_object_add_ip6 (node, "client_address", addr);
11731 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11732 vat_json_init_array (lc);
11733 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11734 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11735 vat_json_object_add_uint (node, "remote_cookie",
11736 clib_net_to_host_u64 (mp->remote_cookie));
11738 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11739 vat_json_object_add_uint (node, "local_session_id",
11740 clib_net_to_host_u32 (mp->local_session_id));
11741 vat_json_object_add_uint (node, "remote_session_id",
11742 clib_net_to_host_u32 (mp->remote_session_id));
11743 vat_json_object_add_string_copy (node, "l2_sublayer",
11744 mp->l2_sublayer_present ? (u8 *) "present"
11745 : (u8 *) "absent");
11749 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11751 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11752 vl_api_control_ping_t *mp_ping;
11755 /* Get list of l2tpv3-tunnel interfaces */
11756 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11759 /* Use a control ping for synchronization */
11760 MPING (CONTROL_PING, mp_ping);
11768 static void vl_api_sw_interface_tap_details_t_handler
11769 (vl_api_sw_interface_tap_details_t * mp)
11771 vat_main_t *vam = &vat_main;
11773 print (vam->ofp, "%-16s %d",
11774 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
11777 static void vl_api_sw_interface_tap_details_t_handler_json
11778 (vl_api_sw_interface_tap_details_t * mp)
11780 vat_main_t *vam = &vat_main;
11781 vat_json_node_t *node = NULL;
11783 if (VAT_JSON_ARRAY != vam->json_tree.type)
11785 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11786 vat_json_init_array (&vam->json_tree);
11788 node = vat_json_array_add (&vam->json_tree);
11790 vat_json_init_object (node);
11791 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11792 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11796 api_sw_interface_tap_dump (vat_main_t * vam)
11798 vl_api_sw_interface_tap_dump_t *mp;
11799 vl_api_control_ping_t *mp_ping;
11802 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
11803 /* Get list of tap interfaces */
11804 M (SW_INTERFACE_TAP_DUMP, mp);
11807 /* Use a control ping for synchronization */
11808 MPING (CONTROL_PING, mp_ping);
11815 static uword unformat_vxlan_decap_next
11816 (unformat_input_t * input, va_list * args)
11818 u32 *result = va_arg (*args, u32 *);
11821 if (unformat (input, "l2"))
11822 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11823 else if (unformat (input, "%d", &tmp))
11831 api_vxlan_add_del_tunnel (vat_main_t * vam)
11833 unformat_input_t *line_input = vam->input;
11834 vl_api_vxlan_add_del_tunnel_t *mp;
11835 ip46_address_t src, dst;
11837 u8 ipv4_set = 0, ipv6_set = 0;
11841 u32 mcast_sw_if_index = ~0;
11842 u32 encap_vrf_id = 0;
11843 u32 decap_next_index = ~0;
11847 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11848 memset (&src, 0, sizeof src);
11849 memset (&dst, 0, sizeof dst);
11851 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11853 if (unformat (line_input, "del"))
11856 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11862 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11868 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11874 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11879 else if (unformat (line_input, "group %U %U",
11880 unformat_ip4_address, &dst.ip4,
11881 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11883 grp_set = dst_set = 1;
11886 else if (unformat (line_input, "group %U",
11887 unformat_ip4_address, &dst.ip4))
11889 grp_set = dst_set = 1;
11892 else if (unformat (line_input, "group %U %U",
11893 unformat_ip6_address, &dst.ip6,
11894 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11896 grp_set = dst_set = 1;
11899 else if (unformat (line_input, "group %U",
11900 unformat_ip6_address, &dst.ip6))
11902 grp_set = dst_set = 1;
11906 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11908 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11910 else if (unformat (line_input, "decap-next %U",
11911 unformat_vxlan_decap_next, &decap_next_index))
11913 else if (unformat (line_input, "vni %d", &vni))
11917 errmsg ("parse error '%U'", format_unformat_error, line_input);
11924 errmsg ("tunnel src address not specified");
11929 errmsg ("tunnel dst address not specified");
11933 if (grp_set && !ip46_address_is_multicast (&dst))
11935 errmsg ("tunnel group address not multicast");
11938 if (grp_set && mcast_sw_if_index == ~0)
11940 errmsg ("tunnel nonexistent multicast device");
11943 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11945 errmsg ("tunnel dst address must be unicast");
11950 if (ipv4_set && ipv6_set)
11952 errmsg ("both IPv4 and IPv6 addresses specified");
11956 if ((vni == 0) || (vni >> 24))
11958 errmsg ("vni not specified or out of range");
11962 M (VXLAN_ADD_DEL_TUNNEL, mp);
11966 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
11967 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
11971 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
11972 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
11974 mp->encap_vrf_id = ntohl (encap_vrf_id);
11975 mp->decap_next_index = ntohl (decap_next_index);
11976 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11977 mp->vni = ntohl (vni);
11978 mp->is_add = is_add;
11979 mp->is_ipv6 = ipv6_set;
11986 static void vl_api_vxlan_tunnel_details_t_handler
11987 (vl_api_vxlan_tunnel_details_t * mp)
11989 vat_main_t *vam = &vat_main;
11990 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
11991 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
11993 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
11994 ntohl (mp->sw_if_index),
11995 format_ip46_address, &src, IP46_TYPE_ANY,
11996 format_ip46_address, &dst, IP46_TYPE_ANY,
11997 ntohl (mp->encap_vrf_id),
11998 ntohl (mp->decap_next_index), ntohl (mp->vni),
11999 ntohl (mp->mcast_sw_if_index));
12002 static void vl_api_vxlan_tunnel_details_t_handler_json
12003 (vl_api_vxlan_tunnel_details_t * mp)
12005 vat_main_t *vam = &vat_main;
12006 vat_json_node_t *node = NULL;
12008 if (VAT_JSON_ARRAY != vam->json_tree.type)
12010 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12011 vat_json_init_array (&vam->json_tree);
12013 node = vat_json_array_add (&vam->json_tree);
12015 vat_json_init_object (node);
12016 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12019 struct in6_addr ip6;
12021 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12022 vat_json_object_add_ip6 (node, "src_address", ip6);
12023 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12024 vat_json_object_add_ip6 (node, "dst_address", ip6);
12028 struct in_addr ip4;
12030 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12031 vat_json_object_add_ip4 (node, "src_address", ip4);
12032 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12033 vat_json_object_add_ip4 (node, "dst_address", ip4);
12035 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12036 vat_json_object_add_uint (node, "decap_next_index",
12037 ntohl (mp->decap_next_index));
12038 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12039 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12040 vat_json_object_add_uint (node, "mcast_sw_if_index",
12041 ntohl (mp->mcast_sw_if_index));
12045 api_vxlan_tunnel_dump (vat_main_t * vam)
12047 unformat_input_t *i = vam->input;
12048 vl_api_vxlan_tunnel_dump_t *mp;
12049 vl_api_control_ping_t *mp_ping;
12051 u8 sw_if_index_set = 0;
12054 /* Parse args required to build the message */
12055 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12057 if (unformat (i, "sw_if_index %d", &sw_if_index))
12058 sw_if_index_set = 1;
12063 if (sw_if_index_set == 0)
12068 if (!vam->json_output)
12070 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12071 "sw_if_index", "src_address", "dst_address",
12072 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12075 /* Get list of vxlan-tunnel interfaces */
12076 M (VXLAN_TUNNEL_DUMP, mp);
12078 mp->sw_if_index = htonl (sw_if_index);
12082 /* Use a control ping for synchronization */
12083 MPING (CONTROL_PING, mp_ping);
12090 static uword unformat_geneve_decap_next
12091 (unformat_input_t * input, va_list * args)
12093 u32 *result = va_arg (*args, u32 *);
12096 if (unformat (input, "l2"))
12097 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12098 else if (unformat (input, "%d", &tmp))
12106 api_geneve_add_del_tunnel (vat_main_t * vam)
12108 unformat_input_t *line_input = vam->input;
12109 vl_api_geneve_add_del_tunnel_t *mp;
12110 ip46_address_t src, dst;
12112 u8 ipv4_set = 0, ipv6_set = 0;
12116 u32 mcast_sw_if_index = ~0;
12117 u32 encap_vrf_id = 0;
12118 u32 decap_next_index = ~0;
12122 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12123 memset (&src, 0, sizeof src);
12124 memset (&dst, 0, sizeof dst);
12126 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12128 if (unformat (line_input, "del"))
12131 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12137 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12143 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12149 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12154 else if (unformat (line_input, "group %U %U",
12155 unformat_ip4_address, &dst.ip4,
12156 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12158 grp_set = dst_set = 1;
12161 else if (unformat (line_input, "group %U",
12162 unformat_ip4_address, &dst.ip4))
12164 grp_set = dst_set = 1;
12167 else if (unformat (line_input, "group %U %U",
12168 unformat_ip6_address, &dst.ip6,
12169 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12171 grp_set = dst_set = 1;
12174 else if (unformat (line_input, "group %U",
12175 unformat_ip6_address, &dst.ip6))
12177 grp_set = dst_set = 1;
12181 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12183 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12185 else if (unformat (line_input, "decap-next %U",
12186 unformat_geneve_decap_next, &decap_next_index))
12188 else if (unformat (line_input, "vni %d", &vni))
12192 errmsg ("parse error '%U'", format_unformat_error, line_input);
12199 errmsg ("tunnel src address not specified");
12204 errmsg ("tunnel dst address not specified");
12208 if (grp_set && !ip46_address_is_multicast (&dst))
12210 errmsg ("tunnel group address not multicast");
12213 if (grp_set && mcast_sw_if_index == ~0)
12215 errmsg ("tunnel nonexistent multicast device");
12218 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12220 errmsg ("tunnel dst address must be unicast");
12225 if (ipv4_set && ipv6_set)
12227 errmsg ("both IPv4 and IPv6 addresses specified");
12231 if ((vni == 0) || (vni >> 24))
12233 errmsg ("vni not specified or out of range");
12237 M (GENEVE_ADD_DEL_TUNNEL, mp);
12241 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12242 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12246 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12247 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12249 mp->encap_vrf_id = ntohl (encap_vrf_id);
12250 mp->decap_next_index = ntohl (decap_next_index);
12251 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12252 mp->vni = ntohl (vni);
12253 mp->is_add = is_add;
12254 mp->is_ipv6 = ipv6_set;
12261 static void vl_api_geneve_tunnel_details_t_handler
12262 (vl_api_geneve_tunnel_details_t * mp)
12264 vat_main_t *vam = &vat_main;
12265 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12266 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12268 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12269 ntohl (mp->sw_if_index),
12270 format_ip46_address, &src, IP46_TYPE_ANY,
12271 format_ip46_address, &dst, IP46_TYPE_ANY,
12272 ntohl (mp->encap_vrf_id),
12273 ntohl (mp->decap_next_index), ntohl (mp->vni),
12274 ntohl (mp->mcast_sw_if_index));
12277 static void vl_api_geneve_tunnel_details_t_handler_json
12278 (vl_api_geneve_tunnel_details_t * mp)
12280 vat_main_t *vam = &vat_main;
12281 vat_json_node_t *node = NULL;
12283 if (VAT_JSON_ARRAY != vam->json_tree.type)
12285 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12286 vat_json_init_array (&vam->json_tree);
12288 node = vat_json_array_add (&vam->json_tree);
12290 vat_json_init_object (node);
12291 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12294 struct in6_addr ip6;
12296 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12297 vat_json_object_add_ip6 (node, "src_address", ip6);
12298 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12299 vat_json_object_add_ip6 (node, "dst_address", ip6);
12303 struct in_addr ip4;
12305 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12306 vat_json_object_add_ip4 (node, "src_address", ip4);
12307 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12308 vat_json_object_add_ip4 (node, "dst_address", ip4);
12310 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12311 vat_json_object_add_uint (node, "decap_next_index",
12312 ntohl (mp->decap_next_index));
12313 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12314 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12315 vat_json_object_add_uint (node, "mcast_sw_if_index",
12316 ntohl (mp->mcast_sw_if_index));
12320 api_geneve_tunnel_dump (vat_main_t * vam)
12322 unformat_input_t *i = vam->input;
12323 vl_api_geneve_tunnel_dump_t *mp;
12324 vl_api_control_ping_t *mp_ping;
12326 u8 sw_if_index_set = 0;
12329 /* Parse args required to build the message */
12330 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12332 if (unformat (i, "sw_if_index %d", &sw_if_index))
12333 sw_if_index_set = 1;
12338 if (sw_if_index_set == 0)
12343 if (!vam->json_output)
12345 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12346 "sw_if_index", "local_address", "remote_address",
12347 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12350 /* Get list of geneve-tunnel interfaces */
12351 M (GENEVE_TUNNEL_DUMP, mp);
12353 mp->sw_if_index = htonl (sw_if_index);
12357 /* Use a control ping for synchronization */
12358 M (CONTROL_PING, mp_ping);
12366 api_gre_add_del_tunnel (vat_main_t * vam)
12368 unformat_input_t *line_input = vam->input;
12369 vl_api_gre_add_del_tunnel_t *mp;
12370 ip4_address_t src4, dst4;
12371 ip6_address_t src6, dst6;
12378 u32 outer_fib_id = 0;
12381 memset (&src4, 0, sizeof src4);
12382 memset (&dst4, 0, sizeof dst4);
12383 memset (&src6, 0, sizeof src6);
12384 memset (&dst6, 0, sizeof dst6);
12386 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12388 if (unformat (line_input, "del"))
12390 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
12395 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
12400 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
12405 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
12410 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12412 else if (unformat (line_input, "teb"))
12416 errmsg ("parse error '%U'", format_unformat_error, line_input);
12423 errmsg ("tunnel src address not specified");
12428 errmsg ("tunnel dst address not specified");
12431 if (ipv4_set && ipv6_set)
12433 errmsg ("both IPv4 and IPv6 addresses specified");
12438 M (GRE_ADD_DEL_TUNNEL, mp);
12442 clib_memcpy (&mp->src_address, &src4, 4);
12443 clib_memcpy (&mp->dst_address, &dst4, 4);
12447 clib_memcpy (&mp->src_address, &src6, 16);
12448 clib_memcpy (&mp->dst_address, &dst6, 16);
12450 mp->outer_fib_id = ntohl (outer_fib_id);
12451 mp->is_add = is_add;
12453 mp->is_ipv6 = ipv6_set;
12460 static void vl_api_gre_tunnel_details_t_handler
12461 (vl_api_gre_tunnel_details_t * mp)
12463 vat_main_t *vam = &vat_main;
12464 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
12465 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
12467 print (vam->ofp, "%11d%24U%24U%6d%14d",
12468 ntohl (mp->sw_if_index),
12469 format_ip46_address, &src, IP46_TYPE_ANY,
12470 format_ip46_address, &dst, IP46_TYPE_ANY,
12471 mp->teb, ntohl (mp->outer_fib_id));
12474 static void vl_api_gre_tunnel_details_t_handler_json
12475 (vl_api_gre_tunnel_details_t * mp)
12477 vat_main_t *vam = &vat_main;
12478 vat_json_node_t *node = NULL;
12479 struct in_addr ip4;
12480 struct in6_addr ip6;
12482 if (VAT_JSON_ARRAY != vam->json_tree.type)
12484 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12485 vat_json_init_array (&vam->json_tree);
12487 node = vat_json_array_add (&vam->json_tree);
12489 vat_json_init_object (node);
12490 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12493 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
12494 vat_json_object_add_ip4 (node, "src_address", ip4);
12495 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
12496 vat_json_object_add_ip4 (node, "dst_address", ip4);
12500 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
12501 vat_json_object_add_ip6 (node, "src_address", ip6);
12502 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
12503 vat_json_object_add_ip6 (node, "dst_address", ip6);
12505 vat_json_object_add_uint (node, "teb", mp->teb);
12506 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
12507 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
12511 api_gre_tunnel_dump (vat_main_t * vam)
12513 unformat_input_t *i = vam->input;
12514 vl_api_gre_tunnel_dump_t *mp;
12515 vl_api_control_ping_t *mp_ping;
12517 u8 sw_if_index_set = 0;
12520 /* Parse args required to build the message */
12521 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12523 if (unformat (i, "sw_if_index %d", &sw_if_index))
12524 sw_if_index_set = 1;
12529 if (sw_if_index_set == 0)
12534 if (!vam->json_output)
12536 print (vam->ofp, "%11s%24s%24s%6s%14s",
12537 "sw_if_index", "src_address", "dst_address", "teb",
12541 /* Get list of gre-tunnel interfaces */
12542 M (GRE_TUNNEL_DUMP, mp);
12544 mp->sw_if_index = htonl (sw_if_index);
12548 /* Use a control ping for synchronization */
12549 MPING (CONTROL_PING, mp_ping);
12557 api_l2_fib_clear_table (vat_main_t * vam)
12559 // unformat_input_t * i = vam->input;
12560 vl_api_l2_fib_clear_table_t *mp;
12563 M (L2_FIB_CLEAR_TABLE, mp);
12571 api_l2_interface_efp_filter (vat_main_t * vam)
12573 unformat_input_t *i = vam->input;
12574 vl_api_l2_interface_efp_filter_t *mp;
12577 u8 sw_if_index_set = 0;
12580 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12582 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12583 sw_if_index_set = 1;
12584 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12585 sw_if_index_set = 1;
12586 else if (unformat (i, "enable"))
12588 else if (unformat (i, "disable"))
12592 clib_warning ("parse error '%U'", format_unformat_error, i);
12597 if (sw_if_index_set == 0)
12599 errmsg ("missing sw_if_index");
12603 M (L2_INTERFACE_EFP_FILTER, mp);
12605 mp->sw_if_index = ntohl (sw_if_index);
12606 mp->enable_disable = enable;
12613 #define foreach_vtr_op \
12614 _("disable", L2_VTR_DISABLED) \
12615 _("push-1", L2_VTR_PUSH_1) \
12616 _("push-2", L2_VTR_PUSH_2) \
12617 _("pop-1", L2_VTR_POP_1) \
12618 _("pop-2", L2_VTR_POP_2) \
12619 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12620 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12621 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12622 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12625 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12627 unformat_input_t *i = vam->input;
12628 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12630 u8 sw_if_index_set = 0;
12633 u32 push_dot1q = 1;
12638 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12640 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12641 sw_if_index_set = 1;
12642 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12643 sw_if_index_set = 1;
12644 else if (unformat (i, "vtr_op %d", &vtr_op))
12646 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12649 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12651 else if (unformat (i, "tag1 %d", &tag1))
12653 else if (unformat (i, "tag2 %d", &tag2))
12657 clib_warning ("parse error '%U'", format_unformat_error, i);
12662 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12664 errmsg ("missing vtr operation or sw_if_index");
12668 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12669 mp->sw_if_index = ntohl (sw_if_index);
12670 mp->vtr_op = ntohl (vtr_op);
12671 mp->push_dot1q = ntohl (push_dot1q);
12672 mp->tag1 = ntohl (tag1);
12673 mp->tag2 = ntohl (tag2);
12681 api_create_vhost_user_if (vat_main_t * vam)
12683 unformat_input_t *i = vam->input;
12684 vl_api_create_vhost_user_if_t *mp;
12687 u8 file_name_set = 0;
12688 u32 custom_dev_instance = ~0;
12690 u8 use_custom_mac = 0;
12694 /* Shut up coverity */
12695 memset (hwaddr, 0, sizeof (hwaddr));
12697 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12699 if (unformat (i, "socket %s", &file_name))
12703 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12705 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12706 use_custom_mac = 1;
12707 else if (unformat (i, "server"))
12709 else if (unformat (i, "tag %s", &tag))
12715 if (file_name_set == 0)
12717 errmsg ("missing socket file name");
12721 if (vec_len (file_name) > 255)
12723 errmsg ("socket file name too long");
12726 vec_add1 (file_name, 0);
12728 M (CREATE_VHOST_USER_IF, mp);
12730 mp->is_server = is_server;
12731 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12732 vec_free (file_name);
12733 if (custom_dev_instance != ~0)
12736 mp->custom_dev_instance = ntohl (custom_dev_instance);
12738 mp->use_custom_mac = use_custom_mac;
12739 clib_memcpy (mp->mac_address, hwaddr, 6);
12741 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12750 api_modify_vhost_user_if (vat_main_t * vam)
12752 unformat_input_t *i = vam->input;
12753 vl_api_modify_vhost_user_if_t *mp;
12756 u8 file_name_set = 0;
12757 u32 custom_dev_instance = ~0;
12758 u8 sw_if_index_set = 0;
12759 u32 sw_if_index = (u32) ~ 0;
12762 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12764 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12765 sw_if_index_set = 1;
12766 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12767 sw_if_index_set = 1;
12768 else if (unformat (i, "socket %s", &file_name))
12772 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12774 else if (unformat (i, "server"))
12780 if (sw_if_index_set == 0)
12782 errmsg ("missing sw_if_index or interface name");
12786 if (file_name_set == 0)
12788 errmsg ("missing socket file name");
12792 if (vec_len (file_name) > 255)
12794 errmsg ("socket file name too long");
12797 vec_add1 (file_name, 0);
12799 M (MODIFY_VHOST_USER_IF, mp);
12801 mp->sw_if_index = ntohl (sw_if_index);
12802 mp->is_server = is_server;
12803 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12804 vec_free (file_name);
12805 if (custom_dev_instance != ~0)
12808 mp->custom_dev_instance = ntohl (custom_dev_instance);
12817 api_delete_vhost_user_if (vat_main_t * vam)
12819 unformat_input_t *i = vam->input;
12820 vl_api_delete_vhost_user_if_t *mp;
12821 u32 sw_if_index = ~0;
12822 u8 sw_if_index_set = 0;
12825 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12827 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12828 sw_if_index_set = 1;
12829 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12830 sw_if_index_set = 1;
12835 if (sw_if_index_set == 0)
12837 errmsg ("missing sw_if_index or interface name");
12842 M (DELETE_VHOST_USER_IF, mp);
12844 mp->sw_if_index = ntohl (sw_if_index);
12851 static void vl_api_sw_interface_vhost_user_details_t_handler
12852 (vl_api_sw_interface_vhost_user_details_t * mp)
12854 vat_main_t *vam = &vat_main;
12856 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12857 (char *) mp->interface_name,
12858 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12859 clib_net_to_host_u64 (mp->features), mp->is_server,
12860 ntohl (mp->num_regions), (char *) mp->sock_filename);
12861 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12864 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12865 (vl_api_sw_interface_vhost_user_details_t * mp)
12867 vat_main_t *vam = &vat_main;
12868 vat_json_node_t *node = NULL;
12870 if (VAT_JSON_ARRAY != vam->json_tree.type)
12872 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12873 vat_json_init_array (&vam->json_tree);
12875 node = vat_json_array_add (&vam->json_tree);
12877 vat_json_init_object (node);
12878 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12879 vat_json_object_add_string_copy (node, "interface_name",
12880 mp->interface_name);
12881 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12882 ntohl (mp->virtio_net_hdr_sz));
12883 vat_json_object_add_uint (node, "features",
12884 clib_net_to_host_u64 (mp->features));
12885 vat_json_object_add_uint (node, "is_server", mp->is_server);
12886 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12887 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12888 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12892 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12894 vl_api_sw_interface_vhost_user_dump_t *mp;
12895 vl_api_control_ping_t *mp_ping;
12898 "Interface name idx hdr_sz features server regions filename");
12900 /* Get list of vhost-user interfaces */
12901 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12904 /* Use a control ping for synchronization */
12905 MPING (CONTROL_PING, mp_ping);
12913 api_show_version (vat_main_t * vam)
12915 vl_api_show_version_t *mp;
12918 M (SHOW_VERSION, mp);
12927 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12929 unformat_input_t *line_input = vam->input;
12930 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12931 ip4_address_t local4, remote4;
12932 ip6_address_t local6, remote6;
12934 u8 ipv4_set = 0, ipv6_set = 0;
12938 u32 mcast_sw_if_index = ~0;
12939 u32 encap_vrf_id = 0;
12940 u32 decap_vrf_id = 0;
12946 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12947 memset (&local4, 0, sizeof local4);
12948 memset (&remote4, 0, sizeof remote4);
12949 memset (&local6, 0, sizeof local6);
12950 memset (&remote6, 0, sizeof remote6);
12952 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12954 if (unformat (line_input, "del"))
12956 else if (unformat (line_input, "local %U",
12957 unformat_ip4_address, &local4))
12962 else if (unformat (line_input, "remote %U",
12963 unformat_ip4_address, &remote4))
12968 else if (unformat (line_input, "local %U",
12969 unformat_ip6_address, &local6))
12974 else if (unformat (line_input, "remote %U",
12975 unformat_ip6_address, &remote6))
12980 else if (unformat (line_input, "group %U %U",
12981 unformat_ip4_address, &remote4,
12982 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12984 grp_set = remote_set = 1;
12987 else if (unformat (line_input, "group %U",
12988 unformat_ip4_address, &remote4))
12990 grp_set = remote_set = 1;
12993 else if (unformat (line_input, "group %U %U",
12994 unformat_ip6_address, &remote6,
12995 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12997 grp_set = remote_set = 1;
13000 else if (unformat (line_input, "group %U",
13001 unformat_ip6_address, &remote6))
13003 grp_set = remote_set = 1;
13007 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13009 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13011 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13013 else if (unformat (line_input, "vni %d", &vni))
13015 else if (unformat (line_input, "next-ip4"))
13017 else if (unformat (line_input, "next-ip6"))
13019 else if (unformat (line_input, "next-ethernet"))
13021 else if (unformat (line_input, "next-nsh"))
13025 errmsg ("parse error '%U'", format_unformat_error, line_input);
13030 if (local_set == 0)
13032 errmsg ("tunnel local address not specified");
13035 if (remote_set == 0)
13037 errmsg ("tunnel remote address not specified");
13040 if (grp_set && mcast_sw_if_index == ~0)
13042 errmsg ("tunnel nonexistent multicast device");
13045 if (ipv4_set && ipv6_set)
13047 errmsg ("both IPv4 and IPv6 addresses specified");
13053 errmsg ("vni not specified");
13057 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13062 clib_memcpy (&mp->local, &local6, sizeof (local6));
13063 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13067 clib_memcpy (&mp->local, &local4, sizeof (local4));
13068 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13071 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13072 mp->encap_vrf_id = ntohl (encap_vrf_id);
13073 mp->decap_vrf_id = ntohl (decap_vrf_id);
13074 mp->protocol = protocol;
13075 mp->vni = ntohl (vni);
13076 mp->is_add = is_add;
13077 mp->is_ipv6 = ipv6_set;
13084 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13085 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13087 vat_main_t *vam = &vat_main;
13088 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13089 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13091 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13092 ntohl (mp->sw_if_index),
13093 format_ip46_address, &local, IP46_TYPE_ANY,
13094 format_ip46_address, &remote, IP46_TYPE_ANY,
13095 ntohl (mp->vni), mp->protocol,
13096 ntohl (mp->mcast_sw_if_index),
13097 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13101 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13102 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13104 vat_main_t *vam = &vat_main;
13105 vat_json_node_t *node = NULL;
13106 struct in_addr ip4;
13107 struct in6_addr ip6;
13109 if (VAT_JSON_ARRAY != vam->json_tree.type)
13111 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13112 vat_json_init_array (&vam->json_tree);
13114 node = vat_json_array_add (&vam->json_tree);
13116 vat_json_init_object (node);
13117 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13120 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13121 vat_json_object_add_ip6 (node, "local", ip6);
13122 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13123 vat_json_object_add_ip6 (node, "remote", ip6);
13127 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13128 vat_json_object_add_ip4 (node, "local", ip4);
13129 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13130 vat_json_object_add_ip4 (node, "remote", ip4);
13132 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13133 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13134 vat_json_object_add_uint (node, "mcast_sw_if_index",
13135 ntohl (mp->mcast_sw_if_index));
13136 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13137 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13138 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13142 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13144 unformat_input_t *i = vam->input;
13145 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13146 vl_api_control_ping_t *mp_ping;
13148 u8 sw_if_index_set = 0;
13151 /* Parse args required to build the message */
13152 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13154 if (unformat (i, "sw_if_index %d", &sw_if_index))
13155 sw_if_index_set = 1;
13160 if (sw_if_index_set == 0)
13165 if (!vam->json_output)
13167 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13168 "sw_if_index", "local", "remote", "vni",
13169 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13172 /* Get list of vxlan-tunnel interfaces */
13173 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13175 mp->sw_if_index = htonl (sw_if_index);
13179 /* Use a control ping for synchronization */
13180 MPING (CONTROL_PING, mp_ping);
13189 format_l2_fib_mac_address (u8 * s, va_list * args)
13191 u8 *a = va_arg (*args, u8 *);
13193 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
13194 a[2], a[3], a[4], a[5], a[6], a[7]);
13197 static void vl_api_l2_fib_table_details_t_handler
13198 (vl_api_l2_fib_table_details_t * mp)
13200 vat_main_t *vam = &vat_main;
13202 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13204 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
13205 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13209 static void vl_api_l2_fib_table_details_t_handler_json
13210 (vl_api_l2_fib_table_details_t * mp)
13212 vat_main_t *vam = &vat_main;
13213 vat_json_node_t *node = NULL;
13215 if (VAT_JSON_ARRAY != vam->json_tree.type)
13217 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13218 vat_json_init_array (&vam->json_tree);
13220 node = vat_json_array_add (&vam->json_tree);
13222 vat_json_init_object (node);
13223 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13224 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
13225 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13226 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13227 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13228 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13232 api_l2_fib_table_dump (vat_main_t * vam)
13234 unformat_input_t *i = vam->input;
13235 vl_api_l2_fib_table_dump_t *mp;
13236 vl_api_control_ping_t *mp_ping;
13241 /* Parse args required to build the message */
13242 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13244 if (unformat (i, "bd_id %d", &bd_id))
13250 if (bd_id_set == 0)
13252 errmsg ("missing bridge domain");
13256 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13258 /* Get list of l2 fib entries */
13259 M (L2_FIB_TABLE_DUMP, mp);
13261 mp->bd_id = ntohl (bd_id);
13264 /* Use a control ping for synchronization */
13265 MPING (CONTROL_PING, mp_ping);
13274 api_interface_name_renumber (vat_main_t * vam)
13276 unformat_input_t *line_input = vam->input;
13277 vl_api_interface_name_renumber_t *mp;
13278 u32 sw_if_index = ~0;
13279 u32 new_show_dev_instance = ~0;
13282 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13284 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13287 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13289 else if (unformat (line_input, "new_show_dev_instance %d",
13290 &new_show_dev_instance))
13296 if (sw_if_index == ~0)
13298 errmsg ("missing interface name or sw_if_index");
13302 if (new_show_dev_instance == ~0)
13304 errmsg ("missing new_show_dev_instance");
13308 M (INTERFACE_NAME_RENUMBER, mp);
13310 mp->sw_if_index = ntohl (sw_if_index);
13311 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13319 api_want_ip4_arp_events (vat_main_t * vam)
13321 unformat_input_t *line_input = vam->input;
13322 vl_api_want_ip4_arp_events_t *mp;
13323 ip4_address_t address;
13324 int address_set = 0;
13325 u32 enable_disable = 1;
13328 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13330 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
13332 else if (unformat (line_input, "del"))
13333 enable_disable = 0;
13338 if (address_set == 0)
13340 errmsg ("missing addresses");
13344 M (WANT_IP4_ARP_EVENTS, mp);
13345 mp->enable_disable = enable_disable;
13346 mp->pid = htonl (getpid ());
13347 mp->address = address.as_u32;
13355 api_want_ip6_nd_events (vat_main_t * vam)
13357 unformat_input_t *line_input = vam->input;
13358 vl_api_want_ip6_nd_events_t *mp;
13359 ip6_address_t address;
13360 int address_set = 0;
13361 u32 enable_disable = 1;
13364 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13366 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
13368 else if (unformat (line_input, "del"))
13369 enable_disable = 0;
13374 if (address_set == 0)
13376 errmsg ("missing addresses");
13380 M (WANT_IP6_ND_EVENTS, mp);
13381 mp->enable_disable = enable_disable;
13382 mp->pid = htonl (getpid ());
13383 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
13391 api_want_l2_macs_events (vat_main_t * vam)
13393 unformat_input_t *line_input = vam->input;
13394 vl_api_want_l2_macs_events_t *mp;
13395 u8 enable_disable = 1;
13396 u32 scan_delay = 0;
13397 u32 max_macs_in_event = 0;
13398 u32 learn_limit = 0;
13401 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13403 if (unformat (line_input, "learn-limit %d", &learn_limit))
13405 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13407 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13409 else if (unformat (line_input, "disable"))
13410 enable_disable = 0;
13415 M (WANT_L2_MACS_EVENTS, mp);
13416 mp->enable_disable = enable_disable;
13417 mp->pid = htonl (getpid ());
13418 mp->learn_limit = htonl (learn_limit);
13419 mp->scan_delay = (u8) scan_delay;
13420 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13427 api_input_acl_set_interface (vat_main_t * vam)
13429 unformat_input_t *i = vam->input;
13430 vl_api_input_acl_set_interface_t *mp;
13432 int sw_if_index_set;
13433 u32 ip4_table_index = ~0;
13434 u32 ip6_table_index = ~0;
13435 u32 l2_table_index = ~0;
13439 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13441 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13442 sw_if_index_set = 1;
13443 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13444 sw_if_index_set = 1;
13445 else if (unformat (i, "del"))
13447 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13449 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13451 else if (unformat (i, "l2-table %d", &l2_table_index))
13455 clib_warning ("parse error '%U'", format_unformat_error, i);
13460 if (sw_if_index_set == 0)
13462 errmsg ("missing interface name or sw_if_index");
13466 M (INPUT_ACL_SET_INTERFACE, mp);
13468 mp->sw_if_index = ntohl (sw_if_index);
13469 mp->ip4_table_index = ntohl (ip4_table_index);
13470 mp->ip6_table_index = ntohl (ip6_table_index);
13471 mp->l2_table_index = ntohl (l2_table_index);
13472 mp->is_add = is_add;
13480 api_ip_address_dump (vat_main_t * vam)
13482 unformat_input_t *i = vam->input;
13483 vl_api_ip_address_dump_t *mp;
13484 vl_api_control_ping_t *mp_ping;
13485 u32 sw_if_index = ~0;
13486 u8 sw_if_index_set = 0;
13491 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13493 if (unformat (i, "sw_if_index %d", &sw_if_index))
13494 sw_if_index_set = 1;
13496 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13497 sw_if_index_set = 1;
13498 else if (unformat (i, "ipv4"))
13500 else if (unformat (i, "ipv6"))
13506 if (ipv4_set && ipv6_set)
13508 errmsg ("ipv4 and ipv6 flags cannot be both set");
13512 if ((!ipv4_set) && (!ipv6_set))
13514 errmsg ("no ipv4 nor ipv6 flag set");
13518 if (sw_if_index_set == 0)
13520 errmsg ("missing interface name or sw_if_index");
13524 vam->current_sw_if_index = sw_if_index;
13525 vam->is_ipv6 = ipv6_set;
13527 M (IP_ADDRESS_DUMP, mp);
13528 mp->sw_if_index = ntohl (sw_if_index);
13529 mp->is_ipv6 = ipv6_set;
13532 /* Use a control ping for synchronization */
13533 MPING (CONTROL_PING, mp_ping);
13541 api_ip_dump (vat_main_t * vam)
13543 vl_api_ip_dump_t *mp;
13544 vl_api_control_ping_t *mp_ping;
13545 unformat_input_t *in = vam->input;
13552 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13554 if (unformat (in, "ipv4"))
13556 else if (unformat (in, "ipv6"))
13562 if (ipv4_set && ipv6_set)
13564 errmsg ("ipv4 and ipv6 flags cannot be both set");
13568 if ((!ipv4_set) && (!ipv6_set))
13570 errmsg ("no ipv4 nor ipv6 flag set");
13574 is_ipv6 = ipv6_set;
13575 vam->is_ipv6 = is_ipv6;
13577 /* free old data */
13578 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13580 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13582 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13585 mp->is_ipv6 = ipv6_set;
13588 /* Use a control ping for synchronization */
13589 MPING (CONTROL_PING, mp_ping);
13597 api_ipsec_spd_add_del (vat_main_t * vam)
13599 unformat_input_t *i = vam->input;
13600 vl_api_ipsec_spd_add_del_t *mp;
13605 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13607 if (unformat (i, "spd_id %d", &spd_id))
13609 else if (unformat (i, "del"))
13613 clib_warning ("parse error '%U'", format_unformat_error, i);
13619 errmsg ("spd_id must be set");
13623 M (IPSEC_SPD_ADD_DEL, mp);
13625 mp->spd_id = ntohl (spd_id);
13626 mp->is_add = is_add;
13634 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13636 unformat_input_t *i = vam->input;
13637 vl_api_ipsec_interface_add_del_spd_t *mp;
13639 u8 sw_if_index_set = 0;
13640 u32 spd_id = (u32) ~ 0;
13644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13646 if (unformat (i, "del"))
13648 else if (unformat (i, "spd_id %d", &spd_id))
13651 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13652 sw_if_index_set = 1;
13653 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13654 sw_if_index_set = 1;
13657 clib_warning ("parse error '%U'", format_unformat_error, i);
13663 if (spd_id == (u32) ~ 0)
13665 errmsg ("spd_id must be set");
13669 if (sw_if_index_set == 0)
13671 errmsg ("missing interface name or sw_if_index");
13675 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13677 mp->spd_id = ntohl (spd_id);
13678 mp->sw_if_index = ntohl (sw_if_index);
13679 mp->is_add = is_add;
13687 api_ipsec_spd_add_del_entry (vat_main_t * vam)
13689 unformat_input_t *i = vam->input;
13690 vl_api_ipsec_spd_add_del_entry_t *mp;
13691 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
13692 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13694 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13695 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13696 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
13697 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
13700 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
13701 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
13702 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
13703 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
13704 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
13705 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
13707 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13709 if (unformat (i, "del"))
13711 if (unformat (i, "outbound"))
13713 if (unformat (i, "inbound"))
13715 else if (unformat (i, "spd_id %d", &spd_id))
13717 else if (unformat (i, "sa_id %d", &sa_id))
13719 else if (unformat (i, "priority %d", &priority))
13721 else if (unformat (i, "protocol %d", &protocol))
13723 else if (unformat (i, "lport_start %d", &lport_start))
13725 else if (unformat (i, "lport_stop %d", &lport_stop))
13727 else if (unformat (i, "rport_start %d", &rport_start))
13729 else if (unformat (i, "rport_stop %d", &rport_stop))
13733 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
13739 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
13746 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
13752 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
13759 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
13765 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
13772 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
13778 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
13784 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13786 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13788 clib_warning ("unsupported action: 'resolve'");
13794 clib_warning ("parse error '%U'", format_unformat_error, i);
13800 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
13802 mp->spd_id = ntohl (spd_id);
13803 mp->priority = ntohl (priority);
13804 mp->is_outbound = is_outbound;
13806 mp->is_ipv6 = is_ipv6;
13807 if (is_ipv6 || is_ip_any)
13809 clib_memcpy (mp->remote_address_start, &raddr6_start,
13810 sizeof (ip6_address_t));
13811 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
13812 sizeof (ip6_address_t));
13813 clib_memcpy (mp->local_address_start, &laddr6_start,
13814 sizeof (ip6_address_t));
13815 clib_memcpy (mp->local_address_stop, &laddr6_stop,
13816 sizeof (ip6_address_t));
13820 clib_memcpy (mp->remote_address_start, &raddr4_start,
13821 sizeof (ip4_address_t));
13822 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
13823 sizeof (ip4_address_t));
13824 clib_memcpy (mp->local_address_start, &laddr4_start,
13825 sizeof (ip4_address_t));
13826 clib_memcpy (mp->local_address_stop, &laddr4_stop,
13827 sizeof (ip4_address_t));
13829 mp->protocol = (u8) protocol;
13830 mp->local_port_start = ntohs ((u16) lport_start);
13831 mp->local_port_stop = ntohs ((u16) lport_stop);
13832 mp->remote_port_start = ntohs ((u16) rport_start);
13833 mp->remote_port_stop = ntohs ((u16) rport_stop);
13834 mp->policy = (u8) policy;
13835 mp->sa_id = ntohl (sa_id);
13836 mp->is_add = is_add;
13837 mp->is_ip_any = is_ip_any;
13844 api_ipsec_sad_add_del_entry (vat_main_t * vam)
13846 unformat_input_t *i = vam->input;
13847 vl_api_ipsec_sad_add_del_entry_t *mp;
13848 u32 sad_id = 0, spi = 0;
13849 u8 *ck = 0, *ik = 0;
13852 u8 protocol = IPSEC_PROTOCOL_AH;
13853 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
13854 u32 crypto_alg = 0, integ_alg = 0;
13855 ip4_address_t tun_src4;
13856 ip4_address_t tun_dst4;
13857 ip6_address_t tun_src6;
13858 ip6_address_t tun_dst6;
13861 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13863 if (unformat (i, "del"))
13865 else if (unformat (i, "sad_id %d", &sad_id))
13867 else if (unformat (i, "spi %d", &spi))
13869 else if (unformat (i, "esp"))
13870 protocol = IPSEC_PROTOCOL_ESP;
13871 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
13874 is_tunnel_ipv6 = 0;
13876 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
13879 is_tunnel_ipv6 = 0;
13881 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
13884 is_tunnel_ipv6 = 1;
13886 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
13889 is_tunnel_ipv6 = 1;
13893 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13895 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13896 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13898 clib_warning ("unsupported crypto-alg: '%U'",
13899 format_ipsec_crypto_alg, crypto_alg);
13903 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13907 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13909 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13910 integ_alg >= IPSEC_INTEG_N_ALG)
13912 clib_warning ("unsupported integ-alg: '%U'",
13913 format_ipsec_integ_alg, integ_alg);
13917 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13921 clib_warning ("parse error '%U'", format_unformat_error, i);
13927 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
13929 mp->sad_id = ntohl (sad_id);
13930 mp->is_add = is_add;
13931 mp->protocol = protocol;
13932 mp->spi = ntohl (spi);
13933 mp->is_tunnel = is_tunnel;
13934 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
13935 mp->crypto_algorithm = crypto_alg;
13936 mp->integrity_algorithm = integ_alg;
13937 mp->crypto_key_length = vec_len (ck);
13938 mp->integrity_key_length = vec_len (ik);
13940 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13941 mp->crypto_key_length = sizeof (mp->crypto_key);
13943 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13944 mp->integrity_key_length = sizeof (mp->integrity_key);
13947 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13949 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13953 if (is_tunnel_ipv6)
13955 clib_memcpy (mp->tunnel_src_address, &tun_src6,
13956 sizeof (ip6_address_t));
13957 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
13958 sizeof (ip6_address_t));
13962 clib_memcpy (mp->tunnel_src_address, &tun_src4,
13963 sizeof (ip4_address_t));
13964 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
13965 sizeof (ip4_address_t));
13975 api_ipsec_sa_set_key (vat_main_t * vam)
13977 unformat_input_t *i = vam->input;
13978 vl_api_ipsec_sa_set_key_t *mp;
13980 u8 *ck = 0, *ik = 0;
13983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13985 if (unformat (i, "sa_id %d", &sa_id))
13987 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13989 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13993 clib_warning ("parse error '%U'", format_unformat_error, i);
13998 M (IPSEC_SA_SET_KEY, mp);
14000 mp->sa_id = ntohl (sa_id);
14001 mp->crypto_key_length = vec_len (ck);
14002 mp->integrity_key_length = vec_len (ik);
14004 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14005 mp->crypto_key_length = sizeof (mp->crypto_key);
14007 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14008 mp->integrity_key_length = sizeof (mp->integrity_key);
14011 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14013 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14021 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14023 unformat_input_t *i = vam->input;
14024 vl_api_ipsec_tunnel_if_add_del_t *mp;
14025 u32 local_spi = 0, remote_spi = 0;
14026 u32 crypto_alg = 0, integ_alg = 0;
14027 u8 *lck = NULL, *rck = NULL;
14028 u8 *lik = NULL, *rik = NULL;
14029 ip4_address_t local_ip = { {0} };
14030 ip4_address_t remote_ip = { {0} };
14033 u8 anti_replay = 0;
14036 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14038 if (unformat (i, "del"))
14040 else if (unformat (i, "esn"))
14042 else if (unformat (i, "anti_replay"))
14044 else if (unformat (i, "local_spi %d", &local_spi))
14046 else if (unformat (i, "remote_spi %d", &remote_spi))
14048 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
14050 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
14052 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14055 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14057 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14059 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14063 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14065 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14066 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14068 errmsg ("unsupported crypto-alg: '%U'\n",
14069 format_ipsec_crypto_alg, crypto_alg);
14075 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14077 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14078 integ_alg >= IPSEC_INTEG_N_ALG)
14080 errmsg ("unsupported integ-alg: '%U'\n",
14081 format_ipsec_integ_alg, integ_alg);
14087 errmsg ("parse error '%U'\n", format_unformat_error, i);
14092 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14094 mp->is_add = is_add;
14096 mp->anti_replay = anti_replay;
14098 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
14099 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
14101 mp->local_spi = htonl (local_spi);
14102 mp->remote_spi = htonl (remote_spi);
14103 mp->crypto_alg = (u8) crypto_alg;
14105 mp->local_crypto_key_len = 0;
14108 mp->local_crypto_key_len = vec_len (lck);
14109 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14110 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14111 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14114 mp->remote_crypto_key_len = 0;
14117 mp->remote_crypto_key_len = vec_len (rck);
14118 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14119 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14120 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14123 mp->integ_alg = (u8) integ_alg;
14125 mp->local_integ_key_len = 0;
14128 mp->local_integ_key_len = vec_len (lik);
14129 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14130 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14131 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14134 mp->remote_integ_key_len = 0;
14137 mp->remote_integ_key_len = vec_len (rik);
14138 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14139 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14140 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14149 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14151 vat_main_t *vam = &vat_main;
14153 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14154 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
14155 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
14156 "tunnel_src_addr %U tunnel_dst_addr %U "
14157 "salt %u seq_outbound %lu last_seq_inbound %lu "
14158 "replay_window %lu total_data_size %lu\n",
14159 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
14161 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
14162 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
14163 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
14164 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14165 mp->tunnel_src_addr,
14166 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14167 mp->tunnel_dst_addr,
14169 clib_net_to_host_u64 (mp->seq_outbound),
14170 clib_net_to_host_u64 (mp->last_seq_inbound),
14171 clib_net_to_host_u64 (mp->replay_window),
14172 clib_net_to_host_u64 (mp->total_data_size));
14175 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14176 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14178 static void vl_api_ipsec_sa_details_t_handler_json
14179 (vl_api_ipsec_sa_details_t * mp)
14181 vat_main_t *vam = &vat_main;
14182 vat_json_node_t *node = NULL;
14183 struct in_addr src_ip4, dst_ip4;
14184 struct in6_addr src_ip6, dst_ip6;
14186 if (VAT_JSON_ARRAY != vam->json_tree.type)
14188 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14189 vat_json_init_array (&vam->json_tree);
14191 node = vat_json_array_add (&vam->json_tree);
14193 vat_json_init_object (node);
14194 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
14195 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14196 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
14197 vat_json_object_add_uint (node, "proto", mp->protocol);
14198 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
14199 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
14200 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
14201 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
14202 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
14203 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
14204 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
14205 mp->crypto_key_len);
14206 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
14207 mp->integ_key_len);
14208 if (mp->is_tunnel_ip6)
14210 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
14211 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
14212 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
14213 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
14217 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
14218 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
14219 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
14220 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
14222 vat_json_object_add_uint (node, "replay_window",
14223 clib_net_to_host_u64 (mp->replay_window));
14224 vat_json_object_add_uint (node, "total_data_size",
14225 clib_net_to_host_u64 (mp->total_data_size));
14230 api_ipsec_sa_dump (vat_main_t * vam)
14232 unformat_input_t *i = vam->input;
14233 vl_api_ipsec_sa_dump_t *mp;
14234 vl_api_control_ping_t *mp_ping;
14238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14240 if (unformat (i, "sa_id %d", &sa_id))
14244 clib_warning ("parse error '%U'", format_unformat_error, i);
14249 M (IPSEC_SA_DUMP, mp);
14251 mp->sa_id = ntohl (sa_id);
14255 /* Use a control ping for synchronization */
14256 M (CONTROL_PING, mp_ping);
14264 api_ikev2_profile_add_del (vat_main_t * vam)
14266 unformat_input_t *i = vam->input;
14267 vl_api_ikev2_profile_add_del_t *mp;
14272 const char *valid_chars = "a-zA-Z0-9_";
14274 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14276 if (unformat (i, "del"))
14278 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14279 vec_add1 (name, 0);
14282 errmsg ("parse error '%U'", format_unformat_error, i);
14287 if (!vec_len (name))
14289 errmsg ("profile name must be specified");
14293 if (vec_len (name) > 64)
14295 errmsg ("profile name too long");
14299 M (IKEV2_PROFILE_ADD_DEL, mp);
14301 clib_memcpy (mp->name, name, vec_len (name));
14302 mp->is_add = is_add;
14311 api_ikev2_profile_set_auth (vat_main_t * vam)
14313 unformat_input_t *i = vam->input;
14314 vl_api_ikev2_profile_set_auth_t *mp;
14317 u32 auth_method = 0;
14321 const char *valid_chars = "a-zA-Z0-9_";
14323 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14325 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14326 vec_add1 (name, 0);
14327 else if (unformat (i, "auth_method %U",
14328 unformat_ikev2_auth_method, &auth_method))
14330 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
14332 else if (unformat (i, "auth_data %v", &data))
14336 errmsg ("parse error '%U'", format_unformat_error, i);
14341 if (!vec_len (name))
14343 errmsg ("profile name must be specified");
14347 if (vec_len (name) > 64)
14349 errmsg ("profile name too long");
14353 if (!vec_len (data))
14355 errmsg ("auth_data must be specified");
14361 errmsg ("auth_method must be specified");
14365 M (IKEV2_PROFILE_SET_AUTH, mp);
14367 mp->is_hex = is_hex;
14368 mp->auth_method = (u8) auth_method;
14369 mp->data_len = vec_len (data);
14370 clib_memcpy (mp->name, name, vec_len (name));
14371 clib_memcpy (mp->data, data, vec_len (data));
14381 api_ikev2_profile_set_id (vat_main_t * vam)
14383 unformat_input_t *i = vam->input;
14384 vl_api_ikev2_profile_set_id_t *mp;
14392 const char *valid_chars = "a-zA-Z0-9_";
14394 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14396 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14397 vec_add1 (name, 0);
14398 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
14400 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
14402 data = vec_new (u8, 4);
14403 clib_memcpy (data, ip4.as_u8, 4);
14405 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
14407 else if (unformat (i, "id_data %v", &data))
14409 else if (unformat (i, "local"))
14411 else if (unformat (i, "remote"))
14415 errmsg ("parse error '%U'", format_unformat_error, i);
14420 if (!vec_len (name))
14422 errmsg ("profile name must be specified");
14426 if (vec_len (name) > 64)
14428 errmsg ("profile name too long");
14432 if (!vec_len (data))
14434 errmsg ("id_data must be specified");
14440 errmsg ("id_type must be specified");
14444 M (IKEV2_PROFILE_SET_ID, mp);
14446 mp->is_local = is_local;
14447 mp->id_type = (u8) id_type;
14448 mp->data_len = vec_len (data);
14449 clib_memcpy (mp->name, name, vec_len (name));
14450 clib_memcpy (mp->data, data, vec_len (data));
14460 api_ikev2_profile_set_ts (vat_main_t * vam)
14462 unformat_input_t *i = vam->input;
14463 vl_api_ikev2_profile_set_ts_t *mp;
14466 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
14467 ip4_address_t start_addr, end_addr;
14469 const char *valid_chars = "a-zA-Z0-9_";
14472 start_addr.as_u32 = 0;
14473 end_addr.as_u32 = (u32) ~ 0;
14475 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14477 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14478 vec_add1 (name, 0);
14479 else if (unformat (i, "protocol %d", &proto))
14481 else if (unformat (i, "start_port %d", &start_port))
14483 else if (unformat (i, "end_port %d", &end_port))
14486 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
14488 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
14490 else if (unformat (i, "local"))
14492 else if (unformat (i, "remote"))
14496 errmsg ("parse error '%U'", format_unformat_error, i);
14501 if (!vec_len (name))
14503 errmsg ("profile name must be specified");
14507 if (vec_len (name) > 64)
14509 errmsg ("profile name too long");
14513 M (IKEV2_PROFILE_SET_TS, mp);
14515 mp->is_local = is_local;
14516 mp->proto = (u8) proto;
14517 mp->start_port = (u16) start_port;
14518 mp->end_port = (u16) end_port;
14519 mp->start_addr = start_addr.as_u32;
14520 mp->end_addr = end_addr.as_u32;
14521 clib_memcpy (mp->name, name, vec_len (name));
14530 api_ikev2_set_local_key (vat_main_t * vam)
14532 unformat_input_t *i = vam->input;
14533 vl_api_ikev2_set_local_key_t *mp;
14537 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14539 if (unformat (i, "file %v", &file))
14540 vec_add1 (file, 0);
14543 errmsg ("parse error '%U'", format_unformat_error, i);
14548 if (!vec_len (file))
14550 errmsg ("RSA key file must be specified");
14554 if (vec_len (file) > 256)
14556 errmsg ("file name too long");
14560 M (IKEV2_SET_LOCAL_KEY, mp);
14562 clib_memcpy (mp->key_file, file, vec_len (file));
14571 api_ikev2_set_responder (vat_main_t * vam)
14573 unformat_input_t *i = vam->input;
14574 vl_api_ikev2_set_responder_t *mp;
14577 u32 sw_if_index = ~0;
14578 ip4_address_t address;
14580 const char *valid_chars = "a-zA-Z0-9_";
14582 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14585 (i, "%U interface %d address %U", unformat_token, valid_chars,
14586 &name, &sw_if_index, unformat_ip4_address, &address))
14587 vec_add1 (name, 0);
14590 errmsg ("parse error '%U'", format_unformat_error, i);
14595 if (!vec_len (name))
14597 errmsg ("profile name must be specified");
14601 if (vec_len (name) > 64)
14603 errmsg ("profile name too long");
14607 M (IKEV2_SET_RESPONDER, mp);
14609 clib_memcpy (mp->name, name, vec_len (name));
14612 mp->sw_if_index = sw_if_index;
14613 clib_memcpy (mp->address, &address, sizeof (address));
14621 api_ikev2_set_ike_transforms (vat_main_t * vam)
14623 unformat_input_t *i = vam->input;
14624 vl_api_ikev2_set_ike_transforms_t *mp;
14627 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14629 const char *valid_chars = "a-zA-Z0-9_";
14631 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14633 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14634 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14635 vec_add1 (name, 0);
14638 errmsg ("parse error '%U'", format_unformat_error, i);
14643 if (!vec_len (name))
14645 errmsg ("profile name must be specified");
14649 if (vec_len (name) > 64)
14651 errmsg ("profile name too long");
14655 M (IKEV2_SET_IKE_TRANSFORMS, mp);
14657 clib_memcpy (mp->name, name, vec_len (name));
14659 mp->crypto_alg = crypto_alg;
14660 mp->crypto_key_size = crypto_key_size;
14661 mp->integ_alg = integ_alg;
14662 mp->dh_group = dh_group;
14671 api_ikev2_set_esp_transforms (vat_main_t * vam)
14673 unformat_input_t *i = vam->input;
14674 vl_api_ikev2_set_esp_transforms_t *mp;
14677 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14679 const char *valid_chars = "a-zA-Z0-9_";
14681 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14683 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14684 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14685 vec_add1 (name, 0);
14688 errmsg ("parse error '%U'", format_unformat_error, i);
14693 if (!vec_len (name))
14695 errmsg ("profile name must be specified");
14699 if (vec_len (name) > 64)
14701 errmsg ("profile name too long");
14705 M (IKEV2_SET_ESP_TRANSFORMS, mp);
14707 clib_memcpy (mp->name, name, vec_len (name));
14709 mp->crypto_alg = crypto_alg;
14710 mp->crypto_key_size = crypto_key_size;
14711 mp->integ_alg = integ_alg;
14712 mp->dh_group = dh_group;
14720 api_ikev2_set_sa_lifetime (vat_main_t * vam)
14722 unformat_input_t *i = vam->input;
14723 vl_api_ikev2_set_sa_lifetime_t *mp;
14726 u64 lifetime, lifetime_maxdata;
14727 u32 lifetime_jitter, handover;
14729 const char *valid_chars = "a-zA-Z0-9_";
14731 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14733 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
14734 &lifetime, &lifetime_jitter, &handover,
14735 &lifetime_maxdata))
14736 vec_add1 (name, 0);
14739 errmsg ("parse error '%U'", format_unformat_error, i);
14744 if (!vec_len (name))
14746 errmsg ("profile name must be specified");
14750 if (vec_len (name) > 64)
14752 errmsg ("profile name too long");
14756 M (IKEV2_SET_SA_LIFETIME, mp);
14758 clib_memcpy (mp->name, name, vec_len (name));
14760 mp->lifetime = lifetime;
14761 mp->lifetime_jitter = lifetime_jitter;
14762 mp->handover = handover;
14763 mp->lifetime_maxdata = lifetime_maxdata;
14771 api_ikev2_initiate_sa_init (vat_main_t * vam)
14773 unformat_input_t *i = vam->input;
14774 vl_api_ikev2_initiate_sa_init_t *mp;
14778 const char *valid_chars = "a-zA-Z0-9_";
14780 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14782 if (unformat (i, "%U", unformat_token, valid_chars, &name))
14783 vec_add1 (name, 0);
14786 errmsg ("parse error '%U'", format_unformat_error, i);
14791 if (!vec_len (name))
14793 errmsg ("profile name must be specified");
14797 if (vec_len (name) > 64)
14799 errmsg ("profile name too long");
14803 M (IKEV2_INITIATE_SA_INIT, mp);
14805 clib_memcpy (mp->name, name, vec_len (name));
14814 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
14816 unformat_input_t *i = vam->input;
14817 vl_api_ikev2_initiate_del_ike_sa_t *mp;
14822 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14824 if (unformat (i, "%lx", &ispi))
14828 errmsg ("parse error '%U'", format_unformat_error, i);
14833 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
14843 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
14845 unformat_input_t *i = vam->input;
14846 vl_api_ikev2_initiate_del_child_sa_t *mp;
14851 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14853 if (unformat (i, "%x", &ispi))
14857 errmsg ("parse error '%U'", format_unformat_error, i);
14862 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
14872 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
14874 unformat_input_t *i = vam->input;
14875 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
14880 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14882 if (unformat (i, "%x", &ispi))
14886 errmsg ("parse error '%U'", format_unformat_error, i);
14891 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
14904 api_map_add_domain (vat_main_t * vam)
14906 unformat_input_t *i = vam->input;
14907 vl_api_map_add_domain_t *mp;
14909 ip4_address_t ip4_prefix;
14910 ip6_address_t ip6_prefix;
14911 ip6_address_t ip6_src;
14912 u32 num_m_args = 0;
14913 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
14914 0, psid_length = 0;
14915 u8 is_translation = 0;
14917 u32 ip6_src_len = 128;
14920 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14922 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
14923 &ip4_prefix, &ip4_prefix_len))
14925 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
14926 &ip6_prefix, &ip6_prefix_len))
14930 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
14933 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
14935 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
14937 else if (unformat (i, "psid-offset %d", &psid_offset))
14939 else if (unformat (i, "psid-len %d", &psid_length))
14941 else if (unformat (i, "mtu %d", &mtu))
14943 else if (unformat (i, "map-t"))
14944 is_translation = 1;
14947 clib_warning ("parse error '%U'", format_unformat_error, i);
14952 if (num_m_args < 3)
14954 errmsg ("mandatory argument(s) missing");
14958 /* Construct the API message */
14959 M (MAP_ADD_DOMAIN, mp);
14961 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
14962 mp->ip4_prefix_len = ip4_prefix_len;
14964 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
14965 mp->ip6_prefix_len = ip6_prefix_len;
14967 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
14968 mp->ip6_src_prefix_len = ip6_src_len;
14970 mp->ea_bits_len = ea_bits_len;
14971 mp->psid_offset = psid_offset;
14972 mp->psid_length = psid_length;
14973 mp->is_translation = is_translation;
14974 mp->mtu = htons (mtu);
14979 /* Wait for a reply, return good/bad news */
14985 api_map_del_domain (vat_main_t * vam)
14987 unformat_input_t *i = vam->input;
14988 vl_api_map_del_domain_t *mp;
14990 u32 num_m_args = 0;
14994 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14996 if (unformat (i, "index %d", &index))
15000 clib_warning ("parse error '%U'", format_unformat_error, i);
15005 if (num_m_args != 1)
15007 errmsg ("mandatory argument(s) missing");
15011 /* Construct the API message */
15012 M (MAP_DEL_DOMAIN, mp);
15014 mp->index = ntohl (index);
15019 /* Wait for a reply, return good/bad news */
15025 api_map_add_del_rule (vat_main_t * vam)
15027 unformat_input_t *i = vam->input;
15028 vl_api_map_add_del_rule_t *mp;
15030 ip6_address_t ip6_dst;
15031 u32 num_m_args = 0, index, psid = 0;
15034 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15036 if (unformat (i, "index %d", &index))
15038 else if (unformat (i, "psid %d", &psid))
15040 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
15042 else if (unformat (i, "del"))
15048 clib_warning ("parse error '%U'", format_unformat_error, i);
15053 /* Construct the API message */
15054 M (MAP_ADD_DEL_RULE, mp);
15056 mp->index = ntohl (index);
15057 mp->is_add = is_add;
15058 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
15059 mp->psid = ntohs (psid);
15064 /* Wait for a reply, return good/bad news */
15070 api_map_domain_dump (vat_main_t * vam)
15072 vl_api_map_domain_dump_t *mp;
15073 vl_api_control_ping_t *mp_ping;
15076 /* Construct the API message */
15077 M (MAP_DOMAIN_DUMP, mp);
15082 /* Use a control ping for synchronization */
15083 MPING (CONTROL_PING, mp_ping);
15091 api_map_rule_dump (vat_main_t * vam)
15093 unformat_input_t *i = vam->input;
15094 vl_api_map_rule_dump_t *mp;
15095 vl_api_control_ping_t *mp_ping;
15096 u32 domain_index = ~0;
15099 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15101 if (unformat (i, "index %u", &domain_index))
15107 if (domain_index == ~0)
15109 clib_warning ("parse error: domain index expected");
15113 /* Construct the API message */
15114 M (MAP_RULE_DUMP, mp);
15116 mp->domain_index = htonl (domain_index);
15121 /* Use a control ping for synchronization */
15122 MPING (CONTROL_PING, mp_ping);
15129 static void vl_api_map_add_domain_reply_t_handler
15130 (vl_api_map_add_domain_reply_t * mp)
15132 vat_main_t *vam = &vat_main;
15133 i32 retval = ntohl (mp->retval);
15135 if (vam->async_mode)
15137 vam->async_errors += (retval < 0);
15141 vam->retval = retval;
15142 vam->result_ready = 1;
15146 static void vl_api_map_add_domain_reply_t_handler_json
15147 (vl_api_map_add_domain_reply_t * mp)
15149 vat_main_t *vam = &vat_main;
15150 vat_json_node_t node;
15152 vat_json_init_object (&node);
15153 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
15154 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
15156 vat_json_print (vam->ofp, &node);
15157 vat_json_free (&node);
15159 vam->retval = ntohl (mp->retval);
15160 vam->result_ready = 1;
15164 api_get_first_msg_id (vat_main_t * vam)
15166 vl_api_get_first_msg_id_t *mp;
15167 unformat_input_t *i = vam->input;
15172 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15174 if (unformat (i, "client %s", &name))
15182 errmsg ("missing client name");
15185 vec_add1 (name, 0);
15187 if (vec_len (name) > 63)
15189 errmsg ("client name too long");
15193 M (GET_FIRST_MSG_ID, mp);
15194 clib_memcpy (mp->name, name, vec_len (name));
15201 api_cop_interface_enable_disable (vat_main_t * vam)
15203 unformat_input_t *line_input = vam->input;
15204 vl_api_cop_interface_enable_disable_t *mp;
15205 u32 sw_if_index = ~0;
15206 u8 enable_disable = 1;
15209 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15211 if (unformat (line_input, "disable"))
15212 enable_disable = 0;
15213 if (unformat (line_input, "enable"))
15214 enable_disable = 1;
15215 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15216 vam, &sw_if_index))
15218 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15224 if (sw_if_index == ~0)
15226 errmsg ("missing interface name or sw_if_index");
15230 /* Construct the API message */
15231 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15232 mp->sw_if_index = ntohl (sw_if_index);
15233 mp->enable_disable = enable_disable;
15237 /* Wait for the reply */
15243 api_cop_whitelist_enable_disable (vat_main_t * vam)
15245 unformat_input_t *line_input = vam->input;
15246 vl_api_cop_whitelist_enable_disable_t *mp;
15247 u32 sw_if_index = ~0;
15248 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15252 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15254 if (unformat (line_input, "ip4"))
15256 else if (unformat (line_input, "ip6"))
15258 else if (unformat (line_input, "default"))
15260 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15261 vam, &sw_if_index))
15263 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15265 else if (unformat (line_input, "fib-id %d", &fib_id))
15271 if (sw_if_index == ~0)
15273 errmsg ("missing interface name or sw_if_index");
15277 /* Construct the API message */
15278 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15279 mp->sw_if_index = ntohl (sw_if_index);
15280 mp->fib_id = ntohl (fib_id);
15283 mp->default_cop = default_cop;
15287 /* Wait for the reply */
15293 api_get_node_graph (vat_main_t * vam)
15295 vl_api_get_node_graph_t *mp;
15298 M (GET_NODE_GRAPH, mp);
15302 /* Wait for the reply */
15308 /** Used for parsing LISP eids */
15309 typedef CLIB_PACKED(struct{
15310 u8 addr[16]; /**< eid address */
15311 u32 len; /**< prefix length if IP */
15312 u8 type; /**< type of eid */
15317 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15319 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15321 memset (a, 0, sizeof (a[0]));
15323 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15325 a->type = 0; /* ipv4 type */
15327 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15329 a->type = 1; /* ipv6 type */
15331 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15333 a->type = 2; /* mac type */
15335 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15337 a->type = 3; /* NSH type */
15338 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15339 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15346 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15355 lisp_eid_size_vat (u8 type)
15372 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15374 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15378 api_one_add_del_locator_set (vat_main_t * vam)
15380 unformat_input_t *input = vam->input;
15381 vl_api_one_add_del_locator_set_t *mp;
15383 u8 *locator_set_name = NULL;
15384 u8 locator_set_name_set = 0;
15385 vl_api_local_locator_t locator, *locators = 0;
15386 u32 sw_if_index, priority, weight;
15390 /* Parse args required to build the message */
15391 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15393 if (unformat (input, "del"))
15397 else if (unformat (input, "locator-set %s", &locator_set_name))
15399 locator_set_name_set = 1;
15401 else if (unformat (input, "sw_if_index %u p %u w %u",
15402 &sw_if_index, &priority, &weight))
15404 locator.sw_if_index = htonl (sw_if_index);
15405 locator.priority = priority;
15406 locator.weight = weight;
15407 vec_add1 (locators, locator);
15411 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15412 &sw_if_index, &priority, &weight))
15414 locator.sw_if_index = htonl (sw_if_index);
15415 locator.priority = priority;
15416 locator.weight = weight;
15417 vec_add1 (locators, locator);
15423 if (locator_set_name_set == 0)
15425 errmsg ("missing locator-set name");
15426 vec_free (locators);
15430 if (vec_len (locator_set_name) > 64)
15432 errmsg ("locator-set name too long");
15433 vec_free (locator_set_name);
15434 vec_free (locators);
15437 vec_add1 (locator_set_name, 0);
15439 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15441 /* Construct the API message */
15442 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15444 mp->is_add = is_add;
15445 clib_memcpy (mp->locator_set_name, locator_set_name,
15446 vec_len (locator_set_name));
15447 vec_free (locator_set_name);
15449 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15451 clib_memcpy (mp->locators, locators, data_len);
15452 vec_free (locators);
15457 /* Wait for a reply... */
15462 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15465 api_one_add_del_locator (vat_main_t * vam)
15467 unformat_input_t *input = vam->input;
15468 vl_api_one_add_del_locator_t *mp;
15469 u32 tmp_if_index = ~0;
15470 u32 sw_if_index = ~0;
15471 u8 sw_if_index_set = 0;
15472 u8 sw_if_index_if_name_set = 0;
15474 u8 priority_set = 0;
15478 u8 *locator_set_name = NULL;
15479 u8 locator_set_name_set = 0;
15482 /* Parse args required to build the message */
15483 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15485 if (unformat (input, "del"))
15489 else if (unformat (input, "locator-set %s", &locator_set_name))
15491 locator_set_name_set = 1;
15493 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15496 sw_if_index_if_name_set = 1;
15497 sw_if_index = tmp_if_index;
15499 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15501 sw_if_index_set = 1;
15502 sw_if_index = tmp_if_index;
15504 else if (unformat (input, "p %d", &priority))
15508 else if (unformat (input, "w %d", &weight))
15516 if (locator_set_name_set == 0)
15518 errmsg ("missing locator-set name");
15522 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15524 errmsg ("missing sw_if_index");
15525 vec_free (locator_set_name);
15529 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15531 errmsg ("cannot use both params interface name and sw_if_index");
15532 vec_free (locator_set_name);
15536 if (priority_set == 0)
15538 errmsg ("missing locator-set priority");
15539 vec_free (locator_set_name);
15543 if (weight_set == 0)
15545 errmsg ("missing locator-set weight");
15546 vec_free (locator_set_name);
15550 if (vec_len (locator_set_name) > 64)
15552 errmsg ("locator-set name too long");
15553 vec_free (locator_set_name);
15556 vec_add1 (locator_set_name, 0);
15558 /* Construct the API message */
15559 M (ONE_ADD_DEL_LOCATOR, mp);
15561 mp->is_add = is_add;
15562 mp->sw_if_index = ntohl (sw_if_index);
15563 mp->priority = priority;
15564 mp->weight = weight;
15565 clib_memcpy (mp->locator_set_name, locator_set_name,
15566 vec_len (locator_set_name));
15567 vec_free (locator_set_name);
15572 /* Wait for a reply... */
15577 #define api_lisp_add_del_locator api_one_add_del_locator
15580 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15582 u32 *key_id = va_arg (*args, u32 *);
15585 if (unformat (input, "%s", &s))
15587 if (!strcmp ((char *) s, "sha1"))
15588 key_id[0] = HMAC_SHA_1_96;
15589 else if (!strcmp ((char *) s, "sha256"))
15590 key_id[0] = HMAC_SHA_256_128;
15593 clib_warning ("invalid key_id: '%s'", s);
15594 key_id[0] = HMAC_NO_KEY;
15605 api_one_add_del_local_eid (vat_main_t * vam)
15607 unformat_input_t *input = vam->input;
15608 vl_api_one_add_del_local_eid_t *mp;
15611 lisp_eid_vat_t _eid, *eid = &_eid;
15612 u8 *locator_set_name = 0;
15613 u8 locator_set_name_set = 0;
15619 /* Parse args required to build the message */
15620 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15622 if (unformat (input, "del"))
15626 else if (unformat (input, "vni %d", &vni))
15630 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15634 else if (unformat (input, "locator-set %s", &locator_set_name))
15636 locator_set_name_set = 1;
15638 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15640 else if (unformat (input, "secret-key %_%v%_", &key))
15646 if (locator_set_name_set == 0)
15648 errmsg ("missing locator-set name");
15654 errmsg ("EID address not set!");
15655 vec_free (locator_set_name);
15659 if (key && (0 == key_id))
15661 errmsg ("invalid key_id!");
15665 if (vec_len (key) > 64)
15667 errmsg ("key too long");
15672 if (vec_len (locator_set_name) > 64)
15674 errmsg ("locator-set name too long");
15675 vec_free (locator_set_name);
15678 vec_add1 (locator_set_name, 0);
15680 /* Construct the API message */
15681 M (ONE_ADD_DEL_LOCAL_EID, mp);
15683 mp->is_add = is_add;
15684 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15685 mp->eid_type = eid->type;
15686 mp->prefix_len = eid->len;
15687 mp->vni = clib_host_to_net_u32 (vni);
15688 mp->key_id = clib_host_to_net_u16 (key_id);
15689 clib_memcpy (mp->locator_set_name, locator_set_name,
15690 vec_len (locator_set_name));
15691 clib_memcpy (mp->key, key, vec_len (key));
15693 vec_free (locator_set_name);
15699 /* Wait for a reply... */
15704 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15707 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15709 u32 dp_table = 0, vni = 0;;
15710 unformat_input_t *input = vam->input;
15711 vl_api_gpe_add_del_fwd_entry_t *mp;
15713 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15714 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15715 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15716 u32 action = ~0, w;
15717 ip4_address_t rmt_rloc4, lcl_rloc4;
15718 ip6_address_t rmt_rloc6, lcl_rloc6;
15719 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15722 memset (&rloc, 0, sizeof (rloc));
15724 /* Parse args required to build the message */
15725 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15727 if (unformat (input, "del"))
15729 else if (unformat (input, "add"))
15731 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15735 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15739 else if (unformat (input, "vrf %d", &dp_table))
15741 else if (unformat (input, "bd %d", &dp_table))
15743 else if (unformat (input, "vni %d", &vni))
15745 else if (unformat (input, "w %d", &w))
15749 errmsg ("No RLOC configured for setting priority/weight!");
15752 curr_rloc->weight = w;
15754 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15755 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15759 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15761 vec_add1 (lcl_locs, rloc);
15763 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15764 vec_add1 (rmt_locs, rloc);
15765 /* weight saved in rmt loc */
15766 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15768 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15769 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15772 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15774 vec_add1 (lcl_locs, rloc);
15776 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15777 vec_add1 (rmt_locs, rloc);
15778 /* weight saved in rmt loc */
15779 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15781 else if (unformat (input, "action %d", &action))
15787 clib_warning ("parse error '%U'", format_unformat_error, input);
15794 errmsg ("remote eid addresses not set");
15798 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15800 errmsg ("eid types don't match");
15804 if (0 == rmt_locs && (u32) ~ 0 == action)
15806 errmsg ("action not set for negative mapping");
15810 /* Construct the API message */
15811 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15812 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15814 mp->is_add = is_add;
15815 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15816 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15817 mp->eid_type = rmt_eid->type;
15818 mp->dp_table = clib_host_to_net_u32 (dp_table);
15819 mp->vni = clib_host_to_net_u32 (vni);
15820 mp->rmt_len = rmt_eid->len;
15821 mp->lcl_len = lcl_eid->len;
15822 mp->action = action;
15824 if (0 != rmt_locs && 0 != lcl_locs)
15826 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15827 clib_memcpy (mp->locs, lcl_locs,
15828 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15830 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15831 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15832 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15834 vec_free (lcl_locs);
15835 vec_free (rmt_locs);
15840 /* Wait for a reply... */
15846 api_one_add_del_map_server (vat_main_t * vam)
15848 unformat_input_t *input = vam->input;
15849 vl_api_one_add_del_map_server_t *mp;
15853 ip4_address_t ipv4;
15854 ip6_address_t ipv6;
15857 /* Parse args required to build the message */
15858 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15860 if (unformat (input, "del"))
15864 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15868 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15876 if (ipv4_set && ipv6_set)
15878 errmsg ("both eid v4 and v6 addresses set");
15882 if (!ipv4_set && !ipv6_set)
15884 errmsg ("eid addresses not set");
15888 /* Construct the API message */
15889 M (ONE_ADD_DEL_MAP_SERVER, mp);
15891 mp->is_add = is_add;
15895 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15900 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15906 /* Wait for a reply... */
15911 #define api_lisp_add_del_map_server api_one_add_del_map_server
15914 api_one_add_del_map_resolver (vat_main_t * vam)
15916 unformat_input_t *input = vam->input;
15917 vl_api_one_add_del_map_resolver_t *mp;
15921 ip4_address_t ipv4;
15922 ip6_address_t ipv6;
15925 /* Parse args required to build the message */
15926 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15928 if (unformat (input, "del"))
15932 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15936 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15944 if (ipv4_set && ipv6_set)
15946 errmsg ("both eid v4 and v6 addresses set");
15950 if (!ipv4_set && !ipv6_set)
15952 errmsg ("eid addresses not set");
15956 /* Construct the API message */
15957 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
15959 mp->is_add = is_add;
15963 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15968 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15974 /* Wait for a reply... */
15979 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
15982 api_lisp_gpe_enable_disable (vat_main_t * vam)
15984 unformat_input_t *input = vam->input;
15985 vl_api_gpe_enable_disable_t *mp;
15990 /* Parse args required to build the message */
15991 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15993 if (unformat (input, "enable"))
15998 else if (unformat (input, "disable"))
16009 errmsg ("Value not set");
16013 /* Construct the API message */
16014 M (GPE_ENABLE_DISABLE, mp);
16021 /* Wait for a reply... */
16027 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16029 unformat_input_t *input = vam->input;
16030 vl_api_one_rloc_probe_enable_disable_t *mp;
16035 /* Parse args required to build the message */
16036 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16038 if (unformat (input, "enable"))
16043 else if (unformat (input, "disable"))
16051 errmsg ("Value not set");
16055 /* Construct the API message */
16056 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16058 mp->is_enabled = is_en;
16063 /* Wait for a reply... */
16068 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16071 api_one_map_register_enable_disable (vat_main_t * vam)
16073 unformat_input_t *input = vam->input;
16074 vl_api_one_map_register_enable_disable_t *mp;
16079 /* Parse args required to build the message */
16080 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16082 if (unformat (input, "enable"))
16087 else if (unformat (input, "disable"))
16095 errmsg ("Value not set");
16099 /* Construct the API message */
16100 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16102 mp->is_enabled = is_en;
16107 /* Wait for a reply... */
16112 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16115 api_one_enable_disable (vat_main_t * vam)
16117 unformat_input_t *input = vam->input;
16118 vl_api_one_enable_disable_t *mp;
16123 /* Parse args required to build the message */
16124 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16126 if (unformat (input, "enable"))
16131 else if (unformat (input, "disable"))
16141 errmsg ("Value not set");
16145 /* Construct the API message */
16146 M (ONE_ENABLE_DISABLE, mp);
16153 /* Wait for a reply... */
16158 #define api_lisp_enable_disable api_one_enable_disable
16161 api_show_one_map_register_state (vat_main_t * vam)
16163 vl_api_show_one_map_register_state_t *mp;
16166 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16171 /* wait for reply */
16176 #define api_show_lisp_map_register_state api_show_one_map_register_state
16179 api_show_one_rloc_probe_state (vat_main_t * vam)
16181 vl_api_show_one_rloc_probe_state_t *mp;
16184 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16189 /* wait for reply */
16194 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16197 api_one_add_del_ndp_entry (vat_main_t * vam)
16199 vl_api_one_add_del_ndp_entry_t *mp;
16200 unformat_input_t *input = vam->input;
16205 u8 mac[6] = { 0, };
16206 u8 ip6[16] = { 0, };
16210 /* Parse args required to build the message */
16211 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16213 if (unformat (input, "del"))
16215 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16217 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16219 else if (unformat (input, "bd %d", &bd))
16223 errmsg ("parse error '%U'", format_unformat_error, input);
16228 if (!bd_set || !ip_set || (!mac_set && is_add))
16230 errmsg ("Missing BD, IP or MAC!");
16234 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16235 mp->is_add = is_add;
16236 clib_memcpy (mp->mac, mac, 6);
16237 mp->bd = clib_host_to_net_u32 (bd);
16238 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16243 /* wait for reply */
16249 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16251 vl_api_one_add_del_l2_arp_entry_t *mp;
16252 unformat_input_t *input = vam->input;
16257 u8 mac[6] = { 0, };
16258 u32 ip4 = 0, bd = ~0;
16261 /* Parse args required to build the message */
16262 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16264 if (unformat (input, "del"))
16266 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16268 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16270 else if (unformat (input, "bd %d", &bd))
16274 errmsg ("parse error '%U'", format_unformat_error, input);
16279 if (!bd_set || !ip_set || (!mac_set && is_add))
16281 errmsg ("Missing BD, IP or MAC!");
16285 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16286 mp->is_add = is_add;
16287 clib_memcpy (mp->mac, mac, 6);
16288 mp->bd = clib_host_to_net_u32 (bd);
16294 /* wait for reply */
16300 api_one_ndp_bd_get (vat_main_t * vam)
16302 vl_api_one_ndp_bd_get_t *mp;
16305 M (ONE_NDP_BD_GET, mp);
16310 /* wait for reply */
16316 api_one_ndp_entries_get (vat_main_t * vam)
16318 vl_api_one_ndp_entries_get_t *mp;
16319 unformat_input_t *input = vam->input;
16324 /* Parse args required to build the message */
16325 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16327 if (unformat (input, "bd %d", &bd))
16331 errmsg ("parse error '%U'", format_unformat_error, input);
16338 errmsg ("Expected bridge domain!");
16342 M (ONE_NDP_ENTRIES_GET, mp);
16343 mp->bd = clib_host_to_net_u32 (bd);
16348 /* wait for reply */
16354 api_one_l2_arp_bd_get (vat_main_t * vam)
16356 vl_api_one_l2_arp_bd_get_t *mp;
16359 M (ONE_L2_ARP_BD_GET, mp);
16364 /* wait for reply */
16370 api_one_l2_arp_entries_get (vat_main_t * vam)
16372 vl_api_one_l2_arp_entries_get_t *mp;
16373 unformat_input_t *input = vam->input;
16378 /* Parse args required to build the message */
16379 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16381 if (unformat (input, "bd %d", &bd))
16385 errmsg ("parse error '%U'", format_unformat_error, input);
16392 errmsg ("Expected bridge domain!");
16396 M (ONE_L2_ARP_ENTRIES_GET, mp);
16397 mp->bd = clib_host_to_net_u32 (bd);
16402 /* wait for reply */
16408 api_one_stats_enable_disable (vat_main_t * vam)
16410 vl_api_one_stats_enable_disable_t *mp;
16411 unformat_input_t *input = vam->input;
16416 /* Parse args required to build the message */
16417 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16419 if (unformat (input, "enable"))
16424 else if (unformat (input, "disable"))
16434 errmsg ("Value not set");
16438 M (ONE_STATS_ENABLE_DISABLE, mp);
16444 /* wait for reply */
16450 api_show_one_stats_enable_disable (vat_main_t * vam)
16452 vl_api_show_one_stats_enable_disable_t *mp;
16455 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16460 /* wait for reply */
16466 api_show_one_map_request_mode (vat_main_t * vam)
16468 vl_api_show_one_map_request_mode_t *mp;
16471 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16476 /* wait for reply */
16481 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16484 api_one_map_request_mode (vat_main_t * vam)
16486 unformat_input_t *input = vam->input;
16487 vl_api_one_map_request_mode_t *mp;
16491 /* Parse args required to build the message */
16492 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16494 if (unformat (input, "dst-only"))
16496 else if (unformat (input, "src-dst"))
16500 errmsg ("parse error '%U'", format_unformat_error, input);
16505 M (ONE_MAP_REQUEST_MODE, mp);
16512 /* wait for reply */
16517 #define api_lisp_map_request_mode api_one_map_request_mode
16520 * Enable/disable ONE proxy ITR.
16522 * @param vam vpp API test context
16523 * @return return code
16526 api_one_pitr_set_locator_set (vat_main_t * vam)
16528 u8 ls_name_set = 0;
16529 unformat_input_t *input = vam->input;
16530 vl_api_one_pitr_set_locator_set_t *mp;
16535 /* Parse args required to build the message */
16536 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16538 if (unformat (input, "del"))
16540 else if (unformat (input, "locator-set %s", &ls_name))
16544 errmsg ("parse error '%U'", format_unformat_error, input);
16551 errmsg ("locator-set name not set!");
16555 M (ONE_PITR_SET_LOCATOR_SET, mp);
16557 mp->is_add = is_add;
16558 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16559 vec_free (ls_name);
16564 /* wait for reply */
16569 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16572 api_one_nsh_set_locator_set (vat_main_t * vam)
16574 u8 ls_name_set = 0;
16575 unformat_input_t *input = vam->input;
16576 vl_api_one_nsh_set_locator_set_t *mp;
16581 /* Parse args required to build the message */
16582 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16584 if (unformat (input, "del"))
16586 else if (unformat (input, "ls %s", &ls_name))
16590 errmsg ("parse error '%U'", format_unformat_error, input);
16595 if (!ls_name_set && is_add)
16597 errmsg ("locator-set name not set!");
16601 M (ONE_NSH_SET_LOCATOR_SET, mp);
16603 mp->is_add = is_add;
16604 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16605 vec_free (ls_name);
16610 /* wait for reply */
16616 api_show_one_pitr (vat_main_t * vam)
16618 vl_api_show_one_pitr_t *mp;
16621 if (!vam->json_output)
16623 print (vam->ofp, "%=20s", "lisp status:");
16626 M (SHOW_ONE_PITR, mp);
16630 /* Wait for a reply... */
16635 #define api_show_lisp_pitr api_show_one_pitr
16638 api_one_use_petr (vat_main_t * vam)
16640 unformat_input_t *input = vam->input;
16641 vl_api_one_use_petr_t *mp;
16646 memset (&ip, 0, sizeof (ip));
16648 /* Parse args required to build the message */
16649 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16651 if (unformat (input, "disable"))
16654 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16657 ip_addr_version (&ip) = IP4;
16660 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16663 ip_addr_version (&ip) = IP6;
16667 errmsg ("parse error '%U'", format_unformat_error, input);
16672 M (ONE_USE_PETR, mp);
16674 mp->is_add = is_add;
16677 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16679 clib_memcpy (mp->address, &ip, 4);
16681 clib_memcpy (mp->address, &ip, 16);
16687 /* wait for reply */
16692 #define api_lisp_use_petr api_one_use_petr
16695 api_show_one_nsh_mapping (vat_main_t * vam)
16697 vl_api_show_one_use_petr_t *mp;
16700 if (!vam->json_output)
16702 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16705 M (SHOW_ONE_NSH_MAPPING, mp);
16709 /* Wait for a reply... */
16715 api_show_one_use_petr (vat_main_t * vam)
16717 vl_api_show_one_use_petr_t *mp;
16720 if (!vam->json_output)
16722 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16725 M (SHOW_ONE_USE_PETR, mp);
16729 /* Wait for a reply... */
16734 #define api_show_lisp_use_petr api_show_one_use_petr
16737 * Add/delete mapping between vni and vrf
16740 api_one_eid_table_add_del_map (vat_main_t * vam)
16742 unformat_input_t *input = vam->input;
16743 vl_api_one_eid_table_add_del_map_t *mp;
16744 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16745 u32 vni, vrf, bd_index;
16748 /* Parse args required to build the message */
16749 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16751 if (unformat (input, "del"))
16753 else if (unformat (input, "vrf %d", &vrf))
16755 else if (unformat (input, "bd_index %d", &bd_index))
16757 else if (unformat (input, "vni %d", &vni))
16763 if (!vni_set || (!vrf_set && !bd_index_set))
16765 errmsg ("missing arguments!");
16769 if (vrf_set && bd_index_set)
16771 errmsg ("error: both vrf and bd entered!");
16775 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16777 mp->is_add = is_add;
16778 mp->vni = htonl (vni);
16779 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16780 mp->is_l2 = bd_index_set;
16785 /* wait for reply */
16790 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16793 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16795 u32 *action = va_arg (*args, u32 *);
16798 if (unformat (input, "%s", &s))
16800 if (!strcmp ((char *) s, "no-action"))
16802 else if (!strcmp ((char *) s, "natively-forward"))
16804 else if (!strcmp ((char *) s, "send-map-request"))
16806 else if (!strcmp ((char *) s, "drop"))
16810 clib_warning ("invalid action: '%s'", s);
16822 * Add/del remote mapping to/from ONE control plane
16824 * @param vam vpp API test context
16825 * @return return code
16828 api_one_add_del_remote_mapping (vat_main_t * vam)
16830 unformat_input_t *input = vam->input;
16831 vl_api_one_add_del_remote_mapping_t *mp;
16833 lisp_eid_vat_t _eid, *eid = &_eid;
16834 lisp_eid_vat_t _seid, *seid = &_seid;
16835 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16836 u32 action = ~0, p, w, data_len;
16837 ip4_address_t rloc4;
16838 ip6_address_t rloc6;
16839 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16842 memset (&rloc, 0, sizeof (rloc));
16844 /* Parse args required to build the message */
16845 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16847 if (unformat (input, "del-all"))
16851 else if (unformat (input, "del"))
16855 else if (unformat (input, "add"))
16859 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16863 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16867 else if (unformat (input, "vni %d", &vni))
16871 else if (unformat (input, "p %d w %d", &p, &w))
16875 errmsg ("No RLOC configured for setting priority/weight!");
16878 curr_rloc->priority = p;
16879 curr_rloc->weight = w;
16881 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16884 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
16885 vec_add1 (rlocs, rloc);
16886 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16888 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
16891 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
16892 vec_add1 (rlocs, rloc);
16893 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16895 else if (unformat (input, "action %U",
16896 unformat_negative_mapping_action, &action))
16902 clib_warning ("parse error '%U'", format_unformat_error, input);
16909 errmsg ("missing params!");
16913 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
16915 errmsg ("no action set for negative map-reply!");
16919 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
16921 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
16922 mp->is_add = is_add;
16923 mp->vni = htonl (vni);
16924 mp->action = (u8) action;
16925 mp->is_src_dst = seid_set;
16926 mp->eid_len = eid->len;
16927 mp->seid_len = seid->len;
16928 mp->del_all = del_all;
16929 mp->eid_type = eid->type;
16930 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16931 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
16933 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
16934 clib_memcpy (mp->rlocs, rlocs, data_len);
16940 /* Wait for a reply... */
16945 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
16948 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
16949 * forwarding entries in data-plane accordingly.
16951 * @param vam vpp API test context
16952 * @return return code
16955 api_one_add_del_adjacency (vat_main_t * vam)
16957 unformat_input_t *input = vam->input;
16958 vl_api_one_add_del_adjacency_t *mp;
16960 ip4_address_t leid4, reid4;
16961 ip6_address_t leid6, reid6;
16962 u8 reid_mac[6] = { 0 };
16963 u8 leid_mac[6] = { 0 };
16964 u8 reid_type, leid_type;
16965 u32 leid_len = 0, reid_len = 0, len;
16969 leid_type = reid_type = (u8) ~ 0;
16971 /* Parse args required to build the message */
16972 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16974 if (unformat (input, "del"))
16978 else if (unformat (input, "add"))
16982 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
16985 reid_type = 0; /* ipv4 */
16988 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
16991 reid_type = 1; /* ipv6 */
16994 else if (unformat (input, "reid %U", unformat_ethernet_address,
16997 reid_type = 2; /* mac */
16999 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17002 leid_type = 0; /* ipv4 */
17005 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17008 leid_type = 1; /* ipv6 */
17011 else if (unformat (input, "leid %U", unformat_ethernet_address,
17014 leid_type = 2; /* mac */
17016 else if (unformat (input, "vni %d", &vni))
17022 errmsg ("parse error '%U'", format_unformat_error, input);
17027 if ((u8) ~ 0 == reid_type)
17029 errmsg ("missing params!");
17033 if (leid_type != reid_type)
17035 errmsg ("remote and local EIDs are of different types!");
17039 M (ONE_ADD_DEL_ADJACENCY, mp);
17040 mp->is_add = is_add;
17041 mp->vni = htonl (vni);
17042 mp->leid_len = leid_len;
17043 mp->reid_len = reid_len;
17044 mp->eid_type = reid_type;
17046 switch (mp->eid_type)
17049 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17050 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17053 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17054 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17057 clib_memcpy (mp->leid, leid_mac, 6);
17058 clib_memcpy (mp->reid, reid_mac, 6);
17061 errmsg ("unknown EID type %d!", mp->eid_type);
17068 /* Wait for a reply... */
17073 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17076 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17078 u32 *mode = va_arg (*args, u32 *);
17080 if (unformat (input, "lisp"))
17082 else if (unformat (input, "vxlan"))
17091 api_gpe_get_encap_mode (vat_main_t * vam)
17093 vl_api_gpe_get_encap_mode_t *mp;
17096 /* Construct the API message */
17097 M (GPE_GET_ENCAP_MODE, mp);
17102 /* Wait for a reply... */
17108 api_gpe_set_encap_mode (vat_main_t * vam)
17110 unformat_input_t *input = vam->input;
17111 vl_api_gpe_set_encap_mode_t *mp;
17115 /* Parse args required to build the message */
17116 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17118 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17124 /* Construct the API message */
17125 M (GPE_SET_ENCAP_MODE, mp);
17132 /* Wait for a reply... */
17138 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17140 unformat_input_t *input = vam->input;
17141 vl_api_gpe_add_del_iface_t *mp;
17142 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17143 u32 dp_table = 0, vni = 0;
17146 /* Parse args required to build the message */
17147 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17149 if (unformat (input, "up"))
17154 else if (unformat (input, "down"))
17159 else if (unformat (input, "table_id %d", &dp_table))
17163 else if (unformat (input, "bd_id %d", &dp_table))
17168 else if (unformat (input, "vni %d", &vni))
17176 if (action_set == 0)
17178 errmsg ("Action not set");
17181 if (dp_table_set == 0 || vni_set == 0)
17183 errmsg ("vni and dp_table must be set");
17187 /* Construct the API message */
17188 M (GPE_ADD_DEL_IFACE, mp);
17190 mp->is_add = is_add;
17191 mp->dp_table = clib_host_to_net_u32 (dp_table);
17193 mp->vni = clib_host_to_net_u32 (vni);
17198 /* Wait for a reply... */
17204 api_one_map_register_fallback_threshold (vat_main_t * vam)
17206 unformat_input_t *input = vam->input;
17207 vl_api_one_map_register_fallback_threshold_t *mp;
17212 /* Parse args required to build the message */
17213 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17215 if (unformat (input, "%u", &value))
17219 clib_warning ("parse error '%U'", format_unformat_error, input);
17226 errmsg ("fallback threshold value is missing!");
17230 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17231 mp->value = clib_host_to_net_u32 (value);
17236 /* Wait for a reply... */
17242 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17244 vl_api_show_one_map_register_fallback_threshold_t *mp;
17247 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17252 /* Wait for a reply... */
17258 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17260 u32 *proto = va_arg (*args, u32 *);
17262 if (unformat (input, "udp"))
17264 else if (unformat (input, "api"))
17273 api_one_set_transport_protocol (vat_main_t * vam)
17275 unformat_input_t *input = vam->input;
17276 vl_api_one_set_transport_protocol_t *mp;
17281 /* Parse args required to build the message */
17282 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17284 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17288 clib_warning ("parse error '%U'", format_unformat_error, input);
17295 errmsg ("Transport protocol missing!");
17299 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17300 mp->protocol = (u8) protocol;
17305 /* Wait for a reply... */
17311 api_one_get_transport_protocol (vat_main_t * vam)
17313 vl_api_one_get_transport_protocol_t *mp;
17316 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17321 /* Wait for a reply... */
17327 api_one_map_register_set_ttl (vat_main_t * vam)
17329 unformat_input_t *input = vam->input;
17330 vl_api_one_map_register_set_ttl_t *mp;
17335 /* Parse args required to build the message */
17336 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17338 if (unformat (input, "%u", &ttl))
17342 clib_warning ("parse error '%U'", format_unformat_error, input);
17349 errmsg ("TTL value missing!");
17353 M (ONE_MAP_REGISTER_SET_TTL, mp);
17354 mp->ttl = clib_host_to_net_u32 (ttl);
17359 /* Wait for a reply... */
17365 api_show_one_map_register_ttl (vat_main_t * vam)
17367 vl_api_show_one_map_register_ttl_t *mp;
17370 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17375 /* Wait for a reply... */
17381 * Add/del map request itr rlocs from ONE control plane and updates
17383 * @param vam vpp API test context
17384 * @return return code
17387 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17389 unformat_input_t *input = vam->input;
17390 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17391 u8 *locator_set_name = 0;
17392 u8 locator_set_name_set = 0;
17396 /* Parse args required to build the message */
17397 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17399 if (unformat (input, "del"))
17403 else if (unformat (input, "%_%v%_", &locator_set_name))
17405 locator_set_name_set = 1;
17409 clib_warning ("parse error '%U'", format_unformat_error, input);
17414 if (is_add && !locator_set_name_set)
17416 errmsg ("itr-rloc is not set!");
17420 if (is_add && vec_len (locator_set_name) > 64)
17422 errmsg ("itr-rloc locator-set name too long");
17423 vec_free (locator_set_name);
17427 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17428 mp->is_add = is_add;
17431 clib_memcpy (mp->locator_set_name, locator_set_name,
17432 vec_len (locator_set_name));
17436 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17438 vec_free (locator_set_name);
17443 /* Wait for a reply... */
17448 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17451 api_one_locator_dump (vat_main_t * vam)
17453 unformat_input_t *input = vam->input;
17454 vl_api_one_locator_dump_t *mp;
17455 vl_api_control_ping_t *mp_ping;
17456 u8 is_index_set = 0, is_name_set = 0;
17461 /* Parse args required to build the message */
17462 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17464 if (unformat (input, "ls_name %_%v%_", &ls_name))
17468 else if (unformat (input, "ls_index %d", &ls_index))
17474 errmsg ("parse error '%U'", format_unformat_error, input);
17479 if (!is_index_set && !is_name_set)
17481 errmsg ("error: expected one of index or name!");
17485 if (is_index_set && is_name_set)
17487 errmsg ("error: only one param expected!");
17491 if (vec_len (ls_name) > 62)
17493 errmsg ("error: locator set name too long!");
17497 if (!vam->json_output)
17499 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17502 M (ONE_LOCATOR_DUMP, mp);
17503 mp->is_index_set = is_index_set;
17506 mp->ls_index = clib_host_to_net_u32 (ls_index);
17509 vec_add1 (ls_name, 0);
17510 strncpy ((char *) mp->ls_name, (char *) ls_name,
17511 sizeof (mp->ls_name) - 1);
17517 /* Use a control ping for synchronization */
17518 MPING (CONTROL_PING, mp_ping);
17521 /* Wait for a reply... */
17526 #define api_lisp_locator_dump api_one_locator_dump
17529 api_one_locator_set_dump (vat_main_t * vam)
17531 vl_api_one_locator_set_dump_t *mp;
17532 vl_api_control_ping_t *mp_ping;
17533 unformat_input_t *input = vam->input;
17537 /* Parse args required to build the message */
17538 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17540 if (unformat (input, "local"))
17544 else if (unformat (input, "remote"))
17550 errmsg ("parse error '%U'", format_unformat_error, input);
17555 if (!vam->json_output)
17557 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17560 M (ONE_LOCATOR_SET_DUMP, mp);
17562 mp->filter = filter;
17567 /* Use a control ping for synchronization */
17568 MPING (CONTROL_PING, mp_ping);
17571 /* Wait for a reply... */
17576 #define api_lisp_locator_set_dump api_one_locator_set_dump
17579 api_one_eid_table_map_dump (vat_main_t * vam)
17583 unformat_input_t *input = vam->input;
17584 vl_api_one_eid_table_map_dump_t *mp;
17585 vl_api_control_ping_t *mp_ping;
17588 /* Parse args required to build the message */
17589 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17591 if (unformat (input, "l2"))
17596 else if (unformat (input, "l3"))
17603 errmsg ("parse error '%U'", format_unformat_error, input);
17610 errmsg ("expected one of 'l2' or 'l3' parameter!");
17614 if (!vam->json_output)
17616 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17619 M (ONE_EID_TABLE_MAP_DUMP, mp);
17625 /* Use a control ping for synchronization */
17626 MPING (CONTROL_PING, mp_ping);
17629 /* Wait for a reply... */
17634 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17637 api_one_eid_table_vni_dump (vat_main_t * vam)
17639 vl_api_one_eid_table_vni_dump_t *mp;
17640 vl_api_control_ping_t *mp_ping;
17643 if (!vam->json_output)
17645 print (vam->ofp, "VNI");
17648 M (ONE_EID_TABLE_VNI_DUMP, mp);
17653 /* Use a control ping for synchronization */
17654 MPING (CONTROL_PING, mp_ping);
17657 /* Wait for a reply... */
17662 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17665 api_one_eid_table_dump (vat_main_t * vam)
17667 unformat_input_t *i = vam->input;
17668 vl_api_one_eid_table_dump_t *mp;
17669 vl_api_control_ping_t *mp_ping;
17670 struct in_addr ip4;
17671 struct in6_addr ip6;
17673 u8 eid_type = ~0, eid_set = 0;
17674 u32 prefix_length = ~0, t, vni = 0;
17677 lisp_nsh_api_t nsh;
17679 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17681 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17687 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17693 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17698 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17703 else if (unformat (i, "vni %d", &t))
17707 else if (unformat (i, "local"))
17711 else if (unformat (i, "remote"))
17717 errmsg ("parse error '%U'", format_unformat_error, i);
17722 if (!vam->json_output)
17724 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17725 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17728 M (ONE_EID_TABLE_DUMP, mp);
17730 mp->filter = filter;
17734 mp->vni = htonl (vni);
17735 mp->eid_type = eid_type;
17739 mp->prefix_length = prefix_length;
17740 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17743 mp->prefix_length = prefix_length;
17744 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17747 clib_memcpy (mp->eid, mac, sizeof (mac));
17750 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17753 errmsg ("unknown EID type %d!", eid_type);
17761 /* Use a control ping for synchronization */
17762 MPING (CONTROL_PING, mp_ping);
17765 /* Wait for a reply... */
17770 #define api_lisp_eid_table_dump api_one_eid_table_dump
17773 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17775 unformat_input_t *i = vam->input;
17776 vl_api_gpe_fwd_entries_get_t *mp;
17781 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17783 if (unformat (i, "vni %d", &vni))
17789 errmsg ("parse error '%U'", format_unformat_error, i);
17796 errmsg ("vni not set!");
17800 if (!vam->json_output)
17802 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17806 M (GPE_FWD_ENTRIES_GET, mp);
17807 mp->vni = clib_host_to_net_u32 (vni);
17812 /* Wait for a reply... */
17817 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17818 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17819 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17820 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17821 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17822 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17823 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17824 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17827 api_one_adjacencies_get (vat_main_t * vam)
17829 unformat_input_t *i = vam->input;
17830 vl_api_one_adjacencies_get_t *mp;
17835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17837 if (unformat (i, "vni %d", &vni))
17843 errmsg ("parse error '%U'", format_unformat_error, i);
17850 errmsg ("vni not set!");
17854 if (!vam->json_output)
17856 print (vam->ofp, "%s %40s", "leid", "reid");
17859 M (ONE_ADJACENCIES_GET, mp);
17860 mp->vni = clib_host_to_net_u32 (vni);
17865 /* Wait for a reply... */
17870 #define api_lisp_adjacencies_get api_one_adjacencies_get
17873 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
17875 unformat_input_t *i = vam->input;
17876 vl_api_gpe_native_fwd_rpaths_get_t *mp;
17878 u8 ip_family_set = 0, is_ip4 = 1;
17880 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17882 if (unformat (i, "ip4"))
17887 else if (unformat (i, "ip6"))
17894 errmsg ("parse error '%U'", format_unformat_error, i);
17899 if (!ip_family_set)
17901 errmsg ("ip family not set!");
17905 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
17906 mp->is_ip4 = is_ip4;
17911 /* Wait for a reply... */
17917 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
17919 vl_api_gpe_fwd_entry_vnis_get_t *mp;
17922 if (!vam->json_output)
17924 print (vam->ofp, "VNIs");
17927 M (GPE_FWD_ENTRY_VNIS_GET, mp);
17932 /* Wait for a reply... */
17938 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
17940 unformat_input_t *i = vam->input;
17941 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
17943 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
17944 struct in_addr ip4;
17945 struct in6_addr ip6;
17946 u32 table_id = 0, nh_sw_if_index = ~0;
17948 memset (&ip4, 0, sizeof (ip4));
17949 memset (&ip6, 0, sizeof (ip6));
17951 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17953 if (unformat (i, "del"))
17955 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
17956 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17961 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
17962 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17967 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
17971 nh_sw_if_index = ~0;
17973 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
17977 nh_sw_if_index = ~0;
17979 else if (unformat (i, "table %d", &table_id))
17983 errmsg ("parse error '%U'", format_unformat_error, i);
17990 errmsg ("nh addr not set!");
17994 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
17995 mp->is_add = is_add;
17996 mp->table_id = clib_host_to_net_u32 (table_id);
17997 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
17998 mp->is_ip4 = is_ip4;
18000 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18002 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18007 /* Wait for a reply... */
18013 api_one_map_server_dump (vat_main_t * vam)
18015 vl_api_one_map_server_dump_t *mp;
18016 vl_api_control_ping_t *mp_ping;
18019 if (!vam->json_output)
18021 print (vam->ofp, "%=20s", "Map server");
18024 M (ONE_MAP_SERVER_DUMP, mp);
18028 /* Use a control ping for synchronization */
18029 MPING (CONTROL_PING, mp_ping);
18032 /* Wait for a reply... */
18037 #define api_lisp_map_server_dump api_one_map_server_dump
18040 api_one_map_resolver_dump (vat_main_t * vam)
18042 vl_api_one_map_resolver_dump_t *mp;
18043 vl_api_control_ping_t *mp_ping;
18046 if (!vam->json_output)
18048 print (vam->ofp, "%=20s", "Map resolver");
18051 M (ONE_MAP_RESOLVER_DUMP, mp);
18055 /* Use a control ping for synchronization */
18056 MPING (CONTROL_PING, mp_ping);
18059 /* Wait for a reply... */
18064 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18067 api_one_stats_flush (vat_main_t * vam)
18069 vl_api_one_stats_flush_t *mp;
18072 M (ONE_STATS_FLUSH, mp);
18079 api_one_stats_dump (vat_main_t * vam)
18081 vl_api_one_stats_dump_t *mp;
18082 vl_api_control_ping_t *mp_ping;
18085 M (ONE_STATS_DUMP, mp);
18089 /* Use a control ping for synchronization */
18090 MPING (CONTROL_PING, mp_ping);
18093 /* Wait for a reply... */
18099 api_show_one_status (vat_main_t * vam)
18101 vl_api_show_one_status_t *mp;
18104 if (!vam->json_output)
18106 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18109 M (SHOW_ONE_STATUS, mp);
18112 /* Wait for a reply... */
18117 #define api_show_lisp_status api_show_one_status
18120 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18122 vl_api_gpe_fwd_entry_path_dump_t *mp;
18123 vl_api_control_ping_t *mp_ping;
18124 unformat_input_t *i = vam->input;
18125 u32 fwd_entry_index = ~0;
18128 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18130 if (unformat (i, "index %d", &fwd_entry_index))
18136 if (~0 == fwd_entry_index)
18138 errmsg ("no index specified!");
18142 if (!vam->json_output)
18144 print (vam->ofp, "first line");
18147 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18151 /* Use a control ping for synchronization */
18152 MPING (CONTROL_PING, mp_ping);
18155 /* Wait for a reply... */
18161 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18163 vl_api_one_get_map_request_itr_rlocs_t *mp;
18166 if (!vam->json_output)
18168 print (vam->ofp, "%=20s", "itr-rlocs:");
18171 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18174 /* Wait for a reply... */
18179 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18182 api_af_packet_create (vat_main_t * vam)
18184 unformat_input_t *i = vam->input;
18185 vl_api_af_packet_create_t *mp;
18186 u8 *host_if_name = 0;
18188 u8 random_hw_addr = 1;
18191 memset (hw_addr, 0, sizeof (hw_addr));
18193 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18195 if (unformat (i, "name %s", &host_if_name))
18196 vec_add1 (host_if_name, 0);
18197 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18198 random_hw_addr = 0;
18203 if (!vec_len (host_if_name))
18205 errmsg ("host-interface name must be specified");
18209 if (vec_len (host_if_name) > 64)
18211 errmsg ("host-interface name too long");
18215 M (AF_PACKET_CREATE, mp);
18217 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18218 clib_memcpy (mp->hw_addr, hw_addr, 6);
18219 mp->use_random_hw_addr = random_hw_addr;
18220 vec_free (host_if_name);
18228 fprintf (vam->ofp ? vam->ofp : stderr,
18229 " new sw_if_index = %d\n", vam->sw_if_index);
18236 api_af_packet_delete (vat_main_t * vam)
18238 unformat_input_t *i = vam->input;
18239 vl_api_af_packet_delete_t *mp;
18240 u8 *host_if_name = 0;
18243 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18245 if (unformat (i, "name %s", &host_if_name))
18246 vec_add1 (host_if_name, 0);
18251 if (!vec_len (host_if_name))
18253 errmsg ("host-interface name must be specified");
18257 if (vec_len (host_if_name) > 64)
18259 errmsg ("host-interface name too long");
18263 M (AF_PACKET_DELETE, mp);
18265 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18266 vec_free (host_if_name);
18274 api_policer_add_del (vat_main_t * vam)
18276 unformat_input_t *i = vam->input;
18277 vl_api_policer_add_del_t *mp;
18287 u8 color_aware = 0;
18288 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18291 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18292 conform_action.dscp = 0;
18293 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18294 exceed_action.dscp = 0;
18295 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18296 violate_action.dscp = 0;
18298 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18300 if (unformat (i, "del"))
18302 else if (unformat (i, "name %s", &name))
18303 vec_add1 (name, 0);
18304 else if (unformat (i, "cir %u", &cir))
18306 else if (unformat (i, "eir %u", &eir))
18308 else if (unformat (i, "cb %u", &cb))
18310 else if (unformat (i, "eb %u", &eb))
18312 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18315 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18318 else if (unformat (i, "type %U", unformat_policer_type, &type))
18320 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18323 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18326 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18329 else if (unformat (i, "color-aware"))
18335 if (!vec_len (name))
18337 errmsg ("policer name must be specified");
18341 if (vec_len (name) > 64)
18343 errmsg ("policer name too long");
18347 M (POLICER_ADD_DEL, mp);
18349 clib_memcpy (mp->name, name, vec_len (name));
18351 mp->is_add = is_add;
18356 mp->rate_type = rate_type;
18357 mp->round_type = round_type;
18359 mp->conform_action_type = conform_action.action_type;
18360 mp->conform_dscp = conform_action.dscp;
18361 mp->exceed_action_type = exceed_action.action_type;
18362 mp->exceed_dscp = exceed_action.dscp;
18363 mp->violate_action_type = violate_action.action_type;
18364 mp->violate_dscp = violate_action.dscp;
18365 mp->color_aware = color_aware;
18373 api_policer_dump (vat_main_t * vam)
18375 unformat_input_t *i = vam->input;
18376 vl_api_policer_dump_t *mp;
18377 vl_api_control_ping_t *mp_ping;
18378 u8 *match_name = 0;
18379 u8 match_name_valid = 0;
18382 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18384 if (unformat (i, "name %s", &match_name))
18386 vec_add1 (match_name, 0);
18387 match_name_valid = 1;
18393 M (POLICER_DUMP, mp);
18394 mp->match_name_valid = match_name_valid;
18395 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18396 vec_free (match_name);
18400 /* Use a control ping for synchronization */
18401 MPING (CONTROL_PING, mp_ping);
18404 /* Wait for a reply... */
18410 api_policer_classify_set_interface (vat_main_t * vam)
18412 unformat_input_t *i = vam->input;
18413 vl_api_policer_classify_set_interface_t *mp;
18415 int sw_if_index_set;
18416 u32 ip4_table_index = ~0;
18417 u32 ip6_table_index = ~0;
18418 u32 l2_table_index = ~0;
18422 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18424 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18425 sw_if_index_set = 1;
18426 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18427 sw_if_index_set = 1;
18428 else if (unformat (i, "del"))
18430 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18432 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18434 else if (unformat (i, "l2-table %d", &l2_table_index))
18438 clib_warning ("parse error '%U'", format_unformat_error, i);
18443 if (sw_if_index_set == 0)
18445 errmsg ("missing interface name or sw_if_index");
18449 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18451 mp->sw_if_index = ntohl (sw_if_index);
18452 mp->ip4_table_index = ntohl (ip4_table_index);
18453 mp->ip6_table_index = ntohl (ip6_table_index);
18454 mp->l2_table_index = ntohl (l2_table_index);
18455 mp->is_add = is_add;
18463 api_policer_classify_dump (vat_main_t * vam)
18465 unformat_input_t *i = vam->input;
18466 vl_api_policer_classify_dump_t *mp;
18467 vl_api_control_ping_t *mp_ping;
18468 u8 type = POLICER_CLASSIFY_N_TABLES;
18471 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18475 errmsg ("classify table type must be specified");
18479 if (!vam->json_output)
18481 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18484 M (POLICER_CLASSIFY_DUMP, mp);
18489 /* Use a control ping for synchronization */
18490 MPING (CONTROL_PING, mp_ping);
18493 /* Wait for a reply... */
18499 api_netmap_create (vat_main_t * vam)
18501 unformat_input_t *i = vam->input;
18502 vl_api_netmap_create_t *mp;
18505 u8 random_hw_addr = 1;
18510 memset (hw_addr, 0, sizeof (hw_addr));
18512 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18514 if (unformat (i, "name %s", &if_name))
18515 vec_add1 (if_name, 0);
18516 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18517 random_hw_addr = 0;
18518 else if (unformat (i, "pipe"))
18520 else if (unformat (i, "master"))
18522 else if (unformat (i, "slave"))
18528 if (!vec_len (if_name))
18530 errmsg ("interface name must be specified");
18534 if (vec_len (if_name) > 64)
18536 errmsg ("interface name too long");
18540 M (NETMAP_CREATE, mp);
18542 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18543 clib_memcpy (mp->hw_addr, hw_addr, 6);
18544 mp->use_random_hw_addr = random_hw_addr;
18545 mp->is_pipe = is_pipe;
18546 mp->is_master = is_master;
18547 vec_free (if_name);
18555 api_netmap_delete (vat_main_t * vam)
18557 unformat_input_t *i = vam->input;
18558 vl_api_netmap_delete_t *mp;
18562 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18564 if (unformat (i, "name %s", &if_name))
18565 vec_add1 (if_name, 0);
18570 if (!vec_len (if_name))
18572 errmsg ("interface name must be specified");
18576 if (vec_len (if_name) > 64)
18578 errmsg ("interface name too long");
18582 M (NETMAP_DELETE, mp);
18584 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18585 vec_free (if_name);
18593 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
18595 if (fp->afi == IP46_TYPE_IP6)
18597 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18598 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18599 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18600 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18601 format_ip6_address, fp->next_hop);
18602 else if (fp->afi == IP46_TYPE_IP4)
18604 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18605 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18606 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18607 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18608 format_ip4_address, fp->next_hop);
18612 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18613 vl_api_fib_path2_t * fp)
18615 struct in_addr ip4;
18616 struct in6_addr ip6;
18618 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18619 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18620 vat_json_object_add_uint (node, "is_local", fp->is_local);
18621 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18622 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18623 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18624 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18625 if (fp->afi == IP46_TYPE_IP4)
18627 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18628 vat_json_object_add_ip4 (node, "next_hop", ip4);
18630 else if (fp->afi == IP46_TYPE_IP6)
18632 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18633 vat_json_object_add_ip6 (node, "next_hop", ip6);
18638 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18640 vat_main_t *vam = &vat_main;
18641 int count = ntohl (mp->mt_count);
18642 vl_api_fib_path2_t *fp;
18645 print (vam->ofp, "[%d]: sw_if_index %d via:",
18646 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
18648 for (i = 0; i < count; i++)
18650 vl_api_mpls_fib_path_print (vam, fp);
18654 print (vam->ofp, "");
18657 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18658 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18661 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18663 vat_main_t *vam = &vat_main;
18664 vat_json_node_t *node = NULL;
18665 int count = ntohl (mp->mt_count);
18666 vl_api_fib_path2_t *fp;
18669 if (VAT_JSON_ARRAY != vam->json_tree.type)
18671 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18672 vat_json_init_array (&vam->json_tree);
18674 node = vat_json_array_add (&vam->json_tree);
18676 vat_json_init_object (node);
18677 vat_json_object_add_uint (node, "tunnel_index",
18678 ntohl (mp->mt_tunnel_index));
18679 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
18681 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
18684 for (i = 0; i < count; i++)
18686 vl_api_mpls_fib_path_json_print (node, fp);
18692 api_mpls_tunnel_dump (vat_main_t * vam)
18694 vl_api_mpls_tunnel_dump_t *mp;
18695 vl_api_control_ping_t *mp_ping;
18699 /* Parse args required to build the message */
18700 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
18702 if (!unformat (vam->input, "tunnel_index %d", &index))
18709 print (vam->ofp, " tunnel_index %d", index);
18711 M (MPLS_TUNNEL_DUMP, mp);
18712 mp->tunnel_index = htonl (index);
18715 /* Use a control ping for synchronization */
18716 MPING (CONTROL_PING, mp_ping);
18723 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
18724 #define vl_api_mpls_fib_details_t_print vl_noop_handler
18728 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
18730 vat_main_t *vam = &vat_main;
18731 int count = ntohl (mp->count);
18732 vl_api_fib_path2_t *fp;
18736 "table-id %d, label %u, ess_bit %u",
18737 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
18739 for (i = 0; i < count; i++)
18741 vl_api_mpls_fib_path_print (vam, fp);
18746 static void vl_api_mpls_fib_details_t_handler_json
18747 (vl_api_mpls_fib_details_t * mp)
18749 vat_main_t *vam = &vat_main;
18750 int count = ntohl (mp->count);
18751 vat_json_node_t *node = NULL;
18752 vl_api_fib_path2_t *fp;
18755 if (VAT_JSON_ARRAY != vam->json_tree.type)
18757 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18758 vat_json_init_array (&vam->json_tree);
18760 node = vat_json_array_add (&vam->json_tree);
18762 vat_json_init_object (node);
18763 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18764 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
18765 vat_json_object_add_uint (node, "label", ntohl (mp->label));
18766 vat_json_object_add_uint (node, "path_count", count);
18768 for (i = 0; i < count; i++)
18770 vl_api_mpls_fib_path_json_print (node, fp);
18776 api_mpls_fib_dump (vat_main_t * vam)
18778 vl_api_mpls_fib_dump_t *mp;
18779 vl_api_control_ping_t *mp_ping;
18782 M (MPLS_FIB_DUMP, mp);
18785 /* Use a control ping for synchronization */
18786 MPING (CONTROL_PING, mp_ping);
18793 #define vl_api_ip_fib_details_t_endian vl_noop_handler
18794 #define vl_api_ip_fib_details_t_print vl_noop_handler
18797 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
18799 vat_main_t *vam = &vat_main;
18800 int count = ntohl (mp->count);
18801 vl_api_fib_path_t *fp;
18805 "table-id %d, prefix %U/%d",
18806 ntohl (mp->table_id), format_ip4_address, mp->address,
18807 mp->address_length);
18809 for (i = 0; i < count; i++)
18811 if (fp->afi == IP46_TYPE_IP6)
18813 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18814 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18815 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18816 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18817 format_ip6_address, fp->next_hop);
18818 else if (fp->afi == IP46_TYPE_IP4)
18820 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18821 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18822 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18823 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18824 format_ip4_address, fp->next_hop);
18829 static void vl_api_ip_fib_details_t_handler_json
18830 (vl_api_ip_fib_details_t * mp)
18832 vat_main_t *vam = &vat_main;
18833 int count = ntohl (mp->count);
18834 vat_json_node_t *node = NULL;
18835 struct in_addr ip4;
18836 struct in6_addr ip6;
18837 vl_api_fib_path_t *fp;
18840 if (VAT_JSON_ARRAY != vam->json_tree.type)
18842 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18843 vat_json_init_array (&vam->json_tree);
18845 node = vat_json_array_add (&vam->json_tree);
18847 vat_json_init_object (node);
18848 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18849 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
18850 vat_json_object_add_ip4 (node, "prefix", ip4);
18851 vat_json_object_add_uint (node, "mask_length", mp->address_length);
18852 vat_json_object_add_uint (node, "path_count", count);
18854 for (i = 0; i < count; i++)
18856 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18857 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18858 vat_json_object_add_uint (node, "is_local", fp->is_local);
18859 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18860 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18861 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18862 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18863 if (fp->afi == IP46_TYPE_IP4)
18865 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18866 vat_json_object_add_ip4 (node, "next_hop", ip4);
18868 else if (fp->afi == IP46_TYPE_IP6)
18870 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18871 vat_json_object_add_ip6 (node, "next_hop", ip6);
18877 api_ip_fib_dump (vat_main_t * vam)
18879 vl_api_ip_fib_dump_t *mp;
18880 vl_api_control_ping_t *mp_ping;
18883 M (IP_FIB_DUMP, mp);
18886 /* Use a control ping for synchronization */
18887 MPING (CONTROL_PING, mp_ping);
18895 api_ip_mfib_dump (vat_main_t * vam)
18897 vl_api_ip_mfib_dump_t *mp;
18898 vl_api_control_ping_t *mp_ping;
18901 M (IP_MFIB_DUMP, mp);
18904 /* Use a control ping for synchronization */
18905 MPING (CONTROL_PING, mp_ping);
18912 static void vl_api_ip_neighbor_details_t_handler
18913 (vl_api_ip_neighbor_details_t * mp)
18915 vat_main_t *vam = &vat_main;
18917 print (vam->ofp, "%c %U %U",
18918 (mp->is_static) ? 'S' : 'D',
18919 format_ethernet_address, &mp->mac_address,
18920 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
18924 static void vl_api_ip_neighbor_details_t_handler_json
18925 (vl_api_ip_neighbor_details_t * mp)
18928 vat_main_t *vam = &vat_main;
18929 vat_json_node_t *node;
18930 struct in_addr ip4;
18931 struct in6_addr ip6;
18933 if (VAT_JSON_ARRAY != vam->json_tree.type)
18935 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18936 vat_json_init_array (&vam->json_tree);
18938 node = vat_json_array_add (&vam->json_tree);
18940 vat_json_init_object (node);
18941 vat_json_object_add_string_copy (node, "flag",
18942 (mp->is_static) ? (u8 *) "static" : (u8 *)
18945 vat_json_object_add_string_copy (node, "link_layer",
18946 format (0, "%U", format_ethernet_address,
18947 &mp->mac_address));
18951 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
18952 vat_json_object_add_ip6 (node, "ip_address", ip6);
18956 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
18957 vat_json_object_add_ip4 (node, "ip_address", ip4);
18962 api_ip_neighbor_dump (vat_main_t * vam)
18964 unformat_input_t *i = vam->input;
18965 vl_api_ip_neighbor_dump_t *mp;
18966 vl_api_control_ping_t *mp_ping;
18968 u32 sw_if_index = ~0;
18971 /* Parse args required to build the message */
18972 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18974 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18976 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18978 else if (unformat (i, "ip6"))
18984 if (sw_if_index == ~0)
18986 errmsg ("missing interface name or sw_if_index");
18990 M (IP_NEIGHBOR_DUMP, mp);
18991 mp->is_ipv6 = (u8) is_ipv6;
18992 mp->sw_if_index = ntohl (sw_if_index);
18995 /* Use a control ping for synchronization */
18996 MPING (CONTROL_PING, mp_ping);
19003 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
19004 #define vl_api_ip6_fib_details_t_print vl_noop_handler
19007 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
19009 vat_main_t *vam = &vat_main;
19010 int count = ntohl (mp->count);
19011 vl_api_fib_path_t *fp;
19015 "table-id %d, prefix %U/%d",
19016 ntohl (mp->table_id), format_ip6_address, mp->address,
19017 mp->address_length);
19019 for (i = 0; i < count; i++)
19021 if (fp->afi == IP46_TYPE_IP6)
19023 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19024 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19025 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19026 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19027 format_ip6_address, fp->next_hop);
19028 else if (fp->afi == IP46_TYPE_IP4)
19030 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19031 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19032 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19033 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19034 format_ip4_address, fp->next_hop);
19039 static void vl_api_ip6_fib_details_t_handler_json
19040 (vl_api_ip6_fib_details_t * mp)
19042 vat_main_t *vam = &vat_main;
19043 int count = ntohl (mp->count);
19044 vat_json_node_t *node = NULL;
19045 struct in_addr ip4;
19046 struct in6_addr ip6;
19047 vl_api_fib_path_t *fp;
19050 if (VAT_JSON_ARRAY != vam->json_tree.type)
19052 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19053 vat_json_init_array (&vam->json_tree);
19055 node = vat_json_array_add (&vam->json_tree);
19057 vat_json_init_object (node);
19058 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19059 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
19060 vat_json_object_add_ip6 (node, "prefix", ip6);
19061 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19062 vat_json_object_add_uint (node, "path_count", count);
19064 for (i = 0; i < count; i++)
19066 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19067 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19068 vat_json_object_add_uint (node, "is_local", fp->is_local);
19069 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19070 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19071 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19072 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19073 if (fp->afi == IP46_TYPE_IP4)
19075 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19076 vat_json_object_add_ip4 (node, "next_hop", ip4);
19078 else if (fp->afi == IP46_TYPE_IP6)
19080 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19081 vat_json_object_add_ip6 (node, "next_hop", ip6);
19087 api_ip6_fib_dump (vat_main_t * vam)
19089 vl_api_ip6_fib_dump_t *mp;
19090 vl_api_control_ping_t *mp_ping;
19093 M (IP6_FIB_DUMP, mp);
19096 /* Use a control ping for synchronization */
19097 MPING (CONTROL_PING, mp_ping);
19105 api_ip6_mfib_dump (vat_main_t * vam)
19107 vl_api_ip6_mfib_dump_t *mp;
19108 vl_api_control_ping_t *mp_ping;
19111 M (IP6_MFIB_DUMP, mp);
19114 /* Use a control ping for synchronization */
19115 MPING (CONTROL_PING, mp_ping);
19123 api_classify_table_ids (vat_main_t * vam)
19125 vl_api_classify_table_ids_t *mp;
19128 /* Construct the API message */
19129 M (CLASSIFY_TABLE_IDS, mp);
19138 api_classify_table_by_interface (vat_main_t * vam)
19140 unformat_input_t *input = vam->input;
19141 vl_api_classify_table_by_interface_t *mp;
19143 u32 sw_if_index = ~0;
19145 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19147 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19149 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19154 if (sw_if_index == ~0)
19156 errmsg ("missing interface name or sw_if_index");
19160 /* Construct the API message */
19161 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19163 mp->sw_if_index = ntohl (sw_if_index);
19171 api_classify_table_info (vat_main_t * vam)
19173 unformat_input_t *input = vam->input;
19174 vl_api_classify_table_info_t *mp;
19178 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19180 if (unformat (input, "table_id %d", &table_id))
19185 if (table_id == ~0)
19187 errmsg ("missing table id");
19191 /* Construct the API message */
19192 M (CLASSIFY_TABLE_INFO, mp);
19194 mp->table_id = ntohl (table_id);
19202 api_classify_session_dump (vat_main_t * vam)
19204 unformat_input_t *input = vam->input;
19205 vl_api_classify_session_dump_t *mp;
19206 vl_api_control_ping_t *mp_ping;
19210 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19212 if (unformat (input, "table_id %d", &table_id))
19217 if (table_id == ~0)
19219 errmsg ("missing table id");
19223 /* Construct the API message */
19224 M (CLASSIFY_SESSION_DUMP, mp);
19226 mp->table_id = ntohl (table_id);
19229 /* Use a control ping for synchronization */
19230 MPING (CONTROL_PING, mp_ping);
19238 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19240 vat_main_t *vam = &vat_main;
19242 print (vam->ofp, "collector_address %U, collector_port %d, "
19243 "src_address %U, vrf_id %d, path_mtu %u, "
19244 "template_interval %u, udp_checksum %d",
19245 format_ip4_address, mp->collector_address,
19246 ntohs (mp->collector_port),
19247 format_ip4_address, mp->src_address,
19248 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19249 ntohl (mp->template_interval), mp->udp_checksum);
19252 vam->result_ready = 1;
19256 vl_api_ipfix_exporter_details_t_handler_json
19257 (vl_api_ipfix_exporter_details_t * mp)
19259 vat_main_t *vam = &vat_main;
19260 vat_json_node_t node;
19261 struct in_addr collector_address;
19262 struct in_addr src_address;
19264 vat_json_init_object (&node);
19265 clib_memcpy (&collector_address, &mp->collector_address,
19266 sizeof (collector_address));
19267 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19268 vat_json_object_add_uint (&node, "collector_port",
19269 ntohs (mp->collector_port));
19270 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19271 vat_json_object_add_ip4 (&node, "src_address", src_address);
19272 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19273 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19274 vat_json_object_add_uint (&node, "template_interval",
19275 ntohl (mp->template_interval));
19276 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19278 vat_json_print (vam->ofp, &node);
19279 vat_json_free (&node);
19281 vam->result_ready = 1;
19285 api_ipfix_exporter_dump (vat_main_t * vam)
19287 vl_api_ipfix_exporter_dump_t *mp;
19290 /* Construct the API message */
19291 M (IPFIX_EXPORTER_DUMP, mp);
19300 api_ipfix_classify_stream_dump (vat_main_t * vam)
19302 vl_api_ipfix_classify_stream_dump_t *mp;
19305 /* Construct the API message */
19306 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19317 vl_api_ipfix_classify_stream_details_t_handler
19318 (vl_api_ipfix_classify_stream_details_t * mp)
19320 vat_main_t *vam = &vat_main;
19321 print (vam->ofp, "domain_id %d, src_port %d",
19322 ntohl (mp->domain_id), ntohs (mp->src_port));
19324 vam->result_ready = 1;
19328 vl_api_ipfix_classify_stream_details_t_handler_json
19329 (vl_api_ipfix_classify_stream_details_t * mp)
19331 vat_main_t *vam = &vat_main;
19332 vat_json_node_t node;
19334 vat_json_init_object (&node);
19335 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19336 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19338 vat_json_print (vam->ofp, &node);
19339 vat_json_free (&node);
19341 vam->result_ready = 1;
19345 api_ipfix_classify_table_dump (vat_main_t * vam)
19347 vl_api_ipfix_classify_table_dump_t *mp;
19348 vl_api_control_ping_t *mp_ping;
19351 if (!vam->json_output)
19353 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19354 "transport_protocol");
19357 /* Construct the API message */
19358 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19363 /* Use a control ping for synchronization */
19364 MPING (CONTROL_PING, mp_ping);
19372 vl_api_ipfix_classify_table_details_t_handler
19373 (vl_api_ipfix_classify_table_details_t * mp)
19375 vat_main_t *vam = &vat_main;
19376 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19377 mp->transport_protocol);
19381 vl_api_ipfix_classify_table_details_t_handler_json
19382 (vl_api_ipfix_classify_table_details_t * mp)
19384 vat_json_node_t *node = NULL;
19385 vat_main_t *vam = &vat_main;
19387 if (VAT_JSON_ARRAY != vam->json_tree.type)
19389 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19390 vat_json_init_array (&vam->json_tree);
19393 node = vat_json_array_add (&vam->json_tree);
19394 vat_json_init_object (node);
19396 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19397 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19398 vat_json_object_add_uint (node, "transport_protocol",
19399 mp->transport_protocol);
19403 api_sw_interface_span_enable_disable (vat_main_t * vam)
19405 unformat_input_t *i = vam->input;
19406 vl_api_sw_interface_span_enable_disable_t *mp;
19407 u32 src_sw_if_index = ~0;
19408 u32 dst_sw_if_index = ~0;
19413 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19416 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19418 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19422 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19424 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19426 else if (unformat (i, "disable"))
19428 else if (unformat (i, "rx"))
19430 else if (unformat (i, "tx"))
19432 else if (unformat (i, "both"))
19434 else if (unformat (i, "l2"))
19440 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19442 mp->sw_if_index_from = htonl (src_sw_if_index);
19443 mp->sw_if_index_to = htonl (dst_sw_if_index);
19453 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19456 vat_main_t *vam = &vat_main;
19457 u8 *sw_if_from_name = 0;
19458 u8 *sw_if_to_name = 0;
19459 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19460 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19461 char *states[] = { "none", "rx", "tx", "both" };
19465 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19467 if ((u32) p->value[0] == sw_if_index_from)
19469 sw_if_from_name = (u8 *)(p->key);
19473 if ((u32) p->value[0] == sw_if_index_to)
19475 sw_if_to_name = (u8 *)(p->key);
19476 if (sw_if_from_name)
19481 print (vam->ofp, "%20s => %20s (%s)",
19482 sw_if_from_name, sw_if_to_name, states[mp->state]);
19486 vl_api_sw_interface_span_details_t_handler_json
19487 (vl_api_sw_interface_span_details_t * mp)
19489 vat_main_t *vam = &vat_main;
19490 vat_json_node_t *node = NULL;
19491 u8 *sw_if_from_name = 0;
19492 u8 *sw_if_to_name = 0;
19493 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19494 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19498 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19500 if ((u32) p->value[0] == sw_if_index_from)
19502 sw_if_from_name = (u8 *)(p->key);
19506 if ((u32) p->value[0] == sw_if_index_to)
19508 sw_if_to_name = (u8 *)(p->key);
19509 if (sw_if_from_name)
19515 if (VAT_JSON_ARRAY != vam->json_tree.type)
19517 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19518 vat_json_init_array (&vam->json_tree);
19520 node = vat_json_array_add (&vam->json_tree);
19522 vat_json_init_object (node);
19523 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19524 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19525 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19526 if (0 != sw_if_to_name)
19528 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19530 vat_json_object_add_uint (node, "state", mp->state);
19534 api_sw_interface_span_dump (vat_main_t * vam)
19536 unformat_input_t *input = vam->input;
19537 vl_api_sw_interface_span_dump_t *mp;
19538 vl_api_control_ping_t *mp_ping;
19542 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19544 if (unformat (input, "l2"))
19550 M (SW_INTERFACE_SPAN_DUMP, mp);
19554 /* Use a control ping for synchronization */
19555 MPING (CONTROL_PING, mp_ping);
19563 api_pg_create_interface (vat_main_t * vam)
19565 unformat_input_t *input = vam->input;
19566 vl_api_pg_create_interface_t *mp;
19570 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19572 if (unformat (input, "if_id %d", &if_id))
19579 errmsg ("missing pg interface index");
19583 /* Construct the API message */
19584 M (PG_CREATE_INTERFACE, mp);
19586 mp->interface_id = ntohl (if_id);
19594 api_pg_capture (vat_main_t * vam)
19596 unformat_input_t *input = vam->input;
19597 vl_api_pg_capture_t *mp;
19602 u8 pcap_file_set = 0;
19605 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19607 if (unformat (input, "if_id %d", &if_id))
19609 else if (unformat (input, "pcap %s", &pcap_file))
19611 else if (unformat (input, "count %d", &count))
19613 else if (unformat (input, "disable"))
19620 errmsg ("missing pg interface index");
19623 if (pcap_file_set > 0)
19625 if (vec_len (pcap_file) > 255)
19627 errmsg ("pcap file name is too long");
19632 u32 name_len = vec_len (pcap_file);
19633 /* Construct the API message */
19634 M (PG_CAPTURE, mp);
19636 mp->interface_id = ntohl (if_id);
19637 mp->is_enabled = enable;
19638 mp->count = ntohl (count);
19639 mp->pcap_name_length = ntohl (name_len);
19640 if (pcap_file_set != 0)
19642 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19644 vec_free (pcap_file);
19652 api_pg_enable_disable (vat_main_t * vam)
19654 unformat_input_t *input = vam->input;
19655 vl_api_pg_enable_disable_t *mp;
19658 u8 stream_name_set = 0;
19659 u8 *stream_name = 0;
19661 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19663 if (unformat (input, "stream %s", &stream_name))
19664 stream_name_set = 1;
19665 else if (unformat (input, "disable"))
19671 if (stream_name_set > 0)
19673 if (vec_len (stream_name) > 255)
19675 errmsg ("stream name too long");
19680 u32 name_len = vec_len (stream_name);
19681 /* Construct the API message */
19682 M (PG_ENABLE_DISABLE, mp);
19684 mp->is_enabled = enable;
19685 if (stream_name_set != 0)
19687 mp->stream_name_length = ntohl (name_len);
19688 clib_memcpy (mp->stream_name, stream_name, name_len);
19690 vec_free (stream_name);
19698 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19700 unformat_input_t *input = vam->input;
19701 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19703 u16 *low_ports = 0;
19704 u16 *high_ports = 0;
19707 ip4_address_t ip4_addr;
19708 ip6_address_t ip6_addr;
19717 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19719 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
19725 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
19730 else if (unformat (input, "vrf %d", &vrf_id))
19732 else if (unformat (input, "del"))
19734 else if (unformat (input, "port %d", &tmp))
19736 if (tmp == 0 || tmp > 65535)
19738 errmsg ("port %d out of range", tmp);
19742 this_hi = this_low + 1;
19743 vec_add1 (low_ports, this_low);
19744 vec_add1 (high_ports, this_hi);
19746 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19748 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19750 errmsg ("incorrect range parameters");
19754 /* Note: in debug CLI +1 is added to high before
19755 passing to real fn that does "the work"
19756 (ip_source_and_port_range_check_add_del).
19757 This fn is a wrapper around the binary API fn a
19758 control plane will call, which expects this increment
19759 to have occurred. Hence letting the binary API control
19760 plane fn do the increment for consistency between VAT
19761 and other control planes.
19764 vec_add1 (low_ports, this_low);
19765 vec_add1 (high_ports, this_hi);
19771 if (prefix_set == 0)
19773 errmsg ("<address>/<mask> not specified");
19779 errmsg ("VRF ID required, not specified");
19786 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19790 if (vec_len (low_ports) == 0)
19792 errmsg ("At least one port or port range required");
19796 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19798 mp->is_add = is_add;
19803 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
19808 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
19811 mp->mask_length = length;
19812 mp->number_of_ranges = vec_len (low_ports);
19814 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
19815 vec_free (low_ports);
19817 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
19818 vec_free (high_ports);
19820 mp->vrf_id = ntohl (vrf_id);
19828 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
19830 unformat_input_t *input = vam->input;
19831 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
19832 u32 sw_if_index = ~0;
19834 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
19835 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
19839 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19841 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19843 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19845 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
19847 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
19849 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
19851 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
19853 else if (unformat (input, "del"))
19859 if (sw_if_index == ~0)
19861 errmsg ("Interface required but not specified");
19867 errmsg ("VRF ID required but not specified");
19871 if (tcp_out_vrf_id == 0
19872 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
19875 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19879 /* Construct the API message */
19880 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
19882 mp->sw_if_index = ntohl (sw_if_index);
19883 mp->is_add = is_add;
19884 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
19885 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
19886 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
19887 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
19892 /* Wait for a reply... */
19898 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
19900 unformat_input_t *i = vam->input;
19901 vl_api_ipsec_gre_add_del_tunnel_t *mp;
19902 u32 local_sa_id = 0;
19903 u32 remote_sa_id = 0;
19904 ip4_address_t src_address;
19905 ip4_address_t dst_address;
19909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19911 if (unformat (i, "local_sa %d", &local_sa_id))
19913 else if (unformat (i, "remote_sa %d", &remote_sa_id))
19915 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
19917 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
19919 else if (unformat (i, "del"))
19923 clib_warning ("parse error '%U'", format_unformat_error, i);
19928 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
19930 mp->local_sa_id = ntohl (local_sa_id);
19931 mp->remote_sa_id = ntohl (remote_sa_id);
19932 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
19933 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
19934 mp->is_add = is_add;
19942 api_punt (vat_main_t * vam)
19944 unformat_input_t *i = vam->input;
19952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19954 if (unformat (i, "ip %d", &ipv))
19956 else if (unformat (i, "protocol %d", &protocol))
19958 else if (unformat (i, "port %d", &port))
19960 else if (unformat (i, "del"))
19964 clib_warning ("parse error '%U'", format_unformat_error, i);
19971 mp->is_add = (u8) is_add;
19972 mp->ipv = (u8) ipv;
19973 mp->l4_protocol = (u8) protocol;
19974 mp->l4_port = htons ((u16) port);
19981 static void vl_api_ipsec_gre_tunnel_details_t_handler
19982 (vl_api_ipsec_gre_tunnel_details_t * mp)
19984 vat_main_t *vam = &vat_main;
19986 print (vam->ofp, "%11d%15U%15U%14d%14d",
19987 ntohl (mp->sw_if_index),
19988 format_ip4_address, &mp->src_address,
19989 format_ip4_address, &mp->dst_address,
19990 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
19993 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
19994 (vl_api_ipsec_gre_tunnel_details_t * mp)
19996 vat_main_t *vam = &vat_main;
19997 vat_json_node_t *node = NULL;
19998 struct in_addr ip4;
20000 if (VAT_JSON_ARRAY != vam->json_tree.type)
20002 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20003 vat_json_init_array (&vam->json_tree);
20005 node = vat_json_array_add (&vam->json_tree);
20007 vat_json_init_object (node);
20008 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20009 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
20010 vat_json_object_add_ip4 (node, "src_address", ip4);
20011 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
20012 vat_json_object_add_ip4 (node, "dst_address", ip4);
20013 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
20014 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
20018 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
20020 unformat_input_t *i = vam->input;
20021 vl_api_ipsec_gre_tunnel_dump_t *mp;
20022 vl_api_control_ping_t *mp_ping;
20024 u8 sw_if_index_set = 0;
20027 /* Parse args required to build the message */
20028 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20030 if (unformat (i, "sw_if_index %d", &sw_if_index))
20031 sw_if_index_set = 1;
20036 if (sw_if_index_set == 0)
20041 if (!vam->json_output)
20043 print (vam->ofp, "%11s%15s%15s%14s%14s",
20044 "sw_if_index", "src_address", "dst_address",
20045 "local_sa_id", "remote_sa_id");
20048 /* Get list of gre-tunnel interfaces */
20049 M (IPSEC_GRE_TUNNEL_DUMP, mp);
20051 mp->sw_if_index = htonl (sw_if_index);
20055 /* Use a control ping for synchronization */
20056 MPING (CONTROL_PING, mp_ping);
20064 api_delete_subif (vat_main_t * vam)
20066 unformat_input_t *i = vam->input;
20067 vl_api_delete_subif_t *mp;
20068 u32 sw_if_index = ~0;
20071 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20073 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20075 if (unformat (i, "sw_if_index %d", &sw_if_index))
20081 if (sw_if_index == ~0)
20083 errmsg ("missing sw_if_index");
20087 /* Construct the API message */
20088 M (DELETE_SUBIF, mp);
20089 mp->sw_if_index = ntohl (sw_if_index);
20096 #define foreach_pbb_vtr_op \
20097 _("disable", L2_VTR_DISABLED) \
20098 _("pop", L2_VTR_POP_2) \
20099 _("push", L2_VTR_PUSH_2)
20102 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20104 unformat_input_t *i = vam->input;
20105 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20106 u32 sw_if_index = ~0, vtr_op = ~0;
20107 u16 outer_tag = ~0;
20108 u8 dmac[6], smac[6];
20109 u8 dmac_set = 0, smac_set = 0;
20115 /* Shut up coverity */
20116 memset (dmac, 0, sizeof (dmac));
20117 memset (smac, 0, sizeof (smac));
20119 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20121 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20123 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20125 else if (unformat (i, "vtr_op %d", &vtr_op))
20127 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20130 else if (unformat (i, "translate_pbb_stag"))
20132 if (unformat (i, "%d", &tmp))
20134 vtr_op = L2_VTR_TRANSLATE_2_1;
20140 ("translate_pbb_stag operation requires outer tag definition");
20144 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20146 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20148 else if (unformat (i, "sid %d", &sid))
20150 else if (unformat (i, "vlanid %d", &tmp))
20154 clib_warning ("parse error '%U'", format_unformat_error, i);
20159 if ((sw_if_index == ~0) || (vtr_op == ~0))
20161 errmsg ("missing sw_if_index or vtr operation");
20164 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20165 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20168 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20172 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20173 mp->sw_if_index = ntohl (sw_if_index);
20174 mp->vtr_op = ntohl (vtr_op);
20175 mp->outer_tag = ntohs (outer_tag);
20176 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20177 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20178 mp->b_vlanid = ntohs (vlanid);
20179 mp->i_sid = ntohl (sid);
20187 api_flow_classify_set_interface (vat_main_t * vam)
20189 unformat_input_t *i = vam->input;
20190 vl_api_flow_classify_set_interface_t *mp;
20192 int sw_if_index_set;
20193 u32 ip4_table_index = ~0;
20194 u32 ip6_table_index = ~0;
20198 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20200 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20201 sw_if_index_set = 1;
20202 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20203 sw_if_index_set = 1;
20204 else if (unformat (i, "del"))
20206 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20208 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20212 clib_warning ("parse error '%U'", format_unformat_error, i);
20217 if (sw_if_index_set == 0)
20219 errmsg ("missing interface name or sw_if_index");
20223 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20225 mp->sw_if_index = ntohl (sw_if_index);
20226 mp->ip4_table_index = ntohl (ip4_table_index);
20227 mp->ip6_table_index = ntohl (ip6_table_index);
20228 mp->is_add = is_add;
20236 api_flow_classify_dump (vat_main_t * vam)
20238 unformat_input_t *i = vam->input;
20239 vl_api_flow_classify_dump_t *mp;
20240 vl_api_control_ping_t *mp_ping;
20241 u8 type = FLOW_CLASSIFY_N_TABLES;
20244 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20248 errmsg ("classify table type must be specified");
20252 if (!vam->json_output)
20254 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20257 M (FLOW_CLASSIFY_DUMP, mp);
20262 /* Use a control ping for synchronization */
20263 MPING (CONTROL_PING, mp_ping);
20266 /* Wait for a reply... */
20272 api_feature_enable_disable (vat_main_t * vam)
20274 unformat_input_t *i = vam->input;
20275 vl_api_feature_enable_disable_t *mp;
20277 u8 *feature_name = 0;
20278 u32 sw_if_index = ~0;
20282 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20284 if (unformat (i, "arc_name %s", &arc_name))
20286 else if (unformat (i, "feature_name %s", &feature_name))
20289 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20291 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20293 else if (unformat (i, "disable"))
20301 errmsg ("missing arc name");
20304 if (vec_len (arc_name) > 63)
20306 errmsg ("arc name too long");
20309 if (feature_name == 0)
20311 errmsg ("missing feature name");
20314 if (vec_len (feature_name) > 63)
20316 errmsg ("feature name too long");
20319 if (sw_if_index == ~0)
20321 errmsg ("missing interface name or sw_if_index");
20325 /* Construct the API message */
20326 M (FEATURE_ENABLE_DISABLE, mp);
20327 mp->sw_if_index = ntohl (sw_if_index);
20328 mp->enable = enable;
20329 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20330 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20331 vec_free (arc_name);
20332 vec_free (feature_name);
20340 api_sw_interface_tag_add_del (vat_main_t * vam)
20342 unformat_input_t *i = vam->input;
20343 vl_api_sw_interface_tag_add_del_t *mp;
20344 u32 sw_if_index = ~0;
20349 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20351 if (unformat (i, "tag %s", &tag))
20353 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20355 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20357 else if (unformat (i, "del"))
20363 if (sw_if_index == ~0)
20365 errmsg ("missing interface name or sw_if_index");
20369 if (enable && (tag == 0))
20371 errmsg ("no tag specified");
20375 /* Construct the API message */
20376 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20377 mp->sw_if_index = ntohl (sw_if_index);
20378 mp->is_add = enable;
20380 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20388 static void vl_api_l2_xconnect_details_t_handler
20389 (vl_api_l2_xconnect_details_t * mp)
20391 vat_main_t *vam = &vat_main;
20393 print (vam->ofp, "%15d%15d",
20394 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20397 static void vl_api_l2_xconnect_details_t_handler_json
20398 (vl_api_l2_xconnect_details_t * mp)
20400 vat_main_t *vam = &vat_main;
20401 vat_json_node_t *node = NULL;
20403 if (VAT_JSON_ARRAY != vam->json_tree.type)
20405 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20406 vat_json_init_array (&vam->json_tree);
20408 node = vat_json_array_add (&vam->json_tree);
20410 vat_json_init_object (node);
20411 vat_json_object_add_uint (node, "rx_sw_if_index",
20412 ntohl (mp->rx_sw_if_index));
20413 vat_json_object_add_uint (node, "tx_sw_if_index",
20414 ntohl (mp->tx_sw_if_index));
20418 api_l2_xconnect_dump (vat_main_t * vam)
20420 vl_api_l2_xconnect_dump_t *mp;
20421 vl_api_control_ping_t *mp_ping;
20424 if (!vam->json_output)
20426 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20429 M (L2_XCONNECT_DUMP, mp);
20433 /* Use a control ping for synchronization */
20434 MPING (CONTROL_PING, mp_ping);
20442 api_sw_interface_set_mtu (vat_main_t * vam)
20444 unformat_input_t *i = vam->input;
20445 vl_api_sw_interface_set_mtu_t *mp;
20446 u32 sw_if_index = ~0;
20450 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20452 if (unformat (i, "mtu %d", &mtu))
20454 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20456 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20462 if (sw_if_index == ~0)
20464 errmsg ("missing interface name or sw_if_index");
20470 errmsg ("no mtu specified");
20474 /* Construct the API message */
20475 M (SW_INTERFACE_SET_MTU, mp);
20476 mp->sw_if_index = ntohl (sw_if_index);
20477 mp->mtu = ntohs ((u16) mtu);
20485 api_p2p_ethernet_add (vat_main_t * vam)
20487 unformat_input_t *i = vam->input;
20488 vl_api_p2p_ethernet_add_t *mp;
20489 u32 parent_if_index = ~0;
20495 memset (remote_mac, 0, sizeof (remote_mac));
20496 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20498 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20500 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20504 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20506 else if (unformat (i, "sub_id %d", &sub_id))
20510 clib_warning ("parse error '%U'", format_unformat_error, i);
20515 if (parent_if_index == ~0)
20517 errmsg ("missing interface name or sw_if_index");
20522 errmsg ("missing remote mac address");
20527 errmsg ("missing sub-interface id");
20531 M (P2P_ETHERNET_ADD, mp);
20532 mp->parent_if_index = ntohl (parent_if_index);
20533 mp->subif_id = ntohl (sub_id);
20534 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20542 api_p2p_ethernet_del (vat_main_t * vam)
20544 unformat_input_t *i = vam->input;
20545 vl_api_p2p_ethernet_del_t *mp;
20546 u32 parent_if_index = ~0;
20551 memset (remote_mac, 0, sizeof (remote_mac));
20552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20554 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20556 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20560 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20564 clib_warning ("parse error '%U'", format_unformat_error, i);
20569 if (parent_if_index == ~0)
20571 errmsg ("missing interface name or sw_if_index");
20576 errmsg ("missing remote mac address");
20580 M (P2P_ETHERNET_DEL, mp);
20581 mp->parent_if_index = ntohl (parent_if_index);
20582 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20590 api_lldp_config (vat_main_t * vam)
20592 unformat_input_t *i = vam->input;
20593 vl_api_lldp_config_t *mp;
20595 int tx_interval = 0;
20596 u8 *sys_name = NULL;
20599 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20601 if (unformat (i, "system-name %s", &sys_name))
20603 else if (unformat (i, "tx-hold %d", &tx_hold))
20605 else if (unformat (i, "tx-interval %d", &tx_interval))
20609 clib_warning ("parse error '%U'", format_unformat_error, i);
20614 vec_add1 (sys_name, 0);
20616 M (LLDP_CONFIG, mp);
20617 mp->tx_hold = htonl (tx_hold);
20618 mp->tx_interval = htonl (tx_interval);
20619 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20620 vec_free (sys_name);
20628 api_sw_interface_set_lldp (vat_main_t * vam)
20630 unformat_input_t *i = vam->input;
20631 vl_api_sw_interface_set_lldp_t *mp;
20632 u32 sw_if_index = ~0;
20634 u8 *port_desc = NULL;
20637 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20639 if (unformat (i, "disable"))
20642 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20644 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20646 else if (unformat (i, "port-desc %s", &port_desc))
20652 if (sw_if_index == ~0)
20654 errmsg ("missing interface name or sw_if_index");
20658 /* Construct the API message */
20659 vec_add1 (port_desc, 0);
20660 M (SW_INTERFACE_SET_LLDP, mp);
20661 mp->sw_if_index = ntohl (sw_if_index);
20662 mp->enable = enable;
20663 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20664 vec_free (port_desc);
20672 api_tcp_configure_src_addresses (vat_main_t * vam)
20674 vl_api_tcp_configure_src_addresses_t *mp;
20675 unformat_input_t *i = vam->input;
20676 ip4_address_t v4first, v4last;
20677 ip6_address_t v6first, v6last;
20682 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20684 if (unformat (i, "%U - %U",
20685 unformat_ip4_address, &v4first,
20686 unformat_ip4_address, &v4last))
20690 errmsg ("one range per message (range already set)");
20695 else if (unformat (i, "%U - %U",
20696 unformat_ip6_address, &v6first,
20697 unformat_ip6_address, &v6last))
20701 errmsg ("one range per message (range already set)");
20706 else if (unformat (i, "vrf %d", &vrf_id))
20712 if (range_set == 0)
20714 errmsg ("address range not set");
20718 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20719 mp->vrf_id = ntohl (vrf_id);
20721 if (range_set == 2)
20724 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20725 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20730 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20731 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20739 api_memfd_segment_create (vat_main_t * vam)
20741 unformat_input_t *i = vam->input;
20742 vl_api_memfd_segment_create_t *mp;
20743 u64 size = 64 << 20;
20746 #if VPP_API_TEST_BUILTIN == 1
20747 errmsg ("memfd_segment_create (builtin) not supported");
20751 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20753 if (unformat (i, "size %U", unformat_memory_size, &size))
20759 M (MEMFD_SEGMENT_CREATE, mp);
20760 mp->requested_size = size;
20767 q_or_quit (vat_main_t * vam)
20769 #if VPP_API_TEST_BUILTIN == 0
20770 longjmp (vam->jump_buf, 1);
20772 return 0; /* not so much */
20776 q (vat_main_t * vam)
20778 return q_or_quit (vam);
20782 quit (vat_main_t * vam)
20784 return q_or_quit (vam);
20788 comment (vat_main_t * vam)
20794 cmd_cmp (void *a1, void *a2)
20799 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
20803 help (vat_main_t * vam)
20808 unformat_input_t *i = vam->input;
20811 if (unformat (i, "%s", &name))
20815 vec_add1 (name, 0);
20817 hs = hash_get_mem (vam->help_by_name, name);
20819 print (vam->ofp, "usage: %s %s", name, hs[0]);
20821 print (vam->ofp, "No such msg / command '%s'", name);
20826 print (vam->ofp, "Help is available for the following:");
20829 hash_foreach_pair (p, vam->function_by_name,
20831 vec_add1 (cmds, (u8 *)(p->key));
20835 vec_sort_with_function (cmds, cmd_cmp);
20837 for (j = 0; j < vec_len (cmds); j++)
20838 print (vam->ofp, "%s", cmds[j]);
20845 set (vat_main_t * vam)
20847 u8 *name = 0, *value = 0;
20848 unformat_input_t *i = vam->input;
20850 if (unformat (i, "%s", &name))
20852 /* The input buffer is a vector, not a string. */
20853 value = vec_dup (i->buffer);
20854 vec_delete (value, i->index, 0);
20855 /* Almost certainly has a trailing newline */
20856 if (value[vec_len (value) - 1] == '\n')
20857 value[vec_len (value) - 1] = 0;
20858 /* Make sure it's a proper string, one way or the other */
20859 vec_add1 (value, 0);
20860 (void) clib_macro_set_value (&vam->macro_main,
20861 (char *) name, (char *) value);
20864 errmsg ("usage: set <name> <value>");
20872 unset (vat_main_t * vam)
20876 if (unformat (vam->input, "%s", &name))
20877 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
20878 errmsg ("unset: %s wasn't set", name);
20891 macro_sort_cmp (void *a1, void *a2)
20893 macro_sort_t *s1 = a1;
20894 macro_sort_t *s2 = a2;
20896 return strcmp ((char *) (s1->name), (char *) (s2->name));
20900 dump_macro_table (vat_main_t * vam)
20902 macro_sort_t *sort_me = 0, *sm;
20907 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
20909 vec_add2 (sort_me, sm, 1);
20910 sm->name = (u8 *)(p->key);
20911 sm->value = (u8 *) (p->value[0]);
20915 vec_sort_with_function (sort_me, macro_sort_cmp);
20917 if (vec_len (sort_me))
20918 print (vam->ofp, "%-15s%s", "Name", "Value");
20920 print (vam->ofp, "The macro table is empty...");
20922 for (i = 0; i < vec_len (sort_me); i++)
20923 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
20928 dump_node_table (vat_main_t * vam)
20931 vlib_node_t *node, *next_node;
20933 if (vec_len (vam->graph_nodes) == 0)
20935 print (vam->ofp, "Node table empty, issue get_node_graph...");
20939 for (i = 0; i < vec_len (vam->graph_nodes); i++)
20941 node = vam->graph_nodes[i];
20942 print (vam->ofp, "[%d] %s", i, node->name);
20943 for (j = 0; j < vec_len (node->next_nodes); j++)
20945 if (node->next_nodes[j] != ~0)
20947 next_node = vam->graph_nodes[node->next_nodes[j]];
20948 print (vam->ofp, " [%d] %s", j, next_node->name);
20956 value_sort_cmp (void *a1, void *a2)
20958 name_sort_t *n1 = a1;
20959 name_sort_t *n2 = a2;
20961 if (n1->value < n2->value)
20963 if (n1->value > n2->value)
20970 dump_msg_api_table (vat_main_t * vam)
20972 api_main_t *am = &api_main;
20973 name_sort_t *nses = 0, *ns;
20978 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
20980 vec_add2 (nses, ns, 1);
20981 ns->name = (u8 *)(hp->key);
20982 ns->value = (u32) hp->value[0];
20986 vec_sort_with_function (nses, value_sort_cmp);
20988 for (i = 0; i < vec_len (nses); i++)
20989 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
20995 get_msg_id (vat_main_t * vam)
21000 if (unformat (vam->input, "%s", &name_and_crc))
21002 message_index = vl_api_get_msg_index (name_and_crc);
21003 if (message_index == ~0)
21005 print (vam->ofp, " '%s' not found", name_and_crc);
21008 print (vam->ofp, " '%s' has message index %d",
21009 name_and_crc, message_index);
21012 errmsg ("name_and_crc required...");
21017 search_node_table (vat_main_t * vam)
21019 unformat_input_t *line_input = vam->input;
21022 vlib_node_t *node, *next_node;
21025 if (vam->graph_node_index_by_name == 0)
21027 print (vam->ofp, "Node table empty, issue get_node_graph...");
21031 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21033 if (unformat (line_input, "%s", &node_to_find))
21035 vec_add1 (node_to_find, 0);
21036 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21039 print (vam->ofp, "%s not found...", node_to_find);
21042 node = vam->graph_nodes[p[0]];
21043 print (vam->ofp, "[%d] %s", p[0], node->name);
21044 for (j = 0; j < vec_len (node->next_nodes); j++)
21046 if (node->next_nodes[j] != ~0)
21048 next_node = vam->graph_nodes[node->next_nodes[j]];
21049 print (vam->ofp, " [%d] %s", j, next_node->name);
21056 clib_warning ("parse error '%U'", format_unformat_error,
21062 vec_free (node_to_find);
21071 script (vat_main_t * vam)
21073 #if (VPP_API_TEST_BUILTIN==0)
21075 char *save_current_file;
21076 unformat_input_t save_input;
21077 jmp_buf save_jump_buf;
21078 u32 save_line_number;
21080 FILE *new_fp, *save_ifp;
21082 if (unformat (vam->input, "%s", &s))
21084 new_fp = fopen ((char *) s, "r");
21087 errmsg ("Couldn't open script file %s", s);
21094 errmsg ("Missing script name");
21098 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21099 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21100 save_ifp = vam->ifp;
21101 save_line_number = vam->input_line_number;
21102 save_current_file = (char *) vam->current_file;
21104 vam->input_line_number = 0;
21106 vam->current_file = s;
21109 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
21110 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21111 vam->ifp = save_ifp;
21112 vam->input_line_number = save_line_number;
21113 vam->current_file = (u8 *) save_current_file;
21118 clib_warning ("use the exec command...");
21124 echo (vat_main_t * vam)
21126 print (vam->ofp, "%v", vam->input->buffer);
21130 /* List of API message constructors, CLI names map to api_xxx */
21131 #define foreach_vpe_api_msg \
21132 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21133 _(sw_interface_dump,"") \
21134 _(sw_interface_set_flags, \
21135 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21136 _(sw_interface_add_del_address, \
21137 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21138 _(sw_interface_set_table, \
21139 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21140 _(sw_interface_set_mpls_enable, \
21141 "<intfc> | sw_if_index [disable | dis]") \
21142 _(sw_interface_set_vpath, \
21143 "<intfc> | sw_if_index <id> enable | disable") \
21144 _(sw_interface_set_vxlan_bypass, \
21145 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21146 _(sw_interface_set_geneve_bypass, \
21147 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21148 _(sw_interface_set_l2_xconnect, \
21149 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21150 "enable | disable") \
21151 _(sw_interface_set_l2_bridge, \
21152 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21153 "[shg <split-horizon-group>] [bvi]\n" \
21154 "enable | disable") \
21155 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21156 _(bridge_domain_add_del, \
21157 "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") \
21158 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21160 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21161 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21162 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21164 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21166 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21168 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
21170 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
21172 "<vpp-if-name> | sw_if_index <id>") \
21173 _(sw_interface_tap_dump, "") \
21174 _(ip_table_add_del, \
21175 "table-id <n> [ipv6]\n") \
21176 _(ip_add_del_route, \
21177 "<addr>/<mask> via <addr> [table-id <n>]\n" \
21178 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
21179 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
21180 "[multipath] [count <n>]") \
21181 _(ip_mroute_add_del, \
21182 "<src> <grp>/<mask> [table-id <n>]\n" \
21183 "[<intfc> | sw_if_index <id>] [local] [del]") \
21184 _(mpls_table_add_del, \
21185 "table-id <n>\n") \
21186 _(mpls_route_add_del, \
21187 "<label> <eos> via <addr> [table-id <n>]\n" \
21188 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
21189 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
21190 "[multipath] [count <n>]") \
21191 _(mpls_ip_bind_unbind, \
21192 "<label> <addr/len>") \
21193 _(mpls_tunnel_add_del, \
21194 " via <addr> [table-id <n>]\n" \
21195 "sw_if_index <id>] [l2] [del]") \
21196 _(proxy_arp_add_del, \
21197 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
21198 _(proxy_arp_intfc_enable_disable, \
21199 "<intfc> | sw_if_index <id> enable | disable") \
21200 _(sw_interface_set_unnumbered, \
21201 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
21202 _(ip_neighbor_add_del, \
21203 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
21204 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
21205 _(reset_vrf, "vrf <id> [ipv6]") \
21206 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
21207 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
21208 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
21209 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
21210 "[outer_vlan_id_any][inner_vlan_id_any]") \
21211 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
21212 _(reset_fib, "vrf <n> [ipv6]") \
21213 _(dhcp_proxy_config, \
21214 "svr <v46-address> src <v46-address>\n" \
21215 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
21216 _(dhcp_proxy_set_vss, \
21217 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
21218 _(dhcp_proxy_dump, "ip6") \
21219 _(dhcp_client_config, \
21220 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
21221 _(set_ip_flow_hash, \
21222 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
21223 _(sw_interface_ip6_enable_disable, \
21224 "<intfc> | sw_if_index <id> enable | disable") \
21225 _(sw_interface_ip6_set_link_local_address, \
21226 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
21227 _(ip6nd_proxy_add_del, \
21228 "<intfc> | sw_if_index <id> <ip6-address>") \
21229 _(ip6nd_proxy_dump, "") \
21230 _(sw_interface_ip6nd_ra_prefix, \
21231 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
21232 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
21233 "[nolink] [isno]") \
21234 _(sw_interface_ip6nd_ra_config, \
21235 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
21236 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
21237 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
21238 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
21239 _(l2_patch_add_del, \
21240 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21241 "enable | disable") \
21242 _(sr_localsid_add_del, \
21243 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
21244 "fib-table <num> (end.psp) sw_if_index <num>") \
21245 _(classify_add_del_table, \
21246 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
21247 " [del] [del-chain] mask <mask-value>\n" \
21248 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
21249 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
21250 _(classify_add_del_session, \
21251 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
21252 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
21253 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
21254 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
21255 _(classify_set_interface_ip_table, \
21256 "<intfc> | sw_if_index <nn> table <nn>") \
21257 _(classify_set_interface_l2_tables, \
21258 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21259 " [other-table <nn>]") \
21260 _(get_node_index, "node <node-name") \
21261 _(add_node_next, "node <node-name> next <next-node-name>") \
21262 _(l2tpv3_create_tunnel, \
21263 "client_address <ip6-addr> our_address <ip6-addr>\n" \
21264 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
21265 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
21266 _(l2tpv3_set_tunnel_cookies, \
21267 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
21268 "[new_remote_cookie <nn>]\n") \
21269 _(l2tpv3_interface_enable_disable, \
21270 "<intfc> | sw_if_index <nn> enable | disable") \
21271 _(l2tpv3_set_lookup_key, \
21272 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
21273 _(sw_if_l2tpv3_tunnel_dump, "") \
21274 _(vxlan_add_del_tunnel, \
21275 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21276 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21277 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21278 _(geneve_add_del_tunnel, \
21279 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21280 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21281 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21282 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21283 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21284 _(gre_add_del_tunnel, \
21285 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
21286 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21287 _(l2_fib_clear_table, "") \
21288 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
21289 _(l2_interface_vlan_tag_rewrite, \
21290 "<intfc> | sw_if_index <nn> \n" \
21291 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
21292 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
21293 _(create_vhost_user_if, \
21294 "socket <filename> [server] [renumber <dev_instance>] " \
21295 "[mac <mac_address>]") \
21296 _(modify_vhost_user_if, \
21297 "<intfc> | sw_if_index <nn> socket <filename>\n" \
21298 "[server] [renumber <dev_instance>]") \
21299 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
21300 _(sw_interface_vhost_user_dump, "") \
21301 _(show_version, "") \
21302 _(vxlan_gpe_add_del_tunnel, \
21303 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
21304 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21305 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
21306 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
21307 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21308 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
21309 _(interface_name_renumber, \
21310 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
21311 _(input_acl_set_interface, \
21312 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21313 " [l2-table <nn>] [del]") \
21314 _(want_ip4_arp_events, "address <ip4-address> [del]") \
21315 _(want_ip6_nd_events, "address <ip6-address> [del]") \
21316 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
21317 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
21318 _(ip_dump, "ipv4 | ipv6") \
21319 _(ipsec_spd_add_del, "spd_id <n> [del]") \
21320 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
21322 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
21323 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
21324 " integ_alg <alg> integ_key <hex>") \
21325 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
21326 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
21327 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
21328 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
21329 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
21330 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
21331 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
21332 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
21333 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
21334 _(ipsec_sa_dump, "[sa_id <n>]") \
21335 _(ikev2_profile_add_del, "name <profile_name> [del]") \
21336 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
21337 "(auth_data 0x<data> | auth_data <data>)") \
21338 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
21339 "(id_data 0x<data> | id_data <data>) (local|remote)") \
21340 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
21341 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
21342 "(local|remote)") \
21343 _(ikev2_set_local_key, "file <absolute_file_path>") \
21344 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
21345 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
21346 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
21347 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
21348 _(ikev2_initiate_sa_init, "<profile_name>") \
21349 _(ikev2_initiate_del_ike_sa, "<ispi>") \
21350 _(ikev2_initiate_del_child_sa, "<ispi>") \
21351 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
21352 _(delete_loopback,"sw_if_index <nn>") \
21353 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
21354 _(map_add_domain, \
21355 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
21356 "ip6-src <ip6addr> " \
21357 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
21358 _(map_del_domain, "index <n>") \
21359 _(map_add_del_rule, \
21360 "index <n> psid <n> dst <ip6addr> [del]") \
21361 _(map_domain_dump, "") \
21362 _(map_rule_dump, "index <map-domain>") \
21363 _(want_interface_events, "enable|disable") \
21364 _(want_stats,"enable|disable") \
21365 _(get_first_msg_id, "client <name>") \
21366 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
21367 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
21368 "fib-id <nn> [ip4][ip6][default]") \
21369 _(get_node_graph, " ") \
21370 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
21371 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
21372 _(ioam_disable, "") \
21373 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
21374 " sw_if_index <sw_if_index> p <priority> " \
21375 "w <weight>] [del]") \
21376 _(one_add_del_locator, "locator-set <locator_name> " \
21377 "iface <intf> | sw_if_index <sw_if_index> " \
21378 "p <priority> w <weight> [del]") \
21379 _(one_add_del_local_eid,"vni <vni> eid " \
21380 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21381 "locator-set <locator_name> [del]" \
21382 "[key-id sha1|sha256 secret-key <secret-key>]")\
21383 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
21384 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
21385 _(one_enable_disable, "enable|disable") \
21386 _(one_map_register_enable_disable, "enable|disable") \
21387 _(one_map_register_fallback_threshold, "<value>") \
21388 _(one_rloc_probe_enable_disable, "enable|disable") \
21389 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21391 "rloc <locator> p <prio> " \
21392 "w <weight> [rloc <loc> ... ] " \
21393 "action <action> [del-all]") \
21394 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21396 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21397 _(one_use_petr, "ip-address> | disable") \
21398 _(one_map_request_mode, "src-dst|dst-only") \
21399 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21400 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21401 _(one_locator_set_dump, "[local | remote]") \
21402 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
21403 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21404 "[local] | [remote]") \
21405 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
21406 _(one_ndp_bd_get, "") \
21407 _(one_ndp_entries_get, "bd <bridge-domain>") \
21408 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
21409 _(one_l2_arp_bd_get, "") \
21410 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
21411 _(one_stats_enable_disable, "enable|disalbe") \
21412 _(show_one_stats_enable_disable, "") \
21413 _(one_eid_table_vni_dump, "") \
21414 _(one_eid_table_map_dump, "l2|l3") \
21415 _(one_map_resolver_dump, "") \
21416 _(one_map_server_dump, "") \
21417 _(one_adjacencies_get, "vni <vni>") \
21418 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
21419 _(show_one_rloc_probe_state, "") \
21420 _(show_one_map_register_state, "") \
21421 _(show_one_status, "") \
21422 _(one_stats_dump, "") \
21423 _(one_stats_flush, "") \
21424 _(one_get_map_request_itr_rlocs, "") \
21425 _(one_map_register_set_ttl, "<ttl>") \
21426 _(one_set_transport_protocol, "udp|api") \
21427 _(one_get_transport_protocol, "") \
21428 _(show_one_nsh_mapping, "") \
21429 _(show_one_pitr, "") \
21430 _(show_one_use_petr, "") \
21431 _(show_one_map_request_mode, "") \
21432 _(show_one_map_register_ttl, "") \
21433 _(show_one_map_register_fallback_threshold, "") \
21434 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
21435 " sw_if_index <sw_if_index> p <priority> " \
21436 "w <weight>] [del]") \
21437 _(lisp_add_del_locator, "locator-set <locator_name> " \
21438 "iface <intf> | sw_if_index <sw_if_index> " \
21439 "p <priority> w <weight> [del]") \
21440 _(lisp_add_del_local_eid,"vni <vni> eid " \
21441 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21442 "locator-set <locator_name> [del]" \
21443 "[key-id sha1|sha256 secret-key <secret-key>]") \
21444 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
21445 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
21446 _(lisp_enable_disable, "enable|disable") \
21447 _(lisp_map_register_enable_disable, "enable|disable") \
21448 _(lisp_rloc_probe_enable_disable, "enable|disable") \
21449 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21451 "rloc <locator> p <prio> " \
21452 "w <weight> [rloc <loc> ... ] " \
21453 "action <action> [del-all]") \
21454 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21456 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21457 _(lisp_use_petr, "<ip-address> | disable") \
21458 _(lisp_map_request_mode, "src-dst|dst-only") \
21459 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21460 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21461 _(lisp_locator_set_dump, "[local | remote]") \
21462 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
21463 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21464 "[local] | [remote]") \
21465 _(lisp_eid_table_vni_dump, "") \
21466 _(lisp_eid_table_map_dump, "l2|l3") \
21467 _(lisp_map_resolver_dump, "") \
21468 _(lisp_map_server_dump, "") \
21469 _(lisp_adjacencies_get, "vni <vni>") \
21470 _(gpe_fwd_entry_vnis_get, "") \
21471 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
21472 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
21473 "[table <table-id>]") \
21474 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
21475 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
21476 _(gpe_set_encap_mode, "lisp|vxlan") \
21477 _(gpe_get_encap_mode, "") \
21478 _(lisp_gpe_add_del_iface, "up|down") \
21479 _(lisp_gpe_enable_disable, "enable|disable") \
21480 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
21481 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
21482 _(show_lisp_rloc_probe_state, "") \
21483 _(show_lisp_map_register_state, "") \
21484 _(show_lisp_status, "") \
21485 _(lisp_get_map_request_itr_rlocs, "") \
21486 _(show_lisp_pitr, "") \
21487 _(show_lisp_use_petr, "") \
21488 _(show_lisp_map_request_mode, "") \
21489 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
21490 _(af_packet_delete, "name <host interface name>") \
21491 _(policer_add_del, "name <policer name> <params> [del]") \
21492 _(policer_dump, "[name <policer name>]") \
21493 _(policer_classify_set_interface, \
21494 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21495 " [l2-table <nn>] [del]") \
21496 _(policer_classify_dump, "type [ip4|ip6|l2]") \
21497 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
21498 "[master|slave]") \
21499 _(netmap_delete, "name <interface name>") \
21500 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
21501 _(mpls_fib_dump, "") \
21502 _(classify_table_ids, "") \
21503 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
21504 _(classify_table_info, "table_id <nn>") \
21505 _(classify_session_dump, "table_id <nn>") \
21506 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
21507 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
21508 "[template_interval <nn>] [udp_checksum]") \
21509 _(ipfix_exporter_dump, "") \
21510 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
21511 _(ipfix_classify_stream_dump, "") \
21512 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
21513 _(ipfix_classify_table_dump, "") \
21514 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
21515 _(sw_interface_span_dump, "[l2]") \
21516 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
21517 _(pg_create_interface, "if_id <nn>") \
21518 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
21519 _(pg_enable_disable, "[stream <id>] disable") \
21520 _(ip_source_and_port_range_check_add_del, \
21521 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
21522 _(ip_source_and_port_range_check_interface_add_del, \
21523 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
21524 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
21525 _(ipsec_gre_add_del_tunnel, \
21526 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
21527 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
21528 _(delete_subif,"<intfc> | sw_if_index <nn>") \
21529 _(l2_interface_pbb_tag_rewrite, \
21530 "<intfc> | sw_if_index <nn> \n" \
21531 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
21532 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
21533 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
21534 _(flow_classify_set_interface, \
21535 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
21536 _(flow_classify_dump, "type [ip4|ip6]") \
21537 _(ip_fib_dump, "") \
21538 _(ip_mfib_dump, "") \
21539 _(ip6_fib_dump, "") \
21540 _(ip6_mfib_dump, "") \
21541 _(feature_enable_disable, "arc_name <arc_name> " \
21542 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
21543 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
21545 _(l2_xconnect_dump, "") \
21546 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
21547 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
21548 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
21549 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
21550 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
21551 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
21552 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>] [disable]") \
21553 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
21554 _(memfd_segment_create,"size <nnn>")
21556 /* List of command functions, CLI names map directly to functions */
21557 #define foreach_cli_function \
21558 _(comment, "usage: comment <ignore-rest-of-line>") \
21559 _(dump_interface_table, "usage: dump_interface_table") \
21560 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
21561 _(dump_ipv4_table, "usage: dump_ipv4_table") \
21562 _(dump_ipv6_table, "usage: dump_ipv6_table") \
21563 _(dump_stats_table, "usage: dump_stats_table") \
21564 _(dump_macro_table, "usage: dump_macro_table ") \
21565 _(dump_node_table, "usage: dump_node_table") \
21566 _(dump_msg_api_table, "usage: dump_msg_api_table") \
21567 _(get_msg_id, "usage: get_msg_id name_and_crc") \
21568 _(echo, "usage: echo <message>") \
21569 _(exec, "usage: exec <vpe-debug-CLI-command>") \
21570 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
21571 _(help, "usage: help") \
21572 _(q, "usage: quit") \
21573 _(quit, "usage: quit") \
21574 _(search_node_table, "usage: search_node_table <name>...") \
21575 _(set, "usage: set <variable-name> <value>") \
21576 _(script, "usage: script <file-name>") \
21577 _(unset, "usage: unset <variable-name>")
21579 static void vl_api_##n##_t_handler_uni \
21580 (vl_api_##n##_t * mp) \
21582 vat_main_t * vam = &vat_main; \
21583 if (vam->json_output) { \
21584 vl_api_##n##_t_handler_json(mp); \
21586 vl_api_##n##_t_handler(mp); \
21589 foreach_vpe_api_reply_msg;
21590 #if VPP_API_TEST_BUILTIN == 0
21591 foreach_standalone_reply_msg;
21596 vat_api_hookup (vat_main_t * vam)
21599 vl_msg_api_set_handlers(VL_API_##N, #n, \
21600 vl_api_##n##_t_handler_uni, \
21602 vl_api_##n##_t_endian, \
21603 vl_api_##n##_t_print, \
21604 sizeof(vl_api_##n##_t), 1);
21605 foreach_vpe_api_reply_msg;
21606 #if VPP_API_TEST_BUILTIN == 0
21607 foreach_standalone_reply_msg;
21611 #if (VPP_API_TEST_BUILTIN==0)
21612 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
21614 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
21616 vam->function_by_name = hash_create_string (0, sizeof (uword));
21618 vam->help_by_name = hash_create_string (0, sizeof (uword));
21621 /* API messages we can send */
21622 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
21623 foreach_vpe_api_msg;
21627 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21628 foreach_vpe_api_msg;
21631 /* CLI functions */
21632 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
21633 foreach_cli_function;
21637 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21638 foreach_cli_function;
21642 #if VPP_API_TEST_BUILTIN
21643 static clib_error_t *
21644 vat_api_hookup_shim (vlib_main_t * vm)
21646 vat_api_hookup (&vat_main);
21650 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
21654 * fd.io coding-style-patch-verification: ON
21657 * eval: (c-set-style "gnu")