2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vppinfra/socket.h>
22 #include <svm/memfd.h>
23 #include <vlibapi/api.h>
24 #include <vlibmemory/api.h>
25 #include <vnet/ip/ip.h>
26 #include <vnet/l2/l2_input.h>
27 #include <vnet/l2tp/l2tp.h>
28 #include <vnet/vxlan/vxlan.h>
29 #include <vnet/geneve/geneve.h>
30 #include <vnet/gre/gre.h>
31 #include <vnet/vxlan-gpe/vxlan_gpe.h>
32 #include <vnet/lisp-gpe/lisp_gpe.h>
34 #include <vpp/api/vpe_msg_enum.h>
35 #include <vnet/l2/l2_classify.h>
36 #include <vnet/l2/l2_vtr.h>
37 #include <vnet/classify/input_acl.h>
38 #include <vnet/classify/policer_classify.h>
39 #include <vnet/classify/flow_classify.h>
40 #include <vnet/mpls/mpls.h>
41 #include <vnet/ipsec/ipsec.h>
42 #include <vnet/ipsec/ikev2.h>
44 #include <vnet/map/map.h>
45 #include <vnet/cop/cop.h>
46 #include <vnet/ip/ip6_hop_by_hop.h>
47 #include <vnet/ip/ip_source_and_port_range_check.h>
48 #include <vnet/policer/xlate.h>
49 #include <vnet/span/span.h>
50 #include <vnet/policer/policer.h>
51 #include <vnet/policer/police.h>
52 #include <vnet/mfib/mfib_types.h>
54 #include "vat/json_format.h"
59 #define vl_typedefs /* define message structures */
60 #include <vpp/api/vpe_all_api_h.h>
63 /* declare message handlers for each api */
65 #define vl_endianfun /* define message structures */
66 #include <vpp/api/vpe_all_api_h.h>
69 /* instantiate all the print functions we know about */
70 #define vl_print(handle, ...)
72 #include <vpp/api/vpe_all_api_h.h>
75 #define __plugin_msg_base 0
76 #include <vlibapi/vat_helper_macros.h>
78 #if VPP_API_TEST_BUILTIN == 0
88 vat_socket_connect (vat_main_t * vam)
90 return vl_socket_client_connect
91 (&vam->socket_client_main, (char *) vam->socket_name,
92 "vpp_api_test(s)", 0 /* default socket rx, tx buffer */ );
94 #else /* vpp built-in case, we don't do sockets... */
96 vat_socket_connect (vat_main_t * vam)
102 vl_socket_client_read_reply (socket_client_main_t * scm)
109 vat_time_now (vat_main_t * vam)
111 #if VPP_API_TEST_BUILTIN
112 return vlib_time_now (vam->vlib_main);
114 return clib_time_now (&vam->clib_time);
119 errmsg (char *fmt, ...)
121 vat_main_t *vam = &vat_main;
126 s = va_format (0, fmt, &va);
131 #if VPP_API_TEST_BUILTIN
132 vlib_cli_output (vam->vlib_main, (char *) s);
135 if (vam->ifp != stdin)
136 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
137 vam->input_line_number);
138 fformat (vam->ofp, (char *) s);
146 #if VPP_API_TEST_BUILTIN == 0
148 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
150 vat_main_t *vam = va_arg (*args, vat_main_t *);
151 u32 *result = va_arg (*args, u32 *);
155 if (!unformat (input, "%s", &if_name))
158 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
165 /* Parse an IP4 address %d.%d.%d.%d. */
167 unformat_ip4_address (unformat_input_t * input, va_list * args)
169 u8 *result = va_arg (*args, u8 *);
172 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
175 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
187 unformat_ethernet_address (unformat_input_t * input, va_list * args)
189 u8 *result = va_arg (*args, u8 *);
192 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
193 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
197 for (i = 0; i < 6; i++)
198 if (a[i] >= (1 << 8))
201 for (i = 0; i < 6; i++)
207 /* Returns ethernet type as an int in host byte order. */
209 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
212 u16 *result = va_arg (*args, u16 *);
216 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
218 if (type >= (1 << 16))
226 /* Parse an IP6 address. */
228 unformat_ip6_address (unformat_input_t * input, va_list * args)
230 ip6_address_t *result = va_arg (*args, ip6_address_t *);
232 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
233 uword c, n_colon, double_colon_index;
235 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
236 double_colon_index = ARRAY_LEN (hex_quads);
237 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
240 if (c >= '0' && c <= '9')
242 else if (c >= 'a' && c <= 'f')
243 hex_digit = c + 10 - 'a';
244 else if (c >= 'A' && c <= 'F')
245 hex_digit = c + 10 - 'A';
246 else if (c == ':' && n_colon < 2)
250 unformat_put_input (input);
254 /* Too many hex quads. */
255 if (n_hex_quads >= ARRAY_LEN (hex_quads))
260 hex_quad = (hex_quad << 4) | hex_digit;
262 /* Hex quad must fit in 16 bits. */
263 if (n_hex_digits >= 4)
270 /* Save position of :: */
273 /* More than one :: ? */
274 if (double_colon_index < ARRAY_LEN (hex_quads))
276 double_colon_index = n_hex_quads;
279 if (n_colon > 0 && n_hex_digits > 0)
281 hex_quads[n_hex_quads++] = hex_quad;
287 if (n_hex_digits > 0)
288 hex_quads[n_hex_quads++] = hex_quad;
293 /* Expand :: to appropriate number of zero hex quads. */
294 if (double_colon_index < ARRAY_LEN (hex_quads))
296 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
298 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
299 hex_quads[n_zero + i] = hex_quads[i];
301 for (i = 0; i < n_zero; i++)
302 hex_quads[double_colon_index + i] = 0;
304 n_hex_quads = ARRAY_LEN (hex_quads);
307 /* Too few hex quads given. */
308 if (n_hex_quads < ARRAY_LEN (hex_quads))
311 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
312 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
319 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
321 u32 *r = va_arg (*args, u32 *);
324 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
325 foreach_ipsec_policy_action
333 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
335 u32 *r = va_arg (*args, u32 *);
338 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
339 foreach_ipsec_crypto_alg
347 format_ipsec_crypto_alg (u8 * s, va_list * args)
349 u32 i = va_arg (*args, u32);
354 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
355 foreach_ipsec_crypto_alg
358 return format (s, "unknown");
360 return format (s, "%s", t);
364 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
366 u32 *r = va_arg (*args, u32 *);
369 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
370 foreach_ipsec_integ_alg
378 format_ipsec_integ_alg (u8 * s, va_list * args)
380 u32 i = va_arg (*args, u32);
385 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
386 foreach_ipsec_integ_alg
389 return format (s, "unknown");
391 return format (s, "%s", t);
395 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
397 u32 *r = va_arg (*args, u32 *);
400 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
401 foreach_ikev2_auth_method
409 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
411 u32 *r = va_arg (*args, u32 *);
414 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
415 foreach_ikev2_id_type
421 #else /* VPP_API_TEST_BUILTIN == 1 */
423 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
425 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
426 vnet_main_t *vnm = vnet_get_main ();
427 u32 *result = va_arg (*args, u32 *);
430 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
433 *result = sw_if_index;
436 #endif /* VPP_API_TEST_BUILTIN */
439 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
441 u8 *r = va_arg (*args, u8 *);
443 if (unformat (input, "kbps"))
444 *r = SSE2_QOS_RATE_KBPS;
445 else if (unformat (input, "pps"))
446 *r = SSE2_QOS_RATE_PPS;
453 unformat_policer_round_type (unformat_input_t * input, va_list * args)
455 u8 *r = va_arg (*args, u8 *);
457 if (unformat (input, "closest"))
458 *r = SSE2_QOS_ROUND_TO_CLOSEST;
459 else if (unformat (input, "up"))
460 *r = SSE2_QOS_ROUND_TO_UP;
461 else if (unformat (input, "down"))
462 *r = SSE2_QOS_ROUND_TO_DOWN;
469 unformat_policer_type (unformat_input_t * input, va_list * args)
471 u8 *r = va_arg (*args, u8 *);
473 if (unformat (input, "1r2c"))
474 *r = SSE2_QOS_POLICER_TYPE_1R2C;
475 else if (unformat (input, "1r3c"))
476 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
477 else if (unformat (input, "2r3c-2698"))
478 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
479 else if (unformat (input, "2r3c-4115"))
480 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
481 else if (unformat (input, "2r3c-mef5cf1"))
482 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
489 unformat_dscp (unformat_input_t * input, va_list * va)
491 u8 *r = va_arg (*va, u8 *);
494 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
503 unformat_policer_action_type (unformat_input_t * input, va_list * va)
505 sse2_qos_pol_action_params_st *a
506 = va_arg (*va, sse2_qos_pol_action_params_st *);
508 if (unformat (input, "drop"))
509 a->action_type = SSE2_QOS_ACTION_DROP;
510 else if (unformat (input, "transmit"))
511 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
512 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
513 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
520 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
522 u32 *r = va_arg (*va, u32 *);
525 if (unformat (input, "ip4"))
526 tid = POLICER_CLASSIFY_TABLE_IP4;
527 else if (unformat (input, "ip6"))
528 tid = POLICER_CLASSIFY_TABLE_IP6;
529 else if (unformat (input, "l2"))
530 tid = POLICER_CLASSIFY_TABLE_L2;
539 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
541 u32 *r = va_arg (*va, u32 *);
544 if (unformat (input, "ip4"))
545 tid = FLOW_CLASSIFY_TABLE_IP4;
546 else if (unformat (input, "ip6"))
547 tid = FLOW_CLASSIFY_TABLE_IP6;
555 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
556 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
557 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
558 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
560 #if (VPP_API_TEST_BUILTIN==0)
562 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
564 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
565 mfib_itf_attribute_t attr;
568 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
570 if (unformat (input, mfib_itf_flag_long_names[attr]))
571 *iflags |= (1 << attr);
573 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
575 if (unformat (input, mfib_itf_flag_names[attr]))
576 *iflags |= (1 << attr);
579 return (old == *iflags ? 0 : 1);
583 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
585 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
586 mfib_entry_attribute_t attr;
589 FOR_EACH_MFIB_ATTRIBUTE (attr)
591 if (unformat (input, mfib_flag_long_names[attr]))
592 *eflags |= (1 << attr);
594 FOR_EACH_MFIB_ATTRIBUTE (attr)
596 if (unformat (input, mfib_flag_names[attr]))
597 *eflags |= (1 << attr);
600 return (old == *eflags ? 0 : 1);
604 format_ip4_address (u8 * s, va_list * args)
606 u8 *a = va_arg (*args, u8 *);
607 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
611 format_ip6_address (u8 * s, va_list * args)
613 ip6_address_t *a = va_arg (*args, ip6_address_t *);
614 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
616 i_max_n_zero = ARRAY_LEN (a->as_u16);
618 i_first_zero = i_max_n_zero;
620 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
622 u32 is_zero = a->as_u16[i] == 0;
623 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
629 if ((!is_zero && n_zeros > max_n_zeros)
630 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
632 i_max_n_zero = i_first_zero;
633 max_n_zeros = n_zeros;
634 i_first_zero = ARRAY_LEN (a->as_u16);
639 last_double_colon = 0;
640 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
642 if (i == i_max_n_zero && max_n_zeros > 1)
644 s = format (s, "::");
645 i += max_n_zeros - 1;
646 last_double_colon = 1;
650 s = format (s, "%s%x",
651 (last_double_colon || i == 0) ? "" : ":",
652 clib_net_to_host_u16 (a->as_u16[i]));
653 last_double_colon = 0;
660 /* Format an IP46 address. */
662 format_ip46_address (u8 * s, va_list * args)
664 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
665 ip46_type_t type = va_arg (*args, ip46_type_t);
671 is_ip4 = ip46_address_is_ip4 (ip46);
682 format (s, "%U", format_ip4_address, &ip46->ip4) :
683 format (s, "%U", format_ip6_address, &ip46->ip6);
687 format_ethernet_address (u8 * s, va_list * args)
689 u8 *a = va_arg (*args, u8 *);
691 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
692 a[0], a[1], a[2], a[3], a[4], a[5]);
697 increment_v4_address (ip4_address_t * a)
701 v = ntohl (a->as_u32) + 1;
702 a->as_u32 = ntohl (v);
706 increment_v6_address (ip6_address_t * a)
710 v0 = clib_net_to_host_u64 (a->as_u64[0]);
711 v1 = clib_net_to_host_u64 (a->as_u64[1]);
716 a->as_u64[0] = clib_net_to_host_u64 (v0);
717 a->as_u64[1] = clib_net_to_host_u64 (v1);
721 increment_mac_address (u8 * mac)
723 u64 tmp = *((u64 *) mac);
724 tmp = clib_net_to_host_u64 (tmp);
725 tmp += 1 << 16; /* skip unused (least significant) octets */
726 tmp = clib_host_to_net_u64 (tmp);
728 clib_memcpy (mac, &tmp, 6);
731 static void vl_api_create_loopback_reply_t_handler
732 (vl_api_create_loopback_reply_t * mp)
734 vat_main_t *vam = &vat_main;
735 i32 retval = ntohl (mp->retval);
737 vam->retval = retval;
738 vam->regenerate_interface_table = 1;
739 vam->sw_if_index = ntohl (mp->sw_if_index);
740 vam->result_ready = 1;
743 static void vl_api_create_loopback_reply_t_handler_json
744 (vl_api_create_loopback_reply_t * mp)
746 vat_main_t *vam = &vat_main;
747 vat_json_node_t node;
749 vat_json_init_object (&node);
750 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
751 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
753 vat_json_print (vam->ofp, &node);
754 vat_json_free (&node);
755 vam->retval = ntohl (mp->retval);
756 vam->result_ready = 1;
759 static void vl_api_create_loopback_instance_reply_t_handler
760 (vl_api_create_loopback_instance_reply_t * mp)
762 vat_main_t *vam = &vat_main;
763 i32 retval = ntohl (mp->retval);
765 vam->retval = retval;
766 vam->regenerate_interface_table = 1;
767 vam->sw_if_index = ntohl (mp->sw_if_index);
768 vam->result_ready = 1;
771 static void vl_api_create_loopback_instance_reply_t_handler_json
772 (vl_api_create_loopback_instance_reply_t * mp)
774 vat_main_t *vam = &vat_main;
775 vat_json_node_t node;
777 vat_json_init_object (&node);
778 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
779 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
781 vat_json_print (vam->ofp, &node);
782 vat_json_free (&node);
783 vam->retval = ntohl (mp->retval);
784 vam->result_ready = 1;
787 static void vl_api_af_packet_create_reply_t_handler
788 (vl_api_af_packet_create_reply_t * mp)
790 vat_main_t *vam = &vat_main;
791 i32 retval = ntohl (mp->retval);
793 vam->retval = retval;
794 vam->regenerate_interface_table = 1;
795 vam->sw_if_index = ntohl (mp->sw_if_index);
796 vam->result_ready = 1;
799 static void vl_api_af_packet_create_reply_t_handler_json
800 (vl_api_af_packet_create_reply_t * mp)
802 vat_main_t *vam = &vat_main;
803 vat_json_node_t node;
805 vat_json_init_object (&node);
806 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
807 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
809 vat_json_print (vam->ofp, &node);
810 vat_json_free (&node);
812 vam->retval = ntohl (mp->retval);
813 vam->result_ready = 1;
816 static void vl_api_create_vlan_subif_reply_t_handler
817 (vl_api_create_vlan_subif_reply_t * mp)
819 vat_main_t *vam = &vat_main;
820 i32 retval = ntohl (mp->retval);
822 vam->retval = retval;
823 vam->regenerate_interface_table = 1;
824 vam->sw_if_index = ntohl (mp->sw_if_index);
825 vam->result_ready = 1;
828 static void vl_api_create_vlan_subif_reply_t_handler_json
829 (vl_api_create_vlan_subif_reply_t * mp)
831 vat_main_t *vam = &vat_main;
832 vat_json_node_t node;
834 vat_json_init_object (&node);
835 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
836 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
838 vat_json_print (vam->ofp, &node);
839 vat_json_free (&node);
841 vam->retval = ntohl (mp->retval);
842 vam->result_ready = 1;
845 static void vl_api_create_subif_reply_t_handler
846 (vl_api_create_subif_reply_t * mp)
848 vat_main_t *vam = &vat_main;
849 i32 retval = ntohl (mp->retval);
851 vam->retval = retval;
852 vam->regenerate_interface_table = 1;
853 vam->sw_if_index = ntohl (mp->sw_if_index);
854 vam->result_ready = 1;
857 static void vl_api_create_subif_reply_t_handler_json
858 (vl_api_create_subif_reply_t * mp)
860 vat_main_t *vam = &vat_main;
861 vat_json_node_t node;
863 vat_json_init_object (&node);
864 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
865 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
867 vat_json_print (vam->ofp, &node);
868 vat_json_free (&node);
870 vam->retval = ntohl (mp->retval);
871 vam->result_ready = 1;
874 static void vl_api_interface_name_renumber_reply_t_handler
875 (vl_api_interface_name_renumber_reply_t * mp)
877 vat_main_t *vam = &vat_main;
878 i32 retval = ntohl (mp->retval);
880 vam->retval = retval;
881 vam->regenerate_interface_table = 1;
882 vam->result_ready = 1;
885 static void vl_api_interface_name_renumber_reply_t_handler_json
886 (vl_api_interface_name_renumber_reply_t * mp)
888 vat_main_t *vam = &vat_main;
889 vat_json_node_t node;
891 vat_json_init_object (&node);
892 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
894 vat_json_print (vam->ofp, &node);
895 vat_json_free (&node);
897 vam->retval = ntohl (mp->retval);
898 vam->result_ready = 1;
902 * Special-case: build the interface table, maintain
903 * the next loopback sw_if_index vbl.
905 static void vl_api_sw_interface_details_t_handler
906 (vl_api_sw_interface_details_t * mp)
908 vat_main_t *vam = &vat_main;
909 u8 *s = format (0, "%s%c", mp->interface_name, 0);
911 hash_set_mem (vam->sw_if_index_by_interface_name, s,
912 ntohl (mp->sw_if_index));
914 /* In sub interface case, fill the sub interface table entry */
915 if (mp->sw_if_index != mp->sup_sw_if_index)
917 sw_interface_subif_t *sub = NULL;
919 vec_add2 (vam->sw_if_subif_table, sub, 1);
921 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
922 strncpy ((char *) sub->interface_name, (char *) s,
923 vec_len (sub->interface_name));
924 sub->sw_if_index = ntohl (mp->sw_if_index);
925 sub->sub_id = ntohl (mp->sub_id);
927 sub->sub_dot1ad = mp->sub_dot1ad;
928 sub->sub_number_of_tags = mp->sub_number_of_tags;
929 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
930 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
931 sub->sub_exact_match = mp->sub_exact_match;
932 sub->sub_default = mp->sub_default;
933 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
934 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
936 /* vlan tag rewrite */
937 sub->vtr_op = ntohl (mp->vtr_op);
938 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
939 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
940 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
944 static void vl_api_sw_interface_details_t_handler_json
945 (vl_api_sw_interface_details_t * mp)
947 vat_main_t *vam = &vat_main;
948 vat_json_node_t *node = NULL;
950 if (VAT_JSON_ARRAY != vam->json_tree.type)
952 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
953 vat_json_init_array (&vam->json_tree);
955 node = vat_json_array_add (&vam->json_tree);
957 vat_json_init_object (node);
958 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
959 vat_json_object_add_uint (node, "sup_sw_if_index",
960 ntohl (mp->sup_sw_if_index));
961 vat_json_object_add_uint (node, "l2_address_length",
962 ntohl (mp->l2_address_length));
963 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
964 sizeof (mp->l2_address));
965 vat_json_object_add_string_copy (node, "interface_name",
967 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
968 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
969 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
970 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
971 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
972 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
973 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
974 vat_json_object_add_uint (node, "sub_number_of_tags",
975 mp->sub_number_of_tags);
976 vat_json_object_add_uint (node, "sub_outer_vlan_id",
977 ntohs (mp->sub_outer_vlan_id));
978 vat_json_object_add_uint (node, "sub_inner_vlan_id",
979 ntohs (mp->sub_inner_vlan_id));
980 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
981 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
982 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
983 mp->sub_outer_vlan_id_any);
984 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
985 mp->sub_inner_vlan_id_any);
986 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
987 vat_json_object_add_uint (node, "vtr_push_dot1q",
988 ntohl (mp->vtr_push_dot1q));
989 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
990 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
993 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
995 format_ethernet_address,
997 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
999 format_ethernet_address,
1001 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1002 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1006 #if VPP_API_TEST_BUILTIN == 0
1007 static void vl_api_sw_interface_event_t_handler
1008 (vl_api_sw_interface_event_t * mp)
1010 vat_main_t *vam = &vat_main;
1011 if (vam->interface_event_display)
1012 errmsg ("interface flags: sw_if_index %d %s %s",
1013 ntohl (mp->sw_if_index),
1014 mp->admin_up_down ? "admin-up" : "admin-down",
1015 mp->link_up_down ? "link-up" : "link-down");
1019 static void vl_api_sw_interface_event_t_handler_json
1020 (vl_api_sw_interface_event_t * mp)
1022 /* JSON output not supported */
1026 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1028 vat_main_t *vam = &vat_main;
1029 i32 retval = ntohl (mp->retval);
1031 vam->retval = retval;
1032 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1033 vam->result_ready = 1;
1037 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1039 vat_main_t *vam = &vat_main;
1040 vat_json_node_t node;
1041 api_main_t *am = &api_main;
1045 vat_json_init_object (&node);
1046 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1047 vat_json_object_add_uint (&node, "reply_in_shmem",
1048 ntohl (mp->reply_in_shmem));
1049 /* Toss the shared-memory original... */
1050 pthread_mutex_lock (&am->vlib_rp->mutex);
1051 oldheap = svm_push_data_heap (am->vlib_rp);
1053 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1056 svm_pop_heap (oldheap);
1057 pthread_mutex_unlock (&am->vlib_rp->mutex);
1059 vat_json_print (vam->ofp, &node);
1060 vat_json_free (&node);
1062 vam->retval = ntohl (mp->retval);
1063 vam->result_ready = 1;
1067 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1069 vat_main_t *vam = &vat_main;
1070 i32 retval = ntohl (mp->retval);
1071 u32 length = ntohl (mp->length);
1073 vec_reset_length (vam->cmd_reply);
1075 vam->retval = retval;
1078 vec_validate (vam->cmd_reply, length);
1079 clib_memcpy ((char *) (vam->cmd_reply), mp->reply, length);
1080 vam->cmd_reply[length] = 0;
1082 vam->result_ready = 1;
1086 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1088 vat_main_t *vam = &vat_main;
1089 vat_json_node_t node;
1091 vec_reset_length (vam->cmd_reply);
1093 vat_json_init_object (&node);
1094 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1095 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1097 vat_json_print (vam->ofp, &node);
1098 vat_json_free (&node);
1100 vam->retval = ntohl (mp->retval);
1101 vam->result_ready = 1;
1104 static void vl_api_classify_add_del_table_reply_t_handler
1105 (vl_api_classify_add_del_table_reply_t * mp)
1107 vat_main_t *vam = &vat_main;
1108 i32 retval = ntohl (mp->retval);
1109 if (vam->async_mode)
1111 vam->async_errors += (retval < 0);
1115 vam->retval = retval;
1117 ((mp->new_table_index != 0xFFFFFFFF) ||
1118 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1119 (mp->match_n_vectors != 0xFFFFFFFF)))
1121 * Note: this is just barely thread-safe, depends on
1122 * the main thread spinning waiting for an answer...
1124 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1125 ntohl (mp->new_table_index),
1126 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1127 vam->result_ready = 1;
1131 static void vl_api_classify_add_del_table_reply_t_handler_json
1132 (vl_api_classify_add_del_table_reply_t * mp)
1134 vat_main_t *vam = &vat_main;
1135 vat_json_node_t node;
1137 vat_json_init_object (&node);
1138 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1139 vat_json_object_add_uint (&node, "new_table_index",
1140 ntohl (mp->new_table_index));
1141 vat_json_object_add_uint (&node, "skip_n_vectors",
1142 ntohl (mp->skip_n_vectors));
1143 vat_json_object_add_uint (&node, "match_n_vectors",
1144 ntohl (mp->match_n_vectors));
1146 vat_json_print (vam->ofp, &node);
1147 vat_json_free (&node);
1149 vam->retval = ntohl (mp->retval);
1150 vam->result_ready = 1;
1153 static void vl_api_get_node_index_reply_t_handler
1154 (vl_api_get_node_index_reply_t * mp)
1156 vat_main_t *vam = &vat_main;
1157 i32 retval = ntohl (mp->retval);
1158 if (vam->async_mode)
1160 vam->async_errors += (retval < 0);
1164 vam->retval = retval;
1166 errmsg ("node index %d", ntohl (mp->node_index));
1167 vam->result_ready = 1;
1171 static void vl_api_get_node_index_reply_t_handler_json
1172 (vl_api_get_node_index_reply_t * mp)
1174 vat_main_t *vam = &vat_main;
1175 vat_json_node_t node;
1177 vat_json_init_object (&node);
1178 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1179 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1181 vat_json_print (vam->ofp, &node);
1182 vat_json_free (&node);
1184 vam->retval = ntohl (mp->retval);
1185 vam->result_ready = 1;
1188 static void vl_api_get_next_index_reply_t_handler
1189 (vl_api_get_next_index_reply_t * mp)
1191 vat_main_t *vam = &vat_main;
1192 i32 retval = ntohl (mp->retval);
1193 if (vam->async_mode)
1195 vam->async_errors += (retval < 0);
1199 vam->retval = retval;
1201 errmsg ("next node index %d", ntohl (mp->next_index));
1202 vam->result_ready = 1;
1206 static void vl_api_get_next_index_reply_t_handler_json
1207 (vl_api_get_next_index_reply_t * mp)
1209 vat_main_t *vam = &vat_main;
1210 vat_json_node_t node;
1212 vat_json_init_object (&node);
1213 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1214 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1216 vat_json_print (vam->ofp, &node);
1217 vat_json_free (&node);
1219 vam->retval = ntohl (mp->retval);
1220 vam->result_ready = 1;
1223 static void vl_api_add_node_next_reply_t_handler
1224 (vl_api_add_node_next_reply_t * mp)
1226 vat_main_t *vam = &vat_main;
1227 i32 retval = ntohl (mp->retval);
1228 if (vam->async_mode)
1230 vam->async_errors += (retval < 0);
1234 vam->retval = retval;
1236 errmsg ("next index %d", ntohl (mp->next_index));
1237 vam->result_ready = 1;
1241 static void vl_api_add_node_next_reply_t_handler_json
1242 (vl_api_add_node_next_reply_t * mp)
1244 vat_main_t *vam = &vat_main;
1245 vat_json_node_t node;
1247 vat_json_init_object (&node);
1248 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1249 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1251 vat_json_print (vam->ofp, &node);
1252 vat_json_free (&node);
1254 vam->retval = ntohl (mp->retval);
1255 vam->result_ready = 1;
1258 static void vl_api_show_version_reply_t_handler
1259 (vl_api_show_version_reply_t * mp)
1261 vat_main_t *vam = &vat_main;
1262 i32 retval = ntohl (mp->retval);
1266 errmsg (" program: %s", mp->program);
1267 errmsg (" version: %s", mp->version);
1268 errmsg (" build date: %s", mp->build_date);
1269 errmsg ("build directory: %s", mp->build_directory);
1271 vam->retval = retval;
1272 vam->result_ready = 1;
1275 static void vl_api_show_version_reply_t_handler_json
1276 (vl_api_show_version_reply_t * mp)
1278 vat_main_t *vam = &vat_main;
1279 vat_json_node_t node;
1281 vat_json_init_object (&node);
1282 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1283 vat_json_object_add_string_copy (&node, "program", mp->program);
1284 vat_json_object_add_string_copy (&node, "version", mp->version);
1285 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1286 vat_json_object_add_string_copy (&node, "build_directory",
1287 mp->build_directory);
1289 vat_json_print (vam->ofp, &node);
1290 vat_json_free (&node);
1292 vam->retval = ntohl (mp->retval);
1293 vam->result_ready = 1;
1297 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1299 u32 sw_if_index = ntohl (mp->sw_if_index);
1300 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1301 mp->mac_ip ? "mac/ip binding" : "address resolution",
1302 ntohl (mp->pid), format_ip4_address, &mp->address,
1303 format_ethernet_address, mp->new_mac, sw_if_index);
1307 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1309 /* JSON output not supported */
1313 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1315 u32 sw_if_index = ntohl (mp->sw_if_index);
1316 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1317 mp->mac_ip ? "mac/ip binding" : "address resolution",
1318 ntohl (mp->pid), format_ip6_address, mp->address,
1319 format_ethernet_address, mp->new_mac, sw_if_index);
1323 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1325 /* JSON output not supported */
1329 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1331 u32 n_macs = ntohl (mp->n_macs);
1332 errmsg ("L2MAC event recived with pid %d cl-idx %d for %d macs: \n",
1333 ntohl (mp->pid), mp->client_index, n_macs);
1335 for (i = 0; i < n_macs; i++)
1337 vl_api_mac_entry_t *mac = &mp->mac[i];
1338 errmsg (" [%d] sw_if_index %d mac_addr %U is_del %d \n",
1339 i + 1, ntohl (mac->sw_if_index),
1340 format_ethernet_address, mac->mac_addr, mac->is_del);
1347 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1349 /* JSON output not supported */
1352 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1353 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1356 * Special-case: build the bridge domain table, maintain
1357 * the next bd id vbl.
1359 static void vl_api_bridge_domain_details_t_handler
1360 (vl_api_bridge_domain_details_t * mp)
1362 vat_main_t *vam = &vat_main;
1363 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1366 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1367 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1369 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1370 ntohl (mp->bd_id), mp->learn, mp->forward,
1371 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1375 vl_api_bridge_domain_sw_if_t *sw_ifs;
1376 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1379 sw_ifs = mp->sw_if_details;
1380 for (i = 0; i < n_sw_ifs; i++)
1386 sw_if_index = ntohl (sw_ifs->sw_if_index);
1389 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1391 if ((u32) p->value[0] == sw_if_index)
1393 sw_if_name = (u8 *)(p->key);
1398 print (vam->ofp, "%7d %3d %s", sw_if_index,
1399 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1400 "sw_if_index not found!");
1407 static void vl_api_bridge_domain_details_t_handler_json
1408 (vl_api_bridge_domain_details_t * mp)
1410 vat_main_t *vam = &vat_main;
1411 vat_json_node_t *node, *array = NULL;
1412 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1414 if (VAT_JSON_ARRAY != vam->json_tree.type)
1416 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1417 vat_json_init_array (&vam->json_tree);
1419 node = vat_json_array_add (&vam->json_tree);
1421 vat_json_init_object (node);
1422 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1423 vat_json_object_add_uint (node, "flood", mp->flood);
1424 vat_json_object_add_uint (node, "forward", mp->forward);
1425 vat_json_object_add_uint (node, "learn", mp->learn);
1426 vat_json_object_add_uint (node, "bvi_sw_if_index",
1427 ntohl (mp->bvi_sw_if_index));
1428 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1429 array = vat_json_object_add (node, "sw_if");
1430 vat_json_init_array (array);
1436 vl_api_bridge_domain_sw_if_t *sw_ifs;
1439 sw_ifs = mp->sw_if_details;
1440 for (i = 0; i < n_sw_ifs; i++)
1442 node = vat_json_array_add (array);
1443 vat_json_init_object (node);
1444 vat_json_object_add_uint (node, "sw_if_index",
1445 ntohl (sw_ifs->sw_if_index));
1446 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1452 static void vl_api_control_ping_reply_t_handler
1453 (vl_api_control_ping_reply_t * mp)
1455 vat_main_t *vam = &vat_main;
1456 i32 retval = ntohl (mp->retval);
1457 if (vam->async_mode)
1459 vam->async_errors += (retval < 0);
1463 vam->retval = retval;
1464 vam->result_ready = 1;
1466 vam->socket_client_main.control_pings_outstanding--;
1469 static void vl_api_control_ping_reply_t_handler_json
1470 (vl_api_control_ping_reply_t * mp)
1472 vat_main_t *vam = &vat_main;
1473 i32 retval = ntohl (mp->retval);
1475 if (VAT_JSON_NONE != vam->json_tree.type)
1477 vat_json_print (vam->ofp, &vam->json_tree);
1478 vat_json_free (&vam->json_tree);
1479 vam->json_tree.type = VAT_JSON_NONE;
1484 vat_json_init_array (&vam->json_tree);
1485 vat_json_print (vam->ofp, &vam->json_tree);
1486 vam->json_tree.type = VAT_JSON_NONE;
1489 vam->retval = retval;
1490 vam->result_ready = 1;
1494 vl_api_bridge_domain_set_mac_age_reply_t_handler
1495 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1497 vat_main_t *vam = &vat_main;
1498 i32 retval = ntohl (mp->retval);
1499 if (vam->async_mode)
1501 vam->async_errors += (retval < 0);
1505 vam->retval = retval;
1506 vam->result_ready = 1;
1510 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1511 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1513 vat_main_t *vam = &vat_main;
1514 vat_json_node_t node;
1516 vat_json_init_object (&node);
1517 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1519 vat_json_print (vam->ofp, &node);
1520 vat_json_free (&node);
1522 vam->retval = ntohl (mp->retval);
1523 vam->result_ready = 1;
1527 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1529 vat_main_t *vam = &vat_main;
1530 i32 retval = ntohl (mp->retval);
1531 if (vam->async_mode)
1533 vam->async_errors += (retval < 0);
1537 vam->retval = retval;
1538 vam->result_ready = 1;
1542 static void vl_api_l2_flags_reply_t_handler_json
1543 (vl_api_l2_flags_reply_t * mp)
1545 vat_main_t *vam = &vat_main;
1546 vat_json_node_t node;
1548 vat_json_init_object (&node);
1549 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1550 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1551 ntohl (mp->resulting_feature_bitmap));
1553 vat_json_print (vam->ofp, &node);
1554 vat_json_free (&node);
1556 vam->retval = ntohl (mp->retval);
1557 vam->result_ready = 1;
1560 static void vl_api_bridge_flags_reply_t_handler
1561 (vl_api_bridge_flags_reply_t * mp)
1563 vat_main_t *vam = &vat_main;
1564 i32 retval = ntohl (mp->retval);
1565 if (vam->async_mode)
1567 vam->async_errors += (retval < 0);
1571 vam->retval = retval;
1572 vam->result_ready = 1;
1576 static void vl_api_bridge_flags_reply_t_handler_json
1577 (vl_api_bridge_flags_reply_t * mp)
1579 vat_main_t *vam = &vat_main;
1580 vat_json_node_t node;
1582 vat_json_init_object (&node);
1583 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1584 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1585 ntohl (mp->resulting_feature_bitmap));
1587 vat_json_print (vam->ofp, &node);
1588 vat_json_free (&node);
1590 vam->retval = ntohl (mp->retval);
1591 vam->result_ready = 1;
1594 static void vl_api_tap_connect_reply_t_handler
1595 (vl_api_tap_connect_reply_t * mp)
1597 vat_main_t *vam = &vat_main;
1598 i32 retval = ntohl (mp->retval);
1599 if (vam->async_mode)
1601 vam->async_errors += (retval < 0);
1605 vam->retval = retval;
1606 vam->sw_if_index = ntohl (mp->sw_if_index);
1607 vam->result_ready = 1;
1612 static void vl_api_tap_connect_reply_t_handler_json
1613 (vl_api_tap_connect_reply_t * mp)
1615 vat_main_t *vam = &vat_main;
1616 vat_json_node_t node;
1618 vat_json_init_object (&node);
1619 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1620 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1622 vat_json_print (vam->ofp, &node);
1623 vat_json_free (&node);
1625 vam->retval = ntohl (mp->retval);
1626 vam->result_ready = 1;
1631 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1633 vat_main_t *vam = &vat_main;
1634 i32 retval = ntohl (mp->retval);
1635 if (vam->async_mode)
1637 vam->async_errors += (retval < 0);
1641 vam->retval = retval;
1642 vam->sw_if_index = ntohl (mp->sw_if_index);
1643 vam->result_ready = 1;
1647 static void vl_api_tap_modify_reply_t_handler_json
1648 (vl_api_tap_modify_reply_t * mp)
1650 vat_main_t *vam = &vat_main;
1651 vat_json_node_t node;
1653 vat_json_init_object (&node);
1654 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1655 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1657 vat_json_print (vam->ofp, &node);
1658 vat_json_free (&node);
1660 vam->retval = ntohl (mp->retval);
1661 vam->result_ready = 1;
1665 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1667 vat_main_t *vam = &vat_main;
1668 i32 retval = ntohl (mp->retval);
1669 if (vam->async_mode)
1671 vam->async_errors += (retval < 0);
1675 vam->retval = retval;
1676 vam->result_ready = 1;
1680 static void vl_api_tap_delete_reply_t_handler_json
1681 (vl_api_tap_delete_reply_t * mp)
1683 vat_main_t *vam = &vat_main;
1684 vat_json_node_t node;
1686 vat_json_init_object (&node);
1687 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1689 vat_json_print (vam->ofp, &node);
1690 vat_json_free (&node);
1692 vam->retval = ntohl (mp->retval);
1693 vam->result_ready = 1;
1696 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1697 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1699 vat_main_t *vam = &vat_main;
1700 i32 retval = ntohl (mp->retval);
1701 if (vam->async_mode)
1703 vam->async_errors += (retval < 0);
1707 vam->retval = retval;
1708 vam->result_ready = 1;
1712 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1713 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1715 vat_main_t *vam = &vat_main;
1716 vat_json_node_t node;
1718 vat_json_init_object (&node);
1719 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1720 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1721 ntohl (mp->sw_if_index));
1723 vat_json_print (vam->ofp, &node);
1724 vat_json_free (&node);
1726 vam->retval = ntohl (mp->retval);
1727 vam->result_ready = 1;
1730 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1731 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1733 vat_main_t *vam = &vat_main;
1734 i32 retval = ntohl (mp->retval);
1735 if (vam->async_mode)
1737 vam->async_errors += (retval < 0);
1741 vam->retval = retval;
1742 vam->sw_if_index = ntohl (mp->sw_if_index);
1743 vam->result_ready = 1;
1747 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1748 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1750 vat_main_t *vam = &vat_main;
1751 vat_json_node_t node;
1753 vat_json_init_object (&node);
1754 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1755 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1757 vat_json_print (vam->ofp, &node);
1758 vat_json_free (&node);
1760 vam->retval = ntohl (mp->retval);
1761 vam->result_ready = 1;
1764 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
1765 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1767 vat_main_t *vam = &vat_main;
1768 i32 retval = ntohl (mp->retval);
1769 if (vam->async_mode)
1771 vam->async_errors += (retval < 0);
1775 vam->retval = retval;
1776 vam->result_ready = 1;
1780 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
1781 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1783 vat_main_t *vam = &vat_main;
1784 vat_json_node_t node;
1786 vat_json_init_object (&node);
1787 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1788 vat_json_object_add_uint (&node, "fwd_entry_index",
1789 clib_net_to_host_u32 (mp->fwd_entry_index));
1791 vat_json_print (vam->ofp, &node);
1792 vat_json_free (&node);
1794 vam->retval = ntohl (mp->retval);
1795 vam->result_ready = 1;
1799 format_lisp_transport_protocol (u8 * s, va_list * args)
1801 u32 proto = va_arg (*args, u32);
1806 return format (s, "udp");
1808 return format (s, "api");
1815 static void vl_api_one_get_transport_protocol_reply_t_handler
1816 (vl_api_one_get_transport_protocol_reply_t * mp)
1818 vat_main_t *vam = &vat_main;
1819 i32 retval = ntohl (mp->retval);
1820 if (vam->async_mode)
1822 vam->async_errors += (retval < 0);
1826 u32 proto = mp->protocol;
1827 print (vam->ofp, "Transport protocol: %U",
1828 format_lisp_transport_protocol, proto);
1829 vam->retval = retval;
1830 vam->result_ready = 1;
1834 static void vl_api_one_get_transport_protocol_reply_t_handler_json
1835 (vl_api_one_get_transport_protocol_reply_t * mp)
1837 vat_main_t *vam = &vat_main;
1838 vat_json_node_t node;
1841 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
1844 vat_json_init_object (&node);
1845 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1846 vat_json_object_add_string_copy (&node, "transport-protocol", s);
1849 vat_json_print (vam->ofp, &node);
1850 vat_json_free (&node);
1852 vam->retval = ntohl (mp->retval);
1853 vam->result_ready = 1;
1856 static void vl_api_one_add_del_locator_set_reply_t_handler
1857 (vl_api_one_add_del_locator_set_reply_t * mp)
1859 vat_main_t *vam = &vat_main;
1860 i32 retval = ntohl (mp->retval);
1861 if (vam->async_mode)
1863 vam->async_errors += (retval < 0);
1867 vam->retval = retval;
1868 vam->result_ready = 1;
1872 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1873 (vl_api_one_add_del_locator_set_reply_t * mp)
1875 vat_main_t *vam = &vat_main;
1876 vat_json_node_t node;
1878 vat_json_init_object (&node);
1879 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1880 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1882 vat_json_print (vam->ofp, &node);
1883 vat_json_free (&node);
1885 vam->retval = ntohl (mp->retval);
1886 vam->result_ready = 1;
1889 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1890 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1892 vat_main_t *vam = &vat_main;
1893 i32 retval = ntohl (mp->retval);
1894 if (vam->async_mode)
1896 vam->async_errors += (retval < 0);
1900 vam->retval = retval;
1901 vam->sw_if_index = ntohl (mp->sw_if_index);
1902 vam->result_ready = 1;
1906 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1907 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1909 vat_main_t *vam = &vat_main;
1910 vat_json_node_t node;
1912 vat_json_init_object (&node);
1913 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1914 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1916 vat_json_print (vam->ofp, &node);
1917 vat_json_free (&node);
1919 vam->retval = ntohl (mp->retval);
1920 vam->result_ready = 1;
1923 static void vl_api_geneve_add_del_tunnel_reply_t_handler
1924 (vl_api_geneve_add_del_tunnel_reply_t * mp)
1926 vat_main_t *vam = &vat_main;
1927 i32 retval = ntohl (mp->retval);
1928 if (vam->async_mode)
1930 vam->async_errors += (retval < 0);
1934 vam->retval = retval;
1935 vam->sw_if_index = ntohl (mp->sw_if_index);
1936 vam->result_ready = 1;
1940 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
1941 (vl_api_geneve_add_del_tunnel_reply_t * mp)
1943 vat_main_t *vam = &vat_main;
1944 vat_json_node_t node;
1946 vat_json_init_object (&node);
1947 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1948 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1950 vat_json_print (vam->ofp, &node);
1951 vat_json_free (&node);
1953 vam->retval = ntohl (mp->retval);
1954 vam->result_ready = 1;
1957 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
1958 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1960 vat_main_t *vam = &vat_main;
1961 i32 retval = ntohl (mp->retval);
1962 if (vam->async_mode)
1964 vam->async_errors += (retval < 0);
1968 vam->retval = retval;
1969 vam->sw_if_index = ntohl (mp->sw_if_index);
1970 vam->result_ready = 1;
1974 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
1975 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1977 vat_main_t *vam = &vat_main;
1978 vat_json_node_t node;
1980 vat_json_init_object (&node);
1981 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1982 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1984 vat_json_print (vam->ofp, &node);
1985 vat_json_free (&node);
1987 vam->retval = ntohl (mp->retval);
1988 vam->result_ready = 1;
1991 static void vl_api_gre_add_del_tunnel_reply_t_handler
1992 (vl_api_gre_add_del_tunnel_reply_t * mp)
1994 vat_main_t *vam = &vat_main;
1995 i32 retval = ntohl (mp->retval);
1996 if (vam->async_mode)
1998 vam->async_errors += (retval < 0);
2002 vam->retval = retval;
2003 vam->sw_if_index = ntohl (mp->sw_if_index);
2004 vam->result_ready = 1;
2008 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2009 (vl_api_gre_add_del_tunnel_reply_t * mp)
2011 vat_main_t *vam = &vat_main;
2012 vat_json_node_t node;
2014 vat_json_init_object (&node);
2015 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2016 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2018 vat_json_print (vam->ofp, &node);
2019 vat_json_free (&node);
2021 vam->retval = ntohl (mp->retval);
2022 vam->result_ready = 1;
2025 static void vl_api_create_vhost_user_if_reply_t_handler
2026 (vl_api_create_vhost_user_if_reply_t * mp)
2028 vat_main_t *vam = &vat_main;
2029 i32 retval = ntohl (mp->retval);
2030 if (vam->async_mode)
2032 vam->async_errors += (retval < 0);
2036 vam->retval = retval;
2037 vam->sw_if_index = ntohl (mp->sw_if_index);
2038 vam->result_ready = 1;
2042 static void vl_api_create_vhost_user_if_reply_t_handler_json
2043 (vl_api_create_vhost_user_if_reply_t * mp)
2045 vat_main_t *vam = &vat_main;
2046 vat_json_node_t node;
2048 vat_json_init_object (&node);
2049 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2050 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2052 vat_json_print (vam->ofp, &node);
2053 vat_json_free (&node);
2055 vam->retval = ntohl (mp->retval);
2056 vam->result_ready = 1;
2059 static clib_error_t *
2060 receive_fd_msg (int socket_fd, int *my_fd)
2063 char ctl[CMSG_SPACE (sizeof (int)) + CMSG_SPACE (sizeof (struct ucred))];
2064 struct msghdr mh = { 0 };
2065 struct iovec iov[1];
2067 struct ucred *cr = 0;
2068 struct cmsghdr *cmsg;
2069 pid_t pid __attribute__ ((unused));
2070 uid_t uid __attribute__ ((unused));
2071 gid_t gid __attribute__ ((unused));
2073 iov[0].iov_base = msgbuf;
2077 mh.msg_control = ctl;
2078 mh.msg_controllen = sizeof (ctl);
2080 memset (ctl, 0, sizeof (ctl));
2082 /* receive the incoming message */
2083 size = recvmsg (socket_fd, &mh, 0);
2086 return (size == 0) ? clib_error_return (0, "disconnected") :
2087 clib_error_return_unix (0, "recvmsg: malformed message (fd %d)",
2091 cmsg = CMSG_FIRSTHDR (&mh);
2094 if (cmsg->cmsg_level == SOL_SOCKET)
2096 if (cmsg->cmsg_type == SCM_CREDENTIALS)
2098 cr = (struct ucred *) CMSG_DATA (cmsg);
2103 else if (cmsg->cmsg_type == SCM_RIGHTS)
2105 clib_memcpy (my_fd, CMSG_DATA (cmsg), sizeof (int));
2108 cmsg = CMSG_NXTHDR (&mh, cmsg);
2113 static void vl_api_memfd_segment_create_reply_t_handler
2114 (vl_api_memfd_segment_create_reply_t * mp)
2116 /* Dont bother in the builtin version */
2117 #if VPP_API_TEST_BUILTIN == 0
2118 vat_main_t *vam = &vat_main;
2119 api_main_t *am = &api_main;
2120 socket_client_main_t *scm = &vam->socket_client_main;
2122 clib_error_t *error;
2123 memfd_private_t memfd;
2124 i32 retval = ntohl (mp->retval);
2128 error = receive_fd_msg (scm->socket_fd, &my_fd);
2135 memset (&memfd, 0, sizeof (memfd));
2138 vam->client_index_invalid = 1;
2140 /* Note: this closes memfd.fd */
2141 retval = memfd_slave_init (&memfd);
2143 clib_warning ("WARNING: segment map returned %d", retval);
2145 /* Pivot to the memory client segment that vpp just created */
2147 am->vlib_rp = (void *) (memfd.requested_va + MMAP_PAGESIZE);
2149 am->shmem_hdr = (void *) am->vlib_rp->user_ctx;
2151 vl_client_install_client_message_handlers ();
2153 vl_client_connect_to_vlib_no_map ("pvt",
2155 32 /* input_queue_length */ );
2156 vam->vl_input_queue = am->shmem_hdr->vl_input_queue;
2158 vl_socket_client_enable_disable (&vam->socket_client_main,
2159 0 /* disable socket */ );
2163 if (vam->async_mode)
2165 vam->async_errors += (retval < 0);
2169 vam->retval = retval;
2170 vam->result_ready = 1;
2175 static void vl_api_memfd_segment_create_reply_t_handler_json
2176 (vl_api_memfd_segment_create_reply_t * mp)
2178 clib_warning ("no");
2181 static void vl_api_dns_resolve_name_reply_t_handler
2182 (vl_api_dns_resolve_name_reply_t * mp)
2184 vat_main_t *vam = &vat_main;
2185 i32 retval = ntohl (mp->retval);
2186 if (vam->async_mode)
2188 vam->async_errors += (retval < 0);
2192 vam->retval = retval;
2193 vam->result_ready = 1;
2198 clib_warning ("ip4 address %U", format_ip4_address,
2199 (ip4_address_t *) mp->ip4_address);
2201 clib_warning ("ip6 address %U", format_ip6_address,
2202 (ip6_address_t *) mp->ip6_address);
2205 clib_warning ("retval %d", retval);
2209 static void vl_api_dns_resolve_name_reply_t_handler_json
2210 (vl_api_dns_resolve_name_reply_t * mp)
2212 clib_warning ("not implemented");
2215 static void vl_api_dns_resolve_ip_reply_t_handler
2216 (vl_api_dns_resolve_ip_reply_t * mp)
2218 vat_main_t *vam = &vat_main;
2219 i32 retval = ntohl (mp->retval);
2220 if (vam->async_mode)
2222 vam->async_errors += (retval < 0);
2226 vam->retval = retval;
2227 vam->result_ready = 1;
2231 clib_warning ("canonical name %s", mp->name);
2234 clib_warning ("retval %d", retval);
2238 static void vl_api_dns_resolve_ip_reply_t_handler_json
2239 (vl_api_dns_resolve_ip_reply_t * mp)
2241 clib_warning ("not implemented");
2245 static void vl_api_ip_address_details_t_handler
2246 (vl_api_ip_address_details_t * mp)
2248 vat_main_t *vam = &vat_main;
2249 static ip_address_details_t empty_ip_address_details = { {0} };
2250 ip_address_details_t *address = NULL;
2251 ip_details_t *current_ip_details = NULL;
2252 ip_details_t *details = NULL;
2254 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2256 if (!details || vam->current_sw_if_index >= vec_len (details)
2257 || !details[vam->current_sw_if_index].present)
2259 errmsg ("ip address details arrived but not stored");
2260 errmsg ("ip_dump should be called first");
2264 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2266 #define addresses (current_ip_details->addr)
2268 vec_validate_init_empty (addresses, vec_len (addresses),
2269 empty_ip_address_details);
2271 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2273 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2274 address->prefix_length = mp->prefix_length;
2278 static void vl_api_ip_address_details_t_handler_json
2279 (vl_api_ip_address_details_t * mp)
2281 vat_main_t *vam = &vat_main;
2282 vat_json_node_t *node = NULL;
2283 struct in6_addr ip6;
2286 if (VAT_JSON_ARRAY != vam->json_tree.type)
2288 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2289 vat_json_init_array (&vam->json_tree);
2291 node = vat_json_array_add (&vam->json_tree);
2293 vat_json_init_object (node);
2296 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2297 vat_json_object_add_ip6 (node, "ip", ip6);
2301 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2302 vat_json_object_add_ip4 (node, "ip", ip4);
2304 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2308 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2310 vat_main_t *vam = &vat_main;
2311 static ip_details_t empty_ip_details = { 0 };
2312 ip_details_t *ip = NULL;
2313 u32 sw_if_index = ~0;
2315 sw_if_index = ntohl (mp->sw_if_index);
2317 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2318 sw_if_index, empty_ip_details);
2320 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2327 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2329 vat_main_t *vam = &vat_main;
2331 if (VAT_JSON_ARRAY != vam->json_tree.type)
2333 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2334 vat_json_init_array (&vam->json_tree);
2336 vat_json_array_add_uint (&vam->json_tree,
2337 clib_net_to_host_u32 (mp->sw_if_index));
2340 static void vl_api_map_domain_details_t_handler_json
2341 (vl_api_map_domain_details_t * mp)
2343 vat_json_node_t *node = NULL;
2344 vat_main_t *vam = &vat_main;
2345 struct in6_addr ip6;
2348 if (VAT_JSON_ARRAY != vam->json_tree.type)
2350 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2351 vat_json_init_array (&vam->json_tree);
2354 node = vat_json_array_add (&vam->json_tree);
2355 vat_json_init_object (node);
2357 vat_json_object_add_uint (node, "domain_index",
2358 clib_net_to_host_u32 (mp->domain_index));
2359 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2360 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2361 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2362 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2363 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2364 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2365 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2366 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2367 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2368 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2369 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2370 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2371 vat_json_object_add_uint (node, "flags", mp->flags);
2372 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2373 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2376 static void vl_api_map_domain_details_t_handler
2377 (vl_api_map_domain_details_t * mp)
2379 vat_main_t *vam = &vat_main;
2381 if (mp->is_translation)
2384 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2385 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2386 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2387 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2388 clib_net_to_host_u32 (mp->domain_index));
2393 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2394 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2395 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2396 format_ip6_address, mp->ip6_src,
2397 clib_net_to_host_u32 (mp->domain_index));
2399 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2400 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2401 mp->is_translation ? "map-t" : "");
2404 static void vl_api_map_rule_details_t_handler_json
2405 (vl_api_map_rule_details_t * mp)
2407 struct in6_addr ip6;
2408 vat_json_node_t *node = NULL;
2409 vat_main_t *vam = &vat_main;
2411 if (VAT_JSON_ARRAY != vam->json_tree.type)
2413 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2414 vat_json_init_array (&vam->json_tree);
2417 node = vat_json_array_add (&vam->json_tree);
2418 vat_json_init_object (node);
2420 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2421 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2422 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2426 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2428 vat_main_t *vam = &vat_main;
2429 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2430 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2434 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2436 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2437 "router_addr %U host_mac %U",
2438 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2439 format_ip4_address, &mp->host_address,
2440 format_ip4_address, &mp->router_address,
2441 format_ethernet_address, mp->host_mac);
2444 static void vl_api_dhcp_compl_event_t_handler_json
2445 (vl_api_dhcp_compl_event_t * mp)
2447 /* JSON output not supported */
2451 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2454 vat_main_t *vam = &vat_main;
2455 static u64 default_counter = 0;
2457 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2459 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2460 sw_if_index, default_counter);
2461 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2465 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2466 interface_counter_t counter)
2468 vat_main_t *vam = &vat_main;
2469 static interface_counter_t default_counter = { 0, };
2471 vec_validate_init_empty (vam->combined_interface_counters,
2472 vnet_counter_type, NULL);
2473 vec_validate_init_empty (vam->combined_interface_counters
2474 [vnet_counter_type], sw_if_index, default_counter);
2475 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2478 static void vl_api_vnet_interface_simple_counters_t_handler
2479 (vl_api_vnet_interface_simple_counters_t * mp)
2484 static void vl_api_vnet_interface_combined_counters_t_handler
2485 (vl_api_vnet_interface_combined_counters_t * mp)
2490 static void vl_api_vnet_interface_simple_counters_t_handler_json
2491 (vl_api_vnet_interface_simple_counters_t * mp)
2496 u32 first_sw_if_index;
2499 count = ntohl (mp->count);
2500 first_sw_if_index = ntohl (mp->first_sw_if_index);
2502 v_packets = (u64 *) & mp->data;
2503 for (i = 0; i < count; i++)
2505 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2506 set_simple_interface_counter (mp->vnet_counter_type,
2507 first_sw_if_index + i, packets);
2512 static void vl_api_vnet_interface_combined_counters_t_handler_json
2513 (vl_api_vnet_interface_combined_counters_t * mp)
2515 interface_counter_t counter;
2517 u32 first_sw_if_index;
2521 count = ntohl (mp->count);
2522 first_sw_if_index = ntohl (mp->first_sw_if_index);
2524 v = (vlib_counter_t *) & mp->data;
2525 for (i = 0; i < count; i++)
2528 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2530 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2531 set_combined_interface_counter (mp->vnet_counter_type,
2532 first_sw_if_index + i, counter);
2538 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2540 vat_main_t *vam = &vat_main;
2543 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2545 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2554 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2556 vat_main_t *vam = &vat_main;
2559 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2561 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2569 static void vl_api_vnet_ip4_fib_counters_t_handler
2570 (vl_api_vnet_ip4_fib_counters_t * mp)
2575 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2576 (vl_api_vnet_ip4_fib_counters_t * mp)
2578 vat_main_t *vam = &vat_main;
2579 vl_api_ip4_fib_counter_t *v;
2580 ip4_fib_counter_t *counter;
2587 vrf_id = ntohl (mp->vrf_id);
2588 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2589 if (~0 == vrf_index)
2591 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2592 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2593 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2594 vec_validate (vam->ip4_fib_counters, vrf_index);
2595 vam->ip4_fib_counters[vrf_index] = NULL;
2598 vec_free (vam->ip4_fib_counters[vrf_index]);
2599 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2600 count = ntohl (mp->count);
2601 for (i = 0; i < count; i++)
2603 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2604 counter = &vam->ip4_fib_counters[vrf_index][i];
2605 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2606 counter->address = ip4;
2607 counter->address_length = v->address_length;
2608 counter->packets = clib_net_to_host_u64 (v->packets);
2609 counter->bytes = clib_net_to_host_u64 (v->bytes);
2614 static void vl_api_vnet_ip4_nbr_counters_t_handler
2615 (vl_api_vnet_ip4_nbr_counters_t * mp)
2620 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2621 (vl_api_vnet_ip4_nbr_counters_t * mp)
2623 vat_main_t *vam = &vat_main;
2624 vl_api_ip4_nbr_counter_t *v;
2625 ip4_nbr_counter_t *counter;
2630 sw_if_index = ntohl (mp->sw_if_index);
2631 count = ntohl (mp->count);
2632 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2635 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2637 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2638 for (i = 0; i < count; i++)
2640 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2641 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2642 counter->address.s_addr = v->address;
2643 counter->packets = clib_net_to_host_u64 (v->packets);
2644 counter->bytes = clib_net_to_host_u64 (v->bytes);
2645 counter->linkt = v->link_type;
2650 static void vl_api_vnet_ip6_fib_counters_t_handler
2651 (vl_api_vnet_ip6_fib_counters_t * mp)
2656 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2657 (vl_api_vnet_ip6_fib_counters_t * mp)
2659 vat_main_t *vam = &vat_main;
2660 vl_api_ip6_fib_counter_t *v;
2661 ip6_fib_counter_t *counter;
2662 struct in6_addr ip6;
2668 vrf_id = ntohl (mp->vrf_id);
2669 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2670 if (~0 == vrf_index)
2672 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2673 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2674 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2675 vec_validate (vam->ip6_fib_counters, vrf_index);
2676 vam->ip6_fib_counters[vrf_index] = NULL;
2679 vec_free (vam->ip6_fib_counters[vrf_index]);
2680 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2681 count = ntohl (mp->count);
2682 for (i = 0; i < count; i++)
2684 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2685 counter = &vam->ip6_fib_counters[vrf_index][i];
2686 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2687 counter->address = ip6;
2688 counter->address_length = v->address_length;
2689 counter->packets = clib_net_to_host_u64 (v->packets);
2690 counter->bytes = clib_net_to_host_u64 (v->bytes);
2695 static void vl_api_vnet_ip6_nbr_counters_t_handler
2696 (vl_api_vnet_ip6_nbr_counters_t * mp)
2701 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2702 (vl_api_vnet_ip6_nbr_counters_t * mp)
2704 vat_main_t *vam = &vat_main;
2705 vl_api_ip6_nbr_counter_t *v;
2706 ip6_nbr_counter_t *counter;
2707 struct in6_addr ip6;
2712 sw_if_index = ntohl (mp->sw_if_index);
2713 count = ntohl (mp->count);
2714 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2717 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2719 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2720 for (i = 0; i < count; i++)
2722 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2723 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2724 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2725 counter->address = ip6;
2726 counter->packets = clib_net_to_host_u64 (v->packets);
2727 counter->bytes = clib_net_to_host_u64 (v->bytes);
2732 static void vl_api_get_first_msg_id_reply_t_handler
2733 (vl_api_get_first_msg_id_reply_t * mp)
2735 vat_main_t *vam = &vat_main;
2736 i32 retval = ntohl (mp->retval);
2738 if (vam->async_mode)
2740 vam->async_errors += (retval < 0);
2744 vam->retval = retval;
2745 vam->result_ready = 1;
2749 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2753 static void vl_api_get_first_msg_id_reply_t_handler_json
2754 (vl_api_get_first_msg_id_reply_t * mp)
2756 vat_main_t *vam = &vat_main;
2757 vat_json_node_t node;
2759 vat_json_init_object (&node);
2760 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2761 vat_json_object_add_uint (&node, "first_msg_id",
2762 (uint) ntohs (mp->first_msg_id));
2764 vat_json_print (vam->ofp, &node);
2765 vat_json_free (&node);
2767 vam->retval = ntohl (mp->retval);
2768 vam->result_ready = 1;
2771 static void vl_api_get_node_graph_reply_t_handler
2772 (vl_api_get_node_graph_reply_t * mp)
2774 vat_main_t *vam = &vat_main;
2775 api_main_t *am = &api_main;
2776 i32 retval = ntohl (mp->retval);
2777 u8 *pvt_copy, *reply;
2782 if (vam->async_mode)
2784 vam->async_errors += (retval < 0);
2788 vam->retval = retval;
2789 vam->result_ready = 1;
2792 /* "Should never happen..." */
2796 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2797 pvt_copy = vec_dup (reply);
2799 /* Toss the shared-memory original... */
2800 pthread_mutex_lock (&am->vlib_rp->mutex);
2801 oldheap = svm_push_data_heap (am->vlib_rp);
2805 svm_pop_heap (oldheap);
2806 pthread_mutex_unlock (&am->vlib_rp->mutex);
2808 if (vam->graph_nodes)
2810 hash_free (vam->graph_node_index_by_name);
2812 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2814 node = vam->graph_nodes[i];
2815 vec_free (node->name);
2816 vec_free (node->next_nodes);
2819 vec_free (vam->graph_nodes);
2822 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2823 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2824 vec_free (pvt_copy);
2826 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2828 node = vam->graph_nodes[i];
2829 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2833 static void vl_api_get_node_graph_reply_t_handler_json
2834 (vl_api_get_node_graph_reply_t * mp)
2836 vat_main_t *vam = &vat_main;
2837 api_main_t *am = &api_main;
2839 vat_json_node_t node;
2842 /* $$$$ make this real? */
2843 vat_json_init_object (&node);
2844 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2845 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2847 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2849 /* Toss the shared-memory original... */
2850 pthread_mutex_lock (&am->vlib_rp->mutex);
2851 oldheap = svm_push_data_heap (am->vlib_rp);
2855 svm_pop_heap (oldheap);
2856 pthread_mutex_unlock (&am->vlib_rp->mutex);
2858 vat_json_print (vam->ofp, &node);
2859 vat_json_free (&node);
2861 vam->retval = ntohl (mp->retval);
2862 vam->result_ready = 1;
2866 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2868 vat_main_t *vam = &vat_main;
2873 s = format (s, "%=16d%=16d%=16d",
2874 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2878 s = format (s, "%=16U%=16d%=16d",
2879 mp->is_ipv6 ? format_ip6_address :
2881 mp->ip_address, mp->priority, mp->weight);
2884 print (vam->ofp, "%v", s);
2889 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2891 vat_main_t *vam = &vat_main;
2892 vat_json_node_t *node = NULL;
2893 struct in6_addr ip6;
2896 if (VAT_JSON_ARRAY != vam->json_tree.type)
2898 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2899 vat_json_init_array (&vam->json_tree);
2901 node = vat_json_array_add (&vam->json_tree);
2902 vat_json_init_object (node);
2904 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2905 vat_json_object_add_uint (node, "priority", mp->priority);
2906 vat_json_object_add_uint (node, "weight", mp->weight);
2909 vat_json_object_add_uint (node, "sw_if_index",
2910 clib_net_to_host_u32 (mp->sw_if_index));
2915 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2916 vat_json_object_add_ip6 (node, "address", ip6);
2920 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2921 vat_json_object_add_ip4 (node, "address", ip4);
2927 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2930 vat_main_t *vam = &vat_main;
2933 ls_name = format (0, "%s", mp->ls_name);
2935 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2941 vl_api_one_locator_set_details_t_handler_json
2942 (vl_api_one_locator_set_details_t * mp)
2944 vat_main_t *vam = &vat_main;
2945 vat_json_node_t *node = 0;
2948 ls_name = format (0, "%s", mp->ls_name);
2949 vec_add1 (ls_name, 0);
2951 if (VAT_JSON_ARRAY != vam->json_tree.type)
2953 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2954 vat_json_init_array (&vam->json_tree);
2956 node = vat_json_array_add (&vam->json_tree);
2958 vat_json_init_object (node);
2959 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2960 vat_json_object_add_uint (node, "ls_index",
2961 clib_net_to_host_u32 (mp->ls_index));
2969 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2972 unformat_nsh_address (unformat_input_t * input, va_list * args)
2974 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2975 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2979 format_nsh_address_vat (u8 * s, va_list * args)
2981 nsh_t *a = va_arg (*args, nsh_t *);
2982 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2986 format_lisp_flat_eid (u8 * s, va_list * args)
2988 u32 type = va_arg (*args, u32);
2989 u8 *eid = va_arg (*args, u8 *);
2990 u32 eid_len = va_arg (*args, u32);
2995 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2997 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2999 return format (s, "%U", format_ethernet_address, eid);
3001 return format (s, "%U", format_nsh_address_vat, eid);
3007 format_lisp_eid_vat (u8 * s, va_list * args)
3009 u32 type = va_arg (*args, u32);
3010 u8 *eid = va_arg (*args, u8 *);
3011 u32 eid_len = va_arg (*args, u32);
3012 u8 *seid = va_arg (*args, u8 *);
3013 u32 seid_len = va_arg (*args, u32);
3014 u32 is_src_dst = va_arg (*args, u32);
3017 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3019 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3025 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3027 vat_main_t *vam = &vat_main;
3028 u8 *s = 0, *eid = 0;
3030 if (~0 == mp->locator_set_index)
3031 s = format (0, "action: %d", mp->action);
3033 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3035 eid = format (0, "%U", format_lisp_eid_vat,
3039 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3042 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3043 clib_net_to_host_u32 (mp->vni),
3045 mp->is_local ? "local" : "remote",
3046 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3047 clib_net_to_host_u16 (mp->key_id), mp->key);
3054 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3057 vat_main_t *vam = &vat_main;
3058 vat_json_node_t *node = 0;
3061 if (VAT_JSON_ARRAY != vam->json_tree.type)
3063 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3064 vat_json_init_array (&vam->json_tree);
3066 node = vat_json_array_add (&vam->json_tree);
3068 vat_json_init_object (node);
3069 if (~0 == mp->locator_set_index)
3070 vat_json_object_add_uint (node, "action", mp->action);
3072 vat_json_object_add_uint (node, "locator_set_index",
3073 clib_net_to_host_u32 (mp->locator_set_index));
3075 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3076 if (mp->eid_type == 3)
3078 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3079 vat_json_init_object (nsh_json);
3080 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3081 vat_json_object_add_uint (nsh_json, "spi",
3082 clib_net_to_host_u32 (nsh->spi));
3083 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3087 eid = format (0, "%U", format_lisp_eid_vat,
3091 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3093 vat_json_object_add_string_copy (node, "eid", eid);
3096 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3097 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3098 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3102 vat_json_object_add_uint (node, "key_id",
3103 clib_net_to_host_u16 (mp->key_id));
3104 vat_json_object_add_string_copy (node, "key", mp->key);
3109 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3111 vat_main_t *vam = &vat_main;
3112 u8 *seid = 0, *deid = 0;
3113 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3115 deid = format (0, "%U", format_lisp_eid_vat,
3116 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3118 seid = format (0, "%U", format_lisp_eid_vat,
3119 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3125 format_ip_address_fcn = format_ip4_address;
3127 format_ip_address_fcn = format_ip6_address;
3130 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3131 clib_net_to_host_u32 (mp->vni),
3133 format_ip_address_fcn, mp->lloc,
3134 format_ip_address_fcn, mp->rloc,
3135 clib_net_to_host_u32 (mp->pkt_count),
3136 clib_net_to_host_u32 (mp->bytes));
3143 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3145 struct in6_addr ip6;
3147 vat_main_t *vam = &vat_main;
3148 vat_json_node_t *node = 0;
3149 u8 *deid = 0, *seid = 0;
3151 if (VAT_JSON_ARRAY != vam->json_tree.type)
3153 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3154 vat_json_init_array (&vam->json_tree);
3156 node = vat_json_array_add (&vam->json_tree);
3158 vat_json_init_object (node);
3159 deid = format (0, "%U", format_lisp_eid_vat,
3160 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3162 seid = format (0, "%U", format_lisp_eid_vat,
3163 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3168 vat_json_object_add_string_copy (node, "seid", seid);
3169 vat_json_object_add_string_copy (node, "deid", deid);
3170 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3174 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3175 vat_json_object_add_ip4 (node, "lloc", ip4);
3176 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3177 vat_json_object_add_ip4 (node, "rloc", ip4);
3181 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3182 vat_json_object_add_ip6 (node, "lloc", ip6);
3183 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3184 vat_json_object_add_ip6 (node, "rloc", ip6);
3186 vat_json_object_add_uint (node, "pkt_count",
3187 clib_net_to_host_u32 (mp->pkt_count));
3188 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3195 vl_api_one_eid_table_map_details_t_handler
3196 (vl_api_one_eid_table_map_details_t * mp)
3198 vat_main_t *vam = &vat_main;
3200 u8 *line = format (0, "%=10d%=10d",
3201 clib_net_to_host_u32 (mp->vni),
3202 clib_net_to_host_u32 (mp->dp_table));
3203 print (vam->ofp, "%v", line);
3208 vl_api_one_eid_table_map_details_t_handler_json
3209 (vl_api_one_eid_table_map_details_t * mp)
3211 vat_main_t *vam = &vat_main;
3212 vat_json_node_t *node = NULL;
3214 if (VAT_JSON_ARRAY != vam->json_tree.type)
3216 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3217 vat_json_init_array (&vam->json_tree);
3219 node = vat_json_array_add (&vam->json_tree);
3220 vat_json_init_object (node);
3221 vat_json_object_add_uint (node, "dp_table",
3222 clib_net_to_host_u32 (mp->dp_table));
3223 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3227 vl_api_one_eid_table_vni_details_t_handler
3228 (vl_api_one_eid_table_vni_details_t * mp)
3230 vat_main_t *vam = &vat_main;
3232 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3233 print (vam->ofp, "%v", line);
3238 vl_api_one_eid_table_vni_details_t_handler_json
3239 (vl_api_one_eid_table_vni_details_t * mp)
3241 vat_main_t *vam = &vat_main;
3242 vat_json_node_t *node = NULL;
3244 if (VAT_JSON_ARRAY != vam->json_tree.type)
3246 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3247 vat_json_init_array (&vam->json_tree);
3249 node = vat_json_array_add (&vam->json_tree);
3250 vat_json_init_object (node);
3251 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3255 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3256 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3258 vat_main_t *vam = &vat_main;
3259 int retval = clib_net_to_host_u32 (mp->retval);
3261 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3262 print (vam->ofp, "fallback threshold value: %d", mp->value);
3264 vam->retval = retval;
3265 vam->result_ready = 1;
3269 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3270 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3272 vat_main_t *vam = &vat_main;
3273 vat_json_node_t _node, *node = &_node;
3274 int retval = clib_net_to_host_u32 (mp->retval);
3276 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3277 vat_json_init_object (node);
3278 vat_json_object_add_uint (node, "value", mp->value);
3280 vat_json_print (vam->ofp, node);
3281 vat_json_free (node);
3283 vam->retval = retval;
3284 vam->result_ready = 1;
3288 vl_api_show_one_map_register_state_reply_t_handler
3289 (vl_api_show_one_map_register_state_reply_t * mp)
3291 vat_main_t *vam = &vat_main;
3292 int retval = clib_net_to_host_u32 (mp->retval);
3294 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3296 vam->retval = retval;
3297 vam->result_ready = 1;
3301 vl_api_show_one_map_register_state_reply_t_handler_json
3302 (vl_api_show_one_map_register_state_reply_t * mp)
3304 vat_main_t *vam = &vat_main;
3305 vat_json_node_t _node, *node = &_node;
3306 int retval = clib_net_to_host_u32 (mp->retval);
3308 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3310 vat_json_init_object (node);
3311 vat_json_object_add_string_copy (node, "state", s);
3313 vat_json_print (vam->ofp, node);
3314 vat_json_free (node);
3316 vam->retval = retval;
3317 vam->result_ready = 1;
3322 vl_api_show_one_rloc_probe_state_reply_t_handler
3323 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3325 vat_main_t *vam = &vat_main;
3326 int retval = clib_net_to_host_u32 (mp->retval);
3331 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3333 vam->retval = retval;
3334 vam->result_ready = 1;
3338 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3339 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3341 vat_main_t *vam = &vat_main;
3342 vat_json_node_t _node, *node = &_node;
3343 int retval = clib_net_to_host_u32 (mp->retval);
3345 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3346 vat_json_init_object (node);
3347 vat_json_object_add_string_copy (node, "state", s);
3349 vat_json_print (vam->ofp, node);
3350 vat_json_free (node);
3352 vam->retval = retval;
3353 vam->result_ready = 1;
3358 vl_api_show_one_stats_enable_disable_reply_t_handler
3359 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3361 vat_main_t *vam = &vat_main;
3362 int retval = clib_net_to_host_u32 (mp->retval);
3367 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3369 vam->retval = retval;
3370 vam->result_ready = 1;
3374 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3375 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3377 vat_main_t *vam = &vat_main;
3378 vat_json_node_t _node, *node = &_node;
3379 int retval = clib_net_to_host_u32 (mp->retval);
3381 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3382 vat_json_init_object (node);
3383 vat_json_object_add_string_copy (node, "state", s);
3385 vat_json_print (vam->ofp, node);
3386 vat_json_free (node);
3388 vam->retval = retval;
3389 vam->result_ready = 1;
3394 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3396 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3397 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3398 e->vni = clib_net_to_host_u32 (e->vni);
3402 gpe_fwd_entries_get_reply_t_net_to_host
3403 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3407 mp->count = clib_net_to_host_u32 (mp->count);
3408 for (i = 0; i < mp->count; i++)
3410 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3415 format_gpe_encap_mode (u8 * s, va_list * args)
3417 u32 mode = va_arg (*args, u32);
3422 return format (s, "lisp");
3424 return format (s, "vxlan");
3430 vl_api_gpe_get_encap_mode_reply_t_handler
3431 (vl_api_gpe_get_encap_mode_reply_t * mp)
3433 vat_main_t *vam = &vat_main;
3435 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3436 vam->retval = ntohl (mp->retval);
3437 vam->result_ready = 1;
3441 vl_api_gpe_get_encap_mode_reply_t_handler_json
3442 (vl_api_gpe_get_encap_mode_reply_t * mp)
3444 vat_main_t *vam = &vat_main;
3445 vat_json_node_t node;
3447 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3448 vec_add1 (encap_mode, 0);
3450 vat_json_init_object (&node);
3451 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3453 vec_free (encap_mode);
3454 vat_json_print (vam->ofp, &node);
3455 vat_json_free (&node);
3457 vam->retval = ntohl (mp->retval);
3458 vam->result_ready = 1;
3462 vl_api_gpe_fwd_entry_path_details_t_handler
3463 (vl_api_gpe_fwd_entry_path_details_t * mp)
3465 vat_main_t *vam = &vat_main;
3466 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3468 if (mp->lcl_loc.is_ip4)
3469 format_ip_address_fcn = format_ip4_address;
3471 format_ip_address_fcn = format_ip6_address;
3473 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3474 format_ip_address_fcn, &mp->lcl_loc,
3475 format_ip_address_fcn, &mp->rmt_loc);
3479 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3481 struct in6_addr ip6;
3486 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3487 vat_json_object_add_ip4 (n, "address", ip4);
3491 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3492 vat_json_object_add_ip6 (n, "address", ip6);
3494 vat_json_object_add_uint (n, "weight", loc->weight);
3498 vl_api_gpe_fwd_entry_path_details_t_handler_json
3499 (vl_api_gpe_fwd_entry_path_details_t * mp)
3501 vat_main_t *vam = &vat_main;
3502 vat_json_node_t *node = NULL;
3503 vat_json_node_t *loc_node;
3505 if (VAT_JSON_ARRAY != vam->json_tree.type)
3507 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3508 vat_json_init_array (&vam->json_tree);
3510 node = vat_json_array_add (&vam->json_tree);
3511 vat_json_init_object (node);
3513 loc_node = vat_json_object_add (node, "local_locator");
3514 vat_json_init_object (loc_node);
3515 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3517 loc_node = vat_json_object_add (node, "remote_locator");
3518 vat_json_init_object (loc_node);
3519 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3523 vl_api_gpe_fwd_entries_get_reply_t_handler
3524 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3526 vat_main_t *vam = &vat_main;
3528 int retval = clib_net_to_host_u32 (mp->retval);
3529 vl_api_gpe_fwd_entry_t *e;
3534 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3536 for (i = 0; i < mp->count; i++)
3538 e = &mp->entries[i];
3539 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3540 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3541 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3545 vam->retval = retval;
3546 vam->result_ready = 1;
3550 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3551 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3554 vat_main_t *vam = &vat_main;
3555 vat_json_node_t *e = 0, root;
3557 int retval = clib_net_to_host_u32 (mp->retval);
3558 vl_api_gpe_fwd_entry_t *fwd;
3563 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3564 vat_json_init_array (&root);
3566 for (i = 0; i < mp->count; i++)
3568 e = vat_json_array_add (&root);
3569 fwd = &mp->entries[i];
3571 vat_json_init_object (e);
3572 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3573 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3574 vat_json_object_add_int (e, "vni", fwd->vni);
3575 vat_json_object_add_int (e, "action", fwd->action);
3577 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3578 fwd->leid_prefix_len);
3580 vat_json_object_add_string_copy (e, "leid", s);
3583 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3584 fwd->reid_prefix_len);
3586 vat_json_object_add_string_copy (e, "reid", s);
3590 vat_json_print (vam->ofp, &root);
3591 vat_json_free (&root);
3594 vam->retval = retval;
3595 vam->result_ready = 1;
3599 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3600 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3602 vat_main_t *vam = &vat_main;
3604 int retval = clib_net_to_host_u32 (mp->retval);
3605 vl_api_gpe_native_fwd_rpath_t *r;
3610 n = clib_net_to_host_u32 (mp->count);
3612 for (i = 0; i < n; i++)
3614 r = &mp->entries[i];
3615 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3616 clib_net_to_host_u32 (r->fib_index),
3617 clib_net_to_host_u32 (r->nh_sw_if_index),
3618 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3622 vam->retval = retval;
3623 vam->result_ready = 1;
3627 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3628 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3630 vat_main_t *vam = &vat_main;
3631 vat_json_node_t root, *e;
3633 int retval = clib_net_to_host_u32 (mp->retval);
3634 vl_api_gpe_native_fwd_rpath_t *r;
3640 n = clib_net_to_host_u32 (mp->count);
3641 vat_json_init_array (&root);
3643 for (i = 0; i < n; i++)
3645 e = vat_json_array_add (&root);
3646 vat_json_init_object (e);
3647 r = &mp->entries[i];
3649 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3652 vat_json_object_add_string_copy (e, "ip4", s);
3655 vat_json_object_add_uint (e, "fib_index",
3656 clib_net_to_host_u32 (r->fib_index));
3657 vat_json_object_add_uint (e, "nh_sw_if_index",
3658 clib_net_to_host_u32 (r->nh_sw_if_index));
3661 vat_json_print (vam->ofp, &root);
3662 vat_json_free (&root);
3665 vam->retval = retval;
3666 vam->result_ready = 1;
3670 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3671 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3673 vat_main_t *vam = &vat_main;
3675 int retval = clib_net_to_host_u32 (mp->retval);
3680 n = clib_net_to_host_u32 (mp->count);
3682 for (i = 0; i < n; i++)
3683 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3686 vam->retval = retval;
3687 vam->result_ready = 1;
3691 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3692 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3694 vat_main_t *vam = &vat_main;
3695 vat_json_node_t root;
3697 int retval = clib_net_to_host_u32 (mp->retval);
3702 n = clib_net_to_host_u32 (mp->count);
3703 vat_json_init_array (&root);
3705 for (i = 0; i < n; i++)
3706 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3708 vat_json_print (vam->ofp, &root);
3709 vat_json_free (&root);
3712 vam->retval = retval;
3713 vam->result_ready = 1;
3717 vl_api_one_ndp_entries_get_reply_t_handler
3718 (vl_api_one_ndp_entries_get_reply_t * mp)
3720 vat_main_t *vam = &vat_main;
3722 int retval = clib_net_to_host_u32 (mp->retval);
3727 n = clib_net_to_host_u32 (mp->count);
3729 for (i = 0; i < n; i++)
3730 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3731 format_ethernet_address, mp->entries[i].mac);
3734 vam->retval = retval;
3735 vam->result_ready = 1;
3739 vl_api_one_ndp_entries_get_reply_t_handler_json
3740 (vl_api_one_ndp_entries_get_reply_t * mp)
3743 vat_main_t *vam = &vat_main;
3744 vat_json_node_t *e = 0, root;
3746 int retval = clib_net_to_host_u32 (mp->retval);
3747 vl_api_one_ndp_entry_t *arp_entry;
3752 n = clib_net_to_host_u32 (mp->count);
3753 vat_json_init_array (&root);
3755 for (i = 0; i < n; i++)
3757 e = vat_json_array_add (&root);
3758 arp_entry = &mp->entries[i];
3760 vat_json_init_object (e);
3761 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3764 vat_json_object_add_string_copy (e, "mac", s);
3767 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3769 vat_json_object_add_string_copy (e, "ip6", s);
3773 vat_json_print (vam->ofp, &root);
3774 vat_json_free (&root);
3777 vam->retval = retval;
3778 vam->result_ready = 1;
3782 vl_api_one_l2_arp_entries_get_reply_t_handler
3783 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3785 vat_main_t *vam = &vat_main;
3787 int retval = clib_net_to_host_u32 (mp->retval);
3792 n = clib_net_to_host_u32 (mp->count);
3794 for (i = 0; i < n; i++)
3795 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3796 format_ethernet_address, mp->entries[i].mac);
3799 vam->retval = retval;
3800 vam->result_ready = 1;
3804 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3805 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3808 vat_main_t *vam = &vat_main;
3809 vat_json_node_t *e = 0, root;
3811 int retval = clib_net_to_host_u32 (mp->retval);
3812 vl_api_one_l2_arp_entry_t *arp_entry;
3817 n = clib_net_to_host_u32 (mp->count);
3818 vat_json_init_array (&root);
3820 for (i = 0; i < n; i++)
3822 e = vat_json_array_add (&root);
3823 arp_entry = &mp->entries[i];
3825 vat_json_init_object (e);
3826 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3829 vat_json_object_add_string_copy (e, "mac", s);
3832 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3834 vat_json_object_add_string_copy (e, "ip4", s);
3838 vat_json_print (vam->ofp, &root);
3839 vat_json_free (&root);
3842 vam->retval = retval;
3843 vam->result_ready = 1;
3847 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3849 vat_main_t *vam = &vat_main;
3851 int retval = clib_net_to_host_u32 (mp->retval);
3856 n = clib_net_to_host_u32 (mp->count);
3858 for (i = 0; i < n; i++)
3860 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3864 vam->retval = retval;
3865 vam->result_ready = 1;
3869 vl_api_one_ndp_bd_get_reply_t_handler_json
3870 (vl_api_one_ndp_bd_get_reply_t * mp)
3872 vat_main_t *vam = &vat_main;
3873 vat_json_node_t root;
3875 int retval = clib_net_to_host_u32 (mp->retval);
3880 n = clib_net_to_host_u32 (mp->count);
3881 vat_json_init_array (&root);
3883 for (i = 0; i < n; i++)
3885 vat_json_array_add_uint (&root,
3886 clib_net_to_host_u32 (mp->bridge_domains[i]));
3889 vat_json_print (vam->ofp, &root);
3890 vat_json_free (&root);
3893 vam->retval = retval;
3894 vam->result_ready = 1;
3898 vl_api_one_l2_arp_bd_get_reply_t_handler
3899 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3901 vat_main_t *vam = &vat_main;
3903 int retval = clib_net_to_host_u32 (mp->retval);
3908 n = clib_net_to_host_u32 (mp->count);
3910 for (i = 0; i < n; i++)
3912 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3916 vam->retval = retval;
3917 vam->result_ready = 1;
3921 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3922 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3924 vat_main_t *vam = &vat_main;
3925 vat_json_node_t root;
3927 int retval = clib_net_to_host_u32 (mp->retval);
3932 n = clib_net_to_host_u32 (mp->count);
3933 vat_json_init_array (&root);
3935 for (i = 0; i < n; i++)
3937 vat_json_array_add_uint (&root,
3938 clib_net_to_host_u32 (mp->bridge_domains[i]));
3941 vat_json_print (vam->ofp, &root);
3942 vat_json_free (&root);
3945 vam->retval = retval;
3946 vam->result_ready = 1;
3950 vl_api_one_adjacencies_get_reply_t_handler
3951 (vl_api_one_adjacencies_get_reply_t * mp)
3953 vat_main_t *vam = &vat_main;
3955 int retval = clib_net_to_host_u32 (mp->retval);
3956 vl_api_one_adjacency_t *a;
3961 n = clib_net_to_host_u32 (mp->count);
3963 for (i = 0; i < n; i++)
3965 a = &mp->adjacencies[i];
3966 print (vam->ofp, "%U %40U",
3967 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3968 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3972 vam->retval = retval;
3973 vam->result_ready = 1;
3977 vl_api_one_adjacencies_get_reply_t_handler_json
3978 (vl_api_one_adjacencies_get_reply_t * mp)
3981 vat_main_t *vam = &vat_main;
3982 vat_json_node_t *e = 0, root;
3984 int retval = clib_net_to_host_u32 (mp->retval);
3985 vl_api_one_adjacency_t *a;
3990 n = clib_net_to_host_u32 (mp->count);
3991 vat_json_init_array (&root);
3993 for (i = 0; i < n; i++)
3995 e = vat_json_array_add (&root);
3996 a = &mp->adjacencies[i];
3998 vat_json_init_object (e);
3999 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4000 a->leid_prefix_len);
4002 vat_json_object_add_string_copy (e, "leid", s);
4005 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4006 a->reid_prefix_len);
4008 vat_json_object_add_string_copy (e, "reid", s);
4012 vat_json_print (vam->ofp, &root);
4013 vat_json_free (&root);
4016 vam->retval = retval;
4017 vam->result_ready = 1;
4021 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4023 vat_main_t *vam = &vat_main;
4025 print (vam->ofp, "%=20U",
4026 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4031 vl_api_one_map_server_details_t_handler_json
4032 (vl_api_one_map_server_details_t * mp)
4034 vat_main_t *vam = &vat_main;
4035 vat_json_node_t *node = NULL;
4036 struct in6_addr ip6;
4039 if (VAT_JSON_ARRAY != vam->json_tree.type)
4041 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4042 vat_json_init_array (&vam->json_tree);
4044 node = vat_json_array_add (&vam->json_tree);
4046 vat_json_init_object (node);
4049 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4050 vat_json_object_add_ip6 (node, "map-server", ip6);
4054 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4055 vat_json_object_add_ip4 (node, "map-server", ip4);
4060 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4063 vat_main_t *vam = &vat_main;
4065 print (vam->ofp, "%=20U",
4066 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4071 vl_api_one_map_resolver_details_t_handler_json
4072 (vl_api_one_map_resolver_details_t * mp)
4074 vat_main_t *vam = &vat_main;
4075 vat_json_node_t *node = NULL;
4076 struct in6_addr ip6;
4079 if (VAT_JSON_ARRAY != vam->json_tree.type)
4081 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4082 vat_json_init_array (&vam->json_tree);
4084 node = vat_json_array_add (&vam->json_tree);
4086 vat_json_init_object (node);
4089 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4090 vat_json_object_add_ip6 (node, "map resolver", ip6);
4094 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4095 vat_json_object_add_ip4 (node, "map resolver", ip4);
4100 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4102 vat_main_t *vam = &vat_main;
4103 i32 retval = ntohl (mp->retval);
4107 print (vam->ofp, "feature: %s\ngpe: %s",
4108 mp->feature_status ? "enabled" : "disabled",
4109 mp->gpe_status ? "enabled" : "disabled");
4112 vam->retval = retval;
4113 vam->result_ready = 1;
4117 vl_api_show_one_status_reply_t_handler_json
4118 (vl_api_show_one_status_reply_t * mp)
4120 vat_main_t *vam = &vat_main;
4121 vat_json_node_t node;
4122 u8 *gpe_status = NULL;
4123 u8 *feature_status = NULL;
4125 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4126 feature_status = format (0, "%s",
4127 mp->feature_status ? "enabled" : "disabled");
4128 vec_add1 (gpe_status, 0);
4129 vec_add1 (feature_status, 0);
4131 vat_json_init_object (&node);
4132 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4133 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4135 vec_free (gpe_status);
4136 vec_free (feature_status);
4138 vat_json_print (vam->ofp, &node);
4139 vat_json_free (&node);
4141 vam->retval = ntohl (mp->retval);
4142 vam->result_ready = 1;
4146 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4147 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4149 vat_main_t *vam = &vat_main;
4150 i32 retval = ntohl (mp->retval);
4154 print (vam->ofp, "%=20s", mp->locator_set_name);
4157 vam->retval = retval;
4158 vam->result_ready = 1;
4162 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4163 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4165 vat_main_t *vam = &vat_main;
4166 vat_json_node_t *node = NULL;
4168 if (VAT_JSON_ARRAY != vam->json_tree.type)
4170 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4171 vat_json_init_array (&vam->json_tree);
4173 node = vat_json_array_add (&vam->json_tree);
4175 vat_json_init_object (node);
4176 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4178 vat_json_print (vam->ofp, node);
4179 vat_json_free (node);
4181 vam->retval = ntohl (mp->retval);
4182 vam->result_ready = 1;
4186 format_lisp_map_request_mode (u8 * s, va_list * args)
4188 u32 mode = va_arg (*args, u32);
4193 return format (0, "dst-only");
4195 return format (0, "src-dst");
4201 vl_api_show_one_map_request_mode_reply_t_handler
4202 (vl_api_show_one_map_request_mode_reply_t * mp)
4204 vat_main_t *vam = &vat_main;
4205 i32 retval = ntohl (mp->retval);
4209 u32 mode = mp->mode;
4210 print (vam->ofp, "map_request_mode: %U",
4211 format_lisp_map_request_mode, mode);
4214 vam->retval = retval;
4215 vam->result_ready = 1;
4219 vl_api_show_one_map_request_mode_reply_t_handler_json
4220 (vl_api_show_one_map_request_mode_reply_t * mp)
4222 vat_main_t *vam = &vat_main;
4223 vat_json_node_t node;
4228 s = format (0, "%U", format_lisp_map_request_mode, mode);
4231 vat_json_init_object (&node);
4232 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4233 vat_json_print (vam->ofp, &node);
4234 vat_json_free (&node);
4237 vam->retval = ntohl (mp->retval);
4238 vam->result_ready = 1;
4242 vl_api_one_show_xtr_mode_reply_t_handler
4243 (vl_api_one_show_xtr_mode_reply_t * mp)
4245 vat_main_t *vam = &vat_main;
4246 i32 retval = ntohl (mp->retval);
4250 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4253 vam->retval = retval;
4254 vam->result_ready = 1;
4258 vl_api_one_show_xtr_mode_reply_t_handler_json
4259 (vl_api_one_show_xtr_mode_reply_t * mp)
4261 vat_main_t *vam = &vat_main;
4262 vat_json_node_t node;
4265 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4266 vec_add1 (status, 0);
4268 vat_json_init_object (&node);
4269 vat_json_object_add_string_copy (&node, "status", status);
4273 vat_json_print (vam->ofp, &node);
4274 vat_json_free (&node);
4276 vam->retval = ntohl (mp->retval);
4277 vam->result_ready = 1;
4281 vl_api_one_show_pitr_mode_reply_t_handler
4282 (vl_api_one_show_pitr_mode_reply_t * mp)
4284 vat_main_t *vam = &vat_main;
4285 i32 retval = ntohl (mp->retval);
4289 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4292 vam->retval = retval;
4293 vam->result_ready = 1;
4297 vl_api_one_show_pitr_mode_reply_t_handler_json
4298 (vl_api_one_show_pitr_mode_reply_t * mp)
4300 vat_main_t *vam = &vat_main;
4301 vat_json_node_t node;
4304 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4305 vec_add1 (status, 0);
4307 vat_json_init_object (&node);
4308 vat_json_object_add_string_copy (&node, "status", status);
4312 vat_json_print (vam->ofp, &node);
4313 vat_json_free (&node);
4315 vam->retval = ntohl (mp->retval);
4316 vam->result_ready = 1;
4320 vl_api_one_show_petr_mode_reply_t_handler
4321 (vl_api_one_show_petr_mode_reply_t * mp)
4323 vat_main_t *vam = &vat_main;
4324 i32 retval = ntohl (mp->retval);
4328 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4331 vam->retval = retval;
4332 vam->result_ready = 1;
4336 vl_api_one_show_petr_mode_reply_t_handler_json
4337 (vl_api_one_show_petr_mode_reply_t * mp)
4339 vat_main_t *vam = &vat_main;
4340 vat_json_node_t node;
4343 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4344 vec_add1 (status, 0);
4346 vat_json_init_object (&node);
4347 vat_json_object_add_string_copy (&node, "status", status);
4351 vat_json_print (vam->ofp, &node);
4352 vat_json_free (&node);
4354 vam->retval = ntohl (mp->retval);
4355 vam->result_ready = 1;
4359 vl_api_show_one_use_petr_reply_t_handler
4360 (vl_api_show_one_use_petr_reply_t * mp)
4362 vat_main_t *vam = &vat_main;
4363 i32 retval = ntohl (mp->retval);
4367 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4370 print (vam->ofp, "Proxy-ETR address; %U",
4371 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4376 vam->retval = retval;
4377 vam->result_ready = 1;
4381 vl_api_show_one_use_petr_reply_t_handler_json
4382 (vl_api_show_one_use_petr_reply_t * mp)
4384 vat_main_t *vam = &vat_main;
4385 vat_json_node_t node;
4388 struct in6_addr ip6;
4390 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4391 vec_add1 (status, 0);
4393 vat_json_init_object (&node);
4394 vat_json_object_add_string_copy (&node, "status", status);
4399 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4400 vat_json_object_add_ip6 (&node, "address", ip6);
4404 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4405 vat_json_object_add_ip4 (&node, "address", ip4);
4411 vat_json_print (vam->ofp, &node);
4412 vat_json_free (&node);
4414 vam->retval = ntohl (mp->retval);
4415 vam->result_ready = 1;
4419 vl_api_show_one_nsh_mapping_reply_t_handler
4420 (vl_api_show_one_nsh_mapping_reply_t * mp)
4422 vat_main_t *vam = &vat_main;
4423 i32 retval = ntohl (mp->retval);
4427 print (vam->ofp, "%-20s%-16s",
4428 mp->is_set ? "set" : "not-set",
4429 mp->is_set ? (char *) mp->locator_set_name : "");
4432 vam->retval = retval;
4433 vam->result_ready = 1;
4437 vl_api_show_one_nsh_mapping_reply_t_handler_json
4438 (vl_api_show_one_nsh_mapping_reply_t * mp)
4440 vat_main_t *vam = &vat_main;
4441 vat_json_node_t node;
4444 status = format (0, "%s", mp->is_set ? "yes" : "no");
4445 vec_add1 (status, 0);
4447 vat_json_init_object (&node);
4448 vat_json_object_add_string_copy (&node, "is_set", status);
4451 vat_json_object_add_string_copy (&node, "locator_set",
4452 mp->locator_set_name);
4457 vat_json_print (vam->ofp, &node);
4458 vat_json_free (&node);
4460 vam->retval = ntohl (mp->retval);
4461 vam->result_ready = 1;
4465 vl_api_show_one_map_register_ttl_reply_t_handler
4466 (vl_api_show_one_map_register_ttl_reply_t * mp)
4468 vat_main_t *vam = &vat_main;
4469 i32 retval = ntohl (mp->retval);
4471 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4475 print (vam->ofp, "ttl: %u", mp->ttl);
4478 vam->retval = retval;
4479 vam->result_ready = 1;
4483 vl_api_show_one_map_register_ttl_reply_t_handler_json
4484 (vl_api_show_one_map_register_ttl_reply_t * mp)
4486 vat_main_t *vam = &vat_main;
4487 vat_json_node_t node;
4489 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4490 vat_json_init_object (&node);
4491 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4493 vat_json_print (vam->ofp, &node);
4494 vat_json_free (&node);
4496 vam->retval = ntohl (mp->retval);
4497 vam->result_ready = 1;
4501 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4503 vat_main_t *vam = &vat_main;
4504 i32 retval = ntohl (mp->retval);
4508 print (vam->ofp, "%-20s%-16s",
4509 mp->status ? "enabled" : "disabled",
4510 mp->status ? (char *) mp->locator_set_name : "");
4513 vam->retval = retval;
4514 vam->result_ready = 1;
4518 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4520 vat_main_t *vam = &vat_main;
4521 vat_json_node_t node;
4524 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4525 vec_add1 (status, 0);
4527 vat_json_init_object (&node);
4528 vat_json_object_add_string_copy (&node, "status", status);
4531 vat_json_object_add_string_copy (&node, "locator_set",
4532 mp->locator_set_name);
4537 vat_json_print (vam->ofp, &node);
4538 vat_json_free (&node);
4540 vam->retval = ntohl (mp->retval);
4541 vam->result_ready = 1;
4545 format_policer_type (u8 * s, va_list * va)
4547 u32 i = va_arg (*va, u32);
4549 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4550 s = format (s, "1r2c");
4551 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4552 s = format (s, "1r3c");
4553 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4554 s = format (s, "2r3c-2698");
4555 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4556 s = format (s, "2r3c-4115");
4557 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4558 s = format (s, "2r3c-mef5cf1");
4560 s = format (s, "ILLEGAL");
4565 format_policer_rate_type (u8 * s, va_list * va)
4567 u32 i = va_arg (*va, u32);
4569 if (i == SSE2_QOS_RATE_KBPS)
4570 s = format (s, "kbps");
4571 else if (i == SSE2_QOS_RATE_PPS)
4572 s = format (s, "pps");
4574 s = format (s, "ILLEGAL");
4579 format_policer_round_type (u8 * s, va_list * va)
4581 u32 i = va_arg (*va, u32);
4583 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4584 s = format (s, "closest");
4585 else if (i == SSE2_QOS_ROUND_TO_UP)
4586 s = format (s, "up");
4587 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4588 s = format (s, "down");
4590 s = format (s, "ILLEGAL");
4595 format_policer_action_type (u8 * s, va_list * va)
4597 u32 i = va_arg (*va, u32);
4599 if (i == SSE2_QOS_ACTION_DROP)
4600 s = format (s, "drop");
4601 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4602 s = format (s, "transmit");
4603 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4604 s = format (s, "mark-and-transmit");
4606 s = format (s, "ILLEGAL");
4611 format_dscp (u8 * s, va_list * va)
4613 u32 i = va_arg (*va, u32);
4618 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4622 return format (s, "ILLEGAL");
4624 s = format (s, "%s", t);
4629 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4631 vat_main_t *vam = &vat_main;
4632 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4634 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4635 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4637 conform_dscp_str = format (0, "");
4639 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4640 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4642 exceed_dscp_str = format (0, "");
4644 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4645 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4647 violate_dscp_str = format (0, "");
4649 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4650 "rate type %U, round type %U, %s rate, %s color-aware, "
4651 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4652 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4653 "conform action %U%s, exceed action %U%s, violate action %U%s",
4655 format_policer_type, mp->type,
4658 clib_net_to_host_u64 (mp->cb),
4659 clib_net_to_host_u64 (mp->eb),
4660 format_policer_rate_type, mp->rate_type,
4661 format_policer_round_type, mp->round_type,
4662 mp->single_rate ? "single" : "dual",
4663 mp->color_aware ? "is" : "not",
4664 ntohl (mp->cir_tokens_per_period),
4665 ntohl (mp->pir_tokens_per_period),
4667 ntohl (mp->current_limit),
4668 ntohl (mp->current_bucket),
4669 ntohl (mp->extended_limit),
4670 ntohl (mp->extended_bucket),
4671 clib_net_to_host_u64 (mp->last_update_time),
4672 format_policer_action_type, mp->conform_action_type,
4674 format_policer_action_type, mp->exceed_action_type,
4676 format_policer_action_type, mp->violate_action_type,
4679 vec_free (conform_dscp_str);
4680 vec_free (exceed_dscp_str);
4681 vec_free (violate_dscp_str);
4684 static void vl_api_policer_details_t_handler_json
4685 (vl_api_policer_details_t * mp)
4687 vat_main_t *vam = &vat_main;
4688 vat_json_node_t *node;
4689 u8 *rate_type_str, *round_type_str, *type_str;
4690 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4692 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4694 format (0, "%U", format_policer_round_type, mp->round_type);
4695 type_str = format (0, "%U", format_policer_type, mp->type);
4696 conform_action_str = format (0, "%U", format_policer_action_type,
4697 mp->conform_action_type);
4698 exceed_action_str = format (0, "%U", format_policer_action_type,
4699 mp->exceed_action_type);
4700 violate_action_str = format (0, "%U", format_policer_action_type,
4701 mp->violate_action_type);
4703 if (VAT_JSON_ARRAY != vam->json_tree.type)
4705 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4706 vat_json_init_array (&vam->json_tree);
4708 node = vat_json_array_add (&vam->json_tree);
4710 vat_json_init_object (node);
4711 vat_json_object_add_string_copy (node, "name", mp->name);
4712 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4713 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4714 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4715 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4716 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4717 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4718 vat_json_object_add_string_copy (node, "type", type_str);
4719 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4720 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4721 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4722 vat_json_object_add_uint (node, "cir_tokens_per_period",
4723 ntohl (mp->cir_tokens_per_period));
4724 vat_json_object_add_uint (node, "eir_tokens_per_period",
4725 ntohl (mp->pir_tokens_per_period));
4726 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4727 vat_json_object_add_uint (node, "current_bucket",
4728 ntohl (mp->current_bucket));
4729 vat_json_object_add_uint (node, "extended_limit",
4730 ntohl (mp->extended_limit));
4731 vat_json_object_add_uint (node, "extended_bucket",
4732 ntohl (mp->extended_bucket));
4733 vat_json_object_add_uint (node, "last_update_time",
4734 ntohl (mp->last_update_time));
4735 vat_json_object_add_string_copy (node, "conform_action",
4736 conform_action_str);
4737 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4739 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4740 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4741 vec_free (dscp_str);
4743 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4744 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4746 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4747 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4748 vec_free (dscp_str);
4750 vat_json_object_add_string_copy (node, "violate_action",
4751 violate_action_str);
4752 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4754 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4755 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4756 vec_free (dscp_str);
4759 vec_free (rate_type_str);
4760 vec_free (round_type_str);
4761 vec_free (type_str);
4762 vec_free (conform_action_str);
4763 vec_free (exceed_action_str);
4764 vec_free (violate_action_str);
4768 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4771 vat_main_t *vam = &vat_main;
4772 int i, count = ntohl (mp->count);
4775 print (vam->ofp, "classify table ids (%d) : ", count);
4776 for (i = 0; i < count; i++)
4778 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4779 print (vam->ofp, (i < count - 1) ? "," : "");
4781 vam->retval = ntohl (mp->retval);
4782 vam->result_ready = 1;
4786 vl_api_classify_table_ids_reply_t_handler_json
4787 (vl_api_classify_table_ids_reply_t * mp)
4789 vat_main_t *vam = &vat_main;
4790 int i, count = ntohl (mp->count);
4794 vat_json_node_t node;
4796 vat_json_init_object (&node);
4797 for (i = 0; i < count; i++)
4799 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4801 vat_json_print (vam->ofp, &node);
4802 vat_json_free (&node);
4804 vam->retval = ntohl (mp->retval);
4805 vam->result_ready = 1;
4809 vl_api_classify_table_by_interface_reply_t_handler
4810 (vl_api_classify_table_by_interface_reply_t * mp)
4812 vat_main_t *vam = &vat_main;
4815 table_id = ntohl (mp->l2_table_id);
4817 print (vam->ofp, "l2 table id : %d", table_id);
4819 print (vam->ofp, "l2 table id : No input ACL tables configured");
4820 table_id = ntohl (mp->ip4_table_id);
4822 print (vam->ofp, "ip4 table id : %d", table_id);
4824 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4825 table_id = ntohl (mp->ip6_table_id);
4827 print (vam->ofp, "ip6 table id : %d", table_id);
4829 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4830 vam->retval = ntohl (mp->retval);
4831 vam->result_ready = 1;
4835 vl_api_classify_table_by_interface_reply_t_handler_json
4836 (vl_api_classify_table_by_interface_reply_t * mp)
4838 vat_main_t *vam = &vat_main;
4839 vat_json_node_t node;
4841 vat_json_init_object (&node);
4843 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4844 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4845 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4847 vat_json_print (vam->ofp, &node);
4848 vat_json_free (&node);
4850 vam->retval = ntohl (mp->retval);
4851 vam->result_ready = 1;
4854 static void vl_api_policer_add_del_reply_t_handler
4855 (vl_api_policer_add_del_reply_t * mp)
4857 vat_main_t *vam = &vat_main;
4858 i32 retval = ntohl (mp->retval);
4859 if (vam->async_mode)
4861 vam->async_errors += (retval < 0);
4865 vam->retval = retval;
4866 vam->result_ready = 1;
4867 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4869 * Note: this is just barely thread-safe, depends on
4870 * the main thread spinning waiting for an answer...
4872 errmsg ("policer index %d", ntohl (mp->policer_index));
4876 static void vl_api_policer_add_del_reply_t_handler_json
4877 (vl_api_policer_add_del_reply_t * mp)
4879 vat_main_t *vam = &vat_main;
4880 vat_json_node_t node;
4882 vat_json_init_object (&node);
4883 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4884 vat_json_object_add_uint (&node, "policer_index",
4885 ntohl (mp->policer_index));
4887 vat_json_print (vam->ofp, &node);
4888 vat_json_free (&node);
4890 vam->retval = ntohl (mp->retval);
4891 vam->result_ready = 1;
4894 /* Format hex dump. */
4896 format_hex_bytes (u8 * s, va_list * va)
4898 u8 *bytes = va_arg (*va, u8 *);
4899 int n_bytes = va_arg (*va, int);
4902 /* Print short or long form depending on byte count. */
4903 uword short_form = n_bytes <= 32;
4904 u32 indent = format_get_indent (s);
4909 for (i = 0; i < n_bytes; i++)
4911 if (!short_form && (i % 32) == 0)
4912 s = format (s, "%08x: ", i);
4913 s = format (s, "%02x", bytes[i]);
4914 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4915 s = format (s, "\n%U", format_white_space, indent);
4922 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4925 vat_main_t *vam = &vat_main;
4926 i32 retval = ntohl (mp->retval);
4929 print (vam->ofp, "classify table info :");
4930 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4931 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4932 ntohl (mp->miss_next_index));
4933 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4934 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4935 ntohl (mp->match_n_vectors));
4936 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4937 ntohl (mp->mask_length));
4939 vam->retval = retval;
4940 vam->result_ready = 1;
4944 vl_api_classify_table_info_reply_t_handler_json
4945 (vl_api_classify_table_info_reply_t * mp)
4947 vat_main_t *vam = &vat_main;
4948 vat_json_node_t node;
4950 i32 retval = ntohl (mp->retval);
4953 vat_json_init_object (&node);
4955 vat_json_object_add_int (&node, "sessions",
4956 ntohl (mp->active_sessions));
4957 vat_json_object_add_int (&node, "nexttbl",
4958 ntohl (mp->next_table_index));
4959 vat_json_object_add_int (&node, "nextnode",
4960 ntohl (mp->miss_next_index));
4961 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4962 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4963 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4964 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4965 ntohl (mp->mask_length), 0);
4966 vat_json_object_add_string_copy (&node, "mask", s);
4968 vat_json_print (vam->ofp, &node);
4969 vat_json_free (&node);
4971 vam->retval = ntohl (mp->retval);
4972 vam->result_ready = 1;
4976 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4979 vat_main_t *vam = &vat_main;
4981 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4982 ntohl (mp->hit_next_index), ntohl (mp->advance),
4983 ntohl (mp->opaque_index));
4984 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4985 ntohl (mp->match_length));
4989 vl_api_classify_session_details_t_handler_json
4990 (vl_api_classify_session_details_t * mp)
4992 vat_main_t *vam = &vat_main;
4993 vat_json_node_t *node = NULL;
4995 if (VAT_JSON_ARRAY != vam->json_tree.type)
4997 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4998 vat_json_init_array (&vam->json_tree);
5000 node = vat_json_array_add (&vam->json_tree);
5002 vat_json_init_object (node);
5003 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5004 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5005 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5007 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5009 vat_json_object_add_string_copy (node, "match", s);
5012 static void vl_api_pg_create_interface_reply_t_handler
5013 (vl_api_pg_create_interface_reply_t * mp)
5015 vat_main_t *vam = &vat_main;
5017 vam->retval = ntohl (mp->retval);
5018 vam->result_ready = 1;
5021 static void vl_api_pg_create_interface_reply_t_handler_json
5022 (vl_api_pg_create_interface_reply_t * mp)
5024 vat_main_t *vam = &vat_main;
5025 vat_json_node_t node;
5027 i32 retval = ntohl (mp->retval);
5030 vat_json_init_object (&node);
5032 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5034 vat_json_print (vam->ofp, &node);
5035 vat_json_free (&node);
5037 vam->retval = ntohl (mp->retval);
5038 vam->result_ready = 1;
5041 static void vl_api_policer_classify_details_t_handler
5042 (vl_api_policer_classify_details_t * mp)
5044 vat_main_t *vam = &vat_main;
5046 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5047 ntohl (mp->table_index));
5050 static void vl_api_policer_classify_details_t_handler_json
5051 (vl_api_policer_classify_details_t * mp)
5053 vat_main_t *vam = &vat_main;
5054 vat_json_node_t *node;
5056 if (VAT_JSON_ARRAY != vam->json_tree.type)
5058 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5059 vat_json_init_array (&vam->json_tree);
5061 node = vat_json_array_add (&vam->json_tree);
5063 vat_json_init_object (node);
5064 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5065 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5068 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5069 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5071 vat_main_t *vam = &vat_main;
5072 i32 retval = ntohl (mp->retval);
5073 if (vam->async_mode)
5075 vam->async_errors += (retval < 0);
5079 vam->retval = retval;
5080 vam->sw_if_index = ntohl (mp->sw_if_index);
5081 vam->result_ready = 1;
5085 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5086 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5088 vat_main_t *vam = &vat_main;
5089 vat_json_node_t node;
5091 vat_json_init_object (&node);
5092 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5093 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5095 vat_json_print (vam->ofp, &node);
5096 vat_json_free (&node);
5098 vam->retval = ntohl (mp->retval);
5099 vam->result_ready = 1;
5102 static void vl_api_flow_classify_details_t_handler
5103 (vl_api_flow_classify_details_t * mp)
5105 vat_main_t *vam = &vat_main;
5107 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5108 ntohl (mp->table_index));
5111 static void vl_api_flow_classify_details_t_handler_json
5112 (vl_api_flow_classify_details_t * mp)
5114 vat_main_t *vam = &vat_main;
5115 vat_json_node_t *node;
5117 if (VAT_JSON_ARRAY != vam->json_tree.type)
5119 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5120 vat_json_init_array (&vam->json_tree);
5122 node = vat_json_array_add (&vam->json_tree);
5124 vat_json_init_object (node);
5125 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5126 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5129 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5130 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5131 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5132 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5133 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5134 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5135 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5136 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5137 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5138 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5139 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5140 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5141 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5142 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5143 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5144 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5145 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5146 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5147 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5148 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5149 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5150 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5153 * Generate boilerplate reply handlers, which
5154 * dig the return value out of the xxx_reply_t API message,
5155 * stick it into vam->retval, and set vam->result_ready
5157 * Could also do this by pointing N message decode slots at
5158 * a single function, but that could break in subtle ways.
5161 #define foreach_standard_reply_retval_handler \
5162 _(sw_interface_set_flags_reply) \
5163 _(sw_interface_add_del_address_reply) \
5164 _(sw_interface_set_rx_mode_reply) \
5165 _(sw_interface_set_table_reply) \
5166 _(sw_interface_set_mpls_enable_reply) \
5167 _(sw_interface_set_vpath_reply) \
5168 _(sw_interface_set_vxlan_bypass_reply) \
5169 _(sw_interface_set_geneve_bypass_reply) \
5170 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5171 _(sw_interface_set_l2_bridge_reply) \
5172 _(bridge_domain_add_del_reply) \
5173 _(sw_interface_set_l2_xconnect_reply) \
5174 _(l2fib_add_del_reply) \
5175 _(l2fib_flush_int_reply) \
5176 _(l2fib_flush_bd_reply) \
5177 _(ip_add_del_route_reply) \
5178 _(ip_table_add_del_reply) \
5179 _(ip_mroute_add_del_reply) \
5180 _(mpls_route_add_del_reply) \
5181 _(mpls_table_add_del_reply) \
5182 _(mpls_ip_bind_unbind_reply) \
5183 _(proxy_arp_add_del_reply) \
5184 _(proxy_arp_intfc_enable_disable_reply) \
5185 _(sw_interface_set_unnumbered_reply) \
5186 _(ip_neighbor_add_del_reply) \
5187 _(reset_vrf_reply) \
5188 _(oam_add_del_reply) \
5189 _(reset_fib_reply) \
5190 _(dhcp_proxy_config_reply) \
5191 _(dhcp_proxy_set_vss_reply) \
5192 _(dhcp_client_config_reply) \
5193 _(set_ip_flow_hash_reply) \
5194 _(sw_interface_ip6_enable_disable_reply) \
5195 _(sw_interface_ip6_set_link_local_address_reply) \
5196 _(ip6nd_proxy_add_del_reply) \
5197 _(sw_interface_ip6nd_ra_prefix_reply) \
5198 _(sw_interface_ip6nd_ra_config_reply) \
5199 _(set_arp_neighbor_limit_reply) \
5200 _(l2_patch_add_del_reply) \
5201 _(sr_policy_add_reply) \
5202 _(sr_policy_mod_reply) \
5203 _(sr_policy_del_reply) \
5204 _(sr_localsid_add_del_reply) \
5205 _(sr_steering_add_del_reply) \
5206 _(classify_add_del_session_reply) \
5207 _(classify_set_interface_ip_table_reply) \
5208 _(classify_set_interface_l2_tables_reply) \
5209 _(l2tpv3_set_tunnel_cookies_reply) \
5210 _(l2tpv3_interface_enable_disable_reply) \
5211 _(l2tpv3_set_lookup_key_reply) \
5212 _(l2_fib_clear_table_reply) \
5213 _(l2_interface_efp_filter_reply) \
5214 _(l2_interface_vlan_tag_rewrite_reply) \
5215 _(modify_vhost_user_if_reply) \
5216 _(delete_vhost_user_if_reply) \
5217 _(want_ip4_arp_events_reply) \
5218 _(want_ip6_nd_events_reply) \
5219 _(want_l2_macs_events_reply) \
5220 _(input_acl_set_interface_reply) \
5221 _(ipsec_spd_add_del_reply) \
5222 _(ipsec_interface_add_del_spd_reply) \
5223 _(ipsec_spd_add_del_entry_reply) \
5224 _(ipsec_sad_add_del_entry_reply) \
5225 _(ipsec_sa_set_key_reply) \
5226 _(ipsec_tunnel_if_add_del_reply) \
5227 _(ipsec_tunnel_if_set_key_reply) \
5228 _(ipsec_tunnel_if_set_sa_reply) \
5229 _(ikev2_profile_add_del_reply) \
5230 _(ikev2_profile_set_auth_reply) \
5231 _(ikev2_profile_set_id_reply) \
5232 _(ikev2_profile_set_ts_reply) \
5233 _(ikev2_set_local_key_reply) \
5234 _(ikev2_set_responder_reply) \
5235 _(ikev2_set_ike_transforms_reply) \
5236 _(ikev2_set_esp_transforms_reply) \
5237 _(ikev2_set_sa_lifetime_reply) \
5238 _(ikev2_initiate_sa_init_reply) \
5239 _(ikev2_initiate_del_ike_sa_reply) \
5240 _(ikev2_initiate_del_child_sa_reply) \
5241 _(ikev2_initiate_rekey_child_sa_reply) \
5242 _(delete_loopback_reply) \
5243 _(bd_ip_mac_add_del_reply) \
5244 _(map_del_domain_reply) \
5245 _(map_add_del_rule_reply) \
5246 _(want_interface_events_reply) \
5247 _(want_stats_reply) \
5248 _(cop_interface_enable_disable_reply) \
5249 _(cop_whitelist_enable_disable_reply) \
5250 _(sw_interface_clear_stats_reply) \
5251 _(ioam_enable_reply) \
5252 _(ioam_disable_reply) \
5253 _(one_add_del_locator_reply) \
5254 _(one_add_del_local_eid_reply) \
5255 _(one_add_del_remote_mapping_reply) \
5256 _(one_add_del_adjacency_reply) \
5257 _(one_add_del_map_resolver_reply) \
5258 _(one_add_del_map_server_reply) \
5259 _(one_enable_disable_reply) \
5260 _(one_rloc_probe_enable_disable_reply) \
5261 _(one_map_register_enable_disable_reply) \
5262 _(one_map_register_set_ttl_reply) \
5263 _(one_set_transport_protocol_reply) \
5264 _(one_map_register_fallback_threshold_reply) \
5265 _(one_pitr_set_locator_set_reply) \
5266 _(one_map_request_mode_reply) \
5267 _(one_add_del_map_request_itr_rlocs_reply) \
5268 _(one_eid_table_add_del_map_reply) \
5269 _(one_use_petr_reply) \
5270 _(one_stats_enable_disable_reply) \
5271 _(one_add_del_l2_arp_entry_reply) \
5272 _(one_add_del_ndp_entry_reply) \
5273 _(one_stats_flush_reply) \
5274 _(one_enable_disable_xtr_mode_reply) \
5275 _(one_enable_disable_pitr_mode_reply) \
5276 _(one_enable_disable_petr_mode_reply) \
5277 _(gpe_enable_disable_reply) \
5278 _(gpe_set_encap_mode_reply) \
5279 _(gpe_add_del_iface_reply) \
5280 _(gpe_add_del_native_fwd_rpath_reply) \
5281 _(af_packet_delete_reply) \
5282 _(policer_classify_set_interface_reply) \
5283 _(netmap_create_reply) \
5284 _(netmap_delete_reply) \
5285 _(set_ipfix_exporter_reply) \
5286 _(set_ipfix_classify_stream_reply) \
5287 _(ipfix_classify_table_add_del_reply) \
5288 _(flow_classify_set_interface_reply) \
5289 _(sw_interface_span_enable_disable_reply) \
5290 _(pg_capture_reply) \
5291 _(pg_enable_disable_reply) \
5292 _(ip_source_and_port_range_check_add_del_reply) \
5293 _(ip_source_and_port_range_check_interface_add_del_reply)\
5294 _(delete_subif_reply) \
5295 _(l2_interface_pbb_tag_rewrite_reply) \
5297 _(feature_enable_disable_reply) \
5298 _(sw_interface_tag_add_del_reply) \
5299 _(sw_interface_set_mtu_reply) \
5300 _(p2p_ethernet_add_reply) \
5301 _(p2p_ethernet_del_reply) \
5302 _(lldp_config_reply) \
5303 _(sw_interface_set_lldp_reply) \
5304 _(tcp_configure_src_addresses_reply) \
5305 _(app_namespace_add_del_reply) \
5306 _(dns_enable_disable_reply) \
5307 _(dns_name_server_add_del_reply) \
5308 _(session_rule_add_del_reply) \
5309 _(ip_container_proxy_add_del_reply)
5312 static void vl_api_##n##_t_handler \
5313 (vl_api_##n##_t * mp) \
5315 vat_main_t * vam = &vat_main; \
5316 i32 retval = ntohl(mp->retval); \
5317 if (vam->async_mode) { \
5318 vam->async_errors += (retval < 0); \
5320 vam->retval = retval; \
5321 vam->result_ready = 1; \
5324 foreach_standard_reply_retval_handler;
5328 static void vl_api_##n##_t_handler_json \
5329 (vl_api_##n##_t * mp) \
5331 vat_main_t * vam = &vat_main; \
5332 vat_json_node_t node; \
5333 vat_json_init_object(&node); \
5334 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5335 vat_json_print(vam->ofp, &node); \
5336 vam->retval = ntohl(mp->retval); \
5337 vam->result_ready = 1; \
5339 foreach_standard_reply_retval_handler;
5343 * Table of message reply handlers, must include boilerplate handlers
5347 #define foreach_vpe_api_reply_msg \
5348 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5349 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5350 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5351 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5352 _(CONTROL_PING_REPLY, control_ping_reply) \
5353 _(CLI_REPLY, cli_reply) \
5354 _(CLI_INBAND_REPLY, cli_inband_reply) \
5355 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5356 sw_interface_add_del_address_reply) \
5357 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5358 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5359 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5360 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5361 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5362 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5363 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5364 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5365 sw_interface_set_l2_xconnect_reply) \
5366 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5367 sw_interface_set_l2_bridge_reply) \
5368 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5369 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5370 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5371 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5372 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5373 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5374 _(L2_FLAGS_REPLY, l2_flags_reply) \
5375 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5376 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5377 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5378 _(TAP_DELETE_REPLY, tap_delete_reply) \
5379 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5380 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5381 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5382 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5383 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5384 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5385 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5386 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5387 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5388 proxy_arp_intfc_enable_disable_reply) \
5389 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5390 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5391 sw_interface_set_unnumbered_reply) \
5392 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5393 _(RESET_VRF_REPLY, reset_vrf_reply) \
5394 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5395 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5396 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5397 _(RESET_FIB_REPLY, reset_fib_reply) \
5398 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5399 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5400 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5401 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5402 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5403 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5404 sw_interface_ip6_enable_disable_reply) \
5405 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5406 sw_interface_ip6_set_link_local_address_reply) \
5407 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5408 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5409 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5410 sw_interface_ip6nd_ra_prefix_reply) \
5411 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5412 sw_interface_ip6nd_ra_config_reply) \
5413 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5414 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5415 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5416 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5417 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5418 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5419 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5420 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5421 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5422 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5423 classify_set_interface_ip_table_reply) \
5424 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5425 classify_set_interface_l2_tables_reply) \
5426 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5427 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5428 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5429 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5430 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5431 l2tpv3_interface_enable_disable_reply) \
5432 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5433 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5434 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5435 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5436 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5437 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5438 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5439 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5440 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5441 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5442 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5443 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5444 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5445 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5446 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5447 _(SHOW_VERSION_REPLY, show_version_reply) \
5448 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5449 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5450 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5451 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5452 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5453 _(IP4_ARP_EVENT, ip4_arp_event) \
5454 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5455 _(IP6_ND_EVENT, ip6_nd_event) \
5456 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5457 _(L2_MACS_EVENT, l2_macs_event) \
5458 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5459 _(IP_ADDRESS_DETAILS, ip_address_details) \
5460 _(IP_DETAILS, ip_details) \
5461 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5462 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5463 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5464 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5465 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5466 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5467 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5468 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5469 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5470 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5471 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5472 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5473 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5474 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5475 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5476 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5477 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5478 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5479 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5480 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5481 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5482 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5483 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5484 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5485 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5486 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5487 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5488 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5489 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5490 _(MAP_RULE_DETAILS, map_rule_details) \
5491 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5492 _(WANT_STATS_REPLY, want_stats_reply) \
5493 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5494 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5495 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5496 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5497 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5498 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5499 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5500 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5501 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5502 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5503 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5504 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5505 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5506 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5507 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5508 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5509 one_map_register_enable_disable_reply) \
5510 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5511 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5512 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5513 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5514 one_map_register_fallback_threshold_reply) \
5515 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5516 one_rloc_probe_enable_disable_reply) \
5517 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5518 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5519 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5520 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5521 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5522 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5523 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5524 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5525 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5526 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5527 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5528 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5529 _(ONE_STATS_DETAILS, one_stats_details) \
5530 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5531 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5532 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5533 show_one_stats_enable_disable_reply) \
5534 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5535 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5536 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5537 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5538 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5539 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5540 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5541 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5542 one_enable_disable_pitr_mode_reply) \
5543 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5544 one_enable_disable_petr_mode_reply) \
5545 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5546 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5547 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5548 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5549 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5550 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5551 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5552 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5553 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5554 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5555 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5556 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5557 gpe_add_del_native_fwd_rpath_reply) \
5558 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5559 gpe_fwd_entry_path_details) \
5560 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5561 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5562 one_add_del_map_request_itr_rlocs_reply) \
5563 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5564 one_get_map_request_itr_rlocs_reply) \
5565 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5566 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5567 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5568 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5569 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5570 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5571 show_one_map_register_state_reply) \
5572 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5573 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5574 show_one_map_register_fallback_threshold_reply) \
5575 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5576 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5577 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5578 _(POLICER_DETAILS, policer_details) \
5579 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5580 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5581 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5582 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5583 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5584 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5585 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5586 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5587 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5588 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5589 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5590 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5591 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5592 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5593 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5594 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5595 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5596 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5597 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5598 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5599 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5600 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5601 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5602 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5603 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5604 ip_source_and_port_range_check_add_del_reply) \
5605 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5606 ip_source_and_port_range_check_interface_add_del_reply) \
5607 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5608 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5609 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5610 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5611 _(PUNT_REPLY, punt_reply) \
5612 _(IP_FIB_DETAILS, ip_fib_details) \
5613 _(IP6_FIB_DETAILS, ip6_fib_details) \
5614 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5615 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5616 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5617 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5618 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5619 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5620 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5621 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5622 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5623 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5624 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5625 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5626 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5627 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5628 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5629 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5630 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5631 _(SESSION_RULES_DETAILS, session_rules_details) \
5632 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5634 #define foreach_standalone_reply_msg \
5635 _(SW_INTERFACE_EVENT, sw_interface_event) \
5636 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5637 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5638 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5639 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5640 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5641 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
5642 _(MEMFD_SEGMENT_CREATE_REPLY, memfd_segment_create_reply) \
5651 #define STR_VTR_OP_CASE(op) \
5652 case L2_VTR_ ## op: \
5656 str_vtr_op (u32 vtr_op)
5660 STR_VTR_OP_CASE (DISABLED);
5661 STR_VTR_OP_CASE (PUSH_1);
5662 STR_VTR_OP_CASE (PUSH_2);
5663 STR_VTR_OP_CASE (POP_1);
5664 STR_VTR_OP_CASE (POP_2);
5665 STR_VTR_OP_CASE (TRANSLATE_1_1);
5666 STR_VTR_OP_CASE (TRANSLATE_1_2);
5667 STR_VTR_OP_CASE (TRANSLATE_2_1);
5668 STR_VTR_OP_CASE (TRANSLATE_2_2);
5675 dump_sub_interface_table (vat_main_t * vam)
5677 const sw_interface_subif_t *sub = NULL;
5679 if (vam->json_output)
5682 ("JSON output supported only for VPE API calls and dump_stats_table");
5687 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5688 "Interface", "sw_if_index",
5689 "sub id", "dot1ad", "tags", "outer id",
5690 "inner id", "exact", "default", "outer any", "inner any");
5692 vec_foreach (sub, vam->sw_if_subif_table)
5695 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5696 sub->interface_name,
5698 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5699 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5700 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5701 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5702 if (sub->vtr_op != L2_VTR_DISABLED)
5705 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5706 "tag1: %d tag2: %d ]",
5707 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5708 sub->vtr_tag1, sub->vtr_tag2);
5716 name_sort_cmp (void *a1, void *a2)
5718 name_sort_t *n1 = a1;
5719 name_sort_t *n2 = a2;
5721 return strcmp ((char *) n1->name, (char *) n2->name);
5725 dump_interface_table (vat_main_t * vam)
5728 name_sort_t *nses = 0, *ns;
5730 if (vam->json_output)
5733 ("JSON output supported only for VPE API calls and dump_stats_table");
5738 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5740 vec_add2 (nses, ns, 1);
5741 ns->name = (u8 *)(p->key);
5742 ns->value = (u32) p->value[0];
5746 vec_sort_with_function (nses, name_sort_cmp);
5748 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5749 vec_foreach (ns, nses)
5751 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5758 dump_ip_table (vat_main_t * vam, int is_ipv6)
5760 const ip_details_t *det = NULL;
5761 const ip_address_details_t *address = NULL;
5764 print (vam->ofp, "%-12s", "sw_if_index");
5766 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5773 print (vam->ofp, "%-12d", i);
5774 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5779 vec_foreach (address, det->addr)
5783 is_ipv6 ? format_ip6_address : format_ip4_address,
5784 address->ip, address->prefix_length);
5792 dump_ipv4_table (vat_main_t * vam)
5794 if (vam->json_output)
5797 ("JSON output supported only for VPE API calls and dump_stats_table");
5801 return dump_ip_table (vam, 0);
5805 dump_ipv6_table (vat_main_t * vam)
5807 if (vam->json_output)
5810 ("JSON output supported only for VPE API calls and dump_stats_table");
5814 return dump_ip_table (vam, 1);
5818 counter_type_to_str (u8 counter_type, u8 is_combined)
5822 switch (counter_type)
5824 case VNET_INTERFACE_COUNTER_DROP:
5826 case VNET_INTERFACE_COUNTER_PUNT:
5828 case VNET_INTERFACE_COUNTER_IP4:
5830 case VNET_INTERFACE_COUNTER_IP6:
5832 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5834 case VNET_INTERFACE_COUNTER_RX_MISS:
5836 case VNET_INTERFACE_COUNTER_RX_ERROR:
5838 case VNET_INTERFACE_COUNTER_TX_ERROR:
5841 return "INVALID-COUNTER-TYPE";
5846 switch (counter_type)
5848 case VNET_INTERFACE_COUNTER_RX:
5850 case VNET_INTERFACE_COUNTER_TX:
5853 return "INVALID-COUNTER-TYPE";
5859 dump_stats_table (vat_main_t * vam)
5861 vat_json_node_t node;
5862 vat_json_node_t *msg_array;
5863 vat_json_node_t *msg;
5864 vat_json_node_t *counter_array;
5865 vat_json_node_t *counter;
5866 interface_counter_t c;
5868 ip4_fib_counter_t *c4;
5869 ip6_fib_counter_t *c6;
5870 ip4_nbr_counter_t *n4;
5871 ip6_nbr_counter_t *n6;
5874 if (!vam->json_output)
5876 clib_warning ("dump_stats_table supported only in JSON format");
5880 vat_json_init_object (&node);
5882 /* interface counters */
5883 msg_array = vat_json_object_add (&node, "interface_counters");
5884 vat_json_init_array (msg_array);
5885 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5887 msg = vat_json_array_add (msg_array);
5888 vat_json_init_object (msg);
5889 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5890 (u8 *) counter_type_to_str (i, 0));
5891 vat_json_object_add_int (msg, "is_combined", 0);
5892 counter_array = vat_json_object_add (msg, "data");
5893 vat_json_init_array (counter_array);
5894 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5896 packets = vam->simple_interface_counters[i][j];
5897 vat_json_array_add_uint (counter_array, packets);
5900 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5902 msg = vat_json_array_add (msg_array);
5903 vat_json_init_object (msg);
5904 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5905 (u8 *) counter_type_to_str (i, 1));
5906 vat_json_object_add_int (msg, "is_combined", 1);
5907 counter_array = vat_json_object_add (msg, "data");
5908 vat_json_init_array (counter_array);
5909 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5911 c = vam->combined_interface_counters[i][j];
5912 counter = vat_json_array_add (counter_array);
5913 vat_json_init_object (counter);
5914 vat_json_object_add_uint (counter, "packets", c.packets);
5915 vat_json_object_add_uint (counter, "bytes", c.bytes);
5919 /* ip4 fib counters */
5920 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5921 vat_json_init_array (msg_array);
5922 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5924 msg = vat_json_array_add (msg_array);
5925 vat_json_init_object (msg);
5926 vat_json_object_add_uint (msg, "vrf_id",
5927 vam->ip4_fib_counters_vrf_id_by_index[i]);
5928 counter_array = vat_json_object_add (msg, "c");
5929 vat_json_init_array (counter_array);
5930 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5932 counter = vat_json_array_add (counter_array);
5933 vat_json_init_object (counter);
5934 c4 = &vam->ip4_fib_counters[i][j];
5935 vat_json_object_add_ip4 (counter, "address", c4->address);
5936 vat_json_object_add_uint (counter, "address_length",
5937 c4->address_length);
5938 vat_json_object_add_uint (counter, "packets", c4->packets);
5939 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5943 /* ip6 fib counters */
5944 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5945 vat_json_init_array (msg_array);
5946 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5948 msg = vat_json_array_add (msg_array);
5949 vat_json_init_object (msg);
5950 vat_json_object_add_uint (msg, "vrf_id",
5951 vam->ip6_fib_counters_vrf_id_by_index[i]);
5952 counter_array = vat_json_object_add (msg, "c");
5953 vat_json_init_array (counter_array);
5954 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5956 counter = vat_json_array_add (counter_array);
5957 vat_json_init_object (counter);
5958 c6 = &vam->ip6_fib_counters[i][j];
5959 vat_json_object_add_ip6 (counter, "address", c6->address);
5960 vat_json_object_add_uint (counter, "address_length",
5961 c6->address_length);
5962 vat_json_object_add_uint (counter, "packets", c6->packets);
5963 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5967 /* ip4 nbr counters */
5968 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5969 vat_json_init_array (msg_array);
5970 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5972 msg = vat_json_array_add (msg_array);
5973 vat_json_init_object (msg);
5974 vat_json_object_add_uint (msg, "sw_if_index", i);
5975 counter_array = vat_json_object_add (msg, "c");
5976 vat_json_init_array (counter_array);
5977 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5979 counter = vat_json_array_add (counter_array);
5980 vat_json_init_object (counter);
5981 n4 = &vam->ip4_nbr_counters[i][j];
5982 vat_json_object_add_ip4 (counter, "address", n4->address);
5983 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5984 vat_json_object_add_uint (counter, "packets", n4->packets);
5985 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5989 /* ip6 nbr counters */
5990 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5991 vat_json_init_array (msg_array);
5992 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5994 msg = vat_json_array_add (msg_array);
5995 vat_json_init_object (msg);
5996 vat_json_object_add_uint (msg, "sw_if_index", i);
5997 counter_array = vat_json_object_add (msg, "c");
5998 vat_json_init_array (counter_array);
5999 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6001 counter = vat_json_array_add (counter_array);
6002 vat_json_init_object (counter);
6003 n6 = &vam->ip6_nbr_counters[i][j];
6004 vat_json_object_add_ip6 (counter, "address", n6->address);
6005 vat_json_object_add_uint (counter, "packets", n6->packets);
6006 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6010 vat_json_print (vam->ofp, &node);
6011 vat_json_free (&node);
6017 * Pass CLI buffers directly in the CLI_INBAND API message,
6018 * instead of an additional shared memory area.
6021 exec_inband (vat_main_t * vam)
6023 vl_api_cli_inband_t *mp;
6024 unformat_input_t *i = vam->input;
6027 if (vec_len (i->buffer) == 0)
6030 if (vam->exec_mode == 0 && unformat (i, "mode"))
6035 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6042 * In order for the CLI command to work, it
6043 * must be a vector ending in \n, not a C-string ending
6046 u32 len = vec_len (vam->input->buffer);
6047 M2 (CLI_INBAND, mp, len);
6048 clib_memcpy (mp->cmd, vam->input->buffer, len);
6049 mp->length = htonl (len);
6053 /* json responses may or may not include a useful reply... */
6054 if (vec_len (vam->cmd_reply))
6055 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6060 exec (vat_main_t * vam)
6062 return exec_inband (vam);
6066 api_create_loopback (vat_main_t * vam)
6068 unformat_input_t *i = vam->input;
6069 vl_api_create_loopback_t *mp;
6070 vl_api_create_loopback_instance_t *mp_lbi;
6073 u8 is_specified = 0;
6074 u32 user_instance = 0;
6077 memset (mac_address, 0, sizeof (mac_address));
6079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6081 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6083 if (unformat (i, "instance %d", &user_instance))
6091 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6092 mp_lbi->is_specified = is_specified;
6094 mp_lbi->user_instance = htonl (user_instance);
6096 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6101 /* Construct the API message */
6102 M (CREATE_LOOPBACK, mp);
6104 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6113 api_delete_loopback (vat_main_t * vam)
6115 unformat_input_t *i = vam->input;
6116 vl_api_delete_loopback_t *mp;
6117 u32 sw_if_index = ~0;
6120 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6122 if (unformat (i, "sw_if_index %d", &sw_if_index))
6128 if (sw_if_index == ~0)
6130 errmsg ("missing sw_if_index");
6134 /* Construct the API message */
6135 M (DELETE_LOOPBACK, mp);
6136 mp->sw_if_index = ntohl (sw_if_index);
6144 api_want_stats (vat_main_t * vam)
6146 unformat_input_t *i = vam->input;
6147 vl_api_want_stats_t *mp;
6151 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6153 if (unformat (i, "enable"))
6155 else if (unformat (i, "disable"))
6163 errmsg ("missing enable|disable");
6168 mp->enable_disable = enable;
6176 api_want_interface_events (vat_main_t * vam)
6178 unformat_input_t *i = vam->input;
6179 vl_api_want_interface_events_t *mp;
6183 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6185 if (unformat (i, "enable"))
6187 else if (unformat (i, "disable"))
6195 errmsg ("missing enable|disable");
6199 M (WANT_INTERFACE_EVENTS, mp);
6200 mp->enable_disable = enable;
6202 vam->interface_event_display = enable;
6210 /* Note: non-static, called once to set up the initial intfc table */
6212 api_sw_interface_dump (vat_main_t * vam)
6214 vl_api_sw_interface_dump_t *mp;
6215 vl_api_control_ping_t *mp_ping;
6217 name_sort_t *nses = 0, *ns;
6218 sw_interface_subif_t *sub = NULL;
6221 /* Toss the old name table */
6223 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6225 vec_add2 (nses, ns, 1);
6226 ns->name = (u8 *)(p->key);
6227 ns->value = (u32) p->value[0];
6231 hash_free (vam->sw_if_index_by_interface_name);
6233 vec_foreach (ns, nses) vec_free (ns->name);
6237 vec_foreach (sub, vam->sw_if_subif_table)
6239 vec_free (sub->interface_name);
6241 vec_free (vam->sw_if_subif_table);
6243 /* recreate the interface name hash table */
6244 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6246 /* Get list of ethernets */
6247 M (SW_INTERFACE_DUMP, mp);
6248 mp->name_filter_valid = 1;
6249 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
6252 /* and local / loopback interfaces */
6253 M (SW_INTERFACE_DUMP, mp);
6254 mp->name_filter_valid = 1;
6255 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
6258 /* and packet-generator interfaces */
6259 M (SW_INTERFACE_DUMP, mp);
6260 mp->name_filter_valid = 1;
6261 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
6264 /* and vxlan-gpe tunnel interfaces */
6265 M (SW_INTERFACE_DUMP, mp);
6266 mp->name_filter_valid = 1;
6267 strncpy ((char *) mp->name_filter, "vxlan_gpe",
6268 sizeof (mp->name_filter) - 1);
6271 /* and vxlan tunnel interfaces */
6272 M (SW_INTERFACE_DUMP, mp);
6273 mp->name_filter_valid = 1;
6274 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
6277 /* and geneve tunnel interfaces */
6278 M (SW_INTERFACE_DUMP, mp);
6279 mp->name_filter_valid = 1;
6280 strncpy ((char *) mp->name_filter, "geneve", sizeof (mp->name_filter) - 1);
6283 /* and host (af_packet) interfaces */
6284 M (SW_INTERFACE_DUMP, mp);
6285 mp->name_filter_valid = 1;
6286 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
6289 /* and l2tpv3 tunnel interfaces */
6290 M (SW_INTERFACE_DUMP, mp);
6291 mp->name_filter_valid = 1;
6292 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
6293 sizeof (mp->name_filter) - 1);
6296 /* and GRE tunnel interfaces */
6297 M (SW_INTERFACE_DUMP, mp);
6298 mp->name_filter_valid = 1;
6299 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
6302 /* and LISP-GPE interfaces */
6303 M (SW_INTERFACE_DUMP, mp);
6304 mp->name_filter_valid = 1;
6305 strncpy ((char *) mp->name_filter, "lisp_gpe",
6306 sizeof (mp->name_filter) - 1);
6309 /* and IPSEC tunnel interfaces */
6310 M (SW_INTERFACE_DUMP, mp);
6311 mp->name_filter_valid = 1;
6312 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
6315 /* Use a control ping for synchronization */
6316 MPING (CONTROL_PING, mp_ping);
6324 api_sw_interface_set_flags (vat_main_t * vam)
6326 unformat_input_t *i = vam->input;
6327 vl_api_sw_interface_set_flags_t *mp;
6329 u8 sw_if_index_set = 0;
6333 /* Parse args required to build the message */
6334 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6336 if (unformat (i, "admin-up"))
6338 else if (unformat (i, "admin-down"))
6341 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6342 sw_if_index_set = 1;
6343 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6344 sw_if_index_set = 1;
6349 if (sw_if_index_set == 0)
6351 errmsg ("missing interface name or sw_if_index");
6355 /* Construct the API message */
6356 M (SW_INTERFACE_SET_FLAGS, mp);
6357 mp->sw_if_index = ntohl (sw_if_index);
6358 mp->admin_up_down = admin_up;
6363 /* Wait for a reply, return the good/bad news... */
6369 api_sw_interface_set_rx_mode (vat_main_t * vam)
6371 unformat_input_t *i = vam->input;
6372 vl_api_sw_interface_set_rx_mode_t *mp;
6374 u8 sw_if_index_set = 0;
6376 u8 queue_id_valid = 0;
6378 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6380 /* Parse args required to build the message */
6381 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6383 if (unformat (i, "queue %d", &queue_id))
6385 else if (unformat (i, "polling"))
6386 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6387 else if (unformat (i, "interrupt"))
6388 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6389 else if (unformat (i, "adaptive"))
6390 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6392 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6393 sw_if_index_set = 1;
6394 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6395 sw_if_index_set = 1;
6400 if (sw_if_index_set == 0)
6402 errmsg ("missing interface name or sw_if_index");
6405 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6407 errmsg ("missing rx-mode");
6411 /* Construct the API message */
6412 M (SW_INTERFACE_SET_RX_MODE, mp);
6413 mp->sw_if_index = ntohl (sw_if_index);
6415 mp->queue_id_valid = queue_id_valid;
6416 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6421 /* Wait for a reply, return the good/bad news... */
6427 api_sw_interface_clear_stats (vat_main_t * vam)
6429 unformat_input_t *i = vam->input;
6430 vl_api_sw_interface_clear_stats_t *mp;
6432 u8 sw_if_index_set = 0;
6435 /* Parse args required to build the message */
6436 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6438 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6439 sw_if_index_set = 1;
6440 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6441 sw_if_index_set = 1;
6446 /* Construct the API message */
6447 M (SW_INTERFACE_CLEAR_STATS, mp);
6449 if (sw_if_index_set == 1)
6450 mp->sw_if_index = ntohl (sw_if_index);
6452 mp->sw_if_index = ~0;
6457 /* Wait for a reply, return the good/bad news... */
6463 api_sw_interface_add_del_address (vat_main_t * vam)
6465 unformat_input_t *i = vam->input;
6466 vl_api_sw_interface_add_del_address_t *mp;
6468 u8 sw_if_index_set = 0;
6469 u8 is_add = 1, del_all = 0;
6470 u32 address_length = 0;
6471 u8 v4_address_set = 0;
6472 u8 v6_address_set = 0;
6473 ip4_address_t v4address;
6474 ip6_address_t v6address;
6477 /* Parse args required to build the message */
6478 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6480 if (unformat (i, "del-all"))
6482 else if (unformat (i, "del"))
6485 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6486 sw_if_index_set = 1;
6487 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6488 sw_if_index_set = 1;
6489 else if (unformat (i, "%U/%d",
6490 unformat_ip4_address, &v4address, &address_length))
6492 else if (unformat (i, "%U/%d",
6493 unformat_ip6_address, &v6address, &address_length))
6499 if (sw_if_index_set == 0)
6501 errmsg ("missing interface name or sw_if_index");
6504 if (v4_address_set && v6_address_set)
6506 errmsg ("both v4 and v6 addresses set");
6509 if (!v4_address_set && !v6_address_set && !del_all)
6511 errmsg ("no addresses set");
6515 /* Construct the API message */
6516 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6518 mp->sw_if_index = ntohl (sw_if_index);
6519 mp->is_add = is_add;
6520 mp->del_all = del_all;
6524 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6528 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6530 mp->address_length = address_length;
6535 /* Wait for a reply, return good/bad news */
6541 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6543 unformat_input_t *i = vam->input;
6544 vl_api_sw_interface_set_mpls_enable_t *mp;
6546 u8 sw_if_index_set = 0;
6550 /* Parse args required to build the message */
6551 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6553 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6554 sw_if_index_set = 1;
6555 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6556 sw_if_index_set = 1;
6557 else if (unformat (i, "disable"))
6559 else if (unformat (i, "dis"))
6565 if (sw_if_index_set == 0)
6567 errmsg ("missing interface name or sw_if_index");
6571 /* Construct the API message */
6572 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6574 mp->sw_if_index = ntohl (sw_if_index);
6575 mp->enable = enable;
6580 /* Wait for a reply... */
6586 api_sw_interface_set_table (vat_main_t * vam)
6588 unformat_input_t *i = vam->input;
6589 vl_api_sw_interface_set_table_t *mp;
6590 u32 sw_if_index, vrf_id = 0;
6591 u8 sw_if_index_set = 0;
6595 /* Parse args required to build the message */
6596 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6598 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6599 sw_if_index_set = 1;
6600 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6601 sw_if_index_set = 1;
6602 else if (unformat (i, "vrf %d", &vrf_id))
6604 else if (unformat (i, "ipv6"))
6610 if (sw_if_index_set == 0)
6612 errmsg ("missing interface name or sw_if_index");
6616 /* Construct the API message */
6617 M (SW_INTERFACE_SET_TABLE, mp);
6619 mp->sw_if_index = ntohl (sw_if_index);
6620 mp->is_ipv6 = is_ipv6;
6621 mp->vrf_id = ntohl (vrf_id);
6626 /* Wait for a reply... */
6631 static void vl_api_sw_interface_get_table_reply_t_handler
6632 (vl_api_sw_interface_get_table_reply_t * mp)
6634 vat_main_t *vam = &vat_main;
6636 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6638 vam->retval = ntohl (mp->retval);
6639 vam->result_ready = 1;
6643 static void vl_api_sw_interface_get_table_reply_t_handler_json
6644 (vl_api_sw_interface_get_table_reply_t * mp)
6646 vat_main_t *vam = &vat_main;
6647 vat_json_node_t node;
6649 vat_json_init_object (&node);
6650 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6651 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6653 vat_json_print (vam->ofp, &node);
6654 vat_json_free (&node);
6656 vam->retval = ntohl (mp->retval);
6657 vam->result_ready = 1;
6661 api_sw_interface_get_table (vat_main_t * vam)
6663 unformat_input_t *i = vam->input;
6664 vl_api_sw_interface_get_table_t *mp;
6666 u8 sw_if_index_set = 0;
6670 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6672 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6673 sw_if_index_set = 1;
6674 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6675 sw_if_index_set = 1;
6676 else if (unformat (i, "ipv6"))
6682 if (sw_if_index_set == 0)
6684 errmsg ("missing interface name or sw_if_index");
6688 M (SW_INTERFACE_GET_TABLE, mp);
6689 mp->sw_if_index = htonl (sw_if_index);
6690 mp->is_ipv6 = is_ipv6;
6698 api_sw_interface_set_vpath (vat_main_t * vam)
6700 unformat_input_t *i = vam->input;
6701 vl_api_sw_interface_set_vpath_t *mp;
6702 u32 sw_if_index = 0;
6703 u8 sw_if_index_set = 0;
6707 /* Parse args required to build the message */
6708 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6710 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6711 sw_if_index_set = 1;
6712 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6713 sw_if_index_set = 1;
6714 else if (unformat (i, "enable"))
6716 else if (unformat (i, "disable"))
6722 if (sw_if_index_set == 0)
6724 errmsg ("missing interface name or sw_if_index");
6728 /* Construct the API message */
6729 M (SW_INTERFACE_SET_VPATH, mp);
6731 mp->sw_if_index = ntohl (sw_if_index);
6732 mp->enable = is_enable;
6737 /* Wait for a reply... */
6743 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6745 unformat_input_t *i = vam->input;
6746 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6747 u32 sw_if_index = 0;
6748 u8 sw_if_index_set = 0;
6753 /* Parse args required to build the message */
6754 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6756 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6757 sw_if_index_set = 1;
6758 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6759 sw_if_index_set = 1;
6760 else if (unformat (i, "enable"))
6762 else if (unformat (i, "disable"))
6764 else if (unformat (i, "ip4"))
6766 else if (unformat (i, "ip6"))
6772 if (sw_if_index_set == 0)
6774 errmsg ("missing interface name or sw_if_index");
6778 /* Construct the API message */
6779 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6781 mp->sw_if_index = ntohl (sw_if_index);
6782 mp->enable = is_enable;
6783 mp->is_ipv6 = is_ipv6;
6788 /* Wait for a reply... */
6794 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6796 unformat_input_t *i = vam->input;
6797 vl_api_sw_interface_set_geneve_bypass_t *mp;
6798 u32 sw_if_index = 0;
6799 u8 sw_if_index_set = 0;
6804 /* Parse args required to build the message */
6805 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6807 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6808 sw_if_index_set = 1;
6809 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6810 sw_if_index_set = 1;
6811 else if (unformat (i, "enable"))
6813 else if (unformat (i, "disable"))
6815 else if (unformat (i, "ip4"))
6817 else if (unformat (i, "ip6"))
6823 if (sw_if_index_set == 0)
6825 errmsg ("missing interface name or sw_if_index");
6829 /* Construct the API message */
6830 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6832 mp->sw_if_index = ntohl (sw_if_index);
6833 mp->enable = is_enable;
6834 mp->is_ipv6 = is_ipv6;
6839 /* Wait for a reply... */
6845 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6847 unformat_input_t *i = vam->input;
6848 vl_api_sw_interface_set_l2_xconnect_t *mp;
6850 u8 rx_sw_if_index_set = 0;
6852 u8 tx_sw_if_index_set = 0;
6856 /* Parse args required to build the message */
6857 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6859 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6860 rx_sw_if_index_set = 1;
6861 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6862 tx_sw_if_index_set = 1;
6863 else if (unformat (i, "rx"))
6865 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6867 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6869 rx_sw_if_index_set = 1;
6874 else if (unformat (i, "tx"))
6876 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6878 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6880 tx_sw_if_index_set = 1;
6885 else if (unformat (i, "enable"))
6887 else if (unformat (i, "disable"))
6893 if (rx_sw_if_index_set == 0)
6895 errmsg ("missing rx interface name or rx_sw_if_index");
6899 if (enable && (tx_sw_if_index_set == 0))
6901 errmsg ("missing tx interface name or tx_sw_if_index");
6905 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6907 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6908 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6909 mp->enable = enable;
6917 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6919 unformat_input_t *i = vam->input;
6920 vl_api_sw_interface_set_l2_bridge_t *mp;
6922 u8 rx_sw_if_index_set = 0;
6930 /* Parse args required to build the message */
6931 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6933 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6934 rx_sw_if_index_set = 1;
6935 else if (unformat (i, "bd_id %d", &bd_id))
6939 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6940 rx_sw_if_index_set = 1;
6941 else if (unformat (i, "shg %d", &shg))
6943 else if (unformat (i, "bvi"))
6945 else if (unformat (i, "enable"))
6947 else if (unformat (i, "disable"))
6953 if (rx_sw_if_index_set == 0)
6955 errmsg ("missing rx interface name or sw_if_index");
6959 if (enable && (bd_id_set == 0))
6961 errmsg ("missing bridge domain");
6965 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6967 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6968 mp->bd_id = ntohl (bd_id);
6971 mp->enable = enable;
6979 api_bridge_domain_dump (vat_main_t * vam)
6981 unformat_input_t *i = vam->input;
6982 vl_api_bridge_domain_dump_t *mp;
6983 vl_api_control_ping_t *mp_ping;
6987 /* Parse args required to build the message */
6988 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6990 if (unformat (i, "bd_id %d", &bd_id))
6996 M (BRIDGE_DOMAIN_DUMP, mp);
6997 mp->bd_id = ntohl (bd_id);
7000 /* Use a control ping for synchronization */
7001 MPING (CONTROL_PING, mp_ping);
7009 api_bridge_domain_add_del (vat_main_t * vam)
7011 unformat_input_t *i = vam->input;
7012 vl_api_bridge_domain_add_del_t *mp;
7015 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7020 /* Parse args required to build the message */
7021 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7023 if (unformat (i, "bd_id %d", &bd_id))
7025 else if (unformat (i, "flood %d", &flood))
7027 else if (unformat (i, "uu-flood %d", &uu_flood))
7029 else if (unformat (i, "forward %d", &forward))
7031 else if (unformat (i, "learn %d", &learn))
7033 else if (unformat (i, "arp-term %d", &arp_term))
7035 else if (unformat (i, "mac-age %d", &mac_age))
7037 else if (unformat (i, "bd-tag %s", &bd_tag))
7039 else if (unformat (i, "del"))
7042 flood = uu_flood = forward = learn = 0;
7050 errmsg ("missing bridge domain");
7057 errmsg ("mac age must be less than 256 ");
7062 if ((bd_tag) && (strlen ((char *) bd_tag) > 63))
7064 errmsg ("bd-tag cannot be longer than 63");
7069 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7071 mp->bd_id = ntohl (bd_id);
7073 mp->uu_flood = uu_flood;
7074 mp->forward = forward;
7076 mp->arp_term = arp_term;
7077 mp->is_add = is_add;
7078 mp->mac_age = (u8) mac_age;
7080 strcpy ((char *) mp->bd_tag, (char *) bd_tag);
7091 api_l2fib_flush_bd (vat_main_t * vam)
7093 unformat_input_t *i = vam->input;
7094 vl_api_l2fib_flush_bd_t *mp;
7098 /* Parse args required to build the message */
7099 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7101 if (unformat (i, "bd_id %d", &bd_id));
7108 errmsg ("missing bridge domain");
7112 M (L2FIB_FLUSH_BD, mp);
7114 mp->bd_id = htonl (bd_id);
7122 api_l2fib_flush_int (vat_main_t * vam)
7124 unformat_input_t *i = vam->input;
7125 vl_api_l2fib_flush_int_t *mp;
7126 u32 sw_if_index = ~0;
7129 /* Parse args required to build the message */
7130 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7132 if (unformat (i, "sw_if_index %d", &sw_if_index));
7134 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7139 if (sw_if_index == ~0)
7141 errmsg ("missing interface name or sw_if_index");
7145 M (L2FIB_FLUSH_INT, mp);
7147 mp->sw_if_index = ntohl (sw_if_index);
7155 api_l2fib_add_del (vat_main_t * vam)
7157 unformat_input_t *i = vam->input;
7158 vl_api_l2fib_add_del_t *mp;
7164 u32 sw_if_index = ~0;
7165 u8 sw_if_index_set = 0;
7174 /* Parse args required to build the message */
7175 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7177 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7179 else if (unformat (i, "bd_id %d", &bd_id))
7181 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7182 sw_if_index_set = 1;
7183 else if (unformat (i, "sw_if"))
7185 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7188 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7189 sw_if_index_set = 1;
7194 else if (unformat (i, "static"))
7196 else if (unformat (i, "filter"))
7201 else if (unformat (i, "bvi"))
7206 else if (unformat (i, "del"))
7208 else if (unformat (i, "count %d", &count))
7216 errmsg ("missing mac address");
7222 errmsg ("missing bridge domain");
7226 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7228 errmsg ("missing interface name or sw_if_index");
7234 /* Turn on async mode */
7235 vam->async_mode = 1;
7236 vam->async_errors = 0;
7237 before = vat_time_now (vam);
7240 for (j = 0; j < count; j++)
7242 M (L2FIB_ADD_DEL, mp);
7244 clib_memcpy (mp->mac, mac, 6);
7245 mp->bd_id = ntohl (bd_id);
7246 mp->is_add = is_add;
7250 mp->sw_if_index = ntohl (sw_if_index);
7251 mp->static_mac = static_mac;
7252 mp->filter_mac = filter_mac;
7253 mp->bvi_mac = bvi_mac;
7255 increment_mac_address (mac);
7262 vl_api_control_ping_t *mp_ping;
7265 /* Shut off async mode */
7266 vam->async_mode = 0;
7268 MPING (CONTROL_PING, mp_ping);
7271 timeout = vat_time_now (vam) + 1.0;
7272 while (vat_time_now (vam) < timeout)
7273 if (vam->result_ready == 1)
7278 if (vam->retval == -99)
7281 if (vam->async_errors > 0)
7283 errmsg ("%d asynchronous errors", vam->async_errors);
7286 vam->async_errors = 0;
7287 after = vat_time_now (vam);
7289 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7290 count, after - before, count / (after - before));
7296 /* Wait for a reply... */
7300 /* Return the good/bad news */
7301 return (vam->retval);
7305 api_bridge_domain_set_mac_age (vat_main_t * vam)
7307 unformat_input_t *i = vam->input;
7308 vl_api_bridge_domain_set_mac_age_t *mp;
7313 /* Parse args required to build the message */
7314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7316 if (unformat (i, "bd_id %d", &bd_id));
7317 else if (unformat (i, "mac-age %d", &mac_age));
7324 errmsg ("missing bridge domain");
7330 errmsg ("mac age must be less than 256 ");
7334 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7336 mp->bd_id = htonl (bd_id);
7337 mp->mac_age = (u8) mac_age;
7345 api_l2_flags (vat_main_t * vam)
7347 unformat_input_t *i = vam->input;
7348 vl_api_l2_flags_t *mp;
7351 u8 sw_if_index_set = 0;
7355 /* Parse args required to build the message */
7356 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7358 if (unformat (i, "sw_if_index %d", &sw_if_index))
7359 sw_if_index_set = 1;
7360 else if (unformat (i, "sw_if"))
7362 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7365 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7366 sw_if_index_set = 1;
7371 else if (unformat (i, "learn"))
7373 else if (unformat (i, "forward"))
7375 else if (unformat (i, "flood"))
7377 else if (unformat (i, "uu-flood"))
7378 flags |= L2_UU_FLOOD;
7379 else if (unformat (i, "arp-term"))
7380 flags |= L2_ARP_TERM;
7381 else if (unformat (i, "off"))
7383 else if (unformat (i, "disable"))
7389 if (sw_if_index_set == 0)
7391 errmsg ("missing interface name or sw_if_index");
7397 mp->sw_if_index = ntohl (sw_if_index);
7398 mp->feature_bitmap = ntohl (flags);
7399 mp->is_set = is_set;
7407 api_bridge_flags (vat_main_t * vam)
7409 unformat_input_t *i = vam->input;
7410 vl_api_bridge_flags_t *mp;
7417 /* Parse args required to build the message */
7418 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7420 if (unformat (i, "bd_id %d", &bd_id))
7422 else if (unformat (i, "learn"))
7424 else if (unformat (i, "forward"))
7426 else if (unformat (i, "flood"))
7428 else if (unformat (i, "uu-flood"))
7429 flags |= L2_UU_FLOOD;
7430 else if (unformat (i, "arp-term"))
7431 flags |= L2_ARP_TERM;
7432 else if (unformat (i, "off"))
7434 else if (unformat (i, "disable"))
7442 errmsg ("missing bridge domain");
7446 M (BRIDGE_FLAGS, mp);
7448 mp->bd_id = ntohl (bd_id);
7449 mp->feature_bitmap = ntohl (flags);
7450 mp->is_set = is_set;
7458 api_bd_ip_mac_add_del (vat_main_t * vam)
7460 unformat_input_t *i = vam->input;
7461 vl_api_bd_ip_mac_add_del_t *mp;
7468 ip4_address_t v4addr;
7469 ip6_address_t v6addr;
7474 /* Parse args required to build the message */
7475 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7477 if (unformat (i, "bd_id %d", &bd_id))
7481 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7485 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7490 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7494 else if (unformat (i, "del"))
7502 errmsg ("missing bridge domain");
7505 else if (ip_set == 0)
7507 errmsg ("missing IP address");
7510 else if (mac_set == 0)
7512 errmsg ("missing MAC address");
7516 M (BD_IP_MAC_ADD_DEL, mp);
7518 mp->bd_id = ntohl (bd_id);
7519 mp->is_ipv6 = is_ipv6;
7520 mp->is_add = is_add;
7522 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7524 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7525 clib_memcpy (mp->mac_address, macaddr, 6);
7532 api_tap_connect (vat_main_t * vam)
7534 unformat_input_t *i = vam->input;
7535 vl_api_tap_connect_t *mp;
7541 ip4_address_t ip4_address;
7543 int ip4_address_set = 0;
7544 ip6_address_t ip6_address;
7546 int ip6_address_set = 0;
7549 memset (mac_address, 0, sizeof (mac_address));
7551 /* Parse args required to build the message */
7552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7554 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7558 else if (unformat (i, "random-mac"))
7560 else if (unformat (i, "tapname %s", &tap_name))
7562 else if (unformat (i, "tag %s", &tag))
7564 else if (unformat (i, "address %U/%d",
7565 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7566 ip4_address_set = 1;
7567 else if (unformat (i, "address %U/%d",
7568 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7569 ip6_address_set = 1;
7576 errmsg ("missing tap name");
7579 if (vec_len (tap_name) > 63)
7581 errmsg ("tap name too long");
7584 vec_add1 (tap_name, 0);
7586 if (vec_len (tag) > 63)
7588 errmsg ("tag too long");
7592 /* Construct the API message */
7593 M (TAP_CONNECT, mp);
7595 mp->use_random_mac = random_mac;
7596 clib_memcpy (mp->mac_address, mac_address, 6);
7597 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7599 clib_memcpy (mp->tag, tag, vec_len (tag));
7601 if (ip4_address_set)
7603 mp->ip4_address_set = 1;
7604 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7605 mp->ip4_mask_width = ip4_mask_width;
7607 if (ip6_address_set)
7609 mp->ip6_address_set = 1;
7610 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7611 mp->ip6_mask_width = ip6_mask_width;
7614 vec_free (tap_name);
7620 /* Wait for a reply... */
7626 api_tap_modify (vat_main_t * vam)
7628 unformat_input_t *i = vam->input;
7629 vl_api_tap_modify_t *mp;
7634 u32 sw_if_index = ~0;
7635 u8 sw_if_index_set = 0;
7638 memset (mac_address, 0, sizeof (mac_address));
7640 /* Parse args required to build the message */
7641 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7643 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7644 sw_if_index_set = 1;
7645 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7646 sw_if_index_set = 1;
7647 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7651 else if (unformat (i, "random-mac"))
7653 else if (unformat (i, "tapname %s", &tap_name))
7659 if (sw_if_index_set == 0)
7661 errmsg ("missing vpp interface name");
7666 errmsg ("missing tap name");
7669 if (vec_len (tap_name) > 63)
7671 errmsg ("tap name too long");
7673 vec_add1 (tap_name, 0);
7675 /* Construct the API message */
7678 mp->use_random_mac = random_mac;
7679 mp->sw_if_index = ntohl (sw_if_index);
7680 clib_memcpy (mp->mac_address, mac_address, 6);
7681 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7682 vec_free (tap_name);
7687 /* Wait for a reply... */
7693 api_tap_delete (vat_main_t * vam)
7695 unformat_input_t *i = vam->input;
7696 vl_api_tap_delete_t *mp;
7697 u32 sw_if_index = ~0;
7698 u8 sw_if_index_set = 0;
7701 /* Parse args required to build the message */
7702 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7704 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7705 sw_if_index_set = 1;
7706 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7707 sw_if_index_set = 1;
7712 if (sw_if_index_set == 0)
7714 errmsg ("missing vpp interface name");
7718 /* Construct the API message */
7721 mp->sw_if_index = ntohl (sw_if_index);
7726 /* Wait for a reply... */
7732 api_ip_table_add_del (vat_main_t * vam)
7734 unformat_input_t *i = vam->input;
7735 vl_api_ip_table_add_del_t *mp;
7741 /* Parse args required to build the message */
7742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7744 if (unformat (i, "ipv6"))
7746 else if (unformat (i, "del"))
7748 else if (unformat (i, "add"))
7750 else if (unformat (i, "table %d", &table_id))
7754 clib_warning ("parse error '%U'", format_unformat_error, i);
7761 errmsg ("missing table-ID");
7765 /* Construct the API message */
7766 M (IP_TABLE_ADD_DEL, mp);
7768 mp->table_id = ntohl (table_id);
7769 mp->is_ipv6 = is_ipv6;
7770 mp->is_add = is_add;
7775 /* Wait for a reply... */
7782 api_ip_add_del_route (vat_main_t * vam)
7784 unformat_input_t *i = vam->input;
7785 vl_api_ip_add_del_route_t *mp;
7786 u32 sw_if_index = ~0, vrf_id = 0;
7788 u8 is_local = 0, is_drop = 0;
7789 u8 is_unreach = 0, is_prohibit = 0;
7790 u8 create_vrf_if_needed = 0;
7792 u32 next_hop_weight = 1;
7793 u8 is_multipath = 0;
7795 u8 address_length_set = 0;
7796 u32 next_hop_table_id = 0;
7797 u32 resolve_attempts = 0;
7798 u32 dst_address_length = 0;
7799 u8 next_hop_set = 0;
7800 ip4_address_t v4_dst_address, v4_next_hop_address;
7801 ip6_address_t v6_dst_address, v6_next_hop_address;
7805 u32 random_add_del = 0;
7806 u32 *random_vector = 0;
7808 u32 random_seed = 0xdeaddabe;
7809 u32 classify_table_index = ~0;
7811 u8 resolve_host = 0, resolve_attached = 0;
7812 mpls_label_t *next_hop_out_label_stack = NULL;
7813 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7814 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7816 /* Parse args required to build the message */
7817 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7819 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7821 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7823 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
7828 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
7833 else if (unformat (i, "/%d", &dst_address_length))
7835 address_length_set = 1;
7838 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
7839 &v4_next_hop_address))
7843 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7844 &v6_next_hop_address))
7848 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7850 else if (unformat (i, "weight %d", &next_hop_weight))
7852 else if (unformat (i, "drop"))
7856 else if (unformat (i, "null-send-unreach"))
7860 else if (unformat (i, "null-send-prohibit"))
7864 else if (unformat (i, "local"))
7868 else if (unformat (i, "classify %d", &classify_table_index))
7872 else if (unformat (i, "del"))
7874 else if (unformat (i, "add"))
7876 else if (unformat (i, "resolve-via-host"))
7878 else if (unformat (i, "resolve-via-attached"))
7879 resolve_attached = 1;
7880 else if (unformat (i, "multipath"))
7882 else if (unformat (i, "vrf %d", &vrf_id))
7884 else if (unformat (i, "create-vrf"))
7885 create_vrf_if_needed = 1;
7886 else if (unformat (i, "count %d", &count))
7888 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7890 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7892 else if (unformat (i, "out-label %d", &next_hop_out_label))
7893 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7894 else if (unformat (i, "via-label %d", &next_hop_via_label))
7896 else if (unformat (i, "random"))
7898 else if (unformat (i, "seed %d", &random_seed))
7902 clib_warning ("parse error '%U'", format_unformat_error, i);
7907 if (!next_hop_set && !is_drop && !is_local &&
7908 !is_classify && !is_unreach && !is_prohibit &&
7909 MPLS_LABEL_INVALID == next_hop_via_label)
7912 ("next hop / local / drop / unreach / prohibit / classify not set");
7916 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7918 errmsg ("next hop and next-hop via label set");
7921 if (address_set == 0)
7923 errmsg ("missing addresses");
7927 if (address_length_set == 0)
7929 errmsg ("missing address length");
7933 /* Generate a pile of unique, random routes */
7936 u32 this_random_address;
7937 random_hash = hash_create (count, sizeof (uword));
7939 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7940 for (j = 0; j <= count; j++)
7944 this_random_address = random_u32 (&random_seed);
7945 this_random_address =
7946 clib_host_to_net_u32 (this_random_address);
7948 while (hash_get (random_hash, this_random_address));
7949 vec_add1 (random_vector, this_random_address);
7950 hash_set (random_hash, this_random_address, 1);
7952 hash_free (random_hash);
7953 v4_dst_address.as_u32 = random_vector[0];
7958 /* Turn on async mode */
7959 vam->async_mode = 1;
7960 vam->async_errors = 0;
7961 before = vat_time_now (vam);
7964 for (j = 0; j < count; j++)
7966 /* Construct the API message */
7967 M2 (IP_ADD_DEL_ROUTE, mp,
7968 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7970 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7971 mp->table_id = ntohl (vrf_id);
7972 mp->create_vrf_if_needed = create_vrf_if_needed;
7974 mp->is_add = is_add;
7975 mp->is_drop = is_drop;
7976 mp->is_unreach = is_unreach;
7977 mp->is_prohibit = is_prohibit;
7978 mp->is_ipv6 = is_ipv6;
7979 mp->is_local = is_local;
7980 mp->is_classify = is_classify;
7981 mp->is_multipath = is_multipath;
7982 mp->is_resolve_host = resolve_host;
7983 mp->is_resolve_attached = resolve_attached;
7984 mp->next_hop_weight = next_hop_weight;
7985 mp->dst_address_length = dst_address_length;
7986 mp->next_hop_table_id = ntohl (next_hop_table_id);
7987 mp->classify_table_index = ntohl (classify_table_index);
7988 mp->next_hop_via_label = ntohl (next_hop_via_label);
7989 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7990 if (0 != mp->next_hop_n_out_labels)
7992 memcpy (mp->next_hop_out_label_stack,
7993 next_hop_out_label_stack,
7994 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7995 vec_free (next_hop_out_label_stack);
8000 clib_memcpy (mp->dst_address, &v6_dst_address,
8001 sizeof (v6_dst_address));
8003 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8004 sizeof (v6_next_hop_address));
8005 increment_v6_address (&v6_dst_address);
8009 clib_memcpy (mp->dst_address, &v4_dst_address,
8010 sizeof (v4_dst_address));
8012 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8013 sizeof (v4_next_hop_address));
8015 v4_dst_address.as_u32 = random_vector[j + 1];
8017 increment_v4_address (&v4_dst_address);
8021 /* If we receive SIGTERM, stop now... */
8026 /* When testing multiple add/del ops, use a control-ping to sync */
8029 vl_api_control_ping_t *mp_ping;
8033 /* Shut off async mode */
8034 vam->async_mode = 0;
8036 MPING (CONTROL_PING, mp_ping);
8039 timeout = vat_time_now (vam) + 1.0;
8040 while (vat_time_now (vam) < timeout)
8041 if (vam->result_ready == 1)
8046 if (vam->retval == -99)
8049 if (vam->async_errors > 0)
8051 errmsg ("%d asynchronous errors", vam->async_errors);
8054 vam->async_errors = 0;
8055 after = vat_time_now (vam);
8057 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8061 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8062 count, after - before, count / (after - before));
8068 /* Wait for a reply... */
8073 /* Return the good/bad news */
8074 return (vam->retval);
8078 api_ip_mroute_add_del (vat_main_t * vam)
8080 unformat_input_t *i = vam->input;
8081 vl_api_ip_mroute_add_del_t *mp;
8082 u32 sw_if_index = ~0, vrf_id = 0;
8085 u8 create_vrf_if_needed = 0;
8088 u32 grp_address_length = 0;
8089 ip4_address_t v4_grp_address, v4_src_address;
8090 ip6_address_t v6_grp_address, v6_src_address;
8091 mfib_itf_flags_t iflags = 0;
8092 mfib_entry_flags_t eflags = 0;
8095 /* Parse args required to build the message */
8096 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8098 if (unformat (i, "sw_if_index %d", &sw_if_index))
8100 else if (unformat (i, "%U %U",
8101 unformat_ip4_address, &v4_src_address,
8102 unformat_ip4_address, &v4_grp_address))
8104 grp_address_length = 64;
8108 else if (unformat (i, "%U %U",
8109 unformat_ip6_address, &v6_src_address,
8110 unformat_ip6_address, &v6_grp_address))
8112 grp_address_length = 256;
8116 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8118 memset (&v4_src_address, 0, sizeof (v4_src_address));
8119 grp_address_length = 32;
8123 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8125 memset (&v6_src_address, 0, sizeof (v6_src_address));
8126 grp_address_length = 128;
8130 else if (unformat (i, "/%d", &grp_address_length))
8132 else if (unformat (i, "local"))
8136 else if (unformat (i, "del"))
8138 else if (unformat (i, "add"))
8140 else if (unformat (i, "vrf %d", &vrf_id))
8142 else if (unformat (i, "create-vrf"))
8143 create_vrf_if_needed = 1;
8144 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8146 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8150 clib_warning ("parse error '%U'", format_unformat_error, i);
8155 if (address_set == 0)
8157 errmsg ("missing addresses\n");
8161 /* Construct the API message */
8162 M (IP_MROUTE_ADD_DEL, mp);
8164 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8165 mp->table_id = ntohl (vrf_id);
8166 mp->create_vrf_if_needed = create_vrf_if_needed;
8168 mp->is_add = is_add;
8169 mp->is_ipv6 = is_ipv6;
8170 mp->is_local = is_local;
8171 mp->itf_flags = ntohl (iflags);
8172 mp->entry_flags = ntohl (eflags);
8173 mp->grp_address_length = grp_address_length;
8174 mp->grp_address_length = ntohs (mp->grp_address_length);
8178 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8179 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8183 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8184 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8190 /* Wait for a reply... */
8196 api_mpls_table_add_del (vat_main_t * vam)
8198 unformat_input_t *i = vam->input;
8199 vl_api_mpls_table_add_del_t *mp;
8204 /* Parse args required to build the message */
8205 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8207 if (unformat (i, "table %d", &table_id))
8209 else if (unformat (i, "del"))
8211 else if (unformat (i, "add"))
8215 clib_warning ("parse error '%U'", format_unformat_error, i);
8222 errmsg ("missing table-ID");
8226 /* Construct the API message */
8227 M (MPLS_TABLE_ADD_DEL, mp);
8229 mp->mt_table_id = ntohl (table_id);
8230 mp->mt_is_add = is_add;
8235 /* Wait for a reply... */
8242 api_mpls_route_add_del (vat_main_t * vam)
8244 unformat_input_t *i = vam->input;
8245 vl_api_mpls_route_add_del_t *mp;
8246 u32 sw_if_index = ~0, table_id = 0;
8247 u8 create_table_if_needed = 0;
8249 u32 next_hop_weight = 1;
8250 u8 is_multipath = 0;
8251 u32 next_hop_table_id = 0;
8252 u8 next_hop_set = 0;
8253 ip4_address_t v4_next_hop_address = {
8256 ip6_address_t v6_next_hop_address = { {0} };
8260 u32 classify_table_index = ~0;
8262 u8 resolve_host = 0, resolve_attached = 0;
8263 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8264 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8265 mpls_label_t *next_hop_out_label_stack = NULL;
8266 mpls_label_t local_label = MPLS_LABEL_INVALID;
8268 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8270 /* Parse args required to build the message */
8271 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8273 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8275 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8277 else if (unformat (i, "%d", &local_label))
8279 else if (unformat (i, "eos"))
8281 else if (unformat (i, "non-eos"))
8283 else if (unformat (i, "via %U", unformat_ip4_address,
8284 &v4_next_hop_address))
8287 next_hop_proto = DPO_PROTO_IP4;
8289 else if (unformat (i, "via %U", unformat_ip6_address,
8290 &v6_next_hop_address))
8293 next_hop_proto = DPO_PROTO_IP6;
8295 else if (unformat (i, "weight %d", &next_hop_weight))
8297 else if (unformat (i, "create-table"))
8298 create_table_if_needed = 1;
8299 else if (unformat (i, "classify %d", &classify_table_index))
8303 else if (unformat (i, "del"))
8305 else if (unformat (i, "add"))
8307 else if (unformat (i, "resolve-via-host"))
8309 else if (unformat (i, "resolve-via-attached"))
8310 resolve_attached = 1;
8311 else if (unformat (i, "multipath"))
8313 else if (unformat (i, "count %d", &count))
8315 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8318 next_hop_proto = DPO_PROTO_IP4;
8320 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8323 next_hop_proto = DPO_PROTO_IP6;
8325 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8327 else if (unformat (i, "via-label %d", &next_hop_via_label))
8329 else if (unformat (i, "out-label %d", &next_hop_out_label))
8330 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8333 clib_warning ("parse error '%U'", format_unformat_error, i);
8338 if (!next_hop_set && !is_classify)
8340 errmsg ("next hop / classify not set");
8344 if (MPLS_LABEL_INVALID == local_label)
8346 errmsg ("missing label");
8352 /* Turn on async mode */
8353 vam->async_mode = 1;
8354 vam->async_errors = 0;
8355 before = vat_time_now (vam);
8358 for (j = 0; j < count; j++)
8360 /* Construct the API message */
8361 M2 (MPLS_ROUTE_ADD_DEL, mp,
8362 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8364 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8365 mp->mr_table_id = ntohl (table_id);
8366 mp->mr_create_table_if_needed = create_table_if_needed;
8368 mp->mr_is_add = is_add;
8369 mp->mr_next_hop_proto = next_hop_proto;
8370 mp->mr_is_classify = is_classify;
8371 mp->mr_is_multipath = is_multipath;
8372 mp->mr_is_resolve_host = resolve_host;
8373 mp->mr_is_resolve_attached = resolve_attached;
8374 mp->mr_next_hop_weight = next_hop_weight;
8375 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8376 mp->mr_classify_table_index = ntohl (classify_table_index);
8377 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8378 mp->mr_label = ntohl (local_label);
8379 mp->mr_eos = is_eos;
8381 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8382 if (0 != mp->mr_next_hop_n_out_labels)
8384 memcpy (mp->mr_next_hop_out_label_stack,
8385 next_hop_out_label_stack,
8386 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8387 vec_free (next_hop_out_label_stack);
8392 if (DPO_PROTO_IP4 == next_hop_proto)
8394 clib_memcpy (mp->mr_next_hop,
8395 &v4_next_hop_address,
8396 sizeof (v4_next_hop_address));
8398 else if (DPO_PROTO_IP6 == next_hop_proto)
8401 clib_memcpy (mp->mr_next_hop,
8402 &v6_next_hop_address,
8403 sizeof (v6_next_hop_address));
8410 /* If we receive SIGTERM, stop now... */
8415 /* When testing multiple add/del ops, use a control-ping to sync */
8418 vl_api_control_ping_t *mp_ping;
8422 /* Shut off async mode */
8423 vam->async_mode = 0;
8425 MPING (CONTROL_PING, mp_ping);
8428 timeout = vat_time_now (vam) + 1.0;
8429 while (vat_time_now (vam) < timeout)
8430 if (vam->result_ready == 1)
8435 if (vam->retval == -99)
8438 if (vam->async_errors > 0)
8440 errmsg ("%d asynchronous errors", vam->async_errors);
8443 vam->async_errors = 0;
8444 after = vat_time_now (vam);
8446 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8450 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8451 count, after - before, count / (after - before));
8457 /* Wait for a reply... */
8462 /* Return the good/bad news */
8463 return (vam->retval);
8467 api_mpls_ip_bind_unbind (vat_main_t * vam)
8469 unformat_input_t *i = vam->input;
8470 vl_api_mpls_ip_bind_unbind_t *mp;
8471 u32 ip_table_id = 0;
8472 u8 create_table_if_needed = 0;
8475 ip4_address_t v4_address;
8476 ip6_address_t v6_address;
8479 mpls_label_t local_label = MPLS_LABEL_INVALID;
8482 /* Parse args required to build the message */
8483 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8485 if (unformat (i, "%U/%d", unformat_ip4_address,
8486 &v4_address, &address_length))
8491 else if (unformat (i, "%U/%d", unformat_ip6_address,
8492 &v6_address, &address_length))
8497 else if (unformat (i, "%d", &local_label))
8499 else if (unformat (i, "create-table"))
8500 create_table_if_needed = 1;
8501 else if (unformat (i, "table-id %d", &ip_table_id))
8503 else if (unformat (i, "unbind"))
8505 else if (unformat (i, "bind"))
8509 clib_warning ("parse error '%U'", format_unformat_error, i);
8516 errmsg ("IP addres not set");
8520 if (MPLS_LABEL_INVALID == local_label)
8522 errmsg ("missing label");
8526 /* Construct the API message */
8527 M (MPLS_IP_BIND_UNBIND, mp);
8529 mp->mb_create_table_if_needed = create_table_if_needed;
8530 mp->mb_is_bind = is_bind;
8531 mp->mb_is_ip4 = is_ip4;
8532 mp->mb_ip_table_id = ntohl (ip_table_id);
8533 mp->mb_mpls_table_id = 0;
8534 mp->mb_label = ntohl (local_label);
8535 mp->mb_address_length = address_length;
8538 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8540 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8545 /* Wait for a reply... */
8551 api_proxy_arp_add_del (vat_main_t * vam)
8553 unformat_input_t *i = vam->input;
8554 vl_api_proxy_arp_add_del_t *mp;
8557 ip4_address_t lo, hi;
8561 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8563 if (unformat (i, "vrf %d", &vrf_id))
8565 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
8566 unformat_ip4_address, &hi))
8568 else if (unformat (i, "del"))
8572 clib_warning ("parse error '%U'", format_unformat_error, i);
8579 errmsg ("address range not set");
8583 M (PROXY_ARP_ADD_DEL, mp);
8585 mp->vrf_id = ntohl (vrf_id);
8586 mp->is_add = is_add;
8587 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
8588 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
8596 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8598 unformat_input_t *i = vam->input;
8599 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8602 u8 sw_if_index_set = 0;
8605 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8607 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8608 sw_if_index_set = 1;
8609 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8610 sw_if_index_set = 1;
8611 else if (unformat (i, "enable"))
8613 else if (unformat (i, "disable"))
8617 clib_warning ("parse error '%U'", format_unformat_error, i);
8622 if (sw_if_index_set == 0)
8624 errmsg ("missing interface name or sw_if_index");
8628 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8630 mp->sw_if_index = ntohl (sw_if_index);
8631 mp->enable_disable = enable;
8639 api_mpls_tunnel_add_del (vat_main_t * vam)
8641 unformat_input_t *i = vam->input;
8642 vl_api_mpls_tunnel_add_del_t *mp;
8646 u32 sw_if_index = ~0;
8647 u32 next_hop_sw_if_index = ~0;
8648 u32 next_hop_proto_is_ip4 = 1;
8650 u32 next_hop_table_id = 0;
8651 ip4_address_t v4_next_hop_address = {
8654 ip6_address_t v6_next_hop_address = { {0} };
8655 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
8658 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8660 if (unformat (i, "add"))
8662 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8664 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
8666 else if (unformat (i, "via %U",
8667 unformat_ip4_address, &v4_next_hop_address))
8669 next_hop_proto_is_ip4 = 1;
8671 else if (unformat (i, "via %U",
8672 unformat_ip6_address, &v6_next_hop_address))
8674 next_hop_proto_is_ip4 = 0;
8676 else if (unformat (i, "l2-only"))
8678 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8680 else if (unformat (i, "out-label %d", &next_hop_out_label))
8681 vec_add1 (labels, ntohl (next_hop_out_label));
8684 clib_warning ("parse error '%U'", format_unformat_error, i);
8689 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
8691 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
8692 mp->mt_sw_if_index = ntohl (sw_if_index);
8693 mp->mt_is_add = is_add;
8694 mp->mt_l2_only = l2_only;
8695 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
8696 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
8698 mp->mt_next_hop_n_out_labels = vec_len (labels);
8700 if (0 != mp->mt_next_hop_n_out_labels)
8702 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
8703 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
8707 if (next_hop_proto_is_ip4)
8709 clib_memcpy (mp->mt_next_hop,
8710 &v4_next_hop_address, sizeof (v4_next_hop_address));
8714 clib_memcpy (mp->mt_next_hop,
8715 &v6_next_hop_address, sizeof (v6_next_hop_address));
8724 api_sw_interface_set_unnumbered (vat_main_t * vam)
8726 unformat_input_t *i = vam->input;
8727 vl_api_sw_interface_set_unnumbered_t *mp;
8729 u32 unnum_sw_index = ~0;
8731 u8 sw_if_index_set = 0;
8734 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8736 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8737 sw_if_index_set = 1;
8738 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8739 sw_if_index_set = 1;
8740 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8742 else if (unformat (i, "del"))
8746 clib_warning ("parse error '%U'", format_unformat_error, i);
8751 if (sw_if_index_set == 0)
8753 errmsg ("missing interface name or sw_if_index");
8757 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8759 mp->sw_if_index = ntohl (sw_if_index);
8760 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8761 mp->is_add = is_add;
8769 api_ip_neighbor_add_del (vat_main_t * vam)
8771 unformat_input_t *i = vam->input;
8772 vl_api_ip_neighbor_add_del_t *mp;
8774 u8 sw_if_index_set = 0;
8777 u8 is_no_fib_entry = 0;
8780 u8 v4_address_set = 0;
8781 u8 v6_address_set = 0;
8782 ip4_address_t v4address;
8783 ip6_address_t v6address;
8786 memset (mac_address, 0, sizeof (mac_address));
8788 /* Parse args required to build the message */
8789 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8791 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8795 else if (unformat (i, "del"))
8798 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8799 sw_if_index_set = 1;
8800 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8801 sw_if_index_set = 1;
8802 else if (unformat (i, "is_static"))
8804 else if (unformat (i, "no-fib-entry"))
8805 is_no_fib_entry = 1;
8806 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
8808 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
8812 clib_warning ("parse error '%U'", format_unformat_error, i);
8817 if (sw_if_index_set == 0)
8819 errmsg ("missing interface name or sw_if_index");
8822 if (v4_address_set && v6_address_set)
8824 errmsg ("both v4 and v6 addresses set");
8827 if (!v4_address_set && !v6_address_set)
8829 errmsg ("no address set");
8833 /* Construct the API message */
8834 M (IP_NEIGHBOR_ADD_DEL, mp);
8836 mp->sw_if_index = ntohl (sw_if_index);
8837 mp->is_add = is_add;
8838 mp->is_static = is_static;
8839 mp->is_no_adj_fib = is_no_fib_entry;
8841 clib_memcpy (mp->mac_address, mac_address, 6);
8845 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
8849 /* mp->is_ipv6 = 0; via memset in M macro above */
8850 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
8856 /* Wait for a reply, return good/bad news */
8862 api_reset_vrf (vat_main_t * vam)
8864 unformat_input_t *i = vam->input;
8865 vl_api_reset_vrf_t *mp;
8871 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8873 if (unformat (i, "vrf %d", &vrf_id))
8875 else if (unformat (i, "ipv6"))
8879 clib_warning ("parse error '%U'", format_unformat_error, i);
8884 if (vrf_id_set == 0)
8886 errmsg ("missing vrf id");
8892 mp->vrf_id = ntohl (vrf_id);
8893 mp->is_ipv6 = is_ipv6;
8901 api_create_vlan_subif (vat_main_t * vam)
8903 unformat_input_t *i = vam->input;
8904 vl_api_create_vlan_subif_t *mp;
8906 u8 sw_if_index_set = 0;
8911 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8913 if (unformat (i, "sw_if_index %d", &sw_if_index))
8914 sw_if_index_set = 1;
8916 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8917 sw_if_index_set = 1;
8918 else if (unformat (i, "vlan %d", &vlan_id))
8922 clib_warning ("parse error '%U'", format_unformat_error, i);
8927 if (sw_if_index_set == 0)
8929 errmsg ("missing interface name or sw_if_index");
8933 if (vlan_id_set == 0)
8935 errmsg ("missing vlan_id");
8938 M (CREATE_VLAN_SUBIF, mp);
8940 mp->sw_if_index = ntohl (sw_if_index);
8941 mp->vlan_id = ntohl (vlan_id);
8948 #define foreach_create_subif_bit \
8955 _(outer_vlan_id_any) \
8956 _(inner_vlan_id_any)
8959 api_create_subif (vat_main_t * vam)
8961 unformat_input_t *i = vam->input;
8962 vl_api_create_subif_t *mp;
8964 u8 sw_if_index_set = 0;
8971 u32 exact_match = 0;
8972 u32 default_sub = 0;
8973 u32 outer_vlan_id_any = 0;
8974 u32 inner_vlan_id_any = 0;
8976 u16 outer_vlan_id = 0;
8977 u16 inner_vlan_id = 0;
8980 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8982 if (unformat (i, "sw_if_index %d", &sw_if_index))
8983 sw_if_index_set = 1;
8985 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8986 sw_if_index_set = 1;
8987 else if (unformat (i, "sub_id %d", &sub_id))
8989 else if (unformat (i, "outer_vlan_id %d", &tmp))
8990 outer_vlan_id = tmp;
8991 else if (unformat (i, "inner_vlan_id %d", &tmp))
8992 inner_vlan_id = tmp;
8994 #define _(a) else if (unformat (i, #a)) a = 1 ;
8995 foreach_create_subif_bit
8999 clib_warning ("parse error '%U'", format_unformat_error, i);
9004 if (sw_if_index_set == 0)
9006 errmsg ("missing interface name or sw_if_index");
9010 if (sub_id_set == 0)
9012 errmsg ("missing sub_id");
9015 M (CREATE_SUBIF, mp);
9017 mp->sw_if_index = ntohl (sw_if_index);
9018 mp->sub_id = ntohl (sub_id);
9020 #define _(a) mp->a = a;
9021 foreach_create_subif_bit;
9024 mp->outer_vlan_id = ntohs (outer_vlan_id);
9025 mp->inner_vlan_id = ntohs (inner_vlan_id);
9033 api_oam_add_del (vat_main_t * vam)
9035 unformat_input_t *i = vam->input;
9036 vl_api_oam_add_del_t *mp;
9039 ip4_address_t src, dst;
9044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9046 if (unformat (i, "vrf %d", &vrf_id))
9048 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9050 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9052 else if (unformat (i, "del"))
9056 clib_warning ("parse error '%U'", format_unformat_error, i);
9063 errmsg ("missing src addr");
9069 errmsg ("missing dst addr");
9073 M (OAM_ADD_DEL, mp);
9075 mp->vrf_id = ntohl (vrf_id);
9076 mp->is_add = is_add;
9077 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9078 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9086 api_reset_fib (vat_main_t * vam)
9088 unformat_input_t *i = vam->input;
9089 vl_api_reset_fib_t *mp;
9095 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9097 if (unformat (i, "vrf %d", &vrf_id))
9099 else if (unformat (i, "ipv6"))
9103 clib_warning ("parse error '%U'", format_unformat_error, i);
9108 if (vrf_id_set == 0)
9110 errmsg ("missing vrf id");
9116 mp->vrf_id = ntohl (vrf_id);
9117 mp->is_ipv6 = is_ipv6;
9125 api_dhcp_proxy_config (vat_main_t * vam)
9127 unformat_input_t *i = vam->input;
9128 vl_api_dhcp_proxy_config_t *mp;
9130 u32 server_vrf_id = 0;
9132 u8 v4_address_set = 0;
9133 u8 v6_address_set = 0;
9134 ip4_address_t v4address;
9135 ip6_address_t v6address;
9136 u8 v4_src_address_set = 0;
9137 u8 v6_src_address_set = 0;
9138 ip4_address_t v4srcaddress;
9139 ip6_address_t v6srcaddress;
9142 /* Parse args required to build the message */
9143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9145 if (unformat (i, "del"))
9147 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9149 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9151 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9153 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9155 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9156 v4_src_address_set = 1;
9157 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9158 v6_src_address_set = 1;
9163 if (v4_address_set && v6_address_set)
9165 errmsg ("both v4 and v6 server addresses set");
9168 if (!v4_address_set && !v6_address_set)
9170 errmsg ("no server addresses set");
9174 if (v4_src_address_set && v6_src_address_set)
9176 errmsg ("both v4 and v6 src addresses set");
9179 if (!v4_src_address_set && !v6_src_address_set)
9181 errmsg ("no src addresses set");
9185 if (!(v4_src_address_set && v4_address_set) &&
9186 !(v6_src_address_set && v6_address_set))
9188 errmsg ("no matching server and src addresses set");
9192 /* Construct the API message */
9193 M (DHCP_PROXY_CONFIG, mp);
9195 mp->is_add = is_add;
9196 mp->rx_vrf_id = ntohl (rx_vrf_id);
9197 mp->server_vrf_id = ntohl (server_vrf_id);
9201 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9202 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9206 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9207 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9213 /* Wait for a reply, return good/bad news */
9218 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9219 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9222 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9224 vat_main_t *vam = &vat_main;
9225 u32 i, count = mp->count;
9226 vl_api_dhcp_server_t *s;
9230 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
9231 ntohl (mp->rx_vrf_id),
9232 format_ip6_address, mp->dhcp_src_address,
9233 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9236 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
9237 ntohl (mp->rx_vrf_id),
9238 format_ip4_address, mp->dhcp_src_address,
9239 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9241 for (i = 0; i < count; i++)
9243 s = &mp->servers[i];
9247 " Server Table-ID %d, Server Address %U",
9248 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9251 " Server Table-ID %d, Server Address %U",
9252 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9256 static void vl_api_dhcp_proxy_details_t_handler_json
9257 (vl_api_dhcp_proxy_details_t * mp)
9259 vat_main_t *vam = &vat_main;
9260 vat_json_node_t *node = NULL;
9261 u32 i, count = mp->count;
9263 struct in6_addr ip6;
9264 vl_api_dhcp_server_t *s;
9266 if (VAT_JSON_ARRAY != vam->json_tree.type)
9268 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9269 vat_json_init_array (&vam->json_tree);
9271 node = vat_json_array_add (&vam->json_tree);
9273 vat_json_init_object (node);
9274 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9275 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9276 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9280 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9281 vat_json_object_add_ip6 (node, "src_address", ip6);
9285 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9286 vat_json_object_add_ip4 (node, "src_address", ip4);
9289 for (i = 0; i < count; i++)
9291 s = &mp->servers[i];
9293 vat_json_object_add_uint (node, "server-table-id",
9294 ntohl (s->server_vrf_id));
9298 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9299 vat_json_object_add_ip4 (node, "src_address", ip4);
9303 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9304 vat_json_object_add_ip6 (node, "server_address", ip6);
9310 api_dhcp_proxy_dump (vat_main_t * vam)
9312 unformat_input_t *i = vam->input;
9313 vl_api_control_ping_t *mp_ping;
9314 vl_api_dhcp_proxy_dump_t *mp;
9318 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9320 if (unformat (i, "ipv6"))
9324 clib_warning ("parse error '%U'", format_unformat_error, i);
9329 M (DHCP_PROXY_DUMP, mp);
9331 mp->is_ip6 = is_ipv6;
9334 /* Use a control ping for synchronization */
9335 MPING (CONTROL_PING, mp_ping);
9343 api_dhcp_proxy_set_vss (vat_main_t * vam)
9345 unformat_input_t *i = vam->input;
9346 vl_api_dhcp_proxy_set_vss_t *mp;
9357 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9359 if (unformat (i, "tbl_id %d", &tbl_id))
9361 if (unformat (i, "fib_id %d", &fib_id))
9363 if (unformat (i, "oui %d", &oui))
9365 else if (unformat (i, "ipv6"))
9367 else if (unformat (i, "del"))
9371 clib_warning ("parse error '%U'", format_unformat_error, i);
9376 if (tbl_id_set == 0)
9378 errmsg ("missing tbl id");
9382 if (fib_id_set == 0)
9384 errmsg ("missing fib id");
9389 errmsg ("missing oui");
9393 M (DHCP_PROXY_SET_VSS, mp);
9394 mp->tbl_id = ntohl (tbl_id);
9395 mp->fib_id = ntohl (fib_id);
9396 mp->oui = ntohl (oui);
9397 mp->is_ipv6 = is_ipv6;
9398 mp->is_add = is_add;
9406 api_dhcp_client_config (vat_main_t * vam)
9408 unformat_input_t *i = vam->input;
9409 vl_api_dhcp_client_config_t *mp;
9411 u8 sw_if_index_set = 0;
9414 u8 disable_event = 0;
9417 /* Parse args required to build the message */
9418 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9420 if (unformat (i, "del"))
9423 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9424 sw_if_index_set = 1;
9425 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9426 sw_if_index_set = 1;
9427 else if (unformat (i, "hostname %s", &hostname))
9429 else if (unformat (i, "disable_event"))
9435 if (sw_if_index_set == 0)
9437 errmsg ("missing interface name or sw_if_index");
9441 if (vec_len (hostname) > 63)
9443 errmsg ("hostname too long");
9445 vec_add1 (hostname, 0);
9447 /* Construct the API message */
9448 M (DHCP_CLIENT_CONFIG, mp);
9450 mp->sw_if_index = htonl (sw_if_index);
9451 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
9452 vec_free (hostname);
9453 mp->is_add = is_add;
9454 mp->want_dhcp_event = disable_event ? 0 : 1;
9455 mp->pid = htonl (getpid ());
9460 /* Wait for a reply, return good/bad news */
9466 api_set_ip_flow_hash (vat_main_t * vam)
9468 unformat_input_t *i = vam->input;
9469 vl_api_set_ip_flow_hash_t *mp;
9481 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9483 if (unformat (i, "vrf %d", &vrf_id))
9485 else if (unformat (i, "ipv6"))
9487 else if (unformat (i, "src"))
9489 else if (unformat (i, "dst"))
9491 else if (unformat (i, "sport"))
9493 else if (unformat (i, "dport"))
9495 else if (unformat (i, "proto"))
9497 else if (unformat (i, "reverse"))
9502 clib_warning ("parse error '%U'", format_unformat_error, i);
9507 if (vrf_id_set == 0)
9509 errmsg ("missing vrf id");
9513 M (SET_IP_FLOW_HASH, mp);
9519 mp->reverse = reverse;
9520 mp->vrf_id = ntohl (vrf_id);
9521 mp->is_ipv6 = is_ipv6;
9529 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9531 unformat_input_t *i = vam->input;
9532 vl_api_sw_interface_ip6_enable_disable_t *mp;
9534 u8 sw_if_index_set = 0;
9538 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9540 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9541 sw_if_index_set = 1;
9542 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9543 sw_if_index_set = 1;
9544 else if (unformat (i, "enable"))
9546 else if (unformat (i, "disable"))
9550 clib_warning ("parse error '%U'", format_unformat_error, i);
9555 if (sw_if_index_set == 0)
9557 errmsg ("missing interface name or sw_if_index");
9561 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9563 mp->sw_if_index = ntohl (sw_if_index);
9564 mp->enable = enable;
9572 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
9574 unformat_input_t *i = vam->input;
9575 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
9577 u8 sw_if_index_set = 0;
9578 u8 v6_address_set = 0;
9579 ip6_address_t v6address;
9582 /* Parse args required to build the message */
9583 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9585 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9586 sw_if_index_set = 1;
9587 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9588 sw_if_index_set = 1;
9589 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9595 if (sw_if_index_set == 0)
9597 errmsg ("missing interface name or sw_if_index");
9600 if (!v6_address_set)
9602 errmsg ("no address set");
9606 /* Construct the API message */
9607 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
9609 mp->sw_if_index = ntohl (sw_if_index);
9610 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9615 /* Wait for a reply, return good/bad news */
9621 api_ip6nd_proxy_add_del (vat_main_t * vam)
9623 unformat_input_t *i = vam->input;
9624 vl_api_ip6nd_proxy_add_del_t *mp;
9625 u32 sw_if_index = ~0;
9626 u8 v6_address_set = 0;
9627 ip6_address_t v6address;
9631 /* Parse args required to build the message */
9632 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9634 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9636 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9638 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9640 if (unformat (i, "del"))
9644 clib_warning ("parse error '%U'", format_unformat_error, i);
9649 if (sw_if_index == ~0)
9651 errmsg ("missing interface name or sw_if_index");
9654 if (!v6_address_set)
9656 errmsg ("no address set");
9660 /* Construct the API message */
9661 M (IP6ND_PROXY_ADD_DEL, mp);
9663 mp->is_del = is_del;
9664 mp->sw_if_index = ntohl (sw_if_index);
9665 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9670 /* Wait for a reply, return good/bad news */
9676 api_ip6nd_proxy_dump (vat_main_t * vam)
9678 vl_api_ip6nd_proxy_dump_t *mp;
9679 vl_api_control_ping_t *mp_ping;
9682 M (IP6ND_PROXY_DUMP, mp);
9686 /* Use a control ping for synchronization */
9687 MPING (CONTROL_PING, mp_ping);
9694 static void vl_api_ip6nd_proxy_details_t_handler
9695 (vl_api_ip6nd_proxy_details_t * mp)
9697 vat_main_t *vam = &vat_main;
9699 print (vam->ofp, "host %U sw_if_index %d",
9700 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
9703 static void vl_api_ip6nd_proxy_details_t_handler_json
9704 (vl_api_ip6nd_proxy_details_t * mp)
9706 vat_main_t *vam = &vat_main;
9707 struct in6_addr ip6;
9708 vat_json_node_t *node = NULL;
9710 if (VAT_JSON_ARRAY != vam->json_tree.type)
9712 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9713 vat_json_init_array (&vam->json_tree);
9715 node = vat_json_array_add (&vam->json_tree);
9717 vat_json_init_object (node);
9718 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9720 clib_memcpy (&ip6, mp->address, sizeof (ip6));
9721 vat_json_object_add_ip6 (node, "host", ip6);
9725 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9727 unformat_input_t *i = vam->input;
9728 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9730 u8 sw_if_index_set = 0;
9731 u32 address_length = 0;
9732 u8 v6_address_set = 0;
9733 ip6_address_t v6address;
9735 u8 no_advertise = 0;
9737 u8 no_autoconfig = 0;
9740 u32 val_lifetime = 0;
9741 u32 pref_lifetime = 0;
9744 /* Parse args required to build the message */
9745 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9747 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9748 sw_if_index_set = 1;
9749 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9750 sw_if_index_set = 1;
9751 else if (unformat (i, "%U/%d",
9752 unformat_ip6_address, &v6address, &address_length))
9754 else if (unformat (i, "val_life %d", &val_lifetime))
9756 else if (unformat (i, "pref_life %d", &pref_lifetime))
9758 else if (unformat (i, "def"))
9760 else if (unformat (i, "noadv"))
9762 else if (unformat (i, "offl"))
9764 else if (unformat (i, "noauto"))
9766 else if (unformat (i, "nolink"))
9768 else if (unformat (i, "isno"))
9772 clib_warning ("parse error '%U'", format_unformat_error, i);
9777 if (sw_if_index_set == 0)
9779 errmsg ("missing interface name or sw_if_index");
9782 if (!v6_address_set)
9784 errmsg ("no address set");
9788 /* Construct the API message */
9789 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9791 mp->sw_if_index = ntohl (sw_if_index);
9792 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9793 mp->address_length = address_length;
9794 mp->use_default = use_default;
9795 mp->no_advertise = no_advertise;
9796 mp->off_link = off_link;
9797 mp->no_autoconfig = no_autoconfig;
9798 mp->no_onlink = no_onlink;
9800 mp->val_lifetime = ntohl (val_lifetime);
9801 mp->pref_lifetime = ntohl (pref_lifetime);
9806 /* Wait for a reply, return good/bad news */
9812 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9814 unformat_input_t *i = vam->input;
9815 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9817 u8 sw_if_index_set = 0;
9822 u8 send_unicast = 0;
9825 u8 default_router = 0;
9826 u32 max_interval = 0;
9827 u32 min_interval = 0;
9829 u32 initial_count = 0;
9830 u32 initial_interval = 0;
9834 /* Parse args required to build the message */
9835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9837 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9838 sw_if_index_set = 1;
9839 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9840 sw_if_index_set = 1;
9841 else if (unformat (i, "maxint %d", &max_interval))
9843 else if (unformat (i, "minint %d", &min_interval))
9845 else if (unformat (i, "life %d", &lifetime))
9847 else if (unformat (i, "count %d", &initial_count))
9849 else if (unformat (i, "interval %d", &initial_interval))
9851 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9853 else if (unformat (i, "managed"))
9855 else if (unformat (i, "other"))
9857 else if (unformat (i, "ll"))
9859 else if (unformat (i, "send"))
9861 else if (unformat (i, "cease"))
9863 else if (unformat (i, "isno"))
9865 else if (unformat (i, "def"))
9869 clib_warning ("parse error '%U'", format_unformat_error, i);
9874 if (sw_if_index_set == 0)
9876 errmsg ("missing interface name or sw_if_index");
9880 /* Construct the API message */
9881 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9883 mp->sw_if_index = ntohl (sw_if_index);
9884 mp->max_interval = ntohl (max_interval);
9885 mp->min_interval = ntohl (min_interval);
9886 mp->lifetime = ntohl (lifetime);
9887 mp->initial_count = ntohl (initial_count);
9888 mp->initial_interval = ntohl (initial_interval);
9889 mp->suppress = suppress;
9890 mp->managed = managed;
9892 mp->ll_option = ll_option;
9893 mp->send_unicast = send_unicast;
9896 mp->default_router = default_router;
9901 /* Wait for a reply, return good/bad news */
9907 api_set_arp_neighbor_limit (vat_main_t * vam)
9909 unformat_input_t *i = vam->input;
9910 vl_api_set_arp_neighbor_limit_t *mp;
9916 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9918 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9920 else if (unformat (i, "ipv6"))
9924 clib_warning ("parse error '%U'", format_unformat_error, i);
9931 errmsg ("missing limit value");
9935 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9937 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9938 mp->is_ipv6 = is_ipv6;
9946 api_l2_patch_add_del (vat_main_t * vam)
9948 unformat_input_t *i = vam->input;
9949 vl_api_l2_patch_add_del_t *mp;
9951 u8 rx_sw_if_index_set = 0;
9953 u8 tx_sw_if_index_set = 0;
9957 /* Parse args required to build the message */
9958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9960 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9961 rx_sw_if_index_set = 1;
9962 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9963 tx_sw_if_index_set = 1;
9964 else if (unformat (i, "rx"))
9966 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9968 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9970 rx_sw_if_index_set = 1;
9975 else if (unformat (i, "tx"))
9977 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9979 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9981 tx_sw_if_index_set = 1;
9986 else if (unformat (i, "del"))
9992 if (rx_sw_if_index_set == 0)
9994 errmsg ("missing rx interface name or rx_sw_if_index");
9998 if (tx_sw_if_index_set == 0)
10000 errmsg ("missing tx interface name or tx_sw_if_index");
10004 M (L2_PATCH_ADD_DEL, mp);
10006 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10007 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10008 mp->is_add = is_add;
10016 u8 localsid_addr[16];
10025 api_sr_localsid_add_del (vat_main_t * vam)
10027 unformat_input_t *i = vam->input;
10028 vl_api_sr_localsid_add_del_t *mp;
10031 ip6_address_t localsid;
10035 u32 fib_table = ~(u32) 0;
10036 ip6_address_t next_hop;
10038 bool nexthop_set = 0;
10042 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10044 if (unformat (i, "del"))
10046 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10047 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
10049 else if (unformat (i, "behavior %u", &behavior));
10050 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10051 else if (unformat (i, "fib-table %u", &fib_table));
10052 else if (unformat (i, "end.psp %u", &behavior));
10057 M (SR_LOCALSID_ADD_DEL, mp);
10059 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
10061 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
10062 mp->behavior = behavior;
10063 mp->sw_if_index = ntohl (sw_if_index);
10064 mp->fib_table = ntohl (fib_table);
10065 mp->end_psp = end_psp;
10066 mp->is_del = is_del;
10074 api_ioam_enable (vat_main_t * vam)
10076 unformat_input_t *input = vam->input;
10077 vl_api_ioam_enable_t *mp;
10079 int has_trace_option = 0;
10080 int has_pot_option = 0;
10081 int has_seqno_option = 0;
10082 int has_analyse_option = 0;
10085 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10087 if (unformat (input, "trace"))
10088 has_trace_option = 1;
10089 else if (unformat (input, "pot"))
10090 has_pot_option = 1;
10091 else if (unformat (input, "seqno"))
10092 has_seqno_option = 1;
10093 else if (unformat (input, "analyse"))
10094 has_analyse_option = 1;
10098 M (IOAM_ENABLE, mp);
10099 mp->id = htons (id);
10100 mp->seqno = has_seqno_option;
10101 mp->analyse = has_analyse_option;
10102 mp->pot_enable = has_pot_option;
10103 mp->trace_enable = has_trace_option;
10112 api_ioam_disable (vat_main_t * vam)
10114 vl_api_ioam_disable_t *mp;
10117 M (IOAM_DISABLE, mp);
10123 #define foreach_tcp_proto_field \
10127 #define foreach_udp_proto_field \
10131 #define foreach_ip4_proto_field \
10143 u16 src_port, dst_port;
10146 #if VPP_API_TEST_BUILTIN == 0
10148 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10150 u8 **maskp = va_arg (*args, u8 **);
10152 u8 found_something = 0;
10155 #define _(a) u8 a=0;
10156 foreach_tcp_proto_field;
10159 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10162 #define _(a) else if (unformat (input, #a)) a=1;
10163 foreach_tcp_proto_field
10169 #define _(a) found_something += a;
10170 foreach_tcp_proto_field;
10173 if (found_something == 0)
10176 vec_validate (mask, sizeof (*tcp) - 1);
10178 tcp = (tcp_header_t *) mask;
10180 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
10181 foreach_tcp_proto_field;
10189 unformat_udp_mask (unformat_input_t * input, va_list * args)
10191 u8 **maskp = va_arg (*args, u8 **);
10193 u8 found_something = 0;
10196 #define _(a) u8 a=0;
10197 foreach_udp_proto_field;
10200 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10203 #define _(a) else if (unformat (input, #a)) a=1;
10204 foreach_udp_proto_field
10210 #define _(a) found_something += a;
10211 foreach_udp_proto_field;
10214 if (found_something == 0)
10217 vec_validate (mask, sizeof (*udp) - 1);
10219 udp = (udp_header_t *) mask;
10221 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
10222 foreach_udp_proto_field;
10230 unformat_l4_mask (unformat_input_t * input, va_list * args)
10232 u8 **maskp = va_arg (*args, u8 **);
10233 u16 src_port = 0, dst_port = 0;
10234 tcpudp_header_t *tcpudp;
10236 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10238 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10240 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10242 else if (unformat (input, "src_port"))
10244 else if (unformat (input, "dst_port"))
10250 if (!src_port && !dst_port)
10254 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10256 tcpudp = (tcpudp_header_t *) mask;
10257 tcpudp->src_port = src_port;
10258 tcpudp->dst_port = dst_port;
10266 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10268 u8 **maskp = va_arg (*args, u8 **);
10270 u8 found_something = 0;
10273 #define _(a) u8 a=0;
10274 foreach_ip4_proto_field;
10280 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10282 if (unformat (input, "version"))
10284 else if (unformat (input, "hdr_length"))
10286 else if (unformat (input, "src"))
10288 else if (unformat (input, "dst"))
10290 else if (unformat (input, "proto"))
10293 #define _(a) else if (unformat (input, #a)) a=1;
10294 foreach_ip4_proto_field
10300 #define _(a) found_something += a;
10301 foreach_ip4_proto_field;
10304 if (found_something == 0)
10307 vec_validate (mask, sizeof (*ip) - 1);
10309 ip = (ip4_header_t *) mask;
10311 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10312 foreach_ip4_proto_field;
10315 ip->ip_version_and_header_length = 0;
10318 ip->ip_version_and_header_length |= 0xF0;
10321 ip->ip_version_and_header_length |= 0x0F;
10327 #define foreach_ip6_proto_field \
10330 _(payload_length) \
10335 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10337 u8 **maskp = va_arg (*args, u8 **);
10339 u8 found_something = 0;
10341 u32 ip_version_traffic_class_and_flow_label;
10343 #define _(a) u8 a=0;
10344 foreach_ip6_proto_field;
10347 u8 traffic_class = 0;
10350 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10352 if (unformat (input, "version"))
10354 else if (unformat (input, "traffic-class"))
10356 else if (unformat (input, "flow-label"))
10358 else if (unformat (input, "src"))
10360 else if (unformat (input, "dst"))
10362 else if (unformat (input, "proto"))
10365 #define _(a) else if (unformat (input, #a)) a=1;
10366 foreach_ip6_proto_field
10372 #define _(a) found_something += a;
10373 foreach_ip6_proto_field;
10376 if (found_something == 0)
10379 vec_validate (mask, sizeof (*ip) - 1);
10381 ip = (ip6_header_t *) mask;
10383 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10384 foreach_ip6_proto_field;
10387 ip_version_traffic_class_and_flow_label = 0;
10390 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10393 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10396 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10398 ip->ip_version_traffic_class_and_flow_label =
10399 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10406 unformat_l3_mask (unformat_input_t * input, va_list * args)
10408 u8 **maskp = va_arg (*args, u8 **);
10410 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10412 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10414 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10423 unformat_l2_mask (unformat_input_t * input, va_list * args)
10425 u8 **maskp = va_arg (*args, u8 **);
10432 u8 ignore_tag1 = 0;
10433 u8 ignore_tag2 = 0;
10440 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10442 if (unformat (input, "src"))
10444 else if (unformat (input, "dst"))
10446 else if (unformat (input, "proto"))
10448 else if (unformat (input, "tag1"))
10450 else if (unformat (input, "tag2"))
10452 else if (unformat (input, "ignore-tag1"))
10454 else if (unformat (input, "ignore-tag2"))
10456 else if (unformat (input, "cos1"))
10458 else if (unformat (input, "cos2"))
10460 else if (unformat (input, "dot1q"))
10462 else if (unformat (input, "dot1ad"))
10467 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10468 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10471 if (tag1 || ignore_tag1 || cos1 || dot1q)
10473 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10476 vec_validate (mask, len - 1);
10479 memset (mask, 0xff, 6);
10482 memset (mask + 6, 0xff, 6);
10484 if (tag2 || dot1ad)
10486 /* inner vlan tag */
10495 mask[21] = mask[20] = 0xff;
10516 mask[16] = mask[17] = 0xff;
10526 mask[12] = mask[13] = 0xff;
10533 unformat_classify_mask (unformat_input_t * input, va_list * args)
10535 u8 **maskp = va_arg (*args, u8 **);
10536 u32 *skipp = va_arg (*args, u32 *);
10537 u32 *matchp = va_arg (*args, u32 *);
10545 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10547 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10549 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10551 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10553 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10567 if (mask || l2 || l3 || l4)
10569 if (l2 || l3 || l4)
10571 /* "With a free Ethernet header in every package" */
10573 vec_validate (l2, 13);
10577 vec_append (mask, l3);
10582 vec_append (mask, l4);
10587 /* Scan forward looking for the first significant mask octet */
10588 for (i = 0; i < vec_len (mask); i++)
10592 /* compute (skip, match) params */
10593 *skipp = i / sizeof (u32x4);
10594 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10596 /* Pad mask to an even multiple of the vector size */
10597 while (vec_len (mask) % sizeof (u32x4))
10598 vec_add1 (mask, 0);
10600 match = vec_len (mask) / sizeof (u32x4);
10602 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10604 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10605 if (*tmp || *(tmp + 1))
10610 clib_warning ("BUG: match 0");
10612 _vec_len (mask) = match * sizeof (u32x4);
10622 #endif /* VPP_API_TEST_BUILTIN */
10624 #define foreach_l2_next \
10626 _(ethernet, ETHERNET_INPUT) \
10627 _(ip4, IP4_INPUT) \
10631 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10633 u32 *miss_next_indexp = va_arg (*args, u32 *);
10634 u32 next_index = 0;
10638 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10642 if (unformat (input, "%d", &tmp))
10651 *miss_next_indexp = next_index;
10655 #define foreach_ip_next \
10658 _(rewrite, REWRITE)
10661 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10663 u32 *miss_next_indexp = va_arg (*args, u32 *);
10664 u32 next_index = 0;
10668 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10672 if (unformat (input, "%d", &tmp))
10681 *miss_next_indexp = next_index;
10685 #define foreach_acl_next \
10689 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10691 u32 *miss_next_indexp = va_arg (*args, u32 *);
10692 u32 next_index = 0;
10696 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10700 if (unformat (input, "permit"))
10705 else if (unformat (input, "%d", &tmp))
10714 *miss_next_indexp = next_index;
10719 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10721 u32 *r = va_arg (*args, u32 *);
10723 if (unformat (input, "conform-color"))
10724 *r = POLICE_CONFORM;
10725 else if (unformat (input, "exceed-color"))
10726 *r = POLICE_EXCEED;
10734 api_classify_add_del_table (vat_main_t * vam)
10736 unformat_input_t *i = vam->input;
10737 vl_api_classify_add_del_table_t *mp;
10744 u32 table_index = ~0;
10745 u32 next_table_index = ~0;
10746 u32 miss_next_index = ~0;
10747 u32 memory_size = 32 << 20;
10749 u32 current_data_flag = 0;
10750 int current_data_offset = 0;
10753 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10755 if (unformat (i, "del"))
10757 else if (unformat (i, "del-chain"))
10762 else if (unformat (i, "buckets %d", &nbuckets))
10764 else if (unformat (i, "memory_size %d", &memory_size))
10766 else if (unformat (i, "skip %d", &skip))
10768 else if (unformat (i, "match %d", &match))
10770 else if (unformat (i, "table %d", &table_index))
10772 else if (unformat (i, "mask %U", unformat_classify_mask,
10773 &mask, &skip, &match))
10775 else if (unformat (i, "next-table %d", &next_table_index))
10777 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10780 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10783 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10786 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10788 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10794 if (is_add && mask == 0)
10796 errmsg ("Mask required");
10800 if (is_add && skip == ~0)
10802 errmsg ("skip count required");
10806 if (is_add && match == ~0)
10808 errmsg ("match count required");
10812 if (!is_add && table_index == ~0)
10814 errmsg ("table index required for delete");
10818 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10820 mp->is_add = is_add;
10821 mp->del_chain = del_chain;
10822 mp->table_index = ntohl (table_index);
10823 mp->nbuckets = ntohl (nbuckets);
10824 mp->memory_size = ntohl (memory_size);
10825 mp->skip_n_vectors = ntohl (skip);
10826 mp->match_n_vectors = ntohl (match);
10827 mp->next_table_index = ntohl (next_table_index);
10828 mp->miss_next_index = ntohl (miss_next_index);
10829 mp->current_data_flag = ntohl (current_data_flag);
10830 mp->current_data_offset = ntohl (current_data_offset);
10831 clib_memcpy (mp->mask, mask, vec_len (mask));
10840 #if VPP_API_TEST_BUILTIN == 0
10842 unformat_l4_match (unformat_input_t * input, va_list * args)
10844 u8 **matchp = va_arg (*args, u8 **);
10846 u8 *proto_header = 0;
10852 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10854 if (unformat (input, "src_port %d", &src_port))
10856 else if (unformat (input, "dst_port %d", &dst_port))
10862 h.src_port = clib_host_to_net_u16 (src_port);
10863 h.dst_port = clib_host_to_net_u16 (dst_port);
10864 vec_validate (proto_header, sizeof (h) - 1);
10865 memcpy (proto_header, &h, sizeof (h));
10867 *matchp = proto_header;
10873 unformat_ip4_match (unformat_input_t * input, va_list * args)
10875 u8 **matchp = va_arg (*args, u8 **);
10880 int hdr_length = 0;
10881 u32 hdr_length_val;
10882 int src = 0, dst = 0;
10883 ip4_address_t src_val, dst_val;
10890 int fragment_id = 0;
10891 u32 fragment_id_val;
10897 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10899 if (unformat (input, "version %d", &version_val))
10901 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10903 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10905 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10907 else if (unformat (input, "proto %d", &proto_val))
10909 else if (unformat (input, "tos %d", &tos_val))
10911 else if (unformat (input, "length %d", &length_val))
10913 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10915 else if (unformat (input, "ttl %d", &ttl_val))
10917 else if (unformat (input, "checksum %d", &checksum_val))
10923 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10924 + ttl + checksum == 0)
10928 * Aligned because we use the real comparison functions
10930 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10932 ip = (ip4_header_t *) match;
10934 /* These are realistically matched in practice */
10936 ip->src_address.as_u32 = src_val.as_u32;
10939 ip->dst_address.as_u32 = dst_val.as_u32;
10942 ip->protocol = proto_val;
10945 /* These are not, but they're included for completeness */
10947 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10950 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10956 ip->length = clib_host_to_net_u16 (length_val);
10962 ip->checksum = clib_host_to_net_u16 (checksum_val);
10969 unformat_ip6_match (unformat_input_t * input, va_list * args)
10971 u8 **matchp = va_arg (*args, u8 **);
10976 u8 traffic_class = 0;
10977 u32 traffic_class_val = 0;
10980 int src = 0, dst = 0;
10981 ip6_address_t src_val, dst_val;
10984 int payload_length = 0;
10985 u32 payload_length_val;
10988 u32 ip_version_traffic_class_and_flow_label;
10990 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10992 if (unformat (input, "version %d", &version_val))
10994 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10996 else if (unformat (input, "flow_label %d", &flow_label_val))
10998 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11000 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11002 else if (unformat (input, "proto %d", &proto_val))
11004 else if (unformat (input, "payload_length %d", &payload_length_val))
11005 payload_length = 1;
11006 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11012 if (version + traffic_class + flow_label + src + dst + proto +
11013 payload_length + hop_limit == 0)
11017 * Aligned because we use the real comparison functions
11019 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11021 ip = (ip6_header_t *) match;
11024 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11027 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11030 ip->protocol = proto_val;
11032 ip_version_traffic_class_and_flow_label = 0;
11035 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11038 ip_version_traffic_class_and_flow_label |=
11039 (traffic_class_val & 0xFF) << 20;
11042 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11044 ip->ip_version_traffic_class_and_flow_label =
11045 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11047 if (payload_length)
11048 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11051 ip->hop_limit = hop_limit_val;
11058 unformat_l3_match (unformat_input_t * input, va_list * args)
11060 u8 **matchp = va_arg (*args, u8 **);
11062 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11064 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11066 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11075 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11077 u8 *tagp = va_arg (*args, u8 *);
11080 if (unformat (input, "%d", &tag))
11082 tagp[0] = (tag >> 8) & 0x0F;
11083 tagp[1] = tag & 0xFF;
11091 unformat_l2_match (unformat_input_t * input, va_list * args)
11093 u8 **matchp = va_arg (*args, u8 **);
11106 u8 ignore_tag1 = 0;
11107 u8 ignore_tag2 = 0;
11113 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11115 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11118 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11120 else if (unformat (input, "proto %U",
11121 unformat_ethernet_type_host_byte_order, &proto_val))
11123 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11125 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11127 else if (unformat (input, "ignore-tag1"))
11129 else if (unformat (input, "ignore-tag2"))
11131 else if (unformat (input, "cos1 %d", &cos1_val))
11133 else if (unformat (input, "cos2 %d", &cos2_val))
11138 if ((src + dst + proto + tag1 + tag2 +
11139 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11142 if (tag1 || ignore_tag1 || cos1)
11144 if (tag2 || ignore_tag2 || cos2)
11147 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11150 clib_memcpy (match, dst_val, 6);
11153 clib_memcpy (match + 6, src_val, 6);
11157 /* inner vlan tag */
11158 match[19] = tag2_val[1];
11159 match[18] = tag2_val[0];
11161 match[18] |= (cos2_val & 0x7) << 5;
11164 match[21] = proto_val & 0xff;
11165 match[20] = proto_val >> 8;
11169 match[15] = tag1_val[1];
11170 match[14] = tag1_val[0];
11173 match[14] |= (cos1_val & 0x7) << 5;
11179 match[15] = tag1_val[1];
11180 match[14] = tag1_val[0];
11183 match[17] = proto_val & 0xff;
11184 match[16] = proto_val >> 8;
11187 match[14] |= (cos1_val & 0x7) << 5;
11193 match[18] |= (cos2_val & 0x7) << 5;
11195 match[14] |= (cos1_val & 0x7) << 5;
11198 match[13] = proto_val & 0xff;
11199 match[12] = proto_val >> 8;
11208 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11210 u8 **matchp = va_arg (*args, u8 **);
11211 u32 skip_n_vectors = va_arg (*args, u32);
11212 u32 match_n_vectors = va_arg (*args, u32);
11219 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11221 if (unformat (input, "hex %U", unformat_hex_string, &match))
11223 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11225 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11227 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11241 if (match || l2 || l3 || l4)
11243 if (l2 || l3 || l4)
11245 /* "Win a free Ethernet header in every packet" */
11247 vec_validate_aligned (l2, 13, sizeof (u32x4));
11251 vec_append_aligned (match, l3, sizeof (u32x4));
11256 vec_append_aligned (match, l4, sizeof (u32x4));
11261 /* Make sure the vector is big enough even if key is all 0's */
11262 vec_validate_aligned
11263 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11266 /* Set size, include skipped vectors */
11267 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11278 api_classify_add_del_session (vat_main_t * vam)
11280 unformat_input_t *i = vam->input;
11281 vl_api_classify_add_del_session_t *mp;
11283 u32 table_index = ~0;
11284 u32 hit_next_index = ~0;
11285 u32 opaque_index = ~0;
11288 u32 skip_n_vectors = 0;
11289 u32 match_n_vectors = 0;
11295 * Warning: you have to supply skip_n and match_n
11296 * because the API client cant simply look at the classify
11300 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11302 if (unformat (i, "del"))
11304 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11307 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11310 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11313 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11315 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11317 else if (unformat (i, "opaque-index %d", &opaque_index))
11319 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11321 else if (unformat (i, "match_n %d", &match_n_vectors))
11323 else if (unformat (i, "match %U", api_unformat_classify_match,
11324 &match, skip_n_vectors, match_n_vectors))
11326 else if (unformat (i, "advance %d", &advance))
11328 else if (unformat (i, "table-index %d", &table_index))
11330 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11332 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11334 else if (unformat (i, "action %d", &action))
11336 else if (unformat (i, "metadata %d", &metadata))
11342 if (table_index == ~0)
11344 errmsg ("Table index required");
11348 if (is_add && match == 0)
11350 errmsg ("Match value required");
11354 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11356 mp->is_add = is_add;
11357 mp->table_index = ntohl (table_index);
11358 mp->hit_next_index = ntohl (hit_next_index);
11359 mp->opaque_index = ntohl (opaque_index);
11360 mp->advance = ntohl (advance);
11361 mp->action = action;
11362 mp->metadata = ntohl (metadata);
11363 clib_memcpy (mp->match, match, vec_len (match));
11372 api_classify_set_interface_ip_table (vat_main_t * vam)
11374 unformat_input_t *i = vam->input;
11375 vl_api_classify_set_interface_ip_table_t *mp;
11377 int sw_if_index_set;
11378 u32 table_index = ~0;
11382 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11384 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11385 sw_if_index_set = 1;
11386 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11387 sw_if_index_set = 1;
11388 else if (unformat (i, "table %d", &table_index))
11392 clib_warning ("parse error '%U'", format_unformat_error, i);
11397 if (sw_if_index_set == 0)
11399 errmsg ("missing interface name or sw_if_index");
11404 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11406 mp->sw_if_index = ntohl (sw_if_index);
11407 mp->table_index = ntohl (table_index);
11408 mp->is_ipv6 = is_ipv6;
11416 api_classify_set_interface_l2_tables (vat_main_t * vam)
11418 unformat_input_t *i = vam->input;
11419 vl_api_classify_set_interface_l2_tables_t *mp;
11421 int sw_if_index_set;
11422 u32 ip4_table_index = ~0;
11423 u32 ip6_table_index = ~0;
11424 u32 other_table_index = ~0;
11428 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11430 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11431 sw_if_index_set = 1;
11432 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11433 sw_if_index_set = 1;
11434 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11436 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11438 else if (unformat (i, "other-table %d", &other_table_index))
11440 else if (unformat (i, "is-input %d", &is_input))
11444 clib_warning ("parse error '%U'", format_unformat_error, i);
11449 if (sw_if_index_set == 0)
11451 errmsg ("missing interface name or sw_if_index");
11456 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11458 mp->sw_if_index = ntohl (sw_if_index);
11459 mp->ip4_table_index = ntohl (ip4_table_index);
11460 mp->ip6_table_index = ntohl (ip6_table_index);
11461 mp->other_table_index = ntohl (other_table_index);
11462 mp->is_input = (u8) is_input;
11470 api_set_ipfix_exporter (vat_main_t * vam)
11472 unformat_input_t *i = vam->input;
11473 vl_api_set_ipfix_exporter_t *mp;
11474 ip4_address_t collector_address;
11475 u8 collector_address_set = 0;
11476 u32 collector_port = ~0;
11477 ip4_address_t src_address;
11478 u8 src_address_set = 0;
11481 u32 template_interval = ~0;
11482 u8 udp_checksum = 0;
11485 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11487 if (unformat (i, "collector_address %U", unformat_ip4_address,
11488 &collector_address))
11489 collector_address_set = 1;
11490 else if (unformat (i, "collector_port %d", &collector_port))
11492 else if (unformat (i, "src_address %U", unformat_ip4_address,
11494 src_address_set = 1;
11495 else if (unformat (i, "vrf_id %d", &vrf_id))
11497 else if (unformat (i, "path_mtu %d", &path_mtu))
11499 else if (unformat (i, "template_interval %d", &template_interval))
11501 else if (unformat (i, "udp_checksum"))
11507 if (collector_address_set == 0)
11509 errmsg ("collector_address required");
11513 if (src_address_set == 0)
11515 errmsg ("src_address required");
11519 M (SET_IPFIX_EXPORTER, mp);
11521 memcpy (mp->collector_address, collector_address.data,
11522 sizeof (collector_address.data));
11523 mp->collector_port = htons ((u16) collector_port);
11524 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11525 mp->vrf_id = htonl (vrf_id);
11526 mp->path_mtu = htonl (path_mtu);
11527 mp->template_interval = htonl (template_interval);
11528 mp->udp_checksum = udp_checksum;
11536 api_set_ipfix_classify_stream (vat_main_t * vam)
11538 unformat_input_t *i = vam->input;
11539 vl_api_set_ipfix_classify_stream_t *mp;
11541 u32 src_port = UDP_DST_PORT_ipfix;
11544 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11546 if (unformat (i, "domain %d", &domain_id))
11548 else if (unformat (i, "src_port %d", &src_port))
11552 errmsg ("unknown input `%U'", format_unformat_error, i);
11557 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11559 mp->domain_id = htonl (domain_id);
11560 mp->src_port = htons ((u16) src_port);
11568 api_ipfix_classify_table_add_del (vat_main_t * vam)
11570 unformat_input_t *i = vam->input;
11571 vl_api_ipfix_classify_table_add_del_t *mp;
11573 u32 classify_table_index = ~0;
11575 u8 transport_protocol = 255;
11578 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11580 if (unformat (i, "add"))
11582 else if (unformat (i, "del"))
11584 else if (unformat (i, "table %d", &classify_table_index))
11586 else if (unformat (i, "ip4"))
11588 else if (unformat (i, "ip6"))
11590 else if (unformat (i, "tcp"))
11591 transport_protocol = 6;
11592 else if (unformat (i, "udp"))
11593 transport_protocol = 17;
11596 errmsg ("unknown input `%U'", format_unformat_error, i);
11603 errmsg ("expecting: add|del");
11606 if (classify_table_index == ~0)
11608 errmsg ("classifier table not specified");
11611 if (ip_version == 0)
11613 errmsg ("IP version not specified");
11617 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11619 mp->is_add = is_add;
11620 mp->table_id = htonl (classify_table_index);
11621 mp->ip_version = ip_version;
11622 mp->transport_protocol = transport_protocol;
11630 api_get_node_index (vat_main_t * vam)
11632 unformat_input_t *i = vam->input;
11633 vl_api_get_node_index_t *mp;
11637 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11639 if (unformat (i, "node %s", &name))
11646 errmsg ("node name required");
11649 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11651 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11655 M (GET_NODE_INDEX, mp);
11656 clib_memcpy (mp->node_name, name, vec_len (name));
11665 api_get_next_index (vat_main_t * vam)
11667 unformat_input_t *i = vam->input;
11668 vl_api_get_next_index_t *mp;
11669 u8 *node_name = 0, *next_node_name = 0;
11672 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11674 if (unformat (i, "node-name %s", &node_name))
11676 else if (unformat (i, "next-node-name %s", &next_node_name))
11680 if (node_name == 0)
11682 errmsg ("node name required");
11685 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11687 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11691 if (next_node_name == 0)
11693 errmsg ("next node name required");
11696 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11698 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11702 M (GET_NEXT_INDEX, mp);
11703 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11704 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11705 vec_free (node_name);
11706 vec_free (next_node_name);
11714 api_add_node_next (vat_main_t * vam)
11716 unformat_input_t *i = vam->input;
11717 vl_api_add_node_next_t *mp;
11722 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11724 if (unformat (i, "node %s", &name))
11726 else if (unformat (i, "next %s", &next))
11733 errmsg ("node name required");
11736 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11738 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11743 errmsg ("next node required");
11746 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11748 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11752 M (ADD_NODE_NEXT, mp);
11753 clib_memcpy (mp->node_name, name, vec_len (name));
11754 clib_memcpy (mp->next_name, next, vec_len (next));
11764 api_l2tpv3_create_tunnel (vat_main_t * vam)
11766 unformat_input_t *i = vam->input;
11767 ip6_address_t client_address, our_address;
11768 int client_address_set = 0;
11769 int our_address_set = 0;
11770 u32 local_session_id = 0;
11771 u32 remote_session_id = 0;
11772 u64 local_cookie = 0;
11773 u64 remote_cookie = 0;
11774 u8 l2_sublayer_present = 0;
11775 vl_api_l2tpv3_create_tunnel_t *mp;
11778 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11780 if (unformat (i, "client_address %U", unformat_ip6_address,
11782 client_address_set = 1;
11783 else if (unformat (i, "our_address %U", unformat_ip6_address,
11785 our_address_set = 1;
11786 else if (unformat (i, "local_session_id %d", &local_session_id))
11788 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11790 else if (unformat (i, "local_cookie %lld", &local_cookie))
11792 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11794 else if (unformat (i, "l2-sublayer-present"))
11795 l2_sublayer_present = 1;
11800 if (client_address_set == 0)
11802 errmsg ("client_address required");
11806 if (our_address_set == 0)
11808 errmsg ("our_address required");
11812 M (L2TPV3_CREATE_TUNNEL, mp);
11814 clib_memcpy (mp->client_address, client_address.as_u8,
11815 sizeof (mp->client_address));
11817 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11819 mp->local_session_id = ntohl (local_session_id);
11820 mp->remote_session_id = ntohl (remote_session_id);
11821 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11822 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11823 mp->l2_sublayer_present = l2_sublayer_present;
11832 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11834 unformat_input_t *i = vam->input;
11836 u8 sw_if_index_set = 0;
11837 u64 new_local_cookie = 0;
11838 u64 new_remote_cookie = 0;
11839 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11842 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11844 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11845 sw_if_index_set = 1;
11846 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11847 sw_if_index_set = 1;
11848 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11850 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11856 if (sw_if_index_set == 0)
11858 errmsg ("missing interface name or sw_if_index");
11862 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11864 mp->sw_if_index = ntohl (sw_if_index);
11865 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11866 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11874 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11876 unformat_input_t *i = vam->input;
11877 vl_api_l2tpv3_interface_enable_disable_t *mp;
11879 u8 sw_if_index_set = 0;
11880 u8 enable_disable = 1;
11883 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11885 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11886 sw_if_index_set = 1;
11887 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11888 sw_if_index_set = 1;
11889 else if (unformat (i, "enable"))
11890 enable_disable = 1;
11891 else if (unformat (i, "disable"))
11892 enable_disable = 0;
11897 if (sw_if_index_set == 0)
11899 errmsg ("missing interface name or sw_if_index");
11903 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11905 mp->sw_if_index = ntohl (sw_if_index);
11906 mp->enable_disable = enable_disable;
11914 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11916 unformat_input_t *i = vam->input;
11917 vl_api_l2tpv3_set_lookup_key_t *mp;
11921 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11923 if (unformat (i, "lookup_v6_src"))
11924 key = L2T_LOOKUP_SRC_ADDRESS;
11925 else if (unformat (i, "lookup_v6_dst"))
11926 key = L2T_LOOKUP_DST_ADDRESS;
11927 else if (unformat (i, "lookup_session_id"))
11928 key = L2T_LOOKUP_SESSION_ID;
11933 if (key == (u8) ~ 0)
11935 errmsg ("l2tp session lookup key unset");
11939 M (L2TPV3_SET_LOOKUP_KEY, mp);
11948 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11949 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11951 vat_main_t *vam = &vat_main;
11953 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11954 format_ip6_address, mp->our_address,
11955 format_ip6_address, mp->client_address,
11956 clib_net_to_host_u32 (mp->sw_if_index));
11959 " local cookies %016llx %016llx remote cookie %016llx",
11960 clib_net_to_host_u64 (mp->local_cookie[0]),
11961 clib_net_to_host_u64 (mp->local_cookie[1]),
11962 clib_net_to_host_u64 (mp->remote_cookie));
11964 print (vam->ofp, " local session-id %d remote session-id %d",
11965 clib_net_to_host_u32 (mp->local_session_id),
11966 clib_net_to_host_u32 (mp->remote_session_id));
11968 print (vam->ofp, " l2 specific sublayer %s\n",
11969 mp->l2_sublayer_present ? "preset" : "absent");
11973 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11974 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11976 vat_main_t *vam = &vat_main;
11977 vat_json_node_t *node = NULL;
11978 struct in6_addr addr;
11980 if (VAT_JSON_ARRAY != vam->json_tree.type)
11982 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11983 vat_json_init_array (&vam->json_tree);
11985 node = vat_json_array_add (&vam->json_tree);
11987 vat_json_init_object (node);
11989 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11990 vat_json_object_add_ip6 (node, "our_address", addr);
11991 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11992 vat_json_object_add_ip6 (node, "client_address", addr);
11994 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11995 vat_json_init_array (lc);
11996 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11997 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11998 vat_json_object_add_uint (node, "remote_cookie",
11999 clib_net_to_host_u64 (mp->remote_cookie));
12001 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12002 vat_json_object_add_uint (node, "local_session_id",
12003 clib_net_to_host_u32 (mp->local_session_id));
12004 vat_json_object_add_uint (node, "remote_session_id",
12005 clib_net_to_host_u32 (mp->remote_session_id));
12006 vat_json_object_add_string_copy (node, "l2_sublayer",
12007 mp->l2_sublayer_present ? (u8 *) "present"
12008 : (u8 *) "absent");
12012 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12014 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12015 vl_api_control_ping_t *mp_ping;
12018 /* Get list of l2tpv3-tunnel interfaces */
12019 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12022 /* Use a control ping for synchronization */
12023 MPING (CONTROL_PING, mp_ping);
12031 static void vl_api_sw_interface_tap_details_t_handler
12032 (vl_api_sw_interface_tap_details_t * mp)
12034 vat_main_t *vam = &vat_main;
12036 print (vam->ofp, "%-16s %d",
12037 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12040 static void vl_api_sw_interface_tap_details_t_handler_json
12041 (vl_api_sw_interface_tap_details_t * mp)
12043 vat_main_t *vam = &vat_main;
12044 vat_json_node_t *node = NULL;
12046 if (VAT_JSON_ARRAY != vam->json_tree.type)
12048 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12049 vat_json_init_array (&vam->json_tree);
12051 node = vat_json_array_add (&vam->json_tree);
12053 vat_json_init_object (node);
12054 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12055 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12059 api_sw_interface_tap_dump (vat_main_t * vam)
12061 vl_api_sw_interface_tap_dump_t *mp;
12062 vl_api_control_ping_t *mp_ping;
12065 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12066 /* Get list of tap interfaces */
12067 M (SW_INTERFACE_TAP_DUMP, mp);
12070 /* Use a control ping for synchronization */
12071 MPING (CONTROL_PING, mp_ping);
12078 static uword unformat_vxlan_decap_next
12079 (unformat_input_t * input, va_list * args)
12081 u32 *result = va_arg (*args, u32 *);
12084 if (unformat (input, "l2"))
12085 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12086 else if (unformat (input, "%d", &tmp))
12094 api_vxlan_add_del_tunnel (vat_main_t * vam)
12096 unformat_input_t *line_input = vam->input;
12097 vl_api_vxlan_add_del_tunnel_t *mp;
12098 ip46_address_t src, dst;
12100 u8 ipv4_set = 0, ipv6_set = 0;
12104 u32 mcast_sw_if_index = ~0;
12105 u32 encap_vrf_id = 0;
12106 u32 decap_next_index = ~0;
12110 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12111 memset (&src, 0, sizeof src);
12112 memset (&dst, 0, sizeof dst);
12114 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12116 if (unformat (line_input, "del"))
12119 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12125 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12131 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12137 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12142 else if (unformat (line_input, "group %U %U",
12143 unformat_ip4_address, &dst.ip4,
12144 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12146 grp_set = dst_set = 1;
12149 else if (unformat (line_input, "group %U",
12150 unformat_ip4_address, &dst.ip4))
12152 grp_set = dst_set = 1;
12155 else if (unformat (line_input, "group %U %U",
12156 unformat_ip6_address, &dst.ip6,
12157 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12159 grp_set = dst_set = 1;
12162 else if (unformat (line_input, "group %U",
12163 unformat_ip6_address, &dst.ip6))
12165 grp_set = dst_set = 1;
12169 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12171 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12173 else if (unformat (line_input, "decap-next %U",
12174 unformat_vxlan_decap_next, &decap_next_index))
12176 else if (unformat (line_input, "vni %d", &vni))
12180 errmsg ("parse error '%U'", format_unformat_error, line_input);
12187 errmsg ("tunnel src address not specified");
12192 errmsg ("tunnel dst address not specified");
12196 if (grp_set && !ip46_address_is_multicast (&dst))
12198 errmsg ("tunnel group address not multicast");
12201 if (grp_set && mcast_sw_if_index == ~0)
12203 errmsg ("tunnel nonexistent multicast device");
12206 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12208 errmsg ("tunnel dst address must be unicast");
12213 if (ipv4_set && ipv6_set)
12215 errmsg ("both IPv4 and IPv6 addresses specified");
12219 if ((vni == 0) || (vni >> 24))
12221 errmsg ("vni not specified or out of range");
12225 M (VXLAN_ADD_DEL_TUNNEL, mp);
12229 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12230 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12234 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12235 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12237 mp->encap_vrf_id = ntohl (encap_vrf_id);
12238 mp->decap_next_index = ntohl (decap_next_index);
12239 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12240 mp->vni = ntohl (vni);
12241 mp->is_add = is_add;
12242 mp->is_ipv6 = ipv6_set;
12249 static void vl_api_vxlan_tunnel_details_t_handler
12250 (vl_api_vxlan_tunnel_details_t * mp)
12252 vat_main_t *vam = &vat_main;
12253 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12254 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12256 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12257 ntohl (mp->sw_if_index),
12258 format_ip46_address, &src, IP46_TYPE_ANY,
12259 format_ip46_address, &dst, IP46_TYPE_ANY,
12260 ntohl (mp->encap_vrf_id),
12261 ntohl (mp->decap_next_index), ntohl (mp->vni),
12262 ntohl (mp->mcast_sw_if_index));
12265 static void vl_api_vxlan_tunnel_details_t_handler_json
12266 (vl_api_vxlan_tunnel_details_t * mp)
12268 vat_main_t *vam = &vat_main;
12269 vat_json_node_t *node = NULL;
12271 if (VAT_JSON_ARRAY != vam->json_tree.type)
12273 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12274 vat_json_init_array (&vam->json_tree);
12276 node = vat_json_array_add (&vam->json_tree);
12278 vat_json_init_object (node);
12279 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12282 struct in6_addr ip6;
12284 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12285 vat_json_object_add_ip6 (node, "src_address", ip6);
12286 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12287 vat_json_object_add_ip6 (node, "dst_address", ip6);
12291 struct in_addr ip4;
12293 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12294 vat_json_object_add_ip4 (node, "src_address", ip4);
12295 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12296 vat_json_object_add_ip4 (node, "dst_address", ip4);
12298 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12299 vat_json_object_add_uint (node, "decap_next_index",
12300 ntohl (mp->decap_next_index));
12301 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12302 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12303 vat_json_object_add_uint (node, "mcast_sw_if_index",
12304 ntohl (mp->mcast_sw_if_index));
12308 api_vxlan_tunnel_dump (vat_main_t * vam)
12310 unformat_input_t *i = vam->input;
12311 vl_api_vxlan_tunnel_dump_t *mp;
12312 vl_api_control_ping_t *mp_ping;
12314 u8 sw_if_index_set = 0;
12317 /* Parse args required to build the message */
12318 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12320 if (unformat (i, "sw_if_index %d", &sw_if_index))
12321 sw_if_index_set = 1;
12326 if (sw_if_index_set == 0)
12331 if (!vam->json_output)
12333 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12334 "sw_if_index", "src_address", "dst_address",
12335 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12338 /* Get list of vxlan-tunnel interfaces */
12339 M (VXLAN_TUNNEL_DUMP, mp);
12341 mp->sw_if_index = htonl (sw_if_index);
12345 /* Use a control ping for synchronization */
12346 MPING (CONTROL_PING, mp_ping);
12353 static uword unformat_geneve_decap_next
12354 (unformat_input_t * input, va_list * args)
12356 u32 *result = va_arg (*args, u32 *);
12359 if (unformat (input, "l2"))
12360 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12361 else if (unformat (input, "%d", &tmp))
12369 api_geneve_add_del_tunnel (vat_main_t * vam)
12371 unformat_input_t *line_input = vam->input;
12372 vl_api_geneve_add_del_tunnel_t *mp;
12373 ip46_address_t src, dst;
12375 u8 ipv4_set = 0, ipv6_set = 0;
12379 u32 mcast_sw_if_index = ~0;
12380 u32 encap_vrf_id = 0;
12381 u32 decap_next_index = ~0;
12385 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12386 memset (&src, 0, sizeof src);
12387 memset (&dst, 0, sizeof dst);
12389 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12391 if (unformat (line_input, "del"))
12394 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12400 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12406 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12412 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12417 else if (unformat (line_input, "group %U %U",
12418 unformat_ip4_address, &dst.ip4,
12419 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12421 grp_set = dst_set = 1;
12424 else if (unformat (line_input, "group %U",
12425 unformat_ip4_address, &dst.ip4))
12427 grp_set = dst_set = 1;
12430 else if (unformat (line_input, "group %U %U",
12431 unformat_ip6_address, &dst.ip6,
12432 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12434 grp_set = dst_set = 1;
12437 else if (unformat (line_input, "group %U",
12438 unformat_ip6_address, &dst.ip6))
12440 grp_set = dst_set = 1;
12444 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12446 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12448 else if (unformat (line_input, "decap-next %U",
12449 unformat_geneve_decap_next, &decap_next_index))
12451 else if (unformat (line_input, "vni %d", &vni))
12455 errmsg ("parse error '%U'", format_unformat_error, line_input);
12462 errmsg ("tunnel src address not specified");
12467 errmsg ("tunnel dst address not specified");
12471 if (grp_set && !ip46_address_is_multicast (&dst))
12473 errmsg ("tunnel group address not multicast");
12476 if (grp_set && mcast_sw_if_index == ~0)
12478 errmsg ("tunnel nonexistent multicast device");
12481 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12483 errmsg ("tunnel dst address must be unicast");
12488 if (ipv4_set && ipv6_set)
12490 errmsg ("both IPv4 and IPv6 addresses specified");
12494 if ((vni == 0) || (vni >> 24))
12496 errmsg ("vni not specified or out of range");
12500 M (GENEVE_ADD_DEL_TUNNEL, mp);
12504 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12505 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12509 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12510 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12512 mp->encap_vrf_id = ntohl (encap_vrf_id);
12513 mp->decap_next_index = ntohl (decap_next_index);
12514 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12515 mp->vni = ntohl (vni);
12516 mp->is_add = is_add;
12517 mp->is_ipv6 = ipv6_set;
12524 static void vl_api_geneve_tunnel_details_t_handler
12525 (vl_api_geneve_tunnel_details_t * mp)
12527 vat_main_t *vam = &vat_main;
12528 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12529 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12531 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12532 ntohl (mp->sw_if_index),
12533 format_ip46_address, &src, IP46_TYPE_ANY,
12534 format_ip46_address, &dst, IP46_TYPE_ANY,
12535 ntohl (mp->encap_vrf_id),
12536 ntohl (mp->decap_next_index), ntohl (mp->vni),
12537 ntohl (mp->mcast_sw_if_index));
12540 static void vl_api_geneve_tunnel_details_t_handler_json
12541 (vl_api_geneve_tunnel_details_t * mp)
12543 vat_main_t *vam = &vat_main;
12544 vat_json_node_t *node = NULL;
12546 if (VAT_JSON_ARRAY != vam->json_tree.type)
12548 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12549 vat_json_init_array (&vam->json_tree);
12551 node = vat_json_array_add (&vam->json_tree);
12553 vat_json_init_object (node);
12554 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12557 struct in6_addr ip6;
12559 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12560 vat_json_object_add_ip6 (node, "src_address", ip6);
12561 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12562 vat_json_object_add_ip6 (node, "dst_address", ip6);
12566 struct in_addr ip4;
12568 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12569 vat_json_object_add_ip4 (node, "src_address", ip4);
12570 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12571 vat_json_object_add_ip4 (node, "dst_address", ip4);
12573 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12574 vat_json_object_add_uint (node, "decap_next_index",
12575 ntohl (mp->decap_next_index));
12576 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12577 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12578 vat_json_object_add_uint (node, "mcast_sw_if_index",
12579 ntohl (mp->mcast_sw_if_index));
12583 api_geneve_tunnel_dump (vat_main_t * vam)
12585 unformat_input_t *i = vam->input;
12586 vl_api_geneve_tunnel_dump_t *mp;
12587 vl_api_control_ping_t *mp_ping;
12589 u8 sw_if_index_set = 0;
12592 /* Parse args required to build the message */
12593 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12595 if (unformat (i, "sw_if_index %d", &sw_if_index))
12596 sw_if_index_set = 1;
12601 if (sw_if_index_set == 0)
12606 if (!vam->json_output)
12608 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12609 "sw_if_index", "local_address", "remote_address",
12610 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12613 /* Get list of geneve-tunnel interfaces */
12614 M (GENEVE_TUNNEL_DUMP, mp);
12616 mp->sw_if_index = htonl (sw_if_index);
12620 /* Use a control ping for synchronization */
12621 M (CONTROL_PING, mp_ping);
12629 api_gre_add_del_tunnel (vat_main_t * vam)
12631 unformat_input_t *line_input = vam->input;
12632 vl_api_gre_add_del_tunnel_t *mp;
12633 ip4_address_t src4, dst4;
12634 ip6_address_t src6, dst6;
12641 u32 outer_fib_id = 0;
12644 memset (&src4, 0, sizeof src4);
12645 memset (&dst4, 0, sizeof dst4);
12646 memset (&src6, 0, sizeof src6);
12647 memset (&dst6, 0, sizeof dst6);
12649 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12651 if (unformat (line_input, "del"))
12653 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
12658 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
12663 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
12668 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
12673 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12675 else if (unformat (line_input, "teb"))
12679 errmsg ("parse error '%U'", format_unformat_error, line_input);
12686 errmsg ("tunnel src address not specified");
12691 errmsg ("tunnel dst address not specified");
12694 if (ipv4_set && ipv6_set)
12696 errmsg ("both IPv4 and IPv6 addresses specified");
12701 M (GRE_ADD_DEL_TUNNEL, mp);
12705 clib_memcpy (&mp->src_address, &src4, 4);
12706 clib_memcpy (&mp->dst_address, &dst4, 4);
12710 clib_memcpy (&mp->src_address, &src6, 16);
12711 clib_memcpy (&mp->dst_address, &dst6, 16);
12713 mp->outer_fib_id = ntohl (outer_fib_id);
12714 mp->is_add = is_add;
12716 mp->is_ipv6 = ipv6_set;
12723 static void vl_api_gre_tunnel_details_t_handler
12724 (vl_api_gre_tunnel_details_t * mp)
12726 vat_main_t *vam = &vat_main;
12727 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
12728 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
12730 print (vam->ofp, "%11d%24U%24U%6d%14d",
12731 ntohl (mp->sw_if_index),
12732 format_ip46_address, &src, IP46_TYPE_ANY,
12733 format_ip46_address, &dst, IP46_TYPE_ANY,
12734 mp->teb, ntohl (mp->outer_fib_id));
12737 static void vl_api_gre_tunnel_details_t_handler_json
12738 (vl_api_gre_tunnel_details_t * mp)
12740 vat_main_t *vam = &vat_main;
12741 vat_json_node_t *node = NULL;
12742 struct in_addr ip4;
12743 struct in6_addr ip6;
12745 if (VAT_JSON_ARRAY != vam->json_tree.type)
12747 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12748 vat_json_init_array (&vam->json_tree);
12750 node = vat_json_array_add (&vam->json_tree);
12752 vat_json_init_object (node);
12753 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12756 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
12757 vat_json_object_add_ip4 (node, "src_address", ip4);
12758 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
12759 vat_json_object_add_ip4 (node, "dst_address", ip4);
12763 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
12764 vat_json_object_add_ip6 (node, "src_address", ip6);
12765 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
12766 vat_json_object_add_ip6 (node, "dst_address", ip6);
12768 vat_json_object_add_uint (node, "teb", mp->teb);
12769 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
12770 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
12774 api_gre_tunnel_dump (vat_main_t * vam)
12776 unformat_input_t *i = vam->input;
12777 vl_api_gre_tunnel_dump_t *mp;
12778 vl_api_control_ping_t *mp_ping;
12780 u8 sw_if_index_set = 0;
12783 /* Parse args required to build the message */
12784 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12786 if (unformat (i, "sw_if_index %d", &sw_if_index))
12787 sw_if_index_set = 1;
12792 if (sw_if_index_set == 0)
12797 if (!vam->json_output)
12799 print (vam->ofp, "%11s%24s%24s%6s%14s",
12800 "sw_if_index", "src_address", "dst_address", "teb",
12804 /* Get list of gre-tunnel interfaces */
12805 M (GRE_TUNNEL_DUMP, mp);
12807 mp->sw_if_index = htonl (sw_if_index);
12811 /* Use a control ping for synchronization */
12812 MPING (CONTROL_PING, mp_ping);
12820 api_l2_fib_clear_table (vat_main_t * vam)
12822 // unformat_input_t * i = vam->input;
12823 vl_api_l2_fib_clear_table_t *mp;
12826 M (L2_FIB_CLEAR_TABLE, mp);
12834 api_l2_interface_efp_filter (vat_main_t * vam)
12836 unformat_input_t *i = vam->input;
12837 vl_api_l2_interface_efp_filter_t *mp;
12840 u8 sw_if_index_set = 0;
12843 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12845 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12846 sw_if_index_set = 1;
12847 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12848 sw_if_index_set = 1;
12849 else if (unformat (i, "enable"))
12851 else if (unformat (i, "disable"))
12855 clib_warning ("parse error '%U'", format_unformat_error, i);
12860 if (sw_if_index_set == 0)
12862 errmsg ("missing sw_if_index");
12866 M (L2_INTERFACE_EFP_FILTER, mp);
12868 mp->sw_if_index = ntohl (sw_if_index);
12869 mp->enable_disable = enable;
12876 #define foreach_vtr_op \
12877 _("disable", L2_VTR_DISABLED) \
12878 _("push-1", L2_VTR_PUSH_1) \
12879 _("push-2", L2_VTR_PUSH_2) \
12880 _("pop-1", L2_VTR_POP_1) \
12881 _("pop-2", L2_VTR_POP_2) \
12882 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12883 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12884 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12885 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12888 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12890 unformat_input_t *i = vam->input;
12891 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12893 u8 sw_if_index_set = 0;
12896 u32 push_dot1q = 1;
12901 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12903 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12904 sw_if_index_set = 1;
12905 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12906 sw_if_index_set = 1;
12907 else if (unformat (i, "vtr_op %d", &vtr_op))
12909 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12912 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12914 else if (unformat (i, "tag1 %d", &tag1))
12916 else if (unformat (i, "tag2 %d", &tag2))
12920 clib_warning ("parse error '%U'", format_unformat_error, i);
12925 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12927 errmsg ("missing vtr operation or sw_if_index");
12931 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12932 mp->sw_if_index = ntohl (sw_if_index);
12933 mp->vtr_op = ntohl (vtr_op);
12934 mp->push_dot1q = ntohl (push_dot1q);
12935 mp->tag1 = ntohl (tag1);
12936 mp->tag2 = ntohl (tag2);
12944 api_create_vhost_user_if (vat_main_t * vam)
12946 unformat_input_t *i = vam->input;
12947 vl_api_create_vhost_user_if_t *mp;
12950 u8 file_name_set = 0;
12951 u32 custom_dev_instance = ~0;
12953 u8 use_custom_mac = 0;
12957 /* Shut up coverity */
12958 memset (hwaddr, 0, sizeof (hwaddr));
12960 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12962 if (unformat (i, "socket %s", &file_name))
12966 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12968 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12969 use_custom_mac = 1;
12970 else if (unformat (i, "server"))
12972 else if (unformat (i, "tag %s", &tag))
12978 if (file_name_set == 0)
12980 errmsg ("missing socket file name");
12984 if (vec_len (file_name) > 255)
12986 errmsg ("socket file name too long");
12989 vec_add1 (file_name, 0);
12991 M (CREATE_VHOST_USER_IF, mp);
12993 mp->is_server = is_server;
12994 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12995 vec_free (file_name);
12996 if (custom_dev_instance != ~0)
12999 mp->custom_dev_instance = ntohl (custom_dev_instance);
13001 mp->use_custom_mac = use_custom_mac;
13002 clib_memcpy (mp->mac_address, hwaddr, 6);
13004 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13013 api_modify_vhost_user_if (vat_main_t * vam)
13015 unformat_input_t *i = vam->input;
13016 vl_api_modify_vhost_user_if_t *mp;
13019 u8 file_name_set = 0;
13020 u32 custom_dev_instance = ~0;
13021 u8 sw_if_index_set = 0;
13022 u32 sw_if_index = (u32) ~ 0;
13025 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13027 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13028 sw_if_index_set = 1;
13029 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13030 sw_if_index_set = 1;
13031 else if (unformat (i, "socket %s", &file_name))
13035 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13037 else if (unformat (i, "server"))
13043 if (sw_if_index_set == 0)
13045 errmsg ("missing sw_if_index or interface name");
13049 if (file_name_set == 0)
13051 errmsg ("missing socket file name");
13055 if (vec_len (file_name) > 255)
13057 errmsg ("socket file name too long");
13060 vec_add1 (file_name, 0);
13062 M (MODIFY_VHOST_USER_IF, mp);
13064 mp->sw_if_index = ntohl (sw_if_index);
13065 mp->is_server = is_server;
13066 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13067 vec_free (file_name);
13068 if (custom_dev_instance != ~0)
13071 mp->custom_dev_instance = ntohl (custom_dev_instance);
13080 api_delete_vhost_user_if (vat_main_t * vam)
13082 unformat_input_t *i = vam->input;
13083 vl_api_delete_vhost_user_if_t *mp;
13084 u32 sw_if_index = ~0;
13085 u8 sw_if_index_set = 0;
13088 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13090 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13091 sw_if_index_set = 1;
13092 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13093 sw_if_index_set = 1;
13098 if (sw_if_index_set == 0)
13100 errmsg ("missing sw_if_index or interface name");
13105 M (DELETE_VHOST_USER_IF, mp);
13107 mp->sw_if_index = ntohl (sw_if_index);
13114 static void vl_api_sw_interface_vhost_user_details_t_handler
13115 (vl_api_sw_interface_vhost_user_details_t * mp)
13117 vat_main_t *vam = &vat_main;
13119 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13120 (char *) mp->interface_name,
13121 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13122 clib_net_to_host_u64 (mp->features), mp->is_server,
13123 ntohl (mp->num_regions), (char *) mp->sock_filename);
13124 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13127 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13128 (vl_api_sw_interface_vhost_user_details_t * mp)
13130 vat_main_t *vam = &vat_main;
13131 vat_json_node_t *node = NULL;
13133 if (VAT_JSON_ARRAY != vam->json_tree.type)
13135 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13136 vat_json_init_array (&vam->json_tree);
13138 node = vat_json_array_add (&vam->json_tree);
13140 vat_json_init_object (node);
13141 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13142 vat_json_object_add_string_copy (node, "interface_name",
13143 mp->interface_name);
13144 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13145 ntohl (mp->virtio_net_hdr_sz));
13146 vat_json_object_add_uint (node, "features",
13147 clib_net_to_host_u64 (mp->features));
13148 vat_json_object_add_uint (node, "is_server", mp->is_server);
13149 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13150 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13151 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13155 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13157 vl_api_sw_interface_vhost_user_dump_t *mp;
13158 vl_api_control_ping_t *mp_ping;
13161 "Interface name idx hdr_sz features server regions filename");
13163 /* Get list of vhost-user interfaces */
13164 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13167 /* Use a control ping for synchronization */
13168 MPING (CONTROL_PING, mp_ping);
13176 api_show_version (vat_main_t * vam)
13178 vl_api_show_version_t *mp;
13181 M (SHOW_VERSION, mp);
13190 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13192 unformat_input_t *line_input = vam->input;
13193 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13194 ip4_address_t local4, remote4;
13195 ip6_address_t local6, remote6;
13197 u8 ipv4_set = 0, ipv6_set = 0;
13201 u32 mcast_sw_if_index = ~0;
13202 u32 encap_vrf_id = 0;
13203 u32 decap_vrf_id = 0;
13209 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13210 memset (&local4, 0, sizeof local4);
13211 memset (&remote4, 0, sizeof remote4);
13212 memset (&local6, 0, sizeof local6);
13213 memset (&remote6, 0, sizeof remote6);
13215 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13217 if (unformat (line_input, "del"))
13219 else if (unformat (line_input, "local %U",
13220 unformat_ip4_address, &local4))
13225 else if (unformat (line_input, "remote %U",
13226 unformat_ip4_address, &remote4))
13231 else if (unformat (line_input, "local %U",
13232 unformat_ip6_address, &local6))
13237 else if (unformat (line_input, "remote %U",
13238 unformat_ip6_address, &remote6))
13243 else if (unformat (line_input, "group %U %U",
13244 unformat_ip4_address, &remote4,
13245 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13247 grp_set = remote_set = 1;
13250 else if (unformat (line_input, "group %U",
13251 unformat_ip4_address, &remote4))
13253 grp_set = remote_set = 1;
13256 else if (unformat (line_input, "group %U %U",
13257 unformat_ip6_address, &remote6,
13258 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13260 grp_set = remote_set = 1;
13263 else if (unformat (line_input, "group %U",
13264 unformat_ip6_address, &remote6))
13266 grp_set = remote_set = 1;
13270 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13272 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13274 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13276 else if (unformat (line_input, "vni %d", &vni))
13278 else if (unformat (line_input, "next-ip4"))
13280 else if (unformat (line_input, "next-ip6"))
13282 else if (unformat (line_input, "next-ethernet"))
13284 else if (unformat (line_input, "next-nsh"))
13288 errmsg ("parse error '%U'", format_unformat_error, line_input);
13293 if (local_set == 0)
13295 errmsg ("tunnel local address not specified");
13298 if (remote_set == 0)
13300 errmsg ("tunnel remote address not specified");
13303 if (grp_set && mcast_sw_if_index == ~0)
13305 errmsg ("tunnel nonexistent multicast device");
13308 if (ipv4_set && ipv6_set)
13310 errmsg ("both IPv4 and IPv6 addresses specified");
13316 errmsg ("vni not specified");
13320 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13325 clib_memcpy (&mp->local, &local6, sizeof (local6));
13326 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13330 clib_memcpy (&mp->local, &local4, sizeof (local4));
13331 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13334 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13335 mp->encap_vrf_id = ntohl (encap_vrf_id);
13336 mp->decap_vrf_id = ntohl (decap_vrf_id);
13337 mp->protocol = protocol;
13338 mp->vni = ntohl (vni);
13339 mp->is_add = is_add;
13340 mp->is_ipv6 = ipv6_set;
13347 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13348 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13350 vat_main_t *vam = &vat_main;
13351 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13352 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13354 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13355 ntohl (mp->sw_if_index),
13356 format_ip46_address, &local, IP46_TYPE_ANY,
13357 format_ip46_address, &remote, IP46_TYPE_ANY,
13358 ntohl (mp->vni), mp->protocol,
13359 ntohl (mp->mcast_sw_if_index),
13360 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13364 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13365 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13367 vat_main_t *vam = &vat_main;
13368 vat_json_node_t *node = NULL;
13369 struct in_addr ip4;
13370 struct in6_addr ip6;
13372 if (VAT_JSON_ARRAY != vam->json_tree.type)
13374 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13375 vat_json_init_array (&vam->json_tree);
13377 node = vat_json_array_add (&vam->json_tree);
13379 vat_json_init_object (node);
13380 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13383 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13384 vat_json_object_add_ip6 (node, "local", ip6);
13385 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13386 vat_json_object_add_ip6 (node, "remote", ip6);
13390 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13391 vat_json_object_add_ip4 (node, "local", ip4);
13392 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13393 vat_json_object_add_ip4 (node, "remote", ip4);
13395 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13396 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13397 vat_json_object_add_uint (node, "mcast_sw_if_index",
13398 ntohl (mp->mcast_sw_if_index));
13399 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13400 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13401 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13405 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13407 unformat_input_t *i = vam->input;
13408 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13409 vl_api_control_ping_t *mp_ping;
13411 u8 sw_if_index_set = 0;
13414 /* Parse args required to build the message */
13415 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13417 if (unformat (i, "sw_if_index %d", &sw_if_index))
13418 sw_if_index_set = 1;
13423 if (sw_if_index_set == 0)
13428 if (!vam->json_output)
13430 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13431 "sw_if_index", "local", "remote", "vni",
13432 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13435 /* Get list of vxlan-tunnel interfaces */
13436 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13438 mp->sw_if_index = htonl (sw_if_index);
13442 /* Use a control ping for synchronization */
13443 MPING (CONTROL_PING, mp_ping);
13450 static void vl_api_l2_fib_table_details_t_handler
13451 (vl_api_l2_fib_table_details_t * mp)
13453 vat_main_t *vam = &vat_main;
13455 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13457 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
13458 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13462 static void vl_api_l2_fib_table_details_t_handler_json
13463 (vl_api_l2_fib_table_details_t * mp)
13465 vat_main_t *vam = &vat_main;
13466 vat_json_node_t *node = NULL;
13468 if (VAT_JSON_ARRAY != vam->json_tree.type)
13470 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13471 vat_json_init_array (&vam->json_tree);
13473 node = vat_json_array_add (&vam->json_tree);
13475 vat_json_init_object (node);
13476 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13477 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
13478 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13479 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13480 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13481 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13485 api_l2_fib_table_dump (vat_main_t * vam)
13487 unformat_input_t *i = vam->input;
13488 vl_api_l2_fib_table_dump_t *mp;
13489 vl_api_control_ping_t *mp_ping;
13494 /* Parse args required to build the message */
13495 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13497 if (unformat (i, "bd_id %d", &bd_id))
13503 if (bd_id_set == 0)
13505 errmsg ("missing bridge domain");
13509 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13511 /* Get list of l2 fib entries */
13512 M (L2_FIB_TABLE_DUMP, mp);
13514 mp->bd_id = ntohl (bd_id);
13517 /* Use a control ping for synchronization */
13518 MPING (CONTROL_PING, mp_ping);
13527 api_interface_name_renumber (vat_main_t * vam)
13529 unformat_input_t *line_input = vam->input;
13530 vl_api_interface_name_renumber_t *mp;
13531 u32 sw_if_index = ~0;
13532 u32 new_show_dev_instance = ~0;
13535 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13537 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13540 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13542 else if (unformat (line_input, "new_show_dev_instance %d",
13543 &new_show_dev_instance))
13549 if (sw_if_index == ~0)
13551 errmsg ("missing interface name or sw_if_index");
13555 if (new_show_dev_instance == ~0)
13557 errmsg ("missing new_show_dev_instance");
13561 M (INTERFACE_NAME_RENUMBER, mp);
13563 mp->sw_if_index = ntohl (sw_if_index);
13564 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13572 api_want_ip4_arp_events (vat_main_t * vam)
13574 unformat_input_t *line_input = vam->input;
13575 vl_api_want_ip4_arp_events_t *mp;
13576 ip4_address_t address;
13577 int address_set = 0;
13578 u32 enable_disable = 1;
13581 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13583 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
13585 else if (unformat (line_input, "del"))
13586 enable_disable = 0;
13591 if (address_set == 0)
13593 errmsg ("missing addresses");
13597 M (WANT_IP4_ARP_EVENTS, mp);
13598 mp->enable_disable = enable_disable;
13599 mp->pid = htonl (getpid ());
13600 mp->address = address.as_u32;
13608 api_want_ip6_nd_events (vat_main_t * vam)
13610 unformat_input_t *line_input = vam->input;
13611 vl_api_want_ip6_nd_events_t *mp;
13612 ip6_address_t address;
13613 int address_set = 0;
13614 u32 enable_disable = 1;
13617 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13619 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
13621 else if (unformat (line_input, "del"))
13622 enable_disable = 0;
13627 if (address_set == 0)
13629 errmsg ("missing addresses");
13633 M (WANT_IP6_ND_EVENTS, mp);
13634 mp->enable_disable = enable_disable;
13635 mp->pid = htonl (getpid ());
13636 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
13644 api_want_l2_macs_events (vat_main_t * vam)
13646 unformat_input_t *line_input = vam->input;
13647 vl_api_want_l2_macs_events_t *mp;
13648 u8 enable_disable = 1;
13649 u32 scan_delay = 0;
13650 u32 max_macs_in_event = 0;
13651 u32 learn_limit = 0;
13654 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13656 if (unformat (line_input, "learn-limit %d", &learn_limit))
13658 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13660 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13662 else if (unformat (line_input, "disable"))
13663 enable_disable = 0;
13668 M (WANT_L2_MACS_EVENTS, mp);
13669 mp->enable_disable = enable_disable;
13670 mp->pid = htonl (getpid ());
13671 mp->learn_limit = htonl (learn_limit);
13672 mp->scan_delay = (u8) scan_delay;
13673 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13680 api_input_acl_set_interface (vat_main_t * vam)
13682 unformat_input_t *i = vam->input;
13683 vl_api_input_acl_set_interface_t *mp;
13685 int sw_if_index_set;
13686 u32 ip4_table_index = ~0;
13687 u32 ip6_table_index = ~0;
13688 u32 l2_table_index = ~0;
13692 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13694 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13695 sw_if_index_set = 1;
13696 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13697 sw_if_index_set = 1;
13698 else if (unformat (i, "del"))
13700 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13702 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13704 else if (unformat (i, "l2-table %d", &l2_table_index))
13708 clib_warning ("parse error '%U'", format_unformat_error, i);
13713 if (sw_if_index_set == 0)
13715 errmsg ("missing interface name or sw_if_index");
13719 M (INPUT_ACL_SET_INTERFACE, mp);
13721 mp->sw_if_index = ntohl (sw_if_index);
13722 mp->ip4_table_index = ntohl (ip4_table_index);
13723 mp->ip6_table_index = ntohl (ip6_table_index);
13724 mp->l2_table_index = ntohl (l2_table_index);
13725 mp->is_add = is_add;
13733 api_ip_address_dump (vat_main_t * vam)
13735 unformat_input_t *i = vam->input;
13736 vl_api_ip_address_dump_t *mp;
13737 vl_api_control_ping_t *mp_ping;
13738 u32 sw_if_index = ~0;
13739 u8 sw_if_index_set = 0;
13744 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13746 if (unformat (i, "sw_if_index %d", &sw_if_index))
13747 sw_if_index_set = 1;
13749 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13750 sw_if_index_set = 1;
13751 else if (unformat (i, "ipv4"))
13753 else if (unformat (i, "ipv6"))
13759 if (ipv4_set && ipv6_set)
13761 errmsg ("ipv4 and ipv6 flags cannot be both set");
13765 if ((!ipv4_set) && (!ipv6_set))
13767 errmsg ("no ipv4 nor ipv6 flag set");
13771 if (sw_if_index_set == 0)
13773 errmsg ("missing interface name or sw_if_index");
13777 vam->current_sw_if_index = sw_if_index;
13778 vam->is_ipv6 = ipv6_set;
13780 M (IP_ADDRESS_DUMP, mp);
13781 mp->sw_if_index = ntohl (sw_if_index);
13782 mp->is_ipv6 = ipv6_set;
13785 /* Use a control ping for synchronization */
13786 MPING (CONTROL_PING, mp_ping);
13794 api_ip_dump (vat_main_t * vam)
13796 vl_api_ip_dump_t *mp;
13797 vl_api_control_ping_t *mp_ping;
13798 unformat_input_t *in = vam->input;
13805 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13807 if (unformat (in, "ipv4"))
13809 else if (unformat (in, "ipv6"))
13815 if (ipv4_set && ipv6_set)
13817 errmsg ("ipv4 and ipv6 flags cannot be both set");
13821 if ((!ipv4_set) && (!ipv6_set))
13823 errmsg ("no ipv4 nor ipv6 flag set");
13827 is_ipv6 = ipv6_set;
13828 vam->is_ipv6 = is_ipv6;
13830 /* free old data */
13831 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13833 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13835 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13838 mp->is_ipv6 = ipv6_set;
13841 /* Use a control ping for synchronization */
13842 MPING (CONTROL_PING, mp_ping);
13850 api_ipsec_spd_add_del (vat_main_t * vam)
13852 unformat_input_t *i = vam->input;
13853 vl_api_ipsec_spd_add_del_t *mp;
13858 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13860 if (unformat (i, "spd_id %d", &spd_id))
13862 else if (unformat (i, "del"))
13866 clib_warning ("parse error '%U'", format_unformat_error, i);
13872 errmsg ("spd_id must be set");
13876 M (IPSEC_SPD_ADD_DEL, mp);
13878 mp->spd_id = ntohl (spd_id);
13879 mp->is_add = is_add;
13887 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13889 unformat_input_t *i = vam->input;
13890 vl_api_ipsec_interface_add_del_spd_t *mp;
13892 u8 sw_if_index_set = 0;
13893 u32 spd_id = (u32) ~ 0;
13897 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13899 if (unformat (i, "del"))
13901 else if (unformat (i, "spd_id %d", &spd_id))
13904 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13905 sw_if_index_set = 1;
13906 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13907 sw_if_index_set = 1;
13910 clib_warning ("parse error '%U'", format_unformat_error, i);
13916 if (spd_id == (u32) ~ 0)
13918 errmsg ("spd_id must be set");
13922 if (sw_if_index_set == 0)
13924 errmsg ("missing interface name or sw_if_index");
13928 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13930 mp->spd_id = ntohl (spd_id);
13931 mp->sw_if_index = ntohl (sw_if_index);
13932 mp->is_add = is_add;
13940 api_ipsec_spd_add_del_entry (vat_main_t * vam)
13942 unformat_input_t *i = vam->input;
13943 vl_api_ipsec_spd_add_del_entry_t *mp;
13944 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
13945 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13947 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13948 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13949 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
13950 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
13953 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
13954 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
13955 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
13956 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
13957 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
13958 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
13960 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13962 if (unformat (i, "del"))
13964 if (unformat (i, "outbound"))
13966 if (unformat (i, "inbound"))
13968 else if (unformat (i, "spd_id %d", &spd_id))
13970 else if (unformat (i, "sa_id %d", &sa_id))
13972 else if (unformat (i, "priority %d", &priority))
13974 else if (unformat (i, "protocol %d", &protocol))
13976 else if (unformat (i, "lport_start %d", &lport_start))
13978 else if (unformat (i, "lport_stop %d", &lport_stop))
13980 else if (unformat (i, "rport_start %d", &rport_start))
13982 else if (unformat (i, "rport_stop %d", &rport_stop))
13986 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
13992 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
13999 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
14005 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
14012 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
14018 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
14025 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
14031 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
14037 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14039 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14041 clib_warning ("unsupported action: 'resolve'");
14047 clib_warning ("parse error '%U'", format_unformat_error, i);
14053 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
14055 mp->spd_id = ntohl (spd_id);
14056 mp->priority = ntohl (priority);
14057 mp->is_outbound = is_outbound;
14059 mp->is_ipv6 = is_ipv6;
14060 if (is_ipv6 || is_ip_any)
14062 clib_memcpy (mp->remote_address_start, &raddr6_start,
14063 sizeof (ip6_address_t));
14064 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
14065 sizeof (ip6_address_t));
14066 clib_memcpy (mp->local_address_start, &laddr6_start,
14067 sizeof (ip6_address_t));
14068 clib_memcpy (mp->local_address_stop, &laddr6_stop,
14069 sizeof (ip6_address_t));
14073 clib_memcpy (mp->remote_address_start, &raddr4_start,
14074 sizeof (ip4_address_t));
14075 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
14076 sizeof (ip4_address_t));
14077 clib_memcpy (mp->local_address_start, &laddr4_start,
14078 sizeof (ip4_address_t));
14079 clib_memcpy (mp->local_address_stop, &laddr4_stop,
14080 sizeof (ip4_address_t));
14082 mp->protocol = (u8) protocol;
14083 mp->local_port_start = ntohs ((u16) lport_start);
14084 mp->local_port_stop = ntohs ((u16) lport_stop);
14085 mp->remote_port_start = ntohs ((u16) rport_start);
14086 mp->remote_port_stop = ntohs ((u16) rport_stop);
14087 mp->policy = (u8) policy;
14088 mp->sa_id = ntohl (sa_id);
14089 mp->is_add = is_add;
14090 mp->is_ip_any = is_ip_any;
14097 api_ipsec_sad_add_del_entry (vat_main_t * vam)
14099 unformat_input_t *i = vam->input;
14100 vl_api_ipsec_sad_add_del_entry_t *mp;
14101 u32 sad_id = 0, spi = 0;
14102 u8 *ck = 0, *ik = 0;
14105 u8 protocol = IPSEC_PROTOCOL_AH;
14106 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
14107 u32 crypto_alg = 0, integ_alg = 0;
14108 ip4_address_t tun_src4;
14109 ip4_address_t tun_dst4;
14110 ip6_address_t tun_src6;
14111 ip6_address_t tun_dst6;
14114 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14116 if (unformat (i, "del"))
14118 else if (unformat (i, "sad_id %d", &sad_id))
14120 else if (unformat (i, "spi %d", &spi))
14122 else if (unformat (i, "esp"))
14123 protocol = IPSEC_PROTOCOL_ESP;
14124 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
14127 is_tunnel_ipv6 = 0;
14129 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
14132 is_tunnel_ipv6 = 0;
14134 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
14137 is_tunnel_ipv6 = 1;
14139 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
14142 is_tunnel_ipv6 = 1;
14146 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14148 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14149 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14151 clib_warning ("unsupported crypto-alg: '%U'",
14152 format_ipsec_crypto_alg, crypto_alg);
14156 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14160 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14162 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14163 integ_alg >= IPSEC_INTEG_N_ALG)
14165 clib_warning ("unsupported integ-alg: '%U'",
14166 format_ipsec_integ_alg, integ_alg);
14170 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14174 clib_warning ("parse error '%U'", format_unformat_error, i);
14180 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
14182 mp->sad_id = ntohl (sad_id);
14183 mp->is_add = is_add;
14184 mp->protocol = protocol;
14185 mp->spi = ntohl (spi);
14186 mp->is_tunnel = is_tunnel;
14187 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
14188 mp->crypto_algorithm = crypto_alg;
14189 mp->integrity_algorithm = integ_alg;
14190 mp->crypto_key_length = vec_len (ck);
14191 mp->integrity_key_length = vec_len (ik);
14193 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14194 mp->crypto_key_length = sizeof (mp->crypto_key);
14196 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14197 mp->integrity_key_length = sizeof (mp->integrity_key);
14200 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14202 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14206 if (is_tunnel_ipv6)
14208 clib_memcpy (mp->tunnel_src_address, &tun_src6,
14209 sizeof (ip6_address_t));
14210 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
14211 sizeof (ip6_address_t));
14215 clib_memcpy (mp->tunnel_src_address, &tun_src4,
14216 sizeof (ip4_address_t));
14217 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
14218 sizeof (ip4_address_t));
14228 api_ipsec_sa_set_key (vat_main_t * vam)
14230 unformat_input_t *i = vam->input;
14231 vl_api_ipsec_sa_set_key_t *mp;
14233 u8 *ck = 0, *ik = 0;
14236 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14238 if (unformat (i, "sa_id %d", &sa_id))
14240 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14242 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14246 clib_warning ("parse error '%U'", format_unformat_error, i);
14251 M (IPSEC_SA_SET_KEY, mp);
14253 mp->sa_id = ntohl (sa_id);
14254 mp->crypto_key_length = vec_len (ck);
14255 mp->integrity_key_length = vec_len (ik);
14257 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14258 mp->crypto_key_length = sizeof (mp->crypto_key);
14260 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14261 mp->integrity_key_length = sizeof (mp->integrity_key);
14264 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14266 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14274 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14276 unformat_input_t *i = vam->input;
14277 vl_api_ipsec_tunnel_if_add_del_t *mp;
14278 u32 local_spi = 0, remote_spi = 0;
14279 u32 crypto_alg = 0, integ_alg = 0;
14280 u8 *lck = NULL, *rck = NULL;
14281 u8 *lik = NULL, *rik = NULL;
14282 ip4_address_t local_ip = { {0} };
14283 ip4_address_t remote_ip = { {0} };
14286 u8 anti_replay = 0;
14289 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14291 if (unformat (i, "del"))
14293 else if (unformat (i, "esn"))
14295 else if (unformat (i, "anti_replay"))
14297 else if (unformat (i, "local_spi %d", &local_spi))
14299 else if (unformat (i, "remote_spi %d", &remote_spi))
14301 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
14303 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
14305 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14308 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14310 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14312 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14316 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14318 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14319 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14321 errmsg ("unsupported crypto-alg: '%U'\n",
14322 format_ipsec_crypto_alg, crypto_alg);
14328 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14330 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14331 integ_alg >= IPSEC_INTEG_N_ALG)
14333 errmsg ("unsupported integ-alg: '%U'\n",
14334 format_ipsec_integ_alg, integ_alg);
14340 errmsg ("parse error '%U'\n", format_unformat_error, i);
14345 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14347 mp->is_add = is_add;
14349 mp->anti_replay = anti_replay;
14351 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
14352 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
14354 mp->local_spi = htonl (local_spi);
14355 mp->remote_spi = htonl (remote_spi);
14356 mp->crypto_alg = (u8) crypto_alg;
14358 mp->local_crypto_key_len = 0;
14361 mp->local_crypto_key_len = vec_len (lck);
14362 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14363 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14364 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14367 mp->remote_crypto_key_len = 0;
14370 mp->remote_crypto_key_len = vec_len (rck);
14371 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14372 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14373 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14376 mp->integ_alg = (u8) integ_alg;
14378 mp->local_integ_key_len = 0;
14381 mp->local_integ_key_len = vec_len (lik);
14382 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14383 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14384 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14387 mp->remote_integ_key_len = 0;
14390 mp->remote_integ_key_len = vec_len (rik);
14391 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14392 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14393 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14402 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14404 vat_main_t *vam = &vat_main;
14406 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14407 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
14408 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
14409 "tunnel_src_addr %U tunnel_dst_addr %U "
14410 "salt %u seq_outbound %lu last_seq_inbound %lu "
14411 "replay_window %lu total_data_size %lu\n",
14412 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
14414 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
14415 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
14416 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
14417 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14418 mp->tunnel_src_addr,
14419 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14420 mp->tunnel_dst_addr,
14422 clib_net_to_host_u64 (mp->seq_outbound),
14423 clib_net_to_host_u64 (mp->last_seq_inbound),
14424 clib_net_to_host_u64 (mp->replay_window),
14425 clib_net_to_host_u64 (mp->total_data_size));
14428 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14429 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14431 static void vl_api_ipsec_sa_details_t_handler_json
14432 (vl_api_ipsec_sa_details_t * mp)
14434 vat_main_t *vam = &vat_main;
14435 vat_json_node_t *node = NULL;
14436 struct in_addr src_ip4, dst_ip4;
14437 struct in6_addr src_ip6, dst_ip6;
14439 if (VAT_JSON_ARRAY != vam->json_tree.type)
14441 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14442 vat_json_init_array (&vam->json_tree);
14444 node = vat_json_array_add (&vam->json_tree);
14446 vat_json_init_object (node);
14447 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
14448 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14449 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
14450 vat_json_object_add_uint (node, "proto", mp->protocol);
14451 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
14452 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
14453 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
14454 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
14455 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
14456 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
14457 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
14458 mp->crypto_key_len);
14459 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
14460 mp->integ_key_len);
14461 if (mp->is_tunnel_ip6)
14463 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
14464 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
14465 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
14466 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
14470 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
14471 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
14472 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
14473 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
14475 vat_json_object_add_uint (node, "replay_window",
14476 clib_net_to_host_u64 (mp->replay_window));
14477 vat_json_object_add_uint (node, "total_data_size",
14478 clib_net_to_host_u64 (mp->total_data_size));
14483 api_ipsec_sa_dump (vat_main_t * vam)
14485 unformat_input_t *i = vam->input;
14486 vl_api_ipsec_sa_dump_t *mp;
14487 vl_api_control_ping_t *mp_ping;
14491 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14493 if (unformat (i, "sa_id %d", &sa_id))
14497 clib_warning ("parse error '%U'", format_unformat_error, i);
14502 M (IPSEC_SA_DUMP, mp);
14504 mp->sa_id = ntohl (sa_id);
14508 /* Use a control ping for synchronization */
14509 M (CONTROL_PING, mp_ping);
14517 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
14519 unformat_input_t *i = vam->input;
14520 vl_api_ipsec_tunnel_if_set_key_t *mp;
14521 u32 sw_if_index = ~0;
14522 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
14527 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14529 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14532 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
14533 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
14535 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
14536 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
14537 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
14538 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
14540 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
14541 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
14542 else if (unformat (i, "%U", unformat_hex_string, &key))
14546 clib_warning ("parse error '%U'", format_unformat_error, i);
14551 if (sw_if_index == ~0)
14553 errmsg ("interface must be specified");
14557 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
14559 errmsg ("key type must be specified");
14565 errmsg ("algorithm must be specified");
14569 if (vec_len (key) == 0)
14571 errmsg ("key must be specified");
14575 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
14577 mp->sw_if_index = htonl (sw_if_index);
14579 mp->key_type = key_type;
14580 mp->key_len = vec_len (key);
14581 clib_memcpy (mp->key, key, vec_len (key));
14590 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
14592 unformat_input_t *i = vam->input;
14593 vl_api_ipsec_tunnel_if_set_sa_t *mp;
14594 u32 sw_if_index = ~0;
14596 u8 is_outbound = (u8) ~ 0;
14599 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14601 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14603 else if (unformat (i, "sa_id %d", &sa_id))
14605 else if (unformat (i, "outbound"))
14607 else if (unformat (i, "inbound"))
14611 clib_warning ("parse error '%U'", format_unformat_error, i);
14616 if (sw_if_index == ~0)
14618 errmsg ("interface must be specified");
14624 errmsg ("SA ID must be specified");
14628 M (IPSEC_TUNNEL_IF_SET_SA, mp);
14630 mp->sw_if_index = htonl (sw_if_index);
14631 mp->sa_id = htonl (sa_id);
14632 mp->is_outbound = is_outbound;
14641 api_ikev2_profile_add_del (vat_main_t * vam)
14643 unformat_input_t *i = vam->input;
14644 vl_api_ikev2_profile_add_del_t *mp;
14649 const char *valid_chars = "a-zA-Z0-9_";
14651 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14653 if (unformat (i, "del"))
14655 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14656 vec_add1 (name, 0);
14659 errmsg ("parse error '%U'", format_unformat_error, i);
14664 if (!vec_len (name))
14666 errmsg ("profile name must be specified");
14670 if (vec_len (name) > 64)
14672 errmsg ("profile name too long");
14676 M (IKEV2_PROFILE_ADD_DEL, mp);
14678 clib_memcpy (mp->name, name, vec_len (name));
14679 mp->is_add = is_add;
14688 api_ikev2_profile_set_auth (vat_main_t * vam)
14690 unformat_input_t *i = vam->input;
14691 vl_api_ikev2_profile_set_auth_t *mp;
14694 u32 auth_method = 0;
14698 const char *valid_chars = "a-zA-Z0-9_";
14700 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14702 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14703 vec_add1 (name, 0);
14704 else if (unformat (i, "auth_method %U",
14705 unformat_ikev2_auth_method, &auth_method))
14707 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
14709 else if (unformat (i, "auth_data %v", &data))
14713 errmsg ("parse error '%U'", format_unformat_error, i);
14718 if (!vec_len (name))
14720 errmsg ("profile name must be specified");
14724 if (vec_len (name) > 64)
14726 errmsg ("profile name too long");
14730 if (!vec_len (data))
14732 errmsg ("auth_data must be specified");
14738 errmsg ("auth_method must be specified");
14742 M (IKEV2_PROFILE_SET_AUTH, mp);
14744 mp->is_hex = is_hex;
14745 mp->auth_method = (u8) auth_method;
14746 mp->data_len = vec_len (data);
14747 clib_memcpy (mp->name, name, vec_len (name));
14748 clib_memcpy (mp->data, data, vec_len (data));
14758 api_ikev2_profile_set_id (vat_main_t * vam)
14760 unformat_input_t *i = vam->input;
14761 vl_api_ikev2_profile_set_id_t *mp;
14769 const char *valid_chars = "a-zA-Z0-9_";
14771 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14773 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14774 vec_add1 (name, 0);
14775 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
14777 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
14779 data = vec_new (u8, 4);
14780 clib_memcpy (data, ip4.as_u8, 4);
14782 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
14784 else if (unformat (i, "id_data %v", &data))
14786 else if (unformat (i, "local"))
14788 else if (unformat (i, "remote"))
14792 errmsg ("parse error '%U'", format_unformat_error, i);
14797 if (!vec_len (name))
14799 errmsg ("profile name must be specified");
14803 if (vec_len (name) > 64)
14805 errmsg ("profile name too long");
14809 if (!vec_len (data))
14811 errmsg ("id_data must be specified");
14817 errmsg ("id_type must be specified");
14821 M (IKEV2_PROFILE_SET_ID, mp);
14823 mp->is_local = is_local;
14824 mp->id_type = (u8) id_type;
14825 mp->data_len = vec_len (data);
14826 clib_memcpy (mp->name, name, vec_len (name));
14827 clib_memcpy (mp->data, data, vec_len (data));
14837 api_ikev2_profile_set_ts (vat_main_t * vam)
14839 unformat_input_t *i = vam->input;
14840 vl_api_ikev2_profile_set_ts_t *mp;
14843 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
14844 ip4_address_t start_addr, end_addr;
14846 const char *valid_chars = "a-zA-Z0-9_";
14849 start_addr.as_u32 = 0;
14850 end_addr.as_u32 = (u32) ~ 0;
14852 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14854 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14855 vec_add1 (name, 0);
14856 else if (unformat (i, "protocol %d", &proto))
14858 else if (unformat (i, "start_port %d", &start_port))
14860 else if (unformat (i, "end_port %d", &end_port))
14863 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
14865 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
14867 else if (unformat (i, "local"))
14869 else if (unformat (i, "remote"))
14873 errmsg ("parse error '%U'", format_unformat_error, i);
14878 if (!vec_len (name))
14880 errmsg ("profile name must be specified");
14884 if (vec_len (name) > 64)
14886 errmsg ("profile name too long");
14890 M (IKEV2_PROFILE_SET_TS, mp);
14892 mp->is_local = is_local;
14893 mp->proto = (u8) proto;
14894 mp->start_port = (u16) start_port;
14895 mp->end_port = (u16) end_port;
14896 mp->start_addr = start_addr.as_u32;
14897 mp->end_addr = end_addr.as_u32;
14898 clib_memcpy (mp->name, name, vec_len (name));
14907 api_ikev2_set_local_key (vat_main_t * vam)
14909 unformat_input_t *i = vam->input;
14910 vl_api_ikev2_set_local_key_t *mp;
14914 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14916 if (unformat (i, "file %v", &file))
14917 vec_add1 (file, 0);
14920 errmsg ("parse error '%U'", format_unformat_error, i);
14925 if (!vec_len (file))
14927 errmsg ("RSA key file must be specified");
14931 if (vec_len (file) > 256)
14933 errmsg ("file name too long");
14937 M (IKEV2_SET_LOCAL_KEY, mp);
14939 clib_memcpy (mp->key_file, file, vec_len (file));
14948 api_ikev2_set_responder (vat_main_t * vam)
14950 unformat_input_t *i = vam->input;
14951 vl_api_ikev2_set_responder_t *mp;
14954 u32 sw_if_index = ~0;
14955 ip4_address_t address;
14957 const char *valid_chars = "a-zA-Z0-9_";
14959 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14962 (i, "%U interface %d address %U", unformat_token, valid_chars,
14963 &name, &sw_if_index, unformat_ip4_address, &address))
14964 vec_add1 (name, 0);
14967 errmsg ("parse error '%U'", format_unformat_error, i);
14972 if (!vec_len (name))
14974 errmsg ("profile name must be specified");
14978 if (vec_len (name) > 64)
14980 errmsg ("profile name too long");
14984 M (IKEV2_SET_RESPONDER, mp);
14986 clib_memcpy (mp->name, name, vec_len (name));
14989 mp->sw_if_index = sw_if_index;
14990 clib_memcpy (mp->address, &address, sizeof (address));
14998 api_ikev2_set_ike_transforms (vat_main_t * vam)
15000 unformat_input_t *i = vam->input;
15001 vl_api_ikev2_set_ike_transforms_t *mp;
15004 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15006 const char *valid_chars = "a-zA-Z0-9_";
15008 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15010 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15011 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15012 vec_add1 (name, 0);
15015 errmsg ("parse error '%U'", format_unformat_error, i);
15020 if (!vec_len (name))
15022 errmsg ("profile name must be specified");
15026 if (vec_len (name) > 64)
15028 errmsg ("profile name too long");
15032 M (IKEV2_SET_IKE_TRANSFORMS, mp);
15034 clib_memcpy (mp->name, name, vec_len (name));
15036 mp->crypto_alg = crypto_alg;
15037 mp->crypto_key_size = crypto_key_size;
15038 mp->integ_alg = integ_alg;
15039 mp->dh_group = dh_group;
15048 api_ikev2_set_esp_transforms (vat_main_t * vam)
15050 unformat_input_t *i = vam->input;
15051 vl_api_ikev2_set_esp_transforms_t *mp;
15054 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15056 const char *valid_chars = "a-zA-Z0-9_";
15058 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15060 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15061 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15062 vec_add1 (name, 0);
15065 errmsg ("parse error '%U'", format_unformat_error, i);
15070 if (!vec_len (name))
15072 errmsg ("profile name must be specified");
15076 if (vec_len (name) > 64)
15078 errmsg ("profile name too long");
15082 M (IKEV2_SET_ESP_TRANSFORMS, mp);
15084 clib_memcpy (mp->name, name, vec_len (name));
15086 mp->crypto_alg = crypto_alg;
15087 mp->crypto_key_size = crypto_key_size;
15088 mp->integ_alg = integ_alg;
15089 mp->dh_group = dh_group;
15097 api_ikev2_set_sa_lifetime (vat_main_t * vam)
15099 unformat_input_t *i = vam->input;
15100 vl_api_ikev2_set_sa_lifetime_t *mp;
15103 u64 lifetime, lifetime_maxdata;
15104 u32 lifetime_jitter, handover;
15106 const char *valid_chars = "a-zA-Z0-9_";
15108 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15110 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
15111 &lifetime, &lifetime_jitter, &handover,
15112 &lifetime_maxdata))
15113 vec_add1 (name, 0);
15116 errmsg ("parse error '%U'", format_unformat_error, i);
15121 if (!vec_len (name))
15123 errmsg ("profile name must be specified");
15127 if (vec_len (name) > 64)
15129 errmsg ("profile name too long");
15133 M (IKEV2_SET_SA_LIFETIME, mp);
15135 clib_memcpy (mp->name, name, vec_len (name));
15137 mp->lifetime = lifetime;
15138 mp->lifetime_jitter = lifetime_jitter;
15139 mp->handover = handover;
15140 mp->lifetime_maxdata = lifetime_maxdata;
15148 api_ikev2_initiate_sa_init (vat_main_t * vam)
15150 unformat_input_t *i = vam->input;
15151 vl_api_ikev2_initiate_sa_init_t *mp;
15155 const char *valid_chars = "a-zA-Z0-9_";
15157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15159 if (unformat (i, "%U", unformat_token, valid_chars, &name))
15160 vec_add1 (name, 0);
15163 errmsg ("parse error '%U'", format_unformat_error, i);
15168 if (!vec_len (name))
15170 errmsg ("profile name must be specified");
15174 if (vec_len (name) > 64)
15176 errmsg ("profile name too long");
15180 M (IKEV2_INITIATE_SA_INIT, mp);
15182 clib_memcpy (mp->name, name, vec_len (name));
15191 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
15193 unformat_input_t *i = vam->input;
15194 vl_api_ikev2_initiate_del_ike_sa_t *mp;
15199 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15201 if (unformat (i, "%lx", &ispi))
15205 errmsg ("parse error '%U'", format_unformat_error, i);
15210 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
15220 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
15222 unformat_input_t *i = vam->input;
15223 vl_api_ikev2_initiate_del_child_sa_t *mp;
15228 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15230 if (unformat (i, "%x", &ispi))
15234 errmsg ("parse error '%U'", format_unformat_error, i);
15239 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
15249 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
15251 unformat_input_t *i = vam->input;
15252 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
15257 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15259 if (unformat (i, "%x", &ispi))
15263 errmsg ("parse error '%U'", format_unformat_error, i);
15268 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
15281 api_map_add_domain (vat_main_t * vam)
15283 unformat_input_t *i = vam->input;
15284 vl_api_map_add_domain_t *mp;
15286 ip4_address_t ip4_prefix;
15287 ip6_address_t ip6_prefix;
15288 ip6_address_t ip6_src;
15289 u32 num_m_args = 0;
15290 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
15291 0, psid_length = 0;
15292 u8 is_translation = 0;
15294 u32 ip6_src_len = 128;
15297 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15299 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
15300 &ip4_prefix, &ip4_prefix_len))
15302 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
15303 &ip6_prefix, &ip6_prefix_len))
15307 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
15310 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
15312 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
15314 else if (unformat (i, "psid-offset %d", &psid_offset))
15316 else if (unformat (i, "psid-len %d", &psid_length))
15318 else if (unformat (i, "mtu %d", &mtu))
15320 else if (unformat (i, "map-t"))
15321 is_translation = 1;
15324 clib_warning ("parse error '%U'", format_unformat_error, i);
15329 if (num_m_args < 3)
15331 errmsg ("mandatory argument(s) missing");
15335 /* Construct the API message */
15336 M (MAP_ADD_DOMAIN, mp);
15338 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
15339 mp->ip4_prefix_len = ip4_prefix_len;
15341 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
15342 mp->ip6_prefix_len = ip6_prefix_len;
15344 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
15345 mp->ip6_src_prefix_len = ip6_src_len;
15347 mp->ea_bits_len = ea_bits_len;
15348 mp->psid_offset = psid_offset;
15349 mp->psid_length = psid_length;
15350 mp->is_translation = is_translation;
15351 mp->mtu = htons (mtu);
15356 /* Wait for a reply, return good/bad news */
15362 api_map_del_domain (vat_main_t * vam)
15364 unformat_input_t *i = vam->input;
15365 vl_api_map_del_domain_t *mp;
15367 u32 num_m_args = 0;
15371 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15373 if (unformat (i, "index %d", &index))
15377 clib_warning ("parse error '%U'", format_unformat_error, i);
15382 if (num_m_args != 1)
15384 errmsg ("mandatory argument(s) missing");
15388 /* Construct the API message */
15389 M (MAP_DEL_DOMAIN, mp);
15391 mp->index = ntohl (index);
15396 /* Wait for a reply, return good/bad news */
15402 api_map_add_del_rule (vat_main_t * vam)
15404 unformat_input_t *i = vam->input;
15405 vl_api_map_add_del_rule_t *mp;
15407 ip6_address_t ip6_dst;
15408 u32 num_m_args = 0, index, psid = 0;
15411 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15413 if (unformat (i, "index %d", &index))
15415 else if (unformat (i, "psid %d", &psid))
15417 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
15419 else if (unformat (i, "del"))
15425 clib_warning ("parse error '%U'", format_unformat_error, i);
15430 /* Construct the API message */
15431 M (MAP_ADD_DEL_RULE, mp);
15433 mp->index = ntohl (index);
15434 mp->is_add = is_add;
15435 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
15436 mp->psid = ntohs (psid);
15441 /* Wait for a reply, return good/bad news */
15447 api_map_domain_dump (vat_main_t * vam)
15449 vl_api_map_domain_dump_t *mp;
15450 vl_api_control_ping_t *mp_ping;
15453 /* Construct the API message */
15454 M (MAP_DOMAIN_DUMP, mp);
15459 /* Use a control ping for synchronization */
15460 MPING (CONTROL_PING, mp_ping);
15468 api_map_rule_dump (vat_main_t * vam)
15470 unformat_input_t *i = vam->input;
15471 vl_api_map_rule_dump_t *mp;
15472 vl_api_control_ping_t *mp_ping;
15473 u32 domain_index = ~0;
15476 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15478 if (unformat (i, "index %u", &domain_index))
15484 if (domain_index == ~0)
15486 clib_warning ("parse error: domain index expected");
15490 /* Construct the API message */
15491 M (MAP_RULE_DUMP, mp);
15493 mp->domain_index = htonl (domain_index);
15498 /* Use a control ping for synchronization */
15499 MPING (CONTROL_PING, mp_ping);
15506 static void vl_api_map_add_domain_reply_t_handler
15507 (vl_api_map_add_domain_reply_t * mp)
15509 vat_main_t *vam = &vat_main;
15510 i32 retval = ntohl (mp->retval);
15512 if (vam->async_mode)
15514 vam->async_errors += (retval < 0);
15518 vam->retval = retval;
15519 vam->result_ready = 1;
15523 static void vl_api_map_add_domain_reply_t_handler_json
15524 (vl_api_map_add_domain_reply_t * mp)
15526 vat_main_t *vam = &vat_main;
15527 vat_json_node_t node;
15529 vat_json_init_object (&node);
15530 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
15531 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
15533 vat_json_print (vam->ofp, &node);
15534 vat_json_free (&node);
15536 vam->retval = ntohl (mp->retval);
15537 vam->result_ready = 1;
15541 api_get_first_msg_id (vat_main_t * vam)
15543 vl_api_get_first_msg_id_t *mp;
15544 unformat_input_t *i = vam->input;
15549 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15551 if (unformat (i, "client %s", &name))
15559 errmsg ("missing client name");
15562 vec_add1 (name, 0);
15564 if (vec_len (name) > 63)
15566 errmsg ("client name too long");
15570 M (GET_FIRST_MSG_ID, mp);
15571 clib_memcpy (mp->name, name, vec_len (name));
15578 api_cop_interface_enable_disable (vat_main_t * vam)
15580 unformat_input_t *line_input = vam->input;
15581 vl_api_cop_interface_enable_disable_t *mp;
15582 u32 sw_if_index = ~0;
15583 u8 enable_disable = 1;
15586 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15588 if (unformat (line_input, "disable"))
15589 enable_disable = 0;
15590 if (unformat (line_input, "enable"))
15591 enable_disable = 1;
15592 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15593 vam, &sw_if_index))
15595 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15601 if (sw_if_index == ~0)
15603 errmsg ("missing interface name or sw_if_index");
15607 /* Construct the API message */
15608 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15609 mp->sw_if_index = ntohl (sw_if_index);
15610 mp->enable_disable = enable_disable;
15614 /* Wait for the reply */
15620 api_cop_whitelist_enable_disable (vat_main_t * vam)
15622 unformat_input_t *line_input = vam->input;
15623 vl_api_cop_whitelist_enable_disable_t *mp;
15624 u32 sw_if_index = ~0;
15625 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15629 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15631 if (unformat (line_input, "ip4"))
15633 else if (unformat (line_input, "ip6"))
15635 else if (unformat (line_input, "default"))
15637 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15638 vam, &sw_if_index))
15640 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15642 else if (unformat (line_input, "fib-id %d", &fib_id))
15648 if (sw_if_index == ~0)
15650 errmsg ("missing interface name or sw_if_index");
15654 /* Construct the API message */
15655 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15656 mp->sw_if_index = ntohl (sw_if_index);
15657 mp->fib_id = ntohl (fib_id);
15660 mp->default_cop = default_cop;
15664 /* Wait for the reply */
15670 api_get_node_graph (vat_main_t * vam)
15672 vl_api_get_node_graph_t *mp;
15675 M (GET_NODE_GRAPH, mp);
15679 /* Wait for the reply */
15685 /** Used for parsing LISP eids */
15686 typedef CLIB_PACKED(struct{
15687 u8 addr[16]; /**< eid address */
15688 u32 len; /**< prefix length if IP */
15689 u8 type; /**< type of eid */
15694 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15696 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15698 memset (a, 0, sizeof (a[0]));
15700 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15702 a->type = 0; /* ipv4 type */
15704 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15706 a->type = 1; /* ipv6 type */
15708 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15710 a->type = 2; /* mac type */
15712 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15714 a->type = 3; /* NSH type */
15715 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15716 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15723 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15732 lisp_eid_size_vat (u8 type)
15749 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15751 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15755 api_one_add_del_locator_set (vat_main_t * vam)
15757 unformat_input_t *input = vam->input;
15758 vl_api_one_add_del_locator_set_t *mp;
15760 u8 *locator_set_name = NULL;
15761 u8 locator_set_name_set = 0;
15762 vl_api_local_locator_t locator, *locators = 0;
15763 u32 sw_if_index, priority, weight;
15767 /* Parse args required to build the message */
15768 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15770 if (unformat (input, "del"))
15774 else if (unformat (input, "locator-set %s", &locator_set_name))
15776 locator_set_name_set = 1;
15778 else if (unformat (input, "sw_if_index %u p %u w %u",
15779 &sw_if_index, &priority, &weight))
15781 locator.sw_if_index = htonl (sw_if_index);
15782 locator.priority = priority;
15783 locator.weight = weight;
15784 vec_add1 (locators, locator);
15788 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15789 &sw_if_index, &priority, &weight))
15791 locator.sw_if_index = htonl (sw_if_index);
15792 locator.priority = priority;
15793 locator.weight = weight;
15794 vec_add1 (locators, locator);
15800 if (locator_set_name_set == 0)
15802 errmsg ("missing locator-set name");
15803 vec_free (locators);
15807 if (vec_len (locator_set_name) > 64)
15809 errmsg ("locator-set name too long");
15810 vec_free (locator_set_name);
15811 vec_free (locators);
15814 vec_add1 (locator_set_name, 0);
15816 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15818 /* Construct the API message */
15819 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15821 mp->is_add = is_add;
15822 clib_memcpy (mp->locator_set_name, locator_set_name,
15823 vec_len (locator_set_name));
15824 vec_free (locator_set_name);
15826 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15828 clib_memcpy (mp->locators, locators, data_len);
15829 vec_free (locators);
15834 /* Wait for a reply... */
15839 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15842 api_one_add_del_locator (vat_main_t * vam)
15844 unformat_input_t *input = vam->input;
15845 vl_api_one_add_del_locator_t *mp;
15846 u32 tmp_if_index = ~0;
15847 u32 sw_if_index = ~0;
15848 u8 sw_if_index_set = 0;
15849 u8 sw_if_index_if_name_set = 0;
15851 u8 priority_set = 0;
15855 u8 *locator_set_name = NULL;
15856 u8 locator_set_name_set = 0;
15859 /* Parse args required to build the message */
15860 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15862 if (unformat (input, "del"))
15866 else if (unformat (input, "locator-set %s", &locator_set_name))
15868 locator_set_name_set = 1;
15870 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15873 sw_if_index_if_name_set = 1;
15874 sw_if_index = tmp_if_index;
15876 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15878 sw_if_index_set = 1;
15879 sw_if_index = tmp_if_index;
15881 else if (unformat (input, "p %d", &priority))
15885 else if (unformat (input, "w %d", &weight))
15893 if (locator_set_name_set == 0)
15895 errmsg ("missing locator-set name");
15899 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15901 errmsg ("missing sw_if_index");
15902 vec_free (locator_set_name);
15906 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15908 errmsg ("cannot use both params interface name and sw_if_index");
15909 vec_free (locator_set_name);
15913 if (priority_set == 0)
15915 errmsg ("missing locator-set priority");
15916 vec_free (locator_set_name);
15920 if (weight_set == 0)
15922 errmsg ("missing locator-set weight");
15923 vec_free (locator_set_name);
15927 if (vec_len (locator_set_name) > 64)
15929 errmsg ("locator-set name too long");
15930 vec_free (locator_set_name);
15933 vec_add1 (locator_set_name, 0);
15935 /* Construct the API message */
15936 M (ONE_ADD_DEL_LOCATOR, mp);
15938 mp->is_add = is_add;
15939 mp->sw_if_index = ntohl (sw_if_index);
15940 mp->priority = priority;
15941 mp->weight = weight;
15942 clib_memcpy (mp->locator_set_name, locator_set_name,
15943 vec_len (locator_set_name));
15944 vec_free (locator_set_name);
15949 /* Wait for a reply... */
15954 #define api_lisp_add_del_locator api_one_add_del_locator
15957 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15959 u32 *key_id = va_arg (*args, u32 *);
15962 if (unformat (input, "%s", &s))
15964 if (!strcmp ((char *) s, "sha1"))
15965 key_id[0] = HMAC_SHA_1_96;
15966 else if (!strcmp ((char *) s, "sha256"))
15967 key_id[0] = HMAC_SHA_256_128;
15970 clib_warning ("invalid key_id: '%s'", s);
15971 key_id[0] = HMAC_NO_KEY;
15982 api_one_add_del_local_eid (vat_main_t * vam)
15984 unformat_input_t *input = vam->input;
15985 vl_api_one_add_del_local_eid_t *mp;
15988 lisp_eid_vat_t _eid, *eid = &_eid;
15989 u8 *locator_set_name = 0;
15990 u8 locator_set_name_set = 0;
15996 /* Parse args required to build the message */
15997 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15999 if (unformat (input, "del"))
16003 else if (unformat (input, "vni %d", &vni))
16007 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16011 else if (unformat (input, "locator-set %s", &locator_set_name))
16013 locator_set_name_set = 1;
16015 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
16017 else if (unformat (input, "secret-key %_%v%_", &key))
16023 if (locator_set_name_set == 0)
16025 errmsg ("missing locator-set name");
16031 errmsg ("EID address not set!");
16032 vec_free (locator_set_name);
16036 if (key && (0 == key_id))
16038 errmsg ("invalid key_id!");
16042 if (vec_len (key) > 64)
16044 errmsg ("key too long");
16049 if (vec_len (locator_set_name) > 64)
16051 errmsg ("locator-set name too long");
16052 vec_free (locator_set_name);
16055 vec_add1 (locator_set_name, 0);
16057 /* Construct the API message */
16058 M (ONE_ADD_DEL_LOCAL_EID, mp);
16060 mp->is_add = is_add;
16061 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16062 mp->eid_type = eid->type;
16063 mp->prefix_len = eid->len;
16064 mp->vni = clib_host_to_net_u32 (vni);
16065 mp->key_id = clib_host_to_net_u16 (key_id);
16066 clib_memcpy (mp->locator_set_name, locator_set_name,
16067 vec_len (locator_set_name));
16068 clib_memcpy (mp->key, key, vec_len (key));
16070 vec_free (locator_set_name);
16076 /* Wait for a reply... */
16081 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
16084 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
16086 u32 dp_table = 0, vni = 0;;
16087 unformat_input_t *input = vam->input;
16088 vl_api_gpe_add_del_fwd_entry_t *mp;
16090 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
16091 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
16092 u8 rmt_eid_set = 0, lcl_eid_set = 0;
16093 u32 action = ~0, w;
16094 ip4_address_t rmt_rloc4, lcl_rloc4;
16095 ip6_address_t rmt_rloc6, lcl_rloc6;
16096 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
16099 memset (&rloc, 0, sizeof (rloc));
16101 /* Parse args required to build the message */
16102 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16104 if (unformat (input, "del"))
16106 else if (unformat (input, "add"))
16108 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
16112 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
16116 else if (unformat (input, "vrf %d", &dp_table))
16118 else if (unformat (input, "bd %d", &dp_table))
16120 else if (unformat (input, "vni %d", &vni))
16122 else if (unformat (input, "w %d", &w))
16126 errmsg ("No RLOC configured for setting priority/weight!");
16129 curr_rloc->weight = w;
16131 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
16132 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
16136 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
16138 vec_add1 (lcl_locs, rloc);
16140 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
16141 vec_add1 (rmt_locs, rloc);
16142 /* weight saved in rmt loc */
16143 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16145 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
16146 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
16149 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
16151 vec_add1 (lcl_locs, rloc);
16153 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
16154 vec_add1 (rmt_locs, rloc);
16155 /* weight saved in rmt loc */
16156 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16158 else if (unformat (input, "action %d", &action))
16164 clib_warning ("parse error '%U'", format_unformat_error, input);
16171 errmsg ("remote eid addresses not set");
16175 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
16177 errmsg ("eid types don't match");
16181 if (0 == rmt_locs && (u32) ~ 0 == action)
16183 errmsg ("action not set for negative mapping");
16187 /* Construct the API message */
16188 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
16189 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
16191 mp->is_add = is_add;
16192 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
16193 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
16194 mp->eid_type = rmt_eid->type;
16195 mp->dp_table = clib_host_to_net_u32 (dp_table);
16196 mp->vni = clib_host_to_net_u32 (vni);
16197 mp->rmt_len = rmt_eid->len;
16198 mp->lcl_len = lcl_eid->len;
16199 mp->action = action;
16201 if (0 != rmt_locs && 0 != lcl_locs)
16203 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
16204 clib_memcpy (mp->locs, lcl_locs,
16205 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
16207 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
16208 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
16209 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
16211 vec_free (lcl_locs);
16212 vec_free (rmt_locs);
16217 /* Wait for a reply... */
16223 api_one_add_del_map_server (vat_main_t * vam)
16225 unformat_input_t *input = vam->input;
16226 vl_api_one_add_del_map_server_t *mp;
16230 ip4_address_t ipv4;
16231 ip6_address_t ipv6;
16234 /* Parse args required to build the message */
16235 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16237 if (unformat (input, "del"))
16241 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16245 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16253 if (ipv4_set && ipv6_set)
16255 errmsg ("both eid v4 and v6 addresses set");
16259 if (!ipv4_set && !ipv6_set)
16261 errmsg ("eid addresses not set");
16265 /* Construct the API message */
16266 M (ONE_ADD_DEL_MAP_SERVER, mp);
16268 mp->is_add = is_add;
16272 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16277 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16283 /* Wait for a reply... */
16288 #define api_lisp_add_del_map_server api_one_add_del_map_server
16291 api_one_add_del_map_resolver (vat_main_t * vam)
16293 unformat_input_t *input = vam->input;
16294 vl_api_one_add_del_map_resolver_t *mp;
16298 ip4_address_t ipv4;
16299 ip6_address_t ipv6;
16302 /* Parse args required to build the message */
16303 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16305 if (unformat (input, "del"))
16309 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16313 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16321 if (ipv4_set && ipv6_set)
16323 errmsg ("both eid v4 and v6 addresses set");
16327 if (!ipv4_set && !ipv6_set)
16329 errmsg ("eid addresses not set");
16333 /* Construct the API message */
16334 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
16336 mp->is_add = is_add;
16340 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16345 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16351 /* Wait for a reply... */
16356 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
16359 api_lisp_gpe_enable_disable (vat_main_t * vam)
16361 unformat_input_t *input = vam->input;
16362 vl_api_gpe_enable_disable_t *mp;
16367 /* Parse args required to build the message */
16368 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16370 if (unformat (input, "enable"))
16375 else if (unformat (input, "disable"))
16386 errmsg ("Value not set");
16390 /* Construct the API message */
16391 M (GPE_ENABLE_DISABLE, mp);
16398 /* Wait for a reply... */
16404 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16406 unformat_input_t *input = vam->input;
16407 vl_api_one_rloc_probe_enable_disable_t *mp;
16412 /* Parse args required to build the message */
16413 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16415 if (unformat (input, "enable"))
16420 else if (unformat (input, "disable"))
16428 errmsg ("Value not set");
16432 /* Construct the API message */
16433 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16435 mp->is_enabled = is_en;
16440 /* Wait for a reply... */
16445 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16448 api_one_map_register_enable_disable (vat_main_t * vam)
16450 unformat_input_t *input = vam->input;
16451 vl_api_one_map_register_enable_disable_t *mp;
16456 /* Parse args required to build the message */
16457 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16459 if (unformat (input, "enable"))
16464 else if (unformat (input, "disable"))
16472 errmsg ("Value not set");
16476 /* Construct the API message */
16477 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16479 mp->is_enabled = is_en;
16484 /* Wait for a reply... */
16489 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16492 api_one_enable_disable (vat_main_t * vam)
16494 unformat_input_t *input = vam->input;
16495 vl_api_one_enable_disable_t *mp;
16500 /* Parse args required to build the message */
16501 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16503 if (unformat (input, "enable"))
16508 else if (unformat (input, "disable"))
16518 errmsg ("Value not set");
16522 /* Construct the API message */
16523 M (ONE_ENABLE_DISABLE, mp);
16530 /* Wait for a reply... */
16535 #define api_lisp_enable_disable api_one_enable_disable
16538 api_one_enable_disable_xtr_mode (vat_main_t * vam)
16540 unformat_input_t *input = vam->input;
16541 vl_api_one_enable_disable_xtr_mode_t *mp;
16546 /* Parse args required to build the message */
16547 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16549 if (unformat (input, "enable"))
16554 else if (unformat (input, "disable"))
16564 errmsg ("Value not set");
16568 /* Construct the API message */
16569 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
16576 /* Wait for a reply... */
16582 api_one_show_xtr_mode (vat_main_t * vam)
16584 vl_api_one_show_xtr_mode_t *mp;
16587 /* Construct the API message */
16588 M (ONE_SHOW_XTR_MODE, mp);
16593 /* Wait for a reply... */
16599 api_one_enable_disable_pitr_mode (vat_main_t * vam)
16601 unformat_input_t *input = vam->input;
16602 vl_api_one_enable_disable_pitr_mode_t *mp;
16607 /* Parse args required to build the message */
16608 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16610 if (unformat (input, "enable"))
16615 else if (unformat (input, "disable"))
16625 errmsg ("Value not set");
16629 /* Construct the API message */
16630 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
16637 /* Wait for a reply... */
16643 api_one_show_pitr_mode (vat_main_t * vam)
16645 vl_api_one_show_pitr_mode_t *mp;
16648 /* Construct the API message */
16649 M (ONE_SHOW_PITR_MODE, mp);
16654 /* Wait for a reply... */
16660 api_one_enable_disable_petr_mode (vat_main_t * vam)
16662 unformat_input_t *input = vam->input;
16663 vl_api_one_enable_disable_petr_mode_t *mp;
16668 /* Parse args required to build the message */
16669 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16671 if (unformat (input, "enable"))
16676 else if (unformat (input, "disable"))
16686 errmsg ("Value not set");
16690 /* Construct the API message */
16691 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
16698 /* Wait for a reply... */
16704 api_one_show_petr_mode (vat_main_t * vam)
16706 vl_api_one_show_petr_mode_t *mp;
16709 /* Construct the API message */
16710 M (ONE_SHOW_PETR_MODE, mp);
16715 /* Wait for a reply... */
16721 api_show_one_map_register_state (vat_main_t * vam)
16723 vl_api_show_one_map_register_state_t *mp;
16726 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16731 /* wait for reply */
16736 #define api_show_lisp_map_register_state api_show_one_map_register_state
16739 api_show_one_rloc_probe_state (vat_main_t * vam)
16741 vl_api_show_one_rloc_probe_state_t *mp;
16744 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16749 /* wait for reply */
16754 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16757 api_one_add_del_ndp_entry (vat_main_t * vam)
16759 vl_api_one_add_del_ndp_entry_t *mp;
16760 unformat_input_t *input = vam->input;
16765 u8 mac[6] = { 0, };
16766 u8 ip6[16] = { 0, };
16770 /* Parse args required to build the message */
16771 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16773 if (unformat (input, "del"))
16775 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16777 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16779 else if (unformat (input, "bd %d", &bd))
16783 errmsg ("parse error '%U'", format_unformat_error, input);
16788 if (!bd_set || !ip_set || (!mac_set && is_add))
16790 errmsg ("Missing BD, IP or MAC!");
16794 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16795 mp->is_add = is_add;
16796 clib_memcpy (mp->mac, mac, 6);
16797 mp->bd = clib_host_to_net_u32 (bd);
16798 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16803 /* wait for reply */
16809 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16811 vl_api_one_add_del_l2_arp_entry_t *mp;
16812 unformat_input_t *input = vam->input;
16817 u8 mac[6] = { 0, };
16818 u32 ip4 = 0, bd = ~0;
16821 /* Parse args required to build the message */
16822 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16824 if (unformat (input, "del"))
16826 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16828 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16830 else if (unformat (input, "bd %d", &bd))
16834 errmsg ("parse error '%U'", format_unformat_error, input);
16839 if (!bd_set || !ip_set || (!mac_set && is_add))
16841 errmsg ("Missing BD, IP or MAC!");
16845 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16846 mp->is_add = is_add;
16847 clib_memcpy (mp->mac, mac, 6);
16848 mp->bd = clib_host_to_net_u32 (bd);
16854 /* wait for reply */
16860 api_one_ndp_bd_get (vat_main_t * vam)
16862 vl_api_one_ndp_bd_get_t *mp;
16865 M (ONE_NDP_BD_GET, mp);
16870 /* wait for reply */
16876 api_one_ndp_entries_get (vat_main_t * vam)
16878 vl_api_one_ndp_entries_get_t *mp;
16879 unformat_input_t *input = vam->input;
16884 /* Parse args required to build the message */
16885 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16887 if (unformat (input, "bd %d", &bd))
16891 errmsg ("parse error '%U'", format_unformat_error, input);
16898 errmsg ("Expected bridge domain!");
16902 M (ONE_NDP_ENTRIES_GET, mp);
16903 mp->bd = clib_host_to_net_u32 (bd);
16908 /* wait for reply */
16914 api_one_l2_arp_bd_get (vat_main_t * vam)
16916 vl_api_one_l2_arp_bd_get_t *mp;
16919 M (ONE_L2_ARP_BD_GET, mp);
16924 /* wait for reply */
16930 api_one_l2_arp_entries_get (vat_main_t * vam)
16932 vl_api_one_l2_arp_entries_get_t *mp;
16933 unformat_input_t *input = vam->input;
16938 /* Parse args required to build the message */
16939 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16941 if (unformat (input, "bd %d", &bd))
16945 errmsg ("parse error '%U'", format_unformat_error, input);
16952 errmsg ("Expected bridge domain!");
16956 M (ONE_L2_ARP_ENTRIES_GET, mp);
16957 mp->bd = clib_host_to_net_u32 (bd);
16962 /* wait for reply */
16968 api_one_stats_enable_disable (vat_main_t * vam)
16970 vl_api_one_stats_enable_disable_t *mp;
16971 unformat_input_t *input = vam->input;
16976 /* Parse args required to build the message */
16977 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16979 if (unformat (input, "enable"))
16984 else if (unformat (input, "disable"))
16994 errmsg ("Value not set");
16998 M (ONE_STATS_ENABLE_DISABLE, mp);
17004 /* wait for reply */
17010 api_show_one_stats_enable_disable (vat_main_t * vam)
17012 vl_api_show_one_stats_enable_disable_t *mp;
17015 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
17020 /* wait for reply */
17026 api_show_one_map_request_mode (vat_main_t * vam)
17028 vl_api_show_one_map_request_mode_t *mp;
17031 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
17036 /* wait for reply */
17041 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
17044 api_one_map_request_mode (vat_main_t * vam)
17046 unformat_input_t *input = vam->input;
17047 vl_api_one_map_request_mode_t *mp;
17051 /* Parse args required to build the message */
17052 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17054 if (unformat (input, "dst-only"))
17056 else if (unformat (input, "src-dst"))
17060 errmsg ("parse error '%U'", format_unformat_error, input);
17065 M (ONE_MAP_REQUEST_MODE, mp);
17072 /* wait for reply */
17077 #define api_lisp_map_request_mode api_one_map_request_mode
17080 * Enable/disable ONE proxy ITR.
17082 * @param vam vpp API test context
17083 * @return return code
17086 api_one_pitr_set_locator_set (vat_main_t * vam)
17088 u8 ls_name_set = 0;
17089 unformat_input_t *input = vam->input;
17090 vl_api_one_pitr_set_locator_set_t *mp;
17095 /* Parse args required to build the message */
17096 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17098 if (unformat (input, "del"))
17100 else if (unformat (input, "locator-set %s", &ls_name))
17104 errmsg ("parse error '%U'", format_unformat_error, input);
17111 errmsg ("locator-set name not set!");
17115 M (ONE_PITR_SET_LOCATOR_SET, mp);
17117 mp->is_add = is_add;
17118 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17119 vec_free (ls_name);
17124 /* wait for reply */
17129 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
17132 api_one_nsh_set_locator_set (vat_main_t * vam)
17134 u8 ls_name_set = 0;
17135 unformat_input_t *input = vam->input;
17136 vl_api_one_nsh_set_locator_set_t *mp;
17141 /* Parse args required to build the message */
17142 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17144 if (unformat (input, "del"))
17146 else if (unformat (input, "ls %s", &ls_name))
17150 errmsg ("parse error '%U'", format_unformat_error, input);
17155 if (!ls_name_set && is_add)
17157 errmsg ("locator-set name not set!");
17161 M (ONE_NSH_SET_LOCATOR_SET, mp);
17163 mp->is_add = is_add;
17164 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17165 vec_free (ls_name);
17170 /* wait for reply */
17176 api_show_one_pitr (vat_main_t * vam)
17178 vl_api_show_one_pitr_t *mp;
17181 if (!vam->json_output)
17183 print (vam->ofp, "%=20s", "lisp status:");
17186 M (SHOW_ONE_PITR, mp);
17190 /* Wait for a reply... */
17195 #define api_show_lisp_pitr api_show_one_pitr
17198 api_one_use_petr (vat_main_t * vam)
17200 unformat_input_t *input = vam->input;
17201 vl_api_one_use_petr_t *mp;
17206 memset (&ip, 0, sizeof (ip));
17208 /* Parse args required to build the message */
17209 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17211 if (unformat (input, "disable"))
17214 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
17217 ip_addr_version (&ip) = IP4;
17220 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
17223 ip_addr_version (&ip) = IP6;
17227 errmsg ("parse error '%U'", format_unformat_error, input);
17232 M (ONE_USE_PETR, mp);
17234 mp->is_add = is_add;
17237 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
17239 clib_memcpy (mp->address, &ip, 4);
17241 clib_memcpy (mp->address, &ip, 16);
17247 /* wait for reply */
17252 #define api_lisp_use_petr api_one_use_petr
17255 api_show_one_nsh_mapping (vat_main_t * vam)
17257 vl_api_show_one_use_petr_t *mp;
17260 if (!vam->json_output)
17262 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
17265 M (SHOW_ONE_NSH_MAPPING, mp);
17269 /* Wait for a reply... */
17275 api_show_one_use_petr (vat_main_t * vam)
17277 vl_api_show_one_use_petr_t *mp;
17280 if (!vam->json_output)
17282 print (vam->ofp, "%=20s", "Proxy-ETR status:");
17285 M (SHOW_ONE_USE_PETR, mp);
17289 /* Wait for a reply... */
17294 #define api_show_lisp_use_petr api_show_one_use_petr
17297 * Add/delete mapping between vni and vrf
17300 api_one_eid_table_add_del_map (vat_main_t * vam)
17302 unformat_input_t *input = vam->input;
17303 vl_api_one_eid_table_add_del_map_t *mp;
17304 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
17305 u32 vni, vrf, bd_index;
17308 /* Parse args required to build the message */
17309 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17311 if (unformat (input, "del"))
17313 else if (unformat (input, "vrf %d", &vrf))
17315 else if (unformat (input, "bd_index %d", &bd_index))
17317 else if (unformat (input, "vni %d", &vni))
17323 if (!vni_set || (!vrf_set && !bd_index_set))
17325 errmsg ("missing arguments!");
17329 if (vrf_set && bd_index_set)
17331 errmsg ("error: both vrf and bd entered!");
17335 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
17337 mp->is_add = is_add;
17338 mp->vni = htonl (vni);
17339 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
17340 mp->is_l2 = bd_index_set;
17345 /* wait for reply */
17350 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
17353 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
17355 u32 *action = va_arg (*args, u32 *);
17358 if (unformat (input, "%s", &s))
17360 if (!strcmp ((char *) s, "no-action"))
17362 else if (!strcmp ((char *) s, "natively-forward"))
17364 else if (!strcmp ((char *) s, "send-map-request"))
17366 else if (!strcmp ((char *) s, "drop"))
17370 clib_warning ("invalid action: '%s'", s);
17382 * Add/del remote mapping to/from ONE control plane
17384 * @param vam vpp API test context
17385 * @return return code
17388 api_one_add_del_remote_mapping (vat_main_t * vam)
17390 unformat_input_t *input = vam->input;
17391 vl_api_one_add_del_remote_mapping_t *mp;
17393 lisp_eid_vat_t _eid, *eid = &_eid;
17394 lisp_eid_vat_t _seid, *seid = &_seid;
17395 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
17396 u32 action = ~0, p, w, data_len;
17397 ip4_address_t rloc4;
17398 ip6_address_t rloc6;
17399 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
17402 memset (&rloc, 0, sizeof (rloc));
17404 /* Parse args required to build the message */
17405 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17407 if (unformat (input, "del-all"))
17411 else if (unformat (input, "del"))
17415 else if (unformat (input, "add"))
17419 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17423 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
17427 else if (unformat (input, "vni %d", &vni))
17431 else if (unformat (input, "p %d w %d", &p, &w))
17435 errmsg ("No RLOC configured for setting priority/weight!");
17438 curr_rloc->priority = p;
17439 curr_rloc->weight = w;
17441 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
17444 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
17445 vec_add1 (rlocs, rloc);
17446 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17448 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
17451 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
17452 vec_add1 (rlocs, rloc);
17453 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17455 else if (unformat (input, "action %U",
17456 unformat_negative_mapping_action, &action))
17462 clib_warning ("parse error '%U'", format_unformat_error, input);
17469 errmsg ("missing params!");
17473 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
17475 errmsg ("no action set for negative map-reply!");
17479 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
17481 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
17482 mp->is_add = is_add;
17483 mp->vni = htonl (vni);
17484 mp->action = (u8) action;
17485 mp->is_src_dst = seid_set;
17486 mp->eid_len = eid->len;
17487 mp->seid_len = seid->len;
17488 mp->del_all = del_all;
17489 mp->eid_type = eid->type;
17490 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17491 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
17493 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
17494 clib_memcpy (mp->rlocs, rlocs, data_len);
17500 /* Wait for a reply... */
17505 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
17508 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
17509 * forwarding entries in data-plane accordingly.
17511 * @param vam vpp API test context
17512 * @return return code
17515 api_one_add_del_adjacency (vat_main_t * vam)
17517 unformat_input_t *input = vam->input;
17518 vl_api_one_add_del_adjacency_t *mp;
17520 ip4_address_t leid4, reid4;
17521 ip6_address_t leid6, reid6;
17522 u8 reid_mac[6] = { 0 };
17523 u8 leid_mac[6] = { 0 };
17524 u8 reid_type, leid_type;
17525 u32 leid_len = 0, reid_len = 0, len;
17529 leid_type = reid_type = (u8) ~ 0;
17531 /* Parse args required to build the message */
17532 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17534 if (unformat (input, "del"))
17538 else if (unformat (input, "add"))
17542 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17545 reid_type = 0; /* ipv4 */
17548 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17551 reid_type = 1; /* ipv6 */
17554 else if (unformat (input, "reid %U", unformat_ethernet_address,
17557 reid_type = 2; /* mac */
17559 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17562 leid_type = 0; /* ipv4 */
17565 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17568 leid_type = 1; /* ipv6 */
17571 else if (unformat (input, "leid %U", unformat_ethernet_address,
17574 leid_type = 2; /* mac */
17576 else if (unformat (input, "vni %d", &vni))
17582 errmsg ("parse error '%U'", format_unformat_error, input);
17587 if ((u8) ~ 0 == reid_type)
17589 errmsg ("missing params!");
17593 if (leid_type != reid_type)
17595 errmsg ("remote and local EIDs are of different types!");
17599 M (ONE_ADD_DEL_ADJACENCY, mp);
17600 mp->is_add = is_add;
17601 mp->vni = htonl (vni);
17602 mp->leid_len = leid_len;
17603 mp->reid_len = reid_len;
17604 mp->eid_type = reid_type;
17606 switch (mp->eid_type)
17609 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17610 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17613 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17614 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17617 clib_memcpy (mp->leid, leid_mac, 6);
17618 clib_memcpy (mp->reid, reid_mac, 6);
17621 errmsg ("unknown EID type %d!", mp->eid_type);
17628 /* Wait for a reply... */
17633 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17636 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17638 u32 *mode = va_arg (*args, u32 *);
17640 if (unformat (input, "lisp"))
17642 else if (unformat (input, "vxlan"))
17651 api_gpe_get_encap_mode (vat_main_t * vam)
17653 vl_api_gpe_get_encap_mode_t *mp;
17656 /* Construct the API message */
17657 M (GPE_GET_ENCAP_MODE, mp);
17662 /* Wait for a reply... */
17668 api_gpe_set_encap_mode (vat_main_t * vam)
17670 unformat_input_t *input = vam->input;
17671 vl_api_gpe_set_encap_mode_t *mp;
17675 /* Parse args required to build the message */
17676 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17678 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17684 /* Construct the API message */
17685 M (GPE_SET_ENCAP_MODE, mp);
17692 /* Wait for a reply... */
17698 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17700 unformat_input_t *input = vam->input;
17701 vl_api_gpe_add_del_iface_t *mp;
17702 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17703 u32 dp_table = 0, vni = 0;
17706 /* Parse args required to build the message */
17707 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17709 if (unformat (input, "up"))
17714 else if (unformat (input, "down"))
17719 else if (unformat (input, "table_id %d", &dp_table))
17723 else if (unformat (input, "bd_id %d", &dp_table))
17728 else if (unformat (input, "vni %d", &vni))
17736 if (action_set == 0)
17738 errmsg ("Action not set");
17741 if (dp_table_set == 0 || vni_set == 0)
17743 errmsg ("vni and dp_table must be set");
17747 /* Construct the API message */
17748 M (GPE_ADD_DEL_IFACE, mp);
17750 mp->is_add = is_add;
17751 mp->dp_table = clib_host_to_net_u32 (dp_table);
17753 mp->vni = clib_host_to_net_u32 (vni);
17758 /* Wait for a reply... */
17764 api_one_map_register_fallback_threshold (vat_main_t * vam)
17766 unformat_input_t *input = vam->input;
17767 vl_api_one_map_register_fallback_threshold_t *mp;
17772 /* Parse args required to build the message */
17773 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17775 if (unformat (input, "%u", &value))
17779 clib_warning ("parse error '%U'", format_unformat_error, input);
17786 errmsg ("fallback threshold value is missing!");
17790 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17791 mp->value = clib_host_to_net_u32 (value);
17796 /* Wait for a reply... */
17802 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17804 vl_api_show_one_map_register_fallback_threshold_t *mp;
17807 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17812 /* Wait for a reply... */
17818 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17820 u32 *proto = va_arg (*args, u32 *);
17822 if (unformat (input, "udp"))
17824 else if (unformat (input, "api"))
17833 api_one_set_transport_protocol (vat_main_t * vam)
17835 unformat_input_t *input = vam->input;
17836 vl_api_one_set_transport_protocol_t *mp;
17841 /* Parse args required to build the message */
17842 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17844 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17848 clib_warning ("parse error '%U'", format_unformat_error, input);
17855 errmsg ("Transport protocol missing!");
17859 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17860 mp->protocol = (u8) protocol;
17865 /* Wait for a reply... */
17871 api_one_get_transport_protocol (vat_main_t * vam)
17873 vl_api_one_get_transport_protocol_t *mp;
17876 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17881 /* Wait for a reply... */
17887 api_one_map_register_set_ttl (vat_main_t * vam)
17889 unformat_input_t *input = vam->input;
17890 vl_api_one_map_register_set_ttl_t *mp;
17895 /* Parse args required to build the message */
17896 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17898 if (unformat (input, "%u", &ttl))
17902 clib_warning ("parse error '%U'", format_unformat_error, input);
17909 errmsg ("TTL value missing!");
17913 M (ONE_MAP_REGISTER_SET_TTL, mp);
17914 mp->ttl = clib_host_to_net_u32 (ttl);
17919 /* Wait for a reply... */
17925 api_show_one_map_register_ttl (vat_main_t * vam)
17927 vl_api_show_one_map_register_ttl_t *mp;
17930 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17935 /* Wait for a reply... */
17941 * Add/del map request itr rlocs from ONE control plane and updates
17943 * @param vam vpp API test context
17944 * @return return code
17947 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17949 unformat_input_t *input = vam->input;
17950 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17951 u8 *locator_set_name = 0;
17952 u8 locator_set_name_set = 0;
17956 /* Parse args required to build the message */
17957 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17959 if (unformat (input, "del"))
17963 else if (unformat (input, "%_%v%_", &locator_set_name))
17965 locator_set_name_set = 1;
17969 clib_warning ("parse error '%U'", format_unformat_error, input);
17974 if (is_add && !locator_set_name_set)
17976 errmsg ("itr-rloc is not set!");
17980 if (is_add && vec_len (locator_set_name) > 64)
17982 errmsg ("itr-rloc locator-set name too long");
17983 vec_free (locator_set_name);
17987 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17988 mp->is_add = is_add;
17991 clib_memcpy (mp->locator_set_name, locator_set_name,
17992 vec_len (locator_set_name));
17996 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17998 vec_free (locator_set_name);
18003 /* Wait for a reply... */
18008 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
18011 api_one_locator_dump (vat_main_t * vam)
18013 unformat_input_t *input = vam->input;
18014 vl_api_one_locator_dump_t *mp;
18015 vl_api_control_ping_t *mp_ping;
18016 u8 is_index_set = 0, is_name_set = 0;
18021 /* Parse args required to build the message */
18022 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18024 if (unformat (input, "ls_name %_%v%_", &ls_name))
18028 else if (unformat (input, "ls_index %d", &ls_index))
18034 errmsg ("parse error '%U'", format_unformat_error, input);
18039 if (!is_index_set && !is_name_set)
18041 errmsg ("error: expected one of index or name!");
18045 if (is_index_set && is_name_set)
18047 errmsg ("error: only one param expected!");
18051 if (vec_len (ls_name) > 62)
18053 errmsg ("error: locator set name too long!");
18057 if (!vam->json_output)
18059 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
18062 M (ONE_LOCATOR_DUMP, mp);
18063 mp->is_index_set = is_index_set;
18066 mp->ls_index = clib_host_to_net_u32 (ls_index);
18069 vec_add1 (ls_name, 0);
18070 strncpy ((char *) mp->ls_name, (char *) ls_name,
18071 sizeof (mp->ls_name) - 1);
18077 /* Use a control ping for synchronization */
18078 MPING (CONTROL_PING, mp_ping);
18081 /* Wait for a reply... */
18086 #define api_lisp_locator_dump api_one_locator_dump
18089 api_one_locator_set_dump (vat_main_t * vam)
18091 vl_api_one_locator_set_dump_t *mp;
18092 vl_api_control_ping_t *mp_ping;
18093 unformat_input_t *input = vam->input;
18097 /* Parse args required to build the message */
18098 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18100 if (unformat (input, "local"))
18104 else if (unformat (input, "remote"))
18110 errmsg ("parse error '%U'", format_unformat_error, input);
18115 if (!vam->json_output)
18117 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
18120 M (ONE_LOCATOR_SET_DUMP, mp);
18122 mp->filter = filter;
18127 /* Use a control ping for synchronization */
18128 MPING (CONTROL_PING, mp_ping);
18131 /* Wait for a reply... */
18136 #define api_lisp_locator_set_dump api_one_locator_set_dump
18139 api_one_eid_table_map_dump (vat_main_t * vam)
18143 unformat_input_t *input = vam->input;
18144 vl_api_one_eid_table_map_dump_t *mp;
18145 vl_api_control_ping_t *mp_ping;
18148 /* Parse args required to build the message */
18149 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18151 if (unformat (input, "l2"))
18156 else if (unformat (input, "l3"))
18163 errmsg ("parse error '%U'", format_unformat_error, input);
18170 errmsg ("expected one of 'l2' or 'l3' parameter!");
18174 if (!vam->json_output)
18176 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
18179 M (ONE_EID_TABLE_MAP_DUMP, mp);
18185 /* Use a control ping for synchronization */
18186 MPING (CONTROL_PING, mp_ping);
18189 /* Wait for a reply... */
18194 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
18197 api_one_eid_table_vni_dump (vat_main_t * vam)
18199 vl_api_one_eid_table_vni_dump_t *mp;
18200 vl_api_control_ping_t *mp_ping;
18203 if (!vam->json_output)
18205 print (vam->ofp, "VNI");
18208 M (ONE_EID_TABLE_VNI_DUMP, mp);
18213 /* Use a control ping for synchronization */
18214 MPING (CONTROL_PING, mp_ping);
18217 /* Wait for a reply... */
18222 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
18225 api_one_eid_table_dump (vat_main_t * vam)
18227 unformat_input_t *i = vam->input;
18228 vl_api_one_eid_table_dump_t *mp;
18229 vl_api_control_ping_t *mp_ping;
18230 struct in_addr ip4;
18231 struct in6_addr ip6;
18233 u8 eid_type = ~0, eid_set = 0;
18234 u32 prefix_length = ~0, t, vni = 0;
18237 lisp_nsh_api_t nsh;
18239 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18241 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
18247 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
18253 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
18258 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
18263 else if (unformat (i, "vni %d", &t))
18267 else if (unformat (i, "local"))
18271 else if (unformat (i, "remote"))
18277 errmsg ("parse error '%U'", format_unformat_error, i);
18282 if (!vam->json_output)
18284 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
18285 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
18288 M (ONE_EID_TABLE_DUMP, mp);
18290 mp->filter = filter;
18294 mp->vni = htonl (vni);
18295 mp->eid_type = eid_type;
18299 mp->prefix_length = prefix_length;
18300 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
18303 mp->prefix_length = prefix_length;
18304 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
18307 clib_memcpy (mp->eid, mac, sizeof (mac));
18310 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
18313 errmsg ("unknown EID type %d!", eid_type);
18321 /* Use a control ping for synchronization */
18322 MPING (CONTROL_PING, mp_ping);
18325 /* Wait for a reply... */
18330 #define api_lisp_eid_table_dump api_one_eid_table_dump
18333 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
18335 unformat_input_t *i = vam->input;
18336 vl_api_gpe_fwd_entries_get_t *mp;
18341 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18343 if (unformat (i, "vni %d", &vni))
18349 errmsg ("parse error '%U'", format_unformat_error, i);
18356 errmsg ("vni not set!");
18360 if (!vam->json_output)
18362 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
18366 M (GPE_FWD_ENTRIES_GET, mp);
18367 mp->vni = clib_host_to_net_u32 (vni);
18372 /* Wait for a reply... */
18377 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
18378 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
18379 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
18380 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
18381 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
18382 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
18383 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
18384 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
18387 api_one_adjacencies_get (vat_main_t * vam)
18389 unformat_input_t *i = vam->input;
18390 vl_api_one_adjacencies_get_t *mp;
18395 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18397 if (unformat (i, "vni %d", &vni))
18403 errmsg ("parse error '%U'", format_unformat_error, i);
18410 errmsg ("vni not set!");
18414 if (!vam->json_output)
18416 print (vam->ofp, "%s %40s", "leid", "reid");
18419 M (ONE_ADJACENCIES_GET, mp);
18420 mp->vni = clib_host_to_net_u32 (vni);
18425 /* Wait for a reply... */
18430 #define api_lisp_adjacencies_get api_one_adjacencies_get
18433 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
18435 unformat_input_t *i = vam->input;
18436 vl_api_gpe_native_fwd_rpaths_get_t *mp;
18438 u8 ip_family_set = 0, is_ip4 = 1;
18440 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18442 if (unformat (i, "ip4"))
18447 else if (unformat (i, "ip6"))
18454 errmsg ("parse error '%U'", format_unformat_error, i);
18459 if (!ip_family_set)
18461 errmsg ("ip family not set!");
18465 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
18466 mp->is_ip4 = is_ip4;
18471 /* Wait for a reply... */
18477 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
18479 vl_api_gpe_fwd_entry_vnis_get_t *mp;
18482 if (!vam->json_output)
18484 print (vam->ofp, "VNIs");
18487 M (GPE_FWD_ENTRY_VNIS_GET, mp);
18492 /* Wait for a reply... */
18498 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
18500 unformat_input_t *i = vam->input;
18501 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
18503 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
18504 struct in_addr ip4;
18505 struct in6_addr ip6;
18506 u32 table_id = 0, nh_sw_if_index = ~0;
18508 memset (&ip4, 0, sizeof (ip4));
18509 memset (&ip6, 0, sizeof (ip6));
18511 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18513 if (unformat (i, "del"))
18515 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
18516 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18521 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
18522 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18527 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18531 nh_sw_if_index = ~0;
18533 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18537 nh_sw_if_index = ~0;
18539 else if (unformat (i, "table %d", &table_id))
18543 errmsg ("parse error '%U'", format_unformat_error, i);
18550 errmsg ("nh addr not set!");
18554 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18555 mp->is_add = is_add;
18556 mp->table_id = clib_host_to_net_u32 (table_id);
18557 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18558 mp->is_ip4 = is_ip4;
18560 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18562 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18567 /* Wait for a reply... */
18573 api_one_map_server_dump (vat_main_t * vam)
18575 vl_api_one_map_server_dump_t *mp;
18576 vl_api_control_ping_t *mp_ping;
18579 if (!vam->json_output)
18581 print (vam->ofp, "%=20s", "Map server");
18584 M (ONE_MAP_SERVER_DUMP, mp);
18588 /* Use a control ping for synchronization */
18589 MPING (CONTROL_PING, mp_ping);
18592 /* Wait for a reply... */
18597 #define api_lisp_map_server_dump api_one_map_server_dump
18600 api_one_map_resolver_dump (vat_main_t * vam)
18602 vl_api_one_map_resolver_dump_t *mp;
18603 vl_api_control_ping_t *mp_ping;
18606 if (!vam->json_output)
18608 print (vam->ofp, "%=20s", "Map resolver");
18611 M (ONE_MAP_RESOLVER_DUMP, mp);
18615 /* Use a control ping for synchronization */
18616 MPING (CONTROL_PING, mp_ping);
18619 /* Wait for a reply... */
18624 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18627 api_one_stats_flush (vat_main_t * vam)
18629 vl_api_one_stats_flush_t *mp;
18632 M (ONE_STATS_FLUSH, mp);
18639 api_one_stats_dump (vat_main_t * vam)
18641 vl_api_one_stats_dump_t *mp;
18642 vl_api_control_ping_t *mp_ping;
18645 M (ONE_STATS_DUMP, mp);
18649 /* Use a control ping for synchronization */
18650 MPING (CONTROL_PING, mp_ping);
18653 /* Wait for a reply... */
18659 api_show_one_status (vat_main_t * vam)
18661 vl_api_show_one_status_t *mp;
18664 if (!vam->json_output)
18666 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18669 M (SHOW_ONE_STATUS, mp);
18672 /* Wait for a reply... */
18677 #define api_show_lisp_status api_show_one_status
18680 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18682 vl_api_gpe_fwd_entry_path_dump_t *mp;
18683 vl_api_control_ping_t *mp_ping;
18684 unformat_input_t *i = vam->input;
18685 u32 fwd_entry_index = ~0;
18688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18690 if (unformat (i, "index %d", &fwd_entry_index))
18696 if (~0 == fwd_entry_index)
18698 errmsg ("no index specified!");
18702 if (!vam->json_output)
18704 print (vam->ofp, "first line");
18707 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18711 /* Use a control ping for synchronization */
18712 MPING (CONTROL_PING, mp_ping);
18715 /* Wait for a reply... */
18721 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18723 vl_api_one_get_map_request_itr_rlocs_t *mp;
18726 if (!vam->json_output)
18728 print (vam->ofp, "%=20s", "itr-rlocs:");
18731 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18734 /* Wait for a reply... */
18739 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18742 api_af_packet_create (vat_main_t * vam)
18744 unformat_input_t *i = vam->input;
18745 vl_api_af_packet_create_t *mp;
18746 u8 *host_if_name = 0;
18748 u8 random_hw_addr = 1;
18751 memset (hw_addr, 0, sizeof (hw_addr));
18753 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18755 if (unformat (i, "name %s", &host_if_name))
18756 vec_add1 (host_if_name, 0);
18757 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18758 random_hw_addr = 0;
18763 if (!vec_len (host_if_name))
18765 errmsg ("host-interface name must be specified");
18769 if (vec_len (host_if_name) > 64)
18771 errmsg ("host-interface name too long");
18775 M (AF_PACKET_CREATE, mp);
18777 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18778 clib_memcpy (mp->hw_addr, hw_addr, 6);
18779 mp->use_random_hw_addr = random_hw_addr;
18780 vec_free (host_if_name);
18788 fprintf (vam->ofp ? vam->ofp : stderr,
18789 " new sw_if_index = %d\n", vam->sw_if_index);
18796 api_af_packet_delete (vat_main_t * vam)
18798 unformat_input_t *i = vam->input;
18799 vl_api_af_packet_delete_t *mp;
18800 u8 *host_if_name = 0;
18803 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18805 if (unformat (i, "name %s", &host_if_name))
18806 vec_add1 (host_if_name, 0);
18811 if (!vec_len (host_if_name))
18813 errmsg ("host-interface name must be specified");
18817 if (vec_len (host_if_name) > 64)
18819 errmsg ("host-interface name too long");
18823 M (AF_PACKET_DELETE, mp);
18825 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18826 vec_free (host_if_name);
18834 api_policer_add_del (vat_main_t * vam)
18836 unformat_input_t *i = vam->input;
18837 vl_api_policer_add_del_t *mp;
18847 u8 color_aware = 0;
18848 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18851 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18852 conform_action.dscp = 0;
18853 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18854 exceed_action.dscp = 0;
18855 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18856 violate_action.dscp = 0;
18858 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18860 if (unformat (i, "del"))
18862 else if (unformat (i, "name %s", &name))
18863 vec_add1 (name, 0);
18864 else if (unformat (i, "cir %u", &cir))
18866 else if (unformat (i, "eir %u", &eir))
18868 else if (unformat (i, "cb %u", &cb))
18870 else if (unformat (i, "eb %u", &eb))
18872 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18875 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18878 else if (unformat (i, "type %U", unformat_policer_type, &type))
18880 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18883 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18886 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18889 else if (unformat (i, "color-aware"))
18895 if (!vec_len (name))
18897 errmsg ("policer name must be specified");
18901 if (vec_len (name) > 64)
18903 errmsg ("policer name too long");
18907 M (POLICER_ADD_DEL, mp);
18909 clib_memcpy (mp->name, name, vec_len (name));
18911 mp->is_add = is_add;
18912 mp->cir = ntohl (cir);
18913 mp->eir = ntohl (eir);
18914 mp->cb = clib_net_to_host_u64 (cb);
18915 mp->eb = clib_net_to_host_u64 (eb);
18916 mp->rate_type = rate_type;
18917 mp->round_type = round_type;
18919 mp->conform_action_type = conform_action.action_type;
18920 mp->conform_dscp = conform_action.dscp;
18921 mp->exceed_action_type = exceed_action.action_type;
18922 mp->exceed_dscp = exceed_action.dscp;
18923 mp->violate_action_type = violate_action.action_type;
18924 mp->violate_dscp = violate_action.dscp;
18925 mp->color_aware = color_aware;
18933 api_policer_dump (vat_main_t * vam)
18935 unformat_input_t *i = vam->input;
18936 vl_api_policer_dump_t *mp;
18937 vl_api_control_ping_t *mp_ping;
18938 u8 *match_name = 0;
18939 u8 match_name_valid = 0;
18942 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18944 if (unformat (i, "name %s", &match_name))
18946 vec_add1 (match_name, 0);
18947 match_name_valid = 1;
18953 M (POLICER_DUMP, mp);
18954 mp->match_name_valid = match_name_valid;
18955 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18956 vec_free (match_name);
18960 /* Use a control ping for synchronization */
18961 MPING (CONTROL_PING, mp_ping);
18964 /* Wait for a reply... */
18970 api_policer_classify_set_interface (vat_main_t * vam)
18972 unformat_input_t *i = vam->input;
18973 vl_api_policer_classify_set_interface_t *mp;
18975 int sw_if_index_set;
18976 u32 ip4_table_index = ~0;
18977 u32 ip6_table_index = ~0;
18978 u32 l2_table_index = ~0;
18982 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18984 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18985 sw_if_index_set = 1;
18986 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18987 sw_if_index_set = 1;
18988 else if (unformat (i, "del"))
18990 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18992 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18994 else if (unformat (i, "l2-table %d", &l2_table_index))
18998 clib_warning ("parse error '%U'", format_unformat_error, i);
19003 if (sw_if_index_set == 0)
19005 errmsg ("missing interface name or sw_if_index");
19009 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
19011 mp->sw_if_index = ntohl (sw_if_index);
19012 mp->ip4_table_index = ntohl (ip4_table_index);
19013 mp->ip6_table_index = ntohl (ip6_table_index);
19014 mp->l2_table_index = ntohl (l2_table_index);
19015 mp->is_add = is_add;
19023 api_policer_classify_dump (vat_main_t * vam)
19025 unformat_input_t *i = vam->input;
19026 vl_api_policer_classify_dump_t *mp;
19027 vl_api_control_ping_t *mp_ping;
19028 u8 type = POLICER_CLASSIFY_N_TABLES;
19031 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
19035 errmsg ("classify table type must be specified");
19039 if (!vam->json_output)
19041 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19044 M (POLICER_CLASSIFY_DUMP, mp);
19049 /* Use a control ping for synchronization */
19050 MPING (CONTROL_PING, mp_ping);
19053 /* Wait for a reply... */
19059 api_netmap_create (vat_main_t * vam)
19061 unformat_input_t *i = vam->input;
19062 vl_api_netmap_create_t *mp;
19065 u8 random_hw_addr = 1;
19070 memset (hw_addr, 0, sizeof (hw_addr));
19072 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19074 if (unformat (i, "name %s", &if_name))
19075 vec_add1 (if_name, 0);
19076 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19077 random_hw_addr = 0;
19078 else if (unformat (i, "pipe"))
19080 else if (unformat (i, "master"))
19082 else if (unformat (i, "slave"))
19088 if (!vec_len (if_name))
19090 errmsg ("interface name must be specified");
19094 if (vec_len (if_name) > 64)
19096 errmsg ("interface name too long");
19100 M (NETMAP_CREATE, mp);
19102 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19103 clib_memcpy (mp->hw_addr, hw_addr, 6);
19104 mp->use_random_hw_addr = random_hw_addr;
19105 mp->is_pipe = is_pipe;
19106 mp->is_master = is_master;
19107 vec_free (if_name);
19115 api_netmap_delete (vat_main_t * vam)
19117 unformat_input_t *i = vam->input;
19118 vl_api_netmap_delete_t *mp;
19122 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19124 if (unformat (i, "name %s", &if_name))
19125 vec_add1 (if_name, 0);
19130 if (!vec_len (if_name))
19132 errmsg ("interface name must be specified");
19136 if (vec_len (if_name) > 64)
19138 errmsg ("interface name too long");
19142 M (NETMAP_DELETE, mp);
19144 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19145 vec_free (if_name);
19153 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
19155 if (fp->afi == IP46_TYPE_IP6)
19157 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19158 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19159 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19160 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19161 format_ip6_address, fp->next_hop);
19162 else if (fp->afi == IP46_TYPE_IP4)
19164 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19165 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19166 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19167 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19168 format_ip4_address, fp->next_hop);
19172 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
19173 vl_api_fib_path2_t * fp)
19175 struct in_addr ip4;
19176 struct in6_addr ip6;
19178 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19179 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19180 vat_json_object_add_uint (node, "is_local", fp->is_local);
19181 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19182 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19183 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19184 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19185 if (fp->afi == IP46_TYPE_IP4)
19187 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19188 vat_json_object_add_ip4 (node, "next_hop", ip4);
19190 else if (fp->afi == IP46_TYPE_IP6)
19192 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19193 vat_json_object_add_ip6 (node, "next_hop", ip6);
19198 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
19200 vat_main_t *vam = &vat_main;
19201 int count = ntohl (mp->mt_count);
19202 vl_api_fib_path2_t *fp;
19205 print (vam->ofp, "[%d]: sw_if_index %d via:",
19206 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
19208 for (i = 0; i < count; i++)
19210 vl_api_mpls_fib_path_print (vam, fp);
19214 print (vam->ofp, "");
19217 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
19218 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
19221 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
19223 vat_main_t *vam = &vat_main;
19224 vat_json_node_t *node = NULL;
19225 int count = ntohl (mp->mt_count);
19226 vl_api_fib_path2_t *fp;
19229 if (VAT_JSON_ARRAY != vam->json_tree.type)
19231 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19232 vat_json_init_array (&vam->json_tree);
19234 node = vat_json_array_add (&vam->json_tree);
19236 vat_json_init_object (node);
19237 vat_json_object_add_uint (node, "tunnel_index",
19238 ntohl (mp->mt_tunnel_index));
19239 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
19241 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
19244 for (i = 0; i < count; i++)
19246 vl_api_mpls_fib_path_json_print (node, fp);
19252 api_mpls_tunnel_dump (vat_main_t * vam)
19254 vl_api_mpls_tunnel_dump_t *mp;
19255 vl_api_control_ping_t *mp_ping;
19259 /* Parse args required to build the message */
19260 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
19262 if (!unformat (vam->input, "tunnel_index %d", &index))
19269 print (vam->ofp, " tunnel_index %d", index);
19271 M (MPLS_TUNNEL_DUMP, mp);
19272 mp->tunnel_index = htonl (index);
19275 /* Use a control ping for synchronization */
19276 MPING (CONTROL_PING, mp_ping);
19283 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
19284 #define vl_api_mpls_fib_details_t_print vl_noop_handler
19288 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
19290 vat_main_t *vam = &vat_main;
19291 int count = ntohl (mp->count);
19292 vl_api_fib_path2_t *fp;
19296 "table-id %d, label %u, ess_bit %u",
19297 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
19299 for (i = 0; i < count; i++)
19301 vl_api_mpls_fib_path_print (vam, fp);
19306 static void vl_api_mpls_fib_details_t_handler_json
19307 (vl_api_mpls_fib_details_t * mp)
19309 vat_main_t *vam = &vat_main;
19310 int count = ntohl (mp->count);
19311 vat_json_node_t *node = NULL;
19312 vl_api_fib_path2_t *fp;
19315 if (VAT_JSON_ARRAY != vam->json_tree.type)
19317 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19318 vat_json_init_array (&vam->json_tree);
19320 node = vat_json_array_add (&vam->json_tree);
19322 vat_json_init_object (node);
19323 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19324 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
19325 vat_json_object_add_uint (node, "label", ntohl (mp->label));
19326 vat_json_object_add_uint (node, "path_count", count);
19328 for (i = 0; i < count; i++)
19330 vl_api_mpls_fib_path_json_print (node, fp);
19336 api_mpls_fib_dump (vat_main_t * vam)
19338 vl_api_mpls_fib_dump_t *mp;
19339 vl_api_control_ping_t *mp_ping;
19342 M (MPLS_FIB_DUMP, mp);
19345 /* Use a control ping for synchronization */
19346 MPING (CONTROL_PING, mp_ping);
19353 #define vl_api_ip_fib_details_t_endian vl_noop_handler
19354 #define vl_api_ip_fib_details_t_print vl_noop_handler
19357 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
19359 vat_main_t *vam = &vat_main;
19360 int count = ntohl (mp->count);
19361 vl_api_fib_path_t *fp;
19365 "table-id %d, prefix %U/%d",
19366 ntohl (mp->table_id), format_ip4_address, mp->address,
19367 mp->address_length);
19369 for (i = 0; i < count; i++)
19371 if (fp->afi == IP46_TYPE_IP6)
19373 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19374 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19375 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19376 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19377 format_ip6_address, fp->next_hop);
19378 else if (fp->afi == IP46_TYPE_IP4)
19380 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19381 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19382 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19383 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19384 format_ip4_address, fp->next_hop);
19389 static void vl_api_ip_fib_details_t_handler_json
19390 (vl_api_ip_fib_details_t * mp)
19392 vat_main_t *vam = &vat_main;
19393 int count = ntohl (mp->count);
19394 vat_json_node_t *node = NULL;
19395 struct in_addr ip4;
19396 struct in6_addr ip6;
19397 vl_api_fib_path_t *fp;
19400 if (VAT_JSON_ARRAY != vam->json_tree.type)
19402 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19403 vat_json_init_array (&vam->json_tree);
19405 node = vat_json_array_add (&vam->json_tree);
19407 vat_json_init_object (node);
19408 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19409 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
19410 vat_json_object_add_ip4 (node, "prefix", ip4);
19411 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19412 vat_json_object_add_uint (node, "path_count", count);
19414 for (i = 0; i < count; i++)
19416 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19417 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19418 vat_json_object_add_uint (node, "is_local", fp->is_local);
19419 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19420 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19421 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19422 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19423 if (fp->afi == IP46_TYPE_IP4)
19425 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19426 vat_json_object_add_ip4 (node, "next_hop", ip4);
19428 else if (fp->afi == IP46_TYPE_IP6)
19430 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19431 vat_json_object_add_ip6 (node, "next_hop", ip6);
19437 api_ip_fib_dump (vat_main_t * vam)
19439 vl_api_ip_fib_dump_t *mp;
19440 vl_api_control_ping_t *mp_ping;
19443 M (IP_FIB_DUMP, mp);
19446 /* Use a control ping for synchronization */
19447 MPING (CONTROL_PING, mp_ping);
19455 api_ip_mfib_dump (vat_main_t * vam)
19457 vl_api_ip_mfib_dump_t *mp;
19458 vl_api_control_ping_t *mp_ping;
19461 M (IP_MFIB_DUMP, mp);
19464 /* Use a control ping for synchronization */
19465 MPING (CONTROL_PING, mp_ping);
19472 static void vl_api_ip_neighbor_details_t_handler
19473 (vl_api_ip_neighbor_details_t * mp)
19475 vat_main_t *vam = &vat_main;
19477 print (vam->ofp, "%c %U %U",
19478 (mp->is_static) ? 'S' : 'D',
19479 format_ethernet_address, &mp->mac_address,
19480 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
19484 static void vl_api_ip_neighbor_details_t_handler_json
19485 (vl_api_ip_neighbor_details_t * mp)
19488 vat_main_t *vam = &vat_main;
19489 vat_json_node_t *node;
19490 struct in_addr ip4;
19491 struct in6_addr ip6;
19493 if (VAT_JSON_ARRAY != vam->json_tree.type)
19495 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19496 vat_json_init_array (&vam->json_tree);
19498 node = vat_json_array_add (&vam->json_tree);
19500 vat_json_init_object (node);
19501 vat_json_object_add_string_copy (node, "flag",
19502 (mp->is_static) ? (u8 *) "static" : (u8 *)
19505 vat_json_object_add_string_copy (node, "link_layer",
19506 format (0, "%U", format_ethernet_address,
19507 &mp->mac_address));
19511 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
19512 vat_json_object_add_ip6 (node, "ip_address", ip6);
19516 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
19517 vat_json_object_add_ip4 (node, "ip_address", ip4);
19522 api_ip_neighbor_dump (vat_main_t * vam)
19524 unformat_input_t *i = vam->input;
19525 vl_api_ip_neighbor_dump_t *mp;
19526 vl_api_control_ping_t *mp_ping;
19528 u32 sw_if_index = ~0;
19531 /* Parse args required to build the message */
19532 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19534 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19536 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19538 else if (unformat (i, "ip6"))
19544 if (sw_if_index == ~0)
19546 errmsg ("missing interface name or sw_if_index");
19550 M (IP_NEIGHBOR_DUMP, mp);
19551 mp->is_ipv6 = (u8) is_ipv6;
19552 mp->sw_if_index = ntohl (sw_if_index);
19555 /* Use a control ping for synchronization */
19556 MPING (CONTROL_PING, mp_ping);
19563 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
19564 #define vl_api_ip6_fib_details_t_print vl_noop_handler
19567 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
19569 vat_main_t *vam = &vat_main;
19570 int count = ntohl (mp->count);
19571 vl_api_fib_path_t *fp;
19575 "table-id %d, prefix %U/%d",
19576 ntohl (mp->table_id), format_ip6_address, mp->address,
19577 mp->address_length);
19579 for (i = 0; i < count; i++)
19581 if (fp->afi == IP46_TYPE_IP6)
19583 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19584 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19585 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19586 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19587 format_ip6_address, fp->next_hop);
19588 else if (fp->afi == IP46_TYPE_IP4)
19590 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19591 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19592 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19593 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19594 format_ip4_address, fp->next_hop);
19599 static void vl_api_ip6_fib_details_t_handler_json
19600 (vl_api_ip6_fib_details_t * mp)
19602 vat_main_t *vam = &vat_main;
19603 int count = ntohl (mp->count);
19604 vat_json_node_t *node = NULL;
19605 struct in_addr ip4;
19606 struct in6_addr ip6;
19607 vl_api_fib_path_t *fp;
19610 if (VAT_JSON_ARRAY != vam->json_tree.type)
19612 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19613 vat_json_init_array (&vam->json_tree);
19615 node = vat_json_array_add (&vam->json_tree);
19617 vat_json_init_object (node);
19618 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19619 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
19620 vat_json_object_add_ip6 (node, "prefix", ip6);
19621 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19622 vat_json_object_add_uint (node, "path_count", count);
19624 for (i = 0; i < count; i++)
19626 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19627 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19628 vat_json_object_add_uint (node, "is_local", fp->is_local);
19629 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19630 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19631 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19632 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19633 if (fp->afi == IP46_TYPE_IP4)
19635 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19636 vat_json_object_add_ip4 (node, "next_hop", ip4);
19638 else if (fp->afi == IP46_TYPE_IP6)
19640 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19641 vat_json_object_add_ip6 (node, "next_hop", ip6);
19647 api_ip6_fib_dump (vat_main_t * vam)
19649 vl_api_ip6_fib_dump_t *mp;
19650 vl_api_control_ping_t *mp_ping;
19653 M (IP6_FIB_DUMP, mp);
19656 /* Use a control ping for synchronization */
19657 MPING (CONTROL_PING, mp_ping);
19665 api_ip6_mfib_dump (vat_main_t * vam)
19667 vl_api_ip6_mfib_dump_t *mp;
19668 vl_api_control_ping_t *mp_ping;
19671 M (IP6_MFIB_DUMP, mp);
19674 /* Use a control ping for synchronization */
19675 MPING (CONTROL_PING, mp_ping);
19683 api_classify_table_ids (vat_main_t * vam)
19685 vl_api_classify_table_ids_t *mp;
19688 /* Construct the API message */
19689 M (CLASSIFY_TABLE_IDS, mp);
19698 api_classify_table_by_interface (vat_main_t * vam)
19700 unformat_input_t *input = vam->input;
19701 vl_api_classify_table_by_interface_t *mp;
19703 u32 sw_if_index = ~0;
19705 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19707 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19709 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19714 if (sw_if_index == ~0)
19716 errmsg ("missing interface name or sw_if_index");
19720 /* Construct the API message */
19721 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19723 mp->sw_if_index = ntohl (sw_if_index);
19731 api_classify_table_info (vat_main_t * vam)
19733 unformat_input_t *input = vam->input;
19734 vl_api_classify_table_info_t *mp;
19738 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19740 if (unformat (input, "table_id %d", &table_id))
19745 if (table_id == ~0)
19747 errmsg ("missing table id");
19751 /* Construct the API message */
19752 M (CLASSIFY_TABLE_INFO, mp);
19754 mp->table_id = ntohl (table_id);
19762 api_classify_session_dump (vat_main_t * vam)
19764 unformat_input_t *input = vam->input;
19765 vl_api_classify_session_dump_t *mp;
19766 vl_api_control_ping_t *mp_ping;
19770 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19772 if (unformat (input, "table_id %d", &table_id))
19777 if (table_id == ~0)
19779 errmsg ("missing table id");
19783 /* Construct the API message */
19784 M (CLASSIFY_SESSION_DUMP, mp);
19786 mp->table_id = ntohl (table_id);
19789 /* Use a control ping for synchronization */
19790 MPING (CONTROL_PING, mp_ping);
19798 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19800 vat_main_t *vam = &vat_main;
19802 print (vam->ofp, "collector_address %U, collector_port %d, "
19803 "src_address %U, vrf_id %d, path_mtu %u, "
19804 "template_interval %u, udp_checksum %d",
19805 format_ip4_address, mp->collector_address,
19806 ntohs (mp->collector_port),
19807 format_ip4_address, mp->src_address,
19808 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19809 ntohl (mp->template_interval), mp->udp_checksum);
19812 vam->result_ready = 1;
19816 vl_api_ipfix_exporter_details_t_handler_json
19817 (vl_api_ipfix_exporter_details_t * mp)
19819 vat_main_t *vam = &vat_main;
19820 vat_json_node_t node;
19821 struct in_addr collector_address;
19822 struct in_addr src_address;
19824 vat_json_init_object (&node);
19825 clib_memcpy (&collector_address, &mp->collector_address,
19826 sizeof (collector_address));
19827 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19828 vat_json_object_add_uint (&node, "collector_port",
19829 ntohs (mp->collector_port));
19830 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19831 vat_json_object_add_ip4 (&node, "src_address", src_address);
19832 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19833 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19834 vat_json_object_add_uint (&node, "template_interval",
19835 ntohl (mp->template_interval));
19836 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19838 vat_json_print (vam->ofp, &node);
19839 vat_json_free (&node);
19841 vam->result_ready = 1;
19845 api_ipfix_exporter_dump (vat_main_t * vam)
19847 vl_api_ipfix_exporter_dump_t *mp;
19850 /* Construct the API message */
19851 M (IPFIX_EXPORTER_DUMP, mp);
19860 api_ipfix_classify_stream_dump (vat_main_t * vam)
19862 vl_api_ipfix_classify_stream_dump_t *mp;
19865 /* Construct the API message */
19866 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19877 vl_api_ipfix_classify_stream_details_t_handler
19878 (vl_api_ipfix_classify_stream_details_t * mp)
19880 vat_main_t *vam = &vat_main;
19881 print (vam->ofp, "domain_id %d, src_port %d",
19882 ntohl (mp->domain_id), ntohs (mp->src_port));
19884 vam->result_ready = 1;
19888 vl_api_ipfix_classify_stream_details_t_handler_json
19889 (vl_api_ipfix_classify_stream_details_t * mp)
19891 vat_main_t *vam = &vat_main;
19892 vat_json_node_t node;
19894 vat_json_init_object (&node);
19895 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19896 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19898 vat_json_print (vam->ofp, &node);
19899 vat_json_free (&node);
19901 vam->result_ready = 1;
19905 api_ipfix_classify_table_dump (vat_main_t * vam)
19907 vl_api_ipfix_classify_table_dump_t *mp;
19908 vl_api_control_ping_t *mp_ping;
19911 if (!vam->json_output)
19913 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19914 "transport_protocol");
19917 /* Construct the API message */
19918 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19923 /* Use a control ping for synchronization */
19924 MPING (CONTROL_PING, mp_ping);
19932 vl_api_ipfix_classify_table_details_t_handler
19933 (vl_api_ipfix_classify_table_details_t * mp)
19935 vat_main_t *vam = &vat_main;
19936 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19937 mp->transport_protocol);
19941 vl_api_ipfix_classify_table_details_t_handler_json
19942 (vl_api_ipfix_classify_table_details_t * mp)
19944 vat_json_node_t *node = NULL;
19945 vat_main_t *vam = &vat_main;
19947 if (VAT_JSON_ARRAY != vam->json_tree.type)
19949 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19950 vat_json_init_array (&vam->json_tree);
19953 node = vat_json_array_add (&vam->json_tree);
19954 vat_json_init_object (node);
19956 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19957 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19958 vat_json_object_add_uint (node, "transport_protocol",
19959 mp->transport_protocol);
19963 api_sw_interface_span_enable_disable (vat_main_t * vam)
19965 unformat_input_t *i = vam->input;
19966 vl_api_sw_interface_span_enable_disable_t *mp;
19967 u32 src_sw_if_index = ~0;
19968 u32 dst_sw_if_index = ~0;
19973 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19976 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19978 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19982 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19984 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19986 else if (unformat (i, "disable"))
19988 else if (unformat (i, "rx"))
19990 else if (unformat (i, "tx"))
19992 else if (unformat (i, "both"))
19994 else if (unformat (i, "l2"))
20000 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
20002 mp->sw_if_index_from = htonl (src_sw_if_index);
20003 mp->sw_if_index_to = htonl (dst_sw_if_index);
20013 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
20016 vat_main_t *vam = &vat_main;
20017 u8 *sw_if_from_name = 0;
20018 u8 *sw_if_to_name = 0;
20019 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20020 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20021 char *states[] = { "none", "rx", "tx", "both" };
20025 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20027 if ((u32) p->value[0] == sw_if_index_from)
20029 sw_if_from_name = (u8 *)(p->key);
20033 if ((u32) p->value[0] == sw_if_index_to)
20035 sw_if_to_name = (u8 *)(p->key);
20036 if (sw_if_from_name)
20041 print (vam->ofp, "%20s => %20s (%s)",
20042 sw_if_from_name, sw_if_to_name, states[mp->state]);
20046 vl_api_sw_interface_span_details_t_handler_json
20047 (vl_api_sw_interface_span_details_t * mp)
20049 vat_main_t *vam = &vat_main;
20050 vat_json_node_t *node = NULL;
20051 u8 *sw_if_from_name = 0;
20052 u8 *sw_if_to_name = 0;
20053 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20054 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20058 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20060 if ((u32) p->value[0] == sw_if_index_from)
20062 sw_if_from_name = (u8 *)(p->key);
20066 if ((u32) p->value[0] == sw_if_index_to)
20068 sw_if_to_name = (u8 *)(p->key);
20069 if (sw_if_from_name)
20075 if (VAT_JSON_ARRAY != vam->json_tree.type)
20077 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20078 vat_json_init_array (&vam->json_tree);
20080 node = vat_json_array_add (&vam->json_tree);
20082 vat_json_init_object (node);
20083 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
20084 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
20085 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
20086 if (0 != sw_if_to_name)
20088 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
20090 vat_json_object_add_uint (node, "state", mp->state);
20094 api_sw_interface_span_dump (vat_main_t * vam)
20096 unformat_input_t *input = vam->input;
20097 vl_api_sw_interface_span_dump_t *mp;
20098 vl_api_control_ping_t *mp_ping;
20102 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20104 if (unformat (input, "l2"))
20110 M (SW_INTERFACE_SPAN_DUMP, mp);
20114 /* Use a control ping for synchronization */
20115 MPING (CONTROL_PING, mp_ping);
20123 api_pg_create_interface (vat_main_t * vam)
20125 unformat_input_t *input = vam->input;
20126 vl_api_pg_create_interface_t *mp;
20130 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20132 if (unformat (input, "if_id %d", &if_id))
20139 errmsg ("missing pg interface index");
20143 /* Construct the API message */
20144 M (PG_CREATE_INTERFACE, mp);
20146 mp->interface_id = ntohl (if_id);
20154 api_pg_capture (vat_main_t * vam)
20156 unformat_input_t *input = vam->input;
20157 vl_api_pg_capture_t *mp;
20162 u8 pcap_file_set = 0;
20165 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20167 if (unformat (input, "if_id %d", &if_id))
20169 else if (unformat (input, "pcap %s", &pcap_file))
20171 else if (unformat (input, "count %d", &count))
20173 else if (unformat (input, "disable"))
20180 errmsg ("missing pg interface index");
20183 if (pcap_file_set > 0)
20185 if (vec_len (pcap_file) > 255)
20187 errmsg ("pcap file name is too long");
20192 u32 name_len = vec_len (pcap_file);
20193 /* Construct the API message */
20194 M (PG_CAPTURE, mp);
20196 mp->interface_id = ntohl (if_id);
20197 mp->is_enabled = enable;
20198 mp->count = ntohl (count);
20199 mp->pcap_name_length = ntohl (name_len);
20200 if (pcap_file_set != 0)
20202 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
20204 vec_free (pcap_file);
20212 api_pg_enable_disable (vat_main_t * vam)
20214 unformat_input_t *input = vam->input;
20215 vl_api_pg_enable_disable_t *mp;
20218 u8 stream_name_set = 0;
20219 u8 *stream_name = 0;
20221 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20223 if (unformat (input, "stream %s", &stream_name))
20224 stream_name_set = 1;
20225 else if (unformat (input, "disable"))
20231 if (stream_name_set > 0)
20233 if (vec_len (stream_name) > 255)
20235 errmsg ("stream name too long");
20240 u32 name_len = vec_len (stream_name);
20241 /* Construct the API message */
20242 M (PG_ENABLE_DISABLE, mp);
20244 mp->is_enabled = enable;
20245 if (stream_name_set != 0)
20247 mp->stream_name_length = ntohl (name_len);
20248 clib_memcpy (mp->stream_name, stream_name, name_len);
20250 vec_free (stream_name);
20258 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
20260 unformat_input_t *input = vam->input;
20261 vl_api_ip_source_and_port_range_check_add_del_t *mp;
20263 u16 *low_ports = 0;
20264 u16 *high_ports = 0;
20267 ip4_address_t ip4_addr;
20268 ip6_address_t ip6_addr;
20277 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20279 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
20285 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
20290 else if (unformat (input, "vrf %d", &vrf_id))
20292 else if (unformat (input, "del"))
20294 else if (unformat (input, "port %d", &tmp))
20296 if (tmp == 0 || tmp > 65535)
20298 errmsg ("port %d out of range", tmp);
20302 this_hi = this_low + 1;
20303 vec_add1 (low_ports, this_low);
20304 vec_add1 (high_ports, this_hi);
20306 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
20308 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
20310 errmsg ("incorrect range parameters");
20314 /* Note: in debug CLI +1 is added to high before
20315 passing to real fn that does "the work"
20316 (ip_source_and_port_range_check_add_del).
20317 This fn is a wrapper around the binary API fn a
20318 control plane will call, which expects this increment
20319 to have occurred. Hence letting the binary API control
20320 plane fn do the increment for consistency between VAT
20321 and other control planes.
20324 vec_add1 (low_ports, this_low);
20325 vec_add1 (high_ports, this_hi);
20331 if (prefix_set == 0)
20333 errmsg ("<address>/<mask> not specified");
20339 errmsg ("VRF ID required, not specified");
20346 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20350 if (vec_len (low_ports) == 0)
20352 errmsg ("At least one port or port range required");
20356 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
20358 mp->is_add = is_add;
20363 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
20368 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
20371 mp->mask_length = length;
20372 mp->number_of_ranges = vec_len (low_ports);
20374 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
20375 vec_free (low_ports);
20377 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
20378 vec_free (high_ports);
20380 mp->vrf_id = ntohl (vrf_id);
20388 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
20390 unformat_input_t *input = vam->input;
20391 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
20392 u32 sw_if_index = ~0;
20394 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
20395 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
20399 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20401 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20403 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20405 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
20407 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
20409 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
20411 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
20413 else if (unformat (input, "del"))
20419 if (sw_if_index == ~0)
20421 errmsg ("Interface required but not specified");
20427 errmsg ("VRF ID required but not specified");
20431 if (tcp_out_vrf_id == 0
20432 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
20435 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20439 /* Construct the API message */
20440 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
20442 mp->sw_if_index = ntohl (sw_if_index);
20443 mp->is_add = is_add;
20444 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20445 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20446 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20447 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20452 /* Wait for a reply... */
20458 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
20460 unformat_input_t *i = vam->input;
20461 vl_api_ipsec_gre_add_del_tunnel_t *mp;
20462 u32 local_sa_id = 0;
20463 u32 remote_sa_id = 0;
20464 ip4_address_t src_address;
20465 ip4_address_t dst_address;
20469 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20471 if (unformat (i, "local_sa %d", &local_sa_id))
20473 else if (unformat (i, "remote_sa %d", &remote_sa_id))
20475 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
20477 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
20479 else if (unformat (i, "del"))
20483 clib_warning ("parse error '%U'", format_unformat_error, i);
20488 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
20490 mp->local_sa_id = ntohl (local_sa_id);
20491 mp->remote_sa_id = ntohl (remote_sa_id);
20492 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
20493 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
20494 mp->is_add = is_add;
20502 api_punt (vat_main_t * vam)
20504 unformat_input_t *i = vam->input;
20512 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20514 if (unformat (i, "ip %d", &ipv))
20516 else if (unformat (i, "protocol %d", &protocol))
20518 else if (unformat (i, "port %d", &port))
20520 else if (unformat (i, "del"))
20524 clib_warning ("parse error '%U'", format_unformat_error, i);
20531 mp->is_add = (u8) is_add;
20532 mp->ipv = (u8) ipv;
20533 mp->l4_protocol = (u8) protocol;
20534 mp->l4_port = htons ((u16) port);
20541 static void vl_api_ipsec_gre_tunnel_details_t_handler
20542 (vl_api_ipsec_gre_tunnel_details_t * mp)
20544 vat_main_t *vam = &vat_main;
20546 print (vam->ofp, "%11d%15U%15U%14d%14d",
20547 ntohl (mp->sw_if_index),
20548 format_ip4_address, &mp->src_address,
20549 format_ip4_address, &mp->dst_address,
20550 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
20553 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
20554 (vl_api_ipsec_gre_tunnel_details_t * mp)
20556 vat_main_t *vam = &vat_main;
20557 vat_json_node_t *node = NULL;
20558 struct in_addr ip4;
20560 if (VAT_JSON_ARRAY != vam->json_tree.type)
20562 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20563 vat_json_init_array (&vam->json_tree);
20565 node = vat_json_array_add (&vam->json_tree);
20567 vat_json_init_object (node);
20568 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20569 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
20570 vat_json_object_add_ip4 (node, "src_address", ip4);
20571 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
20572 vat_json_object_add_ip4 (node, "dst_address", ip4);
20573 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
20574 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
20578 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
20580 unformat_input_t *i = vam->input;
20581 vl_api_ipsec_gre_tunnel_dump_t *mp;
20582 vl_api_control_ping_t *mp_ping;
20584 u8 sw_if_index_set = 0;
20587 /* Parse args required to build the message */
20588 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20590 if (unformat (i, "sw_if_index %d", &sw_if_index))
20591 sw_if_index_set = 1;
20596 if (sw_if_index_set == 0)
20601 if (!vam->json_output)
20603 print (vam->ofp, "%11s%15s%15s%14s%14s",
20604 "sw_if_index", "src_address", "dst_address",
20605 "local_sa_id", "remote_sa_id");
20608 /* Get list of gre-tunnel interfaces */
20609 M (IPSEC_GRE_TUNNEL_DUMP, mp);
20611 mp->sw_if_index = htonl (sw_if_index);
20615 /* Use a control ping for synchronization */
20616 MPING (CONTROL_PING, mp_ping);
20624 api_delete_subif (vat_main_t * vam)
20626 unformat_input_t *i = vam->input;
20627 vl_api_delete_subif_t *mp;
20628 u32 sw_if_index = ~0;
20631 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20633 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20635 if (unformat (i, "sw_if_index %d", &sw_if_index))
20641 if (sw_if_index == ~0)
20643 errmsg ("missing sw_if_index");
20647 /* Construct the API message */
20648 M (DELETE_SUBIF, mp);
20649 mp->sw_if_index = ntohl (sw_if_index);
20656 #define foreach_pbb_vtr_op \
20657 _("disable", L2_VTR_DISABLED) \
20658 _("pop", L2_VTR_POP_2) \
20659 _("push", L2_VTR_PUSH_2)
20662 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20664 unformat_input_t *i = vam->input;
20665 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20666 u32 sw_if_index = ~0, vtr_op = ~0;
20667 u16 outer_tag = ~0;
20668 u8 dmac[6], smac[6];
20669 u8 dmac_set = 0, smac_set = 0;
20675 /* Shut up coverity */
20676 memset (dmac, 0, sizeof (dmac));
20677 memset (smac, 0, sizeof (smac));
20679 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20681 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20683 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20685 else if (unformat (i, "vtr_op %d", &vtr_op))
20687 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20690 else if (unformat (i, "translate_pbb_stag"))
20692 if (unformat (i, "%d", &tmp))
20694 vtr_op = L2_VTR_TRANSLATE_2_1;
20700 ("translate_pbb_stag operation requires outer tag definition");
20704 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20706 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20708 else if (unformat (i, "sid %d", &sid))
20710 else if (unformat (i, "vlanid %d", &tmp))
20714 clib_warning ("parse error '%U'", format_unformat_error, i);
20719 if ((sw_if_index == ~0) || (vtr_op == ~0))
20721 errmsg ("missing sw_if_index or vtr operation");
20724 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20725 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20728 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20732 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20733 mp->sw_if_index = ntohl (sw_if_index);
20734 mp->vtr_op = ntohl (vtr_op);
20735 mp->outer_tag = ntohs (outer_tag);
20736 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20737 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20738 mp->b_vlanid = ntohs (vlanid);
20739 mp->i_sid = ntohl (sid);
20747 api_flow_classify_set_interface (vat_main_t * vam)
20749 unformat_input_t *i = vam->input;
20750 vl_api_flow_classify_set_interface_t *mp;
20752 int sw_if_index_set;
20753 u32 ip4_table_index = ~0;
20754 u32 ip6_table_index = ~0;
20758 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20760 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20761 sw_if_index_set = 1;
20762 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20763 sw_if_index_set = 1;
20764 else if (unformat (i, "del"))
20766 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20768 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20772 clib_warning ("parse error '%U'", format_unformat_error, i);
20777 if (sw_if_index_set == 0)
20779 errmsg ("missing interface name or sw_if_index");
20783 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20785 mp->sw_if_index = ntohl (sw_if_index);
20786 mp->ip4_table_index = ntohl (ip4_table_index);
20787 mp->ip6_table_index = ntohl (ip6_table_index);
20788 mp->is_add = is_add;
20796 api_flow_classify_dump (vat_main_t * vam)
20798 unformat_input_t *i = vam->input;
20799 vl_api_flow_classify_dump_t *mp;
20800 vl_api_control_ping_t *mp_ping;
20801 u8 type = FLOW_CLASSIFY_N_TABLES;
20804 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20808 errmsg ("classify table type must be specified");
20812 if (!vam->json_output)
20814 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20817 M (FLOW_CLASSIFY_DUMP, mp);
20822 /* Use a control ping for synchronization */
20823 MPING (CONTROL_PING, mp_ping);
20826 /* Wait for a reply... */
20832 api_feature_enable_disable (vat_main_t * vam)
20834 unformat_input_t *i = vam->input;
20835 vl_api_feature_enable_disable_t *mp;
20837 u8 *feature_name = 0;
20838 u32 sw_if_index = ~0;
20842 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20844 if (unformat (i, "arc_name %s", &arc_name))
20846 else if (unformat (i, "feature_name %s", &feature_name))
20849 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20851 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20853 else if (unformat (i, "disable"))
20861 errmsg ("missing arc name");
20864 if (vec_len (arc_name) > 63)
20866 errmsg ("arc name too long");
20869 if (feature_name == 0)
20871 errmsg ("missing feature name");
20874 if (vec_len (feature_name) > 63)
20876 errmsg ("feature name too long");
20879 if (sw_if_index == ~0)
20881 errmsg ("missing interface name or sw_if_index");
20885 /* Construct the API message */
20886 M (FEATURE_ENABLE_DISABLE, mp);
20887 mp->sw_if_index = ntohl (sw_if_index);
20888 mp->enable = enable;
20889 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20890 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20891 vec_free (arc_name);
20892 vec_free (feature_name);
20900 api_sw_interface_tag_add_del (vat_main_t * vam)
20902 unformat_input_t *i = vam->input;
20903 vl_api_sw_interface_tag_add_del_t *mp;
20904 u32 sw_if_index = ~0;
20909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20911 if (unformat (i, "tag %s", &tag))
20913 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20915 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20917 else if (unformat (i, "del"))
20923 if (sw_if_index == ~0)
20925 errmsg ("missing interface name or sw_if_index");
20929 if (enable && (tag == 0))
20931 errmsg ("no tag specified");
20935 /* Construct the API message */
20936 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20937 mp->sw_if_index = ntohl (sw_if_index);
20938 mp->is_add = enable;
20940 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20948 static void vl_api_l2_xconnect_details_t_handler
20949 (vl_api_l2_xconnect_details_t * mp)
20951 vat_main_t *vam = &vat_main;
20953 print (vam->ofp, "%15d%15d",
20954 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20957 static void vl_api_l2_xconnect_details_t_handler_json
20958 (vl_api_l2_xconnect_details_t * mp)
20960 vat_main_t *vam = &vat_main;
20961 vat_json_node_t *node = NULL;
20963 if (VAT_JSON_ARRAY != vam->json_tree.type)
20965 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20966 vat_json_init_array (&vam->json_tree);
20968 node = vat_json_array_add (&vam->json_tree);
20970 vat_json_init_object (node);
20971 vat_json_object_add_uint (node, "rx_sw_if_index",
20972 ntohl (mp->rx_sw_if_index));
20973 vat_json_object_add_uint (node, "tx_sw_if_index",
20974 ntohl (mp->tx_sw_if_index));
20978 api_l2_xconnect_dump (vat_main_t * vam)
20980 vl_api_l2_xconnect_dump_t *mp;
20981 vl_api_control_ping_t *mp_ping;
20984 if (!vam->json_output)
20986 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20989 M (L2_XCONNECT_DUMP, mp);
20993 /* Use a control ping for synchronization */
20994 MPING (CONTROL_PING, mp_ping);
21002 api_sw_interface_set_mtu (vat_main_t * vam)
21004 unformat_input_t *i = vam->input;
21005 vl_api_sw_interface_set_mtu_t *mp;
21006 u32 sw_if_index = ~0;
21010 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21012 if (unformat (i, "mtu %d", &mtu))
21014 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21016 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21022 if (sw_if_index == ~0)
21024 errmsg ("missing interface name or sw_if_index");
21030 errmsg ("no mtu specified");
21034 /* Construct the API message */
21035 M (SW_INTERFACE_SET_MTU, mp);
21036 mp->sw_if_index = ntohl (sw_if_index);
21037 mp->mtu = ntohs ((u16) mtu);
21045 api_p2p_ethernet_add (vat_main_t * vam)
21047 unformat_input_t *i = vam->input;
21048 vl_api_p2p_ethernet_add_t *mp;
21049 u32 parent_if_index = ~0;
21055 memset (remote_mac, 0, sizeof (remote_mac));
21056 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21058 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21060 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21064 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21066 else if (unformat (i, "sub_id %d", &sub_id))
21070 clib_warning ("parse error '%U'", format_unformat_error, i);
21075 if (parent_if_index == ~0)
21077 errmsg ("missing interface name or sw_if_index");
21082 errmsg ("missing remote mac address");
21087 errmsg ("missing sub-interface id");
21091 M (P2P_ETHERNET_ADD, mp);
21092 mp->parent_if_index = ntohl (parent_if_index);
21093 mp->subif_id = ntohl (sub_id);
21094 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21102 api_p2p_ethernet_del (vat_main_t * vam)
21104 unformat_input_t *i = vam->input;
21105 vl_api_p2p_ethernet_del_t *mp;
21106 u32 parent_if_index = ~0;
21111 memset (remote_mac, 0, sizeof (remote_mac));
21112 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21114 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21116 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21120 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21124 clib_warning ("parse error '%U'", format_unformat_error, i);
21129 if (parent_if_index == ~0)
21131 errmsg ("missing interface name or sw_if_index");
21136 errmsg ("missing remote mac address");
21140 M (P2P_ETHERNET_DEL, mp);
21141 mp->parent_if_index = ntohl (parent_if_index);
21142 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21150 api_lldp_config (vat_main_t * vam)
21152 unformat_input_t *i = vam->input;
21153 vl_api_lldp_config_t *mp;
21155 int tx_interval = 0;
21156 u8 *sys_name = NULL;
21159 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21161 if (unformat (i, "system-name %s", &sys_name))
21163 else if (unformat (i, "tx-hold %d", &tx_hold))
21165 else if (unformat (i, "tx-interval %d", &tx_interval))
21169 clib_warning ("parse error '%U'", format_unformat_error, i);
21174 vec_add1 (sys_name, 0);
21176 M (LLDP_CONFIG, mp);
21177 mp->tx_hold = htonl (tx_hold);
21178 mp->tx_interval = htonl (tx_interval);
21179 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
21180 vec_free (sys_name);
21188 api_sw_interface_set_lldp (vat_main_t * vam)
21190 unformat_input_t *i = vam->input;
21191 vl_api_sw_interface_set_lldp_t *mp;
21192 u32 sw_if_index = ~0;
21194 u8 *port_desc = NULL, *mgmt_oid = NULL;
21195 ip4_address_t ip4_addr;
21196 ip6_address_t ip6_addr;
21199 memset (&ip4_addr, 0, sizeof (ip4_addr));
21200 memset (&ip6_addr, 0, sizeof (ip6_addr));
21202 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21204 if (unformat (i, "disable"))
21207 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21209 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21211 else if (unformat (i, "port-desc %s", &port_desc))
21213 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
21215 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
21217 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
21223 if (sw_if_index == ~0)
21225 errmsg ("missing interface name or sw_if_index");
21229 /* Construct the API message */
21230 vec_add1 (port_desc, 0);
21231 vec_add1 (mgmt_oid, 0);
21232 M (SW_INTERFACE_SET_LLDP, mp);
21233 mp->sw_if_index = ntohl (sw_if_index);
21234 mp->enable = enable;
21235 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
21236 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
21237 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
21238 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
21239 vec_free (port_desc);
21240 vec_free (mgmt_oid);
21248 api_tcp_configure_src_addresses (vat_main_t * vam)
21250 vl_api_tcp_configure_src_addresses_t *mp;
21251 unformat_input_t *i = vam->input;
21252 ip4_address_t v4first, v4last;
21253 ip6_address_t v6first, v6last;
21258 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21260 if (unformat (i, "%U - %U",
21261 unformat_ip4_address, &v4first,
21262 unformat_ip4_address, &v4last))
21266 errmsg ("one range per message (range already set)");
21271 else if (unformat (i, "%U - %U",
21272 unformat_ip6_address, &v6first,
21273 unformat_ip6_address, &v6last))
21277 errmsg ("one range per message (range already set)");
21282 else if (unformat (i, "vrf %d", &vrf_id))
21288 if (range_set == 0)
21290 errmsg ("address range not set");
21294 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
21295 mp->vrf_id = ntohl (vrf_id);
21297 if (range_set == 2)
21300 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
21301 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
21306 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
21307 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
21315 api_app_namespace_add_del (vat_main_t * vam)
21317 vl_api_app_namespace_add_del_t *mp;
21318 unformat_input_t *i = vam->input;
21319 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
21320 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
21324 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21326 if (unformat (i, "id %_%v%_", &ns_id))
21328 else if (unformat (i, "secret %lu", &secret))
21330 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21331 sw_if_index_set = 1;
21332 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
21334 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
21339 if (!ns_id || !secret_set || !sw_if_index_set)
21341 errmsg ("namespace id, secret and sw_if_index must be set");
21344 if (vec_len (ns_id) > 64)
21346 errmsg ("namespace id too long");
21349 M (APP_NAMESPACE_ADD_DEL, mp);
21351 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
21352 mp->namespace_id_len = vec_len (ns_id);
21353 mp->secret = clib_host_to_net_u64 (secret);
21354 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21355 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
21356 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
21364 api_memfd_segment_create (vat_main_t * vam)
21366 #if VPP_API_TEST_BUILTIN == 0
21367 unformat_input_t *i = vam->input;
21368 vl_api_memfd_segment_create_t *mp;
21369 u64 size = 64 << 20;
21372 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21374 if (unformat (i, "size %U", unformat_memory_size, &size))
21380 M (MEMFD_SEGMENT_CREATE, mp);
21381 mp->requested_size = size;
21387 errmsg ("memfd_segment_create (builtin) not supported");
21393 api_dns_enable_disable (vat_main_t * vam)
21395 unformat_input_t *line_input = vam->input;
21396 vl_api_dns_enable_disable_t *mp;
21397 u8 enable_disable = 1;
21400 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21402 if (unformat (line_input, "disable"))
21403 enable_disable = 0;
21404 if (unformat (line_input, "enable"))
21405 enable_disable = 1;
21410 /* Construct the API message */
21411 M (DNS_ENABLE_DISABLE, mp);
21412 mp->enable = enable_disable;
21416 /* Wait for the reply */
21422 api_dns_resolve_name (vat_main_t * vam)
21424 unformat_input_t *line_input = vam->input;
21425 vl_api_dns_resolve_name_t *mp;
21429 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21431 if (unformat (line_input, "%s", &name))
21437 if (vec_len (name) > 127)
21439 errmsg ("name too long");
21443 /* Construct the API message */
21444 M (DNS_RESOLVE_NAME, mp);
21445 memcpy (mp->name, name, vec_len (name));
21450 /* Wait for the reply */
21456 api_dns_resolve_ip (vat_main_t * vam)
21458 unformat_input_t *line_input = vam->input;
21459 vl_api_dns_resolve_ip_t *mp;
21461 ip4_address_t addr4;
21462 ip6_address_t addr6;
21465 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21467 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
21469 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
21477 errmsg ("missing address");
21481 /* Construct the API message */
21482 M (DNS_RESOLVE_IP, mp);
21483 mp->is_ip6 = is_ip6;
21485 memcpy (mp->address, &addr6, sizeof (addr6));
21487 memcpy (mp->address, &addr4, sizeof (addr4));
21491 /* Wait for the reply */
21497 api_dns_name_server_add_del (vat_main_t * vam)
21499 unformat_input_t *i = vam->input;
21500 vl_api_dns_name_server_add_del_t *mp;
21502 ip6_address_t ip6_server;
21503 ip4_address_t ip4_server;
21508 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21510 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
21512 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
21514 else if (unformat (i, "del"))
21518 clib_warning ("parse error '%U'", format_unformat_error, i);
21523 if (ip4_set && ip6_set)
21525 errmsg ("Only one server address allowed per message");
21528 if ((ip4_set + ip6_set) == 0)
21530 errmsg ("Server address required");
21534 /* Construct the API message */
21535 M (DNS_NAME_SERVER_ADD_DEL, mp);
21539 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
21544 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
21548 mp->is_add = is_add;
21553 /* Wait for a reply, return good/bad news */
21559 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
21561 vat_main_t *vam = &vat_main;
21566 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21567 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21568 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
21569 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
21570 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21571 clib_net_to_host_u32 (mp->action_index), mp->tag);
21576 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21577 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21578 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
21579 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
21580 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21581 clib_net_to_host_u32 (mp->action_index), mp->tag);
21586 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
21589 vat_main_t *vam = &vat_main;
21590 vat_json_node_t *node = NULL;
21591 struct in6_addr ip6;
21592 struct in_addr ip4;
21594 if (VAT_JSON_ARRAY != vam->json_tree.type)
21596 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21597 vat_json_init_array (&vam->json_tree);
21599 node = vat_json_array_add (&vam->json_tree);
21600 vat_json_init_object (node);
21602 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
21603 vat_json_object_add_uint (node, "appns_index",
21604 clib_net_to_host_u32 (mp->appns_index));
21605 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
21606 vat_json_object_add_uint (node, "scope", mp->scope);
21607 vat_json_object_add_uint (node, "action_index",
21608 clib_net_to_host_u32 (mp->action_index));
21609 vat_json_object_add_uint (node, "lcl_port",
21610 clib_net_to_host_u16 (mp->lcl_port));
21611 vat_json_object_add_uint (node, "rmt_port",
21612 clib_net_to_host_u16 (mp->rmt_port));
21613 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
21614 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
21615 vat_json_object_add_string_copy (node, "tag", mp->tag);
21618 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
21619 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
21620 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
21621 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
21625 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
21626 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
21627 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
21628 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
21633 api_session_rule_add_del (vat_main_t * vam)
21635 vl_api_session_rule_add_del_t *mp;
21636 unformat_input_t *i = vam->input;
21637 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
21638 u32 appns_index = 0, scope = 0;
21639 ip4_address_t lcl_ip4, rmt_ip4;
21640 ip6_address_t lcl_ip6, rmt_ip6;
21641 u8 is_ip4 = 1, conn_set = 0;
21642 u8 is_add = 1, *tag = 0;
21645 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21647 if (unformat (i, "del"))
21649 else if (unformat (i, "add"))
21651 else if (unformat (i, "proto tcp"))
21653 else if (unformat (i, "proto udp"))
21655 else if (unformat (i, "appns %d", &appns_index))
21657 else if (unformat (i, "scope %d", &scope))
21659 else if (unformat (i, "tag %_%v%_", &tag))
21663 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
21664 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
21672 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
21673 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
21679 else if (unformat (i, "action %d", &action))
21684 if (proto == ~0 || !conn_set || action == ~0)
21686 errmsg ("transport proto, connection and action must be set");
21692 errmsg ("scope should be 0-3");
21696 M (SESSION_RULE_ADD_DEL, mp);
21698 mp->is_ip4 = is_ip4;
21699 mp->transport_proto = proto;
21700 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
21701 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
21702 mp->lcl_plen = lcl_plen;
21703 mp->rmt_plen = rmt_plen;
21704 mp->action_index = clib_host_to_net_u32 (action);
21705 mp->appns_index = clib_host_to_net_u32 (appns_index);
21707 mp->is_add = is_add;
21710 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
21711 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
21715 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
21716 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
21720 clib_memcpy (mp->tag, tag, vec_len (tag));
21730 api_session_rules_dump (vat_main_t * vam)
21732 vl_api_session_rules_dump_t *mp;
21733 vl_api_control_ping_t *mp_ping;
21736 if (!vam->json_output)
21738 print (vam->ofp, "%=20s", "Session Rules");
21741 M (SESSION_RULES_DUMP, mp);
21745 /* Use a control ping for synchronization */
21746 MPING (CONTROL_PING, mp_ping);
21749 /* Wait for a reply... */
21755 api_ip_container_proxy_add_del (vat_main_t * vam)
21757 vl_api_ip_container_proxy_add_del_t *mp;
21758 unformat_input_t *i = vam->input;
21759 u32 plen = ~0, sw_if_index = ~0;
21766 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21768 if (unformat (i, "del"))
21770 else if (unformat (i, "add"))
21772 if (unformat (i, "%U", unformat_ip4_address, &ip4))
21777 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
21782 else if (unformat (i, "sw_if_index %u", &sw_if_index))
21787 if (sw_if_index == ~0 || plen == ~0)
21789 errmsg ("address and sw_if_index must be set");
21793 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
21795 mp->is_ip4 = is_ip4;
21796 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21798 mp->is_add = is_add;
21800 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
21802 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
21810 q_or_quit (vat_main_t * vam)
21812 #if VPP_API_TEST_BUILTIN == 0
21813 longjmp (vam->jump_buf, 1);
21815 return 0; /* not so much */
21819 q (vat_main_t * vam)
21821 return q_or_quit (vam);
21825 quit (vat_main_t * vam)
21827 return q_or_quit (vam);
21831 comment (vat_main_t * vam)
21837 cmd_cmp (void *a1, void *a2)
21842 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21846 help (vat_main_t * vam)
21851 unformat_input_t *i = vam->input;
21854 if (unformat (i, "%s", &name))
21858 vec_add1 (name, 0);
21860 hs = hash_get_mem (vam->help_by_name, name);
21862 print (vam->ofp, "usage: %s %s", name, hs[0]);
21864 print (vam->ofp, "No such msg / command '%s'", name);
21869 print (vam->ofp, "Help is available for the following:");
21872 hash_foreach_pair (p, vam->function_by_name,
21874 vec_add1 (cmds, (u8 *)(p->key));
21878 vec_sort_with_function (cmds, cmd_cmp);
21880 for (j = 0; j < vec_len (cmds); j++)
21881 print (vam->ofp, "%s", cmds[j]);
21888 set (vat_main_t * vam)
21890 u8 *name = 0, *value = 0;
21891 unformat_input_t *i = vam->input;
21893 if (unformat (i, "%s", &name))
21895 /* The input buffer is a vector, not a string. */
21896 value = vec_dup (i->buffer);
21897 vec_delete (value, i->index, 0);
21898 /* Almost certainly has a trailing newline */
21899 if (value[vec_len (value) - 1] == '\n')
21900 value[vec_len (value) - 1] = 0;
21901 /* Make sure it's a proper string, one way or the other */
21902 vec_add1 (value, 0);
21903 (void) clib_macro_set_value (&vam->macro_main,
21904 (char *) name, (char *) value);
21907 errmsg ("usage: set <name> <value>");
21915 unset (vat_main_t * vam)
21919 if (unformat (vam->input, "%s", &name))
21920 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21921 errmsg ("unset: %s wasn't set", name);
21934 macro_sort_cmp (void *a1, void *a2)
21936 macro_sort_t *s1 = a1;
21937 macro_sort_t *s2 = a2;
21939 return strcmp ((char *) (s1->name), (char *) (s2->name));
21943 dump_macro_table (vat_main_t * vam)
21945 macro_sort_t *sort_me = 0, *sm;
21950 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21952 vec_add2 (sort_me, sm, 1);
21953 sm->name = (u8 *)(p->key);
21954 sm->value = (u8 *) (p->value[0]);
21958 vec_sort_with_function (sort_me, macro_sort_cmp);
21960 if (vec_len (sort_me))
21961 print (vam->ofp, "%-15s%s", "Name", "Value");
21963 print (vam->ofp, "The macro table is empty...");
21965 for (i = 0; i < vec_len (sort_me); i++)
21966 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21971 dump_node_table (vat_main_t * vam)
21974 vlib_node_t *node, *next_node;
21976 if (vec_len (vam->graph_nodes) == 0)
21978 print (vam->ofp, "Node table empty, issue get_node_graph...");
21982 for (i = 0; i < vec_len (vam->graph_nodes); i++)
21984 node = vam->graph_nodes[i];
21985 print (vam->ofp, "[%d] %s", i, node->name);
21986 for (j = 0; j < vec_len (node->next_nodes); j++)
21988 if (node->next_nodes[j] != ~0)
21990 next_node = vam->graph_nodes[node->next_nodes[j]];
21991 print (vam->ofp, " [%d] %s", j, next_node->name);
21999 value_sort_cmp (void *a1, void *a2)
22001 name_sort_t *n1 = a1;
22002 name_sort_t *n2 = a2;
22004 if (n1->value < n2->value)
22006 if (n1->value > n2->value)
22013 dump_msg_api_table (vat_main_t * vam)
22015 api_main_t *am = &api_main;
22016 name_sort_t *nses = 0, *ns;
22021 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
22023 vec_add2 (nses, ns, 1);
22024 ns->name = (u8 *)(hp->key);
22025 ns->value = (u32) hp->value[0];
22029 vec_sort_with_function (nses, value_sort_cmp);
22031 for (i = 0; i < vec_len (nses); i++)
22032 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
22038 get_msg_id (vat_main_t * vam)
22043 if (unformat (vam->input, "%s", &name_and_crc))
22045 message_index = vl_api_get_msg_index (name_and_crc);
22046 if (message_index == ~0)
22048 print (vam->ofp, " '%s' not found", name_and_crc);
22051 print (vam->ofp, " '%s' has message index %d",
22052 name_and_crc, message_index);
22055 errmsg ("name_and_crc required...");
22060 search_node_table (vat_main_t * vam)
22062 unformat_input_t *line_input = vam->input;
22065 vlib_node_t *node, *next_node;
22068 if (vam->graph_node_index_by_name == 0)
22070 print (vam->ofp, "Node table empty, issue get_node_graph...");
22074 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22076 if (unformat (line_input, "%s", &node_to_find))
22078 vec_add1 (node_to_find, 0);
22079 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
22082 print (vam->ofp, "%s not found...", node_to_find);
22085 node = vam->graph_nodes[p[0]];
22086 print (vam->ofp, "[%d] %s", p[0], node->name);
22087 for (j = 0; j < vec_len (node->next_nodes); j++)
22089 if (node->next_nodes[j] != ~0)
22091 next_node = vam->graph_nodes[node->next_nodes[j]];
22092 print (vam->ofp, " [%d] %s", j, next_node->name);
22099 clib_warning ("parse error '%U'", format_unformat_error,
22105 vec_free (node_to_find);
22114 script (vat_main_t * vam)
22116 #if (VPP_API_TEST_BUILTIN==0)
22118 char *save_current_file;
22119 unformat_input_t save_input;
22120 jmp_buf save_jump_buf;
22121 u32 save_line_number;
22123 FILE *new_fp, *save_ifp;
22125 if (unformat (vam->input, "%s", &s))
22127 new_fp = fopen ((char *) s, "r");
22130 errmsg ("Couldn't open script file %s", s);
22137 errmsg ("Missing script name");
22141 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
22142 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
22143 save_ifp = vam->ifp;
22144 save_line_number = vam->input_line_number;
22145 save_current_file = (char *) vam->current_file;
22147 vam->input_line_number = 0;
22149 vam->current_file = s;
22152 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
22153 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
22154 vam->ifp = save_ifp;
22155 vam->input_line_number = save_line_number;
22156 vam->current_file = (u8 *) save_current_file;
22161 clib_warning ("use the exec command...");
22167 echo (vat_main_t * vam)
22169 print (vam->ofp, "%v", vam->input->buffer);
22173 /* List of API message constructors, CLI names map to api_xxx */
22174 #define foreach_vpe_api_msg \
22175 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
22176 _(sw_interface_dump,"") \
22177 _(sw_interface_set_flags, \
22178 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
22179 _(sw_interface_add_del_address, \
22180 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
22181 _(sw_interface_set_rx_mode, \
22182 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
22183 _(sw_interface_set_table, \
22184 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
22185 _(sw_interface_set_mpls_enable, \
22186 "<intfc> | sw_if_index [disable | dis]") \
22187 _(sw_interface_set_vpath, \
22188 "<intfc> | sw_if_index <id> enable | disable") \
22189 _(sw_interface_set_vxlan_bypass, \
22190 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22191 _(sw_interface_set_geneve_bypass, \
22192 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22193 _(sw_interface_set_l2_xconnect, \
22194 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22195 "enable | disable") \
22196 _(sw_interface_set_l2_bridge, \
22197 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
22198 "[shg <split-horizon-group>] [bvi]\n" \
22199 "enable | disable") \
22200 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
22201 _(bridge_domain_add_del, \
22202 "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") \
22203 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
22205 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
22206 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
22207 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
22209 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22211 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22213 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
22215 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
22217 "<vpp-if-name> | sw_if_index <id>") \
22218 _(sw_interface_tap_dump, "") \
22219 _(ip_table_add_del, \
22220 "table-id <n> [ipv6]\n") \
22221 _(ip_add_del_route, \
22222 "<addr>/<mask> via <addr> [table-id <n>]\n" \
22223 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
22224 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
22225 "[multipath] [count <n>]") \
22226 _(ip_mroute_add_del, \
22227 "<src> <grp>/<mask> [table-id <n>]\n" \
22228 "[<intfc> | sw_if_index <id>] [local] [del]") \
22229 _(mpls_table_add_del, \
22230 "table-id <n>\n") \
22231 _(mpls_route_add_del, \
22232 "<label> <eos> via <addr> [table-id <n>]\n" \
22233 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
22234 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
22235 "[multipath] [count <n>]") \
22236 _(mpls_ip_bind_unbind, \
22237 "<label> <addr/len>") \
22238 _(mpls_tunnel_add_del, \
22239 " via <addr> [table-id <n>]\n" \
22240 "sw_if_index <id>] [l2] [del]") \
22241 _(proxy_arp_add_del, \
22242 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
22243 _(proxy_arp_intfc_enable_disable, \
22244 "<intfc> | sw_if_index <id> enable | disable") \
22245 _(sw_interface_set_unnumbered, \
22246 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
22247 _(ip_neighbor_add_del, \
22248 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
22249 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
22250 _(reset_vrf, "vrf <id> [ipv6]") \
22251 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
22252 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
22253 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
22254 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
22255 "[outer_vlan_id_any][inner_vlan_id_any]") \
22256 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
22257 _(reset_fib, "vrf <n> [ipv6]") \
22258 _(dhcp_proxy_config, \
22259 "svr <v46-address> src <v46-address>\n" \
22260 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
22261 _(dhcp_proxy_set_vss, \
22262 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
22263 _(dhcp_proxy_dump, "ip6") \
22264 _(dhcp_client_config, \
22265 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
22266 _(set_ip_flow_hash, \
22267 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
22268 _(sw_interface_ip6_enable_disable, \
22269 "<intfc> | sw_if_index <id> enable | disable") \
22270 _(sw_interface_ip6_set_link_local_address, \
22271 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
22272 _(ip6nd_proxy_add_del, \
22273 "<intfc> | sw_if_index <id> <ip6-address>") \
22274 _(ip6nd_proxy_dump, "") \
22275 _(sw_interface_ip6nd_ra_prefix, \
22276 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
22277 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
22278 "[nolink] [isno]") \
22279 _(sw_interface_ip6nd_ra_config, \
22280 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
22281 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
22282 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
22283 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
22284 _(l2_patch_add_del, \
22285 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22286 "enable | disable") \
22287 _(sr_localsid_add_del, \
22288 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
22289 "fib-table <num> (end.psp) sw_if_index <num>") \
22290 _(classify_add_del_table, \
22291 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
22292 " [del] [del-chain] mask <mask-value>\n" \
22293 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
22294 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
22295 _(classify_add_del_session, \
22296 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
22297 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
22298 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
22299 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
22300 _(classify_set_interface_ip_table, \
22301 "<intfc> | sw_if_index <nn> table <nn>") \
22302 _(classify_set_interface_l2_tables, \
22303 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22304 " [other-table <nn>]") \
22305 _(get_node_index, "node <node-name") \
22306 _(add_node_next, "node <node-name> next <next-node-name>") \
22307 _(l2tpv3_create_tunnel, \
22308 "client_address <ip6-addr> our_address <ip6-addr>\n" \
22309 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
22310 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
22311 _(l2tpv3_set_tunnel_cookies, \
22312 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
22313 "[new_remote_cookie <nn>]\n") \
22314 _(l2tpv3_interface_enable_disable, \
22315 "<intfc> | sw_if_index <nn> enable | disable") \
22316 _(l2tpv3_set_lookup_key, \
22317 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
22318 _(sw_if_l2tpv3_tunnel_dump, "") \
22319 _(vxlan_add_del_tunnel, \
22320 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22321 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22322 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22323 _(geneve_add_del_tunnel, \
22324 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22325 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22326 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22327 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22328 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22329 _(gre_add_del_tunnel, \
22330 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
22331 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22332 _(l2_fib_clear_table, "") \
22333 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
22334 _(l2_interface_vlan_tag_rewrite, \
22335 "<intfc> | sw_if_index <nn> \n" \
22336 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
22337 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
22338 _(create_vhost_user_if, \
22339 "socket <filename> [server] [renumber <dev_instance>] " \
22340 "[mac <mac_address>]") \
22341 _(modify_vhost_user_if, \
22342 "<intfc> | sw_if_index <nn> socket <filename>\n" \
22343 "[server] [renumber <dev_instance>]") \
22344 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
22345 _(sw_interface_vhost_user_dump, "") \
22346 _(show_version, "") \
22347 _(vxlan_gpe_add_del_tunnel, \
22348 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
22349 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22350 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
22351 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
22352 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22353 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
22354 _(interface_name_renumber, \
22355 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
22356 _(input_acl_set_interface, \
22357 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22358 " [l2-table <nn>] [del]") \
22359 _(want_ip4_arp_events, "address <ip4-address> [del]") \
22360 _(want_ip6_nd_events, "address <ip6-address> [del]") \
22361 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
22362 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
22363 _(ip_dump, "ipv4 | ipv6") \
22364 _(ipsec_spd_add_del, "spd_id <n> [del]") \
22365 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
22367 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
22368 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
22369 " integ_alg <alg> integ_key <hex>") \
22370 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
22371 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
22372 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
22373 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
22374 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
22375 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
22376 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
22377 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
22378 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
22379 _(ipsec_sa_dump, "[sa_id <n>]") \
22380 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
22381 " <alg> <hex>\n") \
22382 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
22383 _(ikev2_profile_add_del, "name <profile_name> [del]") \
22384 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
22385 "(auth_data 0x<data> | auth_data <data>)") \
22386 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
22387 "(id_data 0x<data> | id_data <data>) (local|remote)") \
22388 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
22389 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
22390 "(local|remote)") \
22391 _(ikev2_set_local_key, "file <absolute_file_path>") \
22392 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
22393 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
22394 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
22395 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
22396 _(ikev2_initiate_sa_init, "<profile_name>") \
22397 _(ikev2_initiate_del_ike_sa, "<ispi>") \
22398 _(ikev2_initiate_del_child_sa, "<ispi>") \
22399 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
22400 _(delete_loopback,"sw_if_index <nn>") \
22401 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
22402 _(map_add_domain, \
22403 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
22404 "ip6-src <ip6addr> " \
22405 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
22406 _(map_del_domain, "index <n>") \
22407 _(map_add_del_rule, \
22408 "index <n> psid <n> dst <ip6addr> [del]") \
22409 _(map_domain_dump, "") \
22410 _(map_rule_dump, "index <map-domain>") \
22411 _(want_interface_events, "enable|disable") \
22412 _(want_stats,"enable|disable") \
22413 _(get_first_msg_id, "client <name>") \
22414 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
22415 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
22416 "fib-id <nn> [ip4][ip6][default]") \
22417 _(get_node_graph, " ") \
22418 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
22419 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
22420 _(ioam_disable, "") \
22421 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
22422 " sw_if_index <sw_if_index> p <priority> " \
22423 "w <weight>] [del]") \
22424 _(one_add_del_locator, "locator-set <locator_name> " \
22425 "iface <intf> | sw_if_index <sw_if_index> " \
22426 "p <priority> w <weight> [del]") \
22427 _(one_add_del_local_eid,"vni <vni> eid " \
22428 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22429 "locator-set <locator_name> [del]" \
22430 "[key-id sha1|sha256 secret-key <secret-key>]")\
22431 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
22432 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
22433 _(one_enable_disable, "enable|disable") \
22434 _(one_map_register_enable_disable, "enable|disable") \
22435 _(one_map_register_fallback_threshold, "<value>") \
22436 _(one_rloc_probe_enable_disable, "enable|disable") \
22437 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22439 "rloc <locator> p <prio> " \
22440 "w <weight> [rloc <loc> ... ] " \
22441 "action <action> [del-all]") \
22442 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22444 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22445 _(one_use_petr, "ip-address> | disable") \
22446 _(one_map_request_mode, "src-dst|dst-only") \
22447 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22448 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22449 _(one_locator_set_dump, "[local | remote]") \
22450 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
22451 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22452 "[local] | [remote]") \
22453 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
22454 _(one_ndp_bd_get, "") \
22455 _(one_ndp_entries_get, "bd <bridge-domain>") \
22456 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
22457 _(one_l2_arp_bd_get, "") \
22458 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
22459 _(one_stats_enable_disable, "enable|disalbe") \
22460 _(show_one_stats_enable_disable, "") \
22461 _(one_eid_table_vni_dump, "") \
22462 _(one_eid_table_map_dump, "l2|l3") \
22463 _(one_map_resolver_dump, "") \
22464 _(one_map_server_dump, "") \
22465 _(one_adjacencies_get, "vni <vni>") \
22466 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
22467 _(show_one_rloc_probe_state, "") \
22468 _(show_one_map_register_state, "") \
22469 _(show_one_status, "") \
22470 _(one_stats_dump, "") \
22471 _(one_stats_flush, "") \
22472 _(one_get_map_request_itr_rlocs, "") \
22473 _(one_map_register_set_ttl, "<ttl>") \
22474 _(one_set_transport_protocol, "udp|api") \
22475 _(one_get_transport_protocol, "") \
22476 _(one_enable_disable_xtr_mode, "enable|disable") \
22477 _(one_show_xtr_mode, "") \
22478 _(one_enable_disable_pitr_mode, "enable|disable") \
22479 _(one_show_pitr_mode, "") \
22480 _(one_enable_disable_petr_mode, "enable|disable") \
22481 _(one_show_petr_mode, "") \
22482 _(show_one_nsh_mapping, "") \
22483 _(show_one_pitr, "") \
22484 _(show_one_use_petr, "") \
22485 _(show_one_map_request_mode, "") \
22486 _(show_one_map_register_ttl, "") \
22487 _(show_one_map_register_fallback_threshold, "") \
22488 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
22489 " sw_if_index <sw_if_index> p <priority> " \
22490 "w <weight>] [del]") \
22491 _(lisp_add_del_locator, "locator-set <locator_name> " \
22492 "iface <intf> | sw_if_index <sw_if_index> " \
22493 "p <priority> w <weight> [del]") \
22494 _(lisp_add_del_local_eid,"vni <vni> eid " \
22495 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22496 "locator-set <locator_name> [del]" \
22497 "[key-id sha1|sha256 secret-key <secret-key>]") \
22498 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
22499 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
22500 _(lisp_enable_disable, "enable|disable") \
22501 _(lisp_map_register_enable_disable, "enable|disable") \
22502 _(lisp_rloc_probe_enable_disable, "enable|disable") \
22503 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22505 "rloc <locator> p <prio> " \
22506 "w <weight> [rloc <loc> ... ] " \
22507 "action <action> [del-all]") \
22508 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22510 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22511 _(lisp_use_petr, "<ip-address> | disable") \
22512 _(lisp_map_request_mode, "src-dst|dst-only") \
22513 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22514 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22515 _(lisp_locator_set_dump, "[local | remote]") \
22516 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
22517 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22518 "[local] | [remote]") \
22519 _(lisp_eid_table_vni_dump, "") \
22520 _(lisp_eid_table_map_dump, "l2|l3") \
22521 _(lisp_map_resolver_dump, "") \
22522 _(lisp_map_server_dump, "") \
22523 _(lisp_adjacencies_get, "vni <vni>") \
22524 _(gpe_fwd_entry_vnis_get, "") \
22525 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
22526 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
22527 "[table <table-id>]") \
22528 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
22529 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
22530 _(gpe_set_encap_mode, "lisp|vxlan") \
22531 _(gpe_get_encap_mode, "") \
22532 _(lisp_gpe_add_del_iface, "up|down") \
22533 _(lisp_gpe_enable_disable, "enable|disable") \
22534 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
22535 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
22536 _(show_lisp_rloc_probe_state, "") \
22537 _(show_lisp_map_register_state, "") \
22538 _(show_lisp_status, "") \
22539 _(lisp_get_map_request_itr_rlocs, "") \
22540 _(show_lisp_pitr, "") \
22541 _(show_lisp_use_petr, "") \
22542 _(show_lisp_map_request_mode, "") \
22543 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
22544 _(af_packet_delete, "name <host interface name>") \
22545 _(policer_add_del, "name <policer name> <params> [del]") \
22546 _(policer_dump, "[name <policer name>]") \
22547 _(policer_classify_set_interface, \
22548 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22549 " [l2-table <nn>] [del]") \
22550 _(policer_classify_dump, "type [ip4|ip6|l2]") \
22551 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
22552 "[master|slave]") \
22553 _(netmap_delete, "name <interface name>") \
22554 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
22555 _(mpls_fib_dump, "") \
22556 _(classify_table_ids, "") \
22557 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
22558 _(classify_table_info, "table_id <nn>") \
22559 _(classify_session_dump, "table_id <nn>") \
22560 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
22561 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
22562 "[template_interval <nn>] [udp_checksum]") \
22563 _(ipfix_exporter_dump, "") \
22564 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
22565 _(ipfix_classify_stream_dump, "") \
22566 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
22567 _(ipfix_classify_table_dump, "") \
22568 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
22569 _(sw_interface_span_dump, "[l2]") \
22570 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
22571 _(pg_create_interface, "if_id <nn>") \
22572 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
22573 _(pg_enable_disable, "[stream <id>] disable") \
22574 _(ip_source_and_port_range_check_add_del, \
22575 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
22576 _(ip_source_and_port_range_check_interface_add_del, \
22577 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
22578 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
22579 _(ipsec_gre_add_del_tunnel, \
22580 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
22581 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
22582 _(delete_subif,"<intfc> | sw_if_index <nn>") \
22583 _(l2_interface_pbb_tag_rewrite, \
22584 "<intfc> | sw_if_index <nn> \n" \
22585 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
22586 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
22587 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
22588 _(flow_classify_set_interface, \
22589 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
22590 _(flow_classify_dump, "type [ip4|ip6]") \
22591 _(ip_fib_dump, "") \
22592 _(ip_mfib_dump, "") \
22593 _(ip6_fib_dump, "") \
22594 _(ip6_mfib_dump, "") \
22595 _(feature_enable_disable, "arc_name <arc_name> " \
22596 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
22597 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
22599 _(l2_xconnect_dump, "") \
22600 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
22601 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
22602 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
22603 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
22604 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
22605 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
22606 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
22607 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
22608 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
22609 _(memfd_segment_create,"size <nnn>") \
22610 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
22611 _(dns_enable_disable, "[enable][disable]") \
22612 _(dns_name_server_add_del, "<ip-address> [del]") \
22613 _(dns_resolve_name, "<hostname>") \
22614 _(dns_resolve_ip, "<ip4|ip6>") \
22615 _(dns_name_server_add_del, "<ip-address> [del]") \
22616 _(dns_resolve_name, "<hostname>") \
22617 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
22618 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
22619 _(session_rules_dump, "") \
22620 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
22622 /* List of command functions, CLI names map directly to functions */
22623 #define foreach_cli_function \
22624 _(comment, "usage: comment <ignore-rest-of-line>") \
22625 _(dump_interface_table, "usage: dump_interface_table") \
22626 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
22627 _(dump_ipv4_table, "usage: dump_ipv4_table") \
22628 _(dump_ipv6_table, "usage: dump_ipv6_table") \
22629 _(dump_stats_table, "usage: dump_stats_table") \
22630 _(dump_macro_table, "usage: dump_macro_table ") \
22631 _(dump_node_table, "usage: dump_node_table") \
22632 _(dump_msg_api_table, "usage: dump_msg_api_table") \
22633 _(get_msg_id, "usage: get_msg_id name_and_crc") \
22634 _(echo, "usage: echo <message>") \
22635 _(exec, "usage: exec <vpe-debug-CLI-command>") \
22636 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
22637 _(help, "usage: help") \
22638 _(q, "usage: quit") \
22639 _(quit, "usage: quit") \
22640 _(search_node_table, "usage: search_node_table <name>...") \
22641 _(set, "usage: set <variable-name> <value>") \
22642 _(script, "usage: script <file-name>") \
22643 _(unset, "usage: unset <variable-name>")
22645 static void vl_api_##n##_t_handler_uni \
22646 (vl_api_##n##_t * mp) \
22648 vat_main_t * vam = &vat_main; \
22649 if (vam->json_output) { \
22650 vl_api_##n##_t_handler_json(mp); \
22652 vl_api_##n##_t_handler(mp); \
22655 foreach_vpe_api_reply_msg;
22656 #if VPP_API_TEST_BUILTIN == 0
22657 foreach_standalone_reply_msg;
22662 vat_api_hookup (vat_main_t * vam)
22665 vl_msg_api_set_handlers(VL_API_##N, #n, \
22666 vl_api_##n##_t_handler_uni, \
22668 vl_api_##n##_t_endian, \
22669 vl_api_##n##_t_print, \
22670 sizeof(vl_api_##n##_t), 1);
22671 foreach_vpe_api_reply_msg;
22672 #if VPP_API_TEST_BUILTIN == 0
22673 foreach_standalone_reply_msg;
22677 #if (VPP_API_TEST_BUILTIN==0)
22678 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
22680 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
22682 vam->function_by_name = hash_create_string (0, sizeof (uword));
22684 vam->help_by_name = hash_create_string (0, sizeof (uword));
22687 /* API messages we can send */
22688 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
22689 foreach_vpe_api_msg;
22693 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22694 foreach_vpe_api_msg;
22697 /* CLI functions */
22698 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
22699 foreach_cli_function;
22703 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22704 foreach_cli_function;
22708 #if VPP_API_TEST_BUILTIN
22709 static clib_error_t *
22710 vat_api_hookup_shim (vlib_main_t * vm)
22712 vat_api_hookup (&vat_main);
22716 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
22720 * fd.io coding-style-patch-verification: ON
22723 * eval: (c-set-style "gnu")