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)
5311 static void vl_api_##n##_t_handler \
5312 (vl_api_##n##_t * mp) \
5314 vat_main_t * vam = &vat_main; \
5315 i32 retval = ntohl(mp->retval); \
5316 if (vam->async_mode) { \
5317 vam->async_errors += (retval < 0); \
5319 vam->retval = retval; \
5320 vam->result_ready = 1; \
5323 foreach_standard_reply_retval_handler;
5327 static void vl_api_##n##_t_handler_json \
5328 (vl_api_##n##_t * mp) \
5330 vat_main_t * vam = &vat_main; \
5331 vat_json_node_t node; \
5332 vat_json_init_object(&node); \
5333 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5334 vat_json_print(vam->ofp, &node); \
5335 vam->retval = ntohl(mp->retval); \
5336 vam->result_ready = 1; \
5338 foreach_standard_reply_retval_handler;
5342 * Table of message reply handlers, must include boilerplate handlers
5346 #define foreach_vpe_api_reply_msg \
5347 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5348 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5349 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5350 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5351 _(CONTROL_PING_REPLY, control_ping_reply) \
5352 _(CLI_REPLY, cli_reply) \
5353 _(CLI_INBAND_REPLY, cli_inband_reply) \
5354 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5355 sw_interface_add_del_address_reply) \
5356 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5357 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5358 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5359 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5360 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5361 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5362 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5363 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5364 sw_interface_set_l2_xconnect_reply) \
5365 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5366 sw_interface_set_l2_bridge_reply) \
5367 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5368 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5369 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5370 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5371 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5372 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5373 _(L2_FLAGS_REPLY, l2_flags_reply) \
5374 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5375 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5376 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5377 _(TAP_DELETE_REPLY, tap_delete_reply) \
5378 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5379 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5380 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5381 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5382 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5383 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5384 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5385 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5386 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5387 proxy_arp_intfc_enable_disable_reply) \
5388 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5389 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5390 sw_interface_set_unnumbered_reply) \
5391 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5392 _(RESET_VRF_REPLY, reset_vrf_reply) \
5393 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5394 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5395 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5396 _(RESET_FIB_REPLY, reset_fib_reply) \
5397 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5398 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5399 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5400 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5401 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5402 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5403 sw_interface_ip6_enable_disable_reply) \
5404 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5405 sw_interface_ip6_set_link_local_address_reply) \
5406 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5407 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5408 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5409 sw_interface_ip6nd_ra_prefix_reply) \
5410 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5411 sw_interface_ip6nd_ra_config_reply) \
5412 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5413 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5414 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5415 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5416 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5417 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5418 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5419 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5420 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5421 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5422 classify_set_interface_ip_table_reply) \
5423 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5424 classify_set_interface_l2_tables_reply) \
5425 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5426 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5427 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5428 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5429 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5430 l2tpv3_interface_enable_disable_reply) \
5431 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5432 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5433 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5434 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5435 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5436 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5437 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5438 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5439 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5440 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5441 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5442 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5443 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5444 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5445 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5446 _(SHOW_VERSION_REPLY, show_version_reply) \
5447 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5448 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5449 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5450 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5451 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5452 _(IP4_ARP_EVENT, ip4_arp_event) \
5453 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5454 _(IP6_ND_EVENT, ip6_nd_event) \
5455 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5456 _(L2_MACS_EVENT, l2_macs_event) \
5457 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5458 _(IP_ADDRESS_DETAILS, ip_address_details) \
5459 _(IP_DETAILS, ip_details) \
5460 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5461 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5462 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5463 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5464 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5465 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5466 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5467 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5468 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5469 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5470 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5471 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5472 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5473 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5474 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5475 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5476 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5477 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5478 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5479 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5480 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5481 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5482 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5483 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5484 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5485 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5486 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5487 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5488 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5489 _(MAP_RULE_DETAILS, map_rule_details) \
5490 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5491 _(WANT_STATS_REPLY, want_stats_reply) \
5492 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5493 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5494 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5495 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5496 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5497 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5498 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5499 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5500 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5501 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5502 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5503 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5504 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5505 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5506 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5507 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5508 one_map_register_enable_disable_reply) \
5509 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5510 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5511 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5512 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5513 one_map_register_fallback_threshold_reply) \
5514 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5515 one_rloc_probe_enable_disable_reply) \
5516 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5517 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5518 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5519 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5520 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5521 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5522 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5523 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5524 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5525 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5526 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5527 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5528 _(ONE_STATS_DETAILS, one_stats_details) \
5529 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5530 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5531 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5532 show_one_stats_enable_disable_reply) \
5533 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5534 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5535 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5536 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5537 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5538 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5539 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5540 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5541 one_enable_disable_pitr_mode_reply) \
5542 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5543 one_enable_disable_petr_mode_reply) \
5544 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5545 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5546 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5547 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5548 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5549 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5550 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5551 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5552 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5553 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5554 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5555 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5556 gpe_add_del_native_fwd_rpath_reply) \
5557 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5558 gpe_fwd_entry_path_details) \
5559 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5560 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5561 one_add_del_map_request_itr_rlocs_reply) \
5562 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5563 one_get_map_request_itr_rlocs_reply) \
5564 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5565 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5566 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5567 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5568 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5569 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5570 show_one_map_register_state_reply) \
5571 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5572 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5573 show_one_map_register_fallback_threshold_reply) \
5574 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5575 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5576 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5577 _(POLICER_DETAILS, policer_details) \
5578 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5579 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5580 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5581 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5582 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5583 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5584 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5585 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5586 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5587 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5588 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5589 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5590 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5591 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5592 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5593 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5594 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5595 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5596 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5597 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5598 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5599 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5600 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5601 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5602 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5603 ip_source_and_port_range_check_add_del_reply) \
5604 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5605 ip_source_and_port_range_check_interface_add_del_reply) \
5606 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5607 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5608 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5609 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5610 _(PUNT_REPLY, punt_reply) \
5611 _(IP_FIB_DETAILS, ip_fib_details) \
5612 _(IP6_FIB_DETAILS, ip6_fib_details) \
5613 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5614 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5615 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5616 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5617 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5618 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5619 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5620 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5621 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5622 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5623 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5624 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5625 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5626 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5627 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5628 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5629 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5630 _(SESSION_RULES_DETAILS, session_rules_details)
5632 #define foreach_standalone_reply_msg \
5633 _(SW_INTERFACE_EVENT, sw_interface_event) \
5634 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5635 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5636 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5637 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5638 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5639 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
5640 _(MEMFD_SEGMENT_CREATE_REPLY, memfd_segment_create_reply) \
5649 #define STR_VTR_OP_CASE(op) \
5650 case L2_VTR_ ## op: \
5654 str_vtr_op (u32 vtr_op)
5658 STR_VTR_OP_CASE (DISABLED);
5659 STR_VTR_OP_CASE (PUSH_1);
5660 STR_VTR_OP_CASE (PUSH_2);
5661 STR_VTR_OP_CASE (POP_1);
5662 STR_VTR_OP_CASE (POP_2);
5663 STR_VTR_OP_CASE (TRANSLATE_1_1);
5664 STR_VTR_OP_CASE (TRANSLATE_1_2);
5665 STR_VTR_OP_CASE (TRANSLATE_2_1);
5666 STR_VTR_OP_CASE (TRANSLATE_2_2);
5673 dump_sub_interface_table (vat_main_t * vam)
5675 const sw_interface_subif_t *sub = NULL;
5677 if (vam->json_output)
5680 ("JSON output supported only for VPE API calls and dump_stats_table");
5685 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5686 "Interface", "sw_if_index",
5687 "sub id", "dot1ad", "tags", "outer id",
5688 "inner id", "exact", "default", "outer any", "inner any");
5690 vec_foreach (sub, vam->sw_if_subif_table)
5693 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5694 sub->interface_name,
5696 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5697 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5698 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5699 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5700 if (sub->vtr_op != L2_VTR_DISABLED)
5703 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5704 "tag1: %d tag2: %d ]",
5705 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5706 sub->vtr_tag1, sub->vtr_tag2);
5714 name_sort_cmp (void *a1, void *a2)
5716 name_sort_t *n1 = a1;
5717 name_sort_t *n2 = a2;
5719 return strcmp ((char *) n1->name, (char *) n2->name);
5723 dump_interface_table (vat_main_t * vam)
5726 name_sort_t *nses = 0, *ns;
5728 if (vam->json_output)
5731 ("JSON output supported only for VPE API calls and dump_stats_table");
5736 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5738 vec_add2 (nses, ns, 1);
5739 ns->name = (u8 *)(p->key);
5740 ns->value = (u32) p->value[0];
5744 vec_sort_with_function (nses, name_sort_cmp);
5746 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5747 vec_foreach (ns, nses)
5749 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5756 dump_ip_table (vat_main_t * vam, int is_ipv6)
5758 const ip_details_t *det = NULL;
5759 const ip_address_details_t *address = NULL;
5762 print (vam->ofp, "%-12s", "sw_if_index");
5764 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5771 print (vam->ofp, "%-12d", i);
5772 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5777 vec_foreach (address, det->addr)
5781 is_ipv6 ? format_ip6_address : format_ip4_address,
5782 address->ip, address->prefix_length);
5790 dump_ipv4_table (vat_main_t * vam)
5792 if (vam->json_output)
5795 ("JSON output supported only for VPE API calls and dump_stats_table");
5799 return dump_ip_table (vam, 0);
5803 dump_ipv6_table (vat_main_t * vam)
5805 if (vam->json_output)
5808 ("JSON output supported only for VPE API calls and dump_stats_table");
5812 return dump_ip_table (vam, 1);
5816 counter_type_to_str (u8 counter_type, u8 is_combined)
5820 switch (counter_type)
5822 case VNET_INTERFACE_COUNTER_DROP:
5824 case VNET_INTERFACE_COUNTER_PUNT:
5826 case VNET_INTERFACE_COUNTER_IP4:
5828 case VNET_INTERFACE_COUNTER_IP6:
5830 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5832 case VNET_INTERFACE_COUNTER_RX_MISS:
5834 case VNET_INTERFACE_COUNTER_RX_ERROR:
5836 case VNET_INTERFACE_COUNTER_TX_ERROR:
5839 return "INVALID-COUNTER-TYPE";
5844 switch (counter_type)
5846 case VNET_INTERFACE_COUNTER_RX:
5848 case VNET_INTERFACE_COUNTER_TX:
5851 return "INVALID-COUNTER-TYPE";
5857 dump_stats_table (vat_main_t * vam)
5859 vat_json_node_t node;
5860 vat_json_node_t *msg_array;
5861 vat_json_node_t *msg;
5862 vat_json_node_t *counter_array;
5863 vat_json_node_t *counter;
5864 interface_counter_t c;
5866 ip4_fib_counter_t *c4;
5867 ip6_fib_counter_t *c6;
5868 ip4_nbr_counter_t *n4;
5869 ip6_nbr_counter_t *n6;
5872 if (!vam->json_output)
5874 clib_warning ("dump_stats_table supported only in JSON format");
5878 vat_json_init_object (&node);
5880 /* interface counters */
5881 msg_array = vat_json_object_add (&node, "interface_counters");
5882 vat_json_init_array (msg_array);
5883 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5885 msg = vat_json_array_add (msg_array);
5886 vat_json_init_object (msg);
5887 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5888 (u8 *) counter_type_to_str (i, 0));
5889 vat_json_object_add_int (msg, "is_combined", 0);
5890 counter_array = vat_json_object_add (msg, "data");
5891 vat_json_init_array (counter_array);
5892 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5894 packets = vam->simple_interface_counters[i][j];
5895 vat_json_array_add_uint (counter_array, packets);
5898 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5900 msg = vat_json_array_add (msg_array);
5901 vat_json_init_object (msg);
5902 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5903 (u8 *) counter_type_to_str (i, 1));
5904 vat_json_object_add_int (msg, "is_combined", 1);
5905 counter_array = vat_json_object_add (msg, "data");
5906 vat_json_init_array (counter_array);
5907 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5909 c = vam->combined_interface_counters[i][j];
5910 counter = vat_json_array_add (counter_array);
5911 vat_json_init_object (counter);
5912 vat_json_object_add_uint (counter, "packets", c.packets);
5913 vat_json_object_add_uint (counter, "bytes", c.bytes);
5917 /* ip4 fib counters */
5918 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5919 vat_json_init_array (msg_array);
5920 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5922 msg = vat_json_array_add (msg_array);
5923 vat_json_init_object (msg);
5924 vat_json_object_add_uint (msg, "vrf_id",
5925 vam->ip4_fib_counters_vrf_id_by_index[i]);
5926 counter_array = vat_json_object_add (msg, "c");
5927 vat_json_init_array (counter_array);
5928 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5930 counter = vat_json_array_add (counter_array);
5931 vat_json_init_object (counter);
5932 c4 = &vam->ip4_fib_counters[i][j];
5933 vat_json_object_add_ip4 (counter, "address", c4->address);
5934 vat_json_object_add_uint (counter, "address_length",
5935 c4->address_length);
5936 vat_json_object_add_uint (counter, "packets", c4->packets);
5937 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5941 /* ip6 fib counters */
5942 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5943 vat_json_init_array (msg_array);
5944 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5946 msg = vat_json_array_add (msg_array);
5947 vat_json_init_object (msg);
5948 vat_json_object_add_uint (msg, "vrf_id",
5949 vam->ip6_fib_counters_vrf_id_by_index[i]);
5950 counter_array = vat_json_object_add (msg, "c");
5951 vat_json_init_array (counter_array);
5952 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5954 counter = vat_json_array_add (counter_array);
5955 vat_json_init_object (counter);
5956 c6 = &vam->ip6_fib_counters[i][j];
5957 vat_json_object_add_ip6 (counter, "address", c6->address);
5958 vat_json_object_add_uint (counter, "address_length",
5959 c6->address_length);
5960 vat_json_object_add_uint (counter, "packets", c6->packets);
5961 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5965 /* ip4 nbr counters */
5966 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5967 vat_json_init_array (msg_array);
5968 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5970 msg = vat_json_array_add (msg_array);
5971 vat_json_init_object (msg);
5972 vat_json_object_add_uint (msg, "sw_if_index", i);
5973 counter_array = vat_json_object_add (msg, "c");
5974 vat_json_init_array (counter_array);
5975 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5977 counter = vat_json_array_add (counter_array);
5978 vat_json_init_object (counter);
5979 n4 = &vam->ip4_nbr_counters[i][j];
5980 vat_json_object_add_ip4 (counter, "address", n4->address);
5981 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5982 vat_json_object_add_uint (counter, "packets", n4->packets);
5983 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5987 /* ip6 nbr counters */
5988 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5989 vat_json_init_array (msg_array);
5990 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5992 msg = vat_json_array_add (msg_array);
5993 vat_json_init_object (msg);
5994 vat_json_object_add_uint (msg, "sw_if_index", i);
5995 counter_array = vat_json_object_add (msg, "c");
5996 vat_json_init_array (counter_array);
5997 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5999 counter = vat_json_array_add (counter_array);
6000 vat_json_init_object (counter);
6001 n6 = &vam->ip6_nbr_counters[i][j];
6002 vat_json_object_add_ip6 (counter, "address", n6->address);
6003 vat_json_object_add_uint (counter, "packets", n6->packets);
6004 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6008 vat_json_print (vam->ofp, &node);
6009 vat_json_free (&node);
6015 * Pass CLI buffers directly in the CLI_INBAND API message,
6016 * instead of an additional shared memory area.
6019 exec_inband (vat_main_t * vam)
6021 vl_api_cli_inband_t *mp;
6022 unformat_input_t *i = vam->input;
6025 if (vec_len (i->buffer) == 0)
6028 if (vam->exec_mode == 0 && unformat (i, "mode"))
6033 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6040 * In order for the CLI command to work, it
6041 * must be a vector ending in \n, not a C-string ending
6044 u32 len = vec_len (vam->input->buffer);
6045 M2 (CLI_INBAND, mp, len);
6046 clib_memcpy (mp->cmd, vam->input->buffer, len);
6047 mp->length = htonl (len);
6051 /* json responses may or may not include a useful reply... */
6052 if (vec_len (vam->cmd_reply))
6053 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6058 exec (vat_main_t * vam)
6060 return exec_inband (vam);
6064 api_create_loopback (vat_main_t * vam)
6066 unformat_input_t *i = vam->input;
6067 vl_api_create_loopback_t *mp;
6068 vl_api_create_loopback_instance_t *mp_lbi;
6071 u8 is_specified = 0;
6072 u32 user_instance = 0;
6075 memset (mac_address, 0, sizeof (mac_address));
6077 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6079 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6081 if (unformat (i, "instance %d", &user_instance))
6089 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6090 mp_lbi->is_specified = is_specified;
6092 mp_lbi->user_instance = htonl (user_instance);
6094 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6099 /* Construct the API message */
6100 M (CREATE_LOOPBACK, mp);
6102 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6111 api_delete_loopback (vat_main_t * vam)
6113 unformat_input_t *i = vam->input;
6114 vl_api_delete_loopback_t *mp;
6115 u32 sw_if_index = ~0;
6118 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6120 if (unformat (i, "sw_if_index %d", &sw_if_index))
6126 if (sw_if_index == ~0)
6128 errmsg ("missing sw_if_index");
6132 /* Construct the API message */
6133 M (DELETE_LOOPBACK, mp);
6134 mp->sw_if_index = ntohl (sw_if_index);
6142 api_want_stats (vat_main_t * vam)
6144 unformat_input_t *i = vam->input;
6145 vl_api_want_stats_t *mp;
6149 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6151 if (unformat (i, "enable"))
6153 else if (unformat (i, "disable"))
6161 errmsg ("missing enable|disable");
6166 mp->enable_disable = enable;
6174 api_want_interface_events (vat_main_t * vam)
6176 unformat_input_t *i = vam->input;
6177 vl_api_want_interface_events_t *mp;
6181 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6183 if (unformat (i, "enable"))
6185 else if (unformat (i, "disable"))
6193 errmsg ("missing enable|disable");
6197 M (WANT_INTERFACE_EVENTS, mp);
6198 mp->enable_disable = enable;
6200 vam->interface_event_display = enable;
6208 /* Note: non-static, called once to set up the initial intfc table */
6210 api_sw_interface_dump (vat_main_t * vam)
6212 vl_api_sw_interface_dump_t *mp;
6213 vl_api_control_ping_t *mp_ping;
6215 name_sort_t *nses = 0, *ns;
6216 sw_interface_subif_t *sub = NULL;
6219 /* Toss the old name table */
6221 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6223 vec_add2 (nses, ns, 1);
6224 ns->name = (u8 *)(p->key);
6225 ns->value = (u32) p->value[0];
6229 hash_free (vam->sw_if_index_by_interface_name);
6231 vec_foreach (ns, nses) vec_free (ns->name);
6235 vec_foreach (sub, vam->sw_if_subif_table)
6237 vec_free (sub->interface_name);
6239 vec_free (vam->sw_if_subif_table);
6241 /* recreate the interface name hash table */
6242 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6244 /* Get list of ethernets */
6245 M (SW_INTERFACE_DUMP, mp);
6246 mp->name_filter_valid = 1;
6247 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
6250 /* and local / loopback interfaces */
6251 M (SW_INTERFACE_DUMP, mp);
6252 mp->name_filter_valid = 1;
6253 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
6256 /* and packet-generator interfaces */
6257 M (SW_INTERFACE_DUMP, mp);
6258 mp->name_filter_valid = 1;
6259 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
6262 /* and vxlan-gpe tunnel interfaces */
6263 M (SW_INTERFACE_DUMP, mp);
6264 mp->name_filter_valid = 1;
6265 strncpy ((char *) mp->name_filter, "vxlan_gpe",
6266 sizeof (mp->name_filter) - 1);
6269 /* and vxlan tunnel interfaces */
6270 M (SW_INTERFACE_DUMP, mp);
6271 mp->name_filter_valid = 1;
6272 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
6275 /* and geneve tunnel interfaces */
6276 M (SW_INTERFACE_DUMP, mp);
6277 mp->name_filter_valid = 1;
6278 strncpy ((char *) mp->name_filter, "geneve", sizeof (mp->name_filter) - 1);
6281 /* and host (af_packet) interfaces */
6282 M (SW_INTERFACE_DUMP, mp);
6283 mp->name_filter_valid = 1;
6284 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
6287 /* and l2tpv3 tunnel interfaces */
6288 M (SW_INTERFACE_DUMP, mp);
6289 mp->name_filter_valid = 1;
6290 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
6291 sizeof (mp->name_filter) - 1);
6294 /* and GRE tunnel interfaces */
6295 M (SW_INTERFACE_DUMP, mp);
6296 mp->name_filter_valid = 1;
6297 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
6300 /* and LISP-GPE interfaces */
6301 M (SW_INTERFACE_DUMP, mp);
6302 mp->name_filter_valid = 1;
6303 strncpy ((char *) mp->name_filter, "lisp_gpe",
6304 sizeof (mp->name_filter) - 1);
6307 /* and IPSEC tunnel interfaces */
6308 M (SW_INTERFACE_DUMP, mp);
6309 mp->name_filter_valid = 1;
6310 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
6313 /* Use a control ping for synchronization */
6314 MPING (CONTROL_PING, mp_ping);
6322 api_sw_interface_set_flags (vat_main_t * vam)
6324 unformat_input_t *i = vam->input;
6325 vl_api_sw_interface_set_flags_t *mp;
6327 u8 sw_if_index_set = 0;
6331 /* Parse args required to build the message */
6332 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6334 if (unformat (i, "admin-up"))
6336 else if (unformat (i, "admin-down"))
6339 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6340 sw_if_index_set = 1;
6341 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6342 sw_if_index_set = 1;
6347 if (sw_if_index_set == 0)
6349 errmsg ("missing interface name or sw_if_index");
6353 /* Construct the API message */
6354 M (SW_INTERFACE_SET_FLAGS, mp);
6355 mp->sw_if_index = ntohl (sw_if_index);
6356 mp->admin_up_down = admin_up;
6361 /* Wait for a reply, return the good/bad news... */
6367 api_sw_interface_set_rx_mode (vat_main_t * vam)
6369 unformat_input_t *i = vam->input;
6370 vl_api_sw_interface_set_rx_mode_t *mp;
6372 u8 sw_if_index_set = 0;
6374 u8 queue_id_valid = 0;
6376 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6378 /* Parse args required to build the message */
6379 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6381 if (unformat (i, "queue %d", &queue_id))
6383 else if (unformat (i, "polling"))
6384 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6385 else if (unformat (i, "interrupt"))
6386 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6387 else if (unformat (i, "adaptive"))
6388 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6390 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6391 sw_if_index_set = 1;
6392 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6393 sw_if_index_set = 1;
6398 if (sw_if_index_set == 0)
6400 errmsg ("missing interface name or sw_if_index");
6403 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6405 errmsg ("missing rx-mode");
6409 /* Construct the API message */
6410 M (SW_INTERFACE_SET_RX_MODE, mp);
6411 mp->sw_if_index = ntohl (sw_if_index);
6413 mp->queue_id_valid = queue_id_valid;
6414 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6419 /* Wait for a reply, return the good/bad news... */
6425 api_sw_interface_clear_stats (vat_main_t * vam)
6427 unformat_input_t *i = vam->input;
6428 vl_api_sw_interface_clear_stats_t *mp;
6430 u8 sw_if_index_set = 0;
6433 /* Parse args required to build the message */
6434 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6436 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6437 sw_if_index_set = 1;
6438 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6439 sw_if_index_set = 1;
6444 /* Construct the API message */
6445 M (SW_INTERFACE_CLEAR_STATS, mp);
6447 if (sw_if_index_set == 1)
6448 mp->sw_if_index = ntohl (sw_if_index);
6450 mp->sw_if_index = ~0;
6455 /* Wait for a reply, return the good/bad news... */
6461 api_sw_interface_add_del_address (vat_main_t * vam)
6463 unformat_input_t *i = vam->input;
6464 vl_api_sw_interface_add_del_address_t *mp;
6466 u8 sw_if_index_set = 0;
6467 u8 is_add = 1, del_all = 0;
6468 u32 address_length = 0;
6469 u8 v4_address_set = 0;
6470 u8 v6_address_set = 0;
6471 ip4_address_t v4address;
6472 ip6_address_t v6address;
6475 /* Parse args required to build the message */
6476 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6478 if (unformat (i, "del-all"))
6480 else if (unformat (i, "del"))
6483 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6484 sw_if_index_set = 1;
6485 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6486 sw_if_index_set = 1;
6487 else if (unformat (i, "%U/%d",
6488 unformat_ip4_address, &v4address, &address_length))
6490 else if (unformat (i, "%U/%d",
6491 unformat_ip6_address, &v6address, &address_length))
6497 if (sw_if_index_set == 0)
6499 errmsg ("missing interface name or sw_if_index");
6502 if (v4_address_set && v6_address_set)
6504 errmsg ("both v4 and v6 addresses set");
6507 if (!v4_address_set && !v6_address_set && !del_all)
6509 errmsg ("no addresses set");
6513 /* Construct the API message */
6514 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6516 mp->sw_if_index = ntohl (sw_if_index);
6517 mp->is_add = is_add;
6518 mp->del_all = del_all;
6522 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6526 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6528 mp->address_length = address_length;
6533 /* Wait for a reply, return good/bad news */
6539 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6541 unformat_input_t *i = vam->input;
6542 vl_api_sw_interface_set_mpls_enable_t *mp;
6544 u8 sw_if_index_set = 0;
6548 /* Parse args required to build the message */
6549 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6551 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6552 sw_if_index_set = 1;
6553 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6554 sw_if_index_set = 1;
6555 else if (unformat (i, "disable"))
6557 else if (unformat (i, "dis"))
6563 if (sw_if_index_set == 0)
6565 errmsg ("missing interface name or sw_if_index");
6569 /* Construct the API message */
6570 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6572 mp->sw_if_index = ntohl (sw_if_index);
6573 mp->enable = enable;
6578 /* Wait for a reply... */
6584 api_sw_interface_set_table (vat_main_t * vam)
6586 unformat_input_t *i = vam->input;
6587 vl_api_sw_interface_set_table_t *mp;
6588 u32 sw_if_index, vrf_id = 0;
6589 u8 sw_if_index_set = 0;
6593 /* Parse args required to build the message */
6594 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6596 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6597 sw_if_index_set = 1;
6598 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6599 sw_if_index_set = 1;
6600 else if (unformat (i, "vrf %d", &vrf_id))
6602 else if (unformat (i, "ipv6"))
6608 if (sw_if_index_set == 0)
6610 errmsg ("missing interface name or sw_if_index");
6614 /* Construct the API message */
6615 M (SW_INTERFACE_SET_TABLE, mp);
6617 mp->sw_if_index = ntohl (sw_if_index);
6618 mp->is_ipv6 = is_ipv6;
6619 mp->vrf_id = ntohl (vrf_id);
6624 /* Wait for a reply... */
6629 static void vl_api_sw_interface_get_table_reply_t_handler
6630 (vl_api_sw_interface_get_table_reply_t * mp)
6632 vat_main_t *vam = &vat_main;
6634 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6636 vam->retval = ntohl (mp->retval);
6637 vam->result_ready = 1;
6641 static void vl_api_sw_interface_get_table_reply_t_handler_json
6642 (vl_api_sw_interface_get_table_reply_t * mp)
6644 vat_main_t *vam = &vat_main;
6645 vat_json_node_t node;
6647 vat_json_init_object (&node);
6648 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6649 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6651 vat_json_print (vam->ofp, &node);
6652 vat_json_free (&node);
6654 vam->retval = ntohl (mp->retval);
6655 vam->result_ready = 1;
6659 api_sw_interface_get_table (vat_main_t * vam)
6661 unformat_input_t *i = vam->input;
6662 vl_api_sw_interface_get_table_t *mp;
6664 u8 sw_if_index_set = 0;
6668 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6670 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6671 sw_if_index_set = 1;
6672 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6673 sw_if_index_set = 1;
6674 else if (unformat (i, "ipv6"))
6680 if (sw_if_index_set == 0)
6682 errmsg ("missing interface name or sw_if_index");
6686 M (SW_INTERFACE_GET_TABLE, mp);
6687 mp->sw_if_index = htonl (sw_if_index);
6688 mp->is_ipv6 = is_ipv6;
6696 api_sw_interface_set_vpath (vat_main_t * vam)
6698 unformat_input_t *i = vam->input;
6699 vl_api_sw_interface_set_vpath_t *mp;
6700 u32 sw_if_index = 0;
6701 u8 sw_if_index_set = 0;
6705 /* Parse args required to build the message */
6706 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6708 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6709 sw_if_index_set = 1;
6710 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6711 sw_if_index_set = 1;
6712 else if (unformat (i, "enable"))
6714 else if (unformat (i, "disable"))
6720 if (sw_if_index_set == 0)
6722 errmsg ("missing interface name or sw_if_index");
6726 /* Construct the API message */
6727 M (SW_INTERFACE_SET_VPATH, mp);
6729 mp->sw_if_index = ntohl (sw_if_index);
6730 mp->enable = is_enable;
6735 /* Wait for a reply... */
6741 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6743 unformat_input_t *i = vam->input;
6744 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6745 u32 sw_if_index = 0;
6746 u8 sw_if_index_set = 0;
6751 /* Parse args required to build the message */
6752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6754 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6755 sw_if_index_set = 1;
6756 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6757 sw_if_index_set = 1;
6758 else if (unformat (i, "enable"))
6760 else if (unformat (i, "disable"))
6762 else if (unformat (i, "ip4"))
6764 else if (unformat (i, "ip6"))
6770 if (sw_if_index_set == 0)
6772 errmsg ("missing interface name or sw_if_index");
6776 /* Construct the API message */
6777 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6779 mp->sw_if_index = ntohl (sw_if_index);
6780 mp->enable = is_enable;
6781 mp->is_ipv6 = is_ipv6;
6786 /* Wait for a reply... */
6792 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6794 unformat_input_t *i = vam->input;
6795 vl_api_sw_interface_set_geneve_bypass_t *mp;
6796 u32 sw_if_index = 0;
6797 u8 sw_if_index_set = 0;
6802 /* Parse args required to build the message */
6803 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6805 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6806 sw_if_index_set = 1;
6807 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6808 sw_if_index_set = 1;
6809 else if (unformat (i, "enable"))
6811 else if (unformat (i, "disable"))
6813 else if (unformat (i, "ip4"))
6815 else if (unformat (i, "ip6"))
6821 if (sw_if_index_set == 0)
6823 errmsg ("missing interface name or sw_if_index");
6827 /* Construct the API message */
6828 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6830 mp->sw_if_index = ntohl (sw_if_index);
6831 mp->enable = is_enable;
6832 mp->is_ipv6 = is_ipv6;
6837 /* Wait for a reply... */
6843 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6845 unformat_input_t *i = vam->input;
6846 vl_api_sw_interface_set_l2_xconnect_t *mp;
6848 u8 rx_sw_if_index_set = 0;
6850 u8 tx_sw_if_index_set = 0;
6854 /* Parse args required to build the message */
6855 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6857 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6858 rx_sw_if_index_set = 1;
6859 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6860 tx_sw_if_index_set = 1;
6861 else if (unformat (i, "rx"))
6863 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6865 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6867 rx_sw_if_index_set = 1;
6872 else if (unformat (i, "tx"))
6874 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6876 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6878 tx_sw_if_index_set = 1;
6883 else if (unformat (i, "enable"))
6885 else if (unformat (i, "disable"))
6891 if (rx_sw_if_index_set == 0)
6893 errmsg ("missing rx interface name or rx_sw_if_index");
6897 if (enable && (tx_sw_if_index_set == 0))
6899 errmsg ("missing tx interface name or tx_sw_if_index");
6903 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6905 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6906 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6907 mp->enable = enable;
6915 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6917 unformat_input_t *i = vam->input;
6918 vl_api_sw_interface_set_l2_bridge_t *mp;
6920 u8 rx_sw_if_index_set = 0;
6928 /* Parse args required to build the message */
6929 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6931 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6932 rx_sw_if_index_set = 1;
6933 else if (unformat (i, "bd_id %d", &bd_id))
6937 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6938 rx_sw_if_index_set = 1;
6939 else if (unformat (i, "shg %d", &shg))
6941 else if (unformat (i, "bvi"))
6943 else if (unformat (i, "enable"))
6945 else if (unformat (i, "disable"))
6951 if (rx_sw_if_index_set == 0)
6953 errmsg ("missing rx interface name or sw_if_index");
6957 if (enable && (bd_id_set == 0))
6959 errmsg ("missing bridge domain");
6963 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6965 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6966 mp->bd_id = ntohl (bd_id);
6969 mp->enable = enable;
6977 api_bridge_domain_dump (vat_main_t * vam)
6979 unformat_input_t *i = vam->input;
6980 vl_api_bridge_domain_dump_t *mp;
6981 vl_api_control_ping_t *mp_ping;
6985 /* Parse args required to build the message */
6986 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6988 if (unformat (i, "bd_id %d", &bd_id))
6994 M (BRIDGE_DOMAIN_DUMP, mp);
6995 mp->bd_id = ntohl (bd_id);
6998 /* Use a control ping for synchronization */
6999 MPING (CONTROL_PING, mp_ping);
7007 api_bridge_domain_add_del (vat_main_t * vam)
7009 unformat_input_t *i = vam->input;
7010 vl_api_bridge_domain_add_del_t *mp;
7013 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7018 /* Parse args required to build the message */
7019 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7021 if (unformat (i, "bd_id %d", &bd_id))
7023 else if (unformat (i, "flood %d", &flood))
7025 else if (unformat (i, "uu-flood %d", &uu_flood))
7027 else if (unformat (i, "forward %d", &forward))
7029 else if (unformat (i, "learn %d", &learn))
7031 else if (unformat (i, "arp-term %d", &arp_term))
7033 else if (unformat (i, "mac-age %d", &mac_age))
7035 else if (unformat (i, "bd-tag %s", &bd_tag))
7037 else if (unformat (i, "del"))
7040 flood = uu_flood = forward = learn = 0;
7048 errmsg ("missing bridge domain");
7055 errmsg ("mac age must be less than 256 ");
7060 if ((bd_tag) && (strlen ((char *) bd_tag) > 63))
7062 errmsg ("bd-tag cannot be longer than 63");
7067 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7069 mp->bd_id = ntohl (bd_id);
7071 mp->uu_flood = uu_flood;
7072 mp->forward = forward;
7074 mp->arp_term = arp_term;
7075 mp->is_add = is_add;
7076 mp->mac_age = (u8) mac_age;
7078 strcpy ((char *) mp->bd_tag, (char *) bd_tag);
7089 api_l2fib_flush_bd (vat_main_t * vam)
7091 unformat_input_t *i = vam->input;
7092 vl_api_l2fib_flush_bd_t *mp;
7096 /* Parse args required to build the message */
7097 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7099 if (unformat (i, "bd_id %d", &bd_id));
7106 errmsg ("missing bridge domain");
7110 M (L2FIB_FLUSH_BD, mp);
7112 mp->bd_id = htonl (bd_id);
7120 api_l2fib_flush_int (vat_main_t * vam)
7122 unformat_input_t *i = vam->input;
7123 vl_api_l2fib_flush_int_t *mp;
7124 u32 sw_if_index = ~0;
7127 /* Parse args required to build the message */
7128 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7130 if (unformat (i, "sw_if_index %d", &sw_if_index));
7132 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7137 if (sw_if_index == ~0)
7139 errmsg ("missing interface name or sw_if_index");
7143 M (L2FIB_FLUSH_INT, mp);
7145 mp->sw_if_index = ntohl (sw_if_index);
7153 api_l2fib_add_del (vat_main_t * vam)
7155 unformat_input_t *i = vam->input;
7156 vl_api_l2fib_add_del_t *mp;
7162 u32 sw_if_index = ~0;
7163 u8 sw_if_index_set = 0;
7172 /* Parse args required to build the message */
7173 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7175 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7177 else if (unformat (i, "bd_id %d", &bd_id))
7179 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7180 sw_if_index_set = 1;
7181 else if (unformat (i, "sw_if"))
7183 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7186 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7187 sw_if_index_set = 1;
7192 else if (unformat (i, "static"))
7194 else if (unformat (i, "filter"))
7199 else if (unformat (i, "bvi"))
7204 else if (unformat (i, "del"))
7206 else if (unformat (i, "count %d", &count))
7214 errmsg ("missing mac address");
7220 errmsg ("missing bridge domain");
7224 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7226 errmsg ("missing interface name or sw_if_index");
7232 /* Turn on async mode */
7233 vam->async_mode = 1;
7234 vam->async_errors = 0;
7235 before = vat_time_now (vam);
7238 for (j = 0; j < count; j++)
7240 M (L2FIB_ADD_DEL, mp);
7242 clib_memcpy (mp->mac, mac, 6);
7243 mp->bd_id = ntohl (bd_id);
7244 mp->is_add = is_add;
7248 mp->sw_if_index = ntohl (sw_if_index);
7249 mp->static_mac = static_mac;
7250 mp->filter_mac = filter_mac;
7251 mp->bvi_mac = bvi_mac;
7253 increment_mac_address (mac);
7260 vl_api_control_ping_t *mp_ping;
7263 /* Shut off async mode */
7264 vam->async_mode = 0;
7266 MPING (CONTROL_PING, mp_ping);
7269 timeout = vat_time_now (vam) + 1.0;
7270 while (vat_time_now (vam) < timeout)
7271 if (vam->result_ready == 1)
7276 if (vam->retval == -99)
7279 if (vam->async_errors > 0)
7281 errmsg ("%d asynchronous errors", vam->async_errors);
7284 vam->async_errors = 0;
7285 after = vat_time_now (vam);
7287 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7288 count, after - before, count / (after - before));
7294 /* Wait for a reply... */
7298 /* Return the good/bad news */
7299 return (vam->retval);
7303 api_bridge_domain_set_mac_age (vat_main_t * vam)
7305 unformat_input_t *i = vam->input;
7306 vl_api_bridge_domain_set_mac_age_t *mp;
7311 /* Parse args required to build the message */
7312 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7314 if (unformat (i, "bd_id %d", &bd_id));
7315 else if (unformat (i, "mac-age %d", &mac_age));
7322 errmsg ("missing bridge domain");
7328 errmsg ("mac age must be less than 256 ");
7332 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7334 mp->bd_id = htonl (bd_id);
7335 mp->mac_age = (u8) mac_age;
7343 api_l2_flags (vat_main_t * vam)
7345 unformat_input_t *i = vam->input;
7346 vl_api_l2_flags_t *mp;
7349 u8 sw_if_index_set = 0;
7353 /* Parse args required to build the message */
7354 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7356 if (unformat (i, "sw_if_index %d", &sw_if_index))
7357 sw_if_index_set = 1;
7358 else if (unformat (i, "sw_if"))
7360 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7363 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7364 sw_if_index_set = 1;
7369 else if (unformat (i, "learn"))
7371 else if (unformat (i, "forward"))
7373 else if (unformat (i, "flood"))
7375 else if (unformat (i, "uu-flood"))
7376 flags |= L2_UU_FLOOD;
7377 else if (unformat (i, "arp-term"))
7378 flags |= L2_ARP_TERM;
7379 else if (unformat (i, "off"))
7381 else if (unformat (i, "disable"))
7387 if (sw_if_index_set == 0)
7389 errmsg ("missing interface name or sw_if_index");
7395 mp->sw_if_index = ntohl (sw_if_index);
7396 mp->feature_bitmap = ntohl (flags);
7397 mp->is_set = is_set;
7405 api_bridge_flags (vat_main_t * vam)
7407 unformat_input_t *i = vam->input;
7408 vl_api_bridge_flags_t *mp;
7415 /* Parse args required to build the message */
7416 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7418 if (unformat (i, "bd_id %d", &bd_id))
7420 else if (unformat (i, "learn"))
7422 else if (unformat (i, "forward"))
7424 else if (unformat (i, "flood"))
7426 else if (unformat (i, "uu-flood"))
7427 flags |= L2_UU_FLOOD;
7428 else if (unformat (i, "arp-term"))
7429 flags |= L2_ARP_TERM;
7430 else if (unformat (i, "off"))
7432 else if (unformat (i, "disable"))
7440 errmsg ("missing bridge domain");
7444 M (BRIDGE_FLAGS, mp);
7446 mp->bd_id = ntohl (bd_id);
7447 mp->feature_bitmap = ntohl (flags);
7448 mp->is_set = is_set;
7456 api_bd_ip_mac_add_del (vat_main_t * vam)
7458 unformat_input_t *i = vam->input;
7459 vl_api_bd_ip_mac_add_del_t *mp;
7466 ip4_address_t v4addr;
7467 ip6_address_t v6addr;
7472 /* Parse args required to build the message */
7473 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7475 if (unformat (i, "bd_id %d", &bd_id))
7479 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7483 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7488 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7492 else if (unformat (i, "del"))
7500 errmsg ("missing bridge domain");
7503 else if (ip_set == 0)
7505 errmsg ("missing IP address");
7508 else if (mac_set == 0)
7510 errmsg ("missing MAC address");
7514 M (BD_IP_MAC_ADD_DEL, mp);
7516 mp->bd_id = ntohl (bd_id);
7517 mp->is_ipv6 = is_ipv6;
7518 mp->is_add = is_add;
7520 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7522 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7523 clib_memcpy (mp->mac_address, macaddr, 6);
7530 api_tap_connect (vat_main_t * vam)
7532 unformat_input_t *i = vam->input;
7533 vl_api_tap_connect_t *mp;
7539 ip4_address_t ip4_address;
7541 int ip4_address_set = 0;
7542 ip6_address_t ip6_address;
7544 int ip6_address_set = 0;
7547 memset (mac_address, 0, sizeof (mac_address));
7549 /* Parse args required to build the message */
7550 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7552 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7556 else if (unformat (i, "random-mac"))
7558 else if (unformat (i, "tapname %s", &tap_name))
7560 else if (unformat (i, "tag %s", &tag))
7562 else if (unformat (i, "address %U/%d",
7563 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7564 ip4_address_set = 1;
7565 else if (unformat (i, "address %U/%d",
7566 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7567 ip6_address_set = 1;
7574 errmsg ("missing tap name");
7577 if (vec_len (tap_name) > 63)
7579 errmsg ("tap name too long");
7582 vec_add1 (tap_name, 0);
7584 if (vec_len (tag) > 63)
7586 errmsg ("tag too long");
7590 /* Construct the API message */
7591 M (TAP_CONNECT, mp);
7593 mp->use_random_mac = random_mac;
7594 clib_memcpy (mp->mac_address, mac_address, 6);
7595 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7597 clib_memcpy (mp->tag, tag, vec_len (tag));
7599 if (ip4_address_set)
7601 mp->ip4_address_set = 1;
7602 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7603 mp->ip4_mask_width = ip4_mask_width;
7605 if (ip6_address_set)
7607 mp->ip6_address_set = 1;
7608 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7609 mp->ip6_mask_width = ip6_mask_width;
7612 vec_free (tap_name);
7618 /* Wait for a reply... */
7624 api_tap_modify (vat_main_t * vam)
7626 unformat_input_t *i = vam->input;
7627 vl_api_tap_modify_t *mp;
7632 u32 sw_if_index = ~0;
7633 u8 sw_if_index_set = 0;
7636 memset (mac_address, 0, sizeof (mac_address));
7638 /* Parse args required to build the message */
7639 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7641 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7642 sw_if_index_set = 1;
7643 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7644 sw_if_index_set = 1;
7645 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7649 else if (unformat (i, "random-mac"))
7651 else if (unformat (i, "tapname %s", &tap_name))
7657 if (sw_if_index_set == 0)
7659 errmsg ("missing vpp interface name");
7664 errmsg ("missing tap name");
7667 if (vec_len (tap_name) > 63)
7669 errmsg ("tap name too long");
7671 vec_add1 (tap_name, 0);
7673 /* Construct the API message */
7676 mp->use_random_mac = random_mac;
7677 mp->sw_if_index = ntohl (sw_if_index);
7678 clib_memcpy (mp->mac_address, mac_address, 6);
7679 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7680 vec_free (tap_name);
7685 /* Wait for a reply... */
7691 api_tap_delete (vat_main_t * vam)
7693 unformat_input_t *i = vam->input;
7694 vl_api_tap_delete_t *mp;
7695 u32 sw_if_index = ~0;
7696 u8 sw_if_index_set = 0;
7699 /* Parse args required to build the message */
7700 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7702 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7703 sw_if_index_set = 1;
7704 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7705 sw_if_index_set = 1;
7710 if (sw_if_index_set == 0)
7712 errmsg ("missing vpp interface name");
7716 /* Construct the API message */
7719 mp->sw_if_index = ntohl (sw_if_index);
7724 /* Wait for a reply... */
7730 api_ip_table_add_del (vat_main_t * vam)
7732 unformat_input_t *i = vam->input;
7733 vl_api_ip_table_add_del_t *mp;
7739 /* Parse args required to build the message */
7740 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7742 if (unformat (i, "ipv6"))
7744 else if (unformat (i, "del"))
7746 else if (unformat (i, "add"))
7748 else if (unformat (i, "table %d", &table_id))
7752 clib_warning ("parse error '%U'", format_unformat_error, i);
7759 errmsg ("missing table-ID");
7763 /* Construct the API message */
7764 M (IP_TABLE_ADD_DEL, mp);
7766 mp->table_id = ntohl (table_id);
7767 mp->is_ipv6 = is_ipv6;
7768 mp->is_add = is_add;
7773 /* Wait for a reply... */
7780 api_ip_add_del_route (vat_main_t * vam)
7782 unformat_input_t *i = vam->input;
7783 vl_api_ip_add_del_route_t *mp;
7784 u32 sw_if_index = ~0, vrf_id = 0;
7786 u8 is_local = 0, is_drop = 0;
7787 u8 is_unreach = 0, is_prohibit = 0;
7788 u8 create_vrf_if_needed = 0;
7790 u32 next_hop_weight = 1;
7791 u8 is_multipath = 0;
7793 u8 address_length_set = 0;
7794 u32 next_hop_table_id = 0;
7795 u32 resolve_attempts = 0;
7796 u32 dst_address_length = 0;
7797 u8 next_hop_set = 0;
7798 ip4_address_t v4_dst_address, v4_next_hop_address;
7799 ip6_address_t v6_dst_address, v6_next_hop_address;
7803 u32 random_add_del = 0;
7804 u32 *random_vector = 0;
7806 u32 random_seed = 0xdeaddabe;
7807 u32 classify_table_index = ~0;
7809 u8 resolve_host = 0, resolve_attached = 0;
7810 mpls_label_t *next_hop_out_label_stack = NULL;
7811 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7812 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7814 /* Parse args required to build the message */
7815 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7817 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7819 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7821 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
7826 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
7831 else if (unformat (i, "/%d", &dst_address_length))
7833 address_length_set = 1;
7836 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
7837 &v4_next_hop_address))
7841 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7842 &v6_next_hop_address))
7846 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7848 else if (unformat (i, "weight %d", &next_hop_weight))
7850 else if (unformat (i, "drop"))
7854 else if (unformat (i, "null-send-unreach"))
7858 else if (unformat (i, "null-send-prohibit"))
7862 else if (unformat (i, "local"))
7866 else if (unformat (i, "classify %d", &classify_table_index))
7870 else if (unformat (i, "del"))
7872 else if (unformat (i, "add"))
7874 else if (unformat (i, "resolve-via-host"))
7876 else if (unformat (i, "resolve-via-attached"))
7877 resolve_attached = 1;
7878 else if (unformat (i, "multipath"))
7880 else if (unformat (i, "vrf %d", &vrf_id))
7882 else if (unformat (i, "create-vrf"))
7883 create_vrf_if_needed = 1;
7884 else if (unformat (i, "count %d", &count))
7886 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7888 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7890 else if (unformat (i, "out-label %d", &next_hop_out_label))
7891 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7892 else if (unformat (i, "via-label %d", &next_hop_via_label))
7894 else if (unformat (i, "random"))
7896 else if (unformat (i, "seed %d", &random_seed))
7900 clib_warning ("parse error '%U'", format_unformat_error, i);
7905 if (!next_hop_set && !is_drop && !is_local &&
7906 !is_classify && !is_unreach && !is_prohibit &&
7907 MPLS_LABEL_INVALID == next_hop_via_label)
7910 ("next hop / local / drop / unreach / prohibit / classify not set");
7914 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7916 errmsg ("next hop and next-hop via label set");
7919 if (address_set == 0)
7921 errmsg ("missing addresses");
7925 if (address_length_set == 0)
7927 errmsg ("missing address length");
7931 /* Generate a pile of unique, random routes */
7934 u32 this_random_address;
7935 random_hash = hash_create (count, sizeof (uword));
7937 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7938 for (j = 0; j <= count; j++)
7942 this_random_address = random_u32 (&random_seed);
7943 this_random_address =
7944 clib_host_to_net_u32 (this_random_address);
7946 while (hash_get (random_hash, this_random_address));
7947 vec_add1 (random_vector, this_random_address);
7948 hash_set (random_hash, this_random_address, 1);
7950 hash_free (random_hash);
7951 v4_dst_address.as_u32 = random_vector[0];
7956 /* Turn on async mode */
7957 vam->async_mode = 1;
7958 vam->async_errors = 0;
7959 before = vat_time_now (vam);
7962 for (j = 0; j < count; j++)
7964 /* Construct the API message */
7965 M2 (IP_ADD_DEL_ROUTE, mp,
7966 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7968 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7969 mp->table_id = ntohl (vrf_id);
7970 mp->create_vrf_if_needed = create_vrf_if_needed;
7972 mp->is_add = is_add;
7973 mp->is_drop = is_drop;
7974 mp->is_unreach = is_unreach;
7975 mp->is_prohibit = is_prohibit;
7976 mp->is_ipv6 = is_ipv6;
7977 mp->is_local = is_local;
7978 mp->is_classify = is_classify;
7979 mp->is_multipath = is_multipath;
7980 mp->is_resolve_host = resolve_host;
7981 mp->is_resolve_attached = resolve_attached;
7982 mp->next_hop_weight = next_hop_weight;
7983 mp->dst_address_length = dst_address_length;
7984 mp->next_hop_table_id = ntohl (next_hop_table_id);
7985 mp->classify_table_index = ntohl (classify_table_index);
7986 mp->next_hop_via_label = ntohl (next_hop_via_label);
7987 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7988 if (0 != mp->next_hop_n_out_labels)
7990 memcpy (mp->next_hop_out_label_stack,
7991 next_hop_out_label_stack,
7992 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7993 vec_free (next_hop_out_label_stack);
7998 clib_memcpy (mp->dst_address, &v6_dst_address,
7999 sizeof (v6_dst_address));
8001 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8002 sizeof (v6_next_hop_address));
8003 increment_v6_address (&v6_dst_address);
8007 clib_memcpy (mp->dst_address, &v4_dst_address,
8008 sizeof (v4_dst_address));
8010 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8011 sizeof (v4_next_hop_address));
8013 v4_dst_address.as_u32 = random_vector[j + 1];
8015 increment_v4_address (&v4_dst_address);
8019 /* If we receive SIGTERM, stop now... */
8024 /* When testing multiple add/del ops, use a control-ping to sync */
8027 vl_api_control_ping_t *mp_ping;
8031 /* Shut off async mode */
8032 vam->async_mode = 0;
8034 MPING (CONTROL_PING, mp_ping);
8037 timeout = vat_time_now (vam) + 1.0;
8038 while (vat_time_now (vam) < timeout)
8039 if (vam->result_ready == 1)
8044 if (vam->retval == -99)
8047 if (vam->async_errors > 0)
8049 errmsg ("%d asynchronous errors", vam->async_errors);
8052 vam->async_errors = 0;
8053 after = vat_time_now (vam);
8055 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8059 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8060 count, after - before, count / (after - before));
8066 /* Wait for a reply... */
8071 /* Return the good/bad news */
8072 return (vam->retval);
8076 api_ip_mroute_add_del (vat_main_t * vam)
8078 unformat_input_t *i = vam->input;
8079 vl_api_ip_mroute_add_del_t *mp;
8080 u32 sw_if_index = ~0, vrf_id = 0;
8083 u8 create_vrf_if_needed = 0;
8086 u32 grp_address_length = 0;
8087 ip4_address_t v4_grp_address, v4_src_address;
8088 ip6_address_t v6_grp_address, v6_src_address;
8089 mfib_itf_flags_t iflags = 0;
8090 mfib_entry_flags_t eflags = 0;
8093 /* Parse args required to build the message */
8094 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8096 if (unformat (i, "sw_if_index %d", &sw_if_index))
8098 else if (unformat (i, "%U %U",
8099 unformat_ip4_address, &v4_src_address,
8100 unformat_ip4_address, &v4_grp_address))
8102 grp_address_length = 64;
8106 else if (unformat (i, "%U %U",
8107 unformat_ip6_address, &v6_src_address,
8108 unformat_ip6_address, &v6_grp_address))
8110 grp_address_length = 256;
8114 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8116 memset (&v4_src_address, 0, sizeof (v4_src_address));
8117 grp_address_length = 32;
8121 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8123 memset (&v6_src_address, 0, sizeof (v6_src_address));
8124 grp_address_length = 128;
8128 else if (unformat (i, "/%d", &grp_address_length))
8130 else if (unformat (i, "local"))
8134 else if (unformat (i, "del"))
8136 else if (unformat (i, "add"))
8138 else if (unformat (i, "vrf %d", &vrf_id))
8140 else if (unformat (i, "create-vrf"))
8141 create_vrf_if_needed = 1;
8142 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8144 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8148 clib_warning ("parse error '%U'", format_unformat_error, i);
8153 if (address_set == 0)
8155 errmsg ("missing addresses\n");
8159 /* Construct the API message */
8160 M (IP_MROUTE_ADD_DEL, mp);
8162 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8163 mp->table_id = ntohl (vrf_id);
8164 mp->create_vrf_if_needed = create_vrf_if_needed;
8166 mp->is_add = is_add;
8167 mp->is_ipv6 = is_ipv6;
8168 mp->is_local = is_local;
8169 mp->itf_flags = ntohl (iflags);
8170 mp->entry_flags = ntohl (eflags);
8171 mp->grp_address_length = grp_address_length;
8172 mp->grp_address_length = ntohs (mp->grp_address_length);
8176 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8177 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8181 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8182 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8188 /* Wait for a reply... */
8194 api_mpls_table_add_del (vat_main_t * vam)
8196 unformat_input_t *i = vam->input;
8197 vl_api_mpls_table_add_del_t *mp;
8202 /* Parse args required to build the message */
8203 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8205 if (unformat (i, "table %d", &table_id))
8207 else if (unformat (i, "del"))
8209 else if (unformat (i, "add"))
8213 clib_warning ("parse error '%U'", format_unformat_error, i);
8220 errmsg ("missing table-ID");
8224 /* Construct the API message */
8225 M (MPLS_TABLE_ADD_DEL, mp);
8227 mp->mt_table_id = ntohl (table_id);
8228 mp->mt_is_add = is_add;
8233 /* Wait for a reply... */
8240 api_mpls_route_add_del (vat_main_t * vam)
8242 unformat_input_t *i = vam->input;
8243 vl_api_mpls_route_add_del_t *mp;
8244 u32 sw_if_index = ~0, table_id = 0;
8245 u8 create_table_if_needed = 0;
8247 u32 next_hop_weight = 1;
8248 u8 is_multipath = 0;
8249 u32 next_hop_table_id = 0;
8250 u8 next_hop_set = 0;
8251 ip4_address_t v4_next_hop_address = {
8254 ip6_address_t v6_next_hop_address = { {0} };
8258 u32 classify_table_index = ~0;
8260 u8 resolve_host = 0, resolve_attached = 0;
8261 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8262 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8263 mpls_label_t *next_hop_out_label_stack = NULL;
8264 mpls_label_t local_label = MPLS_LABEL_INVALID;
8266 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8268 /* Parse args required to build the message */
8269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8271 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8273 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8275 else if (unformat (i, "%d", &local_label))
8277 else if (unformat (i, "eos"))
8279 else if (unformat (i, "non-eos"))
8281 else if (unformat (i, "via %U", unformat_ip4_address,
8282 &v4_next_hop_address))
8285 next_hop_proto = DPO_PROTO_IP4;
8287 else if (unformat (i, "via %U", unformat_ip6_address,
8288 &v6_next_hop_address))
8291 next_hop_proto = DPO_PROTO_IP6;
8293 else if (unformat (i, "weight %d", &next_hop_weight))
8295 else if (unformat (i, "create-table"))
8296 create_table_if_needed = 1;
8297 else if (unformat (i, "classify %d", &classify_table_index))
8301 else if (unformat (i, "del"))
8303 else if (unformat (i, "add"))
8305 else if (unformat (i, "resolve-via-host"))
8307 else if (unformat (i, "resolve-via-attached"))
8308 resolve_attached = 1;
8309 else if (unformat (i, "multipath"))
8311 else if (unformat (i, "count %d", &count))
8313 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8316 next_hop_proto = DPO_PROTO_IP4;
8318 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8321 next_hop_proto = DPO_PROTO_IP6;
8323 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8325 else if (unformat (i, "via-label %d", &next_hop_via_label))
8327 else if (unformat (i, "out-label %d", &next_hop_out_label))
8328 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8331 clib_warning ("parse error '%U'", format_unformat_error, i);
8336 if (!next_hop_set && !is_classify)
8338 errmsg ("next hop / classify not set");
8342 if (MPLS_LABEL_INVALID == local_label)
8344 errmsg ("missing label");
8350 /* Turn on async mode */
8351 vam->async_mode = 1;
8352 vam->async_errors = 0;
8353 before = vat_time_now (vam);
8356 for (j = 0; j < count; j++)
8358 /* Construct the API message */
8359 M2 (MPLS_ROUTE_ADD_DEL, mp,
8360 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8362 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8363 mp->mr_table_id = ntohl (table_id);
8364 mp->mr_create_table_if_needed = create_table_if_needed;
8366 mp->mr_is_add = is_add;
8367 mp->mr_next_hop_proto = next_hop_proto;
8368 mp->mr_is_classify = is_classify;
8369 mp->mr_is_multipath = is_multipath;
8370 mp->mr_is_resolve_host = resolve_host;
8371 mp->mr_is_resolve_attached = resolve_attached;
8372 mp->mr_next_hop_weight = next_hop_weight;
8373 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8374 mp->mr_classify_table_index = ntohl (classify_table_index);
8375 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8376 mp->mr_label = ntohl (local_label);
8377 mp->mr_eos = is_eos;
8379 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8380 if (0 != mp->mr_next_hop_n_out_labels)
8382 memcpy (mp->mr_next_hop_out_label_stack,
8383 next_hop_out_label_stack,
8384 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8385 vec_free (next_hop_out_label_stack);
8390 if (DPO_PROTO_IP4 == next_hop_proto)
8392 clib_memcpy (mp->mr_next_hop,
8393 &v4_next_hop_address,
8394 sizeof (v4_next_hop_address));
8396 else if (DPO_PROTO_IP6 == next_hop_proto)
8399 clib_memcpy (mp->mr_next_hop,
8400 &v6_next_hop_address,
8401 sizeof (v6_next_hop_address));
8408 /* If we receive SIGTERM, stop now... */
8413 /* When testing multiple add/del ops, use a control-ping to sync */
8416 vl_api_control_ping_t *mp_ping;
8420 /* Shut off async mode */
8421 vam->async_mode = 0;
8423 MPING (CONTROL_PING, mp_ping);
8426 timeout = vat_time_now (vam) + 1.0;
8427 while (vat_time_now (vam) < timeout)
8428 if (vam->result_ready == 1)
8433 if (vam->retval == -99)
8436 if (vam->async_errors > 0)
8438 errmsg ("%d asynchronous errors", vam->async_errors);
8441 vam->async_errors = 0;
8442 after = vat_time_now (vam);
8444 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8448 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8449 count, after - before, count / (after - before));
8455 /* Wait for a reply... */
8460 /* Return the good/bad news */
8461 return (vam->retval);
8465 api_mpls_ip_bind_unbind (vat_main_t * vam)
8467 unformat_input_t *i = vam->input;
8468 vl_api_mpls_ip_bind_unbind_t *mp;
8469 u32 ip_table_id = 0;
8470 u8 create_table_if_needed = 0;
8473 ip4_address_t v4_address;
8474 ip6_address_t v6_address;
8477 mpls_label_t local_label = MPLS_LABEL_INVALID;
8480 /* Parse args required to build the message */
8481 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8483 if (unformat (i, "%U/%d", unformat_ip4_address,
8484 &v4_address, &address_length))
8489 else if (unformat (i, "%U/%d", unformat_ip6_address,
8490 &v6_address, &address_length))
8495 else if (unformat (i, "%d", &local_label))
8497 else if (unformat (i, "create-table"))
8498 create_table_if_needed = 1;
8499 else if (unformat (i, "table-id %d", &ip_table_id))
8501 else if (unformat (i, "unbind"))
8503 else if (unformat (i, "bind"))
8507 clib_warning ("parse error '%U'", format_unformat_error, i);
8514 errmsg ("IP addres not set");
8518 if (MPLS_LABEL_INVALID == local_label)
8520 errmsg ("missing label");
8524 /* Construct the API message */
8525 M (MPLS_IP_BIND_UNBIND, mp);
8527 mp->mb_create_table_if_needed = create_table_if_needed;
8528 mp->mb_is_bind = is_bind;
8529 mp->mb_is_ip4 = is_ip4;
8530 mp->mb_ip_table_id = ntohl (ip_table_id);
8531 mp->mb_mpls_table_id = 0;
8532 mp->mb_label = ntohl (local_label);
8533 mp->mb_address_length = address_length;
8536 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8538 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8543 /* Wait for a reply... */
8549 api_proxy_arp_add_del (vat_main_t * vam)
8551 unformat_input_t *i = vam->input;
8552 vl_api_proxy_arp_add_del_t *mp;
8555 ip4_address_t lo, hi;
8559 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8561 if (unformat (i, "vrf %d", &vrf_id))
8563 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
8564 unformat_ip4_address, &hi))
8566 else if (unformat (i, "del"))
8570 clib_warning ("parse error '%U'", format_unformat_error, i);
8577 errmsg ("address range not set");
8581 M (PROXY_ARP_ADD_DEL, mp);
8583 mp->vrf_id = ntohl (vrf_id);
8584 mp->is_add = is_add;
8585 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
8586 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
8594 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8596 unformat_input_t *i = vam->input;
8597 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8600 u8 sw_if_index_set = 0;
8603 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8605 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8606 sw_if_index_set = 1;
8607 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8608 sw_if_index_set = 1;
8609 else if (unformat (i, "enable"))
8611 else if (unformat (i, "disable"))
8615 clib_warning ("parse error '%U'", format_unformat_error, i);
8620 if (sw_if_index_set == 0)
8622 errmsg ("missing interface name or sw_if_index");
8626 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8628 mp->sw_if_index = ntohl (sw_if_index);
8629 mp->enable_disable = enable;
8637 api_mpls_tunnel_add_del (vat_main_t * vam)
8639 unformat_input_t *i = vam->input;
8640 vl_api_mpls_tunnel_add_del_t *mp;
8644 u32 sw_if_index = ~0;
8645 u32 next_hop_sw_if_index = ~0;
8646 u32 next_hop_proto_is_ip4 = 1;
8648 u32 next_hop_table_id = 0;
8649 ip4_address_t v4_next_hop_address = {
8652 ip6_address_t v6_next_hop_address = { {0} };
8653 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
8656 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8658 if (unformat (i, "add"))
8660 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8662 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
8664 else if (unformat (i, "via %U",
8665 unformat_ip4_address, &v4_next_hop_address))
8667 next_hop_proto_is_ip4 = 1;
8669 else if (unformat (i, "via %U",
8670 unformat_ip6_address, &v6_next_hop_address))
8672 next_hop_proto_is_ip4 = 0;
8674 else if (unformat (i, "l2-only"))
8676 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8678 else if (unformat (i, "out-label %d", &next_hop_out_label))
8679 vec_add1 (labels, ntohl (next_hop_out_label));
8682 clib_warning ("parse error '%U'", format_unformat_error, i);
8687 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
8689 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
8690 mp->mt_sw_if_index = ntohl (sw_if_index);
8691 mp->mt_is_add = is_add;
8692 mp->mt_l2_only = l2_only;
8693 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
8694 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
8696 mp->mt_next_hop_n_out_labels = vec_len (labels);
8698 if (0 != mp->mt_next_hop_n_out_labels)
8700 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
8701 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
8705 if (next_hop_proto_is_ip4)
8707 clib_memcpy (mp->mt_next_hop,
8708 &v4_next_hop_address, sizeof (v4_next_hop_address));
8712 clib_memcpy (mp->mt_next_hop,
8713 &v6_next_hop_address, sizeof (v6_next_hop_address));
8722 api_sw_interface_set_unnumbered (vat_main_t * vam)
8724 unformat_input_t *i = vam->input;
8725 vl_api_sw_interface_set_unnumbered_t *mp;
8727 u32 unnum_sw_index = ~0;
8729 u8 sw_if_index_set = 0;
8732 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8734 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8735 sw_if_index_set = 1;
8736 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8737 sw_if_index_set = 1;
8738 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8740 else if (unformat (i, "del"))
8744 clib_warning ("parse error '%U'", format_unformat_error, i);
8749 if (sw_if_index_set == 0)
8751 errmsg ("missing interface name or sw_if_index");
8755 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8757 mp->sw_if_index = ntohl (sw_if_index);
8758 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8759 mp->is_add = is_add;
8767 api_ip_neighbor_add_del (vat_main_t * vam)
8769 unformat_input_t *i = vam->input;
8770 vl_api_ip_neighbor_add_del_t *mp;
8772 u8 sw_if_index_set = 0;
8775 u8 is_no_fib_entry = 0;
8778 u8 v4_address_set = 0;
8779 u8 v6_address_set = 0;
8780 ip4_address_t v4address;
8781 ip6_address_t v6address;
8784 memset (mac_address, 0, sizeof (mac_address));
8786 /* Parse args required to build the message */
8787 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8789 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8793 else if (unformat (i, "del"))
8796 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8797 sw_if_index_set = 1;
8798 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8799 sw_if_index_set = 1;
8800 else if (unformat (i, "is_static"))
8802 else if (unformat (i, "no-fib-entry"))
8803 is_no_fib_entry = 1;
8804 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
8806 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
8810 clib_warning ("parse error '%U'", format_unformat_error, i);
8815 if (sw_if_index_set == 0)
8817 errmsg ("missing interface name or sw_if_index");
8820 if (v4_address_set && v6_address_set)
8822 errmsg ("both v4 and v6 addresses set");
8825 if (!v4_address_set && !v6_address_set)
8827 errmsg ("no address set");
8831 /* Construct the API message */
8832 M (IP_NEIGHBOR_ADD_DEL, mp);
8834 mp->sw_if_index = ntohl (sw_if_index);
8835 mp->is_add = is_add;
8836 mp->is_static = is_static;
8837 mp->is_no_adj_fib = is_no_fib_entry;
8839 clib_memcpy (mp->mac_address, mac_address, 6);
8843 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
8847 /* mp->is_ipv6 = 0; via memset in M macro above */
8848 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
8854 /* Wait for a reply, return good/bad news */
8860 api_reset_vrf (vat_main_t * vam)
8862 unformat_input_t *i = vam->input;
8863 vl_api_reset_vrf_t *mp;
8869 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8871 if (unformat (i, "vrf %d", &vrf_id))
8873 else if (unformat (i, "ipv6"))
8877 clib_warning ("parse error '%U'", format_unformat_error, i);
8882 if (vrf_id_set == 0)
8884 errmsg ("missing vrf id");
8890 mp->vrf_id = ntohl (vrf_id);
8891 mp->is_ipv6 = is_ipv6;
8899 api_create_vlan_subif (vat_main_t * vam)
8901 unformat_input_t *i = vam->input;
8902 vl_api_create_vlan_subif_t *mp;
8904 u8 sw_if_index_set = 0;
8909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8911 if (unformat (i, "sw_if_index %d", &sw_if_index))
8912 sw_if_index_set = 1;
8914 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8915 sw_if_index_set = 1;
8916 else if (unformat (i, "vlan %d", &vlan_id))
8920 clib_warning ("parse error '%U'", format_unformat_error, i);
8925 if (sw_if_index_set == 0)
8927 errmsg ("missing interface name or sw_if_index");
8931 if (vlan_id_set == 0)
8933 errmsg ("missing vlan_id");
8936 M (CREATE_VLAN_SUBIF, mp);
8938 mp->sw_if_index = ntohl (sw_if_index);
8939 mp->vlan_id = ntohl (vlan_id);
8946 #define foreach_create_subif_bit \
8953 _(outer_vlan_id_any) \
8954 _(inner_vlan_id_any)
8957 api_create_subif (vat_main_t * vam)
8959 unformat_input_t *i = vam->input;
8960 vl_api_create_subif_t *mp;
8962 u8 sw_if_index_set = 0;
8969 u32 exact_match = 0;
8970 u32 default_sub = 0;
8971 u32 outer_vlan_id_any = 0;
8972 u32 inner_vlan_id_any = 0;
8974 u16 outer_vlan_id = 0;
8975 u16 inner_vlan_id = 0;
8978 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8980 if (unformat (i, "sw_if_index %d", &sw_if_index))
8981 sw_if_index_set = 1;
8983 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8984 sw_if_index_set = 1;
8985 else if (unformat (i, "sub_id %d", &sub_id))
8987 else if (unformat (i, "outer_vlan_id %d", &tmp))
8988 outer_vlan_id = tmp;
8989 else if (unformat (i, "inner_vlan_id %d", &tmp))
8990 inner_vlan_id = tmp;
8992 #define _(a) else if (unformat (i, #a)) a = 1 ;
8993 foreach_create_subif_bit
8997 clib_warning ("parse error '%U'", format_unformat_error, i);
9002 if (sw_if_index_set == 0)
9004 errmsg ("missing interface name or sw_if_index");
9008 if (sub_id_set == 0)
9010 errmsg ("missing sub_id");
9013 M (CREATE_SUBIF, mp);
9015 mp->sw_if_index = ntohl (sw_if_index);
9016 mp->sub_id = ntohl (sub_id);
9018 #define _(a) mp->a = a;
9019 foreach_create_subif_bit;
9022 mp->outer_vlan_id = ntohs (outer_vlan_id);
9023 mp->inner_vlan_id = ntohs (inner_vlan_id);
9031 api_oam_add_del (vat_main_t * vam)
9033 unformat_input_t *i = vam->input;
9034 vl_api_oam_add_del_t *mp;
9037 ip4_address_t src, dst;
9042 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9044 if (unformat (i, "vrf %d", &vrf_id))
9046 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9048 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9050 else if (unformat (i, "del"))
9054 clib_warning ("parse error '%U'", format_unformat_error, i);
9061 errmsg ("missing src addr");
9067 errmsg ("missing dst addr");
9071 M (OAM_ADD_DEL, mp);
9073 mp->vrf_id = ntohl (vrf_id);
9074 mp->is_add = is_add;
9075 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9076 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9084 api_reset_fib (vat_main_t * vam)
9086 unformat_input_t *i = vam->input;
9087 vl_api_reset_fib_t *mp;
9093 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9095 if (unformat (i, "vrf %d", &vrf_id))
9097 else if (unformat (i, "ipv6"))
9101 clib_warning ("parse error '%U'", format_unformat_error, i);
9106 if (vrf_id_set == 0)
9108 errmsg ("missing vrf id");
9114 mp->vrf_id = ntohl (vrf_id);
9115 mp->is_ipv6 = is_ipv6;
9123 api_dhcp_proxy_config (vat_main_t * vam)
9125 unformat_input_t *i = vam->input;
9126 vl_api_dhcp_proxy_config_t *mp;
9128 u32 server_vrf_id = 0;
9130 u8 v4_address_set = 0;
9131 u8 v6_address_set = 0;
9132 ip4_address_t v4address;
9133 ip6_address_t v6address;
9134 u8 v4_src_address_set = 0;
9135 u8 v6_src_address_set = 0;
9136 ip4_address_t v4srcaddress;
9137 ip6_address_t v6srcaddress;
9140 /* Parse args required to build the message */
9141 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9143 if (unformat (i, "del"))
9145 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9147 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9149 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9151 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9153 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9154 v4_src_address_set = 1;
9155 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9156 v6_src_address_set = 1;
9161 if (v4_address_set && v6_address_set)
9163 errmsg ("both v4 and v6 server addresses set");
9166 if (!v4_address_set && !v6_address_set)
9168 errmsg ("no server addresses set");
9172 if (v4_src_address_set && v6_src_address_set)
9174 errmsg ("both v4 and v6 src addresses set");
9177 if (!v4_src_address_set && !v6_src_address_set)
9179 errmsg ("no src addresses set");
9183 if (!(v4_src_address_set && v4_address_set) &&
9184 !(v6_src_address_set && v6_address_set))
9186 errmsg ("no matching server and src addresses set");
9190 /* Construct the API message */
9191 M (DHCP_PROXY_CONFIG, mp);
9193 mp->is_add = is_add;
9194 mp->rx_vrf_id = ntohl (rx_vrf_id);
9195 mp->server_vrf_id = ntohl (server_vrf_id);
9199 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9200 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9204 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9205 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9211 /* Wait for a reply, return good/bad news */
9216 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9217 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9220 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9222 vat_main_t *vam = &vat_main;
9223 u32 i, count = mp->count;
9224 vl_api_dhcp_server_t *s;
9228 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
9229 ntohl (mp->rx_vrf_id),
9230 format_ip6_address, mp->dhcp_src_address,
9231 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9234 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
9235 ntohl (mp->rx_vrf_id),
9236 format_ip4_address, mp->dhcp_src_address,
9237 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9239 for (i = 0; i < count; i++)
9241 s = &mp->servers[i];
9245 " Server Table-ID %d, Server Address %U",
9246 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9249 " Server Table-ID %d, Server Address %U",
9250 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9254 static void vl_api_dhcp_proxy_details_t_handler_json
9255 (vl_api_dhcp_proxy_details_t * mp)
9257 vat_main_t *vam = &vat_main;
9258 vat_json_node_t *node = NULL;
9259 u32 i, count = mp->count;
9261 struct in6_addr ip6;
9262 vl_api_dhcp_server_t *s;
9264 if (VAT_JSON_ARRAY != vam->json_tree.type)
9266 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9267 vat_json_init_array (&vam->json_tree);
9269 node = vat_json_array_add (&vam->json_tree);
9271 vat_json_init_object (node);
9272 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9273 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9274 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9278 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9279 vat_json_object_add_ip6 (node, "src_address", ip6);
9283 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9284 vat_json_object_add_ip4 (node, "src_address", ip4);
9287 for (i = 0; i < count; i++)
9289 s = &mp->servers[i];
9291 vat_json_object_add_uint (node, "server-table-id",
9292 ntohl (s->server_vrf_id));
9296 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9297 vat_json_object_add_ip4 (node, "src_address", ip4);
9301 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9302 vat_json_object_add_ip6 (node, "server_address", ip6);
9308 api_dhcp_proxy_dump (vat_main_t * vam)
9310 unformat_input_t *i = vam->input;
9311 vl_api_control_ping_t *mp_ping;
9312 vl_api_dhcp_proxy_dump_t *mp;
9316 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9318 if (unformat (i, "ipv6"))
9322 clib_warning ("parse error '%U'", format_unformat_error, i);
9327 M (DHCP_PROXY_DUMP, mp);
9329 mp->is_ip6 = is_ipv6;
9332 /* Use a control ping for synchronization */
9333 MPING (CONTROL_PING, mp_ping);
9341 api_dhcp_proxy_set_vss (vat_main_t * vam)
9343 unformat_input_t *i = vam->input;
9344 vl_api_dhcp_proxy_set_vss_t *mp;
9355 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9357 if (unformat (i, "tbl_id %d", &tbl_id))
9359 if (unformat (i, "fib_id %d", &fib_id))
9361 if (unformat (i, "oui %d", &oui))
9363 else if (unformat (i, "ipv6"))
9365 else if (unformat (i, "del"))
9369 clib_warning ("parse error '%U'", format_unformat_error, i);
9374 if (tbl_id_set == 0)
9376 errmsg ("missing tbl id");
9380 if (fib_id_set == 0)
9382 errmsg ("missing fib id");
9387 errmsg ("missing oui");
9391 M (DHCP_PROXY_SET_VSS, mp);
9392 mp->tbl_id = ntohl (tbl_id);
9393 mp->fib_id = ntohl (fib_id);
9394 mp->oui = ntohl (oui);
9395 mp->is_ipv6 = is_ipv6;
9396 mp->is_add = is_add;
9404 api_dhcp_client_config (vat_main_t * vam)
9406 unformat_input_t *i = vam->input;
9407 vl_api_dhcp_client_config_t *mp;
9409 u8 sw_if_index_set = 0;
9412 u8 disable_event = 0;
9415 /* Parse args required to build the message */
9416 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9418 if (unformat (i, "del"))
9421 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9422 sw_if_index_set = 1;
9423 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9424 sw_if_index_set = 1;
9425 else if (unformat (i, "hostname %s", &hostname))
9427 else if (unformat (i, "disable_event"))
9433 if (sw_if_index_set == 0)
9435 errmsg ("missing interface name or sw_if_index");
9439 if (vec_len (hostname) > 63)
9441 errmsg ("hostname too long");
9443 vec_add1 (hostname, 0);
9445 /* Construct the API message */
9446 M (DHCP_CLIENT_CONFIG, mp);
9448 mp->sw_if_index = htonl (sw_if_index);
9449 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
9450 vec_free (hostname);
9451 mp->is_add = is_add;
9452 mp->want_dhcp_event = disable_event ? 0 : 1;
9453 mp->pid = htonl (getpid ());
9458 /* Wait for a reply, return good/bad news */
9464 api_set_ip_flow_hash (vat_main_t * vam)
9466 unformat_input_t *i = vam->input;
9467 vl_api_set_ip_flow_hash_t *mp;
9479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9481 if (unformat (i, "vrf %d", &vrf_id))
9483 else if (unformat (i, "ipv6"))
9485 else if (unformat (i, "src"))
9487 else if (unformat (i, "dst"))
9489 else if (unformat (i, "sport"))
9491 else if (unformat (i, "dport"))
9493 else if (unformat (i, "proto"))
9495 else if (unformat (i, "reverse"))
9500 clib_warning ("parse error '%U'", format_unformat_error, i);
9505 if (vrf_id_set == 0)
9507 errmsg ("missing vrf id");
9511 M (SET_IP_FLOW_HASH, mp);
9517 mp->reverse = reverse;
9518 mp->vrf_id = ntohl (vrf_id);
9519 mp->is_ipv6 = is_ipv6;
9527 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9529 unformat_input_t *i = vam->input;
9530 vl_api_sw_interface_ip6_enable_disable_t *mp;
9532 u8 sw_if_index_set = 0;
9536 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9538 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9539 sw_if_index_set = 1;
9540 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9541 sw_if_index_set = 1;
9542 else if (unformat (i, "enable"))
9544 else if (unformat (i, "disable"))
9548 clib_warning ("parse error '%U'", format_unformat_error, i);
9553 if (sw_if_index_set == 0)
9555 errmsg ("missing interface name or sw_if_index");
9559 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9561 mp->sw_if_index = ntohl (sw_if_index);
9562 mp->enable = enable;
9570 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
9572 unformat_input_t *i = vam->input;
9573 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
9575 u8 sw_if_index_set = 0;
9576 u8 v6_address_set = 0;
9577 ip6_address_t v6address;
9580 /* Parse args required to build the message */
9581 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9583 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9584 sw_if_index_set = 1;
9585 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9586 sw_if_index_set = 1;
9587 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9593 if (sw_if_index_set == 0)
9595 errmsg ("missing interface name or sw_if_index");
9598 if (!v6_address_set)
9600 errmsg ("no address set");
9604 /* Construct the API message */
9605 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
9607 mp->sw_if_index = ntohl (sw_if_index);
9608 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9613 /* Wait for a reply, return good/bad news */
9619 api_ip6nd_proxy_add_del (vat_main_t * vam)
9621 unformat_input_t *i = vam->input;
9622 vl_api_ip6nd_proxy_add_del_t *mp;
9623 u32 sw_if_index = ~0;
9624 u8 v6_address_set = 0;
9625 ip6_address_t v6address;
9629 /* Parse args required to build the message */
9630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9632 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9634 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9636 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9638 if (unformat (i, "del"))
9642 clib_warning ("parse error '%U'", format_unformat_error, i);
9647 if (sw_if_index == ~0)
9649 errmsg ("missing interface name or sw_if_index");
9652 if (!v6_address_set)
9654 errmsg ("no address set");
9658 /* Construct the API message */
9659 M (IP6ND_PROXY_ADD_DEL, mp);
9661 mp->is_del = is_del;
9662 mp->sw_if_index = ntohl (sw_if_index);
9663 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9668 /* Wait for a reply, return good/bad news */
9674 api_ip6nd_proxy_dump (vat_main_t * vam)
9676 vl_api_ip6nd_proxy_dump_t *mp;
9677 vl_api_control_ping_t *mp_ping;
9680 M (IP6ND_PROXY_DUMP, mp);
9684 /* Use a control ping for synchronization */
9685 MPING (CONTROL_PING, mp_ping);
9692 static void vl_api_ip6nd_proxy_details_t_handler
9693 (vl_api_ip6nd_proxy_details_t * mp)
9695 vat_main_t *vam = &vat_main;
9697 print (vam->ofp, "host %U sw_if_index %d",
9698 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
9701 static void vl_api_ip6nd_proxy_details_t_handler_json
9702 (vl_api_ip6nd_proxy_details_t * mp)
9704 vat_main_t *vam = &vat_main;
9705 struct in6_addr ip6;
9706 vat_json_node_t *node = NULL;
9708 if (VAT_JSON_ARRAY != vam->json_tree.type)
9710 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9711 vat_json_init_array (&vam->json_tree);
9713 node = vat_json_array_add (&vam->json_tree);
9715 vat_json_init_object (node);
9716 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9718 clib_memcpy (&ip6, mp->address, sizeof (ip6));
9719 vat_json_object_add_ip6 (node, "host", ip6);
9723 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9725 unformat_input_t *i = vam->input;
9726 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9728 u8 sw_if_index_set = 0;
9729 u32 address_length = 0;
9730 u8 v6_address_set = 0;
9731 ip6_address_t v6address;
9733 u8 no_advertise = 0;
9735 u8 no_autoconfig = 0;
9738 u32 val_lifetime = 0;
9739 u32 pref_lifetime = 0;
9742 /* Parse args required to build the message */
9743 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9745 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9746 sw_if_index_set = 1;
9747 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9748 sw_if_index_set = 1;
9749 else if (unformat (i, "%U/%d",
9750 unformat_ip6_address, &v6address, &address_length))
9752 else if (unformat (i, "val_life %d", &val_lifetime))
9754 else if (unformat (i, "pref_life %d", &pref_lifetime))
9756 else if (unformat (i, "def"))
9758 else if (unformat (i, "noadv"))
9760 else if (unformat (i, "offl"))
9762 else if (unformat (i, "noauto"))
9764 else if (unformat (i, "nolink"))
9766 else if (unformat (i, "isno"))
9770 clib_warning ("parse error '%U'", format_unformat_error, i);
9775 if (sw_if_index_set == 0)
9777 errmsg ("missing interface name or sw_if_index");
9780 if (!v6_address_set)
9782 errmsg ("no address set");
9786 /* Construct the API message */
9787 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9789 mp->sw_if_index = ntohl (sw_if_index);
9790 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9791 mp->address_length = address_length;
9792 mp->use_default = use_default;
9793 mp->no_advertise = no_advertise;
9794 mp->off_link = off_link;
9795 mp->no_autoconfig = no_autoconfig;
9796 mp->no_onlink = no_onlink;
9798 mp->val_lifetime = ntohl (val_lifetime);
9799 mp->pref_lifetime = ntohl (pref_lifetime);
9804 /* Wait for a reply, return good/bad news */
9810 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9812 unformat_input_t *i = vam->input;
9813 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9815 u8 sw_if_index_set = 0;
9820 u8 send_unicast = 0;
9823 u8 default_router = 0;
9824 u32 max_interval = 0;
9825 u32 min_interval = 0;
9827 u32 initial_count = 0;
9828 u32 initial_interval = 0;
9832 /* Parse args required to build the message */
9833 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9835 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9836 sw_if_index_set = 1;
9837 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9838 sw_if_index_set = 1;
9839 else if (unformat (i, "maxint %d", &max_interval))
9841 else if (unformat (i, "minint %d", &min_interval))
9843 else if (unformat (i, "life %d", &lifetime))
9845 else if (unformat (i, "count %d", &initial_count))
9847 else if (unformat (i, "interval %d", &initial_interval))
9849 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9851 else if (unformat (i, "managed"))
9853 else if (unformat (i, "other"))
9855 else if (unformat (i, "ll"))
9857 else if (unformat (i, "send"))
9859 else if (unformat (i, "cease"))
9861 else if (unformat (i, "isno"))
9863 else if (unformat (i, "def"))
9867 clib_warning ("parse error '%U'", format_unformat_error, i);
9872 if (sw_if_index_set == 0)
9874 errmsg ("missing interface name or sw_if_index");
9878 /* Construct the API message */
9879 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9881 mp->sw_if_index = ntohl (sw_if_index);
9882 mp->max_interval = ntohl (max_interval);
9883 mp->min_interval = ntohl (min_interval);
9884 mp->lifetime = ntohl (lifetime);
9885 mp->initial_count = ntohl (initial_count);
9886 mp->initial_interval = ntohl (initial_interval);
9887 mp->suppress = suppress;
9888 mp->managed = managed;
9890 mp->ll_option = ll_option;
9891 mp->send_unicast = send_unicast;
9894 mp->default_router = default_router;
9899 /* Wait for a reply, return good/bad news */
9905 api_set_arp_neighbor_limit (vat_main_t * vam)
9907 unformat_input_t *i = vam->input;
9908 vl_api_set_arp_neighbor_limit_t *mp;
9914 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9916 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9918 else if (unformat (i, "ipv6"))
9922 clib_warning ("parse error '%U'", format_unformat_error, i);
9929 errmsg ("missing limit value");
9933 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9935 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9936 mp->is_ipv6 = is_ipv6;
9944 api_l2_patch_add_del (vat_main_t * vam)
9946 unformat_input_t *i = vam->input;
9947 vl_api_l2_patch_add_del_t *mp;
9949 u8 rx_sw_if_index_set = 0;
9951 u8 tx_sw_if_index_set = 0;
9955 /* Parse args required to build the message */
9956 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9958 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9959 rx_sw_if_index_set = 1;
9960 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9961 tx_sw_if_index_set = 1;
9962 else if (unformat (i, "rx"))
9964 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9966 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9968 rx_sw_if_index_set = 1;
9973 else if (unformat (i, "tx"))
9975 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9977 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9979 tx_sw_if_index_set = 1;
9984 else if (unformat (i, "del"))
9990 if (rx_sw_if_index_set == 0)
9992 errmsg ("missing rx interface name or rx_sw_if_index");
9996 if (tx_sw_if_index_set == 0)
9998 errmsg ("missing tx interface name or tx_sw_if_index");
10002 M (L2_PATCH_ADD_DEL, mp);
10004 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10005 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10006 mp->is_add = is_add;
10014 u8 localsid_addr[16];
10023 api_sr_localsid_add_del (vat_main_t * vam)
10025 unformat_input_t *i = vam->input;
10026 vl_api_sr_localsid_add_del_t *mp;
10029 ip6_address_t localsid;
10033 u32 fib_table = ~(u32) 0;
10034 ip6_address_t next_hop;
10036 bool nexthop_set = 0;
10040 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10042 if (unformat (i, "del"))
10044 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10045 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
10047 else if (unformat (i, "behavior %u", &behavior));
10048 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10049 else if (unformat (i, "fib-table %u", &fib_table));
10050 else if (unformat (i, "end.psp %u", &behavior));
10055 M (SR_LOCALSID_ADD_DEL, mp);
10057 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
10059 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
10060 mp->behavior = behavior;
10061 mp->sw_if_index = ntohl (sw_if_index);
10062 mp->fib_table = ntohl (fib_table);
10063 mp->end_psp = end_psp;
10064 mp->is_del = is_del;
10072 api_ioam_enable (vat_main_t * vam)
10074 unformat_input_t *input = vam->input;
10075 vl_api_ioam_enable_t *mp;
10077 int has_trace_option = 0;
10078 int has_pot_option = 0;
10079 int has_seqno_option = 0;
10080 int has_analyse_option = 0;
10083 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10085 if (unformat (input, "trace"))
10086 has_trace_option = 1;
10087 else if (unformat (input, "pot"))
10088 has_pot_option = 1;
10089 else if (unformat (input, "seqno"))
10090 has_seqno_option = 1;
10091 else if (unformat (input, "analyse"))
10092 has_analyse_option = 1;
10096 M (IOAM_ENABLE, mp);
10097 mp->id = htons (id);
10098 mp->seqno = has_seqno_option;
10099 mp->analyse = has_analyse_option;
10100 mp->pot_enable = has_pot_option;
10101 mp->trace_enable = has_trace_option;
10110 api_ioam_disable (vat_main_t * vam)
10112 vl_api_ioam_disable_t *mp;
10115 M (IOAM_DISABLE, mp);
10121 #define foreach_tcp_proto_field \
10125 #define foreach_udp_proto_field \
10129 #define foreach_ip4_proto_field \
10141 u16 src_port, dst_port;
10144 #if VPP_API_TEST_BUILTIN == 0
10146 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10148 u8 **maskp = va_arg (*args, u8 **);
10150 u8 found_something = 0;
10153 #define _(a) u8 a=0;
10154 foreach_tcp_proto_field;
10157 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10160 #define _(a) else if (unformat (input, #a)) a=1;
10161 foreach_tcp_proto_field
10167 #define _(a) found_something += a;
10168 foreach_tcp_proto_field;
10171 if (found_something == 0)
10174 vec_validate (mask, sizeof (*tcp) - 1);
10176 tcp = (tcp_header_t *) mask;
10178 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
10179 foreach_tcp_proto_field;
10187 unformat_udp_mask (unformat_input_t * input, va_list * args)
10189 u8 **maskp = va_arg (*args, u8 **);
10191 u8 found_something = 0;
10194 #define _(a) u8 a=0;
10195 foreach_udp_proto_field;
10198 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10201 #define _(a) else if (unformat (input, #a)) a=1;
10202 foreach_udp_proto_field
10208 #define _(a) found_something += a;
10209 foreach_udp_proto_field;
10212 if (found_something == 0)
10215 vec_validate (mask, sizeof (*udp) - 1);
10217 udp = (udp_header_t *) mask;
10219 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
10220 foreach_udp_proto_field;
10228 unformat_l4_mask (unformat_input_t * input, va_list * args)
10230 u8 **maskp = va_arg (*args, u8 **);
10231 u16 src_port = 0, dst_port = 0;
10232 tcpudp_header_t *tcpudp;
10234 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10236 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10238 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10240 else if (unformat (input, "src_port"))
10242 else if (unformat (input, "dst_port"))
10248 if (!src_port && !dst_port)
10252 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10254 tcpudp = (tcpudp_header_t *) mask;
10255 tcpudp->src_port = src_port;
10256 tcpudp->dst_port = dst_port;
10264 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10266 u8 **maskp = va_arg (*args, u8 **);
10268 u8 found_something = 0;
10271 #define _(a) u8 a=0;
10272 foreach_ip4_proto_field;
10278 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10280 if (unformat (input, "version"))
10282 else if (unformat (input, "hdr_length"))
10284 else if (unformat (input, "src"))
10286 else if (unformat (input, "dst"))
10288 else if (unformat (input, "proto"))
10291 #define _(a) else if (unformat (input, #a)) a=1;
10292 foreach_ip4_proto_field
10298 #define _(a) found_something += a;
10299 foreach_ip4_proto_field;
10302 if (found_something == 0)
10305 vec_validate (mask, sizeof (*ip) - 1);
10307 ip = (ip4_header_t *) mask;
10309 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10310 foreach_ip4_proto_field;
10313 ip->ip_version_and_header_length = 0;
10316 ip->ip_version_and_header_length |= 0xF0;
10319 ip->ip_version_and_header_length |= 0x0F;
10325 #define foreach_ip6_proto_field \
10328 _(payload_length) \
10333 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10335 u8 **maskp = va_arg (*args, u8 **);
10337 u8 found_something = 0;
10339 u32 ip_version_traffic_class_and_flow_label;
10341 #define _(a) u8 a=0;
10342 foreach_ip6_proto_field;
10345 u8 traffic_class = 0;
10348 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10350 if (unformat (input, "version"))
10352 else if (unformat (input, "traffic-class"))
10354 else if (unformat (input, "flow-label"))
10356 else if (unformat (input, "src"))
10358 else if (unformat (input, "dst"))
10360 else if (unformat (input, "proto"))
10363 #define _(a) else if (unformat (input, #a)) a=1;
10364 foreach_ip6_proto_field
10370 #define _(a) found_something += a;
10371 foreach_ip6_proto_field;
10374 if (found_something == 0)
10377 vec_validate (mask, sizeof (*ip) - 1);
10379 ip = (ip6_header_t *) mask;
10381 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10382 foreach_ip6_proto_field;
10385 ip_version_traffic_class_and_flow_label = 0;
10388 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10391 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10394 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10396 ip->ip_version_traffic_class_and_flow_label =
10397 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10404 unformat_l3_mask (unformat_input_t * input, va_list * args)
10406 u8 **maskp = va_arg (*args, u8 **);
10408 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10410 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10412 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10421 unformat_l2_mask (unformat_input_t * input, va_list * args)
10423 u8 **maskp = va_arg (*args, u8 **);
10430 u8 ignore_tag1 = 0;
10431 u8 ignore_tag2 = 0;
10438 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10440 if (unformat (input, "src"))
10442 else if (unformat (input, "dst"))
10444 else if (unformat (input, "proto"))
10446 else if (unformat (input, "tag1"))
10448 else if (unformat (input, "tag2"))
10450 else if (unformat (input, "ignore-tag1"))
10452 else if (unformat (input, "ignore-tag2"))
10454 else if (unformat (input, "cos1"))
10456 else if (unformat (input, "cos2"))
10458 else if (unformat (input, "dot1q"))
10460 else if (unformat (input, "dot1ad"))
10465 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10466 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10469 if (tag1 || ignore_tag1 || cos1 || dot1q)
10471 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10474 vec_validate (mask, len - 1);
10477 memset (mask, 0xff, 6);
10480 memset (mask + 6, 0xff, 6);
10482 if (tag2 || dot1ad)
10484 /* inner vlan tag */
10493 mask[21] = mask[20] = 0xff;
10514 mask[16] = mask[17] = 0xff;
10524 mask[12] = mask[13] = 0xff;
10531 unformat_classify_mask (unformat_input_t * input, va_list * args)
10533 u8 **maskp = va_arg (*args, u8 **);
10534 u32 *skipp = va_arg (*args, u32 *);
10535 u32 *matchp = va_arg (*args, u32 *);
10543 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10545 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10547 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10549 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10551 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10565 if (mask || l2 || l3 || l4)
10567 if (l2 || l3 || l4)
10569 /* "With a free Ethernet header in every package" */
10571 vec_validate (l2, 13);
10575 vec_append (mask, l3);
10580 vec_append (mask, l4);
10585 /* Scan forward looking for the first significant mask octet */
10586 for (i = 0; i < vec_len (mask); i++)
10590 /* compute (skip, match) params */
10591 *skipp = i / sizeof (u32x4);
10592 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10594 /* Pad mask to an even multiple of the vector size */
10595 while (vec_len (mask) % sizeof (u32x4))
10596 vec_add1 (mask, 0);
10598 match = vec_len (mask) / sizeof (u32x4);
10600 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10602 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10603 if (*tmp || *(tmp + 1))
10608 clib_warning ("BUG: match 0");
10610 _vec_len (mask) = match * sizeof (u32x4);
10620 #endif /* VPP_API_TEST_BUILTIN */
10622 #define foreach_l2_next \
10624 _(ethernet, ETHERNET_INPUT) \
10625 _(ip4, IP4_INPUT) \
10629 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10631 u32 *miss_next_indexp = va_arg (*args, u32 *);
10632 u32 next_index = 0;
10636 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10640 if (unformat (input, "%d", &tmp))
10649 *miss_next_indexp = next_index;
10653 #define foreach_ip_next \
10656 _(rewrite, REWRITE)
10659 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10661 u32 *miss_next_indexp = va_arg (*args, u32 *);
10662 u32 next_index = 0;
10666 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10670 if (unformat (input, "%d", &tmp))
10679 *miss_next_indexp = next_index;
10683 #define foreach_acl_next \
10687 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10689 u32 *miss_next_indexp = va_arg (*args, u32 *);
10690 u32 next_index = 0;
10694 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10698 if (unformat (input, "permit"))
10703 else if (unformat (input, "%d", &tmp))
10712 *miss_next_indexp = next_index;
10717 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10719 u32 *r = va_arg (*args, u32 *);
10721 if (unformat (input, "conform-color"))
10722 *r = POLICE_CONFORM;
10723 else if (unformat (input, "exceed-color"))
10724 *r = POLICE_EXCEED;
10732 api_classify_add_del_table (vat_main_t * vam)
10734 unformat_input_t *i = vam->input;
10735 vl_api_classify_add_del_table_t *mp;
10742 u32 table_index = ~0;
10743 u32 next_table_index = ~0;
10744 u32 miss_next_index = ~0;
10745 u32 memory_size = 32 << 20;
10747 u32 current_data_flag = 0;
10748 int current_data_offset = 0;
10751 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10753 if (unformat (i, "del"))
10755 else if (unformat (i, "del-chain"))
10760 else if (unformat (i, "buckets %d", &nbuckets))
10762 else if (unformat (i, "memory_size %d", &memory_size))
10764 else if (unformat (i, "skip %d", &skip))
10766 else if (unformat (i, "match %d", &match))
10768 else if (unformat (i, "table %d", &table_index))
10770 else if (unformat (i, "mask %U", unformat_classify_mask,
10771 &mask, &skip, &match))
10773 else if (unformat (i, "next-table %d", &next_table_index))
10775 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10778 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10781 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10784 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10786 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10792 if (is_add && mask == 0)
10794 errmsg ("Mask required");
10798 if (is_add && skip == ~0)
10800 errmsg ("skip count required");
10804 if (is_add && match == ~0)
10806 errmsg ("match count required");
10810 if (!is_add && table_index == ~0)
10812 errmsg ("table index required for delete");
10816 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10818 mp->is_add = is_add;
10819 mp->del_chain = del_chain;
10820 mp->table_index = ntohl (table_index);
10821 mp->nbuckets = ntohl (nbuckets);
10822 mp->memory_size = ntohl (memory_size);
10823 mp->skip_n_vectors = ntohl (skip);
10824 mp->match_n_vectors = ntohl (match);
10825 mp->next_table_index = ntohl (next_table_index);
10826 mp->miss_next_index = ntohl (miss_next_index);
10827 mp->current_data_flag = ntohl (current_data_flag);
10828 mp->current_data_offset = ntohl (current_data_offset);
10829 clib_memcpy (mp->mask, mask, vec_len (mask));
10838 #if VPP_API_TEST_BUILTIN == 0
10840 unformat_l4_match (unformat_input_t * input, va_list * args)
10842 u8 **matchp = va_arg (*args, u8 **);
10844 u8 *proto_header = 0;
10850 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10852 if (unformat (input, "src_port %d", &src_port))
10854 else if (unformat (input, "dst_port %d", &dst_port))
10860 h.src_port = clib_host_to_net_u16 (src_port);
10861 h.dst_port = clib_host_to_net_u16 (dst_port);
10862 vec_validate (proto_header, sizeof (h) - 1);
10863 memcpy (proto_header, &h, sizeof (h));
10865 *matchp = proto_header;
10871 unformat_ip4_match (unformat_input_t * input, va_list * args)
10873 u8 **matchp = va_arg (*args, u8 **);
10878 int hdr_length = 0;
10879 u32 hdr_length_val;
10880 int src = 0, dst = 0;
10881 ip4_address_t src_val, dst_val;
10888 int fragment_id = 0;
10889 u32 fragment_id_val;
10895 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10897 if (unformat (input, "version %d", &version_val))
10899 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10901 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10903 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10905 else if (unformat (input, "proto %d", &proto_val))
10907 else if (unformat (input, "tos %d", &tos_val))
10909 else if (unformat (input, "length %d", &length_val))
10911 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10913 else if (unformat (input, "ttl %d", &ttl_val))
10915 else if (unformat (input, "checksum %d", &checksum_val))
10921 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10922 + ttl + checksum == 0)
10926 * Aligned because we use the real comparison functions
10928 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10930 ip = (ip4_header_t *) match;
10932 /* These are realistically matched in practice */
10934 ip->src_address.as_u32 = src_val.as_u32;
10937 ip->dst_address.as_u32 = dst_val.as_u32;
10940 ip->protocol = proto_val;
10943 /* These are not, but they're included for completeness */
10945 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10948 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10954 ip->length = clib_host_to_net_u16 (length_val);
10960 ip->checksum = clib_host_to_net_u16 (checksum_val);
10967 unformat_ip6_match (unformat_input_t * input, va_list * args)
10969 u8 **matchp = va_arg (*args, u8 **);
10974 u8 traffic_class = 0;
10975 u32 traffic_class_val = 0;
10978 int src = 0, dst = 0;
10979 ip6_address_t src_val, dst_val;
10982 int payload_length = 0;
10983 u32 payload_length_val;
10986 u32 ip_version_traffic_class_and_flow_label;
10988 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10990 if (unformat (input, "version %d", &version_val))
10992 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10994 else if (unformat (input, "flow_label %d", &flow_label_val))
10996 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10998 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11000 else if (unformat (input, "proto %d", &proto_val))
11002 else if (unformat (input, "payload_length %d", &payload_length_val))
11003 payload_length = 1;
11004 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11010 if (version + traffic_class + flow_label + src + dst + proto +
11011 payload_length + hop_limit == 0)
11015 * Aligned because we use the real comparison functions
11017 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11019 ip = (ip6_header_t *) match;
11022 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11025 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11028 ip->protocol = proto_val;
11030 ip_version_traffic_class_and_flow_label = 0;
11033 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11036 ip_version_traffic_class_and_flow_label |=
11037 (traffic_class_val & 0xFF) << 20;
11040 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11042 ip->ip_version_traffic_class_and_flow_label =
11043 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11045 if (payload_length)
11046 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11049 ip->hop_limit = hop_limit_val;
11056 unformat_l3_match (unformat_input_t * input, va_list * args)
11058 u8 **matchp = va_arg (*args, u8 **);
11060 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11062 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11064 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11073 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11075 u8 *tagp = va_arg (*args, u8 *);
11078 if (unformat (input, "%d", &tag))
11080 tagp[0] = (tag >> 8) & 0x0F;
11081 tagp[1] = tag & 0xFF;
11089 unformat_l2_match (unformat_input_t * input, va_list * args)
11091 u8 **matchp = va_arg (*args, u8 **);
11104 u8 ignore_tag1 = 0;
11105 u8 ignore_tag2 = 0;
11111 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11113 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11116 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11118 else if (unformat (input, "proto %U",
11119 unformat_ethernet_type_host_byte_order, &proto_val))
11121 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11123 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11125 else if (unformat (input, "ignore-tag1"))
11127 else if (unformat (input, "ignore-tag2"))
11129 else if (unformat (input, "cos1 %d", &cos1_val))
11131 else if (unformat (input, "cos2 %d", &cos2_val))
11136 if ((src + dst + proto + tag1 + tag2 +
11137 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11140 if (tag1 || ignore_tag1 || cos1)
11142 if (tag2 || ignore_tag2 || cos2)
11145 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11148 clib_memcpy (match, dst_val, 6);
11151 clib_memcpy (match + 6, src_val, 6);
11155 /* inner vlan tag */
11156 match[19] = tag2_val[1];
11157 match[18] = tag2_val[0];
11159 match[18] |= (cos2_val & 0x7) << 5;
11162 match[21] = proto_val & 0xff;
11163 match[20] = proto_val >> 8;
11167 match[15] = tag1_val[1];
11168 match[14] = tag1_val[0];
11171 match[14] |= (cos1_val & 0x7) << 5;
11177 match[15] = tag1_val[1];
11178 match[14] = tag1_val[0];
11181 match[17] = proto_val & 0xff;
11182 match[16] = proto_val >> 8;
11185 match[14] |= (cos1_val & 0x7) << 5;
11191 match[18] |= (cos2_val & 0x7) << 5;
11193 match[14] |= (cos1_val & 0x7) << 5;
11196 match[13] = proto_val & 0xff;
11197 match[12] = proto_val >> 8;
11206 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11208 u8 **matchp = va_arg (*args, u8 **);
11209 u32 skip_n_vectors = va_arg (*args, u32);
11210 u32 match_n_vectors = va_arg (*args, u32);
11217 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11219 if (unformat (input, "hex %U", unformat_hex_string, &match))
11221 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11223 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11225 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11239 if (match || l2 || l3 || l4)
11241 if (l2 || l3 || l4)
11243 /* "Win a free Ethernet header in every packet" */
11245 vec_validate_aligned (l2, 13, sizeof (u32x4));
11249 vec_append_aligned (match, l3, sizeof (u32x4));
11254 vec_append_aligned (match, l4, sizeof (u32x4));
11259 /* Make sure the vector is big enough even if key is all 0's */
11260 vec_validate_aligned
11261 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11264 /* Set size, include skipped vectors */
11265 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11276 api_classify_add_del_session (vat_main_t * vam)
11278 unformat_input_t *i = vam->input;
11279 vl_api_classify_add_del_session_t *mp;
11281 u32 table_index = ~0;
11282 u32 hit_next_index = ~0;
11283 u32 opaque_index = ~0;
11286 u32 skip_n_vectors = 0;
11287 u32 match_n_vectors = 0;
11293 * Warning: you have to supply skip_n and match_n
11294 * because the API client cant simply look at the classify
11298 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11300 if (unformat (i, "del"))
11302 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11305 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11308 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11311 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11313 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11315 else if (unformat (i, "opaque-index %d", &opaque_index))
11317 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11319 else if (unformat (i, "match_n %d", &match_n_vectors))
11321 else if (unformat (i, "match %U", api_unformat_classify_match,
11322 &match, skip_n_vectors, match_n_vectors))
11324 else if (unformat (i, "advance %d", &advance))
11326 else if (unformat (i, "table-index %d", &table_index))
11328 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11330 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11332 else if (unformat (i, "action %d", &action))
11334 else if (unformat (i, "metadata %d", &metadata))
11340 if (table_index == ~0)
11342 errmsg ("Table index required");
11346 if (is_add && match == 0)
11348 errmsg ("Match value required");
11352 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11354 mp->is_add = is_add;
11355 mp->table_index = ntohl (table_index);
11356 mp->hit_next_index = ntohl (hit_next_index);
11357 mp->opaque_index = ntohl (opaque_index);
11358 mp->advance = ntohl (advance);
11359 mp->action = action;
11360 mp->metadata = ntohl (metadata);
11361 clib_memcpy (mp->match, match, vec_len (match));
11370 api_classify_set_interface_ip_table (vat_main_t * vam)
11372 unformat_input_t *i = vam->input;
11373 vl_api_classify_set_interface_ip_table_t *mp;
11375 int sw_if_index_set;
11376 u32 table_index = ~0;
11380 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11382 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11383 sw_if_index_set = 1;
11384 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11385 sw_if_index_set = 1;
11386 else if (unformat (i, "table %d", &table_index))
11390 clib_warning ("parse error '%U'", format_unformat_error, i);
11395 if (sw_if_index_set == 0)
11397 errmsg ("missing interface name or sw_if_index");
11402 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11404 mp->sw_if_index = ntohl (sw_if_index);
11405 mp->table_index = ntohl (table_index);
11406 mp->is_ipv6 = is_ipv6;
11414 api_classify_set_interface_l2_tables (vat_main_t * vam)
11416 unformat_input_t *i = vam->input;
11417 vl_api_classify_set_interface_l2_tables_t *mp;
11419 int sw_if_index_set;
11420 u32 ip4_table_index = ~0;
11421 u32 ip6_table_index = ~0;
11422 u32 other_table_index = ~0;
11426 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11428 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11429 sw_if_index_set = 1;
11430 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11431 sw_if_index_set = 1;
11432 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11434 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11436 else if (unformat (i, "other-table %d", &other_table_index))
11438 else if (unformat (i, "is-input %d", &is_input))
11442 clib_warning ("parse error '%U'", format_unformat_error, i);
11447 if (sw_if_index_set == 0)
11449 errmsg ("missing interface name or sw_if_index");
11454 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11456 mp->sw_if_index = ntohl (sw_if_index);
11457 mp->ip4_table_index = ntohl (ip4_table_index);
11458 mp->ip6_table_index = ntohl (ip6_table_index);
11459 mp->other_table_index = ntohl (other_table_index);
11460 mp->is_input = (u8) is_input;
11468 api_set_ipfix_exporter (vat_main_t * vam)
11470 unformat_input_t *i = vam->input;
11471 vl_api_set_ipfix_exporter_t *mp;
11472 ip4_address_t collector_address;
11473 u8 collector_address_set = 0;
11474 u32 collector_port = ~0;
11475 ip4_address_t src_address;
11476 u8 src_address_set = 0;
11479 u32 template_interval = ~0;
11480 u8 udp_checksum = 0;
11483 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11485 if (unformat (i, "collector_address %U", unformat_ip4_address,
11486 &collector_address))
11487 collector_address_set = 1;
11488 else if (unformat (i, "collector_port %d", &collector_port))
11490 else if (unformat (i, "src_address %U", unformat_ip4_address,
11492 src_address_set = 1;
11493 else if (unformat (i, "vrf_id %d", &vrf_id))
11495 else if (unformat (i, "path_mtu %d", &path_mtu))
11497 else if (unformat (i, "template_interval %d", &template_interval))
11499 else if (unformat (i, "udp_checksum"))
11505 if (collector_address_set == 0)
11507 errmsg ("collector_address required");
11511 if (src_address_set == 0)
11513 errmsg ("src_address required");
11517 M (SET_IPFIX_EXPORTER, mp);
11519 memcpy (mp->collector_address, collector_address.data,
11520 sizeof (collector_address.data));
11521 mp->collector_port = htons ((u16) collector_port);
11522 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11523 mp->vrf_id = htonl (vrf_id);
11524 mp->path_mtu = htonl (path_mtu);
11525 mp->template_interval = htonl (template_interval);
11526 mp->udp_checksum = udp_checksum;
11534 api_set_ipfix_classify_stream (vat_main_t * vam)
11536 unformat_input_t *i = vam->input;
11537 vl_api_set_ipfix_classify_stream_t *mp;
11539 u32 src_port = UDP_DST_PORT_ipfix;
11542 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11544 if (unformat (i, "domain %d", &domain_id))
11546 else if (unformat (i, "src_port %d", &src_port))
11550 errmsg ("unknown input `%U'", format_unformat_error, i);
11555 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11557 mp->domain_id = htonl (domain_id);
11558 mp->src_port = htons ((u16) src_port);
11566 api_ipfix_classify_table_add_del (vat_main_t * vam)
11568 unformat_input_t *i = vam->input;
11569 vl_api_ipfix_classify_table_add_del_t *mp;
11571 u32 classify_table_index = ~0;
11573 u8 transport_protocol = 255;
11576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11578 if (unformat (i, "add"))
11580 else if (unformat (i, "del"))
11582 else if (unformat (i, "table %d", &classify_table_index))
11584 else if (unformat (i, "ip4"))
11586 else if (unformat (i, "ip6"))
11588 else if (unformat (i, "tcp"))
11589 transport_protocol = 6;
11590 else if (unformat (i, "udp"))
11591 transport_protocol = 17;
11594 errmsg ("unknown input `%U'", format_unformat_error, i);
11601 errmsg ("expecting: add|del");
11604 if (classify_table_index == ~0)
11606 errmsg ("classifier table not specified");
11609 if (ip_version == 0)
11611 errmsg ("IP version not specified");
11615 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11617 mp->is_add = is_add;
11618 mp->table_id = htonl (classify_table_index);
11619 mp->ip_version = ip_version;
11620 mp->transport_protocol = transport_protocol;
11628 api_get_node_index (vat_main_t * vam)
11630 unformat_input_t *i = vam->input;
11631 vl_api_get_node_index_t *mp;
11635 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11637 if (unformat (i, "node %s", &name))
11644 errmsg ("node name required");
11647 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11649 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11653 M (GET_NODE_INDEX, mp);
11654 clib_memcpy (mp->node_name, name, vec_len (name));
11663 api_get_next_index (vat_main_t * vam)
11665 unformat_input_t *i = vam->input;
11666 vl_api_get_next_index_t *mp;
11667 u8 *node_name = 0, *next_node_name = 0;
11670 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11672 if (unformat (i, "node-name %s", &node_name))
11674 else if (unformat (i, "next-node-name %s", &next_node_name))
11678 if (node_name == 0)
11680 errmsg ("node name required");
11683 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11685 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11689 if (next_node_name == 0)
11691 errmsg ("next node name required");
11694 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11696 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11700 M (GET_NEXT_INDEX, mp);
11701 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11702 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11703 vec_free (node_name);
11704 vec_free (next_node_name);
11712 api_add_node_next (vat_main_t * vam)
11714 unformat_input_t *i = vam->input;
11715 vl_api_add_node_next_t *mp;
11720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11722 if (unformat (i, "node %s", &name))
11724 else if (unformat (i, "next %s", &next))
11731 errmsg ("node name required");
11734 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11736 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11741 errmsg ("next node required");
11744 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11746 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11750 M (ADD_NODE_NEXT, mp);
11751 clib_memcpy (mp->node_name, name, vec_len (name));
11752 clib_memcpy (mp->next_name, next, vec_len (next));
11762 api_l2tpv3_create_tunnel (vat_main_t * vam)
11764 unformat_input_t *i = vam->input;
11765 ip6_address_t client_address, our_address;
11766 int client_address_set = 0;
11767 int our_address_set = 0;
11768 u32 local_session_id = 0;
11769 u32 remote_session_id = 0;
11770 u64 local_cookie = 0;
11771 u64 remote_cookie = 0;
11772 u8 l2_sublayer_present = 0;
11773 vl_api_l2tpv3_create_tunnel_t *mp;
11776 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11778 if (unformat (i, "client_address %U", unformat_ip6_address,
11780 client_address_set = 1;
11781 else if (unformat (i, "our_address %U", unformat_ip6_address,
11783 our_address_set = 1;
11784 else if (unformat (i, "local_session_id %d", &local_session_id))
11786 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11788 else if (unformat (i, "local_cookie %lld", &local_cookie))
11790 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11792 else if (unformat (i, "l2-sublayer-present"))
11793 l2_sublayer_present = 1;
11798 if (client_address_set == 0)
11800 errmsg ("client_address required");
11804 if (our_address_set == 0)
11806 errmsg ("our_address required");
11810 M (L2TPV3_CREATE_TUNNEL, mp);
11812 clib_memcpy (mp->client_address, client_address.as_u8,
11813 sizeof (mp->client_address));
11815 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11817 mp->local_session_id = ntohl (local_session_id);
11818 mp->remote_session_id = ntohl (remote_session_id);
11819 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11820 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11821 mp->l2_sublayer_present = l2_sublayer_present;
11830 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11832 unformat_input_t *i = vam->input;
11834 u8 sw_if_index_set = 0;
11835 u64 new_local_cookie = 0;
11836 u64 new_remote_cookie = 0;
11837 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11840 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11842 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11843 sw_if_index_set = 1;
11844 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11845 sw_if_index_set = 1;
11846 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11848 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11854 if (sw_if_index_set == 0)
11856 errmsg ("missing interface name or sw_if_index");
11860 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11862 mp->sw_if_index = ntohl (sw_if_index);
11863 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11864 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11872 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11874 unformat_input_t *i = vam->input;
11875 vl_api_l2tpv3_interface_enable_disable_t *mp;
11877 u8 sw_if_index_set = 0;
11878 u8 enable_disable = 1;
11881 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11883 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11884 sw_if_index_set = 1;
11885 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11886 sw_if_index_set = 1;
11887 else if (unformat (i, "enable"))
11888 enable_disable = 1;
11889 else if (unformat (i, "disable"))
11890 enable_disable = 0;
11895 if (sw_if_index_set == 0)
11897 errmsg ("missing interface name or sw_if_index");
11901 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11903 mp->sw_if_index = ntohl (sw_if_index);
11904 mp->enable_disable = enable_disable;
11912 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11914 unformat_input_t *i = vam->input;
11915 vl_api_l2tpv3_set_lookup_key_t *mp;
11919 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11921 if (unformat (i, "lookup_v6_src"))
11922 key = L2T_LOOKUP_SRC_ADDRESS;
11923 else if (unformat (i, "lookup_v6_dst"))
11924 key = L2T_LOOKUP_DST_ADDRESS;
11925 else if (unformat (i, "lookup_session_id"))
11926 key = L2T_LOOKUP_SESSION_ID;
11931 if (key == (u8) ~ 0)
11933 errmsg ("l2tp session lookup key unset");
11937 M (L2TPV3_SET_LOOKUP_KEY, mp);
11946 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11947 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11949 vat_main_t *vam = &vat_main;
11951 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11952 format_ip6_address, mp->our_address,
11953 format_ip6_address, mp->client_address,
11954 clib_net_to_host_u32 (mp->sw_if_index));
11957 " local cookies %016llx %016llx remote cookie %016llx",
11958 clib_net_to_host_u64 (mp->local_cookie[0]),
11959 clib_net_to_host_u64 (mp->local_cookie[1]),
11960 clib_net_to_host_u64 (mp->remote_cookie));
11962 print (vam->ofp, " local session-id %d remote session-id %d",
11963 clib_net_to_host_u32 (mp->local_session_id),
11964 clib_net_to_host_u32 (mp->remote_session_id));
11966 print (vam->ofp, " l2 specific sublayer %s\n",
11967 mp->l2_sublayer_present ? "preset" : "absent");
11971 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11972 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11974 vat_main_t *vam = &vat_main;
11975 vat_json_node_t *node = NULL;
11976 struct in6_addr addr;
11978 if (VAT_JSON_ARRAY != vam->json_tree.type)
11980 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11981 vat_json_init_array (&vam->json_tree);
11983 node = vat_json_array_add (&vam->json_tree);
11985 vat_json_init_object (node);
11987 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11988 vat_json_object_add_ip6 (node, "our_address", addr);
11989 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11990 vat_json_object_add_ip6 (node, "client_address", addr);
11992 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11993 vat_json_init_array (lc);
11994 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11995 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11996 vat_json_object_add_uint (node, "remote_cookie",
11997 clib_net_to_host_u64 (mp->remote_cookie));
11999 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12000 vat_json_object_add_uint (node, "local_session_id",
12001 clib_net_to_host_u32 (mp->local_session_id));
12002 vat_json_object_add_uint (node, "remote_session_id",
12003 clib_net_to_host_u32 (mp->remote_session_id));
12004 vat_json_object_add_string_copy (node, "l2_sublayer",
12005 mp->l2_sublayer_present ? (u8 *) "present"
12006 : (u8 *) "absent");
12010 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12012 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12013 vl_api_control_ping_t *mp_ping;
12016 /* Get list of l2tpv3-tunnel interfaces */
12017 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12020 /* Use a control ping for synchronization */
12021 MPING (CONTROL_PING, mp_ping);
12029 static void vl_api_sw_interface_tap_details_t_handler
12030 (vl_api_sw_interface_tap_details_t * mp)
12032 vat_main_t *vam = &vat_main;
12034 print (vam->ofp, "%-16s %d",
12035 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12038 static void vl_api_sw_interface_tap_details_t_handler_json
12039 (vl_api_sw_interface_tap_details_t * mp)
12041 vat_main_t *vam = &vat_main;
12042 vat_json_node_t *node = NULL;
12044 if (VAT_JSON_ARRAY != vam->json_tree.type)
12046 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12047 vat_json_init_array (&vam->json_tree);
12049 node = vat_json_array_add (&vam->json_tree);
12051 vat_json_init_object (node);
12052 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12053 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12057 api_sw_interface_tap_dump (vat_main_t * vam)
12059 vl_api_sw_interface_tap_dump_t *mp;
12060 vl_api_control_ping_t *mp_ping;
12063 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12064 /* Get list of tap interfaces */
12065 M (SW_INTERFACE_TAP_DUMP, mp);
12068 /* Use a control ping for synchronization */
12069 MPING (CONTROL_PING, mp_ping);
12076 static uword unformat_vxlan_decap_next
12077 (unformat_input_t * input, va_list * args)
12079 u32 *result = va_arg (*args, u32 *);
12082 if (unformat (input, "l2"))
12083 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12084 else if (unformat (input, "%d", &tmp))
12092 api_vxlan_add_del_tunnel (vat_main_t * vam)
12094 unformat_input_t *line_input = vam->input;
12095 vl_api_vxlan_add_del_tunnel_t *mp;
12096 ip46_address_t src, dst;
12098 u8 ipv4_set = 0, ipv6_set = 0;
12102 u32 mcast_sw_if_index = ~0;
12103 u32 encap_vrf_id = 0;
12104 u32 decap_next_index = ~0;
12108 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12109 memset (&src, 0, sizeof src);
12110 memset (&dst, 0, sizeof dst);
12112 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12114 if (unformat (line_input, "del"))
12117 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12123 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12129 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12135 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12140 else if (unformat (line_input, "group %U %U",
12141 unformat_ip4_address, &dst.ip4,
12142 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12144 grp_set = dst_set = 1;
12147 else if (unformat (line_input, "group %U",
12148 unformat_ip4_address, &dst.ip4))
12150 grp_set = dst_set = 1;
12153 else if (unformat (line_input, "group %U %U",
12154 unformat_ip6_address, &dst.ip6,
12155 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12157 grp_set = dst_set = 1;
12160 else if (unformat (line_input, "group %U",
12161 unformat_ip6_address, &dst.ip6))
12163 grp_set = dst_set = 1;
12167 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12169 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12171 else if (unformat (line_input, "decap-next %U",
12172 unformat_vxlan_decap_next, &decap_next_index))
12174 else if (unformat (line_input, "vni %d", &vni))
12178 errmsg ("parse error '%U'", format_unformat_error, line_input);
12185 errmsg ("tunnel src address not specified");
12190 errmsg ("tunnel dst address not specified");
12194 if (grp_set && !ip46_address_is_multicast (&dst))
12196 errmsg ("tunnel group address not multicast");
12199 if (grp_set && mcast_sw_if_index == ~0)
12201 errmsg ("tunnel nonexistent multicast device");
12204 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12206 errmsg ("tunnel dst address must be unicast");
12211 if (ipv4_set && ipv6_set)
12213 errmsg ("both IPv4 and IPv6 addresses specified");
12217 if ((vni == 0) || (vni >> 24))
12219 errmsg ("vni not specified or out of range");
12223 M (VXLAN_ADD_DEL_TUNNEL, mp);
12227 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12228 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12232 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12233 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12235 mp->encap_vrf_id = ntohl (encap_vrf_id);
12236 mp->decap_next_index = ntohl (decap_next_index);
12237 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12238 mp->vni = ntohl (vni);
12239 mp->is_add = is_add;
12240 mp->is_ipv6 = ipv6_set;
12247 static void vl_api_vxlan_tunnel_details_t_handler
12248 (vl_api_vxlan_tunnel_details_t * mp)
12250 vat_main_t *vam = &vat_main;
12251 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12252 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12254 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12255 ntohl (mp->sw_if_index),
12256 format_ip46_address, &src, IP46_TYPE_ANY,
12257 format_ip46_address, &dst, IP46_TYPE_ANY,
12258 ntohl (mp->encap_vrf_id),
12259 ntohl (mp->decap_next_index), ntohl (mp->vni),
12260 ntohl (mp->mcast_sw_if_index));
12263 static void vl_api_vxlan_tunnel_details_t_handler_json
12264 (vl_api_vxlan_tunnel_details_t * mp)
12266 vat_main_t *vam = &vat_main;
12267 vat_json_node_t *node = NULL;
12269 if (VAT_JSON_ARRAY != vam->json_tree.type)
12271 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12272 vat_json_init_array (&vam->json_tree);
12274 node = vat_json_array_add (&vam->json_tree);
12276 vat_json_init_object (node);
12277 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12280 struct in6_addr ip6;
12282 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12283 vat_json_object_add_ip6 (node, "src_address", ip6);
12284 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12285 vat_json_object_add_ip6 (node, "dst_address", ip6);
12289 struct in_addr ip4;
12291 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12292 vat_json_object_add_ip4 (node, "src_address", ip4);
12293 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12294 vat_json_object_add_ip4 (node, "dst_address", ip4);
12296 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12297 vat_json_object_add_uint (node, "decap_next_index",
12298 ntohl (mp->decap_next_index));
12299 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12300 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12301 vat_json_object_add_uint (node, "mcast_sw_if_index",
12302 ntohl (mp->mcast_sw_if_index));
12306 api_vxlan_tunnel_dump (vat_main_t * vam)
12308 unformat_input_t *i = vam->input;
12309 vl_api_vxlan_tunnel_dump_t *mp;
12310 vl_api_control_ping_t *mp_ping;
12312 u8 sw_if_index_set = 0;
12315 /* Parse args required to build the message */
12316 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12318 if (unformat (i, "sw_if_index %d", &sw_if_index))
12319 sw_if_index_set = 1;
12324 if (sw_if_index_set == 0)
12329 if (!vam->json_output)
12331 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12332 "sw_if_index", "src_address", "dst_address",
12333 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12336 /* Get list of vxlan-tunnel interfaces */
12337 M (VXLAN_TUNNEL_DUMP, mp);
12339 mp->sw_if_index = htonl (sw_if_index);
12343 /* Use a control ping for synchronization */
12344 MPING (CONTROL_PING, mp_ping);
12351 static uword unformat_geneve_decap_next
12352 (unformat_input_t * input, va_list * args)
12354 u32 *result = va_arg (*args, u32 *);
12357 if (unformat (input, "l2"))
12358 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12359 else if (unformat (input, "%d", &tmp))
12367 api_geneve_add_del_tunnel (vat_main_t * vam)
12369 unformat_input_t *line_input = vam->input;
12370 vl_api_geneve_add_del_tunnel_t *mp;
12371 ip46_address_t src, dst;
12373 u8 ipv4_set = 0, ipv6_set = 0;
12377 u32 mcast_sw_if_index = ~0;
12378 u32 encap_vrf_id = 0;
12379 u32 decap_next_index = ~0;
12383 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12384 memset (&src, 0, sizeof src);
12385 memset (&dst, 0, sizeof dst);
12387 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12389 if (unformat (line_input, "del"))
12392 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12398 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12404 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12410 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12415 else if (unformat (line_input, "group %U %U",
12416 unformat_ip4_address, &dst.ip4,
12417 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12419 grp_set = dst_set = 1;
12422 else if (unformat (line_input, "group %U",
12423 unformat_ip4_address, &dst.ip4))
12425 grp_set = dst_set = 1;
12428 else if (unformat (line_input, "group %U %U",
12429 unformat_ip6_address, &dst.ip6,
12430 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12432 grp_set = dst_set = 1;
12435 else if (unformat (line_input, "group %U",
12436 unformat_ip6_address, &dst.ip6))
12438 grp_set = dst_set = 1;
12442 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12444 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12446 else if (unformat (line_input, "decap-next %U",
12447 unformat_geneve_decap_next, &decap_next_index))
12449 else if (unformat (line_input, "vni %d", &vni))
12453 errmsg ("parse error '%U'", format_unformat_error, line_input);
12460 errmsg ("tunnel src address not specified");
12465 errmsg ("tunnel dst address not specified");
12469 if (grp_set && !ip46_address_is_multicast (&dst))
12471 errmsg ("tunnel group address not multicast");
12474 if (grp_set && mcast_sw_if_index == ~0)
12476 errmsg ("tunnel nonexistent multicast device");
12479 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12481 errmsg ("tunnel dst address must be unicast");
12486 if (ipv4_set && ipv6_set)
12488 errmsg ("both IPv4 and IPv6 addresses specified");
12492 if ((vni == 0) || (vni >> 24))
12494 errmsg ("vni not specified or out of range");
12498 M (GENEVE_ADD_DEL_TUNNEL, mp);
12502 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12503 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12507 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12508 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12510 mp->encap_vrf_id = ntohl (encap_vrf_id);
12511 mp->decap_next_index = ntohl (decap_next_index);
12512 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12513 mp->vni = ntohl (vni);
12514 mp->is_add = is_add;
12515 mp->is_ipv6 = ipv6_set;
12522 static void vl_api_geneve_tunnel_details_t_handler
12523 (vl_api_geneve_tunnel_details_t * mp)
12525 vat_main_t *vam = &vat_main;
12526 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12527 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12529 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12530 ntohl (mp->sw_if_index),
12531 format_ip46_address, &src, IP46_TYPE_ANY,
12532 format_ip46_address, &dst, IP46_TYPE_ANY,
12533 ntohl (mp->encap_vrf_id),
12534 ntohl (mp->decap_next_index), ntohl (mp->vni),
12535 ntohl (mp->mcast_sw_if_index));
12538 static void vl_api_geneve_tunnel_details_t_handler_json
12539 (vl_api_geneve_tunnel_details_t * mp)
12541 vat_main_t *vam = &vat_main;
12542 vat_json_node_t *node = NULL;
12544 if (VAT_JSON_ARRAY != vam->json_tree.type)
12546 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12547 vat_json_init_array (&vam->json_tree);
12549 node = vat_json_array_add (&vam->json_tree);
12551 vat_json_init_object (node);
12552 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12555 struct in6_addr ip6;
12557 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12558 vat_json_object_add_ip6 (node, "src_address", ip6);
12559 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12560 vat_json_object_add_ip6 (node, "dst_address", ip6);
12564 struct in_addr ip4;
12566 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12567 vat_json_object_add_ip4 (node, "src_address", ip4);
12568 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12569 vat_json_object_add_ip4 (node, "dst_address", ip4);
12571 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12572 vat_json_object_add_uint (node, "decap_next_index",
12573 ntohl (mp->decap_next_index));
12574 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12575 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12576 vat_json_object_add_uint (node, "mcast_sw_if_index",
12577 ntohl (mp->mcast_sw_if_index));
12581 api_geneve_tunnel_dump (vat_main_t * vam)
12583 unformat_input_t *i = vam->input;
12584 vl_api_geneve_tunnel_dump_t *mp;
12585 vl_api_control_ping_t *mp_ping;
12587 u8 sw_if_index_set = 0;
12590 /* Parse args required to build the message */
12591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12593 if (unformat (i, "sw_if_index %d", &sw_if_index))
12594 sw_if_index_set = 1;
12599 if (sw_if_index_set == 0)
12604 if (!vam->json_output)
12606 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12607 "sw_if_index", "local_address", "remote_address",
12608 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12611 /* Get list of geneve-tunnel interfaces */
12612 M (GENEVE_TUNNEL_DUMP, mp);
12614 mp->sw_if_index = htonl (sw_if_index);
12618 /* Use a control ping for synchronization */
12619 M (CONTROL_PING, mp_ping);
12627 api_gre_add_del_tunnel (vat_main_t * vam)
12629 unformat_input_t *line_input = vam->input;
12630 vl_api_gre_add_del_tunnel_t *mp;
12631 ip4_address_t src4, dst4;
12632 ip6_address_t src6, dst6;
12639 u32 outer_fib_id = 0;
12642 memset (&src4, 0, sizeof src4);
12643 memset (&dst4, 0, sizeof dst4);
12644 memset (&src6, 0, sizeof src6);
12645 memset (&dst6, 0, sizeof dst6);
12647 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12649 if (unformat (line_input, "del"))
12651 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
12656 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
12661 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
12666 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
12671 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12673 else if (unformat (line_input, "teb"))
12677 errmsg ("parse error '%U'", format_unformat_error, line_input);
12684 errmsg ("tunnel src address not specified");
12689 errmsg ("tunnel dst address not specified");
12692 if (ipv4_set && ipv6_set)
12694 errmsg ("both IPv4 and IPv6 addresses specified");
12699 M (GRE_ADD_DEL_TUNNEL, mp);
12703 clib_memcpy (&mp->src_address, &src4, 4);
12704 clib_memcpy (&mp->dst_address, &dst4, 4);
12708 clib_memcpy (&mp->src_address, &src6, 16);
12709 clib_memcpy (&mp->dst_address, &dst6, 16);
12711 mp->outer_fib_id = ntohl (outer_fib_id);
12712 mp->is_add = is_add;
12714 mp->is_ipv6 = ipv6_set;
12721 static void vl_api_gre_tunnel_details_t_handler
12722 (vl_api_gre_tunnel_details_t * mp)
12724 vat_main_t *vam = &vat_main;
12725 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
12726 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
12728 print (vam->ofp, "%11d%24U%24U%6d%14d",
12729 ntohl (mp->sw_if_index),
12730 format_ip46_address, &src, IP46_TYPE_ANY,
12731 format_ip46_address, &dst, IP46_TYPE_ANY,
12732 mp->teb, ntohl (mp->outer_fib_id));
12735 static void vl_api_gre_tunnel_details_t_handler_json
12736 (vl_api_gre_tunnel_details_t * mp)
12738 vat_main_t *vam = &vat_main;
12739 vat_json_node_t *node = NULL;
12740 struct in_addr ip4;
12741 struct in6_addr ip6;
12743 if (VAT_JSON_ARRAY != vam->json_tree.type)
12745 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12746 vat_json_init_array (&vam->json_tree);
12748 node = vat_json_array_add (&vam->json_tree);
12750 vat_json_init_object (node);
12751 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12754 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
12755 vat_json_object_add_ip4 (node, "src_address", ip4);
12756 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
12757 vat_json_object_add_ip4 (node, "dst_address", ip4);
12761 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
12762 vat_json_object_add_ip6 (node, "src_address", ip6);
12763 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
12764 vat_json_object_add_ip6 (node, "dst_address", ip6);
12766 vat_json_object_add_uint (node, "teb", mp->teb);
12767 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
12768 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
12772 api_gre_tunnel_dump (vat_main_t * vam)
12774 unformat_input_t *i = vam->input;
12775 vl_api_gre_tunnel_dump_t *mp;
12776 vl_api_control_ping_t *mp_ping;
12778 u8 sw_if_index_set = 0;
12781 /* Parse args required to build the message */
12782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12784 if (unformat (i, "sw_if_index %d", &sw_if_index))
12785 sw_if_index_set = 1;
12790 if (sw_if_index_set == 0)
12795 if (!vam->json_output)
12797 print (vam->ofp, "%11s%24s%24s%6s%14s",
12798 "sw_if_index", "src_address", "dst_address", "teb",
12802 /* Get list of gre-tunnel interfaces */
12803 M (GRE_TUNNEL_DUMP, mp);
12805 mp->sw_if_index = htonl (sw_if_index);
12809 /* Use a control ping for synchronization */
12810 MPING (CONTROL_PING, mp_ping);
12818 api_l2_fib_clear_table (vat_main_t * vam)
12820 // unformat_input_t * i = vam->input;
12821 vl_api_l2_fib_clear_table_t *mp;
12824 M (L2_FIB_CLEAR_TABLE, mp);
12832 api_l2_interface_efp_filter (vat_main_t * vam)
12834 unformat_input_t *i = vam->input;
12835 vl_api_l2_interface_efp_filter_t *mp;
12838 u8 sw_if_index_set = 0;
12841 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12843 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12844 sw_if_index_set = 1;
12845 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12846 sw_if_index_set = 1;
12847 else if (unformat (i, "enable"))
12849 else if (unformat (i, "disable"))
12853 clib_warning ("parse error '%U'", format_unformat_error, i);
12858 if (sw_if_index_set == 0)
12860 errmsg ("missing sw_if_index");
12864 M (L2_INTERFACE_EFP_FILTER, mp);
12866 mp->sw_if_index = ntohl (sw_if_index);
12867 mp->enable_disable = enable;
12874 #define foreach_vtr_op \
12875 _("disable", L2_VTR_DISABLED) \
12876 _("push-1", L2_VTR_PUSH_1) \
12877 _("push-2", L2_VTR_PUSH_2) \
12878 _("pop-1", L2_VTR_POP_1) \
12879 _("pop-2", L2_VTR_POP_2) \
12880 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12881 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12882 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12883 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12886 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12888 unformat_input_t *i = vam->input;
12889 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12891 u8 sw_if_index_set = 0;
12894 u32 push_dot1q = 1;
12899 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12901 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12902 sw_if_index_set = 1;
12903 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12904 sw_if_index_set = 1;
12905 else if (unformat (i, "vtr_op %d", &vtr_op))
12907 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12910 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12912 else if (unformat (i, "tag1 %d", &tag1))
12914 else if (unformat (i, "tag2 %d", &tag2))
12918 clib_warning ("parse error '%U'", format_unformat_error, i);
12923 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12925 errmsg ("missing vtr operation or sw_if_index");
12929 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12930 mp->sw_if_index = ntohl (sw_if_index);
12931 mp->vtr_op = ntohl (vtr_op);
12932 mp->push_dot1q = ntohl (push_dot1q);
12933 mp->tag1 = ntohl (tag1);
12934 mp->tag2 = ntohl (tag2);
12942 api_create_vhost_user_if (vat_main_t * vam)
12944 unformat_input_t *i = vam->input;
12945 vl_api_create_vhost_user_if_t *mp;
12948 u8 file_name_set = 0;
12949 u32 custom_dev_instance = ~0;
12951 u8 use_custom_mac = 0;
12955 /* Shut up coverity */
12956 memset (hwaddr, 0, sizeof (hwaddr));
12958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12960 if (unformat (i, "socket %s", &file_name))
12964 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12966 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12967 use_custom_mac = 1;
12968 else if (unformat (i, "server"))
12970 else if (unformat (i, "tag %s", &tag))
12976 if (file_name_set == 0)
12978 errmsg ("missing socket file name");
12982 if (vec_len (file_name) > 255)
12984 errmsg ("socket file name too long");
12987 vec_add1 (file_name, 0);
12989 M (CREATE_VHOST_USER_IF, mp);
12991 mp->is_server = is_server;
12992 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12993 vec_free (file_name);
12994 if (custom_dev_instance != ~0)
12997 mp->custom_dev_instance = ntohl (custom_dev_instance);
12999 mp->use_custom_mac = use_custom_mac;
13000 clib_memcpy (mp->mac_address, hwaddr, 6);
13002 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13011 api_modify_vhost_user_if (vat_main_t * vam)
13013 unformat_input_t *i = vam->input;
13014 vl_api_modify_vhost_user_if_t *mp;
13017 u8 file_name_set = 0;
13018 u32 custom_dev_instance = ~0;
13019 u8 sw_if_index_set = 0;
13020 u32 sw_if_index = (u32) ~ 0;
13023 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13025 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13026 sw_if_index_set = 1;
13027 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13028 sw_if_index_set = 1;
13029 else if (unformat (i, "socket %s", &file_name))
13033 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13035 else if (unformat (i, "server"))
13041 if (sw_if_index_set == 0)
13043 errmsg ("missing sw_if_index or interface name");
13047 if (file_name_set == 0)
13049 errmsg ("missing socket file name");
13053 if (vec_len (file_name) > 255)
13055 errmsg ("socket file name too long");
13058 vec_add1 (file_name, 0);
13060 M (MODIFY_VHOST_USER_IF, mp);
13062 mp->sw_if_index = ntohl (sw_if_index);
13063 mp->is_server = is_server;
13064 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13065 vec_free (file_name);
13066 if (custom_dev_instance != ~0)
13069 mp->custom_dev_instance = ntohl (custom_dev_instance);
13078 api_delete_vhost_user_if (vat_main_t * vam)
13080 unformat_input_t *i = vam->input;
13081 vl_api_delete_vhost_user_if_t *mp;
13082 u32 sw_if_index = ~0;
13083 u8 sw_if_index_set = 0;
13086 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13088 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13089 sw_if_index_set = 1;
13090 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13091 sw_if_index_set = 1;
13096 if (sw_if_index_set == 0)
13098 errmsg ("missing sw_if_index or interface name");
13103 M (DELETE_VHOST_USER_IF, mp);
13105 mp->sw_if_index = ntohl (sw_if_index);
13112 static void vl_api_sw_interface_vhost_user_details_t_handler
13113 (vl_api_sw_interface_vhost_user_details_t * mp)
13115 vat_main_t *vam = &vat_main;
13117 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13118 (char *) mp->interface_name,
13119 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13120 clib_net_to_host_u64 (mp->features), mp->is_server,
13121 ntohl (mp->num_regions), (char *) mp->sock_filename);
13122 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13125 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13126 (vl_api_sw_interface_vhost_user_details_t * mp)
13128 vat_main_t *vam = &vat_main;
13129 vat_json_node_t *node = NULL;
13131 if (VAT_JSON_ARRAY != vam->json_tree.type)
13133 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13134 vat_json_init_array (&vam->json_tree);
13136 node = vat_json_array_add (&vam->json_tree);
13138 vat_json_init_object (node);
13139 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13140 vat_json_object_add_string_copy (node, "interface_name",
13141 mp->interface_name);
13142 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13143 ntohl (mp->virtio_net_hdr_sz));
13144 vat_json_object_add_uint (node, "features",
13145 clib_net_to_host_u64 (mp->features));
13146 vat_json_object_add_uint (node, "is_server", mp->is_server);
13147 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13148 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13149 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13153 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13155 vl_api_sw_interface_vhost_user_dump_t *mp;
13156 vl_api_control_ping_t *mp_ping;
13159 "Interface name idx hdr_sz features server regions filename");
13161 /* Get list of vhost-user interfaces */
13162 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13165 /* Use a control ping for synchronization */
13166 MPING (CONTROL_PING, mp_ping);
13174 api_show_version (vat_main_t * vam)
13176 vl_api_show_version_t *mp;
13179 M (SHOW_VERSION, mp);
13188 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13190 unformat_input_t *line_input = vam->input;
13191 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13192 ip4_address_t local4, remote4;
13193 ip6_address_t local6, remote6;
13195 u8 ipv4_set = 0, ipv6_set = 0;
13199 u32 mcast_sw_if_index = ~0;
13200 u32 encap_vrf_id = 0;
13201 u32 decap_vrf_id = 0;
13207 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13208 memset (&local4, 0, sizeof local4);
13209 memset (&remote4, 0, sizeof remote4);
13210 memset (&local6, 0, sizeof local6);
13211 memset (&remote6, 0, sizeof remote6);
13213 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13215 if (unformat (line_input, "del"))
13217 else if (unformat (line_input, "local %U",
13218 unformat_ip4_address, &local4))
13223 else if (unformat (line_input, "remote %U",
13224 unformat_ip4_address, &remote4))
13229 else if (unformat (line_input, "local %U",
13230 unformat_ip6_address, &local6))
13235 else if (unformat (line_input, "remote %U",
13236 unformat_ip6_address, &remote6))
13241 else if (unformat (line_input, "group %U %U",
13242 unformat_ip4_address, &remote4,
13243 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13245 grp_set = remote_set = 1;
13248 else if (unformat (line_input, "group %U",
13249 unformat_ip4_address, &remote4))
13251 grp_set = remote_set = 1;
13254 else if (unformat (line_input, "group %U %U",
13255 unformat_ip6_address, &remote6,
13256 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13258 grp_set = remote_set = 1;
13261 else if (unformat (line_input, "group %U",
13262 unformat_ip6_address, &remote6))
13264 grp_set = remote_set = 1;
13268 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13270 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13272 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13274 else if (unformat (line_input, "vni %d", &vni))
13276 else if (unformat (line_input, "next-ip4"))
13278 else if (unformat (line_input, "next-ip6"))
13280 else if (unformat (line_input, "next-ethernet"))
13282 else if (unformat (line_input, "next-nsh"))
13286 errmsg ("parse error '%U'", format_unformat_error, line_input);
13291 if (local_set == 0)
13293 errmsg ("tunnel local address not specified");
13296 if (remote_set == 0)
13298 errmsg ("tunnel remote address not specified");
13301 if (grp_set && mcast_sw_if_index == ~0)
13303 errmsg ("tunnel nonexistent multicast device");
13306 if (ipv4_set && ipv6_set)
13308 errmsg ("both IPv4 and IPv6 addresses specified");
13314 errmsg ("vni not specified");
13318 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13323 clib_memcpy (&mp->local, &local6, sizeof (local6));
13324 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13328 clib_memcpy (&mp->local, &local4, sizeof (local4));
13329 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13332 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13333 mp->encap_vrf_id = ntohl (encap_vrf_id);
13334 mp->decap_vrf_id = ntohl (decap_vrf_id);
13335 mp->protocol = protocol;
13336 mp->vni = ntohl (vni);
13337 mp->is_add = is_add;
13338 mp->is_ipv6 = ipv6_set;
13345 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13346 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13348 vat_main_t *vam = &vat_main;
13349 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13350 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13352 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13353 ntohl (mp->sw_if_index),
13354 format_ip46_address, &local, IP46_TYPE_ANY,
13355 format_ip46_address, &remote, IP46_TYPE_ANY,
13356 ntohl (mp->vni), mp->protocol,
13357 ntohl (mp->mcast_sw_if_index),
13358 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13362 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13363 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13365 vat_main_t *vam = &vat_main;
13366 vat_json_node_t *node = NULL;
13367 struct in_addr ip4;
13368 struct in6_addr ip6;
13370 if (VAT_JSON_ARRAY != vam->json_tree.type)
13372 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13373 vat_json_init_array (&vam->json_tree);
13375 node = vat_json_array_add (&vam->json_tree);
13377 vat_json_init_object (node);
13378 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13381 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13382 vat_json_object_add_ip6 (node, "local", ip6);
13383 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13384 vat_json_object_add_ip6 (node, "remote", ip6);
13388 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13389 vat_json_object_add_ip4 (node, "local", ip4);
13390 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13391 vat_json_object_add_ip4 (node, "remote", ip4);
13393 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13394 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13395 vat_json_object_add_uint (node, "mcast_sw_if_index",
13396 ntohl (mp->mcast_sw_if_index));
13397 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13398 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13399 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13403 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13405 unformat_input_t *i = vam->input;
13406 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13407 vl_api_control_ping_t *mp_ping;
13409 u8 sw_if_index_set = 0;
13412 /* Parse args required to build the message */
13413 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13415 if (unformat (i, "sw_if_index %d", &sw_if_index))
13416 sw_if_index_set = 1;
13421 if (sw_if_index_set == 0)
13426 if (!vam->json_output)
13428 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13429 "sw_if_index", "local", "remote", "vni",
13430 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13433 /* Get list of vxlan-tunnel interfaces */
13434 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13436 mp->sw_if_index = htonl (sw_if_index);
13440 /* Use a control ping for synchronization */
13441 MPING (CONTROL_PING, mp_ping);
13448 static void vl_api_l2_fib_table_details_t_handler
13449 (vl_api_l2_fib_table_details_t * mp)
13451 vat_main_t *vam = &vat_main;
13453 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13455 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
13456 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13460 static void vl_api_l2_fib_table_details_t_handler_json
13461 (vl_api_l2_fib_table_details_t * mp)
13463 vat_main_t *vam = &vat_main;
13464 vat_json_node_t *node = NULL;
13466 if (VAT_JSON_ARRAY != vam->json_tree.type)
13468 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13469 vat_json_init_array (&vam->json_tree);
13471 node = vat_json_array_add (&vam->json_tree);
13473 vat_json_init_object (node);
13474 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13475 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
13476 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13477 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13478 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13479 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13483 api_l2_fib_table_dump (vat_main_t * vam)
13485 unformat_input_t *i = vam->input;
13486 vl_api_l2_fib_table_dump_t *mp;
13487 vl_api_control_ping_t *mp_ping;
13492 /* Parse args required to build the message */
13493 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13495 if (unformat (i, "bd_id %d", &bd_id))
13501 if (bd_id_set == 0)
13503 errmsg ("missing bridge domain");
13507 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13509 /* Get list of l2 fib entries */
13510 M (L2_FIB_TABLE_DUMP, mp);
13512 mp->bd_id = ntohl (bd_id);
13515 /* Use a control ping for synchronization */
13516 MPING (CONTROL_PING, mp_ping);
13525 api_interface_name_renumber (vat_main_t * vam)
13527 unformat_input_t *line_input = vam->input;
13528 vl_api_interface_name_renumber_t *mp;
13529 u32 sw_if_index = ~0;
13530 u32 new_show_dev_instance = ~0;
13533 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13535 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13538 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13540 else if (unformat (line_input, "new_show_dev_instance %d",
13541 &new_show_dev_instance))
13547 if (sw_if_index == ~0)
13549 errmsg ("missing interface name or sw_if_index");
13553 if (new_show_dev_instance == ~0)
13555 errmsg ("missing new_show_dev_instance");
13559 M (INTERFACE_NAME_RENUMBER, mp);
13561 mp->sw_if_index = ntohl (sw_if_index);
13562 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13570 api_want_ip4_arp_events (vat_main_t * vam)
13572 unformat_input_t *line_input = vam->input;
13573 vl_api_want_ip4_arp_events_t *mp;
13574 ip4_address_t address;
13575 int address_set = 0;
13576 u32 enable_disable = 1;
13579 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13581 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
13583 else if (unformat (line_input, "del"))
13584 enable_disable = 0;
13589 if (address_set == 0)
13591 errmsg ("missing addresses");
13595 M (WANT_IP4_ARP_EVENTS, mp);
13596 mp->enable_disable = enable_disable;
13597 mp->pid = htonl (getpid ());
13598 mp->address = address.as_u32;
13606 api_want_ip6_nd_events (vat_main_t * vam)
13608 unformat_input_t *line_input = vam->input;
13609 vl_api_want_ip6_nd_events_t *mp;
13610 ip6_address_t address;
13611 int address_set = 0;
13612 u32 enable_disable = 1;
13615 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13617 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
13619 else if (unformat (line_input, "del"))
13620 enable_disable = 0;
13625 if (address_set == 0)
13627 errmsg ("missing addresses");
13631 M (WANT_IP6_ND_EVENTS, mp);
13632 mp->enable_disable = enable_disable;
13633 mp->pid = htonl (getpid ());
13634 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
13642 api_want_l2_macs_events (vat_main_t * vam)
13644 unformat_input_t *line_input = vam->input;
13645 vl_api_want_l2_macs_events_t *mp;
13646 u8 enable_disable = 1;
13647 u32 scan_delay = 0;
13648 u32 max_macs_in_event = 0;
13649 u32 learn_limit = 0;
13652 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13654 if (unformat (line_input, "learn-limit %d", &learn_limit))
13656 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13658 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13660 else if (unformat (line_input, "disable"))
13661 enable_disable = 0;
13666 M (WANT_L2_MACS_EVENTS, mp);
13667 mp->enable_disable = enable_disable;
13668 mp->pid = htonl (getpid ());
13669 mp->learn_limit = htonl (learn_limit);
13670 mp->scan_delay = (u8) scan_delay;
13671 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13678 api_input_acl_set_interface (vat_main_t * vam)
13680 unformat_input_t *i = vam->input;
13681 vl_api_input_acl_set_interface_t *mp;
13683 int sw_if_index_set;
13684 u32 ip4_table_index = ~0;
13685 u32 ip6_table_index = ~0;
13686 u32 l2_table_index = ~0;
13690 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13692 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13693 sw_if_index_set = 1;
13694 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13695 sw_if_index_set = 1;
13696 else if (unformat (i, "del"))
13698 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13700 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13702 else if (unformat (i, "l2-table %d", &l2_table_index))
13706 clib_warning ("parse error '%U'", format_unformat_error, i);
13711 if (sw_if_index_set == 0)
13713 errmsg ("missing interface name or sw_if_index");
13717 M (INPUT_ACL_SET_INTERFACE, mp);
13719 mp->sw_if_index = ntohl (sw_if_index);
13720 mp->ip4_table_index = ntohl (ip4_table_index);
13721 mp->ip6_table_index = ntohl (ip6_table_index);
13722 mp->l2_table_index = ntohl (l2_table_index);
13723 mp->is_add = is_add;
13731 api_ip_address_dump (vat_main_t * vam)
13733 unformat_input_t *i = vam->input;
13734 vl_api_ip_address_dump_t *mp;
13735 vl_api_control_ping_t *mp_ping;
13736 u32 sw_if_index = ~0;
13737 u8 sw_if_index_set = 0;
13742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13744 if (unformat (i, "sw_if_index %d", &sw_if_index))
13745 sw_if_index_set = 1;
13747 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13748 sw_if_index_set = 1;
13749 else if (unformat (i, "ipv4"))
13751 else if (unformat (i, "ipv6"))
13757 if (ipv4_set && ipv6_set)
13759 errmsg ("ipv4 and ipv6 flags cannot be both set");
13763 if ((!ipv4_set) && (!ipv6_set))
13765 errmsg ("no ipv4 nor ipv6 flag set");
13769 if (sw_if_index_set == 0)
13771 errmsg ("missing interface name or sw_if_index");
13775 vam->current_sw_if_index = sw_if_index;
13776 vam->is_ipv6 = ipv6_set;
13778 M (IP_ADDRESS_DUMP, mp);
13779 mp->sw_if_index = ntohl (sw_if_index);
13780 mp->is_ipv6 = ipv6_set;
13783 /* Use a control ping for synchronization */
13784 MPING (CONTROL_PING, mp_ping);
13792 api_ip_dump (vat_main_t * vam)
13794 vl_api_ip_dump_t *mp;
13795 vl_api_control_ping_t *mp_ping;
13796 unformat_input_t *in = vam->input;
13803 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13805 if (unformat (in, "ipv4"))
13807 else if (unformat (in, "ipv6"))
13813 if (ipv4_set && ipv6_set)
13815 errmsg ("ipv4 and ipv6 flags cannot be both set");
13819 if ((!ipv4_set) && (!ipv6_set))
13821 errmsg ("no ipv4 nor ipv6 flag set");
13825 is_ipv6 = ipv6_set;
13826 vam->is_ipv6 = is_ipv6;
13828 /* free old data */
13829 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13831 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13833 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13836 mp->is_ipv6 = ipv6_set;
13839 /* Use a control ping for synchronization */
13840 MPING (CONTROL_PING, mp_ping);
13848 api_ipsec_spd_add_del (vat_main_t * vam)
13850 unformat_input_t *i = vam->input;
13851 vl_api_ipsec_spd_add_del_t *mp;
13856 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13858 if (unformat (i, "spd_id %d", &spd_id))
13860 else if (unformat (i, "del"))
13864 clib_warning ("parse error '%U'", format_unformat_error, i);
13870 errmsg ("spd_id must be set");
13874 M (IPSEC_SPD_ADD_DEL, mp);
13876 mp->spd_id = ntohl (spd_id);
13877 mp->is_add = is_add;
13885 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13887 unformat_input_t *i = vam->input;
13888 vl_api_ipsec_interface_add_del_spd_t *mp;
13890 u8 sw_if_index_set = 0;
13891 u32 spd_id = (u32) ~ 0;
13895 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13897 if (unformat (i, "del"))
13899 else if (unformat (i, "spd_id %d", &spd_id))
13902 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13903 sw_if_index_set = 1;
13904 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13905 sw_if_index_set = 1;
13908 clib_warning ("parse error '%U'", format_unformat_error, i);
13914 if (spd_id == (u32) ~ 0)
13916 errmsg ("spd_id must be set");
13920 if (sw_if_index_set == 0)
13922 errmsg ("missing interface name or sw_if_index");
13926 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13928 mp->spd_id = ntohl (spd_id);
13929 mp->sw_if_index = ntohl (sw_if_index);
13930 mp->is_add = is_add;
13938 api_ipsec_spd_add_del_entry (vat_main_t * vam)
13940 unformat_input_t *i = vam->input;
13941 vl_api_ipsec_spd_add_del_entry_t *mp;
13942 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
13943 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13945 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13946 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13947 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
13948 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
13951 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
13952 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
13953 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
13954 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
13955 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
13956 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
13958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13960 if (unformat (i, "del"))
13962 if (unformat (i, "outbound"))
13964 if (unformat (i, "inbound"))
13966 else if (unformat (i, "spd_id %d", &spd_id))
13968 else if (unformat (i, "sa_id %d", &sa_id))
13970 else if (unformat (i, "priority %d", &priority))
13972 else if (unformat (i, "protocol %d", &protocol))
13974 else if (unformat (i, "lport_start %d", &lport_start))
13976 else if (unformat (i, "lport_stop %d", &lport_stop))
13978 else if (unformat (i, "rport_start %d", &rport_start))
13980 else if (unformat (i, "rport_stop %d", &rport_stop))
13984 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
13990 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
13997 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
14003 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
14010 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
14016 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
14023 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
14029 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
14035 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14037 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14039 clib_warning ("unsupported action: 'resolve'");
14045 clib_warning ("parse error '%U'", format_unformat_error, i);
14051 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
14053 mp->spd_id = ntohl (spd_id);
14054 mp->priority = ntohl (priority);
14055 mp->is_outbound = is_outbound;
14057 mp->is_ipv6 = is_ipv6;
14058 if (is_ipv6 || is_ip_any)
14060 clib_memcpy (mp->remote_address_start, &raddr6_start,
14061 sizeof (ip6_address_t));
14062 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
14063 sizeof (ip6_address_t));
14064 clib_memcpy (mp->local_address_start, &laddr6_start,
14065 sizeof (ip6_address_t));
14066 clib_memcpy (mp->local_address_stop, &laddr6_stop,
14067 sizeof (ip6_address_t));
14071 clib_memcpy (mp->remote_address_start, &raddr4_start,
14072 sizeof (ip4_address_t));
14073 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
14074 sizeof (ip4_address_t));
14075 clib_memcpy (mp->local_address_start, &laddr4_start,
14076 sizeof (ip4_address_t));
14077 clib_memcpy (mp->local_address_stop, &laddr4_stop,
14078 sizeof (ip4_address_t));
14080 mp->protocol = (u8) protocol;
14081 mp->local_port_start = ntohs ((u16) lport_start);
14082 mp->local_port_stop = ntohs ((u16) lport_stop);
14083 mp->remote_port_start = ntohs ((u16) rport_start);
14084 mp->remote_port_stop = ntohs ((u16) rport_stop);
14085 mp->policy = (u8) policy;
14086 mp->sa_id = ntohl (sa_id);
14087 mp->is_add = is_add;
14088 mp->is_ip_any = is_ip_any;
14095 api_ipsec_sad_add_del_entry (vat_main_t * vam)
14097 unformat_input_t *i = vam->input;
14098 vl_api_ipsec_sad_add_del_entry_t *mp;
14099 u32 sad_id = 0, spi = 0;
14100 u8 *ck = 0, *ik = 0;
14103 u8 protocol = IPSEC_PROTOCOL_AH;
14104 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
14105 u32 crypto_alg = 0, integ_alg = 0;
14106 ip4_address_t tun_src4;
14107 ip4_address_t tun_dst4;
14108 ip6_address_t tun_src6;
14109 ip6_address_t tun_dst6;
14112 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14114 if (unformat (i, "del"))
14116 else if (unformat (i, "sad_id %d", &sad_id))
14118 else if (unformat (i, "spi %d", &spi))
14120 else if (unformat (i, "esp"))
14121 protocol = IPSEC_PROTOCOL_ESP;
14122 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
14125 is_tunnel_ipv6 = 0;
14127 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
14130 is_tunnel_ipv6 = 0;
14132 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
14135 is_tunnel_ipv6 = 1;
14137 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
14140 is_tunnel_ipv6 = 1;
14144 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14146 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14147 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14149 clib_warning ("unsupported crypto-alg: '%U'",
14150 format_ipsec_crypto_alg, crypto_alg);
14154 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14158 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14160 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14161 integ_alg >= IPSEC_INTEG_N_ALG)
14163 clib_warning ("unsupported integ-alg: '%U'",
14164 format_ipsec_integ_alg, integ_alg);
14168 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14172 clib_warning ("parse error '%U'", format_unformat_error, i);
14178 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
14180 mp->sad_id = ntohl (sad_id);
14181 mp->is_add = is_add;
14182 mp->protocol = protocol;
14183 mp->spi = ntohl (spi);
14184 mp->is_tunnel = is_tunnel;
14185 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
14186 mp->crypto_algorithm = crypto_alg;
14187 mp->integrity_algorithm = integ_alg;
14188 mp->crypto_key_length = vec_len (ck);
14189 mp->integrity_key_length = vec_len (ik);
14191 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14192 mp->crypto_key_length = sizeof (mp->crypto_key);
14194 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14195 mp->integrity_key_length = sizeof (mp->integrity_key);
14198 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14200 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14204 if (is_tunnel_ipv6)
14206 clib_memcpy (mp->tunnel_src_address, &tun_src6,
14207 sizeof (ip6_address_t));
14208 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
14209 sizeof (ip6_address_t));
14213 clib_memcpy (mp->tunnel_src_address, &tun_src4,
14214 sizeof (ip4_address_t));
14215 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
14216 sizeof (ip4_address_t));
14226 api_ipsec_sa_set_key (vat_main_t * vam)
14228 unformat_input_t *i = vam->input;
14229 vl_api_ipsec_sa_set_key_t *mp;
14231 u8 *ck = 0, *ik = 0;
14234 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14236 if (unformat (i, "sa_id %d", &sa_id))
14238 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14240 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14244 clib_warning ("parse error '%U'", format_unformat_error, i);
14249 M (IPSEC_SA_SET_KEY, mp);
14251 mp->sa_id = ntohl (sa_id);
14252 mp->crypto_key_length = vec_len (ck);
14253 mp->integrity_key_length = vec_len (ik);
14255 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14256 mp->crypto_key_length = sizeof (mp->crypto_key);
14258 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14259 mp->integrity_key_length = sizeof (mp->integrity_key);
14262 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14264 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14272 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14274 unformat_input_t *i = vam->input;
14275 vl_api_ipsec_tunnel_if_add_del_t *mp;
14276 u32 local_spi = 0, remote_spi = 0;
14277 u32 crypto_alg = 0, integ_alg = 0;
14278 u8 *lck = NULL, *rck = NULL;
14279 u8 *lik = NULL, *rik = NULL;
14280 ip4_address_t local_ip = { {0} };
14281 ip4_address_t remote_ip = { {0} };
14284 u8 anti_replay = 0;
14287 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14289 if (unformat (i, "del"))
14291 else if (unformat (i, "esn"))
14293 else if (unformat (i, "anti_replay"))
14295 else if (unformat (i, "local_spi %d", &local_spi))
14297 else if (unformat (i, "remote_spi %d", &remote_spi))
14299 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
14301 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
14303 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14306 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14308 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14310 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14314 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14316 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14317 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14319 errmsg ("unsupported crypto-alg: '%U'\n",
14320 format_ipsec_crypto_alg, crypto_alg);
14326 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14328 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14329 integ_alg >= IPSEC_INTEG_N_ALG)
14331 errmsg ("unsupported integ-alg: '%U'\n",
14332 format_ipsec_integ_alg, integ_alg);
14338 errmsg ("parse error '%U'\n", format_unformat_error, i);
14343 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14345 mp->is_add = is_add;
14347 mp->anti_replay = anti_replay;
14349 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
14350 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
14352 mp->local_spi = htonl (local_spi);
14353 mp->remote_spi = htonl (remote_spi);
14354 mp->crypto_alg = (u8) crypto_alg;
14356 mp->local_crypto_key_len = 0;
14359 mp->local_crypto_key_len = vec_len (lck);
14360 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14361 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14362 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14365 mp->remote_crypto_key_len = 0;
14368 mp->remote_crypto_key_len = vec_len (rck);
14369 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14370 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14371 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14374 mp->integ_alg = (u8) integ_alg;
14376 mp->local_integ_key_len = 0;
14379 mp->local_integ_key_len = vec_len (lik);
14380 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14381 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14382 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14385 mp->remote_integ_key_len = 0;
14388 mp->remote_integ_key_len = vec_len (rik);
14389 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14390 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14391 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14400 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14402 vat_main_t *vam = &vat_main;
14404 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14405 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
14406 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
14407 "tunnel_src_addr %U tunnel_dst_addr %U "
14408 "salt %u seq_outbound %lu last_seq_inbound %lu "
14409 "replay_window %lu total_data_size %lu\n",
14410 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
14412 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
14413 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
14414 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
14415 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14416 mp->tunnel_src_addr,
14417 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14418 mp->tunnel_dst_addr,
14420 clib_net_to_host_u64 (mp->seq_outbound),
14421 clib_net_to_host_u64 (mp->last_seq_inbound),
14422 clib_net_to_host_u64 (mp->replay_window),
14423 clib_net_to_host_u64 (mp->total_data_size));
14426 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14427 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14429 static void vl_api_ipsec_sa_details_t_handler_json
14430 (vl_api_ipsec_sa_details_t * mp)
14432 vat_main_t *vam = &vat_main;
14433 vat_json_node_t *node = NULL;
14434 struct in_addr src_ip4, dst_ip4;
14435 struct in6_addr src_ip6, dst_ip6;
14437 if (VAT_JSON_ARRAY != vam->json_tree.type)
14439 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14440 vat_json_init_array (&vam->json_tree);
14442 node = vat_json_array_add (&vam->json_tree);
14444 vat_json_init_object (node);
14445 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
14446 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14447 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
14448 vat_json_object_add_uint (node, "proto", mp->protocol);
14449 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
14450 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
14451 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
14452 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
14453 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
14454 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
14455 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
14456 mp->crypto_key_len);
14457 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
14458 mp->integ_key_len);
14459 if (mp->is_tunnel_ip6)
14461 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
14462 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
14463 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
14464 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
14468 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
14469 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
14470 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
14471 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
14473 vat_json_object_add_uint (node, "replay_window",
14474 clib_net_to_host_u64 (mp->replay_window));
14475 vat_json_object_add_uint (node, "total_data_size",
14476 clib_net_to_host_u64 (mp->total_data_size));
14481 api_ipsec_sa_dump (vat_main_t * vam)
14483 unformat_input_t *i = vam->input;
14484 vl_api_ipsec_sa_dump_t *mp;
14485 vl_api_control_ping_t *mp_ping;
14489 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14491 if (unformat (i, "sa_id %d", &sa_id))
14495 clib_warning ("parse error '%U'", format_unformat_error, i);
14500 M (IPSEC_SA_DUMP, mp);
14502 mp->sa_id = ntohl (sa_id);
14506 /* Use a control ping for synchronization */
14507 M (CONTROL_PING, mp_ping);
14515 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
14517 unformat_input_t *i = vam->input;
14518 vl_api_ipsec_tunnel_if_set_key_t *mp;
14519 u32 sw_if_index = ~0;
14520 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
14525 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14527 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14530 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
14531 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
14533 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
14534 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
14535 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
14536 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
14538 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
14539 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
14540 else if (unformat (i, "%U", unformat_hex_string, &key))
14544 clib_warning ("parse error '%U'", format_unformat_error, i);
14549 if (sw_if_index == ~0)
14551 errmsg ("interface must be specified");
14555 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
14557 errmsg ("key type must be specified");
14563 errmsg ("algorithm must be specified");
14567 if (vec_len (key) == 0)
14569 errmsg ("key must be specified");
14573 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
14575 mp->sw_if_index = htonl (sw_if_index);
14577 mp->key_type = key_type;
14578 mp->key_len = vec_len (key);
14579 clib_memcpy (mp->key, key, vec_len (key));
14588 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
14590 unformat_input_t *i = vam->input;
14591 vl_api_ipsec_tunnel_if_set_sa_t *mp;
14592 u32 sw_if_index = ~0;
14594 u8 is_outbound = (u8) ~ 0;
14597 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14599 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14601 else if (unformat (i, "sa_id %d", &sa_id))
14603 else if (unformat (i, "outbound"))
14605 else if (unformat (i, "inbound"))
14609 clib_warning ("parse error '%U'", format_unformat_error, i);
14614 if (sw_if_index == ~0)
14616 errmsg ("interface must be specified");
14622 errmsg ("SA ID must be specified");
14626 M (IPSEC_TUNNEL_IF_SET_SA, mp);
14628 mp->sw_if_index = htonl (sw_if_index);
14629 mp->sa_id = htonl (sa_id);
14630 mp->is_outbound = is_outbound;
14639 api_ikev2_profile_add_del (vat_main_t * vam)
14641 unformat_input_t *i = vam->input;
14642 vl_api_ikev2_profile_add_del_t *mp;
14647 const char *valid_chars = "a-zA-Z0-9_";
14649 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14651 if (unformat (i, "del"))
14653 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14654 vec_add1 (name, 0);
14657 errmsg ("parse error '%U'", format_unformat_error, i);
14662 if (!vec_len (name))
14664 errmsg ("profile name must be specified");
14668 if (vec_len (name) > 64)
14670 errmsg ("profile name too long");
14674 M (IKEV2_PROFILE_ADD_DEL, mp);
14676 clib_memcpy (mp->name, name, vec_len (name));
14677 mp->is_add = is_add;
14686 api_ikev2_profile_set_auth (vat_main_t * vam)
14688 unformat_input_t *i = vam->input;
14689 vl_api_ikev2_profile_set_auth_t *mp;
14692 u32 auth_method = 0;
14696 const char *valid_chars = "a-zA-Z0-9_";
14698 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14700 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14701 vec_add1 (name, 0);
14702 else if (unformat (i, "auth_method %U",
14703 unformat_ikev2_auth_method, &auth_method))
14705 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
14707 else if (unformat (i, "auth_data %v", &data))
14711 errmsg ("parse error '%U'", format_unformat_error, i);
14716 if (!vec_len (name))
14718 errmsg ("profile name must be specified");
14722 if (vec_len (name) > 64)
14724 errmsg ("profile name too long");
14728 if (!vec_len (data))
14730 errmsg ("auth_data must be specified");
14736 errmsg ("auth_method must be specified");
14740 M (IKEV2_PROFILE_SET_AUTH, mp);
14742 mp->is_hex = is_hex;
14743 mp->auth_method = (u8) auth_method;
14744 mp->data_len = vec_len (data);
14745 clib_memcpy (mp->name, name, vec_len (name));
14746 clib_memcpy (mp->data, data, vec_len (data));
14756 api_ikev2_profile_set_id (vat_main_t * vam)
14758 unformat_input_t *i = vam->input;
14759 vl_api_ikev2_profile_set_id_t *mp;
14767 const char *valid_chars = "a-zA-Z0-9_";
14769 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14771 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14772 vec_add1 (name, 0);
14773 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
14775 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
14777 data = vec_new (u8, 4);
14778 clib_memcpy (data, ip4.as_u8, 4);
14780 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
14782 else if (unformat (i, "id_data %v", &data))
14784 else if (unformat (i, "local"))
14786 else if (unformat (i, "remote"))
14790 errmsg ("parse error '%U'", format_unformat_error, i);
14795 if (!vec_len (name))
14797 errmsg ("profile name must be specified");
14801 if (vec_len (name) > 64)
14803 errmsg ("profile name too long");
14807 if (!vec_len (data))
14809 errmsg ("id_data must be specified");
14815 errmsg ("id_type must be specified");
14819 M (IKEV2_PROFILE_SET_ID, mp);
14821 mp->is_local = is_local;
14822 mp->id_type = (u8) id_type;
14823 mp->data_len = vec_len (data);
14824 clib_memcpy (mp->name, name, vec_len (name));
14825 clib_memcpy (mp->data, data, vec_len (data));
14835 api_ikev2_profile_set_ts (vat_main_t * vam)
14837 unformat_input_t *i = vam->input;
14838 vl_api_ikev2_profile_set_ts_t *mp;
14841 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
14842 ip4_address_t start_addr, end_addr;
14844 const char *valid_chars = "a-zA-Z0-9_";
14847 start_addr.as_u32 = 0;
14848 end_addr.as_u32 = (u32) ~ 0;
14850 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14852 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14853 vec_add1 (name, 0);
14854 else if (unformat (i, "protocol %d", &proto))
14856 else if (unformat (i, "start_port %d", &start_port))
14858 else if (unformat (i, "end_port %d", &end_port))
14861 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
14863 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
14865 else if (unformat (i, "local"))
14867 else if (unformat (i, "remote"))
14871 errmsg ("parse error '%U'", format_unformat_error, i);
14876 if (!vec_len (name))
14878 errmsg ("profile name must be specified");
14882 if (vec_len (name) > 64)
14884 errmsg ("profile name too long");
14888 M (IKEV2_PROFILE_SET_TS, mp);
14890 mp->is_local = is_local;
14891 mp->proto = (u8) proto;
14892 mp->start_port = (u16) start_port;
14893 mp->end_port = (u16) end_port;
14894 mp->start_addr = start_addr.as_u32;
14895 mp->end_addr = end_addr.as_u32;
14896 clib_memcpy (mp->name, name, vec_len (name));
14905 api_ikev2_set_local_key (vat_main_t * vam)
14907 unformat_input_t *i = vam->input;
14908 vl_api_ikev2_set_local_key_t *mp;
14912 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14914 if (unformat (i, "file %v", &file))
14915 vec_add1 (file, 0);
14918 errmsg ("parse error '%U'", format_unformat_error, i);
14923 if (!vec_len (file))
14925 errmsg ("RSA key file must be specified");
14929 if (vec_len (file) > 256)
14931 errmsg ("file name too long");
14935 M (IKEV2_SET_LOCAL_KEY, mp);
14937 clib_memcpy (mp->key_file, file, vec_len (file));
14946 api_ikev2_set_responder (vat_main_t * vam)
14948 unformat_input_t *i = vam->input;
14949 vl_api_ikev2_set_responder_t *mp;
14952 u32 sw_if_index = ~0;
14953 ip4_address_t address;
14955 const char *valid_chars = "a-zA-Z0-9_";
14957 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14960 (i, "%U interface %d address %U", unformat_token, valid_chars,
14961 &name, &sw_if_index, unformat_ip4_address, &address))
14962 vec_add1 (name, 0);
14965 errmsg ("parse error '%U'", format_unformat_error, i);
14970 if (!vec_len (name))
14972 errmsg ("profile name must be specified");
14976 if (vec_len (name) > 64)
14978 errmsg ("profile name too long");
14982 M (IKEV2_SET_RESPONDER, mp);
14984 clib_memcpy (mp->name, name, vec_len (name));
14987 mp->sw_if_index = sw_if_index;
14988 clib_memcpy (mp->address, &address, sizeof (address));
14996 api_ikev2_set_ike_transforms (vat_main_t * vam)
14998 unformat_input_t *i = vam->input;
14999 vl_api_ikev2_set_ike_transforms_t *mp;
15002 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15004 const char *valid_chars = "a-zA-Z0-9_";
15006 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15008 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15009 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15010 vec_add1 (name, 0);
15013 errmsg ("parse error '%U'", format_unformat_error, i);
15018 if (!vec_len (name))
15020 errmsg ("profile name must be specified");
15024 if (vec_len (name) > 64)
15026 errmsg ("profile name too long");
15030 M (IKEV2_SET_IKE_TRANSFORMS, mp);
15032 clib_memcpy (mp->name, name, vec_len (name));
15034 mp->crypto_alg = crypto_alg;
15035 mp->crypto_key_size = crypto_key_size;
15036 mp->integ_alg = integ_alg;
15037 mp->dh_group = dh_group;
15046 api_ikev2_set_esp_transforms (vat_main_t * vam)
15048 unformat_input_t *i = vam->input;
15049 vl_api_ikev2_set_esp_transforms_t *mp;
15052 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15054 const char *valid_chars = "a-zA-Z0-9_";
15056 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15058 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15059 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15060 vec_add1 (name, 0);
15063 errmsg ("parse error '%U'", format_unformat_error, i);
15068 if (!vec_len (name))
15070 errmsg ("profile name must be specified");
15074 if (vec_len (name) > 64)
15076 errmsg ("profile name too long");
15080 M (IKEV2_SET_ESP_TRANSFORMS, mp);
15082 clib_memcpy (mp->name, name, vec_len (name));
15084 mp->crypto_alg = crypto_alg;
15085 mp->crypto_key_size = crypto_key_size;
15086 mp->integ_alg = integ_alg;
15087 mp->dh_group = dh_group;
15095 api_ikev2_set_sa_lifetime (vat_main_t * vam)
15097 unformat_input_t *i = vam->input;
15098 vl_api_ikev2_set_sa_lifetime_t *mp;
15101 u64 lifetime, lifetime_maxdata;
15102 u32 lifetime_jitter, handover;
15104 const char *valid_chars = "a-zA-Z0-9_";
15106 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15108 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
15109 &lifetime, &lifetime_jitter, &handover,
15110 &lifetime_maxdata))
15111 vec_add1 (name, 0);
15114 errmsg ("parse error '%U'", format_unformat_error, i);
15119 if (!vec_len (name))
15121 errmsg ("profile name must be specified");
15125 if (vec_len (name) > 64)
15127 errmsg ("profile name too long");
15131 M (IKEV2_SET_SA_LIFETIME, mp);
15133 clib_memcpy (mp->name, name, vec_len (name));
15135 mp->lifetime = lifetime;
15136 mp->lifetime_jitter = lifetime_jitter;
15137 mp->handover = handover;
15138 mp->lifetime_maxdata = lifetime_maxdata;
15146 api_ikev2_initiate_sa_init (vat_main_t * vam)
15148 unformat_input_t *i = vam->input;
15149 vl_api_ikev2_initiate_sa_init_t *mp;
15153 const char *valid_chars = "a-zA-Z0-9_";
15155 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15157 if (unformat (i, "%U", unformat_token, valid_chars, &name))
15158 vec_add1 (name, 0);
15161 errmsg ("parse error '%U'", format_unformat_error, i);
15166 if (!vec_len (name))
15168 errmsg ("profile name must be specified");
15172 if (vec_len (name) > 64)
15174 errmsg ("profile name too long");
15178 M (IKEV2_INITIATE_SA_INIT, mp);
15180 clib_memcpy (mp->name, name, vec_len (name));
15189 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
15191 unformat_input_t *i = vam->input;
15192 vl_api_ikev2_initiate_del_ike_sa_t *mp;
15197 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15199 if (unformat (i, "%lx", &ispi))
15203 errmsg ("parse error '%U'", format_unformat_error, i);
15208 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
15218 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
15220 unformat_input_t *i = vam->input;
15221 vl_api_ikev2_initiate_del_child_sa_t *mp;
15226 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15228 if (unformat (i, "%x", &ispi))
15232 errmsg ("parse error '%U'", format_unformat_error, i);
15237 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
15247 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
15249 unformat_input_t *i = vam->input;
15250 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
15255 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15257 if (unformat (i, "%x", &ispi))
15261 errmsg ("parse error '%U'", format_unformat_error, i);
15266 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
15279 api_map_add_domain (vat_main_t * vam)
15281 unformat_input_t *i = vam->input;
15282 vl_api_map_add_domain_t *mp;
15284 ip4_address_t ip4_prefix;
15285 ip6_address_t ip6_prefix;
15286 ip6_address_t ip6_src;
15287 u32 num_m_args = 0;
15288 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
15289 0, psid_length = 0;
15290 u8 is_translation = 0;
15292 u32 ip6_src_len = 128;
15295 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15297 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
15298 &ip4_prefix, &ip4_prefix_len))
15300 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
15301 &ip6_prefix, &ip6_prefix_len))
15305 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
15308 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
15310 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
15312 else if (unformat (i, "psid-offset %d", &psid_offset))
15314 else if (unformat (i, "psid-len %d", &psid_length))
15316 else if (unformat (i, "mtu %d", &mtu))
15318 else if (unformat (i, "map-t"))
15319 is_translation = 1;
15322 clib_warning ("parse error '%U'", format_unformat_error, i);
15327 if (num_m_args < 3)
15329 errmsg ("mandatory argument(s) missing");
15333 /* Construct the API message */
15334 M (MAP_ADD_DOMAIN, mp);
15336 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
15337 mp->ip4_prefix_len = ip4_prefix_len;
15339 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
15340 mp->ip6_prefix_len = ip6_prefix_len;
15342 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
15343 mp->ip6_src_prefix_len = ip6_src_len;
15345 mp->ea_bits_len = ea_bits_len;
15346 mp->psid_offset = psid_offset;
15347 mp->psid_length = psid_length;
15348 mp->is_translation = is_translation;
15349 mp->mtu = htons (mtu);
15354 /* Wait for a reply, return good/bad news */
15360 api_map_del_domain (vat_main_t * vam)
15362 unformat_input_t *i = vam->input;
15363 vl_api_map_del_domain_t *mp;
15365 u32 num_m_args = 0;
15369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15371 if (unformat (i, "index %d", &index))
15375 clib_warning ("parse error '%U'", format_unformat_error, i);
15380 if (num_m_args != 1)
15382 errmsg ("mandatory argument(s) missing");
15386 /* Construct the API message */
15387 M (MAP_DEL_DOMAIN, mp);
15389 mp->index = ntohl (index);
15394 /* Wait for a reply, return good/bad news */
15400 api_map_add_del_rule (vat_main_t * vam)
15402 unformat_input_t *i = vam->input;
15403 vl_api_map_add_del_rule_t *mp;
15405 ip6_address_t ip6_dst;
15406 u32 num_m_args = 0, index, psid = 0;
15409 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15411 if (unformat (i, "index %d", &index))
15413 else if (unformat (i, "psid %d", &psid))
15415 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
15417 else if (unformat (i, "del"))
15423 clib_warning ("parse error '%U'", format_unformat_error, i);
15428 /* Construct the API message */
15429 M (MAP_ADD_DEL_RULE, mp);
15431 mp->index = ntohl (index);
15432 mp->is_add = is_add;
15433 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
15434 mp->psid = ntohs (psid);
15439 /* Wait for a reply, return good/bad news */
15445 api_map_domain_dump (vat_main_t * vam)
15447 vl_api_map_domain_dump_t *mp;
15448 vl_api_control_ping_t *mp_ping;
15451 /* Construct the API message */
15452 M (MAP_DOMAIN_DUMP, mp);
15457 /* Use a control ping for synchronization */
15458 MPING (CONTROL_PING, mp_ping);
15466 api_map_rule_dump (vat_main_t * vam)
15468 unformat_input_t *i = vam->input;
15469 vl_api_map_rule_dump_t *mp;
15470 vl_api_control_ping_t *mp_ping;
15471 u32 domain_index = ~0;
15474 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15476 if (unformat (i, "index %u", &domain_index))
15482 if (domain_index == ~0)
15484 clib_warning ("parse error: domain index expected");
15488 /* Construct the API message */
15489 M (MAP_RULE_DUMP, mp);
15491 mp->domain_index = htonl (domain_index);
15496 /* Use a control ping for synchronization */
15497 MPING (CONTROL_PING, mp_ping);
15504 static void vl_api_map_add_domain_reply_t_handler
15505 (vl_api_map_add_domain_reply_t * mp)
15507 vat_main_t *vam = &vat_main;
15508 i32 retval = ntohl (mp->retval);
15510 if (vam->async_mode)
15512 vam->async_errors += (retval < 0);
15516 vam->retval = retval;
15517 vam->result_ready = 1;
15521 static void vl_api_map_add_domain_reply_t_handler_json
15522 (vl_api_map_add_domain_reply_t * mp)
15524 vat_main_t *vam = &vat_main;
15525 vat_json_node_t node;
15527 vat_json_init_object (&node);
15528 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
15529 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
15531 vat_json_print (vam->ofp, &node);
15532 vat_json_free (&node);
15534 vam->retval = ntohl (mp->retval);
15535 vam->result_ready = 1;
15539 api_get_first_msg_id (vat_main_t * vam)
15541 vl_api_get_first_msg_id_t *mp;
15542 unformat_input_t *i = vam->input;
15547 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15549 if (unformat (i, "client %s", &name))
15557 errmsg ("missing client name");
15560 vec_add1 (name, 0);
15562 if (vec_len (name) > 63)
15564 errmsg ("client name too long");
15568 M (GET_FIRST_MSG_ID, mp);
15569 clib_memcpy (mp->name, name, vec_len (name));
15576 api_cop_interface_enable_disable (vat_main_t * vam)
15578 unformat_input_t *line_input = vam->input;
15579 vl_api_cop_interface_enable_disable_t *mp;
15580 u32 sw_if_index = ~0;
15581 u8 enable_disable = 1;
15584 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15586 if (unformat (line_input, "disable"))
15587 enable_disable = 0;
15588 if (unformat (line_input, "enable"))
15589 enable_disable = 1;
15590 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15591 vam, &sw_if_index))
15593 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15599 if (sw_if_index == ~0)
15601 errmsg ("missing interface name or sw_if_index");
15605 /* Construct the API message */
15606 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15607 mp->sw_if_index = ntohl (sw_if_index);
15608 mp->enable_disable = enable_disable;
15612 /* Wait for the reply */
15618 api_cop_whitelist_enable_disable (vat_main_t * vam)
15620 unformat_input_t *line_input = vam->input;
15621 vl_api_cop_whitelist_enable_disable_t *mp;
15622 u32 sw_if_index = ~0;
15623 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15627 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15629 if (unformat (line_input, "ip4"))
15631 else if (unformat (line_input, "ip6"))
15633 else if (unformat (line_input, "default"))
15635 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15636 vam, &sw_if_index))
15638 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15640 else if (unformat (line_input, "fib-id %d", &fib_id))
15646 if (sw_if_index == ~0)
15648 errmsg ("missing interface name or sw_if_index");
15652 /* Construct the API message */
15653 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15654 mp->sw_if_index = ntohl (sw_if_index);
15655 mp->fib_id = ntohl (fib_id);
15658 mp->default_cop = default_cop;
15662 /* Wait for the reply */
15668 api_get_node_graph (vat_main_t * vam)
15670 vl_api_get_node_graph_t *mp;
15673 M (GET_NODE_GRAPH, mp);
15677 /* Wait for the reply */
15683 /** Used for parsing LISP eids */
15684 typedef CLIB_PACKED(struct{
15685 u8 addr[16]; /**< eid address */
15686 u32 len; /**< prefix length if IP */
15687 u8 type; /**< type of eid */
15692 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15694 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15696 memset (a, 0, sizeof (a[0]));
15698 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15700 a->type = 0; /* ipv4 type */
15702 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15704 a->type = 1; /* ipv6 type */
15706 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15708 a->type = 2; /* mac type */
15710 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15712 a->type = 3; /* NSH type */
15713 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15714 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15721 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15730 lisp_eid_size_vat (u8 type)
15747 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15749 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15753 api_one_add_del_locator_set (vat_main_t * vam)
15755 unformat_input_t *input = vam->input;
15756 vl_api_one_add_del_locator_set_t *mp;
15758 u8 *locator_set_name = NULL;
15759 u8 locator_set_name_set = 0;
15760 vl_api_local_locator_t locator, *locators = 0;
15761 u32 sw_if_index, priority, weight;
15765 /* Parse args required to build the message */
15766 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15768 if (unformat (input, "del"))
15772 else if (unformat (input, "locator-set %s", &locator_set_name))
15774 locator_set_name_set = 1;
15776 else if (unformat (input, "sw_if_index %u p %u w %u",
15777 &sw_if_index, &priority, &weight))
15779 locator.sw_if_index = htonl (sw_if_index);
15780 locator.priority = priority;
15781 locator.weight = weight;
15782 vec_add1 (locators, locator);
15786 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15787 &sw_if_index, &priority, &weight))
15789 locator.sw_if_index = htonl (sw_if_index);
15790 locator.priority = priority;
15791 locator.weight = weight;
15792 vec_add1 (locators, locator);
15798 if (locator_set_name_set == 0)
15800 errmsg ("missing locator-set name");
15801 vec_free (locators);
15805 if (vec_len (locator_set_name) > 64)
15807 errmsg ("locator-set name too long");
15808 vec_free (locator_set_name);
15809 vec_free (locators);
15812 vec_add1 (locator_set_name, 0);
15814 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15816 /* Construct the API message */
15817 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15819 mp->is_add = is_add;
15820 clib_memcpy (mp->locator_set_name, locator_set_name,
15821 vec_len (locator_set_name));
15822 vec_free (locator_set_name);
15824 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15826 clib_memcpy (mp->locators, locators, data_len);
15827 vec_free (locators);
15832 /* Wait for a reply... */
15837 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15840 api_one_add_del_locator (vat_main_t * vam)
15842 unformat_input_t *input = vam->input;
15843 vl_api_one_add_del_locator_t *mp;
15844 u32 tmp_if_index = ~0;
15845 u32 sw_if_index = ~0;
15846 u8 sw_if_index_set = 0;
15847 u8 sw_if_index_if_name_set = 0;
15849 u8 priority_set = 0;
15853 u8 *locator_set_name = NULL;
15854 u8 locator_set_name_set = 0;
15857 /* Parse args required to build the message */
15858 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15860 if (unformat (input, "del"))
15864 else if (unformat (input, "locator-set %s", &locator_set_name))
15866 locator_set_name_set = 1;
15868 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15871 sw_if_index_if_name_set = 1;
15872 sw_if_index = tmp_if_index;
15874 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15876 sw_if_index_set = 1;
15877 sw_if_index = tmp_if_index;
15879 else if (unformat (input, "p %d", &priority))
15883 else if (unformat (input, "w %d", &weight))
15891 if (locator_set_name_set == 0)
15893 errmsg ("missing locator-set name");
15897 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15899 errmsg ("missing sw_if_index");
15900 vec_free (locator_set_name);
15904 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15906 errmsg ("cannot use both params interface name and sw_if_index");
15907 vec_free (locator_set_name);
15911 if (priority_set == 0)
15913 errmsg ("missing locator-set priority");
15914 vec_free (locator_set_name);
15918 if (weight_set == 0)
15920 errmsg ("missing locator-set weight");
15921 vec_free (locator_set_name);
15925 if (vec_len (locator_set_name) > 64)
15927 errmsg ("locator-set name too long");
15928 vec_free (locator_set_name);
15931 vec_add1 (locator_set_name, 0);
15933 /* Construct the API message */
15934 M (ONE_ADD_DEL_LOCATOR, mp);
15936 mp->is_add = is_add;
15937 mp->sw_if_index = ntohl (sw_if_index);
15938 mp->priority = priority;
15939 mp->weight = weight;
15940 clib_memcpy (mp->locator_set_name, locator_set_name,
15941 vec_len (locator_set_name));
15942 vec_free (locator_set_name);
15947 /* Wait for a reply... */
15952 #define api_lisp_add_del_locator api_one_add_del_locator
15955 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15957 u32 *key_id = va_arg (*args, u32 *);
15960 if (unformat (input, "%s", &s))
15962 if (!strcmp ((char *) s, "sha1"))
15963 key_id[0] = HMAC_SHA_1_96;
15964 else if (!strcmp ((char *) s, "sha256"))
15965 key_id[0] = HMAC_SHA_256_128;
15968 clib_warning ("invalid key_id: '%s'", s);
15969 key_id[0] = HMAC_NO_KEY;
15980 api_one_add_del_local_eid (vat_main_t * vam)
15982 unformat_input_t *input = vam->input;
15983 vl_api_one_add_del_local_eid_t *mp;
15986 lisp_eid_vat_t _eid, *eid = &_eid;
15987 u8 *locator_set_name = 0;
15988 u8 locator_set_name_set = 0;
15994 /* Parse args required to build the message */
15995 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15997 if (unformat (input, "del"))
16001 else if (unformat (input, "vni %d", &vni))
16005 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16009 else if (unformat (input, "locator-set %s", &locator_set_name))
16011 locator_set_name_set = 1;
16013 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
16015 else if (unformat (input, "secret-key %_%v%_", &key))
16021 if (locator_set_name_set == 0)
16023 errmsg ("missing locator-set name");
16029 errmsg ("EID address not set!");
16030 vec_free (locator_set_name);
16034 if (key && (0 == key_id))
16036 errmsg ("invalid key_id!");
16040 if (vec_len (key) > 64)
16042 errmsg ("key too long");
16047 if (vec_len (locator_set_name) > 64)
16049 errmsg ("locator-set name too long");
16050 vec_free (locator_set_name);
16053 vec_add1 (locator_set_name, 0);
16055 /* Construct the API message */
16056 M (ONE_ADD_DEL_LOCAL_EID, mp);
16058 mp->is_add = is_add;
16059 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16060 mp->eid_type = eid->type;
16061 mp->prefix_len = eid->len;
16062 mp->vni = clib_host_to_net_u32 (vni);
16063 mp->key_id = clib_host_to_net_u16 (key_id);
16064 clib_memcpy (mp->locator_set_name, locator_set_name,
16065 vec_len (locator_set_name));
16066 clib_memcpy (mp->key, key, vec_len (key));
16068 vec_free (locator_set_name);
16074 /* Wait for a reply... */
16079 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
16082 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
16084 u32 dp_table = 0, vni = 0;;
16085 unformat_input_t *input = vam->input;
16086 vl_api_gpe_add_del_fwd_entry_t *mp;
16088 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
16089 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
16090 u8 rmt_eid_set = 0, lcl_eid_set = 0;
16091 u32 action = ~0, w;
16092 ip4_address_t rmt_rloc4, lcl_rloc4;
16093 ip6_address_t rmt_rloc6, lcl_rloc6;
16094 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
16097 memset (&rloc, 0, sizeof (rloc));
16099 /* Parse args required to build the message */
16100 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16102 if (unformat (input, "del"))
16104 else if (unformat (input, "add"))
16106 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
16110 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
16114 else if (unformat (input, "vrf %d", &dp_table))
16116 else if (unformat (input, "bd %d", &dp_table))
16118 else if (unformat (input, "vni %d", &vni))
16120 else if (unformat (input, "w %d", &w))
16124 errmsg ("No RLOC configured for setting priority/weight!");
16127 curr_rloc->weight = w;
16129 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
16130 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
16134 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
16136 vec_add1 (lcl_locs, rloc);
16138 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
16139 vec_add1 (rmt_locs, rloc);
16140 /* weight saved in rmt loc */
16141 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16143 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
16144 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
16147 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
16149 vec_add1 (lcl_locs, rloc);
16151 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
16152 vec_add1 (rmt_locs, rloc);
16153 /* weight saved in rmt loc */
16154 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16156 else if (unformat (input, "action %d", &action))
16162 clib_warning ("parse error '%U'", format_unformat_error, input);
16169 errmsg ("remote eid addresses not set");
16173 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
16175 errmsg ("eid types don't match");
16179 if (0 == rmt_locs && (u32) ~ 0 == action)
16181 errmsg ("action not set for negative mapping");
16185 /* Construct the API message */
16186 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
16187 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
16189 mp->is_add = is_add;
16190 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
16191 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
16192 mp->eid_type = rmt_eid->type;
16193 mp->dp_table = clib_host_to_net_u32 (dp_table);
16194 mp->vni = clib_host_to_net_u32 (vni);
16195 mp->rmt_len = rmt_eid->len;
16196 mp->lcl_len = lcl_eid->len;
16197 mp->action = action;
16199 if (0 != rmt_locs && 0 != lcl_locs)
16201 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
16202 clib_memcpy (mp->locs, lcl_locs,
16203 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
16205 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
16206 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
16207 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
16209 vec_free (lcl_locs);
16210 vec_free (rmt_locs);
16215 /* Wait for a reply... */
16221 api_one_add_del_map_server (vat_main_t * vam)
16223 unformat_input_t *input = vam->input;
16224 vl_api_one_add_del_map_server_t *mp;
16228 ip4_address_t ipv4;
16229 ip6_address_t ipv6;
16232 /* Parse args required to build the message */
16233 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16235 if (unformat (input, "del"))
16239 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16243 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16251 if (ipv4_set && ipv6_set)
16253 errmsg ("both eid v4 and v6 addresses set");
16257 if (!ipv4_set && !ipv6_set)
16259 errmsg ("eid addresses not set");
16263 /* Construct the API message */
16264 M (ONE_ADD_DEL_MAP_SERVER, mp);
16266 mp->is_add = is_add;
16270 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16275 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16281 /* Wait for a reply... */
16286 #define api_lisp_add_del_map_server api_one_add_del_map_server
16289 api_one_add_del_map_resolver (vat_main_t * vam)
16291 unformat_input_t *input = vam->input;
16292 vl_api_one_add_del_map_resolver_t *mp;
16296 ip4_address_t ipv4;
16297 ip6_address_t ipv6;
16300 /* Parse args required to build the message */
16301 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16303 if (unformat (input, "del"))
16307 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16311 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16319 if (ipv4_set && ipv6_set)
16321 errmsg ("both eid v4 and v6 addresses set");
16325 if (!ipv4_set && !ipv6_set)
16327 errmsg ("eid addresses not set");
16331 /* Construct the API message */
16332 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
16334 mp->is_add = is_add;
16338 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16343 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16349 /* Wait for a reply... */
16354 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
16357 api_lisp_gpe_enable_disable (vat_main_t * vam)
16359 unformat_input_t *input = vam->input;
16360 vl_api_gpe_enable_disable_t *mp;
16365 /* Parse args required to build the message */
16366 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16368 if (unformat (input, "enable"))
16373 else if (unformat (input, "disable"))
16384 errmsg ("Value not set");
16388 /* Construct the API message */
16389 M (GPE_ENABLE_DISABLE, mp);
16396 /* Wait for a reply... */
16402 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16404 unformat_input_t *input = vam->input;
16405 vl_api_one_rloc_probe_enable_disable_t *mp;
16410 /* Parse args required to build the message */
16411 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16413 if (unformat (input, "enable"))
16418 else if (unformat (input, "disable"))
16426 errmsg ("Value not set");
16430 /* Construct the API message */
16431 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16433 mp->is_enabled = is_en;
16438 /* Wait for a reply... */
16443 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16446 api_one_map_register_enable_disable (vat_main_t * vam)
16448 unformat_input_t *input = vam->input;
16449 vl_api_one_map_register_enable_disable_t *mp;
16454 /* Parse args required to build the message */
16455 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16457 if (unformat (input, "enable"))
16462 else if (unformat (input, "disable"))
16470 errmsg ("Value not set");
16474 /* Construct the API message */
16475 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16477 mp->is_enabled = is_en;
16482 /* Wait for a reply... */
16487 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16490 api_one_enable_disable (vat_main_t * vam)
16492 unformat_input_t *input = vam->input;
16493 vl_api_one_enable_disable_t *mp;
16498 /* Parse args required to build the message */
16499 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16501 if (unformat (input, "enable"))
16506 else if (unformat (input, "disable"))
16516 errmsg ("Value not set");
16520 /* Construct the API message */
16521 M (ONE_ENABLE_DISABLE, mp);
16528 /* Wait for a reply... */
16533 #define api_lisp_enable_disable api_one_enable_disable
16536 api_one_enable_disable_xtr_mode (vat_main_t * vam)
16538 unformat_input_t *input = vam->input;
16539 vl_api_one_enable_disable_xtr_mode_t *mp;
16544 /* Parse args required to build the message */
16545 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16547 if (unformat (input, "enable"))
16552 else if (unformat (input, "disable"))
16562 errmsg ("Value not set");
16566 /* Construct the API message */
16567 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
16574 /* Wait for a reply... */
16580 api_one_show_xtr_mode (vat_main_t * vam)
16582 vl_api_one_show_xtr_mode_t *mp;
16585 /* Construct the API message */
16586 M (ONE_SHOW_XTR_MODE, mp);
16591 /* Wait for a reply... */
16597 api_one_enable_disable_pitr_mode (vat_main_t * vam)
16599 unformat_input_t *input = vam->input;
16600 vl_api_one_enable_disable_pitr_mode_t *mp;
16605 /* Parse args required to build the message */
16606 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16608 if (unformat (input, "enable"))
16613 else if (unformat (input, "disable"))
16623 errmsg ("Value not set");
16627 /* Construct the API message */
16628 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
16635 /* Wait for a reply... */
16641 api_one_show_pitr_mode (vat_main_t * vam)
16643 vl_api_one_show_pitr_mode_t *mp;
16646 /* Construct the API message */
16647 M (ONE_SHOW_PITR_MODE, mp);
16652 /* Wait for a reply... */
16658 api_one_enable_disable_petr_mode (vat_main_t * vam)
16660 unformat_input_t *input = vam->input;
16661 vl_api_one_enable_disable_petr_mode_t *mp;
16666 /* Parse args required to build the message */
16667 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16669 if (unformat (input, "enable"))
16674 else if (unformat (input, "disable"))
16684 errmsg ("Value not set");
16688 /* Construct the API message */
16689 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
16696 /* Wait for a reply... */
16702 api_one_show_petr_mode (vat_main_t * vam)
16704 vl_api_one_show_petr_mode_t *mp;
16707 /* Construct the API message */
16708 M (ONE_SHOW_PETR_MODE, mp);
16713 /* Wait for a reply... */
16719 api_show_one_map_register_state (vat_main_t * vam)
16721 vl_api_show_one_map_register_state_t *mp;
16724 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16729 /* wait for reply */
16734 #define api_show_lisp_map_register_state api_show_one_map_register_state
16737 api_show_one_rloc_probe_state (vat_main_t * vam)
16739 vl_api_show_one_rloc_probe_state_t *mp;
16742 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16747 /* wait for reply */
16752 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16755 api_one_add_del_ndp_entry (vat_main_t * vam)
16757 vl_api_one_add_del_ndp_entry_t *mp;
16758 unformat_input_t *input = vam->input;
16763 u8 mac[6] = { 0, };
16764 u8 ip6[16] = { 0, };
16768 /* Parse args required to build the message */
16769 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16771 if (unformat (input, "del"))
16773 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16775 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16777 else if (unformat (input, "bd %d", &bd))
16781 errmsg ("parse error '%U'", format_unformat_error, input);
16786 if (!bd_set || !ip_set || (!mac_set && is_add))
16788 errmsg ("Missing BD, IP or MAC!");
16792 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16793 mp->is_add = is_add;
16794 clib_memcpy (mp->mac, mac, 6);
16795 mp->bd = clib_host_to_net_u32 (bd);
16796 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16801 /* wait for reply */
16807 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16809 vl_api_one_add_del_l2_arp_entry_t *mp;
16810 unformat_input_t *input = vam->input;
16815 u8 mac[6] = { 0, };
16816 u32 ip4 = 0, bd = ~0;
16819 /* Parse args required to build the message */
16820 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16822 if (unformat (input, "del"))
16824 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16826 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16828 else if (unformat (input, "bd %d", &bd))
16832 errmsg ("parse error '%U'", format_unformat_error, input);
16837 if (!bd_set || !ip_set || (!mac_set && is_add))
16839 errmsg ("Missing BD, IP or MAC!");
16843 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16844 mp->is_add = is_add;
16845 clib_memcpy (mp->mac, mac, 6);
16846 mp->bd = clib_host_to_net_u32 (bd);
16852 /* wait for reply */
16858 api_one_ndp_bd_get (vat_main_t * vam)
16860 vl_api_one_ndp_bd_get_t *mp;
16863 M (ONE_NDP_BD_GET, mp);
16868 /* wait for reply */
16874 api_one_ndp_entries_get (vat_main_t * vam)
16876 vl_api_one_ndp_entries_get_t *mp;
16877 unformat_input_t *input = vam->input;
16882 /* Parse args required to build the message */
16883 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16885 if (unformat (input, "bd %d", &bd))
16889 errmsg ("parse error '%U'", format_unformat_error, input);
16896 errmsg ("Expected bridge domain!");
16900 M (ONE_NDP_ENTRIES_GET, mp);
16901 mp->bd = clib_host_to_net_u32 (bd);
16906 /* wait for reply */
16912 api_one_l2_arp_bd_get (vat_main_t * vam)
16914 vl_api_one_l2_arp_bd_get_t *mp;
16917 M (ONE_L2_ARP_BD_GET, mp);
16922 /* wait for reply */
16928 api_one_l2_arp_entries_get (vat_main_t * vam)
16930 vl_api_one_l2_arp_entries_get_t *mp;
16931 unformat_input_t *input = vam->input;
16936 /* Parse args required to build the message */
16937 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16939 if (unformat (input, "bd %d", &bd))
16943 errmsg ("parse error '%U'", format_unformat_error, input);
16950 errmsg ("Expected bridge domain!");
16954 M (ONE_L2_ARP_ENTRIES_GET, mp);
16955 mp->bd = clib_host_to_net_u32 (bd);
16960 /* wait for reply */
16966 api_one_stats_enable_disable (vat_main_t * vam)
16968 vl_api_one_stats_enable_disable_t *mp;
16969 unformat_input_t *input = vam->input;
16974 /* Parse args required to build the message */
16975 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16977 if (unformat (input, "enable"))
16982 else if (unformat (input, "disable"))
16992 errmsg ("Value not set");
16996 M (ONE_STATS_ENABLE_DISABLE, mp);
17002 /* wait for reply */
17008 api_show_one_stats_enable_disable (vat_main_t * vam)
17010 vl_api_show_one_stats_enable_disable_t *mp;
17013 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
17018 /* wait for reply */
17024 api_show_one_map_request_mode (vat_main_t * vam)
17026 vl_api_show_one_map_request_mode_t *mp;
17029 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
17034 /* wait for reply */
17039 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
17042 api_one_map_request_mode (vat_main_t * vam)
17044 unformat_input_t *input = vam->input;
17045 vl_api_one_map_request_mode_t *mp;
17049 /* Parse args required to build the message */
17050 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17052 if (unformat (input, "dst-only"))
17054 else if (unformat (input, "src-dst"))
17058 errmsg ("parse error '%U'", format_unformat_error, input);
17063 M (ONE_MAP_REQUEST_MODE, mp);
17070 /* wait for reply */
17075 #define api_lisp_map_request_mode api_one_map_request_mode
17078 * Enable/disable ONE proxy ITR.
17080 * @param vam vpp API test context
17081 * @return return code
17084 api_one_pitr_set_locator_set (vat_main_t * vam)
17086 u8 ls_name_set = 0;
17087 unformat_input_t *input = vam->input;
17088 vl_api_one_pitr_set_locator_set_t *mp;
17093 /* Parse args required to build the message */
17094 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17096 if (unformat (input, "del"))
17098 else if (unformat (input, "locator-set %s", &ls_name))
17102 errmsg ("parse error '%U'", format_unformat_error, input);
17109 errmsg ("locator-set name not set!");
17113 M (ONE_PITR_SET_LOCATOR_SET, mp);
17115 mp->is_add = is_add;
17116 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17117 vec_free (ls_name);
17122 /* wait for reply */
17127 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
17130 api_one_nsh_set_locator_set (vat_main_t * vam)
17132 u8 ls_name_set = 0;
17133 unformat_input_t *input = vam->input;
17134 vl_api_one_nsh_set_locator_set_t *mp;
17139 /* Parse args required to build the message */
17140 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17142 if (unformat (input, "del"))
17144 else if (unformat (input, "ls %s", &ls_name))
17148 errmsg ("parse error '%U'", format_unformat_error, input);
17153 if (!ls_name_set && is_add)
17155 errmsg ("locator-set name not set!");
17159 M (ONE_NSH_SET_LOCATOR_SET, mp);
17161 mp->is_add = is_add;
17162 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17163 vec_free (ls_name);
17168 /* wait for reply */
17174 api_show_one_pitr (vat_main_t * vam)
17176 vl_api_show_one_pitr_t *mp;
17179 if (!vam->json_output)
17181 print (vam->ofp, "%=20s", "lisp status:");
17184 M (SHOW_ONE_PITR, mp);
17188 /* Wait for a reply... */
17193 #define api_show_lisp_pitr api_show_one_pitr
17196 api_one_use_petr (vat_main_t * vam)
17198 unformat_input_t *input = vam->input;
17199 vl_api_one_use_petr_t *mp;
17204 memset (&ip, 0, sizeof (ip));
17206 /* Parse args required to build the message */
17207 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17209 if (unformat (input, "disable"))
17212 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
17215 ip_addr_version (&ip) = IP4;
17218 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
17221 ip_addr_version (&ip) = IP6;
17225 errmsg ("parse error '%U'", format_unformat_error, input);
17230 M (ONE_USE_PETR, mp);
17232 mp->is_add = is_add;
17235 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
17237 clib_memcpy (mp->address, &ip, 4);
17239 clib_memcpy (mp->address, &ip, 16);
17245 /* wait for reply */
17250 #define api_lisp_use_petr api_one_use_petr
17253 api_show_one_nsh_mapping (vat_main_t * vam)
17255 vl_api_show_one_use_petr_t *mp;
17258 if (!vam->json_output)
17260 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
17263 M (SHOW_ONE_NSH_MAPPING, mp);
17267 /* Wait for a reply... */
17273 api_show_one_use_petr (vat_main_t * vam)
17275 vl_api_show_one_use_petr_t *mp;
17278 if (!vam->json_output)
17280 print (vam->ofp, "%=20s", "Proxy-ETR status:");
17283 M (SHOW_ONE_USE_PETR, mp);
17287 /* Wait for a reply... */
17292 #define api_show_lisp_use_petr api_show_one_use_petr
17295 * Add/delete mapping between vni and vrf
17298 api_one_eid_table_add_del_map (vat_main_t * vam)
17300 unformat_input_t *input = vam->input;
17301 vl_api_one_eid_table_add_del_map_t *mp;
17302 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
17303 u32 vni, vrf, bd_index;
17306 /* Parse args required to build the message */
17307 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17309 if (unformat (input, "del"))
17311 else if (unformat (input, "vrf %d", &vrf))
17313 else if (unformat (input, "bd_index %d", &bd_index))
17315 else if (unformat (input, "vni %d", &vni))
17321 if (!vni_set || (!vrf_set && !bd_index_set))
17323 errmsg ("missing arguments!");
17327 if (vrf_set && bd_index_set)
17329 errmsg ("error: both vrf and bd entered!");
17333 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
17335 mp->is_add = is_add;
17336 mp->vni = htonl (vni);
17337 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
17338 mp->is_l2 = bd_index_set;
17343 /* wait for reply */
17348 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
17351 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
17353 u32 *action = va_arg (*args, u32 *);
17356 if (unformat (input, "%s", &s))
17358 if (!strcmp ((char *) s, "no-action"))
17360 else if (!strcmp ((char *) s, "natively-forward"))
17362 else if (!strcmp ((char *) s, "send-map-request"))
17364 else if (!strcmp ((char *) s, "drop"))
17368 clib_warning ("invalid action: '%s'", s);
17380 * Add/del remote mapping to/from ONE control plane
17382 * @param vam vpp API test context
17383 * @return return code
17386 api_one_add_del_remote_mapping (vat_main_t * vam)
17388 unformat_input_t *input = vam->input;
17389 vl_api_one_add_del_remote_mapping_t *mp;
17391 lisp_eid_vat_t _eid, *eid = &_eid;
17392 lisp_eid_vat_t _seid, *seid = &_seid;
17393 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
17394 u32 action = ~0, p, w, data_len;
17395 ip4_address_t rloc4;
17396 ip6_address_t rloc6;
17397 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
17400 memset (&rloc, 0, sizeof (rloc));
17402 /* Parse args required to build the message */
17403 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17405 if (unformat (input, "del-all"))
17409 else if (unformat (input, "del"))
17413 else if (unformat (input, "add"))
17417 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17421 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
17425 else if (unformat (input, "vni %d", &vni))
17429 else if (unformat (input, "p %d w %d", &p, &w))
17433 errmsg ("No RLOC configured for setting priority/weight!");
17436 curr_rloc->priority = p;
17437 curr_rloc->weight = w;
17439 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
17442 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
17443 vec_add1 (rlocs, rloc);
17444 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17446 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
17449 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
17450 vec_add1 (rlocs, rloc);
17451 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17453 else if (unformat (input, "action %U",
17454 unformat_negative_mapping_action, &action))
17460 clib_warning ("parse error '%U'", format_unformat_error, input);
17467 errmsg ("missing params!");
17471 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
17473 errmsg ("no action set for negative map-reply!");
17477 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
17479 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
17480 mp->is_add = is_add;
17481 mp->vni = htonl (vni);
17482 mp->action = (u8) action;
17483 mp->is_src_dst = seid_set;
17484 mp->eid_len = eid->len;
17485 mp->seid_len = seid->len;
17486 mp->del_all = del_all;
17487 mp->eid_type = eid->type;
17488 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17489 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
17491 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
17492 clib_memcpy (mp->rlocs, rlocs, data_len);
17498 /* Wait for a reply... */
17503 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
17506 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
17507 * forwarding entries in data-plane accordingly.
17509 * @param vam vpp API test context
17510 * @return return code
17513 api_one_add_del_adjacency (vat_main_t * vam)
17515 unformat_input_t *input = vam->input;
17516 vl_api_one_add_del_adjacency_t *mp;
17518 ip4_address_t leid4, reid4;
17519 ip6_address_t leid6, reid6;
17520 u8 reid_mac[6] = { 0 };
17521 u8 leid_mac[6] = { 0 };
17522 u8 reid_type, leid_type;
17523 u32 leid_len = 0, reid_len = 0, len;
17527 leid_type = reid_type = (u8) ~ 0;
17529 /* Parse args required to build the message */
17530 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17532 if (unformat (input, "del"))
17536 else if (unformat (input, "add"))
17540 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17543 reid_type = 0; /* ipv4 */
17546 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17549 reid_type = 1; /* ipv6 */
17552 else if (unformat (input, "reid %U", unformat_ethernet_address,
17555 reid_type = 2; /* mac */
17557 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17560 leid_type = 0; /* ipv4 */
17563 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17566 leid_type = 1; /* ipv6 */
17569 else if (unformat (input, "leid %U", unformat_ethernet_address,
17572 leid_type = 2; /* mac */
17574 else if (unformat (input, "vni %d", &vni))
17580 errmsg ("parse error '%U'", format_unformat_error, input);
17585 if ((u8) ~ 0 == reid_type)
17587 errmsg ("missing params!");
17591 if (leid_type != reid_type)
17593 errmsg ("remote and local EIDs are of different types!");
17597 M (ONE_ADD_DEL_ADJACENCY, mp);
17598 mp->is_add = is_add;
17599 mp->vni = htonl (vni);
17600 mp->leid_len = leid_len;
17601 mp->reid_len = reid_len;
17602 mp->eid_type = reid_type;
17604 switch (mp->eid_type)
17607 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17608 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17611 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17612 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17615 clib_memcpy (mp->leid, leid_mac, 6);
17616 clib_memcpy (mp->reid, reid_mac, 6);
17619 errmsg ("unknown EID type %d!", mp->eid_type);
17626 /* Wait for a reply... */
17631 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17634 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17636 u32 *mode = va_arg (*args, u32 *);
17638 if (unformat (input, "lisp"))
17640 else if (unformat (input, "vxlan"))
17649 api_gpe_get_encap_mode (vat_main_t * vam)
17651 vl_api_gpe_get_encap_mode_t *mp;
17654 /* Construct the API message */
17655 M (GPE_GET_ENCAP_MODE, mp);
17660 /* Wait for a reply... */
17666 api_gpe_set_encap_mode (vat_main_t * vam)
17668 unformat_input_t *input = vam->input;
17669 vl_api_gpe_set_encap_mode_t *mp;
17673 /* Parse args required to build the message */
17674 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17676 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17682 /* Construct the API message */
17683 M (GPE_SET_ENCAP_MODE, mp);
17690 /* Wait for a reply... */
17696 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17698 unformat_input_t *input = vam->input;
17699 vl_api_gpe_add_del_iface_t *mp;
17700 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17701 u32 dp_table = 0, vni = 0;
17704 /* Parse args required to build the message */
17705 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17707 if (unformat (input, "up"))
17712 else if (unformat (input, "down"))
17717 else if (unformat (input, "table_id %d", &dp_table))
17721 else if (unformat (input, "bd_id %d", &dp_table))
17726 else if (unformat (input, "vni %d", &vni))
17734 if (action_set == 0)
17736 errmsg ("Action not set");
17739 if (dp_table_set == 0 || vni_set == 0)
17741 errmsg ("vni and dp_table must be set");
17745 /* Construct the API message */
17746 M (GPE_ADD_DEL_IFACE, mp);
17748 mp->is_add = is_add;
17749 mp->dp_table = clib_host_to_net_u32 (dp_table);
17751 mp->vni = clib_host_to_net_u32 (vni);
17756 /* Wait for a reply... */
17762 api_one_map_register_fallback_threshold (vat_main_t * vam)
17764 unformat_input_t *input = vam->input;
17765 vl_api_one_map_register_fallback_threshold_t *mp;
17770 /* Parse args required to build the message */
17771 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17773 if (unformat (input, "%u", &value))
17777 clib_warning ("parse error '%U'", format_unformat_error, input);
17784 errmsg ("fallback threshold value is missing!");
17788 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17789 mp->value = clib_host_to_net_u32 (value);
17794 /* Wait for a reply... */
17800 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17802 vl_api_show_one_map_register_fallback_threshold_t *mp;
17805 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17810 /* Wait for a reply... */
17816 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17818 u32 *proto = va_arg (*args, u32 *);
17820 if (unformat (input, "udp"))
17822 else if (unformat (input, "api"))
17831 api_one_set_transport_protocol (vat_main_t * vam)
17833 unformat_input_t *input = vam->input;
17834 vl_api_one_set_transport_protocol_t *mp;
17839 /* Parse args required to build the message */
17840 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17842 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17846 clib_warning ("parse error '%U'", format_unformat_error, input);
17853 errmsg ("Transport protocol missing!");
17857 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17858 mp->protocol = (u8) protocol;
17863 /* Wait for a reply... */
17869 api_one_get_transport_protocol (vat_main_t * vam)
17871 vl_api_one_get_transport_protocol_t *mp;
17874 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17879 /* Wait for a reply... */
17885 api_one_map_register_set_ttl (vat_main_t * vam)
17887 unformat_input_t *input = vam->input;
17888 vl_api_one_map_register_set_ttl_t *mp;
17893 /* Parse args required to build the message */
17894 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17896 if (unformat (input, "%u", &ttl))
17900 clib_warning ("parse error '%U'", format_unformat_error, input);
17907 errmsg ("TTL value missing!");
17911 M (ONE_MAP_REGISTER_SET_TTL, mp);
17912 mp->ttl = clib_host_to_net_u32 (ttl);
17917 /* Wait for a reply... */
17923 api_show_one_map_register_ttl (vat_main_t * vam)
17925 vl_api_show_one_map_register_ttl_t *mp;
17928 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17933 /* Wait for a reply... */
17939 * Add/del map request itr rlocs from ONE control plane and updates
17941 * @param vam vpp API test context
17942 * @return return code
17945 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17947 unformat_input_t *input = vam->input;
17948 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17949 u8 *locator_set_name = 0;
17950 u8 locator_set_name_set = 0;
17954 /* Parse args required to build the message */
17955 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17957 if (unformat (input, "del"))
17961 else if (unformat (input, "%_%v%_", &locator_set_name))
17963 locator_set_name_set = 1;
17967 clib_warning ("parse error '%U'", format_unformat_error, input);
17972 if (is_add && !locator_set_name_set)
17974 errmsg ("itr-rloc is not set!");
17978 if (is_add && vec_len (locator_set_name) > 64)
17980 errmsg ("itr-rloc locator-set name too long");
17981 vec_free (locator_set_name);
17985 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17986 mp->is_add = is_add;
17989 clib_memcpy (mp->locator_set_name, locator_set_name,
17990 vec_len (locator_set_name));
17994 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17996 vec_free (locator_set_name);
18001 /* Wait for a reply... */
18006 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
18009 api_one_locator_dump (vat_main_t * vam)
18011 unformat_input_t *input = vam->input;
18012 vl_api_one_locator_dump_t *mp;
18013 vl_api_control_ping_t *mp_ping;
18014 u8 is_index_set = 0, is_name_set = 0;
18019 /* Parse args required to build the message */
18020 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18022 if (unformat (input, "ls_name %_%v%_", &ls_name))
18026 else if (unformat (input, "ls_index %d", &ls_index))
18032 errmsg ("parse error '%U'", format_unformat_error, input);
18037 if (!is_index_set && !is_name_set)
18039 errmsg ("error: expected one of index or name!");
18043 if (is_index_set && is_name_set)
18045 errmsg ("error: only one param expected!");
18049 if (vec_len (ls_name) > 62)
18051 errmsg ("error: locator set name too long!");
18055 if (!vam->json_output)
18057 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
18060 M (ONE_LOCATOR_DUMP, mp);
18061 mp->is_index_set = is_index_set;
18064 mp->ls_index = clib_host_to_net_u32 (ls_index);
18067 vec_add1 (ls_name, 0);
18068 strncpy ((char *) mp->ls_name, (char *) ls_name,
18069 sizeof (mp->ls_name) - 1);
18075 /* Use a control ping for synchronization */
18076 MPING (CONTROL_PING, mp_ping);
18079 /* Wait for a reply... */
18084 #define api_lisp_locator_dump api_one_locator_dump
18087 api_one_locator_set_dump (vat_main_t * vam)
18089 vl_api_one_locator_set_dump_t *mp;
18090 vl_api_control_ping_t *mp_ping;
18091 unformat_input_t *input = vam->input;
18095 /* Parse args required to build the message */
18096 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18098 if (unformat (input, "local"))
18102 else if (unformat (input, "remote"))
18108 errmsg ("parse error '%U'", format_unformat_error, input);
18113 if (!vam->json_output)
18115 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
18118 M (ONE_LOCATOR_SET_DUMP, mp);
18120 mp->filter = filter;
18125 /* Use a control ping for synchronization */
18126 MPING (CONTROL_PING, mp_ping);
18129 /* Wait for a reply... */
18134 #define api_lisp_locator_set_dump api_one_locator_set_dump
18137 api_one_eid_table_map_dump (vat_main_t * vam)
18141 unformat_input_t *input = vam->input;
18142 vl_api_one_eid_table_map_dump_t *mp;
18143 vl_api_control_ping_t *mp_ping;
18146 /* Parse args required to build the message */
18147 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18149 if (unformat (input, "l2"))
18154 else if (unformat (input, "l3"))
18161 errmsg ("parse error '%U'", format_unformat_error, input);
18168 errmsg ("expected one of 'l2' or 'l3' parameter!");
18172 if (!vam->json_output)
18174 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
18177 M (ONE_EID_TABLE_MAP_DUMP, mp);
18183 /* Use a control ping for synchronization */
18184 MPING (CONTROL_PING, mp_ping);
18187 /* Wait for a reply... */
18192 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
18195 api_one_eid_table_vni_dump (vat_main_t * vam)
18197 vl_api_one_eid_table_vni_dump_t *mp;
18198 vl_api_control_ping_t *mp_ping;
18201 if (!vam->json_output)
18203 print (vam->ofp, "VNI");
18206 M (ONE_EID_TABLE_VNI_DUMP, mp);
18211 /* Use a control ping for synchronization */
18212 MPING (CONTROL_PING, mp_ping);
18215 /* Wait for a reply... */
18220 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
18223 api_one_eid_table_dump (vat_main_t * vam)
18225 unformat_input_t *i = vam->input;
18226 vl_api_one_eid_table_dump_t *mp;
18227 vl_api_control_ping_t *mp_ping;
18228 struct in_addr ip4;
18229 struct in6_addr ip6;
18231 u8 eid_type = ~0, eid_set = 0;
18232 u32 prefix_length = ~0, t, vni = 0;
18235 lisp_nsh_api_t nsh;
18237 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18239 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
18245 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
18251 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
18256 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
18261 else if (unformat (i, "vni %d", &t))
18265 else if (unformat (i, "local"))
18269 else if (unformat (i, "remote"))
18275 errmsg ("parse error '%U'", format_unformat_error, i);
18280 if (!vam->json_output)
18282 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
18283 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
18286 M (ONE_EID_TABLE_DUMP, mp);
18288 mp->filter = filter;
18292 mp->vni = htonl (vni);
18293 mp->eid_type = eid_type;
18297 mp->prefix_length = prefix_length;
18298 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
18301 mp->prefix_length = prefix_length;
18302 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
18305 clib_memcpy (mp->eid, mac, sizeof (mac));
18308 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
18311 errmsg ("unknown EID type %d!", eid_type);
18319 /* Use a control ping for synchronization */
18320 MPING (CONTROL_PING, mp_ping);
18323 /* Wait for a reply... */
18328 #define api_lisp_eid_table_dump api_one_eid_table_dump
18331 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
18333 unformat_input_t *i = vam->input;
18334 vl_api_gpe_fwd_entries_get_t *mp;
18339 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18341 if (unformat (i, "vni %d", &vni))
18347 errmsg ("parse error '%U'", format_unformat_error, i);
18354 errmsg ("vni not set!");
18358 if (!vam->json_output)
18360 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
18364 M (GPE_FWD_ENTRIES_GET, mp);
18365 mp->vni = clib_host_to_net_u32 (vni);
18370 /* Wait for a reply... */
18375 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
18376 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
18377 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
18378 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
18379 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
18380 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
18381 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
18382 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
18385 api_one_adjacencies_get (vat_main_t * vam)
18387 unformat_input_t *i = vam->input;
18388 vl_api_one_adjacencies_get_t *mp;
18393 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18395 if (unformat (i, "vni %d", &vni))
18401 errmsg ("parse error '%U'", format_unformat_error, i);
18408 errmsg ("vni not set!");
18412 if (!vam->json_output)
18414 print (vam->ofp, "%s %40s", "leid", "reid");
18417 M (ONE_ADJACENCIES_GET, mp);
18418 mp->vni = clib_host_to_net_u32 (vni);
18423 /* Wait for a reply... */
18428 #define api_lisp_adjacencies_get api_one_adjacencies_get
18431 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
18433 unformat_input_t *i = vam->input;
18434 vl_api_gpe_native_fwd_rpaths_get_t *mp;
18436 u8 ip_family_set = 0, is_ip4 = 1;
18438 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18440 if (unformat (i, "ip4"))
18445 else if (unformat (i, "ip6"))
18452 errmsg ("parse error '%U'", format_unformat_error, i);
18457 if (!ip_family_set)
18459 errmsg ("ip family not set!");
18463 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
18464 mp->is_ip4 = is_ip4;
18469 /* Wait for a reply... */
18475 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
18477 vl_api_gpe_fwd_entry_vnis_get_t *mp;
18480 if (!vam->json_output)
18482 print (vam->ofp, "VNIs");
18485 M (GPE_FWD_ENTRY_VNIS_GET, mp);
18490 /* Wait for a reply... */
18496 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
18498 unformat_input_t *i = vam->input;
18499 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
18501 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
18502 struct in_addr ip4;
18503 struct in6_addr ip6;
18504 u32 table_id = 0, nh_sw_if_index = ~0;
18506 memset (&ip4, 0, sizeof (ip4));
18507 memset (&ip6, 0, sizeof (ip6));
18509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18511 if (unformat (i, "del"))
18513 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
18514 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18519 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
18520 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18525 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18529 nh_sw_if_index = ~0;
18531 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18535 nh_sw_if_index = ~0;
18537 else if (unformat (i, "table %d", &table_id))
18541 errmsg ("parse error '%U'", format_unformat_error, i);
18548 errmsg ("nh addr not set!");
18552 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18553 mp->is_add = is_add;
18554 mp->table_id = clib_host_to_net_u32 (table_id);
18555 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18556 mp->is_ip4 = is_ip4;
18558 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18560 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18565 /* Wait for a reply... */
18571 api_one_map_server_dump (vat_main_t * vam)
18573 vl_api_one_map_server_dump_t *mp;
18574 vl_api_control_ping_t *mp_ping;
18577 if (!vam->json_output)
18579 print (vam->ofp, "%=20s", "Map server");
18582 M (ONE_MAP_SERVER_DUMP, mp);
18586 /* Use a control ping for synchronization */
18587 MPING (CONTROL_PING, mp_ping);
18590 /* Wait for a reply... */
18595 #define api_lisp_map_server_dump api_one_map_server_dump
18598 api_one_map_resolver_dump (vat_main_t * vam)
18600 vl_api_one_map_resolver_dump_t *mp;
18601 vl_api_control_ping_t *mp_ping;
18604 if (!vam->json_output)
18606 print (vam->ofp, "%=20s", "Map resolver");
18609 M (ONE_MAP_RESOLVER_DUMP, mp);
18613 /* Use a control ping for synchronization */
18614 MPING (CONTROL_PING, mp_ping);
18617 /* Wait for a reply... */
18622 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18625 api_one_stats_flush (vat_main_t * vam)
18627 vl_api_one_stats_flush_t *mp;
18630 M (ONE_STATS_FLUSH, mp);
18637 api_one_stats_dump (vat_main_t * vam)
18639 vl_api_one_stats_dump_t *mp;
18640 vl_api_control_ping_t *mp_ping;
18643 M (ONE_STATS_DUMP, mp);
18647 /* Use a control ping for synchronization */
18648 MPING (CONTROL_PING, mp_ping);
18651 /* Wait for a reply... */
18657 api_show_one_status (vat_main_t * vam)
18659 vl_api_show_one_status_t *mp;
18662 if (!vam->json_output)
18664 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18667 M (SHOW_ONE_STATUS, mp);
18670 /* Wait for a reply... */
18675 #define api_show_lisp_status api_show_one_status
18678 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18680 vl_api_gpe_fwd_entry_path_dump_t *mp;
18681 vl_api_control_ping_t *mp_ping;
18682 unformat_input_t *i = vam->input;
18683 u32 fwd_entry_index = ~0;
18686 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18688 if (unformat (i, "index %d", &fwd_entry_index))
18694 if (~0 == fwd_entry_index)
18696 errmsg ("no index specified!");
18700 if (!vam->json_output)
18702 print (vam->ofp, "first line");
18705 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18709 /* Use a control ping for synchronization */
18710 MPING (CONTROL_PING, mp_ping);
18713 /* Wait for a reply... */
18719 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18721 vl_api_one_get_map_request_itr_rlocs_t *mp;
18724 if (!vam->json_output)
18726 print (vam->ofp, "%=20s", "itr-rlocs:");
18729 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18732 /* Wait for a reply... */
18737 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18740 api_af_packet_create (vat_main_t * vam)
18742 unformat_input_t *i = vam->input;
18743 vl_api_af_packet_create_t *mp;
18744 u8 *host_if_name = 0;
18746 u8 random_hw_addr = 1;
18749 memset (hw_addr, 0, sizeof (hw_addr));
18751 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18753 if (unformat (i, "name %s", &host_if_name))
18754 vec_add1 (host_if_name, 0);
18755 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18756 random_hw_addr = 0;
18761 if (!vec_len (host_if_name))
18763 errmsg ("host-interface name must be specified");
18767 if (vec_len (host_if_name) > 64)
18769 errmsg ("host-interface name too long");
18773 M (AF_PACKET_CREATE, mp);
18775 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18776 clib_memcpy (mp->hw_addr, hw_addr, 6);
18777 mp->use_random_hw_addr = random_hw_addr;
18778 vec_free (host_if_name);
18786 fprintf (vam->ofp ? vam->ofp : stderr,
18787 " new sw_if_index = %d\n", vam->sw_if_index);
18794 api_af_packet_delete (vat_main_t * vam)
18796 unformat_input_t *i = vam->input;
18797 vl_api_af_packet_delete_t *mp;
18798 u8 *host_if_name = 0;
18801 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18803 if (unformat (i, "name %s", &host_if_name))
18804 vec_add1 (host_if_name, 0);
18809 if (!vec_len (host_if_name))
18811 errmsg ("host-interface name must be specified");
18815 if (vec_len (host_if_name) > 64)
18817 errmsg ("host-interface name too long");
18821 M (AF_PACKET_DELETE, mp);
18823 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18824 vec_free (host_if_name);
18832 api_policer_add_del (vat_main_t * vam)
18834 unformat_input_t *i = vam->input;
18835 vl_api_policer_add_del_t *mp;
18845 u8 color_aware = 0;
18846 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18849 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18850 conform_action.dscp = 0;
18851 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18852 exceed_action.dscp = 0;
18853 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18854 violate_action.dscp = 0;
18856 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18858 if (unformat (i, "del"))
18860 else if (unformat (i, "name %s", &name))
18861 vec_add1 (name, 0);
18862 else if (unformat (i, "cir %u", &cir))
18864 else if (unformat (i, "eir %u", &eir))
18866 else if (unformat (i, "cb %u", &cb))
18868 else if (unformat (i, "eb %u", &eb))
18870 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18873 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18876 else if (unformat (i, "type %U", unformat_policer_type, &type))
18878 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18881 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18884 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18887 else if (unformat (i, "color-aware"))
18893 if (!vec_len (name))
18895 errmsg ("policer name must be specified");
18899 if (vec_len (name) > 64)
18901 errmsg ("policer name too long");
18905 M (POLICER_ADD_DEL, mp);
18907 clib_memcpy (mp->name, name, vec_len (name));
18909 mp->is_add = is_add;
18910 mp->cir = ntohl (cir);
18911 mp->eir = ntohl (eir);
18912 mp->cb = clib_net_to_host_u64 (cb);
18913 mp->eb = clib_net_to_host_u64 (eb);
18914 mp->rate_type = rate_type;
18915 mp->round_type = round_type;
18917 mp->conform_action_type = conform_action.action_type;
18918 mp->conform_dscp = conform_action.dscp;
18919 mp->exceed_action_type = exceed_action.action_type;
18920 mp->exceed_dscp = exceed_action.dscp;
18921 mp->violate_action_type = violate_action.action_type;
18922 mp->violate_dscp = violate_action.dscp;
18923 mp->color_aware = color_aware;
18931 api_policer_dump (vat_main_t * vam)
18933 unformat_input_t *i = vam->input;
18934 vl_api_policer_dump_t *mp;
18935 vl_api_control_ping_t *mp_ping;
18936 u8 *match_name = 0;
18937 u8 match_name_valid = 0;
18940 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18942 if (unformat (i, "name %s", &match_name))
18944 vec_add1 (match_name, 0);
18945 match_name_valid = 1;
18951 M (POLICER_DUMP, mp);
18952 mp->match_name_valid = match_name_valid;
18953 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18954 vec_free (match_name);
18958 /* Use a control ping for synchronization */
18959 MPING (CONTROL_PING, mp_ping);
18962 /* Wait for a reply... */
18968 api_policer_classify_set_interface (vat_main_t * vam)
18970 unformat_input_t *i = vam->input;
18971 vl_api_policer_classify_set_interface_t *mp;
18973 int sw_if_index_set;
18974 u32 ip4_table_index = ~0;
18975 u32 ip6_table_index = ~0;
18976 u32 l2_table_index = ~0;
18980 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18982 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18983 sw_if_index_set = 1;
18984 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18985 sw_if_index_set = 1;
18986 else if (unformat (i, "del"))
18988 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18990 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18992 else if (unformat (i, "l2-table %d", &l2_table_index))
18996 clib_warning ("parse error '%U'", format_unformat_error, i);
19001 if (sw_if_index_set == 0)
19003 errmsg ("missing interface name or sw_if_index");
19007 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
19009 mp->sw_if_index = ntohl (sw_if_index);
19010 mp->ip4_table_index = ntohl (ip4_table_index);
19011 mp->ip6_table_index = ntohl (ip6_table_index);
19012 mp->l2_table_index = ntohl (l2_table_index);
19013 mp->is_add = is_add;
19021 api_policer_classify_dump (vat_main_t * vam)
19023 unformat_input_t *i = vam->input;
19024 vl_api_policer_classify_dump_t *mp;
19025 vl_api_control_ping_t *mp_ping;
19026 u8 type = POLICER_CLASSIFY_N_TABLES;
19029 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
19033 errmsg ("classify table type must be specified");
19037 if (!vam->json_output)
19039 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19042 M (POLICER_CLASSIFY_DUMP, mp);
19047 /* Use a control ping for synchronization */
19048 MPING (CONTROL_PING, mp_ping);
19051 /* Wait for a reply... */
19057 api_netmap_create (vat_main_t * vam)
19059 unformat_input_t *i = vam->input;
19060 vl_api_netmap_create_t *mp;
19063 u8 random_hw_addr = 1;
19068 memset (hw_addr, 0, sizeof (hw_addr));
19070 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19072 if (unformat (i, "name %s", &if_name))
19073 vec_add1 (if_name, 0);
19074 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19075 random_hw_addr = 0;
19076 else if (unformat (i, "pipe"))
19078 else if (unformat (i, "master"))
19080 else if (unformat (i, "slave"))
19086 if (!vec_len (if_name))
19088 errmsg ("interface name must be specified");
19092 if (vec_len (if_name) > 64)
19094 errmsg ("interface name too long");
19098 M (NETMAP_CREATE, mp);
19100 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19101 clib_memcpy (mp->hw_addr, hw_addr, 6);
19102 mp->use_random_hw_addr = random_hw_addr;
19103 mp->is_pipe = is_pipe;
19104 mp->is_master = is_master;
19105 vec_free (if_name);
19113 api_netmap_delete (vat_main_t * vam)
19115 unformat_input_t *i = vam->input;
19116 vl_api_netmap_delete_t *mp;
19120 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19122 if (unformat (i, "name %s", &if_name))
19123 vec_add1 (if_name, 0);
19128 if (!vec_len (if_name))
19130 errmsg ("interface name must be specified");
19134 if (vec_len (if_name) > 64)
19136 errmsg ("interface name too long");
19140 M (NETMAP_DELETE, mp);
19142 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19143 vec_free (if_name);
19151 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
19153 if (fp->afi == IP46_TYPE_IP6)
19155 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19156 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19157 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19158 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19159 format_ip6_address, fp->next_hop);
19160 else if (fp->afi == IP46_TYPE_IP4)
19162 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19163 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19164 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19165 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19166 format_ip4_address, fp->next_hop);
19170 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
19171 vl_api_fib_path2_t * fp)
19173 struct in_addr ip4;
19174 struct in6_addr ip6;
19176 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19177 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19178 vat_json_object_add_uint (node, "is_local", fp->is_local);
19179 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19180 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19181 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19182 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19183 if (fp->afi == IP46_TYPE_IP4)
19185 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19186 vat_json_object_add_ip4 (node, "next_hop", ip4);
19188 else if (fp->afi == IP46_TYPE_IP6)
19190 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19191 vat_json_object_add_ip6 (node, "next_hop", ip6);
19196 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
19198 vat_main_t *vam = &vat_main;
19199 int count = ntohl (mp->mt_count);
19200 vl_api_fib_path2_t *fp;
19203 print (vam->ofp, "[%d]: sw_if_index %d via:",
19204 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
19206 for (i = 0; i < count; i++)
19208 vl_api_mpls_fib_path_print (vam, fp);
19212 print (vam->ofp, "");
19215 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
19216 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
19219 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
19221 vat_main_t *vam = &vat_main;
19222 vat_json_node_t *node = NULL;
19223 int count = ntohl (mp->mt_count);
19224 vl_api_fib_path2_t *fp;
19227 if (VAT_JSON_ARRAY != vam->json_tree.type)
19229 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19230 vat_json_init_array (&vam->json_tree);
19232 node = vat_json_array_add (&vam->json_tree);
19234 vat_json_init_object (node);
19235 vat_json_object_add_uint (node, "tunnel_index",
19236 ntohl (mp->mt_tunnel_index));
19237 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
19239 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
19242 for (i = 0; i < count; i++)
19244 vl_api_mpls_fib_path_json_print (node, fp);
19250 api_mpls_tunnel_dump (vat_main_t * vam)
19252 vl_api_mpls_tunnel_dump_t *mp;
19253 vl_api_control_ping_t *mp_ping;
19257 /* Parse args required to build the message */
19258 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
19260 if (!unformat (vam->input, "tunnel_index %d", &index))
19267 print (vam->ofp, " tunnel_index %d", index);
19269 M (MPLS_TUNNEL_DUMP, mp);
19270 mp->tunnel_index = htonl (index);
19273 /* Use a control ping for synchronization */
19274 MPING (CONTROL_PING, mp_ping);
19281 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
19282 #define vl_api_mpls_fib_details_t_print vl_noop_handler
19286 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
19288 vat_main_t *vam = &vat_main;
19289 int count = ntohl (mp->count);
19290 vl_api_fib_path2_t *fp;
19294 "table-id %d, label %u, ess_bit %u",
19295 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
19297 for (i = 0; i < count; i++)
19299 vl_api_mpls_fib_path_print (vam, fp);
19304 static void vl_api_mpls_fib_details_t_handler_json
19305 (vl_api_mpls_fib_details_t * mp)
19307 vat_main_t *vam = &vat_main;
19308 int count = ntohl (mp->count);
19309 vat_json_node_t *node = NULL;
19310 vl_api_fib_path2_t *fp;
19313 if (VAT_JSON_ARRAY != vam->json_tree.type)
19315 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19316 vat_json_init_array (&vam->json_tree);
19318 node = vat_json_array_add (&vam->json_tree);
19320 vat_json_init_object (node);
19321 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19322 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
19323 vat_json_object_add_uint (node, "label", ntohl (mp->label));
19324 vat_json_object_add_uint (node, "path_count", count);
19326 for (i = 0; i < count; i++)
19328 vl_api_mpls_fib_path_json_print (node, fp);
19334 api_mpls_fib_dump (vat_main_t * vam)
19336 vl_api_mpls_fib_dump_t *mp;
19337 vl_api_control_ping_t *mp_ping;
19340 M (MPLS_FIB_DUMP, mp);
19343 /* Use a control ping for synchronization */
19344 MPING (CONTROL_PING, mp_ping);
19351 #define vl_api_ip_fib_details_t_endian vl_noop_handler
19352 #define vl_api_ip_fib_details_t_print vl_noop_handler
19355 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
19357 vat_main_t *vam = &vat_main;
19358 int count = ntohl (mp->count);
19359 vl_api_fib_path_t *fp;
19363 "table-id %d, prefix %U/%d",
19364 ntohl (mp->table_id), format_ip4_address, mp->address,
19365 mp->address_length);
19367 for (i = 0; i < count; i++)
19369 if (fp->afi == IP46_TYPE_IP6)
19371 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19372 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19373 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19374 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19375 format_ip6_address, fp->next_hop);
19376 else if (fp->afi == IP46_TYPE_IP4)
19378 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19379 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19380 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19381 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19382 format_ip4_address, fp->next_hop);
19387 static void vl_api_ip_fib_details_t_handler_json
19388 (vl_api_ip_fib_details_t * mp)
19390 vat_main_t *vam = &vat_main;
19391 int count = ntohl (mp->count);
19392 vat_json_node_t *node = NULL;
19393 struct in_addr ip4;
19394 struct in6_addr ip6;
19395 vl_api_fib_path_t *fp;
19398 if (VAT_JSON_ARRAY != vam->json_tree.type)
19400 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19401 vat_json_init_array (&vam->json_tree);
19403 node = vat_json_array_add (&vam->json_tree);
19405 vat_json_init_object (node);
19406 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19407 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
19408 vat_json_object_add_ip4 (node, "prefix", ip4);
19409 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19410 vat_json_object_add_uint (node, "path_count", count);
19412 for (i = 0; i < count; i++)
19414 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19415 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19416 vat_json_object_add_uint (node, "is_local", fp->is_local);
19417 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19418 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19419 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19420 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19421 if (fp->afi == IP46_TYPE_IP4)
19423 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19424 vat_json_object_add_ip4 (node, "next_hop", ip4);
19426 else if (fp->afi == IP46_TYPE_IP6)
19428 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19429 vat_json_object_add_ip6 (node, "next_hop", ip6);
19435 api_ip_fib_dump (vat_main_t * vam)
19437 vl_api_ip_fib_dump_t *mp;
19438 vl_api_control_ping_t *mp_ping;
19441 M (IP_FIB_DUMP, mp);
19444 /* Use a control ping for synchronization */
19445 MPING (CONTROL_PING, mp_ping);
19453 api_ip_mfib_dump (vat_main_t * vam)
19455 vl_api_ip_mfib_dump_t *mp;
19456 vl_api_control_ping_t *mp_ping;
19459 M (IP_MFIB_DUMP, mp);
19462 /* Use a control ping for synchronization */
19463 MPING (CONTROL_PING, mp_ping);
19470 static void vl_api_ip_neighbor_details_t_handler
19471 (vl_api_ip_neighbor_details_t * mp)
19473 vat_main_t *vam = &vat_main;
19475 print (vam->ofp, "%c %U %U",
19476 (mp->is_static) ? 'S' : 'D',
19477 format_ethernet_address, &mp->mac_address,
19478 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
19482 static void vl_api_ip_neighbor_details_t_handler_json
19483 (vl_api_ip_neighbor_details_t * mp)
19486 vat_main_t *vam = &vat_main;
19487 vat_json_node_t *node;
19488 struct in_addr ip4;
19489 struct in6_addr ip6;
19491 if (VAT_JSON_ARRAY != vam->json_tree.type)
19493 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19494 vat_json_init_array (&vam->json_tree);
19496 node = vat_json_array_add (&vam->json_tree);
19498 vat_json_init_object (node);
19499 vat_json_object_add_string_copy (node, "flag",
19500 (mp->is_static) ? (u8 *) "static" : (u8 *)
19503 vat_json_object_add_string_copy (node, "link_layer",
19504 format (0, "%U", format_ethernet_address,
19505 &mp->mac_address));
19509 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
19510 vat_json_object_add_ip6 (node, "ip_address", ip6);
19514 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
19515 vat_json_object_add_ip4 (node, "ip_address", ip4);
19520 api_ip_neighbor_dump (vat_main_t * vam)
19522 unformat_input_t *i = vam->input;
19523 vl_api_ip_neighbor_dump_t *mp;
19524 vl_api_control_ping_t *mp_ping;
19526 u32 sw_if_index = ~0;
19529 /* Parse args required to build the message */
19530 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19532 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19534 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19536 else if (unformat (i, "ip6"))
19542 if (sw_if_index == ~0)
19544 errmsg ("missing interface name or sw_if_index");
19548 M (IP_NEIGHBOR_DUMP, mp);
19549 mp->is_ipv6 = (u8) is_ipv6;
19550 mp->sw_if_index = ntohl (sw_if_index);
19553 /* Use a control ping for synchronization */
19554 MPING (CONTROL_PING, mp_ping);
19561 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
19562 #define vl_api_ip6_fib_details_t_print vl_noop_handler
19565 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
19567 vat_main_t *vam = &vat_main;
19568 int count = ntohl (mp->count);
19569 vl_api_fib_path_t *fp;
19573 "table-id %d, prefix %U/%d",
19574 ntohl (mp->table_id), format_ip6_address, mp->address,
19575 mp->address_length);
19577 for (i = 0; i < count; i++)
19579 if (fp->afi == IP46_TYPE_IP6)
19581 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19582 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19583 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19584 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19585 format_ip6_address, fp->next_hop);
19586 else if (fp->afi == IP46_TYPE_IP4)
19588 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19589 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19590 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19591 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19592 format_ip4_address, fp->next_hop);
19597 static void vl_api_ip6_fib_details_t_handler_json
19598 (vl_api_ip6_fib_details_t * mp)
19600 vat_main_t *vam = &vat_main;
19601 int count = ntohl (mp->count);
19602 vat_json_node_t *node = NULL;
19603 struct in_addr ip4;
19604 struct in6_addr ip6;
19605 vl_api_fib_path_t *fp;
19608 if (VAT_JSON_ARRAY != vam->json_tree.type)
19610 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19611 vat_json_init_array (&vam->json_tree);
19613 node = vat_json_array_add (&vam->json_tree);
19615 vat_json_init_object (node);
19616 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19617 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
19618 vat_json_object_add_ip6 (node, "prefix", ip6);
19619 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19620 vat_json_object_add_uint (node, "path_count", count);
19622 for (i = 0; i < count; i++)
19624 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19625 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19626 vat_json_object_add_uint (node, "is_local", fp->is_local);
19627 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19628 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19629 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19630 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19631 if (fp->afi == IP46_TYPE_IP4)
19633 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19634 vat_json_object_add_ip4 (node, "next_hop", ip4);
19636 else if (fp->afi == IP46_TYPE_IP6)
19638 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19639 vat_json_object_add_ip6 (node, "next_hop", ip6);
19645 api_ip6_fib_dump (vat_main_t * vam)
19647 vl_api_ip6_fib_dump_t *mp;
19648 vl_api_control_ping_t *mp_ping;
19651 M (IP6_FIB_DUMP, mp);
19654 /* Use a control ping for synchronization */
19655 MPING (CONTROL_PING, mp_ping);
19663 api_ip6_mfib_dump (vat_main_t * vam)
19665 vl_api_ip6_mfib_dump_t *mp;
19666 vl_api_control_ping_t *mp_ping;
19669 M (IP6_MFIB_DUMP, mp);
19672 /* Use a control ping for synchronization */
19673 MPING (CONTROL_PING, mp_ping);
19681 api_classify_table_ids (vat_main_t * vam)
19683 vl_api_classify_table_ids_t *mp;
19686 /* Construct the API message */
19687 M (CLASSIFY_TABLE_IDS, mp);
19696 api_classify_table_by_interface (vat_main_t * vam)
19698 unformat_input_t *input = vam->input;
19699 vl_api_classify_table_by_interface_t *mp;
19701 u32 sw_if_index = ~0;
19703 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19705 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19707 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19712 if (sw_if_index == ~0)
19714 errmsg ("missing interface name or sw_if_index");
19718 /* Construct the API message */
19719 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19721 mp->sw_if_index = ntohl (sw_if_index);
19729 api_classify_table_info (vat_main_t * vam)
19731 unformat_input_t *input = vam->input;
19732 vl_api_classify_table_info_t *mp;
19736 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19738 if (unformat (input, "table_id %d", &table_id))
19743 if (table_id == ~0)
19745 errmsg ("missing table id");
19749 /* Construct the API message */
19750 M (CLASSIFY_TABLE_INFO, mp);
19752 mp->table_id = ntohl (table_id);
19760 api_classify_session_dump (vat_main_t * vam)
19762 unformat_input_t *input = vam->input;
19763 vl_api_classify_session_dump_t *mp;
19764 vl_api_control_ping_t *mp_ping;
19768 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19770 if (unformat (input, "table_id %d", &table_id))
19775 if (table_id == ~0)
19777 errmsg ("missing table id");
19781 /* Construct the API message */
19782 M (CLASSIFY_SESSION_DUMP, mp);
19784 mp->table_id = ntohl (table_id);
19787 /* Use a control ping for synchronization */
19788 MPING (CONTROL_PING, mp_ping);
19796 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19798 vat_main_t *vam = &vat_main;
19800 print (vam->ofp, "collector_address %U, collector_port %d, "
19801 "src_address %U, vrf_id %d, path_mtu %u, "
19802 "template_interval %u, udp_checksum %d",
19803 format_ip4_address, mp->collector_address,
19804 ntohs (mp->collector_port),
19805 format_ip4_address, mp->src_address,
19806 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19807 ntohl (mp->template_interval), mp->udp_checksum);
19810 vam->result_ready = 1;
19814 vl_api_ipfix_exporter_details_t_handler_json
19815 (vl_api_ipfix_exporter_details_t * mp)
19817 vat_main_t *vam = &vat_main;
19818 vat_json_node_t node;
19819 struct in_addr collector_address;
19820 struct in_addr src_address;
19822 vat_json_init_object (&node);
19823 clib_memcpy (&collector_address, &mp->collector_address,
19824 sizeof (collector_address));
19825 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19826 vat_json_object_add_uint (&node, "collector_port",
19827 ntohs (mp->collector_port));
19828 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19829 vat_json_object_add_ip4 (&node, "src_address", src_address);
19830 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19831 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19832 vat_json_object_add_uint (&node, "template_interval",
19833 ntohl (mp->template_interval));
19834 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19836 vat_json_print (vam->ofp, &node);
19837 vat_json_free (&node);
19839 vam->result_ready = 1;
19843 api_ipfix_exporter_dump (vat_main_t * vam)
19845 vl_api_ipfix_exporter_dump_t *mp;
19848 /* Construct the API message */
19849 M (IPFIX_EXPORTER_DUMP, mp);
19858 api_ipfix_classify_stream_dump (vat_main_t * vam)
19860 vl_api_ipfix_classify_stream_dump_t *mp;
19863 /* Construct the API message */
19864 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19875 vl_api_ipfix_classify_stream_details_t_handler
19876 (vl_api_ipfix_classify_stream_details_t * mp)
19878 vat_main_t *vam = &vat_main;
19879 print (vam->ofp, "domain_id %d, src_port %d",
19880 ntohl (mp->domain_id), ntohs (mp->src_port));
19882 vam->result_ready = 1;
19886 vl_api_ipfix_classify_stream_details_t_handler_json
19887 (vl_api_ipfix_classify_stream_details_t * mp)
19889 vat_main_t *vam = &vat_main;
19890 vat_json_node_t node;
19892 vat_json_init_object (&node);
19893 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19894 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19896 vat_json_print (vam->ofp, &node);
19897 vat_json_free (&node);
19899 vam->result_ready = 1;
19903 api_ipfix_classify_table_dump (vat_main_t * vam)
19905 vl_api_ipfix_classify_table_dump_t *mp;
19906 vl_api_control_ping_t *mp_ping;
19909 if (!vam->json_output)
19911 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19912 "transport_protocol");
19915 /* Construct the API message */
19916 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19921 /* Use a control ping for synchronization */
19922 MPING (CONTROL_PING, mp_ping);
19930 vl_api_ipfix_classify_table_details_t_handler
19931 (vl_api_ipfix_classify_table_details_t * mp)
19933 vat_main_t *vam = &vat_main;
19934 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19935 mp->transport_protocol);
19939 vl_api_ipfix_classify_table_details_t_handler_json
19940 (vl_api_ipfix_classify_table_details_t * mp)
19942 vat_json_node_t *node = NULL;
19943 vat_main_t *vam = &vat_main;
19945 if (VAT_JSON_ARRAY != vam->json_tree.type)
19947 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19948 vat_json_init_array (&vam->json_tree);
19951 node = vat_json_array_add (&vam->json_tree);
19952 vat_json_init_object (node);
19954 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19955 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19956 vat_json_object_add_uint (node, "transport_protocol",
19957 mp->transport_protocol);
19961 api_sw_interface_span_enable_disable (vat_main_t * vam)
19963 unformat_input_t *i = vam->input;
19964 vl_api_sw_interface_span_enable_disable_t *mp;
19965 u32 src_sw_if_index = ~0;
19966 u32 dst_sw_if_index = ~0;
19971 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19974 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19976 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19980 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19982 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19984 else if (unformat (i, "disable"))
19986 else if (unformat (i, "rx"))
19988 else if (unformat (i, "tx"))
19990 else if (unformat (i, "both"))
19992 else if (unformat (i, "l2"))
19998 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
20000 mp->sw_if_index_from = htonl (src_sw_if_index);
20001 mp->sw_if_index_to = htonl (dst_sw_if_index);
20011 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
20014 vat_main_t *vam = &vat_main;
20015 u8 *sw_if_from_name = 0;
20016 u8 *sw_if_to_name = 0;
20017 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20018 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20019 char *states[] = { "none", "rx", "tx", "both" };
20023 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20025 if ((u32) p->value[0] == sw_if_index_from)
20027 sw_if_from_name = (u8 *)(p->key);
20031 if ((u32) p->value[0] == sw_if_index_to)
20033 sw_if_to_name = (u8 *)(p->key);
20034 if (sw_if_from_name)
20039 print (vam->ofp, "%20s => %20s (%s)",
20040 sw_if_from_name, sw_if_to_name, states[mp->state]);
20044 vl_api_sw_interface_span_details_t_handler_json
20045 (vl_api_sw_interface_span_details_t * mp)
20047 vat_main_t *vam = &vat_main;
20048 vat_json_node_t *node = NULL;
20049 u8 *sw_if_from_name = 0;
20050 u8 *sw_if_to_name = 0;
20051 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20052 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20056 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20058 if ((u32) p->value[0] == sw_if_index_from)
20060 sw_if_from_name = (u8 *)(p->key);
20064 if ((u32) p->value[0] == sw_if_index_to)
20066 sw_if_to_name = (u8 *)(p->key);
20067 if (sw_if_from_name)
20073 if (VAT_JSON_ARRAY != vam->json_tree.type)
20075 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20076 vat_json_init_array (&vam->json_tree);
20078 node = vat_json_array_add (&vam->json_tree);
20080 vat_json_init_object (node);
20081 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
20082 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
20083 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
20084 if (0 != sw_if_to_name)
20086 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
20088 vat_json_object_add_uint (node, "state", mp->state);
20092 api_sw_interface_span_dump (vat_main_t * vam)
20094 unformat_input_t *input = vam->input;
20095 vl_api_sw_interface_span_dump_t *mp;
20096 vl_api_control_ping_t *mp_ping;
20100 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20102 if (unformat (input, "l2"))
20108 M (SW_INTERFACE_SPAN_DUMP, mp);
20112 /* Use a control ping for synchronization */
20113 MPING (CONTROL_PING, mp_ping);
20121 api_pg_create_interface (vat_main_t * vam)
20123 unformat_input_t *input = vam->input;
20124 vl_api_pg_create_interface_t *mp;
20128 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20130 if (unformat (input, "if_id %d", &if_id))
20137 errmsg ("missing pg interface index");
20141 /* Construct the API message */
20142 M (PG_CREATE_INTERFACE, mp);
20144 mp->interface_id = ntohl (if_id);
20152 api_pg_capture (vat_main_t * vam)
20154 unformat_input_t *input = vam->input;
20155 vl_api_pg_capture_t *mp;
20160 u8 pcap_file_set = 0;
20163 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20165 if (unformat (input, "if_id %d", &if_id))
20167 else if (unformat (input, "pcap %s", &pcap_file))
20169 else if (unformat (input, "count %d", &count))
20171 else if (unformat (input, "disable"))
20178 errmsg ("missing pg interface index");
20181 if (pcap_file_set > 0)
20183 if (vec_len (pcap_file) > 255)
20185 errmsg ("pcap file name is too long");
20190 u32 name_len = vec_len (pcap_file);
20191 /* Construct the API message */
20192 M (PG_CAPTURE, mp);
20194 mp->interface_id = ntohl (if_id);
20195 mp->is_enabled = enable;
20196 mp->count = ntohl (count);
20197 mp->pcap_name_length = ntohl (name_len);
20198 if (pcap_file_set != 0)
20200 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
20202 vec_free (pcap_file);
20210 api_pg_enable_disable (vat_main_t * vam)
20212 unformat_input_t *input = vam->input;
20213 vl_api_pg_enable_disable_t *mp;
20216 u8 stream_name_set = 0;
20217 u8 *stream_name = 0;
20219 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20221 if (unformat (input, "stream %s", &stream_name))
20222 stream_name_set = 1;
20223 else if (unformat (input, "disable"))
20229 if (stream_name_set > 0)
20231 if (vec_len (stream_name) > 255)
20233 errmsg ("stream name too long");
20238 u32 name_len = vec_len (stream_name);
20239 /* Construct the API message */
20240 M (PG_ENABLE_DISABLE, mp);
20242 mp->is_enabled = enable;
20243 if (stream_name_set != 0)
20245 mp->stream_name_length = ntohl (name_len);
20246 clib_memcpy (mp->stream_name, stream_name, name_len);
20248 vec_free (stream_name);
20256 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
20258 unformat_input_t *input = vam->input;
20259 vl_api_ip_source_and_port_range_check_add_del_t *mp;
20261 u16 *low_ports = 0;
20262 u16 *high_ports = 0;
20265 ip4_address_t ip4_addr;
20266 ip6_address_t ip6_addr;
20275 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20277 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
20283 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
20288 else if (unformat (input, "vrf %d", &vrf_id))
20290 else if (unformat (input, "del"))
20292 else if (unformat (input, "port %d", &tmp))
20294 if (tmp == 0 || tmp > 65535)
20296 errmsg ("port %d out of range", tmp);
20300 this_hi = this_low + 1;
20301 vec_add1 (low_ports, this_low);
20302 vec_add1 (high_ports, this_hi);
20304 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
20306 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
20308 errmsg ("incorrect range parameters");
20312 /* Note: in debug CLI +1 is added to high before
20313 passing to real fn that does "the work"
20314 (ip_source_and_port_range_check_add_del).
20315 This fn is a wrapper around the binary API fn a
20316 control plane will call, which expects this increment
20317 to have occurred. Hence letting the binary API control
20318 plane fn do the increment for consistency between VAT
20319 and other control planes.
20322 vec_add1 (low_ports, this_low);
20323 vec_add1 (high_ports, this_hi);
20329 if (prefix_set == 0)
20331 errmsg ("<address>/<mask> not specified");
20337 errmsg ("VRF ID required, not specified");
20344 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20348 if (vec_len (low_ports) == 0)
20350 errmsg ("At least one port or port range required");
20354 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
20356 mp->is_add = is_add;
20361 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
20366 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
20369 mp->mask_length = length;
20370 mp->number_of_ranges = vec_len (low_ports);
20372 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
20373 vec_free (low_ports);
20375 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
20376 vec_free (high_ports);
20378 mp->vrf_id = ntohl (vrf_id);
20386 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
20388 unformat_input_t *input = vam->input;
20389 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
20390 u32 sw_if_index = ~0;
20392 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
20393 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
20397 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20399 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20401 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20403 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
20405 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
20407 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
20409 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
20411 else if (unformat (input, "del"))
20417 if (sw_if_index == ~0)
20419 errmsg ("Interface required but not specified");
20425 errmsg ("VRF ID required but not specified");
20429 if (tcp_out_vrf_id == 0
20430 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
20433 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20437 /* Construct the API message */
20438 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
20440 mp->sw_if_index = ntohl (sw_if_index);
20441 mp->is_add = is_add;
20442 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20443 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20444 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20445 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20450 /* Wait for a reply... */
20456 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
20458 unformat_input_t *i = vam->input;
20459 vl_api_ipsec_gre_add_del_tunnel_t *mp;
20460 u32 local_sa_id = 0;
20461 u32 remote_sa_id = 0;
20462 ip4_address_t src_address;
20463 ip4_address_t dst_address;
20467 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20469 if (unformat (i, "local_sa %d", &local_sa_id))
20471 else if (unformat (i, "remote_sa %d", &remote_sa_id))
20473 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
20475 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
20477 else if (unformat (i, "del"))
20481 clib_warning ("parse error '%U'", format_unformat_error, i);
20486 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
20488 mp->local_sa_id = ntohl (local_sa_id);
20489 mp->remote_sa_id = ntohl (remote_sa_id);
20490 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
20491 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
20492 mp->is_add = is_add;
20500 api_punt (vat_main_t * vam)
20502 unformat_input_t *i = vam->input;
20510 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20512 if (unformat (i, "ip %d", &ipv))
20514 else if (unformat (i, "protocol %d", &protocol))
20516 else if (unformat (i, "port %d", &port))
20518 else if (unformat (i, "del"))
20522 clib_warning ("parse error '%U'", format_unformat_error, i);
20529 mp->is_add = (u8) is_add;
20530 mp->ipv = (u8) ipv;
20531 mp->l4_protocol = (u8) protocol;
20532 mp->l4_port = htons ((u16) port);
20539 static void vl_api_ipsec_gre_tunnel_details_t_handler
20540 (vl_api_ipsec_gre_tunnel_details_t * mp)
20542 vat_main_t *vam = &vat_main;
20544 print (vam->ofp, "%11d%15U%15U%14d%14d",
20545 ntohl (mp->sw_if_index),
20546 format_ip4_address, &mp->src_address,
20547 format_ip4_address, &mp->dst_address,
20548 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
20551 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
20552 (vl_api_ipsec_gre_tunnel_details_t * mp)
20554 vat_main_t *vam = &vat_main;
20555 vat_json_node_t *node = NULL;
20556 struct in_addr ip4;
20558 if (VAT_JSON_ARRAY != vam->json_tree.type)
20560 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20561 vat_json_init_array (&vam->json_tree);
20563 node = vat_json_array_add (&vam->json_tree);
20565 vat_json_init_object (node);
20566 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20567 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
20568 vat_json_object_add_ip4 (node, "src_address", ip4);
20569 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
20570 vat_json_object_add_ip4 (node, "dst_address", ip4);
20571 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
20572 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
20576 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
20578 unformat_input_t *i = vam->input;
20579 vl_api_ipsec_gre_tunnel_dump_t *mp;
20580 vl_api_control_ping_t *mp_ping;
20582 u8 sw_if_index_set = 0;
20585 /* Parse args required to build the message */
20586 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20588 if (unformat (i, "sw_if_index %d", &sw_if_index))
20589 sw_if_index_set = 1;
20594 if (sw_if_index_set == 0)
20599 if (!vam->json_output)
20601 print (vam->ofp, "%11s%15s%15s%14s%14s",
20602 "sw_if_index", "src_address", "dst_address",
20603 "local_sa_id", "remote_sa_id");
20606 /* Get list of gre-tunnel interfaces */
20607 M (IPSEC_GRE_TUNNEL_DUMP, mp);
20609 mp->sw_if_index = htonl (sw_if_index);
20613 /* Use a control ping for synchronization */
20614 MPING (CONTROL_PING, mp_ping);
20622 api_delete_subif (vat_main_t * vam)
20624 unformat_input_t *i = vam->input;
20625 vl_api_delete_subif_t *mp;
20626 u32 sw_if_index = ~0;
20629 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20631 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20633 if (unformat (i, "sw_if_index %d", &sw_if_index))
20639 if (sw_if_index == ~0)
20641 errmsg ("missing sw_if_index");
20645 /* Construct the API message */
20646 M (DELETE_SUBIF, mp);
20647 mp->sw_if_index = ntohl (sw_if_index);
20654 #define foreach_pbb_vtr_op \
20655 _("disable", L2_VTR_DISABLED) \
20656 _("pop", L2_VTR_POP_2) \
20657 _("push", L2_VTR_PUSH_2)
20660 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20662 unformat_input_t *i = vam->input;
20663 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20664 u32 sw_if_index = ~0, vtr_op = ~0;
20665 u16 outer_tag = ~0;
20666 u8 dmac[6], smac[6];
20667 u8 dmac_set = 0, smac_set = 0;
20673 /* Shut up coverity */
20674 memset (dmac, 0, sizeof (dmac));
20675 memset (smac, 0, sizeof (smac));
20677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20679 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20681 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20683 else if (unformat (i, "vtr_op %d", &vtr_op))
20685 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20688 else if (unformat (i, "translate_pbb_stag"))
20690 if (unformat (i, "%d", &tmp))
20692 vtr_op = L2_VTR_TRANSLATE_2_1;
20698 ("translate_pbb_stag operation requires outer tag definition");
20702 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20704 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20706 else if (unformat (i, "sid %d", &sid))
20708 else if (unformat (i, "vlanid %d", &tmp))
20712 clib_warning ("parse error '%U'", format_unformat_error, i);
20717 if ((sw_if_index == ~0) || (vtr_op == ~0))
20719 errmsg ("missing sw_if_index or vtr operation");
20722 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20723 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20726 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20730 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20731 mp->sw_if_index = ntohl (sw_if_index);
20732 mp->vtr_op = ntohl (vtr_op);
20733 mp->outer_tag = ntohs (outer_tag);
20734 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20735 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20736 mp->b_vlanid = ntohs (vlanid);
20737 mp->i_sid = ntohl (sid);
20745 api_flow_classify_set_interface (vat_main_t * vam)
20747 unformat_input_t *i = vam->input;
20748 vl_api_flow_classify_set_interface_t *mp;
20750 int sw_if_index_set;
20751 u32 ip4_table_index = ~0;
20752 u32 ip6_table_index = ~0;
20756 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20758 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20759 sw_if_index_set = 1;
20760 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20761 sw_if_index_set = 1;
20762 else if (unformat (i, "del"))
20764 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20766 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20770 clib_warning ("parse error '%U'", format_unformat_error, i);
20775 if (sw_if_index_set == 0)
20777 errmsg ("missing interface name or sw_if_index");
20781 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20783 mp->sw_if_index = ntohl (sw_if_index);
20784 mp->ip4_table_index = ntohl (ip4_table_index);
20785 mp->ip6_table_index = ntohl (ip6_table_index);
20786 mp->is_add = is_add;
20794 api_flow_classify_dump (vat_main_t * vam)
20796 unformat_input_t *i = vam->input;
20797 vl_api_flow_classify_dump_t *mp;
20798 vl_api_control_ping_t *mp_ping;
20799 u8 type = FLOW_CLASSIFY_N_TABLES;
20802 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20806 errmsg ("classify table type must be specified");
20810 if (!vam->json_output)
20812 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20815 M (FLOW_CLASSIFY_DUMP, mp);
20820 /* Use a control ping for synchronization */
20821 MPING (CONTROL_PING, mp_ping);
20824 /* Wait for a reply... */
20830 api_feature_enable_disable (vat_main_t * vam)
20832 unformat_input_t *i = vam->input;
20833 vl_api_feature_enable_disable_t *mp;
20835 u8 *feature_name = 0;
20836 u32 sw_if_index = ~0;
20840 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20842 if (unformat (i, "arc_name %s", &arc_name))
20844 else if (unformat (i, "feature_name %s", &feature_name))
20847 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20849 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20851 else if (unformat (i, "disable"))
20859 errmsg ("missing arc name");
20862 if (vec_len (arc_name) > 63)
20864 errmsg ("arc name too long");
20867 if (feature_name == 0)
20869 errmsg ("missing feature name");
20872 if (vec_len (feature_name) > 63)
20874 errmsg ("feature name too long");
20877 if (sw_if_index == ~0)
20879 errmsg ("missing interface name or sw_if_index");
20883 /* Construct the API message */
20884 M (FEATURE_ENABLE_DISABLE, mp);
20885 mp->sw_if_index = ntohl (sw_if_index);
20886 mp->enable = enable;
20887 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20888 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20889 vec_free (arc_name);
20890 vec_free (feature_name);
20898 api_sw_interface_tag_add_del (vat_main_t * vam)
20900 unformat_input_t *i = vam->input;
20901 vl_api_sw_interface_tag_add_del_t *mp;
20902 u32 sw_if_index = ~0;
20907 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20909 if (unformat (i, "tag %s", &tag))
20911 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20913 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20915 else if (unformat (i, "del"))
20921 if (sw_if_index == ~0)
20923 errmsg ("missing interface name or sw_if_index");
20927 if (enable && (tag == 0))
20929 errmsg ("no tag specified");
20933 /* Construct the API message */
20934 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20935 mp->sw_if_index = ntohl (sw_if_index);
20936 mp->is_add = enable;
20938 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20946 static void vl_api_l2_xconnect_details_t_handler
20947 (vl_api_l2_xconnect_details_t * mp)
20949 vat_main_t *vam = &vat_main;
20951 print (vam->ofp, "%15d%15d",
20952 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20955 static void vl_api_l2_xconnect_details_t_handler_json
20956 (vl_api_l2_xconnect_details_t * mp)
20958 vat_main_t *vam = &vat_main;
20959 vat_json_node_t *node = NULL;
20961 if (VAT_JSON_ARRAY != vam->json_tree.type)
20963 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20964 vat_json_init_array (&vam->json_tree);
20966 node = vat_json_array_add (&vam->json_tree);
20968 vat_json_init_object (node);
20969 vat_json_object_add_uint (node, "rx_sw_if_index",
20970 ntohl (mp->rx_sw_if_index));
20971 vat_json_object_add_uint (node, "tx_sw_if_index",
20972 ntohl (mp->tx_sw_if_index));
20976 api_l2_xconnect_dump (vat_main_t * vam)
20978 vl_api_l2_xconnect_dump_t *mp;
20979 vl_api_control_ping_t *mp_ping;
20982 if (!vam->json_output)
20984 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20987 M (L2_XCONNECT_DUMP, mp);
20991 /* Use a control ping for synchronization */
20992 MPING (CONTROL_PING, mp_ping);
21000 api_sw_interface_set_mtu (vat_main_t * vam)
21002 unformat_input_t *i = vam->input;
21003 vl_api_sw_interface_set_mtu_t *mp;
21004 u32 sw_if_index = ~0;
21008 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21010 if (unformat (i, "mtu %d", &mtu))
21012 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21014 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21020 if (sw_if_index == ~0)
21022 errmsg ("missing interface name or sw_if_index");
21028 errmsg ("no mtu specified");
21032 /* Construct the API message */
21033 M (SW_INTERFACE_SET_MTU, mp);
21034 mp->sw_if_index = ntohl (sw_if_index);
21035 mp->mtu = ntohs ((u16) mtu);
21043 api_p2p_ethernet_add (vat_main_t * vam)
21045 unformat_input_t *i = vam->input;
21046 vl_api_p2p_ethernet_add_t *mp;
21047 u32 parent_if_index = ~0;
21053 memset (remote_mac, 0, sizeof (remote_mac));
21054 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21056 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21058 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21062 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21064 else if (unformat (i, "sub_id %d", &sub_id))
21068 clib_warning ("parse error '%U'", format_unformat_error, i);
21073 if (parent_if_index == ~0)
21075 errmsg ("missing interface name or sw_if_index");
21080 errmsg ("missing remote mac address");
21085 errmsg ("missing sub-interface id");
21089 M (P2P_ETHERNET_ADD, mp);
21090 mp->parent_if_index = ntohl (parent_if_index);
21091 mp->subif_id = ntohl (sub_id);
21092 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21100 api_p2p_ethernet_del (vat_main_t * vam)
21102 unformat_input_t *i = vam->input;
21103 vl_api_p2p_ethernet_del_t *mp;
21104 u32 parent_if_index = ~0;
21109 memset (remote_mac, 0, sizeof (remote_mac));
21110 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21112 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21114 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21118 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21122 clib_warning ("parse error '%U'", format_unformat_error, i);
21127 if (parent_if_index == ~0)
21129 errmsg ("missing interface name or sw_if_index");
21134 errmsg ("missing remote mac address");
21138 M (P2P_ETHERNET_DEL, mp);
21139 mp->parent_if_index = ntohl (parent_if_index);
21140 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21148 api_lldp_config (vat_main_t * vam)
21150 unformat_input_t *i = vam->input;
21151 vl_api_lldp_config_t *mp;
21153 int tx_interval = 0;
21154 u8 *sys_name = NULL;
21157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21159 if (unformat (i, "system-name %s", &sys_name))
21161 else if (unformat (i, "tx-hold %d", &tx_hold))
21163 else if (unformat (i, "tx-interval %d", &tx_interval))
21167 clib_warning ("parse error '%U'", format_unformat_error, i);
21172 vec_add1 (sys_name, 0);
21174 M (LLDP_CONFIG, mp);
21175 mp->tx_hold = htonl (tx_hold);
21176 mp->tx_interval = htonl (tx_interval);
21177 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
21178 vec_free (sys_name);
21186 api_sw_interface_set_lldp (vat_main_t * vam)
21188 unformat_input_t *i = vam->input;
21189 vl_api_sw_interface_set_lldp_t *mp;
21190 u32 sw_if_index = ~0;
21192 u8 *port_desc = NULL, *mgmt_oid = NULL;
21193 ip4_address_t ip4_addr;
21194 ip6_address_t ip6_addr;
21197 memset (&ip4_addr, 0, sizeof (ip4_addr));
21198 memset (&ip6_addr, 0, sizeof (ip6_addr));
21200 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21202 if (unformat (i, "disable"))
21205 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21207 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21209 else if (unformat (i, "port-desc %s", &port_desc))
21211 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
21213 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
21215 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
21221 if (sw_if_index == ~0)
21223 errmsg ("missing interface name or sw_if_index");
21227 /* Construct the API message */
21228 vec_add1 (port_desc, 0);
21229 vec_add1 (mgmt_oid, 0);
21230 M (SW_INTERFACE_SET_LLDP, mp);
21231 mp->sw_if_index = ntohl (sw_if_index);
21232 mp->enable = enable;
21233 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
21234 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
21235 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
21236 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
21237 vec_free (port_desc);
21238 vec_free (mgmt_oid);
21246 api_tcp_configure_src_addresses (vat_main_t * vam)
21248 vl_api_tcp_configure_src_addresses_t *mp;
21249 unformat_input_t *i = vam->input;
21250 ip4_address_t v4first, v4last;
21251 ip6_address_t v6first, v6last;
21256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21258 if (unformat (i, "%U - %U",
21259 unformat_ip4_address, &v4first,
21260 unformat_ip4_address, &v4last))
21264 errmsg ("one range per message (range already set)");
21269 else if (unformat (i, "%U - %U",
21270 unformat_ip6_address, &v6first,
21271 unformat_ip6_address, &v6last))
21275 errmsg ("one range per message (range already set)");
21280 else if (unformat (i, "vrf %d", &vrf_id))
21286 if (range_set == 0)
21288 errmsg ("address range not set");
21292 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
21293 mp->vrf_id = ntohl (vrf_id);
21295 if (range_set == 2)
21298 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
21299 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
21304 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
21305 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
21313 api_app_namespace_add_del (vat_main_t * vam)
21315 vl_api_app_namespace_add_del_t *mp;
21316 unformat_input_t *i = vam->input;
21317 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
21318 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
21322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21324 if (unformat (i, "id %_%v%_", &ns_id))
21326 else if (unformat (i, "secret %lu", &secret))
21328 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21329 sw_if_index_set = 1;
21330 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
21332 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
21337 if (!ns_id || !secret_set || !sw_if_index_set)
21339 errmsg ("namespace id, secret and sw_if_index must be set");
21342 if (vec_len (ns_id) > 64)
21344 errmsg ("namespace id too long");
21347 M (APP_NAMESPACE_ADD_DEL, mp);
21349 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
21350 mp->namespace_id_len = vec_len (ns_id);
21351 mp->secret = clib_host_to_net_u64 (secret);
21352 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21353 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
21354 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
21362 api_memfd_segment_create (vat_main_t * vam)
21364 #if VPP_API_TEST_BUILTIN == 0
21365 unformat_input_t *i = vam->input;
21366 vl_api_memfd_segment_create_t *mp;
21367 u64 size = 64 << 20;
21370 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21372 if (unformat (i, "size %U", unformat_memory_size, &size))
21378 M (MEMFD_SEGMENT_CREATE, mp);
21379 mp->requested_size = size;
21385 errmsg ("memfd_segment_create (builtin) not supported");
21391 api_dns_enable_disable (vat_main_t * vam)
21393 unformat_input_t *line_input = vam->input;
21394 vl_api_dns_enable_disable_t *mp;
21395 u8 enable_disable = 1;
21398 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21400 if (unformat (line_input, "disable"))
21401 enable_disable = 0;
21402 if (unformat (line_input, "enable"))
21403 enable_disable = 1;
21408 /* Construct the API message */
21409 M (DNS_ENABLE_DISABLE, mp);
21410 mp->enable = enable_disable;
21414 /* Wait for the reply */
21420 api_dns_resolve_name (vat_main_t * vam)
21422 unformat_input_t *line_input = vam->input;
21423 vl_api_dns_resolve_name_t *mp;
21427 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21429 if (unformat (line_input, "%s", &name))
21435 if (vec_len (name) > 127)
21437 errmsg ("name too long");
21441 /* Construct the API message */
21442 M (DNS_RESOLVE_NAME, mp);
21443 memcpy (mp->name, name, vec_len (name));
21448 /* Wait for the reply */
21454 api_dns_resolve_ip (vat_main_t * vam)
21456 unformat_input_t *line_input = vam->input;
21457 vl_api_dns_resolve_ip_t *mp;
21459 ip4_address_t addr4;
21460 ip6_address_t addr6;
21463 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21465 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
21467 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
21475 errmsg ("missing address");
21479 /* Construct the API message */
21480 M (DNS_RESOLVE_IP, mp);
21481 mp->is_ip6 = is_ip6;
21483 memcpy (mp->address, &addr6, sizeof (addr6));
21485 memcpy (mp->address, &addr4, sizeof (addr4));
21489 /* Wait for the reply */
21495 api_dns_name_server_add_del (vat_main_t * vam)
21497 unformat_input_t *i = vam->input;
21498 vl_api_dns_name_server_add_del_t *mp;
21500 ip6_address_t ip6_server;
21501 ip4_address_t ip4_server;
21506 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21508 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
21510 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
21512 else if (unformat (i, "del"))
21516 clib_warning ("parse error '%U'", format_unformat_error, i);
21521 if (ip4_set && ip6_set)
21523 errmsg ("Only one server address allowed per message");
21526 if ((ip4_set + ip6_set) == 0)
21528 errmsg ("Server address required");
21532 /* Construct the API message */
21533 M (DNS_NAME_SERVER_ADD_DEL, mp);
21537 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
21542 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
21546 mp->is_add = is_add;
21551 /* Wait for a reply, return good/bad news */
21557 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
21559 vat_main_t *vam = &vat_main;
21563 print (vam->ofp, "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d",
21564 mp->appns_index, mp->transport_proto, mp->scope,
21565 format_ip4_address, &mp->lcl_ip, mp->lcl_plen, mp->lcl_port,
21566 format_ip4_address, &mp->rmt_ip, mp->rmt_plen, mp->rmt_port,
21571 print (vam->ofp, "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d",
21572 mp->appns_index, mp->transport_proto, mp->scope,
21573 format_ip6_address, &mp->lcl_ip, mp->lcl_plen, mp->lcl_port,
21574 format_ip6_address, &mp->rmt_ip, mp->rmt_plen, mp->rmt_port,
21580 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
21583 vat_main_t *vam = &vat_main;
21584 vat_json_node_t *node = NULL;
21585 struct in6_addr ip6;
21586 struct in_addr ip4;
21588 if (VAT_JSON_ARRAY != vam->json_tree.type)
21590 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21591 vat_json_init_array (&vam->json_tree);
21593 node = vat_json_array_add (&vam->json_tree);
21594 vat_json_init_object (node);
21596 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
21597 vat_json_object_add_uint (node, "appns_index",
21598 clib_net_to_host_u32 (mp->appns_index));
21599 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
21600 vat_json_object_add_uint (node, "scope", mp->scope);
21601 vat_json_object_add_uint (node, "action_index",
21602 clib_net_to_host_u32 (mp->action_index));
21603 vat_json_object_add_uint (node, "lcl_port",
21604 clib_net_to_host_u16 (mp->lcl_port));
21605 vat_json_object_add_uint (node, "rmt_port",
21606 clib_net_to_host_u16 (mp->rmt_port));
21607 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
21608 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
21611 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
21612 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
21613 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
21614 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
21618 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
21619 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
21620 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
21621 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
21626 api_session_rule_add_del (vat_main_t * vam)
21628 vl_api_session_rule_add_del_t *mp;
21629 unformat_input_t *i = vam->input;
21630 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
21631 u32 appns_index = 0, scope = 0;
21632 ip4_address_t lcl_ip4, rmt_ip4;
21633 ip6_address_t lcl_ip6, rmt_ip6;
21634 u8 is_ip4 = 1, conn_set = 0;
21638 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21640 if (unformat (i, "del"))
21642 else if (unformat (i, "add"))
21644 else if (unformat (i, "proto tcp"))
21646 else if (unformat (i, "proto udp"))
21648 else if (unformat (i, "appns %d", &appns_index))
21650 else if (unformat (i, "scope %d", &scope))
21654 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
21655 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
21663 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
21664 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
21670 else if (unformat (i, "action %d", &action))
21675 if (proto == ~0 || !conn_set || action == ~0)
21677 errmsg ("transport proto, connection and action must be set");
21683 errmsg ("scope should be 0-3");
21687 M (SESSION_RULE_ADD_DEL, mp);
21689 mp->is_ip4 = is_ip4;
21690 mp->transport_proto = proto;
21691 mp->lcl_plen = clib_host_to_net_u16 (lcl_plen);
21692 mp->rmt_plen = clib_host_to_net_u16 (rmt_plen);
21693 mp->action_index = clib_host_to_net_u32 (action);
21694 mp->appns_index = clib_host_to_net_u32 (appns_index);
21696 mp->is_add = is_add;
21699 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
21700 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
21704 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
21705 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
21714 api_session_rules_dump (vat_main_t * vam)
21716 vl_api_session_rules_dump_t *mp;
21717 vl_api_control_ping_t *mp_ping;
21720 if (!vam->json_output)
21722 print (vam->ofp, "%=20s", "Session Rules");
21725 M (SESSION_RULES_DUMP, mp);
21729 /* Use a control ping for synchronization */
21730 MPING (CONTROL_PING, mp_ping);
21733 /* Wait for a reply... */
21739 q_or_quit (vat_main_t * vam)
21741 #if VPP_API_TEST_BUILTIN == 0
21742 longjmp (vam->jump_buf, 1);
21744 return 0; /* not so much */
21748 q (vat_main_t * vam)
21750 return q_or_quit (vam);
21754 quit (vat_main_t * vam)
21756 return q_or_quit (vam);
21760 comment (vat_main_t * vam)
21766 cmd_cmp (void *a1, void *a2)
21771 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21775 help (vat_main_t * vam)
21780 unformat_input_t *i = vam->input;
21783 if (unformat (i, "%s", &name))
21787 vec_add1 (name, 0);
21789 hs = hash_get_mem (vam->help_by_name, name);
21791 print (vam->ofp, "usage: %s %s", name, hs[0]);
21793 print (vam->ofp, "No such msg / command '%s'", name);
21798 print (vam->ofp, "Help is available for the following:");
21801 hash_foreach_pair (p, vam->function_by_name,
21803 vec_add1 (cmds, (u8 *)(p->key));
21807 vec_sort_with_function (cmds, cmd_cmp);
21809 for (j = 0; j < vec_len (cmds); j++)
21810 print (vam->ofp, "%s", cmds[j]);
21817 set (vat_main_t * vam)
21819 u8 *name = 0, *value = 0;
21820 unformat_input_t *i = vam->input;
21822 if (unformat (i, "%s", &name))
21824 /* The input buffer is a vector, not a string. */
21825 value = vec_dup (i->buffer);
21826 vec_delete (value, i->index, 0);
21827 /* Almost certainly has a trailing newline */
21828 if (value[vec_len (value) - 1] == '\n')
21829 value[vec_len (value) - 1] = 0;
21830 /* Make sure it's a proper string, one way or the other */
21831 vec_add1 (value, 0);
21832 (void) clib_macro_set_value (&vam->macro_main,
21833 (char *) name, (char *) value);
21836 errmsg ("usage: set <name> <value>");
21844 unset (vat_main_t * vam)
21848 if (unformat (vam->input, "%s", &name))
21849 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21850 errmsg ("unset: %s wasn't set", name);
21863 macro_sort_cmp (void *a1, void *a2)
21865 macro_sort_t *s1 = a1;
21866 macro_sort_t *s2 = a2;
21868 return strcmp ((char *) (s1->name), (char *) (s2->name));
21872 dump_macro_table (vat_main_t * vam)
21874 macro_sort_t *sort_me = 0, *sm;
21879 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21881 vec_add2 (sort_me, sm, 1);
21882 sm->name = (u8 *)(p->key);
21883 sm->value = (u8 *) (p->value[0]);
21887 vec_sort_with_function (sort_me, macro_sort_cmp);
21889 if (vec_len (sort_me))
21890 print (vam->ofp, "%-15s%s", "Name", "Value");
21892 print (vam->ofp, "The macro table is empty...");
21894 for (i = 0; i < vec_len (sort_me); i++)
21895 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21900 dump_node_table (vat_main_t * vam)
21903 vlib_node_t *node, *next_node;
21905 if (vec_len (vam->graph_nodes) == 0)
21907 print (vam->ofp, "Node table empty, issue get_node_graph...");
21911 for (i = 0; i < vec_len (vam->graph_nodes); i++)
21913 node = vam->graph_nodes[i];
21914 print (vam->ofp, "[%d] %s", i, node->name);
21915 for (j = 0; j < vec_len (node->next_nodes); j++)
21917 if (node->next_nodes[j] != ~0)
21919 next_node = vam->graph_nodes[node->next_nodes[j]];
21920 print (vam->ofp, " [%d] %s", j, next_node->name);
21928 value_sort_cmp (void *a1, void *a2)
21930 name_sort_t *n1 = a1;
21931 name_sort_t *n2 = a2;
21933 if (n1->value < n2->value)
21935 if (n1->value > n2->value)
21942 dump_msg_api_table (vat_main_t * vam)
21944 api_main_t *am = &api_main;
21945 name_sort_t *nses = 0, *ns;
21950 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21952 vec_add2 (nses, ns, 1);
21953 ns->name = (u8 *)(hp->key);
21954 ns->value = (u32) hp->value[0];
21958 vec_sort_with_function (nses, value_sort_cmp);
21960 for (i = 0; i < vec_len (nses); i++)
21961 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21967 get_msg_id (vat_main_t * vam)
21972 if (unformat (vam->input, "%s", &name_and_crc))
21974 message_index = vl_api_get_msg_index (name_and_crc);
21975 if (message_index == ~0)
21977 print (vam->ofp, " '%s' not found", name_and_crc);
21980 print (vam->ofp, " '%s' has message index %d",
21981 name_and_crc, message_index);
21984 errmsg ("name_and_crc required...");
21989 search_node_table (vat_main_t * vam)
21991 unformat_input_t *line_input = vam->input;
21994 vlib_node_t *node, *next_node;
21997 if (vam->graph_node_index_by_name == 0)
21999 print (vam->ofp, "Node table empty, issue get_node_graph...");
22003 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22005 if (unformat (line_input, "%s", &node_to_find))
22007 vec_add1 (node_to_find, 0);
22008 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
22011 print (vam->ofp, "%s not found...", node_to_find);
22014 node = vam->graph_nodes[p[0]];
22015 print (vam->ofp, "[%d] %s", p[0], node->name);
22016 for (j = 0; j < vec_len (node->next_nodes); j++)
22018 if (node->next_nodes[j] != ~0)
22020 next_node = vam->graph_nodes[node->next_nodes[j]];
22021 print (vam->ofp, " [%d] %s", j, next_node->name);
22028 clib_warning ("parse error '%U'", format_unformat_error,
22034 vec_free (node_to_find);
22043 script (vat_main_t * vam)
22045 #if (VPP_API_TEST_BUILTIN==0)
22047 char *save_current_file;
22048 unformat_input_t save_input;
22049 jmp_buf save_jump_buf;
22050 u32 save_line_number;
22052 FILE *new_fp, *save_ifp;
22054 if (unformat (vam->input, "%s", &s))
22056 new_fp = fopen ((char *) s, "r");
22059 errmsg ("Couldn't open script file %s", s);
22066 errmsg ("Missing script name");
22070 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
22071 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
22072 save_ifp = vam->ifp;
22073 save_line_number = vam->input_line_number;
22074 save_current_file = (char *) vam->current_file;
22076 vam->input_line_number = 0;
22078 vam->current_file = s;
22081 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
22082 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
22083 vam->ifp = save_ifp;
22084 vam->input_line_number = save_line_number;
22085 vam->current_file = (u8 *) save_current_file;
22090 clib_warning ("use the exec command...");
22096 echo (vat_main_t * vam)
22098 print (vam->ofp, "%v", vam->input->buffer);
22102 /* List of API message constructors, CLI names map to api_xxx */
22103 #define foreach_vpe_api_msg \
22104 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
22105 _(sw_interface_dump,"") \
22106 _(sw_interface_set_flags, \
22107 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
22108 _(sw_interface_add_del_address, \
22109 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
22110 _(sw_interface_set_rx_mode, \
22111 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
22112 _(sw_interface_set_table, \
22113 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
22114 _(sw_interface_set_mpls_enable, \
22115 "<intfc> | sw_if_index [disable | dis]") \
22116 _(sw_interface_set_vpath, \
22117 "<intfc> | sw_if_index <id> enable | disable") \
22118 _(sw_interface_set_vxlan_bypass, \
22119 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22120 _(sw_interface_set_geneve_bypass, \
22121 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22122 _(sw_interface_set_l2_xconnect, \
22123 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22124 "enable | disable") \
22125 _(sw_interface_set_l2_bridge, \
22126 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
22127 "[shg <split-horizon-group>] [bvi]\n" \
22128 "enable | disable") \
22129 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
22130 _(bridge_domain_add_del, \
22131 "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") \
22132 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
22134 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
22135 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
22136 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
22138 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22140 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22142 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
22144 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
22146 "<vpp-if-name> | sw_if_index <id>") \
22147 _(sw_interface_tap_dump, "") \
22148 _(ip_table_add_del, \
22149 "table-id <n> [ipv6]\n") \
22150 _(ip_add_del_route, \
22151 "<addr>/<mask> via <addr> [table-id <n>]\n" \
22152 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
22153 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
22154 "[multipath] [count <n>]") \
22155 _(ip_mroute_add_del, \
22156 "<src> <grp>/<mask> [table-id <n>]\n" \
22157 "[<intfc> | sw_if_index <id>] [local] [del]") \
22158 _(mpls_table_add_del, \
22159 "table-id <n>\n") \
22160 _(mpls_route_add_del, \
22161 "<label> <eos> via <addr> [table-id <n>]\n" \
22162 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
22163 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
22164 "[multipath] [count <n>]") \
22165 _(mpls_ip_bind_unbind, \
22166 "<label> <addr/len>") \
22167 _(mpls_tunnel_add_del, \
22168 " via <addr> [table-id <n>]\n" \
22169 "sw_if_index <id>] [l2] [del]") \
22170 _(proxy_arp_add_del, \
22171 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
22172 _(proxy_arp_intfc_enable_disable, \
22173 "<intfc> | sw_if_index <id> enable | disable") \
22174 _(sw_interface_set_unnumbered, \
22175 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
22176 _(ip_neighbor_add_del, \
22177 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
22178 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
22179 _(reset_vrf, "vrf <id> [ipv6]") \
22180 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
22181 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
22182 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
22183 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
22184 "[outer_vlan_id_any][inner_vlan_id_any]") \
22185 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
22186 _(reset_fib, "vrf <n> [ipv6]") \
22187 _(dhcp_proxy_config, \
22188 "svr <v46-address> src <v46-address>\n" \
22189 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
22190 _(dhcp_proxy_set_vss, \
22191 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
22192 _(dhcp_proxy_dump, "ip6") \
22193 _(dhcp_client_config, \
22194 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
22195 _(set_ip_flow_hash, \
22196 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
22197 _(sw_interface_ip6_enable_disable, \
22198 "<intfc> | sw_if_index <id> enable | disable") \
22199 _(sw_interface_ip6_set_link_local_address, \
22200 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
22201 _(ip6nd_proxy_add_del, \
22202 "<intfc> | sw_if_index <id> <ip6-address>") \
22203 _(ip6nd_proxy_dump, "") \
22204 _(sw_interface_ip6nd_ra_prefix, \
22205 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
22206 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
22207 "[nolink] [isno]") \
22208 _(sw_interface_ip6nd_ra_config, \
22209 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
22210 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
22211 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
22212 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
22213 _(l2_patch_add_del, \
22214 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22215 "enable | disable") \
22216 _(sr_localsid_add_del, \
22217 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
22218 "fib-table <num> (end.psp) sw_if_index <num>") \
22219 _(classify_add_del_table, \
22220 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
22221 " [del] [del-chain] mask <mask-value>\n" \
22222 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
22223 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
22224 _(classify_add_del_session, \
22225 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
22226 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
22227 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
22228 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
22229 _(classify_set_interface_ip_table, \
22230 "<intfc> | sw_if_index <nn> table <nn>") \
22231 _(classify_set_interface_l2_tables, \
22232 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22233 " [other-table <nn>]") \
22234 _(get_node_index, "node <node-name") \
22235 _(add_node_next, "node <node-name> next <next-node-name>") \
22236 _(l2tpv3_create_tunnel, \
22237 "client_address <ip6-addr> our_address <ip6-addr>\n" \
22238 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
22239 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
22240 _(l2tpv3_set_tunnel_cookies, \
22241 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
22242 "[new_remote_cookie <nn>]\n") \
22243 _(l2tpv3_interface_enable_disable, \
22244 "<intfc> | sw_if_index <nn> enable | disable") \
22245 _(l2tpv3_set_lookup_key, \
22246 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
22247 _(sw_if_l2tpv3_tunnel_dump, "") \
22248 _(vxlan_add_del_tunnel, \
22249 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22250 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22251 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22252 _(geneve_add_del_tunnel, \
22253 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22254 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22255 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22256 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22257 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22258 _(gre_add_del_tunnel, \
22259 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
22260 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22261 _(l2_fib_clear_table, "") \
22262 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
22263 _(l2_interface_vlan_tag_rewrite, \
22264 "<intfc> | sw_if_index <nn> \n" \
22265 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
22266 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
22267 _(create_vhost_user_if, \
22268 "socket <filename> [server] [renumber <dev_instance>] " \
22269 "[mac <mac_address>]") \
22270 _(modify_vhost_user_if, \
22271 "<intfc> | sw_if_index <nn> socket <filename>\n" \
22272 "[server] [renumber <dev_instance>]") \
22273 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
22274 _(sw_interface_vhost_user_dump, "") \
22275 _(show_version, "") \
22276 _(vxlan_gpe_add_del_tunnel, \
22277 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
22278 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22279 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
22280 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
22281 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22282 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
22283 _(interface_name_renumber, \
22284 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
22285 _(input_acl_set_interface, \
22286 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22287 " [l2-table <nn>] [del]") \
22288 _(want_ip4_arp_events, "address <ip4-address> [del]") \
22289 _(want_ip6_nd_events, "address <ip6-address> [del]") \
22290 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
22291 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
22292 _(ip_dump, "ipv4 | ipv6") \
22293 _(ipsec_spd_add_del, "spd_id <n> [del]") \
22294 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
22296 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
22297 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
22298 " integ_alg <alg> integ_key <hex>") \
22299 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
22300 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
22301 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
22302 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
22303 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
22304 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
22305 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
22306 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
22307 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
22308 _(ipsec_sa_dump, "[sa_id <n>]") \
22309 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
22310 " <alg> <hex>\n") \
22311 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
22312 _(ikev2_profile_add_del, "name <profile_name> [del]") \
22313 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
22314 "(auth_data 0x<data> | auth_data <data>)") \
22315 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
22316 "(id_data 0x<data> | id_data <data>) (local|remote)") \
22317 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
22318 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
22319 "(local|remote)") \
22320 _(ikev2_set_local_key, "file <absolute_file_path>") \
22321 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
22322 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
22323 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
22324 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
22325 _(ikev2_initiate_sa_init, "<profile_name>") \
22326 _(ikev2_initiate_del_ike_sa, "<ispi>") \
22327 _(ikev2_initiate_del_child_sa, "<ispi>") \
22328 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
22329 _(delete_loopback,"sw_if_index <nn>") \
22330 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
22331 _(map_add_domain, \
22332 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
22333 "ip6-src <ip6addr> " \
22334 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
22335 _(map_del_domain, "index <n>") \
22336 _(map_add_del_rule, \
22337 "index <n> psid <n> dst <ip6addr> [del]") \
22338 _(map_domain_dump, "") \
22339 _(map_rule_dump, "index <map-domain>") \
22340 _(want_interface_events, "enable|disable") \
22341 _(want_stats,"enable|disable") \
22342 _(get_first_msg_id, "client <name>") \
22343 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
22344 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
22345 "fib-id <nn> [ip4][ip6][default]") \
22346 _(get_node_graph, " ") \
22347 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
22348 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
22349 _(ioam_disable, "") \
22350 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
22351 " sw_if_index <sw_if_index> p <priority> " \
22352 "w <weight>] [del]") \
22353 _(one_add_del_locator, "locator-set <locator_name> " \
22354 "iface <intf> | sw_if_index <sw_if_index> " \
22355 "p <priority> w <weight> [del]") \
22356 _(one_add_del_local_eid,"vni <vni> eid " \
22357 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22358 "locator-set <locator_name> [del]" \
22359 "[key-id sha1|sha256 secret-key <secret-key>]")\
22360 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
22361 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
22362 _(one_enable_disable, "enable|disable") \
22363 _(one_map_register_enable_disable, "enable|disable") \
22364 _(one_map_register_fallback_threshold, "<value>") \
22365 _(one_rloc_probe_enable_disable, "enable|disable") \
22366 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22368 "rloc <locator> p <prio> " \
22369 "w <weight> [rloc <loc> ... ] " \
22370 "action <action> [del-all]") \
22371 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22373 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22374 _(one_use_petr, "ip-address> | disable") \
22375 _(one_map_request_mode, "src-dst|dst-only") \
22376 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22377 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22378 _(one_locator_set_dump, "[local | remote]") \
22379 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
22380 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22381 "[local] | [remote]") \
22382 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
22383 _(one_ndp_bd_get, "") \
22384 _(one_ndp_entries_get, "bd <bridge-domain>") \
22385 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
22386 _(one_l2_arp_bd_get, "") \
22387 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
22388 _(one_stats_enable_disable, "enable|disalbe") \
22389 _(show_one_stats_enable_disable, "") \
22390 _(one_eid_table_vni_dump, "") \
22391 _(one_eid_table_map_dump, "l2|l3") \
22392 _(one_map_resolver_dump, "") \
22393 _(one_map_server_dump, "") \
22394 _(one_adjacencies_get, "vni <vni>") \
22395 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
22396 _(show_one_rloc_probe_state, "") \
22397 _(show_one_map_register_state, "") \
22398 _(show_one_status, "") \
22399 _(one_stats_dump, "") \
22400 _(one_stats_flush, "") \
22401 _(one_get_map_request_itr_rlocs, "") \
22402 _(one_map_register_set_ttl, "<ttl>") \
22403 _(one_set_transport_protocol, "udp|api") \
22404 _(one_get_transport_protocol, "") \
22405 _(one_enable_disable_xtr_mode, "enable|disable") \
22406 _(one_show_xtr_mode, "") \
22407 _(one_enable_disable_pitr_mode, "enable|disable") \
22408 _(one_show_pitr_mode, "") \
22409 _(one_enable_disable_petr_mode, "enable|disable") \
22410 _(one_show_petr_mode, "") \
22411 _(show_one_nsh_mapping, "") \
22412 _(show_one_pitr, "") \
22413 _(show_one_use_petr, "") \
22414 _(show_one_map_request_mode, "") \
22415 _(show_one_map_register_ttl, "") \
22416 _(show_one_map_register_fallback_threshold, "") \
22417 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
22418 " sw_if_index <sw_if_index> p <priority> " \
22419 "w <weight>] [del]") \
22420 _(lisp_add_del_locator, "locator-set <locator_name> " \
22421 "iface <intf> | sw_if_index <sw_if_index> " \
22422 "p <priority> w <weight> [del]") \
22423 _(lisp_add_del_local_eid,"vni <vni> eid " \
22424 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22425 "locator-set <locator_name> [del]" \
22426 "[key-id sha1|sha256 secret-key <secret-key>]") \
22427 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
22428 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
22429 _(lisp_enable_disable, "enable|disable") \
22430 _(lisp_map_register_enable_disable, "enable|disable") \
22431 _(lisp_rloc_probe_enable_disable, "enable|disable") \
22432 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22434 "rloc <locator> p <prio> " \
22435 "w <weight> [rloc <loc> ... ] " \
22436 "action <action> [del-all]") \
22437 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22439 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22440 _(lisp_use_petr, "<ip-address> | disable") \
22441 _(lisp_map_request_mode, "src-dst|dst-only") \
22442 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22443 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22444 _(lisp_locator_set_dump, "[local | remote]") \
22445 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
22446 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22447 "[local] | [remote]") \
22448 _(lisp_eid_table_vni_dump, "") \
22449 _(lisp_eid_table_map_dump, "l2|l3") \
22450 _(lisp_map_resolver_dump, "") \
22451 _(lisp_map_server_dump, "") \
22452 _(lisp_adjacencies_get, "vni <vni>") \
22453 _(gpe_fwd_entry_vnis_get, "") \
22454 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
22455 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
22456 "[table <table-id>]") \
22457 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
22458 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
22459 _(gpe_set_encap_mode, "lisp|vxlan") \
22460 _(gpe_get_encap_mode, "") \
22461 _(lisp_gpe_add_del_iface, "up|down") \
22462 _(lisp_gpe_enable_disable, "enable|disable") \
22463 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
22464 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
22465 _(show_lisp_rloc_probe_state, "") \
22466 _(show_lisp_map_register_state, "") \
22467 _(show_lisp_status, "") \
22468 _(lisp_get_map_request_itr_rlocs, "") \
22469 _(show_lisp_pitr, "") \
22470 _(show_lisp_use_petr, "") \
22471 _(show_lisp_map_request_mode, "") \
22472 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
22473 _(af_packet_delete, "name <host interface name>") \
22474 _(policer_add_del, "name <policer name> <params> [del]") \
22475 _(policer_dump, "[name <policer name>]") \
22476 _(policer_classify_set_interface, \
22477 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22478 " [l2-table <nn>] [del]") \
22479 _(policer_classify_dump, "type [ip4|ip6|l2]") \
22480 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
22481 "[master|slave]") \
22482 _(netmap_delete, "name <interface name>") \
22483 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
22484 _(mpls_fib_dump, "") \
22485 _(classify_table_ids, "") \
22486 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
22487 _(classify_table_info, "table_id <nn>") \
22488 _(classify_session_dump, "table_id <nn>") \
22489 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
22490 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
22491 "[template_interval <nn>] [udp_checksum]") \
22492 _(ipfix_exporter_dump, "") \
22493 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
22494 _(ipfix_classify_stream_dump, "") \
22495 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
22496 _(ipfix_classify_table_dump, "") \
22497 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
22498 _(sw_interface_span_dump, "[l2]") \
22499 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
22500 _(pg_create_interface, "if_id <nn>") \
22501 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
22502 _(pg_enable_disable, "[stream <id>] disable") \
22503 _(ip_source_and_port_range_check_add_del, \
22504 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
22505 _(ip_source_and_port_range_check_interface_add_del, \
22506 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
22507 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
22508 _(ipsec_gre_add_del_tunnel, \
22509 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
22510 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
22511 _(delete_subif,"<intfc> | sw_if_index <nn>") \
22512 _(l2_interface_pbb_tag_rewrite, \
22513 "<intfc> | sw_if_index <nn> \n" \
22514 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
22515 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
22516 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
22517 _(flow_classify_set_interface, \
22518 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
22519 _(flow_classify_dump, "type [ip4|ip6]") \
22520 _(ip_fib_dump, "") \
22521 _(ip_mfib_dump, "") \
22522 _(ip6_fib_dump, "") \
22523 _(ip6_mfib_dump, "") \
22524 _(feature_enable_disable, "arc_name <arc_name> " \
22525 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
22526 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
22528 _(l2_xconnect_dump, "") \
22529 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
22530 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
22531 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
22532 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
22533 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
22534 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
22535 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
22536 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
22537 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
22538 _(memfd_segment_create,"size <nnn>") \
22539 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
22540 _(dns_enable_disable, "[enable][disable]") \
22541 _(dns_name_server_add_del, "<ip-address> [del]") \
22542 _(dns_resolve_name, "<hostname>") \
22543 _(dns_resolve_ip, "<ip4|ip6>") \
22544 _(dns_name_server_add_del, "<ip-address> [del]") \
22545 _(dns_resolve_name, "<hostname>") \
22546 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
22547 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
22548 _(session_rules_dump, "") \
22550 /* List of command functions, CLI names map directly to functions */
22551 #define foreach_cli_function \
22552 _(comment, "usage: comment <ignore-rest-of-line>") \
22553 _(dump_interface_table, "usage: dump_interface_table") \
22554 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
22555 _(dump_ipv4_table, "usage: dump_ipv4_table") \
22556 _(dump_ipv6_table, "usage: dump_ipv6_table") \
22557 _(dump_stats_table, "usage: dump_stats_table") \
22558 _(dump_macro_table, "usage: dump_macro_table ") \
22559 _(dump_node_table, "usage: dump_node_table") \
22560 _(dump_msg_api_table, "usage: dump_msg_api_table") \
22561 _(get_msg_id, "usage: get_msg_id name_and_crc") \
22562 _(echo, "usage: echo <message>") \
22563 _(exec, "usage: exec <vpe-debug-CLI-command>") \
22564 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
22565 _(help, "usage: help") \
22566 _(q, "usage: quit") \
22567 _(quit, "usage: quit") \
22568 _(search_node_table, "usage: search_node_table <name>...") \
22569 _(set, "usage: set <variable-name> <value>") \
22570 _(script, "usage: script <file-name>") \
22571 _(unset, "usage: unset <variable-name>")
22573 static void vl_api_##n##_t_handler_uni \
22574 (vl_api_##n##_t * mp) \
22576 vat_main_t * vam = &vat_main; \
22577 if (vam->json_output) { \
22578 vl_api_##n##_t_handler_json(mp); \
22580 vl_api_##n##_t_handler(mp); \
22583 foreach_vpe_api_reply_msg;
22584 #if VPP_API_TEST_BUILTIN == 0
22585 foreach_standalone_reply_msg;
22590 vat_api_hookup (vat_main_t * vam)
22593 vl_msg_api_set_handlers(VL_API_##N, #n, \
22594 vl_api_##n##_t_handler_uni, \
22596 vl_api_##n##_t_endian, \
22597 vl_api_##n##_t_print, \
22598 sizeof(vl_api_##n##_t), 1);
22599 foreach_vpe_api_reply_msg;
22600 #if VPP_API_TEST_BUILTIN == 0
22601 foreach_standalone_reply_msg;
22605 #if (VPP_API_TEST_BUILTIN==0)
22606 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
22608 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
22610 vam->function_by_name = hash_create_string (0, sizeof (uword));
22612 vam->help_by_name = hash_create_string (0, sizeof (uword));
22615 /* API messages we can send */
22616 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
22617 foreach_vpe_api_msg;
22621 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22622 foreach_vpe_api_msg;
22625 /* CLI functions */
22626 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
22627 foreach_cli_function;
22631 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22632 foreach_cli_function;
22636 #if VPP_API_TEST_BUILTIN
22637 static clib_error_t *
22638 vat_api_hookup_shim (vlib_main_t * vm)
22640 vat_api_hookup (&vat_main);
22644 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
22648 * fd.io coding-style-patch-verification: ON
22651 * eval: (c-set-style "gnu")