2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vppinfra/socket.h>
22 #include <svm/memfd.h>
23 #include <vlibapi/api.h>
24 #include <vlibmemory/api.h>
25 #include <vnet/ip/ip.h>
26 #include <vnet/l2/l2_input.h>
27 #include <vnet/l2tp/l2tp.h>
28 #include <vnet/vxlan/vxlan.h>
29 #include <vnet/geneve/geneve.h>
30 #include <vnet/gre/gre.h>
31 #include <vnet/vxlan-gpe/vxlan_gpe.h>
32 #include <vnet/lisp-gpe/lisp_gpe.h>
34 #include <vpp/api/vpe_msg_enum.h>
35 #include <vnet/l2/l2_classify.h>
36 #include <vnet/l2/l2_vtr.h>
37 #include <vnet/classify/input_acl.h>
38 #include <vnet/classify/policer_classify.h>
39 #include <vnet/classify/flow_classify.h>
40 #include <vnet/mpls/mpls.h>
41 #include <vnet/ipsec/ipsec.h>
42 #include <vnet/ipsec/ikev2.h>
44 #include <vnet/map/map.h>
45 #include <vnet/cop/cop.h>
46 #include <vnet/ip/ip6_hop_by_hop.h>
47 #include <vnet/ip/ip_source_and_port_range_check.h>
48 #include <vnet/policer/xlate.h>
49 #include <vnet/span/span.h>
50 #include <vnet/policer/policer.h>
51 #include <vnet/policer/police.h>
52 #include <vnet/mfib/mfib_types.h>
54 #include "vat/json_format.h"
59 #define vl_typedefs /* define message structures */
60 #include <vpp/api/vpe_all_api_h.h>
63 /* declare message handlers for each api */
65 #define vl_endianfun /* define message structures */
66 #include <vpp/api/vpe_all_api_h.h>
69 /* instantiate all the print functions we know about */
70 #define vl_print(handle, ...)
72 #include <vpp/api/vpe_all_api_h.h>
75 #define __plugin_msg_base 0
76 #include <vlibapi/vat_helper_macros.h>
78 #if VPP_API_TEST_BUILTIN == 0
88 vat_socket_connect (vat_main_t * vam)
90 return vl_socket_client_connect
91 (&vam->socket_client_main, (char *) vam->socket_name,
92 "vpp_api_test(s)", 0 /* default socket rx, tx buffer */ );
94 #else /* vpp built-in case, we don't do sockets... */
96 vat_socket_connect (vat_main_t * vam)
102 vl_socket_client_read_reply (socket_client_main_t * scm)
109 vat_time_now (vat_main_t * vam)
111 #if VPP_API_TEST_BUILTIN
112 return vlib_time_now (vam->vlib_main);
114 return clib_time_now (&vam->clib_time);
119 errmsg (char *fmt, ...)
121 vat_main_t *vam = &vat_main;
126 s = va_format (0, fmt, &va);
131 #if VPP_API_TEST_BUILTIN
132 vlib_cli_output (vam->vlib_main, (char *) s);
135 if (vam->ifp != stdin)
136 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
137 vam->input_line_number);
138 fformat (vam->ofp, (char *) s);
146 #if VPP_API_TEST_BUILTIN == 0
148 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
150 vat_main_t *vam = va_arg (*args, vat_main_t *);
151 u32 *result = va_arg (*args, u32 *);
155 if (!unformat (input, "%s", &if_name))
158 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
165 /* Parse an IP4 address %d.%d.%d.%d. */
167 unformat_ip4_address (unformat_input_t * input, va_list * args)
169 u8 *result = va_arg (*args, u8 *);
172 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
175 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
187 unformat_ethernet_address (unformat_input_t * input, va_list * args)
189 u8 *result = va_arg (*args, u8 *);
192 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
193 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
197 for (i = 0; i < 6; i++)
198 if (a[i] >= (1 << 8))
201 for (i = 0; i < 6; i++)
207 /* Returns ethernet type as an int in host byte order. */
209 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
212 u16 *result = va_arg (*args, u16 *);
216 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
218 if (type >= (1 << 16))
226 /* Parse an IP6 address. */
228 unformat_ip6_address (unformat_input_t * input, va_list * args)
230 ip6_address_t *result = va_arg (*args, ip6_address_t *);
232 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
233 uword c, n_colon, double_colon_index;
235 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
236 double_colon_index = ARRAY_LEN (hex_quads);
237 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
240 if (c >= '0' && c <= '9')
242 else if (c >= 'a' && c <= 'f')
243 hex_digit = c + 10 - 'a';
244 else if (c >= 'A' && c <= 'F')
245 hex_digit = c + 10 - 'A';
246 else if (c == ':' && n_colon < 2)
250 unformat_put_input (input);
254 /* Too many hex quads. */
255 if (n_hex_quads >= ARRAY_LEN (hex_quads))
260 hex_quad = (hex_quad << 4) | hex_digit;
262 /* Hex quad must fit in 16 bits. */
263 if (n_hex_digits >= 4)
270 /* Save position of :: */
273 /* More than one :: ? */
274 if (double_colon_index < ARRAY_LEN (hex_quads))
276 double_colon_index = n_hex_quads;
279 if (n_colon > 0 && n_hex_digits > 0)
281 hex_quads[n_hex_quads++] = hex_quad;
287 if (n_hex_digits > 0)
288 hex_quads[n_hex_quads++] = hex_quad;
293 /* Expand :: to appropriate number of zero hex quads. */
294 if (double_colon_index < ARRAY_LEN (hex_quads))
296 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
298 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
299 hex_quads[n_zero + i] = hex_quads[i];
301 for (i = 0; i < n_zero; i++)
302 hex_quads[double_colon_index + i] = 0;
304 n_hex_quads = ARRAY_LEN (hex_quads);
307 /* Too few hex quads given. */
308 if (n_hex_quads < ARRAY_LEN (hex_quads))
311 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
312 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
319 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
321 u32 *r = va_arg (*args, u32 *);
324 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
325 foreach_ipsec_policy_action
333 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
335 u32 *r = va_arg (*args, u32 *);
338 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
339 foreach_ipsec_crypto_alg
347 format_ipsec_crypto_alg (u8 * s, va_list * args)
349 u32 i = va_arg (*args, u32);
354 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
355 foreach_ipsec_crypto_alg
358 return format (s, "unknown");
360 return format (s, "%s", t);
364 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
366 u32 *r = va_arg (*args, u32 *);
369 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
370 foreach_ipsec_integ_alg
378 format_ipsec_integ_alg (u8 * s, va_list * args)
380 u32 i = va_arg (*args, u32);
385 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
386 foreach_ipsec_integ_alg
389 return format (s, "unknown");
391 return format (s, "%s", t);
395 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
397 u32 *r = va_arg (*args, u32 *);
400 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
401 foreach_ikev2_auth_method
409 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
411 u32 *r = va_arg (*args, u32 *);
414 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
415 foreach_ikev2_id_type
421 #else /* VPP_API_TEST_BUILTIN == 1 */
423 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
425 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
426 vnet_main_t *vnm = vnet_get_main ();
427 u32 *result = va_arg (*args, u32 *);
430 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
433 *result = sw_if_index;
436 #endif /* VPP_API_TEST_BUILTIN */
439 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
441 u8 *r = va_arg (*args, u8 *);
443 if (unformat (input, "kbps"))
444 *r = SSE2_QOS_RATE_KBPS;
445 else if (unformat (input, "pps"))
446 *r = SSE2_QOS_RATE_PPS;
453 unformat_policer_round_type (unformat_input_t * input, va_list * args)
455 u8 *r = va_arg (*args, u8 *);
457 if (unformat (input, "closest"))
458 *r = SSE2_QOS_ROUND_TO_CLOSEST;
459 else if (unformat (input, "up"))
460 *r = SSE2_QOS_ROUND_TO_UP;
461 else if (unformat (input, "down"))
462 *r = SSE2_QOS_ROUND_TO_DOWN;
469 unformat_policer_type (unformat_input_t * input, va_list * args)
471 u8 *r = va_arg (*args, u8 *);
473 if (unformat (input, "1r2c"))
474 *r = SSE2_QOS_POLICER_TYPE_1R2C;
475 else if (unformat (input, "1r3c"))
476 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
477 else if (unformat (input, "2r3c-2698"))
478 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
479 else if (unformat (input, "2r3c-4115"))
480 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
481 else if (unformat (input, "2r3c-mef5cf1"))
482 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
489 unformat_dscp (unformat_input_t * input, va_list * va)
491 u8 *r = va_arg (*va, u8 *);
494 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
503 unformat_policer_action_type (unformat_input_t * input, va_list * va)
505 sse2_qos_pol_action_params_st *a
506 = va_arg (*va, sse2_qos_pol_action_params_st *);
508 if (unformat (input, "drop"))
509 a->action_type = SSE2_QOS_ACTION_DROP;
510 else if (unformat (input, "transmit"))
511 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
512 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
513 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
520 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
522 u32 *r = va_arg (*va, u32 *);
525 if (unformat (input, "ip4"))
526 tid = POLICER_CLASSIFY_TABLE_IP4;
527 else if (unformat (input, "ip6"))
528 tid = POLICER_CLASSIFY_TABLE_IP6;
529 else if (unformat (input, "l2"))
530 tid = POLICER_CLASSIFY_TABLE_L2;
539 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
541 u32 *r = va_arg (*va, u32 *);
544 if (unformat (input, "ip4"))
545 tid = FLOW_CLASSIFY_TABLE_IP4;
546 else if (unformat (input, "ip6"))
547 tid = FLOW_CLASSIFY_TABLE_IP6;
555 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
556 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
557 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
558 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
560 #if (VPP_API_TEST_BUILTIN==0)
562 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
564 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
565 mfib_itf_attribute_t attr;
568 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
570 if (unformat (input, mfib_itf_flag_long_names[attr]))
571 *iflags |= (1 << attr);
573 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
575 if (unformat (input, mfib_itf_flag_names[attr]))
576 *iflags |= (1 << attr);
579 return (old == *iflags ? 0 : 1);
583 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
585 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
586 mfib_entry_attribute_t attr;
589 FOR_EACH_MFIB_ATTRIBUTE (attr)
591 if (unformat (input, mfib_flag_long_names[attr]))
592 *eflags |= (1 << attr);
594 FOR_EACH_MFIB_ATTRIBUTE (attr)
596 if (unformat (input, mfib_flag_names[attr]))
597 *eflags |= (1 << attr);
600 return (old == *eflags ? 0 : 1);
604 format_ip4_address (u8 * s, va_list * args)
606 u8 *a = va_arg (*args, u8 *);
607 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
611 format_ip6_address (u8 * s, va_list * args)
613 ip6_address_t *a = va_arg (*args, ip6_address_t *);
614 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
616 i_max_n_zero = ARRAY_LEN (a->as_u16);
618 i_first_zero = i_max_n_zero;
620 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
622 u32 is_zero = a->as_u16[i] == 0;
623 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
629 if ((!is_zero && n_zeros > max_n_zeros)
630 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
632 i_max_n_zero = i_first_zero;
633 max_n_zeros = n_zeros;
634 i_first_zero = ARRAY_LEN (a->as_u16);
639 last_double_colon = 0;
640 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
642 if (i == i_max_n_zero && max_n_zeros > 1)
644 s = format (s, "::");
645 i += max_n_zeros - 1;
646 last_double_colon = 1;
650 s = format (s, "%s%x",
651 (last_double_colon || i == 0) ? "" : ":",
652 clib_net_to_host_u16 (a->as_u16[i]));
653 last_double_colon = 0;
660 /* Format an IP46 address. */
662 format_ip46_address (u8 * s, va_list * args)
664 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
665 ip46_type_t type = va_arg (*args, ip46_type_t);
671 is_ip4 = ip46_address_is_ip4 (ip46);
682 format (s, "%U", format_ip4_address, &ip46->ip4) :
683 format (s, "%U", format_ip6_address, &ip46->ip6);
687 format_ethernet_address (u8 * s, va_list * args)
689 u8 *a = va_arg (*args, u8 *);
691 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
692 a[0], a[1], a[2], a[3], a[4], a[5]);
697 increment_v4_address (ip4_address_t * a)
701 v = ntohl (a->as_u32) + 1;
702 a->as_u32 = ntohl (v);
706 increment_v6_address (ip6_address_t * a)
710 v0 = clib_net_to_host_u64 (a->as_u64[0]);
711 v1 = clib_net_to_host_u64 (a->as_u64[1]);
716 a->as_u64[0] = clib_net_to_host_u64 (v0);
717 a->as_u64[1] = clib_net_to_host_u64 (v1);
721 increment_mac_address (u64 * mac)
725 tmp = clib_net_to_host_u64 (tmp);
726 tmp += 1 << 16; /* skip unused (least significant) octets */
727 tmp = clib_host_to_net_u64 (tmp);
731 static void vl_api_create_loopback_reply_t_handler
732 (vl_api_create_loopback_reply_t * mp)
734 vat_main_t *vam = &vat_main;
735 i32 retval = ntohl (mp->retval);
737 vam->retval = retval;
738 vam->regenerate_interface_table = 1;
739 vam->sw_if_index = ntohl (mp->sw_if_index);
740 vam->result_ready = 1;
743 static void vl_api_create_loopback_reply_t_handler_json
744 (vl_api_create_loopback_reply_t * mp)
746 vat_main_t *vam = &vat_main;
747 vat_json_node_t node;
749 vat_json_init_object (&node);
750 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
751 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
753 vat_json_print (vam->ofp, &node);
754 vat_json_free (&node);
755 vam->retval = ntohl (mp->retval);
756 vam->result_ready = 1;
759 static void vl_api_create_loopback_instance_reply_t_handler
760 (vl_api_create_loopback_instance_reply_t * mp)
762 vat_main_t *vam = &vat_main;
763 i32 retval = ntohl (mp->retval);
765 vam->retval = retval;
766 vam->regenerate_interface_table = 1;
767 vam->sw_if_index = ntohl (mp->sw_if_index);
768 vam->result_ready = 1;
771 static void vl_api_create_loopback_instance_reply_t_handler_json
772 (vl_api_create_loopback_instance_reply_t * mp)
774 vat_main_t *vam = &vat_main;
775 vat_json_node_t node;
777 vat_json_init_object (&node);
778 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
779 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
781 vat_json_print (vam->ofp, &node);
782 vat_json_free (&node);
783 vam->retval = ntohl (mp->retval);
784 vam->result_ready = 1;
787 static void vl_api_af_packet_create_reply_t_handler
788 (vl_api_af_packet_create_reply_t * mp)
790 vat_main_t *vam = &vat_main;
791 i32 retval = ntohl (mp->retval);
793 vam->retval = retval;
794 vam->regenerate_interface_table = 1;
795 vam->sw_if_index = ntohl (mp->sw_if_index);
796 vam->result_ready = 1;
799 static void vl_api_af_packet_create_reply_t_handler_json
800 (vl_api_af_packet_create_reply_t * mp)
802 vat_main_t *vam = &vat_main;
803 vat_json_node_t node;
805 vat_json_init_object (&node);
806 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
807 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
809 vat_json_print (vam->ofp, &node);
810 vat_json_free (&node);
812 vam->retval = ntohl (mp->retval);
813 vam->result_ready = 1;
816 static void vl_api_create_vlan_subif_reply_t_handler
817 (vl_api_create_vlan_subif_reply_t * mp)
819 vat_main_t *vam = &vat_main;
820 i32 retval = ntohl (mp->retval);
822 vam->retval = retval;
823 vam->regenerate_interface_table = 1;
824 vam->sw_if_index = ntohl (mp->sw_if_index);
825 vam->result_ready = 1;
828 static void vl_api_create_vlan_subif_reply_t_handler_json
829 (vl_api_create_vlan_subif_reply_t * mp)
831 vat_main_t *vam = &vat_main;
832 vat_json_node_t node;
834 vat_json_init_object (&node);
835 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
836 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
838 vat_json_print (vam->ofp, &node);
839 vat_json_free (&node);
841 vam->retval = ntohl (mp->retval);
842 vam->result_ready = 1;
845 static void vl_api_create_subif_reply_t_handler
846 (vl_api_create_subif_reply_t * mp)
848 vat_main_t *vam = &vat_main;
849 i32 retval = ntohl (mp->retval);
851 vam->retval = retval;
852 vam->regenerate_interface_table = 1;
853 vam->sw_if_index = ntohl (mp->sw_if_index);
854 vam->result_ready = 1;
857 static void vl_api_create_subif_reply_t_handler_json
858 (vl_api_create_subif_reply_t * mp)
860 vat_main_t *vam = &vat_main;
861 vat_json_node_t node;
863 vat_json_init_object (&node);
864 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
865 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
867 vat_json_print (vam->ofp, &node);
868 vat_json_free (&node);
870 vam->retval = ntohl (mp->retval);
871 vam->result_ready = 1;
874 static void vl_api_interface_name_renumber_reply_t_handler
875 (vl_api_interface_name_renumber_reply_t * mp)
877 vat_main_t *vam = &vat_main;
878 i32 retval = ntohl (mp->retval);
880 vam->retval = retval;
881 vam->regenerate_interface_table = 1;
882 vam->result_ready = 1;
885 static void vl_api_interface_name_renumber_reply_t_handler_json
886 (vl_api_interface_name_renumber_reply_t * mp)
888 vat_main_t *vam = &vat_main;
889 vat_json_node_t node;
891 vat_json_init_object (&node);
892 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
894 vat_json_print (vam->ofp, &node);
895 vat_json_free (&node);
897 vam->retval = ntohl (mp->retval);
898 vam->result_ready = 1;
902 * Special-case: build the interface table, maintain
903 * the next loopback sw_if_index vbl.
905 static void vl_api_sw_interface_details_t_handler
906 (vl_api_sw_interface_details_t * mp)
908 vat_main_t *vam = &vat_main;
909 u8 *s = format (0, "%s%c", mp->interface_name, 0);
911 hash_set_mem (vam->sw_if_index_by_interface_name, s,
912 ntohl (mp->sw_if_index));
914 /* In sub interface case, fill the sub interface table entry */
915 if (mp->sw_if_index != mp->sup_sw_if_index)
917 sw_interface_subif_t *sub = NULL;
919 vec_add2 (vam->sw_if_subif_table, sub, 1);
921 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
922 strncpy ((char *) sub->interface_name, (char *) s,
923 vec_len (sub->interface_name));
924 sub->sw_if_index = ntohl (mp->sw_if_index);
925 sub->sub_id = ntohl (mp->sub_id);
927 sub->sub_dot1ad = mp->sub_dot1ad;
928 sub->sub_number_of_tags = mp->sub_number_of_tags;
929 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
930 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
931 sub->sub_exact_match = mp->sub_exact_match;
932 sub->sub_default = mp->sub_default;
933 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
934 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
936 /* vlan tag rewrite */
937 sub->vtr_op = ntohl (mp->vtr_op);
938 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
939 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
940 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
944 static void vl_api_sw_interface_details_t_handler_json
945 (vl_api_sw_interface_details_t * mp)
947 vat_main_t *vam = &vat_main;
948 vat_json_node_t *node = NULL;
950 if (VAT_JSON_ARRAY != vam->json_tree.type)
952 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
953 vat_json_init_array (&vam->json_tree);
955 node = vat_json_array_add (&vam->json_tree);
957 vat_json_init_object (node);
958 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
959 vat_json_object_add_uint (node, "sup_sw_if_index",
960 ntohl (mp->sup_sw_if_index));
961 vat_json_object_add_uint (node, "l2_address_length",
962 ntohl (mp->l2_address_length));
963 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
964 sizeof (mp->l2_address));
965 vat_json_object_add_string_copy (node, "interface_name",
967 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
968 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
969 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
970 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
971 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
972 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
973 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
974 vat_json_object_add_uint (node, "sub_number_of_tags",
975 mp->sub_number_of_tags);
976 vat_json_object_add_uint (node, "sub_outer_vlan_id",
977 ntohs (mp->sub_outer_vlan_id));
978 vat_json_object_add_uint (node, "sub_inner_vlan_id",
979 ntohs (mp->sub_inner_vlan_id));
980 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
981 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
982 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
983 mp->sub_outer_vlan_id_any);
984 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
985 mp->sub_inner_vlan_id_any);
986 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
987 vat_json_object_add_uint (node, "vtr_push_dot1q",
988 ntohl (mp->vtr_push_dot1q));
989 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
990 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
993 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
995 format_ethernet_address,
997 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
999 format_ethernet_address,
1001 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1002 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1006 #if VPP_API_TEST_BUILTIN == 0
1007 static void vl_api_sw_interface_event_t_handler
1008 (vl_api_sw_interface_event_t * mp)
1010 vat_main_t *vam = &vat_main;
1011 if (vam->interface_event_display)
1012 errmsg ("interface flags: sw_if_index %d %s %s",
1013 ntohl (mp->sw_if_index),
1014 mp->admin_up_down ? "admin-up" : "admin-down",
1015 mp->link_up_down ? "link-up" : "link-down");
1019 static void vl_api_sw_interface_event_t_handler_json
1020 (vl_api_sw_interface_event_t * mp)
1022 /* JSON output not supported */
1026 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1028 vat_main_t *vam = &vat_main;
1029 i32 retval = ntohl (mp->retval);
1031 vam->retval = retval;
1032 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1033 vam->result_ready = 1;
1037 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1039 vat_main_t *vam = &vat_main;
1040 vat_json_node_t node;
1041 api_main_t *am = &api_main;
1045 vat_json_init_object (&node);
1046 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1047 vat_json_object_add_uint (&node, "reply_in_shmem",
1048 ntohl (mp->reply_in_shmem));
1049 /* Toss the shared-memory original... */
1050 pthread_mutex_lock (&am->vlib_rp->mutex);
1051 oldheap = svm_push_data_heap (am->vlib_rp);
1053 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1056 svm_pop_heap (oldheap);
1057 pthread_mutex_unlock (&am->vlib_rp->mutex);
1059 vat_json_print (vam->ofp, &node);
1060 vat_json_free (&node);
1062 vam->retval = ntohl (mp->retval);
1063 vam->result_ready = 1;
1067 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1069 vat_main_t *vam = &vat_main;
1070 i32 retval = ntohl (mp->retval);
1071 u32 length = ntohl (mp->length);
1073 vec_reset_length (vam->cmd_reply);
1075 vam->retval = retval;
1078 vec_validate (vam->cmd_reply, length);
1079 clib_memcpy ((char *) (vam->cmd_reply), mp->reply, length);
1080 vam->cmd_reply[length] = 0;
1082 vam->result_ready = 1;
1086 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1088 vat_main_t *vam = &vat_main;
1089 vat_json_node_t node;
1091 vec_reset_length (vam->cmd_reply);
1093 vat_json_init_object (&node);
1094 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1095 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1097 vat_json_print (vam->ofp, &node);
1098 vat_json_free (&node);
1100 vam->retval = ntohl (mp->retval);
1101 vam->result_ready = 1;
1104 static void vl_api_classify_add_del_table_reply_t_handler
1105 (vl_api_classify_add_del_table_reply_t * mp)
1107 vat_main_t *vam = &vat_main;
1108 i32 retval = ntohl (mp->retval);
1109 if (vam->async_mode)
1111 vam->async_errors += (retval < 0);
1115 vam->retval = retval;
1117 ((mp->new_table_index != 0xFFFFFFFF) ||
1118 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1119 (mp->match_n_vectors != 0xFFFFFFFF)))
1121 * Note: this is just barely thread-safe, depends on
1122 * the main thread spinning waiting for an answer...
1124 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1125 ntohl (mp->new_table_index),
1126 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1127 vam->result_ready = 1;
1131 static void vl_api_classify_add_del_table_reply_t_handler_json
1132 (vl_api_classify_add_del_table_reply_t * mp)
1134 vat_main_t *vam = &vat_main;
1135 vat_json_node_t node;
1137 vat_json_init_object (&node);
1138 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1139 vat_json_object_add_uint (&node, "new_table_index",
1140 ntohl (mp->new_table_index));
1141 vat_json_object_add_uint (&node, "skip_n_vectors",
1142 ntohl (mp->skip_n_vectors));
1143 vat_json_object_add_uint (&node, "match_n_vectors",
1144 ntohl (mp->match_n_vectors));
1146 vat_json_print (vam->ofp, &node);
1147 vat_json_free (&node);
1149 vam->retval = ntohl (mp->retval);
1150 vam->result_ready = 1;
1153 static void vl_api_get_node_index_reply_t_handler
1154 (vl_api_get_node_index_reply_t * mp)
1156 vat_main_t *vam = &vat_main;
1157 i32 retval = ntohl (mp->retval);
1158 if (vam->async_mode)
1160 vam->async_errors += (retval < 0);
1164 vam->retval = retval;
1166 errmsg ("node index %d", ntohl (mp->node_index));
1167 vam->result_ready = 1;
1171 static void vl_api_get_node_index_reply_t_handler_json
1172 (vl_api_get_node_index_reply_t * mp)
1174 vat_main_t *vam = &vat_main;
1175 vat_json_node_t node;
1177 vat_json_init_object (&node);
1178 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1179 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1181 vat_json_print (vam->ofp, &node);
1182 vat_json_free (&node);
1184 vam->retval = ntohl (mp->retval);
1185 vam->result_ready = 1;
1188 static void vl_api_get_next_index_reply_t_handler
1189 (vl_api_get_next_index_reply_t * mp)
1191 vat_main_t *vam = &vat_main;
1192 i32 retval = ntohl (mp->retval);
1193 if (vam->async_mode)
1195 vam->async_errors += (retval < 0);
1199 vam->retval = retval;
1201 errmsg ("next node index %d", ntohl (mp->next_index));
1202 vam->result_ready = 1;
1206 static void vl_api_get_next_index_reply_t_handler_json
1207 (vl_api_get_next_index_reply_t * mp)
1209 vat_main_t *vam = &vat_main;
1210 vat_json_node_t node;
1212 vat_json_init_object (&node);
1213 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1214 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1216 vat_json_print (vam->ofp, &node);
1217 vat_json_free (&node);
1219 vam->retval = ntohl (mp->retval);
1220 vam->result_ready = 1;
1223 static void vl_api_add_node_next_reply_t_handler
1224 (vl_api_add_node_next_reply_t * mp)
1226 vat_main_t *vam = &vat_main;
1227 i32 retval = ntohl (mp->retval);
1228 if (vam->async_mode)
1230 vam->async_errors += (retval < 0);
1234 vam->retval = retval;
1236 errmsg ("next index %d", ntohl (mp->next_index));
1237 vam->result_ready = 1;
1241 static void vl_api_add_node_next_reply_t_handler_json
1242 (vl_api_add_node_next_reply_t * mp)
1244 vat_main_t *vam = &vat_main;
1245 vat_json_node_t node;
1247 vat_json_init_object (&node);
1248 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1249 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1251 vat_json_print (vam->ofp, &node);
1252 vat_json_free (&node);
1254 vam->retval = ntohl (mp->retval);
1255 vam->result_ready = 1;
1258 static void vl_api_show_version_reply_t_handler
1259 (vl_api_show_version_reply_t * mp)
1261 vat_main_t *vam = &vat_main;
1262 i32 retval = ntohl (mp->retval);
1266 errmsg (" program: %s", mp->program);
1267 errmsg (" version: %s", mp->version);
1268 errmsg (" build date: %s", mp->build_date);
1269 errmsg ("build directory: %s", mp->build_directory);
1271 vam->retval = retval;
1272 vam->result_ready = 1;
1275 static void vl_api_show_version_reply_t_handler_json
1276 (vl_api_show_version_reply_t * mp)
1278 vat_main_t *vam = &vat_main;
1279 vat_json_node_t node;
1281 vat_json_init_object (&node);
1282 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1283 vat_json_object_add_string_copy (&node, "program", mp->program);
1284 vat_json_object_add_string_copy (&node, "version", mp->version);
1285 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1286 vat_json_object_add_string_copy (&node, "build_directory",
1287 mp->build_directory);
1289 vat_json_print (vam->ofp, &node);
1290 vat_json_free (&node);
1292 vam->retval = ntohl (mp->retval);
1293 vam->result_ready = 1;
1297 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1299 u32 sw_if_index = ntohl (mp->sw_if_index);
1300 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1301 mp->mac_ip ? "mac/ip binding" : "address resolution",
1302 ntohl (mp->pid), format_ip4_address, &mp->address,
1303 format_ethernet_address, mp->new_mac, sw_if_index);
1307 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1309 /* JSON output not supported */
1313 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1315 u32 sw_if_index = ntohl (mp->sw_if_index);
1316 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1317 mp->mac_ip ? "mac/ip binding" : "address resolution",
1318 ntohl (mp->pid), format_ip6_address, mp->address,
1319 format_ethernet_address, mp->new_mac, sw_if_index);
1323 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1325 /* JSON output not supported */
1329 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1331 u32 n_macs = ntohl (mp->n_macs);
1332 errmsg ("L2MAC event recived with pid %d cl-idx %d for %d macs: \n",
1333 ntohl (mp->pid), mp->client_index, n_macs);
1335 for (i = 0; i < n_macs; i++)
1337 vl_api_mac_entry_t *mac = &mp->mac[i];
1338 errmsg (" [%d] sw_if_index %d mac_addr %U is_del %d \n",
1339 i + 1, ntohl (mac->sw_if_index),
1340 format_ethernet_address, mac->mac_addr, mac->is_del);
1347 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1349 /* JSON output not supported */
1352 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1353 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1356 * Special-case: build the bridge domain table, maintain
1357 * the next bd id vbl.
1359 static void vl_api_bridge_domain_details_t_handler
1360 (vl_api_bridge_domain_details_t * mp)
1362 vat_main_t *vam = &vat_main;
1363 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1366 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1367 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1369 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1370 ntohl (mp->bd_id), mp->learn, mp->forward,
1371 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1375 vl_api_bridge_domain_sw_if_t *sw_ifs;
1376 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1379 sw_ifs = mp->sw_if_details;
1380 for (i = 0; i < n_sw_ifs; i++)
1386 sw_if_index = ntohl (sw_ifs->sw_if_index);
1389 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1391 if ((u32) p->value[0] == sw_if_index)
1393 sw_if_name = (u8 *)(p->key);
1398 print (vam->ofp, "%7d %3d %s", sw_if_index,
1399 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1400 "sw_if_index not found!");
1407 static void vl_api_bridge_domain_details_t_handler_json
1408 (vl_api_bridge_domain_details_t * mp)
1410 vat_main_t *vam = &vat_main;
1411 vat_json_node_t *node, *array = NULL;
1412 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1414 if (VAT_JSON_ARRAY != vam->json_tree.type)
1416 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1417 vat_json_init_array (&vam->json_tree);
1419 node = vat_json_array_add (&vam->json_tree);
1421 vat_json_init_object (node);
1422 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1423 vat_json_object_add_uint (node, "flood", mp->flood);
1424 vat_json_object_add_uint (node, "forward", mp->forward);
1425 vat_json_object_add_uint (node, "learn", mp->learn);
1426 vat_json_object_add_uint (node, "bvi_sw_if_index",
1427 ntohl (mp->bvi_sw_if_index));
1428 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1429 array = vat_json_object_add (node, "sw_if");
1430 vat_json_init_array (array);
1436 vl_api_bridge_domain_sw_if_t *sw_ifs;
1439 sw_ifs = mp->sw_if_details;
1440 for (i = 0; i < n_sw_ifs; i++)
1442 node = vat_json_array_add (array);
1443 vat_json_init_object (node);
1444 vat_json_object_add_uint (node, "sw_if_index",
1445 ntohl (sw_ifs->sw_if_index));
1446 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1452 static void vl_api_control_ping_reply_t_handler
1453 (vl_api_control_ping_reply_t * mp)
1455 vat_main_t *vam = &vat_main;
1456 i32 retval = ntohl (mp->retval);
1457 if (vam->async_mode)
1459 vam->async_errors += (retval < 0);
1463 vam->retval = retval;
1464 vam->result_ready = 1;
1466 vam->socket_client_main.control_pings_outstanding--;
1469 static void vl_api_control_ping_reply_t_handler_json
1470 (vl_api_control_ping_reply_t * mp)
1472 vat_main_t *vam = &vat_main;
1473 i32 retval = ntohl (mp->retval);
1475 if (VAT_JSON_NONE != vam->json_tree.type)
1477 vat_json_print (vam->ofp, &vam->json_tree);
1478 vat_json_free (&vam->json_tree);
1479 vam->json_tree.type = VAT_JSON_NONE;
1484 vat_json_init_array (&vam->json_tree);
1485 vat_json_print (vam->ofp, &vam->json_tree);
1486 vam->json_tree.type = VAT_JSON_NONE;
1489 vam->retval = retval;
1490 vam->result_ready = 1;
1494 vl_api_bridge_domain_set_mac_age_reply_t_handler
1495 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1497 vat_main_t *vam = &vat_main;
1498 i32 retval = ntohl (mp->retval);
1499 if (vam->async_mode)
1501 vam->async_errors += (retval < 0);
1505 vam->retval = retval;
1506 vam->result_ready = 1;
1510 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1511 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1513 vat_main_t *vam = &vat_main;
1514 vat_json_node_t node;
1516 vat_json_init_object (&node);
1517 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1519 vat_json_print (vam->ofp, &node);
1520 vat_json_free (&node);
1522 vam->retval = ntohl (mp->retval);
1523 vam->result_ready = 1;
1527 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1529 vat_main_t *vam = &vat_main;
1530 i32 retval = ntohl (mp->retval);
1531 if (vam->async_mode)
1533 vam->async_errors += (retval < 0);
1537 vam->retval = retval;
1538 vam->result_ready = 1;
1542 static void vl_api_l2_flags_reply_t_handler_json
1543 (vl_api_l2_flags_reply_t * mp)
1545 vat_main_t *vam = &vat_main;
1546 vat_json_node_t node;
1548 vat_json_init_object (&node);
1549 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1550 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1551 ntohl (mp->resulting_feature_bitmap));
1553 vat_json_print (vam->ofp, &node);
1554 vat_json_free (&node);
1556 vam->retval = ntohl (mp->retval);
1557 vam->result_ready = 1;
1560 static void vl_api_bridge_flags_reply_t_handler
1561 (vl_api_bridge_flags_reply_t * mp)
1563 vat_main_t *vam = &vat_main;
1564 i32 retval = ntohl (mp->retval);
1565 if (vam->async_mode)
1567 vam->async_errors += (retval < 0);
1571 vam->retval = retval;
1572 vam->result_ready = 1;
1576 static void vl_api_bridge_flags_reply_t_handler_json
1577 (vl_api_bridge_flags_reply_t * mp)
1579 vat_main_t *vam = &vat_main;
1580 vat_json_node_t node;
1582 vat_json_init_object (&node);
1583 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1584 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1585 ntohl (mp->resulting_feature_bitmap));
1587 vat_json_print (vam->ofp, &node);
1588 vat_json_free (&node);
1590 vam->retval = ntohl (mp->retval);
1591 vam->result_ready = 1;
1594 static void vl_api_tap_connect_reply_t_handler
1595 (vl_api_tap_connect_reply_t * mp)
1597 vat_main_t *vam = &vat_main;
1598 i32 retval = ntohl (mp->retval);
1599 if (vam->async_mode)
1601 vam->async_errors += (retval < 0);
1605 vam->retval = retval;
1606 vam->sw_if_index = ntohl (mp->sw_if_index);
1607 vam->result_ready = 1;
1612 static void vl_api_tap_connect_reply_t_handler_json
1613 (vl_api_tap_connect_reply_t * mp)
1615 vat_main_t *vam = &vat_main;
1616 vat_json_node_t node;
1618 vat_json_init_object (&node);
1619 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1620 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1622 vat_json_print (vam->ofp, &node);
1623 vat_json_free (&node);
1625 vam->retval = ntohl (mp->retval);
1626 vam->result_ready = 1;
1631 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1633 vat_main_t *vam = &vat_main;
1634 i32 retval = ntohl (mp->retval);
1635 if (vam->async_mode)
1637 vam->async_errors += (retval < 0);
1641 vam->retval = retval;
1642 vam->sw_if_index = ntohl (mp->sw_if_index);
1643 vam->result_ready = 1;
1647 static void vl_api_tap_modify_reply_t_handler_json
1648 (vl_api_tap_modify_reply_t * mp)
1650 vat_main_t *vam = &vat_main;
1651 vat_json_node_t node;
1653 vat_json_init_object (&node);
1654 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1655 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1657 vat_json_print (vam->ofp, &node);
1658 vat_json_free (&node);
1660 vam->retval = ntohl (mp->retval);
1661 vam->result_ready = 1;
1665 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1667 vat_main_t *vam = &vat_main;
1668 i32 retval = ntohl (mp->retval);
1669 if (vam->async_mode)
1671 vam->async_errors += (retval < 0);
1675 vam->retval = retval;
1676 vam->result_ready = 1;
1680 static void vl_api_tap_delete_reply_t_handler_json
1681 (vl_api_tap_delete_reply_t * mp)
1683 vat_main_t *vam = &vat_main;
1684 vat_json_node_t node;
1686 vat_json_init_object (&node);
1687 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1689 vat_json_print (vam->ofp, &node);
1690 vat_json_free (&node);
1692 vam->retval = ntohl (mp->retval);
1693 vam->result_ready = 1;
1696 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1697 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1699 vat_main_t *vam = &vat_main;
1700 i32 retval = ntohl (mp->retval);
1701 if (vam->async_mode)
1703 vam->async_errors += (retval < 0);
1707 vam->retval = retval;
1708 vam->result_ready = 1;
1712 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1713 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1715 vat_main_t *vam = &vat_main;
1716 vat_json_node_t node;
1718 vat_json_init_object (&node);
1719 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1720 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1721 ntohl (mp->sw_if_index));
1723 vat_json_print (vam->ofp, &node);
1724 vat_json_free (&node);
1726 vam->retval = ntohl (mp->retval);
1727 vam->result_ready = 1;
1730 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1731 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1733 vat_main_t *vam = &vat_main;
1734 i32 retval = ntohl (mp->retval);
1735 if (vam->async_mode)
1737 vam->async_errors += (retval < 0);
1741 vam->retval = retval;
1742 vam->sw_if_index = ntohl (mp->sw_if_index);
1743 vam->result_ready = 1;
1747 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1748 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1750 vat_main_t *vam = &vat_main;
1751 vat_json_node_t node;
1753 vat_json_init_object (&node);
1754 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1755 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1757 vat_json_print (vam->ofp, &node);
1758 vat_json_free (&node);
1760 vam->retval = ntohl (mp->retval);
1761 vam->result_ready = 1;
1764 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
1765 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1767 vat_main_t *vam = &vat_main;
1768 i32 retval = ntohl (mp->retval);
1769 if (vam->async_mode)
1771 vam->async_errors += (retval < 0);
1775 vam->retval = retval;
1776 vam->result_ready = 1;
1780 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
1781 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1783 vat_main_t *vam = &vat_main;
1784 vat_json_node_t node;
1786 vat_json_init_object (&node);
1787 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1788 vat_json_object_add_uint (&node, "fwd_entry_index",
1789 clib_net_to_host_u32 (mp->fwd_entry_index));
1791 vat_json_print (vam->ofp, &node);
1792 vat_json_free (&node);
1794 vam->retval = ntohl (mp->retval);
1795 vam->result_ready = 1;
1799 format_lisp_transport_protocol (u8 * s, va_list * args)
1801 u32 proto = va_arg (*args, u32);
1806 return format (s, "udp");
1808 return format (s, "api");
1815 static void vl_api_one_get_transport_protocol_reply_t_handler
1816 (vl_api_one_get_transport_protocol_reply_t * mp)
1818 vat_main_t *vam = &vat_main;
1819 i32 retval = ntohl (mp->retval);
1820 if (vam->async_mode)
1822 vam->async_errors += (retval < 0);
1826 u32 proto = mp->protocol;
1827 print (vam->ofp, "Transport protocol: %U",
1828 format_lisp_transport_protocol, proto);
1829 vam->retval = retval;
1830 vam->result_ready = 1;
1834 static void vl_api_one_get_transport_protocol_reply_t_handler_json
1835 (vl_api_one_get_transport_protocol_reply_t * mp)
1837 vat_main_t *vam = &vat_main;
1838 vat_json_node_t node;
1841 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
1844 vat_json_init_object (&node);
1845 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1846 vat_json_object_add_string_copy (&node, "transport-protocol", s);
1849 vat_json_print (vam->ofp, &node);
1850 vat_json_free (&node);
1852 vam->retval = ntohl (mp->retval);
1853 vam->result_ready = 1;
1856 static void vl_api_one_add_del_locator_set_reply_t_handler
1857 (vl_api_one_add_del_locator_set_reply_t * mp)
1859 vat_main_t *vam = &vat_main;
1860 i32 retval = ntohl (mp->retval);
1861 if (vam->async_mode)
1863 vam->async_errors += (retval < 0);
1867 vam->retval = retval;
1868 vam->result_ready = 1;
1872 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1873 (vl_api_one_add_del_locator_set_reply_t * mp)
1875 vat_main_t *vam = &vat_main;
1876 vat_json_node_t node;
1878 vat_json_init_object (&node);
1879 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1880 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1882 vat_json_print (vam->ofp, &node);
1883 vat_json_free (&node);
1885 vam->retval = ntohl (mp->retval);
1886 vam->result_ready = 1;
1889 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1890 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1892 vat_main_t *vam = &vat_main;
1893 i32 retval = ntohl (mp->retval);
1894 if (vam->async_mode)
1896 vam->async_errors += (retval < 0);
1900 vam->retval = retval;
1901 vam->sw_if_index = ntohl (mp->sw_if_index);
1902 vam->result_ready = 1;
1906 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1907 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1909 vat_main_t *vam = &vat_main;
1910 vat_json_node_t node;
1912 vat_json_init_object (&node);
1913 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1914 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1916 vat_json_print (vam->ofp, &node);
1917 vat_json_free (&node);
1919 vam->retval = ntohl (mp->retval);
1920 vam->result_ready = 1;
1923 static void vl_api_geneve_add_del_tunnel_reply_t_handler
1924 (vl_api_geneve_add_del_tunnel_reply_t * mp)
1926 vat_main_t *vam = &vat_main;
1927 i32 retval = ntohl (mp->retval);
1928 if (vam->async_mode)
1930 vam->async_errors += (retval < 0);
1934 vam->retval = retval;
1935 vam->sw_if_index = ntohl (mp->sw_if_index);
1936 vam->result_ready = 1;
1940 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
1941 (vl_api_geneve_add_del_tunnel_reply_t * mp)
1943 vat_main_t *vam = &vat_main;
1944 vat_json_node_t node;
1946 vat_json_init_object (&node);
1947 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1948 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1950 vat_json_print (vam->ofp, &node);
1951 vat_json_free (&node);
1953 vam->retval = ntohl (mp->retval);
1954 vam->result_ready = 1;
1957 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
1958 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1960 vat_main_t *vam = &vat_main;
1961 i32 retval = ntohl (mp->retval);
1962 if (vam->async_mode)
1964 vam->async_errors += (retval < 0);
1968 vam->retval = retval;
1969 vam->sw_if_index = ntohl (mp->sw_if_index);
1970 vam->result_ready = 1;
1974 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
1975 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1977 vat_main_t *vam = &vat_main;
1978 vat_json_node_t node;
1980 vat_json_init_object (&node);
1981 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1982 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1984 vat_json_print (vam->ofp, &node);
1985 vat_json_free (&node);
1987 vam->retval = ntohl (mp->retval);
1988 vam->result_ready = 1;
1991 static void vl_api_gre_add_del_tunnel_reply_t_handler
1992 (vl_api_gre_add_del_tunnel_reply_t * mp)
1994 vat_main_t *vam = &vat_main;
1995 i32 retval = ntohl (mp->retval);
1996 if (vam->async_mode)
1998 vam->async_errors += (retval < 0);
2002 vam->retval = retval;
2003 vam->sw_if_index = ntohl (mp->sw_if_index);
2004 vam->result_ready = 1;
2008 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2009 (vl_api_gre_add_del_tunnel_reply_t * mp)
2011 vat_main_t *vam = &vat_main;
2012 vat_json_node_t node;
2014 vat_json_init_object (&node);
2015 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2016 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2018 vat_json_print (vam->ofp, &node);
2019 vat_json_free (&node);
2021 vam->retval = ntohl (mp->retval);
2022 vam->result_ready = 1;
2025 static void vl_api_create_vhost_user_if_reply_t_handler
2026 (vl_api_create_vhost_user_if_reply_t * mp)
2028 vat_main_t *vam = &vat_main;
2029 i32 retval = ntohl (mp->retval);
2030 if (vam->async_mode)
2032 vam->async_errors += (retval < 0);
2036 vam->retval = retval;
2037 vam->sw_if_index = ntohl (mp->sw_if_index);
2038 vam->result_ready = 1;
2042 static void vl_api_create_vhost_user_if_reply_t_handler_json
2043 (vl_api_create_vhost_user_if_reply_t * mp)
2045 vat_main_t *vam = &vat_main;
2046 vat_json_node_t node;
2048 vat_json_init_object (&node);
2049 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2050 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2052 vat_json_print (vam->ofp, &node);
2053 vat_json_free (&node);
2055 vam->retval = ntohl (mp->retval);
2056 vam->result_ready = 1;
2059 static clib_error_t *
2060 receive_fd_msg (int socket_fd, int *my_fd)
2063 char ctl[CMSG_SPACE (sizeof (int)) + CMSG_SPACE (sizeof (struct ucred))];
2064 struct msghdr mh = { 0 };
2065 struct iovec iov[1];
2067 struct ucred *cr = 0;
2068 struct cmsghdr *cmsg;
2069 pid_t pid __attribute__ ((unused));
2070 uid_t uid __attribute__ ((unused));
2071 gid_t gid __attribute__ ((unused));
2073 iov[0].iov_base = msgbuf;
2077 mh.msg_control = ctl;
2078 mh.msg_controllen = sizeof (ctl);
2080 memset (ctl, 0, sizeof (ctl));
2082 /* receive the incoming message */
2083 size = recvmsg (socket_fd, &mh, 0);
2086 return (size == 0) ? clib_error_return (0, "disconnected") :
2087 clib_error_return_unix (0, "recvmsg: malformed message (fd %d)",
2091 cmsg = CMSG_FIRSTHDR (&mh);
2094 if (cmsg->cmsg_level == SOL_SOCKET)
2096 if (cmsg->cmsg_type == SCM_CREDENTIALS)
2098 cr = (struct ucred *) CMSG_DATA (cmsg);
2103 else if (cmsg->cmsg_type == SCM_RIGHTS)
2105 clib_memcpy (my_fd, CMSG_DATA (cmsg), sizeof (int));
2108 cmsg = CMSG_NXTHDR (&mh, cmsg);
2113 static void vl_api_memfd_segment_create_reply_t_handler
2114 (vl_api_memfd_segment_create_reply_t * mp)
2116 /* Dont bother in the builtin version */
2117 #if VPP_API_TEST_BUILTIN == 0
2118 vat_main_t *vam = &vat_main;
2119 api_main_t *am = &api_main;
2120 socket_client_main_t *scm = &vam->socket_client_main;
2122 clib_error_t *error;
2123 memfd_private_t memfd;
2124 i32 retval = ntohl (mp->retval);
2128 error = receive_fd_msg (scm->socket_fd, &my_fd);
2135 memset (&memfd, 0, sizeof (memfd));
2138 vam->client_index_invalid = 1;
2140 /* 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_show_one_use_petr_reply_t_handler
4243 (vl_api_show_one_use_petr_reply_t * mp)
4245 vat_main_t *vam = &vat_main;
4246 i32 retval = ntohl (mp->retval);
4250 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4253 print (vam->ofp, "Proxy-ETR address; %U",
4254 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4259 vam->retval = retval;
4260 vam->result_ready = 1;
4264 vl_api_show_one_use_petr_reply_t_handler_json
4265 (vl_api_show_one_use_petr_reply_t * mp)
4267 vat_main_t *vam = &vat_main;
4268 vat_json_node_t node;
4271 struct in6_addr ip6;
4273 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4274 vec_add1 (status, 0);
4276 vat_json_init_object (&node);
4277 vat_json_object_add_string_copy (&node, "status", status);
4282 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4283 vat_json_object_add_ip6 (&node, "address", ip6);
4287 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4288 vat_json_object_add_ip4 (&node, "address", ip4);
4294 vat_json_print (vam->ofp, &node);
4295 vat_json_free (&node);
4297 vam->retval = ntohl (mp->retval);
4298 vam->result_ready = 1;
4302 vl_api_show_one_nsh_mapping_reply_t_handler
4303 (vl_api_show_one_nsh_mapping_reply_t * mp)
4305 vat_main_t *vam = &vat_main;
4306 i32 retval = ntohl (mp->retval);
4310 print (vam->ofp, "%-20s%-16s",
4311 mp->is_set ? "set" : "not-set",
4312 mp->is_set ? (char *) mp->locator_set_name : "");
4315 vam->retval = retval;
4316 vam->result_ready = 1;
4320 vl_api_show_one_nsh_mapping_reply_t_handler_json
4321 (vl_api_show_one_nsh_mapping_reply_t * mp)
4323 vat_main_t *vam = &vat_main;
4324 vat_json_node_t node;
4327 status = format (0, "%s", mp->is_set ? "yes" : "no");
4328 vec_add1 (status, 0);
4330 vat_json_init_object (&node);
4331 vat_json_object_add_string_copy (&node, "is_set", status);
4334 vat_json_object_add_string_copy (&node, "locator_set",
4335 mp->locator_set_name);
4340 vat_json_print (vam->ofp, &node);
4341 vat_json_free (&node);
4343 vam->retval = ntohl (mp->retval);
4344 vam->result_ready = 1;
4348 vl_api_show_one_map_register_ttl_reply_t_handler
4349 (vl_api_show_one_map_register_ttl_reply_t * mp)
4351 vat_main_t *vam = &vat_main;
4352 i32 retval = ntohl (mp->retval);
4354 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4358 print (vam->ofp, "ttl: %u", mp->ttl);
4361 vam->retval = retval;
4362 vam->result_ready = 1;
4366 vl_api_show_one_map_register_ttl_reply_t_handler_json
4367 (vl_api_show_one_map_register_ttl_reply_t * mp)
4369 vat_main_t *vam = &vat_main;
4370 vat_json_node_t node;
4372 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4373 vat_json_init_object (&node);
4374 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4376 vat_json_print (vam->ofp, &node);
4377 vat_json_free (&node);
4379 vam->retval = ntohl (mp->retval);
4380 vam->result_ready = 1;
4384 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4386 vat_main_t *vam = &vat_main;
4387 i32 retval = ntohl (mp->retval);
4391 print (vam->ofp, "%-20s%-16s",
4392 mp->status ? "enabled" : "disabled",
4393 mp->status ? (char *) mp->locator_set_name : "");
4396 vam->retval = retval;
4397 vam->result_ready = 1;
4401 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4403 vat_main_t *vam = &vat_main;
4404 vat_json_node_t node;
4407 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4408 vec_add1 (status, 0);
4410 vat_json_init_object (&node);
4411 vat_json_object_add_string_copy (&node, "status", status);
4414 vat_json_object_add_string_copy (&node, "locator_set",
4415 mp->locator_set_name);
4420 vat_json_print (vam->ofp, &node);
4421 vat_json_free (&node);
4423 vam->retval = ntohl (mp->retval);
4424 vam->result_ready = 1;
4428 format_policer_type (u8 * s, va_list * va)
4430 u32 i = va_arg (*va, u32);
4432 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4433 s = format (s, "1r2c");
4434 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4435 s = format (s, "1r3c");
4436 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4437 s = format (s, "2r3c-2698");
4438 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4439 s = format (s, "2r3c-4115");
4440 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4441 s = format (s, "2r3c-mef5cf1");
4443 s = format (s, "ILLEGAL");
4448 format_policer_rate_type (u8 * s, va_list * va)
4450 u32 i = va_arg (*va, u32);
4452 if (i == SSE2_QOS_RATE_KBPS)
4453 s = format (s, "kbps");
4454 else if (i == SSE2_QOS_RATE_PPS)
4455 s = format (s, "pps");
4457 s = format (s, "ILLEGAL");
4462 format_policer_round_type (u8 * s, va_list * va)
4464 u32 i = va_arg (*va, u32);
4466 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4467 s = format (s, "closest");
4468 else if (i == SSE2_QOS_ROUND_TO_UP)
4469 s = format (s, "up");
4470 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4471 s = format (s, "down");
4473 s = format (s, "ILLEGAL");
4478 format_policer_action_type (u8 * s, va_list * va)
4480 u32 i = va_arg (*va, u32);
4482 if (i == SSE2_QOS_ACTION_DROP)
4483 s = format (s, "drop");
4484 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4485 s = format (s, "transmit");
4486 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4487 s = format (s, "mark-and-transmit");
4489 s = format (s, "ILLEGAL");
4494 format_dscp (u8 * s, va_list * va)
4496 u32 i = va_arg (*va, u32);
4501 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4505 return format (s, "ILLEGAL");
4507 s = format (s, "%s", t);
4512 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4514 vat_main_t *vam = &vat_main;
4515 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4517 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4518 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4520 conform_dscp_str = format (0, "");
4522 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4523 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4525 exceed_dscp_str = format (0, "");
4527 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4528 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4530 violate_dscp_str = format (0, "");
4532 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4533 "rate type %U, round type %U, %s rate, %s color-aware, "
4534 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4535 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4536 "conform action %U%s, exceed action %U%s, violate action %U%s",
4538 format_policer_type, mp->type,
4541 clib_net_to_host_u64 (mp->cb),
4542 clib_net_to_host_u64 (mp->eb),
4543 format_policer_rate_type, mp->rate_type,
4544 format_policer_round_type, mp->round_type,
4545 mp->single_rate ? "single" : "dual",
4546 mp->color_aware ? "is" : "not",
4547 ntohl (mp->cir_tokens_per_period),
4548 ntohl (mp->pir_tokens_per_period),
4550 ntohl (mp->current_limit),
4551 ntohl (mp->current_bucket),
4552 ntohl (mp->extended_limit),
4553 ntohl (mp->extended_bucket),
4554 clib_net_to_host_u64 (mp->last_update_time),
4555 format_policer_action_type, mp->conform_action_type,
4557 format_policer_action_type, mp->exceed_action_type,
4559 format_policer_action_type, mp->violate_action_type,
4562 vec_free (conform_dscp_str);
4563 vec_free (exceed_dscp_str);
4564 vec_free (violate_dscp_str);
4567 static void vl_api_policer_details_t_handler_json
4568 (vl_api_policer_details_t * mp)
4570 vat_main_t *vam = &vat_main;
4571 vat_json_node_t *node;
4572 u8 *rate_type_str, *round_type_str, *type_str;
4573 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4575 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4577 format (0, "%U", format_policer_round_type, mp->round_type);
4578 type_str = format (0, "%U", format_policer_type, mp->type);
4579 conform_action_str = format (0, "%U", format_policer_action_type,
4580 mp->conform_action_type);
4581 exceed_action_str = format (0, "%U", format_policer_action_type,
4582 mp->exceed_action_type);
4583 violate_action_str = format (0, "%U", format_policer_action_type,
4584 mp->violate_action_type);
4586 if (VAT_JSON_ARRAY != vam->json_tree.type)
4588 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4589 vat_json_init_array (&vam->json_tree);
4591 node = vat_json_array_add (&vam->json_tree);
4593 vat_json_init_object (node);
4594 vat_json_object_add_string_copy (node, "name", mp->name);
4595 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4596 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4597 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4598 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4599 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4600 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4601 vat_json_object_add_string_copy (node, "type", type_str);
4602 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4603 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4604 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4605 vat_json_object_add_uint (node, "cir_tokens_per_period",
4606 ntohl (mp->cir_tokens_per_period));
4607 vat_json_object_add_uint (node, "eir_tokens_per_period",
4608 ntohl (mp->pir_tokens_per_period));
4609 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4610 vat_json_object_add_uint (node, "current_bucket",
4611 ntohl (mp->current_bucket));
4612 vat_json_object_add_uint (node, "extended_limit",
4613 ntohl (mp->extended_limit));
4614 vat_json_object_add_uint (node, "extended_bucket",
4615 ntohl (mp->extended_bucket));
4616 vat_json_object_add_uint (node, "last_update_time",
4617 ntohl (mp->last_update_time));
4618 vat_json_object_add_string_copy (node, "conform_action",
4619 conform_action_str);
4620 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4622 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4623 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4624 vec_free (dscp_str);
4626 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4627 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4629 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4630 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4631 vec_free (dscp_str);
4633 vat_json_object_add_string_copy (node, "violate_action",
4634 violate_action_str);
4635 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4637 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4638 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4639 vec_free (dscp_str);
4642 vec_free (rate_type_str);
4643 vec_free (round_type_str);
4644 vec_free (type_str);
4645 vec_free (conform_action_str);
4646 vec_free (exceed_action_str);
4647 vec_free (violate_action_str);
4651 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4654 vat_main_t *vam = &vat_main;
4655 int i, count = ntohl (mp->count);
4658 print (vam->ofp, "classify table ids (%d) : ", count);
4659 for (i = 0; i < count; i++)
4661 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4662 print (vam->ofp, (i < count - 1) ? "," : "");
4664 vam->retval = ntohl (mp->retval);
4665 vam->result_ready = 1;
4669 vl_api_classify_table_ids_reply_t_handler_json
4670 (vl_api_classify_table_ids_reply_t * mp)
4672 vat_main_t *vam = &vat_main;
4673 int i, count = ntohl (mp->count);
4677 vat_json_node_t node;
4679 vat_json_init_object (&node);
4680 for (i = 0; i < count; i++)
4682 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4684 vat_json_print (vam->ofp, &node);
4685 vat_json_free (&node);
4687 vam->retval = ntohl (mp->retval);
4688 vam->result_ready = 1;
4692 vl_api_classify_table_by_interface_reply_t_handler
4693 (vl_api_classify_table_by_interface_reply_t * mp)
4695 vat_main_t *vam = &vat_main;
4698 table_id = ntohl (mp->l2_table_id);
4700 print (vam->ofp, "l2 table id : %d", table_id);
4702 print (vam->ofp, "l2 table id : No input ACL tables configured");
4703 table_id = ntohl (mp->ip4_table_id);
4705 print (vam->ofp, "ip4 table id : %d", table_id);
4707 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4708 table_id = ntohl (mp->ip6_table_id);
4710 print (vam->ofp, "ip6 table id : %d", table_id);
4712 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4713 vam->retval = ntohl (mp->retval);
4714 vam->result_ready = 1;
4718 vl_api_classify_table_by_interface_reply_t_handler_json
4719 (vl_api_classify_table_by_interface_reply_t * mp)
4721 vat_main_t *vam = &vat_main;
4722 vat_json_node_t node;
4724 vat_json_init_object (&node);
4726 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4727 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4728 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4730 vat_json_print (vam->ofp, &node);
4731 vat_json_free (&node);
4733 vam->retval = ntohl (mp->retval);
4734 vam->result_ready = 1;
4737 static void vl_api_policer_add_del_reply_t_handler
4738 (vl_api_policer_add_del_reply_t * mp)
4740 vat_main_t *vam = &vat_main;
4741 i32 retval = ntohl (mp->retval);
4742 if (vam->async_mode)
4744 vam->async_errors += (retval < 0);
4748 vam->retval = retval;
4749 vam->result_ready = 1;
4750 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4752 * Note: this is just barely thread-safe, depends on
4753 * the main thread spinning waiting for an answer...
4755 errmsg ("policer index %d", ntohl (mp->policer_index));
4759 static void vl_api_policer_add_del_reply_t_handler_json
4760 (vl_api_policer_add_del_reply_t * mp)
4762 vat_main_t *vam = &vat_main;
4763 vat_json_node_t node;
4765 vat_json_init_object (&node);
4766 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4767 vat_json_object_add_uint (&node, "policer_index",
4768 ntohl (mp->policer_index));
4770 vat_json_print (vam->ofp, &node);
4771 vat_json_free (&node);
4773 vam->retval = ntohl (mp->retval);
4774 vam->result_ready = 1;
4777 /* Format hex dump. */
4779 format_hex_bytes (u8 * s, va_list * va)
4781 u8 *bytes = va_arg (*va, u8 *);
4782 int n_bytes = va_arg (*va, int);
4785 /* Print short or long form depending on byte count. */
4786 uword short_form = n_bytes <= 32;
4787 u32 indent = format_get_indent (s);
4792 for (i = 0; i < n_bytes; i++)
4794 if (!short_form && (i % 32) == 0)
4795 s = format (s, "%08x: ", i);
4796 s = format (s, "%02x", bytes[i]);
4797 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4798 s = format (s, "\n%U", format_white_space, indent);
4805 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4808 vat_main_t *vam = &vat_main;
4809 i32 retval = ntohl (mp->retval);
4812 print (vam->ofp, "classify table info :");
4813 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4814 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4815 ntohl (mp->miss_next_index));
4816 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4817 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4818 ntohl (mp->match_n_vectors));
4819 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4820 ntohl (mp->mask_length));
4822 vam->retval = retval;
4823 vam->result_ready = 1;
4827 vl_api_classify_table_info_reply_t_handler_json
4828 (vl_api_classify_table_info_reply_t * mp)
4830 vat_main_t *vam = &vat_main;
4831 vat_json_node_t node;
4833 i32 retval = ntohl (mp->retval);
4836 vat_json_init_object (&node);
4838 vat_json_object_add_int (&node, "sessions",
4839 ntohl (mp->active_sessions));
4840 vat_json_object_add_int (&node, "nexttbl",
4841 ntohl (mp->next_table_index));
4842 vat_json_object_add_int (&node, "nextnode",
4843 ntohl (mp->miss_next_index));
4844 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4845 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4846 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4847 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4848 ntohl (mp->mask_length), 0);
4849 vat_json_object_add_string_copy (&node, "mask", s);
4851 vat_json_print (vam->ofp, &node);
4852 vat_json_free (&node);
4854 vam->retval = ntohl (mp->retval);
4855 vam->result_ready = 1;
4859 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4862 vat_main_t *vam = &vat_main;
4864 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4865 ntohl (mp->hit_next_index), ntohl (mp->advance),
4866 ntohl (mp->opaque_index));
4867 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4868 ntohl (mp->match_length));
4872 vl_api_classify_session_details_t_handler_json
4873 (vl_api_classify_session_details_t * mp)
4875 vat_main_t *vam = &vat_main;
4876 vat_json_node_t *node = NULL;
4878 if (VAT_JSON_ARRAY != vam->json_tree.type)
4880 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4881 vat_json_init_array (&vam->json_tree);
4883 node = vat_json_array_add (&vam->json_tree);
4885 vat_json_init_object (node);
4886 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4887 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4888 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4890 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4892 vat_json_object_add_string_copy (node, "match", s);
4895 static void vl_api_pg_create_interface_reply_t_handler
4896 (vl_api_pg_create_interface_reply_t * mp)
4898 vat_main_t *vam = &vat_main;
4900 vam->retval = ntohl (mp->retval);
4901 vam->result_ready = 1;
4904 static void vl_api_pg_create_interface_reply_t_handler_json
4905 (vl_api_pg_create_interface_reply_t * mp)
4907 vat_main_t *vam = &vat_main;
4908 vat_json_node_t node;
4910 i32 retval = ntohl (mp->retval);
4913 vat_json_init_object (&node);
4915 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4917 vat_json_print (vam->ofp, &node);
4918 vat_json_free (&node);
4920 vam->retval = ntohl (mp->retval);
4921 vam->result_ready = 1;
4924 static void vl_api_policer_classify_details_t_handler
4925 (vl_api_policer_classify_details_t * mp)
4927 vat_main_t *vam = &vat_main;
4929 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4930 ntohl (mp->table_index));
4933 static void vl_api_policer_classify_details_t_handler_json
4934 (vl_api_policer_classify_details_t * mp)
4936 vat_main_t *vam = &vat_main;
4937 vat_json_node_t *node;
4939 if (VAT_JSON_ARRAY != vam->json_tree.type)
4941 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4942 vat_json_init_array (&vam->json_tree);
4944 node = vat_json_array_add (&vam->json_tree);
4946 vat_json_init_object (node);
4947 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4948 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4951 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4952 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4954 vat_main_t *vam = &vat_main;
4955 i32 retval = ntohl (mp->retval);
4956 if (vam->async_mode)
4958 vam->async_errors += (retval < 0);
4962 vam->retval = retval;
4963 vam->sw_if_index = ntohl (mp->sw_if_index);
4964 vam->result_ready = 1;
4968 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4969 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4971 vat_main_t *vam = &vat_main;
4972 vat_json_node_t node;
4974 vat_json_init_object (&node);
4975 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4976 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4978 vat_json_print (vam->ofp, &node);
4979 vat_json_free (&node);
4981 vam->retval = ntohl (mp->retval);
4982 vam->result_ready = 1;
4985 static void vl_api_flow_classify_details_t_handler
4986 (vl_api_flow_classify_details_t * mp)
4988 vat_main_t *vam = &vat_main;
4990 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4991 ntohl (mp->table_index));
4994 static void vl_api_flow_classify_details_t_handler_json
4995 (vl_api_flow_classify_details_t * mp)
4997 vat_main_t *vam = &vat_main;
4998 vat_json_node_t *node;
5000 if (VAT_JSON_ARRAY != vam->json_tree.type)
5002 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5003 vat_json_init_array (&vam->json_tree);
5005 node = vat_json_array_add (&vam->json_tree);
5007 vat_json_init_object (node);
5008 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5009 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5012 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5013 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5014 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5015 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5016 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5017 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5018 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5019 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5020 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5021 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5022 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5023 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5024 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5025 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5026 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5027 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5028 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5029 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5030 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5031 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5032 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5033 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5036 * Generate boilerplate reply handlers, which
5037 * dig the return value out of the xxx_reply_t API message,
5038 * stick it into vam->retval, and set vam->result_ready
5040 * Could also do this by pointing N message decode slots at
5041 * a single function, but that could break in subtle ways.
5044 #define foreach_standard_reply_retval_handler \
5045 _(sw_interface_set_flags_reply) \
5046 _(sw_interface_add_del_address_reply) \
5047 _(sw_interface_set_table_reply) \
5048 _(sw_interface_set_mpls_enable_reply) \
5049 _(sw_interface_set_vpath_reply) \
5050 _(sw_interface_set_vxlan_bypass_reply) \
5051 _(sw_interface_set_geneve_bypass_reply) \
5052 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5053 _(sw_interface_set_l2_bridge_reply) \
5054 _(bridge_domain_add_del_reply) \
5055 _(sw_interface_set_l2_xconnect_reply) \
5056 _(l2fib_add_del_reply) \
5057 _(l2fib_flush_int_reply) \
5058 _(l2fib_flush_bd_reply) \
5059 _(ip_add_del_route_reply) \
5060 _(ip_table_add_del_reply) \
5061 _(ip_mroute_add_del_reply) \
5062 _(mpls_route_add_del_reply) \
5063 _(mpls_table_add_del_reply) \
5064 _(mpls_ip_bind_unbind_reply) \
5065 _(proxy_arp_add_del_reply) \
5066 _(proxy_arp_intfc_enable_disable_reply) \
5067 _(sw_interface_set_unnumbered_reply) \
5068 _(ip_neighbor_add_del_reply) \
5069 _(reset_vrf_reply) \
5070 _(oam_add_del_reply) \
5071 _(reset_fib_reply) \
5072 _(dhcp_proxy_config_reply) \
5073 _(dhcp_proxy_set_vss_reply) \
5074 _(dhcp_client_config_reply) \
5075 _(set_ip_flow_hash_reply) \
5076 _(sw_interface_ip6_enable_disable_reply) \
5077 _(sw_interface_ip6_set_link_local_address_reply) \
5078 _(ip6nd_proxy_add_del_reply) \
5079 _(sw_interface_ip6nd_ra_prefix_reply) \
5080 _(sw_interface_ip6nd_ra_config_reply) \
5081 _(set_arp_neighbor_limit_reply) \
5082 _(l2_patch_add_del_reply) \
5083 _(sr_policy_add_reply) \
5084 _(sr_policy_mod_reply) \
5085 _(sr_policy_del_reply) \
5086 _(sr_localsid_add_del_reply) \
5087 _(sr_steering_add_del_reply) \
5088 _(classify_add_del_session_reply) \
5089 _(classify_set_interface_ip_table_reply) \
5090 _(classify_set_interface_l2_tables_reply) \
5091 _(l2tpv3_set_tunnel_cookies_reply) \
5092 _(l2tpv3_interface_enable_disable_reply) \
5093 _(l2tpv3_set_lookup_key_reply) \
5094 _(l2_fib_clear_table_reply) \
5095 _(l2_interface_efp_filter_reply) \
5096 _(l2_interface_vlan_tag_rewrite_reply) \
5097 _(modify_vhost_user_if_reply) \
5098 _(delete_vhost_user_if_reply) \
5099 _(want_ip4_arp_events_reply) \
5100 _(want_ip6_nd_events_reply) \
5101 _(want_l2_macs_events_reply) \
5102 _(input_acl_set_interface_reply) \
5103 _(ipsec_spd_add_del_reply) \
5104 _(ipsec_interface_add_del_spd_reply) \
5105 _(ipsec_spd_add_del_entry_reply) \
5106 _(ipsec_sad_add_del_entry_reply) \
5107 _(ipsec_sa_set_key_reply) \
5108 _(ipsec_tunnel_if_add_del_reply) \
5109 _(ipsec_tunnel_if_set_key_reply) \
5110 _(ipsec_tunnel_if_set_sa_reply) \
5111 _(ikev2_profile_add_del_reply) \
5112 _(ikev2_profile_set_auth_reply) \
5113 _(ikev2_profile_set_id_reply) \
5114 _(ikev2_profile_set_ts_reply) \
5115 _(ikev2_set_local_key_reply) \
5116 _(ikev2_set_responder_reply) \
5117 _(ikev2_set_ike_transforms_reply) \
5118 _(ikev2_set_esp_transforms_reply) \
5119 _(ikev2_set_sa_lifetime_reply) \
5120 _(ikev2_initiate_sa_init_reply) \
5121 _(ikev2_initiate_del_ike_sa_reply) \
5122 _(ikev2_initiate_del_child_sa_reply) \
5123 _(ikev2_initiate_rekey_child_sa_reply) \
5124 _(delete_loopback_reply) \
5125 _(bd_ip_mac_add_del_reply) \
5126 _(map_del_domain_reply) \
5127 _(map_add_del_rule_reply) \
5128 _(want_interface_events_reply) \
5129 _(want_stats_reply) \
5130 _(cop_interface_enable_disable_reply) \
5131 _(cop_whitelist_enable_disable_reply) \
5132 _(sw_interface_clear_stats_reply) \
5133 _(ioam_enable_reply) \
5134 _(ioam_disable_reply) \
5135 _(one_add_del_locator_reply) \
5136 _(one_add_del_local_eid_reply) \
5137 _(one_add_del_remote_mapping_reply) \
5138 _(one_add_del_adjacency_reply) \
5139 _(one_add_del_map_resolver_reply) \
5140 _(one_add_del_map_server_reply) \
5141 _(one_enable_disable_reply) \
5142 _(one_rloc_probe_enable_disable_reply) \
5143 _(one_map_register_enable_disable_reply) \
5144 _(one_map_register_set_ttl_reply) \
5145 _(one_set_transport_protocol_reply) \
5146 _(one_map_register_fallback_threshold_reply) \
5147 _(one_pitr_set_locator_set_reply) \
5148 _(one_map_request_mode_reply) \
5149 _(one_add_del_map_request_itr_rlocs_reply) \
5150 _(one_eid_table_add_del_map_reply) \
5151 _(one_use_petr_reply) \
5152 _(one_stats_enable_disable_reply) \
5153 _(one_add_del_l2_arp_entry_reply) \
5154 _(one_add_del_ndp_entry_reply) \
5155 _(one_stats_flush_reply) \
5156 _(gpe_enable_disable_reply) \
5157 _(gpe_set_encap_mode_reply) \
5158 _(gpe_add_del_iface_reply) \
5159 _(gpe_add_del_native_fwd_rpath_reply) \
5160 _(af_packet_delete_reply) \
5161 _(policer_classify_set_interface_reply) \
5162 _(netmap_create_reply) \
5163 _(netmap_delete_reply) \
5164 _(set_ipfix_exporter_reply) \
5165 _(set_ipfix_classify_stream_reply) \
5166 _(ipfix_classify_table_add_del_reply) \
5167 _(flow_classify_set_interface_reply) \
5168 _(sw_interface_span_enable_disable_reply) \
5169 _(pg_capture_reply) \
5170 _(pg_enable_disable_reply) \
5171 _(ip_source_and_port_range_check_add_del_reply) \
5172 _(ip_source_and_port_range_check_interface_add_del_reply)\
5173 _(delete_subif_reply) \
5174 _(l2_interface_pbb_tag_rewrite_reply) \
5176 _(feature_enable_disable_reply) \
5177 _(sw_interface_tag_add_del_reply) \
5178 _(sw_interface_set_mtu_reply) \
5179 _(p2p_ethernet_add_reply) \
5180 _(p2p_ethernet_del_reply) \
5181 _(lldp_config_reply) \
5182 _(sw_interface_set_lldp_reply) \
5183 _(tcp_configure_src_addresses_reply) \
5184 _(app_namespace_add_del_reply) \
5185 _(dns_enable_disable_reply) \
5186 _(dns_name_server_add_del_reply)
5189 static void vl_api_##n##_t_handler \
5190 (vl_api_##n##_t * mp) \
5192 vat_main_t * vam = &vat_main; \
5193 i32 retval = ntohl(mp->retval); \
5194 if (vam->async_mode) { \
5195 vam->async_errors += (retval < 0); \
5197 vam->retval = retval; \
5198 vam->result_ready = 1; \
5201 foreach_standard_reply_retval_handler;
5205 static void vl_api_##n##_t_handler_json \
5206 (vl_api_##n##_t * mp) \
5208 vat_main_t * vam = &vat_main; \
5209 vat_json_node_t node; \
5210 vat_json_init_object(&node); \
5211 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5212 vat_json_print(vam->ofp, &node); \
5213 vam->retval = ntohl(mp->retval); \
5214 vam->result_ready = 1; \
5216 foreach_standard_reply_retval_handler;
5220 * Table of message reply handlers, must include boilerplate handlers
5224 #define foreach_vpe_api_reply_msg \
5225 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5226 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5227 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5228 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5229 _(CONTROL_PING_REPLY, control_ping_reply) \
5230 _(CLI_REPLY, cli_reply) \
5231 _(CLI_INBAND_REPLY, cli_inband_reply) \
5232 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5233 sw_interface_add_del_address_reply) \
5234 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5235 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5236 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5237 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5238 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5239 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5240 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5241 sw_interface_set_l2_xconnect_reply) \
5242 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5243 sw_interface_set_l2_bridge_reply) \
5244 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5245 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5246 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5247 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5248 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5249 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5250 _(L2_FLAGS_REPLY, l2_flags_reply) \
5251 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5252 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5253 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5254 _(TAP_DELETE_REPLY, tap_delete_reply) \
5255 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5256 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5257 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5258 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5259 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5260 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5261 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5262 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5263 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5264 proxy_arp_intfc_enable_disable_reply) \
5265 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5266 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5267 sw_interface_set_unnumbered_reply) \
5268 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5269 _(RESET_VRF_REPLY, reset_vrf_reply) \
5270 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5271 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5272 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5273 _(RESET_FIB_REPLY, reset_fib_reply) \
5274 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5275 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5276 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5277 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5278 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5279 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5280 sw_interface_ip6_enable_disable_reply) \
5281 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5282 sw_interface_ip6_set_link_local_address_reply) \
5283 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5284 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5285 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5286 sw_interface_ip6nd_ra_prefix_reply) \
5287 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5288 sw_interface_ip6nd_ra_config_reply) \
5289 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5290 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5291 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5292 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5293 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5294 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5295 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5296 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5297 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5298 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5299 classify_set_interface_ip_table_reply) \
5300 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5301 classify_set_interface_l2_tables_reply) \
5302 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5303 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5304 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5305 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5306 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5307 l2tpv3_interface_enable_disable_reply) \
5308 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5309 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5310 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5311 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5312 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5313 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5314 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5315 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5316 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5317 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5318 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5319 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5320 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5321 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5322 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5323 _(SHOW_VERSION_REPLY, show_version_reply) \
5324 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5325 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5326 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5327 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5328 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5329 _(IP4_ARP_EVENT, ip4_arp_event) \
5330 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5331 _(IP6_ND_EVENT, ip6_nd_event) \
5332 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5333 _(L2_MACS_EVENT, l2_macs_event) \
5334 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5335 _(IP_ADDRESS_DETAILS, ip_address_details) \
5336 _(IP_DETAILS, ip_details) \
5337 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5338 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5339 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5340 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5341 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5342 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5343 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5344 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5345 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5346 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5347 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5348 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5349 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5350 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5351 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5352 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5353 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5354 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5355 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5356 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5357 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5358 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5359 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5360 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5361 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5362 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5363 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5364 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5365 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5366 _(MAP_RULE_DETAILS, map_rule_details) \
5367 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5368 _(WANT_STATS_REPLY, want_stats_reply) \
5369 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5370 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5371 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5372 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5373 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5374 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5375 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5376 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5377 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5378 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5379 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5380 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5381 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5382 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5383 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5384 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5385 one_map_register_enable_disable_reply) \
5386 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5387 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5388 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5389 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5390 one_map_register_fallback_threshold_reply) \
5391 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5392 one_rloc_probe_enable_disable_reply) \
5393 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5394 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5395 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5396 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5397 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5398 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5399 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5400 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5401 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5402 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5403 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5404 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5405 _(ONE_STATS_DETAILS, one_stats_details) \
5406 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5407 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5408 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5409 show_one_stats_enable_disable_reply) \
5410 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5411 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5412 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5413 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5414 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5415 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5416 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5417 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5418 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5419 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5420 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5421 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5422 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5423 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5424 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5425 gpe_add_del_native_fwd_rpath_reply) \
5426 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5427 gpe_fwd_entry_path_details) \
5428 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5429 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5430 one_add_del_map_request_itr_rlocs_reply) \
5431 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5432 one_get_map_request_itr_rlocs_reply) \
5433 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5434 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5435 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5436 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5437 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5438 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5439 show_one_map_register_state_reply) \
5440 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5441 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5442 show_one_map_register_fallback_threshold_reply) \
5443 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5444 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5445 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5446 _(POLICER_DETAILS, policer_details) \
5447 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5448 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5449 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5450 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5451 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5452 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5453 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5454 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5455 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5456 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5457 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5458 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5459 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5460 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5461 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5462 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5463 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5464 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5465 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5466 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5467 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5468 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5469 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5470 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5471 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5472 ip_source_and_port_range_check_add_del_reply) \
5473 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5474 ip_source_and_port_range_check_interface_add_del_reply) \
5475 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5476 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5477 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5478 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5479 _(PUNT_REPLY, punt_reply) \
5480 _(IP_FIB_DETAILS, ip_fib_details) \
5481 _(IP6_FIB_DETAILS, ip6_fib_details) \
5482 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5483 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5484 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5485 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5486 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5487 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5488 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5489 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5490 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5491 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5492 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5493 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5494 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5495 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5496 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5497 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply)
5499 #define foreach_standalone_reply_msg \
5500 _(SW_INTERFACE_EVENT, sw_interface_event) \
5501 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5502 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5503 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5504 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5505 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5506 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
5507 _(MEMFD_SEGMENT_CREATE_REPLY, memfd_segment_create_reply) \
5516 #define STR_VTR_OP_CASE(op) \
5517 case L2_VTR_ ## op: \
5521 str_vtr_op (u32 vtr_op)
5525 STR_VTR_OP_CASE (DISABLED);
5526 STR_VTR_OP_CASE (PUSH_1);
5527 STR_VTR_OP_CASE (PUSH_2);
5528 STR_VTR_OP_CASE (POP_1);
5529 STR_VTR_OP_CASE (POP_2);
5530 STR_VTR_OP_CASE (TRANSLATE_1_1);
5531 STR_VTR_OP_CASE (TRANSLATE_1_2);
5532 STR_VTR_OP_CASE (TRANSLATE_2_1);
5533 STR_VTR_OP_CASE (TRANSLATE_2_2);
5540 dump_sub_interface_table (vat_main_t * vam)
5542 const sw_interface_subif_t *sub = NULL;
5544 if (vam->json_output)
5547 ("JSON output supported only for VPE API calls and dump_stats_table");
5552 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5553 "Interface", "sw_if_index",
5554 "sub id", "dot1ad", "tags", "outer id",
5555 "inner id", "exact", "default", "outer any", "inner any");
5557 vec_foreach (sub, vam->sw_if_subif_table)
5560 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5561 sub->interface_name,
5563 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5564 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5565 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5566 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5567 if (sub->vtr_op != L2_VTR_DISABLED)
5570 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5571 "tag1: %d tag2: %d ]",
5572 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5573 sub->vtr_tag1, sub->vtr_tag2);
5581 name_sort_cmp (void *a1, void *a2)
5583 name_sort_t *n1 = a1;
5584 name_sort_t *n2 = a2;
5586 return strcmp ((char *) n1->name, (char *) n2->name);
5590 dump_interface_table (vat_main_t * vam)
5593 name_sort_t *nses = 0, *ns;
5595 if (vam->json_output)
5598 ("JSON output supported only for VPE API calls and dump_stats_table");
5603 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5605 vec_add2 (nses, ns, 1);
5606 ns->name = (u8 *)(p->key);
5607 ns->value = (u32) p->value[0];
5611 vec_sort_with_function (nses, name_sort_cmp);
5613 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5614 vec_foreach (ns, nses)
5616 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5623 dump_ip_table (vat_main_t * vam, int is_ipv6)
5625 const ip_details_t *det = NULL;
5626 const ip_address_details_t *address = NULL;
5629 print (vam->ofp, "%-12s", "sw_if_index");
5631 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5638 print (vam->ofp, "%-12d", i);
5639 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5644 vec_foreach (address, det->addr)
5648 is_ipv6 ? format_ip6_address : format_ip4_address,
5649 address->ip, address->prefix_length);
5657 dump_ipv4_table (vat_main_t * vam)
5659 if (vam->json_output)
5662 ("JSON output supported only for VPE API calls and dump_stats_table");
5666 return dump_ip_table (vam, 0);
5670 dump_ipv6_table (vat_main_t * vam)
5672 if (vam->json_output)
5675 ("JSON output supported only for VPE API calls and dump_stats_table");
5679 return dump_ip_table (vam, 1);
5683 counter_type_to_str (u8 counter_type, u8 is_combined)
5687 switch (counter_type)
5689 case VNET_INTERFACE_COUNTER_DROP:
5691 case VNET_INTERFACE_COUNTER_PUNT:
5693 case VNET_INTERFACE_COUNTER_IP4:
5695 case VNET_INTERFACE_COUNTER_IP6:
5697 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5699 case VNET_INTERFACE_COUNTER_RX_MISS:
5701 case VNET_INTERFACE_COUNTER_RX_ERROR:
5703 case VNET_INTERFACE_COUNTER_TX_ERROR:
5706 return "INVALID-COUNTER-TYPE";
5711 switch (counter_type)
5713 case VNET_INTERFACE_COUNTER_RX:
5715 case VNET_INTERFACE_COUNTER_TX:
5718 return "INVALID-COUNTER-TYPE";
5724 dump_stats_table (vat_main_t * vam)
5726 vat_json_node_t node;
5727 vat_json_node_t *msg_array;
5728 vat_json_node_t *msg;
5729 vat_json_node_t *counter_array;
5730 vat_json_node_t *counter;
5731 interface_counter_t c;
5733 ip4_fib_counter_t *c4;
5734 ip6_fib_counter_t *c6;
5735 ip4_nbr_counter_t *n4;
5736 ip6_nbr_counter_t *n6;
5739 if (!vam->json_output)
5741 clib_warning ("dump_stats_table supported only in JSON format");
5745 vat_json_init_object (&node);
5747 /* interface counters */
5748 msg_array = vat_json_object_add (&node, "interface_counters");
5749 vat_json_init_array (msg_array);
5750 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5752 msg = vat_json_array_add (msg_array);
5753 vat_json_init_object (msg);
5754 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5755 (u8 *) counter_type_to_str (i, 0));
5756 vat_json_object_add_int (msg, "is_combined", 0);
5757 counter_array = vat_json_object_add (msg, "data");
5758 vat_json_init_array (counter_array);
5759 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5761 packets = vam->simple_interface_counters[i][j];
5762 vat_json_array_add_uint (counter_array, packets);
5765 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5767 msg = vat_json_array_add (msg_array);
5768 vat_json_init_object (msg);
5769 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5770 (u8 *) counter_type_to_str (i, 1));
5771 vat_json_object_add_int (msg, "is_combined", 1);
5772 counter_array = vat_json_object_add (msg, "data");
5773 vat_json_init_array (counter_array);
5774 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5776 c = vam->combined_interface_counters[i][j];
5777 counter = vat_json_array_add (counter_array);
5778 vat_json_init_object (counter);
5779 vat_json_object_add_uint (counter, "packets", c.packets);
5780 vat_json_object_add_uint (counter, "bytes", c.bytes);
5784 /* ip4 fib counters */
5785 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5786 vat_json_init_array (msg_array);
5787 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5789 msg = vat_json_array_add (msg_array);
5790 vat_json_init_object (msg);
5791 vat_json_object_add_uint (msg, "vrf_id",
5792 vam->ip4_fib_counters_vrf_id_by_index[i]);
5793 counter_array = vat_json_object_add (msg, "c");
5794 vat_json_init_array (counter_array);
5795 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5797 counter = vat_json_array_add (counter_array);
5798 vat_json_init_object (counter);
5799 c4 = &vam->ip4_fib_counters[i][j];
5800 vat_json_object_add_ip4 (counter, "address", c4->address);
5801 vat_json_object_add_uint (counter, "address_length",
5802 c4->address_length);
5803 vat_json_object_add_uint (counter, "packets", c4->packets);
5804 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5808 /* ip6 fib counters */
5809 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5810 vat_json_init_array (msg_array);
5811 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5813 msg = vat_json_array_add (msg_array);
5814 vat_json_init_object (msg);
5815 vat_json_object_add_uint (msg, "vrf_id",
5816 vam->ip6_fib_counters_vrf_id_by_index[i]);
5817 counter_array = vat_json_object_add (msg, "c");
5818 vat_json_init_array (counter_array);
5819 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5821 counter = vat_json_array_add (counter_array);
5822 vat_json_init_object (counter);
5823 c6 = &vam->ip6_fib_counters[i][j];
5824 vat_json_object_add_ip6 (counter, "address", c6->address);
5825 vat_json_object_add_uint (counter, "address_length",
5826 c6->address_length);
5827 vat_json_object_add_uint (counter, "packets", c6->packets);
5828 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5832 /* ip4 nbr counters */
5833 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5834 vat_json_init_array (msg_array);
5835 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5837 msg = vat_json_array_add (msg_array);
5838 vat_json_init_object (msg);
5839 vat_json_object_add_uint (msg, "sw_if_index", i);
5840 counter_array = vat_json_object_add (msg, "c");
5841 vat_json_init_array (counter_array);
5842 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5844 counter = vat_json_array_add (counter_array);
5845 vat_json_init_object (counter);
5846 n4 = &vam->ip4_nbr_counters[i][j];
5847 vat_json_object_add_ip4 (counter, "address", n4->address);
5848 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5849 vat_json_object_add_uint (counter, "packets", n4->packets);
5850 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5854 /* ip6 nbr counters */
5855 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5856 vat_json_init_array (msg_array);
5857 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5859 msg = vat_json_array_add (msg_array);
5860 vat_json_init_object (msg);
5861 vat_json_object_add_uint (msg, "sw_if_index", i);
5862 counter_array = vat_json_object_add (msg, "c");
5863 vat_json_init_array (counter_array);
5864 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5866 counter = vat_json_array_add (counter_array);
5867 vat_json_init_object (counter);
5868 n6 = &vam->ip6_nbr_counters[i][j];
5869 vat_json_object_add_ip6 (counter, "address", n6->address);
5870 vat_json_object_add_uint (counter, "packets", n6->packets);
5871 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5875 vat_json_print (vam->ofp, &node);
5876 vat_json_free (&node);
5882 * Pass CLI buffers directly in the CLI_INBAND API message,
5883 * instead of an additional shared memory area.
5886 exec_inband (vat_main_t * vam)
5888 vl_api_cli_inband_t *mp;
5889 unformat_input_t *i = vam->input;
5892 if (vec_len (i->buffer) == 0)
5895 if (vam->exec_mode == 0 && unformat (i, "mode"))
5900 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5907 * In order for the CLI command to work, it
5908 * must be a vector ending in \n, not a C-string ending
5911 u32 len = vec_len (vam->input->buffer);
5912 M2 (CLI_INBAND, mp, len);
5913 clib_memcpy (mp->cmd, vam->input->buffer, len);
5914 mp->length = htonl (len);
5918 /* json responses may or may not include a useful reply... */
5919 if (vec_len (vam->cmd_reply))
5920 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5925 exec (vat_main_t * vam)
5927 return exec_inband (vam);
5931 api_create_loopback (vat_main_t * vam)
5933 unformat_input_t *i = vam->input;
5934 vl_api_create_loopback_t *mp;
5935 vl_api_create_loopback_instance_t *mp_lbi;
5938 u8 is_specified = 0;
5939 u32 user_instance = 0;
5942 memset (mac_address, 0, sizeof (mac_address));
5944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5946 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5948 if (unformat (i, "instance %d", &user_instance))
5956 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5957 mp_lbi->is_specified = is_specified;
5959 mp_lbi->user_instance = htonl (user_instance);
5961 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5966 /* Construct the API message */
5967 M (CREATE_LOOPBACK, mp);
5969 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5978 api_delete_loopback (vat_main_t * vam)
5980 unformat_input_t *i = vam->input;
5981 vl_api_delete_loopback_t *mp;
5982 u32 sw_if_index = ~0;
5985 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5987 if (unformat (i, "sw_if_index %d", &sw_if_index))
5993 if (sw_if_index == ~0)
5995 errmsg ("missing sw_if_index");
5999 /* Construct the API message */
6000 M (DELETE_LOOPBACK, mp);
6001 mp->sw_if_index = ntohl (sw_if_index);
6009 api_want_stats (vat_main_t * vam)
6011 unformat_input_t *i = vam->input;
6012 vl_api_want_stats_t *mp;
6016 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6018 if (unformat (i, "enable"))
6020 else if (unformat (i, "disable"))
6028 errmsg ("missing enable|disable");
6033 mp->enable_disable = enable;
6041 api_want_interface_events (vat_main_t * vam)
6043 unformat_input_t *i = vam->input;
6044 vl_api_want_interface_events_t *mp;
6048 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6050 if (unformat (i, "enable"))
6052 else if (unformat (i, "disable"))
6060 errmsg ("missing enable|disable");
6064 M (WANT_INTERFACE_EVENTS, mp);
6065 mp->enable_disable = enable;
6067 vam->interface_event_display = enable;
6075 /* Note: non-static, called once to set up the initial intfc table */
6077 api_sw_interface_dump (vat_main_t * vam)
6079 vl_api_sw_interface_dump_t *mp;
6080 vl_api_control_ping_t *mp_ping;
6082 name_sort_t *nses = 0, *ns;
6083 sw_interface_subif_t *sub = NULL;
6086 /* Toss the old name table */
6088 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6090 vec_add2 (nses, ns, 1);
6091 ns->name = (u8 *)(p->key);
6092 ns->value = (u32) p->value[0];
6096 hash_free (vam->sw_if_index_by_interface_name);
6098 vec_foreach (ns, nses) vec_free (ns->name);
6102 vec_foreach (sub, vam->sw_if_subif_table)
6104 vec_free (sub->interface_name);
6106 vec_free (vam->sw_if_subif_table);
6108 /* recreate the interface name hash table */
6109 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6111 /* Get list of ethernets */
6112 M (SW_INTERFACE_DUMP, mp);
6113 mp->name_filter_valid = 1;
6114 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
6117 /* and local / loopback interfaces */
6118 M (SW_INTERFACE_DUMP, mp);
6119 mp->name_filter_valid = 1;
6120 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
6123 /* and packet-generator interfaces */
6124 M (SW_INTERFACE_DUMP, mp);
6125 mp->name_filter_valid = 1;
6126 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
6129 /* and vxlan-gpe tunnel interfaces */
6130 M (SW_INTERFACE_DUMP, mp);
6131 mp->name_filter_valid = 1;
6132 strncpy ((char *) mp->name_filter, "vxlan_gpe",
6133 sizeof (mp->name_filter) - 1);
6136 /* and vxlan tunnel interfaces */
6137 M (SW_INTERFACE_DUMP, mp);
6138 mp->name_filter_valid = 1;
6139 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
6142 /* and geneve tunnel interfaces */
6143 M (SW_INTERFACE_DUMP, mp);
6144 mp->name_filter_valid = 1;
6145 strncpy ((char *) mp->name_filter, "geneve", sizeof (mp->name_filter) - 1);
6148 /* and host (af_packet) interfaces */
6149 M (SW_INTERFACE_DUMP, mp);
6150 mp->name_filter_valid = 1;
6151 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
6154 /* and l2tpv3 tunnel interfaces */
6155 M (SW_INTERFACE_DUMP, mp);
6156 mp->name_filter_valid = 1;
6157 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
6158 sizeof (mp->name_filter) - 1);
6161 /* and GRE tunnel interfaces */
6162 M (SW_INTERFACE_DUMP, mp);
6163 mp->name_filter_valid = 1;
6164 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
6167 /* and LISP-GPE interfaces */
6168 M (SW_INTERFACE_DUMP, mp);
6169 mp->name_filter_valid = 1;
6170 strncpy ((char *) mp->name_filter, "lisp_gpe",
6171 sizeof (mp->name_filter) - 1);
6174 /* and IPSEC tunnel interfaces */
6175 M (SW_INTERFACE_DUMP, mp);
6176 mp->name_filter_valid = 1;
6177 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
6180 /* Use a control ping for synchronization */
6181 MPING (CONTROL_PING, mp_ping);
6189 api_sw_interface_set_flags (vat_main_t * vam)
6191 unformat_input_t *i = vam->input;
6192 vl_api_sw_interface_set_flags_t *mp;
6194 u8 sw_if_index_set = 0;
6198 /* Parse args required to build the message */
6199 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6201 if (unformat (i, "admin-up"))
6203 else if (unformat (i, "admin-down"))
6206 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6207 sw_if_index_set = 1;
6208 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6209 sw_if_index_set = 1;
6214 if (sw_if_index_set == 0)
6216 errmsg ("missing interface name or sw_if_index");
6220 /* Construct the API message */
6221 M (SW_INTERFACE_SET_FLAGS, mp);
6222 mp->sw_if_index = ntohl (sw_if_index);
6223 mp->admin_up_down = admin_up;
6228 /* Wait for a reply, return the good/bad news... */
6234 api_sw_interface_clear_stats (vat_main_t * vam)
6236 unformat_input_t *i = vam->input;
6237 vl_api_sw_interface_clear_stats_t *mp;
6239 u8 sw_if_index_set = 0;
6242 /* Parse args required to build the message */
6243 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6245 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6246 sw_if_index_set = 1;
6247 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6248 sw_if_index_set = 1;
6253 /* Construct the API message */
6254 M (SW_INTERFACE_CLEAR_STATS, mp);
6256 if (sw_if_index_set == 1)
6257 mp->sw_if_index = ntohl (sw_if_index);
6259 mp->sw_if_index = ~0;
6264 /* Wait for a reply, return the good/bad news... */
6270 api_sw_interface_add_del_address (vat_main_t * vam)
6272 unformat_input_t *i = vam->input;
6273 vl_api_sw_interface_add_del_address_t *mp;
6275 u8 sw_if_index_set = 0;
6276 u8 is_add = 1, del_all = 0;
6277 u32 address_length = 0;
6278 u8 v4_address_set = 0;
6279 u8 v6_address_set = 0;
6280 ip4_address_t v4address;
6281 ip6_address_t v6address;
6284 /* Parse args required to build the message */
6285 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6287 if (unformat (i, "del-all"))
6289 else if (unformat (i, "del"))
6292 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6293 sw_if_index_set = 1;
6294 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6295 sw_if_index_set = 1;
6296 else if (unformat (i, "%U/%d",
6297 unformat_ip4_address, &v4address, &address_length))
6299 else if (unformat (i, "%U/%d",
6300 unformat_ip6_address, &v6address, &address_length))
6306 if (sw_if_index_set == 0)
6308 errmsg ("missing interface name or sw_if_index");
6311 if (v4_address_set && v6_address_set)
6313 errmsg ("both v4 and v6 addresses set");
6316 if (!v4_address_set && !v6_address_set && !del_all)
6318 errmsg ("no addresses set");
6322 /* Construct the API message */
6323 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6325 mp->sw_if_index = ntohl (sw_if_index);
6326 mp->is_add = is_add;
6327 mp->del_all = del_all;
6331 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6335 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6337 mp->address_length = address_length;
6342 /* Wait for a reply, return good/bad news */
6348 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6350 unformat_input_t *i = vam->input;
6351 vl_api_sw_interface_set_mpls_enable_t *mp;
6353 u8 sw_if_index_set = 0;
6357 /* Parse args required to build the message */
6358 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6360 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6361 sw_if_index_set = 1;
6362 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6363 sw_if_index_set = 1;
6364 else if (unformat (i, "disable"))
6366 else if (unformat (i, "dis"))
6372 if (sw_if_index_set == 0)
6374 errmsg ("missing interface name or sw_if_index");
6378 /* Construct the API message */
6379 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6381 mp->sw_if_index = ntohl (sw_if_index);
6382 mp->enable = enable;
6387 /* Wait for a reply... */
6393 api_sw_interface_set_table (vat_main_t * vam)
6395 unformat_input_t *i = vam->input;
6396 vl_api_sw_interface_set_table_t *mp;
6397 u32 sw_if_index, vrf_id = 0;
6398 u8 sw_if_index_set = 0;
6402 /* Parse args required to build the message */
6403 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6405 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6406 sw_if_index_set = 1;
6407 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6408 sw_if_index_set = 1;
6409 else if (unformat (i, "vrf %d", &vrf_id))
6411 else if (unformat (i, "ipv6"))
6417 if (sw_if_index_set == 0)
6419 errmsg ("missing interface name or sw_if_index");
6423 /* Construct the API message */
6424 M (SW_INTERFACE_SET_TABLE, mp);
6426 mp->sw_if_index = ntohl (sw_if_index);
6427 mp->is_ipv6 = is_ipv6;
6428 mp->vrf_id = ntohl (vrf_id);
6433 /* Wait for a reply... */
6438 static void vl_api_sw_interface_get_table_reply_t_handler
6439 (vl_api_sw_interface_get_table_reply_t * mp)
6441 vat_main_t *vam = &vat_main;
6443 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6445 vam->retval = ntohl (mp->retval);
6446 vam->result_ready = 1;
6450 static void vl_api_sw_interface_get_table_reply_t_handler_json
6451 (vl_api_sw_interface_get_table_reply_t * mp)
6453 vat_main_t *vam = &vat_main;
6454 vat_json_node_t node;
6456 vat_json_init_object (&node);
6457 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6458 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6460 vat_json_print (vam->ofp, &node);
6461 vat_json_free (&node);
6463 vam->retval = ntohl (mp->retval);
6464 vam->result_ready = 1;
6468 api_sw_interface_get_table (vat_main_t * vam)
6470 unformat_input_t *i = vam->input;
6471 vl_api_sw_interface_get_table_t *mp;
6473 u8 sw_if_index_set = 0;
6477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6479 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6480 sw_if_index_set = 1;
6481 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6482 sw_if_index_set = 1;
6483 else if (unformat (i, "ipv6"))
6489 if (sw_if_index_set == 0)
6491 errmsg ("missing interface name or sw_if_index");
6495 M (SW_INTERFACE_GET_TABLE, mp);
6496 mp->sw_if_index = htonl (sw_if_index);
6497 mp->is_ipv6 = is_ipv6;
6505 api_sw_interface_set_vpath (vat_main_t * vam)
6507 unformat_input_t *i = vam->input;
6508 vl_api_sw_interface_set_vpath_t *mp;
6509 u32 sw_if_index = 0;
6510 u8 sw_if_index_set = 0;
6514 /* Parse args required to build the message */
6515 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6517 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6518 sw_if_index_set = 1;
6519 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6520 sw_if_index_set = 1;
6521 else if (unformat (i, "enable"))
6523 else if (unformat (i, "disable"))
6529 if (sw_if_index_set == 0)
6531 errmsg ("missing interface name or sw_if_index");
6535 /* Construct the API message */
6536 M (SW_INTERFACE_SET_VPATH, mp);
6538 mp->sw_if_index = ntohl (sw_if_index);
6539 mp->enable = is_enable;
6544 /* Wait for a reply... */
6550 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6552 unformat_input_t *i = vam->input;
6553 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6554 u32 sw_if_index = 0;
6555 u8 sw_if_index_set = 0;
6560 /* Parse args required to build the message */
6561 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6563 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6564 sw_if_index_set = 1;
6565 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6566 sw_if_index_set = 1;
6567 else if (unformat (i, "enable"))
6569 else if (unformat (i, "disable"))
6571 else if (unformat (i, "ip4"))
6573 else if (unformat (i, "ip6"))
6579 if (sw_if_index_set == 0)
6581 errmsg ("missing interface name or sw_if_index");
6585 /* Construct the API message */
6586 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6588 mp->sw_if_index = ntohl (sw_if_index);
6589 mp->enable = is_enable;
6590 mp->is_ipv6 = is_ipv6;
6595 /* Wait for a reply... */
6601 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6603 unformat_input_t *i = vam->input;
6604 vl_api_sw_interface_set_geneve_bypass_t *mp;
6605 u32 sw_if_index = 0;
6606 u8 sw_if_index_set = 0;
6611 /* Parse args required to build the message */
6612 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6614 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6615 sw_if_index_set = 1;
6616 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6617 sw_if_index_set = 1;
6618 else if (unformat (i, "enable"))
6620 else if (unformat (i, "disable"))
6622 else if (unformat (i, "ip4"))
6624 else if (unformat (i, "ip6"))
6630 if (sw_if_index_set == 0)
6632 errmsg ("missing interface name or sw_if_index");
6636 /* Construct the API message */
6637 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6639 mp->sw_if_index = ntohl (sw_if_index);
6640 mp->enable = is_enable;
6641 mp->is_ipv6 = is_ipv6;
6646 /* Wait for a reply... */
6652 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6654 unformat_input_t *i = vam->input;
6655 vl_api_sw_interface_set_l2_xconnect_t *mp;
6657 u8 rx_sw_if_index_set = 0;
6659 u8 tx_sw_if_index_set = 0;
6663 /* Parse args required to build the message */
6664 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6666 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6667 rx_sw_if_index_set = 1;
6668 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6669 tx_sw_if_index_set = 1;
6670 else if (unformat (i, "rx"))
6672 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6674 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6676 rx_sw_if_index_set = 1;
6681 else if (unformat (i, "tx"))
6683 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6685 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6687 tx_sw_if_index_set = 1;
6692 else if (unformat (i, "enable"))
6694 else if (unformat (i, "disable"))
6700 if (rx_sw_if_index_set == 0)
6702 errmsg ("missing rx interface name or rx_sw_if_index");
6706 if (enable && (tx_sw_if_index_set == 0))
6708 errmsg ("missing tx interface name or tx_sw_if_index");
6712 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6714 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6715 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6716 mp->enable = enable;
6724 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6726 unformat_input_t *i = vam->input;
6727 vl_api_sw_interface_set_l2_bridge_t *mp;
6729 u8 rx_sw_if_index_set = 0;
6737 /* Parse args required to build the message */
6738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6740 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6741 rx_sw_if_index_set = 1;
6742 else if (unformat (i, "bd_id %d", &bd_id))
6746 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6747 rx_sw_if_index_set = 1;
6748 else if (unformat (i, "shg %d", &shg))
6750 else if (unformat (i, "bvi"))
6752 else if (unformat (i, "enable"))
6754 else if (unformat (i, "disable"))
6760 if (rx_sw_if_index_set == 0)
6762 errmsg ("missing rx interface name or sw_if_index");
6766 if (enable && (bd_id_set == 0))
6768 errmsg ("missing bridge domain");
6772 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6774 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6775 mp->bd_id = ntohl (bd_id);
6778 mp->enable = enable;
6786 api_bridge_domain_dump (vat_main_t * vam)
6788 unformat_input_t *i = vam->input;
6789 vl_api_bridge_domain_dump_t *mp;
6790 vl_api_control_ping_t *mp_ping;
6794 /* Parse args required to build the message */
6795 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6797 if (unformat (i, "bd_id %d", &bd_id))
6803 M (BRIDGE_DOMAIN_DUMP, mp);
6804 mp->bd_id = ntohl (bd_id);
6807 /* Use a control ping for synchronization */
6808 MPING (CONTROL_PING, mp_ping);
6816 api_bridge_domain_add_del (vat_main_t * vam)
6818 unformat_input_t *i = vam->input;
6819 vl_api_bridge_domain_add_del_t *mp;
6822 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6827 /* Parse args required to build the message */
6828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6830 if (unformat (i, "bd_id %d", &bd_id))
6832 else if (unformat (i, "flood %d", &flood))
6834 else if (unformat (i, "uu-flood %d", &uu_flood))
6836 else if (unformat (i, "forward %d", &forward))
6838 else if (unformat (i, "learn %d", &learn))
6840 else if (unformat (i, "arp-term %d", &arp_term))
6842 else if (unformat (i, "mac-age %d", &mac_age))
6844 else if (unformat (i, "bd-tag %s", &bd_tag))
6846 else if (unformat (i, "del"))
6849 flood = uu_flood = forward = learn = 0;
6857 errmsg ("missing bridge domain");
6864 errmsg ("mac age must be less than 256 ");
6869 if ((bd_tag) && (strlen ((char *) bd_tag) > 63))
6871 errmsg ("bd-tag cannot be longer than 63");
6876 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6878 mp->bd_id = ntohl (bd_id);
6880 mp->uu_flood = uu_flood;
6881 mp->forward = forward;
6883 mp->arp_term = arp_term;
6884 mp->is_add = is_add;
6885 mp->mac_age = (u8) mac_age;
6887 strcpy ((char *) mp->bd_tag, (char *) bd_tag);
6898 api_l2fib_flush_bd (vat_main_t * vam)
6900 unformat_input_t *i = vam->input;
6901 vl_api_l2fib_flush_bd_t *mp;
6905 /* Parse args required to build the message */
6906 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6908 if (unformat (i, "bd_id %d", &bd_id));
6915 errmsg ("missing bridge domain");
6919 M (L2FIB_FLUSH_BD, mp);
6921 mp->bd_id = htonl (bd_id);
6929 api_l2fib_flush_int (vat_main_t * vam)
6931 unformat_input_t *i = vam->input;
6932 vl_api_l2fib_flush_int_t *mp;
6933 u32 sw_if_index = ~0;
6936 /* Parse args required to build the message */
6937 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6939 if (unformat (i, "sw_if_index %d", &sw_if_index));
6941 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6946 if (sw_if_index == ~0)
6948 errmsg ("missing interface name or sw_if_index");
6952 M (L2FIB_FLUSH_INT, mp);
6954 mp->sw_if_index = ntohl (sw_if_index);
6962 api_l2fib_add_del (vat_main_t * vam)
6964 unformat_input_t *i = vam->input;
6965 vl_api_l2fib_add_del_t *mp;
6971 u32 sw_if_index = ~0;
6972 u8 sw_if_index_set = 0;
6981 /* Parse args required to build the message */
6982 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6984 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6986 else if (unformat (i, "bd_id %d", &bd_id))
6988 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6989 sw_if_index_set = 1;
6990 else if (unformat (i, "sw_if"))
6992 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6995 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6996 sw_if_index_set = 1;
7001 else if (unformat (i, "static"))
7003 else if (unformat (i, "filter"))
7008 else if (unformat (i, "bvi"))
7013 else if (unformat (i, "del"))
7015 else if (unformat (i, "count %d", &count))
7023 errmsg ("missing mac address");
7029 errmsg ("missing bridge domain");
7033 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7035 errmsg ("missing interface name or sw_if_index");
7041 /* Turn on async mode */
7042 vam->async_mode = 1;
7043 vam->async_errors = 0;
7044 before = vat_time_now (vam);
7047 for (j = 0; j < count; j++)
7049 M (L2FIB_ADD_DEL, mp);
7052 mp->bd_id = ntohl (bd_id);
7053 mp->is_add = is_add;
7057 mp->sw_if_index = ntohl (sw_if_index);
7058 mp->static_mac = static_mac;
7059 mp->filter_mac = filter_mac;
7060 mp->bvi_mac = bvi_mac;
7062 increment_mac_address (&mac);
7069 vl_api_control_ping_t *mp_ping;
7072 /* Shut off async mode */
7073 vam->async_mode = 0;
7075 MPING (CONTROL_PING, mp_ping);
7078 timeout = vat_time_now (vam) + 1.0;
7079 while (vat_time_now (vam) < timeout)
7080 if (vam->result_ready == 1)
7085 if (vam->retval == -99)
7088 if (vam->async_errors > 0)
7090 errmsg ("%d asynchronous errors", vam->async_errors);
7093 vam->async_errors = 0;
7094 after = vat_time_now (vam);
7096 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7097 count, after - before, count / (after - before));
7103 /* Wait for a reply... */
7107 /* Return the good/bad news */
7108 return (vam->retval);
7112 api_bridge_domain_set_mac_age (vat_main_t * vam)
7114 unformat_input_t *i = vam->input;
7115 vl_api_bridge_domain_set_mac_age_t *mp;
7120 /* Parse args required to build the message */
7121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7123 if (unformat (i, "bd_id %d", &bd_id));
7124 else if (unformat (i, "mac-age %d", &mac_age));
7131 errmsg ("missing bridge domain");
7137 errmsg ("mac age must be less than 256 ");
7141 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7143 mp->bd_id = htonl (bd_id);
7144 mp->mac_age = (u8) mac_age;
7152 api_l2_flags (vat_main_t * vam)
7154 unformat_input_t *i = vam->input;
7155 vl_api_l2_flags_t *mp;
7158 u8 sw_if_index_set = 0;
7162 /* Parse args required to build the message */
7163 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7165 if (unformat (i, "sw_if_index %d", &sw_if_index))
7166 sw_if_index_set = 1;
7167 else if (unformat (i, "sw_if"))
7169 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7172 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7173 sw_if_index_set = 1;
7178 else if (unformat (i, "learn"))
7180 else if (unformat (i, "forward"))
7182 else if (unformat (i, "flood"))
7184 else if (unformat (i, "uu-flood"))
7185 flags |= L2_UU_FLOOD;
7186 else if (unformat (i, "arp-term"))
7187 flags |= L2_ARP_TERM;
7188 else if (unformat (i, "off"))
7190 else if (unformat (i, "disable"))
7196 if (sw_if_index_set == 0)
7198 errmsg ("missing interface name or sw_if_index");
7204 mp->sw_if_index = ntohl (sw_if_index);
7205 mp->feature_bitmap = ntohl (flags);
7206 mp->is_set = is_set;
7214 api_bridge_flags (vat_main_t * vam)
7216 unformat_input_t *i = vam->input;
7217 vl_api_bridge_flags_t *mp;
7224 /* Parse args required to build the message */
7225 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7227 if (unformat (i, "bd_id %d", &bd_id))
7229 else if (unformat (i, "learn"))
7231 else if (unformat (i, "forward"))
7233 else if (unformat (i, "flood"))
7235 else if (unformat (i, "uu-flood"))
7236 flags |= L2_UU_FLOOD;
7237 else if (unformat (i, "arp-term"))
7238 flags |= L2_ARP_TERM;
7239 else if (unformat (i, "off"))
7241 else if (unformat (i, "disable"))
7249 errmsg ("missing bridge domain");
7253 M (BRIDGE_FLAGS, mp);
7255 mp->bd_id = ntohl (bd_id);
7256 mp->feature_bitmap = ntohl (flags);
7257 mp->is_set = is_set;
7265 api_bd_ip_mac_add_del (vat_main_t * vam)
7267 unformat_input_t *i = vam->input;
7268 vl_api_bd_ip_mac_add_del_t *mp;
7275 ip4_address_t v4addr;
7276 ip6_address_t v6addr;
7281 /* Parse args required to build the message */
7282 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7284 if (unformat (i, "bd_id %d", &bd_id))
7288 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7292 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7297 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7301 else if (unformat (i, "del"))
7309 errmsg ("missing bridge domain");
7312 else if (ip_set == 0)
7314 errmsg ("missing IP address");
7317 else if (mac_set == 0)
7319 errmsg ("missing MAC address");
7323 M (BD_IP_MAC_ADD_DEL, mp);
7325 mp->bd_id = ntohl (bd_id);
7326 mp->is_ipv6 = is_ipv6;
7327 mp->is_add = is_add;
7329 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7331 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7332 clib_memcpy (mp->mac_address, macaddr, 6);
7339 api_tap_connect (vat_main_t * vam)
7341 unformat_input_t *i = vam->input;
7342 vl_api_tap_connect_t *mp;
7348 ip4_address_t ip4_address;
7350 int ip4_address_set = 0;
7351 ip6_address_t ip6_address;
7353 int ip6_address_set = 0;
7356 memset (mac_address, 0, sizeof (mac_address));
7358 /* Parse args required to build the message */
7359 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7361 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7365 else if (unformat (i, "random-mac"))
7367 else if (unformat (i, "tapname %s", &tap_name))
7369 else if (unformat (i, "tag %s", &tag))
7371 else if (unformat (i, "address %U/%d",
7372 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7373 ip4_address_set = 1;
7374 else if (unformat (i, "address %U/%d",
7375 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7376 ip6_address_set = 1;
7383 errmsg ("missing tap name");
7386 if (vec_len (tap_name) > 63)
7388 errmsg ("tap name too long");
7391 vec_add1 (tap_name, 0);
7393 if (vec_len (tag) > 63)
7395 errmsg ("tag too long");
7399 /* Construct the API message */
7400 M (TAP_CONNECT, mp);
7402 mp->use_random_mac = random_mac;
7403 clib_memcpy (mp->mac_address, mac_address, 6);
7404 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7406 clib_memcpy (mp->tag, tag, vec_len (tag));
7408 if (ip4_address_set)
7410 mp->ip4_address_set = 1;
7411 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7412 mp->ip4_mask_width = ip4_mask_width;
7414 if (ip6_address_set)
7416 mp->ip6_address_set = 1;
7417 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7418 mp->ip6_mask_width = ip6_mask_width;
7421 vec_free (tap_name);
7427 /* Wait for a reply... */
7433 api_tap_modify (vat_main_t * vam)
7435 unformat_input_t *i = vam->input;
7436 vl_api_tap_modify_t *mp;
7441 u32 sw_if_index = ~0;
7442 u8 sw_if_index_set = 0;
7445 memset (mac_address, 0, sizeof (mac_address));
7447 /* Parse args required to build the message */
7448 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7450 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7451 sw_if_index_set = 1;
7452 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7453 sw_if_index_set = 1;
7454 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7458 else if (unformat (i, "random-mac"))
7460 else if (unformat (i, "tapname %s", &tap_name))
7466 if (sw_if_index_set == 0)
7468 errmsg ("missing vpp interface name");
7473 errmsg ("missing tap name");
7476 if (vec_len (tap_name) > 63)
7478 errmsg ("tap name too long");
7480 vec_add1 (tap_name, 0);
7482 /* Construct the API message */
7485 mp->use_random_mac = random_mac;
7486 mp->sw_if_index = ntohl (sw_if_index);
7487 clib_memcpy (mp->mac_address, mac_address, 6);
7488 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7489 vec_free (tap_name);
7494 /* Wait for a reply... */
7500 api_tap_delete (vat_main_t * vam)
7502 unformat_input_t *i = vam->input;
7503 vl_api_tap_delete_t *mp;
7504 u32 sw_if_index = ~0;
7505 u8 sw_if_index_set = 0;
7508 /* Parse args required to build the message */
7509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7511 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7512 sw_if_index_set = 1;
7513 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7514 sw_if_index_set = 1;
7519 if (sw_if_index_set == 0)
7521 errmsg ("missing vpp interface name");
7525 /* Construct the API message */
7528 mp->sw_if_index = ntohl (sw_if_index);
7533 /* Wait for a reply... */
7539 api_ip_table_add_del (vat_main_t * vam)
7541 unformat_input_t *i = vam->input;
7542 vl_api_ip_table_add_del_t *mp;
7548 /* Parse args required to build the message */
7549 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7551 if (unformat (i, "ipv6"))
7553 else if (unformat (i, "del"))
7555 else if (unformat (i, "add"))
7557 else if (unformat (i, "table %d", &table_id))
7561 clib_warning ("parse error '%U'", format_unformat_error, i);
7568 errmsg ("missing table-ID");
7572 /* Construct the API message */
7573 M (IP_TABLE_ADD_DEL, mp);
7575 mp->table_id = ntohl (table_id);
7576 mp->is_ipv6 = is_ipv6;
7577 mp->is_add = is_add;
7582 /* Wait for a reply... */
7589 api_ip_add_del_route (vat_main_t * vam)
7591 unformat_input_t *i = vam->input;
7592 vl_api_ip_add_del_route_t *mp;
7593 u32 sw_if_index = ~0, vrf_id = 0;
7595 u8 is_local = 0, is_drop = 0;
7596 u8 is_unreach = 0, is_prohibit = 0;
7597 u8 create_vrf_if_needed = 0;
7599 u32 next_hop_weight = 1;
7600 u8 is_multipath = 0;
7602 u8 address_length_set = 0;
7603 u32 next_hop_table_id = 0;
7604 u32 resolve_attempts = 0;
7605 u32 dst_address_length = 0;
7606 u8 next_hop_set = 0;
7607 ip4_address_t v4_dst_address, v4_next_hop_address;
7608 ip6_address_t v6_dst_address, v6_next_hop_address;
7612 u32 random_add_del = 0;
7613 u32 *random_vector = 0;
7615 u32 random_seed = 0xdeaddabe;
7616 u32 classify_table_index = ~0;
7618 u8 resolve_host = 0, resolve_attached = 0;
7619 mpls_label_t *next_hop_out_label_stack = NULL;
7620 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7621 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7623 /* Parse args required to build the message */
7624 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7626 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7628 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7630 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
7635 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
7640 else if (unformat (i, "/%d", &dst_address_length))
7642 address_length_set = 1;
7645 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
7646 &v4_next_hop_address))
7650 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7651 &v6_next_hop_address))
7655 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7657 else if (unformat (i, "weight %d", &next_hop_weight))
7659 else if (unformat (i, "drop"))
7663 else if (unformat (i, "null-send-unreach"))
7667 else if (unformat (i, "null-send-prohibit"))
7671 else if (unformat (i, "local"))
7675 else if (unformat (i, "classify %d", &classify_table_index))
7679 else if (unformat (i, "del"))
7681 else if (unformat (i, "add"))
7683 else if (unformat (i, "resolve-via-host"))
7685 else if (unformat (i, "resolve-via-attached"))
7686 resolve_attached = 1;
7687 else if (unformat (i, "multipath"))
7689 else if (unformat (i, "vrf %d", &vrf_id))
7691 else if (unformat (i, "create-vrf"))
7692 create_vrf_if_needed = 1;
7693 else if (unformat (i, "count %d", &count))
7695 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7697 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7699 else if (unformat (i, "out-label %d", &next_hop_out_label))
7700 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7701 else if (unformat (i, "via-label %d", &next_hop_via_label))
7703 else if (unformat (i, "random"))
7705 else if (unformat (i, "seed %d", &random_seed))
7709 clib_warning ("parse error '%U'", format_unformat_error, i);
7714 if (!next_hop_set && !is_drop && !is_local &&
7715 !is_classify && !is_unreach && !is_prohibit &&
7716 MPLS_LABEL_INVALID == next_hop_via_label)
7719 ("next hop / local / drop / unreach / prohibit / classify not set");
7723 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7725 errmsg ("next hop and next-hop via label set");
7728 if (address_set == 0)
7730 errmsg ("missing addresses");
7734 if (address_length_set == 0)
7736 errmsg ("missing address length");
7740 /* Generate a pile of unique, random routes */
7743 u32 this_random_address;
7744 random_hash = hash_create (count, sizeof (uword));
7746 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7747 for (j = 0; j <= count; j++)
7751 this_random_address = random_u32 (&random_seed);
7752 this_random_address =
7753 clib_host_to_net_u32 (this_random_address);
7755 while (hash_get (random_hash, this_random_address));
7756 vec_add1 (random_vector, this_random_address);
7757 hash_set (random_hash, this_random_address, 1);
7759 hash_free (random_hash);
7760 v4_dst_address.as_u32 = random_vector[0];
7765 /* Turn on async mode */
7766 vam->async_mode = 1;
7767 vam->async_errors = 0;
7768 before = vat_time_now (vam);
7771 for (j = 0; j < count; j++)
7773 /* Construct the API message */
7774 M2 (IP_ADD_DEL_ROUTE, mp,
7775 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7777 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7778 mp->table_id = ntohl (vrf_id);
7779 mp->create_vrf_if_needed = create_vrf_if_needed;
7781 mp->is_add = is_add;
7782 mp->is_drop = is_drop;
7783 mp->is_unreach = is_unreach;
7784 mp->is_prohibit = is_prohibit;
7785 mp->is_ipv6 = is_ipv6;
7786 mp->is_local = is_local;
7787 mp->is_classify = is_classify;
7788 mp->is_multipath = is_multipath;
7789 mp->is_resolve_host = resolve_host;
7790 mp->is_resolve_attached = resolve_attached;
7791 mp->next_hop_weight = next_hop_weight;
7792 mp->dst_address_length = dst_address_length;
7793 mp->next_hop_table_id = ntohl (next_hop_table_id);
7794 mp->classify_table_index = ntohl (classify_table_index);
7795 mp->next_hop_via_label = ntohl (next_hop_via_label);
7796 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7797 if (0 != mp->next_hop_n_out_labels)
7799 memcpy (mp->next_hop_out_label_stack,
7800 next_hop_out_label_stack,
7801 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7802 vec_free (next_hop_out_label_stack);
7807 clib_memcpy (mp->dst_address, &v6_dst_address,
7808 sizeof (v6_dst_address));
7810 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
7811 sizeof (v6_next_hop_address));
7812 increment_v6_address (&v6_dst_address);
7816 clib_memcpy (mp->dst_address, &v4_dst_address,
7817 sizeof (v4_dst_address));
7819 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
7820 sizeof (v4_next_hop_address));
7822 v4_dst_address.as_u32 = random_vector[j + 1];
7824 increment_v4_address (&v4_dst_address);
7828 /* If we receive SIGTERM, stop now... */
7833 /* When testing multiple add/del ops, use a control-ping to sync */
7836 vl_api_control_ping_t *mp_ping;
7840 /* Shut off async mode */
7841 vam->async_mode = 0;
7843 MPING (CONTROL_PING, mp_ping);
7846 timeout = vat_time_now (vam) + 1.0;
7847 while (vat_time_now (vam) < timeout)
7848 if (vam->result_ready == 1)
7853 if (vam->retval == -99)
7856 if (vam->async_errors > 0)
7858 errmsg ("%d asynchronous errors", vam->async_errors);
7861 vam->async_errors = 0;
7862 after = vat_time_now (vam);
7864 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7868 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7869 count, after - before, count / (after - before));
7875 /* Wait for a reply... */
7880 /* Return the good/bad news */
7881 return (vam->retval);
7885 api_ip_mroute_add_del (vat_main_t * vam)
7887 unformat_input_t *i = vam->input;
7888 vl_api_ip_mroute_add_del_t *mp;
7889 u32 sw_if_index = ~0, vrf_id = 0;
7892 u8 create_vrf_if_needed = 0;
7895 u32 grp_address_length = 0;
7896 ip4_address_t v4_grp_address, v4_src_address;
7897 ip6_address_t v6_grp_address, v6_src_address;
7898 mfib_itf_flags_t iflags = 0;
7899 mfib_entry_flags_t eflags = 0;
7902 /* Parse args required to build the message */
7903 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7905 if (unformat (i, "sw_if_index %d", &sw_if_index))
7907 else if (unformat (i, "%U %U",
7908 unformat_ip4_address, &v4_src_address,
7909 unformat_ip4_address, &v4_grp_address))
7911 grp_address_length = 64;
7915 else if (unformat (i, "%U %U",
7916 unformat_ip6_address, &v6_src_address,
7917 unformat_ip6_address, &v6_grp_address))
7919 grp_address_length = 256;
7923 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7925 memset (&v4_src_address, 0, sizeof (v4_src_address));
7926 grp_address_length = 32;
7930 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7932 memset (&v6_src_address, 0, sizeof (v6_src_address));
7933 grp_address_length = 128;
7937 else if (unformat (i, "/%d", &grp_address_length))
7939 else if (unformat (i, "local"))
7943 else if (unformat (i, "del"))
7945 else if (unformat (i, "add"))
7947 else if (unformat (i, "vrf %d", &vrf_id))
7949 else if (unformat (i, "create-vrf"))
7950 create_vrf_if_needed = 1;
7951 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
7953 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7957 clib_warning ("parse error '%U'", format_unformat_error, i);
7962 if (address_set == 0)
7964 errmsg ("missing addresses\n");
7968 /* Construct the API message */
7969 M (IP_MROUTE_ADD_DEL, mp);
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_ipv6 = is_ipv6;
7977 mp->is_local = is_local;
7978 mp->itf_flags = ntohl (iflags);
7979 mp->entry_flags = ntohl (eflags);
7980 mp->grp_address_length = grp_address_length;
7981 mp->grp_address_length = ntohs (mp->grp_address_length);
7985 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7986 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7990 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7991 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7997 /* Wait for a reply... */
8003 api_mpls_table_add_del (vat_main_t * vam)
8005 unformat_input_t *i = vam->input;
8006 vl_api_mpls_table_add_del_t *mp;
8011 /* Parse args required to build the message */
8012 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8014 if (unformat (i, "table %d", &table_id))
8016 else if (unformat (i, "del"))
8018 else if (unformat (i, "add"))
8022 clib_warning ("parse error '%U'", format_unformat_error, i);
8029 errmsg ("missing table-ID");
8033 /* Construct the API message */
8034 M (MPLS_TABLE_ADD_DEL, mp);
8036 mp->mt_table_id = ntohl (table_id);
8037 mp->mt_is_add = is_add;
8042 /* Wait for a reply... */
8049 api_mpls_route_add_del (vat_main_t * vam)
8051 unformat_input_t *i = vam->input;
8052 vl_api_mpls_route_add_del_t *mp;
8053 u32 sw_if_index = ~0, table_id = 0;
8054 u8 create_table_if_needed = 0;
8056 u32 next_hop_weight = 1;
8057 u8 is_multipath = 0;
8058 u32 next_hop_table_id = 0;
8059 u8 next_hop_set = 0;
8060 ip4_address_t v4_next_hop_address = {
8063 ip6_address_t v6_next_hop_address = { {0} };
8067 u32 classify_table_index = ~0;
8069 u8 resolve_host = 0, resolve_attached = 0;
8070 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8071 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8072 mpls_label_t *next_hop_out_label_stack = NULL;
8073 mpls_label_t local_label = MPLS_LABEL_INVALID;
8075 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8077 /* Parse args required to build the message */
8078 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8080 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8082 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8084 else if (unformat (i, "%d", &local_label))
8086 else if (unformat (i, "eos"))
8088 else if (unformat (i, "non-eos"))
8090 else if (unformat (i, "via %U", unformat_ip4_address,
8091 &v4_next_hop_address))
8094 next_hop_proto = DPO_PROTO_IP4;
8096 else if (unformat (i, "via %U", unformat_ip6_address,
8097 &v6_next_hop_address))
8100 next_hop_proto = DPO_PROTO_IP6;
8102 else if (unformat (i, "weight %d", &next_hop_weight))
8104 else if (unformat (i, "create-table"))
8105 create_table_if_needed = 1;
8106 else if (unformat (i, "classify %d", &classify_table_index))
8110 else if (unformat (i, "del"))
8112 else if (unformat (i, "add"))
8114 else if (unformat (i, "resolve-via-host"))
8116 else if (unformat (i, "resolve-via-attached"))
8117 resolve_attached = 1;
8118 else if (unformat (i, "multipath"))
8120 else if (unformat (i, "count %d", &count))
8122 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8125 next_hop_proto = DPO_PROTO_IP4;
8127 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8130 next_hop_proto = DPO_PROTO_IP6;
8132 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8134 else if (unformat (i, "via-label %d", &next_hop_via_label))
8136 else if (unformat (i, "out-label %d", &next_hop_out_label))
8137 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8140 clib_warning ("parse error '%U'", format_unformat_error, i);
8145 if (!next_hop_set && !is_classify)
8147 errmsg ("next hop / classify not set");
8151 if (MPLS_LABEL_INVALID == local_label)
8153 errmsg ("missing label");
8159 /* Turn on async mode */
8160 vam->async_mode = 1;
8161 vam->async_errors = 0;
8162 before = vat_time_now (vam);
8165 for (j = 0; j < count; j++)
8167 /* Construct the API message */
8168 M2 (MPLS_ROUTE_ADD_DEL, mp,
8169 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8171 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8172 mp->mr_table_id = ntohl (table_id);
8173 mp->mr_create_table_if_needed = create_table_if_needed;
8175 mp->mr_is_add = is_add;
8176 mp->mr_next_hop_proto = next_hop_proto;
8177 mp->mr_is_classify = is_classify;
8178 mp->mr_is_multipath = is_multipath;
8179 mp->mr_is_resolve_host = resolve_host;
8180 mp->mr_is_resolve_attached = resolve_attached;
8181 mp->mr_next_hop_weight = next_hop_weight;
8182 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8183 mp->mr_classify_table_index = ntohl (classify_table_index);
8184 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8185 mp->mr_label = ntohl (local_label);
8186 mp->mr_eos = is_eos;
8188 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8189 if (0 != mp->mr_next_hop_n_out_labels)
8191 memcpy (mp->mr_next_hop_out_label_stack,
8192 next_hop_out_label_stack,
8193 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8194 vec_free (next_hop_out_label_stack);
8199 if (DPO_PROTO_IP4 == next_hop_proto)
8201 clib_memcpy (mp->mr_next_hop,
8202 &v4_next_hop_address,
8203 sizeof (v4_next_hop_address));
8205 else if (DPO_PROTO_IP6 == next_hop_proto)
8208 clib_memcpy (mp->mr_next_hop,
8209 &v6_next_hop_address,
8210 sizeof (v6_next_hop_address));
8217 /* If we receive SIGTERM, stop now... */
8222 /* When testing multiple add/del ops, use a control-ping to sync */
8225 vl_api_control_ping_t *mp_ping;
8229 /* Shut off async mode */
8230 vam->async_mode = 0;
8232 MPING (CONTROL_PING, mp_ping);
8235 timeout = vat_time_now (vam) + 1.0;
8236 while (vat_time_now (vam) < timeout)
8237 if (vam->result_ready == 1)
8242 if (vam->retval == -99)
8245 if (vam->async_errors > 0)
8247 errmsg ("%d asynchronous errors", vam->async_errors);
8250 vam->async_errors = 0;
8251 after = vat_time_now (vam);
8253 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8257 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8258 count, after - before, count / (after - before));
8264 /* Wait for a reply... */
8269 /* Return the good/bad news */
8270 return (vam->retval);
8274 api_mpls_ip_bind_unbind (vat_main_t * vam)
8276 unformat_input_t *i = vam->input;
8277 vl_api_mpls_ip_bind_unbind_t *mp;
8278 u32 ip_table_id = 0;
8279 u8 create_table_if_needed = 0;
8282 ip4_address_t v4_address;
8283 ip6_address_t v6_address;
8286 mpls_label_t local_label = MPLS_LABEL_INVALID;
8289 /* Parse args required to build the message */
8290 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8292 if (unformat (i, "%U/%d", unformat_ip4_address,
8293 &v4_address, &address_length))
8298 else if (unformat (i, "%U/%d", unformat_ip6_address,
8299 &v6_address, &address_length))
8304 else if (unformat (i, "%d", &local_label))
8306 else if (unformat (i, "create-table"))
8307 create_table_if_needed = 1;
8308 else if (unformat (i, "table-id %d", &ip_table_id))
8310 else if (unformat (i, "unbind"))
8312 else if (unformat (i, "bind"))
8316 clib_warning ("parse error '%U'", format_unformat_error, i);
8323 errmsg ("IP addres not set");
8327 if (MPLS_LABEL_INVALID == local_label)
8329 errmsg ("missing label");
8333 /* Construct the API message */
8334 M (MPLS_IP_BIND_UNBIND, mp);
8336 mp->mb_create_table_if_needed = create_table_if_needed;
8337 mp->mb_is_bind = is_bind;
8338 mp->mb_is_ip4 = is_ip4;
8339 mp->mb_ip_table_id = ntohl (ip_table_id);
8340 mp->mb_mpls_table_id = 0;
8341 mp->mb_label = ntohl (local_label);
8342 mp->mb_address_length = address_length;
8345 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8347 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8352 /* Wait for a reply... */
8358 api_proxy_arp_add_del (vat_main_t * vam)
8360 unformat_input_t *i = vam->input;
8361 vl_api_proxy_arp_add_del_t *mp;
8364 ip4_address_t lo, hi;
8368 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8370 if (unformat (i, "vrf %d", &vrf_id))
8372 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
8373 unformat_ip4_address, &hi))
8375 else if (unformat (i, "del"))
8379 clib_warning ("parse error '%U'", format_unformat_error, i);
8386 errmsg ("address range not set");
8390 M (PROXY_ARP_ADD_DEL, mp);
8392 mp->vrf_id = ntohl (vrf_id);
8393 mp->is_add = is_add;
8394 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
8395 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
8403 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8405 unformat_input_t *i = vam->input;
8406 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8409 u8 sw_if_index_set = 0;
8412 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8414 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8415 sw_if_index_set = 1;
8416 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8417 sw_if_index_set = 1;
8418 else if (unformat (i, "enable"))
8420 else if (unformat (i, "disable"))
8424 clib_warning ("parse error '%U'", format_unformat_error, i);
8429 if (sw_if_index_set == 0)
8431 errmsg ("missing interface name or sw_if_index");
8435 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8437 mp->sw_if_index = ntohl (sw_if_index);
8438 mp->enable_disable = enable;
8446 api_mpls_tunnel_add_del (vat_main_t * vam)
8448 unformat_input_t *i = vam->input;
8449 vl_api_mpls_tunnel_add_del_t *mp;
8453 u32 sw_if_index = ~0;
8454 u32 next_hop_sw_if_index = ~0;
8455 u32 next_hop_proto_is_ip4 = 1;
8457 u32 next_hop_table_id = 0;
8458 ip4_address_t v4_next_hop_address = {
8461 ip6_address_t v6_next_hop_address = { {0} };
8462 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
8465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8467 if (unformat (i, "add"))
8469 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8471 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
8473 else if (unformat (i, "via %U",
8474 unformat_ip4_address, &v4_next_hop_address))
8476 next_hop_proto_is_ip4 = 1;
8478 else if (unformat (i, "via %U",
8479 unformat_ip6_address, &v6_next_hop_address))
8481 next_hop_proto_is_ip4 = 0;
8483 else if (unformat (i, "l2-only"))
8485 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8487 else if (unformat (i, "out-label %d", &next_hop_out_label))
8488 vec_add1 (labels, ntohl (next_hop_out_label));
8491 clib_warning ("parse error '%U'", format_unformat_error, i);
8496 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
8498 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
8499 mp->mt_sw_if_index = ntohl (sw_if_index);
8500 mp->mt_is_add = is_add;
8501 mp->mt_l2_only = l2_only;
8502 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
8503 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
8505 mp->mt_next_hop_n_out_labels = vec_len (labels);
8507 if (0 != mp->mt_next_hop_n_out_labels)
8509 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
8510 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
8514 if (next_hop_proto_is_ip4)
8516 clib_memcpy (mp->mt_next_hop,
8517 &v4_next_hop_address, sizeof (v4_next_hop_address));
8521 clib_memcpy (mp->mt_next_hop,
8522 &v6_next_hop_address, sizeof (v6_next_hop_address));
8531 api_sw_interface_set_unnumbered (vat_main_t * vam)
8533 unformat_input_t *i = vam->input;
8534 vl_api_sw_interface_set_unnumbered_t *mp;
8536 u32 unnum_sw_index = ~0;
8538 u8 sw_if_index_set = 0;
8541 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8543 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8544 sw_if_index_set = 1;
8545 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8546 sw_if_index_set = 1;
8547 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8549 else if (unformat (i, "del"))
8553 clib_warning ("parse error '%U'", format_unformat_error, i);
8558 if (sw_if_index_set == 0)
8560 errmsg ("missing interface name or sw_if_index");
8564 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8566 mp->sw_if_index = ntohl (sw_if_index);
8567 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8568 mp->is_add = is_add;
8576 api_ip_neighbor_add_del (vat_main_t * vam)
8578 unformat_input_t *i = vam->input;
8579 vl_api_ip_neighbor_add_del_t *mp;
8581 u8 sw_if_index_set = 0;
8584 u8 is_no_fib_entry = 0;
8587 u8 v4_address_set = 0;
8588 u8 v6_address_set = 0;
8589 ip4_address_t v4address;
8590 ip6_address_t v6address;
8593 memset (mac_address, 0, sizeof (mac_address));
8595 /* Parse args required to build the message */
8596 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8598 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8602 else if (unformat (i, "del"))
8605 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8606 sw_if_index_set = 1;
8607 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8608 sw_if_index_set = 1;
8609 else if (unformat (i, "is_static"))
8611 else if (unformat (i, "no-fib-entry"))
8612 is_no_fib_entry = 1;
8613 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
8615 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
8619 clib_warning ("parse error '%U'", format_unformat_error, i);
8624 if (sw_if_index_set == 0)
8626 errmsg ("missing interface name or sw_if_index");
8629 if (v4_address_set && v6_address_set)
8631 errmsg ("both v4 and v6 addresses set");
8634 if (!v4_address_set && !v6_address_set)
8636 errmsg ("no address set");
8640 /* Construct the API message */
8641 M (IP_NEIGHBOR_ADD_DEL, mp);
8643 mp->sw_if_index = ntohl (sw_if_index);
8644 mp->is_add = is_add;
8645 mp->is_static = is_static;
8646 mp->is_no_adj_fib = is_no_fib_entry;
8648 clib_memcpy (mp->mac_address, mac_address, 6);
8652 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
8656 /* mp->is_ipv6 = 0; via memset in M macro above */
8657 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
8663 /* Wait for a reply, return good/bad news */
8669 api_reset_vrf (vat_main_t * vam)
8671 unformat_input_t *i = vam->input;
8672 vl_api_reset_vrf_t *mp;
8678 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8680 if (unformat (i, "vrf %d", &vrf_id))
8682 else if (unformat (i, "ipv6"))
8686 clib_warning ("parse error '%U'", format_unformat_error, i);
8691 if (vrf_id_set == 0)
8693 errmsg ("missing vrf id");
8699 mp->vrf_id = ntohl (vrf_id);
8700 mp->is_ipv6 = is_ipv6;
8708 api_create_vlan_subif (vat_main_t * vam)
8710 unformat_input_t *i = vam->input;
8711 vl_api_create_vlan_subif_t *mp;
8713 u8 sw_if_index_set = 0;
8718 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8720 if (unformat (i, "sw_if_index %d", &sw_if_index))
8721 sw_if_index_set = 1;
8723 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8724 sw_if_index_set = 1;
8725 else if (unformat (i, "vlan %d", &vlan_id))
8729 clib_warning ("parse error '%U'", format_unformat_error, i);
8734 if (sw_if_index_set == 0)
8736 errmsg ("missing interface name or sw_if_index");
8740 if (vlan_id_set == 0)
8742 errmsg ("missing vlan_id");
8745 M (CREATE_VLAN_SUBIF, mp);
8747 mp->sw_if_index = ntohl (sw_if_index);
8748 mp->vlan_id = ntohl (vlan_id);
8755 #define foreach_create_subif_bit \
8762 _(outer_vlan_id_any) \
8763 _(inner_vlan_id_any)
8766 api_create_subif (vat_main_t * vam)
8768 unformat_input_t *i = vam->input;
8769 vl_api_create_subif_t *mp;
8771 u8 sw_if_index_set = 0;
8778 u32 exact_match = 0;
8779 u32 default_sub = 0;
8780 u32 outer_vlan_id_any = 0;
8781 u32 inner_vlan_id_any = 0;
8783 u16 outer_vlan_id = 0;
8784 u16 inner_vlan_id = 0;
8787 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8789 if (unformat (i, "sw_if_index %d", &sw_if_index))
8790 sw_if_index_set = 1;
8792 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8793 sw_if_index_set = 1;
8794 else if (unformat (i, "sub_id %d", &sub_id))
8796 else if (unformat (i, "outer_vlan_id %d", &tmp))
8797 outer_vlan_id = tmp;
8798 else if (unformat (i, "inner_vlan_id %d", &tmp))
8799 inner_vlan_id = tmp;
8801 #define _(a) else if (unformat (i, #a)) a = 1 ;
8802 foreach_create_subif_bit
8806 clib_warning ("parse error '%U'", format_unformat_error, i);
8811 if (sw_if_index_set == 0)
8813 errmsg ("missing interface name or sw_if_index");
8817 if (sub_id_set == 0)
8819 errmsg ("missing sub_id");
8822 M (CREATE_SUBIF, mp);
8824 mp->sw_if_index = ntohl (sw_if_index);
8825 mp->sub_id = ntohl (sub_id);
8827 #define _(a) mp->a = a;
8828 foreach_create_subif_bit;
8831 mp->outer_vlan_id = ntohs (outer_vlan_id);
8832 mp->inner_vlan_id = ntohs (inner_vlan_id);
8840 api_oam_add_del (vat_main_t * vam)
8842 unformat_input_t *i = vam->input;
8843 vl_api_oam_add_del_t *mp;
8846 ip4_address_t src, dst;
8851 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8853 if (unformat (i, "vrf %d", &vrf_id))
8855 else if (unformat (i, "src %U", unformat_ip4_address, &src))
8857 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
8859 else if (unformat (i, "del"))
8863 clib_warning ("parse error '%U'", format_unformat_error, i);
8870 errmsg ("missing src addr");
8876 errmsg ("missing dst addr");
8880 M (OAM_ADD_DEL, mp);
8882 mp->vrf_id = ntohl (vrf_id);
8883 mp->is_add = is_add;
8884 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
8885 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
8893 api_reset_fib (vat_main_t * vam)
8895 unformat_input_t *i = vam->input;
8896 vl_api_reset_fib_t *mp;
8902 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8904 if (unformat (i, "vrf %d", &vrf_id))
8906 else if (unformat (i, "ipv6"))
8910 clib_warning ("parse error '%U'", format_unformat_error, i);
8915 if (vrf_id_set == 0)
8917 errmsg ("missing vrf id");
8923 mp->vrf_id = ntohl (vrf_id);
8924 mp->is_ipv6 = is_ipv6;
8932 api_dhcp_proxy_config (vat_main_t * vam)
8934 unformat_input_t *i = vam->input;
8935 vl_api_dhcp_proxy_config_t *mp;
8937 u32 server_vrf_id = 0;
8939 u8 v4_address_set = 0;
8940 u8 v6_address_set = 0;
8941 ip4_address_t v4address;
8942 ip6_address_t v6address;
8943 u8 v4_src_address_set = 0;
8944 u8 v6_src_address_set = 0;
8945 ip4_address_t v4srcaddress;
8946 ip6_address_t v6srcaddress;
8949 /* Parse args required to build the message */
8950 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8952 if (unformat (i, "del"))
8954 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
8956 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
8958 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
8960 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
8962 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
8963 v4_src_address_set = 1;
8964 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
8965 v6_src_address_set = 1;
8970 if (v4_address_set && v6_address_set)
8972 errmsg ("both v4 and v6 server addresses set");
8975 if (!v4_address_set && !v6_address_set)
8977 errmsg ("no server addresses set");
8981 if (v4_src_address_set && v6_src_address_set)
8983 errmsg ("both v4 and v6 src addresses set");
8986 if (!v4_src_address_set && !v6_src_address_set)
8988 errmsg ("no src addresses set");
8992 if (!(v4_src_address_set && v4_address_set) &&
8993 !(v6_src_address_set && v6_address_set))
8995 errmsg ("no matching server and src addresses set");
8999 /* Construct the API message */
9000 M (DHCP_PROXY_CONFIG, mp);
9002 mp->is_add = is_add;
9003 mp->rx_vrf_id = ntohl (rx_vrf_id);
9004 mp->server_vrf_id = ntohl (server_vrf_id);
9008 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9009 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9013 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9014 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9020 /* Wait for a reply, return good/bad news */
9025 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9026 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9029 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9031 vat_main_t *vam = &vat_main;
9032 u32 i, count = mp->count;
9033 vl_api_dhcp_server_t *s;
9037 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
9038 ntohl (mp->rx_vrf_id),
9039 format_ip6_address, mp->dhcp_src_address,
9040 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9043 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
9044 ntohl (mp->rx_vrf_id),
9045 format_ip4_address, mp->dhcp_src_address,
9046 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9048 for (i = 0; i < count; i++)
9050 s = &mp->servers[i];
9054 " Server Table-ID %d, Server Address %U",
9055 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9058 " Server Table-ID %d, Server Address %U",
9059 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9063 static void vl_api_dhcp_proxy_details_t_handler_json
9064 (vl_api_dhcp_proxy_details_t * mp)
9066 vat_main_t *vam = &vat_main;
9067 vat_json_node_t *node = NULL;
9068 u32 i, count = mp->count;
9070 struct in6_addr ip6;
9071 vl_api_dhcp_server_t *s;
9073 if (VAT_JSON_ARRAY != vam->json_tree.type)
9075 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9076 vat_json_init_array (&vam->json_tree);
9078 node = vat_json_array_add (&vam->json_tree);
9080 vat_json_init_object (node);
9081 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9082 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9083 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9087 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9088 vat_json_object_add_ip6 (node, "src_address", ip6);
9092 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9093 vat_json_object_add_ip4 (node, "src_address", ip4);
9096 for (i = 0; i < count; i++)
9098 s = &mp->servers[i];
9100 vat_json_object_add_uint (node, "server-table-id",
9101 ntohl (s->server_vrf_id));
9105 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9106 vat_json_object_add_ip4 (node, "src_address", ip4);
9110 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9111 vat_json_object_add_ip6 (node, "server_address", ip6);
9117 api_dhcp_proxy_dump (vat_main_t * vam)
9119 unformat_input_t *i = vam->input;
9120 vl_api_control_ping_t *mp_ping;
9121 vl_api_dhcp_proxy_dump_t *mp;
9125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9127 if (unformat (i, "ipv6"))
9131 clib_warning ("parse error '%U'", format_unformat_error, i);
9136 M (DHCP_PROXY_DUMP, mp);
9138 mp->is_ip6 = is_ipv6;
9141 /* Use a control ping for synchronization */
9142 MPING (CONTROL_PING, mp_ping);
9150 api_dhcp_proxy_set_vss (vat_main_t * vam)
9152 unformat_input_t *i = vam->input;
9153 vl_api_dhcp_proxy_set_vss_t *mp;
9164 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9166 if (unformat (i, "tbl_id %d", &tbl_id))
9168 if (unformat (i, "fib_id %d", &fib_id))
9170 if (unformat (i, "oui %d", &oui))
9172 else if (unformat (i, "ipv6"))
9174 else if (unformat (i, "del"))
9178 clib_warning ("parse error '%U'", format_unformat_error, i);
9183 if (tbl_id_set == 0)
9185 errmsg ("missing tbl id");
9189 if (fib_id_set == 0)
9191 errmsg ("missing fib id");
9196 errmsg ("missing oui");
9200 M (DHCP_PROXY_SET_VSS, mp);
9201 mp->tbl_id = ntohl (tbl_id);
9202 mp->fib_id = ntohl (fib_id);
9203 mp->oui = ntohl (oui);
9204 mp->is_ipv6 = is_ipv6;
9205 mp->is_add = is_add;
9213 api_dhcp_client_config (vat_main_t * vam)
9215 unformat_input_t *i = vam->input;
9216 vl_api_dhcp_client_config_t *mp;
9218 u8 sw_if_index_set = 0;
9221 u8 disable_event = 0;
9224 /* Parse args required to build the message */
9225 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9227 if (unformat (i, "del"))
9230 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9231 sw_if_index_set = 1;
9232 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9233 sw_if_index_set = 1;
9234 else if (unformat (i, "hostname %s", &hostname))
9236 else if (unformat (i, "disable_event"))
9242 if (sw_if_index_set == 0)
9244 errmsg ("missing interface name or sw_if_index");
9248 if (vec_len (hostname) > 63)
9250 errmsg ("hostname too long");
9252 vec_add1 (hostname, 0);
9254 /* Construct the API message */
9255 M (DHCP_CLIENT_CONFIG, mp);
9257 mp->sw_if_index = htonl (sw_if_index);
9258 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
9259 vec_free (hostname);
9260 mp->is_add = is_add;
9261 mp->want_dhcp_event = disable_event ? 0 : 1;
9262 mp->pid = htonl (getpid ());
9267 /* Wait for a reply, return good/bad news */
9273 api_set_ip_flow_hash (vat_main_t * vam)
9275 unformat_input_t *i = vam->input;
9276 vl_api_set_ip_flow_hash_t *mp;
9288 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9290 if (unformat (i, "vrf %d", &vrf_id))
9292 else if (unformat (i, "ipv6"))
9294 else if (unformat (i, "src"))
9296 else if (unformat (i, "dst"))
9298 else if (unformat (i, "sport"))
9300 else if (unformat (i, "dport"))
9302 else if (unformat (i, "proto"))
9304 else if (unformat (i, "reverse"))
9309 clib_warning ("parse error '%U'", format_unformat_error, i);
9314 if (vrf_id_set == 0)
9316 errmsg ("missing vrf id");
9320 M (SET_IP_FLOW_HASH, mp);
9326 mp->reverse = reverse;
9327 mp->vrf_id = ntohl (vrf_id);
9328 mp->is_ipv6 = is_ipv6;
9336 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9338 unformat_input_t *i = vam->input;
9339 vl_api_sw_interface_ip6_enable_disable_t *mp;
9341 u8 sw_if_index_set = 0;
9345 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9347 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9348 sw_if_index_set = 1;
9349 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9350 sw_if_index_set = 1;
9351 else if (unformat (i, "enable"))
9353 else if (unformat (i, "disable"))
9357 clib_warning ("parse error '%U'", format_unformat_error, i);
9362 if (sw_if_index_set == 0)
9364 errmsg ("missing interface name or sw_if_index");
9368 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9370 mp->sw_if_index = ntohl (sw_if_index);
9371 mp->enable = enable;
9379 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
9381 unformat_input_t *i = vam->input;
9382 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
9384 u8 sw_if_index_set = 0;
9385 u8 v6_address_set = 0;
9386 ip6_address_t v6address;
9389 /* Parse args required to build the message */
9390 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9392 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9393 sw_if_index_set = 1;
9394 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9395 sw_if_index_set = 1;
9396 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9402 if (sw_if_index_set == 0)
9404 errmsg ("missing interface name or sw_if_index");
9407 if (!v6_address_set)
9409 errmsg ("no address set");
9413 /* Construct the API message */
9414 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
9416 mp->sw_if_index = ntohl (sw_if_index);
9417 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9422 /* Wait for a reply, return good/bad news */
9428 api_ip6nd_proxy_add_del (vat_main_t * vam)
9430 unformat_input_t *i = vam->input;
9431 vl_api_ip6nd_proxy_add_del_t *mp;
9432 u32 sw_if_index = ~0;
9433 u8 v6_address_set = 0;
9434 ip6_address_t v6address;
9438 /* Parse args required to build the message */
9439 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9441 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9443 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9445 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9447 if (unformat (i, "del"))
9451 clib_warning ("parse error '%U'", format_unformat_error, i);
9456 if (sw_if_index == ~0)
9458 errmsg ("missing interface name or sw_if_index");
9461 if (!v6_address_set)
9463 errmsg ("no address set");
9467 /* Construct the API message */
9468 M (IP6ND_PROXY_ADD_DEL, mp);
9470 mp->is_del = is_del;
9471 mp->sw_if_index = ntohl (sw_if_index);
9472 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9477 /* Wait for a reply, return good/bad news */
9483 api_ip6nd_proxy_dump (vat_main_t * vam)
9485 vl_api_ip6nd_proxy_dump_t *mp;
9486 vl_api_control_ping_t *mp_ping;
9489 M (IP6ND_PROXY_DUMP, mp);
9493 /* Use a control ping for synchronization */
9494 MPING (CONTROL_PING, mp_ping);
9501 static void vl_api_ip6nd_proxy_details_t_handler
9502 (vl_api_ip6nd_proxy_details_t * mp)
9504 vat_main_t *vam = &vat_main;
9506 print (vam->ofp, "host %U sw_if_index %d",
9507 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
9510 static void vl_api_ip6nd_proxy_details_t_handler_json
9511 (vl_api_ip6nd_proxy_details_t * mp)
9513 vat_main_t *vam = &vat_main;
9514 struct in6_addr ip6;
9515 vat_json_node_t *node = NULL;
9517 if (VAT_JSON_ARRAY != vam->json_tree.type)
9519 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9520 vat_json_init_array (&vam->json_tree);
9522 node = vat_json_array_add (&vam->json_tree);
9524 vat_json_init_object (node);
9525 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9527 clib_memcpy (&ip6, mp->address, sizeof (ip6));
9528 vat_json_object_add_ip6 (node, "host", ip6);
9532 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9534 unformat_input_t *i = vam->input;
9535 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9537 u8 sw_if_index_set = 0;
9538 u32 address_length = 0;
9539 u8 v6_address_set = 0;
9540 ip6_address_t v6address;
9542 u8 no_advertise = 0;
9544 u8 no_autoconfig = 0;
9547 u32 val_lifetime = 0;
9548 u32 pref_lifetime = 0;
9551 /* Parse args required to build the message */
9552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9554 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9555 sw_if_index_set = 1;
9556 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9557 sw_if_index_set = 1;
9558 else if (unformat (i, "%U/%d",
9559 unformat_ip6_address, &v6address, &address_length))
9561 else if (unformat (i, "val_life %d", &val_lifetime))
9563 else if (unformat (i, "pref_life %d", &pref_lifetime))
9565 else if (unformat (i, "def"))
9567 else if (unformat (i, "noadv"))
9569 else if (unformat (i, "offl"))
9571 else if (unformat (i, "noauto"))
9573 else if (unformat (i, "nolink"))
9575 else if (unformat (i, "isno"))
9579 clib_warning ("parse error '%U'", format_unformat_error, i);
9584 if (sw_if_index_set == 0)
9586 errmsg ("missing interface name or sw_if_index");
9589 if (!v6_address_set)
9591 errmsg ("no address set");
9595 /* Construct the API message */
9596 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9598 mp->sw_if_index = ntohl (sw_if_index);
9599 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9600 mp->address_length = address_length;
9601 mp->use_default = use_default;
9602 mp->no_advertise = no_advertise;
9603 mp->off_link = off_link;
9604 mp->no_autoconfig = no_autoconfig;
9605 mp->no_onlink = no_onlink;
9607 mp->val_lifetime = ntohl (val_lifetime);
9608 mp->pref_lifetime = ntohl (pref_lifetime);
9613 /* Wait for a reply, return good/bad news */
9619 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9621 unformat_input_t *i = vam->input;
9622 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9624 u8 sw_if_index_set = 0;
9629 u8 send_unicast = 0;
9632 u8 default_router = 0;
9633 u32 max_interval = 0;
9634 u32 min_interval = 0;
9636 u32 initial_count = 0;
9637 u32 initial_interval = 0;
9641 /* Parse args required to build the message */
9642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9644 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9645 sw_if_index_set = 1;
9646 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9647 sw_if_index_set = 1;
9648 else if (unformat (i, "maxint %d", &max_interval))
9650 else if (unformat (i, "minint %d", &min_interval))
9652 else if (unformat (i, "life %d", &lifetime))
9654 else if (unformat (i, "count %d", &initial_count))
9656 else if (unformat (i, "interval %d", &initial_interval))
9658 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9660 else if (unformat (i, "managed"))
9662 else if (unformat (i, "other"))
9664 else if (unformat (i, "ll"))
9666 else if (unformat (i, "send"))
9668 else if (unformat (i, "cease"))
9670 else if (unformat (i, "isno"))
9672 else if (unformat (i, "def"))
9676 clib_warning ("parse error '%U'", format_unformat_error, i);
9681 if (sw_if_index_set == 0)
9683 errmsg ("missing interface name or sw_if_index");
9687 /* Construct the API message */
9688 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9690 mp->sw_if_index = ntohl (sw_if_index);
9691 mp->max_interval = ntohl (max_interval);
9692 mp->min_interval = ntohl (min_interval);
9693 mp->lifetime = ntohl (lifetime);
9694 mp->initial_count = ntohl (initial_count);
9695 mp->initial_interval = ntohl (initial_interval);
9696 mp->suppress = suppress;
9697 mp->managed = managed;
9699 mp->ll_option = ll_option;
9700 mp->send_unicast = send_unicast;
9703 mp->default_router = default_router;
9708 /* Wait for a reply, return good/bad news */
9714 api_set_arp_neighbor_limit (vat_main_t * vam)
9716 unformat_input_t *i = vam->input;
9717 vl_api_set_arp_neighbor_limit_t *mp;
9723 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9725 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9727 else if (unformat (i, "ipv6"))
9731 clib_warning ("parse error '%U'", format_unformat_error, i);
9738 errmsg ("missing limit value");
9742 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9744 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9745 mp->is_ipv6 = is_ipv6;
9753 api_l2_patch_add_del (vat_main_t * vam)
9755 unformat_input_t *i = vam->input;
9756 vl_api_l2_patch_add_del_t *mp;
9758 u8 rx_sw_if_index_set = 0;
9760 u8 tx_sw_if_index_set = 0;
9764 /* Parse args required to build the message */
9765 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9767 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9768 rx_sw_if_index_set = 1;
9769 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9770 tx_sw_if_index_set = 1;
9771 else if (unformat (i, "rx"))
9773 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9775 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9777 rx_sw_if_index_set = 1;
9782 else if (unformat (i, "tx"))
9784 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9786 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9788 tx_sw_if_index_set = 1;
9793 else if (unformat (i, "del"))
9799 if (rx_sw_if_index_set == 0)
9801 errmsg ("missing rx interface name or rx_sw_if_index");
9805 if (tx_sw_if_index_set == 0)
9807 errmsg ("missing tx interface name or tx_sw_if_index");
9811 M (L2_PATCH_ADD_DEL, mp);
9813 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9814 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9815 mp->is_add = is_add;
9823 u8 localsid_addr[16];
9832 api_sr_localsid_add_del (vat_main_t * vam)
9834 unformat_input_t *i = vam->input;
9835 vl_api_sr_localsid_add_del_t *mp;
9838 ip6_address_t localsid;
9842 u32 fib_table = ~(u32) 0;
9843 ip6_address_t next_hop;
9845 bool nexthop_set = 0;
9849 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9851 if (unformat (i, "del"))
9853 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9854 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
9856 else if (unformat (i, "behavior %u", &behavior));
9857 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9858 else if (unformat (i, "fib-table %u", &fib_table));
9859 else if (unformat (i, "end.psp %u", &behavior));
9864 M (SR_LOCALSID_ADD_DEL, mp);
9866 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
9868 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
9869 mp->behavior = behavior;
9870 mp->sw_if_index = ntohl (sw_if_index);
9871 mp->fib_table = ntohl (fib_table);
9872 mp->end_psp = end_psp;
9873 mp->is_del = is_del;
9881 api_ioam_enable (vat_main_t * vam)
9883 unformat_input_t *input = vam->input;
9884 vl_api_ioam_enable_t *mp;
9886 int has_trace_option = 0;
9887 int has_pot_option = 0;
9888 int has_seqno_option = 0;
9889 int has_analyse_option = 0;
9892 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9894 if (unformat (input, "trace"))
9895 has_trace_option = 1;
9896 else if (unformat (input, "pot"))
9898 else if (unformat (input, "seqno"))
9899 has_seqno_option = 1;
9900 else if (unformat (input, "analyse"))
9901 has_analyse_option = 1;
9905 M (IOAM_ENABLE, mp);
9906 mp->id = htons (id);
9907 mp->seqno = has_seqno_option;
9908 mp->analyse = has_analyse_option;
9909 mp->pot_enable = has_pot_option;
9910 mp->trace_enable = has_trace_option;
9919 api_ioam_disable (vat_main_t * vam)
9921 vl_api_ioam_disable_t *mp;
9924 M (IOAM_DISABLE, mp);
9930 #define foreach_tcp_proto_field \
9934 #define foreach_udp_proto_field \
9938 #define foreach_ip4_proto_field \
9950 u16 src_port, dst_port;
9953 #if VPP_API_TEST_BUILTIN == 0
9955 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9957 u8 **maskp = va_arg (*args, u8 **);
9959 u8 found_something = 0;
9962 #define _(a) u8 a=0;
9963 foreach_tcp_proto_field;
9966 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9969 #define _(a) else if (unformat (input, #a)) a=1;
9970 foreach_tcp_proto_field
9976 #define _(a) found_something += a;
9977 foreach_tcp_proto_field;
9980 if (found_something == 0)
9983 vec_validate (mask, sizeof (*tcp) - 1);
9985 tcp = (tcp_header_t *) mask;
9987 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
9988 foreach_tcp_proto_field;
9996 unformat_udp_mask (unformat_input_t * input, va_list * args)
9998 u8 **maskp = va_arg (*args, u8 **);
10000 u8 found_something = 0;
10003 #define _(a) u8 a=0;
10004 foreach_udp_proto_field;
10007 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10010 #define _(a) else if (unformat (input, #a)) a=1;
10011 foreach_udp_proto_field
10017 #define _(a) found_something += a;
10018 foreach_udp_proto_field;
10021 if (found_something == 0)
10024 vec_validate (mask, sizeof (*udp) - 1);
10026 udp = (udp_header_t *) mask;
10028 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
10029 foreach_udp_proto_field;
10037 unformat_l4_mask (unformat_input_t * input, va_list * args)
10039 u8 **maskp = va_arg (*args, u8 **);
10040 u16 src_port = 0, dst_port = 0;
10041 tcpudp_header_t *tcpudp;
10043 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10045 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10047 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10049 else if (unformat (input, "src_port"))
10051 else if (unformat (input, "dst_port"))
10057 if (!src_port && !dst_port)
10061 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10063 tcpudp = (tcpudp_header_t *) mask;
10064 tcpudp->src_port = src_port;
10065 tcpudp->dst_port = dst_port;
10073 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10075 u8 **maskp = va_arg (*args, u8 **);
10077 u8 found_something = 0;
10080 #define _(a) u8 a=0;
10081 foreach_ip4_proto_field;
10087 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10089 if (unformat (input, "version"))
10091 else if (unformat (input, "hdr_length"))
10093 else if (unformat (input, "src"))
10095 else if (unformat (input, "dst"))
10097 else if (unformat (input, "proto"))
10100 #define _(a) else if (unformat (input, #a)) a=1;
10101 foreach_ip4_proto_field
10107 #define _(a) found_something += a;
10108 foreach_ip4_proto_field;
10111 if (found_something == 0)
10114 vec_validate (mask, sizeof (*ip) - 1);
10116 ip = (ip4_header_t *) mask;
10118 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10119 foreach_ip4_proto_field;
10122 ip->ip_version_and_header_length = 0;
10125 ip->ip_version_and_header_length |= 0xF0;
10128 ip->ip_version_and_header_length |= 0x0F;
10134 #define foreach_ip6_proto_field \
10137 _(payload_length) \
10142 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10144 u8 **maskp = va_arg (*args, u8 **);
10146 u8 found_something = 0;
10148 u32 ip_version_traffic_class_and_flow_label;
10150 #define _(a) u8 a=0;
10151 foreach_ip6_proto_field;
10154 u8 traffic_class = 0;
10157 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10159 if (unformat (input, "version"))
10161 else if (unformat (input, "traffic-class"))
10163 else if (unformat (input, "flow-label"))
10165 else if (unformat (input, "src"))
10167 else if (unformat (input, "dst"))
10169 else if (unformat (input, "proto"))
10172 #define _(a) else if (unformat (input, #a)) a=1;
10173 foreach_ip6_proto_field
10179 #define _(a) found_something += a;
10180 foreach_ip6_proto_field;
10183 if (found_something == 0)
10186 vec_validate (mask, sizeof (*ip) - 1);
10188 ip = (ip6_header_t *) mask;
10190 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10191 foreach_ip6_proto_field;
10194 ip_version_traffic_class_and_flow_label = 0;
10197 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10200 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10203 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10205 ip->ip_version_traffic_class_and_flow_label =
10206 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10213 unformat_l3_mask (unformat_input_t * input, va_list * args)
10215 u8 **maskp = va_arg (*args, u8 **);
10217 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10219 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10221 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10230 unformat_l2_mask (unformat_input_t * input, va_list * args)
10232 u8 **maskp = va_arg (*args, u8 **);
10239 u8 ignore_tag1 = 0;
10240 u8 ignore_tag2 = 0;
10247 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10249 if (unformat (input, "src"))
10251 else if (unformat (input, "dst"))
10253 else if (unformat (input, "proto"))
10255 else if (unformat (input, "tag1"))
10257 else if (unformat (input, "tag2"))
10259 else if (unformat (input, "ignore-tag1"))
10261 else if (unformat (input, "ignore-tag2"))
10263 else if (unformat (input, "cos1"))
10265 else if (unformat (input, "cos2"))
10267 else if (unformat (input, "dot1q"))
10269 else if (unformat (input, "dot1ad"))
10274 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10275 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10278 if (tag1 || ignore_tag1 || cos1 || dot1q)
10280 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10283 vec_validate (mask, len - 1);
10286 memset (mask, 0xff, 6);
10289 memset (mask + 6, 0xff, 6);
10291 if (tag2 || dot1ad)
10293 /* inner vlan tag */
10302 mask[21] = mask[20] = 0xff;
10323 mask[16] = mask[17] = 0xff;
10333 mask[12] = mask[13] = 0xff;
10340 unformat_classify_mask (unformat_input_t * input, va_list * args)
10342 u8 **maskp = va_arg (*args, u8 **);
10343 u32 *skipp = va_arg (*args, u32 *);
10344 u32 *matchp = va_arg (*args, u32 *);
10352 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10354 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10356 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10358 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10360 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10374 if (mask || l2 || l3 || l4)
10376 if (l2 || l3 || l4)
10378 /* "With a free Ethernet header in every package" */
10380 vec_validate (l2, 13);
10384 vec_append (mask, l3);
10389 vec_append (mask, l4);
10394 /* Scan forward looking for the first significant mask octet */
10395 for (i = 0; i < vec_len (mask); i++)
10399 /* compute (skip, match) params */
10400 *skipp = i / sizeof (u32x4);
10401 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10403 /* Pad mask to an even multiple of the vector size */
10404 while (vec_len (mask) % sizeof (u32x4))
10405 vec_add1 (mask, 0);
10407 match = vec_len (mask) / sizeof (u32x4);
10409 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10411 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10412 if (*tmp || *(tmp + 1))
10417 clib_warning ("BUG: match 0");
10419 _vec_len (mask) = match * sizeof (u32x4);
10429 #endif /* VPP_API_TEST_BUILTIN */
10431 #define foreach_l2_next \
10433 _(ethernet, ETHERNET_INPUT) \
10434 _(ip4, IP4_INPUT) \
10438 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10440 u32 *miss_next_indexp = va_arg (*args, u32 *);
10441 u32 next_index = 0;
10445 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10449 if (unformat (input, "%d", &tmp))
10458 *miss_next_indexp = next_index;
10462 #define foreach_ip_next \
10465 _(rewrite, REWRITE)
10468 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10470 u32 *miss_next_indexp = va_arg (*args, u32 *);
10471 u32 next_index = 0;
10475 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10479 if (unformat (input, "%d", &tmp))
10488 *miss_next_indexp = next_index;
10492 #define foreach_acl_next \
10496 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10498 u32 *miss_next_indexp = va_arg (*args, u32 *);
10499 u32 next_index = 0;
10503 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10507 if (unformat (input, "permit"))
10512 else if (unformat (input, "%d", &tmp))
10521 *miss_next_indexp = next_index;
10526 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10528 u32 *r = va_arg (*args, u32 *);
10530 if (unformat (input, "conform-color"))
10531 *r = POLICE_CONFORM;
10532 else if (unformat (input, "exceed-color"))
10533 *r = POLICE_EXCEED;
10541 api_classify_add_del_table (vat_main_t * vam)
10543 unformat_input_t *i = vam->input;
10544 vl_api_classify_add_del_table_t *mp;
10551 u32 table_index = ~0;
10552 u32 next_table_index = ~0;
10553 u32 miss_next_index = ~0;
10554 u32 memory_size = 32 << 20;
10556 u32 current_data_flag = 0;
10557 int current_data_offset = 0;
10560 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10562 if (unformat (i, "del"))
10564 else if (unformat (i, "del-chain"))
10569 else if (unformat (i, "buckets %d", &nbuckets))
10571 else if (unformat (i, "memory_size %d", &memory_size))
10573 else if (unformat (i, "skip %d", &skip))
10575 else if (unformat (i, "match %d", &match))
10577 else if (unformat (i, "table %d", &table_index))
10579 else if (unformat (i, "mask %U", unformat_classify_mask,
10580 &mask, &skip, &match))
10582 else if (unformat (i, "next-table %d", &next_table_index))
10584 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10587 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10590 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10593 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10595 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10601 if (is_add && mask == 0)
10603 errmsg ("Mask required");
10607 if (is_add && skip == ~0)
10609 errmsg ("skip count required");
10613 if (is_add && match == ~0)
10615 errmsg ("match count required");
10619 if (!is_add && table_index == ~0)
10621 errmsg ("table index required for delete");
10625 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10627 mp->is_add = is_add;
10628 mp->del_chain = del_chain;
10629 mp->table_index = ntohl (table_index);
10630 mp->nbuckets = ntohl (nbuckets);
10631 mp->memory_size = ntohl (memory_size);
10632 mp->skip_n_vectors = ntohl (skip);
10633 mp->match_n_vectors = ntohl (match);
10634 mp->next_table_index = ntohl (next_table_index);
10635 mp->miss_next_index = ntohl (miss_next_index);
10636 mp->current_data_flag = ntohl (current_data_flag);
10637 mp->current_data_offset = ntohl (current_data_offset);
10638 clib_memcpy (mp->mask, mask, vec_len (mask));
10647 #if VPP_API_TEST_BUILTIN == 0
10649 unformat_l4_match (unformat_input_t * input, va_list * args)
10651 u8 **matchp = va_arg (*args, u8 **);
10653 u8 *proto_header = 0;
10659 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10661 if (unformat (input, "src_port %d", &src_port))
10663 else if (unformat (input, "dst_port %d", &dst_port))
10669 h.src_port = clib_host_to_net_u16 (src_port);
10670 h.dst_port = clib_host_to_net_u16 (dst_port);
10671 vec_validate (proto_header, sizeof (h) - 1);
10672 memcpy (proto_header, &h, sizeof (h));
10674 *matchp = proto_header;
10680 unformat_ip4_match (unformat_input_t * input, va_list * args)
10682 u8 **matchp = va_arg (*args, u8 **);
10687 int hdr_length = 0;
10688 u32 hdr_length_val;
10689 int src = 0, dst = 0;
10690 ip4_address_t src_val, dst_val;
10697 int fragment_id = 0;
10698 u32 fragment_id_val;
10704 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10706 if (unformat (input, "version %d", &version_val))
10708 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10710 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10712 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10714 else if (unformat (input, "proto %d", &proto_val))
10716 else if (unformat (input, "tos %d", &tos_val))
10718 else if (unformat (input, "length %d", &length_val))
10720 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10722 else if (unformat (input, "ttl %d", &ttl_val))
10724 else if (unformat (input, "checksum %d", &checksum_val))
10730 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10731 + ttl + checksum == 0)
10735 * Aligned because we use the real comparison functions
10737 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10739 ip = (ip4_header_t *) match;
10741 /* These are realistically matched in practice */
10743 ip->src_address.as_u32 = src_val.as_u32;
10746 ip->dst_address.as_u32 = dst_val.as_u32;
10749 ip->protocol = proto_val;
10752 /* These are not, but they're included for completeness */
10754 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10757 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10763 ip->length = clib_host_to_net_u16 (length_val);
10769 ip->checksum = clib_host_to_net_u16 (checksum_val);
10776 unformat_ip6_match (unformat_input_t * input, va_list * args)
10778 u8 **matchp = va_arg (*args, u8 **);
10783 u8 traffic_class = 0;
10784 u32 traffic_class_val = 0;
10787 int src = 0, dst = 0;
10788 ip6_address_t src_val, dst_val;
10791 int payload_length = 0;
10792 u32 payload_length_val;
10795 u32 ip_version_traffic_class_and_flow_label;
10797 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10799 if (unformat (input, "version %d", &version_val))
10801 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10803 else if (unformat (input, "flow_label %d", &flow_label_val))
10805 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10807 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10809 else if (unformat (input, "proto %d", &proto_val))
10811 else if (unformat (input, "payload_length %d", &payload_length_val))
10812 payload_length = 1;
10813 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10819 if (version + traffic_class + flow_label + src + dst + proto +
10820 payload_length + hop_limit == 0)
10824 * Aligned because we use the real comparison functions
10826 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10828 ip = (ip6_header_t *) match;
10831 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10834 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10837 ip->protocol = proto_val;
10839 ip_version_traffic_class_and_flow_label = 0;
10842 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10845 ip_version_traffic_class_and_flow_label |=
10846 (traffic_class_val & 0xFF) << 20;
10849 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10851 ip->ip_version_traffic_class_and_flow_label =
10852 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10854 if (payload_length)
10855 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10858 ip->hop_limit = hop_limit_val;
10865 unformat_l3_match (unformat_input_t * input, va_list * args)
10867 u8 **matchp = va_arg (*args, u8 **);
10869 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10871 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10873 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10882 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10884 u8 *tagp = va_arg (*args, u8 *);
10887 if (unformat (input, "%d", &tag))
10889 tagp[0] = (tag >> 8) & 0x0F;
10890 tagp[1] = tag & 0xFF;
10898 unformat_l2_match (unformat_input_t * input, va_list * args)
10900 u8 **matchp = va_arg (*args, u8 **);
10913 u8 ignore_tag1 = 0;
10914 u8 ignore_tag2 = 0;
10920 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10922 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10925 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10927 else if (unformat (input, "proto %U",
10928 unformat_ethernet_type_host_byte_order, &proto_val))
10930 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10932 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10934 else if (unformat (input, "ignore-tag1"))
10936 else if (unformat (input, "ignore-tag2"))
10938 else if (unformat (input, "cos1 %d", &cos1_val))
10940 else if (unformat (input, "cos2 %d", &cos2_val))
10945 if ((src + dst + proto + tag1 + tag2 +
10946 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10949 if (tag1 || ignore_tag1 || cos1)
10951 if (tag2 || ignore_tag2 || cos2)
10954 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10957 clib_memcpy (match, dst_val, 6);
10960 clib_memcpy (match + 6, src_val, 6);
10964 /* inner vlan tag */
10965 match[19] = tag2_val[1];
10966 match[18] = tag2_val[0];
10968 match[18] |= (cos2_val & 0x7) << 5;
10971 match[21] = proto_val & 0xff;
10972 match[20] = proto_val >> 8;
10976 match[15] = tag1_val[1];
10977 match[14] = tag1_val[0];
10980 match[14] |= (cos1_val & 0x7) << 5;
10986 match[15] = tag1_val[1];
10987 match[14] = tag1_val[0];
10990 match[17] = proto_val & 0xff;
10991 match[16] = proto_val >> 8;
10994 match[14] |= (cos1_val & 0x7) << 5;
11000 match[18] |= (cos2_val & 0x7) << 5;
11002 match[14] |= (cos1_val & 0x7) << 5;
11005 match[13] = proto_val & 0xff;
11006 match[12] = proto_val >> 8;
11015 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11017 u8 **matchp = va_arg (*args, u8 **);
11018 u32 skip_n_vectors = va_arg (*args, u32);
11019 u32 match_n_vectors = va_arg (*args, u32);
11026 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11028 if (unformat (input, "hex %U", unformat_hex_string, &match))
11030 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11032 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11034 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11048 if (match || l2 || l3 || l4)
11050 if (l2 || l3 || l4)
11052 /* "Win a free Ethernet header in every packet" */
11054 vec_validate_aligned (l2, 13, sizeof (u32x4));
11058 vec_append_aligned (match, l3, sizeof (u32x4));
11063 vec_append_aligned (match, l4, sizeof (u32x4));
11068 /* Make sure the vector is big enough even if key is all 0's */
11069 vec_validate_aligned
11070 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11073 /* Set size, include skipped vectors */
11074 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11085 api_classify_add_del_session (vat_main_t * vam)
11087 unformat_input_t *i = vam->input;
11088 vl_api_classify_add_del_session_t *mp;
11090 u32 table_index = ~0;
11091 u32 hit_next_index = ~0;
11092 u32 opaque_index = ~0;
11095 u32 skip_n_vectors = 0;
11096 u32 match_n_vectors = 0;
11102 * Warning: you have to supply skip_n and match_n
11103 * because the API client cant simply look at the classify
11107 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11109 if (unformat (i, "del"))
11111 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11114 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11117 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11120 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11122 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11124 else if (unformat (i, "opaque-index %d", &opaque_index))
11126 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11128 else if (unformat (i, "match_n %d", &match_n_vectors))
11130 else if (unformat (i, "match %U", api_unformat_classify_match,
11131 &match, skip_n_vectors, match_n_vectors))
11133 else if (unformat (i, "advance %d", &advance))
11135 else if (unformat (i, "table-index %d", &table_index))
11137 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11139 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11141 else if (unformat (i, "action %d", &action))
11143 else if (unformat (i, "metadata %d", &metadata))
11149 if (table_index == ~0)
11151 errmsg ("Table index required");
11155 if (is_add && match == 0)
11157 errmsg ("Match value required");
11161 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11163 mp->is_add = is_add;
11164 mp->table_index = ntohl (table_index);
11165 mp->hit_next_index = ntohl (hit_next_index);
11166 mp->opaque_index = ntohl (opaque_index);
11167 mp->advance = ntohl (advance);
11168 mp->action = action;
11169 mp->metadata = ntohl (metadata);
11170 clib_memcpy (mp->match, match, vec_len (match));
11179 api_classify_set_interface_ip_table (vat_main_t * vam)
11181 unformat_input_t *i = vam->input;
11182 vl_api_classify_set_interface_ip_table_t *mp;
11184 int sw_if_index_set;
11185 u32 table_index = ~0;
11189 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11191 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11192 sw_if_index_set = 1;
11193 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11194 sw_if_index_set = 1;
11195 else if (unformat (i, "table %d", &table_index))
11199 clib_warning ("parse error '%U'", format_unformat_error, i);
11204 if (sw_if_index_set == 0)
11206 errmsg ("missing interface name or sw_if_index");
11211 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11213 mp->sw_if_index = ntohl (sw_if_index);
11214 mp->table_index = ntohl (table_index);
11215 mp->is_ipv6 = is_ipv6;
11223 api_classify_set_interface_l2_tables (vat_main_t * vam)
11225 unformat_input_t *i = vam->input;
11226 vl_api_classify_set_interface_l2_tables_t *mp;
11228 int sw_if_index_set;
11229 u32 ip4_table_index = ~0;
11230 u32 ip6_table_index = ~0;
11231 u32 other_table_index = ~0;
11235 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11237 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11238 sw_if_index_set = 1;
11239 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11240 sw_if_index_set = 1;
11241 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11243 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11245 else if (unformat (i, "other-table %d", &other_table_index))
11247 else if (unformat (i, "is-input %d", &is_input))
11251 clib_warning ("parse error '%U'", format_unformat_error, i);
11256 if (sw_if_index_set == 0)
11258 errmsg ("missing interface name or sw_if_index");
11263 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11265 mp->sw_if_index = ntohl (sw_if_index);
11266 mp->ip4_table_index = ntohl (ip4_table_index);
11267 mp->ip6_table_index = ntohl (ip6_table_index);
11268 mp->other_table_index = ntohl (other_table_index);
11269 mp->is_input = (u8) is_input;
11277 api_set_ipfix_exporter (vat_main_t * vam)
11279 unformat_input_t *i = vam->input;
11280 vl_api_set_ipfix_exporter_t *mp;
11281 ip4_address_t collector_address;
11282 u8 collector_address_set = 0;
11283 u32 collector_port = ~0;
11284 ip4_address_t src_address;
11285 u8 src_address_set = 0;
11288 u32 template_interval = ~0;
11289 u8 udp_checksum = 0;
11292 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11294 if (unformat (i, "collector_address %U", unformat_ip4_address,
11295 &collector_address))
11296 collector_address_set = 1;
11297 else if (unformat (i, "collector_port %d", &collector_port))
11299 else if (unformat (i, "src_address %U", unformat_ip4_address,
11301 src_address_set = 1;
11302 else if (unformat (i, "vrf_id %d", &vrf_id))
11304 else if (unformat (i, "path_mtu %d", &path_mtu))
11306 else if (unformat (i, "template_interval %d", &template_interval))
11308 else if (unformat (i, "udp_checksum"))
11314 if (collector_address_set == 0)
11316 errmsg ("collector_address required");
11320 if (src_address_set == 0)
11322 errmsg ("src_address required");
11326 M (SET_IPFIX_EXPORTER, mp);
11328 memcpy (mp->collector_address, collector_address.data,
11329 sizeof (collector_address.data));
11330 mp->collector_port = htons ((u16) collector_port);
11331 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11332 mp->vrf_id = htonl (vrf_id);
11333 mp->path_mtu = htonl (path_mtu);
11334 mp->template_interval = htonl (template_interval);
11335 mp->udp_checksum = udp_checksum;
11343 api_set_ipfix_classify_stream (vat_main_t * vam)
11345 unformat_input_t *i = vam->input;
11346 vl_api_set_ipfix_classify_stream_t *mp;
11348 u32 src_port = UDP_DST_PORT_ipfix;
11351 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11353 if (unformat (i, "domain %d", &domain_id))
11355 else if (unformat (i, "src_port %d", &src_port))
11359 errmsg ("unknown input `%U'", format_unformat_error, i);
11364 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11366 mp->domain_id = htonl (domain_id);
11367 mp->src_port = htons ((u16) src_port);
11375 api_ipfix_classify_table_add_del (vat_main_t * vam)
11377 unformat_input_t *i = vam->input;
11378 vl_api_ipfix_classify_table_add_del_t *mp;
11380 u32 classify_table_index = ~0;
11382 u8 transport_protocol = 255;
11385 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11387 if (unformat (i, "add"))
11389 else if (unformat (i, "del"))
11391 else if (unformat (i, "table %d", &classify_table_index))
11393 else if (unformat (i, "ip4"))
11395 else if (unformat (i, "ip6"))
11397 else if (unformat (i, "tcp"))
11398 transport_protocol = 6;
11399 else if (unformat (i, "udp"))
11400 transport_protocol = 17;
11403 errmsg ("unknown input `%U'", format_unformat_error, i);
11410 errmsg ("expecting: add|del");
11413 if (classify_table_index == ~0)
11415 errmsg ("classifier table not specified");
11418 if (ip_version == 0)
11420 errmsg ("IP version not specified");
11424 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11426 mp->is_add = is_add;
11427 mp->table_id = htonl (classify_table_index);
11428 mp->ip_version = ip_version;
11429 mp->transport_protocol = transport_protocol;
11437 api_get_node_index (vat_main_t * vam)
11439 unformat_input_t *i = vam->input;
11440 vl_api_get_node_index_t *mp;
11444 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11446 if (unformat (i, "node %s", &name))
11453 errmsg ("node name required");
11456 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11458 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11462 M (GET_NODE_INDEX, mp);
11463 clib_memcpy (mp->node_name, name, vec_len (name));
11472 api_get_next_index (vat_main_t * vam)
11474 unformat_input_t *i = vam->input;
11475 vl_api_get_next_index_t *mp;
11476 u8 *node_name = 0, *next_node_name = 0;
11479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11481 if (unformat (i, "node-name %s", &node_name))
11483 else if (unformat (i, "next-node-name %s", &next_node_name))
11487 if (node_name == 0)
11489 errmsg ("node name required");
11492 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11494 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11498 if (next_node_name == 0)
11500 errmsg ("next node name required");
11503 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11505 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11509 M (GET_NEXT_INDEX, mp);
11510 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11511 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11512 vec_free (node_name);
11513 vec_free (next_node_name);
11521 api_add_node_next (vat_main_t * vam)
11523 unformat_input_t *i = vam->input;
11524 vl_api_add_node_next_t *mp;
11529 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11531 if (unformat (i, "node %s", &name))
11533 else if (unformat (i, "next %s", &next))
11540 errmsg ("node name required");
11543 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11545 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11550 errmsg ("next node required");
11553 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11555 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11559 M (ADD_NODE_NEXT, mp);
11560 clib_memcpy (mp->node_name, name, vec_len (name));
11561 clib_memcpy (mp->next_name, next, vec_len (next));
11571 api_l2tpv3_create_tunnel (vat_main_t * vam)
11573 unformat_input_t *i = vam->input;
11574 ip6_address_t client_address, our_address;
11575 int client_address_set = 0;
11576 int our_address_set = 0;
11577 u32 local_session_id = 0;
11578 u32 remote_session_id = 0;
11579 u64 local_cookie = 0;
11580 u64 remote_cookie = 0;
11581 u8 l2_sublayer_present = 0;
11582 vl_api_l2tpv3_create_tunnel_t *mp;
11585 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11587 if (unformat (i, "client_address %U", unformat_ip6_address,
11589 client_address_set = 1;
11590 else if (unformat (i, "our_address %U", unformat_ip6_address,
11592 our_address_set = 1;
11593 else if (unformat (i, "local_session_id %d", &local_session_id))
11595 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11597 else if (unformat (i, "local_cookie %lld", &local_cookie))
11599 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11601 else if (unformat (i, "l2-sublayer-present"))
11602 l2_sublayer_present = 1;
11607 if (client_address_set == 0)
11609 errmsg ("client_address required");
11613 if (our_address_set == 0)
11615 errmsg ("our_address required");
11619 M (L2TPV3_CREATE_TUNNEL, mp);
11621 clib_memcpy (mp->client_address, client_address.as_u8,
11622 sizeof (mp->client_address));
11624 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11626 mp->local_session_id = ntohl (local_session_id);
11627 mp->remote_session_id = ntohl (remote_session_id);
11628 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11629 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11630 mp->l2_sublayer_present = l2_sublayer_present;
11639 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11641 unformat_input_t *i = vam->input;
11643 u8 sw_if_index_set = 0;
11644 u64 new_local_cookie = 0;
11645 u64 new_remote_cookie = 0;
11646 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11649 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11651 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11652 sw_if_index_set = 1;
11653 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11654 sw_if_index_set = 1;
11655 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11657 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11663 if (sw_if_index_set == 0)
11665 errmsg ("missing interface name or sw_if_index");
11669 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11671 mp->sw_if_index = ntohl (sw_if_index);
11672 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11673 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11681 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11683 unformat_input_t *i = vam->input;
11684 vl_api_l2tpv3_interface_enable_disable_t *mp;
11686 u8 sw_if_index_set = 0;
11687 u8 enable_disable = 1;
11690 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11692 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11693 sw_if_index_set = 1;
11694 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11695 sw_if_index_set = 1;
11696 else if (unformat (i, "enable"))
11697 enable_disable = 1;
11698 else if (unformat (i, "disable"))
11699 enable_disable = 0;
11704 if (sw_if_index_set == 0)
11706 errmsg ("missing interface name or sw_if_index");
11710 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11712 mp->sw_if_index = ntohl (sw_if_index);
11713 mp->enable_disable = enable_disable;
11721 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11723 unformat_input_t *i = vam->input;
11724 vl_api_l2tpv3_set_lookup_key_t *mp;
11728 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11730 if (unformat (i, "lookup_v6_src"))
11731 key = L2T_LOOKUP_SRC_ADDRESS;
11732 else if (unformat (i, "lookup_v6_dst"))
11733 key = L2T_LOOKUP_DST_ADDRESS;
11734 else if (unformat (i, "lookup_session_id"))
11735 key = L2T_LOOKUP_SESSION_ID;
11740 if (key == (u8) ~ 0)
11742 errmsg ("l2tp session lookup key unset");
11746 M (L2TPV3_SET_LOOKUP_KEY, mp);
11755 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11756 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11758 vat_main_t *vam = &vat_main;
11760 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11761 format_ip6_address, mp->our_address,
11762 format_ip6_address, mp->client_address,
11763 clib_net_to_host_u32 (mp->sw_if_index));
11766 " local cookies %016llx %016llx remote cookie %016llx",
11767 clib_net_to_host_u64 (mp->local_cookie[0]),
11768 clib_net_to_host_u64 (mp->local_cookie[1]),
11769 clib_net_to_host_u64 (mp->remote_cookie));
11771 print (vam->ofp, " local session-id %d remote session-id %d",
11772 clib_net_to_host_u32 (mp->local_session_id),
11773 clib_net_to_host_u32 (mp->remote_session_id));
11775 print (vam->ofp, " l2 specific sublayer %s\n",
11776 mp->l2_sublayer_present ? "preset" : "absent");
11780 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11781 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11783 vat_main_t *vam = &vat_main;
11784 vat_json_node_t *node = NULL;
11785 struct in6_addr addr;
11787 if (VAT_JSON_ARRAY != vam->json_tree.type)
11789 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11790 vat_json_init_array (&vam->json_tree);
11792 node = vat_json_array_add (&vam->json_tree);
11794 vat_json_init_object (node);
11796 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11797 vat_json_object_add_ip6 (node, "our_address", addr);
11798 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11799 vat_json_object_add_ip6 (node, "client_address", addr);
11801 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11802 vat_json_init_array (lc);
11803 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11804 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11805 vat_json_object_add_uint (node, "remote_cookie",
11806 clib_net_to_host_u64 (mp->remote_cookie));
11808 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11809 vat_json_object_add_uint (node, "local_session_id",
11810 clib_net_to_host_u32 (mp->local_session_id));
11811 vat_json_object_add_uint (node, "remote_session_id",
11812 clib_net_to_host_u32 (mp->remote_session_id));
11813 vat_json_object_add_string_copy (node, "l2_sublayer",
11814 mp->l2_sublayer_present ? (u8 *) "present"
11815 : (u8 *) "absent");
11819 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11821 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11822 vl_api_control_ping_t *mp_ping;
11825 /* Get list of l2tpv3-tunnel interfaces */
11826 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11829 /* Use a control ping for synchronization */
11830 MPING (CONTROL_PING, mp_ping);
11838 static void vl_api_sw_interface_tap_details_t_handler
11839 (vl_api_sw_interface_tap_details_t * mp)
11841 vat_main_t *vam = &vat_main;
11843 print (vam->ofp, "%-16s %d",
11844 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
11847 static void vl_api_sw_interface_tap_details_t_handler_json
11848 (vl_api_sw_interface_tap_details_t * mp)
11850 vat_main_t *vam = &vat_main;
11851 vat_json_node_t *node = NULL;
11853 if (VAT_JSON_ARRAY != vam->json_tree.type)
11855 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11856 vat_json_init_array (&vam->json_tree);
11858 node = vat_json_array_add (&vam->json_tree);
11860 vat_json_init_object (node);
11861 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11862 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11866 api_sw_interface_tap_dump (vat_main_t * vam)
11868 vl_api_sw_interface_tap_dump_t *mp;
11869 vl_api_control_ping_t *mp_ping;
11872 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
11873 /* Get list of tap interfaces */
11874 M (SW_INTERFACE_TAP_DUMP, mp);
11877 /* Use a control ping for synchronization */
11878 MPING (CONTROL_PING, mp_ping);
11885 static uword unformat_vxlan_decap_next
11886 (unformat_input_t * input, va_list * args)
11888 u32 *result = va_arg (*args, u32 *);
11891 if (unformat (input, "l2"))
11892 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11893 else if (unformat (input, "%d", &tmp))
11901 api_vxlan_add_del_tunnel (vat_main_t * vam)
11903 unformat_input_t *line_input = vam->input;
11904 vl_api_vxlan_add_del_tunnel_t *mp;
11905 ip46_address_t src, dst;
11907 u8 ipv4_set = 0, ipv6_set = 0;
11911 u32 mcast_sw_if_index = ~0;
11912 u32 encap_vrf_id = 0;
11913 u32 decap_next_index = ~0;
11917 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11918 memset (&src, 0, sizeof src);
11919 memset (&dst, 0, sizeof dst);
11921 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11923 if (unformat (line_input, "del"))
11926 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11932 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11938 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11944 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11949 else if (unformat (line_input, "group %U %U",
11950 unformat_ip4_address, &dst.ip4,
11951 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11953 grp_set = dst_set = 1;
11956 else if (unformat (line_input, "group %U",
11957 unformat_ip4_address, &dst.ip4))
11959 grp_set = dst_set = 1;
11962 else if (unformat (line_input, "group %U %U",
11963 unformat_ip6_address, &dst.ip6,
11964 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11966 grp_set = dst_set = 1;
11969 else if (unformat (line_input, "group %U",
11970 unformat_ip6_address, &dst.ip6))
11972 grp_set = dst_set = 1;
11976 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11978 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11980 else if (unformat (line_input, "decap-next %U",
11981 unformat_vxlan_decap_next, &decap_next_index))
11983 else if (unformat (line_input, "vni %d", &vni))
11987 errmsg ("parse error '%U'", format_unformat_error, line_input);
11994 errmsg ("tunnel src address not specified");
11999 errmsg ("tunnel dst address not specified");
12003 if (grp_set && !ip46_address_is_multicast (&dst))
12005 errmsg ("tunnel group address not multicast");
12008 if (grp_set && mcast_sw_if_index == ~0)
12010 errmsg ("tunnel nonexistent multicast device");
12013 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12015 errmsg ("tunnel dst address must be unicast");
12020 if (ipv4_set && ipv6_set)
12022 errmsg ("both IPv4 and IPv6 addresses specified");
12026 if ((vni == 0) || (vni >> 24))
12028 errmsg ("vni not specified or out of range");
12032 M (VXLAN_ADD_DEL_TUNNEL, mp);
12036 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12037 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12041 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12042 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12044 mp->encap_vrf_id = ntohl (encap_vrf_id);
12045 mp->decap_next_index = ntohl (decap_next_index);
12046 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12047 mp->vni = ntohl (vni);
12048 mp->is_add = is_add;
12049 mp->is_ipv6 = ipv6_set;
12056 static void vl_api_vxlan_tunnel_details_t_handler
12057 (vl_api_vxlan_tunnel_details_t * mp)
12059 vat_main_t *vam = &vat_main;
12060 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12061 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12063 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12064 ntohl (mp->sw_if_index),
12065 format_ip46_address, &src, IP46_TYPE_ANY,
12066 format_ip46_address, &dst, IP46_TYPE_ANY,
12067 ntohl (mp->encap_vrf_id),
12068 ntohl (mp->decap_next_index), ntohl (mp->vni),
12069 ntohl (mp->mcast_sw_if_index));
12072 static void vl_api_vxlan_tunnel_details_t_handler_json
12073 (vl_api_vxlan_tunnel_details_t * mp)
12075 vat_main_t *vam = &vat_main;
12076 vat_json_node_t *node = NULL;
12078 if (VAT_JSON_ARRAY != vam->json_tree.type)
12080 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12081 vat_json_init_array (&vam->json_tree);
12083 node = vat_json_array_add (&vam->json_tree);
12085 vat_json_init_object (node);
12086 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12089 struct in6_addr ip6;
12091 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12092 vat_json_object_add_ip6 (node, "src_address", ip6);
12093 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12094 vat_json_object_add_ip6 (node, "dst_address", ip6);
12098 struct in_addr ip4;
12100 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12101 vat_json_object_add_ip4 (node, "src_address", ip4);
12102 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12103 vat_json_object_add_ip4 (node, "dst_address", ip4);
12105 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12106 vat_json_object_add_uint (node, "decap_next_index",
12107 ntohl (mp->decap_next_index));
12108 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12109 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12110 vat_json_object_add_uint (node, "mcast_sw_if_index",
12111 ntohl (mp->mcast_sw_if_index));
12115 api_vxlan_tunnel_dump (vat_main_t * vam)
12117 unformat_input_t *i = vam->input;
12118 vl_api_vxlan_tunnel_dump_t *mp;
12119 vl_api_control_ping_t *mp_ping;
12121 u8 sw_if_index_set = 0;
12124 /* Parse args required to build the message */
12125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12127 if (unformat (i, "sw_if_index %d", &sw_if_index))
12128 sw_if_index_set = 1;
12133 if (sw_if_index_set == 0)
12138 if (!vam->json_output)
12140 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12141 "sw_if_index", "src_address", "dst_address",
12142 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12145 /* Get list of vxlan-tunnel interfaces */
12146 M (VXLAN_TUNNEL_DUMP, mp);
12148 mp->sw_if_index = htonl (sw_if_index);
12152 /* Use a control ping for synchronization */
12153 MPING (CONTROL_PING, mp_ping);
12160 static uword unformat_geneve_decap_next
12161 (unformat_input_t * input, va_list * args)
12163 u32 *result = va_arg (*args, u32 *);
12166 if (unformat (input, "l2"))
12167 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12168 else if (unformat (input, "%d", &tmp))
12176 api_geneve_add_del_tunnel (vat_main_t * vam)
12178 unformat_input_t *line_input = vam->input;
12179 vl_api_geneve_add_del_tunnel_t *mp;
12180 ip46_address_t src, dst;
12182 u8 ipv4_set = 0, ipv6_set = 0;
12186 u32 mcast_sw_if_index = ~0;
12187 u32 encap_vrf_id = 0;
12188 u32 decap_next_index = ~0;
12192 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12193 memset (&src, 0, sizeof src);
12194 memset (&dst, 0, sizeof dst);
12196 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12198 if (unformat (line_input, "del"))
12201 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12207 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12213 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12219 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12224 else if (unformat (line_input, "group %U %U",
12225 unformat_ip4_address, &dst.ip4,
12226 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12228 grp_set = dst_set = 1;
12231 else if (unformat (line_input, "group %U",
12232 unformat_ip4_address, &dst.ip4))
12234 grp_set = dst_set = 1;
12237 else if (unformat (line_input, "group %U %U",
12238 unformat_ip6_address, &dst.ip6,
12239 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12241 grp_set = dst_set = 1;
12244 else if (unformat (line_input, "group %U",
12245 unformat_ip6_address, &dst.ip6))
12247 grp_set = dst_set = 1;
12251 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12253 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12255 else if (unformat (line_input, "decap-next %U",
12256 unformat_geneve_decap_next, &decap_next_index))
12258 else if (unformat (line_input, "vni %d", &vni))
12262 errmsg ("parse error '%U'", format_unformat_error, line_input);
12269 errmsg ("tunnel src address not specified");
12274 errmsg ("tunnel dst address not specified");
12278 if (grp_set && !ip46_address_is_multicast (&dst))
12280 errmsg ("tunnel group address not multicast");
12283 if (grp_set && mcast_sw_if_index == ~0)
12285 errmsg ("tunnel nonexistent multicast device");
12288 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12290 errmsg ("tunnel dst address must be unicast");
12295 if (ipv4_set && ipv6_set)
12297 errmsg ("both IPv4 and IPv6 addresses specified");
12301 if ((vni == 0) || (vni >> 24))
12303 errmsg ("vni not specified or out of range");
12307 M (GENEVE_ADD_DEL_TUNNEL, mp);
12311 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12312 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12316 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12317 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12319 mp->encap_vrf_id = ntohl (encap_vrf_id);
12320 mp->decap_next_index = ntohl (decap_next_index);
12321 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12322 mp->vni = ntohl (vni);
12323 mp->is_add = is_add;
12324 mp->is_ipv6 = ipv6_set;
12331 static void vl_api_geneve_tunnel_details_t_handler
12332 (vl_api_geneve_tunnel_details_t * mp)
12334 vat_main_t *vam = &vat_main;
12335 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12336 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12338 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12339 ntohl (mp->sw_if_index),
12340 format_ip46_address, &src, IP46_TYPE_ANY,
12341 format_ip46_address, &dst, IP46_TYPE_ANY,
12342 ntohl (mp->encap_vrf_id),
12343 ntohl (mp->decap_next_index), ntohl (mp->vni),
12344 ntohl (mp->mcast_sw_if_index));
12347 static void vl_api_geneve_tunnel_details_t_handler_json
12348 (vl_api_geneve_tunnel_details_t * mp)
12350 vat_main_t *vam = &vat_main;
12351 vat_json_node_t *node = NULL;
12353 if (VAT_JSON_ARRAY != vam->json_tree.type)
12355 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12356 vat_json_init_array (&vam->json_tree);
12358 node = vat_json_array_add (&vam->json_tree);
12360 vat_json_init_object (node);
12361 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12364 struct in6_addr ip6;
12366 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12367 vat_json_object_add_ip6 (node, "src_address", ip6);
12368 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12369 vat_json_object_add_ip6 (node, "dst_address", ip6);
12373 struct in_addr ip4;
12375 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12376 vat_json_object_add_ip4 (node, "src_address", ip4);
12377 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12378 vat_json_object_add_ip4 (node, "dst_address", ip4);
12380 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12381 vat_json_object_add_uint (node, "decap_next_index",
12382 ntohl (mp->decap_next_index));
12383 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12384 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12385 vat_json_object_add_uint (node, "mcast_sw_if_index",
12386 ntohl (mp->mcast_sw_if_index));
12390 api_geneve_tunnel_dump (vat_main_t * vam)
12392 unformat_input_t *i = vam->input;
12393 vl_api_geneve_tunnel_dump_t *mp;
12394 vl_api_control_ping_t *mp_ping;
12396 u8 sw_if_index_set = 0;
12399 /* Parse args required to build the message */
12400 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12402 if (unformat (i, "sw_if_index %d", &sw_if_index))
12403 sw_if_index_set = 1;
12408 if (sw_if_index_set == 0)
12413 if (!vam->json_output)
12415 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12416 "sw_if_index", "local_address", "remote_address",
12417 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12420 /* Get list of geneve-tunnel interfaces */
12421 M (GENEVE_TUNNEL_DUMP, mp);
12423 mp->sw_if_index = htonl (sw_if_index);
12427 /* Use a control ping for synchronization */
12428 M (CONTROL_PING, mp_ping);
12436 api_gre_add_del_tunnel (vat_main_t * vam)
12438 unformat_input_t *line_input = vam->input;
12439 vl_api_gre_add_del_tunnel_t *mp;
12440 ip4_address_t src4, dst4;
12441 ip6_address_t src6, dst6;
12448 u32 outer_fib_id = 0;
12451 memset (&src4, 0, sizeof src4);
12452 memset (&dst4, 0, sizeof dst4);
12453 memset (&src6, 0, sizeof src6);
12454 memset (&dst6, 0, sizeof dst6);
12456 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12458 if (unformat (line_input, "del"))
12460 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
12465 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
12470 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
12475 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
12480 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12482 else if (unformat (line_input, "teb"))
12486 errmsg ("parse error '%U'", format_unformat_error, line_input);
12493 errmsg ("tunnel src address not specified");
12498 errmsg ("tunnel dst address not specified");
12501 if (ipv4_set && ipv6_set)
12503 errmsg ("both IPv4 and IPv6 addresses specified");
12508 M (GRE_ADD_DEL_TUNNEL, mp);
12512 clib_memcpy (&mp->src_address, &src4, 4);
12513 clib_memcpy (&mp->dst_address, &dst4, 4);
12517 clib_memcpy (&mp->src_address, &src6, 16);
12518 clib_memcpy (&mp->dst_address, &dst6, 16);
12520 mp->outer_fib_id = ntohl (outer_fib_id);
12521 mp->is_add = is_add;
12523 mp->is_ipv6 = ipv6_set;
12530 static void vl_api_gre_tunnel_details_t_handler
12531 (vl_api_gre_tunnel_details_t * mp)
12533 vat_main_t *vam = &vat_main;
12534 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
12535 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
12537 print (vam->ofp, "%11d%24U%24U%6d%14d",
12538 ntohl (mp->sw_if_index),
12539 format_ip46_address, &src, IP46_TYPE_ANY,
12540 format_ip46_address, &dst, IP46_TYPE_ANY,
12541 mp->teb, ntohl (mp->outer_fib_id));
12544 static void vl_api_gre_tunnel_details_t_handler_json
12545 (vl_api_gre_tunnel_details_t * mp)
12547 vat_main_t *vam = &vat_main;
12548 vat_json_node_t *node = NULL;
12549 struct in_addr ip4;
12550 struct in6_addr ip6;
12552 if (VAT_JSON_ARRAY != vam->json_tree.type)
12554 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12555 vat_json_init_array (&vam->json_tree);
12557 node = vat_json_array_add (&vam->json_tree);
12559 vat_json_init_object (node);
12560 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12563 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
12564 vat_json_object_add_ip4 (node, "src_address", ip4);
12565 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
12566 vat_json_object_add_ip4 (node, "dst_address", ip4);
12570 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
12571 vat_json_object_add_ip6 (node, "src_address", ip6);
12572 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
12573 vat_json_object_add_ip6 (node, "dst_address", ip6);
12575 vat_json_object_add_uint (node, "teb", mp->teb);
12576 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
12577 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
12581 api_gre_tunnel_dump (vat_main_t * vam)
12583 unformat_input_t *i = vam->input;
12584 vl_api_gre_tunnel_dump_t *mp;
12585 vl_api_control_ping_t *mp_ping;
12587 u8 sw_if_index_set = 0;
12590 /* Parse args required to build the message */
12591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12593 if (unformat (i, "sw_if_index %d", &sw_if_index))
12594 sw_if_index_set = 1;
12599 if (sw_if_index_set == 0)
12604 if (!vam->json_output)
12606 print (vam->ofp, "%11s%24s%24s%6s%14s",
12607 "sw_if_index", "src_address", "dst_address", "teb",
12611 /* Get list of gre-tunnel interfaces */
12612 M (GRE_TUNNEL_DUMP, mp);
12614 mp->sw_if_index = htonl (sw_if_index);
12618 /* Use a control ping for synchronization */
12619 MPING (CONTROL_PING, mp_ping);
12627 api_l2_fib_clear_table (vat_main_t * vam)
12629 // unformat_input_t * i = vam->input;
12630 vl_api_l2_fib_clear_table_t *mp;
12633 M (L2_FIB_CLEAR_TABLE, mp);
12641 api_l2_interface_efp_filter (vat_main_t * vam)
12643 unformat_input_t *i = vam->input;
12644 vl_api_l2_interface_efp_filter_t *mp;
12647 u8 sw_if_index_set = 0;
12650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12652 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12653 sw_if_index_set = 1;
12654 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12655 sw_if_index_set = 1;
12656 else if (unformat (i, "enable"))
12658 else if (unformat (i, "disable"))
12662 clib_warning ("parse error '%U'", format_unformat_error, i);
12667 if (sw_if_index_set == 0)
12669 errmsg ("missing sw_if_index");
12673 M (L2_INTERFACE_EFP_FILTER, mp);
12675 mp->sw_if_index = ntohl (sw_if_index);
12676 mp->enable_disable = enable;
12683 #define foreach_vtr_op \
12684 _("disable", L2_VTR_DISABLED) \
12685 _("push-1", L2_VTR_PUSH_1) \
12686 _("push-2", L2_VTR_PUSH_2) \
12687 _("pop-1", L2_VTR_POP_1) \
12688 _("pop-2", L2_VTR_POP_2) \
12689 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12690 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12691 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12692 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12695 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12697 unformat_input_t *i = vam->input;
12698 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12700 u8 sw_if_index_set = 0;
12703 u32 push_dot1q = 1;
12708 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12710 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12711 sw_if_index_set = 1;
12712 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12713 sw_if_index_set = 1;
12714 else if (unformat (i, "vtr_op %d", &vtr_op))
12716 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12719 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12721 else if (unformat (i, "tag1 %d", &tag1))
12723 else if (unformat (i, "tag2 %d", &tag2))
12727 clib_warning ("parse error '%U'", format_unformat_error, i);
12732 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12734 errmsg ("missing vtr operation or sw_if_index");
12738 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12739 mp->sw_if_index = ntohl (sw_if_index);
12740 mp->vtr_op = ntohl (vtr_op);
12741 mp->push_dot1q = ntohl (push_dot1q);
12742 mp->tag1 = ntohl (tag1);
12743 mp->tag2 = ntohl (tag2);
12751 api_create_vhost_user_if (vat_main_t * vam)
12753 unformat_input_t *i = vam->input;
12754 vl_api_create_vhost_user_if_t *mp;
12757 u8 file_name_set = 0;
12758 u32 custom_dev_instance = ~0;
12760 u8 use_custom_mac = 0;
12764 /* Shut up coverity */
12765 memset (hwaddr, 0, sizeof (hwaddr));
12767 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12769 if (unformat (i, "socket %s", &file_name))
12773 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12775 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12776 use_custom_mac = 1;
12777 else if (unformat (i, "server"))
12779 else if (unformat (i, "tag %s", &tag))
12785 if (file_name_set == 0)
12787 errmsg ("missing socket file name");
12791 if (vec_len (file_name) > 255)
12793 errmsg ("socket file name too long");
12796 vec_add1 (file_name, 0);
12798 M (CREATE_VHOST_USER_IF, mp);
12800 mp->is_server = is_server;
12801 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12802 vec_free (file_name);
12803 if (custom_dev_instance != ~0)
12806 mp->custom_dev_instance = ntohl (custom_dev_instance);
12808 mp->use_custom_mac = use_custom_mac;
12809 clib_memcpy (mp->mac_address, hwaddr, 6);
12811 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12820 api_modify_vhost_user_if (vat_main_t * vam)
12822 unformat_input_t *i = vam->input;
12823 vl_api_modify_vhost_user_if_t *mp;
12826 u8 file_name_set = 0;
12827 u32 custom_dev_instance = ~0;
12828 u8 sw_if_index_set = 0;
12829 u32 sw_if_index = (u32) ~ 0;
12832 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12834 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12835 sw_if_index_set = 1;
12836 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12837 sw_if_index_set = 1;
12838 else if (unformat (i, "socket %s", &file_name))
12842 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12844 else if (unformat (i, "server"))
12850 if (sw_if_index_set == 0)
12852 errmsg ("missing sw_if_index or interface name");
12856 if (file_name_set == 0)
12858 errmsg ("missing socket file name");
12862 if (vec_len (file_name) > 255)
12864 errmsg ("socket file name too long");
12867 vec_add1 (file_name, 0);
12869 M (MODIFY_VHOST_USER_IF, mp);
12871 mp->sw_if_index = ntohl (sw_if_index);
12872 mp->is_server = is_server;
12873 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12874 vec_free (file_name);
12875 if (custom_dev_instance != ~0)
12878 mp->custom_dev_instance = ntohl (custom_dev_instance);
12887 api_delete_vhost_user_if (vat_main_t * vam)
12889 unformat_input_t *i = vam->input;
12890 vl_api_delete_vhost_user_if_t *mp;
12891 u32 sw_if_index = ~0;
12892 u8 sw_if_index_set = 0;
12895 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12897 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12898 sw_if_index_set = 1;
12899 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12900 sw_if_index_set = 1;
12905 if (sw_if_index_set == 0)
12907 errmsg ("missing sw_if_index or interface name");
12912 M (DELETE_VHOST_USER_IF, mp);
12914 mp->sw_if_index = ntohl (sw_if_index);
12921 static void vl_api_sw_interface_vhost_user_details_t_handler
12922 (vl_api_sw_interface_vhost_user_details_t * mp)
12924 vat_main_t *vam = &vat_main;
12926 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12927 (char *) mp->interface_name,
12928 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12929 clib_net_to_host_u64 (mp->features), mp->is_server,
12930 ntohl (mp->num_regions), (char *) mp->sock_filename);
12931 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12934 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12935 (vl_api_sw_interface_vhost_user_details_t * mp)
12937 vat_main_t *vam = &vat_main;
12938 vat_json_node_t *node = NULL;
12940 if (VAT_JSON_ARRAY != vam->json_tree.type)
12942 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12943 vat_json_init_array (&vam->json_tree);
12945 node = vat_json_array_add (&vam->json_tree);
12947 vat_json_init_object (node);
12948 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12949 vat_json_object_add_string_copy (node, "interface_name",
12950 mp->interface_name);
12951 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12952 ntohl (mp->virtio_net_hdr_sz));
12953 vat_json_object_add_uint (node, "features",
12954 clib_net_to_host_u64 (mp->features));
12955 vat_json_object_add_uint (node, "is_server", mp->is_server);
12956 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12957 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12958 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12962 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12964 vl_api_sw_interface_vhost_user_dump_t *mp;
12965 vl_api_control_ping_t *mp_ping;
12968 "Interface name idx hdr_sz features server regions filename");
12970 /* Get list of vhost-user interfaces */
12971 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12974 /* Use a control ping for synchronization */
12975 MPING (CONTROL_PING, mp_ping);
12983 api_show_version (vat_main_t * vam)
12985 vl_api_show_version_t *mp;
12988 M (SHOW_VERSION, mp);
12997 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12999 unformat_input_t *line_input = vam->input;
13000 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13001 ip4_address_t local4, remote4;
13002 ip6_address_t local6, remote6;
13004 u8 ipv4_set = 0, ipv6_set = 0;
13008 u32 mcast_sw_if_index = ~0;
13009 u32 encap_vrf_id = 0;
13010 u32 decap_vrf_id = 0;
13016 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13017 memset (&local4, 0, sizeof local4);
13018 memset (&remote4, 0, sizeof remote4);
13019 memset (&local6, 0, sizeof local6);
13020 memset (&remote6, 0, sizeof remote6);
13022 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13024 if (unformat (line_input, "del"))
13026 else if (unformat (line_input, "local %U",
13027 unformat_ip4_address, &local4))
13032 else if (unformat (line_input, "remote %U",
13033 unformat_ip4_address, &remote4))
13038 else if (unformat (line_input, "local %U",
13039 unformat_ip6_address, &local6))
13044 else if (unformat (line_input, "remote %U",
13045 unformat_ip6_address, &remote6))
13050 else if (unformat (line_input, "group %U %U",
13051 unformat_ip4_address, &remote4,
13052 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13054 grp_set = remote_set = 1;
13057 else if (unformat (line_input, "group %U",
13058 unformat_ip4_address, &remote4))
13060 grp_set = remote_set = 1;
13063 else if (unformat (line_input, "group %U %U",
13064 unformat_ip6_address, &remote6,
13065 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13067 grp_set = remote_set = 1;
13070 else if (unformat (line_input, "group %U",
13071 unformat_ip6_address, &remote6))
13073 grp_set = remote_set = 1;
13077 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13079 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13081 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13083 else if (unformat (line_input, "vni %d", &vni))
13085 else if (unformat (line_input, "next-ip4"))
13087 else if (unformat (line_input, "next-ip6"))
13089 else if (unformat (line_input, "next-ethernet"))
13091 else if (unformat (line_input, "next-nsh"))
13095 errmsg ("parse error '%U'", format_unformat_error, line_input);
13100 if (local_set == 0)
13102 errmsg ("tunnel local address not specified");
13105 if (remote_set == 0)
13107 errmsg ("tunnel remote address not specified");
13110 if (grp_set && mcast_sw_if_index == ~0)
13112 errmsg ("tunnel nonexistent multicast device");
13115 if (ipv4_set && ipv6_set)
13117 errmsg ("both IPv4 and IPv6 addresses specified");
13123 errmsg ("vni not specified");
13127 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13132 clib_memcpy (&mp->local, &local6, sizeof (local6));
13133 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13137 clib_memcpy (&mp->local, &local4, sizeof (local4));
13138 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13141 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13142 mp->encap_vrf_id = ntohl (encap_vrf_id);
13143 mp->decap_vrf_id = ntohl (decap_vrf_id);
13144 mp->protocol = protocol;
13145 mp->vni = ntohl (vni);
13146 mp->is_add = is_add;
13147 mp->is_ipv6 = ipv6_set;
13154 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13155 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13157 vat_main_t *vam = &vat_main;
13158 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13159 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13161 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13162 ntohl (mp->sw_if_index),
13163 format_ip46_address, &local, IP46_TYPE_ANY,
13164 format_ip46_address, &remote, IP46_TYPE_ANY,
13165 ntohl (mp->vni), mp->protocol,
13166 ntohl (mp->mcast_sw_if_index),
13167 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13171 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13172 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13174 vat_main_t *vam = &vat_main;
13175 vat_json_node_t *node = NULL;
13176 struct in_addr ip4;
13177 struct in6_addr ip6;
13179 if (VAT_JSON_ARRAY != vam->json_tree.type)
13181 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13182 vat_json_init_array (&vam->json_tree);
13184 node = vat_json_array_add (&vam->json_tree);
13186 vat_json_init_object (node);
13187 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13190 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13191 vat_json_object_add_ip6 (node, "local", ip6);
13192 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13193 vat_json_object_add_ip6 (node, "remote", ip6);
13197 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13198 vat_json_object_add_ip4 (node, "local", ip4);
13199 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13200 vat_json_object_add_ip4 (node, "remote", ip4);
13202 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13203 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13204 vat_json_object_add_uint (node, "mcast_sw_if_index",
13205 ntohl (mp->mcast_sw_if_index));
13206 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13207 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13208 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13212 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13214 unformat_input_t *i = vam->input;
13215 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13216 vl_api_control_ping_t *mp_ping;
13218 u8 sw_if_index_set = 0;
13221 /* Parse args required to build the message */
13222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13224 if (unformat (i, "sw_if_index %d", &sw_if_index))
13225 sw_if_index_set = 1;
13230 if (sw_if_index_set == 0)
13235 if (!vam->json_output)
13237 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13238 "sw_if_index", "local", "remote", "vni",
13239 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13242 /* Get list of vxlan-tunnel interfaces */
13243 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13245 mp->sw_if_index = htonl (sw_if_index);
13249 /* Use a control ping for synchronization */
13250 MPING (CONTROL_PING, mp_ping);
13259 format_l2_fib_mac_address (u8 * s, va_list * args)
13261 u8 *a = va_arg (*args, u8 *);
13263 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
13264 a[2], a[3], a[4], a[5], a[6], a[7]);
13267 static void vl_api_l2_fib_table_details_t_handler
13268 (vl_api_l2_fib_table_details_t * mp)
13270 vat_main_t *vam = &vat_main;
13272 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13274 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
13275 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13279 static void vl_api_l2_fib_table_details_t_handler_json
13280 (vl_api_l2_fib_table_details_t * mp)
13282 vat_main_t *vam = &vat_main;
13283 vat_json_node_t *node = NULL;
13285 if (VAT_JSON_ARRAY != vam->json_tree.type)
13287 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13288 vat_json_init_array (&vam->json_tree);
13290 node = vat_json_array_add (&vam->json_tree);
13292 vat_json_init_object (node);
13293 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13294 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
13295 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13296 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13297 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13298 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13302 api_l2_fib_table_dump (vat_main_t * vam)
13304 unformat_input_t *i = vam->input;
13305 vl_api_l2_fib_table_dump_t *mp;
13306 vl_api_control_ping_t *mp_ping;
13311 /* Parse args required to build the message */
13312 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13314 if (unformat (i, "bd_id %d", &bd_id))
13320 if (bd_id_set == 0)
13322 errmsg ("missing bridge domain");
13326 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13328 /* Get list of l2 fib entries */
13329 M (L2_FIB_TABLE_DUMP, mp);
13331 mp->bd_id = ntohl (bd_id);
13334 /* Use a control ping for synchronization */
13335 MPING (CONTROL_PING, mp_ping);
13344 api_interface_name_renumber (vat_main_t * vam)
13346 unformat_input_t *line_input = vam->input;
13347 vl_api_interface_name_renumber_t *mp;
13348 u32 sw_if_index = ~0;
13349 u32 new_show_dev_instance = ~0;
13352 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13354 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13357 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13359 else if (unformat (line_input, "new_show_dev_instance %d",
13360 &new_show_dev_instance))
13366 if (sw_if_index == ~0)
13368 errmsg ("missing interface name or sw_if_index");
13372 if (new_show_dev_instance == ~0)
13374 errmsg ("missing new_show_dev_instance");
13378 M (INTERFACE_NAME_RENUMBER, mp);
13380 mp->sw_if_index = ntohl (sw_if_index);
13381 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13389 api_want_ip4_arp_events (vat_main_t * vam)
13391 unformat_input_t *line_input = vam->input;
13392 vl_api_want_ip4_arp_events_t *mp;
13393 ip4_address_t address;
13394 int address_set = 0;
13395 u32 enable_disable = 1;
13398 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13400 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
13402 else if (unformat (line_input, "del"))
13403 enable_disable = 0;
13408 if (address_set == 0)
13410 errmsg ("missing addresses");
13414 M (WANT_IP4_ARP_EVENTS, mp);
13415 mp->enable_disable = enable_disable;
13416 mp->pid = htonl (getpid ());
13417 mp->address = address.as_u32;
13425 api_want_ip6_nd_events (vat_main_t * vam)
13427 unformat_input_t *line_input = vam->input;
13428 vl_api_want_ip6_nd_events_t *mp;
13429 ip6_address_t address;
13430 int address_set = 0;
13431 u32 enable_disable = 1;
13434 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13436 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
13438 else if (unformat (line_input, "del"))
13439 enable_disable = 0;
13444 if (address_set == 0)
13446 errmsg ("missing addresses");
13450 M (WANT_IP6_ND_EVENTS, mp);
13451 mp->enable_disable = enable_disable;
13452 mp->pid = htonl (getpid ());
13453 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
13461 api_want_l2_macs_events (vat_main_t * vam)
13463 unformat_input_t *line_input = vam->input;
13464 vl_api_want_l2_macs_events_t *mp;
13465 u8 enable_disable = 1;
13466 u32 scan_delay = 0;
13467 u32 max_macs_in_event = 0;
13468 u32 learn_limit = 0;
13471 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13473 if (unformat (line_input, "learn-limit %d", &learn_limit))
13475 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13477 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13479 else if (unformat (line_input, "disable"))
13480 enable_disable = 0;
13485 M (WANT_L2_MACS_EVENTS, mp);
13486 mp->enable_disable = enable_disable;
13487 mp->pid = htonl (getpid ());
13488 mp->learn_limit = htonl (learn_limit);
13489 mp->scan_delay = (u8) scan_delay;
13490 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13497 api_input_acl_set_interface (vat_main_t * vam)
13499 unformat_input_t *i = vam->input;
13500 vl_api_input_acl_set_interface_t *mp;
13502 int sw_if_index_set;
13503 u32 ip4_table_index = ~0;
13504 u32 ip6_table_index = ~0;
13505 u32 l2_table_index = ~0;
13509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13511 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13512 sw_if_index_set = 1;
13513 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13514 sw_if_index_set = 1;
13515 else if (unformat (i, "del"))
13517 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13519 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13521 else if (unformat (i, "l2-table %d", &l2_table_index))
13525 clib_warning ("parse error '%U'", format_unformat_error, i);
13530 if (sw_if_index_set == 0)
13532 errmsg ("missing interface name or sw_if_index");
13536 M (INPUT_ACL_SET_INTERFACE, mp);
13538 mp->sw_if_index = ntohl (sw_if_index);
13539 mp->ip4_table_index = ntohl (ip4_table_index);
13540 mp->ip6_table_index = ntohl (ip6_table_index);
13541 mp->l2_table_index = ntohl (l2_table_index);
13542 mp->is_add = is_add;
13550 api_ip_address_dump (vat_main_t * vam)
13552 unformat_input_t *i = vam->input;
13553 vl_api_ip_address_dump_t *mp;
13554 vl_api_control_ping_t *mp_ping;
13555 u32 sw_if_index = ~0;
13556 u8 sw_if_index_set = 0;
13561 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13563 if (unformat (i, "sw_if_index %d", &sw_if_index))
13564 sw_if_index_set = 1;
13566 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13567 sw_if_index_set = 1;
13568 else if (unformat (i, "ipv4"))
13570 else if (unformat (i, "ipv6"))
13576 if (ipv4_set && ipv6_set)
13578 errmsg ("ipv4 and ipv6 flags cannot be both set");
13582 if ((!ipv4_set) && (!ipv6_set))
13584 errmsg ("no ipv4 nor ipv6 flag set");
13588 if (sw_if_index_set == 0)
13590 errmsg ("missing interface name or sw_if_index");
13594 vam->current_sw_if_index = sw_if_index;
13595 vam->is_ipv6 = ipv6_set;
13597 M (IP_ADDRESS_DUMP, mp);
13598 mp->sw_if_index = ntohl (sw_if_index);
13599 mp->is_ipv6 = ipv6_set;
13602 /* Use a control ping for synchronization */
13603 MPING (CONTROL_PING, mp_ping);
13611 api_ip_dump (vat_main_t * vam)
13613 vl_api_ip_dump_t *mp;
13614 vl_api_control_ping_t *mp_ping;
13615 unformat_input_t *in = vam->input;
13622 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13624 if (unformat (in, "ipv4"))
13626 else if (unformat (in, "ipv6"))
13632 if (ipv4_set && ipv6_set)
13634 errmsg ("ipv4 and ipv6 flags cannot be both set");
13638 if ((!ipv4_set) && (!ipv6_set))
13640 errmsg ("no ipv4 nor ipv6 flag set");
13644 is_ipv6 = ipv6_set;
13645 vam->is_ipv6 = is_ipv6;
13647 /* free old data */
13648 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13650 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13652 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13655 mp->is_ipv6 = ipv6_set;
13658 /* Use a control ping for synchronization */
13659 MPING (CONTROL_PING, mp_ping);
13667 api_ipsec_spd_add_del (vat_main_t * vam)
13669 unformat_input_t *i = vam->input;
13670 vl_api_ipsec_spd_add_del_t *mp;
13675 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13677 if (unformat (i, "spd_id %d", &spd_id))
13679 else if (unformat (i, "del"))
13683 clib_warning ("parse error '%U'", format_unformat_error, i);
13689 errmsg ("spd_id must be set");
13693 M (IPSEC_SPD_ADD_DEL, mp);
13695 mp->spd_id = ntohl (spd_id);
13696 mp->is_add = is_add;
13704 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13706 unformat_input_t *i = vam->input;
13707 vl_api_ipsec_interface_add_del_spd_t *mp;
13709 u8 sw_if_index_set = 0;
13710 u32 spd_id = (u32) ~ 0;
13714 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13716 if (unformat (i, "del"))
13718 else if (unformat (i, "spd_id %d", &spd_id))
13721 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13722 sw_if_index_set = 1;
13723 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13724 sw_if_index_set = 1;
13727 clib_warning ("parse error '%U'", format_unformat_error, i);
13733 if (spd_id == (u32) ~ 0)
13735 errmsg ("spd_id must be set");
13739 if (sw_if_index_set == 0)
13741 errmsg ("missing interface name or sw_if_index");
13745 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13747 mp->spd_id = ntohl (spd_id);
13748 mp->sw_if_index = ntohl (sw_if_index);
13749 mp->is_add = is_add;
13757 api_ipsec_spd_add_del_entry (vat_main_t * vam)
13759 unformat_input_t *i = vam->input;
13760 vl_api_ipsec_spd_add_del_entry_t *mp;
13761 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
13762 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13764 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13765 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13766 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
13767 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
13770 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
13771 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
13772 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
13773 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
13774 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
13775 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
13777 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13779 if (unformat (i, "del"))
13781 if (unformat (i, "outbound"))
13783 if (unformat (i, "inbound"))
13785 else if (unformat (i, "spd_id %d", &spd_id))
13787 else if (unformat (i, "sa_id %d", &sa_id))
13789 else if (unformat (i, "priority %d", &priority))
13791 else if (unformat (i, "protocol %d", &protocol))
13793 else if (unformat (i, "lport_start %d", &lport_start))
13795 else if (unformat (i, "lport_stop %d", &lport_stop))
13797 else if (unformat (i, "rport_start %d", &rport_start))
13799 else if (unformat (i, "rport_stop %d", &rport_stop))
13803 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
13809 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
13816 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
13822 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
13829 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
13835 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
13842 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
13848 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
13854 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13856 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13858 clib_warning ("unsupported action: 'resolve'");
13864 clib_warning ("parse error '%U'", format_unformat_error, i);
13870 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
13872 mp->spd_id = ntohl (spd_id);
13873 mp->priority = ntohl (priority);
13874 mp->is_outbound = is_outbound;
13876 mp->is_ipv6 = is_ipv6;
13877 if (is_ipv6 || is_ip_any)
13879 clib_memcpy (mp->remote_address_start, &raddr6_start,
13880 sizeof (ip6_address_t));
13881 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
13882 sizeof (ip6_address_t));
13883 clib_memcpy (mp->local_address_start, &laddr6_start,
13884 sizeof (ip6_address_t));
13885 clib_memcpy (mp->local_address_stop, &laddr6_stop,
13886 sizeof (ip6_address_t));
13890 clib_memcpy (mp->remote_address_start, &raddr4_start,
13891 sizeof (ip4_address_t));
13892 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
13893 sizeof (ip4_address_t));
13894 clib_memcpy (mp->local_address_start, &laddr4_start,
13895 sizeof (ip4_address_t));
13896 clib_memcpy (mp->local_address_stop, &laddr4_stop,
13897 sizeof (ip4_address_t));
13899 mp->protocol = (u8) protocol;
13900 mp->local_port_start = ntohs ((u16) lport_start);
13901 mp->local_port_stop = ntohs ((u16) lport_stop);
13902 mp->remote_port_start = ntohs ((u16) rport_start);
13903 mp->remote_port_stop = ntohs ((u16) rport_stop);
13904 mp->policy = (u8) policy;
13905 mp->sa_id = ntohl (sa_id);
13906 mp->is_add = is_add;
13907 mp->is_ip_any = is_ip_any;
13914 api_ipsec_sad_add_del_entry (vat_main_t * vam)
13916 unformat_input_t *i = vam->input;
13917 vl_api_ipsec_sad_add_del_entry_t *mp;
13918 u32 sad_id = 0, spi = 0;
13919 u8 *ck = 0, *ik = 0;
13922 u8 protocol = IPSEC_PROTOCOL_AH;
13923 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
13924 u32 crypto_alg = 0, integ_alg = 0;
13925 ip4_address_t tun_src4;
13926 ip4_address_t tun_dst4;
13927 ip6_address_t tun_src6;
13928 ip6_address_t tun_dst6;
13931 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13933 if (unformat (i, "del"))
13935 else if (unformat (i, "sad_id %d", &sad_id))
13937 else if (unformat (i, "spi %d", &spi))
13939 else if (unformat (i, "esp"))
13940 protocol = IPSEC_PROTOCOL_ESP;
13941 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
13944 is_tunnel_ipv6 = 0;
13946 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
13949 is_tunnel_ipv6 = 0;
13951 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
13954 is_tunnel_ipv6 = 1;
13956 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
13959 is_tunnel_ipv6 = 1;
13963 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13965 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13966 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13968 clib_warning ("unsupported crypto-alg: '%U'",
13969 format_ipsec_crypto_alg, crypto_alg);
13973 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13977 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13979 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13980 integ_alg >= IPSEC_INTEG_N_ALG)
13982 clib_warning ("unsupported integ-alg: '%U'",
13983 format_ipsec_integ_alg, integ_alg);
13987 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13991 clib_warning ("parse error '%U'", format_unformat_error, i);
13997 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
13999 mp->sad_id = ntohl (sad_id);
14000 mp->is_add = is_add;
14001 mp->protocol = protocol;
14002 mp->spi = ntohl (spi);
14003 mp->is_tunnel = is_tunnel;
14004 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
14005 mp->crypto_algorithm = crypto_alg;
14006 mp->integrity_algorithm = integ_alg;
14007 mp->crypto_key_length = vec_len (ck);
14008 mp->integrity_key_length = vec_len (ik);
14010 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14011 mp->crypto_key_length = sizeof (mp->crypto_key);
14013 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14014 mp->integrity_key_length = sizeof (mp->integrity_key);
14017 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14019 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14023 if (is_tunnel_ipv6)
14025 clib_memcpy (mp->tunnel_src_address, &tun_src6,
14026 sizeof (ip6_address_t));
14027 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
14028 sizeof (ip6_address_t));
14032 clib_memcpy (mp->tunnel_src_address, &tun_src4,
14033 sizeof (ip4_address_t));
14034 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
14035 sizeof (ip4_address_t));
14045 api_ipsec_sa_set_key (vat_main_t * vam)
14047 unformat_input_t *i = vam->input;
14048 vl_api_ipsec_sa_set_key_t *mp;
14050 u8 *ck = 0, *ik = 0;
14053 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14055 if (unformat (i, "sa_id %d", &sa_id))
14057 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14059 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14063 clib_warning ("parse error '%U'", format_unformat_error, i);
14068 M (IPSEC_SA_SET_KEY, mp);
14070 mp->sa_id = ntohl (sa_id);
14071 mp->crypto_key_length = vec_len (ck);
14072 mp->integrity_key_length = vec_len (ik);
14074 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14075 mp->crypto_key_length = sizeof (mp->crypto_key);
14077 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14078 mp->integrity_key_length = sizeof (mp->integrity_key);
14081 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14083 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14091 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14093 unformat_input_t *i = vam->input;
14094 vl_api_ipsec_tunnel_if_add_del_t *mp;
14095 u32 local_spi = 0, remote_spi = 0;
14096 u32 crypto_alg = 0, integ_alg = 0;
14097 u8 *lck = NULL, *rck = NULL;
14098 u8 *lik = NULL, *rik = NULL;
14099 ip4_address_t local_ip = { {0} };
14100 ip4_address_t remote_ip = { {0} };
14103 u8 anti_replay = 0;
14106 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14108 if (unformat (i, "del"))
14110 else if (unformat (i, "esn"))
14112 else if (unformat (i, "anti_replay"))
14114 else if (unformat (i, "local_spi %d", &local_spi))
14116 else if (unformat (i, "remote_spi %d", &remote_spi))
14118 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
14120 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
14122 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14125 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14127 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14129 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14133 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14135 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14136 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14138 errmsg ("unsupported crypto-alg: '%U'\n",
14139 format_ipsec_crypto_alg, crypto_alg);
14145 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14147 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14148 integ_alg >= IPSEC_INTEG_N_ALG)
14150 errmsg ("unsupported integ-alg: '%U'\n",
14151 format_ipsec_integ_alg, integ_alg);
14157 errmsg ("parse error '%U'\n", format_unformat_error, i);
14162 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14164 mp->is_add = is_add;
14166 mp->anti_replay = anti_replay;
14168 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
14169 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
14171 mp->local_spi = htonl (local_spi);
14172 mp->remote_spi = htonl (remote_spi);
14173 mp->crypto_alg = (u8) crypto_alg;
14175 mp->local_crypto_key_len = 0;
14178 mp->local_crypto_key_len = vec_len (lck);
14179 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14180 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14181 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14184 mp->remote_crypto_key_len = 0;
14187 mp->remote_crypto_key_len = vec_len (rck);
14188 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14189 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14190 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14193 mp->integ_alg = (u8) integ_alg;
14195 mp->local_integ_key_len = 0;
14198 mp->local_integ_key_len = vec_len (lik);
14199 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14200 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14201 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14204 mp->remote_integ_key_len = 0;
14207 mp->remote_integ_key_len = vec_len (rik);
14208 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14209 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14210 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14219 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14221 vat_main_t *vam = &vat_main;
14223 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14224 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
14225 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
14226 "tunnel_src_addr %U tunnel_dst_addr %U "
14227 "salt %u seq_outbound %lu last_seq_inbound %lu "
14228 "replay_window %lu total_data_size %lu\n",
14229 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
14231 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
14232 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
14233 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
14234 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14235 mp->tunnel_src_addr,
14236 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14237 mp->tunnel_dst_addr,
14239 clib_net_to_host_u64 (mp->seq_outbound),
14240 clib_net_to_host_u64 (mp->last_seq_inbound),
14241 clib_net_to_host_u64 (mp->replay_window),
14242 clib_net_to_host_u64 (mp->total_data_size));
14245 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14246 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14248 static void vl_api_ipsec_sa_details_t_handler_json
14249 (vl_api_ipsec_sa_details_t * mp)
14251 vat_main_t *vam = &vat_main;
14252 vat_json_node_t *node = NULL;
14253 struct in_addr src_ip4, dst_ip4;
14254 struct in6_addr src_ip6, dst_ip6;
14256 if (VAT_JSON_ARRAY != vam->json_tree.type)
14258 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14259 vat_json_init_array (&vam->json_tree);
14261 node = vat_json_array_add (&vam->json_tree);
14263 vat_json_init_object (node);
14264 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
14265 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14266 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
14267 vat_json_object_add_uint (node, "proto", mp->protocol);
14268 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
14269 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
14270 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
14271 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
14272 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
14273 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
14274 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
14275 mp->crypto_key_len);
14276 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
14277 mp->integ_key_len);
14278 if (mp->is_tunnel_ip6)
14280 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
14281 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
14282 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
14283 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
14287 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
14288 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
14289 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
14290 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
14292 vat_json_object_add_uint (node, "replay_window",
14293 clib_net_to_host_u64 (mp->replay_window));
14294 vat_json_object_add_uint (node, "total_data_size",
14295 clib_net_to_host_u64 (mp->total_data_size));
14300 api_ipsec_sa_dump (vat_main_t * vam)
14302 unformat_input_t *i = vam->input;
14303 vl_api_ipsec_sa_dump_t *mp;
14304 vl_api_control_ping_t *mp_ping;
14308 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14310 if (unformat (i, "sa_id %d", &sa_id))
14314 clib_warning ("parse error '%U'", format_unformat_error, i);
14319 M (IPSEC_SA_DUMP, mp);
14321 mp->sa_id = ntohl (sa_id);
14325 /* Use a control ping for synchronization */
14326 M (CONTROL_PING, mp_ping);
14334 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
14336 unformat_input_t *i = vam->input;
14337 vl_api_ipsec_tunnel_if_set_key_t *mp;
14338 u32 sw_if_index = ~0;
14339 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
14344 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14346 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14349 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
14350 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
14352 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
14353 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
14354 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
14355 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
14357 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
14358 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
14359 else if (unformat (i, "%U", unformat_hex_string, &key))
14363 clib_warning ("parse error '%U'", format_unformat_error, i);
14368 if (sw_if_index == ~0)
14370 errmsg ("interface must be specified");
14374 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
14376 errmsg ("key type must be specified");
14382 errmsg ("algorithm must be specified");
14386 if (vec_len (key) == 0)
14388 errmsg ("key must be specified");
14392 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
14394 mp->sw_if_index = htonl (sw_if_index);
14396 mp->key_type = key_type;
14397 mp->key_len = vec_len (key);
14398 clib_memcpy (mp->key, key, vec_len (key));
14407 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
14409 unformat_input_t *i = vam->input;
14410 vl_api_ipsec_tunnel_if_set_sa_t *mp;
14411 u32 sw_if_index = ~0;
14413 u8 is_outbound = (u8) ~ 0;
14416 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14418 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14420 else if (unformat (i, "sa_id %d", &sa_id))
14422 else if (unformat (i, "outbound"))
14424 else if (unformat (i, "inbound"))
14428 clib_warning ("parse error '%U'", format_unformat_error, i);
14433 if (sw_if_index == ~0)
14435 errmsg ("interface must be specified");
14441 errmsg ("SA ID must be specified");
14445 M (IPSEC_TUNNEL_IF_SET_SA, mp);
14447 mp->sw_if_index = htonl (sw_if_index);
14448 mp->sa_id = htonl (sa_id);
14449 mp->is_outbound = is_outbound;
14458 api_ikev2_profile_add_del (vat_main_t * vam)
14460 unformat_input_t *i = vam->input;
14461 vl_api_ikev2_profile_add_del_t *mp;
14466 const char *valid_chars = "a-zA-Z0-9_";
14468 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14470 if (unformat (i, "del"))
14472 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14473 vec_add1 (name, 0);
14476 errmsg ("parse error '%U'", format_unformat_error, i);
14481 if (!vec_len (name))
14483 errmsg ("profile name must be specified");
14487 if (vec_len (name) > 64)
14489 errmsg ("profile name too long");
14493 M (IKEV2_PROFILE_ADD_DEL, mp);
14495 clib_memcpy (mp->name, name, vec_len (name));
14496 mp->is_add = is_add;
14505 api_ikev2_profile_set_auth (vat_main_t * vam)
14507 unformat_input_t *i = vam->input;
14508 vl_api_ikev2_profile_set_auth_t *mp;
14511 u32 auth_method = 0;
14515 const char *valid_chars = "a-zA-Z0-9_";
14517 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14519 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14520 vec_add1 (name, 0);
14521 else if (unformat (i, "auth_method %U",
14522 unformat_ikev2_auth_method, &auth_method))
14524 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
14526 else if (unformat (i, "auth_data %v", &data))
14530 errmsg ("parse error '%U'", format_unformat_error, i);
14535 if (!vec_len (name))
14537 errmsg ("profile name must be specified");
14541 if (vec_len (name) > 64)
14543 errmsg ("profile name too long");
14547 if (!vec_len (data))
14549 errmsg ("auth_data must be specified");
14555 errmsg ("auth_method must be specified");
14559 M (IKEV2_PROFILE_SET_AUTH, mp);
14561 mp->is_hex = is_hex;
14562 mp->auth_method = (u8) auth_method;
14563 mp->data_len = vec_len (data);
14564 clib_memcpy (mp->name, name, vec_len (name));
14565 clib_memcpy (mp->data, data, vec_len (data));
14575 api_ikev2_profile_set_id (vat_main_t * vam)
14577 unformat_input_t *i = vam->input;
14578 vl_api_ikev2_profile_set_id_t *mp;
14586 const char *valid_chars = "a-zA-Z0-9_";
14588 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14590 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14591 vec_add1 (name, 0);
14592 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
14594 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
14596 data = vec_new (u8, 4);
14597 clib_memcpy (data, ip4.as_u8, 4);
14599 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
14601 else if (unformat (i, "id_data %v", &data))
14603 else if (unformat (i, "local"))
14605 else if (unformat (i, "remote"))
14609 errmsg ("parse error '%U'", format_unformat_error, i);
14614 if (!vec_len (name))
14616 errmsg ("profile name must be specified");
14620 if (vec_len (name) > 64)
14622 errmsg ("profile name too long");
14626 if (!vec_len (data))
14628 errmsg ("id_data must be specified");
14634 errmsg ("id_type must be specified");
14638 M (IKEV2_PROFILE_SET_ID, mp);
14640 mp->is_local = is_local;
14641 mp->id_type = (u8) id_type;
14642 mp->data_len = vec_len (data);
14643 clib_memcpy (mp->name, name, vec_len (name));
14644 clib_memcpy (mp->data, data, vec_len (data));
14654 api_ikev2_profile_set_ts (vat_main_t * vam)
14656 unformat_input_t *i = vam->input;
14657 vl_api_ikev2_profile_set_ts_t *mp;
14660 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
14661 ip4_address_t start_addr, end_addr;
14663 const char *valid_chars = "a-zA-Z0-9_";
14666 start_addr.as_u32 = 0;
14667 end_addr.as_u32 = (u32) ~ 0;
14669 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14671 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14672 vec_add1 (name, 0);
14673 else if (unformat (i, "protocol %d", &proto))
14675 else if (unformat (i, "start_port %d", &start_port))
14677 else if (unformat (i, "end_port %d", &end_port))
14680 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
14682 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
14684 else if (unformat (i, "local"))
14686 else if (unformat (i, "remote"))
14690 errmsg ("parse error '%U'", format_unformat_error, i);
14695 if (!vec_len (name))
14697 errmsg ("profile name must be specified");
14701 if (vec_len (name) > 64)
14703 errmsg ("profile name too long");
14707 M (IKEV2_PROFILE_SET_TS, mp);
14709 mp->is_local = is_local;
14710 mp->proto = (u8) proto;
14711 mp->start_port = (u16) start_port;
14712 mp->end_port = (u16) end_port;
14713 mp->start_addr = start_addr.as_u32;
14714 mp->end_addr = end_addr.as_u32;
14715 clib_memcpy (mp->name, name, vec_len (name));
14724 api_ikev2_set_local_key (vat_main_t * vam)
14726 unformat_input_t *i = vam->input;
14727 vl_api_ikev2_set_local_key_t *mp;
14731 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14733 if (unformat (i, "file %v", &file))
14734 vec_add1 (file, 0);
14737 errmsg ("parse error '%U'", format_unformat_error, i);
14742 if (!vec_len (file))
14744 errmsg ("RSA key file must be specified");
14748 if (vec_len (file) > 256)
14750 errmsg ("file name too long");
14754 M (IKEV2_SET_LOCAL_KEY, mp);
14756 clib_memcpy (mp->key_file, file, vec_len (file));
14765 api_ikev2_set_responder (vat_main_t * vam)
14767 unformat_input_t *i = vam->input;
14768 vl_api_ikev2_set_responder_t *mp;
14771 u32 sw_if_index = ~0;
14772 ip4_address_t address;
14774 const char *valid_chars = "a-zA-Z0-9_";
14776 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14779 (i, "%U interface %d address %U", unformat_token, valid_chars,
14780 &name, &sw_if_index, unformat_ip4_address, &address))
14781 vec_add1 (name, 0);
14784 errmsg ("parse error '%U'", format_unformat_error, i);
14789 if (!vec_len (name))
14791 errmsg ("profile name must be specified");
14795 if (vec_len (name) > 64)
14797 errmsg ("profile name too long");
14801 M (IKEV2_SET_RESPONDER, mp);
14803 clib_memcpy (mp->name, name, vec_len (name));
14806 mp->sw_if_index = sw_if_index;
14807 clib_memcpy (mp->address, &address, sizeof (address));
14815 api_ikev2_set_ike_transforms (vat_main_t * vam)
14817 unformat_input_t *i = vam->input;
14818 vl_api_ikev2_set_ike_transforms_t *mp;
14821 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14823 const char *valid_chars = "a-zA-Z0-9_";
14825 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14827 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14828 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14829 vec_add1 (name, 0);
14832 errmsg ("parse error '%U'", format_unformat_error, i);
14837 if (!vec_len (name))
14839 errmsg ("profile name must be specified");
14843 if (vec_len (name) > 64)
14845 errmsg ("profile name too long");
14849 M (IKEV2_SET_IKE_TRANSFORMS, mp);
14851 clib_memcpy (mp->name, name, vec_len (name));
14853 mp->crypto_alg = crypto_alg;
14854 mp->crypto_key_size = crypto_key_size;
14855 mp->integ_alg = integ_alg;
14856 mp->dh_group = dh_group;
14865 api_ikev2_set_esp_transforms (vat_main_t * vam)
14867 unformat_input_t *i = vam->input;
14868 vl_api_ikev2_set_esp_transforms_t *mp;
14871 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14873 const char *valid_chars = "a-zA-Z0-9_";
14875 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14877 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14878 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14879 vec_add1 (name, 0);
14882 errmsg ("parse error '%U'", format_unformat_error, i);
14887 if (!vec_len (name))
14889 errmsg ("profile name must be specified");
14893 if (vec_len (name) > 64)
14895 errmsg ("profile name too long");
14899 M (IKEV2_SET_ESP_TRANSFORMS, mp);
14901 clib_memcpy (mp->name, name, vec_len (name));
14903 mp->crypto_alg = crypto_alg;
14904 mp->crypto_key_size = crypto_key_size;
14905 mp->integ_alg = integ_alg;
14906 mp->dh_group = dh_group;
14914 api_ikev2_set_sa_lifetime (vat_main_t * vam)
14916 unformat_input_t *i = vam->input;
14917 vl_api_ikev2_set_sa_lifetime_t *mp;
14920 u64 lifetime, lifetime_maxdata;
14921 u32 lifetime_jitter, handover;
14923 const char *valid_chars = "a-zA-Z0-9_";
14925 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14927 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
14928 &lifetime, &lifetime_jitter, &handover,
14929 &lifetime_maxdata))
14930 vec_add1 (name, 0);
14933 errmsg ("parse error '%U'", format_unformat_error, i);
14938 if (!vec_len (name))
14940 errmsg ("profile name must be specified");
14944 if (vec_len (name) > 64)
14946 errmsg ("profile name too long");
14950 M (IKEV2_SET_SA_LIFETIME, mp);
14952 clib_memcpy (mp->name, name, vec_len (name));
14954 mp->lifetime = lifetime;
14955 mp->lifetime_jitter = lifetime_jitter;
14956 mp->handover = handover;
14957 mp->lifetime_maxdata = lifetime_maxdata;
14965 api_ikev2_initiate_sa_init (vat_main_t * vam)
14967 unformat_input_t *i = vam->input;
14968 vl_api_ikev2_initiate_sa_init_t *mp;
14972 const char *valid_chars = "a-zA-Z0-9_";
14974 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14976 if (unformat (i, "%U", unformat_token, valid_chars, &name))
14977 vec_add1 (name, 0);
14980 errmsg ("parse error '%U'", format_unformat_error, i);
14985 if (!vec_len (name))
14987 errmsg ("profile name must be specified");
14991 if (vec_len (name) > 64)
14993 errmsg ("profile name too long");
14997 M (IKEV2_INITIATE_SA_INIT, mp);
14999 clib_memcpy (mp->name, name, vec_len (name));
15008 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
15010 unformat_input_t *i = vam->input;
15011 vl_api_ikev2_initiate_del_ike_sa_t *mp;
15016 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15018 if (unformat (i, "%lx", &ispi))
15022 errmsg ("parse error '%U'", format_unformat_error, i);
15027 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
15037 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
15039 unformat_input_t *i = vam->input;
15040 vl_api_ikev2_initiate_del_child_sa_t *mp;
15045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15047 if (unformat (i, "%x", &ispi))
15051 errmsg ("parse error '%U'", format_unformat_error, i);
15056 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
15066 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
15068 unformat_input_t *i = vam->input;
15069 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
15074 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15076 if (unformat (i, "%x", &ispi))
15080 errmsg ("parse error '%U'", format_unformat_error, i);
15085 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
15098 api_map_add_domain (vat_main_t * vam)
15100 unformat_input_t *i = vam->input;
15101 vl_api_map_add_domain_t *mp;
15103 ip4_address_t ip4_prefix;
15104 ip6_address_t ip6_prefix;
15105 ip6_address_t ip6_src;
15106 u32 num_m_args = 0;
15107 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
15108 0, psid_length = 0;
15109 u8 is_translation = 0;
15111 u32 ip6_src_len = 128;
15114 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15116 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
15117 &ip4_prefix, &ip4_prefix_len))
15119 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
15120 &ip6_prefix, &ip6_prefix_len))
15124 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
15127 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
15129 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
15131 else if (unformat (i, "psid-offset %d", &psid_offset))
15133 else if (unformat (i, "psid-len %d", &psid_length))
15135 else if (unformat (i, "mtu %d", &mtu))
15137 else if (unformat (i, "map-t"))
15138 is_translation = 1;
15141 clib_warning ("parse error '%U'", format_unformat_error, i);
15146 if (num_m_args < 3)
15148 errmsg ("mandatory argument(s) missing");
15152 /* Construct the API message */
15153 M (MAP_ADD_DOMAIN, mp);
15155 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
15156 mp->ip4_prefix_len = ip4_prefix_len;
15158 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
15159 mp->ip6_prefix_len = ip6_prefix_len;
15161 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
15162 mp->ip6_src_prefix_len = ip6_src_len;
15164 mp->ea_bits_len = ea_bits_len;
15165 mp->psid_offset = psid_offset;
15166 mp->psid_length = psid_length;
15167 mp->is_translation = is_translation;
15168 mp->mtu = htons (mtu);
15173 /* Wait for a reply, return good/bad news */
15179 api_map_del_domain (vat_main_t * vam)
15181 unformat_input_t *i = vam->input;
15182 vl_api_map_del_domain_t *mp;
15184 u32 num_m_args = 0;
15188 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15190 if (unformat (i, "index %d", &index))
15194 clib_warning ("parse error '%U'", format_unformat_error, i);
15199 if (num_m_args != 1)
15201 errmsg ("mandatory argument(s) missing");
15205 /* Construct the API message */
15206 M (MAP_DEL_DOMAIN, mp);
15208 mp->index = ntohl (index);
15213 /* Wait for a reply, return good/bad news */
15219 api_map_add_del_rule (vat_main_t * vam)
15221 unformat_input_t *i = vam->input;
15222 vl_api_map_add_del_rule_t *mp;
15224 ip6_address_t ip6_dst;
15225 u32 num_m_args = 0, index, psid = 0;
15228 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15230 if (unformat (i, "index %d", &index))
15232 else if (unformat (i, "psid %d", &psid))
15234 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
15236 else if (unformat (i, "del"))
15242 clib_warning ("parse error '%U'", format_unformat_error, i);
15247 /* Construct the API message */
15248 M (MAP_ADD_DEL_RULE, mp);
15250 mp->index = ntohl (index);
15251 mp->is_add = is_add;
15252 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
15253 mp->psid = ntohs (psid);
15258 /* Wait for a reply, return good/bad news */
15264 api_map_domain_dump (vat_main_t * vam)
15266 vl_api_map_domain_dump_t *mp;
15267 vl_api_control_ping_t *mp_ping;
15270 /* Construct the API message */
15271 M (MAP_DOMAIN_DUMP, mp);
15276 /* Use a control ping for synchronization */
15277 MPING (CONTROL_PING, mp_ping);
15285 api_map_rule_dump (vat_main_t * vam)
15287 unformat_input_t *i = vam->input;
15288 vl_api_map_rule_dump_t *mp;
15289 vl_api_control_ping_t *mp_ping;
15290 u32 domain_index = ~0;
15293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15295 if (unformat (i, "index %u", &domain_index))
15301 if (domain_index == ~0)
15303 clib_warning ("parse error: domain index expected");
15307 /* Construct the API message */
15308 M (MAP_RULE_DUMP, mp);
15310 mp->domain_index = htonl (domain_index);
15315 /* Use a control ping for synchronization */
15316 MPING (CONTROL_PING, mp_ping);
15323 static void vl_api_map_add_domain_reply_t_handler
15324 (vl_api_map_add_domain_reply_t * mp)
15326 vat_main_t *vam = &vat_main;
15327 i32 retval = ntohl (mp->retval);
15329 if (vam->async_mode)
15331 vam->async_errors += (retval < 0);
15335 vam->retval = retval;
15336 vam->result_ready = 1;
15340 static void vl_api_map_add_domain_reply_t_handler_json
15341 (vl_api_map_add_domain_reply_t * mp)
15343 vat_main_t *vam = &vat_main;
15344 vat_json_node_t node;
15346 vat_json_init_object (&node);
15347 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
15348 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
15350 vat_json_print (vam->ofp, &node);
15351 vat_json_free (&node);
15353 vam->retval = ntohl (mp->retval);
15354 vam->result_ready = 1;
15358 api_get_first_msg_id (vat_main_t * vam)
15360 vl_api_get_first_msg_id_t *mp;
15361 unformat_input_t *i = vam->input;
15366 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15368 if (unformat (i, "client %s", &name))
15376 errmsg ("missing client name");
15379 vec_add1 (name, 0);
15381 if (vec_len (name) > 63)
15383 errmsg ("client name too long");
15387 M (GET_FIRST_MSG_ID, mp);
15388 clib_memcpy (mp->name, name, vec_len (name));
15395 api_cop_interface_enable_disable (vat_main_t * vam)
15397 unformat_input_t *line_input = vam->input;
15398 vl_api_cop_interface_enable_disable_t *mp;
15399 u32 sw_if_index = ~0;
15400 u8 enable_disable = 1;
15403 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15405 if (unformat (line_input, "disable"))
15406 enable_disable = 0;
15407 if (unformat (line_input, "enable"))
15408 enable_disable = 1;
15409 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15410 vam, &sw_if_index))
15412 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15418 if (sw_if_index == ~0)
15420 errmsg ("missing interface name or sw_if_index");
15424 /* Construct the API message */
15425 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15426 mp->sw_if_index = ntohl (sw_if_index);
15427 mp->enable_disable = enable_disable;
15431 /* Wait for the reply */
15437 api_cop_whitelist_enable_disable (vat_main_t * vam)
15439 unformat_input_t *line_input = vam->input;
15440 vl_api_cop_whitelist_enable_disable_t *mp;
15441 u32 sw_if_index = ~0;
15442 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15446 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15448 if (unformat (line_input, "ip4"))
15450 else if (unformat (line_input, "ip6"))
15452 else if (unformat (line_input, "default"))
15454 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15455 vam, &sw_if_index))
15457 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15459 else if (unformat (line_input, "fib-id %d", &fib_id))
15465 if (sw_if_index == ~0)
15467 errmsg ("missing interface name or sw_if_index");
15471 /* Construct the API message */
15472 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15473 mp->sw_if_index = ntohl (sw_if_index);
15474 mp->fib_id = ntohl (fib_id);
15477 mp->default_cop = default_cop;
15481 /* Wait for the reply */
15487 api_get_node_graph (vat_main_t * vam)
15489 vl_api_get_node_graph_t *mp;
15492 M (GET_NODE_GRAPH, mp);
15496 /* Wait for the reply */
15502 /** Used for parsing LISP eids */
15503 typedef CLIB_PACKED(struct{
15504 u8 addr[16]; /**< eid address */
15505 u32 len; /**< prefix length if IP */
15506 u8 type; /**< type of eid */
15511 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15513 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15515 memset (a, 0, sizeof (a[0]));
15517 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15519 a->type = 0; /* ipv4 type */
15521 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15523 a->type = 1; /* ipv6 type */
15525 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15527 a->type = 2; /* mac type */
15529 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15531 a->type = 3; /* NSH type */
15532 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15533 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15540 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15549 lisp_eid_size_vat (u8 type)
15566 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15568 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15572 api_one_add_del_locator_set (vat_main_t * vam)
15574 unformat_input_t *input = vam->input;
15575 vl_api_one_add_del_locator_set_t *mp;
15577 u8 *locator_set_name = NULL;
15578 u8 locator_set_name_set = 0;
15579 vl_api_local_locator_t locator, *locators = 0;
15580 u32 sw_if_index, priority, weight;
15584 /* Parse args required to build the message */
15585 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15587 if (unformat (input, "del"))
15591 else if (unformat (input, "locator-set %s", &locator_set_name))
15593 locator_set_name_set = 1;
15595 else if (unformat (input, "sw_if_index %u p %u w %u",
15596 &sw_if_index, &priority, &weight))
15598 locator.sw_if_index = htonl (sw_if_index);
15599 locator.priority = priority;
15600 locator.weight = weight;
15601 vec_add1 (locators, locator);
15605 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15606 &sw_if_index, &priority, &weight))
15608 locator.sw_if_index = htonl (sw_if_index);
15609 locator.priority = priority;
15610 locator.weight = weight;
15611 vec_add1 (locators, locator);
15617 if (locator_set_name_set == 0)
15619 errmsg ("missing locator-set name");
15620 vec_free (locators);
15624 if (vec_len (locator_set_name) > 64)
15626 errmsg ("locator-set name too long");
15627 vec_free (locator_set_name);
15628 vec_free (locators);
15631 vec_add1 (locator_set_name, 0);
15633 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15635 /* Construct the API message */
15636 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15638 mp->is_add = is_add;
15639 clib_memcpy (mp->locator_set_name, locator_set_name,
15640 vec_len (locator_set_name));
15641 vec_free (locator_set_name);
15643 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15645 clib_memcpy (mp->locators, locators, data_len);
15646 vec_free (locators);
15651 /* Wait for a reply... */
15656 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15659 api_one_add_del_locator (vat_main_t * vam)
15661 unformat_input_t *input = vam->input;
15662 vl_api_one_add_del_locator_t *mp;
15663 u32 tmp_if_index = ~0;
15664 u32 sw_if_index = ~0;
15665 u8 sw_if_index_set = 0;
15666 u8 sw_if_index_if_name_set = 0;
15668 u8 priority_set = 0;
15672 u8 *locator_set_name = NULL;
15673 u8 locator_set_name_set = 0;
15676 /* Parse args required to build the message */
15677 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15679 if (unformat (input, "del"))
15683 else if (unformat (input, "locator-set %s", &locator_set_name))
15685 locator_set_name_set = 1;
15687 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15690 sw_if_index_if_name_set = 1;
15691 sw_if_index = tmp_if_index;
15693 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15695 sw_if_index_set = 1;
15696 sw_if_index = tmp_if_index;
15698 else if (unformat (input, "p %d", &priority))
15702 else if (unformat (input, "w %d", &weight))
15710 if (locator_set_name_set == 0)
15712 errmsg ("missing locator-set name");
15716 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15718 errmsg ("missing sw_if_index");
15719 vec_free (locator_set_name);
15723 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15725 errmsg ("cannot use both params interface name and sw_if_index");
15726 vec_free (locator_set_name);
15730 if (priority_set == 0)
15732 errmsg ("missing locator-set priority");
15733 vec_free (locator_set_name);
15737 if (weight_set == 0)
15739 errmsg ("missing locator-set weight");
15740 vec_free (locator_set_name);
15744 if (vec_len (locator_set_name) > 64)
15746 errmsg ("locator-set name too long");
15747 vec_free (locator_set_name);
15750 vec_add1 (locator_set_name, 0);
15752 /* Construct the API message */
15753 M (ONE_ADD_DEL_LOCATOR, mp);
15755 mp->is_add = is_add;
15756 mp->sw_if_index = ntohl (sw_if_index);
15757 mp->priority = priority;
15758 mp->weight = weight;
15759 clib_memcpy (mp->locator_set_name, locator_set_name,
15760 vec_len (locator_set_name));
15761 vec_free (locator_set_name);
15766 /* Wait for a reply... */
15771 #define api_lisp_add_del_locator api_one_add_del_locator
15774 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15776 u32 *key_id = va_arg (*args, u32 *);
15779 if (unformat (input, "%s", &s))
15781 if (!strcmp ((char *) s, "sha1"))
15782 key_id[0] = HMAC_SHA_1_96;
15783 else if (!strcmp ((char *) s, "sha256"))
15784 key_id[0] = HMAC_SHA_256_128;
15787 clib_warning ("invalid key_id: '%s'", s);
15788 key_id[0] = HMAC_NO_KEY;
15799 api_one_add_del_local_eid (vat_main_t * vam)
15801 unformat_input_t *input = vam->input;
15802 vl_api_one_add_del_local_eid_t *mp;
15805 lisp_eid_vat_t _eid, *eid = &_eid;
15806 u8 *locator_set_name = 0;
15807 u8 locator_set_name_set = 0;
15813 /* Parse args required to build the message */
15814 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15816 if (unformat (input, "del"))
15820 else if (unformat (input, "vni %d", &vni))
15824 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15828 else if (unformat (input, "locator-set %s", &locator_set_name))
15830 locator_set_name_set = 1;
15832 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15834 else if (unformat (input, "secret-key %_%v%_", &key))
15840 if (locator_set_name_set == 0)
15842 errmsg ("missing locator-set name");
15848 errmsg ("EID address not set!");
15849 vec_free (locator_set_name);
15853 if (key && (0 == key_id))
15855 errmsg ("invalid key_id!");
15859 if (vec_len (key) > 64)
15861 errmsg ("key too long");
15866 if (vec_len (locator_set_name) > 64)
15868 errmsg ("locator-set name too long");
15869 vec_free (locator_set_name);
15872 vec_add1 (locator_set_name, 0);
15874 /* Construct the API message */
15875 M (ONE_ADD_DEL_LOCAL_EID, mp);
15877 mp->is_add = is_add;
15878 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15879 mp->eid_type = eid->type;
15880 mp->prefix_len = eid->len;
15881 mp->vni = clib_host_to_net_u32 (vni);
15882 mp->key_id = clib_host_to_net_u16 (key_id);
15883 clib_memcpy (mp->locator_set_name, locator_set_name,
15884 vec_len (locator_set_name));
15885 clib_memcpy (mp->key, key, vec_len (key));
15887 vec_free (locator_set_name);
15893 /* Wait for a reply... */
15898 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15901 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15903 u32 dp_table = 0, vni = 0;;
15904 unformat_input_t *input = vam->input;
15905 vl_api_gpe_add_del_fwd_entry_t *mp;
15907 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15908 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15909 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15910 u32 action = ~0, w;
15911 ip4_address_t rmt_rloc4, lcl_rloc4;
15912 ip6_address_t rmt_rloc6, lcl_rloc6;
15913 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15916 memset (&rloc, 0, sizeof (rloc));
15918 /* Parse args required to build the message */
15919 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15921 if (unformat (input, "del"))
15923 else if (unformat (input, "add"))
15925 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15929 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15933 else if (unformat (input, "vrf %d", &dp_table))
15935 else if (unformat (input, "bd %d", &dp_table))
15937 else if (unformat (input, "vni %d", &vni))
15939 else if (unformat (input, "w %d", &w))
15943 errmsg ("No RLOC configured for setting priority/weight!");
15946 curr_rloc->weight = w;
15948 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15949 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15953 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15955 vec_add1 (lcl_locs, rloc);
15957 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15958 vec_add1 (rmt_locs, rloc);
15959 /* weight saved in rmt loc */
15960 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15962 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15963 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15966 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15968 vec_add1 (lcl_locs, rloc);
15970 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15971 vec_add1 (rmt_locs, rloc);
15972 /* weight saved in rmt loc */
15973 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15975 else if (unformat (input, "action %d", &action))
15981 clib_warning ("parse error '%U'", format_unformat_error, input);
15988 errmsg ("remote eid addresses not set");
15992 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15994 errmsg ("eid types don't match");
15998 if (0 == rmt_locs && (u32) ~ 0 == action)
16000 errmsg ("action not set for negative mapping");
16004 /* Construct the API message */
16005 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
16006 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
16008 mp->is_add = is_add;
16009 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
16010 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
16011 mp->eid_type = rmt_eid->type;
16012 mp->dp_table = clib_host_to_net_u32 (dp_table);
16013 mp->vni = clib_host_to_net_u32 (vni);
16014 mp->rmt_len = rmt_eid->len;
16015 mp->lcl_len = lcl_eid->len;
16016 mp->action = action;
16018 if (0 != rmt_locs && 0 != lcl_locs)
16020 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
16021 clib_memcpy (mp->locs, lcl_locs,
16022 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
16024 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
16025 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
16026 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
16028 vec_free (lcl_locs);
16029 vec_free (rmt_locs);
16034 /* Wait for a reply... */
16040 api_one_add_del_map_server (vat_main_t * vam)
16042 unformat_input_t *input = vam->input;
16043 vl_api_one_add_del_map_server_t *mp;
16047 ip4_address_t ipv4;
16048 ip6_address_t ipv6;
16051 /* Parse args required to build the message */
16052 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16054 if (unformat (input, "del"))
16058 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16062 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16070 if (ipv4_set && ipv6_set)
16072 errmsg ("both eid v4 and v6 addresses set");
16076 if (!ipv4_set && !ipv6_set)
16078 errmsg ("eid addresses not set");
16082 /* Construct the API message */
16083 M (ONE_ADD_DEL_MAP_SERVER, mp);
16085 mp->is_add = is_add;
16089 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16094 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16100 /* Wait for a reply... */
16105 #define api_lisp_add_del_map_server api_one_add_del_map_server
16108 api_one_add_del_map_resolver (vat_main_t * vam)
16110 unformat_input_t *input = vam->input;
16111 vl_api_one_add_del_map_resolver_t *mp;
16115 ip4_address_t ipv4;
16116 ip6_address_t ipv6;
16119 /* Parse args required to build the message */
16120 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16122 if (unformat (input, "del"))
16126 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16130 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16138 if (ipv4_set && ipv6_set)
16140 errmsg ("both eid v4 and v6 addresses set");
16144 if (!ipv4_set && !ipv6_set)
16146 errmsg ("eid addresses not set");
16150 /* Construct the API message */
16151 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
16153 mp->is_add = is_add;
16157 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16162 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16168 /* Wait for a reply... */
16173 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
16176 api_lisp_gpe_enable_disable (vat_main_t * vam)
16178 unformat_input_t *input = vam->input;
16179 vl_api_gpe_enable_disable_t *mp;
16184 /* Parse args required to build the message */
16185 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16187 if (unformat (input, "enable"))
16192 else if (unformat (input, "disable"))
16203 errmsg ("Value not set");
16207 /* Construct the API message */
16208 M (GPE_ENABLE_DISABLE, mp);
16215 /* Wait for a reply... */
16221 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16223 unformat_input_t *input = vam->input;
16224 vl_api_one_rloc_probe_enable_disable_t *mp;
16229 /* Parse args required to build the message */
16230 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16232 if (unformat (input, "enable"))
16237 else if (unformat (input, "disable"))
16245 errmsg ("Value not set");
16249 /* Construct the API message */
16250 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16252 mp->is_enabled = is_en;
16257 /* Wait for a reply... */
16262 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16265 api_one_map_register_enable_disable (vat_main_t * vam)
16267 unformat_input_t *input = vam->input;
16268 vl_api_one_map_register_enable_disable_t *mp;
16273 /* Parse args required to build the message */
16274 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16276 if (unformat (input, "enable"))
16281 else if (unformat (input, "disable"))
16289 errmsg ("Value not set");
16293 /* Construct the API message */
16294 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16296 mp->is_enabled = is_en;
16301 /* Wait for a reply... */
16306 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16309 api_one_enable_disable (vat_main_t * vam)
16311 unformat_input_t *input = vam->input;
16312 vl_api_one_enable_disable_t *mp;
16317 /* Parse args required to build the message */
16318 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16320 if (unformat (input, "enable"))
16325 else if (unformat (input, "disable"))
16335 errmsg ("Value not set");
16339 /* Construct the API message */
16340 M (ONE_ENABLE_DISABLE, mp);
16347 /* Wait for a reply... */
16352 #define api_lisp_enable_disable api_one_enable_disable
16355 api_show_one_map_register_state (vat_main_t * vam)
16357 vl_api_show_one_map_register_state_t *mp;
16360 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16365 /* wait for reply */
16370 #define api_show_lisp_map_register_state api_show_one_map_register_state
16373 api_show_one_rloc_probe_state (vat_main_t * vam)
16375 vl_api_show_one_rloc_probe_state_t *mp;
16378 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16383 /* wait for reply */
16388 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16391 api_one_add_del_ndp_entry (vat_main_t * vam)
16393 vl_api_one_add_del_ndp_entry_t *mp;
16394 unformat_input_t *input = vam->input;
16399 u8 mac[6] = { 0, };
16400 u8 ip6[16] = { 0, };
16404 /* Parse args required to build the message */
16405 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16407 if (unformat (input, "del"))
16409 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16411 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16413 else if (unformat (input, "bd %d", &bd))
16417 errmsg ("parse error '%U'", format_unformat_error, input);
16422 if (!bd_set || !ip_set || (!mac_set && is_add))
16424 errmsg ("Missing BD, IP or MAC!");
16428 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16429 mp->is_add = is_add;
16430 clib_memcpy (mp->mac, mac, 6);
16431 mp->bd = clib_host_to_net_u32 (bd);
16432 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16437 /* wait for reply */
16443 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16445 vl_api_one_add_del_l2_arp_entry_t *mp;
16446 unformat_input_t *input = vam->input;
16451 u8 mac[6] = { 0, };
16452 u32 ip4 = 0, bd = ~0;
16455 /* Parse args required to build the message */
16456 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16458 if (unformat (input, "del"))
16460 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16462 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16464 else if (unformat (input, "bd %d", &bd))
16468 errmsg ("parse error '%U'", format_unformat_error, input);
16473 if (!bd_set || !ip_set || (!mac_set && is_add))
16475 errmsg ("Missing BD, IP or MAC!");
16479 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16480 mp->is_add = is_add;
16481 clib_memcpy (mp->mac, mac, 6);
16482 mp->bd = clib_host_to_net_u32 (bd);
16488 /* wait for reply */
16494 api_one_ndp_bd_get (vat_main_t * vam)
16496 vl_api_one_ndp_bd_get_t *mp;
16499 M (ONE_NDP_BD_GET, mp);
16504 /* wait for reply */
16510 api_one_ndp_entries_get (vat_main_t * vam)
16512 vl_api_one_ndp_entries_get_t *mp;
16513 unformat_input_t *input = vam->input;
16518 /* Parse args required to build the message */
16519 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16521 if (unformat (input, "bd %d", &bd))
16525 errmsg ("parse error '%U'", format_unformat_error, input);
16532 errmsg ("Expected bridge domain!");
16536 M (ONE_NDP_ENTRIES_GET, mp);
16537 mp->bd = clib_host_to_net_u32 (bd);
16542 /* wait for reply */
16548 api_one_l2_arp_bd_get (vat_main_t * vam)
16550 vl_api_one_l2_arp_bd_get_t *mp;
16553 M (ONE_L2_ARP_BD_GET, mp);
16558 /* wait for reply */
16564 api_one_l2_arp_entries_get (vat_main_t * vam)
16566 vl_api_one_l2_arp_entries_get_t *mp;
16567 unformat_input_t *input = vam->input;
16572 /* Parse args required to build the message */
16573 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16575 if (unformat (input, "bd %d", &bd))
16579 errmsg ("parse error '%U'", format_unformat_error, input);
16586 errmsg ("Expected bridge domain!");
16590 M (ONE_L2_ARP_ENTRIES_GET, mp);
16591 mp->bd = clib_host_to_net_u32 (bd);
16596 /* wait for reply */
16602 api_one_stats_enable_disable (vat_main_t * vam)
16604 vl_api_one_stats_enable_disable_t *mp;
16605 unformat_input_t *input = vam->input;
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 M (ONE_STATS_ENABLE_DISABLE, mp);
16638 /* wait for reply */
16644 api_show_one_stats_enable_disable (vat_main_t * vam)
16646 vl_api_show_one_stats_enable_disable_t *mp;
16649 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16654 /* wait for reply */
16660 api_show_one_map_request_mode (vat_main_t * vam)
16662 vl_api_show_one_map_request_mode_t *mp;
16665 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16670 /* wait for reply */
16675 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16678 api_one_map_request_mode (vat_main_t * vam)
16680 unformat_input_t *input = vam->input;
16681 vl_api_one_map_request_mode_t *mp;
16685 /* Parse args required to build the message */
16686 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16688 if (unformat (input, "dst-only"))
16690 else if (unformat (input, "src-dst"))
16694 errmsg ("parse error '%U'", format_unformat_error, input);
16699 M (ONE_MAP_REQUEST_MODE, mp);
16706 /* wait for reply */
16711 #define api_lisp_map_request_mode api_one_map_request_mode
16714 * Enable/disable ONE proxy ITR.
16716 * @param vam vpp API test context
16717 * @return return code
16720 api_one_pitr_set_locator_set (vat_main_t * vam)
16722 u8 ls_name_set = 0;
16723 unformat_input_t *input = vam->input;
16724 vl_api_one_pitr_set_locator_set_t *mp;
16729 /* Parse args required to build the message */
16730 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16732 if (unformat (input, "del"))
16734 else if (unformat (input, "locator-set %s", &ls_name))
16738 errmsg ("parse error '%U'", format_unformat_error, input);
16745 errmsg ("locator-set name not set!");
16749 M (ONE_PITR_SET_LOCATOR_SET, mp);
16751 mp->is_add = is_add;
16752 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16753 vec_free (ls_name);
16758 /* wait for reply */
16763 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16766 api_one_nsh_set_locator_set (vat_main_t * vam)
16768 u8 ls_name_set = 0;
16769 unformat_input_t *input = vam->input;
16770 vl_api_one_nsh_set_locator_set_t *mp;
16775 /* Parse args required to build the message */
16776 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16778 if (unformat (input, "del"))
16780 else if (unformat (input, "ls %s", &ls_name))
16784 errmsg ("parse error '%U'", format_unformat_error, input);
16789 if (!ls_name_set && is_add)
16791 errmsg ("locator-set name not set!");
16795 M (ONE_NSH_SET_LOCATOR_SET, mp);
16797 mp->is_add = is_add;
16798 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16799 vec_free (ls_name);
16804 /* wait for reply */
16810 api_show_one_pitr (vat_main_t * vam)
16812 vl_api_show_one_pitr_t *mp;
16815 if (!vam->json_output)
16817 print (vam->ofp, "%=20s", "lisp status:");
16820 M (SHOW_ONE_PITR, mp);
16824 /* Wait for a reply... */
16829 #define api_show_lisp_pitr api_show_one_pitr
16832 api_one_use_petr (vat_main_t * vam)
16834 unformat_input_t *input = vam->input;
16835 vl_api_one_use_petr_t *mp;
16840 memset (&ip, 0, sizeof (ip));
16842 /* Parse args required to build the message */
16843 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16845 if (unformat (input, "disable"))
16848 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16851 ip_addr_version (&ip) = IP4;
16854 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16857 ip_addr_version (&ip) = IP6;
16861 errmsg ("parse error '%U'", format_unformat_error, input);
16866 M (ONE_USE_PETR, mp);
16868 mp->is_add = is_add;
16871 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16873 clib_memcpy (mp->address, &ip, 4);
16875 clib_memcpy (mp->address, &ip, 16);
16881 /* wait for reply */
16886 #define api_lisp_use_petr api_one_use_petr
16889 api_show_one_nsh_mapping (vat_main_t * vam)
16891 vl_api_show_one_use_petr_t *mp;
16894 if (!vam->json_output)
16896 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16899 M (SHOW_ONE_NSH_MAPPING, mp);
16903 /* Wait for a reply... */
16909 api_show_one_use_petr (vat_main_t * vam)
16911 vl_api_show_one_use_petr_t *mp;
16914 if (!vam->json_output)
16916 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16919 M (SHOW_ONE_USE_PETR, mp);
16923 /* Wait for a reply... */
16928 #define api_show_lisp_use_petr api_show_one_use_petr
16931 * Add/delete mapping between vni and vrf
16934 api_one_eid_table_add_del_map (vat_main_t * vam)
16936 unformat_input_t *input = vam->input;
16937 vl_api_one_eid_table_add_del_map_t *mp;
16938 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16939 u32 vni, vrf, bd_index;
16942 /* Parse args required to build the message */
16943 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16945 if (unformat (input, "del"))
16947 else if (unformat (input, "vrf %d", &vrf))
16949 else if (unformat (input, "bd_index %d", &bd_index))
16951 else if (unformat (input, "vni %d", &vni))
16957 if (!vni_set || (!vrf_set && !bd_index_set))
16959 errmsg ("missing arguments!");
16963 if (vrf_set && bd_index_set)
16965 errmsg ("error: both vrf and bd entered!");
16969 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16971 mp->is_add = is_add;
16972 mp->vni = htonl (vni);
16973 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16974 mp->is_l2 = bd_index_set;
16979 /* wait for reply */
16984 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16987 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16989 u32 *action = va_arg (*args, u32 *);
16992 if (unformat (input, "%s", &s))
16994 if (!strcmp ((char *) s, "no-action"))
16996 else if (!strcmp ((char *) s, "natively-forward"))
16998 else if (!strcmp ((char *) s, "send-map-request"))
17000 else if (!strcmp ((char *) s, "drop"))
17004 clib_warning ("invalid action: '%s'", s);
17016 * Add/del remote mapping to/from ONE control plane
17018 * @param vam vpp API test context
17019 * @return return code
17022 api_one_add_del_remote_mapping (vat_main_t * vam)
17024 unformat_input_t *input = vam->input;
17025 vl_api_one_add_del_remote_mapping_t *mp;
17027 lisp_eid_vat_t _eid, *eid = &_eid;
17028 lisp_eid_vat_t _seid, *seid = &_seid;
17029 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
17030 u32 action = ~0, p, w, data_len;
17031 ip4_address_t rloc4;
17032 ip6_address_t rloc6;
17033 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
17036 memset (&rloc, 0, sizeof (rloc));
17038 /* Parse args required to build the message */
17039 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17041 if (unformat (input, "del-all"))
17045 else if (unformat (input, "del"))
17049 else if (unformat (input, "add"))
17053 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17057 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
17061 else if (unformat (input, "vni %d", &vni))
17065 else if (unformat (input, "p %d w %d", &p, &w))
17069 errmsg ("No RLOC configured for setting priority/weight!");
17072 curr_rloc->priority = p;
17073 curr_rloc->weight = w;
17075 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
17078 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
17079 vec_add1 (rlocs, rloc);
17080 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17082 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
17085 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
17086 vec_add1 (rlocs, rloc);
17087 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17089 else if (unformat (input, "action %U",
17090 unformat_negative_mapping_action, &action))
17096 clib_warning ("parse error '%U'", format_unformat_error, input);
17103 errmsg ("missing params!");
17107 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
17109 errmsg ("no action set for negative map-reply!");
17113 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
17115 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
17116 mp->is_add = is_add;
17117 mp->vni = htonl (vni);
17118 mp->action = (u8) action;
17119 mp->is_src_dst = seid_set;
17120 mp->eid_len = eid->len;
17121 mp->seid_len = seid->len;
17122 mp->del_all = del_all;
17123 mp->eid_type = eid->type;
17124 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17125 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
17127 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
17128 clib_memcpy (mp->rlocs, rlocs, data_len);
17134 /* Wait for a reply... */
17139 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
17142 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
17143 * forwarding entries in data-plane accordingly.
17145 * @param vam vpp API test context
17146 * @return return code
17149 api_one_add_del_adjacency (vat_main_t * vam)
17151 unformat_input_t *input = vam->input;
17152 vl_api_one_add_del_adjacency_t *mp;
17154 ip4_address_t leid4, reid4;
17155 ip6_address_t leid6, reid6;
17156 u8 reid_mac[6] = { 0 };
17157 u8 leid_mac[6] = { 0 };
17158 u8 reid_type, leid_type;
17159 u32 leid_len = 0, reid_len = 0, len;
17163 leid_type = reid_type = (u8) ~ 0;
17165 /* Parse args required to build the message */
17166 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17168 if (unformat (input, "del"))
17172 else if (unformat (input, "add"))
17176 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17179 reid_type = 0; /* ipv4 */
17182 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17185 reid_type = 1; /* ipv6 */
17188 else if (unformat (input, "reid %U", unformat_ethernet_address,
17191 reid_type = 2; /* mac */
17193 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17196 leid_type = 0; /* ipv4 */
17199 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17202 leid_type = 1; /* ipv6 */
17205 else if (unformat (input, "leid %U", unformat_ethernet_address,
17208 leid_type = 2; /* mac */
17210 else if (unformat (input, "vni %d", &vni))
17216 errmsg ("parse error '%U'", format_unformat_error, input);
17221 if ((u8) ~ 0 == reid_type)
17223 errmsg ("missing params!");
17227 if (leid_type != reid_type)
17229 errmsg ("remote and local EIDs are of different types!");
17233 M (ONE_ADD_DEL_ADJACENCY, mp);
17234 mp->is_add = is_add;
17235 mp->vni = htonl (vni);
17236 mp->leid_len = leid_len;
17237 mp->reid_len = reid_len;
17238 mp->eid_type = reid_type;
17240 switch (mp->eid_type)
17243 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17244 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17247 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17248 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17251 clib_memcpy (mp->leid, leid_mac, 6);
17252 clib_memcpy (mp->reid, reid_mac, 6);
17255 errmsg ("unknown EID type %d!", mp->eid_type);
17262 /* Wait for a reply... */
17267 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17270 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17272 u32 *mode = va_arg (*args, u32 *);
17274 if (unformat (input, "lisp"))
17276 else if (unformat (input, "vxlan"))
17285 api_gpe_get_encap_mode (vat_main_t * vam)
17287 vl_api_gpe_get_encap_mode_t *mp;
17290 /* Construct the API message */
17291 M (GPE_GET_ENCAP_MODE, mp);
17296 /* Wait for a reply... */
17302 api_gpe_set_encap_mode (vat_main_t * vam)
17304 unformat_input_t *input = vam->input;
17305 vl_api_gpe_set_encap_mode_t *mp;
17309 /* Parse args required to build the message */
17310 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17312 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17318 /* Construct the API message */
17319 M (GPE_SET_ENCAP_MODE, mp);
17326 /* Wait for a reply... */
17332 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17334 unformat_input_t *input = vam->input;
17335 vl_api_gpe_add_del_iface_t *mp;
17336 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17337 u32 dp_table = 0, vni = 0;
17340 /* Parse args required to build the message */
17341 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17343 if (unformat (input, "up"))
17348 else if (unformat (input, "down"))
17353 else if (unformat (input, "table_id %d", &dp_table))
17357 else if (unformat (input, "bd_id %d", &dp_table))
17362 else if (unformat (input, "vni %d", &vni))
17370 if (action_set == 0)
17372 errmsg ("Action not set");
17375 if (dp_table_set == 0 || vni_set == 0)
17377 errmsg ("vni and dp_table must be set");
17381 /* Construct the API message */
17382 M (GPE_ADD_DEL_IFACE, mp);
17384 mp->is_add = is_add;
17385 mp->dp_table = clib_host_to_net_u32 (dp_table);
17387 mp->vni = clib_host_to_net_u32 (vni);
17392 /* Wait for a reply... */
17398 api_one_map_register_fallback_threshold (vat_main_t * vam)
17400 unformat_input_t *input = vam->input;
17401 vl_api_one_map_register_fallback_threshold_t *mp;
17406 /* Parse args required to build the message */
17407 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17409 if (unformat (input, "%u", &value))
17413 clib_warning ("parse error '%U'", format_unformat_error, input);
17420 errmsg ("fallback threshold value is missing!");
17424 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17425 mp->value = clib_host_to_net_u32 (value);
17430 /* Wait for a reply... */
17436 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17438 vl_api_show_one_map_register_fallback_threshold_t *mp;
17441 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17446 /* Wait for a reply... */
17452 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17454 u32 *proto = va_arg (*args, u32 *);
17456 if (unformat (input, "udp"))
17458 else if (unformat (input, "api"))
17467 api_one_set_transport_protocol (vat_main_t * vam)
17469 unformat_input_t *input = vam->input;
17470 vl_api_one_set_transport_protocol_t *mp;
17475 /* Parse args required to build the message */
17476 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17478 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17482 clib_warning ("parse error '%U'", format_unformat_error, input);
17489 errmsg ("Transport protocol missing!");
17493 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17494 mp->protocol = (u8) protocol;
17499 /* Wait for a reply... */
17505 api_one_get_transport_protocol (vat_main_t * vam)
17507 vl_api_one_get_transport_protocol_t *mp;
17510 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17515 /* Wait for a reply... */
17521 api_one_map_register_set_ttl (vat_main_t * vam)
17523 unformat_input_t *input = vam->input;
17524 vl_api_one_map_register_set_ttl_t *mp;
17529 /* Parse args required to build the message */
17530 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17532 if (unformat (input, "%u", &ttl))
17536 clib_warning ("parse error '%U'", format_unformat_error, input);
17543 errmsg ("TTL value missing!");
17547 M (ONE_MAP_REGISTER_SET_TTL, mp);
17548 mp->ttl = clib_host_to_net_u32 (ttl);
17553 /* Wait for a reply... */
17559 api_show_one_map_register_ttl (vat_main_t * vam)
17561 vl_api_show_one_map_register_ttl_t *mp;
17564 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17569 /* Wait for a reply... */
17575 * Add/del map request itr rlocs from ONE control plane and updates
17577 * @param vam vpp API test context
17578 * @return return code
17581 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17583 unformat_input_t *input = vam->input;
17584 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17585 u8 *locator_set_name = 0;
17586 u8 locator_set_name_set = 0;
17590 /* Parse args required to build the message */
17591 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17593 if (unformat (input, "del"))
17597 else if (unformat (input, "%_%v%_", &locator_set_name))
17599 locator_set_name_set = 1;
17603 clib_warning ("parse error '%U'", format_unformat_error, input);
17608 if (is_add && !locator_set_name_set)
17610 errmsg ("itr-rloc is not set!");
17614 if (is_add && vec_len (locator_set_name) > 64)
17616 errmsg ("itr-rloc locator-set name too long");
17617 vec_free (locator_set_name);
17621 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17622 mp->is_add = is_add;
17625 clib_memcpy (mp->locator_set_name, locator_set_name,
17626 vec_len (locator_set_name));
17630 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17632 vec_free (locator_set_name);
17637 /* Wait for a reply... */
17642 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17645 api_one_locator_dump (vat_main_t * vam)
17647 unformat_input_t *input = vam->input;
17648 vl_api_one_locator_dump_t *mp;
17649 vl_api_control_ping_t *mp_ping;
17650 u8 is_index_set = 0, is_name_set = 0;
17655 /* Parse args required to build the message */
17656 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17658 if (unformat (input, "ls_name %_%v%_", &ls_name))
17662 else if (unformat (input, "ls_index %d", &ls_index))
17668 errmsg ("parse error '%U'", format_unformat_error, input);
17673 if (!is_index_set && !is_name_set)
17675 errmsg ("error: expected one of index or name!");
17679 if (is_index_set && is_name_set)
17681 errmsg ("error: only one param expected!");
17685 if (vec_len (ls_name) > 62)
17687 errmsg ("error: locator set name too long!");
17691 if (!vam->json_output)
17693 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17696 M (ONE_LOCATOR_DUMP, mp);
17697 mp->is_index_set = is_index_set;
17700 mp->ls_index = clib_host_to_net_u32 (ls_index);
17703 vec_add1 (ls_name, 0);
17704 strncpy ((char *) mp->ls_name, (char *) ls_name,
17705 sizeof (mp->ls_name) - 1);
17711 /* Use a control ping for synchronization */
17712 MPING (CONTROL_PING, mp_ping);
17715 /* Wait for a reply... */
17720 #define api_lisp_locator_dump api_one_locator_dump
17723 api_one_locator_set_dump (vat_main_t * vam)
17725 vl_api_one_locator_set_dump_t *mp;
17726 vl_api_control_ping_t *mp_ping;
17727 unformat_input_t *input = vam->input;
17731 /* Parse args required to build the message */
17732 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17734 if (unformat (input, "local"))
17738 else if (unformat (input, "remote"))
17744 errmsg ("parse error '%U'", format_unformat_error, input);
17749 if (!vam->json_output)
17751 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17754 M (ONE_LOCATOR_SET_DUMP, mp);
17756 mp->filter = filter;
17761 /* Use a control ping for synchronization */
17762 MPING (CONTROL_PING, mp_ping);
17765 /* Wait for a reply... */
17770 #define api_lisp_locator_set_dump api_one_locator_set_dump
17773 api_one_eid_table_map_dump (vat_main_t * vam)
17777 unformat_input_t *input = vam->input;
17778 vl_api_one_eid_table_map_dump_t *mp;
17779 vl_api_control_ping_t *mp_ping;
17782 /* Parse args required to build the message */
17783 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17785 if (unformat (input, "l2"))
17790 else if (unformat (input, "l3"))
17797 errmsg ("parse error '%U'", format_unformat_error, input);
17804 errmsg ("expected one of 'l2' or 'l3' parameter!");
17808 if (!vam->json_output)
17810 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17813 M (ONE_EID_TABLE_MAP_DUMP, mp);
17819 /* Use a control ping for synchronization */
17820 MPING (CONTROL_PING, mp_ping);
17823 /* Wait for a reply... */
17828 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17831 api_one_eid_table_vni_dump (vat_main_t * vam)
17833 vl_api_one_eid_table_vni_dump_t *mp;
17834 vl_api_control_ping_t *mp_ping;
17837 if (!vam->json_output)
17839 print (vam->ofp, "VNI");
17842 M (ONE_EID_TABLE_VNI_DUMP, mp);
17847 /* Use a control ping for synchronization */
17848 MPING (CONTROL_PING, mp_ping);
17851 /* Wait for a reply... */
17856 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17859 api_one_eid_table_dump (vat_main_t * vam)
17861 unformat_input_t *i = vam->input;
17862 vl_api_one_eid_table_dump_t *mp;
17863 vl_api_control_ping_t *mp_ping;
17864 struct in_addr ip4;
17865 struct in6_addr ip6;
17867 u8 eid_type = ~0, eid_set = 0;
17868 u32 prefix_length = ~0, t, vni = 0;
17871 lisp_nsh_api_t nsh;
17873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17875 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17881 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17887 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17892 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17897 else if (unformat (i, "vni %d", &t))
17901 else if (unformat (i, "local"))
17905 else if (unformat (i, "remote"))
17911 errmsg ("parse error '%U'", format_unformat_error, i);
17916 if (!vam->json_output)
17918 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17919 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17922 M (ONE_EID_TABLE_DUMP, mp);
17924 mp->filter = filter;
17928 mp->vni = htonl (vni);
17929 mp->eid_type = eid_type;
17933 mp->prefix_length = prefix_length;
17934 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17937 mp->prefix_length = prefix_length;
17938 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17941 clib_memcpy (mp->eid, mac, sizeof (mac));
17944 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17947 errmsg ("unknown EID type %d!", eid_type);
17955 /* Use a control ping for synchronization */
17956 MPING (CONTROL_PING, mp_ping);
17959 /* Wait for a reply... */
17964 #define api_lisp_eid_table_dump api_one_eid_table_dump
17967 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17969 unformat_input_t *i = vam->input;
17970 vl_api_gpe_fwd_entries_get_t *mp;
17975 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17977 if (unformat (i, "vni %d", &vni))
17983 errmsg ("parse error '%U'", format_unformat_error, i);
17990 errmsg ("vni not set!");
17994 if (!vam->json_output)
17996 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
18000 M (GPE_FWD_ENTRIES_GET, mp);
18001 mp->vni = clib_host_to_net_u32 (vni);
18006 /* Wait for a reply... */
18011 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
18012 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
18013 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
18014 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
18015 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
18016 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
18017 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
18018 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
18021 api_one_adjacencies_get (vat_main_t * vam)
18023 unformat_input_t *i = vam->input;
18024 vl_api_one_adjacencies_get_t *mp;
18029 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18031 if (unformat (i, "vni %d", &vni))
18037 errmsg ("parse error '%U'", format_unformat_error, i);
18044 errmsg ("vni not set!");
18048 if (!vam->json_output)
18050 print (vam->ofp, "%s %40s", "leid", "reid");
18053 M (ONE_ADJACENCIES_GET, mp);
18054 mp->vni = clib_host_to_net_u32 (vni);
18059 /* Wait for a reply... */
18064 #define api_lisp_adjacencies_get api_one_adjacencies_get
18067 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
18069 unformat_input_t *i = vam->input;
18070 vl_api_gpe_native_fwd_rpaths_get_t *mp;
18072 u8 ip_family_set = 0, is_ip4 = 1;
18074 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18076 if (unformat (i, "ip4"))
18081 else if (unformat (i, "ip6"))
18088 errmsg ("parse error '%U'", format_unformat_error, i);
18093 if (!ip_family_set)
18095 errmsg ("ip family not set!");
18099 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
18100 mp->is_ip4 = is_ip4;
18105 /* Wait for a reply... */
18111 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
18113 vl_api_gpe_fwd_entry_vnis_get_t *mp;
18116 if (!vam->json_output)
18118 print (vam->ofp, "VNIs");
18121 M (GPE_FWD_ENTRY_VNIS_GET, mp);
18126 /* Wait for a reply... */
18132 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
18134 unformat_input_t *i = vam->input;
18135 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
18137 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
18138 struct in_addr ip4;
18139 struct in6_addr ip6;
18140 u32 table_id = 0, nh_sw_if_index = ~0;
18142 memset (&ip4, 0, sizeof (ip4));
18143 memset (&ip6, 0, sizeof (ip6));
18145 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18147 if (unformat (i, "del"))
18149 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
18150 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18155 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
18156 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18161 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18165 nh_sw_if_index = ~0;
18167 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18171 nh_sw_if_index = ~0;
18173 else if (unformat (i, "table %d", &table_id))
18177 errmsg ("parse error '%U'", format_unformat_error, i);
18184 errmsg ("nh addr not set!");
18188 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18189 mp->is_add = is_add;
18190 mp->table_id = clib_host_to_net_u32 (table_id);
18191 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18192 mp->is_ip4 = is_ip4;
18194 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18196 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18201 /* Wait for a reply... */
18207 api_one_map_server_dump (vat_main_t * vam)
18209 vl_api_one_map_server_dump_t *mp;
18210 vl_api_control_ping_t *mp_ping;
18213 if (!vam->json_output)
18215 print (vam->ofp, "%=20s", "Map server");
18218 M (ONE_MAP_SERVER_DUMP, mp);
18222 /* Use a control ping for synchronization */
18223 MPING (CONTROL_PING, mp_ping);
18226 /* Wait for a reply... */
18231 #define api_lisp_map_server_dump api_one_map_server_dump
18234 api_one_map_resolver_dump (vat_main_t * vam)
18236 vl_api_one_map_resolver_dump_t *mp;
18237 vl_api_control_ping_t *mp_ping;
18240 if (!vam->json_output)
18242 print (vam->ofp, "%=20s", "Map resolver");
18245 M (ONE_MAP_RESOLVER_DUMP, mp);
18249 /* Use a control ping for synchronization */
18250 MPING (CONTROL_PING, mp_ping);
18253 /* Wait for a reply... */
18258 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18261 api_one_stats_flush (vat_main_t * vam)
18263 vl_api_one_stats_flush_t *mp;
18266 M (ONE_STATS_FLUSH, mp);
18273 api_one_stats_dump (vat_main_t * vam)
18275 vl_api_one_stats_dump_t *mp;
18276 vl_api_control_ping_t *mp_ping;
18279 M (ONE_STATS_DUMP, mp);
18283 /* Use a control ping for synchronization */
18284 MPING (CONTROL_PING, mp_ping);
18287 /* Wait for a reply... */
18293 api_show_one_status (vat_main_t * vam)
18295 vl_api_show_one_status_t *mp;
18298 if (!vam->json_output)
18300 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18303 M (SHOW_ONE_STATUS, mp);
18306 /* Wait for a reply... */
18311 #define api_show_lisp_status api_show_one_status
18314 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18316 vl_api_gpe_fwd_entry_path_dump_t *mp;
18317 vl_api_control_ping_t *mp_ping;
18318 unformat_input_t *i = vam->input;
18319 u32 fwd_entry_index = ~0;
18322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18324 if (unformat (i, "index %d", &fwd_entry_index))
18330 if (~0 == fwd_entry_index)
18332 errmsg ("no index specified!");
18336 if (!vam->json_output)
18338 print (vam->ofp, "first line");
18341 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18345 /* Use a control ping for synchronization */
18346 MPING (CONTROL_PING, mp_ping);
18349 /* Wait for a reply... */
18355 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18357 vl_api_one_get_map_request_itr_rlocs_t *mp;
18360 if (!vam->json_output)
18362 print (vam->ofp, "%=20s", "itr-rlocs:");
18365 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18368 /* Wait for a reply... */
18373 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18376 api_af_packet_create (vat_main_t * vam)
18378 unformat_input_t *i = vam->input;
18379 vl_api_af_packet_create_t *mp;
18380 u8 *host_if_name = 0;
18382 u8 random_hw_addr = 1;
18385 memset (hw_addr, 0, sizeof (hw_addr));
18387 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18389 if (unformat (i, "name %s", &host_if_name))
18390 vec_add1 (host_if_name, 0);
18391 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18392 random_hw_addr = 0;
18397 if (!vec_len (host_if_name))
18399 errmsg ("host-interface name must be specified");
18403 if (vec_len (host_if_name) > 64)
18405 errmsg ("host-interface name too long");
18409 M (AF_PACKET_CREATE, mp);
18411 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18412 clib_memcpy (mp->hw_addr, hw_addr, 6);
18413 mp->use_random_hw_addr = random_hw_addr;
18414 vec_free (host_if_name);
18422 fprintf (vam->ofp ? vam->ofp : stderr,
18423 " new sw_if_index = %d\n", vam->sw_if_index);
18430 api_af_packet_delete (vat_main_t * vam)
18432 unformat_input_t *i = vam->input;
18433 vl_api_af_packet_delete_t *mp;
18434 u8 *host_if_name = 0;
18437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18439 if (unformat (i, "name %s", &host_if_name))
18440 vec_add1 (host_if_name, 0);
18445 if (!vec_len (host_if_name))
18447 errmsg ("host-interface name must be specified");
18451 if (vec_len (host_if_name) > 64)
18453 errmsg ("host-interface name too long");
18457 M (AF_PACKET_DELETE, mp);
18459 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18460 vec_free (host_if_name);
18468 api_policer_add_del (vat_main_t * vam)
18470 unformat_input_t *i = vam->input;
18471 vl_api_policer_add_del_t *mp;
18481 u8 color_aware = 0;
18482 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18485 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18486 conform_action.dscp = 0;
18487 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18488 exceed_action.dscp = 0;
18489 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18490 violate_action.dscp = 0;
18492 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18494 if (unformat (i, "del"))
18496 else if (unformat (i, "name %s", &name))
18497 vec_add1 (name, 0);
18498 else if (unformat (i, "cir %u", &cir))
18500 else if (unformat (i, "eir %u", &eir))
18502 else if (unformat (i, "cb %u", &cb))
18504 else if (unformat (i, "eb %u", &eb))
18506 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18509 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18512 else if (unformat (i, "type %U", unformat_policer_type, &type))
18514 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18517 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18520 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18523 else if (unformat (i, "color-aware"))
18529 if (!vec_len (name))
18531 errmsg ("policer name must be specified");
18535 if (vec_len (name) > 64)
18537 errmsg ("policer name too long");
18541 M (POLICER_ADD_DEL, mp);
18543 clib_memcpy (mp->name, name, vec_len (name));
18545 mp->is_add = is_add;
18546 mp->cir = ntohl (cir);
18547 mp->eir = ntohl (eir);
18548 mp->cb = clib_net_to_host_u64 (cb);
18549 mp->eb = clib_net_to_host_u64 (eb);
18550 mp->rate_type = rate_type;
18551 mp->round_type = round_type;
18553 mp->conform_action_type = conform_action.action_type;
18554 mp->conform_dscp = conform_action.dscp;
18555 mp->exceed_action_type = exceed_action.action_type;
18556 mp->exceed_dscp = exceed_action.dscp;
18557 mp->violate_action_type = violate_action.action_type;
18558 mp->violate_dscp = violate_action.dscp;
18559 mp->color_aware = color_aware;
18567 api_policer_dump (vat_main_t * vam)
18569 unformat_input_t *i = vam->input;
18570 vl_api_policer_dump_t *mp;
18571 vl_api_control_ping_t *mp_ping;
18572 u8 *match_name = 0;
18573 u8 match_name_valid = 0;
18576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18578 if (unformat (i, "name %s", &match_name))
18580 vec_add1 (match_name, 0);
18581 match_name_valid = 1;
18587 M (POLICER_DUMP, mp);
18588 mp->match_name_valid = match_name_valid;
18589 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18590 vec_free (match_name);
18594 /* Use a control ping for synchronization */
18595 MPING (CONTROL_PING, mp_ping);
18598 /* Wait for a reply... */
18604 api_policer_classify_set_interface (vat_main_t * vam)
18606 unformat_input_t *i = vam->input;
18607 vl_api_policer_classify_set_interface_t *mp;
18609 int sw_if_index_set;
18610 u32 ip4_table_index = ~0;
18611 u32 ip6_table_index = ~0;
18612 u32 l2_table_index = ~0;
18616 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18618 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18619 sw_if_index_set = 1;
18620 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18621 sw_if_index_set = 1;
18622 else if (unformat (i, "del"))
18624 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18626 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18628 else if (unformat (i, "l2-table %d", &l2_table_index))
18632 clib_warning ("parse error '%U'", format_unformat_error, i);
18637 if (sw_if_index_set == 0)
18639 errmsg ("missing interface name or sw_if_index");
18643 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18645 mp->sw_if_index = ntohl (sw_if_index);
18646 mp->ip4_table_index = ntohl (ip4_table_index);
18647 mp->ip6_table_index = ntohl (ip6_table_index);
18648 mp->l2_table_index = ntohl (l2_table_index);
18649 mp->is_add = is_add;
18657 api_policer_classify_dump (vat_main_t * vam)
18659 unformat_input_t *i = vam->input;
18660 vl_api_policer_classify_dump_t *mp;
18661 vl_api_control_ping_t *mp_ping;
18662 u8 type = POLICER_CLASSIFY_N_TABLES;
18665 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18669 errmsg ("classify table type must be specified");
18673 if (!vam->json_output)
18675 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18678 M (POLICER_CLASSIFY_DUMP, mp);
18683 /* Use a control ping for synchronization */
18684 MPING (CONTROL_PING, mp_ping);
18687 /* Wait for a reply... */
18693 api_netmap_create (vat_main_t * vam)
18695 unformat_input_t *i = vam->input;
18696 vl_api_netmap_create_t *mp;
18699 u8 random_hw_addr = 1;
18704 memset (hw_addr, 0, sizeof (hw_addr));
18706 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18708 if (unformat (i, "name %s", &if_name))
18709 vec_add1 (if_name, 0);
18710 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18711 random_hw_addr = 0;
18712 else if (unformat (i, "pipe"))
18714 else if (unformat (i, "master"))
18716 else if (unformat (i, "slave"))
18722 if (!vec_len (if_name))
18724 errmsg ("interface name must be specified");
18728 if (vec_len (if_name) > 64)
18730 errmsg ("interface name too long");
18734 M (NETMAP_CREATE, mp);
18736 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18737 clib_memcpy (mp->hw_addr, hw_addr, 6);
18738 mp->use_random_hw_addr = random_hw_addr;
18739 mp->is_pipe = is_pipe;
18740 mp->is_master = is_master;
18741 vec_free (if_name);
18749 api_netmap_delete (vat_main_t * vam)
18751 unformat_input_t *i = vam->input;
18752 vl_api_netmap_delete_t *mp;
18756 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18758 if (unformat (i, "name %s", &if_name))
18759 vec_add1 (if_name, 0);
18764 if (!vec_len (if_name))
18766 errmsg ("interface name must be specified");
18770 if (vec_len (if_name) > 64)
18772 errmsg ("interface name too long");
18776 M (NETMAP_DELETE, mp);
18778 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18779 vec_free (if_name);
18787 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
18789 if (fp->afi == IP46_TYPE_IP6)
18791 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18792 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18793 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18794 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18795 format_ip6_address, fp->next_hop);
18796 else if (fp->afi == IP46_TYPE_IP4)
18798 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18799 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18800 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18801 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18802 format_ip4_address, fp->next_hop);
18806 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18807 vl_api_fib_path2_t * fp)
18809 struct in_addr ip4;
18810 struct in6_addr ip6;
18812 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18813 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18814 vat_json_object_add_uint (node, "is_local", fp->is_local);
18815 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18816 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18817 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18818 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18819 if (fp->afi == IP46_TYPE_IP4)
18821 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18822 vat_json_object_add_ip4 (node, "next_hop", ip4);
18824 else if (fp->afi == IP46_TYPE_IP6)
18826 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18827 vat_json_object_add_ip6 (node, "next_hop", ip6);
18832 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18834 vat_main_t *vam = &vat_main;
18835 int count = ntohl (mp->mt_count);
18836 vl_api_fib_path2_t *fp;
18839 print (vam->ofp, "[%d]: sw_if_index %d via:",
18840 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
18842 for (i = 0; i < count; i++)
18844 vl_api_mpls_fib_path_print (vam, fp);
18848 print (vam->ofp, "");
18851 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18852 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18855 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18857 vat_main_t *vam = &vat_main;
18858 vat_json_node_t *node = NULL;
18859 int count = ntohl (mp->mt_count);
18860 vl_api_fib_path2_t *fp;
18863 if (VAT_JSON_ARRAY != vam->json_tree.type)
18865 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18866 vat_json_init_array (&vam->json_tree);
18868 node = vat_json_array_add (&vam->json_tree);
18870 vat_json_init_object (node);
18871 vat_json_object_add_uint (node, "tunnel_index",
18872 ntohl (mp->mt_tunnel_index));
18873 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
18875 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
18878 for (i = 0; i < count; i++)
18880 vl_api_mpls_fib_path_json_print (node, fp);
18886 api_mpls_tunnel_dump (vat_main_t * vam)
18888 vl_api_mpls_tunnel_dump_t *mp;
18889 vl_api_control_ping_t *mp_ping;
18893 /* Parse args required to build the message */
18894 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
18896 if (!unformat (vam->input, "tunnel_index %d", &index))
18903 print (vam->ofp, " tunnel_index %d", index);
18905 M (MPLS_TUNNEL_DUMP, mp);
18906 mp->tunnel_index = htonl (index);
18909 /* Use a control ping for synchronization */
18910 MPING (CONTROL_PING, mp_ping);
18917 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
18918 #define vl_api_mpls_fib_details_t_print vl_noop_handler
18922 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
18924 vat_main_t *vam = &vat_main;
18925 int count = ntohl (mp->count);
18926 vl_api_fib_path2_t *fp;
18930 "table-id %d, label %u, ess_bit %u",
18931 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
18933 for (i = 0; i < count; i++)
18935 vl_api_mpls_fib_path_print (vam, fp);
18940 static void vl_api_mpls_fib_details_t_handler_json
18941 (vl_api_mpls_fib_details_t * mp)
18943 vat_main_t *vam = &vat_main;
18944 int count = ntohl (mp->count);
18945 vat_json_node_t *node = NULL;
18946 vl_api_fib_path2_t *fp;
18949 if (VAT_JSON_ARRAY != vam->json_tree.type)
18951 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18952 vat_json_init_array (&vam->json_tree);
18954 node = vat_json_array_add (&vam->json_tree);
18956 vat_json_init_object (node);
18957 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18958 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
18959 vat_json_object_add_uint (node, "label", ntohl (mp->label));
18960 vat_json_object_add_uint (node, "path_count", count);
18962 for (i = 0; i < count; i++)
18964 vl_api_mpls_fib_path_json_print (node, fp);
18970 api_mpls_fib_dump (vat_main_t * vam)
18972 vl_api_mpls_fib_dump_t *mp;
18973 vl_api_control_ping_t *mp_ping;
18976 M (MPLS_FIB_DUMP, mp);
18979 /* Use a control ping for synchronization */
18980 MPING (CONTROL_PING, mp_ping);
18987 #define vl_api_ip_fib_details_t_endian vl_noop_handler
18988 #define vl_api_ip_fib_details_t_print vl_noop_handler
18991 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
18993 vat_main_t *vam = &vat_main;
18994 int count = ntohl (mp->count);
18995 vl_api_fib_path_t *fp;
18999 "table-id %d, prefix %U/%d",
19000 ntohl (mp->table_id), format_ip4_address, mp->address,
19001 mp->address_length);
19003 for (i = 0; i < count; i++)
19005 if (fp->afi == IP46_TYPE_IP6)
19007 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19008 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19009 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19010 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19011 format_ip6_address, fp->next_hop);
19012 else if (fp->afi == IP46_TYPE_IP4)
19014 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19015 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19016 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19017 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19018 format_ip4_address, fp->next_hop);
19023 static void vl_api_ip_fib_details_t_handler_json
19024 (vl_api_ip_fib_details_t * mp)
19026 vat_main_t *vam = &vat_main;
19027 int count = ntohl (mp->count);
19028 vat_json_node_t *node = NULL;
19029 struct in_addr ip4;
19030 struct in6_addr ip6;
19031 vl_api_fib_path_t *fp;
19034 if (VAT_JSON_ARRAY != vam->json_tree.type)
19036 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19037 vat_json_init_array (&vam->json_tree);
19039 node = vat_json_array_add (&vam->json_tree);
19041 vat_json_init_object (node);
19042 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19043 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
19044 vat_json_object_add_ip4 (node, "prefix", ip4);
19045 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19046 vat_json_object_add_uint (node, "path_count", count);
19048 for (i = 0; i < count; i++)
19050 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19051 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19052 vat_json_object_add_uint (node, "is_local", fp->is_local);
19053 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19054 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19055 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19056 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19057 if (fp->afi == IP46_TYPE_IP4)
19059 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19060 vat_json_object_add_ip4 (node, "next_hop", ip4);
19062 else if (fp->afi == IP46_TYPE_IP6)
19064 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19065 vat_json_object_add_ip6 (node, "next_hop", ip6);
19071 api_ip_fib_dump (vat_main_t * vam)
19073 vl_api_ip_fib_dump_t *mp;
19074 vl_api_control_ping_t *mp_ping;
19077 M (IP_FIB_DUMP, mp);
19080 /* Use a control ping for synchronization */
19081 MPING (CONTROL_PING, mp_ping);
19089 api_ip_mfib_dump (vat_main_t * vam)
19091 vl_api_ip_mfib_dump_t *mp;
19092 vl_api_control_ping_t *mp_ping;
19095 M (IP_MFIB_DUMP, mp);
19098 /* Use a control ping for synchronization */
19099 MPING (CONTROL_PING, mp_ping);
19106 static void vl_api_ip_neighbor_details_t_handler
19107 (vl_api_ip_neighbor_details_t * mp)
19109 vat_main_t *vam = &vat_main;
19111 print (vam->ofp, "%c %U %U",
19112 (mp->is_static) ? 'S' : 'D',
19113 format_ethernet_address, &mp->mac_address,
19114 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
19118 static void vl_api_ip_neighbor_details_t_handler_json
19119 (vl_api_ip_neighbor_details_t * mp)
19122 vat_main_t *vam = &vat_main;
19123 vat_json_node_t *node;
19124 struct in_addr ip4;
19125 struct in6_addr ip6;
19127 if (VAT_JSON_ARRAY != vam->json_tree.type)
19129 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19130 vat_json_init_array (&vam->json_tree);
19132 node = vat_json_array_add (&vam->json_tree);
19134 vat_json_init_object (node);
19135 vat_json_object_add_string_copy (node, "flag",
19136 (mp->is_static) ? (u8 *) "static" : (u8 *)
19139 vat_json_object_add_string_copy (node, "link_layer",
19140 format (0, "%U", format_ethernet_address,
19141 &mp->mac_address));
19145 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
19146 vat_json_object_add_ip6 (node, "ip_address", ip6);
19150 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
19151 vat_json_object_add_ip4 (node, "ip_address", ip4);
19156 api_ip_neighbor_dump (vat_main_t * vam)
19158 unformat_input_t *i = vam->input;
19159 vl_api_ip_neighbor_dump_t *mp;
19160 vl_api_control_ping_t *mp_ping;
19162 u32 sw_if_index = ~0;
19165 /* Parse args required to build the message */
19166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19168 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19170 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19172 else if (unformat (i, "ip6"))
19178 if (sw_if_index == ~0)
19180 errmsg ("missing interface name or sw_if_index");
19184 M (IP_NEIGHBOR_DUMP, mp);
19185 mp->is_ipv6 = (u8) is_ipv6;
19186 mp->sw_if_index = ntohl (sw_if_index);
19189 /* Use a control ping for synchronization */
19190 MPING (CONTROL_PING, mp_ping);
19197 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
19198 #define vl_api_ip6_fib_details_t_print vl_noop_handler
19201 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
19203 vat_main_t *vam = &vat_main;
19204 int count = ntohl (mp->count);
19205 vl_api_fib_path_t *fp;
19209 "table-id %d, prefix %U/%d",
19210 ntohl (mp->table_id), format_ip6_address, mp->address,
19211 mp->address_length);
19213 for (i = 0; i < count; i++)
19215 if (fp->afi == IP46_TYPE_IP6)
19217 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19218 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19219 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19220 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19221 format_ip6_address, fp->next_hop);
19222 else if (fp->afi == IP46_TYPE_IP4)
19224 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19225 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19226 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19227 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19228 format_ip4_address, fp->next_hop);
19233 static void vl_api_ip6_fib_details_t_handler_json
19234 (vl_api_ip6_fib_details_t * mp)
19236 vat_main_t *vam = &vat_main;
19237 int count = ntohl (mp->count);
19238 vat_json_node_t *node = NULL;
19239 struct in_addr ip4;
19240 struct in6_addr ip6;
19241 vl_api_fib_path_t *fp;
19244 if (VAT_JSON_ARRAY != vam->json_tree.type)
19246 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19247 vat_json_init_array (&vam->json_tree);
19249 node = vat_json_array_add (&vam->json_tree);
19251 vat_json_init_object (node);
19252 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19253 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
19254 vat_json_object_add_ip6 (node, "prefix", ip6);
19255 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19256 vat_json_object_add_uint (node, "path_count", count);
19258 for (i = 0; i < count; i++)
19260 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19261 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19262 vat_json_object_add_uint (node, "is_local", fp->is_local);
19263 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19264 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19265 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19266 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19267 if (fp->afi == IP46_TYPE_IP4)
19269 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19270 vat_json_object_add_ip4 (node, "next_hop", ip4);
19272 else if (fp->afi == IP46_TYPE_IP6)
19274 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19275 vat_json_object_add_ip6 (node, "next_hop", ip6);
19281 api_ip6_fib_dump (vat_main_t * vam)
19283 vl_api_ip6_fib_dump_t *mp;
19284 vl_api_control_ping_t *mp_ping;
19287 M (IP6_FIB_DUMP, mp);
19290 /* Use a control ping for synchronization */
19291 MPING (CONTROL_PING, mp_ping);
19299 api_ip6_mfib_dump (vat_main_t * vam)
19301 vl_api_ip6_mfib_dump_t *mp;
19302 vl_api_control_ping_t *mp_ping;
19305 M (IP6_MFIB_DUMP, mp);
19308 /* Use a control ping for synchronization */
19309 MPING (CONTROL_PING, mp_ping);
19317 api_classify_table_ids (vat_main_t * vam)
19319 vl_api_classify_table_ids_t *mp;
19322 /* Construct the API message */
19323 M (CLASSIFY_TABLE_IDS, mp);
19332 api_classify_table_by_interface (vat_main_t * vam)
19334 unformat_input_t *input = vam->input;
19335 vl_api_classify_table_by_interface_t *mp;
19337 u32 sw_if_index = ~0;
19339 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19341 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19343 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19348 if (sw_if_index == ~0)
19350 errmsg ("missing interface name or sw_if_index");
19354 /* Construct the API message */
19355 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19357 mp->sw_if_index = ntohl (sw_if_index);
19365 api_classify_table_info (vat_main_t * vam)
19367 unformat_input_t *input = vam->input;
19368 vl_api_classify_table_info_t *mp;
19372 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19374 if (unformat (input, "table_id %d", &table_id))
19379 if (table_id == ~0)
19381 errmsg ("missing table id");
19385 /* Construct the API message */
19386 M (CLASSIFY_TABLE_INFO, mp);
19388 mp->table_id = ntohl (table_id);
19396 api_classify_session_dump (vat_main_t * vam)
19398 unformat_input_t *input = vam->input;
19399 vl_api_classify_session_dump_t *mp;
19400 vl_api_control_ping_t *mp_ping;
19404 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19406 if (unformat (input, "table_id %d", &table_id))
19411 if (table_id == ~0)
19413 errmsg ("missing table id");
19417 /* Construct the API message */
19418 M (CLASSIFY_SESSION_DUMP, mp);
19420 mp->table_id = ntohl (table_id);
19423 /* Use a control ping for synchronization */
19424 MPING (CONTROL_PING, mp_ping);
19432 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19434 vat_main_t *vam = &vat_main;
19436 print (vam->ofp, "collector_address %U, collector_port %d, "
19437 "src_address %U, vrf_id %d, path_mtu %u, "
19438 "template_interval %u, udp_checksum %d",
19439 format_ip4_address, mp->collector_address,
19440 ntohs (mp->collector_port),
19441 format_ip4_address, mp->src_address,
19442 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19443 ntohl (mp->template_interval), mp->udp_checksum);
19446 vam->result_ready = 1;
19450 vl_api_ipfix_exporter_details_t_handler_json
19451 (vl_api_ipfix_exporter_details_t * mp)
19453 vat_main_t *vam = &vat_main;
19454 vat_json_node_t node;
19455 struct in_addr collector_address;
19456 struct in_addr src_address;
19458 vat_json_init_object (&node);
19459 clib_memcpy (&collector_address, &mp->collector_address,
19460 sizeof (collector_address));
19461 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19462 vat_json_object_add_uint (&node, "collector_port",
19463 ntohs (mp->collector_port));
19464 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19465 vat_json_object_add_ip4 (&node, "src_address", src_address);
19466 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19467 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19468 vat_json_object_add_uint (&node, "template_interval",
19469 ntohl (mp->template_interval));
19470 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19472 vat_json_print (vam->ofp, &node);
19473 vat_json_free (&node);
19475 vam->result_ready = 1;
19479 api_ipfix_exporter_dump (vat_main_t * vam)
19481 vl_api_ipfix_exporter_dump_t *mp;
19484 /* Construct the API message */
19485 M (IPFIX_EXPORTER_DUMP, mp);
19494 api_ipfix_classify_stream_dump (vat_main_t * vam)
19496 vl_api_ipfix_classify_stream_dump_t *mp;
19499 /* Construct the API message */
19500 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19511 vl_api_ipfix_classify_stream_details_t_handler
19512 (vl_api_ipfix_classify_stream_details_t * mp)
19514 vat_main_t *vam = &vat_main;
19515 print (vam->ofp, "domain_id %d, src_port %d",
19516 ntohl (mp->domain_id), ntohs (mp->src_port));
19518 vam->result_ready = 1;
19522 vl_api_ipfix_classify_stream_details_t_handler_json
19523 (vl_api_ipfix_classify_stream_details_t * mp)
19525 vat_main_t *vam = &vat_main;
19526 vat_json_node_t node;
19528 vat_json_init_object (&node);
19529 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19530 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19532 vat_json_print (vam->ofp, &node);
19533 vat_json_free (&node);
19535 vam->result_ready = 1;
19539 api_ipfix_classify_table_dump (vat_main_t * vam)
19541 vl_api_ipfix_classify_table_dump_t *mp;
19542 vl_api_control_ping_t *mp_ping;
19545 if (!vam->json_output)
19547 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19548 "transport_protocol");
19551 /* Construct the API message */
19552 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19557 /* Use a control ping for synchronization */
19558 MPING (CONTROL_PING, mp_ping);
19566 vl_api_ipfix_classify_table_details_t_handler
19567 (vl_api_ipfix_classify_table_details_t * mp)
19569 vat_main_t *vam = &vat_main;
19570 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19571 mp->transport_protocol);
19575 vl_api_ipfix_classify_table_details_t_handler_json
19576 (vl_api_ipfix_classify_table_details_t * mp)
19578 vat_json_node_t *node = NULL;
19579 vat_main_t *vam = &vat_main;
19581 if (VAT_JSON_ARRAY != vam->json_tree.type)
19583 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19584 vat_json_init_array (&vam->json_tree);
19587 node = vat_json_array_add (&vam->json_tree);
19588 vat_json_init_object (node);
19590 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19591 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19592 vat_json_object_add_uint (node, "transport_protocol",
19593 mp->transport_protocol);
19597 api_sw_interface_span_enable_disable (vat_main_t * vam)
19599 unformat_input_t *i = vam->input;
19600 vl_api_sw_interface_span_enable_disable_t *mp;
19601 u32 src_sw_if_index = ~0;
19602 u32 dst_sw_if_index = ~0;
19607 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19610 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19612 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19616 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19618 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19620 else if (unformat (i, "disable"))
19622 else if (unformat (i, "rx"))
19624 else if (unformat (i, "tx"))
19626 else if (unformat (i, "both"))
19628 else if (unformat (i, "l2"))
19634 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19636 mp->sw_if_index_from = htonl (src_sw_if_index);
19637 mp->sw_if_index_to = htonl (dst_sw_if_index);
19647 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19650 vat_main_t *vam = &vat_main;
19651 u8 *sw_if_from_name = 0;
19652 u8 *sw_if_to_name = 0;
19653 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19654 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19655 char *states[] = { "none", "rx", "tx", "both" };
19659 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19661 if ((u32) p->value[0] == sw_if_index_from)
19663 sw_if_from_name = (u8 *)(p->key);
19667 if ((u32) p->value[0] == sw_if_index_to)
19669 sw_if_to_name = (u8 *)(p->key);
19670 if (sw_if_from_name)
19675 print (vam->ofp, "%20s => %20s (%s)",
19676 sw_if_from_name, sw_if_to_name, states[mp->state]);
19680 vl_api_sw_interface_span_details_t_handler_json
19681 (vl_api_sw_interface_span_details_t * mp)
19683 vat_main_t *vam = &vat_main;
19684 vat_json_node_t *node = NULL;
19685 u8 *sw_if_from_name = 0;
19686 u8 *sw_if_to_name = 0;
19687 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19688 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19692 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19694 if ((u32) p->value[0] == sw_if_index_from)
19696 sw_if_from_name = (u8 *)(p->key);
19700 if ((u32) p->value[0] == sw_if_index_to)
19702 sw_if_to_name = (u8 *)(p->key);
19703 if (sw_if_from_name)
19709 if (VAT_JSON_ARRAY != vam->json_tree.type)
19711 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19712 vat_json_init_array (&vam->json_tree);
19714 node = vat_json_array_add (&vam->json_tree);
19716 vat_json_init_object (node);
19717 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19718 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19719 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19720 if (0 != sw_if_to_name)
19722 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19724 vat_json_object_add_uint (node, "state", mp->state);
19728 api_sw_interface_span_dump (vat_main_t * vam)
19730 unformat_input_t *input = vam->input;
19731 vl_api_sw_interface_span_dump_t *mp;
19732 vl_api_control_ping_t *mp_ping;
19736 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19738 if (unformat (input, "l2"))
19744 M (SW_INTERFACE_SPAN_DUMP, mp);
19748 /* Use a control ping for synchronization */
19749 MPING (CONTROL_PING, mp_ping);
19757 api_pg_create_interface (vat_main_t * vam)
19759 unformat_input_t *input = vam->input;
19760 vl_api_pg_create_interface_t *mp;
19764 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19766 if (unformat (input, "if_id %d", &if_id))
19773 errmsg ("missing pg interface index");
19777 /* Construct the API message */
19778 M (PG_CREATE_INTERFACE, mp);
19780 mp->interface_id = ntohl (if_id);
19788 api_pg_capture (vat_main_t * vam)
19790 unformat_input_t *input = vam->input;
19791 vl_api_pg_capture_t *mp;
19796 u8 pcap_file_set = 0;
19799 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19801 if (unformat (input, "if_id %d", &if_id))
19803 else if (unformat (input, "pcap %s", &pcap_file))
19805 else if (unformat (input, "count %d", &count))
19807 else if (unformat (input, "disable"))
19814 errmsg ("missing pg interface index");
19817 if (pcap_file_set > 0)
19819 if (vec_len (pcap_file) > 255)
19821 errmsg ("pcap file name is too long");
19826 u32 name_len = vec_len (pcap_file);
19827 /* Construct the API message */
19828 M (PG_CAPTURE, mp);
19830 mp->interface_id = ntohl (if_id);
19831 mp->is_enabled = enable;
19832 mp->count = ntohl (count);
19833 mp->pcap_name_length = ntohl (name_len);
19834 if (pcap_file_set != 0)
19836 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19838 vec_free (pcap_file);
19846 api_pg_enable_disable (vat_main_t * vam)
19848 unformat_input_t *input = vam->input;
19849 vl_api_pg_enable_disable_t *mp;
19852 u8 stream_name_set = 0;
19853 u8 *stream_name = 0;
19855 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19857 if (unformat (input, "stream %s", &stream_name))
19858 stream_name_set = 1;
19859 else if (unformat (input, "disable"))
19865 if (stream_name_set > 0)
19867 if (vec_len (stream_name) > 255)
19869 errmsg ("stream name too long");
19874 u32 name_len = vec_len (stream_name);
19875 /* Construct the API message */
19876 M (PG_ENABLE_DISABLE, mp);
19878 mp->is_enabled = enable;
19879 if (stream_name_set != 0)
19881 mp->stream_name_length = ntohl (name_len);
19882 clib_memcpy (mp->stream_name, stream_name, name_len);
19884 vec_free (stream_name);
19892 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19894 unformat_input_t *input = vam->input;
19895 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19897 u16 *low_ports = 0;
19898 u16 *high_ports = 0;
19901 ip4_address_t ip4_addr;
19902 ip6_address_t ip6_addr;
19911 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19913 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
19919 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
19924 else if (unformat (input, "vrf %d", &vrf_id))
19926 else if (unformat (input, "del"))
19928 else if (unformat (input, "port %d", &tmp))
19930 if (tmp == 0 || tmp > 65535)
19932 errmsg ("port %d out of range", tmp);
19936 this_hi = this_low + 1;
19937 vec_add1 (low_ports, this_low);
19938 vec_add1 (high_ports, this_hi);
19940 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19942 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19944 errmsg ("incorrect range parameters");
19948 /* Note: in debug CLI +1 is added to high before
19949 passing to real fn that does "the work"
19950 (ip_source_and_port_range_check_add_del).
19951 This fn is a wrapper around the binary API fn a
19952 control plane will call, which expects this increment
19953 to have occurred. Hence letting the binary API control
19954 plane fn do the increment for consistency between VAT
19955 and other control planes.
19958 vec_add1 (low_ports, this_low);
19959 vec_add1 (high_ports, this_hi);
19965 if (prefix_set == 0)
19967 errmsg ("<address>/<mask> not specified");
19973 errmsg ("VRF ID required, not specified");
19980 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19984 if (vec_len (low_ports) == 0)
19986 errmsg ("At least one port or port range required");
19990 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19992 mp->is_add = is_add;
19997 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
20002 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
20005 mp->mask_length = length;
20006 mp->number_of_ranges = vec_len (low_ports);
20008 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
20009 vec_free (low_ports);
20011 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
20012 vec_free (high_ports);
20014 mp->vrf_id = ntohl (vrf_id);
20022 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
20024 unformat_input_t *input = vam->input;
20025 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
20026 u32 sw_if_index = ~0;
20028 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
20029 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
20033 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20035 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20037 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20039 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
20041 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
20043 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
20045 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
20047 else if (unformat (input, "del"))
20053 if (sw_if_index == ~0)
20055 errmsg ("Interface required but not specified");
20061 errmsg ("VRF ID required but not specified");
20065 if (tcp_out_vrf_id == 0
20066 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
20069 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20073 /* Construct the API message */
20074 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
20076 mp->sw_if_index = ntohl (sw_if_index);
20077 mp->is_add = is_add;
20078 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20079 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20080 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20081 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20086 /* Wait for a reply... */
20092 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
20094 unformat_input_t *i = vam->input;
20095 vl_api_ipsec_gre_add_del_tunnel_t *mp;
20096 u32 local_sa_id = 0;
20097 u32 remote_sa_id = 0;
20098 ip4_address_t src_address;
20099 ip4_address_t dst_address;
20103 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20105 if (unformat (i, "local_sa %d", &local_sa_id))
20107 else if (unformat (i, "remote_sa %d", &remote_sa_id))
20109 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
20111 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
20113 else if (unformat (i, "del"))
20117 clib_warning ("parse error '%U'", format_unformat_error, i);
20122 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
20124 mp->local_sa_id = ntohl (local_sa_id);
20125 mp->remote_sa_id = ntohl (remote_sa_id);
20126 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
20127 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
20128 mp->is_add = is_add;
20136 api_punt (vat_main_t * vam)
20138 unformat_input_t *i = vam->input;
20146 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20148 if (unformat (i, "ip %d", &ipv))
20150 else if (unformat (i, "protocol %d", &protocol))
20152 else if (unformat (i, "port %d", &port))
20154 else if (unformat (i, "del"))
20158 clib_warning ("parse error '%U'", format_unformat_error, i);
20165 mp->is_add = (u8) is_add;
20166 mp->ipv = (u8) ipv;
20167 mp->l4_protocol = (u8) protocol;
20168 mp->l4_port = htons ((u16) port);
20175 static void vl_api_ipsec_gre_tunnel_details_t_handler
20176 (vl_api_ipsec_gre_tunnel_details_t * mp)
20178 vat_main_t *vam = &vat_main;
20180 print (vam->ofp, "%11d%15U%15U%14d%14d",
20181 ntohl (mp->sw_if_index),
20182 format_ip4_address, &mp->src_address,
20183 format_ip4_address, &mp->dst_address,
20184 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
20187 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
20188 (vl_api_ipsec_gre_tunnel_details_t * mp)
20190 vat_main_t *vam = &vat_main;
20191 vat_json_node_t *node = NULL;
20192 struct in_addr ip4;
20194 if (VAT_JSON_ARRAY != vam->json_tree.type)
20196 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20197 vat_json_init_array (&vam->json_tree);
20199 node = vat_json_array_add (&vam->json_tree);
20201 vat_json_init_object (node);
20202 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20203 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
20204 vat_json_object_add_ip4 (node, "src_address", ip4);
20205 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
20206 vat_json_object_add_ip4 (node, "dst_address", ip4);
20207 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
20208 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
20212 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
20214 unformat_input_t *i = vam->input;
20215 vl_api_ipsec_gre_tunnel_dump_t *mp;
20216 vl_api_control_ping_t *mp_ping;
20218 u8 sw_if_index_set = 0;
20221 /* Parse args required to build the message */
20222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20224 if (unformat (i, "sw_if_index %d", &sw_if_index))
20225 sw_if_index_set = 1;
20230 if (sw_if_index_set == 0)
20235 if (!vam->json_output)
20237 print (vam->ofp, "%11s%15s%15s%14s%14s",
20238 "sw_if_index", "src_address", "dst_address",
20239 "local_sa_id", "remote_sa_id");
20242 /* Get list of gre-tunnel interfaces */
20243 M (IPSEC_GRE_TUNNEL_DUMP, mp);
20245 mp->sw_if_index = htonl (sw_if_index);
20249 /* Use a control ping for synchronization */
20250 MPING (CONTROL_PING, mp_ping);
20258 api_delete_subif (vat_main_t * vam)
20260 unformat_input_t *i = vam->input;
20261 vl_api_delete_subif_t *mp;
20262 u32 sw_if_index = ~0;
20265 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20267 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20269 if (unformat (i, "sw_if_index %d", &sw_if_index))
20275 if (sw_if_index == ~0)
20277 errmsg ("missing sw_if_index");
20281 /* Construct the API message */
20282 M (DELETE_SUBIF, mp);
20283 mp->sw_if_index = ntohl (sw_if_index);
20290 #define foreach_pbb_vtr_op \
20291 _("disable", L2_VTR_DISABLED) \
20292 _("pop", L2_VTR_POP_2) \
20293 _("push", L2_VTR_PUSH_2)
20296 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20298 unformat_input_t *i = vam->input;
20299 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20300 u32 sw_if_index = ~0, vtr_op = ~0;
20301 u16 outer_tag = ~0;
20302 u8 dmac[6], smac[6];
20303 u8 dmac_set = 0, smac_set = 0;
20309 /* Shut up coverity */
20310 memset (dmac, 0, sizeof (dmac));
20311 memset (smac, 0, sizeof (smac));
20313 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20315 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20317 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20319 else if (unformat (i, "vtr_op %d", &vtr_op))
20321 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20324 else if (unformat (i, "translate_pbb_stag"))
20326 if (unformat (i, "%d", &tmp))
20328 vtr_op = L2_VTR_TRANSLATE_2_1;
20334 ("translate_pbb_stag operation requires outer tag definition");
20338 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20340 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20342 else if (unformat (i, "sid %d", &sid))
20344 else if (unformat (i, "vlanid %d", &tmp))
20348 clib_warning ("parse error '%U'", format_unformat_error, i);
20353 if ((sw_if_index == ~0) || (vtr_op == ~0))
20355 errmsg ("missing sw_if_index or vtr operation");
20358 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20359 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20362 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20366 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20367 mp->sw_if_index = ntohl (sw_if_index);
20368 mp->vtr_op = ntohl (vtr_op);
20369 mp->outer_tag = ntohs (outer_tag);
20370 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20371 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20372 mp->b_vlanid = ntohs (vlanid);
20373 mp->i_sid = ntohl (sid);
20381 api_flow_classify_set_interface (vat_main_t * vam)
20383 unformat_input_t *i = vam->input;
20384 vl_api_flow_classify_set_interface_t *mp;
20386 int sw_if_index_set;
20387 u32 ip4_table_index = ~0;
20388 u32 ip6_table_index = ~0;
20392 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20394 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20395 sw_if_index_set = 1;
20396 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20397 sw_if_index_set = 1;
20398 else if (unformat (i, "del"))
20400 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20402 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20406 clib_warning ("parse error '%U'", format_unformat_error, i);
20411 if (sw_if_index_set == 0)
20413 errmsg ("missing interface name or sw_if_index");
20417 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20419 mp->sw_if_index = ntohl (sw_if_index);
20420 mp->ip4_table_index = ntohl (ip4_table_index);
20421 mp->ip6_table_index = ntohl (ip6_table_index);
20422 mp->is_add = is_add;
20430 api_flow_classify_dump (vat_main_t * vam)
20432 unformat_input_t *i = vam->input;
20433 vl_api_flow_classify_dump_t *mp;
20434 vl_api_control_ping_t *mp_ping;
20435 u8 type = FLOW_CLASSIFY_N_TABLES;
20438 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20442 errmsg ("classify table type must be specified");
20446 if (!vam->json_output)
20448 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20451 M (FLOW_CLASSIFY_DUMP, mp);
20456 /* Use a control ping for synchronization */
20457 MPING (CONTROL_PING, mp_ping);
20460 /* Wait for a reply... */
20466 api_feature_enable_disable (vat_main_t * vam)
20468 unformat_input_t *i = vam->input;
20469 vl_api_feature_enable_disable_t *mp;
20471 u8 *feature_name = 0;
20472 u32 sw_if_index = ~0;
20476 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20478 if (unformat (i, "arc_name %s", &arc_name))
20480 else if (unformat (i, "feature_name %s", &feature_name))
20483 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20485 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20487 else if (unformat (i, "disable"))
20495 errmsg ("missing arc name");
20498 if (vec_len (arc_name) > 63)
20500 errmsg ("arc name too long");
20503 if (feature_name == 0)
20505 errmsg ("missing feature name");
20508 if (vec_len (feature_name) > 63)
20510 errmsg ("feature name too long");
20513 if (sw_if_index == ~0)
20515 errmsg ("missing interface name or sw_if_index");
20519 /* Construct the API message */
20520 M (FEATURE_ENABLE_DISABLE, mp);
20521 mp->sw_if_index = ntohl (sw_if_index);
20522 mp->enable = enable;
20523 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20524 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20525 vec_free (arc_name);
20526 vec_free (feature_name);
20534 api_sw_interface_tag_add_del (vat_main_t * vam)
20536 unformat_input_t *i = vam->input;
20537 vl_api_sw_interface_tag_add_del_t *mp;
20538 u32 sw_if_index = ~0;
20543 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20545 if (unformat (i, "tag %s", &tag))
20547 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20549 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20551 else if (unformat (i, "del"))
20557 if (sw_if_index == ~0)
20559 errmsg ("missing interface name or sw_if_index");
20563 if (enable && (tag == 0))
20565 errmsg ("no tag specified");
20569 /* Construct the API message */
20570 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20571 mp->sw_if_index = ntohl (sw_if_index);
20572 mp->is_add = enable;
20574 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20582 static void vl_api_l2_xconnect_details_t_handler
20583 (vl_api_l2_xconnect_details_t * mp)
20585 vat_main_t *vam = &vat_main;
20587 print (vam->ofp, "%15d%15d",
20588 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20591 static void vl_api_l2_xconnect_details_t_handler_json
20592 (vl_api_l2_xconnect_details_t * mp)
20594 vat_main_t *vam = &vat_main;
20595 vat_json_node_t *node = NULL;
20597 if (VAT_JSON_ARRAY != vam->json_tree.type)
20599 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20600 vat_json_init_array (&vam->json_tree);
20602 node = vat_json_array_add (&vam->json_tree);
20604 vat_json_init_object (node);
20605 vat_json_object_add_uint (node, "rx_sw_if_index",
20606 ntohl (mp->rx_sw_if_index));
20607 vat_json_object_add_uint (node, "tx_sw_if_index",
20608 ntohl (mp->tx_sw_if_index));
20612 api_l2_xconnect_dump (vat_main_t * vam)
20614 vl_api_l2_xconnect_dump_t *mp;
20615 vl_api_control_ping_t *mp_ping;
20618 if (!vam->json_output)
20620 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20623 M (L2_XCONNECT_DUMP, mp);
20627 /* Use a control ping for synchronization */
20628 MPING (CONTROL_PING, mp_ping);
20636 api_sw_interface_set_mtu (vat_main_t * vam)
20638 unformat_input_t *i = vam->input;
20639 vl_api_sw_interface_set_mtu_t *mp;
20640 u32 sw_if_index = ~0;
20644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20646 if (unformat (i, "mtu %d", &mtu))
20648 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20650 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20656 if (sw_if_index == ~0)
20658 errmsg ("missing interface name or sw_if_index");
20664 errmsg ("no mtu specified");
20668 /* Construct the API message */
20669 M (SW_INTERFACE_SET_MTU, mp);
20670 mp->sw_if_index = ntohl (sw_if_index);
20671 mp->mtu = ntohs ((u16) mtu);
20679 api_p2p_ethernet_add (vat_main_t * vam)
20681 unformat_input_t *i = vam->input;
20682 vl_api_p2p_ethernet_add_t *mp;
20683 u32 parent_if_index = ~0;
20689 memset (remote_mac, 0, sizeof (remote_mac));
20690 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20692 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20694 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20698 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20700 else if (unformat (i, "sub_id %d", &sub_id))
20704 clib_warning ("parse error '%U'", format_unformat_error, i);
20709 if (parent_if_index == ~0)
20711 errmsg ("missing interface name or sw_if_index");
20716 errmsg ("missing remote mac address");
20721 errmsg ("missing sub-interface id");
20725 M (P2P_ETHERNET_ADD, mp);
20726 mp->parent_if_index = ntohl (parent_if_index);
20727 mp->subif_id = ntohl (sub_id);
20728 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20736 api_p2p_ethernet_del (vat_main_t * vam)
20738 unformat_input_t *i = vam->input;
20739 vl_api_p2p_ethernet_del_t *mp;
20740 u32 parent_if_index = ~0;
20745 memset (remote_mac, 0, sizeof (remote_mac));
20746 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20748 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20750 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20754 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20758 clib_warning ("parse error '%U'", format_unformat_error, i);
20763 if (parent_if_index == ~0)
20765 errmsg ("missing interface name or sw_if_index");
20770 errmsg ("missing remote mac address");
20774 M (P2P_ETHERNET_DEL, mp);
20775 mp->parent_if_index = ntohl (parent_if_index);
20776 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20784 api_lldp_config (vat_main_t * vam)
20786 unformat_input_t *i = vam->input;
20787 vl_api_lldp_config_t *mp;
20789 int tx_interval = 0;
20790 u8 *sys_name = NULL;
20793 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20795 if (unformat (i, "system-name %s", &sys_name))
20797 else if (unformat (i, "tx-hold %d", &tx_hold))
20799 else if (unformat (i, "tx-interval %d", &tx_interval))
20803 clib_warning ("parse error '%U'", format_unformat_error, i);
20808 vec_add1 (sys_name, 0);
20810 M (LLDP_CONFIG, mp);
20811 mp->tx_hold = htonl (tx_hold);
20812 mp->tx_interval = htonl (tx_interval);
20813 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20814 vec_free (sys_name);
20822 api_sw_interface_set_lldp (vat_main_t * vam)
20824 unformat_input_t *i = vam->input;
20825 vl_api_sw_interface_set_lldp_t *mp;
20826 u32 sw_if_index = ~0;
20828 u8 *port_desc = NULL, *mgmt_oid = NULL;
20829 ip4_address_t ip4_addr;
20830 ip6_address_t ip6_addr;
20833 memset (&ip4_addr, 0, sizeof (ip4_addr));
20834 memset (&ip6_addr, 0, sizeof (ip6_addr));
20836 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20838 if (unformat (i, "disable"))
20841 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20843 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20845 else if (unformat (i, "port-desc %s", &port_desc))
20847 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
20849 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
20851 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
20857 if (sw_if_index == ~0)
20859 errmsg ("missing interface name or sw_if_index");
20863 /* Construct the API message */
20864 vec_add1 (port_desc, 0);
20865 vec_add1 (mgmt_oid, 0);
20866 M (SW_INTERFACE_SET_LLDP, mp);
20867 mp->sw_if_index = ntohl (sw_if_index);
20868 mp->enable = enable;
20869 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20870 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
20871 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
20872 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
20873 vec_free (port_desc);
20874 vec_free (mgmt_oid);
20882 api_tcp_configure_src_addresses (vat_main_t * vam)
20884 vl_api_tcp_configure_src_addresses_t *mp;
20885 unformat_input_t *i = vam->input;
20886 ip4_address_t v4first, v4last;
20887 ip6_address_t v6first, v6last;
20892 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20894 if (unformat (i, "%U - %U",
20895 unformat_ip4_address, &v4first,
20896 unformat_ip4_address, &v4last))
20900 errmsg ("one range per message (range already set)");
20905 else if (unformat (i, "%U - %U",
20906 unformat_ip6_address, &v6first,
20907 unformat_ip6_address, &v6last))
20911 errmsg ("one range per message (range already set)");
20916 else if (unformat (i, "vrf %d", &vrf_id))
20922 if (range_set == 0)
20924 errmsg ("address range not set");
20928 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20929 mp->vrf_id = ntohl (vrf_id);
20931 if (range_set == 2)
20934 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20935 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20940 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20941 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20949 api_app_namespace_add_del (vat_main_t * vam)
20951 vl_api_app_namespace_add_del_t *mp;
20952 unformat_input_t *i = vam->input;
20953 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
20954 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
20958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20960 if (unformat (i, "id %_%v%_", &ns_id))
20962 else if (unformat (i, "secret %lu", &secret))
20964 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20965 sw_if_index_set = 1;
20966 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
20968 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
20973 if (!ns_id || !secret_set || !sw_if_index_set)
20975 errmsg ("namespace id, secret and sw_if_index must be set");
20978 if (vec_len (ns_id) > 64)
20980 errmsg ("namespace id too long");
20983 M (APP_NAMESPACE_ADD_DEL, mp);
20985 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
20986 mp->namespace_id_len = vec_len (ns_id);
20987 mp->secret = secret;
20988 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20989 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
20990 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
20998 api_memfd_segment_create (vat_main_t * vam)
21000 #if VPP_API_TEST_BUILTIN == 0
21001 unformat_input_t *i = vam->input;
21002 vl_api_memfd_segment_create_t *mp;
21003 u64 size = 64 << 20;
21006 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21008 if (unformat (i, "size %U", unformat_memory_size, &size))
21014 M (MEMFD_SEGMENT_CREATE, mp);
21015 mp->requested_size = size;
21021 errmsg ("memfd_segment_create (builtin) not supported");
21027 api_dns_enable_disable (vat_main_t * vam)
21029 unformat_input_t *line_input = vam->input;
21030 vl_api_dns_enable_disable_t *mp;
21031 u8 enable_disable = 1;
21034 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21036 if (unformat (line_input, "disable"))
21037 enable_disable = 0;
21038 if (unformat (line_input, "enable"))
21039 enable_disable = 1;
21044 /* Construct the API message */
21045 M (DNS_ENABLE_DISABLE, mp);
21046 mp->enable = enable_disable;
21050 /* Wait for the reply */
21056 api_dns_resolve_name (vat_main_t * vam)
21058 unformat_input_t *line_input = vam->input;
21059 vl_api_dns_resolve_name_t *mp;
21063 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21065 if (unformat (line_input, "%s", &name))
21071 if (vec_len (name) > 127)
21073 errmsg ("name too long");
21077 /* Construct the API message */
21078 M (DNS_RESOLVE_NAME, mp);
21079 memcpy (mp->name, name, vec_len (name));
21084 /* Wait for the reply */
21090 api_dns_resolve_ip (vat_main_t * vam)
21092 unformat_input_t *line_input = vam->input;
21093 vl_api_dns_resolve_ip_t *mp;
21095 ip4_address_t addr4;
21096 ip6_address_t addr6;
21099 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21101 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
21103 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
21111 errmsg ("missing address");
21115 /* Construct the API message */
21116 M (DNS_RESOLVE_IP, mp);
21117 mp->is_ip6 = is_ip6;
21119 memcpy (mp->address, &addr6, sizeof (addr6));
21121 memcpy (mp->address, &addr4, sizeof (addr4));
21125 /* Wait for the reply */
21131 api_dns_name_server_add_del (vat_main_t * vam)
21133 unformat_input_t *i = vam->input;
21134 vl_api_dns_name_server_add_del_t *mp;
21136 ip6_address_t ip6_server;
21137 ip4_address_t ip4_server;
21142 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21144 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
21146 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
21148 else if (unformat (i, "del"))
21152 clib_warning ("parse error '%U'", format_unformat_error, i);
21157 if (ip4_set && ip6_set)
21159 errmsg ("Only one server address allowed per message");
21162 if ((ip4_set + ip6_set) == 0)
21164 errmsg ("Server address required");
21168 /* Construct the API message */
21169 M (DNS_NAME_SERVER_ADD_DEL, mp);
21173 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
21178 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
21182 mp->is_add = is_add;
21187 /* Wait for a reply, return good/bad news */
21194 q_or_quit (vat_main_t * vam)
21196 #if VPP_API_TEST_BUILTIN == 0
21197 longjmp (vam->jump_buf, 1);
21199 return 0; /* not so much */
21203 q (vat_main_t * vam)
21205 return q_or_quit (vam);
21209 quit (vat_main_t * vam)
21211 return q_or_quit (vam);
21215 comment (vat_main_t * vam)
21221 cmd_cmp (void *a1, void *a2)
21226 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21230 help (vat_main_t * vam)
21235 unformat_input_t *i = vam->input;
21238 if (unformat (i, "%s", &name))
21242 vec_add1 (name, 0);
21244 hs = hash_get_mem (vam->help_by_name, name);
21246 print (vam->ofp, "usage: %s %s", name, hs[0]);
21248 print (vam->ofp, "No such msg / command '%s'", name);
21253 print (vam->ofp, "Help is available for the following:");
21256 hash_foreach_pair (p, vam->function_by_name,
21258 vec_add1 (cmds, (u8 *)(p->key));
21262 vec_sort_with_function (cmds, cmd_cmp);
21264 for (j = 0; j < vec_len (cmds); j++)
21265 print (vam->ofp, "%s", cmds[j]);
21272 set (vat_main_t * vam)
21274 u8 *name = 0, *value = 0;
21275 unformat_input_t *i = vam->input;
21277 if (unformat (i, "%s", &name))
21279 /* The input buffer is a vector, not a string. */
21280 value = vec_dup (i->buffer);
21281 vec_delete (value, i->index, 0);
21282 /* Almost certainly has a trailing newline */
21283 if (value[vec_len (value) - 1] == '\n')
21284 value[vec_len (value) - 1] = 0;
21285 /* Make sure it's a proper string, one way or the other */
21286 vec_add1 (value, 0);
21287 (void) clib_macro_set_value (&vam->macro_main,
21288 (char *) name, (char *) value);
21291 errmsg ("usage: set <name> <value>");
21299 unset (vat_main_t * vam)
21303 if (unformat (vam->input, "%s", &name))
21304 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21305 errmsg ("unset: %s wasn't set", name);
21318 macro_sort_cmp (void *a1, void *a2)
21320 macro_sort_t *s1 = a1;
21321 macro_sort_t *s2 = a2;
21323 return strcmp ((char *) (s1->name), (char *) (s2->name));
21327 dump_macro_table (vat_main_t * vam)
21329 macro_sort_t *sort_me = 0, *sm;
21334 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21336 vec_add2 (sort_me, sm, 1);
21337 sm->name = (u8 *)(p->key);
21338 sm->value = (u8 *) (p->value[0]);
21342 vec_sort_with_function (sort_me, macro_sort_cmp);
21344 if (vec_len (sort_me))
21345 print (vam->ofp, "%-15s%s", "Name", "Value");
21347 print (vam->ofp, "The macro table is empty...");
21349 for (i = 0; i < vec_len (sort_me); i++)
21350 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21355 dump_node_table (vat_main_t * vam)
21358 vlib_node_t *node, *next_node;
21360 if (vec_len (vam->graph_nodes) == 0)
21362 print (vam->ofp, "Node table empty, issue get_node_graph...");
21366 for (i = 0; i < vec_len (vam->graph_nodes); i++)
21368 node = vam->graph_nodes[i];
21369 print (vam->ofp, "[%d] %s", i, node->name);
21370 for (j = 0; j < vec_len (node->next_nodes); j++)
21372 if (node->next_nodes[j] != ~0)
21374 next_node = vam->graph_nodes[node->next_nodes[j]];
21375 print (vam->ofp, " [%d] %s", j, next_node->name);
21383 value_sort_cmp (void *a1, void *a2)
21385 name_sort_t *n1 = a1;
21386 name_sort_t *n2 = a2;
21388 if (n1->value < n2->value)
21390 if (n1->value > n2->value)
21397 dump_msg_api_table (vat_main_t * vam)
21399 api_main_t *am = &api_main;
21400 name_sort_t *nses = 0, *ns;
21405 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21407 vec_add2 (nses, ns, 1);
21408 ns->name = (u8 *)(hp->key);
21409 ns->value = (u32) hp->value[0];
21413 vec_sort_with_function (nses, value_sort_cmp);
21415 for (i = 0; i < vec_len (nses); i++)
21416 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21422 get_msg_id (vat_main_t * vam)
21427 if (unformat (vam->input, "%s", &name_and_crc))
21429 message_index = vl_api_get_msg_index (name_and_crc);
21430 if (message_index == ~0)
21432 print (vam->ofp, " '%s' not found", name_and_crc);
21435 print (vam->ofp, " '%s' has message index %d",
21436 name_and_crc, message_index);
21439 errmsg ("name_and_crc required...");
21444 search_node_table (vat_main_t * vam)
21446 unformat_input_t *line_input = vam->input;
21449 vlib_node_t *node, *next_node;
21452 if (vam->graph_node_index_by_name == 0)
21454 print (vam->ofp, "Node table empty, issue get_node_graph...");
21458 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21460 if (unformat (line_input, "%s", &node_to_find))
21462 vec_add1 (node_to_find, 0);
21463 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21466 print (vam->ofp, "%s not found...", node_to_find);
21469 node = vam->graph_nodes[p[0]];
21470 print (vam->ofp, "[%d] %s", p[0], node->name);
21471 for (j = 0; j < vec_len (node->next_nodes); j++)
21473 if (node->next_nodes[j] != ~0)
21475 next_node = vam->graph_nodes[node->next_nodes[j]];
21476 print (vam->ofp, " [%d] %s", j, next_node->name);
21483 clib_warning ("parse error '%U'", format_unformat_error,
21489 vec_free (node_to_find);
21498 script (vat_main_t * vam)
21500 #if (VPP_API_TEST_BUILTIN==0)
21502 char *save_current_file;
21503 unformat_input_t save_input;
21504 jmp_buf save_jump_buf;
21505 u32 save_line_number;
21507 FILE *new_fp, *save_ifp;
21509 if (unformat (vam->input, "%s", &s))
21511 new_fp = fopen ((char *) s, "r");
21514 errmsg ("Couldn't open script file %s", s);
21521 errmsg ("Missing script name");
21525 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21526 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21527 save_ifp = vam->ifp;
21528 save_line_number = vam->input_line_number;
21529 save_current_file = (char *) vam->current_file;
21531 vam->input_line_number = 0;
21533 vam->current_file = s;
21536 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
21537 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21538 vam->ifp = save_ifp;
21539 vam->input_line_number = save_line_number;
21540 vam->current_file = (u8 *) save_current_file;
21545 clib_warning ("use the exec command...");
21551 echo (vat_main_t * vam)
21553 print (vam->ofp, "%v", vam->input->buffer);
21557 /* List of API message constructors, CLI names map to api_xxx */
21558 #define foreach_vpe_api_msg \
21559 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21560 _(sw_interface_dump,"") \
21561 _(sw_interface_set_flags, \
21562 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21563 _(sw_interface_add_del_address, \
21564 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21565 _(sw_interface_set_table, \
21566 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21567 _(sw_interface_set_mpls_enable, \
21568 "<intfc> | sw_if_index [disable | dis]") \
21569 _(sw_interface_set_vpath, \
21570 "<intfc> | sw_if_index <id> enable | disable") \
21571 _(sw_interface_set_vxlan_bypass, \
21572 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21573 _(sw_interface_set_geneve_bypass, \
21574 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21575 _(sw_interface_set_l2_xconnect, \
21576 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21577 "enable | disable") \
21578 _(sw_interface_set_l2_bridge, \
21579 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21580 "[shg <split-horizon-group>] [bvi]\n" \
21581 "enable | disable") \
21582 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21583 _(bridge_domain_add_del, \
21584 "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") \
21585 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21587 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21588 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21589 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21591 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21593 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21595 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
21597 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
21599 "<vpp-if-name> | sw_if_index <id>") \
21600 _(sw_interface_tap_dump, "") \
21601 _(ip_table_add_del, \
21602 "table-id <n> [ipv6]\n") \
21603 _(ip_add_del_route, \
21604 "<addr>/<mask> via <addr> [table-id <n>]\n" \
21605 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
21606 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
21607 "[multipath] [count <n>]") \
21608 _(ip_mroute_add_del, \
21609 "<src> <grp>/<mask> [table-id <n>]\n" \
21610 "[<intfc> | sw_if_index <id>] [local] [del]") \
21611 _(mpls_table_add_del, \
21612 "table-id <n>\n") \
21613 _(mpls_route_add_del, \
21614 "<label> <eos> via <addr> [table-id <n>]\n" \
21615 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
21616 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
21617 "[multipath] [count <n>]") \
21618 _(mpls_ip_bind_unbind, \
21619 "<label> <addr/len>") \
21620 _(mpls_tunnel_add_del, \
21621 " via <addr> [table-id <n>]\n" \
21622 "sw_if_index <id>] [l2] [del]") \
21623 _(proxy_arp_add_del, \
21624 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
21625 _(proxy_arp_intfc_enable_disable, \
21626 "<intfc> | sw_if_index <id> enable | disable") \
21627 _(sw_interface_set_unnumbered, \
21628 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
21629 _(ip_neighbor_add_del, \
21630 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
21631 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
21632 _(reset_vrf, "vrf <id> [ipv6]") \
21633 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
21634 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
21635 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
21636 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
21637 "[outer_vlan_id_any][inner_vlan_id_any]") \
21638 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
21639 _(reset_fib, "vrf <n> [ipv6]") \
21640 _(dhcp_proxy_config, \
21641 "svr <v46-address> src <v46-address>\n" \
21642 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
21643 _(dhcp_proxy_set_vss, \
21644 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
21645 _(dhcp_proxy_dump, "ip6") \
21646 _(dhcp_client_config, \
21647 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
21648 _(set_ip_flow_hash, \
21649 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
21650 _(sw_interface_ip6_enable_disable, \
21651 "<intfc> | sw_if_index <id> enable | disable") \
21652 _(sw_interface_ip6_set_link_local_address, \
21653 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
21654 _(ip6nd_proxy_add_del, \
21655 "<intfc> | sw_if_index <id> <ip6-address>") \
21656 _(ip6nd_proxy_dump, "") \
21657 _(sw_interface_ip6nd_ra_prefix, \
21658 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
21659 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
21660 "[nolink] [isno]") \
21661 _(sw_interface_ip6nd_ra_config, \
21662 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
21663 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
21664 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
21665 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
21666 _(l2_patch_add_del, \
21667 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21668 "enable | disable") \
21669 _(sr_localsid_add_del, \
21670 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
21671 "fib-table <num> (end.psp) sw_if_index <num>") \
21672 _(classify_add_del_table, \
21673 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
21674 " [del] [del-chain] mask <mask-value>\n" \
21675 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
21676 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
21677 _(classify_add_del_session, \
21678 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
21679 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
21680 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
21681 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
21682 _(classify_set_interface_ip_table, \
21683 "<intfc> | sw_if_index <nn> table <nn>") \
21684 _(classify_set_interface_l2_tables, \
21685 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21686 " [other-table <nn>]") \
21687 _(get_node_index, "node <node-name") \
21688 _(add_node_next, "node <node-name> next <next-node-name>") \
21689 _(l2tpv3_create_tunnel, \
21690 "client_address <ip6-addr> our_address <ip6-addr>\n" \
21691 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
21692 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
21693 _(l2tpv3_set_tunnel_cookies, \
21694 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
21695 "[new_remote_cookie <nn>]\n") \
21696 _(l2tpv3_interface_enable_disable, \
21697 "<intfc> | sw_if_index <nn> enable | disable") \
21698 _(l2tpv3_set_lookup_key, \
21699 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
21700 _(sw_if_l2tpv3_tunnel_dump, "") \
21701 _(vxlan_add_del_tunnel, \
21702 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21703 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21704 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21705 _(geneve_add_del_tunnel, \
21706 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21707 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21708 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21709 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21710 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21711 _(gre_add_del_tunnel, \
21712 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
21713 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21714 _(l2_fib_clear_table, "") \
21715 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
21716 _(l2_interface_vlan_tag_rewrite, \
21717 "<intfc> | sw_if_index <nn> \n" \
21718 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
21719 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
21720 _(create_vhost_user_if, \
21721 "socket <filename> [server] [renumber <dev_instance>] " \
21722 "[mac <mac_address>]") \
21723 _(modify_vhost_user_if, \
21724 "<intfc> | sw_if_index <nn> socket <filename>\n" \
21725 "[server] [renumber <dev_instance>]") \
21726 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
21727 _(sw_interface_vhost_user_dump, "") \
21728 _(show_version, "") \
21729 _(vxlan_gpe_add_del_tunnel, \
21730 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
21731 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21732 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
21733 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
21734 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21735 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
21736 _(interface_name_renumber, \
21737 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
21738 _(input_acl_set_interface, \
21739 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21740 " [l2-table <nn>] [del]") \
21741 _(want_ip4_arp_events, "address <ip4-address> [del]") \
21742 _(want_ip6_nd_events, "address <ip6-address> [del]") \
21743 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
21744 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
21745 _(ip_dump, "ipv4 | ipv6") \
21746 _(ipsec_spd_add_del, "spd_id <n> [del]") \
21747 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
21749 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
21750 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
21751 " integ_alg <alg> integ_key <hex>") \
21752 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
21753 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
21754 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
21755 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
21756 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
21757 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
21758 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
21759 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
21760 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
21761 _(ipsec_sa_dump, "[sa_id <n>]") \
21762 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
21763 " <alg> <hex>\n") \
21764 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
21765 _(ikev2_profile_add_del, "name <profile_name> [del]") \
21766 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
21767 "(auth_data 0x<data> | auth_data <data>)") \
21768 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
21769 "(id_data 0x<data> | id_data <data>) (local|remote)") \
21770 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
21771 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
21772 "(local|remote)") \
21773 _(ikev2_set_local_key, "file <absolute_file_path>") \
21774 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
21775 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
21776 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
21777 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
21778 _(ikev2_initiate_sa_init, "<profile_name>") \
21779 _(ikev2_initiate_del_ike_sa, "<ispi>") \
21780 _(ikev2_initiate_del_child_sa, "<ispi>") \
21781 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
21782 _(delete_loopback,"sw_if_index <nn>") \
21783 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
21784 _(map_add_domain, \
21785 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
21786 "ip6-src <ip6addr> " \
21787 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
21788 _(map_del_domain, "index <n>") \
21789 _(map_add_del_rule, \
21790 "index <n> psid <n> dst <ip6addr> [del]") \
21791 _(map_domain_dump, "") \
21792 _(map_rule_dump, "index <map-domain>") \
21793 _(want_interface_events, "enable|disable") \
21794 _(want_stats,"enable|disable") \
21795 _(get_first_msg_id, "client <name>") \
21796 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
21797 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
21798 "fib-id <nn> [ip4][ip6][default]") \
21799 _(get_node_graph, " ") \
21800 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
21801 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
21802 _(ioam_disable, "") \
21803 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
21804 " sw_if_index <sw_if_index> p <priority> " \
21805 "w <weight>] [del]") \
21806 _(one_add_del_locator, "locator-set <locator_name> " \
21807 "iface <intf> | sw_if_index <sw_if_index> " \
21808 "p <priority> w <weight> [del]") \
21809 _(one_add_del_local_eid,"vni <vni> eid " \
21810 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21811 "locator-set <locator_name> [del]" \
21812 "[key-id sha1|sha256 secret-key <secret-key>]")\
21813 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
21814 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
21815 _(one_enable_disable, "enable|disable") \
21816 _(one_map_register_enable_disable, "enable|disable") \
21817 _(one_map_register_fallback_threshold, "<value>") \
21818 _(one_rloc_probe_enable_disable, "enable|disable") \
21819 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21821 "rloc <locator> p <prio> " \
21822 "w <weight> [rloc <loc> ... ] " \
21823 "action <action> [del-all]") \
21824 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21826 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21827 _(one_use_petr, "ip-address> | disable") \
21828 _(one_map_request_mode, "src-dst|dst-only") \
21829 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21830 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21831 _(one_locator_set_dump, "[local | remote]") \
21832 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
21833 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21834 "[local] | [remote]") \
21835 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
21836 _(one_ndp_bd_get, "") \
21837 _(one_ndp_entries_get, "bd <bridge-domain>") \
21838 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
21839 _(one_l2_arp_bd_get, "") \
21840 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
21841 _(one_stats_enable_disable, "enable|disalbe") \
21842 _(show_one_stats_enable_disable, "") \
21843 _(one_eid_table_vni_dump, "") \
21844 _(one_eid_table_map_dump, "l2|l3") \
21845 _(one_map_resolver_dump, "") \
21846 _(one_map_server_dump, "") \
21847 _(one_adjacencies_get, "vni <vni>") \
21848 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
21849 _(show_one_rloc_probe_state, "") \
21850 _(show_one_map_register_state, "") \
21851 _(show_one_status, "") \
21852 _(one_stats_dump, "") \
21853 _(one_stats_flush, "") \
21854 _(one_get_map_request_itr_rlocs, "") \
21855 _(one_map_register_set_ttl, "<ttl>") \
21856 _(one_set_transport_protocol, "udp|api") \
21857 _(one_get_transport_protocol, "") \
21858 _(show_one_nsh_mapping, "") \
21859 _(show_one_pitr, "") \
21860 _(show_one_use_petr, "") \
21861 _(show_one_map_request_mode, "") \
21862 _(show_one_map_register_ttl, "") \
21863 _(show_one_map_register_fallback_threshold, "") \
21864 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
21865 " sw_if_index <sw_if_index> p <priority> " \
21866 "w <weight>] [del]") \
21867 _(lisp_add_del_locator, "locator-set <locator_name> " \
21868 "iface <intf> | sw_if_index <sw_if_index> " \
21869 "p <priority> w <weight> [del]") \
21870 _(lisp_add_del_local_eid,"vni <vni> eid " \
21871 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21872 "locator-set <locator_name> [del]" \
21873 "[key-id sha1|sha256 secret-key <secret-key>]") \
21874 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
21875 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
21876 _(lisp_enable_disable, "enable|disable") \
21877 _(lisp_map_register_enable_disable, "enable|disable") \
21878 _(lisp_rloc_probe_enable_disable, "enable|disable") \
21879 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21881 "rloc <locator> p <prio> " \
21882 "w <weight> [rloc <loc> ... ] " \
21883 "action <action> [del-all]") \
21884 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21886 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21887 _(lisp_use_petr, "<ip-address> | disable") \
21888 _(lisp_map_request_mode, "src-dst|dst-only") \
21889 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21890 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21891 _(lisp_locator_set_dump, "[local | remote]") \
21892 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
21893 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21894 "[local] | [remote]") \
21895 _(lisp_eid_table_vni_dump, "") \
21896 _(lisp_eid_table_map_dump, "l2|l3") \
21897 _(lisp_map_resolver_dump, "") \
21898 _(lisp_map_server_dump, "") \
21899 _(lisp_adjacencies_get, "vni <vni>") \
21900 _(gpe_fwd_entry_vnis_get, "") \
21901 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
21902 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
21903 "[table <table-id>]") \
21904 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
21905 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
21906 _(gpe_set_encap_mode, "lisp|vxlan") \
21907 _(gpe_get_encap_mode, "") \
21908 _(lisp_gpe_add_del_iface, "up|down") \
21909 _(lisp_gpe_enable_disable, "enable|disable") \
21910 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
21911 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
21912 _(show_lisp_rloc_probe_state, "") \
21913 _(show_lisp_map_register_state, "") \
21914 _(show_lisp_status, "") \
21915 _(lisp_get_map_request_itr_rlocs, "") \
21916 _(show_lisp_pitr, "") \
21917 _(show_lisp_use_petr, "") \
21918 _(show_lisp_map_request_mode, "") \
21919 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
21920 _(af_packet_delete, "name <host interface name>") \
21921 _(policer_add_del, "name <policer name> <params> [del]") \
21922 _(policer_dump, "[name <policer name>]") \
21923 _(policer_classify_set_interface, \
21924 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21925 " [l2-table <nn>] [del]") \
21926 _(policer_classify_dump, "type [ip4|ip6|l2]") \
21927 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
21928 "[master|slave]") \
21929 _(netmap_delete, "name <interface name>") \
21930 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
21931 _(mpls_fib_dump, "") \
21932 _(classify_table_ids, "") \
21933 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
21934 _(classify_table_info, "table_id <nn>") \
21935 _(classify_session_dump, "table_id <nn>") \
21936 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
21937 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
21938 "[template_interval <nn>] [udp_checksum]") \
21939 _(ipfix_exporter_dump, "") \
21940 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
21941 _(ipfix_classify_stream_dump, "") \
21942 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
21943 _(ipfix_classify_table_dump, "") \
21944 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
21945 _(sw_interface_span_dump, "[l2]") \
21946 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
21947 _(pg_create_interface, "if_id <nn>") \
21948 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
21949 _(pg_enable_disable, "[stream <id>] disable") \
21950 _(ip_source_and_port_range_check_add_del, \
21951 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
21952 _(ip_source_and_port_range_check_interface_add_del, \
21953 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
21954 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
21955 _(ipsec_gre_add_del_tunnel, \
21956 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
21957 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
21958 _(delete_subif,"<intfc> | sw_if_index <nn>") \
21959 _(l2_interface_pbb_tag_rewrite, \
21960 "<intfc> | sw_if_index <nn> \n" \
21961 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
21962 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
21963 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
21964 _(flow_classify_set_interface, \
21965 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
21966 _(flow_classify_dump, "type [ip4|ip6]") \
21967 _(ip_fib_dump, "") \
21968 _(ip_mfib_dump, "") \
21969 _(ip6_fib_dump, "") \
21970 _(ip6_mfib_dump, "") \
21971 _(feature_enable_disable, "arc_name <arc_name> " \
21972 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
21973 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
21975 _(l2_xconnect_dump, "") \
21976 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
21977 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
21978 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
21979 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
21980 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
21981 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
21982 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
21983 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
21984 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
21985 _(memfd_segment_create,"size <nnn>") \
21986 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
21987 _(dns_enable_disable, "[enable][disable]") \
21988 _(dns_name_server_add_del, "<ip-address> [del]") \
21989 _(dns_resolve_name, "<hostname>") \
21990 _(dns_resolve_ip, "<ip4|ip6>")
21992 /* List of command functions, CLI names map directly to functions */
21993 #define foreach_cli_function \
21994 _(comment, "usage: comment <ignore-rest-of-line>") \
21995 _(dump_interface_table, "usage: dump_interface_table") \
21996 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
21997 _(dump_ipv4_table, "usage: dump_ipv4_table") \
21998 _(dump_ipv6_table, "usage: dump_ipv6_table") \
21999 _(dump_stats_table, "usage: dump_stats_table") \
22000 _(dump_macro_table, "usage: dump_macro_table ") \
22001 _(dump_node_table, "usage: dump_node_table") \
22002 _(dump_msg_api_table, "usage: dump_msg_api_table") \
22003 _(get_msg_id, "usage: get_msg_id name_and_crc") \
22004 _(echo, "usage: echo <message>") \
22005 _(exec, "usage: exec <vpe-debug-CLI-command>") \
22006 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
22007 _(help, "usage: help") \
22008 _(q, "usage: quit") \
22009 _(quit, "usage: quit") \
22010 _(search_node_table, "usage: search_node_table <name>...") \
22011 _(set, "usage: set <variable-name> <value>") \
22012 _(script, "usage: script <file-name>") \
22013 _(unset, "usage: unset <variable-name>")
22015 static void vl_api_##n##_t_handler_uni \
22016 (vl_api_##n##_t * mp) \
22018 vat_main_t * vam = &vat_main; \
22019 if (vam->json_output) { \
22020 vl_api_##n##_t_handler_json(mp); \
22022 vl_api_##n##_t_handler(mp); \
22025 foreach_vpe_api_reply_msg;
22026 #if VPP_API_TEST_BUILTIN == 0
22027 foreach_standalone_reply_msg;
22032 vat_api_hookup (vat_main_t * vam)
22035 vl_msg_api_set_handlers(VL_API_##N, #n, \
22036 vl_api_##n##_t_handler_uni, \
22038 vl_api_##n##_t_endian, \
22039 vl_api_##n##_t_print, \
22040 sizeof(vl_api_##n##_t), 1);
22041 foreach_vpe_api_reply_msg;
22042 #if VPP_API_TEST_BUILTIN == 0
22043 foreach_standalone_reply_msg;
22047 #if (VPP_API_TEST_BUILTIN==0)
22048 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
22050 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
22052 vam->function_by_name = hash_create_string (0, sizeof (uword));
22054 vam->help_by_name = hash_create_string (0, sizeof (uword));
22057 /* API messages we can send */
22058 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
22059 foreach_vpe_api_msg;
22063 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22064 foreach_vpe_api_msg;
22067 /* CLI functions */
22068 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
22069 foreach_cli_function;
22073 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22074 foreach_cli_function;
22078 #if VPP_API_TEST_BUILTIN
22079 static clib_error_t *
22080 vat_api_hookup_shim (vlib_main_t * vm)
22082 vat_api_hookup (&vat_main);
22086 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
22090 * fd.io coding-style-patch-verification: ON
22093 * eval: (c-set-style "gnu")