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>
53 #include <vnet/dhcp/dhcp_proxy.h>
55 #include "vat/json_format.h"
60 #define vl_typedefs /* define message structures */
61 #include <vpp/api/vpe_all_api_h.h>
64 /* declare message handlers for each api */
66 #define vl_endianfun /* define message structures */
67 #include <vpp/api/vpe_all_api_h.h>
70 /* instantiate all the print functions we know about */
71 #define vl_print(handle, ...)
73 #include <vpp/api/vpe_all_api_h.h>
76 #define __plugin_msg_base 0
77 #include <vlibapi/vat_helper_macros.h>
79 #if VPP_API_TEST_BUILTIN == 0
89 vat_socket_connect (vat_main_t * vam)
91 return vl_socket_client_connect
92 (&vam->socket_client_main, (char *) vam->socket_name,
93 "vpp_api_test(s)", 0 /* default socket rx, tx buffer */ );
95 #else /* vpp built-in case, we don't do sockets... */
97 vat_socket_connect (vat_main_t * vam)
103 vl_socket_client_read_reply (socket_client_main_t * scm)
110 vat_time_now (vat_main_t * vam)
112 #if VPP_API_TEST_BUILTIN
113 return vlib_time_now (vam->vlib_main);
115 return clib_time_now (&vam->clib_time);
120 errmsg (char *fmt, ...)
122 vat_main_t *vam = &vat_main;
127 s = va_format (0, fmt, &va);
132 #if VPP_API_TEST_BUILTIN
133 vlib_cli_output (vam->vlib_main, (char *) s);
136 if (vam->ifp != stdin)
137 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
138 vam->input_line_number);
139 fformat (vam->ofp, (char *) s);
147 #if VPP_API_TEST_BUILTIN == 0
149 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
151 vat_main_t *vam = va_arg (*args, vat_main_t *);
152 u32 *result = va_arg (*args, u32 *);
156 if (!unformat (input, "%s", &if_name))
159 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
166 /* Parse an IP4 address %d.%d.%d.%d. */
168 unformat_ip4_address (unformat_input_t * input, va_list * args)
170 u8 *result = va_arg (*args, u8 *);
173 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
176 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
188 unformat_ethernet_address (unformat_input_t * input, va_list * args)
190 u8 *result = va_arg (*args, u8 *);
193 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
194 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
198 for (i = 0; i < 6; i++)
199 if (a[i] >= (1 << 8))
202 for (i = 0; i < 6; i++)
208 /* Returns ethernet type as an int in host byte order. */
210 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
213 u16 *result = va_arg (*args, u16 *);
217 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
219 if (type >= (1 << 16))
227 /* Parse an IP6 address. */
229 unformat_ip6_address (unformat_input_t * input, va_list * args)
231 ip6_address_t *result = va_arg (*args, ip6_address_t *);
233 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
234 uword c, n_colon, double_colon_index;
236 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
237 double_colon_index = ARRAY_LEN (hex_quads);
238 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
241 if (c >= '0' && c <= '9')
243 else if (c >= 'a' && c <= 'f')
244 hex_digit = c + 10 - 'a';
245 else if (c >= 'A' && c <= 'F')
246 hex_digit = c + 10 - 'A';
247 else if (c == ':' && n_colon < 2)
251 unformat_put_input (input);
255 /* Too many hex quads. */
256 if (n_hex_quads >= ARRAY_LEN (hex_quads))
261 hex_quad = (hex_quad << 4) | hex_digit;
263 /* Hex quad must fit in 16 bits. */
264 if (n_hex_digits >= 4)
271 /* Save position of :: */
274 /* More than one :: ? */
275 if (double_colon_index < ARRAY_LEN (hex_quads))
277 double_colon_index = n_hex_quads;
280 if (n_colon > 0 && n_hex_digits > 0)
282 hex_quads[n_hex_quads++] = hex_quad;
288 if (n_hex_digits > 0)
289 hex_quads[n_hex_quads++] = hex_quad;
294 /* Expand :: to appropriate number of zero hex quads. */
295 if (double_colon_index < ARRAY_LEN (hex_quads))
297 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
299 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
300 hex_quads[n_zero + i] = hex_quads[i];
302 for (i = 0; i < n_zero; i++)
303 hex_quads[double_colon_index + i] = 0;
305 n_hex_quads = ARRAY_LEN (hex_quads);
308 /* Too few hex quads given. */
309 if (n_hex_quads < ARRAY_LEN (hex_quads))
312 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
313 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
320 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
322 u32 *r = va_arg (*args, u32 *);
325 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
326 foreach_ipsec_policy_action
334 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
336 u32 *r = va_arg (*args, u32 *);
339 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
340 foreach_ipsec_crypto_alg
348 format_ipsec_crypto_alg (u8 * s, va_list * args)
350 u32 i = va_arg (*args, u32);
355 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
356 foreach_ipsec_crypto_alg
359 return format (s, "unknown");
361 return format (s, "%s", t);
365 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
367 u32 *r = va_arg (*args, u32 *);
370 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
371 foreach_ipsec_integ_alg
379 format_ipsec_integ_alg (u8 * s, va_list * args)
381 u32 i = va_arg (*args, u32);
386 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
387 foreach_ipsec_integ_alg
390 return format (s, "unknown");
392 return format (s, "%s", t);
396 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
398 u32 *r = va_arg (*args, u32 *);
401 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
402 foreach_ikev2_auth_method
410 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
412 u32 *r = va_arg (*args, u32 *);
415 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
416 foreach_ikev2_id_type
422 #else /* VPP_API_TEST_BUILTIN == 1 */
424 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
426 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
427 vnet_main_t *vnm = vnet_get_main ();
428 u32 *result = va_arg (*args, u32 *);
431 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
434 *result = sw_if_index;
437 #endif /* VPP_API_TEST_BUILTIN */
440 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
442 u8 *r = va_arg (*args, u8 *);
444 if (unformat (input, "kbps"))
445 *r = SSE2_QOS_RATE_KBPS;
446 else if (unformat (input, "pps"))
447 *r = SSE2_QOS_RATE_PPS;
454 unformat_policer_round_type (unformat_input_t * input, va_list * args)
456 u8 *r = va_arg (*args, u8 *);
458 if (unformat (input, "closest"))
459 *r = SSE2_QOS_ROUND_TO_CLOSEST;
460 else if (unformat (input, "up"))
461 *r = SSE2_QOS_ROUND_TO_UP;
462 else if (unformat (input, "down"))
463 *r = SSE2_QOS_ROUND_TO_DOWN;
470 unformat_policer_type (unformat_input_t * input, va_list * args)
472 u8 *r = va_arg (*args, u8 *);
474 if (unformat (input, "1r2c"))
475 *r = SSE2_QOS_POLICER_TYPE_1R2C;
476 else if (unformat (input, "1r3c"))
477 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
478 else if (unformat (input, "2r3c-2698"))
479 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
480 else if (unformat (input, "2r3c-4115"))
481 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
482 else if (unformat (input, "2r3c-mef5cf1"))
483 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
490 unformat_dscp (unformat_input_t * input, va_list * va)
492 u8 *r = va_arg (*va, u8 *);
495 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
504 unformat_policer_action_type (unformat_input_t * input, va_list * va)
506 sse2_qos_pol_action_params_st *a
507 = va_arg (*va, sse2_qos_pol_action_params_st *);
509 if (unformat (input, "drop"))
510 a->action_type = SSE2_QOS_ACTION_DROP;
511 else if (unformat (input, "transmit"))
512 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
513 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
514 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
521 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
523 u32 *r = va_arg (*va, u32 *);
526 if (unformat (input, "ip4"))
527 tid = POLICER_CLASSIFY_TABLE_IP4;
528 else if (unformat (input, "ip6"))
529 tid = POLICER_CLASSIFY_TABLE_IP6;
530 else if (unformat (input, "l2"))
531 tid = POLICER_CLASSIFY_TABLE_L2;
540 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
542 u32 *r = va_arg (*va, u32 *);
545 if (unformat (input, "ip4"))
546 tid = FLOW_CLASSIFY_TABLE_IP4;
547 else if (unformat (input, "ip6"))
548 tid = FLOW_CLASSIFY_TABLE_IP6;
556 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
557 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
558 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
559 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
561 #if (VPP_API_TEST_BUILTIN==0)
563 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
565 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
566 mfib_itf_attribute_t attr;
569 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
571 if (unformat (input, mfib_itf_flag_long_names[attr]))
572 *iflags |= (1 << attr);
574 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
576 if (unformat (input, mfib_itf_flag_names[attr]))
577 *iflags |= (1 << attr);
580 return (old == *iflags ? 0 : 1);
584 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
586 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
587 mfib_entry_attribute_t attr;
590 FOR_EACH_MFIB_ATTRIBUTE (attr)
592 if (unformat (input, mfib_flag_long_names[attr]))
593 *eflags |= (1 << attr);
595 FOR_EACH_MFIB_ATTRIBUTE (attr)
597 if (unformat (input, mfib_flag_names[attr]))
598 *eflags |= (1 << attr);
601 return (old == *eflags ? 0 : 1);
605 format_ip4_address (u8 * s, va_list * args)
607 u8 *a = va_arg (*args, u8 *);
608 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
612 format_ip6_address (u8 * s, va_list * args)
614 ip6_address_t *a = va_arg (*args, ip6_address_t *);
615 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
617 i_max_n_zero = ARRAY_LEN (a->as_u16);
619 i_first_zero = i_max_n_zero;
621 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
623 u32 is_zero = a->as_u16[i] == 0;
624 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
630 if ((!is_zero && n_zeros > max_n_zeros)
631 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
633 i_max_n_zero = i_first_zero;
634 max_n_zeros = n_zeros;
635 i_first_zero = ARRAY_LEN (a->as_u16);
640 last_double_colon = 0;
641 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
643 if (i == i_max_n_zero && max_n_zeros > 1)
645 s = format (s, "::");
646 i += max_n_zeros - 1;
647 last_double_colon = 1;
651 s = format (s, "%s%x",
652 (last_double_colon || i == 0) ? "" : ":",
653 clib_net_to_host_u16 (a->as_u16[i]));
654 last_double_colon = 0;
661 /* Format an IP46 address. */
663 format_ip46_address (u8 * s, va_list * args)
665 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
666 ip46_type_t type = va_arg (*args, ip46_type_t);
672 is_ip4 = ip46_address_is_ip4 (ip46);
683 format (s, "%U", format_ip4_address, &ip46->ip4) :
684 format (s, "%U", format_ip6_address, &ip46->ip6);
688 format_ethernet_address (u8 * s, va_list * args)
690 u8 *a = va_arg (*args, u8 *);
692 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
693 a[0], a[1], a[2], a[3], a[4], a[5]);
698 increment_v4_address (ip4_address_t * a)
702 v = ntohl (a->as_u32) + 1;
703 a->as_u32 = ntohl (v);
707 increment_v6_address (ip6_address_t * a)
711 v0 = clib_net_to_host_u64 (a->as_u64[0]);
712 v1 = clib_net_to_host_u64 (a->as_u64[1]);
717 a->as_u64[0] = clib_net_to_host_u64 (v0);
718 a->as_u64[1] = clib_net_to_host_u64 (v1);
722 increment_mac_address (u8 * mac)
724 u64 tmp = *((u64 *) mac);
725 tmp = clib_net_to_host_u64 (tmp);
726 tmp += 1 << 16; /* skip unused (least significant) octets */
727 tmp = clib_host_to_net_u64 (tmp);
729 clib_memcpy (mac, &tmp, 6);
732 static void vl_api_create_loopback_reply_t_handler
733 (vl_api_create_loopback_reply_t * mp)
735 vat_main_t *vam = &vat_main;
736 i32 retval = ntohl (mp->retval);
738 vam->retval = retval;
739 vam->regenerate_interface_table = 1;
740 vam->sw_if_index = ntohl (mp->sw_if_index);
741 vam->result_ready = 1;
744 static void vl_api_create_loopback_reply_t_handler_json
745 (vl_api_create_loopback_reply_t * mp)
747 vat_main_t *vam = &vat_main;
748 vat_json_node_t node;
750 vat_json_init_object (&node);
751 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
752 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
754 vat_json_print (vam->ofp, &node);
755 vat_json_free (&node);
756 vam->retval = ntohl (mp->retval);
757 vam->result_ready = 1;
760 static void vl_api_create_loopback_instance_reply_t_handler
761 (vl_api_create_loopback_instance_reply_t * mp)
763 vat_main_t *vam = &vat_main;
764 i32 retval = ntohl (mp->retval);
766 vam->retval = retval;
767 vam->regenerate_interface_table = 1;
768 vam->sw_if_index = ntohl (mp->sw_if_index);
769 vam->result_ready = 1;
772 static void vl_api_create_loopback_instance_reply_t_handler_json
773 (vl_api_create_loopback_instance_reply_t * mp)
775 vat_main_t *vam = &vat_main;
776 vat_json_node_t node;
778 vat_json_init_object (&node);
779 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
780 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
782 vat_json_print (vam->ofp, &node);
783 vat_json_free (&node);
784 vam->retval = ntohl (mp->retval);
785 vam->result_ready = 1;
788 static void vl_api_af_packet_create_reply_t_handler
789 (vl_api_af_packet_create_reply_t * mp)
791 vat_main_t *vam = &vat_main;
792 i32 retval = ntohl (mp->retval);
794 vam->retval = retval;
795 vam->regenerate_interface_table = 1;
796 vam->sw_if_index = ntohl (mp->sw_if_index);
797 vam->result_ready = 1;
800 static void vl_api_af_packet_create_reply_t_handler_json
801 (vl_api_af_packet_create_reply_t * mp)
803 vat_main_t *vam = &vat_main;
804 vat_json_node_t node;
806 vat_json_init_object (&node);
807 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
808 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
810 vat_json_print (vam->ofp, &node);
811 vat_json_free (&node);
813 vam->retval = ntohl (mp->retval);
814 vam->result_ready = 1;
817 static void vl_api_create_vlan_subif_reply_t_handler
818 (vl_api_create_vlan_subif_reply_t * mp)
820 vat_main_t *vam = &vat_main;
821 i32 retval = ntohl (mp->retval);
823 vam->retval = retval;
824 vam->regenerate_interface_table = 1;
825 vam->sw_if_index = ntohl (mp->sw_if_index);
826 vam->result_ready = 1;
829 static void vl_api_create_vlan_subif_reply_t_handler_json
830 (vl_api_create_vlan_subif_reply_t * mp)
832 vat_main_t *vam = &vat_main;
833 vat_json_node_t node;
835 vat_json_init_object (&node);
836 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
837 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
839 vat_json_print (vam->ofp, &node);
840 vat_json_free (&node);
842 vam->retval = ntohl (mp->retval);
843 vam->result_ready = 1;
846 static void vl_api_create_subif_reply_t_handler
847 (vl_api_create_subif_reply_t * mp)
849 vat_main_t *vam = &vat_main;
850 i32 retval = ntohl (mp->retval);
852 vam->retval = retval;
853 vam->regenerate_interface_table = 1;
854 vam->sw_if_index = ntohl (mp->sw_if_index);
855 vam->result_ready = 1;
858 static void vl_api_create_subif_reply_t_handler_json
859 (vl_api_create_subif_reply_t * mp)
861 vat_main_t *vam = &vat_main;
862 vat_json_node_t node;
864 vat_json_init_object (&node);
865 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
866 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
868 vat_json_print (vam->ofp, &node);
869 vat_json_free (&node);
871 vam->retval = ntohl (mp->retval);
872 vam->result_ready = 1;
875 static void vl_api_interface_name_renumber_reply_t_handler
876 (vl_api_interface_name_renumber_reply_t * mp)
878 vat_main_t *vam = &vat_main;
879 i32 retval = ntohl (mp->retval);
881 vam->retval = retval;
882 vam->regenerate_interface_table = 1;
883 vam->result_ready = 1;
886 static void vl_api_interface_name_renumber_reply_t_handler_json
887 (vl_api_interface_name_renumber_reply_t * mp)
889 vat_main_t *vam = &vat_main;
890 vat_json_node_t node;
892 vat_json_init_object (&node);
893 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
895 vat_json_print (vam->ofp, &node);
896 vat_json_free (&node);
898 vam->retval = ntohl (mp->retval);
899 vam->result_ready = 1;
903 * Special-case: build the interface table, maintain
904 * the next loopback sw_if_index vbl.
906 static void vl_api_sw_interface_details_t_handler
907 (vl_api_sw_interface_details_t * mp)
909 vat_main_t *vam = &vat_main;
910 u8 *s = format (0, "%s%c", mp->interface_name, 0);
912 hash_set_mem (vam->sw_if_index_by_interface_name, s,
913 ntohl (mp->sw_if_index));
915 /* In sub interface case, fill the sub interface table entry */
916 if (mp->sw_if_index != mp->sup_sw_if_index)
918 sw_interface_subif_t *sub = NULL;
920 vec_add2 (vam->sw_if_subif_table, sub, 1);
922 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
923 strncpy ((char *) sub->interface_name, (char *) s,
924 vec_len (sub->interface_name));
925 sub->sw_if_index = ntohl (mp->sw_if_index);
926 sub->sub_id = ntohl (mp->sub_id);
928 sub->sub_dot1ad = mp->sub_dot1ad;
929 sub->sub_number_of_tags = mp->sub_number_of_tags;
930 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
931 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
932 sub->sub_exact_match = mp->sub_exact_match;
933 sub->sub_default = mp->sub_default;
934 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
935 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
937 /* vlan tag rewrite */
938 sub->vtr_op = ntohl (mp->vtr_op);
939 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
940 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
941 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
945 static void vl_api_sw_interface_details_t_handler_json
946 (vl_api_sw_interface_details_t * mp)
948 vat_main_t *vam = &vat_main;
949 vat_json_node_t *node = NULL;
951 if (VAT_JSON_ARRAY != vam->json_tree.type)
953 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
954 vat_json_init_array (&vam->json_tree);
956 node = vat_json_array_add (&vam->json_tree);
958 vat_json_init_object (node);
959 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
960 vat_json_object_add_uint (node, "sup_sw_if_index",
961 ntohl (mp->sup_sw_if_index));
962 vat_json_object_add_uint (node, "l2_address_length",
963 ntohl (mp->l2_address_length));
964 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
965 sizeof (mp->l2_address));
966 vat_json_object_add_string_copy (node, "interface_name",
968 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
969 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
970 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
971 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
972 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
973 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
974 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
975 vat_json_object_add_uint (node, "sub_number_of_tags",
976 mp->sub_number_of_tags);
977 vat_json_object_add_uint (node, "sub_outer_vlan_id",
978 ntohs (mp->sub_outer_vlan_id));
979 vat_json_object_add_uint (node, "sub_inner_vlan_id",
980 ntohs (mp->sub_inner_vlan_id));
981 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
982 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
983 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
984 mp->sub_outer_vlan_id_any);
985 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
986 mp->sub_inner_vlan_id_any);
987 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
988 vat_json_object_add_uint (node, "vtr_push_dot1q",
989 ntohl (mp->vtr_push_dot1q));
990 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
991 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
994 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
996 format_ethernet_address,
998 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1000 format_ethernet_address,
1002 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1003 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1007 #if VPP_API_TEST_BUILTIN == 0
1008 static void vl_api_sw_interface_event_t_handler
1009 (vl_api_sw_interface_event_t * mp)
1011 vat_main_t *vam = &vat_main;
1012 if (vam->interface_event_display)
1013 errmsg ("interface flags: sw_if_index %d %s %s",
1014 ntohl (mp->sw_if_index),
1015 mp->admin_up_down ? "admin-up" : "admin-down",
1016 mp->link_up_down ? "link-up" : "link-down");
1020 static void vl_api_sw_interface_event_t_handler_json
1021 (vl_api_sw_interface_event_t * mp)
1023 /* JSON output not supported */
1027 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1029 vat_main_t *vam = &vat_main;
1030 i32 retval = ntohl (mp->retval);
1032 vam->retval = retval;
1033 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1034 vam->result_ready = 1;
1038 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1040 vat_main_t *vam = &vat_main;
1041 vat_json_node_t node;
1042 api_main_t *am = &api_main;
1046 vat_json_init_object (&node);
1047 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1048 vat_json_object_add_uint (&node, "reply_in_shmem",
1049 ntohl (mp->reply_in_shmem));
1050 /* Toss the shared-memory original... */
1051 pthread_mutex_lock (&am->vlib_rp->mutex);
1052 oldheap = svm_push_data_heap (am->vlib_rp);
1054 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1057 svm_pop_heap (oldheap);
1058 pthread_mutex_unlock (&am->vlib_rp->mutex);
1060 vat_json_print (vam->ofp, &node);
1061 vat_json_free (&node);
1063 vam->retval = ntohl (mp->retval);
1064 vam->result_ready = 1;
1068 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1070 vat_main_t *vam = &vat_main;
1071 i32 retval = ntohl (mp->retval);
1072 u32 length = ntohl (mp->length);
1074 vec_reset_length (vam->cmd_reply);
1076 vam->retval = retval;
1079 vec_validate (vam->cmd_reply, length);
1080 clib_memcpy ((char *) (vam->cmd_reply), mp->reply, length);
1081 vam->cmd_reply[length] = 0;
1083 vam->result_ready = 1;
1087 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1089 vat_main_t *vam = &vat_main;
1090 vat_json_node_t node;
1092 vec_reset_length (vam->cmd_reply);
1094 vat_json_init_object (&node);
1095 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1096 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1098 vat_json_print (vam->ofp, &node);
1099 vat_json_free (&node);
1101 vam->retval = ntohl (mp->retval);
1102 vam->result_ready = 1;
1105 static void vl_api_classify_add_del_table_reply_t_handler
1106 (vl_api_classify_add_del_table_reply_t * mp)
1108 vat_main_t *vam = &vat_main;
1109 i32 retval = ntohl (mp->retval);
1110 if (vam->async_mode)
1112 vam->async_errors += (retval < 0);
1116 vam->retval = retval;
1118 ((mp->new_table_index != 0xFFFFFFFF) ||
1119 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1120 (mp->match_n_vectors != 0xFFFFFFFF)))
1122 * Note: this is just barely thread-safe, depends on
1123 * the main thread spinning waiting for an answer...
1125 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1126 ntohl (mp->new_table_index),
1127 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1128 vam->result_ready = 1;
1132 static void vl_api_classify_add_del_table_reply_t_handler_json
1133 (vl_api_classify_add_del_table_reply_t * mp)
1135 vat_main_t *vam = &vat_main;
1136 vat_json_node_t node;
1138 vat_json_init_object (&node);
1139 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1140 vat_json_object_add_uint (&node, "new_table_index",
1141 ntohl (mp->new_table_index));
1142 vat_json_object_add_uint (&node, "skip_n_vectors",
1143 ntohl (mp->skip_n_vectors));
1144 vat_json_object_add_uint (&node, "match_n_vectors",
1145 ntohl (mp->match_n_vectors));
1147 vat_json_print (vam->ofp, &node);
1148 vat_json_free (&node);
1150 vam->retval = ntohl (mp->retval);
1151 vam->result_ready = 1;
1154 static void vl_api_get_node_index_reply_t_handler
1155 (vl_api_get_node_index_reply_t * mp)
1157 vat_main_t *vam = &vat_main;
1158 i32 retval = ntohl (mp->retval);
1159 if (vam->async_mode)
1161 vam->async_errors += (retval < 0);
1165 vam->retval = retval;
1167 errmsg ("node index %d", ntohl (mp->node_index));
1168 vam->result_ready = 1;
1172 static void vl_api_get_node_index_reply_t_handler_json
1173 (vl_api_get_node_index_reply_t * mp)
1175 vat_main_t *vam = &vat_main;
1176 vat_json_node_t node;
1178 vat_json_init_object (&node);
1179 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1180 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1182 vat_json_print (vam->ofp, &node);
1183 vat_json_free (&node);
1185 vam->retval = ntohl (mp->retval);
1186 vam->result_ready = 1;
1189 static void vl_api_get_next_index_reply_t_handler
1190 (vl_api_get_next_index_reply_t * mp)
1192 vat_main_t *vam = &vat_main;
1193 i32 retval = ntohl (mp->retval);
1194 if (vam->async_mode)
1196 vam->async_errors += (retval < 0);
1200 vam->retval = retval;
1202 errmsg ("next node index %d", ntohl (mp->next_index));
1203 vam->result_ready = 1;
1207 static void vl_api_get_next_index_reply_t_handler_json
1208 (vl_api_get_next_index_reply_t * mp)
1210 vat_main_t *vam = &vat_main;
1211 vat_json_node_t node;
1213 vat_json_init_object (&node);
1214 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1215 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1217 vat_json_print (vam->ofp, &node);
1218 vat_json_free (&node);
1220 vam->retval = ntohl (mp->retval);
1221 vam->result_ready = 1;
1224 static void vl_api_add_node_next_reply_t_handler
1225 (vl_api_add_node_next_reply_t * mp)
1227 vat_main_t *vam = &vat_main;
1228 i32 retval = ntohl (mp->retval);
1229 if (vam->async_mode)
1231 vam->async_errors += (retval < 0);
1235 vam->retval = retval;
1237 errmsg ("next index %d", ntohl (mp->next_index));
1238 vam->result_ready = 1;
1242 static void vl_api_add_node_next_reply_t_handler_json
1243 (vl_api_add_node_next_reply_t * mp)
1245 vat_main_t *vam = &vat_main;
1246 vat_json_node_t node;
1248 vat_json_init_object (&node);
1249 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1250 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1252 vat_json_print (vam->ofp, &node);
1253 vat_json_free (&node);
1255 vam->retval = ntohl (mp->retval);
1256 vam->result_ready = 1;
1259 static void vl_api_show_version_reply_t_handler
1260 (vl_api_show_version_reply_t * mp)
1262 vat_main_t *vam = &vat_main;
1263 i32 retval = ntohl (mp->retval);
1267 errmsg (" program: %s", mp->program);
1268 errmsg (" version: %s", mp->version);
1269 errmsg (" build date: %s", mp->build_date);
1270 errmsg ("build directory: %s", mp->build_directory);
1272 vam->retval = retval;
1273 vam->result_ready = 1;
1276 static void vl_api_show_version_reply_t_handler_json
1277 (vl_api_show_version_reply_t * mp)
1279 vat_main_t *vam = &vat_main;
1280 vat_json_node_t node;
1282 vat_json_init_object (&node);
1283 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1284 vat_json_object_add_string_copy (&node, "program", mp->program);
1285 vat_json_object_add_string_copy (&node, "version", mp->version);
1286 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1287 vat_json_object_add_string_copy (&node, "build_directory",
1288 mp->build_directory);
1290 vat_json_print (vam->ofp, &node);
1291 vat_json_free (&node);
1293 vam->retval = ntohl (mp->retval);
1294 vam->result_ready = 1;
1298 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1300 u32 sw_if_index = ntohl (mp->sw_if_index);
1301 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1302 mp->mac_ip ? "mac/ip binding" : "address resolution",
1303 ntohl (mp->pid), format_ip4_address, &mp->address,
1304 format_ethernet_address, mp->new_mac, sw_if_index);
1308 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1310 /* JSON output not supported */
1314 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1316 u32 sw_if_index = ntohl (mp->sw_if_index);
1317 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1318 mp->mac_ip ? "mac/ip binding" : "address resolution",
1319 ntohl (mp->pid), format_ip6_address, mp->address,
1320 format_ethernet_address, mp->new_mac, sw_if_index);
1324 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1326 /* JSON output not supported */
1330 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1332 u32 n_macs = ntohl (mp->n_macs);
1333 errmsg ("L2MAC event recived with pid %d cl-idx %d for %d macs: \n",
1334 ntohl (mp->pid), mp->client_index, n_macs);
1336 for (i = 0; i < n_macs; i++)
1338 vl_api_mac_entry_t *mac = &mp->mac[i];
1339 errmsg (" [%d] sw_if_index %d mac_addr %U is_del %d \n",
1340 i + 1, ntohl (mac->sw_if_index),
1341 format_ethernet_address, mac->mac_addr, mac->is_del);
1348 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1350 /* JSON output not supported */
1353 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1354 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1357 * Special-case: build the bridge domain table, maintain
1358 * the next bd id vbl.
1360 static void vl_api_bridge_domain_details_t_handler
1361 (vl_api_bridge_domain_details_t * mp)
1363 vat_main_t *vam = &vat_main;
1364 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1367 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1368 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1370 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1371 ntohl (mp->bd_id), mp->learn, mp->forward,
1372 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1376 vl_api_bridge_domain_sw_if_t *sw_ifs;
1377 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1380 sw_ifs = mp->sw_if_details;
1381 for (i = 0; i < n_sw_ifs; i++)
1387 sw_if_index = ntohl (sw_ifs->sw_if_index);
1390 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1392 if ((u32) p->value[0] == sw_if_index)
1394 sw_if_name = (u8 *)(p->key);
1399 print (vam->ofp, "%7d %3d %s", sw_if_index,
1400 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1401 "sw_if_index not found!");
1408 static void vl_api_bridge_domain_details_t_handler_json
1409 (vl_api_bridge_domain_details_t * mp)
1411 vat_main_t *vam = &vat_main;
1412 vat_json_node_t *node, *array = NULL;
1413 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1415 if (VAT_JSON_ARRAY != vam->json_tree.type)
1417 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1418 vat_json_init_array (&vam->json_tree);
1420 node = vat_json_array_add (&vam->json_tree);
1422 vat_json_init_object (node);
1423 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1424 vat_json_object_add_uint (node, "flood", mp->flood);
1425 vat_json_object_add_uint (node, "forward", mp->forward);
1426 vat_json_object_add_uint (node, "learn", mp->learn);
1427 vat_json_object_add_uint (node, "bvi_sw_if_index",
1428 ntohl (mp->bvi_sw_if_index));
1429 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1430 array = vat_json_object_add (node, "sw_if");
1431 vat_json_init_array (array);
1437 vl_api_bridge_domain_sw_if_t *sw_ifs;
1440 sw_ifs = mp->sw_if_details;
1441 for (i = 0; i < n_sw_ifs; i++)
1443 node = vat_json_array_add (array);
1444 vat_json_init_object (node);
1445 vat_json_object_add_uint (node, "sw_if_index",
1446 ntohl (sw_ifs->sw_if_index));
1447 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1453 static void vl_api_control_ping_reply_t_handler
1454 (vl_api_control_ping_reply_t * mp)
1456 vat_main_t *vam = &vat_main;
1457 i32 retval = ntohl (mp->retval);
1458 if (vam->async_mode)
1460 vam->async_errors += (retval < 0);
1464 vam->retval = retval;
1465 vam->result_ready = 1;
1467 vam->socket_client_main.control_pings_outstanding--;
1470 static void vl_api_control_ping_reply_t_handler_json
1471 (vl_api_control_ping_reply_t * mp)
1473 vat_main_t *vam = &vat_main;
1474 i32 retval = ntohl (mp->retval);
1476 if (VAT_JSON_NONE != vam->json_tree.type)
1478 vat_json_print (vam->ofp, &vam->json_tree);
1479 vat_json_free (&vam->json_tree);
1480 vam->json_tree.type = VAT_JSON_NONE;
1485 vat_json_init_array (&vam->json_tree);
1486 vat_json_print (vam->ofp, &vam->json_tree);
1487 vam->json_tree.type = VAT_JSON_NONE;
1490 vam->retval = retval;
1491 vam->result_ready = 1;
1495 vl_api_bridge_domain_set_mac_age_reply_t_handler
1496 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1498 vat_main_t *vam = &vat_main;
1499 i32 retval = ntohl (mp->retval);
1500 if (vam->async_mode)
1502 vam->async_errors += (retval < 0);
1506 vam->retval = retval;
1507 vam->result_ready = 1;
1511 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1512 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1514 vat_main_t *vam = &vat_main;
1515 vat_json_node_t node;
1517 vat_json_init_object (&node);
1518 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1520 vat_json_print (vam->ofp, &node);
1521 vat_json_free (&node);
1523 vam->retval = ntohl (mp->retval);
1524 vam->result_ready = 1;
1528 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1530 vat_main_t *vam = &vat_main;
1531 i32 retval = ntohl (mp->retval);
1532 if (vam->async_mode)
1534 vam->async_errors += (retval < 0);
1538 vam->retval = retval;
1539 vam->result_ready = 1;
1543 static void vl_api_l2_flags_reply_t_handler_json
1544 (vl_api_l2_flags_reply_t * mp)
1546 vat_main_t *vam = &vat_main;
1547 vat_json_node_t node;
1549 vat_json_init_object (&node);
1550 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1551 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1552 ntohl (mp->resulting_feature_bitmap));
1554 vat_json_print (vam->ofp, &node);
1555 vat_json_free (&node);
1557 vam->retval = ntohl (mp->retval);
1558 vam->result_ready = 1;
1561 static void vl_api_bridge_flags_reply_t_handler
1562 (vl_api_bridge_flags_reply_t * mp)
1564 vat_main_t *vam = &vat_main;
1565 i32 retval = ntohl (mp->retval);
1566 if (vam->async_mode)
1568 vam->async_errors += (retval < 0);
1572 vam->retval = retval;
1573 vam->result_ready = 1;
1577 static void vl_api_bridge_flags_reply_t_handler_json
1578 (vl_api_bridge_flags_reply_t * mp)
1580 vat_main_t *vam = &vat_main;
1581 vat_json_node_t node;
1583 vat_json_init_object (&node);
1584 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1585 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1586 ntohl (mp->resulting_feature_bitmap));
1588 vat_json_print (vam->ofp, &node);
1589 vat_json_free (&node);
1591 vam->retval = ntohl (mp->retval);
1592 vam->result_ready = 1;
1595 static void vl_api_tap_connect_reply_t_handler
1596 (vl_api_tap_connect_reply_t * mp)
1598 vat_main_t *vam = &vat_main;
1599 i32 retval = ntohl (mp->retval);
1600 if (vam->async_mode)
1602 vam->async_errors += (retval < 0);
1606 vam->retval = retval;
1607 vam->sw_if_index = ntohl (mp->sw_if_index);
1608 vam->result_ready = 1;
1613 static void vl_api_tap_connect_reply_t_handler_json
1614 (vl_api_tap_connect_reply_t * mp)
1616 vat_main_t *vam = &vat_main;
1617 vat_json_node_t node;
1619 vat_json_init_object (&node);
1620 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1621 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1623 vat_json_print (vam->ofp, &node);
1624 vat_json_free (&node);
1626 vam->retval = ntohl (mp->retval);
1627 vam->result_ready = 1;
1632 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1634 vat_main_t *vam = &vat_main;
1635 i32 retval = ntohl (mp->retval);
1636 if (vam->async_mode)
1638 vam->async_errors += (retval < 0);
1642 vam->retval = retval;
1643 vam->sw_if_index = ntohl (mp->sw_if_index);
1644 vam->result_ready = 1;
1648 static void vl_api_tap_modify_reply_t_handler_json
1649 (vl_api_tap_modify_reply_t * mp)
1651 vat_main_t *vam = &vat_main;
1652 vat_json_node_t node;
1654 vat_json_init_object (&node);
1655 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1656 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1658 vat_json_print (vam->ofp, &node);
1659 vat_json_free (&node);
1661 vam->retval = ntohl (mp->retval);
1662 vam->result_ready = 1;
1666 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1668 vat_main_t *vam = &vat_main;
1669 i32 retval = ntohl (mp->retval);
1670 if (vam->async_mode)
1672 vam->async_errors += (retval < 0);
1676 vam->retval = retval;
1677 vam->result_ready = 1;
1681 static void vl_api_tap_delete_reply_t_handler_json
1682 (vl_api_tap_delete_reply_t * mp)
1684 vat_main_t *vam = &vat_main;
1685 vat_json_node_t node;
1687 vat_json_init_object (&node);
1688 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1690 vat_json_print (vam->ofp, &node);
1691 vat_json_free (&node);
1693 vam->retval = ntohl (mp->retval);
1694 vam->result_ready = 1;
1697 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1698 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1700 vat_main_t *vam = &vat_main;
1701 i32 retval = ntohl (mp->retval);
1702 if (vam->async_mode)
1704 vam->async_errors += (retval < 0);
1708 vam->retval = retval;
1709 vam->result_ready = 1;
1713 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1714 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1716 vat_main_t *vam = &vat_main;
1717 vat_json_node_t node;
1719 vat_json_init_object (&node);
1720 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1721 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1722 ntohl (mp->sw_if_index));
1724 vat_json_print (vam->ofp, &node);
1725 vat_json_free (&node);
1727 vam->retval = ntohl (mp->retval);
1728 vam->result_ready = 1;
1731 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1732 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1734 vat_main_t *vam = &vat_main;
1735 i32 retval = ntohl (mp->retval);
1736 if (vam->async_mode)
1738 vam->async_errors += (retval < 0);
1742 vam->retval = retval;
1743 vam->sw_if_index = ntohl (mp->sw_if_index);
1744 vam->result_ready = 1;
1748 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1749 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1751 vat_main_t *vam = &vat_main;
1752 vat_json_node_t node;
1754 vat_json_init_object (&node);
1755 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1756 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1758 vat_json_print (vam->ofp, &node);
1759 vat_json_free (&node);
1761 vam->retval = ntohl (mp->retval);
1762 vam->result_ready = 1;
1765 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
1766 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1768 vat_main_t *vam = &vat_main;
1769 i32 retval = ntohl (mp->retval);
1770 if (vam->async_mode)
1772 vam->async_errors += (retval < 0);
1776 vam->retval = retval;
1777 vam->result_ready = 1;
1781 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
1782 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1784 vat_main_t *vam = &vat_main;
1785 vat_json_node_t node;
1787 vat_json_init_object (&node);
1788 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1789 vat_json_object_add_uint (&node, "fwd_entry_index",
1790 clib_net_to_host_u32 (mp->fwd_entry_index));
1792 vat_json_print (vam->ofp, &node);
1793 vat_json_free (&node);
1795 vam->retval = ntohl (mp->retval);
1796 vam->result_ready = 1;
1800 format_lisp_transport_protocol (u8 * s, va_list * args)
1802 u32 proto = va_arg (*args, u32);
1807 return format (s, "udp");
1809 return format (s, "api");
1816 static void vl_api_one_get_transport_protocol_reply_t_handler
1817 (vl_api_one_get_transport_protocol_reply_t * mp)
1819 vat_main_t *vam = &vat_main;
1820 i32 retval = ntohl (mp->retval);
1821 if (vam->async_mode)
1823 vam->async_errors += (retval < 0);
1827 u32 proto = mp->protocol;
1828 print (vam->ofp, "Transport protocol: %U",
1829 format_lisp_transport_protocol, proto);
1830 vam->retval = retval;
1831 vam->result_ready = 1;
1835 static void vl_api_one_get_transport_protocol_reply_t_handler_json
1836 (vl_api_one_get_transport_protocol_reply_t * mp)
1838 vat_main_t *vam = &vat_main;
1839 vat_json_node_t node;
1842 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
1845 vat_json_init_object (&node);
1846 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1847 vat_json_object_add_string_copy (&node, "transport-protocol", s);
1850 vat_json_print (vam->ofp, &node);
1851 vat_json_free (&node);
1853 vam->retval = ntohl (mp->retval);
1854 vam->result_ready = 1;
1857 static void vl_api_one_add_del_locator_set_reply_t_handler
1858 (vl_api_one_add_del_locator_set_reply_t * mp)
1860 vat_main_t *vam = &vat_main;
1861 i32 retval = ntohl (mp->retval);
1862 if (vam->async_mode)
1864 vam->async_errors += (retval < 0);
1868 vam->retval = retval;
1869 vam->result_ready = 1;
1873 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1874 (vl_api_one_add_del_locator_set_reply_t * mp)
1876 vat_main_t *vam = &vat_main;
1877 vat_json_node_t node;
1879 vat_json_init_object (&node);
1880 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1881 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1883 vat_json_print (vam->ofp, &node);
1884 vat_json_free (&node);
1886 vam->retval = ntohl (mp->retval);
1887 vam->result_ready = 1;
1890 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1891 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1893 vat_main_t *vam = &vat_main;
1894 i32 retval = ntohl (mp->retval);
1895 if (vam->async_mode)
1897 vam->async_errors += (retval < 0);
1901 vam->retval = retval;
1902 vam->sw_if_index = ntohl (mp->sw_if_index);
1903 vam->result_ready = 1;
1907 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1908 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1910 vat_main_t *vam = &vat_main;
1911 vat_json_node_t node;
1913 vat_json_init_object (&node);
1914 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1915 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1917 vat_json_print (vam->ofp, &node);
1918 vat_json_free (&node);
1920 vam->retval = ntohl (mp->retval);
1921 vam->result_ready = 1;
1924 static void vl_api_geneve_add_del_tunnel_reply_t_handler
1925 (vl_api_geneve_add_del_tunnel_reply_t * mp)
1927 vat_main_t *vam = &vat_main;
1928 i32 retval = ntohl (mp->retval);
1929 if (vam->async_mode)
1931 vam->async_errors += (retval < 0);
1935 vam->retval = retval;
1936 vam->sw_if_index = ntohl (mp->sw_if_index);
1937 vam->result_ready = 1;
1941 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
1942 (vl_api_geneve_add_del_tunnel_reply_t * mp)
1944 vat_main_t *vam = &vat_main;
1945 vat_json_node_t node;
1947 vat_json_init_object (&node);
1948 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1949 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1951 vat_json_print (vam->ofp, &node);
1952 vat_json_free (&node);
1954 vam->retval = ntohl (mp->retval);
1955 vam->result_ready = 1;
1958 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
1959 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1961 vat_main_t *vam = &vat_main;
1962 i32 retval = ntohl (mp->retval);
1963 if (vam->async_mode)
1965 vam->async_errors += (retval < 0);
1969 vam->retval = retval;
1970 vam->sw_if_index = ntohl (mp->sw_if_index);
1971 vam->result_ready = 1;
1975 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
1976 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1978 vat_main_t *vam = &vat_main;
1979 vat_json_node_t node;
1981 vat_json_init_object (&node);
1982 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1983 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1985 vat_json_print (vam->ofp, &node);
1986 vat_json_free (&node);
1988 vam->retval = ntohl (mp->retval);
1989 vam->result_ready = 1;
1992 static void vl_api_gre_add_del_tunnel_reply_t_handler
1993 (vl_api_gre_add_del_tunnel_reply_t * mp)
1995 vat_main_t *vam = &vat_main;
1996 i32 retval = ntohl (mp->retval);
1997 if (vam->async_mode)
1999 vam->async_errors += (retval < 0);
2003 vam->retval = retval;
2004 vam->sw_if_index = ntohl (mp->sw_if_index);
2005 vam->result_ready = 1;
2009 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2010 (vl_api_gre_add_del_tunnel_reply_t * mp)
2012 vat_main_t *vam = &vat_main;
2013 vat_json_node_t node;
2015 vat_json_init_object (&node);
2016 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2017 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2019 vat_json_print (vam->ofp, &node);
2020 vat_json_free (&node);
2022 vam->retval = ntohl (mp->retval);
2023 vam->result_ready = 1;
2026 static void vl_api_create_vhost_user_if_reply_t_handler
2027 (vl_api_create_vhost_user_if_reply_t * mp)
2029 vat_main_t *vam = &vat_main;
2030 i32 retval = ntohl (mp->retval);
2031 if (vam->async_mode)
2033 vam->async_errors += (retval < 0);
2037 vam->retval = retval;
2038 vam->sw_if_index = ntohl (mp->sw_if_index);
2039 vam->result_ready = 1;
2043 static void vl_api_create_vhost_user_if_reply_t_handler_json
2044 (vl_api_create_vhost_user_if_reply_t * mp)
2046 vat_main_t *vam = &vat_main;
2047 vat_json_node_t node;
2049 vat_json_init_object (&node);
2050 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2051 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2053 vat_json_print (vam->ofp, &node);
2054 vat_json_free (&node);
2056 vam->retval = ntohl (mp->retval);
2057 vam->result_ready = 1;
2060 static clib_error_t *
2061 receive_fd_msg (int socket_fd, int *my_fd)
2064 char ctl[CMSG_SPACE (sizeof (int)) + CMSG_SPACE (sizeof (struct ucred))];
2065 struct msghdr mh = { 0 };
2066 struct iovec iov[1];
2068 struct ucred *cr = 0;
2069 struct cmsghdr *cmsg;
2070 pid_t pid __attribute__ ((unused));
2071 uid_t uid __attribute__ ((unused));
2072 gid_t gid __attribute__ ((unused));
2074 iov[0].iov_base = msgbuf;
2078 mh.msg_control = ctl;
2079 mh.msg_controllen = sizeof (ctl);
2081 memset (ctl, 0, sizeof (ctl));
2083 /* receive the incoming message */
2084 size = recvmsg (socket_fd, &mh, 0);
2087 return (size == 0) ? clib_error_return (0, "disconnected") :
2088 clib_error_return_unix (0, "recvmsg: malformed message (fd %d)",
2092 cmsg = CMSG_FIRSTHDR (&mh);
2095 if (cmsg->cmsg_level == SOL_SOCKET)
2097 if (cmsg->cmsg_type == SCM_CREDENTIALS)
2099 cr = (struct ucred *) CMSG_DATA (cmsg);
2104 else if (cmsg->cmsg_type == SCM_RIGHTS)
2106 clib_memcpy (my_fd, CMSG_DATA (cmsg), sizeof (int));
2109 cmsg = CMSG_NXTHDR (&mh, cmsg);
2114 static void vl_api_memfd_segment_create_reply_t_handler
2115 (vl_api_memfd_segment_create_reply_t * mp)
2117 /* Dont bother in the builtin version */
2118 #if VPP_API_TEST_BUILTIN == 0
2119 vat_main_t *vam = &vat_main;
2120 api_main_t *am = &api_main;
2121 socket_client_main_t *scm = &vam->socket_client_main;
2123 clib_error_t *error;
2124 memfd_private_t memfd;
2125 i32 retval = ntohl (mp->retval);
2129 error = receive_fd_msg (scm->socket_fd, &my_fd);
2136 memset (&memfd, 0, sizeof (memfd));
2139 vam->client_index_invalid = 1;
2141 /* Note: this closes memfd.fd */
2142 retval = memfd_slave_init (&memfd);
2144 clib_warning ("WARNING: segment map returned %d", retval);
2146 /* Pivot to the memory client segment that vpp just created */
2148 am->vlib_rp = (void *) (memfd.requested_va + MMAP_PAGESIZE);
2150 am->shmem_hdr = (void *) am->vlib_rp->user_ctx;
2152 vl_client_install_client_message_handlers ();
2154 vl_client_connect_to_vlib_no_map ("pvt",
2156 32 /* input_queue_length */ );
2157 vam->vl_input_queue = am->shmem_hdr->vl_input_queue;
2159 vl_socket_client_enable_disable (&vam->socket_client_main,
2160 0 /* disable socket */ );
2164 if (vam->async_mode)
2166 vam->async_errors += (retval < 0);
2170 vam->retval = retval;
2171 vam->result_ready = 1;
2176 static void vl_api_memfd_segment_create_reply_t_handler_json
2177 (vl_api_memfd_segment_create_reply_t * mp)
2179 clib_warning ("no");
2182 static void vl_api_dns_resolve_name_reply_t_handler
2183 (vl_api_dns_resolve_name_reply_t * mp)
2185 vat_main_t *vam = &vat_main;
2186 i32 retval = ntohl (mp->retval);
2187 if (vam->async_mode)
2189 vam->async_errors += (retval < 0);
2193 vam->retval = retval;
2194 vam->result_ready = 1;
2199 clib_warning ("ip4 address %U", format_ip4_address,
2200 (ip4_address_t *) mp->ip4_address);
2202 clib_warning ("ip6 address %U", format_ip6_address,
2203 (ip6_address_t *) mp->ip6_address);
2206 clib_warning ("retval %d", retval);
2210 static void vl_api_dns_resolve_name_reply_t_handler_json
2211 (vl_api_dns_resolve_name_reply_t * mp)
2213 clib_warning ("not implemented");
2216 static void vl_api_dns_resolve_ip_reply_t_handler
2217 (vl_api_dns_resolve_ip_reply_t * mp)
2219 vat_main_t *vam = &vat_main;
2220 i32 retval = ntohl (mp->retval);
2221 if (vam->async_mode)
2223 vam->async_errors += (retval < 0);
2227 vam->retval = retval;
2228 vam->result_ready = 1;
2232 clib_warning ("canonical name %s", mp->name);
2235 clib_warning ("retval %d", retval);
2239 static void vl_api_dns_resolve_ip_reply_t_handler_json
2240 (vl_api_dns_resolve_ip_reply_t * mp)
2242 clib_warning ("not implemented");
2246 static void vl_api_ip_address_details_t_handler
2247 (vl_api_ip_address_details_t * mp)
2249 vat_main_t *vam = &vat_main;
2250 static ip_address_details_t empty_ip_address_details = { {0} };
2251 ip_address_details_t *address = NULL;
2252 ip_details_t *current_ip_details = NULL;
2253 ip_details_t *details = NULL;
2255 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2257 if (!details || vam->current_sw_if_index >= vec_len (details)
2258 || !details[vam->current_sw_if_index].present)
2260 errmsg ("ip address details arrived but not stored");
2261 errmsg ("ip_dump should be called first");
2265 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2267 #define addresses (current_ip_details->addr)
2269 vec_validate_init_empty (addresses, vec_len (addresses),
2270 empty_ip_address_details);
2272 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2274 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2275 address->prefix_length = mp->prefix_length;
2279 static void vl_api_ip_address_details_t_handler_json
2280 (vl_api_ip_address_details_t * mp)
2282 vat_main_t *vam = &vat_main;
2283 vat_json_node_t *node = NULL;
2284 struct in6_addr ip6;
2287 if (VAT_JSON_ARRAY != vam->json_tree.type)
2289 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2290 vat_json_init_array (&vam->json_tree);
2292 node = vat_json_array_add (&vam->json_tree);
2294 vat_json_init_object (node);
2297 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2298 vat_json_object_add_ip6 (node, "ip", ip6);
2302 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2303 vat_json_object_add_ip4 (node, "ip", ip4);
2305 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2309 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2311 vat_main_t *vam = &vat_main;
2312 static ip_details_t empty_ip_details = { 0 };
2313 ip_details_t *ip = NULL;
2314 u32 sw_if_index = ~0;
2316 sw_if_index = ntohl (mp->sw_if_index);
2318 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2319 sw_if_index, empty_ip_details);
2321 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2328 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2330 vat_main_t *vam = &vat_main;
2332 if (VAT_JSON_ARRAY != vam->json_tree.type)
2334 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2335 vat_json_init_array (&vam->json_tree);
2337 vat_json_array_add_uint (&vam->json_tree,
2338 clib_net_to_host_u32 (mp->sw_if_index));
2341 static void vl_api_map_domain_details_t_handler_json
2342 (vl_api_map_domain_details_t * mp)
2344 vat_json_node_t *node = NULL;
2345 vat_main_t *vam = &vat_main;
2346 struct in6_addr ip6;
2349 if (VAT_JSON_ARRAY != vam->json_tree.type)
2351 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2352 vat_json_init_array (&vam->json_tree);
2355 node = vat_json_array_add (&vam->json_tree);
2356 vat_json_init_object (node);
2358 vat_json_object_add_uint (node, "domain_index",
2359 clib_net_to_host_u32 (mp->domain_index));
2360 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2361 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2362 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2363 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2364 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2365 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2366 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2367 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2368 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2369 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2370 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2371 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2372 vat_json_object_add_uint (node, "flags", mp->flags);
2373 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2374 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2377 static void vl_api_map_domain_details_t_handler
2378 (vl_api_map_domain_details_t * mp)
2380 vat_main_t *vam = &vat_main;
2382 if (mp->is_translation)
2385 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2386 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2387 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2388 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2389 clib_net_to_host_u32 (mp->domain_index));
2394 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2395 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2396 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2397 format_ip6_address, mp->ip6_src,
2398 clib_net_to_host_u32 (mp->domain_index));
2400 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2401 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2402 mp->is_translation ? "map-t" : "");
2405 static void vl_api_map_rule_details_t_handler_json
2406 (vl_api_map_rule_details_t * mp)
2408 struct in6_addr ip6;
2409 vat_json_node_t *node = NULL;
2410 vat_main_t *vam = &vat_main;
2412 if (VAT_JSON_ARRAY != vam->json_tree.type)
2414 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2415 vat_json_init_array (&vam->json_tree);
2418 node = vat_json_array_add (&vam->json_tree);
2419 vat_json_init_object (node);
2421 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2422 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2423 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2427 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2429 vat_main_t *vam = &vat_main;
2430 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2431 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2435 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2437 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2438 "router_addr %U host_mac %U",
2439 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2440 format_ip4_address, &mp->host_address,
2441 format_ip4_address, &mp->router_address,
2442 format_ethernet_address, mp->host_mac);
2445 static void vl_api_dhcp_compl_event_t_handler_json
2446 (vl_api_dhcp_compl_event_t * mp)
2448 /* JSON output not supported */
2452 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2455 vat_main_t *vam = &vat_main;
2456 static u64 default_counter = 0;
2458 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2460 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2461 sw_if_index, default_counter);
2462 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2466 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2467 interface_counter_t counter)
2469 vat_main_t *vam = &vat_main;
2470 static interface_counter_t default_counter = { 0, };
2472 vec_validate_init_empty (vam->combined_interface_counters,
2473 vnet_counter_type, NULL);
2474 vec_validate_init_empty (vam->combined_interface_counters
2475 [vnet_counter_type], sw_if_index, default_counter);
2476 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2479 static void vl_api_vnet_interface_simple_counters_t_handler
2480 (vl_api_vnet_interface_simple_counters_t * mp)
2485 static void vl_api_vnet_interface_combined_counters_t_handler
2486 (vl_api_vnet_interface_combined_counters_t * mp)
2491 static void vl_api_vnet_interface_simple_counters_t_handler_json
2492 (vl_api_vnet_interface_simple_counters_t * mp)
2497 u32 first_sw_if_index;
2500 count = ntohl (mp->count);
2501 first_sw_if_index = ntohl (mp->first_sw_if_index);
2503 v_packets = (u64 *) & mp->data;
2504 for (i = 0; i < count; i++)
2506 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2507 set_simple_interface_counter (mp->vnet_counter_type,
2508 first_sw_if_index + i, packets);
2513 static void vl_api_vnet_interface_combined_counters_t_handler_json
2514 (vl_api_vnet_interface_combined_counters_t * mp)
2516 interface_counter_t counter;
2518 u32 first_sw_if_index;
2522 count = ntohl (mp->count);
2523 first_sw_if_index = ntohl (mp->first_sw_if_index);
2525 v = (vlib_counter_t *) & mp->data;
2526 for (i = 0; i < count; i++)
2529 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2531 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2532 set_combined_interface_counter (mp->vnet_counter_type,
2533 first_sw_if_index + i, counter);
2539 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2541 vat_main_t *vam = &vat_main;
2544 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2546 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2555 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2557 vat_main_t *vam = &vat_main;
2560 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2562 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2570 static void vl_api_vnet_ip4_fib_counters_t_handler
2571 (vl_api_vnet_ip4_fib_counters_t * mp)
2576 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2577 (vl_api_vnet_ip4_fib_counters_t * mp)
2579 vat_main_t *vam = &vat_main;
2580 vl_api_ip4_fib_counter_t *v;
2581 ip4_fib_counter_t *counter;
2588 vrf_id = ntohl (mp->vrf_id);
2589 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2590 if (~0 == vrf_index)
2592 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2593 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2594 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2595 vec_validate (vam->ip4_fib_counters, vrf_index);
2596 vam->ip4_fib_counters[vrf_index] = NULL;
2599 vec_free (vam->ip4_fib_counters[vrf_index]);
2600 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2601 count = ntohl (mp->count);
2602 for (i = 0; i < count; i++)
2604 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2605 counter = &vam->ip4_fib_counters[vrf_index][i];
2606 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2607 counter->address = ip4;
2608 counter->address_length = v->address_length;
2609 counter->packets = clib_net_to_host_u64 (v->packets);
2610 counter->bytes = clib_net_to_host_u64 (v->bytes);
2615 static void vl_api_vnet_ip4_nbr_counters_t_handler
2616 (vl_api_vnet_ip4_nbr_counters_t * mp)
2621 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2622 (vl_api_vnet_ip4_nbr_counters_t * mp)
2624 vat_main_t *vam = &vat_main;
2625 vl_api_ip4_nbr_counter_t *v;
2626 ip4_nbr_counter_t *counter;
2631 sw_if_index = ntohl (mp->sw_if_index);
2632 count = ntohl (mp->count);
2633 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2636 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2638 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2639 for (i = 0; i < count; i++)
2641 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2642 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2643 counter->address.s_addr = v->address;
2644 counter->packets = clib_net_to_host_u64 (v->packets);
2645 counter->bytes = clib_net_to_host_u64 (v->bytes);
2646 counter->linkt = v->link_type;
2651 static void vl_api_vnet_ip6_fib_counters_t_handler
2652 (vl_api_vnet_ip6_fib_counters_t * mp)
2657 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2658 (vl_api_vnet_ip6_fib_counters_t * mp)
2660 vat_main_t *vam = &vat_main;
2661 vl_api_ip6_fib_counter_t *v;
2662 ip6_fib_counter_t *counter;
2663 struct in6_addr ip6;
2669 vrf_id = ntohl (mp->vrf_id);
2670 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2671 if (~0 == vrf_index)
2673 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2674 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2675 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2676 vec_validate (vam->ip6_fib_counters, vrf_index);
2677 vam->ip6_fib_counters[vrf_index] = NULL;
2680 vec_free (vam->ip6_fib_counters[vrf_index]);
2681 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2682 count = ntohl (mp->count);
2683 for (i = 0; i < count; i++)
2685 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2686 counter = &vam->ip6_fib_counters[vrf_index][i];
2687 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2688 counter->address = ip6;
2689 counter->address_length = v->address_length;
2690 counter->packets = clib_net_to_host_u64 (v->packets);
2691 counter->bytes = clib_net_to_host_u64 (v->bytes);
2696 static void vl_api_vnet_ip6_nbr_counters_t_handler
2697 (vl_api_vnet_ip6_nbr_counters_t * mp)
2702 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2703 (vl_api_vnet_ip6_nbr_counters_t * mp)
2705 vat_main_t *vam = &vat_main;
2706 vl_api_ip6_nbr_counter_t *v;
2707 ip6_nbr_counter_t *counter;
2708 struct in6_addr ip6;
2713 sw_if_index = ntohl (mp->sw_if_index);
2714 count = ntohl (mp->count);
2715 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2718 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2720 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2721 for (i = 0; i < count; i++)
2723 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2724 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2725 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2726 counter->address = ip6;
2727 counter->packets = clib_net_to_host_u64 (v->packets);
2728 counter->bytes = clib_net_to_host_u64 (v->bytes);
2733 static void vl_api_get_first_msg_id_reply_t_handler
2734 (vl_api_get_first_msg_id_reply_t * mp)
2736 vat_main_t *vam = &vat_main;
2737 i32 retval = ntohl (mp->retval);
2739 if (vam->async_mode)
2741 vam->async_errors += (retval < 0);
2745 vam->retval = retval;
2746 vam->result_ready = 1;
2750 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2754 static void vl_api_get_first_msg_id_reply_t_handler_json
2755 (vl_api_get_first_msg_id_reply_t * mp)
2757 vat_main_t *vam = &vat_main;
2758 vat_json_node_t node;
2760 vat_json_init_object (&node);
2761 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2762 vat_json_object_add_uint (&node, "first_msg_id",
2763 (uint) ntohs (mp->first_msg_id));
2765 vat_json_print (vam->ofp, &node);
2766 vat_json_free (&node);
2768 vam->retval = ntohl (mp->retval);
2769 vam->result_ready = 1;
2772 static void vl_api_get_node_graph_reply_t_handler
2773 (vl_api_get_node_graph_reply_t * mp)
2775 vat_main_t *vam = &vat_main;
2776 api_main_t *am = &api_main;
2777 i32 retval = ntohl (mp->retval);
2778 u8 *pvt_copy, *reply;
2783 if (vam->async_mode)
2785 vam->async_errors += (retval < 0);
2789 vam->retval = retval;
2790 vam->result_ready = 1;
2793 /* "Should never happen..." */
2797 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2798 pvt_copy = vec_dup (reply);
2800 /* Toss the shared-memory original... */
2801 pthread_mutex_lock (&am->vlib_rp->mutex);
2802 oldheap = svm_push_data_heap (am->vlib_rp);
2806 svm_pop_heap (oldheap);
2807 pthread_mutex_unlock (&am->vlib_rp->mutex);
2809 if (vam->graph_nodes)
2811 hash_free (vam->graph_node_index_by_name);
2813 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2815 node = vam->graph_nodes[i];
2816 vec_free (node->name);
2817 vec_free (node->next_nodes);
2820 vec_free (vam->graph_nodes);
2823 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2824 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2825 vec_free (pvt_copy);
2827 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2829 node = vam->graph_nodes[i];
2830 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2834 static void vl_api_get_node_graph_reply_t_handler_json
2835 (vl_api_get_node_graph_reply_t * mp)
2837 vat_main_t *vam = &vat_main;
2838 api_main_t *am = &api_main;
2840 vat_json_node_t node;
2843 /* $$$$ make this real? */
2844 vat_json_init_object (&node);
2845 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2846 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2848 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2850 /* Toss the shared-memory original... */
2851 pthread_mutex_lock (&am->vlib_rp->mutex);
2852 oldheap = svm_push_data_heap (am->vlib_rp);
2856 svm_pop_heap (oldheap);
2857 pthread_mutex_unlock (&am->vlib_rp->mutex);
2859 vat_json_print (vam->ofp, &node);
2860 vat_json_free (&node);
2862 vam->retval = ntohl (mp->retval);
2863 vam->result_ready = 1;
2867 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2869 vat_main_t *vam = &vat_main;
2874 s = format (s, "%=16d%=16d%=16d",
2875 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2879 s = format (s, "%=16U%=16d%=16d",
2880 mp->is_ipv6 ? format_ip6_address :
2882 mp->ip_address, mp->priority, mp->weight);
2885 print (vam->ofp, "%v", s);
2890 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2892 vat_main_t *vam = &vat_main;
2893 vat_json_node_t *node = NULL;
2894 struct in6_addr ip6;
2897 if (VAT_JSON_ARRAY != vam->json_tree.type)
2899 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2900 vat_json_init_array (&vam->json_tree);
2902 node = vat_json_array_add (&vam->json_tree);
2903 vat_json_init_object (node);
2905 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2906 vat_json_object_add_uint (node, "priority", mp->priority);
2907 vat_json_object_add_uint (node, "weight", mp->weight);
2910 vat_json_object_add_uint (node, "sw_if_index",
2911 clib_net_to_host_u32 (mp->sw_if_index));
2916 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2917 vat_json_object_add_ip6 (node, "address", ip6);
2921 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2922 vat_json_object_add_ip4 (node, "address", ip4);
2928 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2931 vat_main_t *vam = &vat_main;
2934 ls_name = format (0, "%s", mp->ls_name);
2936 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2942 vl_api_one_locator_set_details_t_handler_json
2943 (vl_api_one_locator_set_details_t * mp)
2945 vat_main_t *vam = &vat_main;
2946 vat_json_node_t *node = 0;
2949 ls_name = format (0, "%s", mp->ls_name);
2950 vec_add1 (ls_name, 0);
2952 if (VAT_JSON_ARRAY != vam->json_tree.type)
2954 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2955 vat_json_init_array (&vam->json_tree);
2957 node = vat_json_array_add (&vam->json_tree);
2959 vat_json_init_object (node);
2960 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2961 vat_json_object_add_uint (node, "ls_index",
2962 clib_net_to_host_u32 (mp->ls_index));
2970 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2973 unformat_nsh_address (unformat_input_t * input, va_list * args)
2975 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2976 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2980 format_nsh_address_vat (u8 * s, va_list * args)
2982 nsh_t *a = va_arg (*args, nsh_t *);
2983 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2987 format_lisp_flat_eid (u8 * s, va_list * args)
2989 u32 type = va_arg (*args, u32);
2990 u8 *eid = va_arg (*args, u8 *);
2991 u32 eid_len = va_arg (*args, u32);
2996 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2998 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3000 return format (s, "%U", format_ethernet_address, eid);
3002 return format (s, "%U", format_nsh_address_vat, eid);
3008 format_lisp_eid_vat (u8 * s, va_list * args)
3010 u32 type = va_arg (*args, u32);
3011 u8 *eid = va_arg (*args, u8 *);
3012 u32 eid_len = va_arg (*args, u32);
3013 u8 *seid = va_arg (*args, u8 *);
3014 u32 seid_len = va_arg (*args, u32);
3015 u32 is_src_dst = va_arg (*args, u32);
3018 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3020 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3026 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3028 vat_main_t *vam = &vat_main;
3029 u8 *s = 0, *eid = 0;
3031 if (~0 == mp->locator_set_index)
3032 s = format (0, "action: %d", mp->action);
3034 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3036 eid = format (0, "%U", format_lisp_eid_vat,
3040 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3043 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3044 clib_net_to_host_u32 (mp->vni),
3046 mp->is_local ? "local" : "remote",
3047 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3048 clib_net_to_host_u16 (mp->key_id), mp->key);
3055 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3058 vat_main_t *vam = &vat_main;
3059 vat_json_node_t *node = 0;
3062 if (VAT_JSON_ARRAY != vam->json_tree.type)
3064 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3065 vat_json_init_array (&vam->json_tree);
3067 node = vat_json_array_add (&vam->json_tree);
3069 vat_json_init_object (node);
3070 if (~0 == mp->locator_set_index)
3071 vat_json_object_add_uint (node, "action", mp->action);
3073 vat_json_object_add_uint (node, "locator_set_index",
3074 clib_net_to_host_u32 (mp->locator_set_index));
3076 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3077 if (mp->eid_type == 3)
3079 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3080 vat_json_init_object (nsh_json);
3081 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3082 vat_json_object_add_uint (nsh_json, "spi",
3083 clib_net_to_host_u32 (nsh->spi));
3084 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3088 eid = format (0, "%U", format_lisp_eid_vat,
3092 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3094 vat_json_object_add_string_copy (node, "eid", eid);
3097 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3098 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3099 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3103 vat_json_object_add_uint (node, "key_id",
3104 clib_net_to_host_u16 (mp->key_id));
3105 vat_json_object_add_string_copy (node, "key", mp->key);
3110 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3112 vat_main_t *vam = &vat_main;
3113 u8 *seid = 0, *deid = 0;
3114 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3116 deid = format (0, "%U", format_lisp_eid_vat,
3117 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3119 seid = format (0, "%U", format_lisp_eid_vat,
3120 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3126 format_ip_address_fcn = format_ip4_address;
3128 format_ip_address_fcn = format_ip6_address;
3131 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3132 clib_net_to_host_u32 (mp->vni),
3134 format_ip_address_fcn, mp->lloc,
3135 format_ip_address_fcn, mp->rloc,
3136 clib_net_to_host_u32 (mp->pkt_count),
3137 clib_net_to_host_u32 (mp->bytes));
3144 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3146 struct in6_addr ip6;
3148 vat_main_t *vam = &vat_main;
3149 vat_json_node_t *node = 0;
3150 u8 *deid = 0, *seid = 0;
3152 if (VAT_JSON_ARRAY != vam->json_tree.type)
3154 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3155 vat_json_init_array (&vam->json_tree);
3157 node = vat_json_array_add (&vam->json_tree);
3159 vat_json_init_object (node);
3160 deid = format (0, "%U", format_lisp_eid_vat,
3161 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3163 seid = format (0, "%U", format_lisp_eid_vat,
3164 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3169 vat_json_object_add_string_copy (node, "seid", seid);
3170 vat_json_object_add_string_copy (node, "deid", deid);
3171 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3175 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3176 vat_json_object_add_ip4 (node, "lloc", ip4);
3177 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3178 vat_json_object_add_ip4 (node, "rloc", ip4);
3182 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3183 vat_json_object_add_ip6 (node, "lloc", ip6);
3184 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3185 vat_json_object_add_ip6 (node, "rloc", ip6);
3187 vat_json_object_add_uint (node, "pkt_count",
3188 clib_net_to_host_u32 (mp->pkt_count));
3189 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3196 vl_api_one_eid_table_map_details_t_handler
3197 (vl_api_one_eid_table_map_details_t * mp)
3199 vat_main_t *vam = &vat_main;
3201 u8 *line = format (0, "%=10d%=10d",
3202 clib_net_to_host_u32 (mp->vni),
3203 clib_net_to_host_u32 (mp->dp_table));
3204 print (vam->ofp, "%v", line);
3209 vl_api_one_eid_table_map_details_t_handler_json
3210 (vl_api_one_eid_table_map_details_t * mp)
3212 vat_main_t *vam = &vat_main;
3213 vat_json_node_t *node = NULL;
3215 if (VAT_JSON_ARRAY != vam->json_tree.type)
3217 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3218 vat_json_init_array (&vam->json_tree);
3220 node = vat_json_array_add (&vam->json_tree);
3221 vat_json_init_object (node);
3222 vat_json_object_add_uint (node, "dp_table",
3223 clib_net_to_host_u32 (mp->dp_table));
3224 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3228 vl_api_one_eid_table_vni_details_t_handler
3229 (vl_api_one_eid_table_vni_details_t * mp)
3231 vat_main_t *vam = &vat_main;
3233 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3234 print (vam->ofp, "%v", line);
3239 vl_api_one_eid_table_vni_details_t_handler_json
3240 (vl_api_one_eid_table_vni_details_t * mp)
3242 vat_main_t *vam = &vat_main;
3243 vat_json_node_t *node = NULL;
3245 if (VAT_JSON_ARRAY != vam->json_tree.type)
3247 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3248 vat_json_init_array (&vam->json_tree);
3250 node = vat_json_array_add (&vam->json_tree);
3251 vat_json_init_object (node);
3252 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3256 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3257 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3259 vat_main_t *vam = &vat_main;
3260 int retval = clib_net_to_host_u32 (mp->retval);
3262 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3263 print (vam->ofp, "fallback threshold value: %d", mp->value);
3265 vam->retval = retval;
3266 vam->result_ready = 1;
3270 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3271 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3273 vat_main_t *vam = &vat_main;
3274 vat_json_node_t _node, *node = &_node;
3275 int retval = clib_net_to_host_u32 (mp->retval);
3277 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3278 vat_json_init_object (node);
3279 vat_json_object_add_uint (node, "value", mp->value);
3281 vat_json_print (vam->ofp, node);
3282 vat_json_free (node);
3284 vam->retval = retval;
3285 vam->result_ready = 1;
3289 vl_api_show_one_map_register_state_reply_t_handler
3290 (vl_api_show_one_map_register_state_reply_t * mp)
3292 vat_main_t *vam = &vat_main;
3293 int retval = clib_net_to_host_u32 (mp->retval);
3295 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3297 vam->retval = retval;
3298 vam->result_ready = 1;
3302 vl_api_show_one_map_register_state_reply_t_handler_json
3303 (vl_api_show_one_map_register_state_reply_t * mp)
3305 vat_main_t *vam = &vat_main;
3306 vat_json_node_t _node, *node = &_node;
3307 int retval = clib_net_to_host_u32 (mp->retval);
3309 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3311 vat_json_init_object (node);
3312 vat_json_object_add_string_copy (node, "state", s);
3314 vat_json_print (vam->ofp, node);
3315 vat_json_free (node);
3317 vam->retval = retval;
3318 vam->result_ready = 1;
3323 vl_api_show_one_rloc_probe_state_reply_t_handler
3324 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3326 vat_main_t *vam = &vat_main;
3327 int retval = clib_net_to_host_u32 (mp->retval);
3332 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3334 vam->retval = retval;
3335 vam->result_ready = 1;
3339 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3340 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3342 vat_main_t *vam = &vat_main;
3343 vat_json_node_t _node, *node = &_node;
3344 int retval = clib_net_to_host_u32 (mp->retval);
3346 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3347 vat_json_init_object (node);
3348 vat_json_object_add_string_copy (node, "state", s);
3350 vat_json_print (vam->ofp, node);
3351 vat_json_free (node);
3353 vam->retval = retval;
3354 vam->result_ready = 1;
3359 vl_api_show_one_stats_enable_disable_reply_t_handler
3360 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3362 vat_main_t *vam = &vat_main;
3363 int retval = clib_net_to_host_u32 (mp->retval);
3368 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3370 vam->retval = retval;
3371 vam->result_ready = 1;
3375 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3376 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3378 vat_main_t *vam = &vat_main;
3379 vat_json_node_t _node, *node = &_node;
3380 int retval = clib_net_to_host_u32 (mp->retval);
3382 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3383 vat_json_init_object (node);
3384 vat_json_object_add_string_copy (node, "state", s);
3386 vat_json_print (vam->ofp, node);
3387 vat_json_free (node);
3389 vam->retval = retval;
3390 vam->result_ready = 1;
3395 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3397 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3398 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3399 e->vni = clib_net_to_host_u32 (e->vni);
3403 gpe_fwd_entries_get_reply_t_net_to_host
3404 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3408 mp->count = clib_net_to_host_u32 (mp->count);
3409 for (i = 0; i < mp->count; i++)
3411 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3416 format_gpe_encap_mode (u8 * s, va_list * args)
3418 u32 mode = va_arg (*args, u32);
3423 return format (s, "lisp");
3425 return format (s, "vxlan");
3431 vl_api_gpe_get_encap_mode_reply_t_handler
3432 (vl_api_gpe_get_encap_mode_reply_t * mp)
3434 vat_main_t *vam = &vat_main;
3436 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3437 vam->retval = ntohl (mp->retval);
3438 vam->result_ready = 1;
3442 vl_api_gpe_get_encap_mode_reply_t_handler_json
3443 (vl_api_gpe_get_encap_mode_reply_t * mp)
3445 vat_main_t *vam = &vat_main;
3446 vat_json_node_t node;
3448 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3449 vec_add1 (encap_mode, 0);
3451 vat_json_init_object (&node);
3452 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3454 vec_free (encap_mode);
3455 vat_json_print (vam->ofp, &node);
3456 vat_json_free (&node);
3458 vam->retval = ntohl (mp->retval);
3459 vam->result_ready = 1;
3463 vl_api_gpe_fwd_entry_path_details_t_handler
3464 (vl_api_gpe_fwd_entry_path_details_t * mp)
3466 vat_main_t *vam = &vat_main;
3467 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3469 if (mp->lcl_loc.is_ip4)
3470 format_ip_address_fcn = format_ip4_address;
3472 format_ip_address_fcn = format_ip6_address;
3474 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3475 format_ip_address_fcn, &mp->lcl_loc,
3476 format_ip_address_fcn, &mp->rmt_loc);
3480 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3482 struct in6_addr ip6;
3487 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3488 vat_json_object_add_ip4 (n, "address", ip4);
3492 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3493 vat_json_object_add_ip6 (n, "address", ip6);
3495 vat_json_object_add_uint (n, "weight", loc->weight);
3499 vl_api_gpe_fwd_entry_path_details_t_handler_json
3500 (vl_api_gpe_fwd_entry_path_details_t * mp)
3502 vat_main_t *vam = &vat_main;
3503 vat_json_node_t *node = NULL;
3504 vat_json_node_t *loc_node;
3506 if (VAT_JSON_ARRAY != vam->json_tree.type)
3508 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3509 vat_json_init_array (&vam->json_tree);
3511 node = vat_json_array_add (&vam->json_tree);
3512 vat_json_init_object (node);
3514 loc_node = vat_json_object_add (node, "local_locator");
3515 vat_json_init_object (loc_node);
3516 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3518 loc_node = vat_json_object_add (node, "remote_locator");
3519 vat_json_init_object (loc_node);
3520 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3524 vl_api_gpe_fwd_entries_get_reply_t_handler
3525 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3527 vat_main_t *vam = &vat_main;
3529 int retval = clib_net_to_host_u32 (mp->retval);
3530 vl_api_gpe_fwd_entry_t *e;
3535 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3537 for (i = 0; i < mp->count; i++)
3539 e = &mp->entries[i];
3540 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3541 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3542 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3546 vam->retval = retval;
3547 vam->result_ready = 1;
3551 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3552 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3555 vat_main_t *vam = &vat_main;
3556 vat_json_node_t *e = 0, root;
3558 int retval = clib_net_to_host_u32 (mp->retval);
3559 vl_api_gpe_fwd_entry_t *fwd;
3564 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3565 vat_json_init_array (&root);
3567 for (i = 0; i < mp->count; i++)
3569 e = vat_json_array_add (&root);
3570 fwd = &mp->entries[i];
3572 vat_json_init_object (e);
3573 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3574 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3575 vat_json_object_add_int (e, "vni", fwd->vni);
3576 vat_json_object_add_int (e, "action", fwd->action);
3578 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3579 fwd->leid_prefix_len);
3581 vat_json_object_add_string_copy (e, "leid", s);
3584 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3585 fwd->reid_prefix_len);
3587 vat_json_object_add_string_copy (e, "reid", s);
3591 vat_json_print (vam->ofp, &root);
3592 vat_json_free (&root);
3595 vam->retval = retval;
3596 vam->result_ready = 1;
3600 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3601 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3603 vat_main_t *vam = &vat_main;
3605 int retval = clib_net_to_host_u32 (mp->retval);
3606 vl_api_gpe_native_fwd_rpath_t *r;
3611 n = clib_net_to_host_u32 (mp->count);
3613 for (i = 0; i < n; i++)
3615 r = &mp->entries[i];
3616 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3617 clib_net_to_host_u32 (r->fib_index),
3618 clib_net_to_host_u32 (r->nh_sw_if_index),
3619 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3623 vam->retval = retval;
3624 vam->result_ready = 1;
3628 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3629 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3631 vat_main_t *vam = &vat_main;
3632 vat_json_node_t root, *e;
3634 int retval = clib_net_to_host_u32 (mp->retval);
3635 vl_api_gpe_native_fwd_rpath_t *r;
3641 n = clib_net_to_host_u32 (mp->count);
3642 vat_json_init_array (&root);
3644 for (i = 0; i < n; i++)
3646 e = vat_json_array_add (&root);
3647 vat_json_init_object (e);
3648 r = &mp->entries[i];
3650 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3653 vat_json_object_add_string_copy (e, "ip4", s);
3656 vat_json_object_add_uint (e, "fib_index",
3657 clib_net_to_host_u32 (r->fib_index));
3658 vat_json_object_add_uint (e, "nh_sw_if_index",
3659 clib_net_to_host_u32 (r->nh_sw_if_index));
3662 vat_json_print (vam->ofp, &root);
3663 vat_json_free (&root);
3666 vam->retval = retval;
3667 vam->result_ready = 1;
3671 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3672 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3674 vat_main_t *vam = &vat_main;
3676 int retval = clib_net_to_host_u32 (mp->retval);
3681 n = clib_net_to_host_u32 (mp->count);
3683 for (i = 0; i < n; i++)
3684 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3687 vam->retval = retval;
3688 vam->result_ready = 1;
3692 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3693 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3695 vat_main_t *vam = &vat_main;
3696 vat_json_node_t root;
3698 int retval = clib_net_to_host_u32 (mp->retval);
3703 n = clib_net_to_host_u32 (mp->count);
3704 vat_json_init_array (&root);
3706 for (i = 0; i < n; i++)
3707 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3709 vat_json_print (vam->ofp, &root);
3710 vat_json_free (&root);
3713 vam->retval = retval;
3714 vam->result_ready = 1;
3718 vl_api_one_ndp_entries_get_reply_t_handler
3719 (vl_api_one_ndp_entries_get_reply_t * mp)
3721 vat_main_t *vam = &vat_main;
3723 int retval = clib_net_to_host_u32 (mp->retval);
3728 n = clib_net_to_host_u32 (mp->count);
3730 for (i = 0; i < n; i++)
3731 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3732 format_ethernet_address, mp->entries[i].mac);
3735 vam->retval = retval;
3736 vam->result_ready = 1;
3740 vl_api_one_ndp_entries_get_reply_t_handler_json
3741 (vl_api_one_ndp_entries_get_reply_t * mp)
3744 vat_main_t *vam = &vat_main;
3745 vat_json_node_t *e = 0, root;
3747 int retval = clib_net_to_host_u32 (mp->retval);
3748 vl_api_one_ndp_entry_t *arp_entry;
3753 n = clib_net_to_host_u32 (mp->count);
3754 vat_json_init_array (&root);
3756 for (i = 0; i < n; i++)
3758 e = vat_json_array_add (&root);
3759 arp_entry = &mp->entries[i];
3761 vat_json_init_object (e);
3762 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3765 vat_json_object_add_string_copy (e, "mac", s);
3768 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3770 vat_json_object_add_string_copy (e, "ip6", s);
3774 vat_json_print (vam->ofp, &root);
3775 vat_json_free (&root);
3778 vam->retval = retval;
3779 vam->result_ready = 1;
3783 vl_api_one_l2_arp_entries_get_reply_t_handler
3784 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3786 vat_main_t *vam = &vat_main;
3788 int retval = clib_net_to_host_u32 (mp->retval);
3793 n = clib_net_to_host_u32 (mp->count);
3795 for (i = 0; i < n; i++)
3796 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3797 format_ethernet_address, mp->entries[i].mac);
3800 vam->retval = retval;
3801 vam->result_ready = 1;
3805 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3806 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3809 vat_main_t *vam = &vat_main;
3810 vat_json_node_t *e = 0, root;
3812 int retval = clib_net_to_host_u32 (mp->retval);
3813 vl_api_one_l2_arp_entry_t *arp_entry;
3818 n = clib_net_to_host_u32 (mp->count);
3819 vat_json_init_array (&root);
3821 for (i = 0; i < n; i++)
3823 e = vat_json_array_add (&root);
3824 arp_entry = &mp->entries[i];
3826 vat_json_init_object (e);
3827 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3830 vat_json_object_add_string_copy (e, "mac", s);
3833 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3835 vat_json_object_add_string_copy (e, "ip4", s);
3839 vat_json_print (vam->ofp, &root);
3840 vat_json_free (&root);
3843 vam->retval = retval;
3844 vam->result_ready = 1;
3848 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3850 vat_main_t *vam = &vat_main;
3852 int retval = clib_net_to_host_u32 (mp->retval);
3857 n = clib_net_to_host_u32 (mp->count);
3859 for (i = 0; i < n; i++)
3861 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3865 vam->retval = retval;
3866 vam->result_ready = 1;
3870 vl_api_one_ndp_bd_get_reply_t_handler_json
3871 (vl_api_one_ndp_bd_get_reply_t * mp)
3873 vat_main_t *vam = &vat_main;
3874 vat_json_node_t root;
3876 int retval = clib_net_to_host_u32 (mp->retval);
3881 n = clib_net_to_host_u32 (mp->count);
3882 vat_json_init_array (&root);
3884 for (i = 0; i < n; i++)
3886 vat_json_array_add_uint (&root,
3887 clib_net_to_host_u32 (mp->bridge_domains[i]));
3890 vat_json_print (vam->ofp, &root);
3891 vat_json_free (&root);
3894 vam->retval = retval;
3895 vam->result_ready = 1;
3899 vl_api_one_l2_arp_bd_get_reply_t_handler
3900 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3902 vat_main_t *vam = &vat_main;
3904 int retval = clib_net_to_host_u32 (mp->retval);
3909 n = clib_net_to_host_u32 (mp->count);
3911 for (i = 0; i < n; i++)
3913 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3917 vam->retval = retval;
3918 vam->result_ready = 1;
3922 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3923 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3925 vat_main_t *vam = &vat_main;
3926 vat_json_node_t root;
3928 int retval = clib_net_to_host_u32 (mp->retval);
3933 n = clib_net_to_host_u32 (mp->count);
3934 vat_json_init_array (&root);
3936 for (i = 0; i < n; i++)
3938 vat_json_array_add_uint (&root,
3939 clib_net_to_host_u32 (mp->bridge_domains[i]));
3942 vat_json_print (vam->ofp, &root);
3943 vat_json_free (&root);
3946 vam->retval = retval;
3947 vam->result_ready = 1;
3951 vl_api_one_adjacencies_get_reply_t_handler
3952 (vl_api_one_adjacencies_get_reply_t * mp)
3954 vat_main_t *vam = &vat_main;
3956 int retval = clib_net_to_host_u32 (mp->retval);
3957 vl_api_one_adjacency_t *a;
3962 n = clib_net_to_host_u32 (mp->count);
3964 for (i = 0; i < n; i++)
3966 a = &mp->adjacencies[i];
3967 print (vam->ofp, "%U %40U",
3968 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3969 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3973 vam->retval = retval;
3974 vam->result_ready = 1;
3978 vl_api_one_adjacencies_get_reply_t_handler_json
3979 (vl_api_one_adjacencies_get_reply_t * mp)
3982 vat_main_t *vam = &vat_main;
3983 vat_json_node_t *e = 0, root;
3985 int retval = clib_net_to_host_u32 (mp->retval);
3986 vl_api_one_adjacency_t *a;
3991 n = clib_net_to_host_u32 (mp->count);
3992 vat_json_init_array (&root);
3994 for (i = 0; i < n; i++)
3996 e = vat_json_array_add (&root);
3997 a = &mp->adjacencies[i];
3999 vat_json_init_object (e);
4000 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4001 a->leid_prefix_len);
4003 vat_json_object_add_string_copy (e, "leid", s);
4006 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4007 a->reid_prefix_len);
4009 vat_json_object_add_string_copy (e, "reid", s);
4013 vat_json_print (vam->ofp, &root);
4014 vat_json_free (&root);
4017 vam->retval = retval;
4018 vam->result_ready = 1;
4022 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4024 vat_main_t *vam = &vat_main;
4026 print (vam->ofp, "%=20U",
4027 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4032 vl_api_one_map_server_details_t_handler_json
4033 (vl_api_one_map_server_details_t * mp)
4035 vat_main_t *vam = &vat_main;
4036 vat_json_node_t *node = NULL;
4037 struct in6_addr ip6;
4040 if (VAT_JSON_ARRAY != vam->json_tree.type)
4042 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4043 vat_json_init_array (&vam->json_tree);
4045 node = vat_json_array_add (&vam->json_tree);
4047 vat_json_init_object (node);
4050 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4051 vat_json_object_add_ip6 (node, "map-server", ip6);
4055 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4056 vat_json_object_add_ip4 (node, "map-server", ip4);
4061 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4064 vat_main_t *vam = &vat_main;
4066 print (vam->ofp, "%=20U",
4067 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4072 vl_api_one_map_resolver_details_t_handler_json
4073 (vl_api_one_map_resolver_details_t * mp)
4075 vat_main_t *vam = &vat_main;
4076 vat_json_node_t *node = NULL;
4077 struct in6_addr ip6;
4080 if (VAT_JSON_ARRAY != vam->json_tree.type)
4082 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4083 vat_json_init_array (&vam->json_tree);
4085 node = vat_json_array_add (&vam->json_tree);
4087 vat_json_init_object (node);
4090 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4091 vat_json_object_add_ip6 (node, "map resolver", ip6);
4095 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4096 vat_json_object_add_ip4 (node, "map resolver", ip4);
4101 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4103 vat_main_t *vam = &vat_main;
4104 i32 retval = ntohl (mp->retval);
4108 print (vam->ofp, "feature: %s\ngpe: %s",
4109 mp->feature_status ? "enabled" : "disabled",
4110 mp->gpe_status ? "enabled" : "disabled");
4113 vam->retval = retval;
4114 vam->result_ready = 1;
4118 vl_api_show_one_status_reply_t_handler_json
4119 (vl_api_show_one_status_reply_t * mp)
4121 vat_main_t *vam = &vat_main;
4122 vat_json_node_t node;
4123 u8 *gpe_status = NULL;
4124 u8 *feature_status = NULL;
4126 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4127 feature_status = format (0, "%s",
4128 mp->feature_status ? "enabled" : "disabled");
4129 vec_add1 (gpe_status, 0);
4130 vec_add1 (feature_status, 0);
4132 vat_json_init_object (&node);
4133 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4134 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4136 vec_free (gpe_status);
4137 vec_free (feature_status);
4139 vat_json_print (vam->ofp, &node);
4140 vat_json_free (&node);
4142 vam->retval = ntohl (mp->retval);
4143 vam->result_ready = 1;
4147 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4148 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4150 vat_main_t *vam = &vat_main;
4151 i32 retval = ntohl (mp->retval);
4155 print (vam->ofp, "%=20s", mp->locator_set_name);
4158 vam->retval = retval;
4159 vam->result_ready = 1;
4163 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4164 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4166 vat_main_t *vam = &vat_main;
4167 vat_json_node_t *node = NULL;
4169 if (VAT_JSON_ARRAY != vam->json_tree.type)
4171 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4172 vat_json_init_array (&vam->json_tree);
4174 node = vat_json_array_add (&vam->json_tree);
4176 vat_json_init_object (node);
4177 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4179 vat_json_print (vam->ofp, node);
4180 vat_json_free (node);
4182 vam->retval = ntohl (mp->retval);
4183 vam->result_ready = 1;
4187 format_lisp_map_request_mode (u8 * s, va_list * args)
4189 u32 mode = va_arg (*args, u32);
4194 return format (0, "dst-only");
4196 return format (0, "src-dst");
4202 vl_api_show_one_map_request_mode_reply_t_handler
4203 (vl_api_show_one_map_request_mode_reply_t * mp)
4205 vat_main_t *vam = &vat_main;
4206 i32 retval = ntohl (mp->retval);
4210 u32 mode = mp->mode;
4211 print (vam->ofp, "map_request_mode: %U",
4212 format_lisp_map_request_mode, mode);
4215 vam->retval = retval;
4216 vam->result_ready = 1;
4220 vl_api_show_one_map_request_mode_reply_t_handler_json
4221 (vl_api_show_one_map_request_mode_reply_t * mp)
4223 vat_main_t *vam = &vat_main;
4224 vat_json_node_t node;
4229 s = format (0, "%U", format_lisp_map_request_mode, mode);
4232 vat_json_init_object (&node);
4233 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4234 vat_json_print (vam->ofp, &node);
4235 vat_json_free (&node);
4238 vam->retval = ntohl (mp->retval);
4239 vam->result_ready = 1;
4243 vl_api_one_show_xtr_mode_reply_t_handler
4244 (vl_api_one_show_xtr_mode_reply_t * mp)
4246 vat_main_t *vam = &vat_main;
4247 i32 retval = ntohl (mp->retval);
4251 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4254 vam->retval = retval;
4255 vam->result_ready = 1;
4259 vl_api_one_show_xtr_mode_reply_t_handler_json
4260 (vl_api_one_show_xtr_mode_reply_t * mp)
4262 vat_main_t *vam = &vat_main;
4263 vat_json_node_t node;
4266 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4267 vec_add1 (status, 0);
4269 vat_json_init_object (&node);
4270 vat_json_object_add_string_copy (&node, "status", status);
4274 vat_json_print (vam->ofp, &node);
4275 vat_json_free (&node);
4277 vam->retval = ntohl (mp->retval);
4278 vam->result_ready = 1;
4282 vl_api_one_show_pitr_mode_reply_t_handler
4283 (vl_api_one_show_pitr_mode_reply_t * mp)
4285 vat_main_t *vam = &vat_main;
4286 i32 retval = ntohl (mp->retval);
4290 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4293 vam->retval = retval;
4294 vam->result_ready = 1;
4298 vl_api_one_show_pitr_mode_reply_t_handler_json
4299 (vl_api_one_show_pitr_mode_reply_t * mp)
4301 vat_main_t *vam = &vat_main;
4302 vat_json_node_t node;
4305 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4306 vec_add1 (status, 0);
4308 vat_json_init_object (&node);
4309 vat_json_object_add_string_copy (&node, "status", status);
4313 vat_json_print (vam->ofp, &node);
4314 vat_json_free (&node);
4316 vam->retval = ntohl (mp->retval);
4317 vam->result_ready = 1;
4321 vl_api_one_show_petr_mode_reply_t_handler
4322 (vl_api_one_show_petr_mode_reply_t * mp)
4324 vat_main_t *vam = &vat_main;
4325 i32 retval = ntohl (mp->retval);
4329 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4332 vam->retval = retval;
4333 vam->result_ready = 1;
4337 vl_api_one_show_petr_mode_reply_t_handler_json
4338 (vl_api_one_show_petr_mode_reply_t * mp)
4340 vat_main_t *vam = &vat_main;
4341 vat_json_node_t node;
4344 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4345 vec_add1 (status, 0);
4347 vat_json_init_object (&node);
4348 vat_json_object_add_string_copy (&node, "status", status);
4352 vat_json_print (vam->ofp, &node);
4353 vat_json_free (&node);
4355 vam->retval = ntohl (mp->retval);
4356 vam->result_ready = 1;
4360 vl_api_show_one_use_petr_reply_t_handler
4361 (vl_api_show_one_use_petr_reply_t * mp)
4363 vat_main_t *vam = &vat_main;
4364 i32 retval = ntohl (mp->retval);
4368 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4371 print (vam->ofp, "Proxy-ETR address; %U",
4372 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4377 vam->retval = retval;
4378 vam->result_ready = 1;
4382 vl_api_show_one_use_petr_reply_t_handler_json
4383 (vl_api_show_one_use_petr_reply_t * mp)
4385 vat_main_t *vam = &vat_main;
4386 vat_json_node_t node;
4389 struct in6_addr ip6;
4391 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4392 vec_add1 (status, 0);
4394 vat_json_init_object (&node);
4395 vat_json_object_add_string_copy (&node, "status", status);
4400 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4401 vat_json_object_add_ip6 (&node, "address", ip6);
4405 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4406 vat_json_object_add_ip4 (&node, "address", ip4);
4412 vat_json_print (vam->ofp, &node);
4413 vat_json_free (&node);
4415 vam->retval = ntohl (mp->retval);
4416 vam->result_ready = 1;
4420 vl_api_show_one_nsh_mapping_reply_t_handler
4421 (vl_api_show_one_nsh_mapping_reply_t * mp)
4423 vat_main_t *vam = &vat_main;
4424 i32 retval = ntohl (mp->retval);
4428 print (vam->ofp, "%-20s%-16s",
4429 mp->is_set ? "set" : "not-set",
4430 mp->is_set ? (char *) mp->locator_set_name : "");
4433 vam->retval = retval;
4434 vam->result_ready = 1;
4438 vl_api_show_one_nsh_mapping_reply_t_handler_json
4439 (vl_api_show_one_nsh_mapping_reply_t * mp)
4441 vat_main_t *vam = &vat_main;
4442 vat_json_node_t node;
4445 status = format (0, "%s", mp->is_set ? "yes" : "no");
4446 vec_add1 (status, 0);
4448 vat_json_init_object (&node);
4449 vat_json_object_add_string_copy (&node, "is_set", status);
4452 vat_json_object_add_string_copy (&node, "locator_set",
4453 mp->locator_set_name);
4458 vat_json_print (vam->ofp, &node);
4459 vat_json_free (&node);
4461 vam->retval = ntohl (mp->retval);
4462 vam->result_ready = 1;
4466 vl_api_show_one_map_register_ttl_reply_t_handler
4467 (vl_api_show_one_map_register_ttl_reply_t * mp)
4469 vat_main_t *vam = &vat_main;
4470 i32 retval = ntohl (mp->retval);
4472 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4476 print (vam->ofp, "ttl: %u", mp->ttl);
4479 vam->retval = retval;
4480 vam->result_ready = 1;
4484 vl_api_show_one_map_register_ttl_reply_t_handler_json
4485 (vl_api_show_one_map_register_ttl_reply_t * mp)
4487 vat_main_t *vam = &vat_main;
4488 vat_json_node_t node;
4490 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4491 vat_json_init_object (&node);
4492 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4494 vat_json_print (vam->ofp, &node);
4495 vat_json_free (&node);
4497 vam->retval = ntohl (mp->retval);
4498 vam->result_ready = 1;
4502 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4504 vat_main_t *vam = &vat_main;
4505 i32 retval = ntohl (mp->retval);
4509 print (vam->ofp, "%-20s%-16s",
4510 mp->status ? "enabled" : "disabled",
4511 mp->status ? (char *) mp->locator_set_name : "");
4514 vam->retval = retval;
4515 vam->result_ready = 1;
4519 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4521 vat_main_t *vam = &vat_main;
4522 vat_json_node_t node;
4525 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4526 vec_add1 (status, 0);
4528 vat_json_init_object (&node);
4529 vat_json_object_add_string_copy (&node, "status", status);
4532 vat_json_object_add_string_copy (&node, "locator_set",
4533 mp->locator_set_name);
4538 vat_json_print (vam->ofp, &node);
4539 vat_json_free (&node);
4541 vam->retval = ntohl (mp->retval);
4542 vam->result_ready = 1;
4546 format_policer_type (u8 * s, va_list * va)
4548 u32 i = va_arg (*va, u32);
4550 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4551 s = format (s, "1r2c");
4552 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4553 s = format (s, "1r3c");
4554 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4555 s = format (s, "2r3c-2698");
4556 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4557 s = format (s, "2r3c-4115");
4558 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4559 s = format (s, "2r3c-mef5cf1");
4561 s = format (s, "ILLEGAL");
4566 format_policer_rate_type (u8 * s, va_list * va)
4568 u32 i = va_arg (*va, u32);
4570 if (i == SSE2_QOS_RATE_KBPS)
4571 s = format (s, "kbps");
4572 else if (i == SSE2_QOS_RATE_PPS)
4573 s = format (s, "pps");
4575 s = format (s, "ILLEGAL");
4580 format_policer_round_type (u8 * s, va_list * va)
4582 u32 i = va_arg (*va, u32);
4584 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4585 s = format (s, "closest");
4586 else if (i == SSE2_QOS_ROUND_TO_UP)
4587 s = format (s, "up");
4588 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4589 s = format (s, "down");
4591 s = format (s, "ILLEGAL");
4596 format_policer_action_type (u8 * s, va_list * va)
4598 u32 i = va_arg (*va, u32);
4600 if (i == SSE2_QOS_ACTION_DROP)
4601 s = format (s, "drop");
4602 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4603 s = format (s, "transmit");
4604 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4605 s = format (s, "mark-and-transmit");
4607 s = format (s, "ILLEGAL");
4612 format_dscp (u8 * s, va_list * va)
4614 u32 i = va_arg (*va, u32);
4619 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4623 return format (s, "ILLEGAL");
4625 s = format (s, "%s", t);
4630 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4632 vat_main_t *vam = &vat_main;
4633 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4635 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4636 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4638 conform_dscp_str = format (0, "");
4640 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4641 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4643 exceed_dscp_str = format (0, "");
4645 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4646 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4648 violate_dscp_str = format (0, "");
4650 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4651 "rate type %U, round type %U, %s rate, %s color-aware, "
4652 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4653 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4654 "conform action %U%s, exceed action %U%s, violate action %U%s",
4656 format_policer_type, mp->type,
4659 clib_net_to_host_u64 (mp->cb),
4660 clib_net_to_host_u64 (mp->eb),
4661 format_policer_rate_type, mp->rate_type,
4662 format_policer_round_type, mp->round_type,
4663 mp->single_rate ? "single" : "dual",
4664 mp->color_aware ? "is" : "not",
4665 ntohl (mp->cir_tokens_per_period),
4666 ntohl (mp->pir_tokens_per_period),
4668 ntohl (mp->current_limit),
4669 ntohl (mp->current_bucket),
4670 ntohl (mp->extended_limit),
4671 ntohl (mp->extended_bucket),
4672 clib_net_to_host_u64 (mp->last_update_time),
4673 format_policer_action_type, mp->conform_action_type,
4675 format_policer_action_type, mp->exceed_action_type,
4677 format_policer_action_type, mp->violate_action_type,
4680 vec_free (conform_dscp_str);
4681 vec_free (exceed_dscp_str);
4682 vec_free (violate_dscp_str);
4685 static void vl_api_policer_details_t_handler_json
4686 (vl_api_policer_details_t * mp)
4688 vat_main_t *vam = &vat_main;
4689 vat_json_node_t *node;
4690 u8 *rate_type_str, *round_type_str, *type_str;
4691 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4693 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4695 format (0, "%U", format_policer_round_type, mp->round_type);
4696 type_str = format (0, "%U", format_policer_type, mp->type);
4697 conform_action_str = format (0, "%U", format_policer_action_type,
4698 mp->conform_action_type);
4699 exceed_action_str = format (0, "%U", format_policer_action_type,
4700 mp->exceed_action_type);
4701 violate_action_str = format (0, "%U", format_policer_action_type,
4702 mp->violate_action_type);
4704 if (VAT_JSON_ARRAY != vam->json_tree.type)
4706 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4707 vat_json_init_array (&vam->json_tree);
4709 node = vat_json_array_add (&vam->json_tree);
4711 vat_json_init_object (node);
4712 vat_json_object_add_string_copy (node, "name", mp->name);
4713 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4714 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4715 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4716 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4717 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4718 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4719 vat_json_object_add_string_copy (node, "type", type_str);
4720 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4721 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4722 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4723 vat_json_object_add_uint (node, "cir_tokens_per_period",
4724 ntohl (mp->cir_tokens_per_period));
4725 vat_json_object_add_uint (node, "eir_tokens_per_period",
4726 ntohl (mp->pir_tokens_per_period));
4727 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4728 vat_json_object_add_uint (node, "current_bucket",
4729 ntohl (mp->current_bucket));
4730 vat_json_object_add_uint (node, "extended_limit",
4731 ntohl (mp->extended_limit));
4732 vat_json_object_add_uint (node, "extended_bucket",
4733 ntohl (mp->extended_bucket));
4734 vat_json_object_add_uint (node, "last_update_time",
4735 ntohl (mp->last_update_time));
4736 vat_json_object_add_string_copy (node, "conform_action",
4737 conform_action_str);
4738 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4740 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4741 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4742 vec_free (dscp_str);
4744 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4745 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4747 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4748 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4749 vec_free (dscp_str);
4751 vat_json_object_add_string_copy (node, "violate_action",
4752 violate_action_str);
4753 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4755 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4756 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4757 vec_free (dscp_str);
4760 vec_free (rate_type_str);
4761 vec_free (round_type_str);
4762 vec_free (type_str);
4763 vec_free (conform_action_str);
4764 vec_free (exceed_action_str);
4765 vec_free (violate_action_str);
4769 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4772 vat_main_t *vam = &vat_main;
4773 int i, count = ntohl (mp->count);
4776 print (vam->ofp, "classify table ids (%d) : ", count);
4777 for (i = 0; i < count; i++)
4779 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4780 print (vam->ofp, (i < count - 1) ? "," : "");
4782 vam->retval = ntohl (mp->retval);
4783 vam->result_ready = 1;
4787 vl_api_classify_table_ids_reply_t_handler_json
4788 (vl_api_classify_table_ids_reply_t * mp)
4790 vat_main_t *vam = &vat_main;
4791 int i, count = ntohl (mp->count);
4795 vat_json_node_t node;
4797 vat_json_init_object (&node);
4798 for (i = 0; i < count; i++)
4800 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4802 vat_json_print (vam->ofp, &node);
4803 vat_json_free (&node);
4805 vam->retval = ntohl (mp->retval);
4806 vam->result_ready = 1;
4810 vl_api_classify_table_by_interface_reply_t_handler
4811 (vl_api_classify_table_by_interface_reply_t * mp)
4813 vat_main_t *vam = &vat_main;
4816 table_id = ntohl (mp->l2_table_id);
4818 print (vam->ofp, "l2 table id : %d", table_id);
4820 print (vam->ofp, "l2 table id : No input ACL tables configured");
4821 table_id = ntohl (mp->ip4_table_id);
4823 print (vam->ofp, "ip4 table id : %d", table_id);
4825 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4826 table_id = ntohl (mp->ip6_table_id);
4828 print (vam->ofp, "ip6 table id : %d", table_id);
4830 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4831 vam->retval = ntohl (mp->retval);
4832 vam->result_ready = 1;
4836 vl_api_classify_table_by_interface_reply_t_handler_json
4837 (vl_api_classify_table_by_interface_reply_t * mp)
4839 vat_main_t *vam = &vat_main;
4840 vat_json_node_t node;
4842 vat_json_init_object (&node);
4844 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4845 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4846 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4848 vat_json_print (vam->ofp, &node);
4849 vat_json_free (&node);
4851 vam->retval = ntohl (mp->retval);
4852 vam->result_ready = 1;
4855 static void vl_api_policer_add_del_reply_t_handler
4856 (vl_api_policer_add_del_reply_t * mp)
4858 vat_main_t *vam = &vat_main;
4859 i32 retval = ntohl (mp->retval);
4860 if (vam->async_mode)
4862 vam->async_errors += (retval < 0);
4866 vam->retval = retval;
4867 vam->result_ready = 1;
4868 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4870 * Note: this is just barely thread-safe, depends on
4871 * the main thread spinning waiting for an answer...
4873 errmsg ("policer index %d", ntohl (mp->policer_index));
4877 static void vl_api_policer_add_del_reply_t_handler_json
4878 (vl_api_policer_add_del_reply_t * mp)
4880 vat_main_t *vam = &vat_main;
4881 vat_json_node_t node;
4883 vat_json_init_object (&node);
4884 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4885 vat_json_object_add_uint (&node, "policer_index",
4886 ntohl (mp->policer_index));
4888 vat_json_print (vam->ofp, &node);
4889 vat_json_free (&node);
4891 vam->retval = ntohl (mp->retval);
4892 vam->result_ready = 1;
4895 /* Format hex dump. */
4897 format_hex_bytes (u8 * s, va_list * va)
4899 u8 *bytes = va_arg (*va, u8 *);
4900 int n_bytes = va_arg (*va, int);
4903 /* Print short or long form depending on byte count. */
4904 uword short_form = n_bytes <= 32;
4905 u32 indent = format_get_indent (s);
4910 for (i = 0; i < n_bytes; i++)
4912 if (!short_form && (i % 32) == 0)
4913 s = format (s, "%08x: ", i);
4914 s = format (s, "%02x", bytes[i]);
4915 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4916 s = format (s, "\n%U", format_white_space, indent);
4923 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4926 vat_main_t *vam = &vat_main;
4927 i32 retval = ntohl (mp->retval);
4930 print (vam->ofp, "classify table info :");
4931 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4932 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4933 ntohl (mp->miss_next_index));
4934 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4935 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4936 ntohl (mp->match_n_vectors));
4937 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4938 ntohl (mp->mask_length));
4940 vam->retval = retval;
4941 vam->result_ready = 1;
4945 vl_api_classify_table_info_reply_t_handler_json
4946 (vl_api_classify_table_info_reply_t * mp)
4948 vat_main_t *vam = &vat_main;
4949 vat_json_node_t node;
4951 i32 retval = ntohl (mp->retval);
4954 vat_json_init_object (&node);
4956 vat_json_object_add_int (&node, "sessions",
4957 ntohl (mp->active_sessions));
4958 vat_json_object_add_int (&node, "nexttbl",
4959 ntohl (mp->next_table_index));
4960 vat_json_object_add_int (&node, "nextnode",
4961 ntohl (mp->miss_next_index));
4962 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4963 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4964 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4965 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4966 ntohl (mp->mask_length), 0);
4967 vat_json_object_add_string_copy (&node, "mask", s);
4969 vat_json_print (vam->ofp, &node);
4970 vat_json_free (&node);
4972 vam->retval = ntohl (mp->retval);
4973 vam->result_ready = 1;
4977 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4980 vat_main_t *vam = &vat_main;
4982 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4983 ntohl (mp->hit_next_index), ntohl (mp->advance),
4984 ntohl (mp->opaque_index));
4985 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4986 ntohl (mp->match_length));
4990 vl_api_classify_session_details_t_handler_json
4991 (vl_api_classify_session_details_t * mp)
4993 vat_main_t *vam = &vat_main;
4994 vat_json_node_t *node = NULL;
4996 if (VAT_JSON_ARRAY != vam->json_tree.type)
4998 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4999 vat_json_init_array (&vam->json_tree);
5001 node = vat_json_array_add (&vam->json_tree);
5003 vat_json_init_object (node);
5004 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5005 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5006 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5008 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5010 vat_json_object_add_string_copy (node, "match", s);
5013 static void vl_api_pg_create_interface_reply_t_handler
5014 (vl_api_pg_create_interface_reply_t * mp)
5016 vat_main_t *vam = &vat_main;
5018 vam->retval = ntohl (mp->retval);
5019 vam->result_ready = 1;
5022 static void vl_api_pg_create_interface_reply_t_handler_json
5023 (vl_api_pg_create_interface_reply_t * mp)
5025 vat_main_t *vam = &vat_main;
5026 vat_json_node_t node;
5028 i32 retval = ntohl (mp->retval);
5031 vat_json_init_object (&node);
5033 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5035 vat_json_print (vam->ofp, &node);
5036 vat_json_free (&node);
5038 vam->retval = ntohl (mp->retval);
5039 vam->result_ready = 1;
5042 static void vl_api_policer_classify_details_t_handler
5043 (vl_api_policer_classify_details_t * mp)
5045 vat_main_t *vam = &vat_main;
5047 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5048 ntohl (mp->table_index));
5051 static void vl_api_policer_classify_details_t_handler_json
5052 (vl_api_policer_classify_details_t * mp)
5054 vat_main_t *vam = &vat_main;
5055 vat_json_node_t *node;
5057 if (VAT_JSON_ARRAY != vam->json_tree.type)
5059 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5060 vat_json_init_array (&vam->json_tree);
5062 node = vat_json_array_add (&vam->json_tree);
5064 vat_json_init_object (node);
5065 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5066 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5069 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5070 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5072 vat_main_t *vam = &vat_main;
5073 i32 retval = ntohl (mp->retval);
5074 if (vam->async_mode)
5076 vam->async_errors += (retval < 0);
5080 vam->retval = retval;
5081 vam->sw_if_index = ntohl (mp->sw_if_index);
5082 vam->result_ready = 1;
5086 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5087 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5089 vat_main_t *vam = &vat_main;
5090 vat_json_node_t node;
5092 vat_json_init_object (&node);
5093 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5094 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5096 vat_json_print (vam->ofp, &node);
5097 vat_json_free (&node);
5099 vam->retval = ntohl (mp->retval);
5100 vam->result_ready = 1;
5103 static void vl_api_flow_classify_details_t_handler
5104 (vl_api_flow_classify_details_t * mp)
5106 vat_main_t *vam = &vat_main;
5108 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5109 ntohl (mp->table_index));
5112 static void vl_api_flow_classify_details_t_handler_json
5113 (vl_api_flow_classify_details_t * mp)
5115 vat_main_t *vam = &vat_main;
5116 vat_json_node_t *node;
5118 if (VAT_JSON_ARRAY != vam->json_tree.type)
5120 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5121 vat_json_init_array (&vam->json_tree);
5123 node = vat_json_array_add (&vam->json_tree);
5125 vat_json_init_object (node);
5126 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5127 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5130 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5131 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5132 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5133 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5134 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5135 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5136 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5137 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5138 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5139 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5140 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5141 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5142 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5143 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5144 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5145 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5146 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5147 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5148 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5149 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5150 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5151 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5154 * Generate boilerplate reply handlers, which
5155 * dig the return value out of the xxx_reply_t API message,
5156 * stick it into vam->retval, and set vam->result_ready
5158 * Could also do this by pointing N message decode slots at
5159 * a single function, but that could break in subtle ways.
5162 #define foreach_standard_reply_retval_handler \
5163 _(sw_interface_set_flags_reply) \
5164 _(sw_interface_add_del_address_reply) \
5165 _(sw_interface_set_rx_mode_reply) \
5166 _(sw_interface_set_table_reply) \
5167 _(sw_interface_set_mpls_enable_reply) \
5168 _(sw_interface_set_vpath_reply) \
5169 _(sw_interface_set_vxlan_bypass_reply) \
5170 _(sw_interface_set_geneve_bypass_reply) \
5171 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5172 _(sw_interface_set_l2_bridge_reply) \
5173 _(bridge_domain_add_del_reply) \
5174 _(sw_interface_set_l2_xconnect_reply) \
5175 _(l2fib_add_del_reply) \
5176 _(l2fib_flush_int_reply) \
5177 _(l2fib_flush_bd_reply) \
5178 _(ip_add_del_route_reply) \
5179 _(ip_table_add_del_reply) \
5180 _(ip_mroute_add_del_reply) \
5181 _(mpls_route_add_del_reply) \
5182 _(mpls_table_add_del_reply) \
5183 _(mpls_ip_bind_unbind_reply) \
5184 _(bier_route_add_del_reply) \
5185 _(bier_table_add_del_reply) \
5186 _(proxy_arp_add_del_reply) \
5187 _(proxy_arp_intfc_enable_disable_reply) \
5188 _(sw_interface_set_unnumbered_reply) \
5189 _(ip_neighbor_add_del_reply) \
5190 _(oam_add_del_reply) \
5191 _(reset_fib_reply) \
5192 _(dhcp_proxy_config_reply) \
5193 _(dhcp_proxy_set_vss_reply) \
5194 _(dhcp_client_config_reply) \
5195 _(set_ip_flow_hash_reply) \
5196 _(sw_interface_ip6_enable_disable_reply) \
5197 _(sw_interface_ip6_set_link_local_address_reply) \
5198 _(ip6nd_proxy_add_del_reply) \
5199 _(sw_interface_ip6nd_ra_prefix_reply) \
5200 _(sw_interface_ip6nd_ra_config_reply) \
5201 _(set_arp_neighbor_limit_reply) \
5202 _(l2_patch_add_del_reply) \
5203 _(sr_policy_add_reply) \
5204 _(sr_policy_mod_reply) \
5205 _(sr_policy_del_reply) \
5206 _(sr_localsid_add_del_reply) \
5207 _(sr_steering_add_del_reply) \
5208 _(classify_add_del_session_reply) \
5209 _(classify_set_interface_ip_table_reply) \
5210 _(classify_set_interface_l2_tables_reply) \
5211 _(l2tpv3_set_tunnel_cookies_reply) \
5212 _(l2tpv3_interface_enable_disable_reply) \
5213 _(l2tpv3_set_lookup_key_reply) \
5214 _(l2_fib_clear_table_reply) \
5215 _(l2_interface_efp_filter_reply) \
5216 _(l2_interface_vlan_tag_rewrite_reply) \
5217 _(modify_vhost_user_if_reply) \
5218 _(delete_vhost_user_if_reply) \
5219 _(want_ip4_arp_events_reply) \
5220 _(want_ip6_nd_events_reply) \
5221 _(want_l2_macs_events_reply) \
5222 _(input_acl_set_interface_reply) \
5223 _(ipsec_spd_add_del_reply) \
5224 _(ipsec_interface_add_del_spd_reply) \
5225 _(ipsec_spd_add_del_entry_reply) \
5226 _(ipsec_sad_add_del_entry_reply) \
5227 _(ipsec_sa_set_key_reply) \
5228 _(ipsec_tunnel_if_add_del_reply) \
5229 _(ipsec_tunnel_if_set_key_reply) \
5230 _(ipsec_tunnel_if_set_sa_reply) \
5231 _(ikev2_profile_add_del_reply) \
5232 _(ikev2_profile_set_auth_reply) \
5233 _(ikev2_profile_set_id_reply) \
5234 _(ikev2_profile_set_ts_reply) \
5235 _(ikev2_set_local_key_reply) \
5236 _(ikev2_set_responder_reply) \
5237 _(ikev2_set_ike_transforms_reply) \
5238 _(ikev2_set_esp_transforms_reply) \
5239 _(ikev2_set_sa_lifetime_reply) \
5240 _(ikev2_initiate_sa_init_reply) \
5241 _(ikev2_initiate_del_ike_sa_reply) \
5242 _(ikev2_initiate_del_child_sa_reply) \
5243 _(ikev2_initiate_rekey_child_sa_reply) \
5244 _(delete_loopback_reply) \
5245 _(bd_ip_mac_add_del_reply) \
5246 _(map_del_domain_reply) \
5247 _(map_add_del_rule_reply) \
5248 _(want_interface_events_reply) \
5249 _(want_stats_reply) \
5250 _(cop_interface_enable_disable_reply) \
5251 _(cop_whitelist_enable_disable_reply) \
5252 _(sw_interface_clear_stats_reply) \
5253 _(ioam_enable_reply) \
5254 _(ioam_disable_reply) \
5255 _(one_add_del_locator_reply) \
5256 _(one_add_del_local_eid_reply) \
5257 _(one_add_del_remote_mapping_reply) \
5258 _(one_add_del_adjacency_reply) \
5259 _(one_add_del_map_resolver_reply) \
5260 _(one_add_del_map_server_reply) \
5261 _(one_enable_disable_reply) \
5262 _(one_rloc_probe_enable_disable_reply) \
5263 _(one_map_register_enable_disable_reply) \
5264 _(one_map_register_set_ttl_reply) \
5265 _(one_set_transport_protocol_reply) \
5266 _(one_map_register_fallback_threshold_reply) \
5267 _(one_pitr_set_locator_set_reply) \
5268 _(one_map_request_mode_reply) \
5269 _(one_add_del_map_request_itr_rlocs_reply) \
5270 _(one_eid_table_add_del_map_reply) \
5271 _(one_use_petr_reply) \
5272 _(one_stats_enable_disable_reply) \
5273 _(one_add_del_l2_arp_entry_reply) \
5274 _(one_add_del_ndp_entry_reply) \
5275 _(one_stats_flush_reply) \
5276 _(one_enable_disable_xtr_mode_reply) \
5277 _(one_enable_disable_pitr_mode_reply) \
5278 _(one_enable_disable_petr_mode_reply) \
5279 _(gpe_enable_disable_reply) \
5280 _(gpe_set_encap_mode_reply) \
5281 _(gpe_add_del_iface_reply) \
5282 _(gpe_add_del_native_fwd_rpath_reply) \
5283 _(af_packet_delete_reply) \
5284 _(policer_classify_set_interface_reply) \
5285 _(netmap_create_reply) \
5286 _(netmap_delete_reply) \
5287 _(set_ipfix_exporter_reply) \
5288 _(set_ipfix_classify_stream_reply) \
5289 _(ipfix_classify_table_add_del_reply) \
5290 _(flow_classify_set_interface_reply) \
5291 _(sw_interface_span_enable_disable_reply) \
5292 _(pg_capture_reply) \
5293 _(pg_enable_disable_reply) \
5294 _(ip_source_and_port_range_check_add_del_reply) \
5295 _(ip_source_and_port_range_check_interface_add_del_reply)\
5296 _(delete_subif_reply) \
5297 _(l2_interface_pbb_tag_rewrite_reply) \
5299 _(feature_enable_disable_reply) \
5300 _(sw_interface_tag_add_del_reply) \
5301 _(sw_interface_set_mtu_reply) \
5302 _(p2p_ethernet_add_reply) \
5303 _(p2p_ethernet_del_reply) \
5304 _(lldp_config_reply) \
5305 _(sw_interface_set_lldp_reply) \
5306 _(tcp_configure_src_addresses_reply) \
5307 _(dns_enable_disable_reply) \
5308 _(dns_name_server_add_del_reply) \
5309 _(session_rule_add_del_reply) \
5310 _(ip_container_proxy_add_del_reply)
5313 static void vl_api_##n##_t_handler \
5314 (vl_api_##n##_t * mp) \
5316 vat_main_t * vam = &vat_main; \
5317 i32 retval = ntohl(mp->retval); \
5318 if (vam->async_mode) { \
5319 vam->async_errors += (retval < 0); \
5321 vam->retval = retval; \
5322 vam->result_ready = 1; \
5325 foreach_standard_reply_retval_handler;
5329 static void vl_api_##n##_t_handler_json \
5330 (vl_api_##n##_t * mp) \
5332 vat_main_t * vam = &vat_main; \
5333 vat_json_node_t node; \
5334 vat_json_init_object(&node); \
5335 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5336 vat_json_print(vam->ofp, &node); \
5337 vam->retval = ntohl(mp->retval); \
5338 vam->result_ready = 1; \
5340 foreach_standard_reply_retval_handler;
5344 * Table of message reply handlers, must include boilerplate handlers
5348 #define foreach_vpe_api_reply_msg \
5349 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5350 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5351 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5352 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5353 _(CONTROL_PING_REPLY, control_ping_reply) \
5354 _(CLI_REPLY, cli_reply) \
5355 _(CLI_INBAND_REPLY, cli_inband_reply) \
5356 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5357 sw_interface_add_del_address_reply) \
5358 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5359 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5360 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5361 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5362 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5363 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5364 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5365 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5366 sw_interface_set_l2_xconnect_reply) \
5367 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5368 sw_interface_set_l2_bridge_reply) \
5369 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5370 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5371 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5372 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5373 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5374 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5375 _(L2_FLAGS_REPLY, l2_flags_reply) \
5376 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5377 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5378 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5379 _(TAP_DELETE_REPLY, tap_delete_reply) \
5380 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5381 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5382 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5383 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5384 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5385 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5386 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5387 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5388 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5389 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5390 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5391 proxy_arp_intfc_enable_disable_reply) \
5392 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5393 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5394 sw_interface_set_unnumbered_reply) \
5395 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5396 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5397 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5398 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5399 _(RESET_FIB_REPLY, reset_fib_reply) \
5400 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5401 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5402 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5403 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5404 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5405 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5406 sw_interface_ip6_enable_disable_reply) \
5407 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5408 sw_interface_ip6_set_link_local_address_reply) \
5409 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5410 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5411 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5412 sw_interface_ip6nd_ra_prefix_reply) \
5413 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5414 sw_interface_ip6nd_ra_config_reply) \
5415 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5416 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5417 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5418 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5419 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5420 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5421 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5422 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5423 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5424 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5425 classify_set_interface_ip_table_reply) \
5426 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5427 classify_set_interface_l2_tables_reply) \
5428 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5429 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5430 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5431 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5432 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5433 l2tpv3_interface_enable_disable_reply) \
5434 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5435 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5436 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5437 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5438 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5439 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5440 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5441 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5442 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5443 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5444 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5445 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5446 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5447 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5448 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5449 _(SHOW_VERSION_REPLY, show_version_reply) \
5450 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5451 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5452 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5453 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5454 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5455 _(IP4_ARP_EVENT, ip4_arp_event) \
5456 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5457 _(IP6_ND_EVENT, ip6_nd_event) \
5458 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5459 _(L2_MACS_EVENT, l2_macs_event) \
5460 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5461 _(IP_ADDRESS_DETAILS, ip_address_details) \
5462 _(IP_DETAILS, ip_details) \
5463 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5464 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5465 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5466 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5467 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5468 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5469 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5470 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5471 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5472 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5473 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5474 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5475 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5476 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5477 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5478 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5479 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5480 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5481 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5482 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5483 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5484 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5485 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5486 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5487 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5488 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5489 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5490 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5491 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5492 _(MAP_RULE_DETAILS, map_rule_details) \
5493 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5494 _(WANT_STATS_REPLY, want_stats_reply) \
5495 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5496 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5497 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5498 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5499 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5500 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5501 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5502 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5503 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5504 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5505 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5506 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5507 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5508 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5509 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5510 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5511 one_map_register_enable_disable_reply) \
5512 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5513 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5514 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5515 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5516 one_map_register_fallback_threshold_reply) \
5517 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5518 one_rloc_probe_enable_disable_reply) \
5519 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5520 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5521 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5522 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5523 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5524 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5525 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5526 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5527 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5528 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5529 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5530 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5531 _(ONE_STATS_DETAILS, one_stats_details) \
5532 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5533 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5534 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5535 show_one_stats_enable_disable_reply) \
5536 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5537 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5538 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5539 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5540 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5541 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5542 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5543 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5544 one_enable_disable_pitr_mode_reply) \
5545 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5546 one_enable_disable_petr_mode_reply) \
5547 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5548 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5549 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5550 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5551 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5552 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5553 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5554 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5555 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5556 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5557 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5558 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5559 gpe_add_del_native_fwd_rpath_reply) \
5560 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5561 gpe_fwd_entry_path_details) \
5562 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5563 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5564 one_add_del_map_request_itr_rlocs_reply) \
5565 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5566 one_get_map_request_itr_rlocs_reply) \
5567 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5568 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5569 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5570 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5571 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5572 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5573 show_one_map_register_state_reply) \
5574 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5575 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5576 show_one_map_register_fallback_threshold_reply) \
5577 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5578 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5579 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5580 _(POLICER_DETAILS, policer_details) \
5581 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5582 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5583 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5584 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5585 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5586 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5587 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5588 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5589 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5590 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5591 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5592 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5593 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5594 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5595 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5596 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5597 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5598 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5599 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5600 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5601 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5602 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5603 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5604 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5605 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5606 ip_source_and_port_range_check_add_del_reply) \
5607 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5608 ip_source_and_port_range_check_interface_add_del_reply) \
5609 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5610 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5611 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5612 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5613 _(PUNT_REPLY, punt_reply) \
5614 _(IP_FIB_DETAILS, ip_fib_details) \
5615 _(IP6_FIB_DETAILS, ip6_fib_details) \
5616 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5617 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5618 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5619 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5620 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5621 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5622 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5623 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5624 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5625 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5626 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5627 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5628 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5629 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5630 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5631 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5632 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5633 _(SESSION_RULES_DETAILS, session_rules_details) \
5634 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5636 #define foreach_standalone_reply_msg \
5637 _(SW_INTERFACE_EVENT, sw_interface_event) \
5638 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5639 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5640 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5641 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5642 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5643 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
5644 _(MEMFD_SEGMENT_CREATE_REPLY, memfd_segment_create_reply) \
5653 #define STR_VTR_OP_CASE(op) \
5654 case L2_VTR_ ## op: \
5658 str_vtr_op (u32 vtr_op)
5662 STR_VTR_OP_CASE (DISABLED);
5663 STR_VTR_OP_CASE (PUSH_1);
5664 STR_VTR_OP_CASE (PUSH_2);
5665 STR_VTR_OP_CASE (POP_1);
5666 STR_VTR_OP_CASE (POP_2);
5667 STR_VTR_OP_CASE (TRANSLATE_1_1);
5668 STR_VTR_OP_CASE (TRANSLATE_1_2);
5669 STR_VTR_OP_CASE (TRANSLATE_2_1);
5670 STR_VTR_OP_CASE (TRANSLATE_2_2);
5677 dump_sub_interface_table (vat_main_t * vam)
5679 const sw_interface_subif_t *sub = NULL;
5681 if (vam->json_output)
5684 ("JSON output supported only for VPE API calls and dump_stats_table");
5689 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5690 "Interface", "sw_if_index",
5691 "sub id", "dot1ad", "tags", "outer id",
5692 "inner id", "exact", "default", "outer any", "inner any");
5694 vec_foreach (sub, vam->sw_if_subif_table)
5697 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5698 sub->interface_name,
5700 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5701 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5702 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5703 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5704 if (sub->vtr_op != L2_VTR_DISABLED)
5707 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5708 "tag1: %d tag2: %d ]",
5709 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5710 sub->vtr_tag1, sub->vtr_tag2);
5718 name_sort_cmp (void *a1, void *a2)
5720 name_sort_t *n1 = a1;
5721 name_sort_t *n2 = a2;
5723 return strcmp ((char *) n1->name, (char *) n2->name);
5727 dump_interface_table (vat_main_t * vam)
5730 name_sort_t *nses = 0, *ns;
5732 if (vam->json_output)
5735 ("JSON output supported only for VPE API calls and dump_stats_table");
5740 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5742 vec_add2 (nses, ns, 1);
5743 ns->name = (u8 *)(p->key);
5744 ns->value = (u32) p->value[0];
5748 vec_sort_with_function (nses, name_sort_cmp);
5750 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5751 vec_foreach (ns, nses)
5753 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5760 dump_ip_table (vat_main_t * vam, int is_ipv6)
5762 const ip_details_t *det = NULL;
5763 const ip_address_details_t *address = NULL;
5766 print (vam->ofp, "%-12s", "sw_if_index");
5768 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5775 print (vam->ofp, "%-12d", i);
5776 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5781 vec_foreach (address, det->addr)
5785 is_ipv6 ? format_ip6_address : format_ip4_address,
5786 address->ip, address->prefix_length);
5794 dump_ipv4_table (vat_main_t * vam)
5796 if (vam->json_output)
5799 ("JSON output supported only for VPE API calls and dump_stats_table");
5803 return dump_ip_table (vam, 0);
5807 dump_ipv6_table (vat_main_t * vam)
5809 if (vam->json_output)
5812 ("JSON output supported only for VPE API calls and dump_stats_table");
5816 return dump_ip_table (vam, 1);
5820 counter_type_to_str (u8 counter_type, u8 is_combined)
5824 switch (counter_type)
5826 case VNET_INTERFACE_COUNTER_DROP:
5828 case VNET_INTERFACE_COUNTER_PUNT:
5830 case VNET_INTERFACE_COUNTER_IP4:
5832 case VNET_INTERFACE_COUNTER_IP6:
5834 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5836 case VNET_INTERFACE_COUNTER_RX_MISS:
5838 case VNET_INTERFACE_COUNTER_RX_ERROR:
5840 case VNET_INTERFACE_COUNTER_TX_ERROR:
5843 return "INVALID-COUNTER-TYPE";
5848 switch (counter_type)
5850 case VNET_INTERFACE_COUNTER_RX:
5852 case VNET_INTERFACE_COUNTER_TX:
5855 return "INVALID-COUNTER-TYPE";
5861 dump_stats_table (vat_main_t * vam)
5863 vat_json_node_t node;
5864 vat_json_node_t *msg_array;
5865 vat_json_node_t *msg;
5866 vat_json_node_t *counter_array;
5867 vat_json_node_t *counter;
5868 interface_counter_t c;
5870 ip4_fib_counter_t *c4;
5871 ip6_fib_counter_t *c6;
5872 ip4_nbr_counter_t *n4;
5873 ip6_nbr_counter_t *n6;
5876 if (!vam->json_output)
5878 clib_warning ("dump_stats_table supported only in JSON format");
5882 vat_json_init_object (&node);
5884 /* interface counters */
5885 msg_array = vat_json_object_add (&node, "interface_counters");
5886 vat_json_init_array (msg_array);
5887 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5889 msg = vat_json_array_add (msg_array);
5890 vat_json_init_object (msg);
5891 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5892 (u8 *) counter_type_to_str (i, 0));
5893 vat_json_object_add_int (msg, "is_combined", 0);
5894 counter_array = vat_json_object_add (msg, "data");
5895 vat_json_init_array (counter_array);
5896 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5898 packets = vam->simple_interface_counters[i][j];
5899 vat_json_array_add_uint (counter_array, packets);
5902 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5904 msg = vat_json_array_add (msg_array);
5905 vat_json_init_object (msg);
5906 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5907 (u8 *) counter_type_to_str (i, 1));
5908 vat_json_object_add_int (msg, "is_combined", 1);
5909 counter_array = vat_json_object_add (msg, "data");
5910 vat_json_init_array (counter_array);
5911 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5913 c = vam->combined_interface_counters[i][j];
5914 counter = vat_json_array_add (counter_array);
5915 vat_json_init_object (counter);
5916 vat_json_object_add_uint (counter, "packets", c.packets);
5917 vat_json_object_add_uint (counter, "bytes", c.bytes);
5921 /* ip4 fib counters */
5922 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5923 vat_json_init_array (msg_array);
5924 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5926 msg = vat_json_array_add (msg_array);
5927 vat_json_init_object (msg);
5928 vat_json_object_add_uint (msg, "vrf_id",
5929 vam->ip4_fib_counters_vrf_id_by_index[i]);
5930 counter_array = vat_json_object_add (msg, "c");
5931 vat_json_init_array (counter_array);
5932 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5934 counter = vat_json_array_add (counter_array);
5935 vat_json_init_object (counter);
5936 c4 = &vam->ip4_fib_counters[i][j];
5937 vat_json_object_add_ip4 (counter, "address", c4->address);
5938 vat_json_object_add_uint (counter, "address_length",
5939 c4->address_length);
5940 vat_json_object_add_uint (counter, "packets", c4->packets);
5941 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5945 /* ip6 fib counters */
5946 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5947 vat_json_init_array (msg_array);
5948 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5950 msg = vat_json_array_add (msg_array);
5951 vat_json_init_object (msg);
5952 vat_json_object_add_uint (msg, "vrf_id",
5953 vam->ip6_fib_counters_vrf_id_by_index[i]);
5954 counter_array = vat_json_object_add (msg, "c");
5955 vat_json_init_array (counter_array);
5956 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5958 counter = vat_json_array_add (counter_array);
5959 vat_json_init_object (counter);
5960 c6 = &vam->ip6_fib_counters[i][j];
5961 vat_json_object_add_ip6 (counter, "address", c6->address);
5962 vat_json_object_add_uint (counter, "address_length",
5963 c6->address_length);
5964 vat_json_object_add_uint (counter, "packets", c6->packets);
5965 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5969 /* ip4 nbr counters */
5970 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5971 vat_json_init_array (msg_array);
5972 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5974 msg = vat_json_array_add (msg_array);
5975 vat_json_init_object (msg);
5976 vat_json_object_add_uint (msg, "sw_if_index", i);
5977 counter_array = vat_json_object_add (msg, "c");
5978 vat_json_init_array (counter_array);
5979 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5981 counter = vat_json_array_add (counter_array);
5982 vat_json_init_object (counter);
5983 n4 = &vam->ip4_nbr_counters[i][j];
5984 vat_json_object_add_ip4 (counter, "address", n4->address);
5985 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5986 vat_json_object_add_uint (counter, "packets", n4->packets);
5987 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5991 /* ip6 nbr counters */
5992 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5993 vat_json_init_array (msg_array);
5994 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5996 msg = vat_json_array_add (msg_array);
5997 vat_json_init_object (msg);
5998 vat_json_object_add_uint (msg, "sw_if_index", i);
5999 counter_array = vat_json_object_add (msg, "c");
6000 vat_json_init_array (counter_array);
6001 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6003 counter = vat_json_array_add (counter_array);
6004 vat_json_init_object (counter);
6005 n6 = &vam->ip6_nbr_counters[i][j];
6006 vat_json_object_add_ip6 (counter, "address", n6->address);
6007 vat_json_object_add_uint (counter, "packets", n6->packets);
6008 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6012 vat_json_print (vam->ofp, &node);
6013 vat_json_free (&node);
6019 * Pass CLI buffers directly in the CLI_INBAND API message,
6020 * instead of an additional shared memory area.
6023 exec_inband (vat_main_t * vam)
6025 vl_api_cli_inband_t *mp;
6026 unformat_input_t *i = vam->input;
6029 if (vec_len (i->buffer) == 0)
6032 if (vam->exec_mode == 0 && unformat (i, "mode"))
6037 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6044 * In order for the CLI command to work, it
6045 * must be a vector ending in \n, not a C-string ending
6048 u32 len = vec_len (vam->input->buffer);
6049 M2 (CLI_INBAND, mp, len);
6050 clib_memcpy (mp->cmd, vam->input->buffer, len);
6051 mp->length = htonl (len);
6055 /* json responses may or may not include a useful reply... */
6056 if (vec_len (vam->cmd_reply))
6057 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6062 exec (vat_main_t * vam)
6064 return exec_inband (vam);
6068 api_create_loopback (vat_main_t * vam)
6070 unformat_input_t *i = vam->input;
6071 vl_api_create_loopback_t *mp;
6072 vl_api_create_loopback_instance_t *mp_lbi;
6075 u8 is_specified = 0;
6076 u32 user_instance = 0;
6079 memset (mac_address, 0, sizeof (mac_address));
6081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6083 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6085 if (unformat (i, "instance %d", &user_instance))
6093 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6094 mp_lbi->is_specified = is_specified;
6096 mp_lbi->user_instance = htonl (user_instance);
6098 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6103 /* Construct the API message */
6104 M (CREATE_LOOPBACK, mp);
6106 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6115 api_delete_loopback (vat_main_t * vam)
6117 unformat_input_t *i = vam->input;
6118 vl_api_delete_loopback_t *mp;
6119 u32 sw_if_index = ~0;
6122 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6124 if (unformat (i, "sw_if_index %d", &sw_if_index))
6130 if (sw_if_index == ~0)
6132 errmsg ("missing sw_if_index");
6136 /* Construct the API message */
6137 M (DELETE_LOOPBACK, mp);
6138 mp->sw_if_index = ntohl (sw_if_index);
6146 api_want_stats (vat_main_t * vam)
6148 unformat_input_t *i = vam->input;
6149 vl_api_want_stats_t *mp;
6153 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6155 if (unformat (i, "enable"))
6157 else if (unformat (i, "disable"))
6165 errmsg ("missing enable|disable");
6170 mp->enable_disable = enable;
6178 api_want_interface_events (vat_main_t * vam)
6180 unformat_input_t *i = vam->input;
6181 vl_api_want_interface_events_t *mp;
6185 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6187 if (unformat (i, "enable"))
6189 else if (unformat (i, "disable"))
6197 errmsg ("missing enable|disable");
6201 M (WANT_INTERFACE_EVENTS, mp);
6202 mp->enable_disable = enable;
6204 vam->interface_event_display = enable;
6212 /* Note: non-static, called once to set up the initial intfc table */
6214 api_sw_interface_dump (vat_main_t * vam)
6216 vl_api_sw_interface_dump_t *mp;
6217 vl_api_control_ping_t *mp_ping;
6219 name_sort_t *nses = 0, *ns;
6220 sw_interface_subif_t *sub = NULL;
6223 /* Toss the old name table */
6225 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6227 vec_add2 (nses, ns, 1);
6228 ns->name = (u8 *)(p->key);
6229 ns->value = (u32) p->value[0];
6233 hash_free (vam->sw_if_index_by_interface_name);
6235 vec_foreach (ns, nses) vec_free (ns->name);
6239 vec_foreach (sub, vam->sw_if_subif_table)
6241 vec_free (sub->interface_name);
6243 vec_free (vam->sw_if_subif_table);
6245 /* recreate the interface name hash table */
6246 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6248 /* Get list of ethernets */
6249 M (SW_INTERFACE_DUMP, mp);
6250 mp->name_filter_valid = 1;
6251 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
6254 /* and local / loopback interfaces */
6255 M (SW_INTERFACE_DUMP, mp);
6256 mp->name_filter_valid = 1;
6257 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
6260 /* and packet-generator interfaces */
6261 M (SW_INTERFACE_DUMP, mp);
6262 mp->name_filter_valid = 1;
6263 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
6266 /* and vxlan-gpe tunnel interfaces */
6267 M (SW_INTERFACE_DUMP, mp);
6268 mp->name_filter_valid = 1;
6269 strncpy ((char *) mp->name_filter, "vxlan_gpe",
6270 sizeof (mp->name_filter) - 1);
6273 /* and vxlan tunnel interfaces */
6274 M (SW_INTERFACE_DUMP, mp);
6275 mp->name_filter_valid = 1;
6276 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
6279 /* and geneve tunnel interfaces */
6280 M (SW_INTERFACE_DUMP, mp);
6281 mp->name_filter_valid = 1;
6282 strncpy ((char *) mp->name_filter, "geneve", sizeof (mp->name_filter) - 1);
6285 /* and host (af_packet) interfaces */
6286 M (SW_INTERFACE_DUMP, mp);
6287 mp->name_filter_valid = 1;
6288 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
6291 /* and l2tpv3 tunnel interfaces */
6292 M (SW_INTERFACE_DUMP, mp);
6293 mp->name_filter_valid = 1;
6294 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
6295 sizeof (mp->name_filter) - 1);
6298 /* and GRE tunnel interfaces */
6299 M (SW_INTERFACE_DUMP, mp);
6300 mp->name_filter_valid = 1;
6301 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
6304 /* and LISP-GPE interfaces */
6305 M (SW_INTERFACE_DUMP, mp);
6306 mp->name_filter_valid = 1;
6307 strncpy ((char *) mp->name_filter, "lisp_gpe",
6308 sizeof (mp->name_filter) - 1);
6311 /* and IPSEC tunnel interfaces */
6312 M (SW_INTERFACE_DUMP, mp);
6313 mp->name_filter_valid = 1;
6314 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
6317 /* Use a control ping for synchronization */
6318 MPING (CONTROL_PING, mp_ping);
6326 api_sw_interface_set_flags (vat_main_t * vam)
6328 unformat_input_t *i = vam->input;
6329 vl_api_sw_interface_set_flags_t *mp;
6331 u8 sw_if_index_set = 0;
6335 /* Parse args required to build the message */
6336 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6338 if (unformat (i, "admin-up"))
6340 else if (unformat (i, "admin-down"))
6343 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6344 sw_if_index_set = 1;
6345 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6346 sw_if_index_set = 1;
6351 if (sw_if_index_set == 0)
6353 errmsg ("missing interface name or sw_if_index");
6357 /* Construct the API message */
6358 M (SW_INTERFACE_SET_FLAGS, mp);
6359 mp->sw_if_index = ntohl (sw_if_index);
6360 mp->admin_up_down = admin_up;
6365 /* Wait for a reply, return the good/bad news... */
6371 api_sw_interface_set_rx_mode (vat_main_t * vam)
6373 unformat_input_t *i = vam->input;
6374 vl_api_sw_interface_set_rx_mode_t *mp;
6376 u8 sw_if_index_set = 0;
6378 u8 queue_id_valid = 0;
6380 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6382 /* Parse args required to build the message */
6383 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6385 if (unformat (i, "queue %d", &queue_id))
6387 else if (unformat (i, "polling"))
6388 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6389 else if (unformat (i, "interrupt"))
6390 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6391 else if (unformat (i, "adaptive"))
6392 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6394 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6395 sw_if_index_set = 1;
6396 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6397 sw_if_index_set = 1;
6402 if (sw_if_index_set == 0)
6404 errmsg ("missing interface name or sw_if_index");
6407 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6409 errmsg ("missing rx-mode");
6413 /* Construct the API message */
6414 M (SW_INTERFACE_SET_RX_MODE, mp);
6415 mp->sw_if_index = ntohl (sw_if_index);
6417 mp->queue_id_valid = queue_id_valid;
6418 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6423 /* Wait for a reply, return the good/bad news... */
6429 api_sw_interface_clear_stats (vat_main_t * vam)
6431 unformat_input_t *i = vam->input;
6432 vl_api_sw_interface_clear_stats_t *mp;
6434 u8 sw_if_index_set = 0;
6437 /* Parse args required to build the message */
6438 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6440 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6441 sw_if_index_set = 1;
6442 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6443 sw_if_index_set = 1;
6448 /* Construct the API message */
6449 M (SW_INTERFACE_CLEAR_STATS, mp);
6451 if (sw_if_index_set == 1)
6452 mp->sw_if_index = ntohl (sw_if_index);
6454 mp->sw_if_index = ~0;
6459 /* Wait for a reply, return the good/bad news... */
6465 api_sw_interface_add_del_address (vat_main_t * vam)
6467 unformat_input_t *i = vam->input;
6468 vl_api_sw_interface_add_del_address_t *mp;
6470 u8 sw_if_index_set = 0;
6471 u8 is_add = 1, del_all = 0;
6472 u32 address_length = 0;
6473 u8 v4_address_set = 0;
6474 u8 v6_address_set = 0;
6475 ip4_address_t v4address;
6476 ip6_address_t v6address;
6479 /* Parse args required to build the message */
6480 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6482 if (unformat (i, "del-all"))
6484 else if (unformat (i, "del"))
6487 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6488 sw_if_index_set = 1;
6489 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6490 sw_if_index_set = 1;
6491 else if (unformat (i, "%U/%d",
6492 unformat_ip4_address, &v4address, &address_length))
6494 else if (unformat (i, "%U/%d",
6495 unformat_ip6_address, &v6address, &address_length))
6501 if (sw_if_index_set == 0)
6503 errmsg ("missing interface name or sw_if_index");
6506 if (v4_address_set && v6_address_set)
6508 errmsg ("both v4 and v6 addresses set");
6511 if (!v4_address_set && !v6_address_set && !del_all)
6513 errmsg ("no addresses set");
6517 /* Construct the API message */
6518 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6520 mp->sw_if_index = ntohl (sw_if_index);
6521 mp->is_add = is_add;
6522 mp->del_all = del_all;
6526 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6530 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6532 mp->address_length = address_length;
6537 /* Wait for a reply, return good/bad news */
6543 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6545 unformat_input_t *i = vam->input;
6546 vl_api_sw_interface_set_mpls_enable_t *mp;
6548 u8 sw_if_index_set = 0;
6552 /* Parse args required to build the message */
6553 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6555 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6556 sw_if_index_set = 1;
6557 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6558 sw_if_index_set = 1;
6559 else if (unformat (i, "disable"))
6561 else if (unformat (i, "dis"))
6567 if (sw_if_index_set == 0)
6569 errmsg ("missing interface name or sw_if_index");
6573 /* Construct the API message */
6574 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6576 mp->sw_if_index = ntohl (sw_if_index);
6577 mp->enable = enable;
6582 /* Wait for a reply... */
6588 api_sw_interface_set_table (vat_main_t * vam)
6590 unformat_input_t *i = vam->input;
6591 vl_api_sw_interface_set_table_t *mp;
6592 u32 sw_if_index, vrf_id = 0;
6593 u8 sw_if_index_set = 0;
6597 /* Parse args required to build the message */
6598 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6600 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6601 sw_if_index_set = 1;
6602 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6603 sw_if_index_set = 1;
6604 else if (unformat (i, "vrf %d", &vrf_id))
6606 else if (unformat (i, "ipv6"))
6612 if (sw_if_index_set == 0)
6614 errmsg ("missing interface name or sw_if_index");
6618 /* Construct the API message */
6619 M (SW_INTERFACE_SET_TABLE, mp);
6621 mp->sw_if_index = ntohl (sw_if_index);
6622 mp->is_ipv6 = is_ipv6;
6623 mp->vrf_id = ntohl (vrf_id);
6628 /* Wait for a reply... */
6633 static void vl_api_sw_interface_get_table_reply_t_handler
6634 (vl_api_sw_interface_get_table_reply_t * mp)
6636 vat_main_t *vam = &vat_main;
6638 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6640 vam->retval = ntohl (mp->retval);
6641 vam->result_ready = 1;
6645 static void vl_api_sw_interface_get_table_reply_t_handler_json
6646 (vl_api_sw_interface_get_table_reply_t * mp)
6648 vat_main_t *vam = &vat_main;
6649 vat_json_node_t node;
6651 vat_json_init_object (&node);
6652 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6653 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6655 vat_json_print (vam->ofp, &node);
6656 vat_json_free (&node);
6658 vam->retval = ntohl (mp->retval);
6659 vam->result_ready = 1;
6663 api_sw_interface_get_table (vat_main_t * vam)
6665 unformat_input_t *i = vam->input;
6666 vl_api_sw_interface_get_table_t *mp;
6668 u8 sw_if_index_set = 0;
6672 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6674 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6675 sw_if_index_set = 1;
6676 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6677 sw_if_index_set = 1;
6678 else if (unformat (i, "ipv6"))
6684 if (sw_if_index_set == 0)
6686 errmsg ("missing interface name or sw_if_index");
6690 M (SW_INTERFACE_GET_TABLE, mp);
6691 mp->sw_if_index = htonl (sw_if_index);
6692 mp->is_ipv6 = is_ipv6;
6700 api_sw_interface_set_vpath (vat_main_t * vam)
6702 unformat_input_t *i = vam->input;
6703 vl_api_sw_interface_set_vpath_t *mp;
6704 u32 sw_if_index = 0;
6705 u8 sw_if_index_set = 0;
6709 /* Parse args required to build the message */
6710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6712 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6713 sw_if_index_set = 1;
6714 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6715 sw_if_index_set = 1;
6716 else if (unformat (i, "enable"))
6718 else if (unformat (i, "disable"))
6724 if (sw_if_index_set == 0)
6726 errmsg ("missing interface name or sw_if_index");
6730 /* Construct the API message */
6731 M (SW_INTERFACE_SET_VPATH, mp);
6733 mp->sw_if_index = ntohl (sw_if_index);
6734 mp->enable = is_enable;
6739 /* Wait for a reply... */
6745 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6747 unformat_input_t *i = vam->input;
6748 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6749 u32 sw_if_index = 0;
6750 u8 sw_if_index_set = 0;
6755 /* Parse args required to build the message */
6756 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6758 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6759 sw_if_index_set = 1;
6760 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6761 sw_if_index_set = 1;
6762 else if (unformat (i, "enable"))
6764 else if (unformat (i, "disable"))
6766 else if (unformat (i, "ip4"))
6768 else if (unformat (i, "ip6"))
6774 if (sw_if_index_set == 0)
6776 errmsg ("missing interface name or sw_if_index");
6780 /* Construct the API message */
6781 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6783 mp->sw_if_index = ntohl (sw_if_index);
6784 mp->enable = is_enable;
6785 mp->is_ipv6 = is_ipv6;
6790 /* Wait for a reply... */
6796 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6798 unformat_input_t *i = vam->input;
6799 vl_api_sw_interface_set_geneve_bypass_t *mp;
6800 u32 sw_if_index = 0;
6801 u8 sw_if_index_set = 0;
6806 /* Parse args required to build the message */
6807 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6809 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6810 sw_if_index_set = 1;
6811 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6812 sw_if_index_set = 1;
6813 else if (unformat (i, "enable"))
6815 else if (unformat (i, "disable"))
6817 else if (unformat (i, "ip4"))
6819 else if (unformat (i, "ip6"))
6825 if (sw_if_index_set == 0)
6827 errmsg ("missing interface name or sw_if_index");
6831 /* Construct the API message */
6832 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6834 mp->sw_if_index = ntohl (sw_if_index);
6835 mp->enable = is_enable;
6836 mp->is_ipv6 = is_ipv6;
6841 /* Wait for a reply... */
6847 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6849 unformat_input_t *i = vam->input;
6850 vl_api_sw_interface_set_l2_xconnect_t *mp;
6852 u8 rx_sw_if_index_set = 0;
6854 u8 tx_sw_if_index_set = 0;
6858 /* Parse args required to build the message */
6859 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6861 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6862 rx_sw_if_index_set = 1;
6863 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6864 tx_sw_if_index_set = 1;
6865 else if (unformat (i, "rx"))
6867 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6869 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6871 rx_sw_if_index_set = 1;
6876 else if (unformat (i, "tx"))
6878 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6880 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6882 tx_sw_if_index_set = 1;
6887 else if (unformat (i, "enable"))
6889 else if (unformat (i, "disable"))
6895 if (rx_sw_if_index_set == 0)
6897 errmsg ("missing rx interface name or rx_sw_if_index");
6901 if (enable && (tx_sw_if_index_set == 0))
6903 errmsg ("missing tx interface name or tx_sw_if_index");
6907 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6909 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6910 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6911 mp->enable = enable;
6919 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6921 unformat_input_t *i = vam->input;
6922 vl_api_sw_interface_set_l2_bridge_t *mp;
6924 u8 rx_sw_if_index_set = 0;
6932 /* Parse args required to build the message */
6933 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6935 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6936 rx_sw_if_index_set = 1;
6937 else if (unformat (i, "bd_id %d", &bd_id))
6941 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6942 rx_sw_if_index_set = 1;
6943 else if (unformat (i, "shg %d", &shg))
6945 else if (unformat (i, "bvi"))
6947 else if (unformat (i, "enable"))
6949 else if (unformat (i, "disable"))
6955 if (rx_sw_if_index_set == 0)
6957 errmsg ("missing rx interface name or sw_if_index");
6961 if (enable && (bd_id_set == 0))
6963 errmsg ("missing bridge domain");
6967 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6969 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6970 mp->bd_id = ntohl (bd_id);
6973 mp->enable = enable;
6981 api_bridge_domain_dump (vat_main_t * vam)
6983 unformat_input_t *i = vam->input;
6984 vl_api_bridge_domain_dump_t *mp;
6985 vl_api_control_ping_t *mp_ping;
6989 /* Parse args required to build the message */
6990 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6992 if (unformat (i, "bd_id %d", &bd_id))
6998 M (BRIDGE_DOMAIN_DUMP, mp);
6999 mp->bd_id = ntohl (bd_id);
7002 /* Use a control ping for synchronization */
7003 MPING (CONTROL_PING, mp_ping);
7011 api_bridge_domain_add_del (vat_main_t * vam)
7013 unformat_input_t *i = vam->input;
7014 vl_api_bridge_domain_add_del_t *mp;
7017 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7022 /* Parse args required to build the message */
7023 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7025 if (unformat (i, "bd_id %d", &bd_id))
7027 else if (unformat (i, "flood %d", &flood))
7029 else if (unformat (i, "uu-flood %d", &uu_flood))
7031 else if (unformat (i, "forward %d", &forward))
7033 else if (unformat (i, "learn %d", &learn))
7035 else if (unformat (i, "arp-term %d", &arp_term))
7037 else if (unformat (i, "mac-age %d", &mac_age))
7039 else if (unformat (i, "bd-tag %s", &bd_tag))
7041 else if (unformat (i, "del"))
7044 flood = uu_flood = forward = learn = 0;
7052 errmsg ("missing bridge domain");
7059 errmsg ("mac age must be less than 256 ");
7064 if ((bd_tag) && (vec_len (bd_tag) > 63))
7066 errmsg ("bd-tag cannot be longer than 63");
7071 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7073 mp->bd_id = ntohl (bd_id);
7075 mp->uu_flood = uu_flood;
7076 mp->forward = forward;
7078 mp->arp_term = arp_term;
7079 mp->is_add = is_add;
7080 mp->mac_age = (u8) mac_age;
7083 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7084 mp->bd_tag[vec_len (bd_tag)] = 0;
7095 api_l2fib_flush_bd (vat_main_t * vam)
7097 unformat_input_t *i = vam->input;
7098 vl_api_l2fib_flush_bd_t *mp;
7102 /* Parse args required to build the message */
7103 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7105 if (unformat (i, "bd_id %d", &bd_id));
7112 errmsg ("missing bridge domain");
7116 M (L2FIB_FLUSH_BD, mp);
7118 mp->bd_id = htonl (bd_id);
7126 api_l2fib_flush_int (vat_main_t * vam)
7128 unformat_input_t *i = vam->input;
7129 vl_api_l2fib_flush_int_t *mp;
7130 u32 sw_if_index = ~0;
7133 /* Parse args required to build the message */
7134 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7136 if (unformat (i, "sw_if_index %d", &sw_if_index));
7138 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7143 if (sw_if_index == ~0)
7145 errmsg ("missing interface name or sw_if_index");
7149 M (L2FIB_FLUSH_INT, mp);
7151 mp->sw_if_index = ntohl (sw_if_index);
7159 api_l2fib_add_del (vat_main_t * vam)
7161 unformat_input_t *i = vam->input;
7162 vl_api_l2fib_add_del_t *mp;
7168 u32 sw_if_index = ~0;
7169 u8 sw_if_index_set = 0;
7178 /* Parse args required to build the message */
7179 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7181 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7183 else if (unformat (i, "bd_id %d", &bd_id))
7185 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7186 sw_if_index_set = 1;
7187 else if (unformat (i, "sw_if"))
7189 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7192 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7193 sw_if_index_set = 1;
7198 else if (unformat (i, "static"))
7200 else if (unformat (i, "filter"))
7205 else if (unformat (i, "bvi"))
7210 else if (unformat (i, "del"))
7212 else if (unformat (i, "count %d", &count))
7220 errmsg ("missing mac address");
7226 errmsg ("missing bridge domain");
7230 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7232 errmsg ("missing interface name or sw_if_index");
7238 /* Turn on async mode */
7239 vam->async_mode = 1;
7240 vam->async_errors = 0;
7241 before = vat_time_now (vam);
7244 for (j = 0; j < count; j++)
7246 M (L2FIB_ADD_DEL, mp);
7248 clib_memcpy (mp->mac, mac, 6);
7249 mp->bd_id = ntohl (bd_id);
7250 mp->is_add = is_add;
7254 mp->sw_if_index = ntohl (sw_if_index);
7255 mp->static_mac = static_mac;
7256 mp->filter_mac = filter_mac;
7257 mp->bvi_mac = bvi_mac;
7259 increment_mac_address (mac);
7266 vl_api_control_ping_t *mp_ping;
7269 /* Shut off async mode */
7270 vam->async_mode = 0;
7272 MPING (CONTROL_PING, mp_ping);
7275 timeout = vat_time_now (vam) + 1.0;
7276 while (vat_time_now (vam) < timeout)
7277 if (vam->result_ready == 1)
7282 if (vam->retval == -99)
7285 if (vam->async_errors > 0)
7287 errmsg ("%d asynchronous errors", vam->async_errors);
7290 vam->async_errors = 0;
7291 after = vat_time_now (vam);
7293 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7294 count, after - before, count / (after - before));
7300 /* Wait for a reply... */
7304 /* Return the good/bad news */
7305 return (vam->retval);
7309 api_bridge_domain_set_mac_age (vat_main_t * vam)
7311 unformat_input_t *i = vam->input;
7312 vl_api_bridge_domain_set_mac_age_t *mp;
7317 /* Parse args required to build the message */
7318 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7320 if (unformat (i, "bd_id %d", &bd_id));
7321 else if (unformat (i, "mac-age %d", &mac_age));
7328 errmsg ("missing bridge domain");
7334 errmsg ("mac age must be less than 256 ");
7338 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7340 mp->bd_id = htonl (bd_id);
7341 mp->mac_age = (u8) mac_age;
7349 api_l2_flags (vat_main_t * vam)
7351 unformat_input_t *i = vam->input;
7352 vl_api_l2_flags_t *mp;
7355 u8 sw_if_index_set = 0;
7359 /* Parse args required to build the message */
7360 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7362 if (unformat (i, "sw_if_index %d", &sw_if_index))
7363 sw_if_index_set = 1;
7364 else if (unformat (i, "sw_if"))
7366 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7369 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7370 sw_if_index_set = 1;
7375 else if (unformat (i, "learn"))
7377 else if (unformat (i, "forward"))
7379 else if (unformat (i, "flood"))
7381 else if (unformat (i, "uu-flood"))
7382 flags |= L2_UU_FLOOD;
7383 else if (unformat (i, "arp-term"))
7384 flags |= L2_ARP_TERM;
7385 else if (unformat (i, "off"))
7387 else if (unformat (i, "disable"))
7393 if (sw_if_index_set == 0)
7395 errmsg ("missing interface name or sw_if_index");
7401 mp->sw_if_index = ntohl (sw_if_index);
7402 mp->feature_bitmap = ntohl (flags);
7403 mp->is_set = is_set;
7411 api_bridge_flags (vat_main_t * vam)
7413 unformat_input_t *i = vam->input;
7414 vl_api_bridge_flags_t *mp;
7421 /* Parse args required to build the message */
7422 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7424 if (unformat (i, "bd_id %d", &bd_id))
7426 else if (unformat (i, "learn"))
7428 else if (unformat (i, "forward"))
7430 else if (unformat (i, "flood"))
7432 else if (unformat (i, "uu-flood"))
7433 flags |= L2_UU_FLOOD;
7434 else if (unformat (i, "arp-term"))
7435 flags |= L2_ARP_TERM;
7436 else if (unformat (i, "off"))
7438 else if (unformat (i, "disable"))
7446 errmsg ("missing bridge domain");
7450 M (BRIDGE_FLAGS, mp);
7452 mp->bd_id = ntohl (bd_id);
7453 mp->feature_bitmap = ntohl (flags);
7454 mp->is_set = is_set;
7462 api_bd_ip_mac_add_del (vat_main_t * vam)
7464 unformat_input_t *i = vam->input;
7465 vl_api_bd_ip_mac_add_del_t *mp;
7472 ip4_address_t v4addr;
7473 ip6_address_t v6addr;
7478 /* Parse args required to build the message */
7479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7481 if (unformat (i, "bd_id %d", &bd_id))
7485 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7489 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7494 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7498 else if (unformat (i, "del"))
7506 errmsg ("missing bridge domain");
7509 else if (ip_set == 0)
7511 errmsg ("missing IP address");
7514 else if (mac_set == 0)
7516 errmsg ("missing MAC address");
7520 M (BD_IP_MAC_ADD_DEL, mp);
7522 mp->bd_id = ntohl (bd_id);
7523 mp->is_ipv6 = is_ipv6;
7524 mp->is_add = is_add;
7526 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7528 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7529 clib_memcpy (mp->mac_address, macaddr, 6);
7536 api_tap_connect (vat_main_t * vam)
7538 unformat_input_t *i = vam->input;
7539 vl_api_tap_connect_t *mp;
7545 ip4_address_t ip4_address;
7547 int ip4_address_set = 0;
7548 ip6_address_t ip6_address;
7550 int ip6_address_set = 0;
7553 memset (mac_address, 0, sizeof (mac_address));
7555 /* Parse args required to build the message */
7556 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7558 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7562 else if (unformat (i, "random-mac"))
7564 else if (unformat (i, "tapname %s", &tap_name))
7566 else if (unformat (i, "tag %s", &tag))
7568 else if (unformat (i, "address %U/%d",
7569 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7570 ip4_address_set = 1;
7571 else if (unformat (i, "address %U/%d",
7572 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7573 ip6_address_set = 1;
7580 errmsg ("missing tap name");
7583 if (vec_len (tap_name) > 63)
7585 errmsg ("tap name too long");
7588 vec_add1 (tap_name, 0);
7590 if (vec_len (tag) > 63)
7592 errmsg ("tag too long");
7596 /* Construct the API message */
7597 M (TAP_CONNECT, mp);
7599 mp->use_random_mac = random_mac;
7600 clib_memcpy (mp->mac_address, mac_address, 6);
7601 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7603 clib_memcpy (mp->tag, tag, vec_len (tag));
7605 if (ip4_address_set)
7607 mp->ip4_address_set = 1;
7608 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7609 mp->ip4_mask_width = ip4_mask_width;
7611 if (ip6_address_set)
7613 mp->ip6_address_set = 1;
7614 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7615 mp->ip6_mask_width = ip6_mask_width;
7618 vec_free (tap_name);
7624 /* Wait for a reply... */
7630 api_tap_modify (vat_main_t * vam)
7632 unformat_input_t *i = vam->input;
7633 vl_api_tap_modify_t *mp;
7638 u32 sw_if_index = ~0;
7639 u8 sw_if_index_set = 0;
7642 memset (mac_address, 0, sizeof (mac_address));
7644 /* Parse args required to build the message */
7645 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7647 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7648 sw_if_index_set = 1;
7649 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7650 sw_if_index_set = 1;
7651 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7655 else if (unformat (i, "random-mac"))
7657 else if (unformat (i, "tapname %s", &tap_name))
7663 if (sw_if_index_set == 0)
7665 errmsg ("missing vpp interface name");
7670 errmsg ("missing tap name");
7673 if (vec_len (tap_name) > 63)
7675 errmsg ("tap name too long");
7677 vec_add1 (tap_name, 0);
7679 /* Construct the API message */
7682 mp->use_random_mac = random_mac;
7683 mp->sw_if_index = ntohl (sw_if_index);
7684 clib_memcpy (mp->mac_address, mac_address, 6);
7685 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7686 vec_free (tap_name);
7691 /* Wait for a reply... */
7697 api_tap_delete (vat_main_t * vam)
7699 unformat_input_t *i = vam->input;
7700 vl_api_tap_delete_t *mp;
7701 u32 sw_if_index = ~0;
7702 u8 sw_if_index_set = 0;
7705 /* Parse args required to build the message */
7706 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7708 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7709 sw_if_index_set = 1;
7710 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7711 sw_if_index_set = 1;
7716 if (sw_if_index_set == 0)
7718 errmsg ("missing vpp interface name");
7722 /* Construct the API message */
7725 mp->sw_if_index = ntohl (sw_if_index);
7730 /* Wait for a reply... */
7736 api_ip_table_add_del (vat_main_t * vam)
7738 unformat_input_t *i = vam->input;
7739 vl_api_ip_table_add_del_t *mp;
7745 /* Parse args required to build the message */
7746 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7748 if (unformat (i, "ipv6"))
7750 else if (unformat (i, "del"))
7752 else if (unformat (i, "add"))
7754 else if (unformat (i, "table %d", &table_id))
7758 clib_warning ("parse error '%U'", format_unformat_error, i);
7765 errmsg ("missing table-ID");
7769 /* Construct the API message */
7770 M (IP_TABLE_ADD_DEL, mp);
7772 mp->table_id = ntohl (table_id);
7773 mp->is_ipv6 = is_ipv6;
7774 mp->is_add = is_add;
7779 /* Wait for a reply... */
7786 api_ip_add_del_route (vat_main_t * vam)
7788 unformat_input_t *i = vam->input;
7789 vl_api_ip_add_del_route_t *mp;
7790 u32 sw_if_index = ~0, vrf_id = 0;
7792 u8 is_local = 0, is_drop = 0;
7793 u8 is_unreach = 0, is_prohibit = 0;
7794 u8 create_vrf_if_needed = 0;
7796 u32 next_hop_weight = 1;
7797 u8 is_multipath = 0;
7799 u8 address_length_set = 0;
7800 u32 next_hop_table_id = 0;
7801 u32 resolve_attempts = 0;
7802 u32 dst_address_length = 0;
7803 u8 next_hop_set = 0;
7804 ip4_address_t v4_dst_address, v4_next_hop_address;
7805 ip6_address_t v6_dst_address, v6_next_hop_address;
7809 u32 random_add_del = 0;
7810 u32 *random_vector = 0;
7812 u32 random_seed = 0xdeaddabe;
7813 u32 classify_table_index = ~0;
7815 u8 resolve_host = 0, resolve_attached = 0;
7816 mpls_label_t *next_hop_out_label_stack = NULL;
7817 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7818 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7820 /* Parse args required to build the message */
7821 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7823 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7825 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7827 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
7832 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
7837 else if (unformat (i, "/%d", &dst_address_length))
7839 address_length_set = 1;
7842 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
7843 &v4_next_hop_address))
7847 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7848 &v6_next_hop_address))
7852 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7854 else if (unformat (i, "weight %d", &next_hop_weight))
7856 else if (unformat (i, "drop"))
7860 else if (unformat (i, "null-send-unreach"))
7864 else if (unformat (i, "null-send-prohibit"))
7868 else if (unformat (i, "local"))
7872 else if (unformat (i, "classify %d", &classify_table_index))
7876 else if (unformat (i, "del"))
7878 else if (unformat (i, "add"))
7880 else if (unformat (i, "resolve-via-host"))
7882 else if (unformat (i, "resolve-via-attached"))
7883 resolve_attached = 1;
7884 else if (unformat (i, "multipath"))
7886 else if (unformat (i, "vrf %d", &vrf_id))
7888 else if (unformat (i, "create-vrf"))
7889 create_vrf_if_needed = 1;
7890 else if (unformat (i, "count %d", &count))
7892 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7894 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7896 else if (unformat (i, "out-label %d", &next_hop_out_label))
7897 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7898 else if (unformat (i, "via-label %d", &next_hop_via_label))
7900 else if (unformat (i, "random"))
7902 else if (unformat (i, "seed %d", &random_seed))
7906 clib_warning ("parse error '%U'", format_unformat_error, i);
7911 if (!next_hop_set && !is_drop && !is_local &&
7912 !is_classify && !is_unreach && !is_prohibit &&
7913 MPLS_LABEL_INVALID == next_hop_via_label)
7916 ("next hop / local / drop / unreach / prohibit / classify not set");
7920 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7922 errmsg ("next hop and next-hop via label set");
7925 if (address_set == 0)
7927 errmsg ("missing addresses");
7931 if (address_length_set == 0)
7933 errmsg ("missing address length");
7937 /* Generate a pile of unique, random routes */
7940 u32 this_random_address;
7941 random_hash = hash_create (count, sizeof (uword));
7943 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7944 for (j = 0; j <= count; j++)
7948 this_random_address = random_u32 (&random_seed);
7949 this_random_address =
7950 clib_host_to_net_u32 (this_random_address);
7952 while (hash_get (random_hash, this_random_address));
7953 vec_add1 (random_vector, this_random_address);
7954 hash_set (random_hash, this_random_address, 1);
7956 hash_free (random_hash);
7957 v4_dst_address.as_u32 = random_vector[0];
7962 /* Turn on async mode */
7963 vam->async_mode = 1;
7964 vam->async_errors = 0;
7965 before = vat_time_now (vam);
7968 for (j = 0; j < count; j++)
7970 /* Construct the API message */
7971 M2 (IP_ADD_DEL_ROUTE, mp,
7972 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7974 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7975 mp->table_id = ntohl (vrf_id);
7976 mp->create_vrf_if_needed = create_vrf_if_needed;
7978 mp->is_add = is_add;
7979 mp->is_drop = is_drop;
7980 mp->is_unreach = is_unreach;
7981 mp->is_prohibit = is_prohibit;
7982 mp->is_ipv6 = is_ipv6;
7983 mp->is_local = is_local;
7984 mp->is_classify = is_classify;
7985 mp->is_multipath = is_multipath;
7986 mp->is_resolve_host = resolve_host;
7987 mp->is_resolve_attached = resolve_attached;
7988 mp->next_hop_weight = next_hop_weight;
7989 mp->dst_address_length = dst_address_length;
7990 mp->next_hop_table_id = ntohl (next_hop_table_id);
7991 mp->classify_table_index = ntohl (classify_table_index);
7992 mp->next_hop_via_label = ntohl (next_hop_via_label);
7993 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7994 if (0 != mp->next_hop_n_out_labels)
7996 memcpy (mp->next_hop_out_label_stack,
7997 next_hop_out_label_stack,
7998 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7999 vec_free (next_hop_out_label_stack);
8004 clib_memcpy (mp->dst_address, &v6_dst_address,
8005 sizeof (v6_dst_address));
8007 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8008 sizeof (v6_next_hop_address));
8009 increment_v6_address (&v6_dst_address);
8013 clib_memcpy (mp->dst_address, &v4_dst_address,
8014 sizeof (v4_dst_address));
8016 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8017 sizeof (v4_next_hop_address));
8019 v4_dst_address.as_u32 = random_vector[j + 1];
8021 increment_v4_address (&v4_dst_address);
8025 /* If we receive SIGTERM, stop now... */
8030 /* When testing multiple add/del ops, use a control-ping to sync */
8033 vl_api_control_ping_t *mp_ping;
8037 /* Shut off async mode */
8038 vam->async_mode = 0;
8040 MPING (CONTROL_PING, mp_ping);
8043 timeout = vat_time_now (vam) + 1.0;
8044 while (vat_time_now (vam) < timeout)
8045 if (vam->result_ready == 1)
8050 if (vam->retval == -99)
8053 if (vam->async_errors > 0)
8055 errmsg ("%d asynchronous errors", vam->async_errors);
8058 vam->async_errors = 0;
8059 after = vat_time_now (vam);
8061 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8065 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8066 count, after - before, count / (after - before));
8072 /* Wait for a reply... */
8077 /* Return the good/bad news */
8078 return (vam->retval);
8082 api_ip_mroute_add_del (vat_main_t * vam)
8084 unformat_input_t *i = vam->input;
8085 vl_api_ip_mroute_add_del_t *mp;
8086 u32 sw_if_index = ~0, vrf_id = 0;
8089 u8 create_vrf_if_needed = 0;
8092 u32 grp_address_length = 0;
8093 ip4_address_t v4_grp_address, v4_src_address;
8094 ip6_address_t v6_grp_address, v6_src_address;
8095 mfib_itf_flags_t iflags = 0;
8096 mfib_entry_flags_t eflags = 0;
8099 /* Parse args required to build the message */
8100 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8102 if (unformat (i, "sw_if_index %d", &sw_if_index))
8104 else if (unformat (i, "%U %U",
8105 unformat_ip4_address, &v4_src_address,
8106 unformat_ip4_address, &v4_grp_address))
8108 grp_address_length = 64;
8112 else if (unformat (i, "%U %U",
8113 unformat_ip6_address, &v6_src_address,
8114 unformat_ip6_address, &v6_grp_address))
8116 grp_address_length = 256;
8120 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8122 memset (&v4_src_address, 0, sizeof (v4_src_address));
8123 grp_address_length = 32;
8127 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8129 memset (&v6_src_address, 0, sizeof (v6_src_address));
8130 grp_address_length = 128;
8134 else if (unformat (i, "/%d", &grp_address_length))
8136 else if (unformat (i, "local"))
8140 else if (unformat (i, "del"))
8142 else if (unformat (i, "add"))
8144 else if (unformat (i, "vrf %d", &vrf_id))
8146 else if (unformat (i, "create-vrf"))
8147 create_vrf_if_needed = 1;
8148 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8150 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8154 clib_warning ("parse error '%U'", format_unformat_error, i);
8159 if (address_set == 0)
8161 errmsg ("missing addresses\n");
8165 /* Construct the API message */
8166 M (IP_MROUTE_ADD_DEL, mp);
8168 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8169 mp->table_id = ntohl (vrf_id);
8170 mp->create_vrf_if_needed = create_vrf_if_needed;
8172 mp->is_add = is_add;
8173 mp->is_ipv6 = is_ipv6;
8174 mp->is_local = is_local;
8175 mp->itf_flags = ntohl (iflags);
8176 mp->entry_flags = ntohl (eflags);
8177 mp->grp_address_length = grp_address_length;
8178 mp->grp_address_length = ntohs (mp->grp_address_length);
8182 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8183 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8187 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8188 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8194 /* Wait for a reply... */
8200 api_mpls_table_add_del (vat_main_t * vam)
8202 unformat_input_t *i = vam->input;
8203 vl_api_mpls_table_add_del_t *mp;
8208 /* Parse args required to build the message */
8209 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8211 if (unformat (i, "table %d", &table_id))
8213 else if (unformat (i, "del"))
8215 else if (unformat (i, "add"))
8219 clib_warning ("parse error '%U'", format_unformat_error, i);
8226 errmsg ("missing table-ID");
8230 /* Construct the API message */
8231 M (MPLS_TABLE_ADD_DEL, mp);
8233 mp->mt_table_id = ntohl (table_id);
8234 mp->mt_is_add = is_add;
8239 /* Wait for a reply... */
8246 api_mpls_route_add_del (vat_main_t * vam)
8248 unformat_input_t *i = vam->input;
8249 vl_api_mpls_route_add_del_t *mp;
8250 u32 sw_if_index = ~0, table_id = 0;
8251 u8 create_table_if_needed = 0;
8253 u32 next_hop_weight = 1;
8254 u8 is_multipath = 0;
8255 u32 next_hop_table_id = 0;
8256 u8 next_hop_set = 0;
8257 ip4_address_t v4_next_hop_address = {
8260 ip6_address_t v6_next_hop_address = { {0} };
8264 u32 classify_table_index = ~0;
8266 u8 resolve_host = 0, resolve_attached = 0;
8267 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8268 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8269 mpls_label_t *next_hop_out_label_stack = NULL;
8270 mpls_label_t local_label = MPLS_LABEL_INVALID;
8272 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8274 /* Parse args required to build the message */
8275 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8277 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8279 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8281 else if (unformat (i, "%d", &local_label))
8283 else if (unformat (i, "eos"))
8285 else if (unformat (i, "non-eos"))
8287 else if (unformat (i, "via %U", unformat_ip4_address,
8288 &v4_next_hop_address))
8291 next_hop_proto = DPO_PROTO_IP4;
8293 else if (unformat (i, "via %U", unformat_ip6_address,
8294 &v6_next_hop_address))
8297 next_hop_proto = DPO_PROTO_IP6;
8299 else if (unformat (i, "weight %d", &next_hop_weight))
8301 else if (unformat (i, "create-table"))
8302 create_table_if_needed = 1;
8303 else if (unformat (i, "classify %d", &classify_table_index))
8307 else if (unformat (i, "del"))
8309 else if (unformat (i, "add"))
8311 else if (unformat (i, "resolve-via-host"))
8313 else if (unformat (i, "resolve-via-attached"))
8314 resolve_attached = 1;
8315 else if (unformat (i, "multipath"))
8317 else if (unformat (i, "count %d", &count))
8319 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8322 next_hop_proto = DPO_PROTO_IP4;
8324 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8327 next_hop_proto = DPO_PROTO_IP6;
8329 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8331 else if (unformat (i, "via-label %d", &next_hop_via_label))
8333 else if (unformat (i, "out-label %d", &next_hop_out_label))
8334 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8337 clib_warning ("parse error '%U'", format_unformat_error, i);
8342 if (!next_hop_set && !is_classify)
8344 errmsg ("next hop / classify not set");
8348 if (MPLS_LABEL_INVALID == local_label)
8350 errmsg ("missing label");
8356 /* Turn on async mode */
8357 vam->async_mode = 1;
8358 vam->async_errors = 0;
8359 before = vat_time_now (vam);
8362 for (j = 0; j < count; j++)
8364 /* Construct the API message */
8365 M2 (MPLS_ROUTE_ADD_DEL, mp,
8366 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8368 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8369 mp->mr_table_id = ntohl (table_id);
8370 mp->mr_create_table_if_needed = create_table_if_needed;
8372 mp->mr_is_add = is_add;
8373 mp->mr_next_hop_proto = next_hop_proto;
8374 mp->mr_is_classify = is_classify;
8375 mp->mr_is_multipath = is_multipath;
8376 mp->mr_is_resolve_host = resolve_host;
8377 mp->mr_is_resolve_attached = resolve_attached;
8378 mp->mr_next_hop_weight = next_hop_weight;
8379 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8380 mp->mr_classify_table_index = ntohl (classify_table_index);
8381 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8382 mp->mr_label = ntohl (local_label);
8383 mp->mr_eos = is_eos;
8385 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8386 if (0 != mp->mr_next_hop_n_out_labels)
8388 memcpy (mp->mr_next_hop_out_label_stack,
8389 next_hop_out_label_stack,
8390 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8391 vec_free (next_hop_out_label_stack);
8396 if (DPO_PROTO_IP4 == next_hop_proto)
8398 clib_memcpy (mp->mr_next_hop,
8399 &v4_next_hop_address,
8400 sizeof (v4_next_hop_address));
8402 else if (DPO_PROTO_IP6 == next_hop_proto)
8405 clib_memcpy (mp->mr_next_hop,
8406 &v6_next_hop_address,
8407 sizeof (v6_next_hop_address));
8414 /* If we receive SIGTERM, stop now... */
8419 /* When testing multiple add/del ops, use a control-ping to sync */
8422 vl_api_control_ping_t *mp_ping;
8426 /* Shut off async mode */
8427 vam->async_mode = 0;
8429 MPING (CONTROL_PING, mp_ping);
8432 timeout = vat_time_now (vam) + 1.0;
8433 while (vat_time_now (vam) < timeout)
8434 if (vam->result_ready == 1)
8439 if (vam->retval == -99)
8442 if (vam->async_errors > 0)
8444 errmsg ("%d asynchronous errors", vam->async_errors);
8447 vam->async_errors = 0;
8448 after = vat_time_now (vam);
8450 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8454 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8455 count, after - before, count / (after - before));
8461 /* Wait for a reply... */
8466 /* Return the good/bad news */
8467 return (vam->retval);
8471 api_mpls_ip_bind_unbind (vat_main_t * vam)
8473 unformat_input_t *i = vam->input;
8474 vl_api_mpls_ip_bind_unbind_t *mp;
8475 u32 ip_table_id = 0;
8476 u8 create_table_if_needed = 0;
8479 ip4_address_t v4_address;
8480 ip6_address_t v6_address;
8483 mpls_label_t local_label = MPLS_LABEL_INVALID;
8486 /* Parse args required to build the message */
8487 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8489 if (unformat (i, "%U/%d", unformat_ip4_address,
8490 &v4_address, &address_length))
8495 else if (unformat (i, "%U/%d", unformat_ip6_address,
8496 &v6_address, &address_length))
8501 else if (unformat (i, "%d", &local_label))
8503 else if (unformat (i, "create-table"))
8504 create_table_if_needed = 1;
8505 else if (unformat (i, "table-id %d", &ip_table_id))
8507 else if (unformat (i, "unbind"))
8509 else if (unformat (i, "bind"))
8513 clib_warning ("parse error '%U'", format_unformat_error, i);
8520 errmsg ("IP addres not set");
8524 if (MPLS_LABEL_INVALID == local_label)
8526 errmsg ("missing label");
8530 /* Construct the API message */
8531 M (MPLS_IP_BIND_UNBIND, mp);
8533 mp->mb_create_table_if_needed = create_table_if_needed;
8534 mp->mb_is_bind = is_bind;
8535 mp->mb_is_ip4 = is_ip4;
8536 mp->mb_ip_table_id = ntohl (ip_table_id);
8537 mp->mb_mpls_table_id = 0;
8538 mp->mb_label = ntohl (local_label);
8539 mp->mb_address_length = address_length;
8542 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8544 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8549 /* Wait for a reply... */
8555 api_bier_table_add_del (vat_main_t * vam)
8557 unformat_input_t *i = vam->input;
8558 vl_api_bier_table_add_del_t *mp;
8560 u32 set = 0, sub_domain = 0, hdr_len = 3;
8561 mpls_label_t local_label = MPLS_LABEL_INVALID;
8564 /* Parse args required to build the message */
8565 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8567 if (unformat (i, "sub-domain %d", &sub_domain))
8569 else if (unformat (i, "set %d", &set))
8571 else if (unformat (i, "label %d", &local_label))
8573 else if (unformat (i, "hdr-len %d", &hdr_len))
8575 else if (unformat (i, "add"))
8577 else if (unformat (i, "del"))
8581 clib_warning ("parse error '%U'", format_unformat_error, i);
8586 if (MPLS_LABEL_INVALID == local_label)
8588 errmsg ("missing label\n");
8592 /* Construct the API message */
8593 M (BIER_TABLE_ADD_DEL, mp);
8595 mp->bt_is_add = is_add;
8596 mp->bt_label = ntohl (local_label);
8597 mp->bt_tbl_id.bt_set = set;
8598 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8599 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8604 /* Wait for a reply... */
8611 api_bier_route_add_del (vat_main_t * vam)
8613 unformat_input_t *i = vam->input;
8614 vl_api_bier_route_add_del_t *mp;
8616 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8617 ip4_address_t v4_next_hop_address;
8618 ip6_address_t v6_next_hop_address;
8619 u8 next_hop_set = 0;
8620 u8 next_hop_proto_is_ip4 = 1;
8621 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8624 /* Parse args required to build the message */
8625 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8627 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8629 next_hop_proto_is_ip4 = 1;
8632 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8634 next_hop_proto_is_ip4 = 0;
8637 if (unformat (i, "sub-domain %d", &sub_domain))
8639 else if (unformat (i, "set %d", &set))
8641 else if (unformat (i, "hdr-len %d", &hdr_len))
8643 else if (unformat (i, "bp %d", &bp))
8645 else if (unformat (i, "add"))
8647 else if (unformat (i, "del"))
8649 else if (unformat (i, "out-label %d", &next_hop_out_label))
8653 clib_warning ("parse error '%U'", format_unformat_error, i);
8658 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8660 errmsg ("next hop / label set\n");
8665 errmsg ("bit=position not set\n");
8669 /* Construct the API message */
8670 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path3_t));
8672 mp->br_is_add = is_add;
8673 mp->br_tbl_id.bt_set = set;
8674 mp->br_tbl_id.bt_sub_domain = sub_domain;
8675 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
8676 mp->br_bp = ntohs (bp);
8678 mp->br_paths[0].n_labels = 1;
8679 mp->br_paths[0].label_stack[0] = ntohl (next_hop_out_label);
8680 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
8682 if (next_hop_proto_is_ip4)
8684 clib_memcpy (mp->br_paths[0].next_hop,
8685 &v4_next_hop_address, sizeof (v4_next_hop_address));
8689 clib_memcpy (mp->br_paths[0].next_hop,
8690 &v6_next_hop_address, sizeof (v6_next_hop_address));
8696 /* Wait for a reply... */
8703 api_proxy_arp_add_del (vat_main_t * vam)
8705 unformat_input_t *i = vam->input;
8706 vl_api_proxy_arp_add_del_t *mp;
8709 ip4_address_t lo, hi;
8713 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8715 if (unformat (i, "vrf %d", &vrf_id))
8717 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
8718 unformat_ip4_address, &hi))
8720 else if (unformat (i, "del"))
8724 clib_warning ("parse error '%U'", format_unformat_error, i);
8731 errmsg ("address range not set");
8735 M (PROXY_ARP_ADD_DEL, mp);
8737 mp->vrf_id = ntohl (vrf_id);
8738 mp->is_add = is_add;
8739 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
8740 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
8748 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8750 unformat_input_t *i = vam->input;
8751 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8754 u8 sw_if_index_set = 0;
8757 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8759 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8760 sw_if_index_set = 1;
8761 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8762 sw_if_index_set = 1;
8763 else if (unformat (i, "enable"))
8765 else if (unformat (i, "disable"))
8769 clib_warning ("parse error '%U'", format_unformat_error, i);
8774 if (sw_if_index_set == 0)
8776 errmsg ("missing interface name or sw_if_index");
8780 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8782 mp->sw_if_index = ntohl (sw_if_index);
8783 mp->enable_disable = enable;
8791 api_mpls_tunnel_add_del (vat_main_t * vam)
8793 unformat_input_t *i = vam->input;
8794 vl_api_mpls_tunnel_add_del_t *mp;
8798 u32 sw_if_index = ~0;
8799 u32 next_hop_sw_if_index = ~0;
8800 u32 next_hop_proto_is_ip4 = 1;
8802 u32 next_hop_table_id = 0;
8803 ip4_address_t v4_next_hop_address = {
8806 ip6_address_t v6_next_hop_address = { {0} };
8807 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
8810 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8812 if (unformat (i, "add"))
8814 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8816 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
8818 else if (unformat (i, "via %U",
8819 unformat_ip4_address, &v4_next_hop_address))
8821 next_hop_proto_is_ip4 = 1;
8823 else if (unformat (i, "via %U",
8824 unformat_ip6_address, &v6_next_hop_address))
8826 next_hop_proto_is_ip4 = 0;
8828 else if (unformat (i, "l2-only"))
8830 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8832 else if (unformat (i, "out-label %d", &next_hop_out_label))
8833 vec_add1 (labels, ntohl (next_hop_out_label));
8836 clib_warning ("parse error '%U'", format_unformat_error, i);
8841 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
8843 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
8844 mp->mt_sw_if_index = ntohl (sw_if_index);
8845 mp->mt_is_add = is_add;
8846 mp->mt_l2_only = l2_only;
8847 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
8848 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
8850 mp->mt_next_hop_n_out_labels = vec_len (labels);
8852 if (0 != mp->mt_next_hop_n_out_labels)
8854 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
8855 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
8859 if (next_hop_proto_is_ip4)
8861 clib_memcpy (mp->mt_next_hop,
8862 &v4_next_hop_address, sizeof (v4_next_hop_address));
8866 clib_memcpy (mp->mt_next_hop,
8867 &v6_next_hop_address, sizeof (v6_next_hop_address));
8876 api_sw_interface_set_unnumbered (vat_main_t * vam)
8878 unformat_input_t *i = vam->input;
8879 vl_api_sw_interface_set_unnumbered_t *mp;
8881 u32 unnum_sw_index = ~0;
8883 u8 sw_if_index_set = 0;
8886 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8888 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8889 sw_if_index_set = 1;
8890 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8891 sw_if_index_set = 1;
8892 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8894 else if (unformat (i, "del"))
8898 clib_warning ("parse error '%U'", format_unformat_error, i);
8903 if (sw_if_index_set == 0)
8905 errmsg ("missing interface name or sw_if_index");
8909 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8911 mp->sw_if_index = ntohl (sw_if_index);
8912 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8913 mp->is_add = is_add;
8921 api_ip_neighbor_add_del (vat_main_t * vam)
8923 unformat_input_t *i = vam->input;
8924 vl_api_ip_neighbor_add_del_t *mp;
8926 u8 sw_if_index_set = 0;
8929 u8 is_no_fib_entry = 0;
8932 u8 v4_address_set = 0;
8933 u8 v6_address_set = 0;
8934 ip4_address_t v4address;
8935 ip6_address_t v6address;
8938 memset (mac_address, 0, sizeof (mac_address));
8940 /* Parse args required to build the message */
8941 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8943 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8947 else if (unformat (i, "del"))
8950 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8951 sw_if_index_set = 1;
8952 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8953 sw_if_index_set = 1;
8954 else if (unformat (i, "is_static"))
8956 else if (unformat (i, "no-fib-entry"))
8957 is_no_fib_entry = 1;
8958 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
8960 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
8964 clib_warning ("parse error '%U'", format_unformat_error, i);
8969 if (sw_if_index_set == 0)
8971 errmsg ("missing interface name or sw_if_index");
8974 if (v4_address_set && v6_address_set)
8976 errmsg ("both v4 and v6 addresses set");
8979 if (!v4_address_set && !v6_address_set)
8981 errmsg ("no address set");
8985 /* Construct the API message */
8986 M (IP_NEIGHBOR_ADD_DEL, mp);
8988 mp->sw_if_index = ntohl (sw_if_index);
8989 mp->is_add = is_add;
8990 mp->is_static = is_static;
8991 mp->is_no_adj_fib = is_no_fib_entry;
8993 clib_memcpy (mp->mac_address, mac_address, 6);
8997 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9001 /* mp->is_ipv6 = 0; via memset in M macro above */
9002 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9008 /* Wait for a reply, return good/bad news */
9014 api_create_vlan_subif (vat_main_t * vam)
9016 unformat_input_t *i = vam->input;
9017 vl_api_create_vlan_subif_t *mp;
9019 u8 sw_if_index_set = 0;
9024 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9026 if (unformat (i, "sw_if_index %d", &sw_if_index))
9027 sw_if_index_set = 1;
9029 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9030 sw_if_index_set = 1;
9031 else if (unformat (i, "vlan %d", &vlan_id))
9035 clib_warning ("parse error '%U'", format_unformat_error, i);
9040 if (sw_if_index_set == 0)
9042 errmsg ("missing interface name or sw_if_index");
9046 if (vlan_id_set == 0)
9048 errmsg ("missing vlan_id");
9051 M (CREATE_VLAN_SUBIF, mp);
9053 mp->sw_if_index = ntohl (sw_if_index);
9054 mp->vlan_id = ntohl (vlan_id);
9061 #define foreach_create_subif_bit \
9068 _(outer_vlan_id_any) \
9069 _(inner_vlan_id_any)
9072 api_create_subif (vat_main_t * vam)
9074 unformat_input_t *i = vam->input;
9075 vl_api_create_subif_t *mp;
9077 u8 sw_if_index_set = 0;
9084 u32 exact_match = 0;
9085 u32 default_sub = 0;
9086 u32 outer_vlan_id_any = 0;
9087 u32 inner_vlan_id_any = 0;
9089 u16 outer_vlan_id = 0;
9090 u16 inner_vlan_id = 0;
9093 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9095 if (unformat (i, "sw_if_index %d", &sw_if_index))
9096 sw_if_index_set = 1;
9098 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9099 sw_if_index_set = 1;
9100 else if (unformat (i, "sub_id %d", &sub_id))
9102 else if (unformat (i, "outer_vlan_id %d", &tmp))
9103 outer_vlan_id = tmp;
9104 else if (unformat (i, "inner_vlan_id %d", &tmp))
9105 inner_vlan_id = tmp;
9107 #define _(a) else if (unformat (i, #a)) a = 1 ;
9108 foreach_create_subif_bit
9112 clib_warning ("parse error '%U'", format_unformat_error, i);
9117 if (sw_if_index_set == 0)
9119 errmsg ("missing interface name or sw_if_index");
9123 if (sub_id_set == 0)
9125 errmsg ("missing sub_id");
9128 M (CREATE_SUBIF, mp);
9130 mp->sw_if_index = ntohl (sw_if_index);
9131 mp->sub_id = ntohl (sub_id);
9133 #define _(a) mp->a = a;
9134 foreach_create_subif_bit;
9137 mp->outer_vlan_id = ntohs (outer_vlan_id);
9138 mp->inner_vlan_id = ntohs (inner_vlan_id);
9146 api_oam_add_del (vat_main_t * vam)
9148 unformat_input_t *i = vam->input;
9149 vl_api_oam_add_del_t *mp;
9152 ip4_address_t src, dst;
9157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9159 if (unformat (i, "vrf %d", &vrf_id))
9161 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9163 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9165 else if (unformat (i, "del"))
9169 clib_warning ("parse error '%U'", format_unformat_error, i);
9176 errmsg ("missing src addr");
9182 errmsg ("missing dst addr");
9186 M (OAM_ADD_DEL, mp);
9188 mp->vrf_id = ntohl (vrf_id);
9189 mp->is_add = is_add;
9190 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9191 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9199 api_reset_fib (vat_main_t * vam)
9201 unformat_input_t *i = vam->input;
9202 vl_api_reset_fib_t *mp;
9208 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9210 if (unformat (i, "vrf %d", &vrf_id))
9212 else if (unformat (i, "ipv6"))
9216 clib_warning ("parse error '%U'", format_unformat_error, i);
9221 if (vrf_id_set == 0)
9223 errmsg ("missing vrf id");
9229 mp->vrf_id = ntohl (vrf_id);
9230 mp->is_ipv6 = is_ipv6;
9238 api_dhcp_proxy_config (vat_main_t * vam)
9240 unformat_input_t *i = vam->input;
9241 vl_api_dhcp_proxy_config_t *mp;
9243 u32 server_vrf_id = 0;
9245 u8 v4_address_set = 0;
9246 u8 v6_address_set = 0;
9247 ip4_address_t v4address;
9248 ip6_address_t v6address;
9249 u8 v4_src_address_set = 0;
9250 u8 v6_src_address_set = 0;
9251 ip4_address_t v4srcaddress;
9252 ip6_address_t v6srcaddress;
9255 /* Parse args required to build the message */
9256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9258 if (unformat (i, "del"))
9260 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9262 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9264 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9266 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9268 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9269 v4_src_address_set = 1;
9270 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9271 v6_src_address_set = 1;
9276 if (v4_address_set && v6_address_set)
9278 errmsg ("both v4 and v6 server addresses set");
9281 if (!v4_address_set && !v6_address_set)
9283 errmsg ("no server addresses set");
9287 if (v4_src_address_set && v6_src_address_set)
9289 errmsg ("both v4 and v6 src addresses set");
9292 if (!v4_src_address_set && !v6_src_address_set)
9294 errmsg ("no src addresses set");
9298 if (!(v4_src_address_set && v4_address_set) &&
9299 !(v6_src_address_set && v6_address_set))
9301 errmsg ("no matching server and src addresses set");
9305 /* Construct the API message */
9306 M (DHCP_PROXY_CONFIG, mp);
9308 mp->is_add = is_add;
9309 mp->rx_vrf_id = ntohl (rx_vrf_id);
9310 mp->server_vrf_id = ntohl (server_vrf_id);
9314 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9315 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9319 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9320 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9326 /* Wait for a reply, return good/bad news */
9331 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9332 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9335 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9337 vat_main_t *vam = &vat_main;
9338 u32 i, count = mp->count;
9339 vl_api_dhcp_server_t *s;
9343 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9344 "VSS VPN-ID '%s', VSS FIB-ID %d, VSS OUI %d",
9345 ntohl (mp->rx_vrf_id),
9346 format_ip6_address, mp->dhcp_src_address,
9347 mp->vss_type, mp->vss_vpn_ascii_id,
9348 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9351 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9352 "VSS VPN-ID '%s', VSS FIB-ID %d, VSS OUI %d",
9353 ntohl (mp->rx_vrf_id),
9354 format_ip4_address, mp->dhcp_src_address,
9355 mp->vss_type, mp->vss_vpn_ascii_id,
9356 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9358 for (i = 0; i < count; i++)
9360 s = &mp->servers[i];
9364 " Server Table-ID %d, Server Address %U",
9365 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9368 " Server Table-ID %d, Server Address %U",
9369 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9373 static void vl_api_dhcp_proxy_details_t_handler_json
9374 (vl_api_dhcp_proxy_details_t * mp)
9376 vat_main_t *vam = &vat_main;
9377 vat_json_node_t *node = NULL;
9378 u32 i, count = mp->count;
9380 struct in6_addr ip6;
9381 vl_api_dhcp_server_t *s;
9383 if (VAT_JSON_ARRAY != vam->json_tree.type)
9385 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9386 vat_json_init_array (&vam->json_tree);
9388 node = vat_json_array_add (&vam->json_tree);
9390 vat_json_init_object (node);
9391 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9392 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9393 sizeof (mp->vss_type));
9394 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9395 mp->vss_vpn_ascii_id);
9396 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9397 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9401 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9402 vat_json_object_add_ip6 (node, "src_address", ip6);
9406 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9407 vat_json_object_add_ip4 (node, "src_address", ip4);
9410 for (i = 0; i < count; i++)
9412 s = &mp->servers[i];
9414 vat_json_object_add_uint (node, "server-table-id",
9415 ntohl (s->server_vrf_id));
9419 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9420 vat_json_object_add_ip4 (node, "src_address", ip4);
9424 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9425 vat_json_object_add_ip6 (node, "server_address", ip6);
9431 api_dhcp_proxy_dump (vat_main_t * vam)
9433 unformat_input_t *i = vam->input;
9434 vl_api_control_ping_t *mp_ping;
9435 vl_api_dhcp_proxy_dump_t *mp;
9439 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9441 if (unformat (i, "ipv6"))
9445 clib_warning ("parse error '%U'", format_unformat_error, i);
9450 M (DHCP_PROXY_DUMP, mp);
9452 mp->is_ip6 = is_ipv6;
9455 /* Use a control ping for synchronization */
9456 MPING (CONTROL_PING, mp_ping);
9464 api_dhcp_proxy_set_vss (vat_main_t * vam)
9466 unformat_input_t *i = vam->input;
9467 vl_api_dhcp_proxy_set_vss_t *mp;
9471 u8 vss_type = VSS_TYPE_DEFAULT;
9472 u8 *vpn_ascii_id = 0;
9477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9479 if (unformat (i, "tbl_id %d", &tbl_id))
9481 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
9482 vss_type = VSS_TYPE_ASCII;
9483 else if (unformat (i, "fib_id %d", &fib_id))
9484 vss_type = VSS_TYPE_VPN_ID;
9485 else if (unformat (i, "oui %d", &oui))
9486 vss_type = VSS_TYPE_VPN_ID;
9487 else if (unformat (i, "ipv6"))
9489 else if (unformat (i, "del"))
9497 errmsg ("missing tbl_id ");
9498 vec_free (vpn_ascii_id);
9502 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
9504 errmsg ("vpn_ascii_id cannot be longer than 128 ");
9505 vec_free (vpn_ascii_id);
9509 M (DHCP_PROXY_SET_VSS, mp);
9510 mp->tbl_id = ntohl (tbl_id);
9511 mp->vss_type = vss_type;
9514 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
9515 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
9517 mp->vpn_index = ntohl (fib_id);
9518 mp->oui = ntohl (oui);
9519 mp->is_ipv6 = is_ipv6;
9520 mp->is_add = is_add;
9525 vec_free (vpn_ascii_id);
9530 api_dhcp_client_config (vat_main_t * vam)
9532 unformat_input_t *i = vam->input;
9533 vl_api_dhcp_client_config_t *mp;
9535 u8 sw_if_index_set = 0;
9538 u8 disable_event = 0;
9541 /* Parse args required to build the message */
9542 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9544 if (unformat (i, "del"))
9547 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9548 sw_if_index_set = 1;
9549 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9550 sw_if_index_set = 1;
9551 else if (unformat (i, "hostname %s", &hostname))
9553 else if (unformat (i, "disable_event"))
9559 if (sw_if_index_set == 0)
9561 errmsg ("missing interface name or sw_if_index");
9565 if (vec_len (hostname) > 63)
9567 errmsg ("hostname too long");
9569 vec_add1 (hostname, 0);
9571 /* Construct the API message */
9572 M (DHCP_CLIENT_CONFIG, mp);
9574 mp->sw_if_index = htonl (sw_if_index);
9575 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
9576 vec_free (hostname);
9577 mp->is_add = is_add;
9578 mp->want_dhcp_event = disable_event ? 0 : 1;
9579 mp->pid = htonl (getpid ());
9584 /* Wait for a reply, return good/bad news */
9590 api_set_ip_flow_hash (vat_main_t * vam)
9592 unformat_input_t *i = vam->input;
9593 vl_api_set_ip_flow_hash_t *mp;
9605 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9607 if (unformat (i, "vrf %d", &vrf_id))
9609 else if (unformat (i, "ipv6"))
9611 else if (unformat (i, "src"))
9613 else if (unformat (i, "dst"))
9615 else if (unformat (i, "sport"))
9617 else if (unformat (i, "dport"))
9619 else if (unformat (i, "proto"))
9621 else if (unformat (i, "reverse"))
9626 clib_warning ("parse error '%U'", format_unformat_error, i);
9631 if (vrf_id_set == 0)
9633 errmsg ("missing vrf id");
9637 M (SET_IP_FLOW_HASH, mp);
9643 mp->reverse = reverse;
9644 mp->vrf_id = ntohl (vrf_id);
9645 mp->is_ipv6 = is_ipv6;
9653 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9655 unformat_input_t *i = vam->input;
9656 vl_api_sw_interface_ip6_enable_disable_t *mp;
9658 u8 sw_if_index_set = 0;
9662 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9664 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9665 sw_if_index_set = 1;
9666 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9667 sw_if_index_set = 1;
9668 else if (unformat (i, "enable"))
9670 else if (unformat (i, "disable"))
9674 clib_warning ("parse error '%U'", format_unformat_error, i);
9679 if (sw_if_index_set == 0)
9681 errmsg ("missing interface name or sw_if_index");
9685 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9687 mp->sw_if_index = ntohl (sw_if_index);
9688 mp->enable = enable;
9696 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
9698 unformat_input_t *i = vam->input;
9699 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
9701 u8 sw_if_index_set = 0;
9702 u8 v6_address_set = 0;
9703 ip6_address_t v6address;
9706 /* Parse args required to build the message */
9707 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9709 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9710 sw_if_index_set = 1;
9711 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9712 sw_if_index_set = 1;
9713 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9719 if (sw_if_index_set == 0)
9721 errmsg ("missing interface name or sw_if_index");
9724 if (!v6_address_set)
9726 errmsg ("no address set");
9730 /* Construct the API message */
9731 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
9733 mp->sw_if_index = ntohl (sw_if_index);
9734 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9739 /* Wait for a reply, return good/bad news */
9745 api_ip6nd_proxy_add_del (vat_main_t * vam)
9747 unformat_input_t *i = vam->input;
9748 vl_api_ip6nd_proxy_add_del_t *mp;
9749 u32 sw_if_index = ~0;
9750 u8 v6_address_set = 0;
9751 ip6_address_t v6address;
9755 /* Parse args required to build the message */
9756 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9758 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9760 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9762 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9764 if (unformat (i, "del"))
9768 clib_warning ("parse error '%U'", format_unformat_error, i);
9773 if (sw_if_index == ~0)
9775 errmsg ("missing interface name or sw_if_index");
9778 if (!v6_address_set)
9780 errmsg ("no address set");
9784 /* Construct the API message */
9785 M (IP6ND_PROXY_ADD_DEL, mp);
9787 mp->is_del = is_del;
9788 mp->sw_if_index = ntohl (sw_if_index);
9789 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9794 /* Wait for a reply, return good/bad news */
9800 api_ip6nd_proxy_dump (vat_main_t * vam)
9802 vl_api_ip6nd_proxy_dump_t *mp;
9803 vl_api_control_ping_t *mp_ping;
9806 M (IP6ND_PROXY_DUMP, mp);
9810 /* Use a control ping for synchronization */
9811 MPING (CONTROL_PING, mp_ping);
9818 static void vl_api_ip6nd_proxy_details_t_handler
9819 (vl_api_ip6nd_proxy_details_t * mp)
9821 vat_main_t *vam = &vat_main;
9823 print (vam->ofp, "host %U sw_if_index %d",
9824 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
9827 static void vl_api_ip6nd_proxy_details_t_handler_json
9828 (vl_api_ip6nd_proxy_details_t * mp)
9830 vat_main_t *vam = &vat_main;
9831 struct in6_addr ip6;
9832 vat_json_node_t *node = NULL;
9834 if (VAT_JSON_ARRAY != vam->json_tree.type)
9836 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9837 vat_json_init_array (&vam->json_tree);
9839 node = vat_json_array_add (&vam->json_tree);
9841 vat_json_init_object (node);
9842 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9844 clib_memcpy (&ip6, mp->address, sizeof (ip6));
9845 vat_json_object_add_ip6 (node, "host", ip6);
9849 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9851 unformat_input_t *i = vam->input;
9852 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9854 u8 sw_if_index_set = 0;
9855 u32 address_length = 0;
9856 u8 v6_address_set = 0;
9857 ip6_address_t v6address;
9859 u8 no_advertise = 0;
9861 u8 no_autoconfig = 0;
9864 u32 val_lifetime = 0;
9865 u32 pref_lifetime = 0;
9868 /* Parse args required to build the message */
9869 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9871 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9872 sw_if_index_set = 1;
9873 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9874 sw_if_index_set = 1;
9875 else if (unformat (i, "%U/%d",
9876 unformat_ip6_address, &v6address, &address_length))
9878 else if (unformat (i, "val_life %d", &val_lifetime))
9880 else if (unformat (i, "pref_life %d", &pref_lifetime))
9882 else if (unformat (i, "def"))
9884 else if (unformat (i, "noadv"))
9886 else if (unformat (i, "offl"))
9888 else if (unformat (i, "noauto"))
9890 else if (unformat (i, "nolink"))
9892 else if (unformat (i, "isno"))
9896 clib_warning ("parse error '%U'", format_unformat_error, i);
9901 if (sw_if_index_set == 0)
9903 errmsg ("missing interface name or sw_if_index");
9906 if (!v6_address_set)
9908 errmsg ("no address set");
9912 /* Construct the API message */
9913 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9915 mp->sw_if_index = ntohl (sw_if_index);
9916 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9917 mp->address_length = address_length;
9918 mp->use_default = use_default;
9919 mp->no_advertise = no_advertise;
9920 mp->off_link = off_link;
9921 mp->no_autoconfig = no_autoconfig;
9922 mp->no_onlink = no_onlink;
9924 mp->val_lifetime = ntohl (val_lifetime);
9925 mp->pref_lifetime = ntohl (pref_lifetime);
9930 /* Wait for a reply, return good/bad news */
9936 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9938 unformat_input_t *i = vam->input;
9939 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9941 u8 sw_if_index_set = 0;
9946 u8 send_unicast = 0;
9949 u8 default_router = 0;
9950 u32 max_interval = 0;
9951 u32 min_interval = 0;
9953 u32 initial_count = 0;
9954 u32 initial_interval = 0;
9958 /* Parse args required to build the message */
9959 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9961 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9962 sw_if_index_set = 1;
9963 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9964 sw_if_index_set = 1;
9965 else if (unformat (i, "maxint %d", &max_interval))
9967 else if (unformat (i, "minint %d", &min_interval))
9969 else if (unformat (i, "life %d", &lifetime))
9971 else if (unformat (i, "count %d", &initial_count))
9973 else if (unformat (i, "interval %d", &initial_interval))
9975 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9977 else if (unformat (i, "managed"))
9979 else if (unformat (i, "other"))
9981 else if (unformat (i, "ll"))
9983 else if (unformat (i, "send"))
9985 else if (unformat (i, "cease"))
9987 else if (unformat (i, "isno"))
9989 else if (unformat (i, "def"))
9993 clib_warning ("parse error '%U'", format_unformat_error, i);
9998 if (sw_if_index_set == 0)
10000 errmsg ("missing interface name or sw_if_index");
10004 /* Construct the API message */
10005 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10007 mp->sw_if_index = ntohl (sw_if_index);
10008 mp->max_interval = ntohl (max_interval);
10009 mp->min_interval = ntohl (min_interval);
10010 mp->lifetime = ntohl (lifetime);
10011 mp->initial_count = ntohl (initial_count);
10012 mp->initial_interval = ntohl (initial_interval);
10013 mp->suppress = suppress;
10014 mp->managed = managed;
10016 mp->ll_option = ll_option;
10017 mp->send_unicast = send_unicast;
10020 mp->default_router = default_router;
10025 /* Wait for a reply, return good/bad news */
10031 api_set_arp_neighbor_limit (vat_main_t * vam)
10033 unformat_input_t *i = vam->input;
10034 vl_api_set_arp_neighbor_limit_t *mp;
10040 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10042 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10044 else if (unformat (i, "ipv6"))
10048 clib_warning ("parse error '%U'", format_unformat_error, i);
10053 if (limit_set == 0)
10055 errmsg ("missing limit value");
10059 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10061 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10062 mp->is_ipv6 = is_ipv6;
10070 api_l2_patch_add_del (vat_main_t * vam)
10072 unformat_input_t *i = vam->input;
10073 vl_api_l2_patch_add_del_t *mp;
10074 u32 rx_sw_if_index;
10075 u8 rx_sw_if_index_set = 0;
10076 u32 tx_sw_if_index;
10077 u8 tx_sw_if_index_set = 0;
10081 /* Parse args required to build the message */
10082 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10084 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10085 rx_sw_if_index_set = 1;
10086 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10087 tx_sw_if_index_set = 1;
10088 else if (unformat (i, "rx"))
10090 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10092 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10094 rx_sw_if_index_set = 1;
10099 else if (unformat (i, "tx"))
10101 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10103 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10105 tx_sw_if_index_set = 1;
10110 else if (unformat (i, "del"))
10116 if (rx_sw_if_index_set == 0)
10118 errmsg ("missing rx interface name or rx_sw_if_index");
10122 if (tx_sw_if_index_set == 0)
10124 errmsg ("missing tx interface name or tx_sw_if_index");
10128 M (L2_PATCH_ADD_DEL, mp);
10130 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10131 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10132 mp->is_add = is_add;
10140 u8 localsid_addr[16];
10149 api_sr_localsid_add_del (vat_main_t * vam)
10151 unformat_input_t *i = vam->input;
10152 vl_api_sr_localsid_add_del_t *mp;
10155 ip6_address_t localsid;
10159 u32 fib_table = ~(u32) 0;
10160 ip6_address_t next_hop;
10162 bool nexthop_set = 0;
10166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10168 if (unformat (i, "del"))
10170 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10171 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
10173 else if (unformat (i, "behavior %u", &behavior));
10174 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10175 else if (unformat (i, "fib-table %u", &fib_table));
10176 else if (unformat (i, "end.psp %u", &behavior));
10181 M (SR_LOCALSID_ADD_DEL, mp);
10183 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
10185 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
10186 mp->behavior = behavior;
10187 mp->sw_if_index = ntohl (sw_if_index);
10188 mp->fib_table = ntohl (fib_table);
10189 mp->end_psp = end_psp;
10190 mp->is_del = is_del;
10198 api_ioam_enable (vat_main_t * vam)
10200 unformat_input_t *input = vam->input;
10201 vl_api_ioam_enable_t *mp;
10203 int has_trace_option = 0;
10204 int has_pot_option = 0;
10205 int has_seqno_option = 0;
10206 int has_analyse_option = 0;
10209 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10211 if (unformat (input, "trace"))
10212 has_trace_option = 1;
10213 else if (unformat (input, "pot"))
10214 has_pot_option = 1;
10215 else if (unformat (input, "seqno"))
10216 has_seqno_option = 1;
10217 else if (unformat (input, "analyse"))
10218 has_analyse_option = 1;
10222 M (IOAM_ENABLE, mp);
10223 mp->id = htons (id);
10224 mp->seqno = has_seqno_option;
10225 mp->analyse = has_analyse_option;
10226 mp->pot_enable = has_pot_option;
10227 mp->trace_enable = has_trace_option;
10236 api_ioam_disable (vat_main_t * vam)
10238 vl_api_ioam_disable_t *mp;
10241 M (IOAM_DISABLE, mp);
10247 #define foreach_tcp_proto_field \
10251 #define foreach_udp_proto_field \
10255 #define foreach_ip4_proto_field \
10267 u16 src_port, dst_port;
10270 #if VPP_API_TEST_BUILTIN == 0
10272 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10274 u8 **maskp = va_arg (*args, u8 **);
10276 u8 found_something = 0;
10279 #define _(a) u8 a=0;
10280 foreach_tcp_proto_field;
10283 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10286 #define _(a) else if (unformat (input, #a)) a=1;
10287 foreach_tcp_proto_field
10293 #define _(a) found_something += a;
10294 foreach_tcp_proto_field;
10297 if (found_something == 0)
10300 vec_validate (mask, sizeof (*tcp) - 1);
10302 tcp = (tcp_header_t *) mask;
10304 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
10305 foreach_tcp_proto_field;
10313 unformat_udp_mask (unformat_input_t * input, va_list * args)
10315 u8 **maskp = va_arg (*args, u8 **);
10317 u8 found_something = 0;
10320 #define _(a) u8 a=0;
10321 foreach_udp_proto_field;
10324 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10327 #define _(a) else if (unformat (input, #a)) a=1;
10328 foreach_udp_proto_field
10334 #define _(a) found_something += a;
10335 foreach_udp_proto_field;
10338 if (found_something == 0)
10341 vec_validate (mask, sizeof (*udp) - 1);
10343 udp = (udp_header_t *) mask;
10345 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
10346 foreach_udp_proto_field;
10354 unformat_l4_mask (unformat_input_t * input, va_list * args)
10356 u8 **maskp = va_arg (*args, u8 **);
10357 u16 src_port = 0, dst_port = 0;
10358 tcpudp_header_t *tcpudp;
10360 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10362 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10364 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10366 else if (unformat (input, "src_port"))
10368 else if (unformat (input, "dst_port"))
10374 if (!src_port && !dst_port)
10378 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10380 tcpudp = (tcpudp_header_t *) mask;
10381 tcpudp->src_port = src_port;
10382 tcpudp->dst_port = dst_port;
10390 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10392 u8 **maskp = va_arg (*args, u8 **);
10394 u8 found_something = 0;
10397 #define _(a) u8 a=0;
10398 foreach_ip4_proto_field;
10404 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10406 if (unformat (input, "version"))
10408 else if (unformat (input, "hdr_length"))
10410 else if (unformat (input, "src"))
10412 else if (unformat (input, "dst"))
10414 else if (unformat (input, "proto"))
10417 #define _(a) else if (unformat (input, #a)) a=1;
10418 foreach_ip4_proto_field
10424 #define _(a) found_something += a;
10425 foreach_ip4_proto_field;
10428 if (found_something == 0)
10431 vec_validate (mask, sizeof (*ip) - 1);
10433 ip = (ip4_header_t *) mask;
10435 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10436 foreach_ip4_proto_field;
10439 ip->ip_version_and_header_length = 0;
10442 ip->ip_version_and_header_length |= 0xF0;
10445 ip->ip_version_and_header_length |= 0x0F;
10451 #define foreach_ip6_proto_field \
10454 _(payload_length) \
10459 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10461 u8 **maskp = va_arg (*args, u8 **);
10463 u8 found_something = 0;
10465 u32 ip_version_traffic_class_and_flow_label;
10467 #define _(a) u8 a=0;
10468 foreach_ip6_proto_field;
10471 u8 traffic_class = 0;
10474 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10476 if (unformat (input, "version"))
10478 else if (unformat (input, "traffic-class"))
10480 else if (unformat (input, "flow-label"))
10482 else if (unformat (input, "src"))
10484 else if (unformat (input, "dst"))
10486 else if (unformat (input, "proto"))
10489 #define _(a) else if (unformat (input, #a)) a=1;
10490 foreach_ip6_proto_field
10496 #define _(a) found_something += a;
10497 foreach_ip6_proto_field;
10500 if (found_something == 0)
10503 vec_validate (mask, sizeof (*ip) - 1);
10505 ip = (ip6_header_t *) mask;
10507 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10508 foreach_ip6_proto_field;
10511 ip_version_traffic_class_and_flow_label = 0;
10514 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10517 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10520 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10522 ip->ip_version_traffic_class_and_flow_label =
10523 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10530 unformat_l3_mask (unformat_input_t * input, va_list * args)
10532 u8 **maskp = va_arg (*args, u8 **);
10534 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10536 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10538 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10547 unformat_l2_mask (unformat_input_t * input, va_list * args)
10549 u8 **maskp = va_arg (*args, u8 **);
10556 u8 ignore_tag1 = 0;
10557 u8 ignore_tag2 = 0;
10564 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10566 if (unformat (input, "src"))
10568 else if (unformat (input, "dst"))
10570 else if (unformat (input, "proto"))
10572 else if (unformat (input, "tag1"))
10574 else if (unformat (input, "tag2"))
10576 else if (unformat (input, "ignore-tag1"))
10578 else if (unformat (input, "ignore-tag2"))
10580 else if (unformat (input, "cos1"))
10582 else if (unformat (input, "cos2"))
10584 else if (unformat (input, "dot1q"))
10586 else if (unformat (input, "dot1ad"))
10591 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10592 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10595 if (tag1 || ignore_tag1 || cos1 || dot1q)
10597 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10600 vec_validate (mask, len - 1);
10603 memset (mask, 0xff, 6);
10606 memset (mask + 6, 0xff, 6);
10608 if (tag2 || dot1ad)
10610 /* inner vlan tag */
10619 mask[21] = mask[20] = 0xff;
10640 mask[16] = mask[17] = 0xff;
10650 mask[12] = mask[13] = 0xff;
10657 unformat_classify_mask (unformat_input_t * input, va_list * args)
10659 u8 **maskp = va_arg (*args, u8 **);
10660 u32 *skipp = va_arg (*args, u32 *);
10661 u32 *matchp = va_arg (*args, u32 *);
10669 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10671 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10673 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10675 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10677 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10691 if (mask || l2 || l3 || l4)
10693 if (l2 || l3 || l4)
10695 /* "With a free Ethernet header in every package" */
10697 vec_validate (l2, 13);
10701 vec_append (mask, l3);
10706 vec_append (mask, l4);
10711 /* Scan forward looking for the first significant mask octet */
10712 for (i = 0; i < vec_len (mask); i++)
10716 /* compute (skip, match) params */
10717 *skipp = i / sizeof (u32x4);
10718 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10720 /* Pad mask to an even multiple of the vector size */
10721 while (vec_len (mask) % sizeof (u32x4))
10722 vec_add1 (mask, 0);
10724 match = vec_len (mask) / sizeof (u32x4);
10726 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10728 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10729 if (*tmp || *(tmp + 1))
10734 clib_warning ("BUG: match 0");
10736 _vec_len (mask) = match * sizeof (u32x4);
10746 #endif /* VPP_API_TEST_BUILTIN */
10748 #define foreach_l2_next \
10750 _(ethernet, ETHERNET_INPUT) \
10751 _(ip4, IP4_INPUT) \
10755 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10757 u32 *miss_next_indexp = va_arg (*args, u32 *);
10758 u32 next_index = 0;
10762 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10766 if (unformat (input, "%d", &tmp))
10775 *miss_next_indexp = next_index;
10779 #define foreach_ip_next \
10782 _(rewrite, REWRITE)
10785 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10787 u32 *miss_next_indexp = va_arg (*args, u32 *);
10788 u32 next_index = 0;
10792 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10796 if (unformat (input, "%d", &tmp))
10805 *miss_next_indexp = next_index;
10809 #define foreach_acl_next \
10813 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10815 u32 *miss_next_indexp = va_arg (*args, u32 *);
10816 u32 next_index = 0;
10820 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10824 if (unformat (input, "permit"))
10829 else if (unformat (input, "%d", &tmp))
10838 *miss_next_indexp = next_index;
10843 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10845 u32 *r = va_arg (*args, u32 *);
10847 if (unformat (input, "conform-color"))
10848 *r = POLICE_CONFORM;
10849 else if (unformat (input, "exceed-color"))
10850 *r = POLICE_EXCEED;
10858 api_classify_add_del_table (vat_main_t * vam)
10860 unformat_input_t *i = vam->input;
10861 vl_api_classify_add_del_table_t *mp;
10868 u32 table_index = ~0;
10869 u32 next_table_index = ~0;
10870 u32 miss_next_index = ~0;
10871 u32 memory_size = 32 << 20;
10873 u32 current_data_flag = 0;
10874 int current_data_offset = 0;
10877 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10879 if (unformat (i, "del"))
10881 else if (unformat (i, "del-chain"))
10886 else if (unformat (i, "buckets %d", &nbuckets))
10888 else if (unformat (i, "memory_size %d", &memory_size))
10890 else if (unformat (i, "skip %d", &skip))
10892 else if (unformat (i, "match %d", &match))
10894 else if (unformat (i, "table %d", &table_index))
10896 else if (unformat (i, "mask %U", unformat_classify_mask,
10897 &mask, &skip, &match))
10899 else if (unformat (i, "next-table %d", &next_table_index))
10901 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10904 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10907 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10910 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10912 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10918 if (is_add && mask == 0)
10920 errmsg ("Mask required");
10924 if (is_add && skip == ~0)
10926 errmsg ("skip count required");
10930 if (is_add && match == ~0)
10932 errmsg ("match count required");
10936 if (!is_add && table_index == ~0)
10938 errmsg ("table index required for delete");
10942 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10944 mp->is_add = is_add;
10945 mp->del_chain = del_chain;
10946 mp->table_index = ntohl (table_index);
10947 mp->nbuckets = ntohl (nbuckets);
10948 mp->memory_size = ntohl (memory_size);
10949 mp->skip_n_vectors = ntohl (skip);
10950 mp->match_n_vectors = ntohl (match);
10951 mp->next_table_index = ntohl (next_table_index);
10952 mp->miss_next_index = ntohl (miss_next_index);
10953 mp->current_data_flag = ntohl (current_data_flag);
10954 mp->current_data_offset = ntohl (current_data_offset);
10955 clib_memcpy (mp->mask, mask, vec_len (mask));
10964 #if VPP_API_TEST_BUILTIN == 0
10966 unformat_l4_match (unformat_input_t * input, va_list * args)
10968 u8 **matchp = va_arg (*args, u8 **);
10970 u8 *proto_header = 0;
10976 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10978 if (unformat (input, "src_port %d", &src_port))
10980 else if (unformat (input, "dst_port %d", &dst_port))
10986 h.src_port = clib_host_to_net_u16 (src_port);
10987 h.dst_port = clib_host_to_net_u16 (dst_port);
10988 vec_validate (proto_header, sizeof (h) - 1);
10989 memcpy (proto_header, &h, sizeof (h));
10991 *matchp = proto_header;
10997 unformat_ip4_match (unformat_input_t * input, va_list * args)
10999 u8 **matchp = va_arg (*args, u8 **);
11004 int hdr_length = 0;
11005 u32 hdr_length_val;
11006 int src = 0, dst = 0;
11007 ip4_address_t src_val, dst_val;
11014 int fragment_id = 0;
11015 u32 fragment_id_val;
11021 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11023 if (unformat (input, "version %d", &version_val))
11025 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11027 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11029 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11031 else if (unformat (input, "proto %d", &proto_val))
11033 else if (unformat (input, "tos %d", &tos_val))
11035 else if (unformat (input, "length %d", &length_val))
11037 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11039 else if (unformat (input, "ttl %d", &ttl_val))
11041 else if (unformat (input, "checksum %d", &checksum_val))
11047 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11048 + ttl + checksum == 0)
11052 * Aligned because we use the real comparison functions
11054 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11056 ip = (ip4_header_t *) match;
11058 /* These are realistically matched in practice */
11060 ip->src_address.as_u32 = src_val.as_u32;
11063 ip->dst_address.as_u32 = dst_val.as_u32;
11066 ip->protocol = proto_val;
11069 /* These are not, but they're included for completeness */
11071 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11074 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11080 ip->length = clib_host_to_net_u16 (length_val);
11086 ip->checksum = clib_host_to_net_u16 (checksum_val);
11093 unformat_ip6_match (unformat_input_t * input, va_list * args)
11095 u8 **matchp = va_arg (*args, u8 **);
11100 u8 traffic_class = 0;
11101 u32 traffic_class_val = 0;
11104 int src = 0, dst = 0;
11105 ip6_address_t src_val, dst_val;
11108 int payload_length = 0;
11109 u32 payload_length_val;
11112 u32 ip_version_traffic_class_and_flow_label;
11114 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11116 if (unformat (input, "version %d", &version_val))
11118 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11120 else if (unformat (input, "flow_label %d", &flow_label_val))
11122 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11124 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11126 else if (unformat (input, "proto %d", &proto_val))
11128 else if (unformat (input, "payload_length %d", &payload_length_val))
11129 payload_length = 1;
11130 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11136 if (version + traffic_class + flow_label + src + dst + proto +
11137 payload_length + hop_limit == 0)
11141 * Aligned because we use the real comparison functions
11143 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11145 ip = (ip6_header_t *) match;
11148 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11151 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11154 ip->protocol = proto_val;
11156 ip_version_traffic_class_and_flow_label = 0;
11159 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11162 ip_version_traffic_class_and_flow_label |=
11163 (traffic_class_val & 0xFF) << 20;
11166 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11168 ip->ip_version_traffic_class_and_flow_label =
11169 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11171 if (payload_length)
11172 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11175 ip->hop_limit = hop_limit_val;
11182 unformat_l3_match (unformat_input_t * input, va_list * args)
11184 u8 **matchp = va_arg (*args, u8 **);
11186 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11188 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11190 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11199 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11201 u8 *tagp = va_arg (*args, u8 *);
11204 if (unformat (input, "%d", &tag))
11206 tagp[0] = (tag >> 8) & 0x0F;
11207 tagp[1] = tag & 0xFF;
11215 unformat_l2_match (unformat_input_t * input, va_list * args)
11217 u8 **matchp = va_arg (*args, u8 **);
11230 u8 ignore_tag1 = 0;
11231 u8 ignore_tag2 = 0;
11237 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11239 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11242 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11244 else if (unformat (input, "proto %U",
11245 unformat_ethernet_type_host_byte_order, &proto_val))
11247 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11249 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11251 else if (unformat (input, "ignore-tag1"))
11253 else if (unformat (input, "ignore-tag2"))
11255 else if (unformat (input, "cos1 %d", &cos1_val))
11257 else if (unformat (input, "cos2 %d", &cos2_val))
11262 if ((src + dst + proto + tag1 + tag2 +
11263 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11266 if (tag1 || ignore_tag1 || cos1)
11268 if (tag2 || ignore_tag2 || cos2)
11271 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11274 clib_memcpy (match, dst_val, 6);
11277 clib_memcpy (match + 6, src_val, 6);
11281 /* inner vlan tag */
11282 match[19] = tag2_val[1];
11283 match[18] = tag2_val[0];
11285 match[18] |= (cos2_val & 0x7) << 5;
11288 match[21] = proto_val & 0xff;
11289 match[20] = proto_val >> 8;
11293 match[15] = tag1_val[1];
11294 match[14] = tag1_val[0];
11297 match[14] |= (cos1_val & 0x7) << 5;
11303 match[15] = tag1_val[1];
11304 match[14] = tag1_val[0];
11307 match[17] = proto_val & 0xff;
11308 match[16] = proto_val >> 8;
11311 match[14] |= (cos1_val & 0x7) << 5;
11317 match[18] |= (cos2_val & 0x7) << 5;
11319 match[14] |= (cos1_val & 0x7) << 5;
11322 match[13] = proto_val & 0xff;
11323 match[12] = proto_val >> 8;
11332 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11334 u8 **matchp = va_arg (*args, u8 **);
11335 u32 skip_n_vectors = va_arg (*args, u32);
11336 u32 match_n_vectors = va_arg (*args, u32);
11343 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11345 if (unformat (input, "hex %U", unformat_hex_string, &match))
11347 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11349 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11351 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11365 if (match || l2 || l3 || l4)
11367 if (l2 || l3 || l4)
11369 /* "Win a free Ethernet header in every packet" */
11371 vec_validate_aligned (l2, 13, sizeof (u32x4));
11375 vec_append_aligned (match, l3, sizeof (u32x4));
11380 vec_append_aligned (match, l4, sizeof (u32x4));
11385 /* Make sure the vector is big enough even if key is all 0's */
11386 vec_validate_aligned
11387 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11390 /* Set size, include skipped vectors */
11391 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11402 api_classify_add_del_session (vat_main_t * vam)
11404 unformat_input_t *i = vam->input;
11405 vl_api_classify_add_del_session_t *mp;
11407 u32 table_index = ~0;
11408 u32 hit_next_index = ~0;
11409 u32 opaque_index = ~0;
11412 u32 skip_n_vectors = 0;
11413 u32 match_n_vectors = 0;
11419 * Warning: you have to supply skip_n and match_n
11420 * because the API client cant simply look at the classify
11424 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11426 if (unformat (i, "del"))
11428 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11431 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11434 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11437 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11439 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11441 else if (unformat (i, "opaque-index %d", &opaque_index))
11443 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11445 else if (unformat (i, "match_n %d", &match_n_vectors))
11447 else if (unformat (i, "match %U", api_unformat_classify_match,
11448 &match, skip_n_vectors, match_n_vectors))
11450 else if (unformat (i, "advance %d", &advance))
11452 else if (unformat (i, "table-index %d", &table_index))
11454 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11456 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11458 else if (unformat (i, "action %d", &action))
11460 else if (unformat (i, "metadata %d", &metadata))
11466 if (table_index == ~0)
11468 errmsg ("Table index required");
11472 if (is_add && match == 0)
11474 errmsg ("Match value required");
11478 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11480 mp->is_add = is_add;
11481 mp->table_index = ntohl (table_index);
11482 mp->hit_next_index = ntohl (hit_next_index);
11483 mp->opaque_index = ntohl (opaque_index);
11484 mp->advance = ntohl (advance);
11485 mp->action = action;
11486 mp->metadata = ntohl (metadata);
11487 clib_memcpy (mp->match, match, vec_len (match));
11496 api_classify_set_interface_ip_table (vat_main_t * vam)
11498 unformat_input_t *i = vam->input;
11499 vl_api_classify_set_interface_ip_table_t *mp;
11501 int sw_if_index_set;
11502 u32 table_index = ~0;
11506 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11508 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11509 sw_if_index_set = 1;
11510 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11511 sw_if_index_set = 1;
11512 else if (unformat (i, "table %d", &table_index))
11516 clib_warning ("parse error '%U'", format_unformat_error, i);
11521 if (sw_if_index_set == 0)
11523 errmsg ("missing interface name or sw_if_index");
11528 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11530 mp->sw_if_index = ntohl (sw_if_index);
11531 mp->table_index = ntohl (table_index);
11532 mp->is_ipv6 = is_ipv6;
11540 api_classify_set_interface_l2_tables (vat_main_t * vam)
11542 unformat_input_t *i = vam->input;
11543 vl_api_classify_set_interface_l2_tables_t *mp;
11545 int sw_if_index_set;
11546 u32 ip4_table_index = ~0;
11547 u32 ip6_table_index = ~0;
11548 u32 other_table_index = ~0;
11552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11554 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11555 sw_if_index_set = 1;
11556 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11557 sw_if_index_set = 1;
11558 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11560 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11562 else if (unformat (i, "other-table %d", &other_table_index))
11564 else if (unformat (i, "is-input %d", &is_input))
11568 clib_warning ("parse error '%U'", format_unformat_error, i);
11573 if (sw_if_index_set == 0)
11575 errmsg ("missing interface name or sw_if_index");
11580 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11582 mp->sw_if_index = ntohl (sw_if_index);
11583 mp->ip4_table_index = ntohl (ip4_table_index);
11584 mp->ip6_table_index = ntohl (ip6_table_index);
11585 mp->other_table_index = ntohl (other_table_index);
11586 mp->is_input = (u8) is_input;
11594 api_set_ipfix_exporter (vat_main_t * vam)
11596 unformat_input_t *i = vam->input;
11597 vl_api_set_ipfix_exporter_t *mp;
11598 ip4_address_t collector_address;
11599 u8 collector_address_set = 0;
11600 u32 collector_port = ~0;
11601 ip4_address_t src_address;
11602 u8 src_address_set = 0;
11605 u32 template_interval = ~0;
11606 u8 udp_checksum = 0;
11609 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11611 if (unformat (i, "collector_address %U", unformat_ip4_address,
11612 &collector_address))
11613 collector_address_set = 1;
11614 else if (unformat (i, "collector_port %d", &collector_port))
11616 else if (unformat (i, "src_address %U", unformat_ip4_address,
11618 src_address_set = 1;
11619 else if (unformat (i, "vrf_id %d", &vrf_id))
11621 else if (unformat (i, "path_mtu %d", &path_mtu))
11623 else if (unformat (i, "template_interval %d", &template_interval))
11625 else if (unformat (i, "udp_checksum"))
11631 if (collector_address_set == 0)
11633 errmsg ("collector_address required");
11637 if (src_address_set == 0)
11639 errmsg ("src_address required");
11643 M (SET_IPFIX_EXPORTER, mp);
11645 memcpy (mp->collector_address, collector_address.data,
11646 sizeof (collector_address.data));
11647 mp->collector_port = htons ((u16) collector_port);
11648 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11649 mp->vrf_id = htonl (vrf_id);
11650 mp->path_mtu = htonl (path_mtu);
11651 mp->template_interval = htonl (template_interval);
11652 mp->udp_checksum = udp_checksum;
11660 api_set_ipfix_classify_stream (vat_main_t * vam)
11662 unformat_input_t *i = vam->input;
11663 vl_api_set_ipfix_classify_stream_t *mp;
11665 u32 src_port = UDP_DST_PORT_ipfix;
11668 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11670 if (unformat (i, "domain %d", &domain_id))
11672 else if (unformat (i, "src_port %d", &src_port))
11676 errmsg ("unknown input `%U'", format_unformat_error, i);
11681 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11683 mp->domain_id = htonl (domain_id);
11684 mp->src_port = htons ((u16) src_port);
11692 api_ipfix_classify_table_add_del (vat_main_t * vam)
11694 unformat_input_t *i = vam->input;
11695 vl_api_ipfix_classify_table_add_del_t *mp;
11697 u32 classify_table_index = ~0;
11699 u8 transport_protocol = 255;
11702 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11704 if (unformat (i, "add"))
11706 else if (unformat (i, "del"))
11708 else if (unformat (i, "table %d", &classify_table_index))
11710 else if (unformat (i, "ip4"))
11712 else if (unformat (i, "ip6"))
11714 else if (unformat (i, "tcp"))
11715 transport_protocol = 6;
11716 else if (unformat (i, "udp"))
11717 transport_protocol = 17;
11720 errmsg ("unknown input `%U'", format_unformat_error, i);
11727 errmsg ("expecting: add|del");
11730 if (classify_table_index == ~0)
11732 errmsg ("classifier table not specified");
11735 if (ip_version == 0)
11737 errmsg ("IP version not specified");
11741 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11743 mp->is_add = is_add;
11744 mp->table_id = htonl (classify_table_index);
11745 mp->ip_version = ip_version;
11746 mp->transport_protocol = transport_protocol;
11754 api_get_node_index (vat_main_t * vam)
11756 unformat_input_t *i = vam->input;
11757 vl_api_get_node_index_t *mp;
11761 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11763 if (unformat (i, "node %s", &name))
11770 errmsg ("node name required");
11773 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11775 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11779 M (GET_NODE_INDEX, mp);
11780 clib_memcpy (mp->node_name, name, vec_len (name));
11789 api_get_next_index (vat_main_t * vam)
11791 unformat_input_t *i = vam->input;
11792 vl_api_get_next_index_t *mp;
11793 u8 *node_name = 0, *next_node_name = 0;
11796 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11798 if (unformat (i, "node-name %s", &node_name))
11800 else if (unformat (i, "next-node-name %s", &next_node_name))
11804 if (node_name == 0)
11806 errmsg ("node name required");
11809 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11811 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11815 if (next_node_name == 0)
11817 errmsg ("next node name required");
11820 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11822 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11826 M (GET_NEXT_INDEX, mp);
11827 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11828 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11829 vec_free (node_name);
11830 vec_free (next_node_name);
11838 api_add_node_next (vat_main_t * vam)
11840 unformat_input_t *i = vam->input;
11841 vl_api_add_node_next_t *mp;
11846 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11848 if (unformat (i, "node %s", &name))
11850 else if (unformat (i, "next %s", &next))
11857 errmsg ("node name required");
11860 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11862 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11867 errmsg ("next node required");
11870 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11872 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11876 M (ADD_NODE_NEXT, mp);
11877 clib_memcpy (mp->node_name, name, vec_len (name));
11878 clib_memcpy (mp->next_name, next, vec_len (next));
11888 api_l2tpv3_create_tunnel (vat_main_t * vam)
11890 unformat_input_t *i = vam->input;
11891 ip6_address_t client_address, our_address;
11892 int client_address_set = 0;
11893 int our_address_set = 0;
11894 u32 local_session_id = 0;
11895 u32 remote_session_id = 0;
11896 u64 local_cookie = 0;
11897 u64 remote_cookie = 0;
11898 u8 l2_sublayer_present = 0;
11899 vl_api_l2tpv3_create_tunnel_t *mp;
11902 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11904 if (unformat (i, "client_address %U", unformat_ip6_address,
11906 client_address_set = 1;
11907 else if (unformat (i, "our_address %U", unformat_ip6_address,
11909 our_address_set = 1;
11910 else if (unformat (i, "local_session_id %d", &local_session_id))
11912 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11914 else if (unformat (i, "local_cookie %lld", &local_cookie))
11916 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11918 else if (unformat (i, "l2-sublayer-present"))
11919 l2_sublayer_present = 1;
11924 if (client_address_set == 0)
11926 errmsg ("client_address required");
11930 if (our_address_set == 0)
11932 errmsg ("our_address required");
11936 M (L2TPV3_CREATE_TUNNEL, mp);
11938 clib_memcpy (mp->client_address, client_address.as_u8,
11939 sizeof (mp->client_address));
11941 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11943 mp->local_session_id = ntohl (local_session_id);
11944 mp->remote_session_id = ntohl (remote_session_id);
11945 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11946 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11947 mp->l2_sublayer_present = l2_sublayer_present;
11956 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11958 unformat_input_t *i = vam->input;
11960 u8 sw_if_index_set = 0;
11961 u64 new_local_cookie = 0;
11962 u64 new_remote_cookie = 0;
11963 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11968 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11969 sw_if_index_set = 1;
11970 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11971 sw_if_index_set = 1;
11972 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11974 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11980 if (sw_if_index_set == 0)
11982 errmsg ("missing interface name or sw_if_index");
11986 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11988 mp->sw_if_index = ntohl (sw_if_index);
11989 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11990 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11998 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12000 unformat_input_t *i = vam->input;
12001 vl_api_l2tpv3_interface_enable_disable_t *mp;
12003 u8 sw_if_index_set = 0;
12004 u8 enable_disable = 1;
12007 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12009 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12010 sw_if_index_set = 1;
12011 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12012 sw_if_index_set = 1;
12013 else if (unformat (i, "enable"))
12014 enable_disable = 1;
12015 else if (unformat (i, "disable"))
12016 enable_disable = 0;
12021 if (sw_if_index_set == 0)
12023 errmsg ("missing interface name or sw_if_index");
12027 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12029 mp->sw_if_index = ntohl (sw_if_index);
12030 mp->enable_disable = enable_disable;
12038 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12040 unformat_input_t *i = vam->input;
12041 vl_api_l2tpv3_set_lookup_key_t *mp;
12045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12047 if (unformat (i, "lookup_v6_src"))
12048 key = L2T_LOOKUP_SRC_ADDRESS;
12049 else if (unformat (i, "lookup_v6_dst"))
12050 key = L2T_LOOKUP_DST_ADDRESS;
12051 else if (unformat (i, "lookup_session_id"))
12052 key = L2T_LOOKUP_SESSION_ID;
12057 if (key == (u8) ~ 0)
12059 errmsg ("l2tp session lookup key unset");
12063 M (L2TPV3_SET_LOOKUP_KEY, mp);
12072 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12073 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12075 vat_main_t *vam = &vat_main;
12077 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12078 format_ip6_address, mp->our_address,
12079 format_ip6_address, mp->client_address,
12080 clib_net_to_host_u32 (mp->sw_if_index));
12083 " local cookies %016llx %016llx remote cookie %016llx",
12084 clib_net_to_host_u64 (mp->local_cookie[0]),
12085 clib_net_to_host_u64 (mp->local_cookie[1]),
12086 clib_net_to_host_u64 (mp->remote_cookie));
12088 print (vam->ofp, " local session-id %d remote session-id %d",
12089 clib_net_to_host_u32 (mp->local_session_id),
12090 clib_net_to_host_u32 (mp->remote_session_id));
12092 print (vam->ofp, " l2 specific sublayer %s\n",
12093 mp->l2_sublayer_present ? "preset" : "absent");
12097 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12098 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12100 vat_main_t *vam = &vat_main;
12101 vat_json_node_t *node = NULL;
12102 struct in6_addr addr;
12104 if (VAT_JSON_ARRAY != vam->json_tree.type)
12106 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12107 vat_json_init_array (&vam->json_tree);
12109 node = vat_json_array_add (&vam->json_tree);
12111 vat_json_init_object (node);
12113 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12114 vat_json_object_add_ip6 (node, "our_address", addr);
12115 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12116 vat_json_object_add_ip6 (node, "client_address", addr);
12118 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12119 vat_json_init_array (lc);
12120 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12121 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12122 vat_json_object_add_uint (node, "remote_cookie",
12123 clib_net_to_host_u64 (mp->remote_cookie));
12125 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12126 vat_json_object_add_uint (node, "local_session_id",
12127 clib_net_to_host_u32 (mp->local_session_id));
12128 vat_json_object_add_uint (node, "remote_session_id",
12129 clib_net_to_host_u32 (mp->remote_session_id));
12130 vat_json_object_add_string_copy (node, "l2_sublayer",
12131 mp->l2_sublayer_present ? (u8 *) "present"
12132 : (u8 *) "absent");
12136 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12138 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12139 vl_api_control_ping_t *mp_ping;
12142 /* Get list of l2tpv3-tunnel interfaces */
12143 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12146 /* Use a control ping for synchronization */
12147 MPING (CONTROL_PING, mp_ping);
12155 static void vl_api_sw_interface_tap_details_t_handler
12156 (vl_api_sw_interface_tap_details_t * mp)
12158 vat_main_t *vam = &vat_main;
12160 print (vam->ofp, "%-16s %d",
12161 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12164 static void vl_api_sw_interface_tap_details_t_handler_json
12165 (vl_api_sw_interface_tap_details_t * mp)
12167 vat_main_t *vam = &vat_main;
12168 vat_json_node_t *node = NULL;
12170 if (VAT_JSON_ARRAY != vam->json_tree.type)
12172 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12173 vat_json_init_array (&vam->json_tree);
12175 node = vat_json_array_add (&vam->json_tree);
12177 vat_json_init_object (node);
12178 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12179 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12183 api_sw_interface_tap_dump (vat_main_t * vam)
12185 vl_api_sw_interface_tap_dump_t *mp;
12186 vl_api_control_ping_t *mp_ping;
12189 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12190 /* Get list of tap interfaces */
12191 M (SW_INTERFACE_TAP_DUMP, mp);
12194 /* Use a control ping for synchronization */
12195 MPING (CONTROL_PING, mp_ping);
12202 static uword unformat_vxlan_decap_next
12203 (unformat_input_t * input, va_list * args)
12205 u32 *result = va_arg (*args, u32 *);
12208 if (unformat (input, "l2"))
12209 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12210 else if (unformat (input, "%d", &tmp))
12218 api_vxlan_add_del_tunnel (vat_main_t * vam)
12220 unformat_input_t *line_input = vam->input;
12221 vl_api_vxlan_add_del_tunnel_t *mp;
12222 ip46_address_t src, dst;
12224 u8 ipv4_set = 0, ipv6_set = 0;
12228 u32 mcast_sw_if_index = ~0;
12229 u32 encap_vrf_id = 0;
12230 u32 decap_next_index = ~0;
12234 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12235 memset (&src, 0, sizeof src);
12236 memset (&dst, 0, sizeof dst);
12238 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12240 if (unformat (line_input, "del"))
12243 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12249 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12255 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12261 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12266 else if (unformat (line_input, "group %U %U",
12267 unformat_ip4_address, &dst.ip4,
12268 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12270 grp_set = dst_set = 1;
12273 else if (unformat (line_input, "group %U",
12274 unformat_ip4_address, &dst.ip4))
12276 grp_set = dst_set = 1;
12279 else if (unformat (line_input, "group %U %U",
12280 unformat_ip6_address, &dst.ip6,
12281 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12283 grp_set = dst_set = 1;
12286 else if (unformat (line_input, "group %U",
12287 unformat_ip6_address, &dst.ip6))
12289 grp_set = dst_set = 1;
12293 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12295 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12297 else if (unformat (line_input, "decap-next %U",
12298 unformat_vxlan_decap_next, &decap_next_index))
12300 else if (unformat (line_input, "vni %d", &vni))
12304 errmsg ("parse error '%U'", format_unformat_error, line_input);
12311 errmsg ("tunnel src address not specified");
12316 errmsg ("tunnel dst address not specified");
12320 if (grp_set && !ip46_address_is_multicast (&dst))
12322 errmsg ("tunnel group address not multicast");
12325 if (grp_set && mcast_sw_if_index == ~0)
12327 errmsg ("tunnel nonexistent multicast device");
12330 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12332 errmsg ("tunnel dst address must be unicast");
12337 if (ipv4_set && ipv6_set)
12339 errmsg ("both IPv4 and IPv6 addresses specified");
12343 if ((vni == 0) || (vni >> 24))
12345 errmsg ("vni not specified or out of range");
12349 M (VXLAN_ADD_DEL_TUNNEL, mp);
12353 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12354 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12358 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12359 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12361 mp->encap_vrf_id = ntohl (encap_vrf_id);
12362 mp->decap_next_index = ntohl (decap_next_index);
12363 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12364 mp->vni = ntohl (vni);
12365 mp->is_add = is_add;
12366 mp->is_ipv6 = ipv6_set;
12373 static void vl_api_vxlan_tunnel_details_t_handler
12374 (vl_api_vxlan_tunnel_details_t * mp)
12376 vat_main_t *vam = &vat_main;
12377 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12378 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12380 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12381 ntohl (mp->sw_if_index),
12382 format_ip46_address, &src, IP46_TYPE_ANY,
12383 format_ip46_address, &dst, IP46_TYPE_ANY,
12384 ntohl (mp->encap_vrf_id),
12385 ntohl (mp->decap_next_index), ntohl (mp->vni),
12386 ntohl (mp->mcast_sw_if_index));
12389 static void vl_api_vxlan_tunnel_details_t_handler_json
12390 (vl_api_vxlan_tunnel_details_t * mp)
12392 vat_main_t *vam = &vat_main;
12393 vat_json_node_t *node = NULL;
12395 if (VAT_JSON_ARRAY != vam->json_tree.type)
12397 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12398 vat_json_init_array (&vam->json_tree);
12400 node = vat_json_array_add (&vam->json_tree);
12402 vat_json_init_object (node);
12403 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12406 struct in6_addr ip6;
12408 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12409 vat_json_object_add_ip6 (node, "src_address", ip6);
12410 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12411 vat_json_object_add_ip6 (node, "dst_address", ip6);
12415 struct in_addr ip4;
12417 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12418 vat_json_object_add_ip4 (node, "src_address", ip4);
12419 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12420 vat_json_object_add_ip4 (node, "dst_address", ip4);
12422 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12423 vat_json_object_add_uint (node, "decap_next_index",
12424 ntohl (mp->decap_next_index));
12425 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12426 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12427 vat_json_object_add_uint (node, "mcast_sw_if_index",
12428 ntohl (mp->mcast_sw_if_index));
12432 api_vxlan_tunnel_dump (vat_main_t * vam)
12434 unformat_input_t *i = vam->input;
12435 vl_api_vxlan_tunnel_dump_t *mp;
12436 vl_api_control_ping_t *mp_ping;
12438 u8 sw_if_index_set = 0;
12441 /* Parse args required to build the message */
12442 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12444 if (unformat (i, "sw_if_index %d", &sw_if_index))
12445 sw_if_index_set = 1;
12450 if (sw_if_index_set == 0)
12455 if (!vam->json_output)
12457 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12458 "sw_if_index", "src_address", "dst_address",
12459 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12462 /* Get list of vxlan-tunnel interfaces */
12463 M (VXLAN_TUNNEL_DUMP, mp);
12465 mp->sw_if_index = htonl (sw_if_index);
12469 /* Use a control ping for synchronization */
12470 MPING (CONTROL_PING, mp_ping);
12477 static uword unformat_geneve_decap_next
12478 (unformat_input_t * input, va_list * args)
12480 u32 *result = va_arg (*args, u32 *);
12483 if (unformat (input, "l2"))
12484 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12485 else if (unformat (input, "%d", &tmp))
12493 api_geneve_add_del_tunnel (vat_main_t * vam)
12495 unformat_input_t *line_input = vam->input;
12496 vl_api_geneve_add_del_tunnel_t *mp;
12497 ip46_address_t src, dst;
12499 u8 ipv4_set = 0, ipv6_set = 0;
12503 u32 mcast_sw_if_index = ~0;
12504 u32 encap_vrf_id = 0;
12505 u32 decap_next_index = ~0;
12509 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12510 memset (&src, 0, sizeof src);
12511 memset (&dst, 0, sizeof dst);
12513 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12515 if (unformat (line_input, "del"))
12518 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12524 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12530 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12536 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12541 else if (unformat (line_input, "group %U %U",
12542 unformat_ip4_address, &dst.ip4,
12543 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12545 grp_set = dst_set = 1;
12548 else if (unformat (line_input, "group %U",
12549 unformat_ip4_address, &dst.ip4))
12551 grp_set = dst_set = 1;
12554 else if (unformat (line_input, "group %U %U",
12555 unformat_ip6_address, &dst.ip6,
12556 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12558 grp_set = dst_set = 1;
12561 else if (unformat (line_input, "group %U",
12562 unformat_ip6_address, &dst.ip6))
12564 grp_set = dst_set = 1;
12568 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12570 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12572 else if (unformat (line_input, "decap-next %U",
12573 unformat_geneve_decap_next, &decap_next_index))
12575 else if (unformat (line_input, "vni %d", &vni))
12579 errmsg ("parse error '%U'", format_unformat_error, line_input);
12586 errmsg ("tunnel src address not specified");
12591 errmsg ("tunnel dst address not specified");
12595 if (grp_set && !ip46_address_is_multicast (&dst))
12597 errmsg ("tunnel group address not multicast");
12600 if (grp_set && mcast_sw_if_index == ~0)
12602 errmsg ("tunnel nonexistent multicast device");
12605 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12607 errmsg ("tunnel dst address must be unicast");
12612 if (ipv4_set && ipv6_set)
12614 errmsg ("both IPv4 and IPv6 addresses specified");
12618 if ((vni == 0) || (vni >> 24))
12620 errmsg ("vni not specified or out of range");
12624 M (GENEVE_ADD_DEL_TUNNEL, mp);
12628 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12629 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12633 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12634 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12636 mp->encap_vrf_id = ntohl (encap_vrf_id);
12637 mp->decap_next_index = ntohl (decap_next_index);
12638 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12639 mp->vni = ntohl (vni);
12640 mp->is_add = is_add;
12641 mp->is_ipv6 = ipv6_set;
12648 static void vl_api_geneve_tunnel_details_t_handler
12649 (vl_api_geneve_tunnel_details_t * mp)
12651 vat_main_t *vam = &vat_main;
12652 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12653 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12655 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12656 ntohl (mp->sw_if_index),
12657 format_ip46_address, &src, IP46_TYPE_ANY,
12658 format_ip46_address, &dst, IP46_TYPE_ANY,
12659 ntohl (mp->encap_vrf_id),
12660 ntohl (mp->decap_next_index), ntohl (mp->vni),
12661 ntohl (mp->mcast_sw_if_index));
12664 static void vl_api_geneve_tunnel_details_t_handler_json
12665 (vl_api_geneve_tunnel_details_t * mp)
12667 vat_main_t *vam = &vat_main;
12668 vat_json_node_t *node = NULL;
12670 if (VAT_JSON_ARRAY != vam->json_tree.type)
12672 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12673 vat_json_init_array (&vam->json_tree);
12675 node = vat_json_array_add (&vam->json_tree);
12677 vat_json_init_object (node);
12678 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12681 struct in6_addr ip6;
12683 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12684 vat_json_object_add_ip6 (node, "src_address", ip6);
12685 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12686 vat_json_object_add_ip6 (node, "dst_address", ip6);
12690 struct in_addr ip4;
12692 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12693 vat_json_object_add_ip4 (node, "src_address", ip4);
12694 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12695 vat_json_object_add_ip4 (node, "dst_address", ip4);
12697 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12698 vat_json_object_add_uint (node, "decap_next_index",
12699 ntohl (mp->decap_next_index));
12700 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12701 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12702 vat_json_object_add_uint (node, "mcast_sw_if_index",
12703 ntohl (mp->mcast_sw_if_index));
12707 api_geneve_tunnel_dump (vat_main_t * vam)
12709 unformat_input_t *i = vam->input;
12710 vl_api_geneve_tunnel_dump_t *mp;
12711 vl_api_control_ping_t *mp_ping;
12713 u8 sw_if_index_set = 0;
12716 /* Parse args required to build the message */
12717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12719 if (unformat (i, "sw_if_index %d", &sw_if_index))
12720 sw_if_index_set = 1;
12725 if (sw_if_index_set == 0)
12730 if (!vam->json_output)
12732 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12733 "sw_if_index", "local_address", "remote_address",
12734 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12737 /* Get list of geneve-tunnel interfaces */
12738 M (GENEVE_TUNNEL_DUMP, mp);
12740 mp->sw_if_index = htonl (sw_if_index);
12744 /* Use a control ping for synchronization */
12745 M (CONTROL_PING, mp_ping);
12753 api_gre_add_del_tunnel (vat_main_t * vam)
12755 unformat_input_t *line_input = vam->input;
12756 vl_api_gre_add_del_tunnel_t *mp;
12757 ip4_address_t src4, dst4;
12758 ip6_address_t src6, dst6;
12765 u32 outer_fib_id = 0;
12768 memset (&src4, 0, sizeof src4);
12769 memset (&dst4, 0, sizeof dst4);
12770 memset (&src6, 0, sizeof src6);
12771 memset (&dst6, 0, sizeof dst6);
12773 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12775 if (unformat (line_input, "del"))
12777 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
12782 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
12787 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
12792 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
12797 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12799 else if (unformat (line_input, "teb"))
12803 errmsg ("parse error '%U'", format_unformat_error, line_input);
12810 errmsg ("tunnel src address not specified");
12815 errmsg ("tunnel dst address not specified");
12818 if (ipv4_set && ipv6_set)
12820 errmsg ("both IPv4 and IPv6 addresses specified");
12825 M (GRE_ADD_DEL_TUNNEL, mp);
12829 clib_memcpy (&mp->src_address, &src4, 4);
12830 clib_memcpy (&mp->dst_address, &dst4, 4);
12834 clib_memcpy (&mp->src_address, &src6, 16);
12835 clib_memcpy (&mp->dst_address, &dst6, 16);
12837 mp->outer_fib_id = ntohl (outer_fib_id);
12838 mp->is_add = is_add;
12840 mp->is_ipv6 = ipv6_set;
12847 static void vl_api_gre_tunnel_details_t_handler
12848 (vl_api_gre_tunnel_details_t * mp)
12850 vat_main_t *vam = &vat_main;
12851 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
12852 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
12854 print (vam->ofp, "%11d%24U%24U%6d%14d",
12855 ntohl (mp->sw_if_index),
12856 format_ip46_address, &src, IP46_TYPE_ANY,
12857 format_ip46_address, &dst, IP46_TYPE_ANY,
12858 mp->teb, ntohl (mp->outer_fib_id));
12861 static void vl_api_gre_tunnel_details_t_handler_json
12862 (vl_api_gre_tunnel_details_t * mp)
12864 vat_main_t *vam = &vat_main;
12865 vat_json_node_t *node = NULL;
12866 struct in_addr ip4;
12867 struct in6_addr ip6;
12869 if (VAT_JSON_ARRAY != vam->json_tree.type)
12871 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12872 vat_json_init_array (&vam->json_tree);
12874 node = vat_json_array_add (&vam->json_tree);
12876 vat_json_init_object (node);
12877 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12880 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
12881 vat_json_object_add_ip4 (node, "src_address", ip4);
12882 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
12883 vat_json_object_add_ip4 (node, "dst_address", ip4);
12887 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
12888 vat_json_object_add_ip6 (node, "src_address", ip6);
12889 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
12890 vat_json_object_add_ip6 (node, "dst_address", ip6);
12892 vat_json_object_add_uint (node, "teb", mp->teb);
12893 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
12894 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
12898 api_gre_tunnel_dump (vat_main_t * vam)
12900 unformat_input_t *i = vam->input;
12901 vl_api_gre_tunnel_dump_t *mp;
12902 vl_api_control_ping_t *mp_ping;
12904 u8 sw_if_index_set = 0;
12907 /* Parse args required to build the message */
12908 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12910 if (unformat (i, "sw_if_index %d", &sw_if_index))
12911 sw_if_index_set = 1;
12916 if (sw_if_index_set == 0)
12921 if (!vam->json_output)
12923 print (vam->ofp, "%11s%24s%24s%6s%14s",
12924 "sw_if_index", "src_address", "dst_address", "teb",
12928 /* Get list of gre-tunnel interfaces */
12929 M (GRE_TUNNEL_DUMP, mp);
12931 mp->sw_if_index = htonl (sw_if_index);
12935 /* Use a control ping for synchronization */
12936 MPING (CONTROL_PING, mp_ping);
12944 api_l2_fib_clear_table (vat_main_t * vam)
12946 // unformat_input_t * i = vam->input;
12947 vl_api_l2_fib_clear_table_t *mp;
12950 M (L2_FIB_CLEAR_TABLE, mp);
12958 api_l2_interface_efp_filter (vat_main_t * vam)
12960 unformat_input_t *i = vam->input;
12961 vl_api_l2_interface_efp_filter_t *mp;
12964 u8 sw_if_index_set = 0;
12967 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12969 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12970 sw_if_index_set = 1;
12971 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12972 sw_if_index_set = 1;
12973 else if (unformat (i, "enable"))
12975 else if (unformat (i, "disable"))
12979 clib_warning ("parse error '%U'", format_unformat_error, i);
12984 if (sw_if_index_set == 0)
12986 errmsg ("missing sw_if_index");
12990 M (L2_INTERFACE_EFP_FILTER, mp);
12992 mp->sw_if_index = ntohl (sw_if_index);
12993 mp->enable_disable = enable;
13000 #define foreach_vtr_op \
13001 _("disable", L2_VTR_DISABLED) \
13002 _("push-1", L2_VTR_PUSH_1) \
13003 _("push-2", L2_VTR_PUSH_2) \
13004 _("pop-1", L2_VTR_POP_1) \
13005 _("pop-2", L2_VTR_POP_2) \
13006 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13007 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13008 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13009 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13012 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13014 unformat_input_t *i = vam->input;
13015 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13017 u8 sw_if_index_set = 0;
13020 u32 push_dot1q = 1;
13025 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13027 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13028 sw_if_index_set = 1;
13029 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13030 sw_if_index_set = 1;
13031 else if (unformat (i, "vtr_op %d", &vtr_op))
13033 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13036 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13038 else if (unformat (i, "tag1 %d", &tag1))
13040 else if (unformat (i, "tag2 %d", &tag2))
13044 clib_warning ("parse error '%U'", format_unformat_error, i);
13049 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13051 errmsg ("missing vtr operation or sw_if_index");
13055 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13056 mp->sw_if_index = ntohl (sw_if_index);
13057 mp->vtr_op = ntohl (vtr_op);
13058 mp->push_dot1q = ntohl (push_dot1q);
13059 mp->tag1 = ntohl (tag1);
13060 mp->tag2 = ntohl (tag2);
13068 api_create_vhost_user_if (vat_main_t * vam)
13070 unformat_input_t *i = vam->input;
13071 vl_api_create_vhost_user_if_t *mp;
13074 u8 file_name_set = 0;
13075 u32 custom_dev_instance = ~0;
13077 u8 use_custom_mac = 0;
13081 /* Shut up coverity */
13082 memset (hwaddr, 0, sizeof (hwaddr));
13084 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13086 if (unformat (i, "socket %s", &file_name))
13090 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13092 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13093 use_custom_mac = 1;
13094 else if (unformat (i, "server"))
13096 else if (unformat (i, "tag %s", &tag))
13102 if (file_name_set == 0)
13104 errmsg ("missing socket file name");
13108 if (vec_len (file_name) > 255)
13110 errmsg ("socket file name too long");
13113 vec_add1 (file_name, 0);
13115 M (CREATE_VHOST_USER_IF, mp);
13117 mp->is_server = is_server;
13118 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13119 vec_free (file_name);
13120 if (custom_dev_instance != ~0)
13123 mp->custom_dev_instance = ntohl (custom_dev_instance);
13125 mp->use_custom_mac = use_custom_mac;
13126 clib_memcpy (mp->mac_address, hwaddr, 6);
13128 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13137 api_modify_vhost_user_if (vat_main_t * vam)
13139 unformat_input_t *i = vam->input;
13140 vl_api_modify_vhost_user_if_t *mp;
13143 u8 file_name_set = 0;
13144 u32 custom_dev_instance = ~0;
13145 u8 sw_if_index_set = 0;
13146 u32 sw_if_index = (u32) ~ 0;
13149 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13151 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13152 sw_if_index_set = 1;
13153 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13154 sw_if_index_set = 1;
13155 else if (unformat (i, "socket %s", &file_name))
13159 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13161 else if (unformat (i, "server"))
13167 if (sw_if_index_set == 0)
13169 errmsg ("missing sw_if_index or interface name");
13173 if (file_name_set == 0)
13175 errmsg ("missing socket file name");
13179 if (vec_len (file_name) > 255)
13181 errmsg ("socket file name too long");
13184 vec_add1 (file_name, 0);
13186 M (MODIFY_VHOST_USER_IF, mp);
13188 mp->sw_if_index = ntohl (sw_if_index);
13189 mp->is_server = is_server;
13190 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13191 vec_free (file_name);
13192 if (custom_dev_instance != ~0)
13195 mp->custom_dev_instance = ntohl (custom_dev_instance);
13204 api_delete_vhost_user_if (vat_main_t * vam)
13206 unformat_input_t *i = vam->input;
13207 vl_api_delete_vhost_user_if_t *mp;
13208 u32 sw_if_index = ~0;
13209 u8 sw_if_index_set = 0;
13212 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13214 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13215 sw_if_index_set = 1;
13216 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13217 sw_if_index_set = 1;
13222 if (sw_if_index_set == 0)
13224 errmsg ("missing sw_if_index or interface name");
13229 M (DELETE_VHOST_USER_IF, mp);
13231 mp->sw_if_index = ntohl (sw_if_index);
13238 static void vl_api_sw_interface_vhost_user_details_t_handler
13239 (vl_api_sw_interface_vhost_user_details_t * mp)
13241 vat_main_t *vam = &vat_main;
13243 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13244 (char *) mp->interface_name,
13245 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13246 clib_net_to_host_u64 (mp->features), mp->is_server,
13247 ntohl (mp->num_regions), (char *) mp->sock_filename);
13248 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13251 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13252 (vl_api_sw_interface_vhost_user_details_t * mp)
13254 vat_main_t *vam = &vat_main;
13255 vat_json_node_t *node = NULL;
13257 if (VAT_JSON_ARRAY != vam->json_tree.type)
13259 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13260 vat_json_init_array (&vam->json_tree);
13262 node = vat_json_array_add (&vam->json_tree);
13264 vat_json_init_object (node);
13265 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13266 vat_json_object_add_string_copy (node, "interface_name",
13267 mp->interface_name);
13268 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13269 ntohl (mp->virtio_net_hdr_sz));
13270 vat_json_object_add_uint (node, "features",
13271 clib_net_to_host_u64 (mp->features));
13272 vat_json_object_add_uint (node, "is_server", mp->is_server);
13273 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13274 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13275 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13279 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13281 vl_api_sw_interface_vhost_user_dump_t *mp;
13282 vl_api_control_ping_t *mp_ping;
13285 "Interface name idx hdr_sz features server regions filename");
13287 /* Get list of vhost-user interfaces */
13288 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13291 /* Use a control ping for synchronization */
13292 MPING (CONTROL_PING, mp_ping);
13300 api_show_version (vat_main_t * vam)
13302 vl_api_show_version_t *mp;
13305 M (SHOW_VERSION, mp);
13314 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13316 unformat_input_t *line_input = vam->input;
13317 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13318 ip4_address_t local4, remote4;
13319 ip6_address_t local6, remote6;
13321 u8 ipv4_set = 0, ipv6_set = 0;
13325 u32 mcast_sw_if_index = ~0;
13326 u32 encap_vrf_id = 0;
13327 u32 decap_vrf_id = 0;
13333 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13334 memset (&local4, 0, sizeof local4);
13335 memset (&remote4, 0, sizeof remote4);
13336 memset (&local6, 0, sizeof local6);
13337 memset (&remote6, 0, sizeof remote6);
13339 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13341 if (unformat (line_input, "del"))
13343 else if (unformat (line_input, "local %U",
13344 unformat_ip4_address, &local4))
13349 else if (unformat (line_input, "remote %U",
13350 unformat_ip4_address, &remote4))
13355 else if (unformat (line_input, "local %U",
13356 unformat_ip6_address, &local6))
13361 else if (unformat (line_input, "remote %U",
13362 unformat_ip6_address, &remote6))
13367 else if (unformat (line_input, "group %U %U",
13368 unformat_ip4_address, &remote4,
13369 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13371 grp_set = remote_set = 1;
13374 else if (unformat (line_input, "group %U",
13375 unformat_ip4_address, &remote4))
13377 grp_set = remote_set = 1;
13380 else if (unformat (line_input, "group %U %U",
13381 unformat_ip6_address, &remote6,
13382 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13384 grp_set = remote_set = 1;
13387 else if (unformat (line_input, "group %U",
13388 unformat_ip6_address, &remote6))
13390 grp_set = remote_set = 1;
13394 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13396 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13398 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13400 else if (unformat (line_input, "vni %d", &vni))
13402 else if (unformat (line_input, "next-ip4"))
13404 else if (unformat (line_input, "next-ip6"))
13406 else if (unformat (line_input, "next-ethernet"))
13408 else if (unformat (line_input, "next-nsh"))
13412 errmsg ("parse error '%U'", format_unformat_error, line_input);
13417 if (local_set == 0)
13419 errmsg ("tunnel local address not specified");
13422 if (remote_set == 0)
13424 errmsg ("tunnel remote address not specified");
13427 if (grp_set && mcast_sw_if_index == ~0)
13429 errmsg ("tunnel nonexistent multicast device");
13432 if (ipv4_set && ipv6_set)
13434 errmsg ("both IPv4 and IPv6 addresses specified");
13440 errmsg ("vni not specified");
13444 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13449 clib_memcpy (&mp->local, &local6, sizeof (local6));
13450 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13454 clib_memcpy (&mp->local, &local4, sizeof (local4));
13455 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13458 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13459 mp->encap_vrf_id = ntohl (encap_vrf_id);
13460 mp->decap_vrf_id = ntohl (decap_vrf_id);
13461 mp->protocol = protocol;
13462 mp->vni = ntohl (vni);
13463 mp->is_add = is_add;
13464 mp->is_ipv6 = ipv6_set;
13471 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13472 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13474 vat_main_t *vam = &vat_main;
13475 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13476 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13478 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13479 ntohl (mp->sw_if_index),
13480 format_ip46_address, &local, IP46_TYPE_ANY,
13481 format_ip46_address, &remote, IP46_TYPE_ANY,
13482 ntohl (mp->vni), mp->protocol,
13483 ntohl (mp->mcast_sw_if_index),
13484 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13488 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13489 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13491 vat_main_t *vam = &vat_main;
13492 vat_json_node_t *node = NULL;
13493 struct in_addr ip4;
13494 struct in6_addr ip6;
13496 if (VAT_JSON_ARRAY != vam->json_tree.type)
13498 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13499 vat_json_init_array (&vam->json_tree);
13501 node = vat_json_array_add (&vam->json_tree);
13503 vat_json_init_object (node);
13504 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13507 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13508 vat_json_object_add_ip6 (node, "local", ip6);
13509 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13510 vat_json_object_add_ip6 (node, "remote", ip6);
13514 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13515 vat_json_object_add_ip4 (node, "local", ip4);
13516 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13517 vat_json_object_add_ip4 (node, "remote", ip4);
13519 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13520 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13521 vat_json_object_add_uint (node, "mcast_sw_if_index",
13522 ntohl (mp->mcast_sw_if_index));
13523 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13524 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13525 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13529 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13531 unformat_input_t *i = vam->input;
13532 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13533 vl_api_control_ping_t *mp_ping;
13535 u8 sw_if_index_set = 0;
13538 /* Parse args required to build the message */
13539 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13541 if (unformat (i, "sw_if_index %d", &sw_if_index))
13542 sw_if_index_set = 1;
13547 if (sw_if_index_set == 0)
13552 if (!vam->json_output)
13554 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13555 "sw_if_index", "local", "remote", "vni",
13556 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13559 /* Get list of vxlan-tunnel interfaces */
13560 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13562 mp->sw_if_index = htonl (sw_if_index);
13566 /* Use a control ping for synchronization */
13567 MPING (CONTROL_PING, mp_ping);
13574 static void vl_api_l2_fib_table_details_t_handler
13575 (vl_api_l2_fib_table_details_t * mp)
13577 vat_main_t *vam = &vat_main;
13579 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13581 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
13582 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13586 static void vl_api_l2_fib_table_details_t_handler_json
13587 (vl_api_l2_fib_table_details_t * mp)
13589 vat_main_t *vam = &vat_main;
13590 vat_json_node_t *node = NULL;
13592 if (VAT_JSON_ARRAY != vam->json_tree.type)
13594 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13595 vat_json_init_array (&vam->json_tree);
13597 node = vat_json_array_add (&vam->json_tree);
13599 vat_json_init_object (node);
13600 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13601 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
13602 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13603 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13604 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13605 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13609 api_l2_fib_table_dump (vat_main_t * vam)
13611 unformat_input_t *i = vam->input;
13612 vl_api_l2_fib_table_dump_t *mp;
13613 vl_api_control_ping_t *mp_ping;
13618 /* Parse args required to build the message */
13619 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13621 if (unformat (i, "bd_id %d", &bd_id))
13627 if (bd_id_set == 0)
13629 errmsg ("missing bridge domain");
13633 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13635 /* Get list of l2 fib entries */
13636 M (L2_FIB_TABLE_DUMP, mp);
13638 mp->bd_id = ntohl (bd_id);
13641 /* Use a control ping for synchronization */
13642 MPING (CONTROL_PING, mp_ping);
13651 api_interface_name_renumber (vat_main_t * vam)
13653 unformat_input_t *line_input = vam->input;
13654 vl_api_interface_name_renumber_t *mp;
13655 u32 sw_if_index = ~0;
13656 u32 new_show_dev_instance = ~0;
13659 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13661 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13664 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13666 else if (unformat (line_input, "new_show_dev_instance %d",
13667 &new_show_dev_instance))
13673 if (sw_if_index == ~0)
13675 errmsg ("missing interface name or sw_if_index");
13679 if (new_show_dev_instance == ~0)
13681 errmsg ("missing new_show_dev_instance");
13685 M (INTERFACE_NAME_RENUMBER, mp);
13687 mp->sw_if_index = ntohl (sw_if_index);
13688 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13696 api_want_ip4_arp_events (vat_main_t * vam)
13698 unformat_input_t *line_input = vam->input;
13699 vl_api_want_ip4_arp_events_t *mp;
13700 ip4_address_t address;
13701 int address_set = 0;
13702 u32 enable_disable = 1;
13705 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13707 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
13709 else if (unformat (line_input, "del"))
13710 enable_disable = 0;
13715 if (address_set == 0)
13717 errmsg ("missing addresses");
13721 M (WANT_IP4_ARP_EVENTS, mp);
13722 mp->enable_disable = enable_disable;
13723 mp->pid = htonl (getpid ());
13724 mp->address = address.as_u32;
13732 api_want_ip6_nd_events (vat_main_t * vam)
13734 unformat_input_t *line_input = vam->input;
13735 vl_api_want_ip6_nd_events_t *mp;
13736 ip6_address_t address;
13737 int address_set = 0;
13738 u32 enable_disable = 1;
13741 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13743 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
13745 else if (unformat (line_input, "del"))
13746 enable_disable = 0;
13751 if (address_set == 0)
13753 errmsg ("missing addresses");
13757 M (WANT_IP6_ND_EVENTS, mp);
13758 mp->enable_disable = enable_disable;
13759 mp->pid = htonl (getpid ());
13760 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
13768 api_want_l2_macs_events (vat_main_t * vam)
13770 unformat_input_t *line_input = vam->input;
13771 vl_api_want_l2_macs_events_t *mp;
13772 u8 enable_disable = 1;
13773 u32 scan_delay = 0;
13774 u32 max_macs_in_event = 0;
13775 u32 learn_limit = 0;
13778 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13780 if (unformat (line_input, "learn-limit %d", &learn_limit))
13782 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13784 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13786 else if (unformat (line_input, "disable"))
13787 enable_disable = 0;
13792 M (WANT_L2_MACS_EVENTS, mp);
13793 mp->enable_disable = enable_disable;
13794 mp->pid = htonl (getpid ());
13795 mp->learn_limit = htonl (learn_limit);
13796 mp->scan_delay = (u8) scan_delay;
13797 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13804 api_input_acl_set_interface (vat_main_t * vam)
13806 unformat_input_t *i = vam->input;
13807 vl_api_input_acl_set_interface_t *mp;
13809 int sw_if_index_set;
13810 u32 ip4_table_index = ~0;
13811 u32 ip6_table_index = ~0;
13812 u32 l2_table_index = ~0;
13816 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13818 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13819 sw_if_index_set = 1;
13820 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13821 sw_if_index_set = 1;
13822 else if (unformat (i, "del"))
13824 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13826 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13828 else if (unformat (i, "l2-table %d", &l2_table_index))
13832 clib_warning ("parse error '%U'", format_unformat_error, i);
13837 if (sw_if_index_set == 0)
13839 errmsg ("missing interface name or sw_if_index");
13843 M (INPUT_ACL_SET_INTERFACE, mp);
13845 mp->sw_if_index = ntohl (sw_if_index);
13846 mp->ip4_table_index = ntohl (ip4_table_index);
13847 mp->ip6_table_index = ntohl (ip6_table_index);
13848 mp->l2_table_index = ntohl (l2_table_index);
13849 mp->is_add = is_add;
13857 api_ip_address_dump (vat_main_t * vam)
13859 unformat_input_t *i = vam->input;
13860 vl_api_ip_address_dump_t *mp;
13861 vl_api_control_ping_t *mp_ping;
13862 u32 sw_if_index = ~0;
13863 u8 sw_if_index_set = 0;
13868 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13870 if (unformat (i, "sw_if_index %d", &sw_if_index))
13871 sw_if_index_set = 1;
13873 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13874 sw_if_index_set = 1;
13875 else if (unformat (i, "ipv4"))
13877 else if (unformat (i, "ipv6"))
13883 if (ipv4_set && ipv6_set)
13885 errmsg ("ipv4 and ipv6 flags cannot be both set");
13889 if ((!ipv4_set) && (!ipv6_set))
13891 errmsg ("no ipv4 nor ipv6 flag set");
13895 if (sw_if_index_set == 0)
13897 errmsg ("missing interface name or sw_if_index");
13901 vam->current_sw_if_index = sw_if_index;
13902 vam->is_ipv6 = ipv6_set;
13904 M (IP_ADDRESS_DUMP, mp);
13905 mp->sw_if_index = ntohl (sw_if_index);
13906 mp->is_ipv6 = ipv6_set;
13909 /* Use a control ping for synchronization */
13910 MPING (CONTROL_PING, mp_ping);
13918 api_ip_dump (vat_main_t * vam)
13920 vl_api_ip_dump_t *mp;
13921 vl_api_control_ping_t *mp_ping;
13922 unformat_input_t *in = vam->input;
13929 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13931 if (unformat (in, "ipv4"))
13933 else if (unformat (in, "ipv6"))
13939 if (ipv4_set && ipv6_set)
13941 errmsg ("ipv4 and ipv6 flags cannot be both set");
13945 if ((!ipv4_set) && (!ipv6_set))
13947 errmsg ("no ipv4 nor ipv6 flag set");
13951 is_ipv6 = ipv6_set;
13952 vam->is_ipv6 = is_ipv6;
13954 /* free old data */
13955 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13957 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13959 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13962 mp->is_ipv6 = ipv6_set;
13965 /* Use a control ping for synchronization */
13966 MPING (CONTROL_PING, mp_ping);
13974 api_ipsec_spd_add_del (vat_main_t * vam)
13976 unformat_input_t *i = vam->input;
13977 vl_api_ipsec_spd_add_del_t *mp;
13982 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13984 if (unformat (i, "spd_id %d", &spd_id))
13986 else if (unformat (i, "del"))
13990 clib_warning ("parse error '%U'", format_unformat_error, i);
13996 errmsg ("spd_id must be set");
14000 M (IPSEC_SPD_ADD_DEL, mp);
14002 mp->spd_id = ntohl (spd_id);
14003 mp->is_add = is_add;
14011 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14013 unformat_input_t *i = vam->input;
14014 vl_api_ipsec_interface_add_del_spd_t *mp;
14016 u8 sw_if_index_set = 0;
14017 u32 spd_id = (u32) ~ 0;
14021 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14023 if (unformat (i, "del"))
14025 else if (unformat (i, "spd_id %d", &spd_id))
14028 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14029 sw_if_index_set = 1;
14030 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14031 sw_if_index_set = 1;
14034 clib_warning ("parse error '%U'", format_unformat_error, i);
14040 if (spd_id == (u32) ~ 0)
14042 errmsg ("spd_id must be set");
14046 if (sw_if_index_set == 0)
14048 errmsg ("missing interface name or sw_if_index");
14052 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14054 mp->spd_id = ntohl (spd_id);
14055 mp->sw_if_index = ntohl (sw_if_index);
14056 mp->is_add = is_add;
14064 api_ipsec_spd_add_del_entry (vat_main_t * vam)
14066 unformat_input_t *i = vam->input;
14067 vl_api_ipsec_spd_add_del_entry_t *mp;
14068 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
14069 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14071 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14072 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14073 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
14074 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
14077 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
14078 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
14079 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
14080 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
14081 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
14082 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
14084 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14086 if (unformat (i, "del"))
14088 if (unformat (i, "outbound"))
14090 if (unformat (i, "inbound"))
14092 else if (unformat (i, "spd_id %d", &spd_id))
14094 else if (unformat (i, "sa_id %d", &sa_id))
14096 else if (unformat (i, "priority %d", &priority))
14098 else if (unformat (i, "protocol %d", &protocol))
14100 else if (unformat (i, "lport_start %d", &lport_start))
14102 else if (unformat (i, "lport_stop %d", &lport_stop))
14104 else if (unformat (i, "rport_start %d", &rport_start))
14106 else if (unformat (i, "rport_stop %d", &rport_stop))
14110 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
14116 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
14123 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
14129 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
14136 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
14142 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
14149 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
14155 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
14161 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14163 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14165 clib_warning ("unsupported action: 'resolve'");
14171 clib_warning ("parse error '%U'", format_unformat_error, i);
14177 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
14179 mp->spd_id = ntohl (spd_id);
14180 mp->priority = ntohl (priority);
14181 mp->is_outbound = is_outbound;
14183 mp->is_ipv6 = is_ipv6;
14184 if (is_ipv6 || is_ip_any)
14186 clib_memcpy (mp->remote_address_start, &raddr6_start,
14187 sizeof (ip6_address_t));
14188 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
14189 sizeof (ip6_address_t));
14190 clib_memcpy (mp->local_address_start, &laddr6_start,
14191 sizeof (ip6_address_t));
14192 clib_memcpy (mp->local_address_stop, &laddr6_stop,
14193 sizeof (ip6_address_t));
14197 clib_memcpy (mp->remote_address_start, &raddr4_start,
14198 sizeof (ip4_address_t));
14199 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
14200 sizeof (ip4_address_t));
14201 clib_memcpy (mp->local_address_start, &laddr4_start,
14202 sizeof (ip4_address_t));
14203 clib_memcpy (mp->local_address_stop, &laddr4_stop,
14204 sizeof (ip4_address_t));
14206 mp->protocol = (u8) protocol;
14207 mp->local_port_start = ntohs ((u16) lport_start);
14208 mp->local_port_stop = ntohs ((u16) lport_stop);
14209 mp->remote_port_start = ntohs ((u16) rport_start);
14210 mp->remote_port_stop = ntohs ((u16) rport_stop);
14211 mp->policy = (u8) policy;
14212 mp->sa_id = ntohl (sa_id);
14213 mp->is_add = is_add;
14214 mp->is_ip_any = is_ip_any;
14221 api_ipsec_sad_add_del_entry (vat_main_t * vam)
14223 unformat_input_t *i = vam->input;
14224 vl_api_ipsec_sad_add_del_entry_t *mp;
14225 u32 sad_id = 0, spi = 0;
14226 u8 *ck = 0, *ik = 0;
14229 u8 protocol = IPSEC_PROTOCOL_AH;
14230 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
14231 u32 crypto_alg = 0, integ_alg = 0;
14232 ip4_address_t tun_src4;
14233 ip4_address_t tun_dst4;
14234 ip6_address_t tun_src6;
14235 ip6_address_t tun_dst6;
14238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14240 if (unformat (i, "del"))
14242 else if (unformat (i, "sad_id %d", &sad_id))
14244 else if (unformat (i, "spi %d", &spi))
14246 else if (unformat (i, "esp"))
14247 protocol = IPSEC_PROTOCOL_ESP;
14248 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
14251 is_tunnel_ipv6 = 0;
14253 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
14256 is_tunnel_ipv6 = 0;
14258 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
14261 is_tunnel_ipv6 = 1;
14263 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
14266 is_tunnel_ipv6 = 1;
14270 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14272 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14273 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14275 clib_warning ("unsupported crypto-alg: '%U'",
14276 format_ipsec_crypto_alg, crypto_alg);
14280 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14284 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14286 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14287 integ_alg >= IPSEC_INTEG_N_ALG)
14289 clib_warning ("unsupported integ-alg: '%U'",
14290 format_ipsec_integ_alg, integ_alg);
14294 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14298 clib_warning ("parse error '%U'", format_unformat_error, i);
14304 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
14306 mp->sad_id = ntohl (sad_id);
14307 mp->is_add = is_add;
14308 mp->protocol = protocol;
14309 mp->spi = ntohl (spi);
14310 mp->is_tunnel = is_tunnel;
14311 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
14312 mp->crypto_algorithm = crypto_alg;
14313 mp->integrity_algorithm = integ_alg;
14314 mp->crypto_key_length = vec_len (ck);
14315 mp->integrity_key_length = vec_len (ik);
14317 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14318 mp->crypto_key_length = sizeof (mp->crypto_key);
14320 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14321 mp->integrity_key_length = sizeof (mp->integrity_key);
14324 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14326 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14330 if (is_tunnel_ipv6)
14332 clib_memcpy (mp->tunnel_src_address, &tun_src6,
14333 sizeof (ip6_address_t));
14334 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
14335 sizeof (ip6_address_t));
14339 clib_memcpy (mp->tunnel_src_address, &tun_src4,
14340 sizeof (ip4_address_t));
14341 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
14342 sizeof (ip4_address_t));
14352 api_ipsec_sa_set_key (vat_main_t * vam)
14354 unformat_input_t *i = vam->input;
14355 vl_api_ipsec_sa_set_key_t *mp;
14357 u8 *ck = 0, *ik = 0;
14360 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14362 if (unformat (i, "sa_id %d", &sa_id))
14364 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14366 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14370 clib_warning ("parse error '%U'", format_unformat_error, i);
14375 M (IPSEC_SA_SET_KEY, mp);
14377 mp->sa_id = ntohl (sa_id);
14378 mp->crypto_key_length = vec_len (ck);
14379 mp->integrity_key_length = vec_len (ik);
14381 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14382 mp->crypto_key_length = sizeof (mp->crypto_key);
14384 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14385 mp->integrity_key_length = sizeof (mp->integrity_key);
14388 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14390 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14398 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14400 unformat_input_t *i = vam->input;
14401 vl_api_ipsec_tunnel_if_add_del_t *mp;
14402 u32 local_spi = 0, remote_spi = 0;
14403 u32 crypto_alg = 0, integ_alg = 0;
14404 u8 *lck = NULL, *rck = NULL;
14405 u8 *lik = NULL, *rik = NULL;
14406 ip4_address_t local_ip = { {0} };
14407 ip4_address_t remote_ip = { {0} };
14410 u8 anti_replay = 0;
14413 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14415 if (unformat (i, "del"))
14417 else if (unformat (i, "esn"))
14419 else if (unformat (i, "anti_replay"))
14421 else if (unformat (i, "local_spi %d", &local_spi))
14423 else if (unformat (i, "remote_spi %d", &remote_spi))
14425 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
14427 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
14429 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14432 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14434 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14436 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14440 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14442 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14443 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14445 errmsg ("unsupported crypto-alg: '%U'\n",
14446 format_ipsec_crypto_alg, crypto_alg);
14452 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14454 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14455 integ_alg >= IPSEC_INTEG_N_ALG)
14457 errmsg ("unsupported integ-alg: '%U'\n",
14458 format_ipsec_integ_alg, integ_alg);
14464 errmsg ("parse error '%U'\n", format_unformat_error, i);
14469 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14471 mp->is_add = is_add;
14473 mp->anti_replay = anti_replay;
14475 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
14476 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
14478 mp->local_spi = htonl (local_spi);
14479 mp->remote_spi = htonl (remote_spi);
14480 mp->crypto_alg = (u8) crypto_alg;
14482 mp->local_crypto_key_len = 0;
14485 mp->local_crypto_key_len = vec_len (lck);
14486 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14487 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14488 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14491 mp->remote_crypto_key_len = 0;
14494 mp->remote_crypto_key_len = vec_len (rck);
14495 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14496 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14497 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14500 mp->integ_alg = (u8) integ_alg;
14502 mp->local_integ_key_len = 0;
14505 mp->local_integ_key_len = vec_len (lik);
14506 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14507 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14508 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14511 mp->remote_integ_key_len = 0;
14514 mp->remote_integ_key_len = vec_len (rik);
14515 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14516 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14517 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14526 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14528 vat_main_t *vam = &vat_main;
14530 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14531 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
14532 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
14533 "tunnel_src_addr %U tunnel_dst_addr %U "
14534 "salt %u seq_outbound %lu last_seq_inbound %lu "
14535 "replay_window %lu total_data_size %lu\n",
14536 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
14538 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
14539 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
14540 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
14541 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14542 mp->tunnel_src_addr,
14543 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14544 mp->tunnel_dst_addr,
14546 clib_net_to_host_u64 (mp->seq_outbound),
14547 clib_net_to_host_u64 (mp->last_seq_inbound),
14548 clib_net_to_host_u64 (mp->replay_window),
14549 clib_net_to_host_u64 (mp->total_data_size));
14552 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14553 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14555 static void vl_api_ipsec_sa_details_t_handler_json
14556 (vl_api_ipsec_sa_details_t * mp)
14558 vat_main_t *vam = &vat_main;
14559 vat_json_node_t *node = NULL;
14560 struct in_addr src_ip4, dst_ip4;
14561 struct in6_addr src_ip6, dst_ip6;
14563 if (VAT_JSON_ARRAY != vam->json_tree.type)
14565 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14566 vat_json_init_array (&vam->json_tree);
14568 node = vat_json_array_add (&vam->json_tree);
14570 vat_json_init_object (node);
14571 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
14572 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14573 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
14574 vat_json_object_add_uint (node, "proto", mp->protocol);
14575 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
14576 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
14577 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
14578 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
14579 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
14580 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
14581 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
14582 mp->crypto_key_len);
14583 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
14584 mp->integ_key_len);
14585 if (mp->is_tunnel_ip6)
14587 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
14588 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
14589 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
14590 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
14594 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
14595 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
14596 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
14597 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
14599 vat_json_object_add_uint (node, "replay_window",
14600 clib_net_to_host_u64 (mp->replay_window));
14601 vat_json_object_add_uint (node, "total_data_size",
14602 clib_net_to_host_u64 (mp->total_data_size));
14607 api_ipsec_sa_dump (vat_main_t * vam)
14609 unformat_input_t *i = vam->input;
14610 vl_api_ipsec_sa_dump_t *mp;
14611 vl_api_control_ping_t *mp_ping;
14615 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14617 if (unformat (i, "sa_id %d", &sa_id))
14621 clib_warning ("parse error '%U'", format_unformat_error, i);
14626 M (IPSEC_SA_DUMP, mp);
14628 mp->sa_id = ntohl (sa_id);
14632 /* Use a control ping for synchronization */
14633 M (CONTROL_PING, mp_ping);
14641 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
14643 unformat_input_t *i = vam->input;
14644 vl_api_ipsec_tunnel_if_set_key_t *mp;
14645 u32 sw_if_index = ~0;
14646 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
14651 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14653 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14656 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
14657 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
14659 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
14660 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
14661 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
14662 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
14664 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
14665 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
14666 else if (unformat (i, "%U", unformat_hex_string, &key))
14670 clib_warning ("parse error '%U'", format_unformat_error, i);
14675 if (sw_if_index == ~0)
14677 errmsg ("interface must be specified");
14681 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
14683 errmsg ("key type must be specified");
14689 errmsg ("algorithm must be specified");
14693 if (vec_len (key) == 0)
14695 errmsg ("key must be specified");
14699 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
14701 mp->sw_if_index = htonl (sw_if_index);
14703 mp->key_type = key_type;
14704 mp->key_len = vec_len (key);
14705 clib_memcpy (mp->key, key, vec_len (key));
14714 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
14716 unformat_input_t *i = vam->input;
14717 vl_api_ipsec_tunnel_if_set_sa_t *mp;
14718 u32 sw_if_index = ~0;
14720 u8 is_outbound = (u8) ~ 0;
14723 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14725 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14727 else if (unformat (i, "sa_id %d", &sa_id))
14729 else if (unformat (i, "outbound"))
14731 else if (unformat (i, "inbound"))
14735 clib_warning ("parse error '%U'", format_unformat_error, i);
14740 if (sw_if_index == ~0)
14742 errmsg ("interface must be specified");
14748 errmsg ("SA ID must be specified");
14752 M (IPSEC_TUNNEL_IF_SET_SA, mp);
14754 mp->sw_if_index = htonl (sw_if_index);
14755 mp->sa_id = htonl (sa_id);
14756 mp->is_outbound = is_outbound;
14765 api_ikev2_profile_add_del (vat_main_t * vam)
14767 unformat_input_t *i = vam->input;
14768 vl_api_ikev2_profile_add_del_t *mp;
14773 const char *valid_chars = "a-zA-Z0-9_";
14775 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14777 if (unformat (i, "del"))
14779 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14780 vec_add1 (name, 0);
14783 errmsg ("parse error '%U'", format_unformat_error, i);
14788 if (!vec_len (name))
14790 errmsg ("profile name must be specified");
14794 if (vec_len (name) > 64)
14796 errmsg ("profile name too long");
14800 M (IKEV2_PROFILE_ADD_DEL, mp);
14802 clib_memcpy (mp->name, name, vec_len (name));
14803 mp->is_add = is_add;
14812 api_ikev2_profile_set_auth (vat_main_t * vam)
14814 unformat_input_t *i = vam->input;
14815 vl_api_ikev2_profile_set_auth_t *mp;
14818 u32 auth_method = 0;
14822 const char *valid_chars = "a-zA-Z0-9_";
14824 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14826 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14827 vec_add1 (name, 0);
14828 else if (unformat (i, "auth_method %U",
14829 unformat_ikev2_auth_method, &auth_method))
14831 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
14833 else if (unformat (i, "auth_data %v", &data))
14837 errmsg ("parse error '%U'", format_unformat_error, i);
14842 if (!vec_len (name))
14844 errmsg ("profile name must be specified");
14848 if (vec_len (name) > 64)
14850 errmsg ("profile name too long");
14854 if (!vec_len (data))
14856 errmsg ("auth_data must be specified");
14862 errmsg ("auth_method must be specified");
14866 M (IKEV2_PROFILE_SET_AUTH, mp);
14868 mp->is_hex = is_hex;
14869 mp->auth_method = (u8) auth_method;
14870 mp->data_len = vec_len (data);
14871 clib_memcpy (mp->name, name, vec_len (name));
14872 clib_memcpy (mp->data, data, vec_len (data));
14882 api_ikev2_profile_set_id (vat_main_t * vam)
14884 unformat_input_t *i = vam->input;
14885 vl_api_ikev2_profile_set_id_t *mp;
14893 const char *valid_chars = "a-zA-Z0-9_";
14895 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14897 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14898 vec_add1 (name, 0);
14899 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
14901 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
14903 data = vec_new (u8, 4);
14904 clib_memcpy (data, ip4.as_u8, 4);
14906 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
14908 else if (unformat (i, "id_data %v", &data))
14910 else if (unformat (i, "local"))
14912 else if (unformat (i, "remote"))
14916 errmsg ("parse error '%U'", format_unformat_error, i);
14921 if (!vec_len (name))
14923 errmsg ("profile name must be specified");
14927 if (vec_len (name) > 64)
14929 errmsg ("profile name too long");
14933 if (!vec_len (data))
14935 errmsg ("id_data must be specified");
14941 errmsg ("id_type must be specified");
14945 M (IKEV2_PROFILE_SET_ID, mp);
14947 mp->is_local = is_local;
14948 mp->id_type = (u8) id_type;
14949 mp->data_len = vec_len (data);
14950 clib_memcpy (mp->name, name, vec_len (name));
14951 clib_memcpy (mp->data, data, vec_len (data));
14961 api_ikev2_profile_set_ts (vat_main_t * vam)
14963 unformat_input_t *i = vam->input;
14964 vl_api_ikev2_profile_set_ts_t *mp;
14967 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
14968 ip4_address_t start_addr, end_addr;
14970 const char *valid_chars = "a-zA-Z0-9_";
14973 start_addr.as_u32 = 0;
14974 end_addr.as_u32 = (u32) ~ 0;
14976 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14978 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14979 vec_add1 (name, 0);
14980 else if (unformat (i, "protocol %d", &proto))
14982 else if (unformat (i, "start_port %d", &start_port))
14984 else if (unformat (i, "end_port %d", &end_port))
14987 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
14989 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
14991 else if (unformat (i, "local"))
14993 else if (unformat (i, "remote"))
14997 errmsg ("parse error '%U'", format_unformat_error, i);
15002 if (!vec_len (name))
15004 errmsg ("profile name must be specified");
15008 if (vec_len (name) > 64)
15010 errmsg ("profile name too long");
15014 M (IKEV2_PROFILE_SET_TS, mp);
15016 mp->is_local = is_local;
15017 mp->proto = (u8) proto;
15018 mp->start_port = (u16) start_port;
15019 mp->end_port = (u16) end_port;
15020 mp->start_addr = start_addr.as_u32;
15021 mp->end_addr = end_addr.as_u32;
15022 clib_memcpy (mp->name, name, vec_len (name));
15031 api_ikev2_set_local_key (vat_main_t * vam)
15033 unformat_input_t *i = vam->input;
15034 vl_api_ikev2_set_local_key_t *mp;
15038 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15040 if (unformat (i, "file %v", &file))
15041 vec_add1 (file, 0);
15044 errmsg ("parse error '%U'", format_unformat_error, i);
15049 if (!vec_len (file))
15051 errmsg ("RSA key file must be specified");
15055 if (vec_len (file) > 256)
15057 errmsg ("file name too long");
15061 M (IKEV2_SET_LOCAL_KEY, mp);
15063 clib_memcpy (mp->key_file, file, vec_len (file));
15072 api_ikev2_set_responder (vat_main_t * vam)
15074 unformat_input_t *i = vam->input;
15075 vl_api_ikev2_set_responder_t *mp;
15078 u32 sw_if_index = ~0;
15079 ip4_address_t address;
15081 const char *valid_chars = "a-zA-Z0-9_";
15083 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15086 (i, "%U interface %d address %U", unformat_token, valid_chars,
15087 &name, &sw_if_index, unformat_ip4_address, &address))
15088 vec_add1 (name, 0);
15091 errmsg ("parse error '%U'", format_unformat_error, i);
15096 if (!vec_len (name))
15098 errmsg ("profile name must be specified");
15102 if (vec_len (name) > 64)
15104 errmsg ("profile name too long");
15108 M (IKEV2_SET_RESPONDER, mp);
15110 clib_memcpy (mp->name, name, vec_len (name));
15113 mp->sw_if_index = sw_if_index;
15114 clib_memcpy (mp->address, &address, sizeof (address));
15122 api_ikev2_set_ike_transforms (vat_main_t * vam)
15124 unformat_input_t *i = vam->input;
15125 vl_api_ikev2_set_ike_transforms_t *mp;
15128 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15130 const char *valid_chars = "a-zA-Z0-9_";
15132 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15134 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15135 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15136 vec_add1 (name, 0);
15139 errmsg ("parse error '%U'", format_unformat_error, i);
15144 if (!vec_len (name))
15146 errmsg ("profile name must be specified");
15150 if (vec_len (name) > 64)
15152 errmsg ("profile name too long");
15156 M (IKEV2_SET_IKE_TRANSFORMS, mp);
15158 clib_memcpy (mp->name, name, vec_len (name));
15160 mp->crypto_alg = crypto_alg;
15161 mp->crypto_key_size = crypto_key_size;
15162 mp->integ_alg = integ_alg;
15163 mp->dh_group = dh_group;
15172 api_ikev2_set_esp_transforms (vat_main_t * vam)
15174 unformat_input_t *i = vam->input;
15175 vl_api_ikev2_set_esp_transforms_t *mp;
15178 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15180 const char *valid_chars = "a-zA-Z0-9_";
15182 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15184 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15185 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15186 vec_add1 (name, 0);
15189 errmsg ("parse error '%U'", format_unformat_error, i);
15194 if (!vec_len (name))
15196 errmsg ("profile name must be specified");
15200 if (vec_len (name) > 64)
15202 errmsg ("profile name too long");
15206 M (IKEV2_SET_ESP_TRANSFORMS, mp);
15208 clib_memcpy (mp->name, name, vec_len (name));
15210 mp->crypto_alg = crypto_alg;
15211 mp->crypto_key_size = crypto_key_size;
15212 mp->integ_alg = integ_alg;
15213 mp->dh_group = dh_group;
15221 api_ikev2_set_sa_lifetime (vat_main_t * vam)
15223 unformat_input_t *i = vam->input;
15224 vl_api_ikev2_set_sa_lifetime_t *mp;
15227 u64 lifetime, lifetime_maxdata;
15228 u32 lifetime_jitter, handover;
15230 const char *valid_chars = "a-zA-Z0-9_";
15232 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15234 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
15235 &lifetime, &lifetime_jitter, &handover,
15236 &lifetime_maxdata))
15237 vec_add1 (name, 0);
15240 errmsg ("parse error '%U'", format_unformat_error, i);
15245 if (!vec_len (name))
15247 errmsg ("profile name must be specified");
15251 if (vec_len (name) > 64)
15253 errmsg ("profile name too long");
15257 M (IKEV2_SET_SA_LIFETIME, mp);
15259 clib_memcpy (mp->name, name, vec_len (name));
15261 mp->lifetime = lifetime;
15262 mp->lifetime_jitter = lifetime_jitter;
15263 mp->handover = handover;
15264 mp->lifetime_maxdata = lifetime_maxdata;
15272 api_ikev2_initiate_sa_init (vat_main_t * vam)
15274 unformat_input_t *i = vam->input;
15275 vl_api_ikev2_initiate_sa_init_t *mp;
15279 const char *valid_chars = "a-zA-Z0-9_";
15281 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15283 if (unformat (i, "%U", unformat_token, valid_chars, &name))
15284 vec_add1 (name, 0);
15287 errmsg ("parse error '%U'", format_unformat_error, i);
15292 if (!vec_len (name))
15294 errmsg ("profile name must be specified");
15298 if (vec_len (name) > 64)
15300 errmsg ("profile name too long");
15304 M (IKEV2_INITIATE_SA_INIT, mp);
15306 clib_memcpy (mp->name, name, vec_len (name));
15315 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
15317 unformat_input_t *i = vam->input;
15318 vl_api_ikev2_initiate_del_ike_sa_t *mp;
15323 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15325 if (unformat (i, "%lx", &ispi))
15329 errmsg ("parse error '%U'", format_unformat_error, i);
15334 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
15344 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
15346 unformat_input_t *i = vam->input;
15347 vl_api_ikev2_initiate_del_child_sa_t *mp;
15352 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15354 if (unformat (i, "%x", &ispi))
15358 errmsg ("parse error '%U'", format_unformat_error, i);
15363 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
15373 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
15375 unformat_input_t *i = vam->input;
15376 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
15381 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15383 if (unformat (i, "%x", &ispi))
15387 errmsg ("parse error '%U'", format_unformat_error, i);
15392 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
15405 api_map_add_domain (vat_main_t * vam)
15407 unformat_input_t *i = vam->input;
15408 vl_api_map_add_domain_t *mp;
15410 ip4_address_t ip4_prefix;
15411 ip6_address_t ip6_prefix;
15412 ip6_address_t ip6_src;
15413 u32 num_m_args = 0;
15414 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
15415 0, psid_length = 0;
15416 u8 is_translation = 0;
15418 u32 ip6_src_len = 128;
15421 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15423 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
15424 &ip4_prefix, &ip4_prefix_len))
15426 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
15427 &ip6_prefix, &ip6_prefix_len))
15431 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
15434 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
15436 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
15438 else if (unformat (i, "psid-offset %d", &psid_offset))
15440 else if (unformat (i, "psid-len %d", &psid_length))
15442 else if (unformat (i, "mtu %d", &mtu))
15444 else if (unformat (i, "map-t"))
15445 is_translation = 1;
15448 clib_warning ("parse error '%U'", format_unformat_error, i);
15453 if (num_m_args < 3)
15455 errmsg ("mandatory argument(s) missing");
15459 /* Construct the API message */
15460 M (MAP_ADD_DOMAIN, mp);
15462 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
15463 mp->ip4_prefix_len = ip4_prefix_len;
15465 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
15466 mp->ip6_prefix_len = ip6_prefix_len;
15468 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
15469 mp->ip6_src_prefix_len = ip6_src_len;
15471 mp->ea_bits_len = ea_bits_len;
15472 mp->psid_offset = psid_offset;
15473 mp->psid_length = psid_length;
15474 mp->is_translation = is_translation;
15475 mp->mtu = htons (mtu);
15480 /* Wait for a reply, return good/bad news */
15486 api_map_del_domain (vat_main_t * vam)
15488 unformat_input_t *i = vam->input;
15489 vl_api_map_del_domain_t *mp;
15491 u32 num_m_args = 0;
15495 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15497 if (unformat (i, "index %d", &index))
15501 clib_warning ("parse error '%U'", format_unformat_error, i);
15506 if (num_m_args != 1)
15508 errmsg ("mandatory argument(s) missing");
15512 /* Construct the API message */
15513 M (MAP_DEL_DOMAIN, mp);
15515 mp->index = ntohl (index);
15520 /* Wait for a reply, return good/bad news */
15526 api_map_add_del_rule (vat_main_t * vam)
15528 unformat_input_t *i = vam->input;
15529 vl_api_map_add_del_rule_t *mp;
15531 ip6_address_t ip6_dst;
15532 u32 num_m_args = 0, index, psid = 0;
15535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15537 if (unformat (i, "index %d", &index))
15539 else if (unformat (i, "psid %d", &psid))
15541 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
15543 else if (unformat (i, "del"))
15549 clib_warning ("parse error '%U'", format_unformat_error, i);
15554 /* Construct the API message */
15555 M (MAP_ADD_DEL_RULE, mp);
15557 mp->index = ntohl (index);
15558 mp->is_add = is_add;
15559 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
15560 mp->psid = ntohs (psid);
15565 /* Wait for a reply, return good/bad news */
15571 api_map_domain_dump (vat_main_t * vam)
15573 vl_api_map_domain_dump_t *mp;
15574 vl_api_control_ping_t *mp_ping;
15577 /* Construct the API message */
15578 M (MAP_DOMAIN_DUMP, mp);
15583 /* Use a control ping for synchronization */
15584 MPING (CONTROL_PING, mp_ping);
15592 api_map_rule_dump (vat_main_t * vam)
15594 unformat_input_t *i = vam->input;
15595 vl_api_map_rule_dump_t *mp;
15596 vl_api_control_ping_t *mp_ping;
15597 u32 domain_index = ~0;
15600 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15602 if (unformat (i, "index %u", &domain_index))
15608 if (domain_index == ~0)
15610 clib_warning ("parse error: domain index expected");
15614 /* Construct the API message */
15615 M (MAP_RULE_DUMP, mp);
15617 mp->domain_index = htonl (domain_index);
15622 /* Use a control ping for synchronization */
15623 MPING (CONTROL_PING, mp_ping);
15630 static void vl_api_map_add_domain_reply_t_handler
15631 (vl_api_map_add_domain_reply_t * mp)
15633 vat_main_t *vam = &vat_main;
15634 i32 retval = ntohl (mp->retval);
15636 if (vam->async_mode)
15638 vam->async_errors += (retval < 0);
15642 vam->retval = retval;
15643 vam->result_ready = 1;
15647 static void vl_api_map_add_domain_reply_t_handler_json
15648 (vl_api_map_add_domain_reply_t * mp)
15650 vat_main_t *vam = &vat_main;
15651 vat_json_node_t node;
15653 vat_json_init_object (&node);
15654 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
15655 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
15657 vat_json_print (vam->ofp, &node);
15658 vat_json_free (&node);
15660 vam->retval = ntohl (mp->retval);
15661 vam->result_ready = 1;
15665 api_get_first_msg_id (vat_main_t * vam)
15667 vl_api_get_first_msg_id_t *mp;
15668 unformat_input_t *i = vam->input;
15673 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15675 if (unformat (i, "client %s", &name))
15683 errmsg ("missing client name");
15686 vec_add1 (name, 0);
15688 if (vec_len (name) > 63)
15690 errmsg ("client name too long");
15694 M (GET_FIRST_MSG_ID, mp);
15695 clib_memcpy (mp->name, name, vec_len (name));
15702 api_cop_interface_enable_disable (vat_main_t * vam)
15704 unformat_input_t *line_input = vam->input;
15705 vl_api_cop_interface_enable_disable_t *mp;
15706 u32 sw_if_index = ~0;
15707 u8 enable_disable = 1;
15710 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15712 if (unformat (line_input, "disable"))
15713 enable_disable = 0;
15714 if (unformat (line_input, "enable"))
15715 enable_disable = 1;
15716 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15717 vam, &sw_if_index))
15719 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15725 if (sw_if_index == ~0)
15727 errmsg ("missing interface name or sw_if_index");
15731 /* Construct the API message */
15732 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15733 mp->sw_if_index = ntohl (sw_if_index);
15734 mp->enable_disable = enable_disable;
15738 /* Wait for the reply */
15744 api_cop_whitelist_enable_disable (vat_main_t * vam)
15746 unformat_input_t *line_input = vam->input;
15747 vl_api_cop_whitelist_enable_disable_t *mp;
15748 u32 sw_if_index = ~0;
15749 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15753 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15755 if (unformat (line_input, "ip4"))
15757 else if (unformat (line_input, "ip6"))
15759 else if (unformat (line_input, "default"))
15761 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15762 vam, &sw_if_index))
15764 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15766 else if (unformat (line_input, "fib-id %d", &fib_id))
15772 if (sw_if_index == ~0)
15774 errmsg ("missing interface name or sw_if_index");
15778 /* Construct the API message */
15779 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15780 mp->sw_if_index = ntohl (sw_if_index);
15781 mp->fib_id = ntohl (fib_id);
15784 mp->default_cop = default_cop;
15788 /* Wait for the reply */
15794 api_get_node_graph (vat_main_t * vam)
15796 vl_api_get_node_graph_t *mp;
15799 M (GET_NODE_GRAPH, mp);
15803 /* Wait for the reply */
15809 /** Used for parsing LISP eids */
15810 typedef CLIB_PACKED(struct{
15811 u8 addr[16]; /**< eid address */
15812 u32 len; /**< prefix length if IP */
15813 u8 type; /**< type of eid */
15818 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15820 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15822 memset (a, 0, sizeof (a[0]));
15824 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15826 a->type = 0; /* ipv4 type */
15828 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15830 a->type = 1; /* ipv6 type */
15832 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15834 a->type = 2; /* mac type */
15836 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15838 a->type = 3; /* NSH type */
15839 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15840 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15847 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15856 lisp_eid_size_vat (u8 type)
15873 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15875 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15879 api_one_add_del_locator_set (vat_main_t * vam)
15881 unformat_input_t *input = vam->input;
15882 vl_api_one_add_del_locator_set_t *mp;
15884 u8 *locator_set_name = NULL;
15885 u8 locator_set_name_set = 0;
15886 vl_api_local_locator_t locator, *locators = 0;
15887 u32 sw_if_index, priority, weight;
15891 /* Parse args required to build the message */
15892 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15894 if (unformat (input, "del"))
15898 else if (unformat (input, "locator-set %s", &locator_set_name))
15900 locator_set_name_set = 1;
15902 else if (unformat (input, "sw_if_index %u p %u w %u",
15903 &sw_if_index, &priority, &weight))
15905 locator.sw_if_index = htonl (sw_if_index);
15906 locator.priority = priority;
15907 locator.weight = weight;
15908 vec_add1 (locators, locator);
15912 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15913 &sw_if_index, &priority, &weight))
15915 locator.sw_if_index = htonl (sw_if_index);
15916 locator.priority = priority;
15917 locator.weight = weight;
15918 vec_add1 (locators, locator);
15924 if (locator_set_name_set == 0)
15926 errmsg ("missing locator-set name");
15927 vec_free (locators);
15931 if (vec_len (locator_set_name) > 64)
15933 errmsg ("locator-set name too long");
15934 vec_free (locator_set_name);
15935 vec_free (locators);
15938 vec_add1 (locator_set_name, 0);
15940 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15942 /* Construct the API message */
15943 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15945 mp->is_add = is_add;
15946 clib_memcpy (mp->locator_set_name, locator_set_name,
15947 vec_len (locator_set_name));
15948 vec_free (locator_set_name);
15950 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15952 clib_memcpy (mp->locators, locators, data_len);
15953 vec_free (locators);
15958 /* Wait for a reply... */
15963 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15966 api_one_add_del_locator (vat_main_t * vam)
15968 unformat_input_t *input = vam->input;
15969 vl_api_one_add_del_locator_t *mp;
15970 u32 tmp_if_index = ~0;
15971 u32 sw_if_index = ~0;
15972 u8 sw_if_index_set = 0;
15973 u8 sw_if_index_if_name_set = 0;
15975 u8 priority_set = 0;
15979 u8 *locator_set_name = NULL;
15980 u8 locator_set_name_set = 0;
15983 /* Parse args required to build the message */
15984 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15986 if (unformat (input, "del"))
15990 else if (unformat (input, "locator-set %s", &locator_set_name))
15992 locator_set_name_set = 1;
15994 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15997 sw_if_index_if_name_set = 1;
15998 sw_if_index = tmp_if_index;
16000 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
16002 sw_if_index_set = 1;
16003 sw_if_index = tmp_if_index;
16005 else if (unformat (input, "p %d", &priority))
16009 else if (unformat (input, "w %d", &weight))
16017 if (locator_set_name_set == 0)
16019 errmsg ("missing locator-set name");
16023 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16025 errmsg ("missing sw_if_index");
16026 vec_free (locator_set_name);
16030 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
16032 errmsg ("cannot use both params interface name and sw_if_index");
16033 vec_free (locator_set_name);
16037 if (priority_set == 0)
16039 errmsg ("missing locator-set priority");
16040 vec_free (locator_set_name);
16044 if (weight_set == 0)
16046 errmsg ("missing locator-set weight");
16047 vec_free (locator_set_name);
16051 if (vec_len (locator_set_name) > 64)
16053 errmsg ("locator-set name too long");
16054 vec_free (locator_set_name);
16057 vec_add1 (locator_set_name, 0);
16059 /* Construct the API message */
16060 M (ONE_ADD_DEL_LOCATOR, mp);
16062 mp->is_add = is_add;
16063 mp->sw_if_index = ntohl (sw_if_index);
16064 mp->priority = priority;
16065 mp->weight = weight;
16066 clib_memcpy (mp->locator_set_name, locator_set_name,
16067 vec_len (locator_set_name));
16068 vec_free (locator_set_name);
16073 /* Wait for a reply... */
16078 #define api_lisp_add_del_locator api_one_add_del_locator
16081 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
16083 u32 *key_id = va_arg (*args, u32 *);
16086 if (unformat (input, "%s", &s))
16088 if (!strcmp ((char *) s, "sha1"))
16089 key_id[0] = HMAC_SHA_1_96;
16090 else if (!strcmp ((char *) s, "sha256"))
16091 key_id[0] = HMAC_SHA_256_128;
16094 clib_warning ("invalid key_id: '%s'", s);
16095 key_id[0] = HMAC_NO_KEY;
16106 api_one_add_del_local_eid (vat_main_t * vam)
16108 unformat_input_t *input = vam->input;
16109 vl_api_one_add_del_local_eid_t *mp;
16112 lisp_eid_vat_t _eid, *eid = &_eid;
16113 u8 *locator_set_name = 0;
16114 u8 locator_set_name_set = 0;
16120 /* Parse args required to build the message */
16121 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16123 if (unformat (input, "del"))
16127 else if (unformat (input, "vni %d", &vni))
16131 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16135 else if (unformat (input, "locator-set %s", &locator_set_name))
16137 locator_set_name_set = 1;
16139 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
16141 else if (unformat (input, "secret-key %_%v%_", &key))
16147 if (locator_set_name_set == 0)
16149 errmsg ("missing locator-set name");
16155 errmsg ("EID address not set!");
16156 vec_free (locator_set_name);
16160 if (key && (0 == key_id))
16162 errmsg ("invalid key_id!");
16166 if (vec_len (key) > 64)
16168 errmsg ("key too long");
16173 if (vec_len (locator_set_name) > 64)
16175 errmsg ("locator-set name too long");
16176 vec_free (locator_set_name);
16179 vec_add1 (locator_set_name, 0);
16181 /* Construct the API message */
16182 M (ONE_ADD_DEL_LOCAL_EID, mp);
16184 mp->is_add = is_add;
16185 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16186 mp->eid_type = eid->type;
16187 mp->prefix_len = eid->len;
16188 mp->vni = clib_host_to_net_u32 (vni);
16189 mp->key_id = clib_host_to_net_u16 (key_id);
16190 clib_memcpy (mp->locator_set_name, locator_set_name,
16191 vec_len (locator_set_name));
16192 clib_memcpy (mp->key, key, vec_len (key));
16194 vec_free (locator_set_name);
16200 /* Wait for a reply... */
16205 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
16208 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
16210 u32 dp_table = 0, vni = 0;;
16211 unformat_input_t *input = vam->input;
16212 vl_api_gpe_add_del_fwd_entry_t *mp;
16214 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
16215 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
16216 u8 rmt_eid_set = 0, lcl_eid_set = 0;
16217 u32 action = ~0, w;
16218 ip4_address_t rmt_rloc4, lcl_rloc4;
16219 ip6_address_t rmt_rloc6, lcl_rloc6;
16220 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
16223 memset (&rloc, 0, sizeof (rloc));
16225 /* Parse args required to build the message */
16226 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16228 if (unformat (input, "del"))
16230 else if (unformat (input, "add"))
16232 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
16236 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
16240 else if (unformat (input, "vrf %d", &dp_table))
16242 else if (unformat (input, "bd %d", &dp_table))
16244 else if (unformat (input, "vni %d", &vni))
16246 else if (unformat (input, "w %d", &w))
16250 errmsg ("No RLOC configured for setting priority/weight!");
16253 curr_rloc->weight = w;
16255 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
16256 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
16260 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
16262 vec_add1 (lcl_locs, rloc);
16264 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
16265 vec_add1 (rmt_locs, rloc);
16266 /* weight saved in rmt loc */
16267 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16269 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
16270 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
16273 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
16275 vec_add1 (lcl_locs, rloc);
16277 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
16278 vec_add1 (rmt_locs, rloc);
16279 /* weight saved in rmt loc */
16280 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16282 else if (unformat (input, "action %d", &action))
16288 clib_warning ("parse error '%U'", format_unformat_error, input);
16295 errmsg ("remote eid addresses not set");
16299 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
16301 errmsg ("eid types don't match");
16305 if (0 == rmt_locs && (u32) ~ 0 == action)
16307 errmsg ("action not set for negative mapping");
16311 /* Construct the API message */
16312 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
16313 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
16315 mp->is_add = is_add;
16316 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
16317 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
16318 mp->eid_type = rmt_eid->type;
16319 mp->dp_table = clib_host_to_net_u32 (dp_table);
16320 mp->vni = clib_host_to_net_u32 (vni);
16321 mp->rmt_len = rmt_eid->len;
16322 mp->lcl_len = lcl_eid->len;
16323 mp->action = action;
16325 if (0 != rmt_locs && 0 != lcl_locs)
16327 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
16328 clib_memcpy (mp->locs, lcl_locs,
16329 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
16331 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
16332 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
16333 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
16335 vec_free (lcl_locs);
16336 vec_free (rmt_locs);
16341 /* Wait for a reply... */
16347 api_one_add_del_map_server (vat_main_t * vam)
16349 unformat_input_t *input = vam->input;
16350 vl_api_one_add_del_map_server_t *mp;
16354 ip4_address_t ipv4;
16355 ip6_address_t ipv6;
16358 /* Parse args required to build the message */
16359 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16361 if (unformat (input, "del"))
16365 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16369 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16377 if (ipv4_set && ipv6_set)
16379 errmsg ("both eid v4 and v6 addresses set");
16383 if (!ipv4_set && !ipv6_set)
16385 errmsg ("eid addresses not set");
16389 /* Construct the API message */
16390 M (ONE_ADD_DEL_MAP_SERVER, mp);
16392 mp->is_add = is_add;
16396 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16401 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16407 /* Wait for a reply... */
16412 #define api_lisp_add_del_map_server api_one_add_del_map_server
16415 api_one_add_del_map_resolver (vat_main_t * vam)
16417 unformat_input_t *input = vam->input;
16418 vl_api_one_add_del_map_resolver_t *mp;
16422 ip4_address_t ipv4;
16423 ip6_address_t ipv6;
16426 /* Parse args required to build the message */
16427 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16429 if (unformat (input, "del"))
16433 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16437 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16445 if (ipv4_set && ipv6_set)
16447 errmsg ("both eid v4 and v6 addresses set");
16451 if (!ipv4_set && !ipv6_set)
16453 errmsg ("eid addresses not set");
16457 /* Construct the API message */
16458 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
16460 mp->is_add = is_add;
16464 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16469 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16475 /* Wait for a reply... */
16480 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
16483 api_lisp_gpe_enable_disable (vat_main_t * vam)
16485 unformat_input_t *input = vam->input;
16486 vl_api_gpe_enable_disable_t *mp;
16491 /* Parse args required to build the message */
16492 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16494 if (unformat (input, "enable"))
16499 else if (unformat (input, "disable"))
16510 errmsg ("Value not set");
16514 /* Construct the API message */
16515 M (GPE_ENABLE_DISABLE, mp);
16522 /* Wait for a reply... */
16528 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16530 unformat_input_t *input = vam->input;
16531 vl_api_one_rloc_probe_enable_disable_t *mp;
16536 /* Parse args required to build the message */
16537 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16539 if (unformat (input, "enable"))
16544 else if (unformat (input, "disable"))
16552 errmsg ("Value not set");
16556 /* Construct the API message */
16557 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16559 mp->is_enabled = is_en;
16564 /* Wait for a reply... */
16569 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16572 api_one_map_register_enable_disable (vat_main_t * vam)
16574 unformat_input_t *input = vam->input;
16575 vl_api_one_map_register_enable_disable_t *mp;
16580 /* Parse args required to build the message */
16581 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16583 if (unformat (input, "enable"))
16588 else if (unformat (input, "disable"))
16596 errmsg ("Value not set");
16600 /* Construct the API message */
16601 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16603 mp->is_enabled = is_en;
16608 /* Wait for a reply... */
16613 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16616 api_one_enable_disable (vat_main_t * vam)
16618 unformat_input_t *input = vam->input;
16619 vl_api_one_enable_disable_t *mp;
16624 /* Parse args required to build the message */
16625 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16627 if (unformat (input, "enable"))
16632 else if (unformat (input, "disable"))
16642 errmsg ("Value not set");
16646 /* Construct the API message */
16647 M (ONE_ENABLE_DISABLE, mp);
16654 /* Wait for a reply... */
16659 #define api_lisp_enable_disable api_one_enable_disable
16662 api_one_enable_disable_xtr_mode (vat_main_t * vam)
16664 unformat_input_t *input = vam->input;
16665 vl_api_one_enable_disable_xtr_mode_t *mp;
16670 /* Parse args required to build the message */
16671 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16673 if (unformat (input, "enable"))
16678 else if (unformat (input, "disable"))
16688 errmsg ("Value not set");
16692 /* Construct the API message */
16693 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
16700 /* Wait for a reply... */
16706 api_one_show_xtr_mode (vat_main_t * vam)
16708 vl_api_one_show_xtr_mode_t *mp;
16711 /* Construct the API message */
16712 M (ONE_SHOW_XTR_MODE, mp);
16717 /* Wait for a reply... */
16723 api_one_enable_disable_pitr_mode (vat_main_t * vam)
16725 unformat_input_t *input = vam->input;
16726 vl_api_one_enable_disable_pitr_mode_t *mp;
16731 /* Parse args required to build the message */
16732 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16734 if (unformat (input, "enable"))
16739 else if (unformat (input, "disable"))
16749 errmsg ("Value not set");
16753 /* Construct the API message */
16754 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
16761 /* Wait for a reply... */
16767 api_one_show_pitr_mode (vat_main_t * vam)
16769 vl_api_one_show_pitr_mode_t *mp;
16772 /* Construct the API message */
16773 M (ONE_SHOW_PITR_MODE, mp);
16778 /* Wait for a reply... */
16784 api_one_enable_disable_petr_mode (vat_main_t * vam)
16786 unformat_input_t *input = vam->input;
16787 vl_api_one_enable_disable_petr_mode_t *mp;
16792 /* Parse args required to build the message */
16793 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16795 if (unformat (input, "enable"))
16800 else if (unformat (input, "disable"))
16810 errmsg ("Value not set");
16814 /* Construct the API message */
16815 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
16822 /* Wait for a reply... */
16828 api_one_show_petr_mode (vat_main_t * vam)
16830 vl_api_one_show_petr_mode_t *mp;
16833 /* Construct the API message */
16834 M (ONE_SHOW_PETR_MODE, mp);
16839 /* Wait for a reply... */
16845 api_show_one_map_register_state (vat_main_t * vam)
16847 vl_api_show_one_map_register_state_t *mp;
16850 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16855 /* wait for reply */
16860 #define api_show_lisp_map_register_state api_show_one_map_register_state
16863 api_show_one_rloc_probe_state (vat_main_t * vam)
16865 vl_api_show_one_rloc_probe_state_t *mp;
16868 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16873 /* wait for reply */
16878 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16881 api_one_add_del_ndp_entry (vat_main_t * vam)
16883 vl_api_one_add_del_ndp_entry_t *mp;
16884 unformat_input_t *input = vam->input;
16889 u8 mac[6] = { 0, };
16890 u8 ip6[16] = { 0, };
16894 /* Parse args required to build the message */
16895 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16897 if (unformat (input, "del"))
16899 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16901 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16903 else if (unformat (input, "bd %d", &bd))
16907 errmsg ("parse error '%U'", format_unformat_error, input);
16912 if (!bd_set || !ip_set || (!mac_set && is_add))
16914 errmsg ("Missing BD, IP or MAC!");
16918 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16919 mp->is_add = is_add;
16920 clib_memcpy (mp->mac, mac, 6);
16921 mp->bd = clib_host_to_net_u32 (bd);
16922 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16927 /* wait for reply */
16933 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16935 vl_api_one_add_del_l2_arp_entry_t *mp;
16936 unformat_input_t *input = vam->input;
16941 u8 mac[6] = { 0, };
16942 u32 ip4 = 0, bd = ~0;
16945 /* Parse args required to build the message */
16946 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16948 if (unformat (input, "del"))
16950 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16952 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16954 else if (unformat (input, "bd %d", &bd))
16958 errmsg ("parse error '%U'", format_unformat_error, input);
16963 if (!bd_set || !ip_set || (!mac_set && is_add))
16965 errmsg ("Missing BD, IP or MAC!");
16969 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16970 mp->is_add = is_add;
16971 clib_memcpy (mp->mac, mac, 6);
16972 mp->bd = clib_host_to_net_u32 (bd);
16978 /* wait for reply */
16984 api_one_ndp_bd_get (vat_main_t * vam)
16986 vl_api_one_ndp_bd_get_t *mp;
16989 M (ONE_NDP_BD_GET, mp);
16994 /* wait for reply */
17000 api_one_ndp_entries_get (vat_main_t * vam)
17002 vl_api_one_ndp_entries_get_t *mp;
17003 unformat_input_t *input = vam->input;
17008 /* Parse args required to build the message */
17009 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17011 if (unformat (input, "bd %d", &bd))
17015 errmsg ("parse error '%U'", format_unformat_error, input);
17022 errmsg ("Expected bridge domain!");
17026 M (ONE_NDP_ENTRIES_GET, mp);
17027 mp->bd = clib_host_to_net_u32 (bd);
17032 /* wait for reply */
17038 api_one_l2_arp_bd_get (vat_main_t * vam)
17040 vl_api_one_l2_arp_bd_get_t *mp;
17043 M (ONE_L2_ARP_BD_GET, mp);
17048 /* wait for reply */
17054 api_one_l2_arp_entries_get (vat_main_t * vam)
17056 vl_api_one_l2_arp_entries_get_t *mp;
17057 unformat_input_t *input = vam->input;
17062 /* Parse args required to build the message */
17063 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17065 if (unformat (input, "bd %d", &bd))
17069 errmsg ("parse error '%U'", format_unformat_error, input);
17076 errmsg ("Expected bridge domain!");
17080 M (ONE_L2_ARP_ENTRIES_GET, mp);
17081 mp->bd = clib_host_to_net_u32 (bd);
17086 /* wait for reply */
17092 api_one_stats_enable_disable (vat_main_t * vam)
17094 vl_api_one_stats_enable_disable_t *mp;
17095 unformat_input_t *input = vam->input;
17100 /* Parse args required to build the message */
17101 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17103 if (unformat (input, "enable"))
17108 else if (unformat (input, "disable"))
17118 errmsg ("Value not set");
17122 M (ONE_STATS_ENABLE_DISABLE, mp);
17128 /* wait for reply */
17134 api_show_one_stats_enable_disable (vat_main_t * vam)
17136 vl_api_show_one_stats_enable_disable_t *mp;
17139 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
17144 /* wait for reply */
17150 api_show_one_map_request_mode (vat_main_t * vam)
17152 vl_api_show_one_map_request_mode_t *mp;
17155 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
17160 /* wait for reply */
17165 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
17168 api_one_map_request_mode (vat_main_t * vam)
17170 unformat_input_t *input = vam->input;
17171 vl_api_one_map_request_mode_t *mp;
17175 /* Parse args required to build the message */
17176 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17178 if (unformat (input, "dst-only"))
17180 else if (unformat (input, "src-dst"))
17184 errmsg ("parse error '%U'", format_unformat_error, input);
17189 M (ONE_MAP_REQUEST_MODE, mp);
17196 /* wait for reply */
17201 #define api_lisp_map_request_mode api_one_map_request_mode
17204 * Enable/disable ONE proxy ITR.
17206 * @param vam vpp API test context
17207 * @return return code
17210 api_one_pitr_set_locator_set (vat_main_t * vam)
17212 u8 ls_name_set = 0;
17213 unformat_input_t *input = vam->input;
17214 vl_api_one_pitr_set_locator_set_t *mp;
17219 /* Parse args required to build the message */
17220 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17222 if (unformat (input, "del"))
17224 else if (unformat (input, "locator-set %s", &ls_name))
17228 errmsg ("parse error '%U'", format_unformat_error, input);
17235 errmsg ("locator-set name not set!");
17239 M (ONE_PITR_SET_LOCATOR_SET, mp);
17241 mp->is_add = is_add;
17242 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17243 vec_free (ls_name);
17248 /* wait for reply */
17253 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
17256 api_one_nsh_set_locator_set (vat_main_t * vam)
17258 u8 ls_name_set = 0;
17259 unformat_input_t *input = vam->input;
17260 vl_api_one_nsh_set_locator_set_t *mp;
17265 /* Parse args required to build the message */
17266 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17268 if (unformat (input, "del"))
17270 else if (unformat (input, "ls %s", &ls_name))
17274 errmsg ("parse error '%U'", format_unformat_error, input);
17279 if (!ls_name_set && is_add)
17281 errmsg ("locator-set name not set!");
17285 M (ONE_NSH_SET_LOCATOR_SET, mp);
17287 mp->is_add = is_add;
17288 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17289 vec_free (ls_name);
17294 /* wait for reply */
17300 api_show_one_pitr (vat_main_t * vam)
17302 vl_api_show_one_pitr_t *mp;
17305 if (!vam->json_output)
17307 print (vam->ofp, "%=20s", "lisp status:");
17310 M (SHOW_ONE_PITR, mp);
17314 /* Wait for a reply... */
17319 #define api_show_lisp_pitr api_show_one_pitr
17322 api_one_use_petr (vat_main_t * vam)
17324 unformat_input_t *input = vam->input;
17325 vl_api_one_use_petr_t *mp;
17330 memset (&ip, 0, sizeof (ip));
17332 /* Parse args required to build the message */
17333 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17335 if (unformat (input, "disable"))
17338 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
17341 ip_addr_version (&ip) = IP4;
17344 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
17347 ip_addr_version (&ip) = IP6;
17351 errmsg ("parse error '%U'", format_unformat_error, input);
17356 M (ONE_USE_PETR, mp);
17358 mp->is_add = is_add;
17361 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
17363 clib_memcpy (mp->address, &ip, 4);
17365 clib_memcpy (mp->address, &ip, 16);
17371 /* wait for reply */
17376 #define api_lisp_use_petr api_one_use_petr
17379 api_show_one_nsh_mapping (vat_main_t * vam)
17381 vl_api_show_one_use_petr_t *mp;
17384 if (!vam->json_output)
17386 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
17389 M (SHOW_ONE_NSH_MAPPING, mp);
17393 /* Wait for a reply... */
17399 api_show_one_use_petr (vat_main_t * vam)
17401 vl_api_show_one_use_petr_t *mp;
17404 if (!vam->json_output)
17406 print (vam->ofp, "%=20s", "Proxy-ETR status:");
17409 M (SHOW_ONE_USE_PETR, mp);
17413 /* Wait for a reply... */
17418 #define api_show_lisp_use_petr api_show_one_use_petr
17421 * Add/delete mapping between vni and vrf
17424 api_one_eid_table_add_del_map (vat_main_t * vam)
17426 unformat_input_t *input = vam->input;
17427 vl_api_one_eid_table_add_del_map_t *mp;
17428 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
17429 u32 vni, vrf, bd_index;
17432 /* Parse args required to build the message */
17433 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17435 if (unformat (input, "del"))
17437 else if (unformat (input, "vrf %d", &vrf))
17439 else if (unformat (input, "bd_index %d", &bd_index))
17441 else if (unformat (input, "vni %d", &vni))
17447 if (!vni_set || (!vrf_set && !bd_index_set))
17449 errmsg ("missing arguments!");
17453 if (vrf_set && bd_index_set)
17455 errmsg ("error: both vrf and bd entered!");
17459 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
17461 mp->is_add = is_add;
17462 mp->vni = htonl (vni);
17463 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
17464 mp->is_l2 = bd_index_set;
17469 /* wait for reply */
17474 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
17477 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
17479 u32 *action = va_arg (*args, u32 *);
17482 if (unformat (input, "%s", &s))
17484 if (!strcmp ((char *) s, "no-action"))
17486 else if (!strcmp ((char *) s, "natively-forward"))
17488 else if (!strcmp ((char *) s, "send-map-request"))
17490 else if (!strcmp ((char *) s, "drop"))
17494 clib_warning ("invalid action: '%s'", s);
17506 * Add/del remote mapping to/from ONE control plane
17508 * @param vam vpp API test context
17509 * @return return code
17512 api_one_add_del_remote_mapping (vat_main_t * vam)
17514 unformat_input_t *input = vam->input;
17515 vl_api_one_add_del_remote_mapping_t *mp;
17517 lisp_eid_vat_t _eid, *eid = &_eid;
17518 lisp_eid_vat_t _seid, *seid = &_seid;
17519 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
17520 u32 action = ~0, p, w, data_len;
17521 ip4_address_t rloc4;
17522 ip6_address_t rloc6;
17523 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
17526 memset (&rloc, 0, sizeof (rloc));
17528 /* Parse args required to build the message */
17529 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17531 if (unformat (input, "del-all"))
17535 else if (unformat (input, "del"))
17539 else if (unformat (input, "add"))
17543 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17547 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
17551 else if (unformat (input, "vni %d", &vni))
17555 else if (unformat (input, "p %d w %d", &p, &w))
17559 errmsg ("No RLOC configured for setting priority/weight!");
17562 curr_rloc->priority = p;
17563 curr_rloc->weight = w;
17565 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
17568 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
17569 vec_add1 (rlocs, rloc);
17570 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17572 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
17575 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
17576 vec_add1 (rlocs, rloc);
17577 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17579 else if (unformat (input, "action %U",
17580 unformat_negative_mapping_action, &action))
17586 clib_warning ("parse error '%U'", format_unformat_error, input);
17593 errmsg ("missing params!");
17597 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
17599 errmsg ("no action set for negative map-reply!");
17603 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
17605 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
17606 mp->is_add = is_add;
17607 mp->vni = htonl (vni);
17608 mp->action = (u8) action;
17609 mp->is_src_dst = seid_set;
17610 mp->eid_len = eid->len;
17611 mp->seid_len = seid->len;
17612 mp->del_all = del_all;
17613 mp->eid_type = eid->type;
17614 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17615 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
17617 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
17618 clib_memcpy (mp->rlocs, rlocs, data_len);
17624 /* Wait for a reply... */
17629 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
17632 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
17633 * forwarding entries in data-plane accordingly.
17635 * @param vam vpp API test context
17636 * @return return code
17639 api_one_add_del_adjacency (vat_main_t * vam)
17641 unformat_input_t *input = vam->input;
17642 vl_api_one_add_del_adjacency_t *mp;
17644 ip4_address_t leid4, reid4;
17645 ip6_address_t leid6, reid6;
17646 u8 reid_mac[6] = { 0 };
17647 u8 leid_mac[6] = { 0 };
17648 u8 reid_type, leid_type;
17649 u32 leid_len = 0, reid_len = 0, len;
17653 leid_type = reid_type = (u8) ~ 0;
17655 /* Parse args required to build the message */
17656 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17658 if (unformat (input, "del"))
17662 else if (unformat (input, "add"))
17666 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17669 reid_type = 0; /* ipv4 */
17672 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17675 reid_type = 1; /* ipv6 */
17678 else if (unformat (input, "reid %U", unformat_ethernet_address,
17681 reid_type = 2; /* mac */
17683 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17686 leid_type = 0; /* ipv4 */
17689 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17692 leid_type = 1; /* ipv6 */
17695 else if (unformat (input, "leid %U", unformat_ethernet_address,
17698 leid_type = 2; /* mac */
17700 else if (unformat (input, "vni %d", &vni))
17706 errmsg ("parse error '%U'", format_unformat_error, input);
17711 if ((u8) ~ 0 == reid_type)
17713 errmsg ("missing params!");
17717 if (leid_type != reid_type)
17719 errmsg ("remote and local EIDs are of different types!");
17723 M (ONE_ADD_DEL_ADJACENCY, mp);
17724 mp->is_add = is_add;
17725 mp->vni = htonl (vni);
17726 mp->leid_len = leid_len;
17727 mp->reid_len = reid_len;
17728 mp->eid_type = reid_type;
17730 switch (mp->eid_type)
17733 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17734 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17737 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17738 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17741 clib_memcpy (mp->leid, leid_mac, 6);
17742 clib_memcpy (mp->reid, reid_mac, 6);
17745 errmsg ("unknown EID type %d!", mp->eid_type);
17752 /* Wait for a reply... */
17757 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17760 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17762 u32 *mode = va_arg (*args, u32 *);
17764 if (unformat (input, "lisp"))
17766 else if (unformat (input, "vxlan"))
17775 api_gpe_get_encap_mode (vat_main_t * vam)
17777 vl_api_gpe_get_encap_mode_t *mp;
17780 /* Construct the API message */
17781 M (GPE_GET_ENCAP_MODE, mp);
17786 /* Wait for a reply... */
17792 api_gpe_set_encap_mode (vat_main_t * vam)
17794 unformat_input_t *input = vam->input;
17795 vl_api_gpe_set_encap_mode_t *mp;
17799 /* Parse args required to build the message */
17800 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17802 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17808 /* Construct the API message */
17809 M (GPE_SET_ENCAP_MODE, mp);
17816 /* Wait for a reply... */
17822 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17824 unformat_input_t *input = vam->input;
17825 vl_api_gpe_add_del_iface_t *mp;
17826 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17827 u32 dp_table = 0, vni = 0;
17830 /* Parse args required to build the message */
17831 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17833 if (unformat (input, "up"))
17838 else if (unformat (input, "down"))
17843 else if (unformat (input, "table_id %d", &dp_table))
17847 else if (unformat (input, "bd_id %d", &dp_table))
17852 else if (unformat (input, "vni %d", &vni))
17860 if (action_set == 0)
17862 errmsg ("Action not set");
17865 if (dp_table_set == 0 || vni_set == 0)
17867 errmsg ("vni and dp_table must be set");
17871 /* Construct the API message */
17872 M (GPE_ADD_DEL_IFACE, mp);
17874 mp->is_add = is_add;
17875 mp->dp_table = clib_host_to_net_u32 (dp_table);
17877 mp->vni = clib_host_to_net_u32 (vni);
17882 /* Wait for a reply... */
17888 api_one_map_register_fallback_threshold (vat_main_t * vam)
17890 unformat_input_t *input = vam->input;
17891 vl_api_one_map_register_fallback_threshold_t *mp;
17896 /* Parse args required to build the message */
17897 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17899 if (unformat (input, "%u", &value))
17903 clib_warning ("parse error '%U'", format_unformat_error, input);
17910 errmsg ("fallback threshold value is missing!");
17914 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17915 mp->value = clib_host_to_net_u32 (value);
17920 /* Wait for a reply... */
17926 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17928 vl_api_show_one_map_register_fallback_threshold_t *mp;
17931 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17936 /* Wait for a reply... */
17942 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17944 u32 *proto = va_arg (*args, u32 *);
17946 if (unformat (input, "udp"))
17948 else if (unformat (input, "api"))
17957 api_one_set_transport_protocol (vat_main_t * vam)
17959 unformat_input_t *input = vam->input;
17960 vl_api_one_set_transport_protocol_t *mp;
17965 /* Parse args required to build the message */
17966 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17968 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17972 clib_warning ("parse error '%U'", format_unformat_error, input);
17979 errmsg ("Transport protocol missing!");
17983 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17984 mp->protocol = (u8) protocol;
17989 /* Wait for a reply... */
17995 api_one_get_transport_protocol (vat_main_t * vam)
17997 vl_api_one_get_transport_protocol_t *mp;
18000 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
18005 /* Wait for a reply... */
18011 api_one_map_register_set_ttl (vat_main_t * vam)
18013 unformat_input_t *input = vam->input;
18014 vl_api_one_map_register_set_ttl_t *mp;
18019 /* Parse args required to build the message */
18020 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18022 if (unformat (input, "%u", &ttl))
18026 clib_warning ("parse error '%U'", format_unformat_error, input);
18033 errmsg ("TTL value missing!");
18037 M (ONE_MAP_REGISTER_SET_TTL, mp);
18038 mp->ttl = clib_host_to_net_u32 (ttl);
18043 /* Wait for a reply... */
18049 api_show_one_map_register_ttl (vat_main_t * vam)
18051 vl_api_show_one_map_register_ttl_t *mp;
18054 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
18059 /* Wait for a reply... */
18065 * Add/del map request itr rlocs from ONE control plane and updates
18067 * @param vam vpp API test context
18068 * @return return code
18071 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
18073 unformat_input_t *input = vam->input;
18074 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
18075 u8 *locator_set_name = 0;
18076 u8 locator_set_name_set = 0;
18080 /* Parse args required to build the message */
18081 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18083 if (unformat (input, "del"))
18087 else if (unformat (input, "%_%v%_", &locator_set_name))
18089 locator_set_name_set = 1;
18093 clib_warning ("parse error '%U'", format_unformat_error, input);
18098 if (is_add && !locator_set_name_set)
18100 errmsg ("itr-rloc is not set!");
18104 if (is_add && vec_len (locator_set_name) > 64)
18106 errmsg ("itr-rloc locator-set name too long");
18107 vec_free (locator_set_name);
18111 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
18112 mp->is_add = is_add;
18115 clib_memcpy (mp->locator_set_name, locator_set_name,
18116 vec_len (locator_set_name));
18120 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
18122 vec_free (locator_set_name);
18127 /* Wait for a reply... */
18132 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
18135 api_one_locator_dump (vat_main_t * vam)
18137 unformat_input_t *input = vam->input;
18138 vl_api_one_locator_dump_t *mp;
18139 vl_api_control_ping_t *mp_ping;
18140 u8 is_index_set = 0, is_name_set = 0;
18145 /* Parse args required to build the message */
18146 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18148 if (unformat (input, "ls_name %_%v%_", &ls_name))
18152 else if (unformat (input, "ls_index %d", &ls_index))
18158 errmsg ("parse error '%U'", format_unformat_error, input);
18163 if (!is_index_set && !is_name_set)
18165 errmsg ("error: expected one of index or name!");
18169 if (is_index_set && is_name_set)
18171 errmsg ("error: only one param expected!");
18175 if (vec_len (ls_name) > 62)
18177 errmsg ("error: locator set name too long!");
18181 if (!vam->json_output)
18183 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
18186 M (ONE_LOCATOR_DUMP, mp);
18187 mp->is_index_set = is_index_set;
18190 mp->ls_index = clib_host_to_net_u32 (ls_index);
18193 vec_add1 (ls_name, 0);
18194 strncpy ((char *) mp->ls_name, (char *) ls_name,
18195 sizeof (mp->ls_name) - 1);
18201 /* Use a control ping for synchronization */
18202 MPING (CONTROL_PING, mp_ping);
18205 /* Wait for a reply... */
18210 #define api_lisp_locator_dump api_one_locator_dump
18213 api_one_locator_set_dump (vat_main_t * vam)
18215 vl_api_one_locator_set_dump_t *mp;
18216 vl_api_control_ping_t *mp_ping;
18217 unformat_input_t *input = vam->input;
18221 /* Parse args required to build the message */
18222 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18224 if (unformat (input, "local"))
18228 else if (unformat (input, "remote"))
18234 errmsg ("parse error '%U'", format_unformat_error, input);
18239 if (!vam->json_output)
18241 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
18244 M (ONE_LOCATOR_SET_DUMP, mp);
18246 mp->filter = filter;
18251 /* Use a control ping for synchronization */
18252 MPING (CONTROL_PING, mp_ping);
18255 /* Wait for a reply... */
18260 #define api_lisp_locator_set_dump api_one_locator_set_dump
18263 api_one_eid_table_map_dump (vat_main_t * vam)
18267 unformat_input_t *input = vam->input;
18268 vl_api_one_eid_table_map_dump_t *mp;
18269 vl_api_control_ping_t *mp_ping;
18272 /* Parse args required to build the message */
18273 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18275 if (unformat (input, "l2"))
18280 else if (unformat (input, "l3"))
18287 errmsg ("parse error '%U'", format_unformat_error, input);
18294 errmsg ("expected one of 'l2' or 'l3' parameter!");
18298 if (!vam->json_output)
18300 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
18303 M (ONE_EID_TABLE_MAP_DUMP, mp);
18309 /* Use a control ping for synchronization */
18310 MPING (CONTROL_PING, mp_ping);
18313 /* Wait for a reply... */
18318 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
18321 api_one_eid_table_vni_dump (vat_main_t * vam)
18323 vl_api_one_eid_table_vni_dump_t *mp;
18324 vl_api_control_ping_t *mp_ping;
18327 if (!vam->json_output)
18329 print (vam->ofp, "VNI");
18332 M (ONE_EID_TABLE_VNI_DUMP, mp);
18337 /* Use a control ping for synchronization */
18338 MPING (CONTROL_PING, mp_ping);
18341 /* Wait for a reply... */
18346 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
18349 api_one_eid_table_dump (vat_main_t * vam)
18351 unformat_input_t *i = vam->input;
18352 vl_api_one_eid_table_dump_t *mp;
18353 vl_api_control_ping_t *mp_ping;
18354 struct in_addr ip4;
18355 struct in6_addr ip6;
18357 u8 eid_type = ~0, eid_set = 0;
18358 u32 prefix_length = ~0, t, vni = 0;
18361 lisp_nsh_api_t nsh;
18363 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18365 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
18371 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
18377 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
18382 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
18387 else if (unformat (i, "vni %d", &t))
18391 else if (unformat (i, "local"))
18395 else if (unformat (i, "remote"))
18401 errmsg ("parse error '%U'", format_unformat_error, i);
18406 if (!vam->json_output)
18408 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
18409 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
18412 M (ONE_EID_TABLE_DUMP, mp);
18414 mp->filter = filter;
18418 mp->vni = htonl (vni);
18419 mp->eid_type = eid_type;
18423 mp->prefix_length = prefix_length;
18424 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
18427 mp->prefix_length = prefix_length;
18428 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
18431 clib_memcpy (mp->eid, mac, sizeof (mac));
18434 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
18437 errmsg ("unknown EID type %d!", eid_type);
18445 /* Use a control ping for synchronization */
18446 MPING (CONTROL_PING, mp_ping);
18449 /* Wait for a reply... */
18454 #define api_lisp_eid_table_dump api_one_eid_table_dump
18457 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
18459 unformat_input_t *i = vam->input;
18460 vl_api_gpe_fwd_entries_get_t *mp;
18465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18467 if (unformat (i, "vni %d", &vni))
18473 errmsg ("parse error '%U'", format_unformat_error, i);
18480 errmsg ("vni not set!");
18484 if (!vam->json_output)
18486 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
18490 M (GPE_FWD_ENTRIES_GET, mp);
18491 mp->vni = clib_host_to_net_u32 (vni);
18496 /* Wait for a reply... */
18501 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
18502 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
18503 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
18504 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
18505 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
18506 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
18507 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
18508 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
18511 api_one_adjacencies_get (vat_main_t * vam)
18513 unformat_input_t *i = vam->input;
18514 vl_api_one_adjacencies_get_t *mp;
18519 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18521 if (unformat (i, "vni %d", &vni))
18527 errmsg ("parse error '%U'", format_unformat_error, i);
18534 errmsg ("vni not set!");
18538 if (!vam->json_output)
18540 print (vam->ofp, "%s %40s", "leid", "reid");
18543 M (ONE_ADJACENCIES_GET, mp);
18544 mp->vni = clib_host_to_net_u32 (vni);
18549 /* Wait for a reply... */
18554 #define api_lisp_adjacencies_get api_one_adjacencies_get
18557 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
18559 unformat_input_t *i = vam->input;
18560 vl_api_gpe_native_fwd_rpaths_get_t *mp;
18562 u8 ip_family_set = 0, is_ip4 = 1;
18564 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18566 if (unformat (i, "ip4"))
18571 else if (unformat (i, "ip6"))
18578 errmsg ("parse error '%U'", format_unformat_error, i);
18583 if (!ip_family_set)
18585 errmsg ("ip family not set!");
18589 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
18590 mp->is_ip4 = is_ip4;
18595 /* Wait for a reply... */
18601 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
18603 vl_api_gpe_fwd_entry_vnis_get_t *mp;
18606 if (!vam->json_output)
18608 print (vam->ofp, "VNIs");
18611 M (GPE_FWD_ENTRY_VNIS_GET, mp);
18616 /* Wait for a reply... */
18622 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
18624 unformat_input_t *i = vam->input;
18625 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
18627 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
18628 struct in_addr ip4;
18629 struct in6_addr ip6;
18630 u32 table_id = 0, nh_sw_if_index = ~0;
18632 memset (&ip4, 0, sizeof (ip4));
18633 memset (&ip6, 0, sizeof (ip6));
18635 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18637 if (unformat (i, "del"))
18639 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
18640 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18645 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
18646 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18651 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18655 nh_sw_if_index = ~0;
18657 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18661 nh_sw_if_index = ~0;
18663 else if (unformat (i, "table %d", &table_id))
18667 errmsg ("parse error '%U'", format_unformat_error, i);
18674 errmsg ("nh addr not set!");
18678 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18679 mp->is_add = is_add;
18680 mp->table_id = clib_host_to_net_u32 (table_id);
18681 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18682 mp->is_ip4 = is_ip4;
18684 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18686 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18691 /* Wait for a reply... */
18697 api_one_map_server_dump (vat_main_t * vam)
18699 vl_api_one_map_server_dump_t *mp;
18700 vl_api_control_ping_t *mp_ping;
18703 if (!vam->json_output)
18705 print (vam->ofp, "%=20s", "Map server");
18708 M (ONE_MAP_SERVER_DUMP, mp);
18712 /* Use a control ping for synchronization */
18713 MPING (CONTROL_PING, mp_ping);
18716 /* Wait for a reply... */
18721 #define api_lisp_map_server_dump api_one_map_server_dump
18724 api_one_map_resolver_dump (vat_main_t * vam)
18726 vl_api_one_map_resolver_dump_t *mp;
18727 vl_api_control_ping_t *mp_ping;
18730 if (!vam->json_output)
18732 print (vam->ofp, "%=20s", "Map resolver");
18735 M (ONE_MAP_RESOLVER_DUMP, mp);
18739 /* Use a control ping for synchronization */
18740 MPING (CONTROL_PING, mp_ping);
18743 /* Wait for a reply... */
18748 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18751 api_one_stats_flush (vat_main_t * vam)
18753 vl_api_one_stats_flush_t *mp;
18756 M (ONE_STATS_FLUSH, mp);
18763 api_one_stats_dump (vat_main_t * vam)
18765 vl_api_one_stats_dump_t *mp;
18766 vl_api_control_ping_t *mp_ping;
18769 M (ONE_STATS_DUMP, mp);
18773 /* Use a control ping for synchronization */
18774 MPING (CONTROL_PING, mp_ping);
18777 /* Wait for a reply... */
18783 api_show_one_status (vat_main_t * vam)
18785 vl_api_show_one_status_t *mp;
18788 if (!vam->json_output)
18790 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18793 M (SHOW_ONE_STATUS, mp);
18796 /* Wait for a reply... */
18801 #define api_show_lisp_status api_show_one_status
18804 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18806 vl_api_gpe_fwd_entry_path_dump_t *mp;
18807 vl_api_control_ping_t *mp_ping;
18808 unformat_input_t *i = vam->input;
18809 u32 fwd_entry_index = ~0;
18812 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18814 if (unformat (i, "index %d", &fwd_entry_index))
18820 if (~0 == fwd_entry_index)
18822 errmsg ("no index specified!");
18826 if (!vam->json_output)
18828 print (vam->ofp, "first line");
18831 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18835 /* Use a control ping for synchronization */
18836 MPING (CONTROL_PING, mp_ping);
18839 /* Wait for a reply... */
18845 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18847 vl_api_one_get_map_request_itr_rlocs_t *mp;
18850 if (!vam->json_output)
18852 print (vam->ofp, "%=20s", "itr-rlocs:");
18855 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18858 /* Wait for a reply... */
18863 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18866 api_af_packet_create (vat_main_t * vam)
18868 unformat_input_t *i = vam->input;
18869 vl_api_af_packet_create_t *mp;
18870 u8 *host_if_name = 0;
18872 u8 random_hw_addr = 1;
18875 memset (hw_addr, 0, sizeof (hw_addr));
18877 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18879 if (unformat (i, "name %s", &host_if_name))
18880 vec_add1 (host_if_name, 0);
18881 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18882 random_hw_addr = 0;
18887 if (!vec_len (host_if_name))
18889 errmsg ("host-interface name must be specified");
18893 if (vec_len (host_if_name) > 64)
18895 errmsg ("host-interface name too long");
18899 M (AF_PACKET_CREATE, mp);
18901 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18902 clib_memcpy (mp->hw_addr, hw_addr, 6);
18903 mp->use_random_hw_addr = random_hw_addr;
18904 vec_free (host_if_name);
18912 fprintf (vam->ofp ? vam->ofp : stderr,
18913 " new sw_if_index = %d\n", vam->sw_if_index);
18920 api_af_packet_delete (vat_main_t * vam)
18922 unformat_input_t *i = vam->input;
18923 vl_api_af_packet_delete_t *mp;
18924 u8 *host_if_name = 0;
18927 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18929 if (unformat (i, "name %s", &host_if_name))
18930 vec_add1 (host_if_name, 0);
18935 if (!vec_len (host_if_name))
18937 errmsg ("host-interface name must be specified");
18941 if (vec_len (host_if_name) > 64)
18943 errmsg ("host-interface name too long");
18947 M (AF_PACKET_DELETE, mp);
18949 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18950 vec_free (host_if_name);
18958 api_policer_add_del (vat_main_t * vam)
18960 unformat_input_t *i = vam->input;
18961 vl_api_policer_add_del_t *mp;
18971 u8 color_aware = 0;
18972 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18975 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18976 conform_action.dscp = 0;
18977 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18978 exceed_action.dscp = 0;
18979 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18980 violate_action.dscp = 0;
18982 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18984 if (unformat (i, "del"))
18986 else if (unformat (i, "name %s", &name))
18987 vec_add1 (name, 0);
18988 else if (unformat (i, "cir %u", &cir))
18990 else if (unformat (i, "eir %u", &eir))
18992 else if (unformat (i, "cb %u", &cb))
18994 else if (unformat (i, "eb %u", &eb))
18996 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18999 else if (unformat (i, "round_type %U", unformat_policer_round_type,
19002 else if (unformat (i, "type %U", unformat_policer_type, &type))
19004 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
19007 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
19010 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
19013 else if (unformat (i, "color-aware"))
19019 if (!vec_len (name))
19021 errmsg ("policer name must be specified");
19025 if (vec_len (name) > 64)
19027 errmsg ("policer name too long");
19031 M (POLICER_ADD_DEL, mp);
19033 clib_memcpy (mp->name, name, vec_len (name));
19035 mp->is_add = is_add;
19036 mp->cir = ntohl (cir);
19037 mp->eir = ntohl (eir);
19038 mp->cb = clib_net_to_host_u64 (cb);
19039 mp->eb = clib_net_to_host_u64 (eb);
19040 mp->rate_type = rate_type;
19041 mp->round_type = round_type;
19043 mp->conform_action_type = conform_action.action_type;
19044 mp->conform_dscp = conform_action.dscp;
19045 mp->exceed_action_type = exceed_action.action_type;
19046 mp->exceed_dscp = exceed_action.dscp;
19047 mp->violate_action_type = violate_action.action_type;
19048 mp->violate_dscp = violate_action.dscp;
19049 mp->color_aware = color_aware;
19057 api_policer_dump (vat_main_t * vam)
19059 unformat_input_t *i = vam->input;
19060 vl_api_policer_dump_t *mp;
19061 vl_api_control_ping_t *mp_ping;
19062 u8 *match_name = 0;
19063 u8 match_name_valid = 0;
19066 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19068 if (unformat (i, "name %s", &match_name))
19070 vec_add1 (match_name, 0);
19071 match_name_valid = 1;
19077 M (POLICER_DUMP, mp);
19078 mp->match_name_valid = match_name_valid;
19079 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
19080 vec_free (match_name);
19084 /* Use a control ping for synchronization */
19085 MPING (CONTROL_PING, mp_ping);
19088 /* Wait for a reply... */
19094 api_policer_classify_set_interface (vat_main_t * vam)
19096 unformat_input_t *i = vam->input;
19097 vl_api_policer_classify_set_interface_t *mp;
19099 int sw_if_index_set;
19100 u32 ip4_table_index = ~0;
19101 u32 ip6_table_index = ~0;
19102 u32 l2_table_index = ~0;
19106 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19108 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19109 sw_if_index_set = 1;
19110 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19111 sw_if_index_set = 1;
19112 else if (unformat (i, "del"))
19114 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19116 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19118 else if (unformat (i, "l2-table %d", &l2_table_index))
19122 clib_warning ("parse error '%U'", format_unformat_error, i);
19127 if (sw_if_index_set == 0)
19129 errmsg ("missing interface name or sw_if_index");
19133 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
19135 mp->sw_if_index = ntohl (sw_if_index);
19136 mp->ip4_table_index = ntohl (ip4_table_index);
19137 mp->ip6_table_index = ntohl (ip6_table_index);
19138 mp->l2_table_index = ntohl (l2_table_index);
19139 mp->is_add = is_add;
19147 api_policer_classify_dump (vat_main_t * vam)
19149 unformat_input_t *i = vam->input;
19150 vl_api_policer_classify_dump_t *mp;
19151 vl_api_control_ping_t *mp_ping;
19152 u8 type = POLICER_CLASSIFY_N_TABLES;
19155 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
19159 errmsg ("classify table type must be specified");
19163 if (!vam->json_output)
19165 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19168 M (POLICER_CLASSIFY_DUMP, mp);
19173 /* Use a control ping for synchronization */
19174 MPING (CONTROL_PING, mp_ping);
19177 /* Wait for a reply... */
19183 api_netmap_create (vat_main_t * vam)
19185 unformat_input_t *i = vam->input;
19186 vl_api_netmap_create_t *mp;
19189 u8 random_hw_addr = 1;
19194 memset (hw_addr, 0, sizeof (hw_addr));
19196 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19198 if (unformat (i, "name %s", &if_name))
19199 vec_add1 (if_name, 0);
19200 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19201 random_hw_addr = 0;
19202 else if (unformat (i, "pipe"))
19204 else if (unformat (i, "master"))
19206 else if (unformat (i, "slave"))
19212 if (!vec_len (if_name))
19214 errmsg ("interface name must be specified");
19218 if (vec_len (if_name) > 64)
19220 errmsg ("interface name too long");
19224 M (NETMAP_CREATE, mp);
19226 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19227 clib_memcpy (mp->hw_addr, hw_addr, 6);
19228 mp->use_random_hw_addr = random_hw_addr;
19229 mp->is_pipe = is_pipe;
19230 mp->is_master = is_master;
19231 vec_free (if_name);
19239 api_netmap_delete (vat_main_t * vam)
19241 unformat_input_t *i = vam->input;
19242 vl_api_netmap_delete_t *mp;
19246 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19248 if (unformat (i, "name %s", &if_name))
19249 vec_add1 (if_name, 0);
19254 if (!vec_len (if_name))
19256 errmsg ("interface name must be specified");
19260 if (vec_len (if_name) > 64)
19262 errmsg ("interface name too long");
19266 M (NETMAP_DELETE, mp);
19268 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19269 vec_free (if_name);
19277 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
19279 if (fp->afi == IP46_TYPE_IP6)
19281 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19282 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19283 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19284 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19285 format_ip6_address, fp->next_hop);
19286 else if (fp->afi == IP46_TYPE_IP4)
19288 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19289 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19290 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19291 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19292 format_ip4_address, fp->next_hop);
19296 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
19297 vl_api_fib_path2_t * fp)
19299 struct in_addr ip4;
19300 struct in6_addr ip6;
19302 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19303 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19304 vat_json_object_add_uint (node, "is_local", fp->is_local);
19305 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19306 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19307 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19308 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19309 if (fp->afi == IP46_TYPE_IP4)
19311 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19312 vat_json_object_add_ip4 (node, "next_hop", ip4);
19314 else if (fp->afi == IP46_TYPE_IP6)
19316 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19317 vat_json_object_add_ip6 (node, "next_hop", ip6);
19322 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
19324 vat_main_t *vam = &vat_main;
19325 int count = ntohl (mp->mt_count);
19326 vl_api_fib_path2_t *fp;
19329 print (vam->ofp, "[%d]: sw_if_index %d via:",
19330 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
19332 for (i = 0; i < count; i++)
19334 vl_api_mpls_fib_path_print (vam, fp);
19338 print (vam->ofp, "");
19341 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
19342 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
19345 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
19347 vat_main_t *vam = &vat_main;
19348 vat_json_node_t *node = NULL;
19349 int count = ntohl (mp->mt_count);
19350 vl_api_fib_path2_t *fp;
19353 if (VAT_JSON_ARRAY != vam->json_tree.type)
19355 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19356 vat_json_init_array (&vam->json_tree);
19358 node = vat_json_array_add (&vam->json_tree);
19360 vat_json_init_object (node);
19361 vat_json_object_add_uint (node, "tunnel_index",
19362 ntohl (mp->mt_tunnel_index));
19363 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
19365 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
19368 for (i = 0; i < count; i++)
19370 vl_api_mpls_fib_path_json_print (node, fp);
19376 api_mpls_tunnel_dump (vat_main_t * vam)
19378 vl_api_mpls_tunnel_dump_t *mp;
19379 vl_api_control_ping_t *mp_ping;
19383 /* Parse args required to build the message */
19384 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
19386 if (!unformat (vam->input, "tunnel_index %d", &index))
19393 print (vam->ofp, " tunnel_index %d", index);
19395 M (MPLS_TUNNEL_DUMP, mp);
19396 mp->tunnel_index = htonl (index);
19399 /* Use a control ping for synchronization */
19400 MPING (CONTROL_PING, mp_ping);
19407 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
19408 #define vl_api_mpls_fib_details_t_print vl_noop_handler
19412 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
19414 vat_main_t *vam = &vat_main;
19415 int count = ntohl (mp->count);
19416 vl_api_fib_path2_t *fp;
19420 "table-id %d, label %u, ess_bit %u",
19421 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
19423 for (i = 0; i < count; i++)
19425 vl_api_mpls_fib_path_print (vam, fp);
19430 static void vl_api_mpls_fib_details_t_handler_json
19431 (vl_api_mpls_fib_details_t * mp)
19433 vat_main_t *vam = &vat_main;
19434 int count = ntohl (mp->count);
19435 vat_json_node_t *node = NULL;
19436 vl_api_fib_path2_t *fp;
19439 if (VAT_JSON_ARRAY != vam->json_tree.type)
19441 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19442 vat_json_init_array (&vam->json_tree);
19444 node = vat_json_array_add (&vam->json_tree);
19446 vat_json_init_object (node);
19447 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19448 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
19449 vat_json_object_add_uint (node, "label", ntohl (mp->label));
19450 vat_json_object_add_uint (node, "path_count", count);
19452 for (i = 0; i < count; i++)
19454 vl_api_mpls_fib_path_json_print (node, fp);
19460 api_mpls_fib_dump (vat_main_t * vam)
19462 vl_api_mpls_fib_dump_t *mp;
19463 vl_api_control_ping_t *mp_ping;
19466 M (MPLS_FIB_DUMP, mp);
19469 /* Use a control ping for synchronization */
19470 MPING (CONTROL_PING, mp_ping);
19477 #define vl_api_ip_fib_details_t_endian vl_noop_handler
19478 #define vl_api_ip_fib_details_t_print vl_noop_handler
19481 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
19483 vat_main_t *vam = &vat_main;
19484 int count = ntohl (mp->count);
19485 vl_api_fib_path_t *fp;
19489 "table-id %d, prefix %U/%d",
19490 ntohl (mp->table_id), format_ip4_address, mp->address,
19491 mp->address_length);
19493 for (i = 0; i < count; i++)
19495 if (fp->afi == IP46_TYPE_IP6)
19497 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19498 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19499 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19500 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19501 format_ip6_address, fp->next_hop);
19502 else if (fp->afi == IP46_TYPE_IP4)
19504 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19505 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19506 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19507 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19508 format_ip4_address, fp->next_hop);
19513 static void vl_api_ip_fib_details_t_handler_json
19514 (vl_api_ip_fib_details_t * mp)
19516 vat_main_t *vam = &vat_main;
19517 int count = ntohl (mp->count);
19518 vat_json_node_t *node = NULL;
19519 struct in_addr ip4;
19520 struct in6_addr ip6;
19521 vl_api_fib_path_t *fp;
19524 if (VAT_JSON_ARRAY != vam->json_tree.type)
19526 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19527 vat_json_init_array (&vam->json_tree);
19529 node = vat_json_array_add (&vam->json_tree);
19531 vat_json_init_object (node);
19532 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19533 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
19534 vat_json_object_add_ip4 (node, "prefix", ip4);
19535 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19536 vat_json_object_add_uint (node, "path_count", count);
19538 for (i = 0; i < count; i++)
19540 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19541 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19542 vat_json_object_add_uint (node, "is_local", fp->is_local);
19543 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19544 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19545 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19546 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19547 if (fp->afi == IP46_TYPE_IP4)
19549 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19550 vat_json_object_add_ip4 (node, "next_hop", ip4);
19552 else if (fp->afi == IP46_TYPE_IP6)
19554 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19555 vat_json_object_add_ip6 (node, "next_hop", ip6);
19561 api_ip_fib_dump (vat_main_t * vam)
19563 vl_api_ip_fib_dump_t *mp;
19564 vl_api_control_ping_t *mp_ping;
19567 M (IP_FIB_DUMP, mp);
19570 /* Use a control ping for synchronization */
19571 MPING (CONTROL_PING, mp_ping);
19579 api_ip_mfib_dump (vat_main_t * vam)
19581 vl_api_ip_mfib_dump_t *mp;
19582 vl_api_control_ping_t *mp_ping;
19585 M (IP_MFIB_DUMP, mp);
19588 /* Use a control ping for synchronization */
19589 MPING (CONTROL_PING, mp_ping);
19596 static void vl_api_ip_neighbor_details_t_handler
19597 (vl_api_ip_neighbor_details_t * mp)
19599 vat_main_t *vam = &vat_main;
19601 print (vam->ofp, "%c %U %U",
19602 (mp->is_static) ? 'S' : 'D',
19603 format_ethernet_address, &mp->mac_address,
19604 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
19608 static void vl_api_ip_neighbor_details_t_handler_json
19609 (vl_api_ip_neighbor_details_t * mp)
19612 vat_main_t *vam = &vat_main;
19613 vat_json_node_t *node;
19614 struct in_addr ip4;
19615 struct in6_addr ip6;
19617 if (VAT_JSON_ARRAY != vam->json_tree.type)
19619 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19620 vat_json_init_array (&vam->json_tree);
19622 node = vat_json_array_add (&vam->json_tree);
19624 vat_json_init_object (node);
19625 vat_json_object_add_string_copy (node, "flag",
19626 (mp->is_static) ? (u8 *) "static" : (u8 *)
19629 vat_json_object_add_string_copy (node, "link_layer",
19630 format (0, "%U", format_ethernet_address,
19631 &mp->mac_address));
19635 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
19636 vat_json_object_add_ip6 (node, "ip_address", ip6);
19640 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
19641 vat_json_object_add_ip4 (node, "ip_address", ip4);
19646 api_ip_neighbor_dump (vat_main_t * vam)
19648 unformat_input_t *i = vam->input;
19649 vl_api_ip_neighbor_dump_t *mp;
19650 vl_api_control_ping_t *mp_ping;
19652 u32 sw_if_index = ~0;
19655 /* Parse args required to build the message */
19656 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19658 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19660 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19662 else if (unformat (i, "ip6"))
19668 if (sw_if_index == ~0)
19670 errmsg ("missing interface name or sw_if_index");
19674 M (IP_NEIGHBOR_DUMP, mp);
19675 mp->is_ipv6 = (u8) is_ipv6;
19676 mp->sw_if_index = ntohl (sw_if_index);
19679 /* Use a control ping for synchronization */
19680 MPING (CONTROL_PING, mp_ping);
19687 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
19688 #define vl_api_ip6_fib_details_t_print vl_noop_handler
19691 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
19693 vat_main_t *vam = &vat_main;
19694 int count = ntohl (mp->count);
19695 vl_api_fib_path_t *fp;
19699 "table-id %d, prefix %U/%d",
19700 ntohl (mp->table_id), format_ip6_address, mp->address,
19701 mp->address_length);
19703 for (i = 0; i < count; i++)
19705 if (fp->afi == IP46_TYPE_IP6)
19707 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19708 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19709 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19710 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19711 format_ip6_address, fp->next_hop);
19712 else if (fp->afi == IP46_TYPE_IP4)
19714 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19715 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19716 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19717 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19718 format_ip4_address, fp->next_hop);
19723 static void vl_api_ip6_fib_details_t_handler_json
19724 (vl_api_ip6_fib_details_t * mp)
19726 vat_main_t *vam = &vat_main;
19727 int count = ntohl (mp->count);
19728 vat_json_node_t *node = NULL;
19729 struct in_addr ip4;
19730 struct in6_addr ip6;
19731 vl_api_fib_path_t *fp;
19734 if (VAT_JSON_ARRAY != vam->json_tree.type)
19736 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19737 vat_json_init_array (&vam->json_tree);
19739 node = vat_json_array_add (&vam->json_tree);
19741 vat_json_init_object (node);
19742 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19743 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
19744 vat_json_object_add_ip6 (node, "prefix", ip6);
19745 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19746 vat_json_object_add_uint (node, "path_count", count);
19748 for (i = 0; i < count; i++)
19750 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19751 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19752 vat_json_object_add_uint (node, "is_local", fp->is_local);
19753 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19754 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19755 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19756 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19757 if (fp->afi == IP46_TYPE_IP4)
19759 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19760 vat_json_object_add_ip4 (node, "next_hop", ip4);
19762 else if (fp->afi == IP46_TYPE_IP6)
19764 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19765 vat_json_object_add_ip6 (node, "next_hop", ip6);
19771 api_ip6_fib_dump (vat_main_t * vam)
19773 vl_api_ip6_fib_dump_t *mp;
19774 vl_api_control_ping_t *mp_ping;
19777 M (IP6_FIB_DUMP, mp);
19780 /* Use a control ping for synchronization */
19781 MPING (CONTROL_PING, mp_ping);
19789 api_ip6_mfib_dump (vat_main_t * vam)
19791 vl_api_ip6_mfib_dump_t *mp;
19792 vl_api_control_ping_t *mp_ping;
19795 M (IP6_MFIB_DUMP, mp);
19798 /* Use a control ping for synchronization */
19799 MPING (CONTROL_PING, mp_ping);
19807 api_classify_table_ids (vat_main_t * vam)
19809 vl_api_classify_table_ids_t *mp;
19812 /* Construct the API message */
19813 M (CLASSIFY_TABLE_IDS, mp);
19822 api_classify_table_by_interface (vat_main_t * vam)
19824 unformat_input_t *input = vam->input;
19825 vl_api_classify_table_by_interface_t *mp;
19827 u32 sw_if_index = ~0;
19829 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19831 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19833 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19838 if (sw_if_index == ~0)
19840 errmsg ("missing interface name or sw_if_index");
19844 /* Construct the API message */
19845 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19847 mp->sw_if_index = ntohl (sw_if_index);
19855 api_classify_table_info (vat_main_t * vam)
19857 unformat_input_t *input = vam->input;
19858 vl_api_classify_table_info_t *mp;
19862 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19864 if (unformat (input, "table_id %d", &table_id))
19869 if (table_id == ~0)
19871 errmsg ("missing table id");
19875 /* Construct the API message */
19876 M (CLASSIFY_TABLE_INFO, mp);
19878 mp->table_id = ntohl (table_id);
19886 api_classify_session_dump (vat_main_t * vam)
19888 unformat_input_t *input = vam->input;
19889 vl_api_classify_session_dump_t *mp;
19890 vl_api_control_ping_t *mp_ping;
19894 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19896 if (unformat (input, "table_id %d", &table_id))
19901 if (table_id == ~0)
19903 errmsg ("missing table id");
19907 /* Construct the API message */
19908 M (CLASSIFY_SESSION_DUMP, mp);
19910 mp->table_id = ntohl (table_id);
19913 /* Use a control ping for synchronization */
19914 MPING (CONTROL_PING, mp_ping);
19922 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19924 vat_main_t *vam = &vat_main;
19926 print (vam->ofp, "collector_address %U, collector_port %d, "
19927 "src_address %U, vrf_id %d, path_mtu %u, "
19928 "template_interval %u, udp_checksum %d",
19929 format_ip4_address, mp->collector_address,
19930 ntohs (mp->collector_port),
19931 format_ip4_address, mp->src_address,
19932 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19933 ntohl (mp->template_interval), mp->udp_checksum);
19936 vam->result_ready = 1;
19940 vl_api_ipfix_exporter_details_t_handler_json
19941 (vl_api_ipfix_exporter_details_t * mp)
19943 vat_main_t *vam = &vat_main;
19944 vat_json_node_t node;
19945 struct in_addr collector_address;
19946 struct in_addr src_address;
19948 vat_json_init_object (&node);
19949 clib_memcpy (&collector_address, &mp->collector_address,
19950 sizeof (collector_address));
19951 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19952 vat_json_object_add_uint (&node, "collector_port",
19953 ntohs (mp->collector_port));
19954 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19955 vat_json_object_add_ip4 (&node, "src_address", src_address);
19956 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19957 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19958 vat_json_object_add_uint (&node, "template_interval",
19959 ntohl (mp->template_interval));
19960 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19962 vat_json_print (vam->ofp, &node);
19963 vat_json_free (&node);
19965 vam->result_ready = 1;
19969 api_ipfix_exporter_dump (vat_main_t * vam)
19971 vl_api_ipfix_exporter_dump_t *mp;
19974 /* Construct the API message */
19975 M (IPFIX_EXPORTER_DUMP, mp);
19984 api_ipfix_classify_stream_dump (vat_main_t * vam)
19986 vl_api_ipfix_classify_stream_dump_t *mp;
19989 /* Construct the API message */
19990 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
20001 vl_api_ipfix_classify_stream_details_t_handler
20002 (vl_api_ipfix_classify_stream_details_t * mp)
20004 vat_main_t *vam = &vat_main;
20005 print (vam->ofp, "domain_id %d, src_port %d",
20006 ntohl (mp->domain_id), ntohs (mp->src_port));
20008 vam->result_ready = 1;
20012 vl_api_ipfix_classify_stream_details_t_handler_json
20013 (vl_api_ipfix_classify_stream_details_t * mp)
20015 vat_main_t *vam = &vat_main;
20016 vat_json_node_t node;
20018 vat_json_init_object (&node);
20019 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
20020 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
20022 vat_json_print (vam->ofp, &node);
20023 vat_json_free (&node);
20025 vam->result_ready = 1;
20029 api_ipfix_classify_table_dump (vat_main_t * vam)
20031 vl_api_ipfix_classify_table_dump_t *mp;
20032 vl_api_control_ping_t *mp_ping;
20035 if (!vam->json_output)
20037 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
20038 "transport_protocol");
20041 /* Construct the API message */
20042 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
20047 /* Use a control ping for synchronization */
20048 MPING (CONTROL_PING, mp_ping);
20056 vl_api_ipfix_classify_table_details_t_handler
20057 (vl_api_ipfix_classify_table_details_t * mp)
20059 vat_main_t *vam = &vat_main;
20060 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
20061 mp->transport_protocol);
20065 vl_api_ipfix_classify_table_details_t_handler_json
20066 (vl_api_ipfix_classify_table_details_t * mp)
20068 vat_json_node_t *node = NULL;
20069 vat_main_t *vam = &vat_main;
20071 if (VAT_JSON_ARRAY != vam->json_tree.type)
20073 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20074 vat_json_init_array (&vam->json_tree);
20077 node = vat_json_array_add (&vam->json_tree);
20078 vat_json_init_object (node);
20080 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
20081 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
20082 vat_json_object_add_uint (node, "transport_protocol",
20083 mp->transport_protocol);
20087 api_sw_interface_span_enable_disable (vat_main_t * vam)
20089 unformat_input_t *i = vam->input;
20090 vl_api_sw_interface_span_enable_disable_t *mp;
20091 u32 src_sw_if_index = ~0;
20092 u32 dst_sw_if_index = ~0;
20097 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20100 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
20102 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
20106 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
20108 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
20110 else if (unformat (i, "disable"))
20112 else if (unformat (i, "rx"))
20114 else if (unformat (i, "tx"))
20116 else if (unformat (i, "both"))
20118 else if (unformat (i, "l2"))
20124 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
20126 mp->sw_if_index_from = htonl (src_sw_if_index);
20127 mp->sw_if_index_to = htonl (dst_sw_if_index);
20137 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
20140 vat_main_t *vam = &vat_main;
20141 u8 *sw_if_from_name = 0;
20142 u8 *sw_if_to_name = 0;
20143 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20144 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20145 char *states[] = { "none", "rx", "tx", "both" };
20149 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20151 if ((u32) p->value[0] == sw_if_index_from)
20153 sw_if_from_name = (u8 *)(p->key);
20157 if ((u32) p->value[0] == sw_if_index_to)
20159 sw_if_to_name = (u8 *)(p->key);
20160 if (sw_if_from_name)
20165 print (vam->ofp, "%20s => %20s (%s)",
20166 sw_if_from_name, sw_if_to_name, states[mp->state]);
20170 vl_api_sw_interface_span_details_t_handler_json
20171 (vl_api_sw_interface_span_details_t * mp)
20173 vat_main_t *vam = &vat_main;
20174 vat_json_node_t *node = NULL;
20175 u8 *sw_if_from_name = 0;
20176 u8 *sw_if_to_name = 0;
20177 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20178 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20182 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20184 if ((u32) p->value[0] == sw_if_index_from)
20186 sw_if_from_name = (u8 *)(p->key);
20190 if ((u32) p->value[0] == sw_if_index_to)
20192 sw_if_to_name = (u8 *)(p->key);
20193 if (sw_if_from_name)
20199 if (VAT_JSON_ARRAY != vam->json_tree.type)
20201 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20202 vat_json_init_array (&vam->json_tree);
20204 node = vat_json_array_add (&vam->json_tree);
20206 vat_json_init_object (node);
20207 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
20208 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
20209 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
20210 if (0 != sw_if_to_name)
20212 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
20214 vat_json_object_add_uint (node, "state", mp->state);
20218 api_sw_interface_span_dump (vat_main_t * vam)
20220 unformat_input_t *input = vam->input;
20221 vl_api_sw_interface_span_dump_t *mp;
20222 vl_api_control_ping_t *mp_ping;
20226 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20228 if (unformat (input, "l2"))
20234 M (SW_INTERFACE_SPAN_DUMP, mp);
20238 /* Use a control ping for synchronization */
20239 MPING (CONTROL_PING, mp_ping);
20247 api_pg_create_interface (vat_main_t * vam)
20249 unformat_input_t *input = vam->input;
20250 vl_api_pg_create_interface_t *mp;
20254 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20256 if (unformat (input, "if_id %d", &if_id))
20263 errmsg ("missing pg interface index");
20267 /* Construct the API message */
20268 M (PG_CREATE_INTERFACE, mp);
20270 mp->interface_id = ntohl (if_id);
20278 api_pg_capture (vat_main_t * vam)
20280 unformat_input_t *input = vam->input;
20281 vl_api_pg_capture_t *mp;
20286 u8 pcap_file_set = 0;
20289 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20291 if (unformat (input, "if_id %d", &if_id))
20293 else if (unformat (input, "pcap %s", &pcap_file))
20295 else if (unformat (input, "count %d", &count))
20297 else if (unformat (input, "disable"))
20304 errmsg ("missing pg interface index");
20307 if (pcap_file_set > 0)
20309 if (vec_len (pcap_file) > 255)
20311 errmsg ("pcap file name is too long");
20316 u32 name_len = vec_len (pcap_file);
20317 /* Construct the API message */
20318 M (PG_CAPTURE, mp);
20320 mp->interface_id = ntohl (if_id);
20321 mp->is_enabled = enable;
20322 mp->count = ntohl (count);
20323 mp->pcap_name_length = ntohl (name_len);
20324 if (pcap_file_set != 0)
20326 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
20328 vec_free (pcap_file);
20336 api_pg_enable_disable (vat_main_t * vam)
20338 unformat_input_t *input = vam->input;
20339 vl_api_pg_enable_disable_t *mp;
20342 u8 stream_name_set = 0;
20343 u8 *stream_name = 0;
20345 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20347 if (unformat (input, "stream %s", &stream_name))
20348 stream_name_set = 1;
20349 else if (unformat (input, "disable"))
20355 if (stream_name_set > 0)
20357 if (vec_len (stream_name) > 255)
20359 errmsg ("stream name too long");
20364 u32 name_len = vec_len (stream_name);
20365 /* Construct the API message */
20366 M (PG_ENABLE_DISABLE, mp);
20368 mp->is_enabled = enable;
20369 if (stream_name_set != 0)
20371 mp->stream_name_length = ntohl (name_len);
20372 clib_memcpy (mp->stream_name, stream_name, name_len);
20374 vec_free (stream_name);
20382 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
20384 unformat_input_t *input = vam->input;
20385 vl_api_ip_source_and_port_range_check_add_del_t *mp;
20387 u16 *low_ports = 0;
20388 u16 *high_ports = 0;
20391 ip4_address_t ip4_addr;
20392 ip6_address_t ip6_addr;
20401 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20403 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
20409 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
20414 else if (unformat (input, "vrf %d", &vrf_id))
20416 else if (unformat (input, "del"))
20418 else if (unformat (input, "port %d", &tmp))
20420 if (tmp == 0 || tmp > 65535)
20422 errmsg ("port %d out of range", tmp);
20426 this_hi = this_low + 1;
20427 vec_add1 (low_ports, this_low);
20428 vec_add1 (high_ports, this_hi);
20430 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
20432 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
20434 errmsg ("incorrect range parameters");
20438 /* Note: in debug CLI +1 is added to high before
20439 passing to real fn that does "the work"
20440 (ip_source_and_port_range_check_add_del).
20441 This fn is a wrapper around the binary API fn a
20442 control plane will call, which expects this increment
20443 to have occurred. Hence letting the binary API control
20444 plane fn do the increment for consistency between VAT
20445 and other control planes.
20448 vec_add1 (low_ports, this_low);
20449 vec_add1 (high_ports, this_hi);
20455 if (prefix_set == 0)
20457 errmsg ("<address>/<mask> not specified");
20463 errmsg ("VRF ID required, not specified");
20470 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20474 if (vec_len (low_ports) == 0)
20476 errmsg ("At least one port or port range required");
20480 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
20482 mp->is_add = is_add;
20487 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
20492 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
20495 mp->mask_length = length;
20496 mp->number_of_ranges = vec_len (low_ports);
20498 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
20499 vec_free (low_ports);
20501 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
20502 vec_free (high_ports);
20504 mp->vrf_id = ntohl (vrf_id);
20512 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
20514 unformat_input_t *input = vam->input;
20515 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
20516 u32 sw_if_index = ~0;
20518 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
20519 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
20523 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20525 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20527 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20529 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
20531 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
20533 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
20535 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
20537 else if (unformat (input, "del"))
20543 if (sw_if_index == ~0)
20545 errmsg ("Interface required but not specified");
20551 errmsg ("VRF ID required but not specified");
20555 if (tcp_out_vrf_id == 0
20556 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
20559 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20563 /* Construct the API message */
20564 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
20566 mp->sw_if_index = ntohl (sw_if_index);
20567 mp->is_add = is_add;
20568 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20569 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20570 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20571 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20576 /* Wait for a reply... */
20582 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
20584 unformat_input_t *i = vam->input;
20585 vl_api_ipsec_gre_add_del_tunnel_t *mp;
20586 u32 local_sa_id = 0;
20587 u32 remote_sa_id = 0;
20588 ip4_address_t src_address;
20589 ip4_address_t dst_address;
20593 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20595 if (unformat (i, "local_sa %d", &local_sa_id))
20597 else if (unformat (i, "remote_sa %d", &remote_sa_id))
20599 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
20601 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
20603 else if (unformat (i, "del"))
20607 clib_warning ("parse error '%U'", format_unformat_error, i);
20612 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
20614 mp->local_sa_id = ntohl (local_sa_id);
20615 mp->remote_sa_id = ntohl (remote_sa_id);
20616 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
20617 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
20618 mp->is_add = is_add;
20626 api_punt (vat_main_t * vam)
20628 unformat_input_t *i = vam->input;
20636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20638 if (unformat (i, "ip %d", &ipv))
20640 else if (unformat (i, "protocol %d", &protocol))
20642 else if (unformat (i, "port %d", &port))
20644 else if (unformat (i, "del"))
20648 clib_warning ("parse error '%U'", format_unformat_error, i);
20655 mp->is_add = (u8) is_add;
20656 mp->ipv = (u8) ipv;
20657 mp->l4_protocol = (u8) protocol;
20658 mp->l4_port = htons ((u16) port);
20665 static void vl_api_ipsec_gre_tunnel_details_t_handler
20666 (vl_api_ipsec_gre_tunnel_details_t * mp)
20668 vat_main_t *vam = &vat_main;
20670 print (vam->ofp, "%11d%15U%15U%14d%14d",
20671 ntohl (mp->sw_if_index),
20672 format_ip4_address, &mp->src_address,
20673 format_ip4_address, &mp->dst_address,
20674 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
20677 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
20678 (vl_api_ipsec_gre_tunnel_details_t * mp)
20680 vat_main_t *vam = &vat_main;
20681 vat_json_node_t *node = NULL;
20682 struct in_addr ip4;
20684 if (VAT_JSON_ARRAY != vam->json_tree.type)
20686 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20687 vat_json_init_array (&vam->json_tree);
20689 node = vat_json_array_add (&vam->json_tree);
20691 vat_json_init_object (node);
20692 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20693 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
20694 vat_json_object_add_ip4 (node, "src_address", ip4);
20695 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
20696 vat_json_object_add_ip4 (node, "dst_address", ip4);
20697 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
20698 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
20702 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
20704 unformat_input_t *i = vam->input;
20705 vl_api_ipsec_gre_tunnel_dump_t *mp;
20706 vl_api_control_ping_t *mp_ping;
20708 u8 sw_if_index_set = 0;
20711 /* Parse args required to build the message */
20712 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20714 if (unformat (i, "sw_if_index %d", &sw_if_index))
20715 sw_if_index_set = 1;
20720 if (sw_if_index_set == 0)
20725 if (!vam->json_output)
20727 print (vam->ofp, "%11s%15s%15s%14s%14s",
20728 "sw_if_index", "src_address", "dst_address",
20729 "local_sa_id", "remote_sa_id");
20732 /* Get list of gre-tunnel interfaces */
20733 M (IPSEC_GRE_TUNNEL_DUMP, mp);
20735 mp->sw_if_index = htonl (sw_if_index);
20739 /* Use a control ping for synchronization */
20740 MPING (CONTROL_PING, mp_ping);
20748 api_delete_subif (vat_main_t * vam)
20750 unformat_input_t *i = vam->input;
20751 vl_api_delete_subif_t *mp;
20752 u32 sw_if_index = ~0;
20755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20757 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20759 if (unformat (i, "sw_if_index %d", &sw_if_index))
20765 if (sw_if_index == ~0)
20767 errmsg ("missing sw_if_index");
20771 /* Construct the API message */
20772 M (DELETE_SUBIF, mp);
20773 mp->sw_if_index = ntohl (sw_if_index);
20780 #define foreach_pbb_vtr_op \
20781 _("disable", L2_VTR_DISABLED) \
20782 _("pop", L2_VTR_POP_2) \
20783 _("push", L2_VTR_PUSH_2)
20786 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20788 unformat_input_t *i = vam->input;
20789 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20790 u32 sw_if_index = ~0, vtr_op = ~0;
20791 u16 outer_tag = ~0;
20792 u8 dmac[6], smac[6];
20793 u8 dmac_set = 0, smac_set = 0;
20799 /* Shut up coverity */
20800 memset (dmac, 0, sizeof (dmac));
20801 memset (smac, 0, sizeof (smac));
20803 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20805 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20807 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20809 else if (unformat (i, "vtr_op %d", &vtr_op))
20811 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20814 else if (unformat (i, "translate_pbb_stag"))
20816 if (unformat (i, "%d", &tmp))
20818 vtr_op = L2_VTR_TRANSLATE_2_1;
20824 ("translate_pbb_stag operation requires outer tag definition");
20828 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20830 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20832 else if (unformat (i, "sid %d", &sid))
20834 else if (unformat (i, "vlanid %d", &tmp))
20838 clib_warning ("parse error '%U'", format_unformat_error, i);
20843 if ((sw_if_index == ~0) || (vtr_op == ~0))
20845 errmsg ("missing sw_if_index or vtr operation");
20848 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20849 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20852 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20856 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20857 mp->sw_if_index = ntohl (sw_if_index);
20858 mp->vtr_op = ntohl (vtr_op);
20859 mp->outer_tag = ntohs (outer_tag);
20860 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20861 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20862 mp->b_vlanid = ntohs (vlanid);
20863 mp->i_sid = ntohl (sid);
20871 api_flow_classify_set_interface (vat_main_t * vam)
20873 unformat_input_t *i = vam->input;
20874 vl_api_flow_classify_set_interface_t *mp;
20876 int sw_if_index_set;
20877 u32 ip4_table_index = ~0;
20878 u32 ip6_table_index = ~0;
20882 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20884 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20885 sw_if_index_set = 1;
20886 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20887 sw_if_index_set = 1;
20888 else if (unformat (i, "del"))
20890 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20892 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20896 clib_warning ("parse error '%U'", format_unformat_error, i);
20901 if (sw_if_index_set == 0)
20903 errmsg ("missing interface name or sw_if_index");
20907 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20909 mp->sw_if_index = ntohl (sw_if_index);
20910 mp->ip4_table_index = ntohl (ip4_table_index);
20911 mp->ip6_table_index = ntohl (ip6_table_index);
20912 mp->is_add = is_add;
20920 api_flow_classify_dump (vat_main_t * vam)
20922 unformat_input_t *i = vam->input;
20923 vl_api_flow_classify_dump_t *mp;
20924 vl_api_control_ping_t *mp_ping;
20925 u8 type = FLOW_CLASSIFY_N_TABLES;
20928 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20932 errmsg ("classify table type must be specified");
20936 if (!vam->json_output)
20938 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20941 M (FLOW_CLASSIFY_DUMP, mp);
20946 /* Use a control ping for synchronization */
20947 MPING (CONTROL_PING, mp_ping);
20950 /* Wait for a reply... */
20956 api_feature_enable_disable (vat_main_t * vam)
20958 unformat_input_t *i = vam->input;
20959 vl_api_feature_enable_disable_t *mp;
20961 u8 *feature_name = 0;
20962 u32 sw_if_index = ~0;
20966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20968 if (unformat (i, "arc_name %s", &arc_name))
20970 else if (unformat (i, "feature_name %s", &feature_name))
20973 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20975 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20977 else if (unformat (i, "disable"))
20985 errmsg ("missing arc name");
20988 if (vec_len (arc_name) > 63)
20990 errmsg ("arc name too long");
20993 if (feature_name == 0)
20995 errmsg ("missing feature name");
20998 if (vec_len (feature_name) > 63)
21000 errmsg ("feature name too long");
21003 if (sw_if_index == ~0)
21005 errmsg ("missing interface name or sw_if_index");
21009 /* Construct the API message */
21010 M (FEATURE_ENABLE_DISABLE, mp);
21011 mp->sw_if_index = ntohl (sw_if_index);
21012 mp->enable = enable;
21013 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
21014 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
21015 vec_free (arc_name);
21016 vec_free (feature_name);
21024 api_sw_interface_tag_add_del (vat_main_t * vam)
21026 unformat_input_t *i = vam->input;
21027 vl_api_sw_interface_tag_add_del_t *mp;
21028 u32 sw_if_index = ~0;
21033 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21035 if (unformat (i, "tag %s", &tag))
21037 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21039 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21041 else if (unformat (i, "del"))
21047 if (sw_if_index == ~0)
21049 errmsg ("missing interface name or sw_if_index");
21053 if (enable && (tag == 0))
21055 errmsg ("no tag specified");
21059 /* Construct the API message */
21060 M (SW_INTERFACE_TAG_ADD_DEL, mp);
21061 mp->sw_if_index = ntohl (sw_if_index);
21062 mp->is_add = enable;
21064 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
21072 static void vl_api_l2_xconnect_details_t_handler
21073 (vl_api_l2_xconnect_details_t * mp)
21075 vat_main_t *vam = &vat_main;
21077 print (vam->ofp, "%15d%15d",
21078 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
21081 static void vl_api_l2_xconnect_details_t_handler_json
21082 (vl_api_l2_xconnect_details_t * mp)
21084 vat_main_t *vam = &vat_main;
21085 vat_json_node_t *node = NULL;
21087 if (VAT_JSON_ARRAY != vam->json_tree.type)
21089 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21090 vat_json_init_array (&vam->json_tree);
21092 node = vat_json_array_add (&vam->json_tree);
21094 vat_json_init_object (node);
21095 vat_json_object_add_uint (node, "rx_sw_if_index",
21096 ntohl (mp->rx_sw_if_index));
21097 vat_json_object_add_uint (node, "tx_sw_if_index",
21098 ntohl (mp->tx_sw_if_index));
21102 api_l2_xconnect_dump (vat_main_t * vam)
21104 vl_api_l2_xconnect_dump_t *mp;
21105 vl_api_control_ping_t *mp_ping;
21108 if (!vam->json_output)
21110 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
21113 M (L2_XCONNECT_DUMP, mp);
21117 /* Use a control ping for synchronization */
21118 MPING (CONTROL_PING, mp_ping);
21126 api_sw_interface_set_mtu (vat_main_t * vam)
21128 unformat_input_t *i = vam->input;
21129 vl_api_sw_interface_set_mtu_t *mp;
21130 u32 sw_if_index = ~0;
21134 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21136 if (unformat (i, "mtu %d", &mtu))
21138 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21140 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21146 if (sw_if_index == ~0)
21148 errmsg ("missing interface name or sw_if_index");
21154 errmsg ("no mtu specified");
21158 /* Construct the API message */
21159 M (SW_INTERFACE_SET_MTU, mp);
21160 mp->sw_if_index = ntohl (sw_if_index);
21161 mp->mtu = ntohs ((u16) mtu);
21169 api_p2p_ethernet_add (vat_main_t * vam)
21171 unformat_input_t *i = vam->input;
21172 vl_api_p2p_ethernet_add_t *mp;
21173 u32 parent_if_index = ~0;
21179 memset (remote_mac, 0, sizeof (remote_mac));
21180 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21182 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21184 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21188 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21190 else if (unformat (i, "sub_id %d", &sub_id))
21194 clib_warning ("parse error '%U'", format_unformat_error, i);
21199 if (parent_if_index == ~0)
21201 errmsg ("missing interface name or sw_if_index");
21206 errmsg ("missing remote mac address");
21211 errmsg ("missing sub-interface id");
21215 M (P2P_ETHERNET_ADD, mp);
21216 mp->parent_if_index = ntohl (parent_if_index);
21217 mp->subif_id = ntohl (sub_id);
21218 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21226 api_p2p_ethernet_del (vat_main_t * vam)
21228 unformat_input_t *i = vam->input;
21229 vl_api_p2p_ethernet_del_t *mp;
21230 u32 parent_if_index = ~0;
21235 memset (remote_mac, 0, sizeof (remote_mac));
21236 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21238 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21240 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21244 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21248 clib_warning ("parse error '%U'", format_unformat_error, i);
21253 if (parent_if_index == ~0)
21255 errmsg ("missing interface name or sw_if_index");
21260 errmsg ("missing remote mac address");
21264 M (P2P_ETHERNET_DEL, mp);
21265 mp->parent_if_index = ntohl (parent_if_index);
21266 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21274 api_lldp_config (vat_main_t * vam)
21276 unformat_input_t *i = vam->input;
21277 vl_api_lldp_config_t *mp;
21279 int tx_interval = 0;
21280 u8 *sys_name = NULL;
21283 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21285 if (unformat (i, "system-name %s", &sys_name))
21287 else if (unformat (i, "tx-hold %d", &tx_hold))
21289 else if (unformat (i, "tx-interval %d", &tx_interval))
21293 clib_warning ("parse error '%U'", format_unformat_error, i);
21298 vec_add1 (sys_name, 0);
21300 M (LLDP_CONFIG, mp);
21301 mp->tx_hold = htonl (tx_hold);
21302 mp->tx_interval = htonl (tx_interval);
21303 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
21304 vec_free (sys_name);
21312 api_sw_interface_set_lldp (vat_main_t * vam)
21314 unformat_input_t *i = vam->input;
21315 vl_api_sw_interface_set_lldp_t *mp;
21316 u32 sw_if_index = ~0;
21318 u8 *port_desc = NULL, *mgmt_oid = NULL;
21319 ip4_address_t ip4_addr;
21320 ip6_address_t ip6_addr;
21323 memset (&ip4_addr, 0, sizeof (ip4_addr));
21324 memset (&ip6_addr, 0, sizeof (ip6_addr));
21326 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21328 if (unformat (i, "disable"))
21331 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21333 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21335 else if (unformat (i, "port-desc %s", &port_desc))
21337 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
21339 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
21341 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
21347 if (sw_if_index == ~0)
21349 errmsg ("missing interface name or sw_if_index");
21353 /* Construct the API message */
21354 vec_add1 (port_desc, 0);
21355 vec_add1 (mgmt_oid, 0);
21356 M (SW_INTERFACE_SET_LLDP, mp);
21357 mp->sw_if_index = ntohl (sw_if_index);
21358 mp->enable = enable;
21359 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
21360 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
21361 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
21362 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
21363 vec_free (port_desc);
21364 vec_free (mgmt_oid);
21372 api_tcp_configure_src_addresses (vat_main_t * vam)
21374 vl_api_tcp_configure_src_addresses_t *mp;
21375 unformat_input_t *i = vam->input;
21376 ip4_address_t v4first, v4last;
21377 ip6_address_t v6first, v6last;
21382 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21384 if (unformat (i, "%U - %U",
21385 unformat_ip4_address, &v4first,
21386 unformat_ip4_address, &v4last))
21390 errmsg ("one range per message (range already set)");
21395 else if (unformat (i, "%U - %U",
21396 unformat_ip6_address, &v6first,
21397 unformat_ip6_address, &v6last))
21401 errmsg ("one range per message (range already set)");
21406 else if (unformat (i, "vrf %d", &vrf_id))
21412 if (range_set == 0)
21414 errmsg ("address range not set");
21418 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
21419 mp->vrf_id = ntohl (vrf_id);
21421 if (range_set == 2)
21424 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
21425 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
21430 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
21431 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
21438 static void vl_api_app_namespace_add_del_reply_t_handler
21439 (vl_api_app_namespace_add_del_reply_t * mp)
21441 vat_main_t *vam = &vat_main;
21442 i32 retval = ntohl (mp->retval);
21443 if (vam->async_mode)
21445 vam->async_errors += (retval < 0);
21449 vam->retval = retval;
21451 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
21452 vam->result_ready = 1;
21456 static void vl_api_app_namespace_add_del_reply_t_handler_json
21457 (vl_api_app_namespace_add_del_reply_t * mp)
21459 vat_main_t *vam = &vat_main;
21460 vat_json_node_t node;
21462 vat_json_init_object (&node);
21463 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
21464 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
21466 vat_json_print (vam->ofp, &node);
21467 vat_json_free (&node);
21469 vam->retval = ntohl (mp->retval);
21470 vam->result_ready = 1;
21474 api_app_namespace_add_del (vat_main_t * vam)
21476 vl_api_app_namespace_add_del_t *mp;
21477 unformat_input_t *i = vam->input;
21478 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
21479 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
21483 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21485 if (unformat (i, "id %_%v%_", &ns_id))
21487 else if (unformat (i, "secret %lu", &secret))
21489 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21490 sw_if_index_set = 1;
21491 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
21493 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
21498 if (!ns_id || !secret_set || !sw_if_index_set)
21500 errmsg ("namespace id, secret and sw_if_index must be set");
21503 if (vec_len (ns_id) > 64)
21505 errmsg ("namespace id too long");
21508 M (APP_NAMESPACE_ADD_DEL, mp);
21510 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
21511 mp->namespace_id_len = vec_len (ns_id);
21512 mp->secret = clib_host_to_net_u64 (secret);
21513 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21514 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
21515 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
21523 api_memfd_segment_create (vat_main_t * vam)
21525 #if VPP_API_TEST_BUILTIN == 0
21526 unformat_input_t *i = vam->input;
21527 vl_api_memfd_segment_create_t *mp;
21528 u64 size = 64 << 20;
21531 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21533 if (unformat (i, "size %U", unformat_memory_size, &size))
21539 M (MEMFD_SEGMENT_CREATE, mp);
21540 mp->requested_size = size;
21546 errmsg ("memfd_segment_create (builtin) not supported");
21552 api_dns_enable_disable (vat_main_t * vam)
21554 unformat_input_t *line_input = vam->input;
21555 vl_api_dns_enable_disable_t *mp;
21556 u8 enable_disable = 1;
21559 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21561 if (unformat (line_input, "disable"))
21562 enable_disable = 0;
21563 if (unformat (line_input, "enable"))
21564 enable_disable = 1;
21569 /* Construct the API message */
21570 M (DNS_ENABLE_DISABLE, mp);
21571 mp->enable = enable_disable;
21575 /* Wait for the reply */
21581 api_dns_resolve_name (vat_main_t * vam)
21583 unformat_input_t *line_input = vam->input;
21584 vl_api_dns_resolve_name_t *mp;
21588 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21590 if (unformat (line_input, "%s", &name))
21596 if (vec_len (name) > 127)
21598 errmsg ("name too long");
21602 /* Construct the API message */
21603 M (DNS_RESOLVE_NAME, mp);
21604 memcpy (mp->name, name, vec_len (name));
21609 /* Wait for the reply */
21615 api_dns_resolve_ip (vat_main_t * vam)
21617 unformat_input_t *line_input = vam->input;
21618 vl_api_dns_resolve_ip_t *mp;
21620 ip4_address_t addr4;
21621 ip6_address_t addr6;
21624 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21626 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
21628 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
21636 errmsg ("missing address");
21640 /* Construct the API message */
21641 M (DNS_RESOLVE_IP, mp);
21642 mp->is_ip6 = is_ip6;
21644 memcpy (mp->address, &addr6, sizeof (addr6));
21646 memcpy (mp->address, &addr4, sizeof (addr4));
21650 /* Wait for the reply */
21656 api_dns_name_server_add_del (vat_main_t * vam)
21658 unformat_input_t *i = vam->input;
21659 vl_api_dns_name_server_add_del_t *mp;
21661 ip6_address_t ip6_server;
21662 ip4_address_t ip4_server;
21667 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21669 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
21671 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
21673 else if (unformat (i, "del"))
21677 clib_warning ("parse error '%U'", format_unformat_error, i);
21682 if (ip4_set && ip6_set)
21684 errmsg ("Only one server address allowed per message");
21687 if ((ip4_set + ip6_set) == 0)
21689 errmsg ("Server address required");
21693 /* Construct the API message */
21694 M (DNS_NAME_SERVER_ADD_DEL, mp);
21698 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
21703 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
21707 mp->is_add = is_add;
21712 /* Wait for a reply, return good/bad news */
21718 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
21720 vat_main_t *vam = &vat_main;
21725 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21726 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21727 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
21728 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
21729 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21730 clib_net_to_host_u32 (mp->action_index), mp->tag);
21735 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21736 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21737 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
21738 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
21739 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21740 clib_net_to_host_u32 (mp->action_index), mp->tag);
21745 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
21748 vat_main_t *vam = &vat_main;
21749 vat_json_node_t *node = NULL;
21750 struct in6_addr ip6;
21751 struct in_addr ip4;
21753 if (VAT_JSON_ARRAY != vam->json_tree.type)
21755 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21756 vat_json_init_array (&vam->json_tree);
21758 node = vat_json_array_add (&vam->json_tree);
21759 vat_json_init_object (node);
21761 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
21762 vat_json_object_add_uint (node, "appns_index",
21763 clib_net_to_host_u32 (mp->appns_index));
21764 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
21765 vat_json_object_add_uint (node, "scope", mp->scope);
21766 vat_json_object_add_uint (node, "action_index",
21767 clib_net_to_host_u32 (mp->action_index));
21768 vat_json_object_add_uint (node, "lcl_port",
21769 clib_net_to_host_u16 (mp->lcl_port));
21770 vat_json_object_add_uint (node, "rmt_port",
21771 clib_net_to_host_u16 (mp->rmt_port));
21772 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
21773 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
21774 vat_json_object_add_string_copy (node, "tag", mp->tag);
21777 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
21778 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
21779 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
21780 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
21784 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
21785 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
21786 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
21787 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
21792 api_session_rule_add_del (vat_main_t * vam)
21794 vl_api_session_rule_add_del_t *mp;
21795 unformat_input_t *i = vam->input;
21796 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
21797 u32 appns_index = 0, scope = 0;
21798 ip4_address_t lcl_ip4, rmt_ip4;
21799 ip6_address_t lcl_ip6, rmt_ip6;
21800 u8 is_ip4 = 1, conn_set = 0;
21801 u8 is_add = 1, *tag = 0;
21804 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21806 if (unformat (i, "del"))
21808 else if (unformat (i, "add"))
21810 else if (unformat (i, "proto tcp"))
21812 else if (unformat (i, "proto udp"))
21814 else if (unformat (i, "appns %d", &appns_index))
21816 else if (unformat (i, "scope %d", &scope))
21818 else if (unformat (i, "tag %_%v%_", &tag))
21822 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
21823 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
21831 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
21832 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
21838 else if (unformat (i, "action %d", &action))
21843 if (proto == ~0 || !conn_set || action == ~0)
21845 errmsg ("transport proto, connection and action must be set");
21851 errmsg ("scope should be 0-3");
21855 M (SESSION_RULE_ADD_DEL, mp);
21857 mp->is_ip4 = is_ip4;
21858 mp->transport_proto = proto;
21859 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
21860 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
21861 mp->lcl_plen = lcl_plen;
21862 mp->rmt_plen = rmt_plen;
21863 mp->action_index = clib_host_to_net_u32 (action);
21864 mp->appns_index = clib_host_to_net_u32 (appns_index);
21866 mp->is_add = is_add;
21869 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
21870 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
21874 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
21875 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
21879 clib_memcpy (mp->tag, tag, vec_len (tag));
21889 api_session_rules_dump (vat_main_t * vam)
21891 vl_api_session_rules_dump_t *mp;
21892 vl_api_control_ping_t *mp_ping;
21895 if (!vam->json_output)
21897 print (vam->ofp, "%=20s", "Session Rules");
21900 M (SESSION_RULES_DUMP, mp);
21904 /* Use a control ping for synchronization */
21905 MPING (CONTROL_PING, mp_ping);
21908 /* Wait for a reply... */
21914 api_ip_container_proxy_add_del (vat_main_t * vam)
21916 vl_api_ip_container_proxy_add_del_t *mp;
21917 unformat_input_t *i = vam->input;
21918 u32 plen = ~0, sw_if_index = ~0;
21925 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21927 if (unformat (i, "del"))
21929 else if (unformat (i, "add"))
21931 if (unformat (i, "%U", unformat_ip4_address, &ip4))
21936 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
21941 else if (unformat (i, "sw_if_index %u", &sw_if_index))
21946 if (sw_if_index == ~0 || plen == ~0)
21948 errmsg ("address and sw_if_index must be set");
21952 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
21954 mp->is_ip4 = is_ip4;
21955 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21957 mp->is_add = is_add;
21959 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
21961 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
21969 q_or_quit (vat_main_t * vam)
21971 #if VPP_API_TEST_BUILTIN == 0
21972 longjmp (vam->jump_buf, 1);
21974 return 0; /* not so much */
21978 q (vat_main_t * vam)
21980 return q_or_quit (vam);
21984 quit (vat_main_t * vam)
21986 return q_or_quit (vam);
21990 comment (vat_main_t * vam)
21996 cmd_cmp (void *a1, void *a2)
22001 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
22005 help (vat_main_t * vam)
22010 unformat_input_t *i = vam->input;
22013 if (unformat (i, "%s", &name))
22017 vec_add1 (name, 0);
22019 hs = hash_get_mem (vam->help_by_name, name);
22021 print (vam->ofp, "usage: %s %s", name, hs[0]);
22023 print (vam->ofp, "No such msg / command '%s'", name);
22028 print (vam->ofp, "Help is available for the following:");
22031 hash_foreach_pair (p, vam->function_by_name,
22033 vec_add1 (cmds, (u8 *)(p->key));
22037 vec_sort_with_function (cmds, cmd_cmp);
22039 for (j = 0; j < vec_len (cmds); j++)
22040 print (vam->ofp, "%s", cmds[j]);
22047 set (vat_main_t * vam)
22049 u8 *name = 0, *value = 0;
22050 unformat_input_t *i = vam->input;
22052 if (unformat (i, "%s", &name))
22054 /* The input buffer is a vector, not a string. */
22055 value = vec_dup (i->buffer);
22056 vec_delete (value, i->index, 0);
22057 /* Almost certainly has a trailing newline */
22058 if (value[vec_len (value) - 1] == '\n')
22059 value[vec_len (value) - 1] = 0;
22060 /* Make sure it's a proper string, one way or the other */
22061 vec_add1 (value, 0);
22062 (void) clib_macro_set_value (&vam->macro_main,
22063 (char *) name, (char *) value);
22066 errmsg ("usage: set <name> <value>");
22074 unset (vat_main_t * vam)
22078 if (unformat (vam->input, "%s", &name))
22079 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
22080 errmsg ("unset: %s wasn't set", name);
22093 macro_sort_cmp (void *a1, void *a2)
22095 macro_sort_t *s1 = a1;
22096 macro_sort_t *s2 = a2;
22098 return strcmp ((char *) (s1->name), (char *) (s2->name));
22102 dump_macro_table (vat_main_t * vam)
22104 macro_sort_t *sort_me = 0, *sm;
22109 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
22111 vec_add2 (sort_me, sm, 1);
22112 sm->name = (u8 *)(p->key);
22113 sm->value = (u8 *) (p->value[0]);
22117 vec_sort_with_function (sort_me, macro_sort_cmp);
22119 if (vec_len (sort_me))
22120 print (vam->ofp, "%-15s%s", "Name", "Value");
22122 print (vam->ofp, "The macro table is empty...");
22124 for (i = 0; i < vec_len (sort_me); i++)
22125 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
22130 dump_node_table (vat_main_t * vam)
22133 vlib_node_t *node, *next_node;
22135 if (vec_len (vam->graph_nodes) == 0)
22137 print (vam->ofp, "Node table empty, issue get_node_graph...");
22141 for (i = 0; i < vec_len (vam->graph_nodes); i++)
22143 node = vam->graph_nodes[i];
22144 print (vam->ofp, "[%d] %s", i, node->name);
22145 for (j = 0; j < vec_len (node->next_nodes); j++)
22147 if (node->next_nodes[j] != ~0)
22149 next_node = vam->graph_nodes[node->next_nodes[j]];
22150 print (vam->ofp, " [%d] %s", j, next_node->name);
22158 value_sort_cmp (void *a1, void *a2)
22160 name_sort_t *n1 = a1;
22161 name_sort_t *n2 = a2;
22163 if (n1->value < n2->value)
22165 if (n1->value > n2->value)
22172 dump_msg_api_table (vat_main_t * vam)
22174 api_main_t *am = &api_main;
22175 name_sort_t *nses = 0, *ns;
22180 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
22182 vec_add2 (nses, ns, 1);
22183 ns->name = (u8 *)(hp->key);
22184 ns->value = (u32) hp->value[0];
22188 vec_sort_with_function (nses, value_sort_cmp);
22190 for (i = 0; i < vec_len (nses); i++)
22191 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
22197 get_msg_id (vat_main_t * vam)
22202 if (unformat (vam->input, "%s", &name_and_crc))
22204 message_index = vl_api_get_msg_index (name_and_crc);
22205 if (message_index == ~0)
22207 print (vam->ofp, " '%s' not found", name_and_crc);
22210 print (vam->ofp, " '%s' has message index %d",
22211 name_and_crc, message_index);
22214 errmsg ("name_and_crc required...");
22219 search_node_table (vat_main_t * vam)
22221 unformat_input_t *line_input = vam->input;
22224 vlib_node_t *node, *next_node;
22227 if (vam->graph_node_index_by_name == 0)
22229 print (vam->ofp, "Node table empty, issue get_node_graph...");
22233 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22235 if (unformat (line_input, "%s", &node_to_find))
22237 vec_add1 (node_to_find, 0);
22238 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
22241 print (vam->ofp, "%s not found...", node_to_find);
22244 node = vam->graph_nodes[p[0]];
22245 print (vam->ofp, "[%d] %s", p[0], node->name);
22246 for (j = 0; j < vec_len (node->next_nodes); j++)
22248 if (node->next_nodes[j] != ~0)
22250 next_node = vam->graph_nodes[node->next_nodes[j]];
22251 print (vam->ofp, " [%d] %s", j, next_node->name);
22258 clib_warning ("parse error '%U'", format_unformat_error,
22264 vec_free (node_to_find);
22273 script (vat_main_t * vam)
22275 #if (VPP_API_TEST_BUILTIN==0)
22277 char *save_current_file;
22278 unformat_input_t save_input;
22279 jmp_buf save_jump_buf;
22280 u32 save_line_number;
22282 FILE *new_fp, *save_ifp;
22284 if (unformat (vam->input, "%s", &s))
22286 new_fp = fopen ((char *) s, "r");
22289 errmsg ("Couldn't open script file %s", s);
22296 errmsg ("Missing script name");
22300 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
22301 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
22302 save_ifp = vam->ifp;
22303 save_line_number = vam->input_line_number;
22304 save_current_file = (char *) vam->current_file;
22306 vam->input_line_number = 0;
22308 vam->current_file = s;
22311 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
22312 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
22313 vam->ifp = save_ifp;
22314 vam->input_line_number = save_line_number;
22315 vam->current_file = (u8 *) save_current_file;
22320 clib_warning ("use the exec command...");
22326 echo (vat_main_t * vam)
22328 print (vam->ofp, "%v", vam->input->buffer);
22332 /* List of API message constructors, CLI names map to api_xxx */
22333 #define foreach_vpe_api_msg \
22334 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
22335 _(sw_interface_dump,"") \
22336 _(sw_interface_set_flags, \
22337 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
22338 _(sw_interface_add_del_address, \
22339 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
22340 _(sw_interface_set_rx_mode, \
22341 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
22342 _(sw_interface_set_table, \
22343 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
22344 _(sw_interface_set_mpls_enable, \
22345 "<intfc> | sw_if_index [disable | dis]") \
22346 _(sw_interface_set_vpath, \
22347 "<intfc> | sw_if_index <id> enable | disable") \
22348 _(sw_interface_set_vxlan_bypass, \
22349 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22350 _(sw_interface_set_geneve_bypass, \
22351 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22352 _(sw_interface_set_l2_xconnect, \
22353 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22354 "enable | disable") \
22355 _(sw_interface_set_l2_bridge, \
22356 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
22357 "[shg <split-horizon-group>] [bvi]\n" \
22358 "enable | disable") \
22359 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
22360 _(bridge_domain_add_del, \
22361 "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 <text>] [del]\n") \
22362 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
22364 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
22365 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
22366 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
22368 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22370 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22372 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
22374 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
22376 "<vpp-if-name> | sw_if_index <id>") \
22377 _(sw_interface_tap_dump, "") \
22378 _(ip_table_add_del, \
22379 "table-id <n> [ipv6]\n") \
22380 _(ip_add_del_route, \
22381 "<addr>/<mask> via <addr> [table-id <n>]\n" \
22382 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
22383 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
22384 "[multipath] [count <n>]") \
22385 _(ip_mroute_add_del, \
22386 "<src> <grp>/<mask> [table-id <n>]\n" \
22387 "[<intfc> | sw_if_index <id>] [local] [del]") \
22388 _(mpls_table_add_del, \
22389 "table-id <n>\n") \
22390 _(mpls_route_add_del, \
22391 "<label> <eos> via <addr> [table-id <n>]\n" \
22392 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
22393 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
22394 "[multipath] [count <n>]") \
22395 _(mpls_ip_bind_unbind, \
22396 "<label> <addr/len>") \
22397 _(mpls_tunnel_add_del, \
22398 " via <addr> [table-id <n>]\n" \
22399 "sw_if_index <id>] [l2] [del]") \
22400 _(bier_table_add_del, \
22401 "<label> <sub-domain> <set> <bsl> [del]") \
22402 _(bier_route_add_del, \
22403 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
22404 "[<intfc> | sw_if_index <id>]" \
22405 "[weight <n>] [del] [multipath]") \
22406 _(proxy_arp_add_del, \
22407 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
22408 _(proxy_arp_intfc_enable_disable, \
22409 "<intfc> | sw_if_index <id> enable | disable") \
22410 _(sw_interface_set_unnumbered, \
22411 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
22412 _(ip_neighbor_add_del, \
22413 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
22414 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
22415 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
22416 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
22417 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
22418 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
22419 "[outer_vlan_id_any][inner_vlan_id_any]") \
22420 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
22421 _(reset_fib, "vrf <n> [ipv6]") \
22422 _(dhcp_proxy_config, \
22423 "svr <v46-address> src <v46-address>\n" \
22424 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
22425 _(dhcp_proxy_set_vss, \
22426 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
22427 _(dhcp_proxy_dump, "ip6") \
22428 _(dhcp_client_config, \
22429 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
22430 _(set_ip_flow_hash, \
22431 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
22432 _(sw_interface_ip6_enable_disable, \
22433 "<intfc> | sw_if_index <id> enable | disable") \
22434 _(sw_interface_ip6_set_link_local_address, \
22435 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
22436 _(ip6nd_proxy_add_del, \
22437 "<intfc> | sw_if_index <id> <ip6-address>") \
22438 _(ip6nd_proxy_dump, "") \
22439 _(sw_interface_ip6nd_ra_prefix, \
22440 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
22441 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
22442 "[nolink] [isno]") \
22443 _(sw_interface_ip6nd_ra_config, \
22444 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
22445 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
22446 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
22447 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
22448 _(l2_patch_add_del, \
22449 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22450 "enable | disable") \
22451 _(sr_localsid_add_del, \
22452 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
22453 "fib-table <num> (end.psp) sw_if_index <num>") \
22454 _(classify_add_del_table, \
22455 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
22456 " [del] [del-chain] mask <mask-value>\n" \
22457 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
22458 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
22459 _(classify_add_del_session, \
22460 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
22461 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
22462 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
22463 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
22464 _(classify_set_interface_ip_table, \
22465 "<intfc> | sw_if_index <nn> table <nn>") \
22466 _(classify_set_interface_l2_tables, \
22467 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22468 " [other-table <nn>]") \
22469 _(get_node_index, "node <node-name") \
22470 _(add_node_next, "node <node-name> next <next-node-name>") \
22471 _(l2tpv3_create_tunnel, \
22472 "client_address <ip6-addr> our_address <ip6-addr>\n" \
22473 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
22474 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
22475 _(l2tpv3_set_tunnel_cookies, \
22476 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
22477 "[new_remote_cookie <nn>]\n") \
22478 _(l2tpv3_interface_enable_disable, \
22479 "<intfc> | sw_if_index <nn> enable | disable") \
22480 _(l2tpv3_set_lookup_key, \
22481 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
22482 _(sw_if_l2tpv3_tunnel_dump, "") \
22483 _(vxlan_add_del_tunnel, \
22484 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22485 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22486 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22487 _(geneve_add_del_tunnel, \
22488 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22489 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22490 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22491 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22492 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22493 _(gre_add_del_tunnel, \
22494 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
22495 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22496 _(l2_fib_clear_table, "") \
22497 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
22498 _(l2_interface_vlan_tag_rewrite, \
22499 "<intfc> | sw_if_index <nn> \n" \
22500 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
22501 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
22502 _(create_vhost_user_if, \
22503 "socket <filename> [server] [renumber <dev_instance>] " \
22504 "[mac <mac_address>]") \
22505 _(modify_vhost_user_if, \
22506 "<intfc> | sw_if_index <nn> socket <filename>\n" \
22507 "[server] [renumber <dev_instance>]") \
22508 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
22509 _(sw_interface_vhost_user_dump, "") \
22510 _(show_version, "") \
22511 _(vxlan_gpe_add_del_tunnel, \
22512 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
22513 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22514 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
22515 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
22516 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22517 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
22518 _(interface_name_renumber, \
22519 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
22520 _(input_acl_set_interface, \
22521 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22522 " [l2-table <nn>] [del]") \
22523 _(want_ip4_arp_events, "address <ip4-address> [del]") \
22524 _(want_ip6_nd_events, "address <ip6-address> [del]") \
22525 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
22526 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
22527 _(ip_dump, "ipv4 | ipv6") \
22528 _(ipsec_spd_add_del, "spd_id <n> [del]") \
22529 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
22531 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
22532 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
22533 " integ_alg <alg> integ_key <hex>") \
22534 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
22535 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
22536 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
22537 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
22538 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
22539 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
22540 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
22541 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
22542 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
22543 _(ipsec_sa_dump, "[sa_id <n>]") \
22544 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
22545 " <alg> <hex>\n") \
22546 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
22547 _(ikev2_profile_add_del, "name <profile_name> [del]") \
22548 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
22549 "(auth_data 0x<data> | auth_data <data>)") \
22550 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
22551 "(id_data 0x<data> | id_data <data>) (local|remote)") \
22552 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
22553 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
22554 "(local|remote)") \
22555 _(ikev2_set_local_key, "file <absolute_file_path>") \
22556 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
22557 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
22558 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
22559 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
22560 _(ikev2_initiate_sa_init, "<profile_name>") \
22561 _(ikev2_initiate_del_ike_sa, "<ispi>") \
22562 _(ikev2_initiate_del_child_sa, "<ispi>") \
22563 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
22564 _(delete_loopback,"sw_if_index <nn>") \
22565 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
22566 _(map_add_domain, \
22567 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
22568 "ip6-src <ip6addr> " \
22569 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
22570 _(map_del_domain, "index <n>") \
22571 _(map_add_del_rule, \
22572 "index <n> psid <n> dst <ip6addr> [del]") \
22573 _(map_domain_dump, "") \
22574 _(map_rule_dump, "index <map-domain>") \
22575 _(want_interface_events, "enable|disable") \
22576 _(want_stats,"enable|disable") \
22577 _(get_first_msg_id, "client <name>") \
22578 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
22579 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
22580 "fib-id <nn> [ip4][ip6][default]") \
22581 _(get_node_graph, " ") \
22582 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
22583 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
22584 _(ioam_disable, "") \
22585 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
22586 " sw_if_index <sw_if_index> p <priority> " \
22587 "w <weight>] [del]") \
22588 _(one_add_del_locator, "locator-set <locator_name> " \
22589 "iface <intf> | sw_if_index <sw_if_index> " \
22590 "p <priority> w <weight> [del]") \
22591 _(one_add_del_local_eid,"vni <vni> eid " \
22592 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22593 "locator-set <locator_name> [del]" \
22594 "[key-id sha1|sha256 secret-key <secret-key>]")\
22595 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
22596 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
22597 _(one_enable_disable, "enable|disable") \
22598 _(one_map_register_enable_disable, "enable|disable") \
22599 _(one_map_register_fallback_threshold, "<value>") \
22600 _(one_rloc_probe_enable_disable, "enable|disable") \
22601 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22603 "rloc <locator> p <prio> " \
22604 "w <weight> [rloc <loc> ... ] " \
22605 "action <action> [del-all]") \
22606 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22608 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22609 _(one_use_petr, "ip-address> | disable") \
22610 _(one_map_request_mode, "src-dst|dst-only") \
22611 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22612 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22613 _(one_locator_set_dump, "[local | remote]") \
22614 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
22615 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22616 "[local] | [remote]") \
22617 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
22618 _(one_ndp_bd_get, "") \
22619 _(one_ndp_entries_get, "bd <bridge-domain>") \
22620 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
22621 _(one_l2_arp_bd_get, "") \
22622 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
22623 _(one_stats_enable_disable, "enable|disalbe") \
22624 _(show_one_stats_enable_disable, "") \
22625 _(one_eid_table_vni_dump, "") \
22626 _(one_eid_table_map_dump, "l2|l3") \
22627 _(one_map_resolver_dump, "") \
22628 _(one_map_server_dump, "") \
22629 _(one_adjacencies_get, "vni <vni>") \
22630 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
22631 _(show_one_rloc_probe_state, "") \
22632 _(show_one_map_register_state, "") \
22633 _(show_one_status, "") \
22634 _(one_stats_dump, "") \
22635 _(one_stats_flush, "") \
22636 _(one_get_map_request_itr_rlocs, "") \
22637 _(one_map_register_set_ttl, "<ttl>") \
22638 _(one_set_transport_protocol, "udp|api") \
22639 _(one_get_transport_protocol, "") \
22640 _(one_enable_disable_xtr_mode, "enable|disable") \
22641 _(one_show_xtr_mode, "") \
22642 _(one_enable_disable_pitr_mode, "enable|disable") \
22643 _(one_show_pitr_mode, "") \
22644 _(one_enable_disable_petr_mode, "enable|disable") \
22645 _(one_show_petr_mode, "") \
22646 _(show_one_nsh_mapping, "") \
22647 _(show_one_pitr, "") \
22648 _(show_one_use_petr, "") \
22649 _(show_one_map_request_mode, "") \
22650 _(show_one_map_register_ttl, "") \
22651 _(show_one_map_register_fallback_threshold, "") \
22652 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
22653 " sw_if_index <sw_if_index> p <priority> " \
22654 "w <weight>] [del]") \
22655 _(lisp_add_del_locator, "locator-set <locator_name> " \
22656 "iface <intf> | sw_if_index <sw_if_index> " \
22657 "p <priority> w <weight> [del]") \
22658 _(lisp_add_del_local_eid,"vni <vni> eid " \
22659 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22660 "locator-set <locator_name> [del]" \
22661 "[key-id sha1|sha256 secret-key <secret-key>]") \
22662 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
22663 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
22664 _(lisp_enable_disable, "enable|disable") \
22665 _(lisp_map_register_enable_disable, "enable|disable") \
22666 _(lisp_rloc_probe_enable_disable, "enable|disable") \
22667 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22669 "rloc <locator> p <prio> " \
22670 "w <weight> [rloc <loc> ... ] " \
22671 "action <action> [del-all]") \
22672 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22674 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22675 _(lisp_use_petr, "<ip-address> | disable") \
22676 _(lisp_map_request_mode, "src-dst|dst-only") \
22677 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22678 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22679 _(lisp_locator_set_dump, "[local | remote]") \
22680 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
22681 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22682 "[local] | [remote]") \
22683 _(lisp_eid_table_vni_dump, "") \
22684 _(lisp_eid_table_map_dump, "l2|l3") \
22685 _(lisp_map_resolver_dump, "") \
22686 _(lisp_map_server_dump, "") \
22687 _(lisp_adjacencies_get, "vni <vni>") \
22688 _(gpe_fwd_entry_vnis_get, "") \
22689 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
22690 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
22691 "[table <table-id>]") \
22692 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
22693 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
22694 _(gpe_set_encap_mode, "lisp|vxlan") \
22695 _(gpe_get_encap_mode, "") \
22696 _(lisp_gpe_add_del_iface, "up|down") \
22697 _(lisp_gpe_enable_disable, "enable|disable") \
22698 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
22699 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
22700 _(show_lisp_rloc_probe_state, "") \
22701 _(show_lisp_map_register_state, "") \
22702 _(show_lisp_status, "") \
22703 _(lisp_get_map_request_itr_rlocs, "") \
22704 _(show_lisp_pitr, "") \
22705 _(show_lisp_use_petr, "") \
22706 _(show_lisp_map_request_mode, "") \
22707 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
22708 _(af_packet_delete, "name <host interface name>") \
22709 _(policer_add_del, "name <policer name> <params> [del]") \
22710 _(policer_dump, "[name <policer name>]") \
22711 _(policer_classify_set_interface, \
22712 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22713 " [l2-table <nn>] [del]") \
22714 _(policer_classify_dump, "type [ip4|ip6|l2]") \
22715 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
22716 "[master|slave]") \
22717 _(netmap_delete, "name <interface name>") \
22718 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
22719 _(mpls_fib_dump, "") \
22720 _(classify_table_ids, "") \
22721 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
22722 _(classify_table_info, "table_id <nn>") \
22723 _(classify_session_dump, "table_id <nn>") \
22724 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
22725 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
22726 "[template_interval <nn>] [udp_checksum]") \
22727 _(ipfix_exporter_dump, "") \
22728 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
22729 _(ipfix_classify_stream_dump, "") \
22730 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
22731 _(ipfix_classify_table_dump, "") \
22732 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
22733 _(sw_interface_span_dump, "[l2]") \
22734 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
22735 _(pg_create_interface, "if_id <nn>") \
22736 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
22737 _(pg_enable_disable, "[stream <id>] disable") \
22738 _(ip_source_and_port_range_check_add_del, \
22739 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
22740 _(ip_source_and_port_range_check_interface_add_del, \
22741 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
22742 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
22743 _(ipsec_gre_add_del_tunnel, \
22744 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
22745 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
22746 _(delete_subif,"<intfc> | sw_if_index <nn>") \
22747 _(l2_interface_pbb_tag_rewrite, \
22748 "<intfc> | sw_if_index <nn> \n" \
22749 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
22750 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
22751 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
22752 _(flow_classify_set_interface, \
22753 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
22754 _(flow_classify_dump, "type [ip4|ip6]") \
22755 _(ip_fib_dump, "") \
22756 _(ip_mfib_dump, "") \
22757 _(ip6_fib_dump, "") \
22758 _(ip6_mfib_dump, "") \
22759 _(feature_enable_disable, "arc_name <arc_name> " \
22760 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
22761 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
22763 _(l2_xconnect_dump, "") \
22764 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
22765 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
22766 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
22767 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
22768 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
22769 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
22770 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
22771 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
22772 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
22773 _(memfd_segment_create,"size <nnn>") \
22774 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
22775 _(dns_enable_disable, "[enable][disable]") \
22776 _(dns_name_server_add_del, "<ip-address> [del]") \
22777 _(dns_resolve_name, "<hostname>") \
22778 _(dns_resolve_ip, "<ip4|ip6>") \
22779 _(dns_name_server_add_del, "<ip-address> [del]") \
22780 _(dns_resolve_name, "<hostname>") \
22781 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
22782 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
22783 _(session_rules_dump, "") \
22784 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
22786 /* List of command functions, CLI names map directly to functions */
22787 #define foreach_cli_function \
22788 _(comment, "usage: comment <ignore-rest-of-line>") \
22789 _(dump_interface_table, "usage: dump_interface_table") \
22790 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
22791 _(dump_ipv4_table, "usage: dump_ipv4_table") \
22792 _(dump_ipv6_table, "usage: dump_ipv6_table") \
22793 _(dump_stats_table, "usage: dump_stats_table") \
22794 _(dump_macro_table, "usage: dump_macro_table ") \
22795 _(dump_node_table, "usage: dump_node_table") \
22796 _(dump_msg_api_table, "usage: dump_msg_api_table") \
22797 _(get_msg_id, "usage: get_msg_id name_and_crc") \
22798 _(echo, "usage: echo <message>") \
22799 _(exec, "usage: exec <vpe-debug-CLI-command>") \
22800 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
22801 _(help, "usage: help") \
22802 _(q, "usage: quit") \
22803 _(quit, "usage: quit") \
22804 _(search_node_table, "usage: search_node_table <name>...") \
22805 _(set, "usage: set <variable-name> <value>") \
22806 _(script, "usage: script <file-name>") \
22807 _(unset, "usage: unset <variable-name>")
22809 static void vl_api_##n##_t_handler_uni \
22810 (vl_api_##n##_t * mp) \
22812 vat_main_t * vam = &vat_main; \
22813 if (vam->json_output) { \
22814 vl_api_##n##_t_handler_json(mp); \
22816 vl_api_##n##_t_handler(mp); \
22819 foreach_vpe_api_reply_msg;
22820 #if VPP_API_TEST_BUILTIN == 0
22821 foreach_standalone_reply_msg;
22826 vat_api_hookup (vat_main_t * vam)
22829 vl_msg_api_set_handlers(VL_API_##N, #n, \
22830 vl_api_##n##_t_handler_uni, \
22832 vl_api_##n##_t_endian, \
22833 vl_api_##n##_t_print, \
22834 sizeof(vl_api_##n##_t), 1);
22835 foreach_vpe_api_reply_msg;
22836 #if VPP_API_TEST_BUILTIN == 0
22837 foreach_standalone_reply_msg;
22841 #if (VPP_API_TEST_BUILTIN==0)
22842 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
22844 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
22846 vam->function_by_name = hash_create_string (0, sizeof (uword));
22848 vam->help_by_name = hash_create_string (0, sizeof (uword));
22851 /* API messages we can send */
22852 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
22853 foreach_vpe_api_msg;
22857 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22858 foreach_vpe_api_msg;
22861 /* CLI functions */
22862 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
22863 foreach_cli_function;
22867 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22868 foreach_cli_function;
22872 #if VPP_API_TEST_BUILTIN
22873 static clib_error_t *
22874 vat_api_hookup_shim (vlib_main_t * vm)
22876 vat_api_hookup (&vat_main);
22880 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
22884 * fd.io coding-style-patch-verification: ON
22887 * eval: (c-set-style "gnu")