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 (u8 * mac)
723 u64 tmp = *((u64 *) mac);
724 tmp = clib_net_to_host_u64 (tmp);
725 tmp += 1 << 16; /* skip unused (least significant) octets */
726 tmp = clib_host_to_net_u64 (tmp);
728 clib_memcpy (mac, &tmp, 6);
731 static void vl_api_create_loopback_reply_t_handler
732 (vl_api_create_loopback_reply_t * mp)
734 vat_main_t *vam = &vat_main;
735 i32 retval = ntohl (mp->retval);
737 vam->retval = retval;
738 vam->regenerate_interface_table = 1;
739 vam->sw_if_index = ntohl (mp->sw_if_index);
740 vam->result_ready = 1;
743 static void vl_api_create_loopback_reply_t_handler_json
744 (vl_api_create_loopback_reply_t * mp)
746 vat_main_t *vam = &vat_main;
747 vat_json_node_t node;
749 vat_json_init_object (&node);
750 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
751 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
753 vat_json_print (vam->ofp, &node);
754 vat_json_free (&node);
755 vam->retval = ntohl (mp->retval);
756 vam->result_ready = 1;
759 static void vl_api_create_loopback_instance_reply_t_handler
760 (vl_api_create_loopback_instance_reply_t * mp)
762 vat_main_t *vam = &vat_main;
763 i32 retval = ntohl (mp->retval);
765 vam->retval = retval;
766 vam->regenerate_interface_table = 1;
767 vam->sw_if_index = ntohl (mp->sw_if_index);
768 vam->result_ready = 1;
771 static void vl_api_create_loopback_instance_reply_t_handler_json
772 (vl_api_create_loopback_instance_reply_t * mp)
774 vat_main_t *vam = &vat_main;
775 vat_json_node_t node;
777 vat_json_init_object (&node);
778 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
779 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
781 vat_json_print (vam->ofp, &node);
782 vat_json_free (&node);
783 vam->retval = ntohl (mp->retval);
784 vam->result_ready = 1;
787 static void vl_api_af_packet_create_reply_t_handler
788 (vl_api_af_packet_create_reply_t * mp)
790 vat_main_t *vam = &vat_main;
791 i32 retval = ntohl (mp->retval);
793 vam->retval = retval;
794 vam->regenerate_interface_table = 1;
795 vam->sw_if_index = ntohl (mp->sw_if_index);
796 vam->result_ready = 1;
799 static void vl_api_af_packet_create_reply_t_handler_json
800 (vl_api_af_packet_create_reply_t * mp)
802 vat_main_t *vam = &vat_main;
803 vat_json_node_t node;
805 vat_json_init_object (&node);
806 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
807 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
809 vat_json_print (vam->ofp, &node);
810 vat_json_free (&node);
812 vam->retval = ntohl (mp->retval);
813 vam->result_ready = 1;
816 static void vl_api_create_vlan_subif_reply_t_handler
817 (vl_api_create_vlan_subif_reply_t * mp)
819 vat_main_t *vam = &vat_main;
820 i32 retval = ntohl (mp->retval);
822 vam->retval = retval;
823 vam->regenerate_interface_table = 1;
824 vam->sw_if_index = ntohl (mp->sw_if_index);
825 vam->result_ready = 1;
828 static void vl_api_create_vlan_subif_reply_t_handler_json
829 (vl_api_create_vlan_subif_reply_t * mp)
831 vat_main_t *vam = &vat_main;
832 vat_json_node_t node;
834 vat_json_init_object (&node);
835 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
836 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
838 vat_json_print (vam->ofp, &node);
839 vat_json_free (&node);
841 vam->retval = ntohl (mp->retval);
842 vam->result_ready = 1;
845 static void vl_api_create_subif_reply_t_handler
846 (vl_api_create_subif_reply_t * mp)
848 vat_main_t *vam = &vat_main;
849 i32 retval = ntohl (mp->retval);
851 vam->retval = retval;
852 vam->regenerate_interface_table = 1;
853 vam->sw_if_index = ntohl (mp->sw_if_index);
854 vam->result_ready = 1;
857 static void vl_api_create_subif_reply_t_handler_json
858 (vl_api_create_subif_reply_t * mp)
860 vat_main_t *vam = &vat_main;
861 vat_json_node_t node;
863 vat_json_init_object (&node);
864 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
865 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
867 vat_json_print (vam->ofp, &node);
868 vat_json_free (&node);
870 vam->retval = ntohl (mp->retval);
871 vam->result_ready = 1;
874 static void vl_api_interface_name_renumber_reply_t_handler
875 (vl_api_interface_name_renumber_reply_t * mp)
877 vat_main_t *vam = &vat_main;
878 i32 retval = ntohl (mp->retval);
880 vam->retval = retval;
881 vam->regenerate_interface_table = 1;
882 vam->result_ready = 1;
885 static void vl_api_interface_name_renumber_reply_t_handler_json
886 (vl_api_interface_name_renumber_reply_t * mp)
888 vat_main_t *vam = &vat_main;
889 vat_json_node_t node;
891 vat_json_init_object (&node);
892 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
894 vat_json_print (vam->ofp, &node);
895 vat_json_free (&node);
897 vam->retval = ntohl (mp->retval);
898 vam->result_ready = 1;
902 * Special-case: build the interface table, maintain
903 * the next loopback sw_if_index vbl.
905 static void vl_api_sw_interface_details_t_handler
906 (vl_api_sw_interface_details_t * mp)
908 vat_main_t *vam = &vat_main;
909 u8 *s = format (0, "%s%c", mp->interface_name, 0);
911 hash_set_mem (vam->sw_if_index_by_interface_name, s,
912 ntohl (mp->sw_if_index));
914 /* In sub interface case, fill the sub interface table entry */
915 if (mp->sw_if_index != mp->sup_sw_if_index)
917 sw_interface_subif_t *sub = NULL;
919 vec_add2 (vam->sw_if_subif_table, sub, 1);
921 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
922 strncpy ((char *) sub->interface_name, (char *) s,
923 vec_len (sub->interface_name));
924 sub->sw_if_index = ntohl (mp->sw_if_index);
925 sub->sub_id = ntohl (mp->sub_id);
927 sub->sub_dot1ad = mp->sub_dot1ad;
928 sub->sub_number_of_tags = mp->sub_number_of_tags;
929 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
930 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
931 sub->sub_exact_match = mp->sub_exact_match;
932 sub->sub_default = mp->sub_default;
933 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
934 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
936 /* vlan tag rewrite */
937 sub->vtr_op = ntohl (mp->vtr_op);
938 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
939 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
940 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
944 static void vl_api_sw_interface_details_t_handler_json
945 (vl_api_sw_interface_details_t * mp)
947 vat_main_t *vam = &vat_main;
948 vat_json_node_t *node = NULL;
950 if (VAT_JSON_ARRAY != vam->json_tree.type)
952 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
953 vat_json_init_array (&vam->json_tree);
955 node = vat_json_array_add (&vam->json_tree);
957 vat_json_init_object (node);
958 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
959 vat_json_object_add_uint (node, "sup_sw_if_index",
960 ntohl (mp->sup_sw_if_index));
961 vat_json_object_add_uint (node, "l2_address_length",
962 ntohl (mp->l2_address_length));
963 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
964 sizeof (mp->l2_address));
965 vat_json_object_add_string_copy (node, "interface_name",
967 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
968 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
969 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
970 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
971 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
972 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
973 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
974 vat_json_object_add_uint (node, "sub_number_of_tags",
975 mp->sub_number_of_tags);
976 vat_json_object_add_uint (node, "sub_outer_vlan_id",
977 ntohs (mp->sub_outer_vlan_id));
978 vat_json_object_add_uint (node, "sub_inner_vlan_id",
979 ntohs (mp->sub_inner_vlan_id));
980 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
981 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
982 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
983 mp->sub_outer_vlan_id_any);
984 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
985 mp->sub_inner_vlan_id_any);
986 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
987 vat_json_object_add_uint (node, "vtr_push_dot1q",
988 ntohl (mp->vtr_push_dot1q));
989 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
990 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
993 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
995 format_ethernet_address,
997 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
999 format_ethernet_address,
1001 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1002 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1006 #if VPP_API_TEST_BUILTIN == 0
1007 static void vl_api_sw_interface_event_t_handler
1008 (vl_api_sw_interface_event_t * mp)
1010 vat_main_t *vam = &vat_main;
1011 if (vam->interface_event_display)
1012 errmsg ("interface flags: sw_if_index %d %s %s",
1013 ntohl (mp->sw_if_index),
1014 mp->admin_up_down ? "admin-up" : "admin-down",
1015 mp->link_up_down ? "link-up" : "link-down");
1019 static void vl_api_sw_interface_event_t_handler_json
1020 (vl_api_sw_interface_event_t * mp)
1022 /* JSON output not supported */
1026 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1028 vat_main_t *vam = &vat_main;
1029 i32 retval = ntohl (mp->retval);
1031 vam->retval = retval;
1032 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1033 vam->result_ready = 1;
1037 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1039 vat_main_t *vam = &vat_main;
1040 vat_json_node_t node;
1041 api_main_t *am = &api_main;
1045 vat_json_init_object (&node);
1046 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1047 vat_json_object_add_uint (&node, "reply_in_shmem",
1048 ntohl (mp->reply_in_shmem));
1049 /* Toss the shared-memory original... */
1050 pthread_mutex_lock (&am->vlib_rp->mutex);
1051 oldheap = svm_push_data_heap (am->vlib_rp);
1053 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1056 svm_pop_heap (oldheap);
1057 pthread_mutex_unlock (&am->vlib_rp->mutex);
1059 vat_json_print (vam->ofp, &node);
1060 vat_json_free (&node);
1062 vam->retval = ntohl (mp->retval);
1063 vam->result_ready = 1;
1067 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1069 vat_main_t *vam = &vat_main;
1070 i32 retval = ntohl (mp->retval);
1071 u32 length = ntohl (mp->length);
1073 vec_reset_length (vam->cmd_reply);
1075 vam->retval = retval;
1078 vec_validate (vam->cmd_reply, length);
1079 clib_memcpy ((char *) (vam->cmd_reply), mp->reply, length);
1080 vam->cmd_reply[length] = 0;
1082 vam->result_ready = 1;
1086 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1088 vat_main_t *vam = &vat_main;
1089 vat_json_node_t node;
1091 vec_reset_length (vam->cmd_reply);
1093 vat_json_init_object (&node);
1094 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1095 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1097 vat_json_print (vam->ofp, &node);
1098 vat_json_free (&node);
1100 vam->retval = ntohl (mp->retval);
1101 vam->result_ready = 1;
1104 static void vl_api_classify_add_del_table_reply_t_handler
1105 (vl_api_classify_add_del_table_reply_t * mp)
1107 vat_main_t *vam = &vat_main;
1108 i32 retval = ntohl (mp->retval);
1109 if (vam->async_mode)
1111 vam->async_errors += (retval < 0);
1115 vam->retval = retval;
1117 ((mp->new_table_index != 0xFFFFFFFF) ||
1118 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1119 (mp->match_n_vectors != 0xFFFFFFFF)))
1121 * Note: this is just barely thread-safe, depends on
1122 * the main thread spinning waiting for an answer...
1124 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1125 ntohl (mp->new_table_index),
1126 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1127 vam->result_ready = 1;
1131 static void vl_api_classify_add_del_table_reply_t_handler_json
1132 (vl_api_classify_add_del_table_reply_t * mp)
1134 vat_main_t *vam = &vat_main;
1135 vat_json_node_t node;
1137 vat_json_init_object (&node);
1138 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1139 vat_json_object_add_uint (&node, "new_table_index",
1140 ntohl (mp->new_table_index));
1141 vat_json_object_add_uint (&node, "skip_n_vectors",
1142 ntohl (mp->skip_n_vectors));
1143 vat_json_object_add_uint (&node, "match_n_vectors",
1144 ntohl (mp->match_n_vectors));
1146 vat_json_print (vam->ofp, &node);
1147 vat_json_free (&node);
1149 vam->retval = ntohl (mp->retval);
1150 vam->result_ready = 1;
1153 static void vl_api_get_node_index_reply_t_handler
1154 (vl_api_get_node_index_reply_t * mp)
1156 vat_main_t *vam = &vat_main;
1157 i32 retval = ntohl (mp->retval);
1158 if (vam->async_mode)
1160 vam->async_errors += (retval < 0);
1164 vam->retval = retval;
1166 errmsg ("node index %d", ntohl (mp->node_index));
1167 vam->result_ready = 1;
1171 static void vl_api_get_node_index_reply_t_handler_json
1172 (vl_api_get_node_index_reply_t * mp)
1174 vat_main_t *vam = &vat_main;
1175 vat_json_node_t node;
1177 vat_json_init_object (&node);
1178 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1179 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1181 vat_json_print (vam->ofp, &node);
1182 vat_json_free (&node);
1184 vam->retval = ntohl (mp->retval);
1185 vam->result_ready = 1;
1188 static void vl_api_get_next_index_reply_t_handler
1189 (vl_api_get_next_index_reply_t * mp)
1191 vat_main_t *vam = &vat_main;
1192 i32 retval = ntohl (mp->retval);
1193 if (vam->async_mode)
1195 vam->async_errors += (retval < 0);
1199 vam->retval = retval;
1201 errmsg ("next node index %d", ntohl (mp->next_index));
1202 vam->result_ready = 1;
1206 static void vl_api_get_next_index_reply_t_handler_json
1207 (vl_api_get_next_index_reply_t * mp)
1209 vat_main_t *vam = &vat_main;
1210 vat_json_node_t node;
1212 vat_json_init_object (&node);
1213 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1214 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1216 vat_json_print (vam->ofp, &node);
1217 vat_json_free (&node);
1219 vam->retval = ntohl (mp->retval);
1220 vam->result_ready = 1;
1223 static void vl_api_add_node_next_reply_t_handler
1224 (vl_api_add_node_next_reply_t * mp)
1226 vat_main_t *vam = &vat_main;
1227 i32 retval = ntohl (mp->retval);
1228 if (vam->async_mode)
1230 vam->async_errors += (retval < 0);
1234 vam->retval = retval;
1236 errmsg ("next index %d", ntohl (mp->next_index));
1237 vam->result_ready = 1;
1241 static void vl_api_add_node_next_reply_t_handler_json
1242 (vl_api_add_node_next_reply_t * mp)
1244 vat_main_t *vam = &vat_main;
1245 vat_json_node_t node;
1247 vat_json_init_object (&node);
1248 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1249 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1251 vat_json_print (vam->ofp, &node);
1252 vat_json_free (&node);
1254 vam->retval = ntohl (mp->retval);
1255 vam->result_ready = 1;
1258 static void vl_api_show_version_reply_t_handler
1259 (vl_api_show_version_reply_t * mp)
1261 vat_main_t *vam = &vat_main;
1262 i32 retval = ntohl (mp->retval);
1266 errmsg (" program: %s", mp->program);
1267 errmsg (" version: %s", mp->version);
1268 errmsg (" build date: %s", mp->build_date);
1269 errmsg ("build directory: %s", mp->build_directory);
1271 vam->retval = retval;
1272 vam->result_ready = 1;
1275 static void vl_api_show_version_reply_t_handler_json
1276 (vl_api_show_version_reply_t * mp)
1278 vat_main_t *vam = &vat_main;
1279 vat_json_node_t node;
1281 vat_json_init_object (&node);
1282 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1283 vat_json_object_add_string_copy (&node, "program", mp->program);
1284 vat_json_object_add_string_copy (&node, "version", mp->version);
1285 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1286 vat_json_object_add_string_copy (&node, "build_directory",
1287 mp->build_directory);
1289 vat_json_print (vam->ofp, &node);
1290 vat_json_free (&node);
1292 vam->retval = ntohl (mp->retval);
1293 vam->result_ready = 1;
1297 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1299 u32 sw_if_index = ntohl (mp->sw_if_index);
1300 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1301 mp->mac_ip ? "mac/ip binding" : "address resolution",
1302 ntohl (mp->pid), format_ip4_address, &mp->address,
1303 format_ethernet_address, mp->new_mac, sw_if_index);
1307 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1309 /* JSON output not supported */
1313 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1315 u32 sw_if_index = ntohl (mp->sw_if_index);
1316 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1317 mp->mac_ip ? "mac/ip binding" : "address resolution",
1318 ntohl (mp->pid), format_ip6_address, mp->address,
1319 format_ethernet_address, mp->new_mac, sw_if_index);
1323 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1325 /* JSON output not supported */
1329 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1331 u32 n_macs = ntohl (mp->n_macs);
1332 errmsg ("L2MAC event recived with pid %d cl-idx %d for %d macs: \n",
1333 ntohl (mp->pid), mp->client_index, n_macs);
1335 for (i = 0; i < n_macs; i++)
1337 vl_api_mac_entry_t *mac = &mp->mac[i];
1338 errmsg (" [%d] sw_if_index %d mac_addr %U is_del %d \n",
1339 i + 1, ntohl (mac->sw_if_index),
1340 format_ethernet_address, mac->mac_addr, mac->is_del);
1347 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1349 /* JSON output not supported */
1352 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1353 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1356 * Special-case: build the bridge domain table, maintain
1357 * the next bd id vbl.
1359 static void vl_api_bridge_domain_details_t_handler
1360 (vl_api_bridge_domain_details_t * mp)
1362 vat_main_t *vam = &vat_main;
1363 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1366 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1367 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1369 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1370 ntohl (mp->bd_id), mp->learn, mp->forward,
1371 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1375 vl_api_bridge_domain_sw_if_t *sw_ifs;
1376 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1379 sw_ifs = mp->sw_if_details;
1380 for (i = 0; i < n_sw_ifs; i++)
1386 sw_if_index = ntohl (sw_ifs->sw_if_index);
1389 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1391 if ((u32) p->value[0] == sw_if_index)
1393 sw_if_name = (u8 *)(p->key);
1398 print (vam->ofp, "%7d %3d %s", sw_if_index,
1399 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1400 "sw_if_index not found!");
1407 static void vl_api_bridge_domain_details_t_handler_json
1408 (vl_api_bridge_domain_details_t * mp)
1410 vat_main_t *vam = &vat_main;
1411 vat_json_node_t *node, *array = NULL;
1412 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1414 if (VAT_JSON_ARRAY != vam->json_tree.type)
1416 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1417 vat_json_init_array (&vam->json_tree);
1419 node = vat_json_array_add (&vam->json_tree);
1421 vat_json_init_object (node);
1422 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1423 vat_json_object_add_uint (node, "flood", mp->flood);
1424 vat_json_object_add_uint (node, "forward", mp->forward);
1425 vat_json_object_add_uint (node, "learn", mp->learn);
1426 vat_json_object_add_uint (node, "bvi_sw_if_index",
1427 ntohl (mp->bvi_sw_if_index));
1428 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1429 array = vat_json_object_add (node, "sw_if");
1430 vat_json_init_array (array);
1436 vl_api_bridge_domain_sw_if_t *sw_ifs;
1439 sw_ifs = mp->sw_if_details;
1440 for (i = 0; i < n_sw_ifs; i++)
1442 node = vat_json_array_add (array);
1443 vat_json_init_object (node);
1444 vat_json_object_add_uint (node, "sw_if_index",
1445 ntohl (sw_ifs->sw_if_index));
1446 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1452 static void vl_api_control_ping_reply_t_handler
1453 (vl_api_control_ping_reply_t * mp)
1455 vat_main_t *vam = &vat_main;
1456 i32 retval = ntohl (mp->retval);
1457 if (vam->async_mode)
1459 vam->async_errors += (retval < 0);
1463 vam->retval = retval;
1464 vam->result_ready = 1;
1466 vam->socket_client_main.control_pings_outstanding--;
1469 static void vl_api_control_ping_reply_t_handler_json
1470 (vl_api_control_ping_reply_t * mp)
1472 vat_main_t *vam = &vat_main;
1473 i32 retval = ntohl (mp->retval);
1475 if (VAT_JSON_NONE != vam->json_tree.type)
1477 vat_json_print (vam->ofp, &vam->json_tree);
1478 vat_json_free (&vam->json_tree);
1479 vam->json_tree.type = VAT_JSON_NONE;
1484 vat_json_init_array (&vam->json_tree);
1485 vat_json_print (vam->ofp, &vam->json_tree);
1486 vam->json_tree.type = VAT_JSON_NONE;
1489 vam->retval = retval;
1490 vam->result_ready = 1;
1494 vl_api_bridge_domain_set_mac_age_reply_t_handler
1495 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1497 vat_main_t *vam = &vat_main;
1498 i32 retval = ntohl (mp->retval);
1499 if (vam->async_mode)
1501 vam->async_errors += (retval < 0);
1505 vam->retval = retval;
1506 vam->result_ready = 1;
1510 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1511 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1513 vat_main_t *vam = &vat_main;
1514 vat_json_node_t node;
1516 vat_json_init_object (&node);
1517 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1519 vat_json_print (vam->ofp, &node);
1520 vat_json_free (&node);
1522 vam->retval = ntohl (mp->retval);
1523 vam->result_ready = 1;
1527 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1529 vat_main_t *vam = &vat_main;
1530 i32 retval = ntohl (mp->retval);
1531 if (vam->async_mode)
1533 vam->async_errors += (retval < 0);
1537 vam->retval = retval;
1538 vam->result_ready = 1;
1542 static void vl_api_l2_flags_reply_t_handler_json
1543 (vl_api_l2_flags_reply_t * mp)
1545 vat_main_t *vam = &vat_main;
1546 vat_json_node_t node;
1548 vat_json_init_object (&node);
1549 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1550 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1551 ntohl (mp->resulting_feature_bitmap));
1553 vat_json_print (vam->ofp, &node);
1554 vat_json_free (&node);
1556 vam->retval = ntohl (mp->retval);
1557 vam->result_ready = 1;
1560 static void vl_api_bridge_flags_reply_t_handler
1561 (vl_api_bridge_flags_reply_t * mp)
1563 vat_main_t *vam = &vat_main;
1564 i32 retval = ntohl (mp->retval);
1565 if (vam->async_mode)
1567 vam->async_errors += (retval < 0);
1571 vam->retval = retval;
1572 vam->result_ready = 1;
1576 static void vl_api_bridge_flags_reply_t_handler_json
1577 (vl_api_bridge_flags_reply_t * mp)
1579 vat_main_t *vam = &vat_main;
1580 vat_json_node_t node;
1582 vat_json_init_object (&node);
1583 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1584 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1585 ntohl (mp->resulting_feature_bitmap));
1587 vat_json_print (vam->ofp, &node);
1588 vat_json_free (&node);
1590 vam->retval = ntohl (mp->retval);
1591 vam->result_ready = 1;
1594 static void vl_api_tap_connect_reply_t_handler
1595 (vl_api_tap_connect_reply_t * mp)
1597 vat_main_t *vam = &vat_main;
1598 i32 retval = ntohl (mp->retval);
1599 if (vam->async_mode)
1601 vam->async_errors += (retval < 0);
1605 vam->retval = retval;
1606 vam->sw_if_index = ntohl (mp->sw_if_index);
1607 vam->result_ready = 1;
1612 static void vl_api_tap_connect_reply_t_handler_json
1613 (vl_api_tap_connect_reply_t * mp)
1615 vat_main_t *vam = &vat_main;
1616 vat_json_node_t node;
1618 vat_json_init_object (&node);
1619 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1620 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1622 vat_json_print (vam->ofp, &node);
1623 vat_json_free (&node);
1625 vam->retval = ntohl (mp->retval);
1626 vam->result_ready = 1;
1631 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1633 vat_main_t *vam = &vat_main;
1634 i32 retval = ntohl (mp->retval);
1635 if (vam->async_mode)
1637 vam->async_errors += (retval < 0);
1641 vam->retval = retval;
1642 vam->sw_if_index = ntohl (mp->sw_if_index);
1643 vam->result_ready = 1;
1647 static void vl_api_tap_modify_reply_t_handler_json
1648 (vl_api_tap_modify_reply_t * mp)
1650 vat_main_t *vam = &vat_main;
1651 vat_json_node_t node;
1653 vat_json_init_object (&node);
1654 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1655 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1657 vat_json_print (vam->ofp, &node);
1658 vat_json_free (&node);
1660 vam->retval = ntohl (mp->retval);
1661 vam->result_ready = 1;
1665 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1667 vat_main_t *vam = &vat_main;
1668 i32 retval = ntohl (mp->retval);
1669 if (vam->async_mode)
1671 vam->async_errors += (retval < 0);
1675 vam->retval = retval;
1676 vam->result_ready = 1;
1680 static void vl_api_tap_delete_reply_t_handler_json
1681 (vl_api_tap_delete_reply_t * mp)
1683 vat_main_t *vam = &vat_main;
1684 vat_json_node_t node;
1686 vat_json_init_object (&node);
1687 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1689 vat_json_print (vam->ofp, &node);
1690 vat_json_free (&node);
1692 vam->retval = ntohl (mp->retval);
1693 vam->result_ready = 1;
1696 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1697 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1699 vat_main_t *vam = &vat_main;
1700 i32 retval = ntohl (mp->retval);
1701 if (vam->async_mode)
1703 vam->async_errors += (retval < 0);
1707 vam->retval = retval;
1708 vam->result_ready = 1;
1712 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1713 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1715 vat_main_t *vam = &vat_main;
1716 vat_json_node_t node;
1718 vat_json_init_object (&node);
1719 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1720 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1721 ntohl (mp->sw_if_index));
1723 vat_json_print (vam->ofp, &node);
1724 vat_json_free (&node);
1726 vam->retval = ntohl (mp->retval);
1727 vam->result_ready = 1;
1730 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1731 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1733 vat_main_t *vam = &vat_main;
1734 i32 retval = ntohl (mp->retval);
1735 if (vam->async_mode)
1737 vam->async_errors += (retval < 0);
1741 vam->retval = retval;
1742 vam->sw_if_index = ntohl (mp->sw_if_index);
1743 vam->result_ready = 1;
1747 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1748 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1750 vat_main_t *vam = &vat_main;
1751 vat_json_node_t node;
1753 vat_json_init_object (&node);
1754 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1755 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1757 vat_json_print (vam->ofp, &node);
1758 vat_json_free (&node);
1760 vam->retval = ntohl (mp->retval);
1761 vam->result_ready = 1;
1764 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
1765 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1767 vat_main_t *vam = &vat_main;
1768 i32 retval = ntohl (mp->retval);
1769 if (vam->async_mode)
1771 vam->async_errors += (retval < 0);
1775 vam->retval = retval;
1776 vam->result_ready = 1;
1780 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
1781 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1783 vat_main_t *vam = &vat_main;
1784 vat_json_node_t node;
1786 vat_json_init_object (&node);
1787 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1788 vat_json_object_add_uint (&node, "fwd_entry_index",
1789 clib_net_to_host_u32 (mp->fwd_entry_index));
1791 vat_json_print (vam->ofp, &node);
1792 vat_json_free (&node);
1794 vam->retval = ntohl (mp->retval);
1795 vam->result_ready = 1;
1799 format_lisp_transport_protocol (u8 * s, va_list * args)
1801 u32 proto = va_arg (*args, u32);
1806 return format (s, "udp");
1808 return format (s, "api");
1815 static void vl_api_one_get_transport_protocol_reply_t_handler
1816 (vl_api_one_get_transport_protocol_reply_t * mp)
1818 vat_main_t *vam = &vat_main;
1819 i32 retval = ntohl (mp->retval);
1820 if (vam->async_mode)
1822 vam->async_errors += (retval < 0);
1826 u32 proto = mp->protocol;
1827 print (vam->ofp, "Transport protocol: %U",
1828 format_lisp_transport_protocol, proto);
1829 vam->retval = retval;
1830 vam->result_ready = 1;
1834 static void vl_api_one_get_transport_protocol_reply_t_handler_json
1835 (vl_api_one_get_transport_protocol_reply_t * mp)
1837 vat_main_t *vam = &vat_main;
1838 vat_json_node_t node;
1841 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
1844 vat_json_init_object (&node);
1845 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1846 vat_json_object_add_string_copy (&node, "transport-protocol", s);
1849 vat_json_print (vam->ofp, &node);
1850 vat_json_free (&node);
1852 vam->retval = ntohl (mp->retval);
1853 vam->result_ready = 1;
1856 static void vl_api_one_add_del_locator_set_reply_t_handler
1857 (vl_api_one_add_del_locator_set_reply_t * mp)
1859 vat_main_t *vam = &vat_main;
1860 i32 retval = ntohl (mp->retval);
1861 if (vam->async_mode)
1863 vam->async_errors += (retval < 0);
1867 vam->retval = retval;
1868 vam->result_ready = 1;
1872 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1873 (vl_api_one_add_del_locator_set_reply_t * mp)
1875 vat_main_t *vam = &vat_main;
1876 vat_json_node_t node;
1878 vat_json_init_object (&node);
1879 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1880 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1882 vat_json_print (vam->ofp, &node);
1883 vat_json_free (&node);
1885 vam->retval = ntohl (mp->retval);
1886 vam->result_ready = 1;
1889 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1890 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1892 vat_main_t *vam = &vat_main;
1893 i32 retval = ntohl (mp->retval);
1894 if (vam->async_mode)
1896 vam->async_errors += (retval < 0);
1900 vam->retval = retval;
1901 vam->sw_if_index = ntohl (mp->sw_if_index);
1902 vam->result_ready = 1;
1906 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1907 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1909 vat_main_t *vam = &vat_main;
1910 vat_json_node_t node;
1912 vat_json_init_object (&node);
1913 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1914 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1916 vat_json_print (vam->ofp, &node);
1917 vat_json_free (&node);
1919 vam->retval = ntohl (mp->retval);
1920 vam->result_ready = 1;
1923 static void vl_api_geneve_add_del_tunnel_reply_t_handler
1924 (vl_api_geneve_add_del_tunnel_reply_t * mp)
1926 vat_main_t *vam = &vat_main;
1927 i32 retval = ntohl (mp->retval);
1928 if (vam->async_mode)
1930 vam->async_errors += (retval < 0);
1934 vam->retval = retval;
1935 vam->sw_if_index = ntohl (mp->sw_if_index);
1936 vam->result_ready = 1;
1940 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
1941 (vl_api_geneve_add_del_tunnel_reply_t * mp)
1943 vat_main_t *vam = &vat_main;
1944 vat_json_node_t node;
1946 vat_json_init_object (&node);
1947 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1948 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1950 vat_json_print (vam->ofp, &node);
1951 vat_json_free (&node);
1953 vam->retval = ntohl (mp->retval);
1954 vam->result_ready = 1;
1957 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
1958 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1960 vat_main_t *vam = &vat_main;
1961 i32 retval = ntohl (mp->retval);
1962 if (vam->async_mode)
1964 vam->async_errors += (retval < 0);
1968 vam->retval = retval;
1969 vam->sw_if_index = ntohl (mp->sw_if_index);
1970 vam->result_ready = 1;
1974 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
1975 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1977 vat_main_t *vam = &vat_main;
1978 vat_json_node_t node;
1980 vat_json_init_object (&node);
1981 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1982 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1984 vat_json_print (vam->ofp, &node);
1985 vat_json_free (&node);
1987 vam->retval = ntohl (mp->retval);
1988 vam->result_ready = 1;
1991 static void vl_api_gre_add_del_tunnel_reply_t_handler
1992 (vl_api_gre_add_del_tunnel_reply_t * mp)
1994 vat_main_t *vam = &vat_main;
1995 i32 retval = ntohl (mp->retval);
1996 if (vam->async_mode)
1998 vam->async_errors += (retval < 0);
2002 vam->retval = retval;
2003 vam->sw_if_index = ntohl (mp->sw_if_index);
2004 vam->result_ready = 1;
2008 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2009 (vl_api_gre_add_del_tunnel_reply_t * mp)
2011 vat_main_t *vam = &vat_main;
2012 vat_json_node_t node;
2014 vat_json_init_object (&node);
2015 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2016 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2018 vat_json_print (vam->ofp, &node);
2019 vat_json_free (&node);
2021 vam->retval = ntohl (mp->retval);
2022 vam->result_ready = 1;
2025 static void vl_api_create_vhost_user_if_reply_t_handler
2026 (vl_api_create_vhost_user_if_reply_t * mp)
2028 vat_main_t *vam = &vat_main;
2029 i32 retval = ntohl (mp->retval);
2030 if (vam->async_mode)
2032 vam->async_errors += (retval < 0);
2036 vam->retval = retval;
2037 vam->sw_if_index = ntohl (mp->sw_if_index);
2038 vam->result_ready = 1;
2042 static void vl_api_create_vhost_user_if_reply_t_handler_json
2043 (vl_api_create_vhost_user_if_reply_t * mp)
2045 vat_main_t *vam = &vat_main;
2046 vat_json_node_t node;
2048 vat_json_init_object (&node);
2049 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2050 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2052 vat_json_print (vam->ofp, &node);
2053 vat_json_free (&node);
2055 vam->retval = ntohl (mp->retval);
2056 vam->result_ready = 1;
2059 static clib_error_t *
2060 receive_fd_msg (int socket_fd, int *my_fd)
2063 char ctl[CMSG_SPACE (sizeof (int)) + CMSG_SPACE (sizeof (struct ucred))];
2064 struct msghdr mh = { 0 };
2065 struct iovec iov[1];
2067 struct ucred *cr = 0;
2068 struct cmsghdr *cmsg;
2069 pid_t pid __attribute__ ((unused));
2070 uid_t uid __attribute__ ((unused));
2071 gid_t gid __attribute__ ((unused));
2073 iov[0].iov_base = msgbuf;
2077 mh.msg_control = ctl;
2078 mh.msg_controllen = sizeof (ctl);
2080 memset (ctl, 0, sizeof (ctl));
2082 /* receive the incoming message */
2083 size = recvmsg (socket_fd, &mh, 0);
2086 return (size == 0) ? clib_error_return (0, "disconnected") :
2087 clib_error_return_unix (0, "recvmsg: malformed message (fd %d)",
2091 cmsg = CMSG_FIRSTHDR (&mh);
2094 if (cmsg->cmsg_level == SOL_SOCKET)
2096 if (cmsg->cmsg_type == SCM_CREDENTIALS)
2098 cr = (struct ucred *) CMSG_DATA (cmsg);
2103 else if (cmsg->cmsg_type == SCM_RIGHTS)
2105 clib_memcpy (my_fd, CMSG_DATA (cmsg), sizeof (int));
2108 cmsg = CMSG_NXTHDR (&mh, cmsg);
2113 static void vl_api_memfd_segment_create_reply_t_handler
2114 (vl_api_memfd_segment_create_reply_t * mp)
2116 /* Dont bother in the builtin version */
2117 #if VPP_API_TEST_BUILTIN == 0
2118 vat_main_t *vam = &vat_main;
2119 api_main_t *am = &api_main;
2120 socket_client_main_t *scm = &vam->socket_client_main;
2122 clib_error_t *error;
2123 memfd_private_t memfd;
2124 i32 retval = ntohl (mp->retval);
2128 error = receive_fd_msg (scm->socket_fd, &my_fd);
2135 memset (&memfd, 0, sizeof (memfd));
2138 vam->client_index_invalid = 1;
2140 /* Note: this closes memfd.fd */
2141 retval = memfd_slave_init (&memfd);
2143 clib_warning ("WARNING: segment map returned %d", retval);
2145 /* Pivot to the memory client segment that vpp just created */
2147 am->vlib_rp = (void *) (memfd.requested_va + MMAP_PAGESIZE);
2149 am->shmem_hdr = (void *) am->vlib_rp->user_ctx;
2151 vl_client_install_client_message_handlers ();
2153 vl_client_connect_to_vlib_no_map ("pvt",
2155 32 /* input_queue_length */ );
2156 vam->vl_input_queue = am->shmem_hdr->vl_input_queue;
2158 vl_socket_client_enable_disable (&vam->socket_client_main,
2159 0 /* disable socket */ );
2163 if (vam->async_mode)
2165 vam->async_errors += (retval < 0);
2169 vam->retval = retval;
2170 vam->result_ready = 1;
2175 static void vl_api_memfd_segment_create_reply_t_handler_json
2176 (vl_api_memfd_segment_create_reply_t * mp)
2178 clib_warning ("no");
2181 static void vl_api_dns_resolve_name_reply_t_handler
2182 (vl_api_dns_resolve_name_reply_t * mp)
2184 vat_main_t *vam = &vat_main;
2185 i32 retval = ntohl (mp->retval);
2186 if (vam->async_mode)
2188 vam->async_errors += (retval < 0);
2192 vam->retval = retval;
2193 vam->result_ready = 1;
2198 clib_warning ("ip4 address %U", format_ip4_address,
2199 (ip4_address_t *) mp->ip4_address);
2201 clib_warning ("ip6 address %U", format_ip6_address,
2202 (ip6_address_t *) mp->ip6_address);
2205 clib_warning ("retval %d", retval);
2209 static void vl_api_dns_resolve_name_reply_t_handler_json
2210 (vl_api_dns_resolve_name_reply_t * mp)
2212 clib_warning ("not implemented");
2215 static void vl_api_dns_resolve_ip_reply_t_handler
2216 (vl_api_dns_resolve_ip_reply_t * mp)
2218 vat_main_t *vam = &vat_main;
2219 i32 retval = ntohl (mp->retval);
2220 if (vam->async_mode)
2222 vam->async_errors += (retval < 0);
2226 vam->retval = retval;
2227 vam->result_ready = 1;
2231 clib_warning ("canonical name %s", mp->name);
2234 clib_warning ("retval %d", retval);
2238 static void vl_api_dns_resolve_ip_reply_t_handler_json
2239 (vl_api_dns_resolve_ip_reply_t * mp)
2241 clib_warning ("not implemented");
2245 static void vl_api_ip_address_details_t_handler
2246 (vl_api_ip_address_details_t * mp)
2248 vat_main_t *vam = &vat_main;
2249 static ip_address_details_t empty_ip_address_details = { {0} };
2250 ip_address_details_t *address = NULL;
2251 ip_details_t *current_ip_details = NULL;
2252 ip_details_t *details = NULL;
2254 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2256 if (!details || vam->current_sw_if_index >= vec_len (details)
2257 || !details[vam->current_sw_if_index].present)
2259 errmsg ("ip address details arrived but not stored");
2260 errmsg ("ip_dump should be called first");
2264 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2266 #define addresses (current_ip_details->addr)
2268 vec_validate_init_empty (addresses, vec_len (addresses),
2269 empty_ip_address_details);
2271 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2273 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2274 address->prefix_length = mp->prefix_length;
2278 static void vl_api_ip_address_details_t_handler_json
2279 (vl_api_ip_address_details_t * mp)
2281 vat_main_t *vam = &vat_main;
2282 vat_json_node_t *node = NULL;
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);
2291 node = vat_json_array_add (&vam->json_tree);
2293 vat_json_init_object (node);
2296 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2297 vat_json_object_add_ip6 (node, "ip", ip6);
2301 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2302 vat_json_object_add_ip4 (node, "ip", ip4);
2304 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2308 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2310 vat_main_t *vam = &vat_main;
2311 static ip_details_t empty_ip_details = { 0 };
2312 ip_details_t *ip = NULL;
2313 u32 sw_if_index = ~0;
2315 sw_if_index = ntohl (mp->sw_if_index);
2317 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2318 sw_if_index, empty_ip_details);
2320 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2327 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2329 vat_main_t *vam = &vat_main;
2331 if (VAT_JSON_ARRAY != vam->json_tree.type)
2333 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2334 vat_json_init_array (&vam->json_tree);
2336 vat_json_array_add_uint (&vam->json_tree,
2337 clib_net_to_host_u32 (mp->sw_if_index));
2340 static void vl_api_map_domain_details_t_handler_json
2341 (vl_api_map_domain_details_t * mp)
2343 vat_json_node_t *node = NULL;
2344 vat_main_t *vam = &vat_main;
2345 struct in6_addr ip6;
2348 if (VAT_JSON_ARRAY != vam->json_tree.type)
2350 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2351 vat_json_init_array (&vam->json_tree);
2354 node = vat_json_array_add (&vam->json_tree);
2355 vat_json_init_object (node);
2357 vat_json_object_add_uint (node, "domain_index",
2358 clib_net_to_host_u32 (mp->domain_index));
2359 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2360 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2361 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2362 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2363 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2364 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2365 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2366 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2367 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2368 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2369 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2370 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2371 vat_json_object_add_uint (node, "flags", mp->flags);
2372 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2373 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2376 static void vl_api_map_domain_details_t_handler
2377 (vl_api_map_domain_details_t * mp)
2379 vat_main_t *vam = &vat_main;
2381 if (mp->is_translation)
2384 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2385 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2386 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2387 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2388 clib_net_to_host_u32 (mp->domain_index));
2393 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2394 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2395 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2396 format_ip6_address, mp->ip6_src,
2397 clib_net_to_host_u32 (mp->domain_index));
2399 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2400 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2401 mp->is_translation ? "map-t" : "");
2404 static void vl_api_map_rule_details_t_handler_json
2405 (vl_api_map_rule_details_t * mp)
2407 struct in6_addr ip6;
2408 vat_json_node_t *node = NULL;
2409 vat_main_t *vam = &vat_main;
2411 if (VAT_JSON_ARRAY != vam->json_tree.type)
2413 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2414 vat_json_init_array (&vam->json_tree);
2417 node = vat_json_array_add (&vam->json_tree);
2418 vat_json_init_object (node);
2420 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2421 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2422 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2426 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2428 vat_main_t *vam = &vat_main;
2429 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2430 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2434 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2436 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2437 "router_addr %U host_mac %U",
2438 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2439 format_ip4_address, &mp->host_address,
2440 format_ip4_address, &mp->router_address,
2441 format_ethernet_address, mp->host_mac);
2444 static void vl_api_dhcp_compl_event_t_handler_json
2445 (vl_api_dhcp_compl_event_t * mp)
2447 /* JSON output not supported */
2451 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2454 vat_main_t *vam = &vat_main;
2455 static u64 default_counter = 0;
2457 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2459 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2460 sw_if_index, default_counter);
2461 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2465 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2466 interface_counter_t counter)
2468 vat_main_t *vam = &vat_main;
2469 static interface_counter_t default_counter = { 0, };
2471 vec_validate_init_empty (vam->combined_interface_counters,
2472 vnet_counter_type, NULL);
2473 vec_validate_init_empty (vam->combined_interface_counters
2474 [vnet_counter_type], sw_if_index, default_counter);
2475 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2478 static void vl_api_vnet_interface_simple_counters_t_handler
2479 (vl_api_vnet_interface_simple_counters_t * mp)
2484 static void vl_api_vnet_interface_combined_counters_t_handler
2485 (vl_api_vnet_interface_combined_counters_t * mp)
2490 static void vl_api_vnet_interface_simple_counters_t_handler_json
2491 (vl_api_vnet_interface_simple_counters_t * mp)
2496 u32 first_sw_if_index;
2499 count = ntohl (mp->count);
2500 first_sw_if_index = ntohl (mp->first_sw_if_index);
2502 v_packets = (u64 *) & mp->data;
2503 for (i = 0; i < count; i++)
2505 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2506 set_simple_interface_counter (mp->vnet_counter_type,
2507 first_sw_if_index + i, packets);
2512 static void vl_api_vnet_interface_combined_counters_t_handler_json
2513 (vl_api_vnet_interface_combined_counters_t * mp)
2515 interface_counter_t counter;
2517 u32 first_sw_if_index;
2521 count = ntohl (mp->count);
2522 first_sw_if_index = ntohl (mp->first_sw_if_index);
2524 v = (vlib_counter_t *) & mp->data;
2525 for (i = 0; i < count; i++)
2528 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2530 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2531 set_combined_interface_counter (mp->vnet_counter_type,
2532 first_sw_if_index + i, counter);
2538 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2540 vat_main_t *vam = &vat_main;
2543 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2545 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2554 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2556 vat_main_t *vam = &vat_main;
2559 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2561 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2569 static void vl_api_vnet_ip4_fib_counters_t_handler
2570 (vl_api_vnet_ip4_fib_counters_t * mp)
2575 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2576 (vl_api_vnet_ip4_fib_counters_t * mp)
2578 vat_main_t *vam = &vat_main;
2579 vl_api_ip4_fib_counter_t *v;
2580 ip4_fib_counter_t *counter;
2587 vrf_id = ntohl (mp->vrf_id);
2588 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2589 if (~0 == vrf_index)
2591 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2592 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2593 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2594 vec_validate (vam->ip4_fib_counters, vrf_index);
2595 vam->ip4_fib_counters[vrf_index] = NULL;
2598 vec_free (vam->ip4_fib_counters[vrf_index]);
2599 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2600 count = ntohl (mp->count);
2601 for (i = 0; i < count; i++)
2603 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2604 counter = &vam->ip4_fib_counters[vrf_index][i];
2605 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2606 counter->address = ip4;
2607 counter->address_length = v->address_length;
2608 counter->packets = clib_net_to_host_u64 (v->packets);
2609 counter->bytes = clib_net_to_host_u64 (v->bytes);
2614 static void vl_api_vnet_ip4_nbr_counters_t_handler
2615 (vl_api_vnet_ip4_nbr_counters_t * mp)
2620 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2621 (vl_api_vnet_ip4_nbr_counters_t * mp)
2623 vat_main_t *vam = &vat_main;
2624 vl_api_ip4_nbr_counter_t *v;
2625 ip4_nbr_counter_t *counter;
2630 sw_if_index = ntohl (mp->sw_if_index);
2631 count = ntohl (mp->count);
2632 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2635 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2637 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2638 for (i = 0; i < count; i++)
2640 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2641 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2642 counter->address.s_addr = v->address;
2643 counter->packets = clib_net_to_host_u64 (v->packets);
2644 counter->bytes = clib_net_to_host_u64 (v->bytes);
2645 counter->linkt = v->link_type;
2650 static void vl_api_vnet_ip6_fib_counters_t_handler
2651 (vl_api_vnet_ip6_fib_counters_t * mp)
2656 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2657 (vl_api_vnet_ip6_fib_counters_t * mp)
2659 vat_main_t *vam = &vat_main;
2660 vl_api_ip6_fib_counter_t *v;
2661 ip6_fib_counter_t *counter;
2662 struct in6_addr ip6;
2668 vrf_id = ntohl (mp->vrf_id);
2669 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2670 if (~0 == vrf_index)
2672 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2673 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2674 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2675 vec_validate (vam->ip6_fib_counters, vrf_index);
2676 vam->ip6_fib_counters[vrf_index] = NULL;
2679 vec_free (vam->ip6_fib_counters[vrf_index]);
2680 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2681 count = ntohl (mp->count);
2682 for (i = 0; i < count; i++)
2684 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2685 counter = &vam->ip6_fib_counters[vrf_index][i];
2686 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2687 counter->address = ip6;
2688 counter->address_length = v->address_length;
2689 counter->packets = clib_net_to_host_u64 (v->packets);
2690 counter->bytes = clib_net_to_host_u64 (v->bytes);
2695 static void vl_api_vnet_ip6_nbr_counters_t_handler
2696 (vl_api_vnet_ip6_nbr_counters_t * mp)
2701 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2702 (vl_api_vnet_ip6_nbr_counters_t * mp)
2704 vat_main_t *vam = &vat_main;
2705 vl_api_ip6_nbr_counter_t *v;
2706 ip6_nbr_counter_t *counter;
2707 struct in6_addr ip6;
2712 sw_if_index = ntohl (mp->sw_if_index);
2713 count = ntohl (mp->count);
2714 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2717 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2719 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2720 for (i = 0; i < count; i++)
2722 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2723 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2724 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2725 counter->address = ip6;
2726 counter->packets = clib_net_to_host_u64 (v->packets);
2727 counter->bytes = clib_net_to_host_u64 (v->bytes);
2732 static void vl_api_get_first_msg_id_reply_t_handler
2733 (vl_api_get_first_msg_id_reply_t * mp)
2735 vat_main_t *vam = &vat_main;
2736 i32 retval = ntohl (mp->retval);
2738 if (vam->async_mode)
2740 vam->async_errors += (retval < 0);
2744 vam->retval = retval;
2745 vam->result_ready = 1;
2749 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2753 static void vl_api_get_first_msg_id_reply_t_handler_json
2754 (vl_api_get_first_msg_id_reply_t * mp)
2756 vat_main_t *vam = &vat_main;
2757 vat_json_node_t node;
2759 vat_json_init_object (&node);
2760 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2761 vat_json_object_add_uint (&node, "first_msg_id",
2762 (uint) ntohs (mp->first_msg_id));
2764 vat_json_print (vam->ofp, &node);
2765 vat_json_free (&node);
2767 vam->retval = ntohl (mp->retval);
2768 vam->result_ready = 1;
2771 static void vl_api_get_node_graph_reply_t_handler
2772 (vl_api_get_node_graph_reply_t * mp)
2774 vat_main_t *vam = &vat_main;
2775 api_main_t *am = &api_main;
2776 i32 retval = ntohl (mp->retval);
2777 u8 *pvt_copy, *reply;
2782 if (vam->async_mode)
2784 vam->async_errors += (retval < 0);
2788 vam->retval = retval;
2789 vam->result_ready = 1;
2792 /* "Should never happen..." */
2796 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2797 pvt_copy = vec_dup (reply);
2799 /* Toss the shared-memory original... */
2800 pthread_mutex_lock (&am->vlib_rp->mutex);
2801 oldheap = svm_push_data_heap (am->vlib_rp);
2805 svm_pop_heap (oldheap);
2806 pthread_mutex_unlock (&am->vlib_rp->mutex);
2808 if (vam->graph_nodes)
2810 hash_free (vam->graph_node_index_by_name);
2812 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2814 node = vam->graph_nodes[i];
2815 vec_free (node->name);
2816 vec_free (node->next_nodes);
2819 vec_free (vam->graph_nodes);
2822 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2823 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2824 vec_free (pvt_copy);
2826 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2828 node = vam->graph_nodes[i];
2829 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2833 static void vl_api_get_node_graph_reply_t_handler_json
2834 (vl_api_get_node_graph_reply_t * mp)
2836 vat_main_t *vam = &vat_main;
2837 api_main_t *am = &api_main;
2839 vat_json_node_t node;
2842 /* $$$$ make this real? */
2843 vat_json_init_object (&node);
2844 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2845 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2847 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2849 /* Toss the shared-memory original... */
2850 pthread_mutex_lock (&am->vlib_rp->mutex);
2851 oldheap = svm_push_data_heap (am->vlib_rp);
2855 svm_pop_heap (oldheap);
2856 pthread_mutex_unlock (&am->vlib_rp->mutex);
2858 vat_json_print (vam->ofp, &node);
2859 vat_json_free (&node);
2861 vam->retval = ntohl (mp->retval);
2862 vam->result_ready = 1;
2866 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2868 vat_main_t *vam = &vat_main;
2873 s = format (s, "%=16d%=16d%=16d",
2874 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2878 s = format (s, "%=16U%=16d%=16d",
2879 mp->is_ipv6 ? format_ip6_address :
2881 mp->ip_address, mp->priority, mp->weight);
2884 print (vam->ofp, "%v", s);
2889 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2891 vat_main_t *vam = &vat_main;
2892 vat_json_node_t *node = NULL;
2893 struct in6_addr ip6;
2896 if (VAT_JSON_ARRAY != vam->json_tree.type)
2898 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2899 vat_json_init_array (&vam->json_tree);
2901 node = vat_json_array_add (&vam->json_tree);
2902 vat_json_init_object (node);
2904 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2905 vat_json_object_add_uint (node, "priority", mp->priority);
2906 vat_json_object_add_uint (node, "weight", mp->weight);
2909 vat_json_object_add_uint (node, "sw_if_index",
2910 clib_net_to_host_u32 (mp->sw_if_index));
2915 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2916 vat_json_object_add_ip6 (node, "address", ip6);
2920 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2921 vat_json_object_add_ip4 (node, "address", ip4);
2927 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2930 vat_main_t *vam = &vat_main;
2933 ls_name = format (0, "%s", mp->ls_name);
2935 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2941 vl_api_one_locator_set_details_t_handler_json
2942 (vl_api_one_locator_set_details_t * mp)
2944 vat_main_t *vam = &vat_main;
2945 vat_json_node_t *node = 0;
2948 ls_name = format (0, "%s", mp->ls_name);
2949 vec_add1 (ls_name, 0);
2951 if (VAT_JSON_ARRAY != vam->json_tree.type)
2953 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2954 vat_json_init_array (&vam->json_tree);
2956 node = vat_json_array_add (&vam->json_tree);
2958 vat_json_init_object (node);
2959 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2960 vat_json_object_add_uint (node, "ls_index",
2961 clib_net_to_host_u32 (mp->ls_index));
2969 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2972 unformat_nsh_address (unformat_input_t * input, va_list * args)
2974 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2975 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2979 format_nsh_address_vat (u8 * s, va_list * args)
2981 nsh_t *a = va_arg (*args, nsh_t *);
2982 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2986 format_lisp_flat_eid (u8 * s, va_list * args)
2988 u32 type = va_arg (*args, u32);
2989 u8 *eid = va_arg (*args, u8 *);
2990 u32 eid_len = va_arg (*args, u32);
2995 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2997 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2999 return format (s, "%U", format_ethernet_address, eid);
3001 return format (s, "%U", format_nsh_address_vat, eid);
3007 format_lisp_eid_vat (u8 * s, va_list * args)
3009 u32 type = va_arg (*args, u32);
3010 u8 *eid = va_arg (*args, u8 *);
3011 u32 eid_len = va_arg (*args, u32);
3012 u8 *seid = va_arg (*args, u8 *);
3013 u32 seid_len = va_arg (*args, u32);
3014 u32 is_src_dst = va_arg (*args, u32);
3017 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3019 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3025 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3027 vat_main_t *vam = &vat_main;
3028 u8 *s = 0, *eid = 0;
3030 if (~0 == mp->locator_set_index)
3031 s = format (0, "action: %d", mp->action);
3033 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3035 eid = format (0, "%U", format_lisp_eid_vat,
3039 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3042 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3043 clib_net_to_host_u32 (mp->vni),
3045 mp->is_local ? "local" : "remote",
3046 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3047 clib_net_to_host_u16 (mp->key_id), mp->key);
3054 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3057 vat_main_t *vam = &vat_main;
3058 vat_json_node_t *node = 0;
3061 if (VAT_JSON_ARRAY != vam->json_tree.type)
3063 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3064 vat_json_init_array (&vam->json_tree);
3066 node = vat_json_array_add (&vam->json_tree);
3068 vat_json_init_object (node);
3069 if (~0 == mp->locator_set_index)
3070 vat_json_object_add_uint (node, "action", mp->action);
3072 vat_json_object_add_uint (node, "locator_set_index",
3073 clib_net_to_host_u32 (mp->locator_set_index));
3075 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3076 if (mp->eid_type == 3)
3078 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3079 vat_json_init_object (nsh_json);
3080 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3081 vat_json_object_add_uint (nsh_json, "spi",
3082 clib_net_to_host_u32 (nsh->spi));
3083 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3087 eid = format (0, "%U", format_lisp_eid_vat,
3091 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3093 vat_json_object_add_string_copy (node, "eid", eid);
3096 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3097 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3098 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3102 vat_json_object_add_uint (node, "key_id",
3103 clib_net_to_host_u16 (mp->key_id));
3104 vat_json_object_add_string_copy (node, "key", mp->key);
3109 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3111 vat_main_t *vam = &vat_main;
3112 u8 *seid = 0, *deid = 0;
3113 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3115 deid = format (0, "%U", format_lisp_eid_vat,
3116 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3118 seid = format (0, "%U", format_lisp_eid_vat,
3119 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3125 format_ip_address_fcn = format_ip4_address;
3127 format_ip_address_fcn = format_ip6_address;
3130 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3131 clib_net_to_host_u32 (mp->vni),
3133 format_ip_address_fcn, mp->lloc,
3134 format_ip_address_fcn, mp->rloc,
3135 clib_net_to_host_u32 (mp->pkt_count),
3136 clib_net_to_host_u32 (mp->bytes));
3143 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3145 struct in6_addr ip6;
3147 vat_main_t *vam = &vat_main;
3148 vat_json_node_t *node = 0;
3149 u8 *deid = 0, *seid = 0;
3151 if (VAT_JSON_ARRAY != vam->json_tree.type)
3153 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3154 vat_json_init_array (&vam->json_tree);
3156 node = vat_json_array_add (&vam->json_tree);
3158 vat_json_init_object (node);
3159 deid = format (0, "%U", format_lisp_eid_vat,
3160 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3162 seid = format (0, "%U", format_lisp_eid_vat,
3163 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3168 vat_json_object_add_string_copy (node, "seid", seid);
3169 vat_json_object_add_string_copy (node, "deid", deid);
3170 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3174 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3175 vat_json_object_add_ip4 (node, "lloc", ip4);
3176 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3177 vat_json_object_add_ip4 (node, "rloc", ip4);
3181 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3182 vat_json_object_add_ip6 (node, "lloc", ip6);
3183 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3184 vat_json_object_add_ip6 (node, "rloc", ip6);
3186 vat_json_object_add_uint (node, "pkt_count",
3187 clib_net_to_host_u32 (mp->pkt_count));
3188 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3195 vl_api_one_eid_table_map_details_t_handler
3196 (vl_api_one_eid_table_map_details_t * mp)
3198 vat_main_t *vam = &vat_main;
3200 u8 *line = format (0, "%=10d%=10d",
3201 clib_net_to_host_u32 (mp->vni),
3202 clib_net_to_host_u32 (mp->dp_table));
3203 print (vam->ofp, "%v", line);
3208 vl_api_one_eid_table_map_details_t_handler_json
3209 (vl_api_one_eid_table_map_details_t * mp)
3211 vat_main_t *vam = &vat_main;
3212 vat_json_node_t *node = NULL;
3214 if (VAT_JSON_ARRAY != vam->json_tree.type)
3216 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3217 vat_json_init_array (&vam->json_tree);
3219 node = vat_json_array_add (&vam->json_tree);
3220 vat_json_init_object (node);
3221 vat_json_object_add_uint (node, "dp_table",
3222 clib_net_to_host_u32 (mp->dp_table));
3223 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3227 vl_api_one_eid_table_vni_details_t_handler
3228 (vl_api_one_eid_table_vni_details_t * mp)
3230 vat_main_t *vam = &vat_main;
3232 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3233 print (vam->ofp, "%v", line);
3238 vl_api_one_eid_table_vni_details_t_handler_json
3239 (vl_api_one_eid_table_vni_details_t * mp)
3241 vat_main_t *vam = &vat_main;
3242 vat_json_node_t *node = NULL;
3244 if (VAT_JSON_ARRAY != vam->json_tree.type)
3246 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3247 vat_json_init_array (&vam->json_tree);
3249 node = vat_json_array_add (&vam->json_tree);
3250 vat_json_init_object (node);
3251 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3255 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3256 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3258 vat_main_t *vam = &vat_main;
3259 int retval = clib_net_to_host_u32 (mp->retval);
3261 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3262 print (vam->ofp, "fallback threshold value: %d", mp->value);
3264 vam->retval = retval;
3265 vam->result_ready = 1;
3269 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3270 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3272 vat_main_t *vam = &vat_main;
3273 vat_json_node_t _node, *node = &_node;
3274 int retval = clib_net_to_host_u32 (mp->retval);
3276 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3277 vat_json_init_object (node);
3278 vat_json_object_add_uint (node, "value", mp->value);
3280 vat_json_print (vam->ofp, node);
3281 vat_json_free (node);
3283 vam->retval = retval;
3284 vam->result_ready = 1;
3288 vl_api_show_one_map_register_state_reply_t_handler
3289 (vl_api_show_one_map_register_state_reply_t * mp)
3291 vat_main_t *vam = &vat_main;
3292 int retval = clib_net_to_host_u32 (mp->retval);
3294 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3296 vam->retval = retval;
3297 vam->result_ready = 1;
3301 vl_api_show_one_map_register_state_reply_t_handler_json
3302 (vl_api_show_one_map_register_state_reply_t * mp)
3304 vat_main_t *vam = &vat_main;
3305 vat_json_node_t _node, *node = &_node;
3306 int retval = clib_net_to_host_u32 (mp->retval);
3308 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3310 vat_json_init_object (node);
3311 vat_json_object_add_string_copy (node, "state", s);
3313 vat_json_print (vam->ofp, node);
3314 vat_json_free (node);
3316 vam->retval = retval;
3317 vam->result_ready = 1;
3322 vl_api_show_one_rloc_probe_state_reply_t_handler
3323 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3325 vat_main_t *vam = &vat_main;
3326 int retval = clib_net_to_host_u32 (mp->retval);
3331 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3333 vam->retval = retval;
3334 vam->result_ready = 1;
3338 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3339 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3341 vat_main_t *vam = &vat_main;
3342 vat_json_node_t _node, *node = &_node;
3343 int retval = clib_net_to_host_u32 (mp->retval);
3345 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3346 vat_json_init_object (node);
3347 vat_json_object_add_string_copy (node, "state", s);
3349 vat_json_print (vam->ofp, node);
3350 vat_json_free (node);
3352 vam->retval = retval;
3353 vam->result_ready = 1;
3358 vl_api_show_one_stats_enable_disable_reply_t_handler
3359 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3361 vat_main_t *vam = &vat_main;
3362 int retval = clib_net_to_host_u32 (mp->retval);
3367 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3369 vam->retval = retval;
3370 vam->result_ready = 1;
3374 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3375 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3377 vat_main_t *vam = &vat_main;
3378 vat_json_node_t _node, *node = &_node;
3379 int retval = clib_net_to_host_u32 (mp->retval);
3381 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3382 vat_json_init_object (node);
3383 vat_json_object_add_string_copy (node, "state", s);
3385 vat_json_print (vam->ofp, node);
3386 vat_json_free (node);
3388 vam->retval = retval;
3389 vam->result_ready = 1;
3394 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3396 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3397 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3398 e->vni = clib_net_to_host_u32 (e->vni);
3402 gpe_fwd_entries_get_reply_t_net_to_host
3403 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3407 mp->count = clib_net_to_host_u32 (mp->count);
3408 for (i = 0; i < mp->count; i++)
3410 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3415 format_gpe_encap_mode (u8 * s, va_list * args)
3417 u32 mode = va_arg (*args, u32);
3422 return format (s, "lisp");
3424 return format (s, "vxlan");
3430 vl_api_gpe_get_encap_mode_reply_t_handler
3431 (vl_api_gpe_get_encap_mode_reply_t * mp)
3433 vat_main_t *vam = &vat_main;
3435 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3436 vam->retval = ntohl (mp->retval);
3437 vam->result_ready = 1;
3441 vl_api_gpe_get_encap_mode_reply_t_handler_json
3442 (vl_api_gpe_get_encap_mode_reply_t * mp)
3444 vat_main_t *vam = &vat_main;
3445 vat_json_node_t node;
3447 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3448 vec_add1 (encap_mode, 0);
3450 vat_json_init_object (&node);
3451 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3453 vec_free (encap_mode);
3454 vat_json_print (vam->ofp, &node);
3455 vat_json_free (&node);
3457 vam->retval = ntohl (mp->retval);
3458 vam->result_ready = 1;
3462 vl_api_gpe_fwd_entry_path_details_t_handler
3463 (vl_api_gpe_fwd_entry_path_details_t * mp)
3465 vat_main_t *vam = &vat_main;
3466 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3468 if (mp->lcl_loc.is_ip4)
3469 format_ip_address_fcn = format_ip4_address;
3471 format_ip_address_fcn = format_ip6_address;
3473 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3474 format_ip_address_fcn, &mp->lcl_loc,
3475 format_ip_address_fcn, &mp->rmt_loc);
3479 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3481 struct in6_addr ip6;
3486 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3487 vat_json_object_add_ip4 (n, "address", ip4);
3491 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3492 vat_json_object_add_ip6 (n, "address", ip6);
3494 vat_json_object_add_uint (n, "weight", loc->weight);
3498 vl_api_gpe_fwd_entry_path_details_t_handler_json
3499 (vl_api_gpe_fwd_entry_path_details_t * mp)
3501 vat_main_t *vam = &vat_main;
3502 vat_json_node_t *node = NULL;
3503 vat_json_node_t *loc_node;
3505 if (VAT_JSON_ARRAY != vam->json_tree.type)
3507 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3508 vat_json_init_array (&vam->json_tree);
3510 node = vat_json_array_add (&vam->json_tree);
3511 vat_json_init_object (node);
3513 loc_node = vat_json_object_add (node, "local_locator");
3514 vat_json_init_object (loc_node);
3515 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3517 loc_node = vat_json_object_add (node, "remote_locator");
3518 vat_json_init_object (loc_node);
3519 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3523 vl_api_gpe_fwd_entries_get_reply_t_handler
3524 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3526 vat_main_t *vam = &vat_main;
3528 int retval = clib_net_to_host_u32 (mp->retval);
3529 vl_api_gpe_fwd_entry_t *e;
3534 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3536 for (i = 0; i < mp->count; i++)
3538 e = &mp->entries[i];
3539 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3540 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3541 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3545 vam->retval = retval;
3546 vam->result_ready = 1;
3550 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3551 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3554 vat_main_t *vam = &vat_main;
3555 vat_json_node_t *e = 0, root;
3557 int retval = clib_net_to_host_u32 (mp->retval);
3558 vl_api_gpe_fwd_entry_t *fwd;
3563 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3564 vat_json_init_array (&root);
3566 for (i = 0; i < mp->count; i++)
3568 e = vat_json_array_add (&root);
3569 fwd = &mp->entries[i];
3571 vat_json_init_object (e);
3572 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3573 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3574 vat_json_object_add_int (e, "vni", fwd->vni);
3575 vat_json_object_add_int (e, "action", fwd->action);
3577 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3578 fwd->leid_prefix_len);
3580 vat_json_object_add_string_copy (e, "leid", s);
3583 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3584 fwd->reid_prefix_len);
3586 vat_json_object_add_string_copy (e, "reid", s);
3590 vat_json_print (vam->ofp, &root);
3591 vat_json_free (&root);
3594 vam->retval = retval;
3595 vam->result_ready = 1;
3599 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3600 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3602 vat_main_t *vam = &vat_main;
3604 int retval = clib_net_to_host_u32 (mp->retval);
3605 vl_api_gpe_native_fwd_rpath_t *r;
3610 n = clib_net_to_host_u32 (mp->count);
3612 for (i = 0; i < n; i++)
3614 r = &mp->entries[i];
3615 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3616 clib_net_to_host_u32 (r->fib_index),
3617 clib_net_to_host_u32 (r->nh_sw_if_index),
3618 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3622 vam->retval = retval;
3623 vam->result_ready = 1;
3627 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3628 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3630 vat_main_t *vam = &vat_main;
3631 vat_json_node_t root, *e;
3633 int retval = clib_net_to_host_u32 (mp->retval);
3634 vl_api_gpe_native_fwd_rpath_t *r;
3640 n = clib_net_to_host_u32 (mp->count);
3641 vat_json_init_array (&root);
3643 for (i = 0; i < n; i++)
3645 e = vat_json_array_add (&root);
3646 vat_json_init_object (e);
3647 r = &mp->entries[i];
3649 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3652 vat_json_object_add_string_copy (e, "ip4", s);
3655 vat_json_object_add_uint (e, "fib_index",
3656 clib_net_to_host_u32 (r->fib_index));
3657 vat_json_object_add_uint (e, "nh_sw_if_index",
3658 clib_net_to_host_u32 (r->nh_sw_if_index));
3661 vat_json_print (vam->ofp, &root);
3662 vat_json_free (&root);
3665 vam->retval = retval;
3666 vam->result_ready = 1;
3670 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3671 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3673 vat_main_t *vam = &vat_main;
3675 int retval = clib_net_to_host_u32 (mp->retval);
3680 n = clib_net_to_host_u32 (mp->count);
3682 for (i = 0; i < n; i++)
3683 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3686 vam->retval = retval;
3687 vam->result_ready = 1;
3691 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3692 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3694 vat_main_t *vam = &vat_main;
3695 vat_json_node_t root;
3697 int retval = clib_net_to_host_u32 (mp->retval);
3702 n = clib_net_to_host_u32 (mp->count);
3703 vat_json_init_array (&root);
3705 for (i = 0; i < n; i++)
3706 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3708 vat_json_print (vam->ofp, &root);
3709 vat_json_free (&root);
3712 vam->retval = retval;
3713 vam->result_ready = 1;
3717 vl_api_one_ndp_entries_get_reply_t_handler
3718 (vl_api_one_ndp_entries_get_reply_t * mp)
3720 vat_main_t *vam = &vat_main;
3722 int retval = clib_net_to_host_u32 (mp->retval);
3727 n = clib_net_to_host_u32 (mp->count);
3729 for (i = 0; i < n; i++)
3730 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3731 format_ethernet_address, mp->entries[i].mac);
3734 vam->retval = retval;
3735 vam->result_ready = 1;
3739 vl_api_one_ndp_entries_get_reply_t_handler_json
3740 (vl_api_one_ndp_entries_get_reply_t * mp)
3743 vat_main_t *vam = &vat_main;
3744 vat_json_node_t *e = 0, root;
3746 int retval = clib_net_to_host_u32 (mp->retval);
3747 vl_api_one_ndp_entry_t *arp_entry;
3752 n = clib_net_to_host_u32 (mp->count);
3753 vat_json_init_array (&root);
3755 for (i = 0; i < n; i++)
3757 e = vat_json_array_add (&root);
3758 arp_entry = &mp->entries[i];
3760 vat_json_init_object (e);
3761 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3764 vat_json_object_add_string_copy (e, "mac", s);
3767 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3769 vat_json_object_add_string_copy (e, "ip6", s);
3773 vat_json_print (vam->ofp, &root);
3774 vat_json_free (&root);
3777 vam->retval = retval;
3778 vam->result_ready = 1;
3782 vl_api_one_l2_arp_entries_get_reply_t_handler
3783 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3785 vat_main_t *vam = &vat_main;
3787 int retval = clib_net_to_host_u32 (mp->retval);
3792 n = clib_net_to_host_u32 (mp->count);
3794 for (i = 0; i < n; i++)
3795 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3796 format_ethernet_address, mp->entries[i].mac);
3799 vam->retval = retval;
3800 vam->result_ready = 1;
3804 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3805 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3808 vat_main_t *vam = &vat_main;
3809 vat_json_node_t *e = 0, root;
3811 int retval = clib_net_to_host_u32 (mp->retval);
3812 vl_api_one_l2_arp_entry_t *arp_entry;
3817 n = clib_net_to_host_u32 (mp->count);
3818 vat_json_init_array (&root);
3820 for (i = 0; i < n; i++)
3822 e = vat_json_array_add (&root);
3823 arp_entry = &mp->entries[i];
3825 vat_json_init_object (e);
3826 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3829 vat_json_object_add_string_copy (e, "mac", s);
3832 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3834 vat_json_object_add_string_copy (e, "ip4", s);
3838 vat_json_print (vam->ofp, &root);
3839 vat_json_free (&root);
3842 vam->retval = retval;
3843 vam->result_ready = 1;
3847 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3849 vat_main_t *vam = &vat_main;
3851 int retval = clib_net_to_host_u32 (mp->retval);
3856 n = clib_net_to_host_u32 (mp->count);
3858 for (i = 0; i < n; i++)
3860 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3864 vam->retval = retval;
3865 vam->result_ready = 1;
3869 vl_api_one_ndp_bd_get_reply_t_handler_json
3870 (vl_api_one_ndp_bd_get_reply_t * mp)
3872 vat_main_t *vam = &vat_main;
3873 vat_json_node_t root;
3875 int retval = clib_net_to_host_u32 (mp->retval);
3880 n = clib_net_to_host_u32 (mp->count);
3881 vat_json_init_array (&root);
3883 for (i = 0; i < n; i++)
3885 vat_json_array_add_uint (&root,
3886 clib_net_to_host_u32 (mp->bridge_domains[i]));
3889 vat_json_print (vam->ofp, &root);
3890 vat_json_free (&root);
3893 vam->retval = retval;
3894 vam->result_ready = 1;
3898 vl_api_one_l2_arp_bd_get_reply_t_handler
3899 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3901 vat_main_t *vam = &vat_main;
3903 int retval = clib_net_to_host_u32 (mp->retval);
3908 n = clib_net_to_host_u32 (mp->count);
3910 for (i = 0; i < n; i++)
3912 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3916 vam->retval = retval;
3917 vam->result_ready = 1;
3921 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3922 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3924 vat_main_t *vam = &vat_main;
3925 vat_json_node_t root;
3927 int retval = clib_net_to_host_u32 (mp->retval);
3932 n = clib_net_to_host_u32 (mp->count);
3933 vat_json_init_array (&root);
3935 for (i = 0; i < n; i++)
3937 vat_json_array_add_uint (&root,
3938 clib_net_to_host_u32 (mp->bridge_domains[i]));
3941 vat_json_print (vam->ofp, &root);
3942 vat_json_free (&root);
3945 vam->retval = retval;
3946 vam->result_ready = 1;
3950 vl_api_one_adjacencies_get_reply_t_handler
3951 (vl_api_one_adjacencies_get_reply_t * mp)
3953 vat_main_t *vam = &vat_main;
3955 int retval = clib_net_to_host_u32 (mp->retval);
3956 vl_api_one_adjacency_t *a;
3961 n = clib_net_to_host_u32 (mp->count);
3963 for (i = 0; i < n; i++)
3965 a = &mp->adjacencies[i];
3966 print (vam->ofp, "%U %40U",
3967 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3968 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3972 vam->retval = retval;
3973 vam->result_ready = 1;
3977 vl_api_one_adjacencies_get_reply_t_handler_json
3978 (vl_api_one_adjacencies_get_reply_t * mp)
3981 vat_main_t *vam = &vat_main;
3982 vat_json_node_t *e = 0, root;
3984 int retval = clib_net_to_host_u32 (mp->retval);
3985 vl_api_one_adjacency_t *a;
3990 n = clib_net_to_host_u32 (mp->count);
3991 vat_json_init_array (&root);
3993 for (i = 0; i < n; i++)
3995 e = vat_json_array_add (&root);
3996 a = &mp->adjacencies[i];
3998 vat_json_init_object (e);
3999 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4000 a->leid_prefix_len);
4002 vat_json_object_add_string_copy (e, "leid", s);
4005 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4006 a->reid_prefix_len);
4008 vat_json_object_add_string_copy (e, "reid", s);
4012 vat_json_print (vam->ofp, &root);
4013 vat_json_free (&root);
4016 vam->retval = retval;
4017 vam->result_ready = 1;
4021 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4023 vat_main_t *vam = &vat_main;
4025 print (vam->ofp, "%=20U",
4026 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4031 vl_api_one_map_server_details_t_handler_json
4032 (vl_api_one_map_server_details_t * mp)
4034 vat_main_t *vam = &vat_main;
4035 vat_json_node_t *node = NULL;
4036 struct in6_addr ip6;
4039 if (VAT_JSON_ARRAY != vam->json_tree.type)
4041 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4042 vat_json_init_array (&vam->json_tree);
4044 node = vat_json_array_add (&vam->json_tree);
4046 vat_json_init_object (node);
4049 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4050 vat_json_object_add_ip6 (node, "map-server", ip6);
4054 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4055 vat_json_object_add_ip4 (node, "map-server", ip4);
4060 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4063 vat_main_t *vam = &vat_main;
4065 print (vam->ofp, "%=20U",
4066 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4071 vl_api_one_map_resolver_details_t_handler_json
4072 (vl_api_one_map_resolver_details_t * mp)
4074 vat_main_t *vam = &vat_main;
4075 vat_json_node_t *node = NULL;
4076 struct in6_addr ip6;
4079 if (VAT_JSON_ARRAY != vam->json_tree.type)
4081 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4082 vat_json_init_array (&vam->json_tree);
4084 node = vat_json_array_add (&vam->json_tree);
4086 vat_json_init_object (node);
4089 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4090 vat_json_object_add_ip6 (node, "map resolver", ip6);
4094 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4095 vat_json_object_add_ip4 (node, "map resolver", ip4);
4100 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4102 vat_main_t *vam = &vat_main;
4103 i32 retval = ntohl (mp->retval);
4107 print (vam->ofp, "feature: %s\ngpe: %s",
4108 mp->feature_status ? "enabled" : "disabled",
4109 mp->gpe_status ? "enabled" : "disabled");
4112 vam->retval = retval;
4113 vam->result_ready = 1;
4117 vl_api_show_one_status_reply_t_handler_json
4118 (vl_api_show_one_status_reply_t * mp)
4120 vat_main_t *vam = &vat_main;
4121 vat_json_node_t node;
4122 u8 *gpe_status = NULL;
4123 u8 *feature_status = NULL;
4125 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4126 feature_status = format (0, "%s",
4127 mp->feature_status ? "enabled" : "disabled");
4128 vec_add1 (gpe_status, 0);
4129 vec_add1 (feature_status, 0);
4131 vat_json_init_object (&node);
4132 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4133 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4135 vec_free (gpe_status);
4136 vec_free (feature_status);
4138 vat_json_print (vam->ofp, &node);
4139 vat_json_free (&node);
4141 vam->retval = ntohl (mp->retval);
4142 vam->result_ready = 1;
4146 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4147 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4149 vat_main_t *vam = &vat_main;
4150 i32 retval = ntohl (mp->retval);
4154 print (vam->ofp, "%=20s", mp->locator_set_name);
4157 vam->retval = retval;
4158 vam->result_ready = 1;
4162 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4163 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4165 vat_main_t *vam = &vat_main;
4166 vat_json_node_t *node = NULL;
4168 if (VAT_JSON_ARRAY != vam->json_tree.type)
4170 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4171 vat_json_init_array (&vam->json_tree);
4173 node = vat_json_array_add (&vam->json_tree);
4175 vat_json_init_object (node);
4176 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4178 vat_json_print (vam->ofp, node);
4179 vat_json_free (node);
4181 vam->retval = ntohl (mp->retval);
4182 vam->result_ready = 1;
4186 format_lisp_map_request_mode (u8 * s, va_list * args)
4188 u32 mode = va_arg (*args, u32);
4193 return format (0, "dst-only");
4195 return format (0, "src-dst");
4201 vl_api_show_one_map_request_mode_reply_t_handler
4202 (vl_api_show_one_map_request_mode_reply_t * mp)
4204 vat_main_t *vam = &vat_main;
4205 i32 retval = ntohl (mp->retval);
4209 u32 mode = mp->mode;
4210 print (vam->ofp, "map_request_mode: %U",
4211 format_lisp_map_request_mode, mode);
4214 vam->retval = retval;
4215 vam->result_ready = 1;
4219 vl_api_show_one_map_request_mode_reply_t_handler_json
4220 (vl_api_show_one_map_request_mode_reply_t * mp)
4222 vat_main_t *vam = &vat_main;
4223 vat_json_node_t node;
4228 s = format (0, "%U", format_lisp_map_request_mode, mode);
4231 vat_json_init_object (&node);
4232 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4233 vat_json_print (vam->ofp, &node);
4234 vat_json_free (&node);
4237 vam->retval = ntohl (mp->retval);
4238 vam->result_ready = 1;
4242 vl_api_one_show_xtr_mode_reply_t_handler
4243 (vl_api_one_show_xtr_mode_reply_t * mp)
4245 vat_main_t *vam = &vat_main;
4246 i32 retval = ntohl (mp->retval);
4250 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4253 vam->retval = retval;
4254 vam->result_ready = 1;
4258 vl_api_one_show_xtr_mode_reply_t_handler_json
4259 (vl_api_one_show_xtr_mode_reply_t * mp)
4261 vat_main_t *vam = &vat_main;
4262 vat_json_node_t node;
4265 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4266 vec_add1 (status, 0);
4268 vat_json_init_object (&node);
4269 vat_json_object_add_string_copy (&node, "status", status);
4273 vat_json_print (vam->ofp, &node);
4274 vat_json_free (&node);
4276 vam->retval = ntohl (mp->retval);
4277 vam->result_ready = 1;
4281 vl_api_one_show_pitr_mode_reply_t_handler
4282 (vl_api_one_show_pitr_mode_reply_t * mp)
4284 vat_main_t *vam = &vat_main;
4285 i32 retval = ntohl (mp->retval);
4289 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4292 vam->retval = retval;
4293 vam->result_ready = 1;
4297 vl_api_one_show_pitr_mode_reply_t_handler_json
4298 (vl_api_one_show_pitr_mode_reply_t * mp)
4300 vat_main_t *vam = &vat_main;
4301 vat_json_node_t node;
4304 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4305 vec_add1 (status, 0);
4307 vat_json_init_object (&node);
4308 vat_json_object_add_string_copy (&node, "status", status);
4312 vat_json_print (vam->ofp, &node);
4313 vat_json_free (&node);
4315 vam->retval = ntohl (mp->retval);
4316 vam->result_ready = 1;
4320 vl_api_one_show_petr_mode_reply_t_handler
4321 (vl_api_one_show_petr_mode_reply_t * mp)
4323 vat_main_t *vam = &vat_main;
4324 i32 retval = ntohl (mp->retval);
4328 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4331 vam->retval = retval;
4332 vam->result_ready = 1;
4336 vl_api_one_show_petr_mode_reply_t_handler_json
4337 (vl_api_one_show_petr_mode_reply_t * mp)
4339 vat_main_t *vam = &vat_main;
4340 vat_json_node_t node;
4343 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4344 vec_add1 (status, 0);
4346 vat_json_init_object (&node);
4347 vat_json_object_add_string_copy (&node, "status", status);
4351 vat_json_print (vam->ofp, &node);
4352 vat_json_free (&node);
4354 vam->retval = ntohl (mp->retval);
4355 vam->result_ready = 1;
4359 vl_api_show_one_use_petr_reply_t_handler
4360 (vl_api_show_one_use_petr_reply_t * mp)
4362 vat_main_t *vam = &vat_main;
4363 i32 retval = ntohl (mp->retval);
4367 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4370 print (vam->ofp, "Proxy-ETR address; %U",
4371 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4376 vam->retval = retval;
4377 vam->result_ready = 1;
4381 vl_api_show_one_use_petr_reply_t_handler_json
4382 (vl_api_show_one_use_petr_reply_t * mp)
4384 vat_main_t *vam = &vat_main;
4385 vat_json_node_t node;
4388 struct in6_addr ip6;
4390 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4391 vec_add1 (status, 0);
4393 vat_json_init_object (&node);
4394 vat_json_object_add_string_copy (&node, "status", status);
4399 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4400 vat_json_object_add_ip6 (&node, "address", ip6);
4404 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4405 vat_json_object_add_ip4 (&node, "address", ip4);
4411 vat_json_print (vam->ofp, &node);
4412 vat_json_free (&node);
4414 vam->retval = ntohl (mp->retval);
4415 vam->result_ready = 1;
4419 vl_api_show_one_nsh_mapping_reply_t_handler
4420 (vl_api_show_one_nsh_mapping_reply_t * mp)
4422 vat_main_t *vam = &vat_main;
4423 i32 retval = ntohl (mp->retval);
4427 print (vam->ofp, "%-20s%-16s",
4428 mp->is_set ? "set" : "not-set",
4429 mp->is_set ? (char *) mp->locator_set_name : "");
4432 vam->retval = retval;
4433 vam->result_ready = 1;
4437 vl_api_show_one_nsh_mapping_reply_t_handler_json
4438 (vl_api_show_one_nsh_mapping_reply_t * mp)
4440 vat_main_t *vam = &vat_main;
4441 vat_json_node_t node;
4444 status = format (0, "%s", mp->is_set ? "yes" : "no");
4445 vec_add1 (status, 0);
4447 vat_json_init_object (&node);
4448 vat_json_object_add_string_copy (&node, "is_set", status);
4451 vat_json_object_add_string_copy (&node, "locator_set",
4452 mp->locator_set_name);
4457 vat_json_print (vam->ofp, &node);
4458 vat_json_free (&node);
4460 vam->retval = ntohl (mp->retval);
4461 vam->result_ready = 1;
4465 vl_api_show_one_map_register_ttl_reply_t_handler
4466 (vl_api_show_one_map_register_ttl_reply_t * mp)
4468 vat_main_t *vam = &vat_main;
4469 i32 retval = ntohl (mp->retval);
4471 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4475 print (vam->ofp, "ttl: %u", mp->ttl);
4478 vam->retval = retval;
4479 vam->result_ready = 1;
4483 vl_api_show_one_map_register_ttl_reply_t_handler_json
4484 (vl_api_show_one_map_register_ttl_reply_t * mp)
4486 vat_main_t *vam = &vat_main;
4487 vat_json_node_t node;
4489 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4490 vat_json_init_object (&node);
4491 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4493 vat_json_print (vam->ofp, &node);
4494 vat_json_free (&node);
4496 vam->retval = ntohl (mp->retval);
4497 vam->result_ready = 1;
4501 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4503 vat_main_t *vam = &vat_main;
4504 i32 retval = ntohl (mp->retval);
4508 print (vam->ofp, "%-20s%-16s",
4509 mp->status ? "enabled" : "disabled",
4510 mp->status ? (char *) mp->locator_set_name : "");
4513 vam->retval = retval;
4514 vam->result_ready = 1;
4518 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4520 vat_main_t *vam = &vat_main;
4521 vat_json_node_t node;
4524 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4525 vec_add1 (status, 0);
4527 vat_json_init_object (&node);
4528 vat_json_object_add_string_copy (&node, "status", status);
4531 vat_json_object_add_string_copy (&node, "locator_set",
4532 mp->locator_set_name);
4537 vat_json_print (vam->ofp, &node);
4538 vat_json_free (&node);
4540 vam->retval = ntohl (mp->retval);
4541 vam->result_ready = 1;
4545 format_policer_type (u8 * s, va_list * va)
4547 u32 i = va_arg (*va, u32);
4549 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4550 s = format (s, "1r2c");
4551 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4552 s = format (s, "1r3c");
4553 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4554 s = format (s, "2r3c-2698");
4555 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4556 s = format (s, "2r3c-4115");
4557 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4558 s = format (s, "2r3c-mef5cf1");
4560 s = format (s, "ILLEGAL");
4565 format_policer_rate_type (u8 * s, va_list * va)
4567 u32 i = va_arg (*va, u32);
4569 if (i == SSE2_QOS_RATE_KBPS)
4570 s = format (s, "kbps");
4571 else if (i == SSE2_QOS_RATE_PPS)
4572 s = format (s, "pps");
4574 s = format (s, "ILLEGAL");
4579 format_policer_round_type (u8 * s, va_list * va)
4581 u32 i = va_arg (*va, u32);
4583 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4584 s = format (s, "closest");
4585 else if (i == SSE2_QOS_ROUND_TO_UP)
4586 s = format (s, "up");
4587 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4588 s = format (s, "down");
4590 s = format (s, "ILLEGAL");
4595 format_policer_action_type (u8 * s, va_list * va)
4597 u32 i = va_arg (*va, u32);
4599 if (i == SSE2_QOS_ACTION_DROP)
4600 s = format (s, "drop");
4601 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4602 s = format (s, "transmit");
4603 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4604 s = format (s, "mark-and-transmit");
4606 s = format (s, "ILLEGAL");
4611 format_dscp (u8 * s, va_list * va)
4613 u32 i = va_arg (*va, u32);
4618 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4622 return format (s, "ILLEGAL");
4624 s = format (s, "%s", t);
4629 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4631 vat_main_t *vam = &vat_main;
4632 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4634 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4635 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4637 conform_dscp_str = format (0, "");
4639 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4640 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4642 exceed_dscp_str = format (0, "");
4644 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4645 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4647 violate_dscp_str = format (0, "");
4649 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4650 "rate type %U, round type %U, %s rate, %s color-aware, "
4651 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4652 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4653 "conform action %U%s, exceed action %U%s, violate action %U%s",
4655 format_policer_type, mp->type,
4658 clib_net_to_host_u64 (mp->cb),
4659 clib_net_to_host_u64 (mp->eb),
4660 format_policer_rate_type, mp->rate_type,
4661 format_policer_round_type, mp->round_type,
4662 mp->single_rate ? "single" : "dual",
4663 mp->color_aware ? "is" : "not",
4664 ntohl (mp->cir_tokens_per_period),
4665 ntohl (mp->pir_tokens_per_period),
4667 ntohl (mp->current_limit),
4668 ntohl (mp->current_bucket),
4669 ntohl (mp->extended_limit),
4670 ntohl (mp->extended_bucket),
4671 clib_net_to_host_u64 (mp->last_update_time),
4672 format_policer_action_type, mp->conform_action_type,
4674 format_policer_action_type, mp->exceed_action_type,
4676 format_policer_action_type, mp->violate_action_type,
4679 vec_free (conform_dscp_str);
4680 vec_free (exceed_dscp_str);
4681 vec_free (violate_dscp_str);
4684 static void vl_api_policer_details_t_handler_json
4685 (vl_api_policer_details_t * mp)
4687 vat_main_t *vam = &vat_main;
4688 vat_json_node_t *node;
4689 u8 *rate_type_str, *round_type_str, *type_str;
4690 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4692 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4694 format (0, "%U", format_policer_round_type, mp->round_type);
4695 type_str = format (0, "%U", format_policer_type, mp->type);
4696 conform_action_str = format (0, "%U", format_policer_action_type,
4697 mp->conform_action_type);
4698 exceed_action_str = format (0, "%U", format_policer_action_type,
4699 mp->exceed_action_type);
4700 violate_action_str = format (0, "%U", format_policer_action_type,
4701 mp->violate_action_type);
4703 if (VAT_JSON_ARRAY != vam->json_tree.type)
4705 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4706 vat_json_init_array (&vam->json_tree);
4708 node = vat_json_array_add (&vam->json_tree);
4710 vat_json_init_object (node);
4711 vat_json_object_add_string_copy (node, "name", mp->name);
4712 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4713 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4714 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4715 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4716 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4717 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4718 vat_json_object_add_string_copy (node, "type", type_str);
4719 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4720 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4721 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4722 vat_json_object_add_uint (node, "cir_tokens_per_period",
4723 ntohl (mp->cir_tokens_per_period));
4724 vat_json_object_add_uint (node, "eir_tokens_per_period",
4725 ntohl (mp->pir_tokens_per_period));
4726 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4727 vat_json_object_add_uint (node, "current_bucket",
4728 ntohl (mp->current_bucket));
4729 vat_json_object_add_uint (node, "extended_limit",
4730 ntohl (mp->extended_limit));
4731 vat_json_object_add_uint (node, "extended_bucket",
4732 ntohl (mp->extended_bucket));
4733 vat_json_object_add_uint (node, "last_update_time",
4734 ntohl (mp->last_update_time));
4735 vat_json_object_add_string_copy (node, "conform_action",
4736 conform_action_str);
4737 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4739 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4740 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4741 vec_free (dscp_str);
4743 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4744 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4746 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4747 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4748 vec_free (dscp_str);
4750 vat_json_object_add_string_copy (node, "violate_action",
4751 violate_action_str);
4752 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4754 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4755 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4756 vec_free (dscp_str);
4759 vec_free (rate_type_str);
4760 vec_free (round_type_str);
4761 vec_free (type_str);
4762 vec_free (conform_action_str);
4763 vec_free (exceed_action_str);
4764 vec_free (violate_action_str);
4768 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4771 vat_main_t *vam = &vat_main;
4772 int i, count = ntohl (mp->count);
4775 print (vam->ofp, "classify table ids (%d) : ", count);
4776 for (i = 0; i < count; i++)
4778 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4779 print (vam->ofp, (i < count - 1) ? "," : "");
4781 vam->retval = ntohl (mp->retval);
4782 vam->result_ready = 1;
4786 vl_api_classify_table_ids_reply_t_handler_json
4787 (vl_api_classify_table_ids_reply_t * mp)
4789 vat_main_t *vam = &vat_main;
4790 int i, count = ntohl (mp->count);
4794 vat_json_node_t node;
4796 vat_json_init_object (&node);
4797 for (i = 0; i < count; i++)
4799 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4801 vat_json_print (vam->ofp, &node);
4802 vat_json_free (&node);
4804 vam->retval = ntohl (mp->retval);
4805 vam->result_ready = 1;
4809 vl_api_classify_table_by_interface_reply_t_handler
4810 (vl_api_classify_table_by_interface_reply_t * mp)
4812 vat_main_t *vam = &vat_main;
4815 table_id = ntohl (mp->l2_table_id);
4817 print (vam->ofp, "l2 table id : %d", table_id);
4819 print (vam->ofp, "l2 table id : No input ACL tables configured");
4820 table_id = ntohl (mp->ip4_table_id);
4822 print (vam->ofp, "ip4 table id : %d", table_id);
4824 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4825 table_id = ntohl (mp->ip6_table_id);
4827 print (vam->ofp, "ip6 table id : %d", table_id);
4829 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4830 vam->retval = ntohl (mp->retval);
4831 vam->result_ready = 1;
4835 vl_api_classify_table_by_interface_reply_t_handler_json
4836 (vl_api_classify_table_by_interface_reply_t * mp)
4838 vat_main_t *vam = &vat_main;
4839 vat_json_node_t node;
4841 vat_json_init_object (&node);
4843 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4844 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4845 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4847 vat_json_print (vam->ofp, &node);
4848 vat_json_free (&node);
4850 vam->retval = ntohl (mp->retval);
4851 vam->result_ready = 1;
4854 static void vl_api_policer_add_del_reply_t_handler
4855 (vl_api_policer_add_del_reply_t * mp)
4857 vat_main_t *vam = &vat_main;
4858 i32 retval = ntohl (mp->retval);
4859 if (vam->async_mode)
4861 vam->async_errors += (retval < 0);
4865 vam->retval = retval;
4866 vam->result_ready = 1;
4867 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4869 * Note: this is just barely thread-safe, depends on
4870 * the main thread spinning waiting for an answer...
4872 errmsg ("policer index %d", ntohl (mp->policer_index));
4876 static void vl_api_policer_add_del_reply_t_handler_json
4877 (vl_api_policer_add_del_reply_t * mp)
4879 vat_main_t *vam = &vat_main;
4880 vat_json_node_t node;
4882 vat_json_init_object (&node);
4883 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4884 vat_json_object_add_uint (&node, "policer_index",
4885 ntohl (mp->policer_index));
4887 vat_json_print (vam->ofp, &node);
4888 vat_json_free (&node);
4890 vam->retval = ntohl (mp->retval);
4891 vam->result_ready = 1;
4894 /* Format hex dump. */
4896 format_hex_bytes (u8 * s, va_list * va)
4898 u8 *bytes = va_arg (*va, u8 *);
4899 int n_bytes = va_arg (*va, int);
4902 /* Print short or long form depending on byte count. */
4903 uword short_form = n_bytes <= 32;
4904 u32 indent = format_get_indent (s);
4909 for (i = 0; i < n_bytes; i++)
4911 if (!short_form && (i % 32) == 0)
4912 s = format (s, "%08x: ", i);
4913 s = format (s, "%02x", bytes[i]);
4914 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4915 s = format (s, "\n%U", format_white_space, indent);
4922 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4925 vat_main_t *vam = &vat_main;
4926 i32 retval = ntohl (mp->retval);
4929 print (vam->ofp, "classify table info :");
4930 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4931 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4932 ntohl (mp->miss_next_index));
4933 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4934 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4935 ntohl (mp->match_n_vectors));
4936 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4937 ntohl (mp->mask_length));
4939 vam->retval = retval;
4940 vam->result_ready = 1;
4944 vl_api_classify_table_info_reply_t_handler_json
4945 (vl_api_classify_table_info_reply_t * mp)
4947 vat_main_t *vam = &vat_main;
4948 vat_json_node_t node;
4950 i32 retval = ntohl (mp->retval);
4953 vat_json_init_object (&node);
4955 vat_json_object_add_int (&node, "sessions",
4956 ntohl (mp->active_sessions));
4957 vat_json_object_add_int (&node, "nexttbl",
4958 ntohl (mp->next_table_index));
4959 vat_json_object_add_int (&node, "nextnode",
4960 ntohl (mp->miss_next_index));
4961 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4962 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4963 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4964 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4965 ntohl (mp->mask_length), 0);
4966 vat_json_object_add_string_copy (&node, "mask", s);
4968 vat_json_print (vam->ofp, &node);
4969 vat_json_free (&node);
4971 vam->retval = ntohl (mp->retval);
4972 vam->result_ready = 1;
4976 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4979 vat_main_t *vam = &vat_main;
4981 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4982 ntohl (mp->hit_next_index), ntohl (mp->advance),
4983 ntohl (mp->opaque_index));
4984 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4985 ntohl (mp->match_length));
4989 vl_api_classify_session_details_t_handler_json
4990 (vl_api_classify_session_details_t * mp)
4992 vat_main_t *vam = &vat_main;
4993 vat_json_node_t *node = NULL;
4995 if (VAT_JSON_ARRAY != vam->json_tree.type)
4997 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4998 vat_json_init_array (&vam->json_tree);
5000 node = vat_json_array_add (&vam->json_tree);
5002 vat_json_init_object (node);
5003 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5004 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5005 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5007 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5009 vat_json_object_add_string_copy (node, "match", s);
5012 static void vl_api_pg_create_interface_reply_t_handler
5013 (vl_api_pg_create_interface_reply_t * mp)
5015 vat_main_t *vam = &vat_main;
5017 vam->retval = ntohl (mp->retval);
5018 vam->result_ready = 1;
5021 static void vl_api_pg_create_interface_reply_t_handler_json
5022 (vl_api_pg_create_interface_reply_t * mp)
5024 vat_main_t *vam = &vat_main;
5025 vat_json_node_t node;
5027 i32 retval = ntohl (mp->retval);
5030 vat_json_init_object (&node);
5032 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5034 vat_json_print (vam->ofp, &node);
5035 vat_json_free (&node);
5037 vam->retval = ntohl (mp->retval);
5038 vam->result_ready = 1;
5041 static void vl_api_policer_classify_details_t_handler
5042 (vl_api_policer_classify_details_t * mp)
5044 vat_main_t *vam = &vat_main;
5046 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5047 ntohl (mp->table_index));
5050 static void vl_api_policer_classify_details_t_handler_json
5051 (vl_api_policer_classify_details_t * mp)
5053 vat_main_t *vam = &vat_main;
5054 vat_json_node_t *node;
5056 if (VAT_JSON_ARRAY != vam->json_tree.type)
5058 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5059 vat_json_init_array (&vam->json_tree);
5061 node = vat_json_array_add (&vam->json_tree);
5063 vat_json_init_object (node);
5064 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5065 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5068 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5069 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5071 vat_main_t *vam = &vat_main;
5072 i32 retval = ntohl (mp->retval);
5073 if (vam->async_mode)
5075 vam->async_errors += (retval < 0);
5079 vam->retval = retval;
5080 vam->sw_if_index = ntohl (mp->sw_if_index);
5081 vam->result_ready = 1;
5085 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5086 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5088 vat_main_t *vam = &vat_main;
5089 vat_json_node_t node;
5091 vat_json_init_object (&node);
5092 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5093 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5095 vat_json_print (vam->ofp, &node);
5096 vat_json_free (&node);
5098 vam->retval = ntohl (mp->retval);
5099 vam->result_ready = 1;
5102 static void vl_api_flow_classify_details_t_handler
5103 (vl_api_flow_classify_details_t * mp)
5105 vat_main_t *vam = &vat_main;
5107 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5108 ntohl (mp->table_index));
5111 static void vl_api_flow_classify_details_t_handler_json
5112 (vl_api_flow_classify_details_t * mp)
5114 vat_main_t *vam = &vat_main;
5115 vat_json_node_t *node;
5117 if (VAT_JSON_ARRAY != vam->json_tree.type)
5119 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5120 vat_json_init_array (&vam->json_tree);
5122 node = vat_json_array_add (&vam->json_tree);
5124 vat_json_init_object (node);
5125 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5126 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5129 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5130 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5131 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5132 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5133 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5134 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5135 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5136 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5137 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5138 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5139 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5140 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5141 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5142 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5143 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5144 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5145 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5146 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5147 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5148 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5149 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5150 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5153 * Generate boilerplate reply handlers, which
5154 * dig the return value out of the xxx_reply_t API message,
5155 * stick it into vam->retval, and set vam->result_ready
5157 * Could also do this by pointing N message decode slots at
5158 * a single function, but that could break in subtle ways.
5161 #define foreach_standard_reply_retval_handler \
5162 _(sw_interface_set_flags_reply) \
5163 _(sw_interface_add_del_address_reply) \
5164 _(sw_interface_set_rx_mode_reply) \
5165 _(sw_interface_set_table_reply) \
5166 _(sw_interface_set_mpls_enable_reply) \
5167 _(sw_interface_set_vpath_reply) \
5168 _(sw_interface_set_vxlan_bypass_reply) \
5169 _(sw_interface_set_geneve_bypass_reply) \
5170 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5171 _(sw_interface_set_l2_bridge_reply) \
5172 _(bridge_domain_add_del_reply) \
5173 _(sw_interface_set_l2_xconnect_reply) \
5174 _(l2fib_add_del_reply) \
5175 _(l2fib_flush_int_reply) \
5176 _(l2fib_flush_bd_reply) \
5177 _(ip_add_del_route_reply) \
5178 _(ip_table_add_del_reply) \
5179 _(ip_mroute_add_del_reply) \
5180 _(mpls_route_add_del_reply) \
5181 _(mpls_table_add_del_reply) \
5182 _(mpls_ip_bind_unbind_reply) \
5183 _(bier_route_add_del_reply) \
5184 _(bier_table_add_del_reply) \
5185 _(proxy_arp_add_del_reply) \
5186 _(proxy_arp_intfc_enable_disable_reply) \
5187 _(sw_interface_set_unnumbered_reply) \
5188 _(ip_neighbor_add_del_reply) \
5189 _(oam_add_del_reply) \
5190 _(reset_fib_reply) \
5191 _(dhcp_proxy_config_reply) \
5192 _(dhcp_proxy_set_vss_reply) \
5193 _(dhcp_client_config_reply) \
5194 _(set_ip_flow_hash_reply) \
5195 _(sw_interface_ip6_enable_disable_reply) \
5196 _(sw_interface_ip6_set_link_local_address_reply) \
5197 _(ip6nd_proxy_add_del_reply) \
5198 _(sw_interface_ip6nd_ra_prefix_reply) \
5199 _(sw_interface_ip6nd_ra_config_reply) \
5200 _(set_arp_neighbor_limit_reply) \
5201 _(l2_patch_add_del_reply) \
5202 _(sr_policy_add_reply) \
5203 _(sr_policy_mod_reply) \
5204 _(sr_policy_del_reply) \
5205 _(sr_localsid_add_del_reply) \
5206 _(sr_steering_add_del_reply) \
5207 _(classify_add_del_session_reply) \
5208 _(classify_set_interface_ip_table_reply) \
5209 _(classify_set_interface_l2_tables_reply) \
5210 _(l2tpv3_set_tunnel_cookies_reply) \
5211 _(l2tpv3_interface_enable_disable_reply) \
5212 _(l2tpv3_set_lookup_key_reply) \
5213 _(l2_fib_clear_table_reply) \
5214 _(l2_interface_efp_filter_reply) \
5215 _(l2_interface_vlan_tag_rewrite_reply) \
5216 _(modify_vhost_user_if_reply) \
5217 _(delete_vhost_user_if_reply) \
5218 _(want_ip4_arp_events_reply) \
5219 _(want_ip6_nd_events_reply) \
5220 _(want_l2_macs_events_reply) \
5221 _(input_acl_set_interface_reply) \
5222 _(ipsec_spd_add_del_reply) \
5223 _(ipsec_interface_add_del_spd_reply) \
5224 _(ipsec_spd_add_del_entry_reply) \
5225 _(ipsec_sad_add_del_entry_reply) \
5226 _(ipsec_sa_set_key_reply) \
5227 _(ipsec_tunnel_if_add_del_reply) \
5228 _(ipsec_tunnel_if_set_key_reply) \
5229 _(ipsec_tunnel_if_set_sa_reply) \
5230 _(ikev2_profile_add_del_reply) \
5231 _(ikev2_profile_set_auth_reply) \
5232 _(ikev2_profile_set_id_reply) \
5233 _(ikev2_profile_set_ts_reply) \
5234 _(ikev2_set_local_key_reply) \
5235 _(ikev2_set_responder_reply) \
5236 _(ikev2_set_ike_transforms_reply) \
5237 _(ikev2_set_esp_transforms_reply) \
5238 _(ikev2_set_sa_lifetime_reply) \
5239 _(ikev2_initiate_sa_init_reply) \
5240 _(ikev2_initiate_del_ike_sa_reply) \
5241 _(ikev2_initiate_del_child_sa_reply) \
5242 _(ikev2_initiate_rekey_child_sa_reply) \
5243 _(delete_loopback_reply) \
5244 _(bd_ip_mac_add_del_reply) \
5245 _(map_del_domain_reply) \
5246 _(map_add_del_rule_reply) \
5247 _(want_interface_events_reply) \
5248 _(want_stats_reply) \
5249 _(cop_interface_enable_disable_reply) \
5250 _(cop_whitelist_enable_disable_reply) \
5251 _(sw_interface_clear_stats_reply) \
5252 _(ioam_enable_reply) \
5253 _(ioam_disable_reply) \
5254 _(one_add_del_locator_reply) \
5255 _(one_add_del_local_eid_reply) \
5256 _(one_add_del_remote_mapping_reply) \
5257 _(one_add_del_adjacency_reply) \
5258 _(one_add_del_map_resolver_reply) \
5259 _(one_add_del_map_server_reply) \
5260 _(one_enable_disable_reply) \
5261 _(one_rloc_probe_enable_disable_reply) \
5262 _(one_map_register_enable_disable_reply) \
5263 _(one_map_register_set_ttl_reply) \
5264 _(one_set_transport_protocol_reply) \
5265 _(one_map_register_fallback_threshold_reply) \
5266 _(one_pitr_set_locator_set_reply) \
5267 _(one_map_request_mode_reply) \
5268 _(one_add_del_map_request_itr_rlocs_reply) \
5269 _(one_eid_table_add_del_map_reply) \
5270 _(one_use_petr_reply) \
5271 _(one_stats_enable_disable_reply) \
5272 _(one_add_del_l2_arp_entry_reply) \
5273 _(one_add_del_ndp_entry_reply) \
5274 _(one_stats_flush_reply) \
5275 _(one_enable_disable_xtr_mode_reply) \
5276 _(one_enable_disable_pitr_mode_reply) \
5277 _(one_enable_disable_petr_mode_reply) \
5278 _(gpe_enable_disable_reply) \
5279 _(gpe_set_encap_mode_reply) \
5280 _(gpe_add_del_iface_reply) \
5281 _(gpe_add_del_native_fwd_rpath_reply) \
5282 _(af_packet_delete_reply) \
5283 _(policer_classify_set_interface_reply) \
5284 _(netmap_create_reply) \
5285 _(netmap_delete_reply) \
5286 _(set_ipfix_exporter_reply) \
5287 _(set_ipfix_classify_stream_reply) \
5288 _(ipfix_classify_table_add_del_reply) \
5289 _(flow_classify_set_interface_reply) \
5290 _(sw_interface_span_enable_disable_reply) \
5291 _(pg_capture_reply) \
5292 _(pg_enable_disable_reply) \
5293 _(ip_source_and_port_range_check_add_del_reply) \
5294 _(ip_source_and_port_range_check_interface_add_del_reply)\
5295 _(delete_subif_reply) \
5296 _(l2_interface_pbb_tag_rewrite_reply) \
5298 _(feature_enable_disable_reply) \
5299 _(sw_interface_tag_add_del_reply) \
5300 _(sw_interface_set_mtu_reply) \
5301 _(p2p_ethernet_add_reply) \
5302 _(p2p_ethernet_del_reply) \
5303 _(lldp_config_reply) \
5304 _(sw_interface_set_lldp_reply) \
5305 _(tcp_configure_src_addresses_reply) \
5306 _(dns_enable_disable_reply) \
5307 _(dns_name_server_add_del_reply) \
5308 _(session_rule_add_del_reply) \
5309 _(ip_container_proxy_add_del_reply)
5312 static void vl_api_##n##_t_handler \
5313 (vl_api_##n##_t * mp) \
5315 vat_main_t * vam = &vat_main; \
5316 i32 retval = ntohl(mp->retval); \
5317 if (vam->async_mode) { \
5318 vam->async_errors += (retval < 0); \
5320 vam->retval = retval; \
5321 vam->result_ready = 1; \
5324 foreach_standard_reply_retval_handler;
5328 static void vl_api_##n##_t_handler_json \
5329 (vl_api_##n##_t * mp) \
5331 vat_main_t * vam = &vat_main; \
5332 vat_json_node_t node; \
5333 vat_json_init_object(&node); \
5334 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5335 vat_json_print(vam->ofp, &node); \
5336 vam->retval = ntohl(mp->retval); \
5337 vam->result_ready = 1; \
5339 foreach_standard_reply_retval_handler;
5343 * Table of message reply handlers, must include boilerplate handlers
5347 #define foreach_vpe_api_reply_msg \
5348 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5349 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5350 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5351 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5352 _(CONTROL_PING_REPLY, control_ping_reply) \
5353 _(CLI_REPLY, cli_reply) \
5354 _(CLI_INBAND_REPLY, cli_inband_reply) \
5355 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5356 sw_interface_add_del_address_reply) \
5357 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5358 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5359 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5360 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5361 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5362 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5363 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5364 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5365 sw_interface_set_l2_xconnect_reply) \
5366 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5367 sw_interface_set_l2_bridge_reply) \
5368 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5369 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5370 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5371 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5372 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5373 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5374 _(L2_FLAGS_REPLY, l2_flags_reply) \
5375 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5376 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5377 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5378 _(TAP_DELETE_REPLY, tap_delete_reply) \
5379 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5380 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5381 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5382 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5383 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5384 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5385 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5386 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5387 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5388 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5389 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5390 proxy_arp_intfc_enable_disable_reply) \
5391 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5392 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5393 sw_interface_set_unnumbered_reply) \
5394 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5395 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5396 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5397 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5398 _(RESET_FIB_REPLY, reset_fib_reply) \
5399 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5400 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5401 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5402 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5403 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5404 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5405 sw_interface_ip6_enable_disable_reply) \
5406 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5407 sw_interface_ip6_set_link_local_address_reply) \
5408 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5409 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5410 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5411 sw_interface_ip6nd_ra_prefix_reply) \
5412 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5413 sw_interface_ip6nd_ra_config_reply) \
5414 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5415 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5416 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5417 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5418 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5419 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5420 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5421 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5422 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5423 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5424 classify_set_interface_ip_table_reply) \
5425 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5426 classify_set_interface_l2_tables_reply) \
5427 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5428 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5429 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5430 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5431 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5432 l2tpv3_interface_enable_disable_reply) \
5433 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5434 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5435 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5436 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5437 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5438 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5439 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5440 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5441 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5442 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5443 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5444 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5445 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5446 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5447 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5448 _(SHOW_VERSION_REPLY, show_version_reply) \
5449 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5450 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5451 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5452 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5453 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5454 _(IP4_ARP_EVENT, ip4_arp_event) \
5455 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5456 _(IP6_ND_EVENT, ip6_nd_event) \
5457 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5458 _(L2_MACS_EVENT, l2_macs_event) \
5459 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5460 _(IP_ADDRESS_DETAILS, ip_address_details) \
5461 _(IP_DETAILS, ip_details) \
5462 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5463 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5464 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5465 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5466 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5467 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5468 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5469 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5470 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5471 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5472 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5473 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5474 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5475 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5476 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5477 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5478 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5479 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5480 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5481 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5482 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5483 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5484 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5485 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5486 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5487 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5488 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5489 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5490 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5491 _(MAP_RULE_DETAILS, map_rule_details) \
5492 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5493 _(WANT_STATS_REPLY, want_stats_reply) \
5494 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5495 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5496 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5497 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5498 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5499 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5500 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5501 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5502 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5503 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5504 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5505 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5506 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5507 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5508 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5509 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5510 one_map_register_enable_disable_reply) \
5511 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5512 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5513 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5514 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5515 one_map_register_fallback_threshold_reply) \
5516 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5517 one_rloc_probe_enable_disable_reply) \
5518 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5519 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5520 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5521 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5522 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5523 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5524 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5525 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5526 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5527 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5528 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5529 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5530 _(ONE_STATS_DETAILS, one_stats_details) \
5531 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5532 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5533 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5534 show_one_stats_enable_disable_reply) \
5535 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5536 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5537 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5538 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5539 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5540 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5541 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5542 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5543 one_enable_disable_pitr_mode_reply) \
5544 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5545 one_enable_disable_petr_mode_reply) \
5546 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5547 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5548 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5549 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5550 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5551 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5552 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5553 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5554 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5555 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5556 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5557 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5558 gpe_add_del_native_fwd_rpath_reply) \
5559 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5560 gpe_fwd_entry_path_details) \
5561 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5562 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5563 one_add_del_map_request_itr_rlocs_reply) \
5564 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5565 one_get_map_request_itr_rlocs_reply) \
5566 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5567 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5568 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5569 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5570 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5571 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5572 show_one_map_register_state_reply) \
5573 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5574 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5575 show_one_map_register_fallback_threshold_reply) \
5576 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5577 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5578 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5579 _(POLICER_DETAILS, policer_details) \
5580 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5581 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5582 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5583 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5584 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5585 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5586 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5587 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5588 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5589 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5590 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5591 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5592 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5593 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5594 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5595 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5596 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5597 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5598 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5599 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5600 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5601 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5602 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5603 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5604 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5605 ip_source_and_port_range_check_add_del_reply) \
5606 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5607 ip_source_and_port_range_check_interface_add_del_reply) \
5608 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5609 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5610 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5611 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5612 _(PUNT_REPLY, punt_reply) \
5613 _(IP_FIB_DETAILS, ip_fib_details) \
5614 _(IP6_FIB_DETAILS, ip6_fib_details) \
5615 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5616 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5617 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5618 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5619 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5620 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5621 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5622 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5623 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5624 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5625 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5626 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5627 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5628 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5629 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5630 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5631 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5632 _(SESSION_RULES_DETAILS, session_rules_details) \
5633 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5635 #define foreach_standalone_reply_msg \
5636 _(SW_INTERFACE_EVENT, sw_interface_event) \
5637 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5638 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5639 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5640 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5641 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5642 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
5643 _(MEMFD_SEGMENT_CREATE_REPLY, memfd_segment_create_reply) \
5652 #define STR_VTR_OP_CASE(op) \
5653 case L2_VTR_ ## op: \
5657 str_vtr_op (u32 vtr_op)
5661 STR_VTR_OP_CASE (DISABLED);
5662 STR_VTR_OP_CASE (PUSH_1);
5663 STR_VTR_OP_CASE (PUSH_2);
5664 STR_VTR_OP_CASE (POP_1);
5665 STR_VTR_OP_CASE (POP_2);
5666 STR_VTR_OP_CASE (TRANSLATE_1_1);
5667 STR_VTR_OP_CASE (TRANSLATE_1_2);
5668 STR_VTR_OP_CASE (TRANSLATE_2_1);
5669 STR_VTR_OP_CASE (TRANSLATE_2_2);
5676 dump_sub_interface_table (vat_main_t * vam)
5678 const sw_interface_subif_t *sub = NULL;
5680 if (vam->json_output)
5683 ("JSON output supported only for VPE API calls and dump_stats_table");
5688 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5689 "Interface", "sw_if_index",
5690 "sub id", "dot1ad", "tags", "outer id",
5691 "inner id", "exact", "default", "outer any", "inner any");
5693 vec_foreach (sub, vam->sw_if_subif_table)
5696 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5697 sub->interface_name,
5699 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5700 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5701 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5702 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5703 if (sub->vtr_op != L2_VTR_DISABLED)
5706 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5707 "tag1: %d tag2: %d ]",
5708 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5709 sub->vtr_tag1, sub->vtr_tag2);
5717 name_sort_cmp (void *a1, void *a2)
5719 name_sort_t *n1 = a1;
5720 name_sort_t *n2 = a2;
5722 return strcmp ((char *) n1->name, (char *) n2->name);
5726 dump_interface_table (vat_main_t * vam)
5729 name_sort_t *nses = 0, *ns;
5731 if (vam->json_output)
5734 ("JSON output supported only for VPE API calls and dump_stats_table");
5739 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5741 vec_add2 (nses, ns, 1);
5742 ns->name = (u8 *)(p->key);
5743 ns->value = (u32) p->value[0];
5747 vec_sort_with_function (nses, name_sort_cmp);
5749 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5750 vec_foreach (ns, nses)
5752 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5759 dump_ip_table (vat_main_t * vam, int is_ipv6)
5761 const ip_details_t *det = NULL;
5762 const ip_address_details_t *address = NULL;
5765 print (vam->ofp, "%-12s", "sw_if_index");
5767 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5774 print (vam->ofp, "%-12d", i);
5775 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5780 vec_foreach (address, det->addr)
5784 is_ipv6 ? format_ip6_address : format_ip4_address,
5785 address->ip, address->prefix_length);
5793 dump_ipv4_table (vat_main_t * vam)
5795 if (vam->json_output)
5798 ("JSON output supported only for VPE API calls and dump_stats_table");
5802 return dump_ip_table (vam, 0);
5806 dump_ipv6_table (vat_main_t * vam)
5808 if (vam->json_output)
5811 ("JSON output supported only for VPE API calls and dump_stats_table");
5815 return dump_ip_table (vam, 1);
5819 counter_type_to_str (u8 counter_type, u8 is_combined)
5823 switch (counter_type)
5825 case VNET_INTERFACE_COUNTER_DROP:
5827 case VNET_INTERFACE_COUNTER_PUNT:
5829 case VNET_INTERFACE_COUNTER_IP4:
5831 case VNET_INTERFACE_COUNTER_IP6:
5833 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5835 case VNET_INTERFACE_COUNTER_RX_MISS:
5837 case VNET_INTERFACE_COUNTER_RX_ERROR:
5839 case VNET_INTERFACE_COUNTER_TX_ERROR:
5842 return "INVALID-COUNTER-TYPE";
5847 switch (counter_type)
5849 case VNET_INTERFACE_COUNTER_RX:
5851 case VNET_INTERFACE_COUNTER_TX:
5854 return "INVALID-COUNTER-TYPE";
5860 dump_stats_table (vat_main_t * vam)
5862 vat_json_node_t node;
5863 vat_json_node_t *msg_array;
5864 vat_json_node_t *msg;
5865 vat_json_node_t *counter_array;
5866 vat_json_node_t *counter;
5867 interface_counter_t c;
5869 ip4_fib_counter_t *c4;
5870 ip6_fib_counter_t *c6;
5871 ip4_nbr_counter_t *n4;
5872 ip6_nbr_counter_t *n6;
5875 if (!vam->json_output)
5877 clib_warning ("dump_stats_table supported only in JSON format");
5881 vat_json_init_object (&node);
5883 /* interface counters */
5884 msg_array = vat_json_object_add (&node, "interface_counters");
5885 vat_json_init_array (msg_array);
5886 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5888 msg = vat_json_array_add (msg_array);
5889 vat_json_init_object (msg);
5890 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5891 (u8 *) counter_type_to_str (i, 0));
5892 vat_json_object_add_int (msg, "is_combined", 0);
5893 counter_array = vat_json_object_add (msg, "data");
5894 vat_json_init_array (counter_array);
5895 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5897 packets = vam->simple_interface_counters[i][j];
5898 vat_json_array_add_uint (counter_array, packets);
5901 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5903 msg = vat_json_array_add (msg_array);
5904 vat_json_init_object (msg);
5905 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5906 (u8 *) counter_type_to_str (i, 1));
5907 vat_json_object_add_int (msg, "is_combined", 1);
5908 counter_array = vat_json_object_add (msg, "data");
5909 vat_json_init_array (counter_array);
5910 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5912 c = vam->combined_interface_counters[i][j];
5913 counter = vat_json_array_add (counter_array);
5914 vat_json_init_object (counter);
5915 vat_json_object_add_uint (counter, "packets", c.packets);
5916 vat_json_object_add_uint (counter, "bytes", c.bytes);
5920 /* ip4 fib counters */
5921 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5922 vat_json_init_array (msg_array);
5923 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5925 msg = vat_json_array_add (msg_array);
5926 vat_json_init_object (msg);
5927 vat_json_object_add_uint (msg, "vrf_id",
5928 vam->ip4_fib_counters_vrf_id_by_index[i]);
5929 counter_array = vat_json_object_add (msg, "c");
5930 vat_json_init_array (counter_array);
5931 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5933 counter = vat_json_array_add (counter_array);
5934 vat_json_init_object (counter);
5935 c4 = &vam->ip4_fib_counters[i][j];
5936 vat_json_object_add_ip4 (counter, "address", c4->address);
5937 vat_json_object_add_uint (counter, "address_length",
5938 c4->address_length);
5939 vat_json_object_add_uint (counter, "packets", c4->packets);
5940 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5944 /* ip6 fib counters */
5945 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5946 vat_json_init_array (msg_array);
5947 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5949 msg = vat_json_array_add (msg_array);
5950 vat_json_init_object (msg);
5951 vat_json_object_add_uint (msg, "vrf_id",
5952 vam->ip6_fib_counters_vrf_id_by_index[i]);
5953 counter_array = vat_json_object_add (msg, "c");
5954 vat_json_init_array (counter_array);
5955 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5957 counter = vat_json_array_add (counter_array);
5958 vat_json_init_object (counter);
5959 c6 = &vam->ip6_fib_counters[i][j];
5960 vat_json_object_add_ip6 (counter, "address", c6->address);
5961 vat_json_object_add_uint (counter, "address_length",
5962 c6->address_length);
5963 vat_json_object_add_uint (counter, "packets", c6->packets);
5964 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5968 /* ip4 nbr counters */
5969 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5970 vat_json_init_array (msg_array);
5971 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5973 msg = vat_json_array_add (msg_array);
5974 vat_json_init_object (msg);
5975 vat_json_object_add_uint (msg, "sw_if_index", i);
5976 counter_array = vat_json_object_add (msg, "c");
5977 vat_json_init_array (counter_array);
5978 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5980 counter = vat_json_array_add (counter_array);
5981 vat_json_init_object (counter);
5982 n4 = &vam->ip4_nbr_counters[i][j];
5983 vat_json_object_add_ip4 (counter, "address", n4->address);
5984 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5985 vat_json_object_add_uint (counter, "packets", n4->packets);
5986 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5990 /* ip6 nbr counters */
5991 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5992 vat_json_init_array (msg_array);
5993 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5995 msg = vat_json_array_add (msg_array);
5996 vat_json_init_object (msg);
5997 vat_json_object_add_uint (msg, "sw_if_index", i);
5998 counter_array = vat_json_object_add (msg, "c");
5999 vat_json_init_array (counter_array);
6000 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6002 counter = vat_json_array_add (counter_array);
6003 vat_json_init_object (counter);
6004 n6 = &vam->ip6_nbr_counters[i][j];
6005 vat_json_object_add_ip6 (counter, "address", n6->address);
6006 vat_json_object_add_uint (counter, "packets", n6->packets);
6007 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6011 vat_json_print (vam->ofp, &node);
6012 vat_json_free (&node);
6018 * Pass CLI buffers directly in the CLI_INBAND API message,
6019 * instead of an additional shared memory area.
6022 exec_inband (vat_main_t * vam)
6024 vl_api_cli_inband_t *mp;
6025 unformat_input_t *i = vam->input;
6028 if (vec_len (i->buffer) == 0)
6031 if (vam->exec_mode == 0 && unformat (i, "mode"))
6036 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6043 * In order for the CLI command to work, it
6044 * must be a vector ending in \n, not a C-string ending
6047 u32 len = vec_len (vam->input->buffer);
6048 M2 (CLI_INBAND, mp, len);
6049 clib_memcpy (mp->cmd, vam->input->buffer, len);
6050 mp->length = htonl (len);
6054 /* json responses may or may not include a useful reply... */
6055 if (vec_len (vam->cmd_reply))
6056 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6061 exec (vat_main_t * vam)
6063 return exec_inband (vam);
6067 api_create_loopback (vat_main_t * vam)
6069 unformat_input_t *i = vam->input;
6070 vl_api_create_loopback_t *mp;
6071 vl_api_create_loopback_instance_t *mp_lbi;
6074 u8 is_specified = 0;
6075 u32 user_instance = 0;
6078 memset (mac_address, 0, sizeof (mac_address));
6080 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6082 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6084 if (unformat (i, "instance %d", &user_instance))
6092 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6093 mp_lbi->is_specified = is_specified;
6095 mp_lbi->user_instance = htonl (user_instance);
6097 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6102 /* Construct the API message */
6103 M (CREATE_LOOPBACK, mp);
6105 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6114 api_delete_loopback (vat_main_t * vam)
6116 unformat_input_t *i = vam->input;
6117 vl_api_delete_loopback_t *mp;
6118 u32 sw_if_index = ~0;
6121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6123 if (unformat (i, "sw_if_index %d", &sw_if_index))
6129 if (sw_if_index == ~0)
6131 errmsg ("missing sw_if_index");
6135 /* Construct the API message */
6136 M (DELETE_LOOPBACK, mp);
6137 mp->sw_if_index = ntohl (sw_if_index);
6145 api_want_stats (vat_main_t * vam)
6147 unformat_input_t *i = vam->input;
6148 vl_api_want_stats_t *mp;
6152 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6154 if (unformat (i, "enable"))
6156 else if (unformat (i, "disable"))
6164 errmsg ("missing enable|disable");
6169 mp->enable_disable = enable;
6177 api_want_interface_events (vat_main_t * vam)
6179 unformat_input_t *i = vam->input;
6180 vl_api_want_interface_events_t *mp;
6184 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6186 if (unformat (i, "enable"))
6188 else if (unformat (i, "disable"))
6196 errmsg ("missing enable|disable");
6200 M (WANT_INTERFACE_EVENTS, mp);
6201 mp->enable_disable = enable;
6203 vam->interface_event_display = enable;
6211 /* Note: non-static, called once to set up the initial intfc table */
6213 api_sw_interface_dump (vat_main_t * vam)
6215 vl_api_sw_interface_dump_t *mp;
6216 vl_api_control_ping_t *mp_ping;
6218 name_sort_t *nses = 0, *ns;
6219 sw_interface_subif_t *sub = NULL;
6222 /* Toss the old name table */
6224 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6226 vec_add2 (nses, ns, 1);
6227 ns->name = (u8 *)(p->key);
6228 ns->value = (u32) p->value[0];
6232 hash_free (vam->sw_if_index_by_interface_name);
6234 vec_foreach (ns, nses) vec_free (ns->name);
6238 vec_foreach (sub, vam->sw_if_subif_table)
6240 vec_free (sub->interface_name);
6242 vec_free (vam->sw_if_subif_table);
6244 /* recreate the interface name hash table */
6245 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6247 /* Get list of ethernets */
6248 M (SW_INTERFACE_DUMP, mp);
6249 mp->name_filter_valid = 1;
6250 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
6253 /* and local / loopback interfaces */
6254 M (SW_INTERFACE_DUMP, mp);
6255 mp->name_filter_valid = 1;
6256 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
6259 /* and packet-generator interfaces */
6260 M (SW_INTERFACE_DUMP, mp);
6261 mp->name_filter_valid = 1;
6262 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
6265 /* and vxlan-gpe tunnel interfaces */
6266 M (SW_INTERFACE_DUMP, mp);
6267 mp->name_filter_valid = 1;
6268 strncpy ((char *) mp->name_filter, "vxlan_gpe",
6269 sizeof (mp->name_filter) - 1);
6272 /* and vxlan tunnel interfaces */
6273 M (SW_INTERFACE_DUMP, mp);
6274 mp->name_filter_valid = 1;
6275 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
6278 /* and geneve tunnel interfaces */
6279 M (SW_INTERFACE_DUMP, mp);
6280 mp->name_filter_valid = 1;
6281 strncpy ((char *) mp->name_filter, "geneve", sizeof (mp->name_filter) - 1);
6284 /* and host (af_packet) interfaces */
6285 M (SW_INTERFACE_DUMP, mp);
6286 mp->name_filter_valid = 1;
6287 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
6290 /* and l2tpv3 tunnel interfaces */
6291 M (SW_INTERFACE_DUMP, mp);
6292 mp->name_filter_valid = 1;
6293 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
6294 sizeof (mp->name_filter) - 1);
6297 /* and GRE tunnel interfaces */
6298 M (SW_INTERFACE_DUMP, mp);
6299 mp->name_filter_valid = 1;
6300 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
6303 /* and LISP-GPE interfaces */
6304 M (SW_INTERFACE_DUMP, mp);
6305 mp->name_filter_valid = 1;
6306 strncpy ((char *) mp->name_filter, "lisp_gpe",
6307 sizeof (mp->name_filter) - 1);
6310 /* and IPSEC tunnel interfaces */
6311 M (SW_INTERFACE_DUMP, mp);
6312 mp->name_filter_valid = 1;
6313 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
6316 /* Use a control ping for synchronization */
6317 MPING (CONTROL_PING, mp_ping);
6325 api_sw_interface_set_flags (vat_main_t * vam)
6327 unformat_input_t *i = vam->input;
6328 vl_api_sw_interface_set_flags_t *mp;
6330 u8 sw_if_index_set = 0;
6334 /* Parse args required to build the message */
6335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6337 if (unformat (i, "admin-up"))
6339 else if (unformat (i, "admin-down"))
6342 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6343 sw_if_index_set = 1;
6344 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6345 sw_if_index_set = 1;
6350 if (sw_if_index_set == 0)
6352 errmsg ("missing interface name or sw_if_index");
6356 /* Construct the API message */
6357 M (SW_INTERFACE_SET_FLAGS, mp);
6358 mp->sw_if_index = ntohl (sw_if_index);
6359 mp->admin_up_down = admin_up;
6364 /* Wait for a reply, return the good/bad news... */
6370 api_sw_interface_set_rx_mode (vat_main_t * vam)
6372 unformat_input_t *i = vam->input;
6373 vl_api_sw_interface_set_rx_mode_t *mp;
6375 u8 sw_if_index_set = 0;
6377 u8 queue_id_valid = 0;
6379 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6381 /* Parse args required to build the message */
6382 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6384 if (unformat (i, "queue %d", &queue_id))
6386 else if (unformat (i, "polling"))
6387 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6388 else if (unformat (i, "interrupt"))
6389 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6390 else if (unformat (i, "adaptive"))
6391 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6393 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6394 sw_if_index_set = 1;
6395 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6396 sw_if_index_set = 1;
6401 if (sw_if_index_set == 0)
6403 errmsg ("missing interface name or sw_if_index");
6406 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6408 errmsg ("missing rx-mode");
6412 /* Construct the API message */
6413 M (SW_INTERFACE_SET_RX_MODE, mp);
6414 mp->sw_if_index = ntohl (sw_if_index);
6416 mp->queue_id_valid = queue_id_valid;
6417 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6422 /* Wait for a reply, return the good/bad news... */
6428 api_sw_interface_clear_stats (vat_main_t * vam)
6430 unformat_input_t *i = vam->input;
6431 vl_api_sw_interface_clear_stats_t *mp;
6433 u8 sw_if_index_set = 0;
6436 /* Parse args required to build the message */
6437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6439 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6440 sw_if_index_set = 1;
6441 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6442 sw_if_index_set = 1;
6447 /* Construct the API message */
6448 M (SW_INTERFACE_CLEAR_STATS, mp);
6450 if (sw_if_index_set == 1)
6451 mp->sw_if_index = ntohl (sw_if_index);
6453 mp->sw_if_index = ~0;
6458 /* Wait for a reply, return the good/bad news... */
6464 api_sw_interface_add_del_address (vat_main_t * vam)
6466 unformat_input_t *i = vam->input;
6467 vl_api_sw_interface_add_del_address_t *mp;
6469 u8 sw_if_index_set = 0;
6470 u8 is_add = 1, del_all = 0;
6471 u32 address_length = 0;
6472 u8 v4_address_set = 0;
6473 u8 v6_address_set = 0;
6474 ip4_address_t v4address;
6475 ip6_address_t v6address;
6478 /* Parse args required to build the message */
6479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6481 if (unformat (i, "del-all"))
6483 else if (unformat (i, "del"))
6486 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6487 sw_if_index_set = 1;
6488 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6489 sw_if_index_set = 1;
6490 else if (unformat (i, "%U/%d",
6491 unformat_ip4_address, &v4address, &address_length))
6493 else if (unformat (i, "%U/%d",
6494 unformat_ip6_address, &v6address, &address_length))
6500 if (sw_if_index_set == 0)
6502 errmsg ("missing interface name or sw_if_index");
6505 if (v4_address_set && v6_address_set)
6507 errmsg ("both v4 and v6 addresses set");
6510 if (!v4_address_set && !v6_address_set && !del_all)
6512 errmsg ("no addresses set");
6516 /* Construct the API message */
6517 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6519 mp->sw_if_index = ntohl (sw_if_index);
6520 mp->is_add = is_add;
6521 mp->del_all = del_all;
6525 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6529 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6531 mp->address_length = address_length;
6536 /* Wait for a reply, return good/bad news */
6542 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6544 unformat_input_t *i = vam->input;
6545 vl_api_sw_interface_set_mpls_enable_t *mp;
6547 u8 sw_if_index_set = 0;
6551 /* Parse args required to build the message */
6552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6554 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6555 sw_if_index_set = 1;
6556 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6557 sw_if_index_set = 1;
6558 else if (unformat (i, "disable"))
6560 else if (unformat (i, "dis"))
6566 if (sw_if_index_set == 0)
6568 errmsg ("missing interface name or sw_if_index");
6572 /* Construct the API message */
6573 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6575 mp->sw_if_index = ntohl (sw_if_index);
6576 mp->enable = enable;
6581 /* Wait for a reply... */
6587 api_sw_interface_set_table (vat_main_t * vam)
6589 unformat_input_t *i = vam->input;
6590 vl_api_sw_interface_set_table_t *mp;
6591 u32 sw_if_index, vrf_id = 0;
6592 u8 sw_if_index_set = 0;
6596 /* Parse args required to build the message */
6597 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6599 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6600 sw_if_index_set = 1;
6601 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6602 sw_if_index_set = 1;
6603 else if (unformat (i, "vrf %d", &vrf_id))
6605 else if (unformat (i, "ipv6"))
6611 if (sw_if_index_set == 0)
6613 errmsg ("missing interface name or sw_if_index");
6617 /* Construct the API message */
6618 M (SW_INTERFACE_SET_TABLE, mp);
6620 mp->sw_if_index = ntohl (sw_if_index);
6621 mp->is_ipv6 = is_ipv6;
6622 mp->vrf_id = ntohl (vrf_id);
6627 /* Wait for a reply... */
6632 static void vl_api_sw_interface_get_table_reply_t_handler
6633 (vl_api_sw_interface_get_table_reply_t * mp)
6635 vat_main_t *vam = &vat_main;
6637 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6639 vam->retval = ntohl (mp->retval);
6640 vam->result_ready = 1;
6644 static void vl_api_sw_interface_get_table_reply_t_handler_json
6645 (vl_api_sw_interface_get_table_reply_t * mp)
6647 vat_main_t *vam = &vat_main;
6648 vat_json_node_t node;
6650 vat_json_init_object (&node);
6651 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6652 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6654 vat_json_print (vam->ofp, &node);
6655 vat_json_free (&node);
6657 vam->retval = ntohl (mp->retval);
6658 vam->result_ready = 1;
6662 api_sw_interface_get_table (vat_main_t * vam)
6664 unformat_input_t *i = vam->input;
6665 vl_api_sw_interface_get_table_t *mp;
6667 u8 sw_if_index_set = 0;
6671 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6673 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6674 sw_if_index_set = 1;
6675 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6676 sw_if_index_set = 1;
6677 else if (unformat (i, "ipv6"))
6683 if (sw_if_index_set == 0)
6685 errmsg ("missing interface name or sw_if_index");
6689 M (SW_INTERFACE_GET_TABLE, mp);
6690 mp->sw_if_index = htonl (sw_if_index);
6691 mp->is_ipv6 = is_ipv6;
6699 api_sw_interface_set_vpath (vat_main_t * vam)
6701 unformat_input_t *i = vam->input;
6702 vl_api_sw_interface_set_vpath_t *mp;
6703 u32 sw_if_index = 0;
6704 u8 sw_if_index_set = 0;
6708 /* Parse args required to build the message */
6709 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6711 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6712 sw_if_index_set = 1;
6713 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6714 sw_if_index_set = 1;
6715 else if (unformat (i, "enable"))
6717 else if (unformat (i, "disable"))
6723 if (sw_if_index_set == 0)
6725 errmsg ("missing interface name or sw_if_index");
6729 /* Construct the API message */
6730 M (SW_INTERFACE_SET_VPATH, mp);
6732 mp->sw_if_index = ntohl (sw_if_index);
6733 mp->enable = is_enable;
6738 /* Wait for a reply... */
6744 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6746 unformat_input_t *i = vam->input;
6747 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6748 u32 sw_if_index = 0;
6749 u8 sw_if_index_set = 0;
6754 /* Parse args required to build the message */
6755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6757 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6758 sw_if_index_set = 1;
6759 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6760 sw_if_index_set = 1;
6761 else if (unformat (i, "enable"))
6763 else if (unformat (i, "disable"))
6765 else if (unformat (i, "ip4"))
6767 else if (unformat (i, "ip6"))
6773 if (sw_if_index_set == 0)
6775 errmsg ("missing interface name or sw_if_index");
6779 /* Construct the API message */
6780 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6782 mp->sw_if_index = ntohl (sw_if_index);
6783 mp->enable = is_enable;
6784 mp->is_ipv6 = is_ipv6;
6789 /* Wait for a reply... */
6795 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6797 unformat_input_t *i = vam->input;
6798 vl_api_sw_interface_set_geneve_bypass_t *mp;
6799 u32 sw_if_index = 0;
6800 u8 sw_if_index_set = 0;
6805 /* Parse args required to build the message */
6806 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6808 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6809 sw_if_index_set = 1;
6810 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6811 sw_if_index_set = 1;
6812 else if (unformat (i, "enable"))
6814 else if (unformat (i, "disable"))
6816 else if (unformat (i, "ip4"))
6818 else if (unformat (i, "ip6"))
6824 if (sw_if_index_set == 0)
6826 errmsg ("missing interface name or sw_if_index");
6830 /* Construct the API message */
6831 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6833 mp->sw_if_index = ntohl (sw_if_index);
6834 mp->enable = is_enable;
6835 mp->is_ipv6 = is_ipv6;
6840 /* Wait for a reply... */
6846 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6848 unformat_input_t *i = vam->input;
6849 vl_api_sw_interface_set_l2_xconnect_t *mp;
6851 u8 rx_sw_if_index_set = 0;
6853 u8 tx_sw_if_index_set = 0;
6857 /* Parse args required to build the message */
6858 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6860 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6861 rx_sw_if_index_set = 1;
6862 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6863 tx_sw_if_index_set = 1;
6864 else if (unformat (i, "rx"))
6866 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6868 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6870 rx_sw_if_index_set = 1;
6875 else if (unformat (i, "tx"))
6877 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6879 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6881 tx_sw_if_index_set = 1;
6886 else if (unformat (i, "enable"))
6888 else if (unformat (i, "disable"))
6894 if (rx_sw_if_index_set == 0)
6896 errmsg ("missing rx interface name or rx_sw_if_index");
6900 if (enable && (tx_sw_if_index_set == 0))
6902 errmsg ("missing tx interface name or tx_sw_if_index");
6906 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6908 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6909 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6910 mp->enable = enable;
6918 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6920 unformat_input_t *i = vam->input;
6921 vl_api_sw_interface_set_l2_bridge_t *mp;
6923 u8 rx_sw_if_index_set = 0;
6931 /* Parse args required to build the message */
6932 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6934 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6935 rx_sw_if_index_set = 1;
6936 else if (unformat (i, "bd_id %d", &bd_id))
6940 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6941 rx_sw_if_index_set = 1;
6942 else if (unformat (i, "shg %d", &shg))
6944 else if (unformat (i, "bvi"))
6946 else if (unformat (i, "enable"))
6948 else if (unformat (i, "disable"))
6954 if (rx_sw_if_index_set == 0)
6956 errmsg ("missing rx interface name or sw_if_index");
6960 if (enable && (bd_id_set == 0))
6962 errmsg ("missing bridge domain");
6966 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6968 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6969 mp->bd_id = ntohl (bd_id);
6972 mp->enable = enable;
6980 api_bridge_domain_dump (vat_main_t * vam)
6982 unformat_input_t *i = vam->input;
6983 vl_api_bridge_domain_dump_t *mp;
6984 vl_api_control_ping_t *mp_ping;
6988 /* Parse args required to build the message */
6989 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6991 if (unformat (i, "bd_id %d", &bd_id))
6997 M (BRIDGE_DOMAIN_DUMP, mp);
6998 mp->bd_id = ntohl (bd_id);
7001 /* Use a control ping for synchronization */
7002 MPING (CONTROL_PING, mp_ping);
7010 api_bridge_domain_add_del (vat_main_t * vam)
7012 unformat_input_t *i = vam->input;
7013 vl_api_bridge_domain_add_del_t *mp;
7016 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7021 /* Parse args required to build the message */
7022 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7024 if (unformat (i, "bd_id %d", &bd_id))
7026 else if (unformat (i, "flood %d", &flood))
7028 else if (unformat (i, "uu-flood %d", &uu_flood))
7030 else if (unformat (i, "forward %d", &forward))
7032 else if (unformat (i, "learn %d", &learn))
7034 else if (unformat (i, "arp-term %d", &arp_term))
7036 else if (unformat (i, "mac-age %d", &mac_age))
7038 else if (unformat (i, "bd-tag %s", &bd_tag))
7040 else if (unformat (i, "del"))
7043 flood = uu_flood = forward = learn = 0;
7051 errmsg ("missing bridge domain");
7058 errmsg ("mac age must be less than 256 ");
7063 if ((bd_tag) && (strlen ((char *) bd_tag) > 63))
7065 errmsg ("bd-tag cannot be longer than 63");
7070 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7072 mp->bd_id = ntohl (bd_id);
7074 mp->uu_flood = uu_flood;
7075 mp->forward = forward;
7077 mp->arp_term = arp_term;
7078 mp->is_add = is_add;
7079 mp->mac_age = (u8) mac_age;
7081 strcpy ((char *) mp->bd_tag, (char *) bd_tag);
7092 api_l2fib_flush_bd (vat_main_t * vam)
7094 unformat_input_t *i = vam->input;
7095 vl_api_l2fib_flush_bd_t *mp;
7099 /* Parse args required to build the message */
7100 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7102 if (unformat (i, "bd_id %d", &bd_id));
7109 errmsg ("missing bridge domain");
7113 M (L2FIB_FLUSH_BD, mp);
7115 mp->bd_id = htonl (bd_id);
7123 api_l2fib_flush_int (vat_main_t * vam)
7125 unformat_input_t *i = vam->input;
7126 vl_api_l2fib_flush_int_t *mp;
7127 u32 sw_if_index = ~0;
7130 /* Parse args required to build the message */
7131 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7133 if (unformat (i, "sw_if_index %d", &sw_if_index));
7135 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7140 if (sw_if_index == ~0)
7142 errmsg ("missing interface name or sw_if_index");
7146 M (L2FIB_FLUSH_INT, mp);
7148 mp->sw_if_index = ntohl (sw_if_index);
7156 api_l2fib_add_del (vat_main_t * vam)
7158 unformat_input_t *i = vam->input;
7159 vl_api_l2fib_add_del_t *mp;
7165 u32 sw_if_index = ~0;
7166 u8 sw_if_index_set = 0;
7175 /* Parse args required to build the message */
7176 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7178 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7180 else if (unformat (i, "bd_id %d", &bd_id))
7182 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7183 sw_if_index_set = 1;
7184 else if (unformat (i, "sw_if"))
7186 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7189 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7190 sw_if_index_set = 1;
7195 else if (unformat (i, "static"))
7197 else if (unformat (i, "filter"))
7202 else if (unformat (i, "bvi"))
7207 else if (unformat (i, "del"))
7209 else if (unformat (i, "count %d", &count))
7217 errmsg ("missing mac address");
7223 errmsg ("missing bridge domain");
7227 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7229 errmsg ("missing interface name or sw_if_index");
7235 /* Turn on async mode */
7236 vam->async_mode = 1;
7237 vam->async_errors = 0;
7238 before = vat_time_now (vam);
7241 for (j = 0; j < count; j++)
7243 M (L2FIB_ADD_DEL, mp);
7245 clib_memcpy (mp->mac, mac, 6);
7246 mp->bd_id = ntohl (bd_id);
7247 mp->is_add = is_add;
7251 mp->sw_if_index = ntohl (sw_if_index);
7252 mp->static_mac = static_mac;
7253 mp->filter_mac = filter_mac;
7254 mp->bvi_mac = bvi_mac;
7256 increment_mac_address (mac);
7263 vl_api_control_ping_t *mp_ping;
7266 /* Shut off async mode */
7267 vam->async_mode = 0;
7269 MPING (CONTROL_PING, mp_ping);
7272 timeout = vat_time_now (vam) + 1.0;
7273 while (vat_time_now (vam) < timeout)
7274 if (vam->result_ready == 1)
7279 if (vam->retval == -99)
7282 if (vam->async_errors > 0)
7284 errmsg ("%d asynchronous errors", vam->async_errors);
7287 vam->async_errors = 0;
7288 after = vat_time_now (vam);
7290 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7291 count, after - before, count / (after - before));
7297 /* Wait for a reply... */
7301 /* Return the good/bad news */
7302 return (vam->retval);
7306 api_bridge_domain_set_mac_age (vat_main_t * vam)
7308 unformat_input_t *i = vam->input;
7309 vl_api_bridge_domain_set_mac_age_t *mp;
7314 /* Parse args required to build the message */
7315 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7317 if (unformat (i, "bd_id %d", &bd_id));
7318 else if (unformat (i, "mac-age %d", &mac_age));
7325 errmsg ("missing bridge domain");
7331 errmsg ("mac age must be less than 256 ");
7335 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7337 mp->bd_id = htonl (bd_id);
7338 mp->mac_age = (u8) mac_age;
7346 api_l2_flags (vat_main_t * vam)
7348 unformat_input_t *i = vam->input;
7349 vl_api_l2_flags_t *mp;
7352 u8 sw_if_index_set = 0;
7356 /* Parse args required to build the message */
7357 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7359 if (unformat (i, "sw_if_index %d", &sw_if_index))
7360 sw_if_index_set = 1;
7361 else if (unformat (i, "sw_if"))
7363 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7366 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7367 sw_if_index_set = 1;
7372 else if (unformat (i, "learn"))
7374 else if (unformat (i, "forward"))
7376 else if (unformat (i, "flood"))
7378 else if (unformat (i, "uu-flood"))
7379 flags |= L2_UU_FLOOD;
7380 else if (unformat (i, "arp-term"))
7381 flags |= L2_ARP_TERM;
7382 else if (unformat (i, "off"))
7384 else if (unformat (i, "disable"))
7390 if (sw_if_index_set == 0)
7392 errmsg ("missing interface name or sw_if_index");
7398 mp->sw_if_index = ntohl (sw_if_index);
7399 mp->feature_bitmap = ntohl (flags);
7400 mp->is_set = is_set;
7408 api_bridge_flags (vat_main_t * vam)
7410 unformat_input_t *i = vam->input;
7411 vl_api_bridge_flags_t *mp;
7418 /* Parse args required to build the message */
7419 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7421 if (unformat (i, "bd_id %d", &bd_id))
7423 else if (unformat (i, "learn"))
7425 else if (unformat (i, "forward"))
7427 else if (unformat (i, "flood"))
7429 else if (unformat (i, "uu-flood"))
7430 flags |= L2_UU_FLOOD;
7431 else if (unformat (i, "arp-term"))
7432 flags |= L2_ARP_TERM;
7433 else if (unformat (i, "off"))
7435 else if (unformat (i, "disable"))
7443 errmsg ("missing bridge domain");
7447 M (BRIDGE_FLAGS, mp);
7449 mp->bd_id = ntohl (bd_id);
7450 mp->feature_bitmap = ntohl (flags);
7451 mp->is_set = is_set;
7459 api_bd_ip_mac_add_del (vat_main_t * vam)
7461 unformat_input_t *i = vam->input;
7462 vl_api_bd_ip_mac_add_del_t *mp;
7469 ip4_address_t v4addr;
7470 ip6_address_t v6addr;
7475 /* Parse args required to build the message */
7476 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7478 if (unformat (i, "bd_id %d", &bd_id))
7482 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7486 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7491 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7495 else if (unformat (i, "del"))
7503 errmsg ("missing bridge domain");
7506 else if (ip_set == 0)
7508 errmsg ("missing IP address");
7511 else if (mac_set == 0)
7513 errmsg ("missing MAC address");
7517 M (BD_IP_MAC_ADD_DEL, mp);
7519 mp->bd_id = ntohl (bd_id);
7520 mp->is_ipv6 = is_ipv6;
7521 mp->is_add = is_add;
7523 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7525 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7526 clib_memcpy (mp->mac_address, macaddr, 6);
7533 api_tap_connect (vat_main_t * vam)
7535 unformat_input_t *i = vam->input;
7536 vl_api_tap_connect_t *mp;
7542 ip4_address_t ip4_address;
7544 int ip4_address_set = 0;
7545 ip6_address_t ip6_address;
7547 int ip6_address_set = 0;
7550 memset (mac_address, 0, sizeof (mac_address));
7552 /* Parse args required to build the message */
7553 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7555 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7559 else if (unformat (i, "random-mac"))
7561 else if (unformat (i, "tapname %s", &tap_name))
7563 else if (unformat (i, "tag %s", &tag))
7565 else if (unformat (i, "address %U/%d",
7566 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7567 ip4_address_set = 1;
7568 else if (unformat (i, "address %U/%d",
7569 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7570 ip6_address_set = 1;
7577 errmsg ("missing tap name");
7580 if (vec_len (tap_name) > 63)
7582 errmsg ("tap name too long");
7585 vec_add1 (tap_name, 0);
7587 if (vec_len (tag) > 63)
7589 errmsg ("tag too long");
7593 /* Construct the API message */
7594 M (TAP_CONNECT, mp);
7596 mp->use_random_mac = random_mac;
7597 clib_memcpy (mp->mac_address, mac_address, 6);
7598 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7600 clib_memcpy (mp->tag, tag, vec_len (tag));
7602 if (ip4_address_set)
7604 mp->ip4_address_set = 1;
7605 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7606 mp->ip4_mask_width = ip4_mask_width;
7608 if (ip6_address_set)
7610 mp->ip6_address_set = 1;
7611 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7612 mp->ip6_mask_width = ip6_mask_width;
7615 vec_free (tap_name);
7621 /* Wait for a reply... */
7627 api_tap_modify (vat_main_t * vam)
7629 unformat_input_t *i = vam->input;
7630 vl_api_tap_modify_t *mp;
7635 u32 sw_if_index = ~0;
7636 u8 sw_if_index_set = 0;
7639 memset (mac_address, 0, sizeof (mac_address));
7641 /* Parse args required to build the message */
7642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7644 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7645 sw_if_index_set = 1;
7646 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7647 sw_if_index_set = 1;
7648 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7652 else if (unformat (i, "random-mac"))
7654 else if (unformat (i, "tapname %s", &tap_name))
7660 if (sw_if_index_set == 0)
7662 errmsg ("missing vpp interface name");
7667 errmsg ("missing tap name");
7670 if (vec_len (tap_name) > 63)
7672 errmsg ("tap name too long");
7674 vec_add1 (tap_name, 0);
7676 /* Construct the API message */
7679 mp->use_random_mac = random_mac;
7680 mp->sw_if_index = ntohl (sw_if_index);
7681 clib_memcpy (mp->mac_address, mac_address, 6);
7682 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7683 vec_free (tap_name);
7688 /* Wait for a reply... */
7694 api_tap_delete (vat_main_t * vam)
7696 unformat_input_t *i = vam->input;
7697 vl_api_tap_delete_t *mp;
7698 u32 sw_if_index = ~0;
7699 u8 sw_if_index_set = 0;
7702 /* Parse args required to build the message */
7703 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7705 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7706 sw_if_index_set = 1;
7707 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7708 sw_if_index_set = 1;
7713 if (sw_if_index_set == 0)
7715 errmsg ("missing vpp interface name");
7719 /* Construct the API message */
7722 mp->sw_if_index = ntohl (sw_if_index);
7727 /* Wait for a reply... */
7733 api_ip_table_add_del (vat_main_t * vam)
7735 unformat_input_t *i = vam->input;
7736 vl_api_ip_table_add_del_t *mp;
7742 /* Parse args required to build the message */
7743 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7745 if (unformat (i, "ipv6"))
7747 else if (unformat (i, "del"))
7749 else if (unformat (i, "add"))
7751 else if (unformat (i, "table %d", &table_id))
7755 clib_warning ("parse error '%U'", format_unformat_error, i);
7762 errmsg ("missing table-ID");
7766 /* Construct the API message */
7767 M (IP_TABLE_ADD_DEL, mp);
7769 mp->table_id = ntohl (table_id);
7770 mp->is_ipv6 = is_ipv6;
7771 mp->is_add = is_add;
7776 /* Wait for a reply... */
7783 api_ip_add_del_route (vat_main_t * vam)
7785 unformat_input_t *i = vam->input;
7786 vl_api_ip_add_del_route_t *mp;
7787 u32 sw_if_index = ~0, vrf_id = 0;
7789 u8 is_local = 0, is_drop = 0;
7790 u8 is_unreach = 0, is_prohibit = 0;
7791 u8 create_vrf_if_needed = 0;
7793 u32 next_hop_weight = 1;
7794 u8 is_multipath = 0;
7796 u8 address_length_set = 0;
7797 u32 next_hop_table_id = 0;
7798 u32 resolve_attempts = 0;
7799 u32 dst_address_length = 0;
7800 u8 next_hop_set = 0;
7801 ip4_address_t v4_dst_address, v4_next_hop_address;
7802 ip6_address_t v6_dst_address, v6_next_hop_address;
7806 u32 random_add_del = 0;
7807 u32 *random_vector = 0;
7809 u32 random_seed = 0xdeaddabe;
7810 u32 classify_table_index = ~0;
7812 u8 resolve_host = 0, resolve_attached = 0;
7813 mpls_label_t *next_hop_out_label_stack = NULL;
7814 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7815 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7817 /* Parse args required to build the message */
7818 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7820 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7822 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7824 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
7829 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
7834 else if (unformat (i, "/%d", &dst_address_length))
7836 address_length_set = 1;
7839 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
7840 &v4_next_hop_address))
7844 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7845 &v6_next_hop_address))
7849 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7851 else if (unformat (i, "weight %d", &next_hop_weight))
7853 else if (unformat (i, "drop"))
7857 else if (unformat (i, "null-send-unreach"))
7861 else if (unformat (i, "null-send-prohibit"))
7865 else if (unformat (i, "local"))
7869 else if (unformat (i, "classify %d", &classify_table_index))
7873 else if (unformat (i, "del"))
7875 else if (unformat (i, "add"))
7877 else if (unformat (i, "resolve-via-host"))
7879 else if (unformat (i, "resolve-via-attached"))
7880 resolve_attached = 1;
7881 else if (unformat (i, "multipath"))
7883 else if (unformat (i, "vrf %d", &vrf_id))
7885 else if (unformat (i, "create-vrf"))
7886 create_vrf_if_needed = 1;
7887 else if (unformat (i, "count %d", &count))
7889 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7891 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7893 else if (unformat (i, "out-label %d", &next_hop_out_label))
7894 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7895 else if (unformat (i, "via-label %d", &next_hop_via_label))
7897 else if (unformat (i, "random"))
7899 else if (unformat (i, "seed %d", &random_seed))
7903 clib_warning ("parse error '%U'", format_unformat_error, i);
7908 if (!next_hop_set && !is_drop && !is_local &&
7909 !is_classify && !is_unreach && !is_prohibit &&
7910 MPLS_LABEL_INVALID == next_hop_via_label)
7913 ("next hop / local / drop / unreach / prohibit / classify not set");
7917 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7919 errmsg ("next hop and next-hop via label set");
7922 if (address_set == 0)
7924 errmsg ("missing addresses");
7928 if (address_length_set == 0)
7930 errmsg ("missing address length");
7934 /* Generate a pile of unique, random routes */
7937 u32 this_random_address;
7938 random_hash = hash_create (count, sizeof (uword));
7940 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7941 for (j = 0; j <= count; j++)
7945 this_random_address = random_u32 (&random_seed);
7946 this_random_address =
7947 clib_host_to_net_u32 (this_random_address);
7949 while (hash_get (random_hash, this_random_address));
7950 vec_add1 (random_vector, this_random_address);
7951 hash_set (random_hash, this_random_address, 1);
7953 hash_free (random_hash);
7954 v4_dst_address.as_u32 = random_vector[0];
7959 /* Turn on async mode */
7960 vam->async_mode = 1;
7961 vam->async_errors = 0;
7962 before = vat_time_now (vam);
7965 for (j = 0; j < count; j++)
7967 /* Construct the API message */
7968 M2 (IP_ADD_DEL_ROUTE, mp,
7969 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7971 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7972 mp->table_id = ntohl (vrf_id);
7973 mp->create_vrf_if_needed = create_vrf_if_needed;
7975 mp->is_add = is_add;
7976 mp->is_drop = is_drop;
7977 mp->is_unreach = is_unreach;
7978 mp->is_prohibit = is_prohibit;
7979 mp->is_ipv6 = is_ipv6;
7980 mp->is_local = is_local;
7981 mp->is_classify = is_classify;
7982 mp->is_multipath = is_multipath;
7983 mp->is_resolve_host = resolve_host;
7984 mp->is_resolve_attached = resolve_attached;
7985 mp->next_hop_weight = next_hop_weight;
7986 mp->dst_address_length = dst_address_length;
7987 mp->next_hop_table_id = ntohl (next_hop_table_id);
7988 mp->classify_table_index = ntohl (classify_table_index);
7989 mp->next_hop_via_label = ntohl (next_hop_via_label);
7990 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7991 if (0 != mp->next_hop_n_out_labels)
7993 memcpy (mp->next_hop_out_label_stack,
7994 next_hop_out_label_stack,
7995 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7996 vec_free (next_hop_out_label_stack);
8001 clib_memcpy (mp->dst_address, &v6_dst_address,
8002 sizeof (v6_dst_address));
8004 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8005 sizeof (v6_next_hop_address));
8006 increment_v6_address (&v6_dst_address);
8010 clib_memcpy (mp->dst_address, &v4_dst_address,
8011 sizeof (v4_dst_address));
8013 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8014 sizeof (v4_next_hop_address));
8016 v4_dst_address.as_u32 = random_vector[j + 1];
8018 increment_v4_address (&v4_dst_address);
8022 /* If we receive SIGTERM, stop now... */
8027 /* When testing multiple add/del ops, use a control-ping to sync */
8030 vl_api_control_ping_t *mp_ping;
8034 /* Shut off async mode */
8035 vam->async_mode = 0;
8037 MPING (CONTROL_PING, mp_ping);
8040 timeout = vat_time_now (vam) + 1.0;
8041 while (vat_time_now (vam) < timeout)
8042 if (vam->result_ready == 1)
8047 if (vam->retval == -99)
8050 if (vam->async_errors > 0)
8052 errmsg ("%d asynchronous errors", vam->async_errors);
8055 vam->async_errors = 0;
8056 after = vat_time_now (vam);
8058 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8062 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8063 count, after - before, count / (after - before));
8069 /* Wait for a reply... */
8074 /* Return the good/bad news */
8075 return (vam->retval);
8079 api_ip_mroute_add_del (vat_main_t * vam)
8081 unformat_input_t *i = vam->input;
8082 vl_api_ip_mroute_add_del_t *mp;
8083 u32 sw_if_index = ~0, vrf_id = 0;
8086 u8 create_vrf_if_needed = 0;
8089 u32 grp_address_length = 0;
8090 ip4_address_t v4_grp_address, v4_src_address;
8091 ip6_address_t v6_grp_address, v6_src_address;
8092 mfib_itf_flags_t iflags = 0;
8093 mfib_entry_flags_t eflags = 0;
8096 /* Parse args required to build the message */
8097 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8099 if (unformat (i, "sw_if_index %d", &sw_if_index))
8101 else if (unformat (i, "%U %U",
8102 unformat_ip4_address, &v4_src_address,
8103 unformat_ip4_address, &v4_grp_address))
8105 grp_address_length = 64;
8109 else if (unformat (i, "%U %U",
8110 unformat_ip6_address, &v6_src_address,
8111 unformat_ip6_address, &v6_grp_address))
8113 grp_address_length = 256;
8117 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8119 memset (&v4_src_address, 0, sizeof (v4_src_address));
8120 grp_address_length = 32;
8124 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8126 memset (&v6_src_address, 0, sizeof (v6_src_address));
8127 grp_address_length = 128;
8131 else if (unformat (i, "/%d", &grp_address_length))
8133 else if (unformat (i, "local"))
8137 else if (unformat (i, "del"))
8139 else if (unformat (i, "add"))
8141 else if (unformat (i, "vrf %d", &vrf_id))
8143 else if (unformat (i, "create-vrf"))
8144 create_vrf_if_needed = 1;
8145 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8147 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8151 clib_warning ("parse error '%U'", format_unformat_error, i);
8156 if (address_set == 0)
8158 errmsg ("missing addresses\n");
8162 /* Construct the API message */
8163 M (IP_MROUTE_ADD_DEL, mp);
8165 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8166 mp->table_id = ntohl (vrf_id);
8167 mp->create_vrf_if_needed = create_vrf_if_needed;
8169 mp->is_add = is_add;
8170 mp->is_ipv6 = is_ipv6;
8171 mp->is_local = is_local;
8172 mp->itf_flags = ntohl (iflags);
8173 mp->entry_flags = ntohl (eflags);
8174 mp->grp_address_length = grp_address_length;
8175 mp->grp_address_length = ntohs (mp->grp_address_length);
8179 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8180 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8184 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8185 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8191 /* Wait for a reply... */
8197 api_mpls_table_add_del (vat_main_t * vam)
8199 unformat_input_t *i = vam->input;
8200 vl_api_mpls_table_add_del_t *mp;
8205 /* Parse args required to build the message */
8206 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8208 if (unformat (i, "table %d", &table_id))
8210 else if (unformat (i, "del"))
8212 else if (unformat (i, "add"))
8216 clib_warning ("parse error '%U'", format_unformat_error, i);
8223 errmsg ("missing table-ID");
8227 /* Construct the API message */
8228 M (MPLS_TABLE_ADD_DEL, mp);
8230 mp->mt_table_id = ntohl (table_id);
8231 mp->mt_is_add = is_add;
8236 /* Wait for a reply... */
8243 api_mpls_route_add_del (vat_main_t * vam)
8245 unformat_input_t *i = vam->input;
8246 vl_api_mpls_route_add_del_t *mp;
8247 u32 sw_if_index = ~0, table_id = 0;
8248 u8 create_table_if_needed = 0;
8250 u32 next_hop_weight = 1;
8251 u8 is_multipath = 0;
8252 u32 next_hop_table_id = 0;
8253 u8 next_hop_set = 0;
8254 ip4_address_t v4_next_hop_address = {
8257 ip6_address_t v6_next_hop_address = { {0} };
8261 u32 classify_table_index = ~0;
8263 u8 resolve_host = 0, resolve_attached = 0;
8264 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8265 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8266 mpls_label_t *next_hop_out_label_stack = NULL;
8267 mpls_label_t local_label = MPLS_LABEL_INVALID;
8269 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8271 /* Parse args required to build the message */
8272 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8274 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8276 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8278 else if (unformat (i, "%d", &local_label))
8280 else if (unformat (i, "eos"))
8282 else if (unformat (i, "non-eos"))
8284 else if (unformat (i, "via %U", unformat_ip4_address,
8285 &v4_next_hop_address))
8288 next_hop_proto = DPO_PROTO_IP4;
8290 else if (unformat (i, "via %U", unformat_ip6_address,
8291 &v6_next_hop_address))
8294 next_hop_proto = DPO_PROTO_IP6;
8296 else if (unformat (i, "weight %d", &next_hop_weight))
8298 else if (unformat (i, "create-table"))
8299 create_table_if_needed = 1;
8300 else if (unformat (i, "classify %d", &classify_table_index))
8304 else if (unformat (i, "del"))
8306 else if (unformat (i, "add"))
8308 else if (unformat (i, "resolve-via-host"))
8310 else if (unformat (i, "resolve-via-attached"))
8311 resolve_attached = 1;
8312 else if (unformat (i, "multipath"))
8314 else if (unformat (i, "count %d", &count))
8316 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8319 next_hop_proto = DPO_PROTO_IP4;
8321 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8324 next_hop_proto = DPO_PROTO_IP6;
8326 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8328 else if (unformat (i, "via-label %d", &next_hop_via_label))
8330 else if (unformat (i, "out-label %d", &next_hop_out_label))
8331 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8334 clib_warning ("parse error '%U'", format_unformat_error, i);
8339 if (!next_hop_set && !is_classify)
8341 errmsg ("next hop / classify not set");
8345 if (MPLS_LABEL_INVALID == local_label)
8347 errmsg ("missing label");
8353 /* Turn on async mode */
8354 vam->async_mode = 1;
8355 vam->async_errors = 0;
8356 before = vat_time_now (vam);
8359 for (j = 0; j < count; j++)
8361 /* Construct the API message */
8362 M2 (MPLS_ROUTE_ADD_DEL, mp,
8363 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8365 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8366 mp->mr_table_id = ntohl (table_id);
8367 mp->mr_create_table_if_needed = create_table_if_needed;
8369 mp->mr_is_add = is_add;
8370 mp->mr_next_hop_proto = next_hop_proto;
8371 mp->mr_is_classify = is_classify;
8372 mp->mr_is_multipath = is_multipath;
8373 mp->mr_is_resolve_host = resolve_host;
8374 mp->mr_is_resolve_attached = resolve_attached;
8375 mp->mr_next_hop_weight = next_hop_weight;
8376 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8377 mp->mr_classify_table_index = ntohl (classify_table_index);
8378 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8379 mp->mr_label = ntohl (local_label);
8380 mp->mr_eos = is_eos;
8382 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8383 if (0 != mp->mr_next_hop_n_out_labels)
8385 memcpy (mp->mr_next_hop_out_label_stack,
8386 next_hop_out_label_stack,
8387 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8388 vec_free (next_hop_out_label_stack);
8393 if (DPO_PROTO_IP4 == next_hop_proto)
8395 clib_memcpy (mp->mr_next_hop,
8396 &v4_next_hop_address,
8397 sizeof (v4_next_hop_address));
8399 else if (DPO_PROTO_IP6 == next_hop_proto)
8402 clib_memcpy (mp->mr_next_hop,
8403 &v6_next_hop_address,
8404 sizeof (v6_next_hop_address));
8411 /* If we receive SIGTERM, stop now... */
8416 /* When testing multiple add/del ops, use a control-ping to sync */
8419 vl_api_control_ping_t *mp_ping;
8423 /* Shut off async mode */
8424 vam->async_mode = 0;
8426 MPING (CONTROL_PING, mp_ping);
8429 timeout = vat_time_now (vam) + 1.0;
8430 while (vat_time_now (vam) < timeout)
8431 if (vam->result_ready == 1)
8436 if (vam->retval == -99)
8439 if (vam->async_errors > 0)
8441 errmsg ("%d asynchronous errors", vam->async_errors);
8444 vam->async_errors = 0;
8445 after = vat_time_now (vam);
8447 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8451 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8452 count, after - before, count / (after - before));
8458 /* Wait for a reply... */
8463 /* Return the good/bad news */
8464 return (vam->retval);
8468 api_mpls_ip_bind_unbind (vat_main_t * vam)
8470 unformat_input_t *i = vam->input;
8471 vl_api_mpls_ip_bind_unbind_t *mp;
8472 u32 ip_table_id = 0;
8473 u8 create_table_if_needed = 0;
8476 ip4_address_t v4_address;
8477 ip6_address_t v6_address;
8480 mpls_label_t local_label = MPLS_LABEL_INVALID;
8483 /* Parse args required to build the message */
8484 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8486 if (unformat (i, "%U/%d", unformat_ip4_address,
8487 &v4_address, &address_length))
8492 else if (unformat (i, "%U/%d", unformat_ip6_address,
8493 &v6_address, &address_length))
8498 else if (unformat (i, "%d", &local_label))
8500 else if (unformat (i, "create-table"))
8501 create_table_if_needed = 1;
8502 else if (unformat (i, "table-id %d", &ip_table_id))
8504 else if (unformat (i, "unbind"))
8506 else if (unformat (i, "bind"))
8510 clib_warning ("parse error '%U'", format_unformat_error, i);
8517 errmsg ("IP addres not set");
8521 if (MPLS_LABEL_INVALID == local_label)
8523 errmsg ("missing label");
8527 /* Construct the API message */
8528 M (MPLS_IP_BIND_UNBIND, mp);
8530 mp->mb_create_table_if_needed = create_table_if_needed;
8531 mp->mb_is_bind = is_bind;
8532 mp->mb_is_ip4 = is_ip4;
8533 mp->mb_ip_table_id = ntohl (ip_table_id);
8534 mp->mb_mpls_table_id = 0;
8535 mp->mb_label = ntohl (local_label);
8536 mp->mb_address_length = address_length;
8539 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8541 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8546 /* Wait for a reply... */
8552 api_bier_table_add_del (vat_main_t * vam)
8554 unformat_input_t *i = vam->input;
8555 vl_api_bier_table_add_del_t *mp;
8557 u32 set = 0, sub_domain = 0, hdr_len = 3;
8558 mpls_label_t local_label = MPLS_LABEL_INVALID;
8561 /* Parse args required to build the message */
8562 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8564 if (unformat (i, "sub-domain %d", &sub_domain))
8566 else if (unformat (i, "set %d", &set))
8568 else if (unformat (i, "label %d", &local_label))
8570 else if (unformat (i, "hdr-len %d", &hdr_len))
8572 else if (unformat (i, "add"))
8574 else if (unformat (i, "del"))
8578 clib_warning ("parse error '%U'", format_unformat_error, i);
8583 if (MPLS_LABEL_INVALID == local_label)
8585 errmsg ("missing label\n");
8589 /* Construct the API message */
8590 M (BIER_TABLE_ADD_DEL, mp);
8592 mp->bt_is_add = is_add;
8593 mp->bt_label = ntohl (local_label);
8594 mp->bt_tbl_id.bt_set = set;
8595 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8596 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8601 /* Wait for a reply... */
8608 api_bier_route_add_del (vat_main_t * vam)
8610 unformat_input_t *i = vam->input;
8611 vl_api_bier_route_add_del_t *mp;
8613 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8614 ip4_address_t v4_next_hop_address;
8615 ip6_address_t v6_next_hop_address;
8616 u8 next_hop_set = 0;
8617 u8 next_hop_proto_is_ip4 = 1;
8618 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8621 /* Parse args required to build the message */
8622 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8624 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8626 next_hop_proto_is_ip4 = 1;
8629 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8631 next_hop_proto_is_ip4 = 0;
8634 if (unformat (i, "sub-domain %d", &sub_domain))
8636 else if (unformat (i, "set %d", &set))
8638 else if (unformat (i, "hdr-len %d", &hdr_len))
8640 else if (unformat (i, "bp %d", &bp))
8642 else if (unformat (i, "add"))
8644 else if (unformat (i, "del"))
8646 else if (unformat (i, "out-label %d", &next_hop_out_label))
8650 clib_warning ("parse error '%U'", format_unformat_error, i);
8655 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8657 errmsg ("next hop / label set\n");
8662 errmsg ("bit=position not set\n");
8666 /* Construct the API message */
8667 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path3_t));
8669 mp->br_is_add = is_add;
8670 mp->br_tbl_id.bt_set = set;
8671 mp->br_tbl_id.bt_sub_domain = sub_domain;
8672 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
8673 mp->br_bp = ntohs (bp);
8675 mp->br_paths[0].n_labels = 1;
8676 mp->br_paths[0].label_stack[0] = ntohl (next_hop_out_label);
8677 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
8679 if (next_hop_proto_is_ip4)
8681 clib_memcpy (mp->br_paths[0].next_hop,
8682 &v4_next_hop_address, sizeof (v4_next_hop_address));
8686 clib_memcpy (mp->br_paths[0].next_hop,
8687 &v6_next_hop_address, sizeof (v6_next_hop_address));
8693 /* Wait for a reply... */
8700 api_proxy_arp_add_del (vat_main_t * vam)
8702 unformat_input_t *i = vam->input;
8703 vl_api_proxy_arp_add_del_t *mp;
8706 ip4_address_t lo, hi;
8710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8712 if (unformat (i, "vrf %d", &vrf_id))
8714 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
8715 unformat_ip4_address, &hi))
8717 else if (unformat (i, "del"))
8721 clib_warning ("parse error '%U'", format_unformat_error, i);
8728 errmsg ("address range not set");
8732 M (PROXY_ARP_ADD_DEL, mp);
8734 mp->vrf_id = ntohl (vrf_id);
8735 mp->is_add = is_add;
8736 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
8737 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
8745 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8747 unformat_input_t *i = vam->input;
8748 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8751 u8 sw_if_index_set = 0;
8754 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8756 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8757 sw_if_index_set = 1;
8758 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8759 sw_if_index_set = 1;
8760 else if (unformat (i, "enable"))
8762 else if (unformat (i, "disable"))
8766 clib_warning ("parse error '%U'", format_unformat_error, i);
8771 if (sw_if_index_set == 0)
8773 errmsg ("missing interface name or sw_if_index");
8777 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8779 mp->sw_if_index = ntohl (sw_if_index);
8780 mp->enable_disable = enable;
8788 api_mpls_tunnel_add_del (vat_main_t * vam)
8790 unformat_input_t *i = vam->input;
8791 vl_api_mpls_tunnel_add_del_t *mp;
8795 u32 sw_if_index = ~0;
8796 u32 next_hop_sw_if_index = ~0;
8797 u32 next_hop_proto_is_ip4 = 1;
8799 u32 next_hop_table_id = 0;
8800 ip4_address_t v4_next_hop_address = {
8803 ip6_address_t v6_next_hop_address = { {0} };
8804 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
8807 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8809 if (unformat (i, "add"))
8811 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8813 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
8815 else if (unformat (i, "via %U",
8816 unformat_ip4_address, &v4_next_hop_address))
8818 next_hop_proto_is_ip4 = 1;
8820 else if (unformat (i, "via %U",
8821 unformat_ip6_address, &v6_next_hop_address))
8823 next_hop_proto_is_ip4 = 0;
8825 else if (unformat (i, "l2-only"))
8827 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8829 else if (unformat (i, "out-label %d", &next_hop_out_label))
8830 vec_add1 (labels, ntohl (next_hop_out_label));
8833 clib_warning ("parse error '%U'", format_unformat_error, i);
8838 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
8840 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
8841 mp->mt_sw_if_index = ntohl (sw_if_index);
8842 mp->mt_is_add = is_add;
8843 mp->mt_l2_only = l2_only;
8844 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
8845 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
8847 mp->mt_next_hop_n_out_labels = vec_len (labels);
8849 if (0 != mp->mt_next_hop_n_out_labels)
8851 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
8852 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
8856 if (next_hop_proto_is_ip4)
8858 clib_memcpy (mp->mt_next_hop,
8859 &v4_next_hop_address, sizeof (v4_next_hop_address));
8863 clib_memcpy (mp->mt_next_hop,
8864 &v6_next_hop_address, sizeof (v6_next_hop_address));
8873 api_sw_interface_set_unnumbered (vat_main_t * vam)
8875 unformat_input_t *i = vam->input;
8876 vl_api_sw_interface_set_unnumbered_t *mp;
8878 u32 unnum_sw_index = ~0;
8880 u8 sw_if_index_set = 0;
8883 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8885 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8886 sw_if_index_set = 1;
8887 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8888 sw_if_index_set = 1;
8889 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8891 else if (unformat (i, "del"))
8895 clib_warning ("parse error '%U'", format_unformat_error, i);
8900 if (sw_if_index_set == 0)
8902 errmsg ("missing interface name or sw_if_index");
8906 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8908 mp->sw_if_index = ntohl (sw_if_index);
8909 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8910 mp->is_add = is_add;
8918 api_ip_neighbor_add_del (vat_main_t * vam)
8920 unformat_input_t *i = vam->input;
8921 vl_api_ip_neighbor_add_del_t *mp;
8923 u8 sw_if_index_set = 0;
8926 u8 is_no_fib_entry = 0;
8929 u8 v4_address_set = 0;
8930 u8 v6_address_set = 0;
8931 ip4_address_t v4address;
8932 ip6_address_t v6address;
8935 memset (mac_address, 0, sizeof (mac_address));
8937 /* Parse args required to build the message */
8938 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8940 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8944 else if (unformat (i, "del"))
8947 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8948 sw_if_index_set = 1;
8949 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8950 sw_if_index_set = 1;
8951 else if (unformat (i, "is_static"))
8953 else if (unformat (i, "no-fib-entry"))
8954 is_no_fib_entry = 1;
8955 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
8957 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
8961 clib_warning ("parse error '%U'", format_unformat_error, i);
8966 if (sw_if_index_set == 0)
8968 errmsg ("missing interface name or sw_if_index");
8971 if (v4_address_set && v6_address_set)
8973 errmsg ("both v4 and v6 addresses set");
8976 if (!v4_address_set && !v6_address_set)
8978 errmsg ("no address set");
8982 /* Construct the API message */
8983 M (IP_NEIGHBOR_ADD_DEL, mp);
8985 mp->sw_if_index = ntohl (sw_if_index);
8986 mp->is_add = is_add;
8987 mp->is_static = is_static;
8988 mp->is_no_adj_fib = is_no_fib_entry;
8990 clib_memcpy (mp->mac_address, mac_address, 6);
8994 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
8998 /* mp->is_ipv6 = 0; via memset in M macro above */
8999 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9005 /* Wait for a reply, return good/bad news */
9011 api_create_vlan_subif (vat_main_t * vam)
9013 unformat_input_t *i = vam->input;
9014 vl_api_create_vlan_subif_t *mp;
9016 u8 sw_if_index_set = 0;
9021 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9023 if (unformat (i, "sw_if_index %d", &sw_if_index))
9024 sw_if_index_set = 1;
9026 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9027 sw_if_index_set = 1;
9028 else if (unformat (i, "vlan %d", &vlan_id))
9032 clib_warning ("parse error '%U'", format_unformat_error, i);
9037 if (sw_if_index_set == 0)
9039 errmsg ("missing interface name or sw_if_index");
9043 if (vlan_id_set == 0)
9045 errmsg ("missing vlan_id");
9048 M (CREATE_VLAN_SUBIF, mp);
9050 mp->sw_if_index = ntohl (sw_if_index);
9051 mp->vlan_id = ntohl (vlan_id);
9058 #define foreach_create_subif_bit \
9065 _(outer_vlan_id_any) \
9066 _(inner_vlan_id_any)
9069 api_create_subif (vat_main_t * vam)
9071 unformat_input_t *i = vam->input;
9072 vl_api_create_subif_t *mp;
9074 u8 sw_if_index_set = 0;
9081 u32 exact_match = 0;
9082 u32 default_sub = 0;
9083 u32 outer_vlan_id_any = 0;
9084 u32 inner_vlan_id_any = 0;
9086 u16 outer_vlan_id = 0;
9087 u16 inner_vlan_id = 0;
9090 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9092 if (unformat (i, "sw_if_index %d", &sw_if_index))
9093 sw_if_index_set = 1;
9095 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9096 sw_if_index_set = 1;
9097 else if (unformat (i, "sub_id %d", &sub_id))
9099 else if (unformat (i, "outer_vlan_id %d", &tmp))
9100 outer_vlan_id = tmp;
9101 else if (unformat (i, "inner_vlan_id %d", &tmp))
9102 inner_vlan_id = tmp;
9104 #define _(a) else if (unformat (i, #a)) a = 1 ;
9105 foreach_create_subif_bit
9109 clib_warning ("parse error '%U'", format_unformat_error, i);
9114 if (sw_if_index_set == 0)
9116 errmsg ("missing interface name or sw_if_index");
9120 if (sub_id_set == 0)
9122 errmsg ("missing sub_id");
9125 M (CREATE_SUBIF, mp);
9127 mp->sw_if_index = ntohl (sw_if_index);
9128 mp->sub_id = ntohl (sub_id);
9130 #define _(a) mp->a = a;
9131 foreach_create_subif_bit;
9134 mp->outer_vlan_id = ntohs (outer_vlan_id);
9135 mp->inner_vlan_id = ntohs (inner_vlan_id);
9143 api_oam_add_del (vat_main_t * vam)
9145 unformat_input_t *i = vam->input;
9146 vl_api_oam_add_del_t *mp;
9149 ip4_address_t src, dst;
9154 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9156 if (unformat (i, "vrf %d", &vrf_id))
9158 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9160 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9162 else if (unformat (i, "del"))
9166 clib_warning ("parse error '%U'", format_unformat_error, i);
9173 errmsg ("missing src addr");
9179 errmsg ("missing dst addr");
9183 M (OAM_ADD_DEL, mp);
9185 mp->vrf_id = ntohl (vrf_id);
9186 mp->is_add = is_add;
9187 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9188 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9196 api_reset_fib (vat_main_t * vam)
9198 unformat_input_t *i = vam->input;
9199 vl_api_reset_fib_t *mp;
9205 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9207 if (unformat (i, "vrf %d", &vrf_id))
9209 else if (unformat (i, "ipv6"))
9213 clib_warning ("parse error '%U'", format_unformat_error, i);
9218 if (vrf_id_set == 0)
9220 errmsg ("missing vrf id");
9226 mp->vrf_id = ntohl (vrf_id);
9227 mp->is_ipv6 = is_ipv6;
9235 api_dhcp_proxy_config (vat_main_t * vam)
9237 unformat_input_t *i = vam->input;
9238 vl_api_dhcp_proxy_config_t *mp;
9240 u32 server_vrf_id = 0;
9242 u8 v4_address_set = 0;
9243 u8 v6_address_set = 0;
9244 ip4_address_t v4address;
9245 ip6_address_t v6address;
9246 u8 v4_src_address_set = 0;
9247 u8 v6_src_address_set = 0;
9248 ip4_address_t v4srcaddress;
9249 ip6_address_t v6srcaddress;
9252 /* Parse args required to build the message */
9253 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9255 if (unformat (i, "del"))
9257 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9259 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9261 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9263 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9265 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9266 v4_src_address_set = 1;
9267 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9268 v6_src_address_set = 1;
9273 if (v4_address_set && v6_address_set)
9275 errmsg ("both v4 and v6 server addresses set");
9278 if (!v4_address_set && !v6_address_set)
9280 errmsg ("no server addresses set");
9284 if (v4_src_address_set && v6_src_address_set)
9286 errmsg ("both v4 and v6 src addresses set");
9289 if (!v4_src_address_set && !v6_src_address_set)
9291 errmsg ("no src addresses set");
9295 if (!(v4_src_address_set && v4_address_set) &&
9296 !(v6_src_address_set && v6_address_set))
9298 errmsg ("no matching server and src addresses set");
9302 /* Construct the API message */
9303 M (DHCP_PROXY_CONFIG, mp);
9305 mp->is_add = is_add;
9306 mp->rx_vrf_id = ntohl (rx_vrf_id);
9307 mp->server_vrf_id = ntohl (server_vrf_id);
9311 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9312 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9316 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9317 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9323 /* Wait for a reply, return good/bad news */
9328 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9329 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9332 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9334 vat_main_t *vam = &vat_main;
9335 u32 i, count = mp->count;
9336 vl_api_dhcp_server_t *s;
9340 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
9341 ntohl (mp->rx_vrf_id),
9342 format_ip6_address, mp->dhcp_src_address,
9343 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9346 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
9347 ntohl (mp->rx_vrf_id),
9348 format_ip4_address, mp->dhcp_src_address,
9349 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9351 for (i = 0; i < count; i++)
9353 s = &mp->servers[i];
9357 " Server Table-ID %d, Server Address %U",
9358 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9361 " Server Table-ID %d, Server Address %U",
9362 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9366 static void vl_api_dhcp_proxy_details_t_handler_json
9367 (vl_api_dhcp_proxy_details_t * mp)
9369 vat_main_t *vam = &vat_main;
9370 vat_json_node_t *node = NULL;
9371 u32 i, count = mp->count;
9373 struct in6_addr ip6;
9374 vl_api_dhcp_server_t *s;
9376 if (VAT_JSON_ARRAY != vam->json_tree.type)
9378 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9379 vat_json_init_array (&vam->json_tree);
9381 node = vat_json_array_add (&vam->json_tree);
9383 vat_json_init_object (node);
9384 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9385 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9386 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9390 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9391 vat_json_object_add_ip6 (node, "src_address", ip6);
9395 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9396 vat_json_object_add_ip4 (node, "src_address", ip4);
9399 for (i = 0; i < count; i++)
9401 s = &mp->servers[i];
9403 vat_json_object_add_uint (node, "server-table-id",
9404 ntohl (s->server_vrf_id));
9408 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9409 vat_json_object_add_ip4 (node, "src_address", ip4);
9413 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9414 vat_json_object_add_ip6 (node, "server_address", ip6);
9420 api_dhcp_proxy_dump (vat_main_t * vam)
9422 unformat_input_t *i = vam->input;
9423 vl_api_control_ping_t *mp_ping;
9424 vl_api_dhcp_proxy_dump_t *mp;
9428 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9430 if (unformat (i, "ipv6"))
9434 clib_warning ("parse error '%U'", format_unformat_error, i);
9439 M (DHCP_PROXY_DUMP, mp);
9441 mp->is_ip6 = is_ipv6;
9444 /* Use a control ping for synchronization */
9445 MPING (CONTROL_PING, mp_ping);
9453 api_dhcp_proxy_set_vss (vat_main_t * vam)
9455 unformat_input_t *i = vam->input;
9456 vl_api_dhcp_proxy_set_vss_t *mp;
9467 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9469 if (unformat (i, "tbl_id %d", &tbl_id))
9471 if (unformat (i, "fib_id %d", &fib_id))
9473 if (unformat (i, "oui %d", &oui))
9475 else if (unformat (i, "ipv6"))
9477 else if (unformat (i, "del"))
9481 clib_warning ("parse error '%U'", format_unformat_error, i);
9486 if (tbl_id_set == 0)
9488 errmsg ("missing tbl id");
9492 if (fib_id_set == 0)
9494 errmsg ("missing fib id");
9499 errmsg ("missing oui");
9503 M (DHCP_PROXY_SET_VSS, mp);
9504 mp->tbl_id = ntohl (tbl_id);
9505 mp->fib_id = ntohl (fib_id);
9506 mp->oui = ntohl (oui);
9507 mp->is_ipv6 = is_ipv6;
9508 mp->is_add = is_add;
9516 api_dhcp_client_config (vat_main_t * vam)
9518 unformat_input_t *i = vam->input;
9519 vl_api_dhcp_client_config_t *mp;
9521 u8 sw_if_index_set = 0;
9524 u8 disable_event = 0;
9527 /* Parse args required to build the message */
9528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9530 if (unformat (i, "del"))
9533 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9534 sw_if_index_set = 1;
9535 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9536 sw_if_index_set = 1;
9537 else if (unformat (i, "hostname %s", &hostname))
9539 else if (unformat (i, "disable_event"))
9545 if (sw_if_index_set == 0)
9547 errmsg ("missing interface name or sw_if_index");
9551 if (vec_len (hostname) > 63)
9553 errmsg ("hostname too long");
9555 vec_add1 (hostname, 0);
9557 /* Construct the API message */
9558 M (DHCP_CLIENT_CONFIG, mp);
9560 mp->sw_if_index = htonl (sw_if_index);
9561 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
9562 vec_free (hostname);
9563 mp->is_add = is_add;
9564 mp->want_dhcp_event = disable_event ? 0 : 1;
9565 mp->pid = htonl (getpid ());
9570 /* Wait for a reply, return good/bad news */
9576 api_set_ip_flow_hash (vat_main_t * vam)
9578 unformat_input_t *i = vam->input;
9579 vl_api_set_ip_flow_hash_t *mp;
9591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9593 if (unformat (i, "vrf %d", &vrf_id))
9595 else if (unformat (i, "ipv6"))
9597 else if (unformat (i, "src"))
9599 else if (unformat (i, "dst"))
9601 else if (unformat (i, "sport"))
9603 else if (unformat (i, "dport"))
9605 else if (unformat (i, "proto"))
9607 else if (unformat (i, "reverse"))
9612 clib_warning ("parse error '%U'", format_unformat_error, i);
9617 if (vrf_id_set == 0)
9619 errmsg ("missing vrf id");
9623 M (SET_IP_FLOW_HASH, mp);
9629 mp->reverse = reverse;
9630 mp->vrf_id = ntohl (vrf_id);
9631 mp->is_ipv6 = is_ipv6;
9639 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9641 unformat_input_t *i = vam->input;
9642 vl_api_sw_interface_ip6_enable_disable_t *mp;
9644 u8 sw_if_index_set = 0;
9648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9650 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9651 sw_if_index_set = 1;
9652 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9653 sw_if_index_set = 1;
9654 else if (unformat (i, "enable"))
9656 else if (unformat (i, "disable"))
9660 clib_warning ("parse error '%U'", format_unformat_error, i);
9665 if (sw_if_index_set == 0)
9667 errmsg ("missing interface name or sw_if_index");
9671 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9673 mp->sw_if_index = ntohl (sw_if_index);
9674 mp->enable = enable;
9682 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
9684 unformat_input_t *i = vam->input;
9685 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
9687 u8 sw_if_index_set = 0;
9688 u8 v6_address_set = 0;
9689 ip6_address_t v6address;
9692 /* Parse args required to build the message */
9693 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9695 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9696 sw_if_index_set = 1;
9697 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9698 sw_if_index_set = 1;
9699 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9705 if (sw_if_index_set == 0)
9707 errmsg ("missing interface name or sw_if_index");
9710 if (!v6_address_set)
9712 errmsg ("no address set");
9716 /* Construct the API message */
9717 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
9719 mp->sw_if_index = ntohl (sw_if_index);
9720 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9725 /* Wait for a reply, return good/bad news */
9731 api_ip6nd_proxy_add_del (vat_main_t * vam)
9733 unformat_input_t *i = vam->input;
9734 vl_api_ip6nd_proxy_add_del_t *mp;
9735 u32 sw_if_index = ~0;
9736 u8 v6_address_set = 0;
9737 ip6_address_t v6address;
9741 /* Parse args required to build the message */
9742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9744 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9746 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9748 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9750 if (unformat (i, "del"))
9754 clib_warning ("parse error '%U'", format_unformat_error, i);
9759 if (sw_if_index == ~0)
9761 errmsg ("missing interface name or sw_if_index");
9764 if (!v6_address_set)
9766 errmsg ("no address set");
9770 /* Construct the API message */
9771 M (IP6ND_PROXY_ADD_DEL, mp);
9773 mp->is_del = is_del;
9774 mp->sw_if_index = ntohl (sw_if_index);
9775 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9780 /* Wait for a reply, return good/bad news */
9786 api_ip6nd_proxy_dump (vat_main_t * vam)
9788 vl_api_ip6nd_proxy_dump_t *mp;
9789 vl_api_control_ping_t *mp_ping;
9792 M (IP6ND_PROXY_DUMP, mp);
9796 /* Use a control ping for synchronization */
9797 MPING (CONTROL_PING, mp_ping);
9804 static void vl_api_ip6nd_proxy_details_t_handler
9805 (vl_api_ip6nd_proxy_details_t * mp)
9807 vat_main_t *vam = &vat_main;
9809 print (vam->ofp, "host %U sw_if_index %d",
9810 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
9813 static void vl_api_ip6nd_proxy_details_t_handler_json
9814 (vl_api_ip6nd_proxy_details_t * mp)
9816 vat_main_t *vam = &vat_main;
9817 struct in6_addr ip6;
9818 vat_json_node_t *node = NULL;
9820 if (VAT_JSON_ARRAY != vam->json_tree.type)
9822 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9823 vat_json_init_array (&vam->json_tree);
9825 node = vat_json_array_add (&vam->json_tree);
9827 vat_json_init_object (node);
9828 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9830 clib_memcpy (&ip6, mp->address, sizeof (ip6));
9831 vat_json_object_add_ip6 (node, "host", ip6);
9835 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9837 unformat_input_t *i = vam->input;
9838 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9840 u8 sw_if_index_set = 0;
9841 u32 address_length = 0;
9842 u8 v6_address_set = 0;
9843 ip6_address_t v6address;
9845 u8 no_advertise = 0;
9847 u8 no_autoconfig = 0;
9850 u32 val_lifetime = 0;
9851 u32 pref_lifetime = 0;
9854 /* Parse args required to build the message */
9855 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9857 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9858 sw_if_index_set = 1;
9859 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9860 sw_if_index_set = 1;
9861 else if (unformat (i, "%U/%d",
9862 unformat_ip6_address, &v6address, &address_length))
9864 else if (unformat (i, "val_life %d", &val_lifetime))
9866 else if (unformat (i, "pref_life %d", &pref_lifetime))
9868 else if (unformat (i, "def"))
9870 else if (unformat (i, "noadv"))
9872 else if (unformat (i, "offl"))
9874 else if (unformat (i, "noauto"))
9876 else if (unformat (i, "nolink"))
9878 else if (unformat (i, "isno"))
9882 clib_warning ("parse error '%U'", format_unformat_error, i);
9887 if (sw_if_index_set == 0)
9889 errmsg ("missing interface name or sw_if_index");
9892 if (!v6_address_set)
9894 errmsg ("no address set");
9898 /* Construct the API message */
9899 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9901 mp->sw_if_index = ntohl (sw_if_index);
9902 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9903 mp->address_length = address_length;
9904 mp->use_default = use_default;
9905 mp->no_advertise = no_advertise;
9906 mp->off_link = off_link;
9907 mp->no_autoconfig = no_autoconfig;
9908 mp->no_onlink = no_onlink;
9910 mp->val_lifetime = ntohl (val_lifetime);
9911 mp->pref_lifetime = ntohl (pref_lifetime);
9916 /* Wait for a reply, return good/bad news */
9922 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9924 unformat_input_t *i = vam->input;
9925 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9927 u8 sw_if_index_set = 0;
9932 u8 send_unicast = 0;
9935 u8 default_router = 0;
9936 u32 max_interval = 0;
9937 u32 min_interval = 0;
9939 u32 initial_count = 0;
9940 u32 initial_interval = 0;
9944 /* Parse args required to build the message */
9945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9947 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9948 sw_if_index_set = 1;
9949 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9950 sw_if_index_set = 1;
9951 else if (unformat (i, "maxint %d", &max_interval))
9953 else if (unformat (i, "minint %d", &min_interval))
9955 else if (unformat (i, "life %d", &lifetime))
9957 else if (unformat (i, "count %d", &initial_count))
9959 else if (unformat (i, "interval %d", &initial_interval))
9961 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9963 else if (unformat (i, "managed"))
9965 else if (unformat (i, "other"))
9967 else if (unformat (i, "ll"))
9969 else if (unformat (i, "send"))
9971 else if (unformat (i, "cease"))
9973 else if (unformat (i, "isno"))
9975 else if (unformat (i, "def"))
9979 clib_warning ("parse error '%U'", format_unformat_error, i);
9984 if (sw_if_index_set == 0)
9986 errmsg ("missing interface name or sw_if_index");
9990 /* Construct the API message */
9991 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9993 mp->sw_if_index = ntohl (sw_if_index);
9994 mp->max_interval = ntohl (max_interval);
9995 mp->min_interval = ntohl (min_interval);
9996 mp->lifetime = ntohl (lifetime);
9997 mp->initial_count = ntohl (initial_count);
9998 mp->initial_interval = ntohl (initial_interval);
9999 mp->suppress = suppress;
10000 mp->managed = managed;
10002 mp->ll_option = ll_option;
10003 mp->send_unicast = send_unicast;
10006 mp->default_router = default_router;
10011 /* Wait for a reply, return good/bad news */
10017 api_set_arp_neighbor_limit (vat_main_t * vam)
10019 unformat_input_t *i = vam->input;
10020 vl_api_set_arp_neighbor_limit_t *mp;
10026 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10028 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10030 else if (unformat (i, "ipv6"))
10034 clib_warning ("parse error '%U'", format_unformat_error, i);
10039 if (limit_set == 0)
10041 errmsg ("missing limit value");
10045 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10047 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10048 mp->is_ipv6 = is_ipv6;
10056 api_l2_patch_add_del (vat_main_t * vam)
10058 unformat_input_t *i = vam->input;
10059 vl_api_l2_patch_add_del_t *mp;
10060 u32 rx_sw_if_index;
10061 u8 rx_sw_if_index_set = 0;
10062 u32 tx_sw_if_index;
10063 u8 tx_sw_if_index_set = 0;
10067 /* Parse args required to build the message */
10068 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10070 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10071 rx_sw_if_index_set = 1;
10072 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10073 tx_sw_if_index_set = 1;
10074 else if (unformat (i, "rx"))
10076 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10078 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10080 rx_sw_if_index_set = 1;
10085 else if (unformat (i, "tx"))
10087 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10089 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10091 tx_sw_if_index_set = 1;
10096 else if (unformat (i, "del"))
10102 if (rx_sw_if_index_set == 0)
10104 errmsg ("missing rx interface name or rx_sw_if_index");
10108 if (tx_sw_if_index_set == 0)
10110 errmsg ("missing tx interface name or tx_sw_if_index");
10114 M (L2_PATCH_ADD_DEL, mp);
10116 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10117 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10118 mp->is_add = is_add;
10126 u8 localsid_addr[16];
10135 api_sr_localsid_add_del (vat_main_t * vam)
10137 unformat_input_t *i = vam->input;
10138 vl_api_sr_localsid_add_del_t *mp;
10141 ip6_address_t localsid;
10145 u32 fib_table = ~(u32) 0;
10146 ip6_address_t next_hop;
10148 bool nexthop_set = 0;
10152 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10154 if (unformat (i, "del"))
10156 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10157 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
10159 else if (unformat (i, "behavior %u", &behavior));
10160 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10161 else if (unformat (i, "fib-table %u", &fib_table));
10162 else if (unformat (i, "end.psp %u", &behavior));
10167 M (SR_LOCALSID_ADD_DEL, mp);
10169 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
10171 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
10172 mp->behavior = behavior;
10173 mp->sw_if_index = ntohl (sw_if_index);
10174 mp->fib_table = ntohl (fib_table);
10175 mp->end_psp = end_psp;
10176 mp->is_del = is_del;
10184 api_ioam_enable (vat_main_t * vam)
10186 unformat_input_t *input = vam->input;
10187 vl_api_ioam_enable_t *mp;
10189 int has_trace_option = 0;
10190 int has_pot_option = 0;
10191 int has_seqno_option = 0;
10192 int has_analyse_option = 0;
10195 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10197 if (unformat (input, "trace"))
10198 has_trace_option = 1;
10199 else if (unformat (input, "pot"))
10200 has_pot_option = 1;
10201 else if (unformat (input, "seqno"))
10202 has_seqno_option = 1;
10203 else if (unformat (input, "analyse"))
10204 has_analyse_option = 1;
10208 M (IOAM_ENABLE, mp);
10209 mp->id = htons (id);
10210 mp->seqno = has_seqno_option;
10211 mp->analyse = has_analyse_option;
10212 mp->pot_enable = has_pot_option;
10213 mp->trace_enable = has_trace_option;
10222 api_ioam_disable (vat_main_t * vam)
10224 vl_api_ioam_disable_t *mp;
10227 M (IOAM_DISABLE, mp);
10233 #define foreach_tcp_proto_field \
10237 #define foreach_udp_proto_field \
10241 #define foreach_ip4_proto_field \
10253 u16 src_port, dst_port;
10256 #if VPP_API_TEST_BUILTIN == 0
10258 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10260 u8 **maskp = va_arg (*args, u8 **);
10262 u8 found_something = 0;
10265 #define _(a) u8 a=0;
10266 foreach_tcp_proto_field;
10269 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10272 #define _(a) else if (unformat (input, #a)) a=1;
10273 foreach_tcp_proto_field
10279 #define _(a) found_something += a;
10280 foreach_tcp_proto_field;
10283 if (found_something == 0)
10286 vec_validate (mask, sizeof (*tcp) - 1);
10288 tcp = (tcp_header_t *) mask;
10290 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
10291 foreach_tcp_proto_field;
10299 unformat_udp_mask (unformat_input_t * input, va_list * args)
10301 u8 **maskp = va_arg (*args, u8 **);
10303 u8 found_something = 0;
10306 #define _(a) u8 a=0;
10307 foreach_udp_proto_field;
10310 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10313 #define _(a) else if (unformat (input, #a)) a=1;
10314 foreach_udp_proto_field
10320 #define _(a) found_something += a;
10321 foreach_udp_proto_field;
10324 if (found_something == 0)
10327 vec_validate (mask, sizeof (*udp) - 1);
10329 udp = (udp_header_t *) mask;
10331 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
10332 foreach_udp_proto_field;
10340 unformat_l4_mask (unformat_input_t * input, va_list * args)
10342 u8 **maskp = va_arg (*args, u8 **);
10343 u16 src_port = 0, dst_port = 0;
10344 tcpudp_header_t *tcpudp;
10346 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10348 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10350 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10352 else if (unformat (input, "src_port"))
10354 else if (unformat (input, "dst_port"))
10360 if (!src_port && !dst_port)
10364 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10366 tcpudp = (tcpudp_header_t *) mask;
10367 tcpudp->src_port = src_port;
10368 tcpudp->dst_port = dst_port;
10376 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10378 u8 **maskp = va_arg (*args, u8 **);
10380 u8 found_something = 0;
10383 #define _(a) u8 a=0;
10384 foreach_ip4_proto_field;
10390 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10392 if (unformat (input, "version"))
10394 else if (unformat (input, "hdr_length"))
10396 else if (unformat (input, "src"))
10398 else if (unformat (input, "dst"))
10400 else if (unformat (input, "proto"))
10403 #define _(a) else if (unformat (input, #a)) a=1;
10404 foreach_ip4_proto_field
10410 #define _(a) found_something += a;
10411 foreach_ip4_proto_field;
10414 if (found_something == 0)
10417 vec_validate (mask, sizeof (*ip) - 1);
10419 ip = (ip4_header_t *) mask;
10421 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10422 foreach_ip4_proto_field;
10425 ip->ip_version_and_header_length = 0;
10428 ip->ip_version_and_header_length |= 0xF0;
10431 ip->ip_version_and_header_length |= 0x0F;
10437 #define foreach_ip6_proto_field \
10440 _(payload_length) \
10445 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10447 u8 **maskp = va_arg (*args, u8 **);
10449 u8 found_something = 0;
10451 u32 ip_version_traffic_class_and_flow_label;
10453 #define _(a) u8 a=0;
10454 foreach_ip6_proto_field;
10457 u8 traffic_class = 0;
10460 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10462 if (unformat (input, "version"))
10464 else if (unformat (input, "traffic-class"))
10466 else if (unformat (input, "flow-label"))
10468 else if (unformat (input, "src"))
10470 else if (unformat (input, "dst"))
10472 else if (unformat (input, "proto"))
10475 #define _(a) else if (unformat (input, #a)) a=1;
10476 foreach_ip6_proto_field
10482 #define _(a) found_something += a;
10483 foreach_ip6_proto_field;
10486 if (found_something == 0)
10489 vec_validate (mask, sizeof (*ip) - 1);
10491 ip = (ip6_header_t *) mask;
10493 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10494 foreach_ip6_proto_field;
10497 ip_version_traffic_class_and_flow_label = 0;
10500 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10503 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10506 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10508 ip->ip_version_traffic_class_and_flow_label =
10509 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10516 unformat_l3_mask (unformat_input_t * input, va_list * args)
10518 u8 **maskp = va_arg (*args, u8 **);
10520 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10522 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10524 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10533 unformat_l2_mask (unformat_input_t * input, va_list * args)
10535 u8 **maskp = va_arg (*args, u8 **);
10542 u8 ignore_tag1 = 0;
10543 u8 ignore_tag2 = 0;
10550 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10552 if (unformat (input, "src"))
10554 else if (unformat (input, "dst"))
10556 else if (unformat (input, "proto"))
10558 else if (unformat (input, "tag1"))
10560 else if (unformat (input, "tag2"))
10562 else if (unformat (input, "ignore-tag1"))
10564 else if (unformat (input, "ignore-tag2"))
10566 else if (unformat (input, "cos1"))
10568 else if (unformat (input, "cos2"))
10570 else if (unformat (input, "dot1q"))
10572 else if (unformat (input, "dot1ad"))
10577 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10578 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10581 if (tag1 || ignore_tag1 || cos1 || dot1q)
10583 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10586 vec_validate (mask, len - 1);
10589 memset (mask, 0xff, 6);
10592 memset (mask + 6, 0xff, 6);
10594 if (tag2 || dot1ad)
10596 /* inner vlan tag */
10605 mask[21] = mask[20] = 0xff;
10626 mask[16] = mask[17] = 0xff;
10636 mask[12] = mask[13] = 0xff;
10643 unformat_classify_mask (unformat_input_t * input, va_list * args)
10645 u8 **maskp = va_arg (*args, u8 **);
10646 u32 *skipp = va_arg (*args, u32 *);
10647 u32 *matchp = va_arg (*args, u32 *);
10655 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10657 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10659 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10661 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10663 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10677 if (mask || l2 || l3 || l4)
10679 if (l2 || l3 || l4)
10681 /* "With a free Ethernet header in every package" */
10683 vec_validate (l2, 13);
10687 vec_append (mask, l3);
10692 vec_append (mask, l4);
10697 /* Scan forward looking for the first significant mask octet */
10698 for (i = 0; i < vec_len (mask); i++)
10702 /* compute (skip, match) params */
10703 *skipp = i / sizeof (u32x4);
10704 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10706 /* Pad mask to an even multiple of the vector size */
10707 while (vec_len (mask) % sizeof (u32x4))
10708 vec_add1 (mask, 0);
10710 match = vec_len (mask) / sizeof (u32x4);
10712 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10714 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10715 if (*tmp || *(tmp + 1))
10720 clib_warning ("BUG: match 0");
10722 _vec_len (mask) = match * sizeof (u32x4);
10732 #endif /* VPP_API_TEST_BUILTIN */
10734 #define foreach_l2_next \
10736 _(ethernet, ETHERNET_INPUT) \
10737 _(ip4, IP4_INPUT) \
10741 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10743 u32 *miss_next_indexp = va_arg (*args, u32 *);
10744 u32 next_index = 0;
10748 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10752 if (unformat (input, "%d", &tmp))
10761 *miss_next_indexp = next_index;
10765 #define foreach_ip_next \
10768 _(rewrite, REWRITE)
10771 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10773 u32 *miss_next_indexp = va_arg (*args, u32 *);
10774 u32 next_index = 0;
10778 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10782 if (unformat (input, "%d", &tmp))
10791 *miss_next_indexp = next_index;
10795 #define foreach_acl_next \
10799 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10801 u32 *miss_next_indexp = va_arg (*args, u32 *);
10802 u32 next_index = 0;
10806 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10810 if (unformat (input, "permit"))
10815 else if (unformat (input, "%d", &tmp))
10824 *miss_next_indexp = next_index;
10829 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10831 u32 *r = va_arg (*args, u32 *);
10833 if (unformat (input, "conform-color"))
10834 *r = POLICE_CONFORM;
10835 else if (unformat (input, "exceed-color"))
10836 *r = POLICE_EXCEED;
10844 api_classify_add_del_table (vat_main_t * vam)
10846 unformat_input_t *i = vam->input;
10847 vl_api_classify_add_del_table_t *mp;
10854 u32 table_index = ~0;
10855 u32 next_table_index = ~0;
10856 u32 miss_next_index = ~0;
10857 u32 memory_size = 32 << 20;
10859 u32 current_data_flag = 0;
10860 int current_data_offset = 0;
10863 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10865 if (unformat (i, "del"))
10867 else if (unformat (i, "del-chain"))
10872 else if (unformat (i, "buckets %d", &nbuckets))
10874 else if (unformat (i, "memory_size %d", &memory_size))
10876 else if (unformat (i, "skip %d", &skip))
10878 else if (unformat (i, "match %d", &match))
10880 else if (unformat (i, "table %d", &table_index))
10882 else if (unformat (i, "mask %U", unformat_classify_mask,
10883 &mask, &skip, &match))
10885 else if (unformat (i, "next-table %d", &next_table_index))
10887 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10890 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10893 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10896 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10898 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10904 if (is_add && mask == 0)
10906 errmsg ("Mask required");
10910 if (is_add && skip == ~0)
10912 errmsg ("skip count required");
10916 if (is_add && match == ~0)
10918 errmsg ("match count required");
10922 if (!is_add && table_index == ~0)
10924 errmsg ("table index required for delete");
10928 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10930 mp->is_add = is_add;
10931 mp->del_chain = del_chain;
10932 mp->table_index = ntohl (table_index);
10933 mp->nbuckets = ntohl (nbuckets);
10934 mp->memory_size = ntohl (memory_size);
10935 mp->skip_n_vectors = ntohl (skip);
10936 mp->match_n_vectors = ntohl (match);
10937 mp->next_table_index = ntohl (next_table_index);
10938 mp->miss_next_index = ntohl (miss_next_index);
10939 mp->current_data_flag = ntohl (current_data_flag);
10940 mp->current_data_offset = ntohl (current_data_offset);
10941 clib_memcpy (mp->mask, mask, vec_len (mask));
10950 #if VPP_API_TEST_BUILTIN == 0
10952 unformat_l4_match (unformat_input_t * input, va_list * args)
10954 u8 **matchp = va_arg (*args, u8 **);
10956 u8 *proto_header = 0;
10962 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10964 if (unformat (input, "src_port %d", &src_port))
10966 else if (unformat (input, "dst_port %d", &dst_port))
10972 h.src_port = clib_host_to_net_u16 (src_port);
10973 h.dst_port = clib_host_to_net_u16 (dst_port);
10974 vec_validate (proto_header, sizeof (h) - 1);
10975 memcpy (proto_header, &h, sizeof (h));
10977 *matchp = proto_header;
10983 unformat_ip4_match (unformat_input_t * input, va_list * args)
10985 u8 **matchp = va_arg (*args, u8 **);
10990 int hdr_length = 0;
10991 u32 hdr_length_val;
10992 int src = 0, dst = 0;
10993 ip4_address_t src_val, dst_val;
11000 int fragment_id = 0;
11001 u32 fragment_id_val;
11007 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11009 if (unformat (input, "version %d", &version_val))
11011 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11013 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11015 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11017 else if (unformat (input, "proto %d", &proto_val))
11019 else if (unformat (input, "tos %d", &tos_val))
11021 else if (unformat (input, "length %d", &length_val))
11023 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11025 else if (unformat (input, "ttl %d", &ttl_val))
11027 else if (unformat (input, "checksum %d", &checksum_val))
11033 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11034 + ttl + checksum == 0)
11038 * Aligned because we use the real comparison functions
11040 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11042 ip = (ip4_header_t *) match;
11044 /* These are realistically matched in practice */
11046 ip->src_address.as_u32 = src_val.as_u32;
11049 ip->dst_address.as_u32 = dst_val.as_u32;
11052 ip->protocol = proto_val;
11055 /* These are not, but they're included for completeness */
11057 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11060 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11066 ip->length = clib_host_to_net_u16 (length_val);
11072 ip->checksum = clib_host_to_net_u16 (checksum_val);
11079 unformat_ip6_match (unformat_input_t * input, va_list * args)
11081 u8 **matchp = va_arg (*args, u8 **);
11086 u8 traffic_class = 0;
11087 u32 traffic_class_val = 0;
11090 int src = 0, dst = 0;
11091 ip6_address_t src_val, dst_val;
11094 int payload_length = 0;
11095 u32 payload_length_val;
11098 u32 ip_version_traffic_class_and_flow_label;
11100 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11102 if (unformat (input, "version %d", &version_val))
11104 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11106 else if (unformat (input, "flow_label %d", &flow_label_val))
11108 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11110 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11112 else if (unformat (input, "proto %d", &proto_val))
11114 else if (unformat (input, "payload_length %d", &payload_length_val))
11115 payload_length = 1;
11116 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11122 if (version + traffic_class + flow_label + src + dst + proto +
11123 payload_length + hop_limit == 0)
11127 * Aligned because we use the real comparison functions
11129 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11131 ip = (ip6_header_t *) match;
11134 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11137 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11140 ip->protocol = proto_val;
11142 ip_version_traffic_class_and_flow_label = 0;
11145 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11148 ip_version_traffic_class_and_flow_label |=
11149 (traffic_class_val & 0xFF) << 20;
11152 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11154 ip->ip_version_traffic_class_and_flow_label =
11155 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11157 if (payload_length)
11158 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11161 ip->hop_limit = hop_limit_val;
11168 unformat_l3_match (unformat_input_t * input, va_list * args)
11170 u8 **matchp = va_arg (*args, u8 **);
11172 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11174 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11176 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11185 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11187 u8 *tagp = va_arg (*args, u8 *);
11190 if (unformat (input, "%d", &tag))
11192 tagp[0] = (tag >> 8) & 0x0F;
11193 tagp[1] = tag & 0xFF;
11201 unformat_l2_match (unformat_input_t * input, va_list * args)
11203 u8 **matchp = va_arg (*args, u8 **);
11216 u8 ignore_tag1 = 0;
11217 u8 ignore_tag2 = 0;
11223 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11225 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11228 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11230 else if (unformat (input, "proto %U",
11231 unformat_ethernet_type_host_byte_order, &proto_val))
11233 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11235 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11237 else if (unformat (input, "ignore-tag1"))
11239 else if (unformat (input, "ignore-tag2"))
11241 else if (unformat (input, "cos1 %d", &cos1_val))
11243 else if (unformat (input, "cos2 %d", &cos2_val))
11248 if ((src + dst + proto + tag1 + tag2 +
11249 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11252 if (tag1 || ignore_tag1 || cos1)
11254 if (tag2 || ignore_tag2 || cos2)
11257 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11260 clib_memcpy (match, dst_val, 6);
11263 clib_memcpy (match + 6, src_val, 6);
11267 /* inner vlan tag */
11268 match[19] = tag2_val[1];
11269 match[18] = tag2_val[0];
11271 match[18] |= (cos2_val & 0x7) << 5;
11274 match[21] = proto_val & 0xff;
11275 match[20] = proto_val >> 8;
11279 match[15] = tag1_val[1];
11280 match[14] = tag1_val[0];
11283 match[14] |= (cos1_val & 0x7) << 5;
11289 match[15] = tag1_val[1];
11290 match[14] = tag1_val[0];
11293 match[17] = proto_val & 0xff;
11294 match[16] = proto_val >> 8;
11297 match[14] |= (cos1_val & 0x7) << 5;
11303 match[18] |= (cos2_val & 0x7) << 5;
11305 match[14] |= (cos1_val & 0x7) << 5;
11308 match[13] = proto_val & 0xff;
11309 match[12] = proto_val >> 8;
11318 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11320 u8 **matchp = va_arg (*args, u8 **);
11321 u32 skip_n_vectors = va_arg (*args, u32);
11322 u32 match_n_vectors = va_arg (*args, u32);
11329 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11331 if (unformat (input, "hex %U", unformat_hex_string, &match))
11333 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11335 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11337 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11351 if (match || l2 || l3 || l4)
11353 if (l2 || l3 || l4)
11355 /* "Win a free Ethernet header in every packet" */
11357 vec_validate_aligned (l2, 13, sizeof (u32x4));
11361 vec_append_aligned (match, l3, sizeof (u32x4));
11366 vec_append_aligned (match, l4, sizeof (u32x4));
11371 /* Make sure the vector is big enough even if key is all 0's */
11372 vec_validate_aligned
11373 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11376 /* Set size, include skipped vectors */
11377 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11388 api_classify_add_del_session (vat_main_t * vam)
11390 unformat_input_t *i = vam->input;
11391 vl_api_classify_add_del_session_t *mp;
11393 u32 table_index = ~0;
11394 u32 hit_next_index = ~0;
11395 u32 opaque_index = ~0;
11398 u32 skip_n_vectors = 0;
11399 u32 match_n_vectors = 0;
11405 * Warning: you have to supply skip_n and match_n
11406 * because the API client cant simply look at the classify
11410 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11412 if (unformat (i, "del"))
11414 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11417 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11420 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11423 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11425 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11427 else if (unformat (i, "opaque-index %d", &opaque_index))
11429 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11431 else if (unformat (i, "match_n %d", &match_n_vectors))
11433 else if (unformat (i, "match %U", api_unformat_classify_match,
11434 &match, skip_n_vectors, match_n_vectors))
11436 else if (unformat (i, "advance %d", &advance))
11438 else if (unformat (i, "table-index %d", &table_index))
11440 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11442 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11444 else if (unformat (i, "action %d", &action))
11446 else if (unformat (i, "metadata %d", &metadata))
11452 if (table_index == ~0)
11454 errmsg ("Table index required");
11458 if (is_add && match == 0)
11460 errmsg ("Match value required");
11464 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11466 mp->is_add = is_add;
11467 mp->table_index = ntohl (table_index);
11468 mp->hit_next_index = ntohl (hit_next_index);
11469 mp->opaque_index = ntohl (opaque_index);
11470 mp->advance = ntohl (advance);
11471 mp->action = action;
11472 mp->metadata = ntohl (metadata);
11473 clib_memcpy (mp->match, match, vec_len (match));
11482 api_classify_set_interface_ip_table (vat_main_t * vam)
11484 unformat_input_t *i = vam->input;
11485 vl_api_classify_set_interface_ip_table_t *mp;
11487 int sw_if_index_set;
11488 u32 table_index = ~0;
11492 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11494 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11495 sw_if_index_set = 1;
11496 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11497 sw_if_index_set = 1;
11498 else if (unformat (i, "table %d", &table_index))
11502 clib_warning ("parse error '%U'", format_unformat_error, i);
11507 if (sw_if_index_set == 0)
11509 errmsg ("missing interface name or sw_if_index");
11514 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11516 mp->sw_if_index = ntohl (sw_if_index);
11517 mp->table_index = ntohl (table_index);
11518 mp->is_ipv6 = is_ipv6;
11526 api_classify_set_interface_l2_tables (vat_main_t * vam)
11528 unformat_input_t *i = vam->input;
11529 vl_api_classify_set_interface_l2_tables_t *mp;
11531 int sw_if_index_set;
11532 u32 ip4_table_index = ~0;
11533 u32 ip6_table_index = ~0;
11534 u32 other_table_index = ~0;
11538 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11540 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11541 sw_if_index_set = 1;
11542 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11543 sw_if_index_set = 1;
11544 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11546 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11548 else if (unformat (i, "other-table %d", &other_table_index))
11550 else if (unformat (i, "is-input %d", &is_input))
11554 clib_warning ("parse error '%U'", format_unformat_error, i);
11559 if (sw_if_index_set == 0)
11561 errmsg ("missing interface name or sw_if_index");
11566 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11568 mp->sw_if_index = ntohl (sw_if_index);
11569 mp->ip4_table_index = ntohl (ip4_table_index);
11570 mp->ip6_table_index = ntohl (ip6_table_index);
11571 mp->other_table_index = ntohl (other_table_index);
11572 mp->is_input = (u8) is_input;
11580 api_set_ipfix_exporter (vat_main_t * vam)
11582 unformat_input_t *i = vam->input;
11583 vl_api_set_ipfix_exporter_t *mp;
11584 ip4_address_t collector_address;
11585 u8 collector_address_set = 0;
11586 u32 collector_port = ~0;
11587 ip4_address_t src_address;
11588 u8 src_address_set = 0;
11591 u32 template_interval = ~0;
11592 u8 udp_checksum = 0;
11595 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11597 if (unformat (i, "collector_address %U", unformat_ip4_address,
11598 &collector_address))
11599 collector_address_set = 1;
11600 else if (unformat (i, "collector_port %d", &collector_port))
11602 else if (unformat (i, "src_address %U", unformat_ip4_address,
11604 src_address_set = 1;
11605 else if (unformat (i, "vrf_id %d", &vrf_id))
11607 else if (unformat (i, "path_mtu %d", &path_mtu))
11609 else if (unformat (i, "template_interval %d", &template_interval))
11611 else if (unformat (i, "udp_checksum"))
11617 if (collector_address_set == 0)
11619 errmsg ("collector_address required");
11623 if (src_address_set == 0)
11625 errmsg ("src_address required");
11629 M (SET_IPFIX_EXPORTER, mp);
11631 memcpy (mp->collector_address, collector_address.data,
11632 sizeof (collector_address.data));
11633 mp->collector_port = htons ((u16) collector_port);
11634 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11635 mp->vrf_id = htonl (vrf_id);
11636 mp->path_mtu = htonl (path_mtu);
11637 mp->template_interval = htonl (template_interval);
11638 mp->udp_checksum = udp_checksum;
11646 api_set_ipfix_classify_stream (vat_main_t * vam)
11648 unformat_input_t *i = vam->input;
11649 vl_api_set_ipfix_classify_stream_t *mp;
11651 u32 src_port = UDP_DST_PORT_ipfix;
11654 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11656 if (unformat (i, "domain %d", &domain_id))
11658 else if (unformat (i, "src_port %d", &src_port))
11662 errmsg ("unknown input `%U'", format_unformat_error, i);
11667 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11669 mp->domain_id = htonl (domain_id);
11670 mp->src_port = htons ((u16) src_port);
11678 api_ipfix_classify_table_add_del (vat_main_t * vam)
11680 unformat_input_t *i = vam->input;
11681 vl_api_ipfix_classify_table_add_del_t *mp;
11683 u32 classify_table_index = ~0;
11685 u8 transport_protocol = 255;
11688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11690 if (unformat (i, "add"))
11692 else if (unformat (i, "del"))
11694 else if (unformat (i, "table %d", &classify_table_index))
11696 else if (unformat (i, "ip4"))
11698 else if (unformat (i, "ip6"))
11700 else if (unformat (i, "tcp"))
11701 transport_protocol = 6;
11702 else if (unformat (i, "udp"))
11703 transport_protocol = 17;
11706 errmsg ("unknown input `%U'", format_unformat_error, i);
11713 errmsg ("expecting: add|del");
11716 if (classify_table_index == ~0)
11718 errmsg ("classifier table not specified");
11721 if (ip_version == 0)
11723 errmsg ("IP version not specified");
11727 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11729 mp->is_add = is_add;
11730 mp->table_id = htonl (classify_table_index);
11731 mp->ip_version = ip_version;
11732 mp->transport_protocol = transport_protocol;
11740 api_get_node_index (vat_main_t * vam)
11742 unformat_input_t *i = vam->input;
11743 vl_api_get_node_index_t *mp;
11747 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11749 if (unformat (i, "node %s", &name))
11756 errmsg ("node name required");
11759 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11761 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11765 M (GET_NODE_INDEX, mp);
11766 clib_memcpy (mp->node_name, name, vec_len (name));
11775 api_get_next_index (vat_main_t * vam)
11777 unformat_input_t *i = vam->input;
11778 vl_api_get_next_index_t *mp;
11779 u8 *node_name = 0, *next_node_name = 0;
11782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11784 if (unformat (i, "node-name %s", &node_name))
11786 else if (unformat (i, "next-node-name %s", &next_node_name))
11790 if (node_name == 0)
11792 errmsg ("node name required");
11795 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11797 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11801 if (next_node_name == 0)
11803 errmsg ("next node name required");
11806 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11808 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11812 M (GET_NEXT_INDEX, mp);
11813 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11814 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11815 vec_free (node_name);
11816 vec_free (next_node_name);
11824 api_add_node_next (vat_main_t * vam)
11826 unformat_input_t *i = vam->input;
11827 vl_api_add_node_next_t *mp;
11832 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11834 if (unformat (i, "node %s", &name))
11836 else if (unformat (i, "next %s", &next))
11843 errmsg ("node name required");
11846 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11848 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11853 errmsg ("next node required");
11856 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11858 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11862 M (ADD_NODE_NEXT, mp);
11863 clib_memcpy (mp->node_name, name, vec_len (name));
11864 clib_memcpy (mp->next_name, next, vec_len (next));
11874 api_l2tpv3_create_tunnel (vat_main_t * vam)
11876 unformat_input_t *i = vam->input;
11877 ip6_address_t client_address, our_address;
11878 int client_address_set = 0;
11879 int our_address_set = 0;
11880 u32 local_session_id = 0;
11881 u32 remote_session_id = 0;
11882 u64 local_cookie = 0;
11883 u64 remote_cookie = 0;
11884 u8 l2_sublayer_present = 0;
11885 vl_api_l2tpv3_create_tunnel_t *mp;
11888 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11890 if (unformat (i, "client_address %U", unformat_ip6_address,
11892 client_address_set = 1;
11893 else if (unformat (i, "our_address %U", unformat_ip6_address,
11895 our_address_set = 1;
11896 else if (unformat (i, "local_session_id %d", &local_session_id))
11898 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11900 else if (unformat (i, "local_cookie %lld", &local_cookie))
11902 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11904 else if (unformat (i, "l2-sublayer-present"))
11905 l2_sublayer_present = 1;
11910 if (client_address_set == 0)
11912 errmsg ("client_address required");
11916 if (our_address_set == 0)
11918 errmsg ("our_address required");
11922 M (L2TPV3_CREATE_TUNNEL, mp);
11924 clib_memcpy (mp->client_address, client_address.as_u8,
11925 sizeof (mp->client_address));
11927 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11929 mp->local_session_id = ntohl (local_session_id);
11930 mp->remote_session_id = ntohl (remote_session_id);
11931 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11932 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11933 mp->l2_sublayer_present = l2_sublayer_present;
11942 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11944 unformat_input_t *i = vam->input;
11946 u8 sw_if_index_set = 0;
11947 u64 new_local_cookie = 0;
11948 u64 new_remote_cookie = 0;
11949 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11954 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11955 sw_if_index_set = 1;
11956 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11957 sw_if_index_set = 1;
11958 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11960 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11966 if (sw_if_index_set == 0)
11968 errmsg ("missing interface name or sw_if_index");
11972 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11974 mp->sw_if_index = ntohl (sw_if_index);
11975 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11976 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11984 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11986 unformat_input_t *i = vam->input;
11987 vl_api_l2tpv3_interface_enable_disable_t *mp;
11989 u8 sw_if_index_set = 0;
11990 u8 enable_disable = 1;
11993 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11995 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11996 sw_if_index_set = 1;
11997 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11998 sw_if_index_set = 1;
11999 else if (unformat (i, "enable"))
12000 enable_disable = 1;
12001 else if (unformat (i, "disable"))
12002 enable_disable = 0;
12007 if (sw_if_index_set == 0)
12009 errmsg ("missing interface name or sw_if_index");
12013 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12015 mp->sw_if_index = ntohl (sw_if_index);
12016 mp->enable_disable = enable_disable;
12024 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12026 unformat_input_t *i = vam->input;
12027 vl_api_l2tpv3_set_lookup_key_t *mp;
12031 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12033 if (unformat (i, "lookup_v6_src"))
12034 key = L2T_LOOKUP_SRC_ADDRESS;
12035 else if (unformat (i, "lookup_v6_dst"))
12036 key = L2T_LOOKUP_DST_ADDRESS;
12037 else if (unformat (i, "lookup_session_id"))
12038 key = L2T_LOOKUP_SESSION_ID;
12043 if (key == (u8) ~ 0)
12045 errmsg ("l2tp session lookup key unset");
12049 M (L2TPV3_SET_LOOKUP_KEY, mp);
12058 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12059 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12061 vat_main_t *vam = &vat_main;
12063 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12064 format_ip6_address, mp->our_address,
12065 format_ip6_address, mp->client_address,
12066 clib_net_to_host_u32 (mp->sw_if_index));
12069 " local cookies %016llx %016llx remote cookie %016llx",
12070 clib_net_to_host_u64 (mp->local_cookie[0]),
12071 clib_net_to_host_u64 (mp->local_cookie[1]),
12072 clib_net_to_host_u64 (mp->remote_cookie));
12074 print (vam->ofp, " local session-id %d remote session-id %d",
12075 clib_net_to_host_u32 (mp->local_session_id),
12076 clib_net_to_host_u32 (mp->remote_session_id));
12078 print (vam->ofp, " l2 specific sublayer %s\n",
12079 mp->l2_sublayer_present ? "preset" : "absent");
12083 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12084 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12086 vat_main_t *vam = &vat_main;
12087 vat_json_node_t *node = NULL;
12088 struct in6_addr addr;
12090 if (VAT_JSON_ARRAY != vam->json_tree.type)
12092 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12093 vat_json_init_array (&vam->json_tree);
12095 node = vat_json_array_add (&vam->json_tree);
12097 vat_json_init_object (node);
12099 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12100 vat_json_object_add_ip6 (node, "our_address", addr);
12101 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12102 vat_json_object_add_ip6 (node, "client_address", addr);
12104 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12105 vat_json_init_array (lc);
12106 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12107 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12108 vat_json_object_add_uint (node, "remote_cookie",
12109 clib_net_to_host_u64 (mp->remote_cookie));
12111 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12112 vat_json_object_add_uint (node, "local_session_id",
12113 clib_net_to_host_u32 (mp->local_session_id));
12114 vat_json_object_add_uint (node, "remote_session_id",
12115 clib_net_to_host_u32 (mp->remote_session_id));
12116 vat_json_object_add_string_copy (node, "l2_sublayer",
12117 mp->l2_sublayer_present ? (u8 *) "present"
12118 : (u8 *) "absent");
12122 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12124 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12125 vl_api_control_ping_t *mp_ping;
12128 /* Get list of l2tpv3-tunnel interfaces */
12129 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12132 /* Use a control ping for synchronization */
12133 MPING (CONTROL_PING, mp_ping);
12141 static void vl_api_sw_interface_tap_details_t_handler
12142 (vl_api_sw_interface_tap_details_t * mp)
12144 vat_main_t *vam = &vat_main;
12146 print (vam->ofp, "%-16s %d",
12147 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12150 static void vl_api_sw_interface_tap_details_t_handler_json
12151 (vl_api_sw_interface_tap_details_t * mp)
12153 vat_main_t *vam = &vat_main;
12154 vat_json_node_t *node = NULL;
12156 if (VAT_JSON_ARRAY != vam->json_tree.type)
12158 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12159 vat_json_init_array (&vam->json_tree);
12161 node = vat_json_array_add (&vam->json_tree);
12163 vat_json_init_object (node);
12164 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12165 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12169 api_sw_interface_tap_dump (vat_main_t * vam)
12171 vl_api_sw_interface_tap_dump_t *mp;
12172 vl_api_control_ping_t *mp_ping;
12175 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12176 /* Get list of tap interfaces */
12177 M (SW_INTERFACE_TAP_DUMP, mp);
12180 /* Use a control ping for synchronization */
12181 MPING (CONTROL_PING, mp_ping);
12188 static uword unformat_vxlan_decap_next
12189 (unformat_input_t * input, va_list * args)
12191 u32 *result = va_arg (*args, u32 *);
12194 if (unformat (input, "l2"))
12195 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12196 else if (unformat (input, "%d", &tmp))
12204 api_vxlan_add_del_tunnel (vat_main_t * vam)
12206 unformat_input_t *line_input = vam->input;
12207 vl_api_vxlan_add_del_tunnel_t *mp;
12208 ip46_address_t src, dst;
12210 u8 ipv4_set = 0, ipv6_set = 0;
12214 u32 mcast_sw_if_index = ~0;
12215 u32 encap_vrf_id = 0;
12216 u32 decap_next_index = ~0;
12220 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12221 memset (&src, 0, sizeof src);
12222 memset (&dst, 0, sizeof dst);
12224 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12226 if (unformat (line_input, "del"))
12229 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12235 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12241 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12247 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12252 else if (unformat (line_input, "group %U %U",
12253 unformat_ip4_address, &dst.ip4,
12254 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12256 grp_set = dst_set = 1;
12259 else if (unformat (line_input, "group %U",
12260 unformat_ip4_address, &dst.ip4))
12262 grp_set = dst_set = 1;
12265 else if (unformat (line_input, "group %U %U",
12266 unformat_ip6_address, &dst.ip6,
12267 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12269 grp_set = dst_set = 1;
12272 else if (unformat (line_input, "group %U",
12273 unformat_ip6_address, &dst.ip6))
12275 grp_set = dst_set = 1;
12279 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12281 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12283 else if (unformat (line_input, "decap-next %U",
12284 unformat_vxlan_decap_next, &decap_next_index))
12286 else if (unformat (line_input, "vni %d", &vni))
12290 errmsg ("parse error '%U'", format_unformat_error, line_input);
12297 errmsg ("tunnel src address not specified");
12302 errmsg ("tunnel dst address not specified");
12306 if (grp_set && !ip46_address_is_multicast (&dst))
12308 errmsg ("tunnel group address not multicast");
12311 if (grp_set && mcast_sw_if_index == ~0)
12313 errmsg ("tunnel nonexistent multicast device");
12316 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12318 errmsg ("tunnel dst address must be unicast");
12323 if (ipv4_set && ipv6_set)
12325 errmsg ("both IPv4 and IPv6 addresses specified");
12329 if ((vni == 0) || (vni >> 24))
12331 errmsg ("vni not specified or out of range");
12335 M (VXLAN_ADD_DEL_TUNNEL, mp);
12339 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12340 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12344 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12345 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12347 mp->encap_vrf_id = ntohl (encap_vrf_id);
12348 mp->decap_next_index = ntohl (decap_next_index);
12349 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12350 mp->vni = ntohl (vni);
12351 mp->is_add = is_add;
12352 mp->is_ipv6 = ipv6_set;
12359 static void vl_api_vxlan_tunnel_details_t_handler
12360 (vl_api_vxlan_tunnel_details_t * mp)
12362 vat_main_t *vam = &vat_main;
12363 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12364 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12366 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12367 ntohl (mp->sw_if_index),
12368 format_ip46_address, &src, IP46_TYPE_ANY,
12369 format_ip46_address, &dst, IP46_TYPE_ANY,
12370 ntohl (mp->encap_vrf_id),
12371 ntohl (mp->decap_next_index), ntohl (mp->vni),
12372 ntohl (mp->mcast_sw_if_index));
12375 static void vl_api_vxlan_tunnel_details_t_handler_json
12376 (vl_api_vxlan_tunnel_details_t * mp)
12378 vat_main_t *vam = &vat_main;
12379 vat_json_node_t *node = NULL;
12381 if (VAT_JSON_ARRAY != vam->json_tree.type)
12383 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12384 vat_json_init_array (&vam->json_tree);
12386 node = vat_json_array_add (&vam->json_tree);
12388 vat_json_init_object (node);
12389 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12392 struct in6_addr ip6;
12394 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12395 vat_json_object_add_ip6 (node, "src_address", ip6);
12396 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12397 vat_json_object_add_ip6 (node, "dst_address", ip6);
12401 struct in_addr ip4;
12403 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12404 vat_json_object_add_ip4 (node, "src_address", ip4);
12405 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12406 vat_json_object_add_ip4 (node, "dst_address", ip4);
12408 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12409 vat_json_object_add_uint (node, "decap_next_index",
12410 ntohl (mp->decap_next_index));
12411 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12412 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12413 vat_json_object_add_uint (node, "mcast_sw_if_index",
12414 ntohl (mp->mcast_sw_if_index));
12418 api_vxlan_tunnel_dump (vat_main_t * vam)
12420 unformat_input_t *i = vam->input;
12421 vl_api_vxlan_tunnel_dump_t *mp;
12422 vl_api_control_ping_t *mp_ping;
12424 u8 sw_if_index_set = 0;
12427 /* Parse args required to build the message */
12428 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12430 if (unformat (i, "sw_if_index %d", &sw_if_index))
12431 sw_if_index_set = 1;
12436 if (sw_if_index_set == 0)
12441 if (!vam->json_output)
12443 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12444 "sw_if_index", "src_address", "dst_address",
12445 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12448 /* Get list of vxlan-tunnel interfaces */
12449 M (VXLAN_TUNNEL_DUMP, mp);
12451 mp->sw_if_index = htonl (sw_if_index);
12455 /* Use a control ping for synchronization */
12456 MPING (CONTROL_PING, mp_ping);
12463 static uword unformat_geneve_decap_next
12464 (unformat_input_t * input, va_list * args)
12466 u32 *result = va_arg (*args, u32 *);
12469 if (unformat (input, "l2"))
12470 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12471 else if (unformat (input, "%d", &tmp))
12479 api_geneve_add_del_tunnel (vat_main_t * vam)
12481 unformat_input_t *line_input = vam->input;
12482 vl_api_geneve_add_del_tunnel_t *mp;
12483 ip46_address_t src, dst;
12485 u8 ipv4_set = 0, ipv6_set = 0;
12489 u32 mcast_sw_if_index = ~0;
12490 u32 encap_vrf_id = 0;
12491 u32 decap_next_index = ~0;
12495 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12496 memset (&src, 0, sizeof src);
12497 memset (&dst, 0, sizeof dst);
12499 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12501 if (unformat (line_input, "del"))
12504 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12510 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12516 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12522 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12527 else if (unformat (line_input, "group %U %U",
12528 unformat_ip4_address, &dst.ip4,
12529 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12531 grp_set = dst_set = 1;
12534 else if (unformat (line_input, "group %U",
12535 unformat_ip4_address, &dst.ip4))
12537 grp_set = dst_set = 1;
12540 else if (unformat (line_input, "group %U %U",
12541 unformat_ip6_address, &dst.ip6,
12542 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12544 grp_set = dst_set = 1;
12547 else if (unformat (line_input, "group %U",
12548 unformat_ip6_address, &dst.ip6))
12550 grp_set = dst_set = 1;
12554 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12556 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12558 else if (unformat (line_input, "decap-next %U",
12559 unformat_geneve_decap_next, &decap_next_index))
12561 else if (unformat (line_input, "vni %d", &vni))
12565 errmsg ("parse error '%U'", format_unformat_error, line_input);
12572 errmsg ("tunnel src address not specified");
12577 errmsg ("tunnel dst address not specified");
12581 if (grp_set && !ip46_address_is_multicast (&dst))
12583 errmsg ("tunnel group address not multicast");
12586 if (grp_set && mcast_sw_if_index == ~0)
12588 errmsg ("tunnel nonexistent multicast device");
12591 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12593 errmsg ("tunnel dst address must be unicast");
12598 if (ipv4_set && ipv6_set)
12600 errmsg ("both IPv4 and IPv6 addresses specified");
12604 if ((vni == 0) || (vni >> 24))
12606 errmsg ("vni not specified or out of range");
12610 M (GENEVE_ADD_DEL_TUNNEL, mp);
12614 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12615 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12619 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12620 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12622 mp->encap_vrf_id = ntohl (encap_vrf_id);
12623 mp->decap_next_index = ntohl (decap_next_index);
12624 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12625 mp->vni = ntohl (vni);
12626 mp->is_add = is_add;
12627 mp->is_ipv6 = ipv6_set;
12634 static void vl_api_geneve_tunnel_details_t_handler
12635 (vl_api_geneve_tunnel_details_t * mp)
12637 vat_main_t *vam = &vat_main;
12638 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12639 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12641 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12642 ntohl (mp->sw_if_index),
12643 format_ip46_address, &src, IP46_TYPE_ANY,
12644 format_ip46_address, &dst, IP46_TYPE_ANY,
12645 ntohl (mp->encap_vrf_id),
12646 ntohl (mp->decap_next_index), ntohl (mp->vni),
12647 ntohl (mp->mcast_sw_if_index));
12650 static void vl_api_geneve_tunnel_details_t_handler_json
12651 (vl_api_geneve_tunnel_details_t * mp)
12653 vat_main_t *vam = &vat_main;
12654 vat_json_node_t *node = NULL;
12656 if (VAT_JSON_ARRAY != vam->json_tree.type)
12658 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12659 vat_json_init_array (&vam->json_tree);
12661 node = vat_json_array_add (&vam->json_tree);
12663 vat_json_init_object (node);
12664 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12667 struct in6_addr ip6;
12669 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12670 vat_json_object_add_ip6 (node, "src_address", ip6);
12671 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12672 vat_json_object_add_ip6 (node, "dst_address", ip6);
12676 struct in_addr ip4;
12678 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12679 vat_json_object_add_ip4 (node, "src_address", ip4);
12680 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12681 vat_json_object_add_ip4 (node, "dst_address", ip4);
12683 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12684 vat_json_object_add_uint (node, "decap_next_index",
12685 ntohl (mp->decap_next_index));
12686 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12687 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12688 vat_json_object_add_uint (node, "mcast_sw_if_index",
12689 ntohl (mp->mcast_sw_if_index));
12693 api_geneve_tunnel_dump (vat_main_t * vam)
12695 unformat_input_t *i = vam->input;
12696 vl_api_geneve_tunnel_dump_t *mp;
12697 vl_api_control_ping_t *mp_ping;
12699 u8 sw_if_index_set = 0;
12702 /* Parse args required to build the message */
12703 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12705 if (unformat (i, "sw_if_index %d", &sw_if_index))
12706 sw_if_index_set = 1;
12711 if (sw_if_index_set == 0)
12716 if (!vam->json_output)
12718 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12719 "sw_if_index", "local_address", "remote_address",
12720 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12723 /* Get list of geneve-tunnel interfaces */
12724 M (GENEVE_TUNNEL_DUMP, mp);
12726 mp->sw_if_index = htonl (sw_if_index);
12730 /* Use a control ping for synchronization */
12731 M (CONTROL_PING, mp_ping);
12739 api_gre_add_del_tunnel (vat_main_t * vam)
12741 unformat_input_t *line_input = vam->input;
12742 vl_api_gre_add_del_tunnel_t *mp;
12743 ip4_address_t src4, dst4;
12744 ip6_address_t src6, dst6;
12751 u32 outer_fib_id = 0;
12754 memset (&src4, 0, sizeof src4);
12755 memset (&dst4, 0, sizeof dst4);
12756 memset (&src6, 0, sizeof src6);
12757 memset (&dst6, 0, sizeof dst6);
12759 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12761 if (unformat (line_input, "del"))
12763 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
12768 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
12773 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
12778 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
12783 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12785 else if (unformat (line_input, "teb"))
12789 errmsg ("parse error '%U'", format_unformat_error, line_input);
12796 errmsg ("tunnel src address not specified");
12801 errmsg ("tunnel dst address not specified");
12804 if (ipv4_set && ipv6_set)
12806 errmsg ("both IPv4 and IPv6 addresses specified");
12811 M (GRE_ADD_DEL_TUNNEL, mp);
12815 clib_memcpy (&mp->src_address, &src4, 4);
12816 clib_memcpy (&mp->dst_address, &dst4, 4);
12820 clib_memcpy (&mp->src_address, &src6, 16);
12821 clib_memcpy (&mp->dst_address, &dst6, 16);
12823 mp->outer_fib_id = ntohl (outer_fib_id);
12824 mp->is_add = is_add;
12826 mp->is_ipv6 = ipv6_set;
12833 static void vl_api_gre_tunnel_details_t_handler
12834 (vl_api_gre_tunnel_details_t * mp)
12836 vat_main_t *vam = &vat_main;
12837 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
12838 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
12840 print (vam->ofp, "%11d%24U%24U%6d%14d",
12841 ntohl (mp->sw_if_index),
12842 format_ip46_address, &src, IP46_TYPE_ANY,
12843 format_ip46_address, &dst, IP46_TYPE_ANY,
12844 mp->teb, ntohl (mp->outer_fib_id));
12847 static void vl_api_gre_tunnel_details_t_handler_json
12848 (vl_api_gre_tunnel_details_t * mp)
12850 vat_main_t *vam = &vat_main;
12851 vat_json_node_t *node = NULL;
12852 struct in_addr ip4;
12853 struct in6_addr ip6;
12855 if (VAT_JSON_ARRAY != vam->json_tree.type)
12857 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12858 vat_json_init_array (&vam->json_tree);
12860 node = vat_json_array_add (&vam->json_tree);
12862 vat_json_init_object (node);
12863 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12866 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
12867 vat_json_object_add_ip4 (node, "src_address", ip4);
12868 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
12869 vat_json_object_add_ip4 (node, "dst_address", ip4);
12873 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
12874 vat_json_object_add_ip6 (node, "src_address", ip6);
12875 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
12876 vat_json_object_add_ip6 (node, "dst_address", ip6);
12878 vat_json_object_add_uint (node, "teb", mp->teb);
12879 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
12880 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
12884 api_gre_tunnel_dump (vat_main_t * vam)
12886 unformat_input_t *i = vam->input;
12887 vl_api_gre_tunnel_dump_t *mp;
12888 vl_api_control_ping_t *mp_ping;
12890 u8 sw_if_index_set = 0;
12893 /* Parse args required to build the message */
12894 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12896 if (unformat (i, "sw_if_index %d", &sw_if_index))
12897 sw_if_index_set = 1;
12902 if (sw_if_index_set == 0)
12907 if (!vam->json_output)
12909 print (vam->ofp, "%11s%24s%24s%6s%14s",
12910 "sw_if_index", "src_address", "dst_address", "teb",
12914 /* Get list of gre-tunnel interfaces */
12915 M (GRE_TUNNEL_DUMP, mp);
12917 mp->sw_if_index = htonl (sw_if_index);
12921 /* Use a control ping for synchronization */
12922 MPING (CONTROL_PING, mp_ping);
12930 api_l2_fib_clear_table (vat_main_t * vam)
12932 // unformat_input_t * i = vam->input;
12933 vl_api_l2_fib_clear_table_t *mp;
12936 M (L2_FIB_CLEAR_TABLE, mp);
12944 api_l2_interface_efp_filter (vat_main_t * vam)
12946 unformat_input_t *i = vam->input;
12947 vl_api_l2_interface_efp_filter_t *mp;
12950 u8 sw_if_index_set = 0;
12953 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12955 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12956 sw_if_index_set = 1;
12957 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12958 sw_if_index_set = 1;
12959 else if (unformat (i, "enable"))
12961 else if (unformat (i, "disable"))
12965 clib_warning ("parse error '%U'", format_unformat_error, i);
12970 if (sw_if_index_set == 0)
12972 errmsg ("missing sw_if_index");
12976 M (L2_INTERFACE_EFP_FILTER, mp);
12978 mp->sw_if_index = ntohl (sw_if_index);
12979 mp->enable_disable = enable;
12986 #define foreach_vtr_op \
12987 _("disable", L2_VTR_DISABLED) \
12988 _("push-1", L2_VTR_PUSH_1) \
12989 _("push-2", L2_VTR_PUSH_2) \
12990 _("pop-1", L2_VTR_POP_1) \
12991 _("pop-2", L2_VTR_POP_2) \
12992 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12993 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12994 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12995 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12998 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13000 unformat_input_t *i = vam->input;
13001 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13003 u8 sw_if_index_set = 0;
13006 u32 push_dot1q = 1;
13011 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13013 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13014 sw_if_index_set = 1;
13015 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13016 sw_if_index_set = 1;
13017 else if (unformat (i, "vtr_op %d", &vtr_op))
13019 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13022 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13024 else if (unformat (i, "tag1 %d", &tag1))
13026 else if (unformat (i, "tag2 %d", &tag2))
13030 clib_warning ("parse error '%U'", format_unformat_error, i);
13035 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13037 errmsg ("missing vtr operation or sw_if_index");
13041 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13042 mp->sw_if_index = ntohl (sw_if_index);
13043 mp->vtr_op = ntohl (vtr_op);
13044 mp->push_dot1q = ntohl (push_dot1q);
13045 mp->tag1 = ntohl (tag1);
13046 mp->tag2 = ntohl (tag2);
13054 api_create_vhost_user_if (vat_main_t * vam)
13056 unformat_input_t *i = vam->input;
13057 vl_api_create_vhost_user_if_t *mp;
13060 u8 file_name_set = 0;
13061 u32 custom_dev_instance = ~0;
13063 u8 use_custom_mac = 0;
13067 /* Shut up coverity */
13068 memset (hwaddr, 0, sizeof (hwaddr));
13070 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13072 if (unformat (i, "socket %s", &file_name))
13076 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13078 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13079 use_custom_mac = 1;
13080 else if (unformat (i, "server"))
13082 else if (unformat (i, "tag %s", &tag))
13088 if (file_name_set == 0)
13090 errmsg ("missing socket file name");
13094 if (vec_len (file_name) > 255)
13096 errmsg ("socket file name too long");
13099 vec_add1 (file_name, 0);
13101 M (CREATE_VHOST_USER_IF, mp);
13103 mp->is_server = is_server;
13104 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13105 vec_free (file_name);
13106 if (custom_dev_instance != ~0)
13109 mp->custom_dev_instance = ntohl (custom_dev_instance);
13111 mp->use_custom_mac = use_custom_mac;
13112 clib_memcpy (mp->mac_address, hwaddr, 6);
13114 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13123 api_modify_vhost_user_if (vat_main_t * vam)
13125 unformat_input_t *i = vam->input;
13126 vl_api_modify_vhost_user_if_t *mp;
13129 u8 file_name_set = 0;
13130 u32 custom_dev_instance = ~0;
13131 u8 sw_if_index_set = 0;
13132 u32 sw_if_index = (u32) ~ 0;
13135 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13137 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13138 sw_if_index_set = 1;
13139 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13140 sw_if_index_set = 1;
13141 else if (unformat (i, "socket %s", &file_name))
13145 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13147 else if (unformat (i, "server"))
13153 if (sw_if_index_set == 0)
13155 errmsg ("missing sw_if_index or interface name");
13159 if (file_name_set == 0)
13161 errmsg ("missing socket file name");
13165 if (vec_len (file_name) > 255)
13167 errmsg ("socket file name too long");
13170 vec_add1 (file_name, 0);
13172 M (MODIFY_VHOST_USER_IF, mp);
13174 mp->sw_if_index = ntohl (sw_if_index);
13175 mp->is_server = is_server;
13176 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13177 vec_free (file_name);
13178 if (custom_dev_instance != ~0)
13181 mp->custom_dev_instance = ntohl (custom_dev_instance);
13190 api_delete_vhost_user_if (vat_main_t * vam)
13192 unformat_input_t *i = vam->input;
13193 vl_api_delete_vhost_user_if_t *mp;
13194 u32 sw_if_index = ~0;
13195 u8 sw_if_index_set = 0;
13198 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13200 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13201 sw_if_index_set = 1;
13202 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13203 sw_if_index_set = 1;
13208 if (sw_if_index_set == 0)
13210 errmsg ("missing sw_if_index or interface name");
13215 M (DELETE_VHOST_USER_IF, mp);
13217 mp->sw_if_index = ntohl (sw_if_index);
13224 static void vl_api_sw_interface_vhost_user_details_t_handler
13225 (vl_api_sw_interface_vhost_user_details_t * mp)
13227 vat_main_t *vam = &vat_main;
13229 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13230 (char *) mp->interface_name,
13231 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13232 clib_net_to_host_u64 (mp->features), mp->is_server,
13233 ntohl (mp->num_regions), (char *) mp->sock_filename);
13234 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13237 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13238 (vl_api_sw_interface_vhost_user_details_t * mp)
13240 vat_main_t *vam = &vat_main;
13241 vat_json_node_t *node = NULL;
13243 if (VAT_JSON_ARRAY != vam->json_tree.type)
13245 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13246 vat_json_init_array (&vam->json_tree);
13248 node = vat_json_array_add (&vam->json_tree);
13250 vat_json_init_object (node);
13251 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13252 vat_json_object_add_string_copy (node, "interface_name",
13253 mp->interface_name);
13254 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13255 ntohl (mp->virtio_net_hdr_sz));
13256 vat_json_object_add_uint (node, "features",
13257 clib_net_to_host_u64 (mp->features));
13258 vat_json_object_add_uint (node, "is_server", mp->is_server);
13259 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13260 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13261 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13265 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13267 vl_api_sw_interface_vhost_user_dump_t *mp;
13268 vl_api_control_ping_t *mp_ping;
13271 "Interface name idx hdr_sz features server regions filename");
13273 /* Get list of vhost-user interfaces */
13274 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13277 /* Use a control ping for synchronization */
13278 MPING (CONTROL_PING, mp_ping);
13286 api_show_version (vat_main_t * vam)
13288 vl_api_show_version_t *mp;
13291 M (SHOW_VERSION, mp);
13300 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13302 unformat_input_t *line_input = vam->input;
13303 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13304 ip4_address_t local4, remote4;
13305 ip6_address_t local6, remote6;
13307 u8 ipv4_set = 0, ipv6_set = 0;
13311 u32 mcast_sw_if_index = ~0;
13312 u32 encap_vrf_id = 0;
13313 u32 decap_vrf_id = 0;
13319 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13320 memset (&local4, 0, sizeof local4);
13321 memset (&remote4, 0, sizeof remote4);
13322 memset (&local6, 0, sizeof local6);
13323 memset (&remote6, 0, sizeof remote6);
13325 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13327 if (unformat (line_input, "del"))
13329 else if (unformat (line_input, "local %U",
13330 unformat_ip4_address, &local4))
13335 else if (unformat (line_input, "remote %U",
13336 unformat_ip4_address, &remote4))
13341 else if (unformat (line_input, "local %U",
13342 unformat_ip6_address, &local6))
13347 else if (unformat (line_input, "remote %U",
13348 unformat_ip6_address, &remote6))
13353 else if (unformat (line_input, "group %U %U",
13354 unformat_ip4_address, &remote4,
13355 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13357 grp_set = remote_set = 1;
13360 else if (unformat (line_input, "group %U",
13361 unformat_ip4_address, &remote4))
13363 grp_set = remote_set = 1;
13366 else if (unformat (line_input, "group %U %U",
13367 unformat_ip6_address, &remote6,
13368 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13370 grp_set = remote_set = 1;
13373 else if (unformat (line_input, "group %U",
13374 unformat_ip6_address, &remote6))
13376 grp_set = remote_set = 1;
13380 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13382 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13384 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13386 else if (unformat (line_input, "vni %d", &vni))
13388 else if (unformat (line_input, "next-ip4"))
13390 else if (unformat (line_input, "next-ip6"))
13392 else if (unformat (line_input, "next-ethernet"))
13394 else if (unformat (line_input, "next-nsh"))
13398 errmsg ("parse error '%U'", format_unformat_error, line_input);
13403 if (local_set == 0)
13405 errmsg ("tunnel local address not specified");
13408 if (remote_set == 0)
13410 errmsg ("tunnel remote address not specified");
13413 if (grp_set && mcast_sw_if_index == ~0)
13415 errmsg ("tunnel nonexistent multicast device");
13418 if (ipv4_set && ipv6_set)
13420 errmsg ("both IPv4 and IPv6 addresses specified");
13426 errmsg ("vni not specified");
13430 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13435 clib_memcpy (&mp->local, &local6, sizeof (local6));
13436 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13440 clib_memcpy (&mp->local, &local4, sizeof (local4));
13441 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13444 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13445 mp->encap_vrf_id = ntohl (encap_vrf_id);
13446 mp->decap_vrf_id = ntohl (decap_vrf_id);
13447 mp->protocol = protocol;
13448 mp->vni = ntohl (vni);
13449 mp->is_add = is_add;
13450 mp->is_ipv6 = ipv6_set;
13457 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13458 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13460 vat_main_t *vam = &vat_main;
13461 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13462 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13464 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13465 ntohl (mp->sw_if_index),
13466 format_ip46_address, &local, IP46_TYPE_ANY,
13467 format_ip46_address, &remote, IP46_TYPE_ANY,
13468 ntohl (mp->vni), mp->protocol,
13469 ntohl (mp->mcast_sw_if_index),
13470 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13474 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13475 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13477 vat_main_t *vam = &vat_main;
13478 vat_json_node_t *node = NULL;
13479 struct in_addr ip4;
13480 struct in6_addr ip6;
13482 if (VAT_JSON_ARRAY != vam->json_tree.type)
13484 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13485 vat_json_init_array (&vam->json_tree);
13487 node = vat_json_array_add (&vam->json_tree);
13489 vat_json_init_object (node);
13490 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13493 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13494 vat_json_object_add_ip6 (node, "local", ip6);
13495 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13496 vat_json_object_add_ip6 (node, "remote", ip6);
13500 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13501 vat_json_object_add_ip4 (node, "local", ip4);
13502 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13503 vat_json_object_add_ip4 (node, "remote", ip4);
13505 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13506 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13507 vat_json_object_add_uint (node, "mcast_sw_if_index",
13508 ntohl (mp->mcast_sw_if_index));
13509 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13510 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13511 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13515 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13517 unformat_input_t *i = vam->input;
13518 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13519 vl_api_control_ping_t *mp_ping;
13521 u8 sw_if_index_set = 0;
13524 /* Parse args required to build the message */
13525 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13527 if (unformat (i, "sw_if_index %d", &sw_if_index))
13528 sw_if_index_set = 1;
13533 if (sw_if_index_set == 0)
13538 if (!vam->json_output)
13540 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13541 "sw_if_index", "local", "remote", "vni",
13542 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13545 /* Get list of vxlan-tunnel interfaces */
13546 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13548 mp->sw_if_index = htonl (sw_if_index);
13552 /* Use a control ping for synchronization */
13553 MPING (CONTROL_PING, mp_ping);
13560 static void vl_api_l2_fib_table_details_t_handler
13561 (vl_api_l2_fib_table_details_t * mp)
13563 vat_main_t *vam = &vat_main;
13565 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13567 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
13568 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13572 static void vl_api_l2_fib_table_details_t_handler_json
13573 (vl_api_l2_fib_table_details_t * mp)
13575 vat_main_t *vam = &vat_main;
13576 vat_json_node_t *node = NULL;
13578 if (VAT_JSON_ARRAY != vam->json_tree.type)
13580 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13581 vat_json_init_array (&vam->json_tree);
13583 node = vat_json_array_add (&vam->json_tree);
13585 vat_json_init_object (node);
13586 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13587 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
13588 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13589 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13590 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13591 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13595 api_l2_fib_table_dump (vat_main_t * vam)
13597 unformat_input_t *i = vam->input;
13598 vl_api_l2_fib_table_dump_t *mp;
13599 vl_api_control_ping_t *mp_ping;
13604 /* Parse args required to build the message */
13605 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13607 if (unformat (i, "bd_id %d", &bd_id))
13613 if (bd_id_set == 0)
13615 errmsg ("missing bridge domain");
13619 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13621 /* Get list of l2 fib entries */
13622 M (L2_FIB_TABLE_DUMP, mp);
13624 mp->bd_id = ntohl (bd_id);
13627 /* Use a control ping for synchronization */
13628 MPING (CONTROL_PING, mp_ping);
13637 api_interface_name_renumber (vat_main_t * vam)
13639 unformat_input_t *line_input = vam->input;
13640 vl_api_interface_name_renumber_t *mp;
13641 u32 sw_if_index = ~0;
13642 u32 new_show_dev_instance = ~0;
13645 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13647 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13650 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13652 else if (unformat (line_input, "new_show_dev_instance %d",
13653 &new_show_dev_instance))
13659 if (sw_if_index == ~0)
13661 errmsg ("missing interface name or sw_if_index");
13665 if (new_show_dev_instance == ~0)
13667 errmsg ("missing new_show_dev_instance");
13671 M (INTERFACE_NAME_RENUMBER, mp);
13673 mp->sw_if_index = ntohl (sw_if_index);
13674 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13682 api_want_ip4_arp_events (vat_main_t * vam)
13684 unformat_input_t *line_input = vam->input;
13685 vl_api_want_ip4_arp_events_t *mp;
13686 ip4_address_t address;
13687 int address_set = 0;
13688 u32 enable_disable = 1;
13691 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13693 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
13695 else if (unformat (line_input, "del"))
13696 enable_disable = 0;
13701 if (address_set == 0)
13703 errmsg ("missing addresses");
13707 M (WANT_IP4_ARP_EVENTS, mp);
13708 mp->enable_disable = enable_disable;
13709 mp->pid = htonl (getpid ());
13710 mp->address = address.as_u32;
13718 api_want_ip6_nd_events (vat_main_t * vam)
13720 unformat_input_t *line_input = vam->input;
13721 vl_api_want_ip6_nd_events_t *mp;
13722 ip6_address_t address;
13723 int address_set = 0;
13724 u32 enable_disable = 1;
13727 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13729 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
13731 else if (unformat (line_input, "del"))
13732 enable_disable = 0;
13737 if (address_set == 0)
13739 errmsg ("missing addresses");
13743 M (WANT_IP6_ND_EVENTS, mp);
13744 mp->enable_disable = enable_disable;
13745 mp->pid = htonl (getpid ());
13746 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
13754 api_want_l2_macs_events (vat_main_t * vam)
13756 unformat_input_t *line_input = vam->input;
13757 vl_api_want_l2_macs_events_t *mp;
13758 u8 enable_disable = 1;
13759 u32 scan_delay = 0;
13760 u32 max_macs_in_event = 0;
13761 u32 learn_limit = 0;
13764 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13766 if (unformat (line_input, "learn-limit %d", &learn_limit))
13768 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13770 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13772 else if (unformat (line_input, "disable"))
13773 enable_disable = 0;
13778 M (WANT_L2_MACS_EVENTS, mp);
13779 mp->enable_disable = enable_disable;
13780 mp->pid = htonl (getpid ());
13781 mp->learn_limit = htonl (learn_limit);
13782 mp->scan_delay = (u8) scan_delay;
13783 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13790 api_input_acl_set_interface (vat_main_t * vam)
13792 unformat_input_t *i = vam->input;
13793 vl_api_input_acl_set_interface_t *mp;
13795 int sw_if_index_set;
13796 u32 ip4_table_index = ~0;
13797 u32 ip6_table_index = ~0;
13798 u32 l2_table_index = ~0;
13802 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13804 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13805 sw_if_index_set = 1;
13806 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13807 sw_if_index_set = 1;
13808 else if (unformat (i, "del"))
13810 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13812 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13814 else if (unformat (i, "l2-table %d", &l2_table_index))
13818 clib_warning ("parse error '%U'", format_unformat_error, i);
13823 if (sw_if_index_set == 0)
13825 errmsg ("missing interface name or sw_if_index");
13829 M (INPUT_ACL_SET_INTERFACE, mp);
13831 mp->sw_if_index = ntohl (sw_if_index);
13832 mp->ip4_table_index = ntohl (ip4_table_index);
13833 mp->ip6_table_index = ntohl (ip6_table_index);
13834 mp->l2_table_index = ntohl (l2_table_index);
13835 mp->is_add = is_add;
13843 api_ip_address_dump (vat_main_t * vam)
13845 unformat_input_t *i = vam->input;
13846 vl_api_ip_address_dump_t *mp;
13847 vl_api_control_ping_t *mp_ping;
13848 u32 sw_if_index = ~0;
13849 u8 sw_if_index_set = 0;
13854 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13856 if (unformat (i, "sw_if_index %d", &sw_if_index))
13857 sw_if_index_set = 1;
13859 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13860 sw_if_index_set = 1;
13861 else if (unformat (i, "ipv4"))
13863 else if (unformat (i, "ipv6"))
13869 if (ipv4_set && ipv6_set)
13871 errmsg ("ipv4 and ipv6 flags cannot be both set");
13875 if ((!ipv4_set) && (!ipv6_set))
13877 errmsg ("no ipv4 nor ipv6 flag set");
13881 if (sw_if_index_set == 0)
13883 errmsg ("missing interface name or sw_if_index");
13887 vam->current_sw_if_index = sw_if_index;
13888 vam->is_ipv6 = ipv6_set;
13890 M (IP_ADDRESS_DUMP, mp);
13891 mp->sw_if_index = ntohl (sw_if_index);
13892 mp->is_ipv6 = ipv6_set;
13895 /* Use a control ping for synchronization */
13896 MPING (CONTROL_PING, mp_ping);
13904 api_ip_dump (vat_main_t * vam)
13906 vl_api_ip_dump_t *mp;
13907 vl_api_control_ping_t *mp_ping;
13908 unformat_input_t *in = vam->input;
13915 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13917 if (unformat (in, "ipv4"))
13919 else if (unformat (in, "ipv6"))
13925 if (ipv4_set && ipv6_set)
13927 errmsg ("ipv4 and ipv6 flags cannot be both set");
13931 if ((!ipv4_set) && (!ipv6_set))
13933 errmsg ("no ipv4 nor ipv6 flag set");
13937 is_ipv6 = ipv6_set;
13938 vam->is_ipv6 = is_ipv6;
13940 /* free old data */
13941 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13943 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13945 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13948 mp->is_ipv6 = ipv6_set;
13951 /* Use a control ping for synchronization */
13952 MPING (CONTROL_PING, mp_ping);
13960 api_ipsec_spd_add_del (vat_main_t * vam)
13962 unformat_input_t *i = vam->input;
13963 vl_api_ipsec_spd_add_del_t *mp;
13968 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13970 if (unformat (i, "spd_id %d", &spd_id))
13972 else if (unformat (i, "del"))
13976 clib_warning ("parse error '%U'", format_unformat_error, i);
13982 errmsg ("spd_id must be set");
13986 M (IPSEC_SPD_ADD_DEL, mp);
13988 mp->spd_id = ntohl (spd_id);
13989 mp->is_add = is_add;
13997 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13999 unformat_input_t *i = vam->input;
14000 vl_api_ipsec_interface_add_del_spd_t *mp;
14002 u8 sw_if_index_set = 0;
14003 u32 spd_id = (u32) ~ 0;
14007 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14009 if (unformat (i, "del"))
14011 else if (unformat (i, "spd_id %d", &spd_id))
14014 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14015 sw_if_index_set = 1;
14016 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14017 sw_if_index_set = 1;
14020 clib_warning ("parse error '%U'", format_unformat_error, i);
14026 if (spd_id == (u32) ~ 0)
14028 errmsg ("spd_id must be set");
14032 if (sw_if_index_set == 0)
14034 errmsg ("missing interface name or sw_if_index");
14038 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14040 mp->spd_id = ntohl (spd_id);
14041 mp->sw_if_index = ntohl (sw_if_index);
14042 mp->is_add = is_add;
14050 api_ipsec_spd_add_del_entry (vat_main_t * vam)
14052 unformat_input_t *i = vam->input;
14053 vl_api_ipsec_spd_add_del_entry_t *mp;
14054 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
14055 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14057 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14058 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14059 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
14060 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
14063 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
14064 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
14065 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
14066 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
14067 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
14068 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
14070 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14072 if (unformat (i, "del"))
14074 if (unformat (i, "outbound"))
14076 if (unformat (i, "inbound"))
14078 else if (unformat (i, "spd_id %d", &spd_id))
14080 else if (unformat (i, "sa_id %d", &sa_id))
14082 else if (unformat (i, "priority %d", &priority))
14084 else if (unformat (i, "protocol %d", &protocol))
14086 else if (unformat (i, "lport_start %d", &lport_start))
14088 else if (unformat (i, "lport_stop %d", &lport_stop))
14090 else if (unformat (i, "rport_start %d", &rport_start))
14092 else if (unformat (i, "rport_stop %d", &rport_stop))
14096 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
14102 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
14109 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
14115 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
14122 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
14128 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
14135 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
14141 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
14147 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14149 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14151 clib_warning ("unsupported action: 'resolve'");
14157 clib_warning ("parse error '%U'", format_unformat_error, i);
14163 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
14165 mp->spd_id = ntohl (spd_id);
14166 mp->priority = ntohl (priority);
14167 mp->is_outbound = is_outbound;
14169 mp->is_ipv6 = is_ipv6;
14170 if (is_ipv6 || is_ip_any)
14172 clib_memcpy (mp->remote_address_start, &raddr6_start,
14173 sizeof (ip6_address_t));
14174 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
14175 sizeof (ip6_address_t));
14176 clib_memcpy (mp->local_address_start, &laddr6_start,
14177 sizeof (ip6_address_t));
14178 clib_memcpy (mp->local_address_stop, &laddr6_stop,
14179 sizeof (ip6_address_t));
14183 clib_memcpy (mp->remote_address_start, &raddr4_start,
14184 sizeof (ip4_address_t));
14185 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
14186 sizeof (ip4_address_t));
14187 clib_memcpy (mp->local_address_start, &laddr4_start,
14188 sizeof (ip4_address_t));
14189 clib_memcpy (mp->local_address_stop, &laddr4_stop,
14190 sizeof (ip4_address_t));
14192 mp->protocol = (u8) protocol;
14193 mp->local_port_start = ntohs ((u16) lport_start);
14194 mp->local_port_stop = ntohs ((u16) lport_stop);
14195 mp->remote_port_start = ntohs ((u16) rport_start);
14196 mp->remote_port_stop = ntohs ((u16) rport_stop);
14197 mp->policy = (u8) policy;
14198 mp->sa_id = ntohl (sa_id);
14199 mp->is_add = is_add;
14200 mp->is_ip_any = is_ip_any;
14207 api_ipsec_sad_add_del_entry (vat_main_t * vam)
14209 unformat_input_t *i = vam->input;
14210 vl_api_ipsec_sad_add_del_entry_t *mp;
14211 u32 sad_id = 0, spi = 0;
14212 u8 *ck = 0, *ik = 0;
14215 u8 protocol = IPSEC_PROTOCOL_AH;
14216 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
14217 u32 crypto_alg = 0, integ_alg = 0;
14218 ip4_address_t tun_src4;
14219 ip4_address_t tun_dst4;
14220 ip6_address_t tun_src6;
14221 ip6_address_t tun_dst6;
14224 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14226 if (unformat (i, "del"))
14228 else if (unformat (i, "sad_id %d", &sad_id))
14230 else if (unformat (i, "spi %d", &spi))
14232 else if (unformat (i, "esp"))
14233 protocol = IPSEC_PROTOCOL_ESP;
14234 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
14237 is_tunnel_ipv6 = 0;
14239 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
14242 is_tunnel_ipv6 = 0;
14244 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
14247 is_tunnel_ipv6 = 1;
14249 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
14252 is_tunnel_ipv6 = 1;
14256 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14258 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14259 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14261 clib_warning ("unsupported crypto-alg: '%U'",
14262 format_ipsec_crypto_alg, crypto_alg);
14266 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14270 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14272 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14273 integ_alg >= IPSEC_INTEG_N_ALG)
14275 clib_warning ("unsupported integ-alg: '%U'",
14276 format_ipsec_integ_alg, integ_alg);
14280 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14284 clib_warning ("parse error '%U'", format_unformat_error, i);
14290 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
14292 mp->sad_id = ntohl (sad_id);
14293 mp->is_add = is_add;
14294 mp->protocol = protocol;
14295 mp->spi = ntohl (spi);
14296 mp->is_tunnel = is_tunnel;
14297 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
14298 mp->crypto_algorithm = crypto_alg;
14299 mp->integrity_algorithm = integ_alg;
14300 mp->crypto_key_length = vec_len (ck);
14301 mp->integrity_key_length = vec_len (ik);
14303 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14304 mp->crypto_key_length = sizeof (mp->crypto_key);
14306 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14307 mp->integrity_key_length = sizeof (mp->integrity_key);
14310 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14312 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14316 if (is_tunnel_ipv6)
14318 clib_memcpy (mp->tunnel_src_address, &tun_src6,
14319 sizeof (ip6_address_t));
14320 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
14321 sizeof (ip6_address_t));
14325 clib_memcpy (mp->tunnel_src_address, &tun_src4,
14326 sizeof (ip4_address_t));
14327 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
14328 sizeof (ip4_address_t));
14338 api_ipsec_sa_set_key (vat_main_t * vam)
14340 unformat_input_t *i = vam->input;
14341 vl_api_ipsec_sa_set_key_t *mp;
14343 u8 *ck = 0, *ik = 0;
14346 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14348 if (unformat (i, "sa_id %d", &sa_id))
14350 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14352 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14356 clib_warning ("parse error '%U'", format_unformat_error, i);
14361 M (IPSEC_SA_SET_KEY, mp);
14363 mp->sa_id = ntohl (sa_id);
14364 mp->crypto_key_length = vec_len (ck);
14365 mp->integrity_key_length = vec_len (ik);
14367 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14368 mp->crypto_key_length = sizeof (mp->crypto_key);
14370 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14371 mp->integrity_key_length = sizeof (mp->integrity_key);
14374 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14376 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14384 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14386 unformat_input_t *i = vam->input;
14387 vl_api_ipsec_tunnel_if_add_del_t *mp;
14388 u32 local_spi = 0, remote_spi = 0;
14389 u32 crypto_alg = 0, integ_alg = 0;
14390 u8 *lck = NULL, *rck = NULL;
14391 u8 *lik = NULL, *rik = NULL;
14392 ip4_address_t local_ip = { {0} };
14393 ip4_address_t remote_ip = { {0} };
14396 u8 anti_replay = 0;
14399 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14401 if (unformat (i, "del"))
14403 else if (unformat (i, "esn"))
14405 else if (unformat (i, "anti_replay"))
14407 else if (unformat (i, "local_spi %d", &local_spi))
14409 else if (unformat (i, "remote_spi %d", &remote_spi))
14411 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
14413 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
14415 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14418 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14420 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14422 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14426 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14428 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14429 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14431 errmsg ("unsupported crypto-alg: '%U'\n",
14432 format_ipsec_crypto_alg, crypto_alg);
14438 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14440 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14441 integ_alg >= IPSEC_INTEG_N_ALG)
14443 errmsg ("unsupported integ-alg: '%U'\n",
14444 format_ipsec_integ_alg, integ_alg);
14450 errmsg ("parse error '%U'\n", format_unformat_error, i);
14455 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14457 mp->is_add = is_add;
14459 mp->anti_replay = anti_replay;
14461 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
14462 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
14464 mp->local_spi = htonl (local_spi);
14465 mp->remote_spi = htonl (remote_spi);
14466 mp->crypto_alg = (u8) crypto_alg;
14468 mp->local_crypto_key_len = 0;
14471 mp->local_crypto_key_len = vec_len (lck);
14472 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14473 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14474 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14477 mp->remote_crypto_key_len = 0;
14480 mp->remote_crypto_key_len = vec_len (rck);
14481 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14482 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14483 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14486 mp->integ_alg = (u8) integ_alg;
14488 mp->local_integ_key_len = 0;
14491 mp->local_integ_key_len = vec_len (lik);
14492 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14493 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14494 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14497 mp->remote_integ_key_len = 0;
14500 mp->remote_integ_key_len = vec_len (rik);
14501 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14502 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14503 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14512 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14514 vat_main_t *vam = &vat_main;
14516 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14517 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
14518 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
14519 "tunnel_src_addr %U tunnel_dst_addr %U "
14520 "salt %u seq_outbound %lu last_seq_inbound %lu "
14521 "replay_window %lu total_data_size %lu\n",
14522 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
14524 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
14525 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
14526 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
14527 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14528 mp->tunnel_src_addr,
14529 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14530 mp->tunnel_dst_addr,
14532 clib_net_to_host_u64 (mp->seq_outbound),
14533 clib_net_to_host_u64 (mp->last_seq_inbound),
14534 clib_net_to_host_u64 (mp->replay_window),
14535 clib_net_to_host_u64 (mp->total_data_size));
14538 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14539 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14541 static void vl_api_ipsec_sa_details_t_handler_json
14542 (vl_api_ipsec_sa_details_t * mp)
14544 vat_main_t *vam = &vat_main;
14545 vat_json_node_t *node = NULL;
14546 struct in_addr src_ip4, dst_ip4;
14547 struct in6_addr src_ip6, dst_ip6;
14549 if (VAT_JSON_ARRAY != vam->json_tree.type)
14551 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14552 vat_json_init_array (&vam->json_tree);
14554 node = vat_json_array_add (&vam->json_tree);
14556 vat_json_init_object (node);
14557 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
14558 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14559 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
14560 vat_json_object_add_uint (node, "proto", mp->protocol);
14561 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
14562 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
14563 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
14564 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
14565 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
14566 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
14567 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
14568 mp->crypto_key_len);
14569 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
14570 mp->integ_key_len);
14571 if (mp->is_tunnel_ip6)
14573 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
14574 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
14575 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
14576 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
14580 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
14581 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
14582 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
14583 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
14585 vat_json_object_add_uint (node, "replay_window",
14586 clib_net_to_host_u64 (mp->replay_window));
14587 vat_json_object_add_uint (node, "total_data_size",
14588 clib_net_to_host_u64 (mp->total_data_size));
14593 api_ipsec_sa_dump (vat_main_t * vam)
14595 unformat_input_t *i = vam->input;
14596 vl_api_ipsec_sa_dump_t *mp;
14597 vl_api_control_ping_t *mp_ping;
14601 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14603 if (unformat (i, "sa_id %d", &sa_id))
14607 clib_warning ("parse error '%U'", format_unformat_error, i);
14612 M (IPSEC_SA_DUMP, mp);
14614 mp->sa_id = ntohl (sa_id);
14618 /* Use a control ping for synchronization */
14619 M (CONTROL_PING, mp_ping);
14627 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
14629 unformat_input_t *i = vam->input;
14630 vl_api_ipsec_tunnel_if_set_key_t *mp;
14631 u32 sw_if_index = ~0;
14632 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
14637 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14639 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14642 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
14643 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
14645 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
14646 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
14647 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
14648 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
14650 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
14651 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
14652 else if (unformat (i, "%U", unformat_hex_string, &key))
14656 clib_warning ("parse error '%U'", format_unformat_error, i);
14661 if (sw_if_index == ~0)
14663 errmsg ("interface must be specified");
14667 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
14669 errmsg ("key type must be specified");
14675 errmsg ("algorithm must be specified");
14679 if (vec_len (key) == 0)
14681 errmsg ("key must be specified");
14685 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
14687 mp->sw_if_index = htonl (sw_if_index);
14689 mp->key_type = key_type;
14690 mp->key_len = vec_len (key);
14691 clib_memcpy (mp->key, key, vec_len (key));
14700 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
14702 unformat_input_t *i = vam->input;
14703 vl_api_ipsec_tunnel_if_set_sa_t *mp;
14704 u32 sw_if_index = ~0;
14706 u8 is_outbound = (u8) ~ 0;
14709 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14711 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14713 else if (unformat (i, "sa_id %d", &sa_id))
14715 else if (unformat (i, "outbound"))
14717 else if (unformat (i, "inbound"))
14721 clib_warning ("parse error '%U'", format_unformat_error, i);
14726 if (sw_if_index == ~0)
14728 errmsg ("interface must be specified");
14734 errmsg ("SA ID must be specified");
14738 M (IPSEC_TUNNEL_IF_SET_SA, mp);
14740 mp->sw_if_index = htonl (sw_if_index);
14741 mp->sa_id = htonl (sa_id);
14742 mp->is_outbound = is_outbound;
14751 api_ikev2_profile_add_del (vat_main_t * vam)
14753 unformat_input_t *i = vam->input;
14754 vl_api_ikev2_profile_add_del_t *mp;
14759 const char *valid_chars = "a-zA-Z0-9_";
14761 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14763 if (unformat (i, "del"))
14765 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14766 vec_add1 (name, 0);
14769 errmsg ("parse error '%U'", format_unformat_error, i);
14774 if (!vec_len (name))
14776 errmsg ("profile name must be specified");
14780 if (vec_len (name) > 64)
14782 errmsg ("profile name too long");
14786 M (IKEV2_PROFILE_ADD_DEL, mp);
14788 clib_memcpy (mp->name, name, vec_len (name));
14789 mp->is_add = is_add;
14798 api_ikev2_profile_set_auth (vat_main_t * vam)
14800 unformat_input_t *i = vam->input;
14801 vl_api_ikev2_profile_set_auth_t *mp;
14804 u32 auth_method = 0;
14808 const char *valid_chars = "a-zA-Z0-9_";
14810 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14812 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14813 vec_add1 (name, 0);
14814 else if (unformat (i, "auth_method %U",
14815 unformat_ikev2_auth_method, &auth_method))
14817 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
14819 else if (unformat (i, "auth_data %v", &data))
14823 errmsg ("parse error '%U'", format_unformat_error, i);
14828 if (!vec_len (name))
14830 errmsg ("profile name must be specified");
14834 if (vec_len (name) > 64)
14836 errmsg ("profile name too long");
14840 if (!vec_len (data))
14842 errmsg ("auth_data must be specified");
14848 errmsg ("auth_method must be specified");
14852 M (IKEV2_PROFILE_SET_AUTH, mp);
14854 mp->is_hex = is_hex;
14855 mp->auth_method = (u8) auth_method;
14856 mp->data_len = vec_len (data);
14857 clib_memcpy (mp->name, name, vec_len (name));
14858 clib_memcpy (mp->data, data, vec_len (data));
14868 api_ikev2_profile_set_id (vat_main_t * vam)
14870 unformat_input_t *i = vam->input;
14871 vl_api_ikev2_profile_set_id_t *mp;
14879 const char *valid_chars = "a-zA-Z0-9_";
14881 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14883 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14884 vec_add1 (name, 0);
14885 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
14887 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
14889 data = vec_new (u8, 4);
14890 clib_memcpy (data, ip4.as_u8, 4);
14892 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
14894 else if (unformat (i, "id_data %v", &data))
14896 else if (unformat (i, "local"))
14898 else if (unformat (i, "remote"))
14902 errmsg ("parse error '%U'", format_unformat_error, i);
14907 if (!vec_len (name))
14909 errmsg ("profile name must be specified");
14913 if (vec_len (name) > 64)
14915 errmsg ("profile name too long");
14919 if (!vec_len (data))
14921 errmsg ("id_data must be specified");
14927 errmsg ("id_type must be specified");
14931 M (IKEV2_PROFILE_SET_ID, mp);
14933 mp->is_local = is_local;
14934 mp->id_type = (u8) id_type;
14935 mp->data_len = vec_len (data);
14936 clib_memcpy (mp->name, name, vec_len (name));
14937 clib_memcpy (mp->data, data, vec_len (data));
14947 api_ikev2_profile_set_ts (vat_main_t * vam)
14949 unformat_input_t *i = vam->input;
14950 vl_api_ikev2_profile_set_ts_t *mp;
14953 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
14954 ip4_address_t start_addr, end_addr;
14956 const char *valid_chars = "a-zA-Z0-9_";
14959 start_addr.as_u32 = 0;
14960 end_addr.as_u32 = (u32) ~ 0;
14962 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14964 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14965 vec_add1 (name, 0);
14966 else if (unformat (i, "protocol %d", &proto))
14968 else if (unformat (i, "start_port %d", &start_port))
14970 else if (unformat (i, "end_port %d", &end_port))
14973 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
14975 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
14977 else if (unformat (i, "local"))
14979 else if (unformat (i, "remote"))
14983 errmsg ("parse error '%U'", format_unformat_error, i);
14988 if (!vec_len (name))
14990 errmsg ("profile name must be specified");
14994 if (vec_len (name) > 64)
14996 errmsg ("profile name too long");
15000 M (IKEV2_PROFILE_SET_TS, mp);
15002 mp->is_local = is_local;
15003 mp->proto = (u8) proto;
15004 mp->start_port = (u16) start_port;
15005 mp->end_port = (u16) end_port;
15006 mp->start_addr = start_addr.as_u32;
15007 mp->end_addr = end_addr.as_u32;
15008 clib_memcpy (mp->name, name, vec_len (name));
15017 api_ikev2_set_local_key (vat_main_t * vam)
15019 unformat_input_t *i = vam->input;
15020 vl_api_ikev2_set_local_key_t *mp;
15024 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15026 if (unformat (i, "file %v", &file))
15027 vec_add1 (file, 0);
15030 errmsg ("parse error '%U'", format_unformat_error, i);
15035 if (!vec_len (file))
15037 errmsg ("RSA key file must be specified");
15041 if (vec_len (file) > 256)
15043 errmsg ("file name too long");
15047 M (IKEV2_SET_LOCAL_KEY, mp);
15049 clib_memcpy (mp->key_file, file, vec_len (file));
15058 api_ikev2_set_responder (vat_main_t * vam)
15060 unformat_input_t *i = vam->input;
15061 vl_api_ikev2_set_responder_t *mp;
15064 u32 sw_if_index = ~0;
15065 ip4_address_t address;
15067 const char *valid_chars = "a-zA-Z0-9_";
15069 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15072 (i, "%U interface %d address %U", unformat_token, valid_chars,
15073 &name, &sw_if_index, unformat_ip4_address, &address))
15074 vec_add1 (name, 0);
15077 errmsg ("parse error '%U'", format_unformat_error, i);
15082 if (!vec_len (name))
15084 errmsg ("profile name must be specified");
15088 if (vec_len (name) > 64)
15090 errmsg ("profile name too long");
15094 M (IKEV2_SET_RESPONDER, mp);
15096 clib_memcpy (mp->name, name, vec_len (name));
15099 mp->sw_if_index = sw_if_index;
15100 clib_memcpy (mp->address, &address, sizeof (address));
15108 api_ikev2_set_ike_transforms (vat_main_t * vam)
15110 unformat_input_t *i = vam->input;
15111 vl_api_ikev2_set_ike_transforms_t *mp;
15114 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15116 const char *valid_chars = "a-zA-Z0-9_";
15118 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15120 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15121 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15122 vec_add1 (name, 0);
15125 errmsg ("parse error '%U'", format_unformat_error, i);
15130 if (!vec_len (name))
15132 errmsg ("profile name must be specified");
15136 if (vec_len (name) > 64)
15138 errmsg ("profile name too long");
15142 M (IKEV2_SET_IKE_TRANSFORMS, mp);
15144 clib_memcpy (mp->name, name, vec_len (name));
15146 mp->crypto_alg = crypto_alg;
15147 mp->crypto_key_size = crypto_key_size;
15148 mp->integ_alg = integ_alg;
15149 mp->dh_group = dh_group;
15158 api_ikev2_set_esp_transforms (vat_main_t * vam)
15160 unformat_input_t *i = vam->input;
15161 vl_api_ikev2_set_esp_transforms_t *mp;
15164 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15166 const char *valid_chars = "a-zA-Z0-9_";
15168 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15170 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15171 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15172 vec_add1 (name, 0);
15175 errmsg ("parse error '%U'", format_unformat_error, i);
15180 if (!vec_len (name))
15182 errmsg ("profile name must be specified");
15186 if (vec_len (name) > 64)
15188 errmsg ("profile name too long");
15192 M (IKEV2_SET_ESP_TRANSFORMS, mp);
15194 clib_memcpy (mp->name, name, vec_len (name));
15196 mp->crypto_alg = crypto_alg;
15197 mp->crypto_key_size = crypto_key_size;
15198 mp->integ_alg = integ_alg;
15199 mp->dh_group = dh_group;
15207 api_ikev2_set_sa_lifetime (vat_main_t * vam)
15209 unformat_input_t *i = vam->input;
15210 vl_api_ikev2_set_sa_lifetime_t *mp;
15213 u64 lifetime, lifetime_maxdata;
15214 u32 lifetime_jitter, handover;
15216 const char *valid_chars = "a-zA-Z0-9_";
15218 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15220 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
15221 &lifetime, &lifetime_jitter, &handover,
15222 &lifetime_maxdata))
15223 vec_add1 (name, 0);
15226 errmsg ("parse error '%U'", format_unformat_error, i);
15231 if (!vec_len (name))
15233 errmsg ("profile name must be specified");
15237 if (vec_len (name) > 64)
15239 errmsg ("profile name too long");
15243 M (IKEV2_SET_SA_LIFETIME, mp);
15245 clib_memcpy (mp->name, name, vec_len (name));
15247 mp->lifetime = lifetime;
15248 mp->lifetime_jitter = lifetime_jitter;
15249 mp->handover = handover;
15250 mp->lifetime_maxdata = lifetime_maxdata;
15258 api_ikev2_initiate_sa_init (vat_main_t * vam)
15260 unformat_input_t *i = vam->input;
15261 vl_api_ikev2_initiate_sa_init_t *mp;
15265 const char *valid_chars = "a-zA-Z0-9_";
15267 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15269 if (unformat (i, "%U", unformat_token, valid_chars, &name))
15270 vec_add1 (name, 0);
15273 errmsg ("parse error '%U'", format_unformat_error, i);
15278 if (!vec_len (name))
15280 errmsg ("profile name must be specified");
15284 if (vec_len (name) > 64)
15286 errmsg ("profile name too long");
15290 M (IKEV2_INITIATE_SA_INIT, mp);
15292 clib_memcpy (mp->name, name, vec_len (name));
15301 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
15303 unformat_input_t *i = vam->input;
15304 vl_api_ikev2_initiate_del_ike_sa_t *mp;
15309 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15311 if (unformat (i, "%lx", &ispi))
15315 errmsg ("parse error '%U'", format_unformat_error, i);
15320 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
15330 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
15332 unformat_input_t *i = vam->input;
15333 vl_api_ikev2_initiate_del_child_sa_t *mp;
15338 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15340 if (unformat (i, "%x", &ispi))
15344 errmsg ("parse error '%U'", format_unformat_error, i);
15349 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
15359 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
15361 unformat_input_t *i = vam->input;
15362 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
15367 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15369 if (unformat (i, "%x", &ispi))
15373 errmsg ("parse error '%U'", format_unformat_error, i);
15378 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
15391 api_map_add_domain (vat_main_t * vam)
15393 unformat_input_t *i = vam->input;
15394 vl_api_map_add_domain_t *mp;
15396 ip4_address_t ip4_prefix;
15397 ip6_address_t ip6_prefix;
15398 ip6_address_t ip6_src;
15399 u32 num_m_args = 0;
15400 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
15401 0, psid_length = 0;
15402 u8 is_translation = 0;
15404 u32 ip6_src_len = 128;
15407 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15409 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
15410 &ip4_prefix, &ip4_prefix_len))
15412 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
15413 &ip6_prefix, &ip6_prefix_len))
15417 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
15420 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
15422 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
15424 else if (unformat (i, "psid-offset %d", &psid_offset))
15426 else if (unformat (i, "psid-len %d", &psid_length))
15428 else if (unformat (i, "mtu %d", &mtu))
15430 else if (unformat (i, "map-t"))
15431 is_translation = 1;
15434 clib_warning ("parse error '%U'", format_unformat_error, i);
15439 if (num_m_args < 3)
15441 errmsg ("mandatory argument(s) missing");
15445 /* Construct the API message */
15446 M (MAP_ADD_DOMAIN, mp);
15448 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
15449 mp->ip4_prefix_len = ip4_prefix_len;
15451 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
15452 mp->ip6_prefix_len = ip6_prefix_len;
15454 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
15455 mp->ip6_src_prefix_len = ip6_src_len;
15457 mp->ea_bits_len = ea_bits_len;
15458 mp->psid_offset = psid_offset;
15459 mp->psid_length = psid_length;
15460 mp->is_translation = is_translation;
15461 mp->mtu = htons (mtu);
15466 /* Wait for a reply, return good/bad news */
15472 api_map_del_domain (vat_main_t * vam)
15474 unformat_input_t *i = vam->input;
15475 vl_api_map_del_domain_t *mp;
15477 u32 num_m_args = 0;
15481 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15483 if (unformat (i, "index %d", &index))
15487 clib_warning ("parse error '%U'", format_unformat_error, i);
15492 if (num_m_args != 1)
15494 errmsg ("mandatory argument(s) missing");
15498 /* Construct the API message */
15499 M (MAP_DEL_DOMAIN, mp);
15501 mp->index = ntohl (index);
15506 /* Wait for a reply, return good/bad news */
15512 api_map_add_del_rule (vat_main_t * vam)
15514 unformat_input_t *i = vam->input;
15515 vl_api_map_add_del_rule_t *mp;
15517 ip6_address_t ip6_dst;
15518 u32 num_m_args = 0, index, psid = 0;
15521 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15523 if (unformat (i, "index %d", &index))
15525 else if (unformat (i, "psid %d", &psid))
15527 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
15529 else if (unformat (i, "del"))
15535 clib_warning ("parse error '%U'", format_unformat_error, i);
15540 /* Construct the API message */
15541 M (MAP_ADD_DEL_RULE, mp);
15543 mp->index = ntohl (index);
15544 mp->is_add = is_add;
15545 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
15546 mp->psid = ntohs (psid);
15551 /* Wait for a reply, return good/bad news */
15557 api_map_domain_dump (vat_main_t * vam)
15559 vl_api_map_domain_dump_t *mp;
15560 vl_api_control_ping_t *mp_ping;
15563 /* Construct the API message */
15564 M (MAP_DOMAIN_DUMP, mp);
15569 /* Use a control ping for synchronization */
15570 MPING (CONTROL_PING, mp_ping);
15578 api_map_rule_dump (vat_main_t * vam)
15580 unformat_input_t *i = vam->input;
15581 vl_api_map_rule_dump_t *mp;
15582 vl_api_control_ping_t *mp_ping;
15583 u32 domain_index = ~0;
15586 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15588 if (unformat (i, "index %u", &domain_index))
15594 if (domain_index == ~0)
15596 clib_warning ("parse error: domain index expected");
15600 /* Construct the API message */
15601 M (MAP_RULE_DUMP, mp);
15603 mp->domain_index = htonl (domain_index);
15608 /* Use a control ping for synchronization */
15609 MPING (CONTROL_PING, mp_ping);
15616 static void vl_api_map_add_domain_reply_t_handler
15617 (vl_api_map_add_domain_reply_t * mp)
15619 vat_main_t *vam = &vat_main;
15620 i32 retval = ntohl (mp->retval);
15622 if (vam->async_mode)
15624 vam->async_errors += (retval < 0);
15628 vam->retval = retval;
15629 vam->result_ready = 1;
15633 static void vl_api_map_add_domain_reply_t_handler_json
15634 (vl_api_map_add_domain_reply_t * mp)
15636 vat_main_t *vam = &vat_main;
15637 vat_json_node_t node;
15639 vat_json_init_object (&node);
15640 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
15641 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
15643 vat_json_print (vam->ofp, &node);
15644 vat_json_free (&node);
15646 vam->retval = ntohl (mp->retval);
15647 vam->result_ready = 1;
15651 api_get_first_msg_id (vat_main_t * vam)
15653 vl_api_get_first_msg_id_t *mp;
15654 unformat_input_t *i = vam->input;
15659 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15661 if (unformat (i, "client %s", &name))
15669 errmsg ("missing client name");
15672 vec_add1 (name, 0);
15674 if (vec_len (name) > 63)
15676 errmsg ("client name too long");
15680 M (GET_FIRST_MSG_ID, mp);
15681 clib_memcpy (mp->name, name, vec_len (name));
15688 api_cop_interface_enable_disable (vat_main_t * vam)
15690 unformat_input_t *line_input = vam->input;
15691 vl_api_cop_interface_enable_disable_t *mp;
15692 u32 sw_if_index = ~0;
15693 u8 enable_disable = 1;
15696 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15698 if (unformat (line_input, "disable"))
15699 enable_disable = 0;
15700 if (unformat (line_input, "enable"))
15701 enable_disable = 1;
15702 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15703 vam, &sw_if_index))
15705 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15711 if (sw_if_index == ~0)
15713 errmsg ("missing interface name or sw_if_index");
15717 /* Construct the API message */
15718 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15719 mp->sw_if_index = ntohl (sw_if_index);
15720 mp->enable_disable = enable_disable;
15724 /* Wait for the reply */
15730 api_cop_whitelist_enable_disable (vat_main_t * vam)
15732 unformat_input_t *line_input = vam->input;
15733 vl_api_cop_whitelist_enable_disable_t *mp;
15734 u32 sw_if_index = ~0;
15735 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15739 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15741 if (unformat (line_input, "ip4"))
15743 else if (unformat (line_input, "ip6"))
15745 else if (unformat (line_input, "default"))
15747 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15748 vam, &sw_if_index))
15750 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15752 else if (unformat (line_input, "fib-id %d", &fib_id))
15758 if (sw_if_index == ~0)
15760 errmsg ("missing interface name or sw_if_index");
15764 /* Construct the API message */
15765 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15766 mp->sw_if_index = ntohl (sw_if_index);
15767 mp->fib_id = ntohl (fib_id);
15770 mp->default_cop = default_cop;
15774 /* Wait for the reply */
15780 api_get_node_graph (vat_main_t * vam)
15782 vl_api_get_node_graph_t *mp;
15785 M (GET_NODE_GRAPH, mp);
15789 /* Wait for the reply */
15795 /** Used for parsing LISP eids */
15796 typedef CLIB_PACKED(struct{
15797 u8 addr[16]; /**< eid address */
15798 u32 len; /**< prefix length if IP */
15799 u8 type; /**< type of eid */
15804 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15806 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15808 memset (a, 0, sizeof (a[0]));
15810 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15812 a->type = 0; /* ipv4 type */
15814 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15816 a->type = 1; /* ipv6 type */
15818 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15820 a->type = 2; /* mac type */
15822 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15824 a->type = 3; /* NSH type */
15825 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15826 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15833 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15842 lisp_eid_size_vat (u8 type)
15859 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15861 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15865 api_one_add_del_locator_set (vat_main_t * vam)
15867 unformat_input_t *input = vam->input;
15868 vl_api_one_add_del_locator_set_t *mp;
15870 u8 *locator_set_name = NULL;
15871 u8 locator_set_name_set = 0;
15872 vl_api_local_locator_t locator, *locators = 0;
15873 u32 sw_if_index, priority, weight;
15877 /* Parse args required to build the message */
15878 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15880 if (unformat (input, "del"))
15884 else if (unformat (input, "locator-set %s", &locator_set_name))
15886 locator_set_name_set = 1;
15888 else if (unformat (input, "sw_if_index %u p %u w %u",
15889 &sw_if_index, &priority, &weight))
15891 locator.sw_if_index = htonl (sw_if_index);
15892 locator.priority = priority;
15893 locator.weight = weight;
15894 vec_add1 (locators, locator);
15898 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15899 &sw_if_index, &priority, &weight))
15901 locator.sw_if_index = htonl (sw_if_index);
15902 locator.priority = priority;
15903 locator.weight = weight;
15904 vec_add1 (locators, locator);
15910 if (locator_set_name_set == 0)
15912 errmsg ("missing locator-set name");
15913 vec_free (locators);
15917 if (vec_len (locator_set_name) > 64)
15919 errmsg ("locator-set name too long");
15920 vec_free (locator_set_name);
15921 vec_free (locators);
15924 vec_add1 (locator_set_name, 0);
15926 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15928 /* Construct the API message */
15929 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15931 mp->is_add = is_add;
15932 clib_memcpy (mp->locator_set_name, locator_set_name,
15933 vec_len (locator_set_name));
15934 vec_free (locator_set_name);
15936 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15938 clib_memcpy (mp->locators, locators, data_len);
15939 vec_free (locators);
15944 /* Wait for a reply... */
15949 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15952 api_one_add_del_locator (vat_main_t * vam)
15954 unformat_input_t *input = vam->input;
15955 vl_api_one_add_del_locator_t *mp;
15956 u32 tmp_if_index = ~0;
15957 u32 sw_if_index = ~0;
15958 u8 sw_if_index_set = 0;
15959 u8 sw_if_index_if_name_set = 0;
15961 u8 priority_set = 0;
15965 u8 *locator_set_name = NULL;
15966 u8 locator_set_name_set = 0;
15969 /* Parse args required to build the message */
15970 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15972 if (unformat (input, "del"))
15976 else if (unformat (input, "locator-set %s", &locator_set_name))
15978 locator_set_name_set = 1;
15980 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15983 sw_if_index_if_name_set = 1;
15984 sw_if_index = tmp_if_index;
15986 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15988 sw_if_index_set = 1;
15989 sw_if_index = tmp_if_index;
15991 else if (unformat (input, "p %d", &priority))
15995 else if (unformat (input, "w %d", &weight))
16003 if (locator_set_name_set == 0)
16005 errmsg ("missing locator-set name");
16009 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16011 errmsg ("missing sw_if_index");
16012 vec_free (locator_set_name);
16016 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
16018 errmsg ("cannot use both params interface name and sw_if_index");
16019 vec_free (locator_set_name);
16023 if (priority_set == 0)
16025 errmsg ("missing locator-set priority");
16026 vec_free (locator_set_name);
16030 if (weight_set == 0)
16032 errmsg ("missing locator-set weight");
16033 vec_free (locator_set_name);
16037 if (vec_len (locator_set_name) > 64)
16039 errmsg ("locator-set name too long");
16040 vec_free (locator_set_name);
16043 vec_add1 (locator_set_name, 0);
16045 /* Construct the API message */
16046 M (ONE_ADD_DEL_LOCATOR, mp);
16048 mp->is_add = is_add;
16049 mp->sw_if_index = ntohl (sw_if_index);
16050 mp->priority = priority;
16051 mp->weight = weight;
16052 clib_memcpy (mp->locator_set_name, locator_set_name,
16053 vec_len (locator_set_name));
16054 vec_free (locator_set_name);
16059 /* Wait for a reply... */
16064 #define api_lisp_add_del_locator api_one_add_del_locator
16067 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
16069 u32 *key_id = va_arg (*args, u32 *);
16072 if (unformat (input, "%s", &s))
16074 if (!strcmp ((char *) s, "sha1"))
16075 key_id[0] = HMAC_SHA_1_96;
16076 else if (!strcmp ((char *) s, "sha256"))
16077 key_id[0] = HMAC_SHA_256_128;
16080 clib_warning ("invalid key_id: '%s'", s);
16081 key_id[0] = HMAC_NO_KEY;
16092 api_one_add_del_local_eid (vat_main_t * vam)
16094 unformat_input_t *input = vam->input;
16095 vl_api_one_add_del_local_eid_t *mp;
16098 lisp_eid_vat_t _eid, *eid = &_eid;
16099 u8 *locator_set_name = 0;
16100 u8 locator_set_name_set = 0;
16106 /* Parse args required to build the message */
16107 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16109 if (unformat (input, "del"))
16113 else if (unformat (input, "vni %d", &vni))
16117 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16121 else if (unformat (input, "locator-set %s", &locator_set_name))
16123 locator_set_name_set = 1;
16125 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
16127 else if (unformat (input, "secret-key %_%v%_", &key))
16133 if (locator_set_name_set == 0)
16135 errmsg ("missing locator-set name");
16141 errmsg ("EID address not set!");
16142 vec_free (locator_set_name);
16146 if (key && (0 == key_id))
16148 errmsg ("invalid key_id!");
16152 if (vec_len (key) > 64)
16154 errmsg ("key too long");
16159 if (vec_len (locator_set_name) > 64)
16161 errmsg ("locator-set name too long");
16162 vec_free (locator_set_name);
16165 vec_add1 (locator_set_name, 0);
16167 /* Construct the API message */
16168 M (ONE_ADD_DEL_LOCAL_EID, mp);
16170 mp->is_add = is_add;
16171 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16172 mp->eid_type = eid->type;
16173 mp->prefix_len = eid->len;
16174 mp->vni = clib_host_to_net_u32 (vni);
16175 mp->key_id = clib_host_to_net_u16 (key_id);
16176 clib_memcpy (mp->locator_set_name, locator_set_name,
16177 vec_len (locator_set_name));
16178 clib_memcpy (mp->key, key, vec_len (key));
16180 vec_free (locator_set_name);
16186 /* Wait for a reply... */
16191 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
16194 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
16196 u32 dp_table = 0, vni = 0;;
16197 unformat_input_t *input = vam->input;
16198 vl_api_gpe_add_del_fwd_entry_t *mp;
16200 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
16201 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
16202 u8 rmt_eid_set = 0, lcl_eid_set = 0;
16203 u32 action = ~0, w;
16204 ip4_address_t rmt_rloc4, lcl_rloc4;
16205 ip6_address_t rmt_rloc6, lcl_rloc6;
16206 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
16209 memset (&rloc, 0, sizeof (rloc));
16211 /* Parse args required to build the message */
16212 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16214 if (unformat (input, "del"))
16216 else if (unformat (input, "add"))
16218 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
16222 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
16226 else if (unformat (input, "vrf %d", &dp_table))
16228 else if (unformat (input, "bd %d", &dp_table))
16230 else if (unformat (input, "vni %d", &vni))
16232 else if (unformat (input, "w %d", &w))
16236 errmsg ("No RLOC configured for setting priority/weight!");
16239 curr_rloc->weight = w;
16241 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
16242 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
16246 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
16248 vec_add1 (lcl_locs, rloc);
16250 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
16251 vec_add1 (rmt_locs, rloc);
16252 /* weight saved in rmt loc */
16253 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16255 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
16256 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
16259 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
16261 vec_add1 (lcl_locs, rloc);
16263 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
16264 vec_add1 (rmt_locs, rloc);
16265 /* weight saved in rmt loc */
16266 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16268 else if (unformat (input, "action %d", &action))
16274 clib_warning ("parse error '%U'", format_unformat_error, input);
16281 errmsg ("remote eid addresses not set");
16285 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
16287 errmsg ("eid types don't match");
16291 if (0 == rmt_locs && (u32) ~ 0 == action)
16293 errmsg ("action not set for negative mapping");
16297 /* Construct the API message */
16298 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
16299 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
16301 mp->is_add = is_add;
16302 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
16303 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
16304 mp->eid_type = rmt_eid->type;
16305 mp->dp_table = clib_host_to_net_u32 (dp_table);
16306 mp->vni = clib_host_to_net_u32 (vni);
16307 mp->rmt_len = rmt_eid->len;
16308 mp->lcl_len = lcl_eid->len;
16309 mp->action = action;
16311 if (0 != rmt_locs && 0 != lcl_locs)
16313 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
16314 clib_memcpy (mp->locs, lcl_locs,
16315 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
16317 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
16318 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
16319 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
16321 vec_free (lcl_locs);
16322 vec_free (rmt_locs);
16327 /* Wait for a reply... */
16333 api_one_add_del_map_server (vat_main_t * vam)
16335 unformat_input_t *input = vam->input;
16336 vl_api_one_add_del_map_server_t *mp;
16340 ip4_address_t ipv4;
16341 ip6_address_t ipv6;
16344 /* Parse args required to build the message */
16345 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16347 if (unformat (input, "del"))
16351 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16355 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16363 if (ipv4_set && ipv6_set)
16365 errmsg ("both eid v4 and v6 addresses set");
16369 if (!ipv4_set && !ipv6_set)
16371 errmsg ("eid addresses not set");
16375 /* Construct the API message */
16376 M (ONE_ADD_DEL_MAP_SERVER, mp);
16378 mp->is_add = is_add;
16382 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16387 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16393 /* Wait for a reply... */
16398 #define api_lisp_add_del_map_server api_one_add_del_map_server
16401 api_one_add_del_map_resolver (vat_main_t * vam)
16403 unformat_input_t *input = vam->input;
16404 vl_api_one_add_del_map_resolver_t *mp;
16408 ip4_address_t ipv4;
16409 ip6_address_t ipv6;
16412 /* Parse args required to build the message */
16413 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16415 if (unformat (input, "del"))
16419 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16423 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16431 if (ipv4_set && ipv6_set)
16433 errmsg ("both eid v4 and v6 addresses set");
16437 if (!ipv4_set && !ipv6_set)
16439 errmsg ("eid addresses not set");
16443 /* Construct the API message */
16444 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
16446 mp->is_add = is_add;
16450 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16455 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16461 /* Wait for a reply... */
16466 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
16469 api_lisp_gpe_enable_disable (vat_main_t * vam)
16471 unformat_input_t *input = vam->input;
16472 vl_api_gpe_enable_disable_t *mp;
16477 /* Parse args required to build the message */
16478 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16480 if (unformat (input, "enable"))
16485 else if (unformat (input, "disable"))
16496 errmsg ("Value not set");
16500 /* Construct the API message */
16501 M (GPE_ENABLE_DISABLE, mp);
16508 /* Wait for a reply... */
16514 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16516 unformat_input_t *input = vam->input;
16517 vl_api_one_rloc_probe_enable_disable_t *mp;
16522 /* Parse args required to build the message */
16523 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16525 if (unformat (input, "enable"))
16530 else if (unformat (input, "disable"))
16538 errmsg ("Value not set");
16542 /* Construct the API message */
16543 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16545 mp->is_enabled = is_en;
16550 /* Wait for a reply... */
16555 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16558 api_one_map_register_enable_disable (vat_main_t * vam)
16560 unformat_input_t *input = vam->input;
16561 vl_api_one_map_register_enable_disable_t *mp;
16566 /* Parse args required to build the message */
16567 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16569 if (unformat (input, "enable"))
16574 else if (unformat (input, "disable"))
16582 errmsg ("Value not set");
16586 /* Construct the API message */
16587 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16589 mp->is_enabled = is_en;
16594 /* Wait for a reply... */
16599 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16602 api_one_enable_disable (vat_main_t * vam)
16604 unformat_input_t *input = vam->input;
16605 vl_api_one_enable_disable_t *mp;
16610 /* Parse args required to build the message */
16611 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16613 if (unformat (input, "enable"))
16618 else if (unformat (input, "disable"))
16628 errmsg ("Value not set");
16632 /* Construct the API message */
16633 M (ONE_ENABLE_DISABLE, mp);
16640 /* Wait for a reply... */
16645 #define api_lisp_enable_disable api_one_enable_disable
16648 api_one_enable_disable_xtr_mode (vat_main_t * vam)
16650 unformat_input_t *input = vam->input;
16651 vl_api_one_enable_disable_xtr_mode_t *mp;
16656 /* Parse args required to build the message */
16657 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16659 if (unformat (input, "enable"))
16664 else if (unformat (input, "disable"))
16674 errmsg ("Value not set");
16678 /* Construct the API message */
16679 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
16686 /* Wait for a reply... */
16692 api_one_show_xtr_mode (vat_main_t * vam)
16694 vl_api_one_show_xtr_mode_t *mp;
16697 /* Construct the API message */
16698 M (ONE_SHOW_XTR_MODE, mp);
16703 /* Wait for a reply... */
16709 api_one_enable_disable_pitr_mode (vat_main_t * vam)
16711 unformat_input_t *input = vam->input;
16712 vl_api_one_enable_disable_pitr_mode_t *mp;
16717 /* Parse args required to build the message */
16718 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16720 if (unformat (input, "enable"))
16725 else if (unformat (input, "disable"))
16735 errmsg ("Value not set");
16739 /* Construct the API message */
16740 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
16747 /* Wait for a reply... */
16753 api_one_show_pitr_mode (vat_main_t * vam)
16755 vl_api_one_show_pitr_mode_t *mp;
16758 /* Construct the API message */
16759 M (ONE_SHOW_PITR_MODE, mp);
16764 /* Wait for a reply... */
16770 api_one_enable_disable_petr_mode (vat_main_t * vam)
16772 unformat_input_t *input = vam->input;
16773 vl_api_one_enable_disable_petr_mode_t *mp;
16778 /* Parse args required to build the message */
16779 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16781 if (unformat (input, "enable"))
16786 else if (unformat (input, "disable"))
16796 errmsg ("Value not set");
16800 /* Construct the API message */
16801 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
16808 /* Wait for a reply... */
16814 api_one_show_petr_mode (vat_main_t * vam)
16816 vl_api_one_show_petr_mode_t *mp;
16819 /* Construct the API message */
16820 M (ONE_SHOW_PETR_MODE, mp);
16825 /* Wait for a reply... */
16831 api_show_one_map_register_state (vat_main_t * vam)
16833 vl_api_show_one_map_register_state_t *mp;
16836 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16841 /* wait for reply */
16846 #define api_show_lisp_map_register_state api_show_one_map_register_state
16849 api_show_one_rloc_probe_state (vat_main_t * vam)
16851 vl_api_show_one_rloc_probe_state_t *mp;
16854 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16859 /* wait for reply */
16864 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16867 api_one_add_del_ndp_entry (vat_main_t * vam)
16869 vl_api_one_add_del_ndp_entry_t *mp;
16870 unformat_input_t *input = vam->input;
16875 u8 mac[6] = { 0, };
16876 u8 ip6[16] = { 0, };
16880 /* Parse args required to build the message */
16881 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16883 if (unformat (input, "del"))
16885 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16887 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16889 else if (unformat (input, "bd %d", &bd))
16893 errmsg ("parse error '%U'", format_unformat_error, input);
16898 if (!bd_set || !ip_set || (!mac_set && is_add))
16900 errmsg ("Missing BD, IP or MAC!");
16904 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16905 mp->is_add = is_add;
16906 clib_memcpy (mp->mac, mac, 6);
16907 mp->bd = clib_host_to_net_u32 (bd);
16908 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16913 /* wait for reply */
16919 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16921 vl_api_one_add_del_l2_arp_entry_t *mp;
16922 unformat_input_t *input = vam->input;
16927 u8 mac[6] = { 0, };
16928 u32 ip4 = 0, bd = ~0;
16931 /* Parse args required to build the message */
16932 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16934 if (unformat (input, "del"))
16936 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16938 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16940 else if (unformat (input, "bd %d", &bd))
16944 errmsg ("parse error '%U'", format_unformat_error, input);
16949 if (!bd_set || !ip_set || (!mac_set && is_add))
16951 errmsg ("Missing BD, IP or MAC!");
16955 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16956 mp->is_add = is_add;
16957 clib_memcpy (mp->mac, mac, 6);
16958 mp->bd = clib_host_to_net_u32 (bd);
16964 /* wait for reply */
16970 api_one_ndp_bd_get (vat_main_t * vam)
16972 vl_api_one_ndp_bd_get_t *mp;
16975 M (ONE_NDP_BD_GET, mp);
16980 /* wait for reply */
16986 api_one_ndp_entries_get (vat_main_t * vam)
16988 vl_api_one_ndp_entries_get_t *mp;
16989 unformat_input_t *input = vam->input;
16994 /* Parse args required to build the message */
16995 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16997 if (unformat (input, "bd %d", &bd))
17001 errmsg ("parse error '%U'", format_unformat_error, input);
17008 errmsg ("Expected bridge domain!");
17012 M (ONE_NDP_ENTRIES_GET, mp);
17013 mp->bd = clib_host_to_net_u32 (bd);
17018 /* wait for reply */
17024 api_one_l2_arp_bd_get (vat_main_t * vam)
17026 vl_api_one_l2_arp_bd_get_t *mp;
17029 M (ONE_L2_ARP_BD_GET, mp);
17034 /* wait for reply */
17040 api_one_l2_arp_entries_get (vat_main_t * vam)
17042 vl_api_one_l2_arp_entries_get_t *mp;
17043 unformat_input_t *input = vam->input;
17048 /* Parse args required to build the message */
17049 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17051 if (unformat (input, "bd %d", &bd))
17055 errmsg ("parse error '%U'", format_unformat_error, input);
17062 errmsg ("Expected bridge domain!");
17066 M (ONE_L2_ARP_ENTRIES_GET, mp);
17067 mp->bd = clib_host_to_net_u32 (bd);
17072 /* wait for reply */
17078 api_one_stats_enable_disable (vat_main_t * vam)
17080 vl_api_one_stats_enable_disable_t *mp;
17081 unformat_input_t *input = vam->input;
17086 /* Parse args required to build the message */
17087 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17089 if (unformat (input, "enable"))
17094 else if (unformat (input, "disable"))
17104 errmsg ("Value not set");
17108 M (ONE_STATS_ENABLE_DISABLE, mp);
17114 /* wait for reply */
17120 api_show_one_stats_enable_disable (vat_main_t * vam)
17122 vl_api_show_one_stats_enable_disable_t *mp;
17125 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
17130 /* wait for reply */
17136 api_show_one_map_request_mode (vat_main_t * vam)
17138 vl_api_show_one_map_request_mode_t *mp;
17141 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
17146 /* wait for reply */
17151 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
17154 api_one_map_request_mode (vat_main_t * vam)
17156 unformat_input_t *input = vam->input;
17157 vl_api_one_map_request_mode_t *mp;
17161 /* Parse args required to build the message */
17162 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17164 if (unformat (input, "dst-only"))
17166 else if (unformat (input, "src-dst"))
17170 errmsg ("parse error '%U'", format_unformat_error, input);
17175 M (ONE_MAP_REQUEST_MODE, mp);
17182 /* wait for reply */
17187 #define api_lisp_map_request_mode api_one_map_request_mode
17190 * Enable/disable ONE proxy ITR.
17192 * @param vam vpp API test context
17193 * @return return code
17196 api_one_pitr_set_locator_set (vat_main_t * vam)
17198 u8 ls_name_set = 0;
17199 unformat_input_t *input = vam->input;
17200 vl_api_one_pitr_set_locator_set_t *mp;
17205 /* Parse args required to build the message */
17206 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17208 if (unformat (input, "del"))
17210 else if (unformat (input, "locator-set %s", &ls_name))
17214 errmsg ("parse error '%U'", format_unformat_error, input);
17221 errmsg ("locator-set name not set!");
17225 M (ONE_PITR_SET_LOCATOR_SET, mp);
17227 mp->is_add = is_add;
17228 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17229 vec_free (ls_name);
17234 /* wait for reply */
17239 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
17242 api_one_nsh_set_locator_set (vat_main_t * vam)
17244 u8 ls_name_set = 0;
17245 unformat_input_t *input = vam->input;
17246 vl_api_one_nsh_set_locator_set_t *mp;
17251 /* Parse args required to build the message */
17252 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17254 if (unformat (input, "del"))
17256 else if (unformat (input, "ls %s", &ls_name))
17260 errmsg ("parse error '%U'", format_unformat_error, input);
17265 if (!ls_name_set && is_add)
17267 errmsg ("locator-set name not set!");
17271 M (ONE_NSH_SET_LOCATOR_SET, mp);
17273 mp->is_add = is_add;
17274 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17275 vec_free (ls_name);
17280 /* wait for reply */
17286 api_show_one_pitr (vat_main_t * vam)
17288 vl_api_show_one_pitr_t *mp;
17291 if (!vam->json_output)
17293 print (vam->ofp, "%=20s", "lisp status:");
17296 M (SHOW_ONE_PITR, mp);
17300 /* Wait for a reply... */
17305 #define api_show_lisp_pitr api_show_one_pitr
17308 api_one_use_petr (vat_main_t * vam)
17310 unformat_input_t *input = vam->input;
17311 vl_api_one_use_petr_t *mp;
17316 memset (&ip, 0, sizeof (ip));
17318 /* Parse args required to build the message */
17319 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17321 if (unformat (input, "disable"))
17324 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
17327 ip_addr_version (&ip) = IP4;
17330 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
17333 ip_addr_version (&ip) = IP6;
17337 errmsg ("parse error '%U'", format_unformat_error, input);
17342 M (ONE_USE_PETR, mp);
17344 mp->is_add = is_add;
17347 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
17349 clib_memcpy (mp->address, &ip, 4);
17351 clib_memcpy (mp->address, &ip, 16);
17357 /* wait for reply */
17362 #define api_lisp_use_petr api_one_use_petr
17365 api_show_one_nsh_mapping (vat_main_t * vam)
17367 vl_api_show_one_use_petr_t *mp;
17370 if (!vam->json_output)
17372 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
17375 M (SHOW_ONE_NSH_MAPPING, mp);
17379 /* Wait for a reply... */
17385 api_show_one_use_petr (vat_main_t * vam)
17387 vl_api_show_one_use_petr_t *mp;
17390 if (!vam->json_output)
17392 print (vam->ofp, "%=20s", "Proxy-ETR status:");
17395 M (SHOW_ONE_USE_PETR, mp);
17399 /* Wait for a reply... */
17404 #define api_show_lisp_use_petr api_show_one_use_petr
17407 * Add/delete mapping between vni and vrf
17410 api_one_eid_table_add_del_map (vat_main_t * vam)
17412 unformat_input_t *input = vam->input;
17413 vl_api_one_eid_table_add_del_map_t *mp;
17414 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
17415 u32 vni, vrf, bd_index;
17418 /* Parse args required to build the message */
17419 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17421 if (unformat (input, "del"))
17423 else if (unformat (input, "vrf %d", &vrf))
17425 else if (unformat (input, "bd_index %d", &bd_index))
17427 else if (unformat (input, "vni %d", &vni))
17433 if (!vni_set || (!vrf_set && !bd_index_set))
17435 errmsg ("missing arguments!");
17439 if (vrf_set && bd_index_set)
17441 errmsg ("error: both vrf and bd entered!");
17445 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
17447 mp->is_add = is_add;
17448 mp->vni = htonl (vni);
17449 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
17450 mp->is_l2 = bd_index_set;
17455 /* wait for reply */
17460 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
17463 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
17465 u32 *action = va_arg (*args, u32 *);
17468 if (unformat (input, "%s", &s))
17470 if (!strcmp ((char *) s, "no-action"))
17472 else if (!strcmp ((char *) s, "natively-forward"))
17474 else if (!strcmp ((char *) s, "send-map-request"))
17476 else if (!strcmp ((char *) s, "drop"))
17480 clib_warning ("invalid action: '%s'", s);
17492 * Add/del remote mapping to/from ONE control plane
17494 * @param vam vpp API test context
17495 * @return return code
17498 api_one_add_del_remote_mapping (vat_main_t * vam)
17500 unformat_input_t *input = vam->input;
17501 vl_api_one_add_del_remote_mapping_t *mp;
17503 lisp_eid_vat_t _eid, *eid = &_eid;
17504 lisp_eid_vat_t _seid, *seid = &_seid;
17505 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
17506 u32 action = ~0, p, w, data_len;
17507 ip4_address_t rloc4;
17508 ip6_address_t rloc6;
17509 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
17512 memset (&rloc, 0, sizeof (rloc));
17514 /* Parse args required to build the message */
17515 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17517 if (unformat (input, "del-all"))
17521 else if (unformat (input, "del"))
17525 else if (unformat (input, "add"))
17529 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17533 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
17537 else if (unformat (input, "vni %d", &vni))
17541 else if (unformat (input, "p %d w %d", &p, &w))
17545 errmsg ("No RLOC configured for setting priority/weight!");
17548 curr_rloc->priority = p;
17549 curr_rloc->weight = w;
17551 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
17554 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
17555 vec_add1 (rlocs, rloc);
17556 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17558 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
17561 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
17562 vec_add1 (rlocs, rloc);
17563 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17565 else if (unformat (input, "action %U",
17566 unformat_negative_mapping_action, &action))
17572 clib_warning ("parse error '%U'", format_unformat_error, input);
17579 errmsg ("missing params!");
17583 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
17585 errmsg ("no action set for negative map-reply!");
17589 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
17591 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
17592 mp->is_add = is_add;
17593 mp->vni = htonl (vni);
17594 mp->action = (u8) action;
17595 mp->is_src_dst = seid_set;
17596 mp->eid_len = eid->len;
17597 mp->seid_len = seid->len;
17598 mp->del_all = del_all;
17599 mp->eid_type = eid->type;
17600 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17601 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
17603 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
17604 clib_memcpy (mp->rlocs, rlocs, data_len);
17610 /* Wait for a reply... */
17615 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
17618 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
17619 * forwarding entries in data-plane accordingly.
17621 * @param vam vpp API test context
17622 * @return return code
17625 api_one_add_del_adjacency (vat_main_t * vam)
17627 unformat_input_t *input = vam->input;
17628 vl_api_one_add_del_adjacency_t *mp;
17630 ip4_address_t leid4, reid4;
17631 ip6_address_t leid6, reid6;
17632 u8 reid_mac[6] = { 0 };
17633 u8 leid_mac[6] = { 0 };
17634 u8 reid_type, leid_type;
17635 u32 leid_len = 0, reid_len = 0, len;
17639 leid_type = reid_type = (u8) ~ 0;
17641 /* Parse args required to build the message */
17642 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17644 if (unformat (input, "del"))
17648 else if (unformat (input, "add"))
17652 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17655 reid_type = 0; /* ipv4 */
17658 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17661 reid_type = 1; /* ipv6 */
17664 else if (unformat (input, "reid %U", unformat_ethernet_address,
17667 reid_type = 2; /* mac */
17669 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17672 leid_type = 0; /* ipv4 */
17675 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17678 leid_type = 1; /* ipv6 */
17681 else if (unformat (input, "leid %U", unformat_ethernet_address,
17684 leid_type = 2; /* mac */
17686 else if (unformat (input, "vni %d", &vni))
17692 errmsg ("parse error '%U'", format_unformat_error, input);
17697 if ((u8) ~ 0 == reid_type)
17699 errmsg ("missing params!");
17703 if (leid_type != reid_type)
17705 errmsg ("remote and local EIDs are of different types!");
17709 M (ONE_ADD_DEL_ADJACENCY, mp);
17710 mp->is_add = is_add;
17711 mp->vni = htonl (vni);
17712 mp->leid_len = leid_len;
17713 mp->reid_len = reid_len;
17714 mp->eid_type = reid_type;
17716 switch (mp->eid_type)
17719 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17720 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17723 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17724 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17727 clib_memcpy (mp->leid, leid_mac, 6);
17728 clib_memcpy (mp->reid, reid_mac, 6);
17731 errmsg ("unknown EID type %d!", mp->eid_type);
17738 /* Wait for a reply... */
17743 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17746 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17748 u32 *mode = va_arg (*args, u32 *);
17750 if (unformat (input, "lisp"))
17752 else if (unformat (input, "vxlan"))
17761 api_gpe_get_encap_mode (vat_main_t * vam)
17763 vl_api_gpe_get_encap_mode_t *mp;
17766 /* Construct the API message */
17767 M (GPE_GET_ENCAP_MODE, mp);
17772 /* Wait for a reply... */
17778 api_gpe_set_encap_mode (vat_main_t * vam)
17780 unformat_input_t *input = vam->input;
17781 vl_api_gpe_set_encap_mode_t *mp;
17785 /* Parse args required to build the message */
17786 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17788 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17794 /* Construct the API message */
17795 M (GPE_SET_ENCAP_MODE, mp);
17802 /* Wait for a reply... */
17808 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17810 unformat_input_t *input = vam->input;
17811 vl_api_gpe_add_del_iface_t *mp;
17812 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17813 u32 dp_table = 0, vni = 0;
17816 /* Parse args required to build the message */
17817 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17819 if (unformat (input, "up"))
17824 else if (unformat (input, "down"))
17829 else if (unformat (input, "table_id %d", &dp_table))
17833 else if (unformat (input, "bd_id %d", &dp_table))
17838 else if (unformat (input, "vni %d", &vni))
17846 if (action_set == 0)
17848 errmsg ("Action not set");
17851 if (dp_table_set == 0 || vni_set == 0)
17853 errmsg ("vni and dp_table must be set");
17857 /* Construct the API message */
17858 M (GPE_ADD_DEL_IFACE, mp);
17860 mp->is_add = is_add;
17861 mp->dp_table = clib_host_to_net_u32 (dp_table);
17863 mp->vni = clib_host_to_net_u32 (vni);
17868 /* Wait for a reply... */
17874 api_one_map_register_fallback_threshold (vat_main_t * vam)
17876 unformat_input_t *input = vam->input;
17877 vl_api_one_map_register_fallback_threshold_t *mp;
17882 /* Parse args required to build the message */
17883 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17885 if (unformat (input, "%u", &value))
17889 clib_warning ("parse error '%U'", format_unformat_error, input);
17896 errmsg ("fallback threshold value is missing!");
17900 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17901 mp->value = clib_host_to_net_u32 (value);
17906 /* Wait for a reply... */
17912 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17914 vl_api_show_one_map_register_fallback_threshold_t *mp;
17917 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17922 /* Wait for a reply... */
17928 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17930 u32 *proto = va_arg (*args, u32 *);
17932 if (unformat (input, "udp"))
17934 else if (unformat (input, "api"))
17943 api_one_set_transport_protocol (vat_main_t * vam)
17945 unformat_input_t *input = vam->input;
17946 vl_api_one_set_transport_protocol_t *mp;
17951 /* Parse args required to build the message */
17952 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17954 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17958 clib_warning ("parse error '%U'", format_unformat_error, input);
17965 errmsg ("Transport protocol missing!");
17969 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17970 mp->protocol = (u8) protocol;
17975 /* Wait for a reply... */
17981 api_one_get_transport_protocol (vat_main_t * vam)
17983 vl_api_one_get_transport_protocol_t *mp;
17986 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17991 /* Wait for a reply... */
17997 api_one_map_register_set_ttl (vat_main_t * vam)
17999 unformat_input_t *input = vam->input;
18000 vl_api_one_map_register_set_ttl_t *mp;
18005 /* Parse args required to build the message */
18006 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18008 if (unformat (input, "%u", &ttl))
18012 clib_warning ("parse error '%U'", format_unformat_error, input);
18019 errmsg ("TTL value missing!");
18023 M (ONE_MAP_REGISTER_SET_TTL, mp);
18024 mp->ttl = clib_host_to_net_u32 (ttl);
18029 /* Wait for a reply... */
18035 api_show_one_map_register_ttl (vat_main_t * vam)
18037 vl_api_show_one_map_register_ttl_t *mp;
18040 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
18045 /* Wait for a reply... */
18051 * Add/del map request itr rlocs from ONE control plane and updates
18053 * @param vam vpp API test context
18054 * @return return code
18057 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
18059 unformat_input_t *input = vam->input;
18060 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
18061 u8 *locator_set_name = 0;
18062 u8 locator_set_name_set = 0;
18066 /* Parse args required to build the message */
18067 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18069 if (unformat (input, "del"))
18073 else if (unformat (input, "%_%v%_", &locator_set_name))
18075 locator_set_name_set = 1;
18079 clib_warning ("parse error '%U'", format_unformat_error, input);
18084 if (is_add && !locator_set_name_set)
18086 errmsg ("itr-rloc is not set!");
18090 if (is_add && vec_len (locator_set_name) > 64)
18092 errmsg ("itr-rloc locator-set name too long");
18093 vec_free (locator_set_name);
18097 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
18098 mp->is_add = is_add;
18101 clib_memcpy (mp->locator_set_name, locator_set_name,
18102 vec_len (locator_set_name));
18106 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
18108 vec_free (locator_set_name);
18113 /* Wait for a reply... */
18118 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
18121 api_one_locator_dump (vat_main_t * vam)
18123 unformat_input_t *input = vam->input;
18124 vl_api_one_locator_dump_t *mp;
18125 vl_api_control_ping_t *mp_ping;
18126 u8 is_index_set = 0, is_name_set = 0;
18131 /* Parse args required to build the message */
18132 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18134 if (unformat (input, "ls_name %_%v%_", &ls_name))
18138 else if (unformat (input, "ls_index %d", &ls_index))
18144 errmsg ("parse error '%U'", format_unformat_error, input);
18149 if (!is_index_set && !is_name_set)
18151 errmsg ("error: expected one of index or name!");
18155 if (is_index_set && is_name_set)
18157 errmsg ("error: only one param expected!");
18161 if (vec_len (ls_name) > 62)
18163 errmsg ("error: locator set name too long!");
18167 if (!vam->json_output)
18169 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
18172 M (ONE_LOCATOR_DUMP, mp);
18173 mp->is_index_set = is_index_set;
18176 mp->ls_index = clib_host_to_net_u32 (ls_index);
18179 vec_add1 (ls_name, 0);
18180 strncpy ((char *) mp->ls_name, (char *) ls_name,
18181 sizeof (mp->ls_name) - 1);
18187 /* Use a control ping for synchronization */
18188 MPING (CONTROL_PING, mp_ping);
18191 /* Wait for a reply... */
18196 #define api_lisp_locator_dump api_one_locator_dump
18199 api_one_locator_set_dump (vat_main_t * vam)
18201 vl_api_one_locator_set_dump_t *mp;
18202 vl_api_control_ping_t *mp_ping;
18203 unformat_input_t *input = vam->input;
18207 /* Parse args required to build the message */
18208 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18210 if (unformat (input, "local"))
18214 else if (unformat (input, "remote"))
18220 errmsg ("parse error '%U'", format_unformat_error, input);
18225 if (!vam->json_output)
18227 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
18230 M (ONE_LOCATOR_SET_DUMP, mp);
18232 mp->filter = filter;
18237 /* Use a control ping for synchronization */
18238 MPING (CONTROL_PING, mp_ping);
18241 /* Wait for a reply... */
18246 #define api_lisp_locator_set_dump api_one_locator_set_dump
18249 api_one_eid_table_map_dump (vat_main_t * vam)
18253 unformat_input_t *input = vam->input;
18254 vl_api_one_eid_table_map_dump_t *mp;
18255 vl_api_control_ping_t *mp_ping;
18258 /* Parse args required to build the message */
18259 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18261 if (unformat (input, "l2"))
18266 else if (unformat (input, "l3"))
18273 errmsg ("parse error '%U'", format_unformat_error, input);
18280 errmsg ("expected one of 'l2' or 'l3' parameter!");
18284 if (!vam->json_output)
18286 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
18289 M (ONE_EID_TABLE_MAP_DUMP, mp);
18295 /* Use a control ping for synchronization */
18296 MPING (CONTROL_PING, mp_ping);
18299 /* Wait for a reply... */
18304 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
18307 api_one_eid_table_vni_dump (vat_main_t * vam)
18309 vl_api_one_eid_table_vni_dump_t *mp;
18310 vl_api_control_ping_t *mp_ping;
18313 if (!vam->json_output)
18315 print (vam->ofp, "VNI");
18318 M (ONE_EID_TABLE_VNI_DUMP, mp);
18323 /* Use a control ping for synchronization */
18324 MPING (CONTROL_PING, mp_ping);
18327 /* Wait for a reply... */
18332 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
18335 api_one_eid_table_dump (vat_main_t * vam)
18337 unformat_input_t *i = vam->input;
18338 vl_api_one_eid_table_dump_t *mp;
18339 vl_api_control_ping_t *mp_ping;
18340 struct in_addr ip4;
18341 struct in6_addr ip6;
18343 u8 eid_type = ~0, eid_set = 0;
18344 u32 prefix_length = ~0, t, vni = 0;
18347 lisp_nsh_api_t nsh;
18349 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18351 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
18357 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
18363 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
18368 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
18373 else if (unformat (i, "vni %d", &t))
18377 else if (unformat (i, "local"))
18381 else if (unformat (i, "remote"))
18387 errmsg ("parse error '%U'", format_unformat_error, i);
18392 if (!vam->json_output)
18394 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
18395 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
18398 M (ONE_EID_TABLE_DUMP, mp);
18400 mp->filter = filter;
18404 mp->vni = htonl (vni);
18405 mp->eid_type = eid_type;
18409 mp->prefix_length = prefix_length;
18410 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
18413 mp->prefix_length = prefix_length;
18414 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
18417 clib_memcpy (mp->eid, mac, sizeof (mac));
18420 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
18423 errmsg ("unknown EID type %d!", eid_type);
18431 /* Use a control ping for synchronization */
18432 MPING (CONTROL_PING, mp_ping);
18435 /* Wait for a reply... */
18440 #define api_lisp_eid_table_dump api_one_eid_table_dump
18443 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
18445 unformat_input_t *i = vam->input;
18446 vl_api_gpe_fwd_entries_get_t *mp;
18451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18453 if (unformat (i, "vni %d", &vni))
18459 errmsg ("parse error '%U'", format_unformat_error, i);
18466 errmsg ("vni not set!");
18470 if (!vam->json_output)
18472 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
18476 M (GPE_FWD_ENTRIES_GET, mp);
18477 mp->vni = clib_host_to_net_u32 (vni);
18482 /* Wait for a reply... */
18487 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
18488 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
18489 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
18490 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
18491 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
18492 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
18493 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
18494 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
18497 api_one_adjacencies_get (vat_main_t * vam)
18499 unformat_input_t *i = vam->input;
18500 vl_api_one_adjacencies_get_t *mp;
18505 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18507 if (unformat (i, "vni %d", &vni))
18513 errmsg ("parse error '%U'", format_unformat_error, i);
18520 errmsg ("vni not set!");
18524 if (!vam->json_output)
18526 print (vam->ofp, "%s %40s", "leid", "reid");
18529 M (ONE_ADJACENCIES_GET, mp);
18530 mp->vni = clib_host_to_net_u32 (vni);
18535 /* Wait for a reply... */
18540 #define api_lisp_adjacencies_get api_one_adjacencies_get
18543 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
18545 unformat_input_t *i = vam->input;
18546 vl_api_gpe_native_fwd_rpaths_get_t *mp;
18548 u8 ip_family_set = 0, is_ip4 = 1;
18550 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18552 if (unformat (i, "ip4"))
18557 else if (unformat (i, "ip6"))
18564 errmsg ("parse error '%U'", format_unformat_error, i);
18569 if (!ip_family_set)
18571 errmsg ("ip family not set!");
18575 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
18576 mp->is_ip4 = is_ip4;
18581 /* Wait for a reply... */
18587 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
18589 vl_api_gpe_fwd_entry_vnis_get_t *mp;
18592 if (!vam->json_output)
18594 print (vam->ofp, "VNIs");
18597 M (GPE_FWD_ENTRY_VNIS_GET, mp);
18602 /* Wait for a reply... */
18608 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
18610 unformat_input_t *i = vam->input;
18611 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
18613 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
18614 struct in_addr ip4;
18615 struct in6_addr ip6;
18616 u32 table_id = 0, nh_sw_if_index = ~0;
18618 memset (&ip4, 0, sizeof (ip4));
18619 memset (&ip6, 0, sizeof (ip6));
18621 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18623 if (unformat (i, "del"))
18625 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
18626 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18631 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
18632 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18637 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18641 nh_sw_if_index = ~0;
18643 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18647 nh_sw_if_index = ~0;
18649 else if (unformat (i, "table %d", &table_id))
18653 errmsg ("parse error '%U'", format_unformat_error, i);
18660 errmsg ("nh addr not set!");
18664 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18665 mp->is_add = is_add;
18666 mp->table_id = clib_host_to_net_u32 (table_id);
18667 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18668 mp->is_ip4 = is_ip4;
18670 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18672 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18677 /* Wait for a reply... */
18683 api_one_map_server_dump (vat_main_t * vam)
18685 vl_api_one_map_server_dump_t *mp;
18686 vl_api_control_ping_t *mp_ping;
18689 if (!vam->json_output)
18691 print (vam->ofp, "%=20s", "Map server");
18694 M (ONE_MAP_SERVER_DUMP, mp);
18698 /* Use a control ping for synchronization */
18699 MPING (CONTROL_PING, mp_ping);
18702 /* Wait for a reply... */
18707 #define api_lisp_map_server_dump api_one_map_server_dump
18710 api_one_map_resolver_dump (vat_main_t * vam)
18712 vl_api_one_map_resolver_dump_t *mp;
18713 vl_api_control_ping_t *mp_ping;
18716 if (!vam->json_output)
18718 print (vam->ofp, "%=20s", "Map resolver");
18721 M (ONE_MAP_RESOLVER_DUMP, mp);
18725 /* Use a control ping for synchronization */
18726 MPING (CONTROL_PING, mp_ping);
18729 /* Wait for a reply... */
18734 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18737 api_one_stats_flush (vat_main_t * vam)
18739 vl_api_one_stats_flush_t *mp;
18742 M (ONE_STATS_FLUSH, mp);
18749 api_one_stats_dump (vat_main_t * vam)
18751 vl_api_one_stats_dump_t *mp;
18752 vl_api_control_ping_t *mp_ping;
18755 M (ONE_STATS_DUMP, mp);
18759 /* Use a control ping for synchronization */
18760 MPING (CONTROL_PING, mp_ping);
18763 /* Wait for a reply... */
18769 api_show_one_status (vat_main_t * vam)
18771 vl_api_show_one_status_t *mp;
18774 if (!vam->json_output)
18776 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18779 M (SHOW_ONE_STATUS, mp);
18782 /* Wait for a reply... */
18787 #define api_show_lisp_status api_show_one_status
18790 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18792 vl_api_gpe_fwd_entry_path_dump_t *mp;
18793 vl_api_control_ping_t *mp_ping;
18794 unformat_input_t *i = vam->input;
18795 u32 fwd_entry_index = ~0;
18798 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18800 if (unformat (i, "index %d", &fwd_entry_index))
18806 if (~0 == fwd_entry_index)
18808 errmsg ("no index specified!");
18812 if (!vam->json_output)
18814 print (vam->ofp, "first line");
18817 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18821 /* Use a control ping for synchronization */
18822 MPING (CONTROL_PING, mp_ping);
18825 /* Wait for a reply... */
18831 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18833 vl_api_one_get_map_request_itr_rlocs_t *mp;
18836 if (!vam->json_output)
18838 print (vam->ofp, "%=20s", "itr-rlocs:");
18841 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18844 /* Wait for a reply... */
18849 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18852 api_af_packet_create (vat_main_t * vam)
18854 unformat_input_t *i = vam->input;
18855 vl_api_af_packet_create_t *mp;
18856 u8 *host_if_name = 0;
18858 u8 random_hw_addr = 1;
18861 memset (hw_addr, 0, sizeof (hw_addr));
18863 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18865 if (unformat (i, "name %s", &host_if_name))
18866 vec_add1 (host_if_name, 0);
18867 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18868 random_hw_addr = 0;
18873 if (!vec_len (host_if_name))
18875 errmsg ("host-interface name must be specified");
18879 if (vec_len (host_if_name) > 64)
18881 errmsg ("host-interface name too long");
18885 M (AF_PACKET_CREATE, mp);
18887 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18888 clib_memcpy (mp->hw_addr, hw_addr, 6);
18889 mp->use_random_hw_addr = random_hw_addr;
18890 vec_free (host_if_name);
18898 fprintf (vam->ofp ? vam->ofp : stderr,
18899 " new sw_if_index = %d\n", vam->sw_if_index);
18906 api_af_packet_delete (vat_main_t * vam)
18908 unformat_input_t *i = vam->input;
18909 vl_api_af_packet_delete_t *mp;
18910 u8 *host_if_name = 0;
18913 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18915 if (unformat (i, "name %s", &host_if_name))
18916 vec_add1 (host_if_name, 0);
18921 if (!vec_len (host_if_name))
18923 errmsg ("host-interface name must be specified");
18927 if (vec_len (host_if_name) > 64)
18929 errmsg ("host-interface name too long");
18933 M (AF_PACKET_DELETE, mp);
18935 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18936 vec_free (host_if_name);
18944 api_policer_add_del (vat_main_t * vam)
18946 unformat_input_t *i = vam->input;
18947 vl_api_policer_add_del_t *mp;
18957 u8 color_aware = 0;
18958 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18961 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18962 conform_action.dscp = 0;
18963 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18964 exceed_action.dscp = 0;
18965 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18966 violate_action.dscp = 0;
18968 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18970 if (unformat (i, "del"))
18972 else if (unformat (i, "name %s", &name))
18973 vec_add1 (name, 0);
18974 else if (unformat (i, "cir %u", &cir))
18976 else if (unformat (i, "eir %u", &eir))
18978 else if (unformat (i, "cb %u", &cb))
18980 else if (unformat (i, "eb %u", &eb))
18982 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18985 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18988 else if (unformat (i, "type %U", unformat_policer_type, &type))
18990 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18993 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18996 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18999 else if (unformat (i, "color-aware"))
19005 if (!vec_len (name))
19007 errmsg ("policer name must be specified");
19011 if (vec_len (name) > 64)
19013 errmsg ("policer name too long");
19017 M (POLICER_ADD_DEL, mp);
19019 clib_memcpy (mp->name, name, vec_len (name));
19021 mp->is_add = is_add;
19022 mp->cir = ntohl (cir);
19023 mp->eir = ntohl (eir);
19024 mp->cb = clib_net_to_host_u64 (cb);
19025 mp->eb = clib_net_to_host_u64 (eb);
19026 mp->rate_type = rate_type;
19027 mp->round_type = round_type;
19029 mp->conform_action_type = conform_action.action_type;
19030 mp->conform_dscp = conform_action.dscp;
19031 mp->exceed_action_type = exceed_action.action_type;
19032 mp->exceed_dscp = exceed_action.dscp;
19033 mp->violate_action_type = violate_action.action_type;
19034 mp->violate_dscp = violate_action.dscp;
19035 mp->color_aware = color_aware;
19043 api_policer_dump (vat_main_t * vam)
19045 unformat_input_t *i = vam->input;
19046 vl_api_policer_dump_t *mp;
19047 vl_api_control_ping_t *mp_ping;
19048 u8 *match_name = 0;
19049 u8 match_name_valid = 0;
19052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19054 if (unformat (i, "name %s", &match_name))
19056 vec_add1 (match_name, 0);
19057 match_name_valid = 1;
19063 M (POLICER_DUMP, mp);
19064 mp->match_name_valid = match_name_valid;
19065 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
19066 vec_free (match_name);
19070 /* Use a control ping for synchronization */
19071 MPING (CONTROL_PING, mp_ping);
19074 /* Wait for a reply... */
19080 api_policer_classify_set_interface (vat_main_t * vam)
19082 unformat_input_t *i = vam->input;
19083 vl_api_policer_classify_set_interface_t *mp;
19085 int sw_if_index_set;
19086 u32 ip4_table_index = ~0;
19087 u32 ip6_table_index = ~0;
19088 u32 l2_table_index = ~0;
19092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19094 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19095 sw_if_index_set = 1;
19096 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19097 sw_if_index_set = 1;
19098 else if (unformat (i, "del"))
19100 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19102 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19104 else if (unformat (i, "l2-table %d", &l2_table_index))
19108 clib_warning ("parse error '%U'", format_unformat_error, i);
19113 if (sw_if_index_set == 0)
19115 errmsg ("missing interface name or sw_if_index");
19119 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
19121 mp->sw_if_index = ntohl (sw_if_index);
19122 mp->ip4_table_index = ntohl (ip4_table_index);
19123 mp->ip6_table_index = ntohl (ip6_table_index);
19124 mp->l2_table_index = ntohl (l2_table_index);
19125 mp->is_add = is_add;
19133 api_policer_classify_dump (vat_main_t * vam)
19135 unformat_input_t *i = vam->input;
19136 vl_api_policer_classify_dump_t *mp;
19137 vl_api_control_ping_t *mp_ping;
19138 u8 type = POLICER_CLASSIFY_N_TABLES;
19141 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
19145 errmsg ("classify table type must be specified");
19149 if (!vam->json_output)
19151 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19154 M (POLICER_CLASSIFY_DUMP, mp);
19159 /* Use a control ping for synchronization */
19160 MPING (CONTROL_PING, mp_ping);
19163 /* Wait for a reply... */
19169 api_netmap_create (vat_main_t * vam)
19171 unformat_input_t *i = vam->input;
19172 vl_api_netmap_create_t *mp;
19175 u8 random_hw_addr = 1;
19180 memset (hw_addr, 0, sizeof (hw_addr));
19182 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19184 if (unformat (i, "name %s", &if_name))
19185 vec_add1 (if_name, 0);
19186 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19187 random_hw_addr = 0;
19188 else if (unformat (i, "pipe"))
19190 else if (unformat (i, "master"))
19192 else if (unformat (i, "slave"))
19198 if (!vec_len (if_name))
19200 errmsg ("interface name must be specified");
19204 if (vec_len (if_name) > 64)
19206 errmsg ("interface name too long");
19210 M (NETMAP_CREATE, mp);
19212 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19213 clib_memcpy (mp->hw_addr, hw_addr, 6);
19214 mp->use_random_hw_addr = random_hw_addr;
19215 mp->is_pipe = is_pipe;
19216 mp->is_master = is_master;
19217 vec_free (if_name);
19225 api_netmap_delete (vat_main_t * vam)
19227 unformat_input_t *i = vam->input;
19228 vl_api_netmap_delete_t *mp;
19232 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19234 if (unformat (i, "name %s", &if_name))
19235 vec_add1 (if_name, 0);
19240 if (!vec_len (if_name))
19242 errmsg ("interface name must be specified");
19246 if (vec_len (if_name) > 64)
19248 errmsg ("interface name too long");
19252 M (NETMAP_DELETE, mp);
19254 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19255 vec_free (if_name);
19263 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
19265 if (fp->afi == IP46_TYPE_IP6)
19267 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19268 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19269 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19270 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19271 format_ip6_address, fp->next_hop);
19272 else if (fp->afi == IP46_TYPE_IP4)
19274 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19275 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19276 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19277 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19278 format_ip4_address, fp->next_hop);
19282 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
19283 vl_api_fib_path2_t * fp)
19285 struct in_addr ip4;
19286 struct in6_addr ip6;
19288 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19289 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19290 vat_json_object_add_uint (node, "is_local", fp->is_local);
19291 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19292 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19293 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19294 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19295 if (fp->afi == IP46_TYPE_IP4)
19297 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19298 vat_json_object_add_ip4 (node, "next_hop", ip4);
19300 else if (fp->afi == IP46_TYPE_IP6)
19302 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19303 vat_json_object_add_ip6 (node, "next_hop", ip6);
19308 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
19310 vat_main_t *vam = &vat_main;
19311 int count = ntohl (mp->mt_count);
19312 vl_api_fib_path2_t *fp;
19315 print (vam->ofp, "[%d]: sw_if_index %d via:",
19316 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
19318 for (i = 0; i < count; i++)
19320 vl_api_mpls_fib_path_print (vam, fp);
19324 print (vam->ofp, "");
19327 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
19328 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
19331 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
19333 vat_main_t *vam = &vat_main;
19334 vat_json_node_t *node = NULL;
19335 int count = ntohl (mp->mt_count);
19336 vl_api_fib_path2_t *fp;
19339 if (VAT_JSON_ARRAY != vam->json_tree.type)
19341 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19342 vat_json_init_array (&vam->json_tree);
19344 node = vat_json_array_add (&vam->json_tree);
19346 vat_json_init_object (node);
19347 vat_json_object_add_uint (node, "tunnel_index",
19348 ntohl (mp->mt_tunnel_index));
19349 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
19351 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
19354 for (i = 0; i < count; i++)
19356 vl_api_mpls_fib_path_json_print (node, fp);
19362 api_mpls_tunnel_dump (vat_main_t * vam)
19364 vl_api_mpls_tunnel_dump_t *mp;
19365 vl_api_control_ping_t *mp_ping;
19369 /* Parse args required to build the message */
19370 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
19372 if (!unformat (vam->input, "tunnel_index %d", &index))
19379 print (vam->ofp, " tunnel_index %d", index);
19381 M (MPLS_TUNNEL_DUMP, mp);
19382 mp->tunnel_index = htonl (index);
19385 /* Use a control ping for synchronization */
19386 MPING (CONTROL_PING, mp_ping);
19393 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
19394 #define vl_api_mpls_fib_details_t_print vl_noop_handler
19398 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
19400 vat_main_t *vam = &vat_main;
19401 int count = ntohl (mp->count);
19402 vl_api_fib_path2_t *fp;
19406 "table-id %d, label %u, ess_bit %u",
19407 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
19409 for (i = 0; i < count; i++)
19411 vl_api_mpls_fib_path_print (vam, fp);
19416 static void vl_api_mpls_fib_details_t_handler_json
19417 (vl_api_mpls_fib_details_t * mp)
19419 vat_main_t *vam = &vat_main;
19420 int count = ntohl (mp->count);
19421 vat_json_node_t *node = NULL;
19422 vl_api_fib_path2_t *fp;
19425 if (VAT_JSON_ARRAY != vam->json_tree.type)
19427 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19428 vat_json_init_array (&vam->json_tree);
19430 node = vat_json_array_add (&vam->json_tree);
19432 vat_json_init_object (node);
19433 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19434 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
19435 vat_json_object_add_uint (node, "label", ntohl (mp->label));
19436 vat_json_object_add_uint (node, "path_count", count);
19438 for (i = 0; i < count; i++)
19440 vl_api_mpls_fib_path_json_print (node, fp);
19446 api_mpls_fib_dump (vat_main_t * vam)
19448 vl_api_mpls_fib_dump_t *mp;
19449 vl_api_control_ping_t *mp_ping;
19452 M (MPLS_FIB_DUMP, mp);
19455 /* Use a control ping for synchronization */
19456 MPING (CONTROL_PING, mp_ping);
19463 #define vl_api_ip_fib_details_t_endian vl_noop_handler
19464 #define vl_api_ip_fib_details_t_print vl_noop_handler
19467 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
19469 vat_main_t *vam = &vat_main;
19470 int count = ntohl (mp->count);
19471 vl_api_fib_path_t *fp;
19475 "table-id %d, prefix %U/%d",
19476 ntohl (mp->table_id), format_ip4_address, mp->address,
19477 mp->address_length);
19479 for (i = 0; i < count; i++)
19481 if (fp->afi == IP46_TYPE_IP6)
19483 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19484 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19485 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19486 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19487 format_ip6_address, fp->next_hop);
19488 else if (fp->afi == IP46_TYPE_IP4)
19490 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19491 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19492 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19493 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19494 format_ip4_address, fp->next_hop);
19499 static void vl_api_ip_fib_details_t_handler_json
19500 (vl_api_ip_fib_details_t * mp)
19502 vat_main_t *vam = &vat_main;
19503 int count = ntohl (mp->count);
19504 vat_json_node_t *node = NULL;
19505 struct in_addr ip4;
19506 struct in6_addr ip6;
19507 vl_api_fib_path_t *fp;
19510 if (VAT_JSON_ARRAY != vam->json_tree.type)
19512 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19513 vat_json_init_array (&vam->json_tree);
19515 node = vat_json_array_add (&vam->json_tree);
19517 vat_json_init_object (node);
19518 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19519 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
19520 vat_json_object_add_ip4 (node, "prefix", ip4);
19521 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19522 vat_json_object_add_uint (node, "path_count", count);
19524 for (i = 0; i < count; i++)
19526 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19527 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19528 vat_json_object_add_uint (node, "is_local", fp->is_local);
19529 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19530 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19531 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19532 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19533 if (fp->afi == IP46_TYPE_IP4)
19535 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19536 vat_json_object_add_ip4 (node, "next_hop", ip4);
19538 else if (fp->afi == IP46_TYPE_IP6)
19540 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19541 vat_json_object_add_ip6 (node, "next_hop", ip6);
19547 api_ip_fib_dump (vat_main_t * vam)
19549 vl_api_ip_fib_dump_t *mp;
19550 vl_api_control_ping_t *mp_ping;
19553 M (IP_FIB_DUMP, mp);
19556 /* Use a control ping for synchronization */
19557 MPING (CONTROL_PING, mp_ping);
19565 api_ip_mfib_dump (vat_main_t * vam)
19567 vl_api_ip_mfib_dump_t *mp;
19568 vl_api_control_ping_t *mp_ping;
19571 M (IP_MFIB_DUMP, mp);
19574 /* Use a control ping for synchronization */
19575 MPING (CONTROL_PING, mp_ping);
19582 static void vl_api_ip_neighbor_details_t_handler
19583 (vl_api_ip_neighbor_details_t * mp)
19585 vat_main_t *vam = &vat_main;
19587 print (vam->ofp, "%c %U %U",
19588 (mp->is_static) ? 'S' : 'D',
19589 format_ethernet_address, &mp->mac_address,
19590 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
19594 static void vl_api_ip_neighbor_details_t_handler_json
19595 (vl_api_ip_neighbor_details_t * mp)
19598 vat_main_t *vam = &vat_main;
19599 vat_json_node_t *node;
19600 struct in_addr ip4;
19601 struct in6_addr ip6;
19603 if (VAT_JSON_ARRAY != vam->json_tree.type)
19605 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19606 vat_json_init_array (&vam->json_tree);
19608 node = vat_json_array_add (&vam->json_tree);
19610 vat_json_init_object (node);
19611 vat_json_object_add_string_copy (node, "flag",
19612 (mp->is_static) ? (u8 *) "static" : (u8 *)
19615 vat_json_object_add_string_copy (node, "link_layer",
19616 format (0, "%U", format_ethernet_address,
19617 &mp->mac_address));
19621 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
19622 vat_json_object_add_ip6 (node, "ip_address", ip6);
19626 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
19627 vat_json_object_add_ip4 (node, "ip_address", ip4);
19632 api_ip_neighbor_dump (vat_main_t * vam)
19634 unformat_input_t *i = vam->input;
19635 vl_api_ip_neighbor_dump_t *mp;
19636 vl_api_control_ping_t *mp_ping;
19638 u32 sw_if_index = ~0;
19641 /* Parse args required to build the message */
19642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19644 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19646 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19648 else if (unformat (i, "ip6"))
19654 if (sw_if_index == ~0)
19656 errmsg ("missing interface name or sw_if_index");
19660 M (IP_NEIGHBOR_DUMP, mp);
19661 mp->is_ipv6 = (u8) is_ipv6;
19662 mp->sw_if_index = ntohl (sw_if_index);
19665 /* Use a control ping for synchronization */
19666 MPING (CONTROL_PING, mp_ping);
19673 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
19674 #define vl_api_ip6_fib_details_t_print vl_noop_handler
19677 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
19679 vat_main_t *vam = &vat_main;
19680 int count = ntohl (mp->count);
19681 vl_api_fib_path_t *fp;
19685 "table-id %d, prefix %U/%d",
19686 ntohl (mp->table_id), format_ip6_address, mp->address,
19687 mp->address_length);
19689 for (i = 0; i < count; i++)
19691 if (fp->afi == IP46_TYPE_IP6)
19693 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19694 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19695 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19696 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19697 format_ip6_address, fp->next_hop);
19698 else if (fp->afi == IP46_TYPE_IP4)
19700 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19701 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19702 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19703 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19704 format_ip4_address, fp->next_hop);
19709 static void vl_api_ip6_fib_details_t_handler_json
19710 (vl_api_ip6_fib_details_t * mp)
19712 vat_main_t *vam = &vat_main;
19713 int count = ntohl (mp->count);
19714 vat_json_node_t *node = NULL;
19715 struct in_addr ip4;
19716 struct in6_addr ip6;
19717 vl_api_fib_path_t *fp;
19720 if (VAT_JSON_ARRAY != vam->json_tree.type)
19722 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19723 vat_json_init_array (&vam->json_tree);
19725 node = vat_json_array_add (&vam->json_tree);
19727 vat_json_init_object (node);
19728 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19729 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
19730 vat_json_object_add_ip6 (node, "prefix", ip6);
19731 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19732 vat_json_object_add_uint (node, "path_count", count);
19734 for (i = 0; i < count; i++)
19736 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19737 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19738 vat_json_object_add_uint (node, "is_local", fp->is_local);
19739 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19740 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19741 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19742 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19743 if (fp->afi == IP46_TYPE_IP4)
19745 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19746 vat_json_object_add_ip4 (node, "next_hop", ip4);
19748 else if (fp->afi == IP46_TYPE_IP6)
19750 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19751 vat_json_object_add_ip6 (node, "next_hop", ip6);
19757 api_ip6_fib_dump (vat_main_t * vam)
19759 vl_api_ip6_fib_dump_t *mp;
19760 vl_api_control_ping_t *mp_ping;
19763 M (IP6_FIB_DUMP, mp);
19766 /* Use a control ping for synchronization */
19767 MPING (CONTROL_PING, mp_ping);
19775 api_ip6_mfib_dump (vat_main_t * vam)
19777 vl_api_ip6_mfib_dump_t *mp;
19778 vl_api_control_ping_t *mp_ping;
19781 M (IP6_MFIB_DUMP, mp);
19784 /* Use a control ping for synchronization */
19785 MPING (CONTROL_PING, mp_ping);
19793 api_classify_table_ids (vat_main_t * vam)
19795 vl_api_classify_table_ids_t *mp;
19798 /* Construct the API message */
19799 M (CLASSIFY_TABLE_IDS, mp);
19808 api_classify_table_by_interface (vat_main_t * vam)
19810 unformat_input_t *input = vam->input;
19811 vl_api_classify_table_by_interface_t *mp;
19813 u32 sw_if_index = ~0;
19815 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19817 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19819 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19824 if (sw_if_index == ~0)
19826 errmsg ("missing interface name or sw_if_index");
19830 /* Construct the API message */
19831 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19833 mp->sw_if_index = ntohl (sw_if_index);
19841 api_classify_table_info (vat_main_t * vam)
19843 unformat_input_t *input = vam->input;
19844 vl_api_classify_table_info_t *mp;
19848 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19850 if (unformat (input, "table_id %d", &table_id))
19855 if (table_id == ~0)
19857 errmsg ("missing table id");
19861 /* Construct the API message */
19862 M (CLASSIFY_TABLE_INFO, mp);
19864 mp->table_id = ntohl (table_id);
19872 api_classify_session_dump (vat_main_t * vam)
19874 unformat_input_t *input = vam->input;
19875 vl_api_classify_session_dump_t *mp;
19876 vl_api_control_ping_t *mp_ping;
19880 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19882 if (unformat (input, "table_id %d", &table_id))
19887 if (table_id == ~0)
19889 errmsg ("missing table id");
19893 /* Construct the API message */
19894 M (CLASSIFY_SESSION_DUMP, mp);
19896 mp->table_id = ntohl (table_id);
19899 /* Use a control ping for synchronization */
19900 MPING (CONTROL_PING, mp_ping);
19908 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19910 vat_main_t *vam = &vat_main;
19912 print (vam->ofp, "collector_address %U, collector_port %d, "
19913 "src_address %U, vrf_id %d, path_mtu %u, "
19914 "template_interval %u, udp_checksum %d",
19915 format_ip4_address, mp->collector_address,
19916 ntohs (mp->collector_port),
19917 format_ip4_address, mp->src_address,
19918 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19919 ntohl (mp->template_interval), mp->udp_checksum);
19922 vam->result_ready = 1;
19926 vl_api_ipfix_exporter_details_t_handler_json
19927 (vl_api_ipfix_exporter_details_t * mp)
19929 vat_main_t *vam = &vat_main;
19930 vat_json_node_t node;
19931 struct in_addr collector_address;
19932 struct in_addr src_address;
19934 vat_json_init_object (&node);
19935 clib_memcpy (&collector_address, &mp->collector_address,
19936 sizeof (collector_address));
19937 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19938 vat_json_object_add_uint (&node, "collector_port",
19939 ntohs (mp->collector_port));
19940 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19941 vat_json_object_add_ip4 (&node, "src_address", src_address);
19942 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19943 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19944 vat_json_object_add_uint (&node, "template_interval",
19945 ntohl (mp->template_interval));
19946 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19948 vat_json_print (vam->ofp, &node);
19949 vat_json_free (&node);
19951 vam->result_ready = 1;
19955 api_ipfix_exporter_dump (vat_main_t * vam)
19957 vl_api_ipfix_exporter_dump_t *mp;
19960 /* Construct the API message */
19961 M (IPFIX_EXPORTER_DUMP, mp);
19970 api_ipfix_classify_stream_dump (vat_main_t * vam)
19972 vl_api_ipfix_classify_stream_dump_t *mp;
19975 /* Construct the API message */
19976 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19987 vl_api_ipfix_classify_stream_details_t_handler
19988 (vl_api_ipfix_classify_stream_details_t * mp)
19990 vat_main_t *vam = &vat_main;
19991 print (vam->ofp, "domain_id %d, src_port %d",
19992 ntohl (mp->domain_id), ntohs (mp->src_port));
19994 vam->result_ready = 1;
19998 vl_api_ipfix_classify_stream_details_t_handler_json
19999 (vl_api_ipfix_classify_stream_details_t * mp)
20001 vat_main_t *vam = &vat_main;
20002 vat_json_node_t node;
20004 vat_json_init_object (&node);
20005 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
20006 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
20008 vat_json_print (vam->ofp, &node);
20009 vat_json_free (&node);
20011 vam->result_ready = 1;
20015 api_ipfix_classify_table_dump (vat_main_t * vam)
20017 vl_api_ipfix_classify_table_dump_t *mp;
20018 vl_api_control_ping_t *mp_ping;
20021 if (!vam->json_output)
20023 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
20024 "transport_protocol");
20027 /* Construct the API message */
20028 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
20033 /* Use a control ping for synchronization */
20034 MPING (CONTROL_PING, mp_ping);
20042 vl_api_ipfix_classify_table_details_t_handler
20043 (vl_api_ipfix_classify_table_details_t * mp)
20045 vat_main_t *vam = &vat_main;
20046 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
20047 mp->transport_protocol);
20051 vl_api_ipfix_classify_table_details_t_handler_json
20052 (vl_api_ipfix_classify_table_details_t * mp)
20054 vat_json_node_t *node = NULL;
20055 vat_main_t *vam = &vat_main;
20057 if (VAT_JSON_ARRAY != vam->json_tree.type)
20059 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20060 vat_json_init_array (&vam->json_tree);
20063 node = vat_json_array_add (&vam->json_tree);
20064 vat_json_init_object (node);
20066 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
20067 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
20068 vat_json_object_add_uint (node, "transport_protocol",
20069 mp->transport_protocol);
20073 api_sw_interface_span_enable_disable (vat_main_t * vam)
20075 unformat_input_t *i = vam->input;
20076 vl_api_sw_interface_span_enable_disable_t *mp;
20077 u32 src_sw_if_index = ~0;
20078 u32 dst_sw_if_index = ~0;
20083 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20086 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
20088 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
20092 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
20094 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
20096 else if (unformat (i, "disable"))
20098 else if (unformat (i, "rx"))
20100 else if (unformat (i, "tx"))
20102 else if (unformat (i, "both"))
20104 else if (unformat (i, "l2"))
20110 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
20112 mp->sw_if_index_from = htonl (src_sw_if_index);
20113 mp->sw_if_index_to = htonl (dst_sw_if_index);
20123 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
20126 vat_main_t *vam = &vat_main;
20127 u8 *sw_if_from_name = 0;
20128 u8 *sw_if_to_name = 0;
20129 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20130 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20131 char *states[] = { "none", "rx", "tx", "both" };
20135 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20137 if ((u32) p->value[0] == sw_if_index_from)
20139 sw_if_from_name = (u8 *)(p->key);
20143 if ((u32) p->value[0] == sw_if_index_to)
20145 sw_if_to_name = (u8 *)(p->key);
20146 if (sw_if_from_name)
20151 print (vam->ofp, "%20s => %20s (%s)",
20152 sw_if_from_name, sw_if_to_name, states[mp->state]);
20156 vl_api_sw_interface_span_details_t_handler_json
20157 (vl_api_sw_interface_span_details_t * mp)
20159 vat_main_t *vam = &vat_main;
20160 vat_json_node_t *node = NULL;
20161 u8 *sw_if_from_name = 0;
20162 u8 *sw_if_to_name = 0;
20163 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20164 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20168 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20170 if ((u32) p->value[0] == sw_if_index_from)
20172 sw_if_from_name = (u8 *)(p->key);
20176 if ((u32) p->value[0] == sw_if_index_to)
20178 sw_if_to_name = (u8 *)(p->key);
20179 if (sw_if_from_name)
20185 if (VAT_JSON_ARRAY != vam->json_tree.type)
20187 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20188 vat_json_init_array (&vam->json_tree);
20190 node = vat_json_array_add (&vam->json_tree);
20192 vat_json_init_object (node);
20193 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
20194 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
20195 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
20196 if (0 != sw_if_to_name)
20198 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
20200 vat_json_object_add_uint (node, "state", mp->state);
20204 api_sw_interface_span_dump (vat_main_t * vam)
20206 unformat_input_t *input = vam->input;
20207 vl_api_sw_interface_span_dump_t *mp;
20208 vl_api_control_ping_t *mp_ping;
20212 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20214 if (unformat (input, "l2"))
20220 M (SW_INTERFACE_SPAN_DUMP, mp);
20224 /* Use a control ping for synchronization */
20225 MPING (CONTROL_PING, mp_ping);
20233 api_pg_create_interface (vat_main_t * vam)
20235 unformat_input_t *input = vam->input;
20236 vl_api_pg_create_interface_t *mp;
20240 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20242 if (unformat (input, "if_id %d", &if_id))
20249 errmsg ("missing pg interface index");
20253 /* Construct the API message */
20254 M (PG_CREATE_INTERFACE, mp);
20256 mp->interface_id = ntohl (if_id);
20264 api_pg_capture (vat_main_t * vam)
20266 unformat_input_t *input = vam->input;
20267 vl_api_pg_capture_t *mp;
20272 u8 pcap_file_set = 0;
20275 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20277 if (unformat (input, "if_id %d", &if_id))
20279 else if (unformat (input, "pcap %s", &pcap_file))
20281 else if (unformat (input, "count %d", &count))
20283 else if (unformat (input, "disable"))
20290 errmsg ("missing pg interface index");
20293 if (pcap_file_set > 0)
20295 if (vec_len (pcap_file) > 255)
20297 errmsg ("pcap file name is too long");
20302 u32 name_len = vec_len (pcap_file);
20303 /* Construct the API message */
20304 M (PG_CAPTURE, mp);
20306 mp->interface_id = ntohl (if_id);
20307 mp->is_enabled = enable;
20308 mp->count = ntohl (count);
20309 mp->pcap_name_length = ntohl (name_len);
20310 if (pcap_file_set != 0)
20312 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
20314 vec_free (pcap_file);
20322 api_pg_enable_disable (vat_main_t * vam)
20324 unformat_input_t *input = vam->input;
20325 vl_api_pg_enable_disable_t *mp;
20328 u8 stream_name_set = 0;
20329 u8 *stream_name = 0;
20331 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20333 if (unformat (input, "stream %s", &stream_name))
20334 stream_name_set = 1;
20335 else if (unformat (input, "disable"))
20341 if (stream_name_set > 0)
20343 if (vec_len (stream_name) > 255)
20345 errmsg ("stream name too long");
20350 u32 name_len = vec_len (stream_name);
20351 /* Construct the API message */
20352 M (PG_ENABLE_DISABLE, mp);
20354 mp->is_enabled = enable;
20355 if (stream_name_set != 0)
20357 mp->stream_name_length = ntohl (name_len);
20358 clib_memcpy (mp->stream_name, stream_name, name_len);
20360 vec_free (stream_name);
20368 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
20370 unformat_input_t *input = vam->input;
20371 vl_api_ip_source_and_port_range_check_add_del_t *mp;
20373 u16 *low_ports = 0;
20374 u16 *high_ports = 0;
20377 ip4_address_t ip4_addr;
20378 ip6_address_t ip6_addr;
20387 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20389 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
20395 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
20400 else if (unformat (input, "vrf %d", &vrf_id))
20402 else if (unformat (input, "del"))
20404 else if (unformat (input, "port %d", &tmp))
20406 if (tmp == 0 || tmp > 65535)
20408 errmsg ("port %d out of range", tmp);
20412 this_hi = this_low + 1;
20413 vec_add1 (low_ports, this_low);
20414 vec_add1 (high_ports, this_hi);
20416 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
20418 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
20420 errmsg ("incorrect range parameters");
20424 /* Note: in debug CLI +1 is added to high before
20425 passing to real fn that does "the work"
20426 (ip_source_and_port_range_check_add_del).
20427 This fn is a wrapper around the binary API fn a
20428 control plane will call, which expects this increment
20429 to have occurred. Hence letting the binary API control
20430 plane fn do the increment for consistency between VAT
20431 and other control planes.
20434 vec_add1 (low_ports, this_low);
20435 vec_add1 (high_ports, this_hi);
20441 if (prefix_set == 0)
20443 errmsg ("<address>/<mask> not specified");
20449 errmsg ("VRF ID required, not specified");
20456 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20460 if (vec_len (low_ports) == 0)
20462 errmsg ("At least one port or port range required");
20466 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
20468 mp->is_add = is_add;
20473 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
20478 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
20481 mp->mask_length = length;
20482 mp->number_of_ranges = vec_len (low_ports);
20484 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
20485 vec_free (low_ports);
20487 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
20488 vec_free (high_ports);
20490 mp->vrf_id = ntohl (vrf_id);
20498 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
20500 unformat_input_t *input = vam->input;
20501 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
20502 u32 sw_if_index = ~0;
20504 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
20505 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
20509 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20511 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20513 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20515 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
20517 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
20519 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
20521 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
20523 else if (unformat (input, "del"))
20529 if (sw_if_index == ~0)
20531 errmsg ("Interface required but not specified");
20537 errmsg ("VRF ID required but not specified");
20541 if (tcp_out_vrf_id == 0
20542 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
20545 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20549 /* Construct the API message */
20550 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
20552 mp->sw_if_index = ntohl (sw_if_index);
20553 mp->is_add = is_add;
20554 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20555 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20556 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20557 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20562 /* Wait for a reply... */
20568 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
20570 unformat_input_t *i = vam->input;
20571 vl_api_ipsec_gre_add_del_tunnel_t *mp;
20572 u32 local_sa_id = 0;
20573 u32 remote_sa_id = 0;
20574 ip4_address_t src_address;
20575 ip4_address_t dst_address;
20579 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20581 if (unformat (i, "local_sa %d", &local_sa_id))
20583 else if (unformat (i, "remote_sa %d", &remote_sa_id))
20585 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
20587 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
20589 else if (unformat (i, "del"))
20593 clib_warning ("parse error '%U'", format_unformat_error, i);
20598 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
20600 mp->local_sa_id = ntohl (local_sa_id);
20601 mp->remote_sa_id = ntohl (remote_sa_id);
20602 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
20603 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
20604 mp->is_add = is_add;
20612 api_punt (vat_main_t * vam)
20614 unformat_input_t *i = vam->input;
20622 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20624 if (unformat (i, "ip %d", &ipv))
20626 else if (unformat (i, "protocol %d", &protocol))
20628 else if (unformat (i, "port %d", &port))
20630 else if (unformat (i, "del"))
20634 clib_warning ("parse error '%U'", format_unformat_error, i);
20641 mp->is_add = (u8) is_add;
20642 mp->ipv = (u8) ipv;
20643 mp->l4_protocol = (u8) protocol;
20644 mp->l4_port = htons ((u16) port);
20651 static void vl_api_ipsec_gre_tunnel_details_t_handler
20652 (vl_api_ipsec_gre_tunnel_details_t * mp)
20654 vat_main_t *vam = &vat_main;
20656 print (vam->ofp, "%11d%15U%15U%14d%14d",
20657 ntohl (mp->sw_if_index),
20658 format_ip4_address, &mp->src_address,
20659 format_ip4_address, &mp->dst_address,
20660 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
20663 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
20664 (vl_api_ipsec_gre_tunnel_details_t * mp)
20666 vat_main_t *vam = &vat_main;
20667 vat_json_node_t *node = NULL;
20668 struct in_addr ip4;
20670 if (VAT_JSON_ARRAY != vam->json_tree.type)
20672 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20673 vat_json_init_array (&vam->json_tree);
20675 node = vat_json_array_add (&vam->json_tree);
20677 vat_json_init_object (node);
20678 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20679 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
20680 vat_json_object_add_ip4 (node, "src_address", ip4);
20681 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
20682 vat_json_object_add_ip4 (node, "dst_address", ip4);
20683 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
20684 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
20688 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
20690 unformat_input_t *i = vam->input;
20691 vl_api_ipsec_gre_tunnel_dump_t *mp;
20692 vl_api_control_ping_t *mp_ping;
20694 u8 sw_if_index_set = 0;
20697 /* Parse args required to build the message */
20698 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20700 if (unformat (i, "sw_if_index %d", &sw_if_index))
20701 sw_if_index_set = 1;
20706 if (sw_if_index_set == 0)
20711 if (!vam->json_output)
20713 print (vam->ofp, "%11s%15s%15s%14s%14s",
20714 "sw_if_index", "src_address", "dst_address",
20715 "local_sa_id", "remote_sa_id");
20718 /* Get list of gre-tunnel interfaces */
20719 M (IPSEC_GRE_TUNNEL_DUMP, mp);
20721 mp->sw_if_index = htonl (sw_if_index);
20725 /* Use a control ping for synchronization */
20726 MPING (CONTROL_PING, mp_ping);
20734 api_delete_subif (vat_main_t * vam)
20736 unformat_input_t *i = vam->input;
20737 vl_api_delete_subif_t *mp;
20738 u32 sw_if_index = ~0;
20741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20743 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20745 if (unformat (i, "sw_if_index %d", &sw_if_index))
20751 if (sw_if_index == ~0)
20753 errmsg ("missing sw_if_index");
20757 /* Construct the API message */
20758 M (DELETE_SUBIF, mp);
20759 mp->sw_if_index = ntohl (sw_if_index);
20766 #define foreach_pbb_vtr_op \
20767 _("disable", L2_VTR_DISABLED) \
20768 _("pop", L2_VTR_POP_2) \
20769 _("push", L2_VTR_PUSH_2)
20772 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20774 unformat_input_t *i = vam->input;
20775 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20776 u32 sw_if_index = ~0, vtr_op = ~0;
20777 u16 outer_tag = ~0;
20778 u8 dmac[6], smac[6];
20779 u8 dmac_set = 0, smac_set = 0;
20785 /* Shut up coverity */
20786 memset (dmac, 0, sizeof (dmac));
20787 memset (smac, 0, sizeof (smac));
20789 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20791 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20793 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20795 else if (unformat (i, "vtr_op %d", &vtr_op))
20797 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20800 else if (unformat (i, "translate_pbb_stag"))
20802 if (unformat (i, "%d", &tmp))
20804 vtr_op = L2_VTR_TRANSLATE_2_1;
20810 ("translate_pbb_stag operation requires outer tag definition");
20814 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20816 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20818 else if (unformat (i, "sid %d", &sid))
20820 else if (unformat (i, "vlanid %d", &tmp))
20824 clib_warning ("parse error '%U'", format_unformat_error, i);
20829 if ((sw_if_index == ~0) || (vtr_op == ~0))
20831 errmsg ("missing sw_if_index or vtr operation");
20834 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20835 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20838 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20842 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20843 mp->sw_if_index = ntohl (sw_if_index);
20844 mp->vtr_op = ntohl (vtr_op);
20845 mp->outer_tag = ntohs (outer_tag);
20846 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20847 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20848 mp->b_vlanid = ntohs (vlanid);
20849 mp->i_sid = ntohl (sid);
20857 api_flow_classify_set_interface (vat_main_t * vam)
20859 unformat_input_t *i = vam->input;
20860 vl_api_flow_classify_set_interface_t *mp;
20862 int sw_if_index_set;
20863 u32 ip4_table_index = ~0;
20864 u32 ip6_table_index = ~0;
20868 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20870 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20871 sw_if_index_set = 1;
20872 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20873 sw_if_index_set = 1;
20874 else if (unformat (i, "del"))
20876 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20878 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20882 clib_warning ("parse error '%U'", format_unformat_error, i);
20887 if (sw_if_index_set == 0)
20889 errmsg ("missing interface name or sw_if_index");
20893 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20895 mp->sw_if_index = ntohl (sw_if_index);
20896 mp->ip4_table_index = ntohl (ip4_table_index);
20897 mp->ip6_table_index = ntohl (ip6_table_index);
20898 mp->is_add = is_add;
20906 api_flow_classify_dump (vat_main_t * vam)
20908 unformat_input_t *i = vam->input;
20909 vl_api_flow_classify_dump_t *mp;
20910 vl_api_control_ping_t *mp_ping;
20911 u8 type = FLOW_CLASSIFY_N_TABLES;
20914 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20918 errmsg ("classify table type must be specified");
20922 if (!vam->json_output)
20924 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20927 M (FLOW_CLASSIFY_DUMP, mp);
20932 /* Use a control ping for synchronization */
20933 MPING (CONTROL_PING, mp_ping);
20936 /* Wait for a reply... */
20942 api_feature_enable_disable (vat_main_t * vam)
20944 unformat_input_t *i = vam->input;
20945 vl_api_feature_enable_disable_t *mp;
20947 u8 *feature_name = 0;
20948 u32 sw_if_index = ~0;
20952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20954 if (unformat (i, "arc_name %s", &arc_name))
20956 else if (unformat (i, "feature_name %s", &feature_name))
20959 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20961 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20963 else if (unformat (i, "disable"))
20971 errmsg ("missing arc name");
20974 if (vec_len (arc_name) > 63)
20976 errmsg ("arc name too long");
20979 if (feature_name == 0)
20981 errmsg ("missing feature name");
20984 if (vec_len (feature_name) > 63)
20986 errmsg ("feature name too long");
20989 if (sw_if_index == ~0)
20991 errmsg ("missing interface name or sw_if_index");
20995 /* Construct the API message */
20996 M (FEATURE_ENABLE_DISABLE, mp);
20997 mp->sw_if_index = ntohl (sw_if_index);
20998 mp->enable = enable;
20999 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
21000 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
21001 vec_free (arc_name);
21002 vec_free (feature_name);
21010 api_sw_interface_tag_add_del (vat_main_t * vam)
21012 unformat_input_t *i = vam->input;
21013 vl_api_sw_interface_tag_add_del_t *mp;
21014 u32 sw_if_index = ~0;
21019 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21021 if (unformat (i, "tag %s", &tag))
21023 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21025 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21027 else if (unformat (i, "del"))
21033 if (sw_if_index == ~0)
21035 errmsg ("missing interface name or sw_if_index");
21039 if (enable && (tag == 0))
21041 errmsg ("no tag specified");
21045 /* Construct the API message */
21046 M (SW_INTERFACE_TAG_ADD_DEL, mp);
21047 mp->sw_if_index = ntohl (sw_if_index);
21048 mp->is_add = enable;
21050 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
21058 static void vl_api_l2_xconnect_details_t_handler
21059 (vl_api_l2_xconnect_details_t * mp)
21061 vat_main_t *vam = &vat_main;
21063 print (vam->ofp, "%15d%15d",
21064 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
21067 static void vl_api_l2_xconnect_details_t_handler_json
21068 (vl_api_l2_xconnect_details_t * mp)
21070 vat_main_t *vam = &vat_main;
21071 vat_json_node_t *node = NULL;
21073 if (VAT_JSON_ARRAY != vam->json_tree.type)
21075 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21076 vat_json_init_array (&vam->json_tree);
21078 node = vat_json_array_add (&vam->json_tree);
21080 vat_json_init_object (node);
21081 vat_json_object_add_uint (node, "rx_sw_if_index",
21082 ntohl (mp->rx_sw_if_index));
21083 vat_json_object_add_uint (node, "tx_sw_if_index",
21084 ntohl (mp->tx_sw_if_index));
21088 api_l2_xconnect_dump (vat_main_t * vam)
21090 vl_api_l2_xconnect_dump_t *mp;
21091 vl_api_control_ping_t *mp_ping;
21094 if (!vam->json_output)
21096 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
21099 M (L2_XCONNECT_DUMP, mp);
21103 /* Use a control ping for synchronization */
21104 MPING (CONTROL_PING, mp_ping);
21112 api_sw_interface_set_mtu (vat_main_t * vam)
21114 unformat_input_t *i = vam->input;
21115 vl_api_sw_interface_set_mtu_t *mp;
21116 u32 sw_if_index = ~0;
21120 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21122 if (unformat (i, "mtu %d", &mtu))
21124 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21126 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21132 if (sw_if_index == ~0)
21134 errmsg ("missing interface name or sw_if_index");
21140 errmsg ("no mtu specified");
21144 /* Construct the API message */
21145 M (SW_INTERFACE_SET_MTU, mp);
21146 mp->sw_if_index = ntohl (sw_if_index);
21147 mp->mtu = ntohs ((u16) mtu);
21155 api_p2p_ethernet_add (vat_main_t * vam)
21157 unformat_input_t *i = vam->input;
21158 vl_api_p2p_ethernet_add_t *mp;
21159 u32 parent_if_index = ~0;
21165 memset (remote_mac, 0, sizeof (remote_mac));
21166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21168 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21170 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21174 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21176 else if (unformat (i, "sub_id %d", &sub_id))
21180 clib_warning ("parse error '%U'", format_unformat_error, i);
21185 if (parent_if_index == ~0)
21187 errmsg ("missing interface name or sw_if_index");
21192 errmsg ("missing remote mac address");
21197 errmsg ("missing sub-interface id");
21201 M (P2P_ETHERNET_ADD, mp);
21202 mp->parent_if_index = ntohl (parent_if_index);
21203 mp->subif_id = ntohl (sub_id);
21204 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21212 api_p2p_ethernet_del (vat_main_t * vam)
21214 unformat_input_t *i = vam->input;
21215 vl_api_p2p_ethernet_del_t *mp;
21216 u32 parent_if_index = ~0;
21221 memset (remote_mac, 0, sizeof (remote_mac));
21222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21224 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21226 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21230 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21234 clib_warning ("parse error '%U'", format_unformat_error, i);
21239 if (parent_if_index == ~0)
21241 errmsg ("missing interface name or sw_if_index");
21246 errmsg ("missing remote mac address");
21250 M (P2P_ETHERNET_DEL, mp);
21251 mp->parent_if_index = ntohl (parent_if_index);
21252 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21260 api_lldp_config (vat_main_t * vam)
21262 unformat_input_t *i = vam->input;
21263 vl_api_lldp_config_t *mp;
21265 int tx_interval = 0;
21266 u8 *sys_name = NULL;
21269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21271 if (unformat (i, "system-name %s", &sys_name))
21273 else if (unformat (i, "tx-hold %d", &tx_hold))
21275 else if (unformat (i, "tx-interval %d", &tx_interval))
21279 clib_warning ("parse error '%U'", format_unformat_error, i);
21284 vec_add1 (sys_name, 0);
21286 M (LLDP_CONFIG, mp);
21287 mp->tx_hold = htonl (tx_hold);
21288 mp->tx_interval = htonl (tx_interval);
21289 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
21290 vec_free (sys_name);
21298 api_sw_interface_set_lldp (vat_main_t * vam)
21300 unformat_input_t *i = vam->input;
21301 vl_api_sw_interface_set_lldp_t *mp;
21302 u32 sw_if_index = ~0;
21304 u8 *port_desc = NULL, *mgmt_oid = NULL;
21305 ip4_address_t ip4_addr;
21306 ip6_address_t ip6_addr;
21309 memset (&ip4_addr, 0, sizeof (ip4_addr));
21310 memset (&ip6_addr, 0, sizeof (ip6_addr));
21312 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21314 if (unformat (i, "disable"))
21317 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21319 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21321 else if (unformat (i, "port-desc %s", &port_desc))
21323 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
21325 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
21327 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
21333 if (sw_if_index == ~0)
21335 errmsg ("missing interface name or sw_if_index");
21339 /* Construct the API message */
21340 vec_add1 (port_desc, 0);
21341 vec_add1 (mgmt_oid, 0);
21342 M (SW_INTERFACE_SET_LLDP, mp);
21343 mp->sw_if_index = ntohl (sw_if_index);
21344 mp->enable = enable;
21345 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
21346 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
21347 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
21348 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
21349 vec_free (port_desc);
21350 vec_free (mgmt_oid);
21358 api_tcp_configure_src_addresses (vat_main_t * vam)
21360 vl_api_tcp_configure_src_addresses_t *mp;
21361 unformat_input_t *i = vam->input;
21362 ip4_address_t v4first, v4last;
21363 ip6_address_t v6first, v6last;
21368 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21370 if (unformat (i, "%U - %U",
21371 unformat_ip4_address, &v4first,
21372 unformat_ip4_address, &v4last))
21376 errmsg ("one range per message (range already set)");
21381 else if (unformat (i, "%U - %U",
21382 unformat_ip6_address, &v6first,
21383 unformat_ip6_address, &v6last))
21387 errmsg ("one range per message (range already set)");
21392 else if (unformat (i, "vrf %d", &vrf_id))
21398 if (range_set == 0)
21400 errmsg ("address range not set");
21404 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
21405 mp->vrf_id = ntohl (vrf_id);
21407 if (range_set == 2)
21410 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
21411 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
21416 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
21417 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
21424 static void vl_api_app_namespace_add_del_reply_t_handler
21425 (vl_api_app_namespace_add_del_reply_t * mp)
21427 vat_main_t *vam = &vat_main;
21428 i32 retval = ntohl (mp->retval);
21429 if (vam->async_mode)
21431 vam->async_errors += (retval < 0);
21435 vam->retval = retval;
21437 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
21438 vam->result_ready = 1;
21442 static void vl_api_app_namespace_add_del_reply_t_handler_json
21443 (vl_api_app_namespace_add_del_reply_t * mp)
21445 vat_main_t *vam = &vat_main;
21446 vat_json_node_t node;
21448 vat_json_init_object (&node);
21449 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
21450 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
21452 vat_json_print (vam->ofp, &node);
21453 vat_json_free (&node);
21455 vam->retval = ntohl (mp->retval);
21456 vam->result_ready = 1;
21460 api_app_namespace_add_del (vat_main_t * vam)
21462 vl_api_app_namespace_add_del_t *mp;
21463 unformat_input_t *i = vam->input;
21464 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
21465 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
21469 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21471 if (unformat (i, "id %_%v%_", &ns_id))
21473 else if (unformat (i, "secret %lu", &secret))
21475 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21476 sw_if_index_set = 1;
21477 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
21479 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
21484 if (!ns_id || !secret_set || !sw_if_index_set)
21486 errmsg ("namespace id, secret and sw_if_index must be set");
21489 if (vec_len (ns_id) > 64)
21491 errmsg ("namespace id too long");
21494 M (APP_NAMESPACE_ADD_DEL, mp);
21496 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
21497 mp->namespace_id_len = vec_len (ns_id);
21498 mp->secret = clib_host_to_net_u64 (secret);
21499 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21500 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
21501 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
21509 api_memfd_segment_create (vat_main_t * vam)
21511 #if VPP_API_TEST_BUILTIN == 0
21512 unformat_input_t *i = vam->input;
21513 vl_api_memfd_segment_create_t *mp;
21514 u64 size = 64 << 20;
21517 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21519 if (unformat (i, "size %U", unformat_memory_size, &size))
21525 M (MEMFD_SEGMENT_CREATE, mp);
21526 mp->requested_size = size;
21532 errmsg ("memfd_segment_create (builtin) not supported");
21538 api_dns_enable_disable (vat_main_t * vam)
21540 unformat_input_t *line_input = vam->input;
21541 vl_api_dns_enable_disable_t *mp;
21542 u8 enable_disable = 1;
21545 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21547 if (unformat (line_input, "disable"))
21548 enable_disable = 0;
21549 if (unformat (line_input, "enable"))
21550 enable_disable = 1;
21555 /* Construct the API message */
21556 M (DNS_ENABLE_DISABLE, mp);
21557 mp->enable = enable_disable;
21561 /* Wait for the reply */
21567 api_dns_resolve_name (vat_main_t * vam)
21569 unformat_input_t *line_input = vam->input;
21570 vl_api_dns_resolve_name_t *mp;
21574 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21576 if (unformat (line_input, "%s", &name))
21582 if (vec_len (name) > 127)
21584 errmsg ("name too long");
21588 /* Construct the API message */
21589 M (DNS_RESOLVE_NAME, mp);
21590 memcpy (mp->name, name, vec_len (name));
21595 /* Wait for the reply */
21601 api_dns_resolve_ip (vat_main_t * vam)
21603 unformat_input_t *line_input = vam->input;
21604 vl_api_dns_resolve_ip_t *mp;
21606 ip4_address_t addr4;
21607 ip6_address_t addr6;
21610 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21612 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
21614 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
21622 errmsg ("missing address");
21626 /* Construct the API message */
21627 M (DNS_RESOLVE_IP, mp);
21628 mp->is_ip6 = is_ip6;
21630 memcpy (mp->address, &addr6, sizeof (addr6));
21632 memcpy (mp->address, &addr4, sizeof (addr4));
21636 /* Wait for the reply */
21642 api_dns_name_server_add_del (vat_main_t * vam)
21644 unformat_input_t *i = vam->input;
21645 vl_api_dns_name_server_add_del_t *mp;
21647 ip6_address_t ip6_server;
21648 ip4_address_t ip4_server;
21653 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21655 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
21657 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
21659 else if (unformat (i, "del"))
21663 clib_warning ("parse error '%U'", format_unformat_error, i);
21668 if (ip4_set && ip6_set)
21670 errmsg ("Only one server address allowed per message");
21673 if ((ip4_set + ip6_set) == 0)
21675 errmsg ("Server address required");
21679 /* Construct the API message */
21680 M (DNS_NAME_SERVER_ADD_DEL, mp);
21684 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
21689 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
21693 mp->is_add = is_add;
21698 /* Wait for a reply, return good/bad news */
21704 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
21706 vat_main_t *vam = &vat_main;
21711 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21712 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21713 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
21714 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
21715 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21716 clib_net_to_host_u32 (mp->action_index), mp->tag);
21721 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21722 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21723 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
21724 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
21725 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21726 clib_net_to_host_u32 (mp->action_index), mp->tag);
21731 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
21734 vat_main_t *vam = &vat_main;
21735 vat_json_node_t *node = NULL;
21736 struct in6_addr ip6;
21737 struct in_addr ip4;
21739 if (VAT_JSON_ARRAY != vam->json_tree.type)
21741 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21742 vat_json_init_array (&vam->json_tree);
21744 node = vat_json_array_add (&vam->json_tree);
21745 vat_json_init_object (node);
21747 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
21748 vat_json_object_add_uint (node, "appns_index",
21749 clib_net_to_host_u32 (mp->appns_index));
21750 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
21751 vat_json_object_add_uint (node, "scope", mp->scope);
21752 vat_json_object_add_uint (node, "action_index",
21753 clib_net_to_host_u32 (mp->action_index));
21754 vat_json_object_add_uint (node, "lcl_port",
21755 clib_net_to_host_u16 (mp->lcl_port));
21756 vat_json_object_add_uint (node, "rmt_port",
21757 clib_net_to_host_u16 (mp->rmt_port));
21758 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
21759 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
21760 vat_json_object_add_string_copy (node, "tag", mp->tag);
21763 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
21764 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
21765 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
21766 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
21770 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
21771 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
21772 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
21773 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
21778 api_session_rule_add_del (vat_main_t * vam)
21780 vl_api_session_rule_add_del_t *mp;
21781 unformat_input_t *i = vam->input;
21782 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
21783 u32 appns_index = 0, scope = 0;
21784 ip4_address_t lcl_ip4, rmt_ip4;
21785 ip6_address_t lcl_ip6, rmt_ip6;
21786 u8 is_ip4 = 1, conn_set = 0;
21787 u8 is_add = 1, *tag = 0;
21790 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21792 if (unformat (i, "del"))
21794 else if (unformat (i, "add"))
21796 else if (unformat (i, "proto tcp"))
21798 else if (unformat (i, "proto udp"))
21800 else if (unformat (i, "appns %d", &appns_index))
21802 else if (unformat (i, "scope %d", &scope))
21804 else if (unformat (i, "tag %_%v%_", &tag))
21808 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
21809 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
21817 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
21818 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
21824 else if (unformat (i, "action %d", &action))
21829 if (proto == ~0 || !conn_set || action == ~0)
21831 errmsg ("transport proto, connection and action must be set");
21837 errmsg ("scope should be 0-3");
21841 M (SESSION_RULE_ADD_DEL, mp);
21843 mp->is_ip4 = is_ip4;
21844 mp->transport_proto = proto;
21845 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
21846 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
21847 mp->lcl_plen = lcl_plen;
21848 mp->rmt_plen = rmt_plen;
21849 mp->action_index = clib_host_to_net_u32 (action);
21850 mp->appns_index = clib_host_to_net_u32 (appns_index);
21852 mp->is_add = is_add;
21855 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
21856 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
21860 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
21861 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
21865 clib_memcpy (mp->tag, tag, vec_len (tag));
21875 api_session_rules_dump (vat_main_t * vam)
21877 vl_api_session_rules_dump_t *mp;
21878 vl_api_control_ping_t *mp_ping;
21881 if (!vam->json_output)
21883 print (vam->ofp, "%=20s", "Session Rules");
21886 M (SESSION_RULES_DUMP, mp);
21890 /* Use a control ping for synchronization */
21891 MPING (CONTROL_PING, mp_ping);
21894 /* Wait for a reply... */
21900 api_ip_container_proxy_add_del (vat_main_t * vam)
21902 vl_api_ip_container_proxy_add_del_t *mp;
21903 unformat_input_t *i = vam->input;
21904 u32 plen = ~0, sw_if_index = ~0;
21911 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21913 if (unformat (i, "del"))
21915 else if (unformat (i, "add"))
21917 if (unformat (i, "%U", unformat_ip4_address, &ip4))
21922 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
21927 else if (unformat (i, "sw_if_index %u", &sw_if_index))
21932 if (sw_if_index == ~0 || plen == ~0)
21934 errmsg ("address and sw_if_index must be set");
21938 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
21940 mp->is_ip4 = is_ip4;
21941 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21943 mp->is_add = is_add;
21945 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
21947 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
21955 q_or_quit (vat_main_t * vam)
21957 #if VPP_API_TEST_BUILTIN == 0
21958 longjmp (vam->jump_buf, 1);
21960 return 0; /* not so much */
21964 q (vat_main_t * vam)
21966 return q_or_quit (vam);
21970 quit (vat_main_t * vam)
21972 return q_or_quit (vam);
21976 comment (vat_main_t * vam)
21982 cmd_cmp (void *a1, void *a2)
21987 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21991 help (vat_main_t * vam)
21996 unformat_input_t *i = vam->input;
21999 if (unformat (i, "%s", &name))
22003 vec_add1 (name, 0);
22005 hs = hash_get_mem (vam->help_by_name, name);
22007 print (vam->ofp, "usage: %s %s", name, hs[0]);
22009 print (vam->ofp, "No such msg / command '%s'", name);
22014 print (vam->ofp, "Help is available for the following:");
22017 hash_foreach_pair (p, vam->function_by_name,
22019 vec_add1 (cmds, (u8 *)(p->key));
22023 vec_sort_with_function (cmds, cmd_cmp);
22025 for (j = 0; j < vec_len (cmds); j++)
22026 print (vam->ofp, "%s", cmds[j]);
22033 set (vat_main_t * vam)
22035 u8 *name = 0, *value = 0;
22036 unformat_input_t *i = vam->input;
22038 if (unformat (i, "%s", &name))
22040 /* The input buffer is a vector, not a string. */
22041 value = vec_dup (i->buffer);
22042 vec_delete (value, i->index, 0);
22043 /* Almost certainly has a trailing newline */
22044 if (value[vec_len (value) - 1] == '\n')
22045 value[vec_len (value) - 1] = 0;
22046 /* Make sure it's a proper string, one way or the other */
22047 vec_add1 (value, 0);
22048 (void) clib_macro_set_value (&vam->macro_main,
22049 (char *) name, (char *) value);
22052 errmsg ("usage: set <name> <value>");
22060 unset (vat_main_t * vam)
22064 if (unformat (vam->input, "%s", &name))
22065 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
22066 errmsg ("unset: %s wasn't set", name);
22079 macro_sort_cmp (void *a1, void *a2)
22081 macro_sort_t *s1 = a1;
22082 macro_sort_t *s2 = a2;
22084 return strcmp ((char *) (s1->name), (char *) (s2->name));
22088 dump_macro_table (vat_main_t * vam)
22090 macro_sort_t *sort_me = 0, *sm;
22095 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
22097 vec_add2 (sort_me, sm, 1);
22098 sm->name = (u8 *)(p->key);
22099 sm->value = (u8 *) (p->value[0]);
22103 vec_sort_with_function (sort_me, macro_sort_cmp);
22105 if (vec_len (sort_me))
22106 print (vam->ofp, "%-15s%s", "Name", "Value");
22108 print (vam->ofp, "The macro table is empty...");
22110 for (i = 0; i < vec_len (sort_me); i++)
22111 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
22116 dump_node_table (vat_main_t * vam)
22119 vlib_node_t *node, *next_node;
22121 if (vec_len (vam->graph_nodes) == 0)
22123 print (vam->ofp, "Node table empty, issue get_node_graph...");
22127 for (i = 0; i < vec_len (vam->graph_nodes); i++)
22129 node = vam->graph_nodes[i];
22130 print (vam->ofp, "[%d] %s", i, node->name);
22131 for (j = 0; j < vec_len (node->next_nodes); j++)
22133 if (node->next_nodes[j] != ~0)
22135 next_node = vam->graph_nodes[node->next_nodes[j]];
22136 print (vam->ofp, " [%d] %s", j, next_node->name);
22144 value_sort_cmp (void *a1, void *a2)
22146 name_sort_t *n1 = a1;
22147 name_sort_t *n2 = a2;
22149 if (n1->value < n2->value)
22151 if (n1->value > n2->value)
22158 dump_msg_api_table (vat_main_t * vam)
22160 api_main_t *am = &api_main;
22161 name_sort_t *nses = 0, *ns;
22166 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
22168 vec_add2 (nses, ns, 1);
22169 ns->name = (u8 *)(hp->key);
22170 ns->value = (u32) hp->value[0];
22174 vec_sort_with_function (nses, value_sort_cmp);
22176 for (i = 0; i < vec_len (nses); i++)
22177 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
22183 get_msg_id (vat_main_t * vam)
22188 if (unformat (vam->input, "%s", &name_and_crc))
22190 message_index = vl_api_get_msg_index (name_and_crc);
22191 if (message_index == ~0)
22193 print (vam->ofp, " '%s' not found", name_and_crc);
22196 print (vam->ofp, " '%s' has message index %d",
22197 name_and_crc, message_index);
22200 errmsg ("name_and_crc required...");
22205 search_node_table (vat_main_t * vam)
22207 unformat_input_t *line_input = vam->input;
22210 vlib_node_t *node, *next_node;
22213 if (vam->graph_node_index_by_name == 0)
22215 print (vam->ofp, "Node table empty, issue get_node_graph...");
22219 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22221 if (unformat (line_input, "%s", &node_to_find))
22223 vec_add1 (node_to_find, 0);
22224 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
22227 print (vam->ofp, "%s not found...", node_to_find);
22230 node = vam->graph_nodes[p[0]];
22231 print (vam->ofp, "[%d] %s", p[0], node->name);
22232 for (j = 0; j < vec_len (node->next_nodes); j++)
22234 if (node->next_nodes[j] != ~0)
22236 next_node = vam->graph_nodes[node->next_nodes[j]];
22237 print (vam->ofp, " [%d] %s", j, next_node->name);
22244 clib_warning ("parse error '%U'", format_unformat_error,
22250 vec_free (node_to_find);
22259 script (vat_main_t * vam)
22261 #if (VPP_API_TEST_BUILTIN==0)
22263 char *save_current_file;
22264 unformat_input_t save_input;
22265 jmp_buf save_jump_buf;
22266 u32 save_line_number;
22268 FILE *new_fp, *save_ifp;
22270 if (unformat (vam->input, "%s", &s))
22272 new_fp = fopen ((char *) s, "r");
22275 errmsg ("Couldn't open script file %s", s);
22282 errmsg ("Missing script name");
22286 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
22287 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
22288 save_ifp = vam->ifp;
22289 save_line_number = vam->input_line_number;
22290 save_current_file = (char *) vam->current_file;
22292 vam->input_line_number = 0;
22294 vam->current_file = s;
22297 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
22298 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
22299 vam->ifp = save_ifp;
22300 vam->input_line_number = save_line_number;
22301 vam->current_file = (u8 *) save_current_file;
22306 clib_warning ("use the exec command...");
22312 echo (vat_main_t * vam)
22314 print (vam->ofp, "%v", vam->input->buffer);
22318 /* List of API message constructors, CLI names map to api_xxx */
22319 #define foreach_vpe_api_msg \
22320 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
22321 _(sw_interface_dump,"") \
22322 _(sw_interface_set_flags, \
22323 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
22324 _(sw_interface_add_del_address, \
22325 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
22326 _(sw_interface_set_rx_mode, \
22327 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
22328 _(sw_interface_set_table, \
22329 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
22330 _(sw_interface_set_mpls_enable, \
22331 "<intfc> | sw_if_index [disable | dis]") \
22332 _(sw_interface_set_vpath, \
22333 "<intfc> | sw_if_index <id> enable | disable") \
22334 _(sw_interface_set_vxlan_bypass, \
22335 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22336 _(sw_interface_set_geneve_bypass, \
22337 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22338 _(sw_interface_set_l2_xconnect, \
22339 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22340 "enable | disable") \
22341 _(sw_interface_set_l2_bridge, \
22342 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
22343 "[shg <split-horizon-group>] [bvi]\n" \
22344 "enable | disable") \
22345 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
22346 _(bridge_domain_add_del, \
22347 "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") \
22348 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
22350 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
22351 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
22352 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
22354 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22356 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22358 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
22360 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
22362 "<vpp-if-name> | sw_if_index <id>") \
22363 _(sw_interface_tap_dump, "") \
22364 _(ip_table_add_del, \
22365 "table-id <n> [ipv6]\n") \
22366 _(ip_add_del_route, \
22367 "<addr>/<mask> via <addr> [table-id <n>]\n" \
22368 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
22369 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
22370 "[multipath] [count <n>]") \
22371 _(ip_mroute_add_del, \
22372 "<src> <grp>/<mask> [table-id <n>]\n" \
22373 "[<intfc> | sw_if_index <id>] [local] [del]") \
22374 _(mpls_table_add_del, \
22375 "table-id <n>\n") \
22376 _(mpls_route_add_del, \
22377 "<label> <eos> via <addr> [table-id <n>]\n" \
22378 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
22379 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
22380 "[multipath] [count <n>]") \
22381 _(mpls_ip_bind_unbind, \
22382 "<label> <addr/len>") \
22383 _(mpls_tunnel_add_del, \
22384 " via <addr> [table-id <n>]\n" \
22385 "sw_if_index <id>] [l2] [del]") \
22386 _(bier_table_add_del, \
22387 "<label> <sub-domain> <set> <bsl> [del]") \
22388 _(bier_route_add_del, \
22389 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
22390 "[<intfc> | sw_if_index <id>]" \
22391 "[weight <n>] [del] [multipath]") \
22392 _(proxy_arp_add_del, \
22393 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
22394 _(proxy_arp_intfc_enable_disable, \
22395 "<intfc> | sw_if_index <id> enable | disable") \
22396 _(sw_interface_set_unnumbered, \
22397 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
22398 _(ip_neighbor_add_del, \
22399 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
22400 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
22401 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
22402 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
22403 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
22404 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
22405 "[outer_vlan_id_any][inner_vlan_id_any]") \
22406 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
22407 _(reset_fib, "vrf <n> [ipv6]") \
22408 _(dhcp_proxy_config, \
22409 "svr <v46-address> src <v46-address>\n" \
22410 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
22411 _(dhcp_proxy_set_vss, \
22412 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
22413 _(dhcp_proxy_dump, "ip6") \
22414 _(dhcp_client_config, \
22415 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
22416 _(set_ip_flow_hash, \
22417 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
22418 _(sw_interface_ip6_enable_disable, \
22419 "<intfc> | sw_if_index <id> enable | disable") \
22420 _(sw_interface_ip6_set_link_local_address, \
22421 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
22422 _(ip6nd_proxy_add_del, \
22423 "<intfc> | sw_if_index <id> <ip6-address>") \
22424 _(ip6nd_proxy_dump, "") \
22425 _(sw_interface_ip6nd_ra_prefix, \
22426 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
22427 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
22428 "[nolink] [isno]") \
22429 _(sw_interface_ip6nd_ra_config, \
22430 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
22431 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
22432 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
22433 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
22434 _(l2_patch_add_del, \
22435 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22436 "enable | disable") \
22437 _(sr_localsid_add_del, \
22438 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
22439 "fib-table <num> (end.psp) sw_if_index <num>") \
22440 _(classify_add_del_table, \
22441 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
22442 " [del] [del-chain] mask <mask-value>\n" \
22443 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
22444 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
22445 _(classify_add_del_session, \
22446 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
22447 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
22448 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
22449 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
22450 _(classify_set_interface_ip_table, \
22451 "<intfc> | sw_if_index <nn> table <nn>") \
22452 _(classify_set_interface_l2_tables, \
22453 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22454 " [other-table <nn>]") \
22455 _(get_node_index, "node <node-name") \
22456 _(add_node_next, "node <node-name> next <next-node-name>") \
22457 _(l2tpv3_create_tunnel, \
22458 "client_address <ip6-addr> our_address <ip6-addr>\n" \
22459 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
22460 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
22461 _(l2tpv3_set_tunnel_cookies, \
22462 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
22463 "[new_remote_cookie <nn>]\n") \
22464 _(l2tpv3_interface_enable_disable, \
22465 "<intfc> | sw_if_index <nn> enable | disable") \
22466 _(l2tpv3_set_lookup_key, \
22467 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
22468 _(sw_if_l2tpv3_tunnel_dump, "") \
22469 _(vxlan_add_del_tunnel, \
22470 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22471 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22472 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22473 _(geneve_add_del_tunnel, \
22474 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22475 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22476 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22477 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22478 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22479 _(gre_add_del_tunnel, \
22480 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
22481 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22482 _(l2_fib_clear_table, "") \
22483 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
22484 _(l2_interface_vlan_tag_rewrite, \
22485 "<intfc> | sw_if_index <nn> \n" \
22486 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
22487 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
22488 _(create_vhost_user_if, \
22489 "socket <filename> [server] [renumber <dev_instance>] " \
22490 "[mac <mac_address>]") \
22491 _(modify_vhost_user_if, \
22492 "<intfc> | sw_if_index <nn> socket <filename>\n" \
22493 "[server] [renumber <dev_instance>]") \
22494 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
22495 _(sw_interface_vhost_user_dump, "") \
22496 _(show_version, "") \
22497 _(vxlan_gpe_add_del_tunnel, \
22498 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
22499 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22500 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
22501 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
22502 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22503 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
22504 _(interface_name_renumber, \
22505 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
22506 _(input_acl_set_interface, \
22507 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22508 " [l2-table <nn>] [del]") \
22509 _(want_ip4_arp_events, "address <ip4-address> [del]") \
22510 _(want_ip6_nd_events, "address <ip6-address> [del]") \
22511 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
22512 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
22513 _(ip_dump, "ipv4 | ipv6") \
22514 _(ipsec_spd_add_del, "spd_id <n> [del]") \
22515 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
22517 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
22518 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
22519 " integ_alg <alg> integ_key <hex>") \
22520 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
22521 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
22522 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
22523 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
22524 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
22525 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
22526 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
22527 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
22528 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
22529 _(ipsec_sa_dump, "[sa_id <n>]") \
22530 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
22531 " <alg> <hex>\n") \
22532 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
22533 _(ikev2_profile_add_del, "name <profile_name> [del]") \
22534 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
22535 "(auth_data 0x<data> | auth_data <data>)") \
22536 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
22537 "(id_data 0x<data> | id_data <data>) (local|remote)") \
22538 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
22539 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
22540 "(local|remote)") \
22541 _(ikev2_set_local_key, "file <absolute_file_path>") \
22542 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
22543 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
22544 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
22545 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
22546 _(ikev2_initiate_sa_init, "<profile_name>") \
22547 _(ikev2_initiate_del_ike_sa, "<ispi>") \
22548 _(ikev2_initiate_del_child_sa, "<ispi>") \
22549 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
22550 _(delete_loopback,"sw_if_index <nn>") \
22551 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
22552 _(map_add_domain, \
22553 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
22554 "ip6-src <ip6addr> " \
22555 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
22556 _(map_del_domain, "index <n>") \
22557 _(map_add_del_rule, \
22558 "index <n> psid <n> dst <ip6addr> [del]") \
22559 _(map_domain_dump, "") \
22560 _(map_rule_dump, "index <map-domain>") \
22561 _(want_interface_events, "enable|disable") \
22562 _(want_stats,"enable|disable") \
22563 _(get_first_msg_id, "client <name>") \
22564 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
22565 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
22566 "fib-id <nn> [ip4][ip6][default]") \
22567 _(get_node_graph, " ") \
22568 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
22569 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
22570 _(ioam_disable, "") \
22571 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
22572 " sw_if_index <sw_if_index> p <priority> " \
22573 "w <weight>] [del]") \
22574 _(one_add_del_locator, "locator-set <locator_name> " \
22575 "iface <intf> | sw_if_index <sw_if_index> " \
22576 "p <priority> w <weight> [del]") \
22577 _(one_add_del_local_eid,"vni <vni> eid " \
22578 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22579 "locator-set <locator_name> [del]" \
22580 "[key-id sha1|sha256 secret-key <secret-key>]")\
22581 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
22582 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
22583 _(one_enable_disable, "enable|disable") \
22584 _(one_map_register_enable_disable, "enable|disable") \
22585 _(one_map_register_fallback_threshold, "<value>") \
22586 _(one_rloc_probe_enable_disable, "enable|disable") \
22587 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22589 "rloc <locator> p <prio> " \
22590 "w <weight> [rloc <loc> ... ] " \
22591 "action <action> [del-all]") \
22592 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22594 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22595 _(one_use_petr, "ip-address> | disable") \
22596 _(one_map_request_mode, "src-dst|dst-only") \
22597 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22598 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22599 _(one_locator_set_dump, "[local | remote]") \
22600 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
22601 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22602 "[local] | [remote]") \
22603 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
22604 _(one_ndp_bd_get, "") \
22605 _(one_ndp_entries_get, "bd <bridge-domain>") \
22606 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
22607 _(one_l2_arp_bd_get, "") \
22608 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
22609 _(one_stats_enable_disable, "enable|disalbe") \
22610 _(show_one_stats_enable_disable, "") \
22611 _(one_eid_table_vni_dump, "") \
22612 _(one_eid_table_map_dump, "l2|l3") \
22613 _(one_map_resolver_dump, "") \
22614 _(one_map_server_dump, "") \
22615 _(one_adjacencies_get, "vni <vni>") \
22616 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
22617 _(show_one_rloc_probe_state, "") \
22618 _(show_one_map_register_state, "") \
22619 _(show_one_status, "") \
22620 _(one_stats_dump, "") \
22621 _(one_stats_flush, "") \
22622 _(one_get_map_request_itr_rlocs, "") \
22623 _(one_map_register_set_ttl, "<ttl>") \
22624 _(one_set_transport_protocol, "udp|api") \
22625 _(one_get_transport_protocol, "") \
22626 _(one_enable_disable_xtr_mode, "enable|disable") \
22627 _(one_show_xtr_mode, "") \
22628 _(one_enable_disable_pitr_mode, "enable|disable") \
22629 _(one_show_pitr_mode, "") \
22630 _(one_enable_disable_petr_mode, "enable|disable") \
22631 _(one_show_petr_mode, "") \
22632 _(show_one_nsh_mapping, "") \
22633 _(show_one_pitr, "") \
22634 _(show_one_use_petr, "") \
22635 _(show_one_map_request_mode, "") \
22636 _(show_one_map_register_ttl, "") \
22637 _(show_one_map_register_fallback_threshold, "") \
22638 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
22639 " sw_if_index <sw_if_index> p <priority> " \
22640 "w <weight>] [del]") \
22641 _(lisp_add_del_locator, "locator-set <locator_name> " \
22642 "iface <intf> | sw_if_index <sw_if_index> " \
22643 "p <priority> w <weight> [del]") \
22644 _(lisp_add_del_local_eid,"vni <vni> eid " \
22645 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22646 "locator-set <locator_name> [del]" \
22647 "[key-id sha1|sha256 secret-key <secret-key>]") \
22648 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
22649 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
22650 _(lisp_enable_disable, "enable|disable") \
22651 _(lisp_map_register_enable_disable, "enable|disable") \
22652 _(lisp_rloc_probe_enable_disable, "enable|disable") \
22653 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22655 "rloc <locator> p <prio> " \
22656 "w <weight> [rloc <loc> ... ] " \
22657 "action <action> [del-all]") \
22658 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22660 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22661 _(lisp_use_petr, "<ip-address> | disable") \
22662 _(lisp_map_request_mode, "src-dst|dst-only") \
22663 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22664 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22665 _(lisp_locator_set_dump, "[local | remote]") \
22666 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
22667 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22668 "[local] | [remote]") \
22669 _(lisp_eid_table_vni_dump, "") \
22670 _(lisp_eid_table_map_dump, "l2|l3") \
22671 _(lisp_map_resolver_dump, "") \
22672 _(lisp_map_server_dump, "") \
22673 _(lisp_adjacencies_get, "vni <vni>") \
22674 _(gpe_fwd_entry_vnis_get, "") \
22675 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
22676 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
22677 "[table <table-id>]") \
22678 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
22679 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
22680 _(gpe_set_encap_mode, "lisp|vxlan") \
22681 _(gpe_get_encap_mode, "") \
22682 _(lisp_gpe_add_del_iface, "up|down") \
22683 _(lisp_gpe_enable_disable, "enable|disable") \
22684 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
22685 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
22686 _(show_lisp_rloc_probe_state, "") \
22687 _(show_lisp_map_register_state, "") \
22688 _(show_lisp_status, "") \
22689 _(lisp_get_map_request_itr_rlocs, "") \
22690 _(show_lisp_pitr, "") \
22691 _(show_lisp_use_petr, "") \
22692 _(show_lisp_map_request_mode, "") \
22693 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
22694 _(af_packet_delete, "name <host interface name>") \
22695 _(policer_add_del, "name <policer name> <params> [del]") \
22696 _(policer_dump, "[name <policer name>]") \
22697 _(policer_classify_set_interface, \
22698 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22699 " [l2-table <nn>] [del]") \
22700 _(policer_classify_dump, "type [ip4|ip6|l2]") \
22701 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
22702 "[master|slave]") \
22703 _(netmap_delete, "name <interface name>") \
22704 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
22705 _(mpls_fib_dump, "") \
22706 _(classify_table_ids, "") \
22707 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
22708 _(classify_table_info, "table_id <nn>") \
22709 _(classify_session_dump, "table_id <nn>") \
22710 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
22711 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
22712 "[template_interval <nn>] [udp_checksum]") \
22713 _(ipfix_exporter_dump, "") \
22714 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
22715 _(ipfix_classify_stream_dump, "") \
22716 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
22717 _(ipfix_classify_table_dump, "") \
22718 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
22719 _(sw_interface_span_dump, "[l2]") \
22720 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
22721 _(pg_create_interface, "if_id <nn>") \
22722 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
22723 _(pg_enable_disable, "[stream <id>] disable") \
22724 _(ip_source_and_port_range_check_add_del, \
22725 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
22726 _(ip_source_and_port_range_check_interface_add_del, \
22727 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
22728 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
22729 _(ipsec_gre_add_del_tunnel, \
22730 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
22731 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
22732 _(delete_subif,"<intfc> | sw_if_index <nn>") \
22733 _(l2_interface_pbb_tag_rewrite, \
22734 "<intfc> | sw_if_index <nn> \n" \
22735 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
22736 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
22737 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
22738 _(flow_classify_set_interface, \
22739 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
22740 _(flow_classify_dump, "type [ip4|ip6]") \
22741 _(ip_fib_dump, "") \
22742 _(ip_mfib_dump, "") \
22743 _(ip6_fib_dump, "") \
22744 _(ip6_mfib_dump, "") \
22745 _(feature_enable_disable, "arc_name <arc_name> " \
22746 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
22747 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
22749 _(l2_xconnect_dump, "") \
22750 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
22751 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
22752 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
22753 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
22754 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
22755 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
22756 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
22757 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
22758 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
22759 _(memfd_segment_create,"size <nnn>") \
22760 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
22761 _(dns_enable_disable, "[enable][disable]") \
22762 _(dns_name_server_add_del, "<ip-address> [del]") \
22763 _(dns_resolve_name, "<hostname>") \
22764 _(dns_resolve_ip, "<ip4|ip6>") \
22765 _(dns_name_server_add_del, "<ip-address> [del]") \
22766 _(dns_resolve_name, "<hostname>") \
22767 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
22768 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
22769 _(session_rules_dump, "") \
22770 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
22772 /* List of command functions, CLI names map directly to functions */
22773 #define foreach_cli_function \
22774 _(comment, "usage: comment <ignore-rest-of-line>") \
22775 _(dump_interface_table, "usage: dump_interface_table") \
22776 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
22777 _(dump_ipv4_table, "usage: dump_ipv4_table") \
22778 _(dump_ipv6_table, "usage: dump_ipv6_table") \
22779 _(dump_stats_table, "usage: dump_stats_table") \
22780 _(dump_macro_table, "usage: dump_macro_table ") \
22781 _(dump_node_table, "usage: dump_node_table") \
22782 _(dump_msg_api_table, "usage: dump_msg_api_table") \
22783 _(get_msg_id, "usage: get_msg_id name_and_crc") \
22784 _(echo, "usage: echo <message>") \
22785 _(exec, "usage: exec <vpe-debug-CLI-command>") \
22786 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
22787 _(help, "usage: help") \
22788 _(q, "usage: quit") \
22789 _(quit, "usage: quit") \
22790 _(search_node_table, "usage: search_node_table <name>...") \
22791 _(set, "usage: set <variable-name> <value>") \
22792 _(script, "usage: script <file-name>") \
22793 _(unset, "usage: unset <variable-name>")
22795 static void vl_api_##n##_t_handler_uni \
22796 (vl_api_##n##_t * mp) \
22798 vat_main_t * vam = &vat_main; \
22799 if (vam->json_output) { \
22800 vl_api_##n##_t_handler_json(mp); \
22802 vl_api_##n##_t_handler(mp); \
22805 foreach_vpe_api_reply_msg;
22806 #if VPP_API_TEST_BUILTIN == 0
22807 foreach_standalone_reply_msg;
22812 vat_api_hookup (vat_main_t * vam)
22815 vl_msg_api_set_handlers(VL_API_##N, #n, \
22816 vl_api_##n##_t_handler_uni, \
22818 vl_api_##n##_t_endian, \
22819 vl_api_##n##_t_print, \
22820 sizeof(vl_api_##n##_t), 1);
22821 foreach_vpe_api_reply_msg;
22822 #if VPP_API_TEST_BUILTIN == 0
22823 foreach_standalone_reply_msg;
22827 #if (VPP_API_TEST_BUILTIN==0)
22828 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
22830 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
22832 vam->function_by_name = hash_create_string (0, sizeof (uword));
22834 vam->help_by_name = hash_create_string (0, sizeof (uword));
22837 /* API messages we can send */
22838 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
22839 foreach_vpe_api_msg;
22843 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22844 foreach_vpe_api_msg;
22847 /* CLI functions */
22848 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
22849 foreach_cli_function;
22853 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22854 foreach_cli_function;
22858 #if VPP_API_TEST_BUILTIN
22859 static clib_error_t *
22860 vat_api_hookup_shim (vlib_main_t * vm)
22862 vat_api_hookup (&vat_main);
22866 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
22870 * fd.io coding-style-patch-verification: ON
22873 * eval: (c-set-style "gnu")