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;
1698 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_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->sw_if_index = ntohl (mp->sw_if_index);
1710 vam->result_ready = 1;
1715 static void vl_api_tap_create_v2_reply_t_handler_json
1716 (vl_api_tap_create_v2_reply_t * mp)
1718 vat_main_t *vam = &vat_main;
1719 vat_json_node_t node;
1721 vat_json_init_object (&node);
1722 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1723 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1725 vat_json_print (vam->ofp, &node);
1726 vat_json_free (&node);
1728 vam->retval = ntohl (mp->retval);
1729 vam->result_ready = 1;
1734 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1736 vat_main_t *vam = &vat_main;
1737 i32 retval = ntohl (mp->retval);
1738 if (vam->async_mode)
1740 vam->async_errors += (retval < 0);
1744 vam->retval = retval;
1745 vam->result_ready = 1;
1749 static void vl_api_tap_delete_v2_reply_t_handler_json
1750 (vl_api_tap_delete_v2_reply_t * mp)
1752 vat_main_t *vam = &vat_main;
1753 vat_json_node_t node;
1755 vat_json_init_object (&node);
1756 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
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_mpls_tunnel_add_del_reply_t_handler
1766 (vl_api_mpls_tunnel_add_del_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_mpls_tunnel_add_del_reply_t_handler_json
1782 (vl_api_mpls_tunnel_add_del_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, "tunnel_sw_if_index",
1790 ntohl (mp->sw_if_index));
1792 vat_json_print (vam->ofp, &node);
1793 vat_json_free (&node);
1795 vam->retval = ntohl (mp->retval);
1796 vam->result_ready = 1;
1799 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1800 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1802 vat_main_t *vam = &vat_main;
1803 i32 retval = ntohl (mp->retval);
1804 if (vam->async_mode)
1806 vam->async_errors += (retval < 0);
1810 vam->retval = retval;
1811 vam->sw_if_index = ntohl (mp->sw_if_index);
1812 vam->result_ready = 1;
1816 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1817 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1819 vat_main_t *vam = &vat_main;
1820 vat_json_node_t node;
1822 vat_json_init_object (&node);
1823 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1824 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1826 vat_json_print (vam->ofp, &node);
1827 vat_json_free (&node);
1829 vam->retval = ntohl (mp->retval);
1830 vam->result_ready = 1;
1833 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
1834 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1836 vat_main_t *vam = &vat_main;
1837 i32 retval = ntohl (mp->retval);
1838 if (vam->async_mode)
1840 vam->async_errors += (retval < 0);
1844 vam->retval = retval;
1845 vam->result_ready = 1;
1849 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
1850 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1852 vat_main_t *vam = &vat_main;
1853 vat_json_node_t node;
1855 vat_json_init_object (&node);
1856 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1857 vat_json_object_add_uint (&node, "fwd_entry_index",
1858 clib_net_to_host_u32 (mp->fwd_entry_index));
1860 vat_json_print (vam->ofp, &node);
1861 vat_json_free (&node);
1863 vam->retval = ntohl (mp->retval);
1864 vam->result_ready = 1;
1868 format_lisp_transport_protocol (u8 * s, va_list * args)
1870 u32 proto = va_arg (*args, u32);
1875 return format (s, "udp");
1877 return format (s, "api");
1884 static void vl_api_one_get_transport_protocol_reply_t_handler
1885 (vl_api_one_get_transport_protocol_reply_t * mp)
1887 vat_main_t *vam = &vat_main;
1888 i32 retval = ntohl (mp->retval);
1889 if (vam->async_mode)
1891 vam->async_errors += (retval < 0);
1895 u32 proto = mp->protocol;
1896 print (vam->ofp, "Transport protocol: %U",
1897 format_lisp_transport_protocol, proto);
1898 vam->retval = retval;
1899 vam->result_ready = 1;
1903 static void vl_api_one_get_transport_protocol_reply_t_handler_json
1904 (vl_api_one_get_transport_protocol_reply_t * mp)
1906 vat_main_t *vam = &vat_main;
1907 vat_json_node_t node;
1910 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
1913 vat_json_init_object (&node);
1914 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1915 vat_json_object_add_string_copy (&node, "transport-protocol", s);
1918 vat_json_print (vam->ofp, &node);
1919 vat_json_free (&node);
1921 vam->retval = ntohl (mp->retval);
1922 vam->result_ready = 1;
1925 static void vl_api_one_add_del_locator_set_reply_t_handler
1926 (vl_api_one_add_del_locator_set_reply_t * mp)
1928 vat_main_t *vam = &vat_main;
1929 i32 retval = ntohl (mp->retval);
1930 if (vam->async_mode)
1932 vam->async_errors += (retval < 0);
1936 vam->retval = retval;
1937 vam->result_ready = 1;
1941 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1942 (vl_api_one_add_del_locator_set_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, "locator_set_index", ntohl (mp->ls_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_add_del_tunnel_reply_t_handler
1959 (vl_api_vxlan_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_add_del_tunnel_reply_t_handler_json
1976 (vl_api_vxlan_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_geneve_add_del_tunnel_reply_t_handler
1993 (vl_api_geneve_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_geneve_add_del_tunnel_reply_t_handler_json
2010 (vl_api_geneve_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_vxlan_gpe_add_del_tunnel_reply_t_handler
2027 (vl_api_vxlan_gpe_add_del_tunnel_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_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2044 (vl_api_vxlan_gpe_add_del_tunnel_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 void vl_api_gre_add_del_tunnel_reply_t_handler
2061 (vl_api_gre_add_del_tunnel_reply_t * mp)
2063 vat_main_t *vam = &vat_main;
2064 i32 retval = ntohl (mp->retval);
2065 if (vam->async_mode)
2067 vam->async_errors += (retval < 0);
2071 vam->retval = retval;
2072 vam->sw_if_index = ntohl (mp->sw_if_index);
2073 vam->result_ready = 1;
2077 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2078 (vl_api_gre_add_del_tunnel_reply_t * mp)
2080 vat_main_t *vam = &vat_main;
2081 vat_json_node_t node;
2083 vat_json_init_object (&node);
2084 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2085 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2087 vat_json_print (vam->ofp, &node);
2088 vat_json_free (&node);
2090 vam->retval = ntohl (mp->retval);
2091 vam->result_ready = 1;
2094 static void vl_api_create_vhost_user_if_reply_t_handler
2095 (vl_api_create_vhost_user_if_reply_t * mp)
2097 vat_main_t *vam = &vat_main;
2098 i32 retval = ntohl (mp->retval);
2099 if (vam->async_mode)
2101 vam->async_errors += (retval < 0);
2105 vam->retval = retval;
2106 vam->sw_if_index = ntohl (mp->sw_if_index);
2107 vam->result_ready = 1;
2111 static void vl_api_create_vhost_user_if_reply_t_handler_json
2112 (vl_api_create_vhost_user_if_reply_t * mp)
2114 vat_main_t *vam = &vat_main;
2115 vat_json_node_t node;
2117 vat_json_init_object (&node);
2118 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2119 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2121 vat_json_print (vam->ofp, &node);
2122 vat_json_free (&node);
2124 vam->retval = ntohl (mp->retval);
2125 vam->result_ready = 1;
2128 static clib_error_t *
2129 receive_fd_msg (int socket_fd, int *my_fd)
2132 char ctl[CMSG_SPACE (sizeof (int)) + CMSG_SPACE (sizeof (struct ucred))];
2133 struct msghdr mh = { 0 };
2134 struct iovec iov[1];
2136 struct ucred *cr = 0;
2137 struct cmsghdr *cmsg;
2138 pid_t pid __attribute__ ((unused));
2139 uid_t uid __attribute__ ((unused));
2140 gid_t gid __attribute__ ((unused));
2142 iov[0].iov_base = msgbuf;
2146 mh.msg_control = ctl;
2147 mh.msg_controllen = sizeof (ctl);
2149 memset (ctl, 0, sizeof (ctl));
2151 /* receive the incoming message */
2152 size = recvmsg (socket_fd, &mh, 0);
2155 return (size == 0) ? clib_error_return (0, "disconnected") :
2156 clib_error_return_unix (0, "recvmsg: malformed message (fd %d)",
2160 cmsg = CMSG_FIRSTHDR (&mh);
2163 if (cmsg->cmsg_level == SOL_SOCKET)
2165 if (cmsg->cmsg_type == SCM_CREDENTIALS)
2167 cr = (struct ucred *) CMSG_DATA (cmsg);
2172 else if (cmsg->cmsg_type == SCM_RIGHTS)
2174 clib_memcpy (my_fd, CMSG_DATA (cmsg), sizeof (int));
2177 cmsg = CMSG_NXTHDR (&mh, cmsg);
2182 static void vl_api_memfd_segment_create_reply_t_handler
2183 (vl_api_memfd_segment_create_reply_t * mp)
2185 /* Dont bother in the builtin version */
2186 #if VPP_API_TEST_BUILTIN == 0
2187 vat_main_t *vam = &vat_main;
2188 api_main_t *am = &api_main;
2189 socket_client_main_t *scm = &vam->socket_client_main;
2191 clib_error_t *error;
2192 memfd_private_t memfd;
2193 i32 retval = ntohl (mp->retval);
2197 error = receive_fd_msg (scm->socket_fd, &my_fd);
2204 memset (&memfd, 0, sizeof (memfd));
2207 vam->client_index_invalid = 1;
2209 /* Note: this closes memfd.fd */
2210 retval = memfd_slave_init (&memfd);
2212 clib_warning ("WARNING: segment map returned %d", retval);
2214 /* Pivot to the memory client segment that vpp just created */
2216 am->vlib_rp = (void *) (memfd.requested_va + MMAP_PAGESIZE);
2218 am->shmem_hdr = (void *) am->vlib_rp->user_ctx;
2220 vl_client_install_client_message_handlers ();
2222 vl_client_connect_to_vlib_no_map ("pvt",
2224 32 /* input_queue_length */ );
2225 vam->vl_input_queue = am->shmem_hdr->vl_input_queue;
2227 vl_socket_client_enable_disable (&vam->socket_client_main,
2228 0 /* disable socket */ );
2232 if (vam->async_mode)
2234 vam->async_errors += (retval < 0);
2238 vam->retval = retval;
2239 vam->result_ready = 1;
2244 static void vl_api_memfd_segment_create_reply_t_handler_json
2245 (vl_api_memfd_segment_create_reply_t * mp)
2247 clib_warning ("no");
2250 static void vl_api_dns_resolve_name_reply_t_handler
2251 (vl_api_dns_resolve_name_reply_t * mp)
2253 vat_main_t *vam = &vat_main;
2254 i32 retval = ntohl (mp->retval);
2255 if (vam->async_mode)
2257 vam->async_errors += (retval < 0);
2261 vam->retval = retval;
2262 vam->result_ready = 1;
2267 clib_warning ("ip4 address %U", format_ip4_address,
2268 (ip4_address_t *) mp->ip4_address);
2270 clib_warning ("ip6 address %U", format_ip6_address,
2271 (ip6_address_t *) mp->ip6_address);
2274 clib_warning ("retval %d", retval);
2278 static void vl_api_dns_resolve_name_reply_t_handler_json
2279 (vl_api_dns_resolve_name_reply_t * mp)
2281 clib_warning ("not implemented");
2284 static void vl_api_dns_resolve_ip_reply_t_handler
2285 (vl_api_dns_resolve_ip_reply_t * mp)
2287 vat_main_t *vam = &vat_main;
2288 i32 retval = ntohl (mp->retval);
2289 if (vam->async_mode)
2291 vam->async_errors += (retval < 0);
2295 vam->retval = retval;
2296 vam->result_ready = 1;
2300 clib_warning ("canonical name %s", mp->name);
2303 clib_warning ("retval %d", retval);
2307 static void vl_api_dns_resolve_ip_reply_t_handler_json
2308 (vl_api_dns_resolve_ip_reply_t * mp)
2310 clib_warning ("not implemented");
2314 static void vl_api_ip_address_details_t_handler
2315 (vl_api_ip_address_details_t * mp)
2317 vat_main_t *vam = &vat_main;
2318 static ip_address_details_t empty_ip_address_details = { {0} };
2319 ip_address_details_t *address = NULL;
2320 ip_details_t *current_ip_details = NULL;
2321 ip_details_t *details = NULL;
2323 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2325 if (!details || vam->current_sw_if_index >= vec_len (details)
2326 || !details[vam->current_sw_if_index].present)
2328 errmsg ("ip address details arrived but not stored");
2329 errmsg ("ip_dump should be called first");
2333 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2335 #define addresses (current_ip_details->addr)
2337 vec_validate_init_empty (addresses, vec_len (addresses),
2338 empty_ip_address_details);
2340 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2342 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2343 address->prefix_length = mp->prefix_length;
2347 static void vl_api_ip_address_details_t_handler_json
2348 (vl_api_ip_address_details_t * mp)
2350 vat_main_t *vam = &vat_main;
2351 vat_json_node_t *node = NULL;
2352 struct in6_addr ip6;
2355 if (VAT_JSON_ARRAY != vam->json_tree.type)
2357 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2358 vat_json_init_array (&vam->json_tree);
2360 node = vat_json_array_add (&vam->json_tree);
2362 vat_json_init_object (node);
2365 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2366 vat_json_object_add_ip6 (node, "ip", ip6);
2370 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2371 vat_json_object_add_ip4 (node, "ip", ip4);
2373 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2377 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2379 vat_main_t *vam = &vat_main;
2380 static ip_details_t empty_ip_details = { 0 };
2381 ip_details_t *ip = NULL;
2382 u32 sw_if_index = ~0;
2384 sw_if_index = ntohl (mp->sw_if_index);
2386 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2387 sw_if_index, empty_ip_details);
2389 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2396 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2398 vat_main_t *vam = &vat_main;
2400 if (VAT_JSON_ARRAY != vam->json_tree.type)
2402 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2403 vat_json_init_array (&vam->json_tree);
2405 vat_json_array_add_uint (&vam->json_tree,
2406 clib_net_to_host_u32 (mp->sw_if_index));
2409 static void vl_api_map_domain_details_t_handler_json
2410 (vl_api_map_domain_details_t * mp)
2412 vat_json_node_t *node = NULL;
2413 vat_main_t *vam = &vat_main;
2414 struct in6_addr ip6;
2417 if (VAT_JSON_ARRAY != vam->json_tree.type)
2419 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2420 vat_json_init_array (&vam->json_tree);
2423 node = vat_json_array_add (&vam->json_tree);
2424 vat_json_init_object (node);
2426 vat_json_object_add_uint (node, "domain_index",
2427 clib_net_to_host_u32 (mp->domain_index));
2428 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2429 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2430 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2431 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2432 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2433 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2434 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2435 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2436 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2437 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2438 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2439 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2440 vat_json_object_add_uint (node, "flags", mp->flags);
2441 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2442 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2445 static void vl_api_map_domain_details_t_handler
2446 (vl_api_map_domain_details_t * mp)
2448 vat_main_t *vam = &vat_main;
2450 if (mp->is_translation)
2453 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2454 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2455 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2456 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2457 clib_net_to_host_u32 (mp->domain_index));
2462 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2463 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2464 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2465 format_ip6_address, mp->ip6_src,
2466 clib_net_to_host_u32 (mp->domain_index));
2468 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2469 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2470 mp->is_translation ? "map-t" : "");
2473 static void vl_api_map_rule_details_t_handler_json
2474 (vl_api_map_rule_details_t * mp)
2476 struct in6_addr ip6;
2477 vat_json_node_t *node = NULL;
2478 vat_main_t *vam = &vat_main;
2480 if (VAT_JSON_ARRAY != vam->json_tree.type)
2482 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2483 vat_json_init_array (&vam->json_tree);
2486 node = vat_json_array_add (&vam->json_tree);
2487 vat_json_init_object (node);
2489 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2490 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2491 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2495 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2497 vat_main_t *vam = &vat_main;
2498 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2499 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2503 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2505 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2506 "router_addr %U host_mac %U",
2507 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2508 format_ip4_address, &mp->host_address,
2509 format_ip4_address, &mp->router_address,
2510 format_ethernet_address, mp->host_mac);
2513 static void vl_api_dhcp_compl_event_t_handler_json
2514 (vl_api_dhcp_compl_event_t * mp)
2516 /* JSON output not supported */
2520 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2523 vat_main_t *vam = &vat_main;
2524 static u64 default_counter = 0;
2526 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2528 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2529 sw_if_index, default_counter);
2530 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2534 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2535 interface_counter_t counter)
2537 vat_main_t *vam = &vat_main;
2538 static interface_counter_t default_counter = { 0, };
2540 vec_validate_init_empty (vam->combined_interface_counters,
2541 vnet_counter_type, NULL);
2542 vec_validate_init_empty (vam->combined_interface_counters
2543 [vnet_counter_type], sw_if_index, default_counter);
2544 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2547 static void vl_api_vnet_interface_simple_counters_t_handler
2548 (vl_api_vnet_interface_simple_counters_t * mp)
2553 static void vl_api_vnet_interface_combined_counters_t_handler
2554 (vl_api_vnet_interface_combined_counters_t * mp)
2559 static void vl_api_vnet_interface_simple_counters_t_handler_json
2560 (vl_api_vnet_interface_simple_counters_t * mp)
2565 u32 first_sw_if_index;
2568 count = ntohl (mp->count);
2569 first_sw_if_index = ntohl (mp->first_sw_if_index);
2571 v_packets = (u64 *) & mp->data;
2572 for (i = 0; i < count; i++)
2574 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2575 set_simple_interface_counter (mp->vnet_counter_type,
2576 first_sw_if_index + i, packets);
2581 static void vl_api_vnet_interface_combined_counters_t_handler_json
2582 (vl_api_vnet_interface_combined_counters_t * mp)
2584 interface_counter_t counter;
2586 u32 first_sw_if_index;
2590 count = ntohl (mp->count);
2591 first_sw_if_index = ntohl (mp->first_sw_if_index);
2593 v = (vlib_counter_t *) & mp->data;
2594 for (i = 0; i < count; i++)
2597 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2599 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2600 set_combined_interface_counter (mp->vnet_counter_type,
2601 first_sw_if_index + i, counter);
2607 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2609 vat_main_t *vam = &vat_main;
2612 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2614 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2623 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2625 vat_main_t *vam = &vat_main;
2628 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2630 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2638 static void vl_api_vnet_ip4_fib_counters_t_handler
2639 (vl_api_vnet_ip4_fib_counters_t * mp)
2644 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2645 (vl_api_vnet_ip4_fib_counters_t * mp)
2647 vat_main_t *vam = &vat_main;
2648 vl_api_ip4_fib_counter_t *v;
2649 ip4_fib_counter_t *counter;
2656 vrf_id = ntohl (mp->vrf_id);
2657 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2658 if (~0 == vrf_index)
2660 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2661 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2662 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2663 vec_validate (vam->ip4_fib_counters, vrf_index);
2664 vam->ip4_fib_counters[vrf_index] = NULL;
2667 vec_free (vam->ip4_fib_counters[vrf_index]);
2668 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2669 count = ntohl (mp->count);
2670 for (i = 0; i < count; i++)
2672 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2673 counter = &vam->ip4_fib_counters[vrf_index][i];
2674 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2675 counter->address = ip4;
2676 counter->address_length = v->address_length;
2677 counter->packets = clib_net_to_host_u64 (v->packets);
2678 counter->bytes = clib_net_to_host_u64 (v->bytes);
2683 static void vl_api_vnet_ip4_nbr_counters_t_handler
2684 (vl_api_vnet_ip4_nbr_counters_t * mp)
2689 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2690 (vl_api_vnet_ip4_nbr_counters_t * mp)
2692 vat_main_t *vam = &vat_main;
2693 vl_api_ip4_nbr_counter_t *v;
2694 ip4_nbr_counter_t *counter;
2699 sw_if_index = ntohl (mp->sw_if_index);
2700 count = ntohl (mp->count);
2701 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2704 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2706 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2707 for (i = 0; i < count; i++)
2709 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2710 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2711 counter->address.s_addr = v->address;
2712 counter->packets = clib_net_to_host_u64 (v->packets);
2713 counter->bytes = clib_net_to_host_u64 (v->bytes);
2714 counter->linkt = v->link_type;
2719 static void vl_api_vnet_ip6_fib_counters_t_handler
2720 (vl_api_vnet_ip6_fib_counters_t * mp)
2725 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2726 (vl_api_vnet_ip6_fib_counters_t * mp)
2728 vat_main_t *vam = &vat_main;
2729 vl_api_ip6_fib_counter_t *v;
2730 ip6_fib_counter_t *counter;
2731 struct in6_addr ip6;
2737 vrf_id = ntohl (mp->vrf_id);
2738 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2739 if (~0 == vrf_index)
2741 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2742 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2743 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2744 vec_validate (vam->ip6_fib_counters, vrf_index);
2745 vam->ip6_fib_counters[vrf_index] = NULL;
2748 vec_free (vam->ip6_fib_counters[vrf_index]);
2749 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2750 count = ntohl (mp->count);
2751 for (i = 0; i < count; i++)
2753 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2754 counter = &vam->ip6_fib_counters[vrf_index][i];
2755 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2756 counter->address = ip6;
2757 counter->address_length = v->address_length;
2758 counter->packets = clib_net_to_host_u64 (v->packets);
2759 counter->bytes = clib_net_to_host_u64 (v->bytes);
2764 static void vl_api_vnet_ip6_nbr_counters_t_handler
2765 (vl_api_vnet_ip6_nbr_counters_t * mp)
2770 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2771 (vl_api_vnet_ip6_nbr_counters_t * mp)
2773 vat_main_t *vam = &vat_main;
2774 vl_api_ip6_nbr_counter_t *v;
2775 ip6_nbr_counter_t *counter;
2776 struct in6_addr ip6;
2781 sw_if_index = ntohl (mp->sw_if_index);
2782 count = ntohl (mp->count);
2783 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2786 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2788 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2789 for (i = 0; i < count; i++)
2791 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2792 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2793 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2794 counter->address = ip6;
2795 counter->packets = clib_net_to_host_u64 (v->packets);
2796 counter->bytes = clib_net_to_host_u64 (v->bytes);
2801 static void vl_api_get_first_msg_id_reply_t_handler
2802 (vl_api_get_first_msg_id_reply_t * mp)
2804 vat_main_t *vam = &vat_main;
2805 i32 retval = ntohl (mp->retval);
2807 if (vam->async_mode)
2809 vam->async_errors += (retval < 0);
2813 vam->retval = retval;
2814 vam->result_ready = 1;
2818 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2822 static void vl_api_get_first_msg_id_reply_t_handler_json
2823 (vl_api_get_first_msg_id_reply_t * mp)
2825 vat_main_t *vam = &vat_main;
2826 vat_json_node_t node;
2828 vat_json_init_object (&node);
2829 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2830 vat_json_object_add_uint (&node, "first_msg_id",
2831 (uint) ntohs (mp->first_msg_id));
2833 vat_json_print (vam->ofp, &node);
2834 vat_json_free (&node);
2836 vam->retval = ntohl (mp->retval);
2837 vam->result_ready = 1;
2840 static void vl_api_get_node_graph_reply_t_handler
2841 (vl_api_get_node_graph_reply_t * mp)
2843 vat_main_t *vam = &vat_main;
2844 api_main_t *am = &api_main;
2845 i32 retval = ntohl (mp->retval);
2846 u8 *pvt_copy, *reply;
2851 if (vam->async_mode)
2853 vam->async_errors += (retval < 0);
2857 vam->retval = retval;
2858 vam->result_ready = 1;
2861 /* "Should never happen..." */
2865 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2866 pvt_copy = vec_dup (reply);
2868 /* Toss the shared-memory original... */
2869 pthread_mutex_lock (&am->vlib_rp->mutex);
2870 oldheap = svm_push_data_heap (am->vlib_rp);
2874 svm_pop_heap (oldheap);
2875 pthread_mutex_unlock (&am->vlib_rp->mutex);
2877 if (vam->graph_nodes)
2879 hash_free (vam->graph_node_index_by_name);
2881 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2883 node = vam->graph_nodes[i];
2884 vec_free (node->name);
2885 vec_free (node->next_nodes);
2888 vec_free (vam->graph_nodes);
2891 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2892 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2893 vec_free (pvt_copy);
2895 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2897 node = vam->graph_nodes[i];
2898 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2902 static void vl_api_get_node_graph_reply_t_handler_json
2903 (vl_api_get_node_graph_reply_t * mp)
2905 vat_main_t *vam = &vat_main;
2906 api_main_t *am = &api_main;
2908 vat_json_node_t node;
2911 /* $$$$ make this real? */
2912 vat_json_init_object (&node);
2913 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2914 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2916 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2918 /* Toss the shared-memory original... */
2919 pthread_mutex_lock (&am->vlib_rp->mutex);
2920 oldheap = svm_push_data_heap (am->vlib_rp);
2924 svm_pop_heap (oldheap);
2925 pthread_mutex_unlock (&am->vlib_rp->mutex);
2927 vat_json_print (vam->ofp, &node);
2928 vat_json_free (&node);
2930 vam->retval = ntohl (mp->retval);
2931 vam->result_ready = 1;
2935 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2937 vat_main_t *vam = &vat_main;
2942 s = format (s, "%=16d%=16d%=16d",
2943 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2947 s = format (s, "%=16U%=16d%=16d",
2948 mp->is_ipv6 ? format_ip6_address :
2950 mp->ip_address, mp->priority, mp->weight);
2953 print (vam->ofp, "%v", s);
2958 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2960 vat_main_t *vam = &vat_main;
2961 vat_json_node_t *node = NULL;
2962 struct in6_addr ip6;
2965 if (VAT_JSON_ARRAY != vam->json_tree.type)
2967 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2968 vat_json_init_array (&vam->json_tree);
2970 node = vat_json_array_add (&vam->json_tree);
2971 vat_json_init_object (node);
2973 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2974 vat_json_object_add_uint (node, "priority", mp->priority);
2975 vat_json_object_add_uint (node, "weight", mp->weight);
2978 vat_json_object_add_uint (node, "sw_if_index",
2979 clib_net_to_host_u32 (mp->sw_if_index));
2984 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2985 vat_json_object_add_ip6 (node, "address", ip6);
2989 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2990 vat_json_object_add_ip4 (node, "address", ip4);
2996 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2999 vat_main_t *vam = &vat_main;
3002 ls_name = format (0, "%s", mp->ls_name);
3004 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
3010 vl_api_one_locator_set_details_t_handler_json
3011 (vl_api_one_locator_set_details_t * mp)
3013 vat_main_t *vam = &vat_main;
3014 vat_json_node_t *node = 0;
3017 ls_name = format (0, "%s", mp->ls_name);
3018 vec_add1 (ls_name, 0);
3020 if (VAT_JSON_ARRAY != vam->json_tree.type)
3022 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3023 vat_json_init_array (&vam->json_tree);
3025 node = vat_json_array_add (&vam->json_tree);
3027 vat_json_init_object (node);
3028 vat_json_object_add_string_copy (node, "ls_name", ls_name);
3029 vat_json_object_add_uint (node, "ls_index",
3030 clib_net_to_host_u32 (mp->ls_index));
3038 } __attribute__ ((__packed__)) lisp_nsh_api_t;
3041 unformat_nsh_address (unformat_input_t * input, va_list * args)
3043 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
3044 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3048 format_nsh_address_vat (u8 * s, va_list * args)
3050 nsh_t *a = va_arg (*args, nsh_t *);
3051 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3055 format_lisp_flat_eid (u8 * s, va_list * args)
3057 u32 type = va_arg (*args, u32);
3058 u8 *eid = va_arg (*args, u8 *);
3059 u32 eid_len = va_arg (*args, u32);
3064 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3066 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3068 return format (s, "%U", format_ethernet_address, eid);
3070 return format (s, "%U", format_nsh_address_vat, eid);
3076 format_lisp_eid_vat (u8 * s, va_list * args)
3078 u32 type = va_arg (*args, u32);
3079 u8 *eid = va_arg (*args, u8 *);
3080 u32 eid_len = va_arg (*args, u32);
3081 u8 *seid = va_arg (*args, u8 *);
3082 u32 seid_len = va_arg (*args, u32);
3083 u32 is_src_dst = va_arg (*args, u32);
3086 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3088 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3094 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3096 vat_main_t *vam = &vat_main;
3097 u8 *s = 0, *eid = 0;
3099 if (~0 == mp->locator_set_index)
3100 s = format (0, "action: %d", mp->action);
3102 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3104 eid = format (0, "%U", format_lisp_eid_vat,
3108 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3111 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3112 clib_net_to_host_u32 (mp->vni),
3114 mp->is_local ? "local" : "remote",
3115 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3116 clib_net_to_host_u16 (mp->key_id), mp->key);
3123 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3126 vat_main_t *vam = &vat_main;
3127 vat_json_node_t *node = 0;
3130 if (VAT_JSON_ARRAY != vam->json_tree.type)
3132 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3133 vat_json_init_array (&vam->json_tree);
3135 node = vat_json_array_add (&vam->json_tree);
3137 vat_json_init_object (node);
3138 if (~0 == mp->locator_set_index)
3139 vat_json_object_add_uint (node, "action", mp->action);
3141 vat_json_object_add_uint (node, "locator_set_index",
3142 clib_net_to_host_u32 (mp->locator_set_index));
3144 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3145 if (mp->eid_type == 3)
3147 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3148 vat_json_init_object (nsh_json);
3149 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3150 vat_json_object_add_uint (nsh_json, "spi",
3151 clib_net_to_host_u32 (nsh->spi));
3152 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3156 eid = format (0, "%U", format_lisp_eid_vat,
3160 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3162 vat_json_object_add_string_copy (node, "eid", eid);
3165 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3166 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3167 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3171 vat_json_object_add_uint (node, "key_id",
3172 clib_net_to_host_u16 (mp->key_id));
3173 vat_json_object_add_string_copy (node, "key", mp->key);
3178 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3180 vat_main_t *vam = &vat_main;
3181 u8 *seid = 0, *deid = 0;
3182 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3184 deid = format (0, "%U", format_lisp_eid_vat,
3185 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3187 seid = format (0, "%U", format_lisp_eid_vat,
3188 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3194 format_ip_address_fcn = format_ip4_address;
3196 format_ip_address_fcn = format_ip6_address;
3199 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3200 clib_net_to_host_u32 (mp->vni),
3202 format_ip_address_fcn, mp->lloc,
3203 format_ip_address_fcn, mp->rloc,
3204 clib_net_to_host_u32 (mp->pkt_count),
3205 clib_net_to_host_u32 (mp->bytes));
3212 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3214 struct in6_addr ip6;
3216 vat_main_t *vam = &vat_main;
3217 vat_json_node_t *node = 0;
3218 u8 *deid = 0, *seid = 0;
3220 if (VAT_JSON_ARRAY != vam->json_tree.type)
3222 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3223 vat_json_init_array (&vam->json_tree);
3225 node = vat_json_array_add (&vam->json_tree);
3227 vat_json_init_object (node);
3228 deid = format (0, "%U", format_lisp_eid_vat,
3229 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3231 seid = format (0, "%U", format_lisp_eid_vat,
3232 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3237 vat_json_object_add_string_copy (node, "seid", seid);
3238 vat_json_object_add_string_copy (node, "deid", deid);
3239 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3243 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3244 vat_json_object_add_ip4 (node, "lloc", ip4);
3245 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3246 vat_json_object_add_ip4 (node, "rloc", ip4);
3250 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3251 vat_json_object_add_ip6 (node, "lloc", ip6);
3252 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3253 vat_json_object_add_ip6 (node, "rloc", ip6);
3255 vat_json_object_add_uint (node, "pkt_count",
3256 clib_net_to_host_u32 (mp->pkt_count));
3257 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3264 vl_api_one_eid_table_map_details_t_handler
3265 (vl_api_one_eid_table_map_details_t * mp)
3267 vat_main_t *vam = &vat_main;
3269 u8 *line = format (0, "%=10d%=10d",
3270 clib_net_to_host_u32 (mp->vni),
3271 clib_net_to_host_u32 (mp->dp_table));
3272 print (vam->ofp, "%v", line);
3277 vl_api_one_eid_table_map_details_t_handler_json
3278 (vl_api_one_eid_table_map_details_t * mp)
3280 vat_main_t *vam = &vat_main;
3281 vat_json_node_t *node = NULL;
3283 if (VAT_JSON_ARRAY != vam->json_tree.type)
3285 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3286 vat_json_init_array (&vam->json_tree);
3288 node = vat_json_array_add (&vam->json_tree);
3289 vat_json_init_object (node);
3290 vat_json_object_add_uint (node, "dp_table",
3291 clib_net_to_host_u32 (mp->dp_table));
3292 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3296 vl_api_one_eid_table_vni_details_t_handler
3297 (vl_api_one_eid_table_vni_details_t * mp)
3299 vat_main_t *vam = &vat_main;
3301 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3302 print (vam->ofp, "%v", line);
3307 vl_api_one_eid_table_vni_details_t_handler_json
3308 (vl_api_one_eid_table_vni_details_t * mp)
3310 vat_main_t *vam = &vat_main;
3311 vat_json_node_t *node = NULL;
3313 if (VAT_JSON_ARRAY != vam->json_tree.type)
3315 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3316 vat_json_init_array (&vam->json_tree);
3318 node = vat_json_array_add (&vam->json_tree);
3319 vat_json_init_object (node);
3320 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3324 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3325 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3327 vat_main_t *vam = &vat_main;
3328 int retval = clib_net_to_host_u32 (mp->retval);
3330 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3331 print (vam->ofp, "fallback threshold value: %d", mp->value);
3333 vam->retval = retval;
3334 vam->result_ready = 1;
3338 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3339 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3341 vat_main_t *vam = &vat_main;
3342 vat_json_node_t _node, *node = &_node;
3343 int retval = clib_net_to_host_u32 (mp->retval);
3345 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3346 vat_json_init_object (node);
3347 vat_json_object_add_uint (node, "value", mp->value);
3349 vat_json_print (vam->ofp, node);
3350 vat_json_free (node);
3352 vam->retval = retval;
3353 vam->result_ready = 1;
3357 vl_api_show_one_map_register_state_reply_t_handler
3358 (vl_api_show_one_map_register_state_reply_t * mp)
3360 vat_main_t *vam = &vat_main;
3361 int retval = clib_net_to_host_u32 (mp->retval);
3363 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3365 vam->retval = retval;
3366 vam->result_ready = 1;
3370 vl_api_show_one_map_register_state_reply_t_handler_json
3371 (vl_api_show_one_map_register_state_reply_t * mp)
3373 vat_main_t *vam = &vat_main;
3374 vat_json_node_t _node, *node = &_node;
3375 int retval = clib_net_to_host_u32 (mp->retval);
3377 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3379 vat_json_init_object (node);
3380 vat_json_object_add_string_copy (node, "state", s);
3382 vat_json_print (vam->ofp, node);
3383 vat_json_free (node);
3385 vam->retval = retval;
3386 vam->result_ready = 1;
3391 vl_api_show_one_rloc_probe_state_reply_t_handler
3392 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3394 vat_main_t *vam = &vat_main;
3395 int retval = clib_net_to_host_u32 (mp->retval);
3400 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3402 vam->retval = retval;
3403 vam->result_ready = 1;
3407 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3408 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3410 vat_main_t *vam = &vat_main;
3411 vat_json_node_t _node, *node = &_node;
3412 int retval = clib_net_to_host_u32 (mp->retval);
3414 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3415 vat_json_init_object (node);
3416 vat_json_object_add_string_copy (node, "state", s);
3418 vat_json_print (vam->ofp, node);
3419 vat_json_free (node);
3421 vam->retval = retval;
3422 vam->result_ready = 1;
3427 vl_api_show_one_stats_enable_disable_reply_t_handler
3428 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3430 vat_main_t *vam = &vat_main;
3431 int retval = clib_net_to_host_u32 (mp->retval);
3436 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3438 vam->retval = retval;
3439 vam->result_ready = 1;
3443 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3444 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3446 vat_main_t *vam = &vat_main;
3447 vat_json_node_t _node, *node = &_node;
3448 int retval = clib_net_to_host_u32 (mp->retval);
3450 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3451 vat_json_init_object (node);
3452 vat_json_object_add_string_copy (node, "state", s);
3454 vat_json_print (vam->ofp, node);
3455 vat_json_free (node);
3457 vam->retval = retval;
3458 vam->result_ready = 1;
3463 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3465 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3466 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3467 e->vni = clib_net_to_host_u32 (e->vni);
3471 gpe_fwd_entries_get_reply_t_net_to_host
3472 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3476 mp->count = clib_net_to_host_u32 (mp->count);
3477 for (i = 0; i < mp->count; i++)
3479 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3484 format_gpe_encap_mode (u8 * s, va_list * args)
3486 u32 mode = va_arg (*args, u32);
3491 return format (s, "lisp");
3493 return format (s, "vxlan");
3499 vl_api_gpe_get_encap_mode_reply_t_handler
3500 (vl_api_gpe_get_encap_mode_reply_t * mp)
3502 vat_main_t *vam = &vat_main;
3504 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3505 vam->retval = ntohl (mp->retval);
3506 vam->result_ready = 1;
3510 vl_api_gpe_get_encap_mode_reply_t_handler_json
3511 (vl_api_gpe_get_encap_mode_reply_t * mp)
3513 vat_main_t *vam = &vat_main;
3514 vat_json_node_t node;
3516 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3517 vec_add1 (encap_mode, 0);
3519 vat_json_init_object (&node);
3520 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3522 vec_free (encap_mode);
3523 vat_json_print (vam->ofp, &node);
3524 vat_json_free (&node);
3526 vam->retval = ntohl (mp->retval);
3527 vam->result_ready = 1;
3531 vl_api_gpe_fwd_entry_path_details_t_handler
3532 (vl_api_gpe_fwd_entry_path_details_t * mp)
3534 vat_main_t *vam = &vat_main;
3535 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3537 if (mp->lcl_loc.is_ip4)
3538 format_ip_address_fcn = format_ip4_address;
3540 format_ip_address_fcn = format_ip6_address;
3542 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3543 format_ip_address_fcn, &mp->lcl_loc,
3544 format_ip_address_fcn, &mp->rmt_loc);
3548 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3550 struct in6_addr ip6;
3555 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3556 vat_json_object_add_ip4 (n, "address", ip4);
3560 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3561 vat_json_object_add_ip6 (n, "address", ip6);
3563 vat_json_object_add_uint (n, "weight", loc->weight);
3567 vl_api_gpe_fwd_entry_path_details_t_handler_json
3568 (vl_api_gpe_fwd_entry_path_details_t * mp)
3570 vat_main_t *vam = &vat_main;
3571 vat_json_node_t *node = NULL;
3572 vat_json_node_t *loc_node;
3574 if (VAT_JSON_ARRAY != vam->json_tree.type)
3576 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3577 vat_json_init_array (&vam->json_tree);
3579 node = vat_json_array_add (&vam->json_tree);
3580 vat_json_init_object (node);
3582 loc_node = vat_json_object_add (node, "local_locator");
3583 vat_json_init_object (loc_node);
3584 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3586 loc_node = vat_json_object_add (node, "remote_locator");
3587 vat_json_init_object (loc_node);
3588 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3592 vl_api_gpe_fwd_entries_get_reply_t_handler
3593 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3595 vat_main_t *vam = &vat_main;
3597 int retval = clib_net_to_host_u32 (mp->retval);
3598 vl_api_gpe_fwd_entry_t *e;
3603 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3605 for (i = 0; i < mp->count; i++)
3607 e = &mp->entries[i];
3608 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3609 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3610 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3614 vam->retval = retval;
3615 vam->result_ready = 1;
3619 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3620 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3623 vat_main_t *vam = &vat_main;
3624 vat_json_node_t *e = 0, root;
3626 int retval = clib_net_to_host_u32 (mp->retval);
3627 vl_api_gpe_fwd_entry_t *fwd;
3632 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3633 vat_json_init_array (&root);
3635 for (i = 0; i < mp->count; i++)
3637 e = vat_json_array_add (&root);
3638 fwd = &mp->entries[i];
3640 vat_json_init_object (e);
3641 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3642 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3643 vat_json_object_add_int (e, "vni", fwd->vni);
3644 vat_json_object_add_int (e, "action", fwd->action);
3646 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3647 fwd->leid_prefix_len);
3649 vat_json_object_add_string_copy (e, "leid", s);
3652 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3653 fwd->reid_prefix_len);
3655 vat_json_object_add_string_copy (e, "reid", s);
3659 vat_json_print (vam->ofp, &root);
3660 vat_json_free (&root);
3663 vam->retval = retval;
3664 vam->result_ready = 1;
3668 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3669 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3671 vat_main_t *vam = &vat_main;
3673 int retval = clib_net_to_host_u32 (mp->retval);
3674 vl_api_gpe_native_fwd_rpath_t *r;
3679 n = clib_net_to_host_u32 (mp->count);
3681 for (i = 0; i < n; i++)
3683 r = &mp->entries[i];
3684 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3685 clib_net_to_host_u32 (r->fib_index),
3686 clib_net_to_host_u32 (r->nh_sw_if_index),
3687 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3691 vam->retval = retval;
3692 vam->result_ready = 1;
3696 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3697 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3699 vat_main_t *vam = &vat_main;
3700 vat_json_node_t root, *e;
3702 int retval = clib_net_to_host_u32 (mp->retval);
3703 vl_api_gpe_native_fwd_rpath_t *r;
3709 n = clib_net_to_host_u32 (mp->count);
3710 vat_json_init_array (&root);
3712 for (i = 0; i < n; i++)
3714 e = vat_json_array_add (&root);
3715 vat_json_init_object (e);
3716 r = &mp->entries[i];
3718 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3721 vat_json_object_add_string_copy (e, "ip4", s);
3724 vat_json_object_add_uint (e, "fib_index",
3725 clib_net_to_host_u32 (r->fib_index));
3726 vat_json_object_add_uint (e, "nh_sw_if_index",
3727 clib_net_to_host_u32 (r->nh_sw_if_index));
3730 vat_json_print (vam->ofp, &root);
3731 vat_json_free (&root);
3734 vam->retval = retval;
3735 vam->result_ready = 1;
3739 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3740 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3742 vat_main_t *vam = &vat_main;
3744 int retval = clib_net_to_host_u32 (mp->retval);
3749 n = clib_net_to_host_u32 (mp->count);
3751 for (i = 0; i < n; i++)
3752 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3755 vam->retval = retval;
3756 vam->result_ready = 1;
3760 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3761 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3763 vat_main_t *vam = &vat_main;
3764 vat_json_node_t root;
3766 int retval = clib_net_to_host_u32 (mp->retval);
3771 n = clib_net_to_host_u32 (mp->count);
3772 vat_json_init_array (&root);
3774 for (i = 0; i < n; i++)
3775 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3777 vat_json_print (vam->ofp, &root);
3778 vat_json_free (&root);
3781 vam->retval = retval;
3782 vam->result_ready = 1;
3786 vl_api_one_ndp_entries_get_reply_t_handler
3787 (vl_api_one_ndp_entries_get_reply_t * mp)
3789 vat_main_t *vam = &vat_main;
3791 int retval = clib_net_to_host_u32 (mp->retval);
3796 n = clib_net_to_host_u32 (mp->count);
3798 for (i = 0; i < n; i++)
3799 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3800 format_ethernet_address, mp->entries[i].mac);
3803 vam->retval = retval;
3804 vam->result_ready = 1;
3808 vl_api_one_ndp_entries_get_reply_t_handler_json
3809 (vl_api_one_ndp_entries_get_reply_t * mp)
3812 vat_main_t *vam = &vat_main;
3813 vat_json_node_t *e = 0, root;
3815 int retval = clib_net_to_host_u32 (mp->retval);
3816 vl_api_one_ndp_entry_t *arp_entry;
3821 n = clib_net_to_host_u32 (mp->count);
3822 vat_json_init_array (&root);
3824 for (i = 0; i < n; i++)
3826 e = vat_json_array_add (&root);
3827 arp_entry = &mp->entries[i];
3829 vat_json_init_object (e);
3830 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3833 vat_json_object_add_string_copy (e, "mac", s);
3836 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3838 vat_json_object_add_string_copy (e, "ip6", s);
3842 vat_json_print (vam->ofp, &root);
3843 vat_json_free (&root);
3846 vam->retval = retval;
3847 vam->result_ready = 1;
3851 vl_api_one_l2_arp_entries_get_reply_t_handler
3852 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3854 vat_main_t *vam = &vat_main;
3856 int retval = clib_net_to_host_u32 (mp->retval);
3861 n = clib_net_to_host_u32 (mp->count);
3863 for (i = 0; i < n; i++)
3864 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3865 format_ethernet_address, mp->entries[i].mac);
3868 vam->retval = retval;
3869 vam->result_ready = 1;
3873 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3874 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3877 vat_main_t *vam = &vat_main;
3878 vat_json_node_t *e = 0, root;
3880 int retval = clib_net_to_host_u32 (mp->retval);
3881 vl_api_one_l2_arp_entry_t *arp_entry;
3886 n = clib_net_to_host_u32 (mp->count);
3887 vat_json_init_array (&root);
3889 for (i = 0; i < n; i++)
3891 e = vat_json_array_add (&root);
3892 arp_entry = &mp->entries[i];
3894 vat_json_init_object (e);
3895 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3898 vat_json_object_add_string_copy (e, "mac", s);
3901 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3903 vat_json_object_add_string_copy (e, "ip4", s);
3907 vat_json_print (vam->ofp, &root);
3908 vat_json_free (&root);
3911 vam->retval = retval;
3912 vam->result_ready = 1;
3916 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3918 vat_main_t *vam = &vat_main;
3920 int retval = clib_net_to_host_u32 (mp->retval);
3925 n = clib_net_to_host_u32 (mp->count);
3927 for (i = 0; i < n; i++)
3929 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3933 vam->retval = retval;
3934 vam->result_ready = 1;
3938 vl_api_one_ndp_bd_get_reply_t_handler_json
3939 (vl_api_one_ndp_bd_get_reply_t * mp)
3941 vat_main_t *vam = &vat_main;
3942 vat_json_node_t root;
3944 int retval = clib_net_to_host_u32 (mp->retval);
3949 n = clib_net_to_host_u32 (mp->count);
3950 vat_json_init_array (&root);
3952 for (i = 0; i < n; i++)
3954 vat_json_array_add_uint (&root,
3955 clib_net_to_host_u32 (mp->bridge_domains[i]));
3958 vat_json_print (vam->ofp, &root);
3959 vat_json_free (&root);
3962 vam->retval = retval;
3963 vam->result_ready = 1;
3967 vl_api_one_l2_arp_bd_get_reply_t_handler
3968 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3970 vat_main_t *vam = &vat_main;
3972 int retval = clib_net_to_host_u32 (mp->retval);
3977 n = clib_net_to_host_u32 (mp->count);
3979 for (i = 0; i < n; i++)
3981 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3985 vam->retval = retval;
3986 vam->result_ready = 1;
3990 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3991 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3993 vat_main_t *vam = &vat_main;
3994 vat_json_node_t root;
3996 int retval = clib_net_to_host_u32 (mp->retval);
4001 n = clib_net_to_host_u32 (mp->count);
4002 vat_json_init_array (&root);
4004 for (i = 0; i < n; i++)
4006 vat_json_array_add_uint (&root,
4007 clib_net_to_host_u32 (mp->bridge_domains[i]));
4010 vat_json_print (vam->ofp, &root);
4011 vat_json_free (&root);
4014 vam->retval = retval;
4015 vam->result_ready = 1;
4019 vl_api_one_adjacencies_get_reply_t_handler
4020 (vl_api_one_adjacencies_get_reply_t * mp)
4022 vat_main_t *vam = &vat_main;
4024 int retval = clib_net_to_host_u32 (mp->retval);
4025 vl_api_one_adjacency_t *a;
4030 n = clib_net_to_host_u32 (mp->count);
4032 for (i = 0; i < n; i++)
4034 a = &mp->adjacencies[i];
4035 print (vam->ofp, "%U %40U",
4036 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
4037 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
4041 vam->retval = retval;
4042 vam->result_ready = 1;
4046 vl_api_one_adjacencies_get_reply_t_handler_json
4047 (vl_api_one_adjacencies_get_reply_t * mp)
4050 vat_main_t *vam = &vat_main;
4051 vat_json_node_t *e = 0, root;
4053 int retval = clib_net_to_host_u32 (mp->retval);
4054 vl_api_one_adjacency_t *a;
4059 n = clib_net_to_host_u32 (mp->count);
4060 vat_json_init_array (&root);
4062 for (i = 0; i < n; i++)
4064 e = vat_json_array_add (&root);
4065 a = &mp->adjacencies[i];
4067 vat_json_init_object (e);
4068 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4069 a->leid_prefix_len);
4071 vat_json_object_add_string_copy (e, "leid", s);
4074 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4075 a->reid_prefix_len);
4077 vat_json_object_add_string_copy (e, "reid", s);
4081 vat_json_print (vam->ofp, &root);
4082 vat_json_free (&root);
4085 vam->retval = retval;
4086 vam->result_ready = 1;
4090 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4092 vat_main_t *vam = &vat_main;
4094 print (vam->ofp, "%=20U",
4095 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4100 vl_api_one_map_server_details_t_handler_json
4101 (vl_api_one_map_server_details_t * mp)
4103 vat_main_t *vam = &vat_main;
4104 vat_json_node_t *node = NULL;
4105 struct in6_addr ip6;
4108 if (VAT_JSON_ARRAY != vam->json_tree.type)
4110 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4111 vat_json_init_array (&vam->json_tree);
4113 node = vat_json_array_add (&vam->json_tree);
4115 vat_json_init_object (node);
4118 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4119 vat_json_object_add_ip6 (node, "map-server", ip6);
4123 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4124 vat_json_object_add_ip4 (node, "map-server", ip4);
4129 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4132 vat_main_t *vam = &vat_main;
4134 print (vam->ofp, "%=20U",
4135 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4140 vl_api_one_map_resolver_details_t_handler_json
4141 (vl_api_one_map_resolver_details_t * mp)
4143 vat_main_t *vam = &vat_main;
4144 vat_json_node_t *node = NULL;
4145 struct in6_addr ip6;
4148 if (VAT_JSON_ARRAY != vam->json_tree.type)
4150 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4151 vat_json_init_array (&vam->json_tree);
4153 node = vat_json_array_add (&vam->json_tree);
4155 vat_json_init_object (node);
4158 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4159 vat_json_object_add_ip6 (node, "map resolver", ip6);
4163 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4164 vat_json_object_add_ip4 (node, "map resolver", ip4);
4169 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4171 vat_main_t *vam = &vat_main;
4172 i32 retval = ntohl (mp->retval);
4176 print (vam->ofp, "feature: %s\ngpe: %s",
4177 mp->feature_status ? "enabled" : "disabled",
4178 mp->gpe_status ? "enabled" : "disabled");
4181 vam->retval = retval;
4182 vam->result_ready = 1;
4186 vl_api_show_one_status_reply_t_handler_json
4187 (vl_api_show_one_status_reply_t * mp)
4189 vat_main_t *vam = &vat_main;
4190 vat_json_node_t node;
4191 u8 *gpe_status = NULL;
4192 u8 *feature_status = NULL;
4194 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4195 feature_status = format (0, "%s",
4196 mp->feature_status ? "enabled" : "disabled");
4197 vec_add1 (gpe_status, 0);
4198 vec_add1 (feature_status, 0);
4200 vat_json_init_object (&node);
4201 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4202 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4204 vec_free (gpe_status);
4205 vec_free (feature_status);
4207 vat_json_print (vam->ofp, &node);
4208 vat_json_free (&node);
4210 vam->retval = ntohl (mp->retval);
4211 vam->result_ready = 1;
4215 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4216 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4218 vat_main_t *vam = &vat_main;
4219 i32 retval = ntohl (mp->retval);
4223 print (vam->ofp, "%=20s", mp->locator_set_name);
4226 vam->retval = retval;
4227 vam->result_ready = 1;
4231 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4232 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4234 vat_main_t *vam = &vat_main;
4235 vat_json_node_t *node = NULL;
4237 if (VAT_JSON_ARRAY != vam->json_tree.type)
4239 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4240 vat_json_init_array (&vam->json_tree);
4242 node = vat_json_array_add (&vam->json_tree);
4244 vat_json_init_object (node);
4245 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4247 vat_json_print (vam->ofp, node);
4248 vat_json_free (node);
4250 vam->retval = ntohl (mp->retval);
4251 vam->result_ready = 1;
4255 format_lisp_map_request_mode (u8 * s, va_list * args)
4257 u32 mode = va_arg (*args, u32);
4262 return format (0, "dst-only");
4264 return format (0, "src-dst");
4270 vl_api_show_one_map_request_mode_reply_t_handler
4271 (vl_api_show_one_map_request_mode_reply_t * mp)
4273 vat_main_t *vam = &vat_main;
4274 i32 retval = ntohl (mp->retval);
4278 u32 mode = mp->mode;
4279 print (vam->ofp, "map_request_mode: %U",
4280 format_lisp_map_request_mode, mode);
4283 vam->retval = retval;
4284 vam->result_ready = 1;
4288 vl_api_show_one_map_request_mode_reply_t_handler_json
4289 (vl_api_show_one_map_request_mode_reply_t * mp)
4291 vat_main_t *vam = &vat_main;
4292 vat_json_node_t node;
4297 s = format (0, "%U", format_lisp_map_request_mode, mode);
4300 vat_json_init_object (&node);
4301 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4302 vat_json_print (vam->ofp, &node);
4303 vat_json_free (&node);
4306 vam->retval = ntohl (mp->retval);
4307 vam->result_ready = 1;
4311 vl_api_one_show_xtr_mode_reply_t_handler
4312 (vl_api_one_show_xtr_mode_reply_t * mp)
4314 vat_main_t *vam = &vat_main;
4315 i32 retval = ntohl (mp->retval);
4319 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4322 vam->retval = retval;
4323 vam->result_ready = 1;
4327 vl_api_one_show_xtr_mode_reply_t_handler_json
4328 (vl_api_one_show_xtr_mode_reply_t * mp)
4330 vat_main_t *vam = &vat_main;
4331 vat_json_node_t node;
4334 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4335 vec_add1 (status, 0);
4337 vat_json_init_object (&node);
4338 vat_json_object_add_string_copy (&node, "status", status);
4342 vat_json_print (vam->ofp, &node);
4343 vat_json_free (&node);
4345 vam->retval = ntohl (mp->retval);
4346 vam->result_ready = 1;
4350 vl_api_one_show_pitr_mode_reply_t_handler
4351 (vl_api_one_show_pitr_mode_reply_t * mp)
4353 vat_main_t *vam = &vat_main;
4354 i32 retval = ntohl (mp->retval);
4358 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4361 vam->retval = retval;
4362 vam->result_ready = 1;
4366 vl_api_one_show_pitr_mode_reply_t_handler_json
4367 (vl_api_one_show_pitr_mode_reply_t * mp)
4369 vat_main_t *vam = &vat_main;
4370 vat_json_node_t node;
4373 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4374 vec_add1 (status, 0);
4376 vat_json_init_object (&node);
4377 vat_json_object_add_string_copy (&node, "status", status);
4381 vat_json_print (vam->ofp, &node);
4382 vat_json_free (&node);
4384 vam->retval = ntohl (mp->retval);
4385 vam->result_ready = 1;
4389 vl_api_one_show_petr_mode_reply_t_handler
4390 (vl_api_one_show_petr_mode_reply_t * mp)
4392 vat_main_t *vam = &vat_main;
4393 i32 retval = ntohl (mp->retval);
4397 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4400 vam->retval = retval;
4401 vam->result_ready = 1;
4405 vl_api_one_show_petr_mode_reply_t_handler_json
4406 (vl_api_one_show_petr_mode_reply_t * mp)
4408 vat_main_t *vam = &vat_main;
4409 vat_json_node_t node;
4412 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4413 vec_add1 (status, 0);
4415 vat_json_init_object (&node);
4416 vat_json_object_add_string_copy (&node, "status", status);
4420 vat_json_print (vam->ofp, &node);
4421 vat_json_free (&node);
4423 vam->retval = ntohl (mp->retval);
4424 vam->result_ready = 1;
4428 vl_api_show_one_use_petr_reply_t_handler
4429 (vl_api_show_one_use_petr_reply_t * mp)
4431 vat_main_t *vam = &vat_main;
4432 i32 retval = ntohl (mp->retval);
4436 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4439 print (vam->ofp, "Proxy-ETR address; %U",
4440 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4445 vam->retval = retval;
4446 vam->result_ready = 1;
4450 vl_api_show_one_use_petr_reply_t_handler_json
4451 (vl_api_show_one_use_petr_reply_t * mp)
4453 vat_main_t *vam = &vat_main;
4454 vat_json_node_t node;
4457 struct in6_addr ip6;
4459 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4460 vec_add1 (status, 0);
4462 vat_json_init_object (&node);
4463 vat_json_object_add_string_copy (&node, "status", status);
4468 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4469 vat_json_object_add_ip6 (&node, "address", ip6);
4473 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4474 vat_json_object_add_ip4 (&node, "address", ip4);
4480 vat_json_print (vam->ofp, &node);
4481 vat_json_free (&node);
4483 vam->retval = ntohl (mp->retval);
4484 vam->result_ready = 1;
4488 vl_api_show_one_nsh_mapping_reply_t_handler
4489 (vl_api_show_one_nsh_mapping_reply_t * mp)
4491 vat_main_t *vam = &vat_main;
4492 i32 retval = ntohl (mp->retval);
4496 print (vam->ofp, "%-20s%-16s",
4497 mp->is_set ? "set" : "not-set",
4498 mp->is_set ? (char *) mp->locator_set_name : "");
4501 vam->retval = retval;
4502 vam->result_ready = 1;
4506 vl_api_show_one_nsh_mapping_reply_t_handler_json
4507 (vl_api_show_one_nsh_mapping_reply_t * mp)
4509 vat_main_t *vam = &vat_main;
4510 vat_json_node_t node;
4513 status = format (0, "%s", mp->is_set ? "yes" : "no");
4514 vec_add1 (status, 0);
4516 vat_json_init_object (&node);
4517 vat_json_object_add_string_copy (&node, "is_set", status);
4520 vat_json_object_add_string_copy (&node, "locator_set",
4521 mp->locator_set_name);
4526 vat_json_print (vam->ofp, &node);
4527 vat_json_free (&node);
4529 vam->retval = ntohl (mp->retval);
4530 vam->result_ready = 1;
4534 vl_api_show_one_map_register_ttl_reply_t_handler
4535 (vl_api_show_one_map_register_ttl_reply_t * mp)
4537 vat_main_t *vam = &vat_main;
4538 i32 retval = ntohl (mp->retval);
4540 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4544 print (vam->ofp, "ttl: %u", mp->ttl);
4547 vam->retval = retval;
4548 vam->result_ready = 1;
4552 vl_api_show_one_map_register_ttl_reply_t_handler_json
4553 (vl_api_show_one_map_register_ttl_reply_t * mp)
4555 vat_main_t *vam = &vat_main;
4556 vat_json_node_t node;
4558 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4559 vat_json_init_object (&node);
4560 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4562 vat_json_print (vam->ofp, &node);
4563 vat_json_free (&node);
4565 vam->retval = ntohl (mp->retval);
4566 vam->result_ready = 1;
4570 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4572 vat_main_t *vam = &vat_main;
4573 i32 retval = ntohl (mp->retval);
4577 print (vam->ofp, "%-20s%-16s",
4578 mp->status ? "enabled" : "disabled",
4579 mp->status ? (char *) mp->locator_set_name : "");
4582 vam->retval = retval;
4583 vam->result_ready = 1;
4587 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4589 vat_main_t *vam = &vat_main;
4590 vat_json_node_t node;
4593 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4594 vec_add1 (status, 0);
4596 vat_json_init_object (&node);
4597 vat_json_object_add_string_copy (&node, "status", status);
4600 vat_json_object_add_string_copy (&node, "locator_set",
4601 mp->locator_set_name);
4606 vat_json_print (vam->ofp, &node);
4607 vat_json_free (&node);
4609 vam->retval = ntohl (mp->retval);
4610 vam->result_ready = 1;
4614 format_policer_type (u8 * s, va_list * va)
4616 u32 i = va_arg (*va, u32);
4618 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4619 s = format (s, "1r2c");
4620 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4621 s = format (s, "1r3c");
4622 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4623 s = format (s, "2r3c-2698");
4624 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4625 s = format (s, "2r3c-4115");
4626 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4627 s = format (s, "2r3c-mef5cf1");
4629 s = format (s, "ILLEGAL");
4634 format_policer_rate_type (u8 * s, va_list * va)
4636 u32 i = va_arg (*va, u32);
4638 if (i == SSE2_QOS_RATE_KBPS)
4639 s = format (s, "kbps");
4640 else if (i == SSE2_QOS_RATE_PPS)
4641 s = format (s, "pps");
4643 s = format (s, "ILLEGAL");
4648 format_policer_round_type (u8 * s, va_list * va)
4650 u32 i = va_arg (*va, u32);
4652 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4653 s = format (s, "closest");
4654 else if (i == SSE2_QOS_ROUND_TO_UP)
4655 s = format (s, "up");
4656 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4657 s = format (s, "down");
4659 s = format (s, "ILLEGAL");
4664 format_policer_action_type (u8 * s, va_list * va)
4666 u32 i = va_arg (*va, u32);
4668 if (i == SSE2_QOS_ACTION_DROP)
4669 s = format (s, "drop");
4670 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4671 s = format (s, "transmit");
4672 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4673 s = format (s, "mark-and-transmit");
4675 s = format (s, "ILLEGAL");
4680 format_dscp (u8 * s, va_list * va)
4682 u32 i = va_arg (*va, u32);
4687 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4691 return format (s, "ILLEGAL");
4693 s = format (s, "%s", t);
4698 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4700 vat_main_t *vam = &vat_main;
4701 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4703 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4704 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4706 conform_dscp_str = format (0, "");
4708 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4709 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4711 exceed_dscp_str = format (0, "");
4713 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4714 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4716 violate_dscp_str = format (0, "");
4718 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4719 "rate type %U, round type %U, %s rate, %s color-aware, "
4720 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4721 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4722 "conform action %U%s, exceed action %U%s, violate action %U%s",
4724 format_policer_type, mp->type,
4727 clib_net_to_host_u64 (mp->cb),
4728 clib_net_to_host_u64 (mp->eb),
4729 format_policer_rate_type, mp->rate_type,
4730 format_policer_round_type, mp->round_type,
4731 mp->single_rate ? "single" : "dual",
4732 mp->color_aware ? "is" : "not",
4733 ntohl (mp->cir_tokens_per_period),
4734 ntohl (mp->pir_tokens_per_period),
4736 ntohl (mp->current_limit),
4737 ntohl (mp->current_bucket),
4738 ntohl (mp->extended_limit),
4739 ntohl (mp->extended_bucket),
4740 clib_net_to_host_u64 (mp->last_update_time),
4741 format_policer_action_type, mp->conform_action_type,
4743 format_policer_action_type, mp->exceed_action_type,
4745 format_policer_action_type, mp->violate_action_type,
4748 vec_free (conform_dscp_str);
4749 vec_free (exceed_dscp_str);
4750 vec_free (violate_dscp_str);
4753 static void vl_api_policer_details_t_handler_json
4754 (vl_api_policer_details_t * mp)
4756 vat_main_t *vam = &vat_main;
4757 vat_json_node_t *node;
4758 u8 *rate_type_str, *round_type_str, *type_str;
4759 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4761 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4763 format (0, "%U", format_policer_round_type, mp->round_type);
4764 type_str = format (0, "%U", format_policer_type, mp->type);
4765 conform_action_str = format (0, "%U", format_policer_action_type,
4766 mp->conform_action_type);
4767 exceed_action_str = format (0, "%U", format_policer_action_type,
4768 mp->exceed_action_type);
4769 violate_action_str = format (0, "%U", format_policer_action_type,
4770 mp->violate_action_type);
4772 if (VAT_JSON_ARRAY != vam->json_tree.type)
4774 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4775 vat_json_init_array (&vam->json_tree);
4777 node = vat_json_array_add (&vam->json_tree);
4779 vat_json_init_object (node);
4780 vat_json_object_add_string_copy (node, "name", mp->name);
4781 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4782 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4783 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4784 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4785 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4786 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4787 vat_json_object_add_string_copy (node, "type", type_str);
4788 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4789 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4790 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4791 vat_json_object_add_uint (node, "cir_tokens_per_period",
4792 ntohl (mp->cir_tokens_per_period));
4793 vat_json_object_add_uint (node, "eir_tokens_per_period",
4794 ntohl (mp->pir_tokens_per_period));
4795 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4796 vat_json_object_add_uint (node, "current_bucket",
4797 ntohl (mp->current_bucket));
4798 vat_json_object_add_uint (node, "extended_limit",
4799 ntohl (mp->extended_limit));
4800 vat_json_object_add_uint (node, "extended_bucket",
4801 ntohl (mp->extended_bucket));
4802 vat_json_object_add_uint (node, "last_update_time",
4803 ntohl (mp->last_update_time));
4804 vat_json_object_add_string_copy (node, "conform_action",
4805 conform_action_str);
4806 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4808 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4809 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4810 vec_free (dscp_str);
4812 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4813 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4815 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4816 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4817 vec_free (dscp_str);
4819 vat_json_object_add_string_copy (node, "violate_action",
4820 violate_action_str);
4821 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4823 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4824 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4825 vec_free (dscp_str);
4828 vec_free (rate_type_str);
4829 vec_free (round_type_str);
4830 vec_free (type_str);
4831 vec_free (conform_action_str);
4832 vec_free (exceed_action_str);
4833 vec_free (violate_action_str);
4837 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4840 vat_main_t *vam = &vat_main;
4841 int i, count = ntohl (mp->count);
4844 print (vam->ofp, "classify table ids (%d) : ", count);
4845 for (i = 0; i < count; i++)
4847 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4848 print (vam->ofp, (i < count - 1) ? "," : "");
4850 vam->retval = ntohl (mp->retval);
4851 vam->result_ready = 1;
4855 vl_api_classify_table_ids_reply_t_handler_json
4856 (vl_api_classify_table_ids_reply_t * mp)
4858 vat_main_t *vam = &vat_main;
4859 int i, count = ntohl (mp->count);
4863 vat_json_node_t node;
4865 vat_json_init_object (&node);
4866 for (i = 0; i < count; i++)
4868 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4870 vat_json_print (vam->ofp, &node);
4871 vat_json_free (&node);
4873 vam->retval = ntohl (mp->retval);
4874 vam->result_ready = 1;
4878 vl_api_classify_table_by_interface_reply_t_handler
4879 (vl_api_classify_table_by_interface_reply_t * mp)
4881 vat_main_t *vam = &vat_main;
4884 table_id = ntohl (mp->l2_table_id);
4886 print (vam->ofp, "l2 table id : %d", table_id);
4888 print (vam->ofp, "l2 table id : No input ACL tables configured");
4889 table_id = ntohl (mp->ip4_table_id);
4891 print (vam->ofp, "ip4 table id : %d", table_id);
4893 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4894 table_id = ntohl (mp->ip6_table_id);
4896 print (vam->ofp, "ip6 table id : %d", table_id);
4898 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4899 vam->retval = ntohl (mp->retval);
4900 vam->result_ready = 1;
4904 vl_api_classify_table_by_interface_reply_t_handler_json
4905 (vl_api_classify_table_by_interface_reply_t * mp)
4907 vat_main_t *vam = &vat_main;
4908 vat_json_node_t node;
4910 vat_json_init_object (&node);
4912 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4913 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4914 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4916 vat_json_print (vam->ofp, &node);
4917 vat_json_free (&node);
4919 vam->retval = ntohl (mp->retval);
4920 vam->result_ready = 1;
4923 static void vl_api_policer_add_del_reply_t_handler
4924 (vl_api_policer_add_del_reply_t * mp)
4926 vat_main_t *vam = &vat_main;
4927 i32 retval = ntohl (mp->retval);
4928 if (vam->async_mode)
4930 vam->async_errors += (retval < 0);
4934 vam->retval = retval;
4935 vam->result_ready = 1;
4936 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4938 * Note: this is just barely thread-safe, depends on
4939 * the main thread spinning waiting for an answer...
4941 errmsg ("policer index %d", ntohl (mp->policer_index));
4945 static void vl_api_policer_add_del_reply_t_handler_json
4946 (vl_api_policer_add_del_reply_t * mp)
4948 vat_main_t *vam = &vat_main;
4949 vat_json_node_t node;
4951 vat_json_init_object (&node);
4952 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4953 vat_json_object_add_uint (&node, "policer_index",
4954 ntohl (mp->policer_index));
4956 vat_json_print (vam->ofp, &node);
4957 vat_json_free (&node);
4959 vam->retval = ntohl (mp->retval);
4960 vam->result_ready = 1;
4963 /* Format hex dump. */
4965 format_hex_bytes (u8 * s, va_list * va)
4967 u8 *bytes = va_arg (*va, u8 *);
4968 int n_bytes = va_arg (*va, int);
4971 /* Print short or long form depending on byte count. */
4972 uword short_form = n_bytes <= 32;
4973 u32 indent = format_get_indent (s);
4978 for (i = 0; i < n_bytes; i++)
4980 if (!short_form && (i % 32) == 0)
4981 s = format (s, "%08x: ", i);
4982 s = format (s, "%02x", bytes[i]);
4983 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4984 s = format (s, "\n%U", format_white_space, indent);
4991 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4994 vat_main_t *vam = &vat_main;
4995 i32 retval = ntohl (mp->retval);
4998 print (vam->ofp, "classify table info :");
4999 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
5000 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
5001 ntohl (mp->miss_next_index));
5002 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
5003 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
5004 ntohl (mp->match_n_vectors));
5005 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
5006 ntohl (mp->mask_length));
5008 vam->retval = retval;
5009 vam->result_ready = 1;
5013 vl_api_classify_table_info_reply_t_handler_json
5014 (vl_api_classify_table_info_reply_t * mp)
5016 vat_main_t *vam = &vat_main;
5017 vat_json_node_t node;
5019 i32 retval = ntohl (mp->retval);
5022 vat_json_init_object (&node);
5024 vat_json_object_add_int (&node, "sessions",
5025 ntohl (mp->active_sessions));
5026 vat_json_object_add_int (&node, "nexttbl",
5027 ntohl (mp->next_table_index));
5028 vat_json_object_add_int (&node, "nextnode",
5029 ntohl (mp->miss_next_index));
5030 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
5031 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
5032 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
5033 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
5034 ntohl (mp->mask_length), 0);
5035 vat_json_object_add_string_copy (&node, "mask", s);
5037 vat_json_print (vam->ofp, &node);
5038 vat_json_free (&node);
5040 vam->retval = ntohl (mp->retval);
5041 vam->result_ready = 1;
5045 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5048 vat_main_t *vam = &vat_main;
5050 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5051 ntohl (mp->hit_next_index), ntohl (mp->advance),
5052 ntohl (mp->opaque_index));
5053 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5054 ntohl (mp->match_length));
5058 vl_api_classify_session_details_t_handler_json
5059 (vl_api_classify_session_details_t * mp)
5061 vat_main_t *vam = &vat_main;
5062 vat_json_node_t *node = NULL;
5064 if (VAT_JSON_ARRAY != vam->json_tree.type)
5066 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5067 vat_json_init_array (&vam->json_tree);
5069 node = vat_json_array_add (&vam->json_tree);
5071 vat_json_init_object (node);
5072 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5073 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5074 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5076 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5078 vat_json_object_add_string_copy (node, "match", s);
5081 static void vl_api_pg_create_interface_reply_t_handler
5082 (vl_api_pg_create_interface_reply_t * mp)
5084 vat_main_t *vam = &vat_main;
5086 vam->retval = ntohl (mp->retval);
5087 vam->result_ready = 1;
5090 static void vl_api_pg_create_interface_reply_t_handler_json
5091 (vl_api_pg_create_interface_reply_t * mp)
5093 vat_main_t *vam = &vat_main;
5094 vat_json_node_t node;
5096 i32 retval = ntohl (mp->retval);
5099 vat_json_init_object (&node);
5101 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5103 vat_json_print (vam->ofp, &node);
5104 vat_json_free (&node);
5106 vam->retval = ntohl (mp->retval);
5107 vam->result_ready = 1;
5110 static void vl_api_policer_classify_details_t_handler
5111 (vl_api_policer_classify_details_t * mp)
5113 vat_main_t *vam = &vat_main;
5115 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5116 ntohl (mp->table_index));
5119 static void vl_api_policer_classify_details_t_handler_json
5120 (vl_api_policer_classify_details_t * mp)
5122 vat_main_t *vam = &vat_main;
5123 vat_json_node_t *node;
5125 if (VAT_JSON_ARRAY != vam->json_tree.type)
5127 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5128 vat_json_init_array (&vam->json_tree);
5130 node = vat_json_array_add (&vam->json_tree);
5132 vat_json_init_object (node);
5133 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5134 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5137 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5138 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5140 vat_main_t *vam = &vat_main;
5141 i32 retval = ntohl (mp->retval);
5142 if (vam->async_mode)
5144 vam->async_errors += (retval < 0);
5148 vam->retval = retval;
5149 vam->sw_if_index = ntohl (mp->sw_if_index);
5150 vam->result_ready = 1;
5154 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5155 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5157 vat_main_t *vam = &vat_main;
5158 vat_json_node_t node;
5160 vat_json_init_object (&node);
5161 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5162 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5164 vat_json_print (vam->ofp, &node);
5165 vat_json_free (&node);
5167 vam->retval = ntohl (mp->retval);
5168 vam->result_ready = 1;
5171 static void vl_api_flow_classify_details_t_handler
5172 (vl_api_flow_classify_details_t * mp)
5174 vat_main_t *vam = &vat_main;
5176 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5177 ntohl (mp->table_index));
5180 static void vl_api_flow_classify_details_t_handler_json
5181 (vl_api_flow_classify_details_t * mp)
5183 vat_main_t *vam = &vat_main;
5184 vat_json_node_t *node;
5186 if (VAT_JSON_ARRAY != vam->json_tree.type)
5188 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5189 vat_json_init_array (&vam->json_tree);
5191 node = vat_json_array_add (&vam->json_tree);
5193 vat_json_init_object (node);
5194 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5195 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5198 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5199 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5200 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5201 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5202 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5203 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5204 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5205 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5206 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5207 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5208 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5209 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5210 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5211 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5212 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5213 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5214 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5215 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5216 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5217 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5218 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5219 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5222 * Generate boilerplate reply handlers, which
5223 * dig the return value out of the xxx_reply_t API message,
5224 * stick it into vam->retval, and set vam->result_ready
5226 * Could also do this by pointing N message decode slots at
5227 * a single function, but that could break in subtle ways.
5230 #define foreach_standard_reply_retval_handler \
5231 _(sw_interface_set_flags_reply) \
5232 _(sw_interface_add_del_address_reply) \
5233 _(sw_interface_set_rx_mode_reply) \
5234 _(sw_interface_set_table_reply) \
5235 _(sw_interface_set_mpls_enable_reply) \
5236 _(sw_interface_set_vpath_reply) \
5237 _(sw_interface_set_vxlan_bypass_reply) \
5238 _(sw_interface_set_geneve_bypass_reply) \
5239 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5240 _(sw_interface_set_l2_bridge_reply) \
5241 _(bridge_domain_add_del_reply) \
5242 _(sw_interface_set_l2_xconnect_reply) \
5243 _(l2fib_add_del_reply) \
5244 _(l2fib_flush_int_reply) \
5245 _(l2fib_flush_bd_reply) \
5246 _(ip_add_del_route_reply) \
5247 _(ip_table_add_del_reply) \
5248 _(ip_mroute_add_del_reply) \
5249 _(mpls_route_add_del_reply) \
5250 _(mpls_table_add_del_reply) \
5251 _(mpls_ip_bind_unbind_reply) \
5252 _(bier_route_add_del_reply) \
5253 _(bier_table_add_del_reply) \
5254 _(proxy_arp_add_del_reply) \
5255 _(proxy_arp_intfc_enable_disable_reply) \
5256 _(sw_interface_set_unnumbered_reply) \
5257 _(ip_neighbor_add_del_reply) \
5258 _(oam_add_del_reply) \
5259 _(reset_fib_reply) \
5260 _(dhcp_proxy_config_reply) \
5261 _(dhcp_proxy_set_vss_reply) \
5262 _(dhcp_client_config_reply) \
5263 _(set_ip_flow_hash_reply) \
5264 _(sw_interface_ip6_enable_disable_reply) \
5265 _(sw_interface_ip6_set_link_local_address_reply) \
5266 _(ip6nd_proxy_add_del_reply) \
5267 _(sw_interface_ip6nd_ra_prefix_reply) \
5268 _(sw_interface_ip6nd_ra_config_reply) \
5269 _(set_arp_neighbor_limit_reply) \
5270 _(l2_patch_add_del_reply) \
5271 _(sr_policy_add_reply) \
5272 _(sr_policy_mod_reply) \
5273 _(sr_policy_del_reply) \
5274 _(sr_localsid_add_del_reply) \
5275 _(sr_steering_add_del_reply) \
5276 _(classify_add_del_session_reply) \
5277 _(classify_set_interface_ip_table_reply) \
5278 _(classify_set_interface_l2_tables_reply) \
5279 _(l2tpv3_set_tunnel_cookies_reply) \
5280 _(l2tpv3_interface_enable_disable_reply) \
5281 _(l2tpv3_set_lookup_key_reply) \
5282 _(l2_fib_clear_table_reply) \
5283 _(l2_interface_efp_filter_reply) \
5284 _(l2_interface_vlan_tag_rewrite_reply) \
5285 _(modify_vhost_user_if_reply) \
5286 _(delete_vhost_user_if_reply) \
5287 _(want_ip4_arp_events_reply) \
5288 _(want_ip6_nd_events_reply) \
5289 _(want_l2_macs_events_reply) \
5290 _(input_acl_set_interface_reply) \
5291 _(ipsec_spd_add_del_reply) \
5292 _(ipsec_interface_add_del_spd_reply) \
5293 _(ipsec_spd_add_del_entry_reply) \
5294 _(ipsec_sad_add_del_entry_reply) \
5295 _(ipsec_sa_set_key_reply) \
5296 _(ipsec_tunnel_if_add_del_reply) \
5297 _(ipsec_tunnel_if_set_key_reply) \
5298 _(ipsec_tunnel_if_set_sa_reply) \
5299 _(ikev2_profile_add_del_reply) \
5300 _(ikev2_profile_set_auth_reply) \
5301 _(ikev2_profile_set_id_reply) \
5302 _(ikev2_profile_set_ts_reply) \
5303 _(ikev2_set_local_key_reply) \
5304 _(ikev2_set_responder_reply) \
5305 _(ikev2_set_ike_transforms_reply) \
5306 _(ikev2_set_esp_transforms_reply) \
5307 _(ikev2_set_sa_lifetime_reply) \
5308 _(ikev2_initiate_sa_init_reply) \
5309 _(ikev2_initiate_del_ike_sa_reply) \
5310 _(ikev2_initiate_del_child_sa_reply) \
5311 _(ikev2_initiate_rekey_child_sa_reply) \
5312 _(delete_loopback_reply) \
5313 _(bd_ip_mac_add_del_reply) \
5314 _(map_del_domain_reply) \
5315 _(map_add_del_rule_reply) \
5316 _(want_interface_events_reply) \
5317 _(want_stats_reply) \
5318 _(cop_interface_enable_disable_reply) \
5319 _(cop_whitelist_enable_disable_reply) \
5320 _(sw_interface_clear_stats_reply) \
5321 _(ioam_enable_reply) \
5322 _(ioam_disable_reply) \
5323 _(one_add_del_locator_reply) \
5324 _(one_add_del_local_eid_reply) \
5325 _(one_add_del_remote_mapping_reply) \
5326 _(one_add_del_adjacency_reply) \
5327 _(one_add_del_map_resolver_reply) \
5328 _(one_add_del_map_server_reply) \
5329 _(one_enable_disable_reply) \
5330 _(one_rloc_probe_enable_disable_reply) \
5331 _(one_map_register_enable_disable_reply) \
5332 _(one_map_register_set_ttl_reply) \
5333 _(one_set_transport_protocol_reply) \
5334 _(one_map_register_fallback_threshold_reply) \
5335 _(one_pitr_set_locator_set_reply) \
5336 _(one_map_request_mode_reply) \
5337 _(one_add_del_map_request_itr_rlocs_reply) \
5338 _(one_eid_table_add_del_map_reply) \
5339 _(one_use_petr_reply) \
5340 _(one_stats_enable_disable_reply) \
5341 _(one_add_del_l2_arp_entry_reply) \
5342 _(one_add_del_ndp_entry_reply) \
5343 _(one_stats_flush_reply) \
5344 _(one_enable_disable_xtr_mode_reply) \
5345 _(one_enable_disable_pitr_mode_reply) \
5346 _(one_enable_disable_petr_mode_reply) \
5347 _(gpe_enable_disable_reply) \
5348 _(gpe_set_encap_mode_reply) \
5349 _(gpe_add_del_iface_reply) \
5350 _(gpe_add_del_native_fwd_rpath_reply) \
5351 _(af_packet_delete_reply) \
5352 _(policer_classify_set_interface_reply) \
5353 _(netmap_create_reply) \
5354 _(netmap_delete_reply) \
5355 _(set_ipfix_exporter_reply) \
5356 _(set_ipfix_classify_stream_reply) \
5357 _(ipfix_classify_table_add_del_reply) \
5358 _(flow_classify_set_interface_reply) \
5359 _(sw_interface_span_enable_disable_reply) \
5360 _(pg_capture_reply) \
5361 _(pg_enable_disable_reply) \
5362 _(ip_source_and_port_range_check_add_del_reply) \
5363 _(ip_source_and_port_range_check_interface_add_del_reply)\
5364 _(delete_subif_reply) \
5365 _(l2_interface_pbb_tag_rewrite_reply) \
5367 _(feature_enable_disable_reply) \
5368 _(sw_interface_tag_add_del_reply) \
5369 _(sw_interface_set_mtu_reply) \
5370 _(p2p_ethernet_add_reply) \
5371 _(p2p_ethernet_del_reply) \
5372 _(lldp_config_reply) \
5373 _(sw_interface_set_lldp_reply) \
5374 _(tcp_configure_src_addresses_reply) \
5375 _(dns_enable_disable_reply) \
5376 _(dns_name_server_add_del_reply) \
5377 _(session_rule_add_del_reply) \
5378 _(ip_container_proxy_add_del_reply)
5381 static void vl_api_##n##_t_handler \
5382 (vl_api_##n##_t * mp) \
5384 vat_main_t * vam = &vat_main; \
5385 i32 retval = ntohl(mp->retval); \
5386 if (vam->async_mode) { \
5387 vam->async_errors += (retval < 0); \
5389 vam->retval = retval; \
5390 vam->result_ready = 1; \
5393 foreach_standard_reply_retval_handler;
5397 static void vl_api_##n##_t_handler_json \
5398 (vl_api_##n##_t * mp) \
5400 vat_main_t * vam = &vat_main; \
5401 vat_json_node_t node; \
5402 vat_json_init_object(&node); \
5403 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5404 vat_json_print(vam->ofp, &node); \
5405 vam->retval = ntohl(mp->retval); \
5406 vam->result_ready = 1; \
5408 foreach_standard_reply_retval_handler;
5412 * Table of message reply handlers, must include boilerplate handlers
5416 #define foreach_vpe_api_reply_msg \
5417 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5418 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5419 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5420 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5421 _(CONTROL_PING_REPLY, control_ping_reply) \
5422 _(CLI_REPLY, cli_reply) \
5423 _(CLI_INBAND_REPLY, cli_inband_reply) \
5424 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5425 sw_interface_add_del_address_reply) \
5426 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5427 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5428 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5429 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5430 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5431 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5432 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5433 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5434 sw_interface_set_l2_xconnect_reply) \
5435 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5436 sw_interface_set_l2_bridge_reply) \
5437 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5438 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5439 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5440 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5441 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5442 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5443 _(L2_FLAGS_REPLY, l2_flags_reply) \
5444 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5445 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5446 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5447 _(TAP_DELETE_REPLY, tap_delete_reply) \
5448 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5449 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5450 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5451 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5452 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5453 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5454 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5455 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5456 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5457 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5458 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5459 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5460 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5461 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5462 proxy_arp_intfc_enable_disable_reply) \
5463 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5464 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5465 sw_interface_set_unnumbered_reply) \
5466 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5467 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5468 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5469 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5470 _(RESET_FIB_REPLY, reset_fib_reply) \
5471 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5472 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5473 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5474 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5475 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5476 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5477 sw_interface_ip6_enable_disable_reply) \
5478 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5479 sw_interface_ip6_set_link_local_address_reply) \
5480 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5481 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5482 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5483 sw_interface_ip6nd_ra_prefix_reply) \
5484 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5485 sw_interface_ip6nd_ra_config_reply) \
5486 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5487 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5488 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5489 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5490 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5491 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5492 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5493 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5494 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5495 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5496 classify_set_interface_ip_table_reply) \
5497 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5498 classify_set_interface_l2_tables_reply) \
5499 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5500 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5501 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5502 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5503 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5504 l2tpv3_interface_enable_disable_reply) \
5505 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5506 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5507 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5508 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5509 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5510 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5511 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5512 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5513 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5514 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5515 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5516 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5517 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5518 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5519 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5520 _(SHOW_VERSION_REPLY, show_version_reply) \
5521 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5522 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5523 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5524 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5525 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5526 _(IP4_ARP_EVENT, ip4_arp_event) \
5527 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5528 _(IP6_ND_EVENT, ip6_nd_event) \
5529 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5530 _(L2_MACS_EVENT, l2_macs_event) \
5531 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5532 _(IP_ADDRESS_DETAILS, ip_address_details) \
5533 _(IP_DETAILS, ip_details) \
5534 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5535 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5536 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5537 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5538 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5539 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5540 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5541 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5542 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5543 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5544 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5545 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5546 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5547 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5548 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5549 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5550 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5551 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5552 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5553 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5554 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5555 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5556 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5557 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5558 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5559 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5560 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5561 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5562 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5563 _(MAP_RULE_DETAILS, map_rule_details) \
5564 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5565 _(WANT_STATS_REPLY, want_stats_reply) \
5566 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5567 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5568 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5569 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5570 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5571 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5572 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5573 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5574 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5575 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5576 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5577 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5578 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5579 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5580 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5581 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5582 one_map_register_enable_disable_reply) \
5583 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5584 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5585 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5586 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5587 one_map_register_fallback_threshold_reply) \
5588 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5589 one_rloc_probe_enable_disable_reply) \
5590 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5591 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5592 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5593 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5594 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5595 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5596 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5597 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5598 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5599 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5600 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5601 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5602 _(ONE_STATS_DETAILS, one_stats_details) \
5603 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5604 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5605 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5606 show_one_stats_enable_disable_reply) \
5607 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5608 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5609 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5610 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5611 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5612 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5613 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5614 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5615 one_enable_disable_pitr_mode_reply) \
5616 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5617 one_enable_disable_petr_mode_reply) \
5618 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5619 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5620 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5621 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5622 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5623 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5624 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5625 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5626 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5627 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5628 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5629 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5630 gpe_add_del_native_fwd_rpath_reply) \
5631 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5632 gpe_fwd_entry_path_details) \
5633 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5634 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5635 one_add_del_map_request_itr_rlocs_reply) \
5636 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5637 one_get_map_request_itr_rlocs_reply) \
5638 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5639 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5640 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5641 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5642 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5643 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5644 show_one_map_register_state_reply) \
5645 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5646 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5647 show_one_map_register_fallback_threshold_reply) \
5648 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5649 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5650 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5651 _(POLICER_DETAILS, policer_details) \
5652 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5653 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5654 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5655 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5656 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5657 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5658 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5659 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5660 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5661 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5662 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5663 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5664 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5665 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5666 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5667 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5668 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5669 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5670 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5671 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5672 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5673 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5674 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5675 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5676 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5677 ip_source_and_port_range_check_add_del_reply) \
5678 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5679 ip_source_and_port_range_check_interface_add_del_reply) \
5680 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5681 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5682 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5683 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5684 _(PUNT_REPLY, punt_reply) \
5685 _(IP_FIB_DETAILS, ip_fib_details) \
5686 _(IP6_FIB_DETAILS, ip6_fib_details) \
5687 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5688 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5689 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5690 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5691 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5692 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5693 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5694 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5695 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5696 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5697 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5698 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5699 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5700 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5701 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5702 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5703 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5704 _(SESSION_RULES_DETAILS, session_rules_details) \
5705 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5707 #define foreach_standalone_reply_msg \
5708 _(SW_INTERFACE_EVENT, sw_interface_event) \
5709 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5710 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5711 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5712 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5713 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5714 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
5715 _(MEMFD_SEGMENT_CREATE_REPLY, memfd_segment_create_reply) \
5724 #define STR_VTR_OP_CASE(op) \
5725 case L2_VTR_ ## op: \
5729 str_vtr_op (u32 vtr_op)
5733 STR_VTR_OP_CASE (DISABLED);
5734 STR_VTR_OP_CASE (PUSH_1);
5735 STR_VTR_OP_CASE (PUSH_2);
5736 STR_VTR_OP_CASE (POP_1);
5737 STR_VTR_OP_CASE (POP_2);
5738 STR_VTR_OP_CASE (TRANSLATE_1_1);
5739 STR_VTR_OP_CASE (TRANSLATE_1_2);
5740 STR_VTR_OP_CASE (TRANSLATE_2_1);
5741 STR_VTR_OP_CASE (TRANSLATE_2_2);
5748 dump_sub_interface_table (vat_main_t * vam)
5750 const sw_interface_subif_t *sub = NULL;
5752 if (vam->json_output)
5755 ("JSON output supported only for VPE API calls and dump_stats_table");
5760 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5761 "Interface", "sw_if_index",
5762 "sub id", "dot1ad", "tags", "outer id",
5763 "inner id", "exact", "default", "outer any", "inner any");
5765 vec_foreach (sub, vam->sw_if_subif_table)
5768 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5769 sub->interface_name,
5771 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5772 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5773 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5774 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5775 if (sub->vtr_op != L2_VTR_DISABLED)
5778 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5779 "tag1: %d tag2: %d ]",
5780 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5781 sub->vtr_tag1, sub->vtr_tag2);
5789 name_sort_cmp (void *a1, void *a2)
5791 name_sort_t *n1 = a1;
5792 name_sort_t *n2 = a2;
5794 return strcmp ((char *) n1->name, (char *) n2->name);
5798 dump_interface_table (vat_main_t * vam)
5801 name_sort_t *nses = 0, *ns;
5803 if (vam->json_output)
5806 ("JSON output supported only for VPE API calls and dump_stats_table");
5811 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5813 vec_add2 (nses, ns, 1);
5814 ns->name = (u8 *)(p->key);
5815 ns->value = (u32) p->value[0];
5819 vec_sort_with_function (nses, name_sort_cmp);
5821 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5822 vec_foreach (ns, nses)
5824 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5831 dump_ip_table (vat_main_t * vam, int is_ipv6)
5833 const ip_details_t *det = NULL;
5834 const ip_address_details_t *address = NULL;
5837 print (vam->ofp, "%-12s", "sw_if_index");
5839 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5846 print (vam->ofp, "%-12d", i);
5847 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5852 vec_foreach (address, det->addr)
5856 is_ipv6 ? format_ip6_address : format_ip4_address,
5857 address->ip, address->prefix_length);
5865 dump_ipv4_table (vat_main_t * vam)
5867 if (vam->json_output)
5870 ("JSON output supported only for VPE API calls and dump_stats_table");
5874 return dump_ip_table (vam, 0);
5878 dump_ipv6_table (vat_main_t * vam)
5880 if (vam->json_output)
5883 ("JSON output supported only for VPE API calls and dump_stats_table");
5887 return dump_ip_table (vam, 1);
5891 counter_type_to_str (u8 counter_type, u8 is_combined)
5895 switch (counter_type)
5897 case VNET_INTERFACE_COUNTER_DROP:
5899 case VNET_INTERFACE_COUNTER_PUNT:
5901 case VNET_INTERFACE_COUNTER_IP4:
5903 case VNET_INTERFACE_COUNTER_IP6:
5905 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5907 case VNET_INTERFACE_COUNTER_RX_MISS:
5909 case VNET_INTERFACE_COUNTER_RX_ERROR:
5911 case VNET_INTERFACE_COUNTER_TX_ERROR:
5914 return "INVALID-COUNTER-TYPE";
5919 switch (counter_type)
5921 case VNET_INTERFACE_COUNTER_RX:
5923 case VNET_INTERFACE_COUNTER_TX:
5926 return "INVALID-COUNTER-TYPE";
5932 dump_stats_table (vat_main_t * vam)
5934 vat_json_node_t node;
5935 vat_json_node_t *msg_array;
5936 vat_json_node_t *msg;
5937 vat_json_node_t *counter_array;
5938 vat_json_node_t *counter;
5939 interface_counter_t c;
5941 ip4_fib_counter_t *c4;
5942 ip6_fib_counter_t *c6;
5943 ip4_nbr_counter_t *n4;
5944 ip6_nbr_counter_t *n6;
5947 if (!vam->json_output)
5949 clib_warning ("dump_stats_table supported only in JSON format");
5953 vat_json_init_object (&node);
5955 /* interface counters */
5956 msg_array = vat_json_object_add (&node, "interface_counters");
5957 vat_json_init_array (msg_array);
5958 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5960 msg = vat_json_array_add (msg_array);
5961 vat_json_init_object (msg);
5962 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5963 (u8 *) counter_type_to_str (i, 0));
5964 vat_json_object_add_int (msg, "is_combined", 0);
5965 counter_array = vat_json_object_add (msg, "data");
5966 vat_json_init_array (counter_array);
5967 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5969 packets = vam->simple_interface_counters[i][j];
5970 vat_json_array_add_uint (counter_array, packets);
5973 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5975 msg = vat_json_array_add (msg_array);
5976 vat_json_init_object (msg);
5977 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5978 (u8 *) counter_type_to_str (i, 1));
5979 vat_json_object_add_int (msg, "is_combined", 1);
5980 counter_array = vat_json_object_add (msg, "data");
5981 vat_json_init_array (counter_array);
5982 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5984 c = vam->combined_interface_counters[i][j];
5985 counter = vat_json_array_add (counter_array);
5986 vat_json_init_object (counter);
5987 vat_json_object_add_uint (counter, "packets", c.packets);
5988 vat_json_object_add_uint (counter, "bytes", c.bytes);
5992 /* ip4 fib counters */
5993 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5994 vat_json_init_array (msg_array);
5995 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5997 msg = vat_json_array_add (msg_array);
5998 vat_json_init_object (msg);
5999 vat_json_object_add_uint (msg, "vrf_id",
6000 vam->ip4_fib_counters_vrf_id_by_index[i]);
6001 counter_array = vat_json_object_add (msg, "c");
6002 vat_json_init_array (counter_array);
6003 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6005 counter = vat_json_array_add (counter_array);
6006 vat_json_init_object (counter);
6007 c4 = &vam->ip4_fib_counters[i][j];
6008 vat_json_object_add_ip4 (counter, "address", c4->address);
6009 vat_json_object_add_uint (counter, "address_length",
6010 c4->address_length);
6011 vat_json_object_add_uint (counter, "packets", c4->packets);
6012 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6016 /* ip6 fib counters */
6017 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6018 vat_json_init_array (msg_array);
6019 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6021 msg = vat_json_array_add (msg_array);
6022 vat_json_init_object (msg);
6023 vat_json_object_add_uint (msg, "vrf_id",
6024 vam->ip6_fib_counters_vrf_id_by_index[i]);
6025 counter_array = vat_json_object_add (msg, "c");
6026 vat_json_init_array (counter_array);
6027 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6029 counter = vat_json_array_add (counter_array);
6030 vat_json_init_object (counter);
6031 c6 = &vam->ip6_fib_counters[i][j];
6032 vat_json_object_add_ip6 (counter, "address", c6->address);
6033 vat_json_object_add_uint (counter, "address_length",
6034 c6->address_length);
6035 vat_json_object_add_uint (counter, "packets", c6->packets);
6036 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6040 /* ip4 nbr counters */
6041 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6042 vat_json_init_array (msg_array);
6043 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6045 msg = vat_json_array_add (msg_array);
6046 vat_json_init_object (msg);
6047 vat_json_object_add_uint (msg, "sw_if_index", i);
6048 counter_array = vat_json_object_add (msg, "c");
6049 vat_json_init_array (counter_array);
6050 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6052 counter = vat_json_array_add (counter_array);
6053 vat_json_init_object (counter);
6054 n4 = &vam->ip4_nbr_counters[i][j];
6055 vat_json_object_add_ip4 (counter, "address", n4->address);
6056 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6057 vat_json_object_add_uint (counter, "packets", n4->packets);
6058 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6062 /* ip6 nbr counters */
6063 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6064 vat_json_init_array (msg_array);
6065 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6067 msg = vat_json_array_add (msg_array);
6068 vat_json_init_object (msg);
6069 vat_json_object_add_uint (msg, "sw_if_index", i);
6070 counter_array = vat_json_object_add (msg, "c");
6071 vat_json_init_array (counter_array);
6072 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6074 counter = vat_json_array_add (counter_array);
6075 vat_json_init_object (counter);
6076 n6 = &vam->ip6_nbr_counters[i][j];
6077 vat_json_object_add_ip6 (counter, "address", n6->address);
6078 vat_json_object_add_uint (counter, "packets", n6->packets);
6079 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6083 vat_json_print (vam->ofp, &node);
6084 vat_json_free (&node);
6090 * Pass CLI buffers directly in the CLI_INBAND API message,
6091 * instead of an additional shared memory area.
6094 exec_inband (vat_main_t * vam)
6096 vl_api_cli_inband_t *mp;
6097 unformat_input_t *i = vam->input;
6100 if (vec_len (i->buffer) == 0)
6103 if (vam->exec_mode == 0 && unformat (i, "mode"))
6108 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6115 * In order for the CLI command to work, it
6116 * must be a vector ending in \n, not a C-string ending
6119 u32 len = vec_len (vam->input->buffer);
6120 M2 (CLI_INBAND, mp, len);
6121 clib_memcpy (mp->cmd, vam->input->buffer, len);
6122 mp->length = htonl (len);
6126 /* json responses may or may not include a useful reply... */
6127 if (vec_len (vam->cmd_reply))
6128 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6133 exec (vat_main_t * vam)
6135 return exec_inband (vam);
6139 api_create_loopback (vat_main_t * vam)
6141 unformat_input_t *i = vam->input;
6142 vl_api_create_loopback_t *mp;
6143 vl_api_create_loopback_instance_t *mp_lbi;
6146 u8 is_specified = 0;
6147 u32 user_instance = 0;
6150 memset (mac_address, 0, sizeof (mac_address));
6152 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6154 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6156 if (unformat (i, "instance %d", &user_instance))
6164 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6165 mp_lbi->is_specified = is_specified;
6167 mp_lbi->user_instance = htonl (user_instance);
6169 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6174 /* Construct the API message */
6175 M (CREATE_LOOPBACK, mp);
6177 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6186 api_delete_loopback (vat_main_t * vam)
6188 unformat_input_t *i = vam->input;
6189 vl_api_delete_loopback_t *mp;
6190 u32 sw_if_index = ~0;
6193 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6195 if (unformat (i, "sw_if_index %d", &sw_if_index))
6201 if (sw_if_index == ~0)
6203 errmsg ("missing sw_if_index");
6207 /* Construct the API message */
6208 M (DELETE_LOOPBACK, mp);
6209 mp->sw_if_index = ntohl (sw_if_index);
6217 api_want_stats (vat_main_t * vam)
6219 unformat_input_t *i = vam->input;
6220 vl_api_want_stats_t *mp;
6224 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6226 if (unformat (i, "enable"))
6228 else if (unformat (i, "disable"))
6236 errmsg ("missing enable|disable");
6241 mp->enable_disable = enable;
6249 api_want_interface_events (vat_main_t * vam)
6251 unformat_input_t *i = vam->input;
6252 vl_api_want_interface_events_t *mp;
6256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6258 if (unformat (i, "enable"))
6260 else if (unformat (i, "disable"))
6268 errmsg ("missing enable|disable");
6272 M (WANT_INTERFACE_EVENTS, mp);
6273 mp->enable_disable = enable;
6275 vam->interface_event_display = enable;
6283 /* Note: non-static, called once to set up the initial intfc table */
6285 api_sw_interface_dump (vat_main_t * vam)
6287 vl_api_sw_interface_dump_t *mp;
6288 vl_api_control_ping_t *mp_ping;
6290 name_sort_t *nses = 0, *ns;
6291 sw_interface_subif_t *sub = NULL;
6294 /* Toss the old name table */
6296 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6298 vec_add2 (nses, ns, 1);
6299 ns->name = (u8 *)(p->key);
6300 ns->value = (u32) p->value[0];
6304 hash_free (vam->sw_if_index_by_interface_name);
6306 vec_foreach (ns, nses) vec_free (ns->name);
6310 vec_foreach (sub, vam->sw_if_subif_table)
6312 vec_free (sub->interface_name);
6314 vec_free (vam->sw_if_subif_table);
6316 /* recreate the interface name hash table */
6317 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6319 /* Get list of ethernets */
6320 M (SW_INTERFACE_DUMP, mp);
6321 mp->name_filter_valid = 1;
6322 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
6325 /* and local / loopback interfaces */
6326 M (SW_INTERFACE_DUMP, mp);
6327 mp->name_filter_valid = 1;
6328 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
6331 /* and packet-generator interfaces */
6332 M (SW_INTERFACE_DUMP, mp);
6333 mp->name_filter_valid = 1;
6334 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
6337 /* and vxlan-gpe tunnel interfaces */
6338 M (SW_INTERFACE_DUMP, mp);
6339 mp->name_filter_valid = 1;
6340 strncpy ((char *) mp->name_filter, "vxlan_gpe",
6341 sizeof (mp->name_filter) - 1);
6344 /* and vxlan tunnel interfaces */
6345 M (SW_INTERFACE_DUMP, mp);
6346 mp->name_filter_valid = 1;
6347 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
6350 /* and geneve tunnel interfaces */
6351 M (SW_INTERFACE_DUMP, mp);
6352 mp->name_filter_valid = 1;
6353 strncpy ((char *) mp->name_filter, "geneve", sizeof (mp->name_filter) - 1);
6356 /* and host (af_packet) interfaces */
6357 M (SW_INTERFACE_DUMP, mp);
6358 mp->name_filter_valid = 1;
6359 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
6362 /* and l2tpv3 tunnel interfaces */
6363 M (SW_INTERFACE_DUMP, mp);
6364 mp->name_filter_valid = 1;
6365 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
6366 sizeof (mp->name_filter) - 1);
6369 /* and GRE tunnel interfaces */
6370 M (SW_INTERFACE_DUMP, mp);
6371 mp->name_filter_valid = 1;
6372 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
6375 /* and LISP-GPE interfaces */
6376 M (SW_INTERFACE_DUMP, mp);
6377 mp->name_filter_valid = 1;
6378 strncpy ((char *) mp->name_filter, "lisp_gpe",
6379 sizeof (mp->name_filter) - 1);
6382 /* and IPSEC tunnel interfaces */
6383 M (SW_INTERFACE_DUMP, mp);
6384 mp->name_filter_valid = 1;
6385 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
6388 /* Use a control ping for synchronization */
6389 MPING (CONTROL_PING, mp_ping);
6397 api_sw_interface_set_flags (vat_main_t * vam)
6399 unformat_input_t *i = vam->input;
6400 vl_api_sw_interface_set_flags_t *mp;
6402 u8 sw_if_index_set = 0;
6406 /* Parse args required to build the message */
6407 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6409 if (unformat (i, "admin-up"))
6411 else if (unformat (i, "admin-down"))
6414 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6415 sw_if_index_set = 1;
6416 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6417 sw_if_index_set = 1;
6422 if (sw_if_index_set == 0)
6424 errmsg ("missing interface name or sw_if_index");
6428 /* Construct the API message */
6429 M (SW_INTERFACE_SET_FLAGS, mp);
6430 mp->sw_if_index = ntohl (sw_if_index);
6431 mp->admin_up_down = admin_up;
6436 /* Wait for a reply, return the good/bad news... */
6442 api_sw_interface_set_rx_mode (vat_main_t * vam)
6444 unformat_input_t *i = vam->input;
6445 vl_api_sw_interface_set_rx_mode_t *mp;
6447 u8 sw_if_index_set = 0;
6449 u8 queue_id_valid = 0;
6451 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6453 /* Parse args required to build the message */
6454 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6456 if (unformat (i, "queue %d", &queue_id))
6458 else if (unformat (i, "polling"))
6459 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6460 else if (unformat (i, "interrupt"))
6461 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6462 else if (unformat (i, "adaptive"))
6463 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6465 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6466 sw_if_index_set = 1;
6467 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6468 sw_if_index_set = 1;
6473 if (sw_if_index_set == 0)
6475 errmsg ("missing interface name or sw_if_index");
6478 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6480 errmsg ("missing rx-mode");
6484 /* Construct the API message */
6485 M (SW_INTERFACE_SET_RX_MODE, mp);
6486 mp->sw_if_index = ntohl (sw_if_index);
6488 mp->queue_id_valid = queue_id_valid;
6489 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6494 /* Wait for a reply, return the good/bad news... */
6500 api_sw_interface_clear_stats (vat_main_t * vam)
6502 unformat_input_t *i = vam->input;
6503 vl_api_sw_interface_clear_stats_t *mp;
6505 u8 sw_if_index_set = 0;
6508 /* Parse args required to build the message */
6509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6511 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6512 sw_if_index_set = 1;
6513 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6514 sw_if_index_set = 1;
6519 /* Construct the API message */
6520 M (SW_INTERFACE_CLEAR_STATS, mp);
6522 if (sw_if_index_set == 1)
6523 mp->sw_if_index = ntohl (sw_if_index);
6525 mp->sw_if_index = ~0;
6530 /* Wait for a reply, return the good/bad news... */
6536 api_sw_interface_add_del_address (vat_main_t * vam)
6538 unformat_input_t *i = vam->input;
6539 vl_api_sw_interface_add_del_address_t *mp;
6541 u8 sw_if_index_set = 0;
6542 u8 is_add = 1, del_all = 0;
6543 u32 address_length = 0;
6544 u8 v4_address_set = 0;
6545 u8 v6_address_set = 0;
6546 ip4_address_t v4address;
6547 ip6_address_t v6address;
6550 /* Parse args required to build the message */
6551 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6553 if (unformat (i, "del-all"))
6555 else if (unformat (i, "del"))
6558 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6559 sw_if_index_set = 1;
6560 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6561 sw_if_index_set = 1;
6562 else if (unformat (i, "%U/%d",
6563 unformat_ip4_address, &v4address, &address_length))
6565 else if (unformat (i, "%U/%d",
6566 unformat_ip6_address, &v6address, &address_length))
6572 if (sw_if_index_set == 0)
6574 errmsg ("missing interface name or sw_if_index");
6577 if (v4_address_set && v6_address_set)
6579 errmsg ("both v4 and v6 addresses set");
6582 if (!v4_address_set && !v6_address_set && !del_all)
6584 errmsg ("no addresses set");
6588 /* Construct the API message */
6589 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6591 mp->sw_if_index = ntohl (sw_if_index);
6592 mp->is_add = is_add;
6593 mp->del_all = del_all;
6597 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6601 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6603 mp->address_length = address_length;
6608 /* Wait for a reply, return good/bad news */
6614 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6616 unformat_input_t *i = vam->input;
6617 vl_api_sw_interface_set_mpls_enable_t *mp;
6619 u8 sw_if_index_set = 0;
6623 /* Parse args required to build the message */
6624 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6626 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6627 sw_if_index_set = 1;
6628 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6629 sw_if_index_set = 1;
6630 else if (unformat (i, "disable"))
6632 else if (unformat (i, "dis"))
6638 if (sw_if_index_set == 0)
6640 errmsg ("missing interface name or sw_if_index");
6644 /* Construct the API message */
6645 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6647 mp->sw_if_index = ntohl (sw_if_index);
6648 mp->enable = enable;
6653 /* Wait for a reply... */
6659 api_sw_interface_set_table (vat_main_t * vam)
6661 unformat_input_t *i = vam->input;
6662 vl_api_sw_interface_set_table_t *mp;
6663 u32 sw_if_index, vrf_id = 0;
6664 u8 sw_if_index_set = 0;
6668 /* Parse args required to build the message */
6669 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6671 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6672 sw_if_index_set = 1;
6673 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6674 sw_if_index_set = 1;
6675 else if (unformat (i, "vrf %d", &vrf_id))
6677 else if (unformat (i, "ipv6"))
6683 if (sw_if_index_set == 0)
6685 errmsg ("missing interface name or sw_if_index");
6689 /* Construct the API message */
6690 M (SW_INTERFACE_SET_TABLE, mp);
6692 mp->sw_if_index = ntohl (sw_if_index);
6693 mp->is_ipv6 = is_ipv6;
6694 mp->vrf_id = ntohl (vrf_id);
6699 /* Wait for a reply... */
6704 static void vl_api_sw_interface_get_table_reply_t_handler
6705 (vl_api_sw_interface_get_table_reply_t * mp)
6707 vat_main_t *vam = &vat_main;
6709 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6711 vam->retval = ntohl (mp->retval);
6712 vam->result_ready = 1;
6716 static void vl_api_sw_interface_get_table_reply_t_handler_json
6717 (vl_api_sw_interface_get_table_reply_t * mp)
6719 vat_main_t *vam = &vat_main;
6720 vat_json_node_t node;
6722 vat_json_init_object (&node);
6723 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6724 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6726 vat_json_print (vam->ofp, &node);
6727 vat_json_free (&node);
6729 vam->retval = ntohl (mp->retval);
6730 vam->result_ready = 1;
6734 api_sw_interface_get_table (vat_main_t * vam)
6736 unformat_input_t *i = vam->input;
6737 vl_api_sw_interface_get_table_t *mp;
6739 u8 sw_if_index_set = 0;
6743 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6745 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6746 sw_if_index_set = 1;
6747 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6748 sw_if_index_set = 1;
6749 else if (unformat (i, "ipv6"))
6755 if (sw_if_index_set == 0)
6757 errmsg ("missing interface name or sw_if_index");
6761 M (SW_INTERFACE_GET_TABLE, mp);
6762 mp->sw_if_index = htonl (sw_if_index);
6763 mp->is_ipv6 = is_ipv6;
6771 api_sw_interface_set_vpath (vat_main_t * vam)
6773 unformat_input_t *i = vam->input;
6774 vl_api_sw_interface_set_vpath_t *mp;
6775 u32 sw_if_index = 0;
6776 u8 sw_if_index_set = 0;
6780 /* Parse args required to build the message */
6781 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6783 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6784 sw_if_index_set = 1;
6785 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6786 sw_if_index_set = 1;
6787 else if (unformat (i, "enable"))
6789 else if (unformat (i, "disable"))
6795 if (sw_if_index_set == 0)
6797 errmsg ("missing interface name or sw_if_index");
6801 /* Construct the API message */
6802 M (SW_INTERFACE_SET_VPATH, mp);
6804 mp->sw_if_index = ntohl (sw_if_index);
6805 mp->enable = is_enable;
6810 /* Wait for a reply... */
6816 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6818 unformat_input_t *i = vam->input;
6819 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6820 u32 sw_if_index = 0;
6821 u8 sw_if_index_set = 0;
6826 /* Parse args required to build the message */
6827 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6829 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6830 sw_if_index_set = 1;
6831 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6832 sw_if_index_set = 1;
6833 else if (unformat (i, "enable"))
6835 else if (unformat (i, "disable"))
6837 else if (unformat (i, "ip4"))
6839 else if (unformat (i, "ip6"))
6845 if (sw_if_index_set == 0)
6847 errmsg ("missing interface name or sw_if_index");
6851 /* Construct the API message */
6852 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6854 mp->sw_if_index = ntohl (sw_if_index);
6855 mp->enable = is_enable;
6856 mp->is_ipv6 = is_ipv6;
6861 /* Wait for a reply... */
6867 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6869 unformat_input_t *i = vam->input;
6870 vl_api_sw_interface_set_geneve_bypass_t *mp;
6871 u32 sw_if_index = 0;
6872 u8 sw_if_index_set = 0;
6877 /* Parse args required to build the message */
6878 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6880 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6881 sw_if_index_set = 1;
6882 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6883 sw_if_index_set = 1;
6884 else if (unformat (i, "enable"))
6886 else if (unformat (i, "disable"))
6888 else if (unformat (i, "ip4"))
6890 else if (unformat (i, "ip6"))
6896 if (sw_if_index_set == 0)
6898 errmsg ("missing interface name or sw_if_index");
6902 /* Construct the API message */
6903 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6905 mp->sw_if_index = ntohl (sw_if_index);
6906 mp->enable = is_enable;
6907 mp->is_ipv6 = is_ipv6;
6912 /* Wait for a reply... */
6918 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6920 unformat_input_t *i = vam->input;
6921 vl_api_sw_interface_set_l2_xconnect_t *mp;
6923 u8 rx_sw_if_index_set = 0;
6925 u8 tx_sw_if_index_set = 0;
6929 /* Parse args required to build the message */
6930 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6932 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6933 rx_sw_if_index_set = 1;
6934 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6935 tx_sw_if_index_set = 1;
6936 else if (unformat (i, "rx"))
6938 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6940 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6942 rx_sw_if_index_set = 1;
6947 else if (unformat (i, "tx"))
6949 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6951 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6953 tx_sw_if_index_set = 1;
6958 else if (unformat (i, "enable"))
6960 else if (unformat (i, "disable"))
6966 if (rx_sw_if_index_set == 0)
6968 errmsg ("missing rx interface name or rx_sw_if_index");
6972 if (enable && (tx_sw_if_index_set == 0))
6974 errmsg ("missing tx interface name or tx_sw_if_index");
6978 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6980 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6981 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6982 mp->enable = enable;
6990 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6992 unformat_input_t *i = vam->input;
6993 vl_api_sw_interface_set_l2_bridge_t *mp;
6995 u8 rx_sw_if_index_set = 0;
7003 /* Parse args required to build the message */
7004 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7006 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7007 rx_sw_if_index_set = 1;
7008 else if (unformat (i, "bd_id %d", &bd_id))
7012 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7013 rx_sw_if_index_set = 1;
7014 else if (unformat (i, "shg %d", &shg))
7016 else if (unformat (i, "bvi"))
7018 else if (unformat (i, "enable"))
7020 else if (unformat (i, "disable"))
7026 if (rx_sw_if_index_set == 0)
7028 errmsg ("missing rx interface name or sw_if_index");
7032 if (enable && (bd_id_set == 0))
7034 errmsg ("missing bridge domain");
7038 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7040 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7041 mp->bd_id = ntohl (bd_id);
7044 mp->enable = enable;
7052 api_bridge_domain_dump (vat_main_t * vam)
7054 unformat_input_t *i = vam->input;
7055 vl_api_bridge_domain_dump_t *mp;
7056 vl_api_control_ping_t *mp_ping;
7060 /* Parse args required to build the message */
7061 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7063 if (unformat (i, "bd_id %d", &bd_id))
7069 M (BRIDGE_DOMAIN_DUMP, mp);
7070 mp->bd_id = ntohl (bd_id);
7073 /* Use a control ping for synchronization */
7074 MPING (CONTROL_PING, mp_ping);
7082 api_bridge_domain_add_del (vat_main_t * vam)
7084 unformat_input_t *i = vam->input;
7085 vl_api_bridge_domain_add_del_t *mp;
7088 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7093 /* Parse args required to build the message */
7094 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7096 if (unformat (i, "bd_id %d", &bd_id))
7098 else if (unformat (i, "flood %d", &flood))
7100 else if (unformat (i, "uu-flood %d", &uu_flood))
7102 else if (unformat (i, "forward %d", &forward))
7104 else if (unformat (i, "learn %d", &learn))
7106 else if (unformat (i, "arp-term %d", &arp_term))
7108 else if (unformat (i, "mac-age %d", &mac_age))
7110 else if (unformat (i, "bd-tag %s", &bd_tag))
7112 else if (unformat (i, "del"))
7115 flood = uu_flood = forward = learn = 0;
7123 errmsg ("missing bridge domain");
7130 errmsg ("mac age must be less than 256 ");
7135 if ((bd_tag) && (vec_len (bd_tag) > 63))
7137 errmsg ("bd-tag cannot be longer than 63");
7142 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7144 mp->bd_id = ntohl (bd_id);
7146 mp->uu_flood = uu_flood;
7147 mp->forward = forward;
7149 mp->arp_term = arp_term;
7150 mp->is_add = is_add;
7151 mp->mac_age = (u8) mac_age;
7154 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7155 mp->bd_tag[vec_len (bd_tag)] = 0;
7166 api_l2fib_flush_bd (vat_main_t * vam)
7168 unformat_input_t *i = vam->input;
7169 vl_api_l2fib_flush_bd_t *mp;
7173 /* Parse args required to build the message */
7174 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7176 if (unformat (i, "bd_id %d", &bd_id));
7183 errmsg ("missing bridge domain");
7187 M (L2FIB_FLUSH_BD, mp);
7189 mp->bd_id = htonl (bd_id);
7197 api_l2fib_flush_int (vat_main_t * vam)
7199 unformat_input_t *i = vam->input;
7200 vl_api_l2fib_flush_int_t *mp;
7201 u32 sw_if_index = ~0;
7204 /* Parse args required to build the message */
7205 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7207 if (unformat (i, "sw_if_index %d", &sw_if_index));
7209 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7214 if (sw_if_index == ~0)
7216 errmsg ("missing interface name or sw_if_index");
7220 M (L2FIB_FLUSH_INT, mp);
7222 mp->sw_if_index = ntohl (sw_if_index);
7230 api_l2fib_add_del (vat_main_t * vam)
7232 unformat_input_t *i = vam->input;
7233 vl_api_l2fib_add_del_t *mp;
7239 u32 sw_if_index = ~0;
7240 u8 sw_if_index_set = 0;
7249 /* Parse args required to build the message */
7250 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7252 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7254 else if (unformat (i, "bd_id %d", &bd_id))
7256 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7257 sw_if_index_set = 1;
7258 else if (unformat (i, "sw_if"))
7260 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7263 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7264 sw_if_index_set = 1;
7269 else if (unformat (i, "static"))
7271 else if (unformat (i, "filter"))
7276 else if (unformat (i, "bvi"))
7281 else if (unformat (i, "del"))
7283 else if (unformat (i, "count %d", &count))
7291 errmsg ("missing mac address");
7297 errmsg ("missing bridge domain");
7301 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7303 errmsg ("missing interface name or sw_if_index");
7309 /* Turn on async mode */
7310 vam->async_mode = 1;
7311 vam->async_errors = 0;
7312 before = vat_time_now (vam);
7315 for (j = 0; j < count; j++)
7317 M (L2FIB_ADD_DEL, mp);
7319 clib_memcpy (mp->mac, mac, 6);
7320 mp->bd_id = ntohl (bd_id);
7321 mp->is_add = is_add;
7325 mp->sw_if_index = ntohl (sw_if_index);
7326 mp->static_mac = static_mac;
7327 mp->filter_mac = filter_mac;
7328 mp->bvi_mac = bvi_mac;
7330 increment_mac_address (mac);
7337 vl_api_control_ping_t *mp_ping;
7340 /* Shut off async mode */
7341 vam->async_mode = 0;
7343 MPING (CONTROL_PING, mp_ping);
7346 timeout = vat_time_now (vam) + 1.0;
7347 while (vat_time_now (vam) < timeout)
7348 if (vam->result_ready == 1)
7353 if (vam->retval == -99)
7356 if (vam->async_errors > 0)
7358 errmsg ("%d asynchronous errors", vam->async_errors);
7361 vam->async_errors = 0;
7362 after = vat_time_now (vam);
7364 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7365 count, after - before, count / (after - before));
7371 /* Wait for a reply... */
7375 /* Return the good/bad news */
7376 return (vam->retval);
7380 api_bridge_domain_set_mac_age (vat_main_t * vam)
7382 unformat_input_t *i = vam->input;
7383 vl_api_bridge_domain_set_mac_age_t *mp;
7388 /* Parse args required to build the message */
7389 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7391 if (unformat (i, "bd_id %d", &bd_id));
7392 else if (unformat (i, "mac-age %d", &mac_age));
7399 errmsg ("missing bridge domain");
7405 errmsg ("mac age must be less than 256 ");
7409 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7411 mp->bd_id = htonl (bd_id);
7412 mp->mac_age = (u8) mac_age;
7420 api_l2_flags (vat_main_t * vam)
7422 unformat_input_t *i = vam->input;
7423 vl_api_l2_flags_t *mp;
7426 u8 sw_if_index_set = 0;
7430 /* Parse args required to build the message */
7431 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7433 if (unformat (i, "sw_if_index %d", &sw_if_index))
7434 sw_if_index_set = 1;
7435 else if (unformat (i, "sw_if"))
7437 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7440 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7441 sw_if_index_set = 1;
7446 else if (unformat (i, "learn"))
7448 else if (unformat (i, "forward"))
7450 else if (unformat (i, "flood"))
7452 else if (unformat (i, "uu-flood"))
7453 flags |= L2_UU_FLOOD;
7454 else if (unformat (i, "arp-term"))
7455 flags |= L2_ARP_TERM;
7456 else if (unformat (i, "off"))
7458 else if (unformat (i, "disable"))
7464 if (sw_if_index_set == 0)
7466 errmsg ("missing interface name or sw_if_index");
7472 mp->sw_if_index = ntohl (sw_if_index);
7473 mp->feature_bitmap = ntohl (flags);
7474 mp->is_set = is_set;
7482 api_bridge_flags (vat_main_t * vam)
7484 unformat_input_t *i = vam->input;
7485 vl_api_bridge_flags_t *mp;
7492 /* Parse args required to build the message */
7493 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7495 if (unformat (i, "bd_id %d", &bd_id))
7497 else if (unformat (i, "learn"))
7499 else if (unformat (i, "forward"))
7501 else if (unformat (i, "flood"))
7503 else if (unformat (i, "uu-flood"))
7504 flags |= L2_UU_FLOOD;
7505 else if (unformat (i, "arp-term"))
7506 flags |= L2_ARP_TERM;
7507 else if (unformat (i, "off"))
7509 else if (unformat (i, "disable"))
7517 errmsg ("missing bridge domain");
7521 M (BRIDGE_FLAGS, mp);
7523 mp->bd_id = ntohl (bd_id);
7524 mp->feature_bitmap = ntohl (flags);
7525 mp->is_set = is_set;
7533 api_bd_ip_mac_add_del (vat_main_t * vam)
7535 unformat_input_t *i = vam->input;
7536 vl_api_bd_ip_mac_add_del_t *mp;
7543 ip4_address_t v4addr;
7544 ip6_address_t v6addr;
7549 /* Parse args required to build the message */
7550 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7552 if (unformat (i, "bd_id %d", &bd_id))
7556 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7560 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7565 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7569 else if (unformat (i, "del"))
7577 errmsg ("missing bridge domain");
7580 else if (ip_set == 0)
7582 errmsg ("missing IP address");
7585 else if (mac_set == 0)
7587 errmsg ("missing MAC address");
7591 M (BD_IP_MAC_ADD_DEL, mp);
7593 mp->bd_id = ntohl (bd_id);
7594 mp->is_ipv6 = is_ipv6;
7595 mp->is_add = is_add;
7597 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7599 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7600 clib_memcpy (mp->mac_address, macaddr, 6);
7607 api_tap_connect (vat_main_t * vam)
7609 unformat_input_t *i = vam->input;
7610 vl_api_tap_connect_t *mp;
7616 ip4_address_t ip4_address;
7618 int ip4_address_set = 0;
7619 ip6_address_t ip6_address;
7621 int ip6_address_set = 0;
7624 memset (mac_address, 0, sizeof (mac_address));
7626 /* Parse args required to build the message */
7627 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7629 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7633 else if (unformat (i, "random-mac"))
7635 else if (unformat (i, "tapname %s", &tap_name))
7637 else if (unformat (i, "tag %s", &tag))
7639 else if (unformat (i, "address %U/%d",
7640 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7641 ip4_address_set = 1;
7642 else if (unformat (i, "address %U/%d",
7643 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7644 ip6_address_set = 1;
7651 errmsg ("missing tap name");
7654 if (vec_len (tap_name) > 63)
7656 errmsg ("tap name too long");
7659 vec_add1 (tap_name, 0);
7661 if (vec_len (tag) > 63)
7663 errmsg ("tag too long");
7667 /* Construct the API message */
7668 M (TAP_CONNECT, mp);
7670 mp->use_random_mac = random_mac;
7671 clib_memcpy (mp->mac_address, mac_address, 6);
7672 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7674 clib_memcpy (mp->tag, tag, vec_len (tag));
7676 if (ip4_address_set)
7678 mp->ip4_address_set = 1;
7679 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7680 mp->ip4_mask_width = ip4_mask_width;
7682 if (ip6_address_set)
7684 mp->ip6_address_set = 1;
7685 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7686 mp->ip6_mask_width = ip6_mask_width;
7689 vec_free (tap_name);
7695 /* Wait for a reply... */
7701 api_tap_modify (vat_main_t * vam)
7703 unformat_input_t *i = vam->input;
7704 vl_api_tap_modify_t *mp;
7709 u32 sw_if_index = ~0;
7710 u8 sw_if_index_set = 0;
7713 memset (mac_address, 0, sizeof (mac_address));
7715 /* Parse args required to build the message */
7716 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7718 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7719 sw_if_index_set = 1;
7720 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7721 sw_if_index_set = 1;
7722 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7726 else if (unformat (i, "random-mac"))
7728 else if (unformat (i, "tapname %s", &tap_name))
7734 if (sw_if_index_set == 0)
7736 errmsg ("missing vpp interface name");
7741 errmsg ("missing tap name");
7744 if (vec_len (tap_name) > 63)
7746 errmsg ("tap name too long");
7748 vec_add1 (tap_name, 0);
7750 /* Construct the API message */
7753 mp->use_random_mac = random_mac;
7754 mp->sw_if_index = ntohl (sw_if_index);
7755 clib_memcpy (mp->mac_address, mac_address, 6);
7756 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7757 vec_free (tap_name);
7762 /* Wait for a reply... */
7768 api_tap_delete (vat_main_t * vam)
7770 unformat_input_t *i = vam->input;
7771 vl_api_tap_delete_t *mp;
7772 u32 sw_if_index = ~0;
7773 u8 sw_if_index_set = 0;
7776 /* Parse args required to build the message */
7777 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7779 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7780 sw_if_index_set = 1;
7781 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7782 sw_if_index_set = 1;
7787 if (sw_if_index_set == 0)
7789 errmsg ("missing vpp interface name");
7793 /* Construct the API message */
7796 mp->sw_if_index = ntohl (sw_if_index);
7801 /* Wait for a reply... */
7807 api_tap_create_v2 (vat_main_t * vam)
7809 unformat_input_t *i = vam->input;
7810 vl_api_tap_create_v2_t *mp;
7814 u8 *host_namespace = 0;
7815 u8 *host_bridge = 0;
7816 ip4_address_t host_ip4_addr;
7817 u32 host_ip4_prefix_len = 0;
7818 ip6_address_t host_ip6_addr;
7819 u32 host_ip6_prefix_len = 0;
7821 int rx_ring_sz = 0, tx_ring_sz = 0;
7823 memset (mac_address, 0, sizeof (mac_address));
7825 /* Parse args required to build the message */
7826 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7828 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7832 else if (unformat (i, "name %s", &tap_name))
7834 else if (unformat (i, "host-ns %s", &host_namespace))
7836 else if (unformat (i, "host-bridge %s", &host_bridge))
7838 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7839 &host_ip4_addr, &host_ip4_prefix_len))
7841 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7842 &host_ip6_addr, &host_ip6_prefix_len))
7844 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7846 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7854 errmsg ("missing tap name. ");
7857 if (vec_len (tap_name) > 63)
7859 errmsg ("tap name too long. ");
7862 if (vec_len (host_namespace) > 63)
7864 errmsg ("host name space too long. ");
7867 if (vec_len (host_bridge) > 63)
7869 errmsg ("host bridge name too long. ");
7872 if (host_ip4_prefix_len > 32)
7874 errmsg ("host ip4 prefix length not valid. ");
7877 if (host_ip6_prefix_len > 128)
7879 errmsg ("host ip6 prefix length not valid. ");
7882 if (!is_pow2 (rx_ring_sz))
7884 errmsg ("rx ring size must be power of 2. ");
7887 if (rx_ring_sz > 32768)
7889 errmsg ("rx ring size must be 32768 or lower. ");
7892 if (!is_pow2 (tx_ring_sz))
7894 errmsg ("tx ring size must be power of 2. ");
7897 if (tx_ring_sz > 32768)
7899 errmsg ("tx ring size must be 32768 or lower. ");
7903 vec_add1 (tap_name, 0);
7905 /* Construct the API message */
7906 M (TAP_CREATE_V2, mp);
7908 mp->use_random_mac = random_mac;
7909 clib_memcpy (mp->mac_address, mac_address, 6);
7910 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7911 mp->host_namespace_set = host_namespace != 0;
7912 mp->host_bridge_set = host_bridge != 0;
7913 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7914 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7915 mp->rx_ring_sz = rx_ring_sz;
7916 mp->tx_ring_sz = tx_ring_sz;
7918 clib_memcpy (mp->host_namespace, host_namespace,
7919 vec_len (host_namespace));
7921 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7922 if (host_ip4_prefix_len)
7923 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
7924 if (host_ip4_prefix_len)
7925 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
7928 vec_free (tap_name);
7933 /* Wait for a reply... */
7939 api_tap_delete_v2 (vat_main_t * vam)
7941 unformat_input_t *i = vam->input;
7942 vl_api_tap_delete_v2_t *mp;
7943 u32 sw_if_index = ~0;
7944 u8 sw_if_index_set = 0;
7947 /* Parse args required to build the message */
7948 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7950 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7951 sw_if_index_set = 1;
7952 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7953 sw_if_index_set = 1;
7958 if (sw_if_index_set == 0)
7960 errmsg ("missing vpp interface name. ");
7964 /* Construct the API message */
7965 M (TAP_DELETE_V2, mp);
7967 mp->sw_if_index = ntohl (sw_if_index);
7972 /* Wait for a reply... */
7978 api_ip_table_add_del (vat_main_t * vam)
7980 unformat_input_t *i = vam->input;
7981 vl_api_ip_table_add_del_t *mp;
7987 /* Parse args required to build the message */
7988 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7990 if (unformat (i, "ipv6"))
7992 else if (unformat (i, "del"))
7994 else if (unformat (i, "add"))
7996 else if (unformat (i, "table %d", &table_id))
8000 clib_warning ("parse error '%U'", format_unformat_error, i);
8007 errmsg ("missing table-ID");
8011 /* Construct the API message */
8012 M (IP_TABLE_ADD_DEL, mp);
8014 mp->table_id = ntohl (table_id);
8015 mp->is_ipv6 = is_ipv6;
8016 mp->is_add = is_add;
8021 /* Wait for a reply... */
8028 api_ip_add_del_route (vat_main_t * vam)
8030 unformat_input_t *i = vam->input;
8031 vl_api_ip_add_del_route_t *mp;
8032 u32 sw_if_index = ~0, vrf_id = 0;
8034 u8 is_local = 0, is_drop = 0;
8035 u8 is_unreach = 0, is_prohibit = 0;
8036 u8 create_vrf_if_needed = 0;
8038 u32 next_hop_weight = 1;
8039 u8 is_multipath = 0;
8041 u8 address_length_set = 0;
8042 u32 next_hop_table_id = 0;
8043 u32 resolve_attempts = 0;
8044 u32 dst_address_length = 0;
8045 u8 next_hop_set = 0;
8046 ip4_address_t v4_dst_address, v4_next_hop_address;
8047 ip6_address_t v6_dst_address, v6_next_hop_address;
8051 u32 random_add_del = 0;
8052 u32 *random_vector = 0;
8054 u32 random_seed = 0xdeaddabe;
8055 u32 classify_table_index = ~0;
8057 u8 resolve_host = 0, resolve_attached = 0;
8058 mpls_label_t *next_hop_out_label_stack = NULL;
8059 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8060 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8062 /* Parse args required to build the message */
8063 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8065 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8067 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8069 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8074 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8079 else if (unformat (i, "/%d", &dst_address_length))
8081 address_length_set = 1;
8084 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8085 &v4_next_hop_address))
8089 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8090 &v6_next_hop_address))
8094 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8096 else if (unformat (i, "weight %d", &next_hop_weight))
8098 else if (unformat (i, "drop"))
8102 else if (unformat (i, "null-send-unreach"))
8106 else if (unformat (i, "null-send-prohibit"))
8110 else if (unformat (i, "local"))
8114 else if (unformat (i, "classify %d", &classify_table_index))
8118 else if (unformat (i, "del"))
8120 else if (unformat (i, "add"))
8122 else if (unformat (i, "resolve-via-host"))
8124 else if (unformat (i, "resolve-via-attached"))
8125 resolve_attached = 1;
8126 else if (unformat (i, "multipath"))
8128 else if (unformat (i, "vrf %d", &vrf_id))
8130 else if (unformat (i, "create-vrf"))
8131 create_vrf_if_needed = 1;
8132 else if (unformat (i, "count %d", &count))
8134 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8136 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8138 else if (unformat (i, "out-label %d", &next_hop_out_label))
8139 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8140 else if (unformat (i, "via-label %d", &next_hop_via_label))
8142 else if (unformat (i, "random"))
8144 else if (unformat (i, "seed %d", &random_seed))
8148 clib_warning ("parse error '%U'", format_unformat_error, i);
8153 if (!next_hop_set && !is_drop && !is_local &&
8154 !is_classify && !is_unreach && !is_prohibit &&
8155 MPLS_LABEL_INVALID == next_hop_via_label)
8158 ("next hop / local / drop / unreach / prohibit / classify not set");
8162 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8164 errmsg ("next hop and next-hop via label set");
8167 if (address_set == 0)
8169 errmsg ("missing addresses");
8173 if (address_length_set == 0)
8175 errmsg ("missing address length");
8179 /* Generate a pile of unique, random routes */
8182 u32 this_random_address;
8183 random_hash = hash_create (count, sizeof (uword));
8185 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8186 for (j = 0; j <= count; j++)
8190 this_random_address = random_u32 (&random_seed);
8191 this_random_address =
8192 clib_host_to_net_u32 (this_random_address);
8194 while (hash_get (random_hash, this_random_address));
8195 vec_add1 (random_vector, this_random_address);
8196 hash_set (random_hash, this_random_address, 1);
8198 hash_free (random_hash);
8199 v4_dst_address.as_u32 = random_vector[0];
8204 /* Turn on async mode */
8205 vam->async_mode = 1;
8206 vam->async_errors = 0;
8207 before = vat_time_now (vam);
8210 for (j = 0; j < count; j++)
8212 /* Construct the API message */
8213 M2 (IP_ADD_DEL_ROUTE, mp,
8214 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8216 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8217 mp->table_id = ntohl (vrf_id);
8218 mp->create_vrf_if_needed = create_vrf_if_needed;
8220 mp->is_add = is_add;
8221 mp->is_drop = is_drop;
8222 mp->is_unreach = is_unreach;
8223 mp->is_prohibit = is_prohibit;
8224 mp->is_ipv6 = is_ipv6;
8225 mp->is_local = is_local;
8226 mp->is_classify = is_classify;
8227 mp->is_multipath = is_multipath;
8228 mp->is_resolve_host = resolve_host;
8229 mp->is_resolve_attached = resolve_attached;
8230 mp->next_hop_weight = next_hop_weight;
8231 mp->dst_address_length = dst_address_length;
8232 mp->next_hop_table_id = ntohl (next_hop_table_id);
8233 mp->classify_table_index = ntohl (classify_table_index);
8234 mp->next_hop_via_label = ntohl (next_hop_via_label);
8235 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8236 if (0 != mp->next_hop_n_out_labels)
8238 memcpy (mp->next_hop_out_label_stack,
8239 next_hop_out_label_stack,
8240 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8241 vec_free (next_hop_out_label_stack);
8246 clib_memcpy (mp->dst_address, &v6_dst_address,
8247 sizeof (v6_dst_address));
8249 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8250 sizeof (v6_next_hop_address));
8251 increment_v6_address (&v6_dst_address);
8255 clib_memcpy (mp->dst_address, &v4_dst_address,
8256 sizeof (v4_dst_address));
8258 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8259 sizeof (v4_next_hop_address));
8261 v4_dst_address.as_u32 = random_vector[j + 1];
8263 increment_v4_address (&v4_dst_address);
8267 /* If we receive SIGTERM, stop now... */
8272 /* When testing multiple add/del ops, use a control-ping to sync */
8275 vl_api_control_ping_t *mp_ping;
8279 /* Shut off async mode */
8280 vam->async_mode = 0;
8282 MPING (CONTROL_PING, mp_ping);
8285 timeout = vat_time_now (vam) + 1.0;
8286 while (vat_time_now (vam) < timeout)
8287 if (vam->result_ready == 1)
8292 if (vam->retval == -99)
8295 if (vam->async_errors > 0)
8297 errmsg ("%d asynchronous errors", vam->async_errors);
8300 vam->async_errors = 0;
8301 after = vat_time_now (vam);
8303 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8307 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8308 count, after - before, count / (after - before));
8314 /* Wait for a reply... */
8319 /* Return the good/bad news */
8320 return (vam->retval);
8324 api_ip_mroute_add_del (vat_main_t * vam)
8326 unformat_input_t *i = vam->input;
8327 vl_api_ip_mroute_add_del_t *mp;
8328 u32 sw_if_index = ~0, vrf_id = 0;
8331 u8 create_vrf_if_needed = 0;
8334 u32 grp_address_length = 0;
8335 ip4_address_t v4_grp_address, v4_src_address;
8336 ip6_address_t v6_grp_address, v6_src_address;
8337 mfib_itf_flags_t iflags = 0;
8338 mfib_entry_flags_t eflags = 0;
8341 /* Parse args required to build the message */
8342 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8344 if (unformat (i, "sw_if_index %d", &sw_if_index))
8346 else if (unformat (i, "%U %U",
8347 unformat_ip4_address, &v4_src_address,
8348 unformat_ip4_address, &v4_grp_address))
8350 grp_address_length = 64;
8354 else if (unformat (i, "%U %U",
8355 unformat_ip6_address, &v6_src_address,
8356 unformat_ip6_address, &v6_grp_address))
8358 grp_address_length = 256;
8362 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8364 memset (&v4_src_address, 0, sizeof (v4_src_address));
8365 grp_address_length = 32;
8369 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8371 memset (&v6_src_address, 0, sizeof (v6_src_address));
8372 grp_address_length = 128;
8376 else if (unformat (i, "/%d", &grp_address_length))
8378 else if (unformat (i, "local"))
8382 else if (unformat (i, "del"))
8384 else if (unformat (i, "add"))
8386 else if (unformat (i, "vrf %d", &vrf_id))
8388 else if (unformat (i, "create-vrf"))
8389 create_vrf_if_needed = 1;
8390 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8392 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8396 clib_warning ("parse error '%U'", format_unformat_error, i);
8401 if (address_set == 0)
8403 errmsg ("missing addresses\n");
8407 /* Construct the API message */
8408 M (IP_MROUTE_ADD_DEL, mp);
8410 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8411 mp->table_id = ntohl (vrf_id);
8412 mp->create_vrf_if_needed = create_vrf_if_needed;
8414 mp->is_add = is_add;
8415 mp->is_ipv6 = is_ipv6;
8416 mp->is_local = is_local;
8417 mp->itf_flags = ntohl (iflags);
8418 mp->entry_flags = ntohl (eflags);
8419 mp->grp_address_length = grp_address_length;
8420 mp->grp_address_length = ntohs (mp->grp_address_length);
8424 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8425 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8429 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8430 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8436 /* Wait for a reply... */
8442 api_mpls_table_add_del (vat_main_t * vam)
8444 unformat_input_t *i = vam->input;
8445 vl_api_mpls_table_add_del_t *mp;
8450 /* Parse args required to build the message */
8451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8453 if (unformat (i, "table %d", &table_id))
8455 else if (unformat (i, "del"))
8457 else if (unformat (i, "add"))
8461 clib_warning ("parse error '%U'", format_unformat_error, i);
8468 errmsg ("missing table-ID");
8472 /* Construct the API message */
8473 M (MPLS_TABLE_ADD_DEL, mp);
8475 mp->mt_table_id = ntohl (table_id);
8476 mp->mt_is_add = is_add;
8481 /* Wait for a reply... */
8488 api_mpls_route_add_del (vat_main_t * vam)
8490 unformat_input_t *i = vam->input;
8491 vl_api_mpls_route_add_del_t *mp;
8492 u32 sw_if_index = ~0, table_id = 0;
8493 u8 create_table_if_needed = 0;
8495 u32 next_hop_weight = 1;
8496 u8 is_multipath = 0;
8497 u32 next_hop_table_id = 0;
8498 u8 next_hop_set = 0;
8499 ip4_address_t v4_next_hop_address = {
8502 ip6_address_t v6_next_hop_address = { {0} };
8506 u32 classify_table_index = ~0;
8508 u8 resolve_host = 0, resolve_attached = 0;
8509 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8510 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8511 mpls_label_t *next_hop_out_label_stack = NULL;
8512 mpls_label_t local_label = MPLS_LABEL_INVALID;
8514 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8516 /* Parse args required to build the message */
8517 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8519 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8521 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8523 else if (unformat (i, "%d", &local_label))
8525 else if (unformat (i, "eos"))
8527 else if (unformat (i, "non-eos"))
8529 else if (unformat (i, "via %U", unformat_ip4_address,
8530 &v4_next_hop_address))
8533 next_hop_proto = DPO_PROTO_IP4;
8535 else if (unformat (i, "via %U", unformat_ip6_address,
8536 &v6_next_hop_address))
8539 next_hop_proto = DPO_PROTO_IP6;
8541 else if (unformat (i, "weight %d", &next_hop_weight))
8543 else if (unformat (i, "create-table"))
8544 create_table_if_needed = 1;
8545 else if (unformat (i, "classify %d", &classify_table_index))
8549 else if (unformat (i, "del"))
8551 else if (unformat (i, "add"))
8553 else if (unformat (i, "resolve-via-host"))
8555 else if (unformat (i, "resolve-via-attached"))
8556 resolve_attached = 1;
8557 else if (unformat (i, "multipath"))
8559 else if (unformat (i, "count %d", &count))
8561 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8564 next_hop_proto = DPO_PROTO_IP4;
8566 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8569 next_hop_proto = DPO_PROTO_IP6;
8571 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8573 else if (unformat (i, "via-label %d", &next_hop_via_label))
8575 else if (unformat (i, "out-label %d", &next_hop_out_label))
8576 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8579 clib_warning ("parse error '%U'", format_unformat_error, i);
8584 if (!next_hop_set && !is_classify)
8586 errmsg ("next hop / classify not set");
8590 if (MPLS_LABEL_INVALID == local_label)
8592 errmsg ("missing label");
8598 /* Turn on async mode */
8599 vam->async_mode = 1;
8600 vam->async_errors = 0;
8601 before = vat_time_now (vam);
8604 for (j = 0; j < count; j++)
8606 /* Construct the API message */
8607 M2 (MPLS_ROUTE_ADD_DEL, mp,
8608 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8610 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8611 mp->mr_table_id = ntohl (table_id);
8612 mp->mr_create_table_if_needed = create_table_if_needed;
8614 mp->mr_is_add = is_add;
8615 mp->mr_next_hop_proto = next_hop_proto;
8616 mp->mr_is_classify = is_classify;
8617 mp->mr_is_multipath = is_multipath;
8618 mp->mr_is_resolve_host = resolve_host;
8619 mp->mr_is_resolve_attached = resolve_attached;
8620 mp->mr_next_hop_weight = next_hop_weight;
8621 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8622 mp->mr_classify_table_index = ntohl (classify_table_index);
8623 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8624 mp->mr_label = ntohl (local_label);
8625 mp->mr_eos = is_eos;
8627 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8628 if (0 != mp->mr_next_hop_n_out_labels)
8630 memcpy (mp->mr_next_hop_out_label_stack,
8631 next_hop_out_label_stack,
8632 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8633 vec_free (next_hop_out_label_stack);
8638 if (DPO_PROTO_IP4 == next_hop_proto)
8640 clib_memcpy (mp->mr_next_hop,
8641 &v4_next_hop_address,
8642 sizeof (v4_next_hop_address));
8644 else if (DPO_PROTO_IP6 == next_hop_proto)
8647 clib_memcpy (mp->mr_next_hop,
8648 &v6_next_hop_address,
8649 sizeof (v6_next_hop_address));
8656 /* If we receive SIGTERM, stop now... */
8661 /* When testing multiple add/del ops, use a control-ping to sync */
8664 vl_api_control_ping_t *mp_ping;
8668 /* Shut off async mode */
8669 vam->async_mode = 0;
8671 MPING (CONTROL_PING, mp_ping);
8674 timeout = vat_time_now (vam) + 1.0;
8675 while (vat_time_now (vam) < timeout)
8676 if (vam->result_ready == 1)
8681 if (vam->retval == -99)
8684 if (vam->async_errors > 0)
8686 errmsg ("%d asynchronous errors", vam->async_errors);
8689 vam->async_errors = 0;
8690 after = vat_time_now (vam);
8692 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8696 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8697 count, after - before, count / (after - before));
8703 /* Wait for a reply... */
8708 /* Return the good/bad news */
8709 return (vam->retval);
8713 api_mpls_ip_bind_unbind (vat_main_t * vam)
8715 unformat_input_t *i = vam->input;
8716 vl_api_mpls_ip_bind_unbind_t *mp;
8717 u32 ip_table_id = 0;
8718 u8 create_table_if_needed = 0;
8721 ip4_address_t v4_address;
8722 ip6_address_t v6_address;
8725 mpls_label_t local_label = MPLS_LABEL_INVALID;
8728 /* Parse args required to build the message */
8729 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8731 if (unformat (i, "%U/%d", unformat_ip4_address,
8732 &v4_address, &address_length))
8737 else if (unformat (i, "%U/%d", unformat_ip6_address,
8738 &v6_address, &address_length))
8743 else if (unformat (i, "%d", &local_label))
8745 else if (unformat (i, "create-table"))
8746 create_table_if_needed = 1;
8747 else if (unformat (i, "table-id %d", &ip_table_id))
8749 else if (unformat (i, "unbind"))
8751 else if (unformat (i, "bind"))
8755 clib_warning ("parse error '%U'", format_unformat_error, i);
8762 errmsg ("IP addres not set");
8766 if (MPLS_LABEL_INVALID == local_label)
8768 errmsg ("missing label");
8772 /* Construct the API message */
8773 M (MPLS_IP_BIND_UNBIND, mp);
8775 mp->mb_create_table_if_needed = create_table_if_needed;
8776 mp->mb_is_bind = is_bind;
8777 mp->mb_is_ip4 = is_ip4;
8778 mp->mb_ip_table_id = ntohl (ip_table_id);
8779 mp->mb_mpls_table_id = 0;
8780 mp->mb_label = ntohl (local_label);
8781 mp->mb_address_length = address_length;
8784 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8786 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8791 /* Wait for a reply... */
8797 api_bier_table_add_del (vat_main_t * vam)
8799 unformat_input_t *i = vam->input;
8800 vl_api_bier_table_add_del_t *mp;
8802 u32 set = 0, sub_domain = 0, hdr_len = 3;
8803 mpls_label_t local_label = MPLS_LABEL_INVALID;
8806 /* Parse args required to build the message */
8807 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8809 if (unformat (i, "sub-domain %d", &sub_domain))
8811 else if (unformat (i, "set %d", &set))
8813 else if (unformat (i, "label %d", &local_label))
8815 else if (unformat (i, "hdr-len %d", &hdr_len))
8817 else if (unformat (i, "add"))
8819 else if (unformat (i, "del"))
8823 clib_warning ("parse error '%U'", format_unformat_error, i);
8828 if (MPLS_LABEL_INVALID == local_label)
8830 errmsg ("missing label\n");
8834 /* Construct the API message */
8835 M (BIER_TABLE_ADD_DEL, mp);
8837 mp->bt_is_add = is_add;
8838 mp->bt_label = ntohl (local_label);
8839 mp->bt_tbl_id.bt_set = set;
8840 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8841 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8846 /* Wait for a reply... */
8853 api_bier_route_add_del (vat_main_t * vam)
8855 unformat_input_t *i = vam->input;
8856 vl_api_bier_route_add_del_t *mp;
8858 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8859 ip4_address_t v4_next_hop_address;
8860 ip6_address_t v6_next_hop_address;
8861 u8 next_hop_set = 0;
8862 u8 next_hop_proto_is_ip4 = 1;
8863 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8866 /* Parse args required to build the message */
8867 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8869 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8871 next_hop_proto_is_ip4 = 1;
8874 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8876 next_hop_proto_is_ip4 = 0;
8879 if (unformat (i, "sub-domain %d", &sub_domain))
8881 else if (unformat (i, "set %d", &set))
8883 else if (unformat (i, "hdr-len %d", &hdr_len))
8885 else if (unformat (i, "bp %d", &bp))
8887 else if (unformat (i, "add"))
8889 else if (unformat (i, "del"))
8891 else if (unformat (i, "out-label %d", &next_hop_out_label))
8895 clib_warning ("parse error '%U'", format_unformat_error, i);
8900 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8902 errmsg ("next hop / label set\n");
8907 errmsg ("bit=position not set\n");
8911 /* Construct the API message */
8912 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path3_t));
8914 mp->br_is_add = is_add;
8915 mp->br_tbl_id.bt_set = set;
8916 mp->br_tbl_id.bt_sub_domain = sub_domain;
8917 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
8918 mp->br_bp = ntohs (bp);
8920 mp->br_paths[0].n_labels = 1;
8921 mp->br_paths[0].label_stack[0] = ntohl (next_hop_out_label);
8922 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
8924 if (next_hop_proto_is_ip4)
8926 clib_memcpy (mp->br_paths[0].next_hop,
8927 &v4_next_hop_address, sizeof (v4_next_hop_address));
8931 clib_memcpy (mp->br_paths[0].next_hop,
8932 &v6_next_hop_address, sizeof (v6_next_hop_address));
8938 /* Wait for a reply... */
8945 api_proxy_arp_add_del (vat_main_t * vam)
8947 unformat_input_t *i = vam->input;
8948 vl_api_proxy_arp_add_del_t *mp;
8951 ip4_address_t lo, hi;
8955 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8957 if (unformat (i, "vrf %d", &vrf_id))
8959 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
8960 unformat_ip4_address, &hi))
8962 else if (unformat (i, "del"))
8966 clib_warning ("parse error '%U'", format_unformat_error, i);
8973 errmsg ("address range not set");
8977 M (PROXY_ARP_ADD_DEL, mp);
8979 mp->vrf_id = ntohl (vrf_id);
8980 mp->is_add = is_add;
8981 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
8982 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
8990 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8992 unformat_input_t *i = vam->input;
8993 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8996 u8 sw_if_index_set = 0;
8999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9001 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9002 sw_if_index_set = 1;
9003 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9004 sw_if_index_set = 1;
9005 else if (unformat (i, "enable"))
9007 else if (unformat (i, "disable"))
9011 clib_warning ("parse error '%U'", format_unformat_error, i);
9016 if (sw_if_index_set == 0)
9018 errmsg ("missing interface name or sw_if_index");
9022 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9024 mp->sw_if_index = ntohl (sw_if_index);
9025 mp->enable_disable = enable;
9033 api_mpls_tunnel_add_del (vat_main_t * vam)
9035 unformat_input_t *i = vam->input;
9036 vl_api_mpls_tunnel_add_del_t *mp;
9040 u32 sw_if_index = ~0;
9041 u32 next_hop_sw_if_index = ~0;
9042 u32 next_hop_proto_is_ip4 = 1;
9044 u32 next_hop_table_id = 0;
9045 ip4_address_t v4_next_hop_address = {
9048 ip6_address_t v6_next_hop_address = { {0} };
9049 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
9052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9054 if (unformat (i, "add"))
9056 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9058 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9060 else if (unformat (i, "via %U",
9061 unformat_ip4_address, &v4_next_hop_address))
9063 next_hop_proto_is_ip4 = 1;
9065 else if (unformat (i, "via %U",
9066 unformat_ip6_address, &v6_next_hop_address))
9068 next_hop_proto_is_ip4 = 0;
9070 else if (unformat (i, "l2-only"))
9072 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9074 else if (unformat (i, "out-label %d", &next_hop_out_label))
9075 vec_add1 (labels, ntohl (next_hop_out_label));
9078 clib_warning ("parse error '%U'", format_unformat_error, i);
9083 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
9085 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9086 mp->mt_sw_if_index = ntohl (sw_if_index);
9087 mp->mt_is_add = is_add;
9088 mp->mt_l2_only = l2_only;
9089 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9090 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9092 mp->mt_next_hop_n_out_labels = vec_len (labels);
9094 if (0 != mp->mt_next_hop_n_out_labels)
9096 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
9097 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
9101 if (next_hop_proto_is_ip4)
9103 clib_memcpy (mp->mt_next_hop,
9104 &v4_next_hop_address, sizeof (v4_next_hop_address));
9108 clib_memcpy (mp->mt_next_hop,
9109 &v6_next_hop_address, sizeof (v6_next_hop_address));
9118 api_sw_interface_set_unnumbered (vat_main_t * vam)
9120 unformat_input_t *i = vam->input;
9121 vl_api_sw_interface_set_unnumbered_t *mp;
9123 u32 unnum_sw_index = ~0;
9125 u8 sw_if_index_set = 0;
9128 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9130 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9131 sw_if_index_set = 1;
9132 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9133 sw_if_index_set = 1;
9134 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9136 else if (unformat (i, "del"))
9140 clib_warning ("parse error '%U'", format_unformat_error, i);
9145 if (sw_if_index_set == 0)
9147 errmsg ("missing interface name or sw_if_index");
9151 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9153 mp->sw_if_index = ntohl (sw_if_index);
9154 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9155 mp->is_add = is_add;
9163 api_ip_neighbor_add_del (vat_main_t * vam)
9165 unformat_input_t *i = vam->input;
9166 vl_api_ip_neighbor_add_del_t *mp;
9168 u8 sw_if_index_set = 0;
9171 u8 is_no_fib_entry = 0;
9174 u8 v4_address_set = 0;
9175 u8 v6_address_set = 0;
9176 ip4_address_t v4address;
9177 ip6_address_t v6address;
9180 memset (mac_address, 0, sizeof (mac_address));
9182 /* Parse args required to build the message */
9183 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9185 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9189 else if (unformat (i, "del"))
9192 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9193 sw_if_index_set = 1;
9194 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9195 sw_if_index_set = 1;
9196 else if (unformat (i, "is_static"))
9198 else if (unformat (i, "no-fib-entry"))
9199 is_no_fib_entry = 1;
9200 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9202 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9206 clib_warning ("parse error '%U'", format_unformat_error, i);
9211 if (sw_if_index_set == 0)
9213 errmsg ("missing interface name or sw_if_index");
9216 if (v4_address_set && v6_address_set)
9218 errmsg ("both v4 and v6 addresses set");
9221 if (!v4_address_set && !v6_address_set)
9223 errmsg ("no address set");
9227 /* Construct the API message */
9228 M (IP_NEIGHBOR_ADD_DEL, mp);
9230 mp->sw_if_index = ntohl (sw_if_index);
9231 mp->is_add = is_add;
9232 mp->is_static = is_static;
9233 mp->is_no_adj_fib = is_no_fib_entry;
9235 clib_memcpy (mp->mac_address, mac_address, 6);
9239 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9243 /* mp->is_ipv6 = 0; via memset in M macro above */
9244 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9250 /* Wait for a reply, return good/bad news */
9256 api_create_vlan_subif (vat_main_t * vam)
9258 unformat_input_t *i = vam->input;
9259 vl_api_create_vlan_subif_t *mp;
9261 u8 sw_if_index_set = 0;
9266 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9268 if (unformat (i, "sw_if_index %d", &sw_if_index))
9269 sw_if_index_set = 1;
9271 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9272 sw_if_index_set = 1;
9273 else if (unformat (i, "vlan %d", &vlan_id))
9277 clib_warning ("parse error '%U'", format_unformat_error, i);
9282 if (sw_if_index_set == 0)
9284 errmsg ("missing interface name or sw_if_index");
9288 if (vlan_id_set == 0)
9290 errmsg ("missing vlan_id");
9293 M (CREATE_VLAN_SUBIF, mp);
9295 mp->sw_if_index = ntohl (sw_if_index);
9296 mp->vlan_id = ntohl (vlan_id);
9303 #define foreach_create_subif_bit \
9310 _(outer_vlan_id_any) \
9311 _(inner_vlan_id_any)
9314 api_create_subif (vat_main_t * vam)
9316 unformat_input_t *i = vam->input;
9317 vl_api_create_subif_t *mp;
9319 u8 sw_if_index_set = 0;
9326 u32 exact_match = 0;
9327 u32 default_sub = 0;
9328 u32 outer_vlan_id_any = 0;
9329 u32 inner_vlan_id_any = 0;
9331 u16 outer_vlan_id = 0;
9332 u16 inner_vlan_id = 0;
9335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9337 if (unformat (i, "sw_if_index %d", &sw_if_index))
9338 sw_if_index_set = 1;
9340 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9341 sw_if_index_set = 1;
9342 else if (unformat (i, "sub_id %d", &sub_id))
9344 else if (unformat (i, "outer_vlan_id %d", &tmp))
9345 outer_vlan_id = tmp;
9346 else if (unformat (i, "inner_vlan_id %d", &tmp))
9347 inner_vlan_id = tmp;
9349 #define _(a) else if (unformat (i, #a)) a = 1 ;
9350 foreach_create_subif_bit
9354 clib_warning ("parse error '%U'", format_unformat_error, i);
9359 if (sw_if_index_set == 0)
9361 errmsg ("missing interface name or sw_if_index");
9365 if (sub_id_set == 0)
9367 errmsg ("missing sub_id");
9370 M (CREATE_SUBIF, mp);
9372 mp->sw_if_index = ntohl (sw_if_index);
9373 mp->sub_id = ntohl (sub_id);
9375 #define _(a) mp->a = a;
9376 foreach_create_subif_bit;
9379 mp->outer_vlan_id = ntohs (outer_vlan_id);
9380 mp->inner_vlan_id = ntohs (inner_vlan_id);
9388 api_oam_add_del (vat_main_t * vam)
9390 unformat_input_t *i = vam->input;
9391 vl_api_oam_add_del_t *mp;
9394 ip4_address_t src, dst;
9399 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9401 if (unformat (i, "vrf %d", &vrf_id))
9403 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9405 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9407 else if (unformat (i, "del"))
9411 clib_warning ("parse error '%U'", format_unformat_error, i);
9418 errmsg ("missing src addr");
9424 errmsg ("missing dst addr");
9428 M (OAM_ADD_DEL, mp);
9430 mp->vrf_id = ntohl (vrf_id);
9431 mp->is_add = is_add;
9432 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9433 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9441 api_reset_fib (vat_main_t * vam)
9443 unformat_input_t *i = vam->input;
9444 vl_api_reset_fib_t *mp;
9450 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9452 if (unformat (i, "vrf %d", &vrf_id))
9454 else if (unformat (i, "ipv6"))
9458 clib_warning ("parse error '%U'", format_unformat_error, i);
9463 if (vrf_id_set == 0)
9465 errmsg ("missing vrf id");
9471 mp->vrf_id = ntohl (vrf_id);
9472 mp->is_ipv6 = is_ipv6;
9480 api_dhcp_proxy_config (vat_main_t * vam)
9482 unformat_input_t *i = vam->input;
9483 vl_api_dhcp_proxy_config_t *mp;
9485 u32 server_vrf_id = 0;
9487 u8 v4_address_set = 0;
9488 u8 v6_address_set = 0;
9489 ip4_address_t v4address;
9490 ip6_address_t v6address;
9491 u8 v4_src_address_set = 0;
9492 u8 v6_src_address_set = 0;
9493 ip4_address_t v4srcaddress;
9494 ip6_address_t v6srcaddress;
9497 /* Parse args required to build the message */
9498 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9500 if (unformat (i, "del"))
9502 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9504 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9506 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9508 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9510 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9511 v4_src_address_set = 1;
9512 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9513 v6_src_address_set = 1;
9518 if (v4_address_set && v6_address_set)
9520 errmsg ("both v4 and v6 server addresses set");
9523 if (!v4_address_set && !v6_address_set)
9525 errmsg ("no server addresses set");
9529 if (v4_src_address_set && v6_src_address_set)
9531 errmsg ("both v4 and v6 src addresses set");
9534 if (!v4_src_address_set && !v6_src_address_set)
9536 errmsg ("no src addresses set");
9540 if (!(v4_src_address_set && v4_address_set) &&
9541 !(v6_src_address_set && v6_address_set))
9543 errmsg ("no matching server and src addresses set");
9547 /* Construct the API message */
9548 M (DHCP_PROXY_CONFIG, mp);
9550 mp->is_add = is_add;
9551 mp->rx_vrf_id = ntohl (rx_vrf_id);
9552 mp->server_vrf_id = ntohl (server_vrf_id);
9556 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9557 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9561 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9562 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9568 /* Wait for a reply, return good/bad news */
9573 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9574 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9577 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9579 vat_main_t *vam = &vat_main;
9580 u32 i, count = mp->count;
9581 vl_api_dhcp_server_t *s;
9585 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9586 "VSS VPN-ID '%s', VSS FIB-ID %d, VSS OUI %d",
9587 ntohl (mp->rx_vrf_id),
9588 format_ip6_address, mp->dhcp_src_address,
9589 mp->vss_type, mp->vss_vpn_ascii_id,
9590 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9593 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9594 "VSS VPN-ID '%s', VSS FIB-ID %d, VSS OUI %d",
9595 ntohl (mp->rx_vrf_id),
9596 format_ip4_address, mp->dhcp_src_address,
9597 mp->vss_type, mp->vss_vpn_ascii_id,
9598 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9600 for (i = 0; i < count; i++)
9602 s = &mp->servers[i];
9606 " Server Table-ID %d, Server Address %U",
9607 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9610 " Server Table-ID %d, Server Address %U",
9611 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9615 static void vl_api_dhcp_proxy_details_t_handler_json
9616 (vl_api_dhcp_proxy_details_t * mp)
9618 vat_main_t *vam = &vat_main;
9619 vat_json_node_t *node = NULL;
9620 u32 i, count = mp->count;
9622 struct in6_addr ip6;
9623 vl_api_dhcp_server_t *s;
9625 if (VAT_JSON_ARRAY != vam->json_tree.type)
9627 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9628 vat_json_init_array (&vam->json_tree);
9630 node = vat_json_array_add (&vam->json_tree);
9632 vat_json_init_object (node);
9633 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9634 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9635 sizeof (mp->vss_type));
9636 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9637 mp->vss_vpn_ascii_id);
9638 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9639 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9643 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9644 vat_json_object_add_ip6 (node, "src_address", ip6);
9648 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9649 vat_json_object_add_ip4 (node, "src_address", ip4);
9652 for (i = 0; i < count; i++)
9654 s = &mp->servers[i];
9656 vat_json_object_add_uint (node, "server-table-id",
9657 ntohl (s->server_vrf_id));
9661 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9662 vat_json_object_add_ip4 (node, "src_address", ip4);
9666 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9667 vat_json_object_add_ip6 (node, "server_address", ip6);
9673 api_dhcp_proxy_dump (vat_main_t * vam)
9675 unformat_input_t *i = vam->input;
9676 vl_api_control_ping_t *mp_ping;
9677 vl_api_dhcp_proxy_dump_t *mp;
9681 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9683 if (unformat (i, "ipv6"))
9687 clib_warning ("parse error '%U'", format_unformat_error, i);
9692 M (DHCP_PROXY_DUMP, mp);
9694 mp->is_ip6 = is_ipv6;
9697 /* Use a control ping for synchronization */
9698 MPING (CONTROL_PING, mp_ping);
9706 api_dhcp_proxy_set_vss (vat_main_t * vam)
9708 unformat_input_t *i = vam->input;
9709 vl_api_dhcp_proxy_set_vss_t *mp;
9713 u8 vss_type = VSS_TYPE_DEFAULT;
9714 u8 *vpn_ascii_id = 0;
9719 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9721 if (unformat (i, "tbl_id %d", &tbl_id))
9723 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
9724 vss_type = VSS_TYPE_ASCII;
9725 else if (unformat (i, "fib_id %d", &fib_id))
9726 vss_type = VSS_TYPE_VPN_ID;
9727 else if (unformat (i, "oui %d", &oui))
9728 vss_type = VSS_TYPE_VPN_ID;
9729 else if (unformat (i, "ipv6"))
9731 else if (unformat (i, "del"))
9739 errmsg ("missing tbl_id ");
9740 vec_free (vpn_ascii_id);
9744 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
9746 errmsg ("vpn_ascii_id cannot be longer than 128 ");
9747 vec_free (vpn_ascii_id);
9751 M (DHCP_PROXY_SET_VSS, mp);
9752 mp->tbl_id = ntohl (tbl_id);
9753 mp->vss_type = vss_type;
9756 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
9757 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
9759 mp->vpn_index = ntohl (fib_id);
9760 mp->oui = ntohl (oui);
9761 mp->is_ipv6 = is_ipv6;
9762 mp->is_add = is_add;
9767 vec_free (vpn_ascii_id);
9772 api_dhcp_client_config (vat_main_t * vam)
9774 unformat_input_t *i = vam->input;
9775 vl_api_dhcp_client_config_t *mp;
9777 u8 sw_if_index_set = 0;
9780 u8 disable_event = 0;
9783 /* Parse args required to build the message */
9784 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9786 if (unformat (i, "del"))
9789 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9790 sw_if_index_set = 1;
9791 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9792 sw_if_index_set = 1;
9793 else if (unformat (i, "hostname %s", &hostname))
9795 else if (unformat (i, "disable_event"))
9801 if (sw_if_index_set == 0)
9803 errmsg ("missing interface name or sw_if_index");
9807 if (vec_len (hostname) > 63)
9809 errmsg ("hostname too long");
9811 vec_add1 (hostname, 0);
9813 /* Construct the API message */
9814 M (DHCP_CLIENT_CONFIG, mp);
9816 mp->sw_if_index = htonl (sw_if_index);
9817 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
9818 vec_free (hostname);
9819 mp->is_add = is_add;
9820 mp->want_dhcp_event = disable_event ? 0 : 1;
9821 mp->pid = htonl (getpid ());
9826 /* Wait for a reply, return good/bad news */
9832 api_set_ip_flow_hash (vat_main_t * vam)
9834 unformat_input_t *i = vam->input;
9835 vl_api_set_ip_flow_hash_t *mp;
9847 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9849 if (unformat (i, "vrf %d", &vrf_id))
9851 else if (unformat (i, "ipv6"))
9853 else if (unformat (i, "src"))
9855 else if (unformat (i, "dst"))
9857 else if (unformat (i, "sport"))
9859 else if (unformat (i, "dport"))
9861 else if (unformat (i, "proto"))
9863 else if (unformat (i, "reverse"))
9868 clib_warning ("parse error '%U'", format_unformat_error, i);
9873 if (vrf_id_set == 0)
9875 errmsg ("missing vrf id");
9879 M (SET_IP_FLOW_HASH, mp);
9885 mp->reverse = reverse;
9886 mp->vrf_id = ntohl (vrf_id);
9887 mp->is_ipv6 = is_ipv6;
9895 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9897 unformat_input_t *i = vam->input;
9898 vl_api_sw_interface_ip6_enable_disable_t *mp;
9900 u8 sw_if_index_set = 0;
9904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9906 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9907 sw_if_index_set = 1;
9908 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9909 sw_if_index_set = 1;
9910 else if (unformat (i, "enable"))
9912 else if (unformat (i, "disable"))
9916 clib_warning ("parse error '%U'", format_unformat_error, i);
9921 if (sw_if_index_set == 0)
9923 errmsg ("missing interface name or sw_if_index");
9927 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9929 mp->sw_if_index = ntohl (sw_if_index);
9930 mp->enable = enable;
9938 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
9940 unformat_input_t *i = vam->input;
9941 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
9943 u8 sw_if_index_set = 0;
9944 u8 v6_address_set = 0;
9945 ip6_address_t v6address;
9948 /* Parse args required to build the message */
9949 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9951 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9952 sw_if_index_set = 1;
9953 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9954 sw_if_index_set = 1;
9955 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9961 if (sw_if_index_set == 0)
9963 errmsg ("missing interface name or sw_if_index");
9966 if (!v6_address_set)
9968 errmsg ("no address set");
9972 /* Construct the API message */
9973 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
9975 mp->sw_if_index = ntohl (sw_if_index);
9976 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9981 /* Wait for a reply, return good/bad news */
9987 api_ip6nd_proxy_add_del (vat_main_t * vam)
9989 unformat_input_t *i = vam->input;
9990 vl_api_ip6nd_proxy_add_del_t *mp;
9991 u32 sw_if_index = ~0;
9992 u8 v6_address_set = 0;
9993 ip6_address_t v6address;
9997 /* Parse args required to build the message */
9998 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10000 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10002 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10004 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10005 v6_address_set = 1;
10006 if (unformat (i, "del"))
10010 clib_warning ("parse error '%U'", format_unformat_error, i);
10015 if (sw_if_index == ~0)
10017 errmsg ("missing interface name or sw_if_index");
10020 if (!v6_address_set)
10022 errmsg ("no address set");
10026 /* Construct the API message */
10027 M (IP6ND_PROXY_ADD_DEL, mp);
10029 mp->is_del = is_del;
10030 mp->sw_if_index = ntohl (sw_if_index);
10031 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10036 /* Wait for a reply, return good/bad news */
10042 api_ip6nd_proxy_dump (vat_main_t * vam)
10044 vl_api_ip6nd_proxy_dump_t *mp;
10045 vl_api_control_ping_t *mp_ping;
10048 M (IP6ND_PROXY_DUMP, mp);
10052 /* Use a control ping for synchronization */
10053 MPING (CONTROL_PING, mp_ping);
10060 static void vl_api_ip6nd_proxy_details_t_handler
10061 (vl_api_ip6nd_proxy_details_t * mp)
10063 vat_main_t *vam = &vat_main;
10065 print (vam->ofp, "host %U sw_if_index %d",
10066 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10069 static void vl_api_ip6nd_proxy_details_t_handler_json
10070 (vl_api_ip6nd_proxy_details_t * mp)
10072 vat_main_t *vam = &vat_main;
10073 struct in6_addr ip6;
10074 vat_json_node_t *node = NULL;
10076 if (VAT_JSON_ARRAY != vam->json_tree.type)
10078 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10079 vat_json_init_array (&vam->json_tree);
10081 node = vat_json_array_add (&vam->json_tree);
10083 vat_json_init_object (node);
10084 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10086 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10087 vat_json_object_add_ip6 (node, "host", ip6);
10091 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10093 unformat_input_t *i = vam->input;
10094 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10096 u8 sw_if_index_set = 0;
10097 u32 address_length = 0;
10098 u8 v6_address_set = 0;
10099 ip6_address_t v6address;
10100 u8 use_default = 0;
10101 u8 no_advertise = 0;
10103 u8 no_autoconfig = 0;
10106 u32 val_lifetime = 0;
10107 u32 pref_lifetime = 0;
10110 /* Parse args required to build the message */
10111 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10113 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10114 sw_if_index_set = 1;
10115 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10116 sw_if_index_set = 1;
10117 else if (unformat (i, "%U/%d",
10118 unformat_ip6_address, &v6address, &address_length))
10119 v6_address_set = 1;
10120 else if (unformat (i, "val_life %d", &val_lifetime))
10122 else if (unformat (i, "pref_life %d", &pref_lifetime))
10124 else if (unformat (i, "def"))
10126 else if (unformat (i, "noadv"))
10128 else if (unformat (i, "offl"))
10130 else if (unformat (i, "noauto"))
10132 else if (unformat (i, "nolink"))
10134 else if (unformat (i, "isno"))
10138 clib_warning ("parse error '%U'", format_unformat_error, i);
10143 if (sw_if_index_set == 0)
10145 errmsg ("missing interface name or sw_if_index");
10148 if (!v6_address_set)
10150 errmsg ("no address set");
10154 /* Construct the API message */
10155 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10157 mp->sw_if_index = ntohl (sw_if_index);
10158 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10159 mp->address_length = address_length;
10160 mp->use_default = use_default;
10161 mp->no_advertise = no_advertise;
10162 mp->off_link = off_link;
10163 mp->no_autoconfig = no_autoconfig;
10164 mp->no_onlink = no_onlink;
10166 mp->val_lifetime = ntohl (val_lifetime);
10167 mp->pref_lifetime = ntohl (pref_lifetime);
10172 /* Wait for a reply, return good/bad news */
10178 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10180 unformat_input_t *i = vam->input;
10181 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10183 u8 sw_if_index_set = 0;
10188 u8 send_unicast = 0;
10191 u8 default_router = 0;
10192 u32 max_interval = 0;
10193 u32 min_interval = 0;
10195 u32 initial_count = 0;
10196 u32 initial_interval = 0;
10200 /* Parse args required to build the message */
10201 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10203 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10204 sw_if_index_set = 1;
10205 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10206 sw_if_index_set = 1;
10207 else if (unformat (i, "maxint %d", &max_interval))
10209 else if (unformat (i, "minint %d", &min_interval))
10211 else if (unformat (i, "life %d", &lifetime))
10213 else if (unformat (i, "count %d", &initial_count))
10215 else if (unformat (i, "interval %d", &initial_interval))
10217 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10219 else if (unformat (i, "managed"))
10221 else if (unformat (i, "other"))
10223 else if (unformat (i, "ll"))
10225 else if (unformat (i, "send"))
10227 else if (unformat (i, "cease"))
10229 else if (unformat (i, "isno"))
10231 else if (unformat (i, "def"))
10232 default_router = 1;
10235 clib_warning ("parse error '%U'", format_unformat_error, i);
10240 if (sw_if_index_set == 0)
10242 errmsg ("missing interface name or sw_if_index");
10246 /* Construct the API message */
10247 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10249 mp->sw_if_index = ntohl (sw_if_index);
10250 mp->max_interval = ntohl (max_interval);
10251 mp->min_interval = ntohl (min_interval);
10252 mp->lifetime = ntohl (lifetime);
10253 mp->initial_count = ntohl (initial_count);
10254 mp->initial_interval = ntohl (initial_interval);
10255 mp->suppress = suppress;
10256 mp->managed = managed;
10258 mp->ll_option = ll_option;
10259 mp->send_unicast = send_unicast;
10262 mp->default_router = default_router;
10267 /* Wait for a reply, return good/bad news */
10273 api_set_arp_neighbor_limit (vat_main_t * vam)
10275 unformat_input_t *i = vam->input;
10276 vl_api_set_arp_neighbor_limit_t *mp;
10282 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10284 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10286 else if (unformat (i, "ipv6"))
10290 clib_warning ("parse error '%U'", format_unformat_error, i);
10295 if (limit_set == 0)
10297 errmsg ("missing limit value");
10301 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10303 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10304 mp->is_ipv6 = is_ipv6;
10312 api_l2_patch_add_del (vat_main_t * vam)
10314 unformat_input_t *i = vam->input;
10315 vl_api_l2_patch_add_del_t *mp;
10316 u32 rx_sw_if_index;
10317 u8 rx_sw_if_index_set = 0;
10318 u32 tx_sw_if_index;
10319 u8 tx_sw_if_index_set = 0;
10323 /* Parse args required to build the message */
10324 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10326 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10327 rx_sw_if_index_set = 1;
10328 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10329 tx_sw_if_index_set = 1;
10330 else if (unformat (i, "rx"))
10332 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10334 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10336 rx_sw_if_index_set = 1;
10341 else if (unformat (i, "tx"))
10343 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10345 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10347 tx_sw_if_index_set = 1;
10352 else if (unformat (i, "del"))
10358 if (rx_sw_if_index_set == 0)
10360 errmsg ("missing rx interface name or rx_sw_if_index");
10364 if (tx_sw_if_index_set == 0)
10366 errmsg ("missing tx interface name or tx_sw_if_index");
10370 M (L2_PATCH_ADD_DEL, mp);
10372 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10373 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10374 mp->is_add = is_add;
10382 u8 localsid_addr[16];
10391 api_sr_localsid_add_del (vat_main_t * vam)
10393 unformat_input_t *i = vam->input;
10394 vl_api_sr_localsid_add_del_t *mp;
10397 ip6_address_t localsid;
10401 u32 fib_table = ~(u32) 0;
10402 ip6_address_t next_hop;
10404 bool nexthop_set = 0;
10408 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10410 if (unformat (i, "del"))
10412 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10413 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
10415 else if (unformat (i, "behavior %u", &behavior));
10416 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10417 else if (unformat (i, "fib-table %u", &fib_table));
10418 else if (unformat (i, "end.psp %u", &behavior));
10423 M (SR_LOCALSID_ADD_DEL, mp);
10425 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
10427 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
10428 mp->behavior = behavior;
10429 mp->sw_if_index = ntohl (sw_if_index);
10430 mp->fib_table = ntohl (fib_table);
10431 mp->end_psp = end_psp;
10432 mp->is_del = is_del;
10440 api_ioam_enable (vat_main_t * vam)
10442 unformat_input_t *input = vam->input;
10443 vl_api_ioam_enable_t *mp;
10445 int has_trace_option = 0;
10446 int has_pot_option = 0;
10447 int has_seqno_option = 0;
10448 int has_analyse_option = 0;
10451 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10453 if (unformat (input, "trace"))
10454 has_trace_option = 1;
10455 else if (unformat (input, "pot"))
10456 has_pot_option = 1;
10457 else if (unformat (input, "seqno"))
10458 has_seqno_option = 1;
10459 else if (unformat (input, "analyse"))
10460 has_analyse_option = 1;
10464 M (IOAM_ENABLE, mp);
10465 mp->id = htons (id);
10466 mp->seqno = has_seqno_option;
10467 mp->analyse = has_analyse_option;
10468 mp->pot_enable = has_pot_option;
10469 mp->trace_enable = has_trace_option;
10478 api_ioam_disable (vat_main_t * vam)
10480 vl_api_ioam_disable_t *mp;
10483 M (IOAM_DISABLE, mp);
10489 #define foreach_tcp_proto_field \
10493 #define foreach_udp_proto_field \
10497 #define foreach_ip4_proto_field \
10509 u16 src_port, dst_port;
10512 #if VPP_API_TEST_BUILTIN == 0
10514 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10516 u8 **maskp = va_arg (*args, u8 **);
10518 u8 found_something = 0;
10521 #define _(a) u8 a=0;
10522 foreach_tcp_proto_field;
10525 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10528 #define _(a) else if (unformat (input, #a)) a=1;
10529 foreach_tcp_proto_field
10535 #define _(a) found_something += a;
10536 foreach_tcp_proto_field;
10539 if (found_something == 0)
10542 vec_validate (mask, sizeof (*tcp) - 1);
10544 tcp = (tcp_header_t *) mask;
10546 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
10547 foreach_tcp_proto_field;
10555 unformat_udp_mask (unformat_input_t * input, va_list * args)
10557 u8 **maskp = va_arg (*args, u8 **);
10559 u8 found_something = 0;
10562 #define _(a) u8 a=0;
10563 foreach_udp_proto_field;
10566 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10569 #define _(a) else if (unformat (input, #a)) a=1;
10570 foreach_udp_proto_field
10576 #define _(a) found_something += a;
10577 foreach_udp_proto_field;
10580 if (found_something == 0)
10583 vec_validate (mask, sizeof (*udp) - 1);
10585 udp = (udp_header_t *) mask;
10587 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
10588 foreach_udp_proto_field;
10596 unformat_l4_mask (unformat_input_t * input, va_list * args)
10598 u8 **maskp = va_arg (*args, u8 **);
10599 u16 src_port = 0, dst_port = 0;
10600 tcpudp_header_t *tcpudp;
10602 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10604 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10606 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10608 else if (unformat (input, "src_port"))
10610 else if (unformat (input, "dst_port"))
10616 if (!src_port && !dst_port)
10620 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10622 tcpudp = (tcpudp_header_t *) mask;
10623 tcpudp->src_port = src_port;
10624 tcpudp->dst_port = dst_port;
10632 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10634 u8 **maskp = va_arg (*args, u8 **);
10636 u8 found_something = 0;
10639 #define _(a) u8 a=0;
10640 foreach_ip4_proto_field;
10646 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10648 if (unformat (input, "version"))
10650 else if (unformat (input, "hdr_length"))
10652 else if (unformat (input, "src"))
10654 else if (unformat (input, "dst"))
10656 else if (unformat (input, "proto"))
10659 #define _(a) else if (unformat (input, #a)) a=1;
10660 foreach_ip4_proto_field
10666 #define _(a) found_something += a;
10667 foreach_ip4_proto_field;
10670 if (found_something == 0)
10673 vec_validate (mask, sizeof (*ip) - 1);
10675 ip = (ip4_header_t *) mask;
10677 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10678 foreach_ip4_proto_field;
10681 ip->ip_version_and_header_length = 0;
10684 ip->ip_version_and_header_length |= 0xF0;
10687 ip->ip_version_and_header_length |= 0x0F;
10693 #define foreach_ip6_proto_field \
10696 _(payload_length) \
10701 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10703 u8 **maskp = va_arg (*args, u8 **);
10705 u8 found_something = 0;
10707 u32 ip_version_traffic_class_and_flow_label;
10709 #define _(a) u8 a=0;
10710 foreach_ip6_proto_field;
10713 u8 traffic_class = 0;
10716 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10718 if (unformat (input, "version"))
10720 else if (unformat (input, "traffic-class"))
10722 else if (unformat (input, "flow-label"))
10724 else if (unformat (input, "src"))
10726 else if (unformat (input, "dst"))
10728 else if (unformat (input, "proto"))
10731 #define _(a) else if (unformat (input, #a)) a=1;
10732 foreach_ip6_proto_field
10738 #define _(a) found_something += a;
10739 foreach_ip6_proto_field;
10742 if (found_something == 0)
10745 vec_validate (mask, sizeof (*ip) - 1);
10747 ip = (ip6_header_t *) mask;
10749 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10750 foreach_ip6_proto_field;
10753 ip_version_traffic_class_and_flow_label = 0;
10756 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10759 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10762 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10764 ip->ip_version_traffic_class_and_flow_label =
10765 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10772 unformat_l3_mask (unformat_input_t * input, va_list * args)
10774 u8 **maskp = va_arg (*args, u8 **);
10776 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10778 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10780 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10789 unformat_l2_mask (unformat_input_t * input, va_list * args)
10791 u8 **maskp = va_arg (*args, u8 **);
10798 u8 ignore_tag1 = 0;
10799 u8 ignore_tag2 = 0;
10806 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10808 if (unformat (input, "src"))
10810 else if (unformat (input, "dst"))
10812 else if (unformat (input, "proto"))
10814 else if (unformat (input, "tag1"))
10816 else if (unformat (input, "tag2"))
10818 else if (unformat (input, "ignore-tag1"))
10820 else if (unformat (input, "ignore-tag2"))
10822 else if (unformat (input, "cos1"))
10824 else if (unformat (input, "cos2"))
10826 else if (unformat (input, "dot1q"))
10828 else if (unformat (input, "dot1ad"))
10833 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10834 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10837 if (tag1 || ignore_tag1 || cos1 || dot1q)
10839 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10842 vec_validate (mask, len - 1);
10845 memset (mask, 0xff, 6);
10848 memset (mask + 6, 0xff, 6);
10850 if (tag2 || dot1ad)
10852 /* inner vlan tag */
10861 mask[21] = mask[20] = 0xff;
10882 mask[16] = mask[17] = 0xff;
10892 mask[12] = mask[13] = 0xff;
10899 unformat_classify_mask (unformat_input_t * input, va_list * args)
10901 u8 **maskp = va_arg (*args, u8 **);
10902 u32 *skipp = va_arg (*args, u32 *);
10903 u32 *matchp = va_arg (*args, u32 *);
10911 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10913 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10915 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10917 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10919 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10933 if (mask || l2 || l3 || l4)
10935 if (l2 || l3 || l4)
10937 /* "With a free Ethernet header in every package" */
10939 vec_validate (l2, 13);
10943 vec_append (mask, l3);
10948 vec_append (mask, l4);
10953 /* Scan forward looking for the first significant mask octet */
10954 for (i = 0; i < vec_len (mask); i++)
10958 /* compute (skip, match) params */
10959 *skipp = i / sizeof (u32x4);
10960 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10962 /* Pad mask to an even multiple of the vector size */
10963 while (vec_len (mask) % sizeof (u32x4))
10964 vec_add1 (mask, 0);
10966 match = vec_len (mask) / sizeof (u32x4);
10968 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10970 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10971 if (*tmp || *(tmp + 1))
10976 clib_warning ("BUG: match 0");
10978 _vec_len (mask) = match * sizeof (u32x4);
10988 #endif /* VPP_API_TEST_BUILTIN */
10990 #define foreach_l2_next \
10992 _(ethernet, ETHERNET_INPUT) \
10993 _(ip4, IP4_INPUT) \
10997 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10999 u32 *miss_next_indexp = va_arg (*args, u32 *);
11000 u32 next_index = 0;
11004 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11008 if (unformat (input, "%d", &tmp))
11017 *miss_next_indexp = next_index;
11021 #define foreach_ip_next \
11024 _(rewrite, REWRITE)
11027 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11029 u32 *miss_next_indexp = va_arg (*args, u32 *);
11030 u32 next_index = 0;
11034 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11038 if (unformat (input, "%d", &tmp))
11047 *miss_next_indexp = next_index;
11051 #define foreach_acl_next \
11055 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11057 u32 *miss_next_indexp = va_arg (*args, u32 *);
11058 u32 next_index = 0;
11062 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11066 if (unformat (input, "permit"))
11071 else if (unformat (input, "%d", &tmp))
11080 *miss_next_indexp = next_index;
11085 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11087 u32 *r = va_arg (*args, u32 *);
11089 if (unformat (input, "conform-color"))
11090 *r = POLICE_CONFORM;
11091 else if (unformat (input, "exceed-color"))
11092 *r = POLICE_EXCEED;
11100 api_classify_add_del_table (vat_main_t * vam)
11102 unformat_input_t *i = vam->input;
11103 vl_api_classify_add_del_table_t *mp;
11110 u32 table_index = ~0;
11111 u32 next_table_index = ~0;
11112 u32 miss_next_index = ~0;
11113 u32 memory_size = 32 << 20;
11115 u32 current_data_flag = 0;
11116 int current_data_offset = 0;
11119 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11121 if (unformat (i, "del"))
11123 else if (unformat (i, "del-chain"))
11128 else if (unformat (i, "buckets %d", &nbuckets))
11130 else if (unformat (i, "memory_size %d", &memory_size))
11132 else if (unformat (i, "skip %d", &skip))
11134 else if (unformat (i, "match %d", &match))
11136 else if (unformat (i, "table %d", &table_index))
11138 else if (unformat (i, "mask %U", unformat_classify_mask,
11139 &mask, &skip, &match))
11141 else if (unformat (i, "next-table %d", &next_table_index))
11143 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11146 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11149 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11152 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11154 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11160 if (is_add && mask == 0)
11162 errmsg ("Mask required");
11166 if (is_add && skip == ~0)
11168 errmsg ("skip count required");
11172 if (is_add && match == ~0)
11174 errmsg ("match count required");
11178 if (!is_add && table_index == ~0)
11180 errmsg ("table index required for delete");
11184 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11186 mp->is_add = is_add;
11187 mp->del_chain = del_chain;
11188 mp->table_index = ntohl (table_index);
11189 mp->nbuckets = ntohl (nbuckets);
11190 mp->memory_size = ntohl (memory_size);
11191 mp->skip_n_vectors = ntohl (skip);
11192 mp->match_n_vectors = ntohl (match);
11193 mp->next_table_index = ntohl (next_table_index);
11194 mp->miss_next_index = ntohl (miss_next_index);
11195 mp->current_data_flag = ntohl (current_data_flag);
11196 mp->current_data_offset = ntohl (current_data_offset);
11197 clib_memcpy (mp->mask, mask, vec_len (mask));
11206 #if VPP_API_TEST_BUILTIN == 0
11208 unformat_l4_match (unformat_input_t * input, va_list * args)
11210 u8 **matchp = va_arg (*args, u8 **);
11212 u8 *proto_header = 0;
11218 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11220 if (unformat (input, "src_port %d", &src_port))
11222 else if (unformat (input, "dst_port %d", &dst_port))
11228 h.src_port = clib_host_to_net_u16 (src_port);
11229 h.dst_port = clib_host_to_net_u16 (dst_port);
11230 vec_validate (proto_header, sizeof (h) - 1);
11231 memcpy (proto_header, &h, sizeof (h));
11233 *matchp = proto_header;
11239 unformat_ip4_match (unformat_input_t * input, va_list * args)
11241 u8 **matchp = va_arg (*args, u8 **);
11246 int hdr_length = 0;
11247 u32 hdr_length_val;
11248 int src = 0, dst = 0;
11249 ip4_address_t src_val, dst_val;
11256 int fragment_id = 0;
11257 u32 fragment_id_val;
11263 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11265 if (unformat (input, "version %d", &version_val))
11267 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11269 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11271 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11273 else if (unformat (input, "proto %d", &proto_val))
11275 else if (unformat (input, "tos %d", &tos_val))
11277 else if (unformat (input, "length %d", &length_val))
11279 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11281 else if (unformat (input, "ttl %d", &ttl_val))
11283 else if (unformat (input, "checksum %d", &checksum_val))
11289 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11290 + ttl + checksum == 0)
11294 * Aligned because we use the real comparison functions
11296 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11298 ip = (ip4_header_t *) match;
11300 /* These are realistically matched in practice */
11302 ip->src_address.as_u32 = src_val.as_u32;
11305 ip->dst_address.as_u32 = dst_val.as_u32;
11308 ip->protocol = proto_val;
11311 /* These are not, but they're included for completeness */
11313 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11316 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11322 ip->length = clib_host_to_net_u16 (length_val);
11328 ip->checksum = clib_host_to_net_u16 (checksum_val);
11335 unformat_ip6_match (unformat_input_t * input, va_list * args)
11337 u8 **matchp = va_arg (*args, u8 **);
11342 u8 traffic_class = 0;
11343 u32 traffic_class_val = 0;
11346 int src = 0, dst = 0;
11347 ip6_address_t src_val, dst_val;
11350 int payload_length = 0;
11351 u32 payload_length_val;
11354 u32 ip_version_traffic_class_and_flow_label;
11356 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11358 if (unformat (input, "version %d", &version_val))
11360 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11362 else if (unformat (input, "flow_label %d", &flow_label_val))
11364 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11366 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11368 else if (unformat (input, "proto %d", &proto_val))
11370 else if (unformat (input, "payload_length %d", &payload_length_val))
11371 payload_length = 1;
11372 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11378 if (version + traffic_class + flow_label + src + dst + proto +
11379 payload_length + hop_limit == 0)
11383 * Aligned because we use the real comparison functions
11385 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11387 ip = (ip6_header_t *) match;
11390 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11393 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11396 ip->protocol = proto_val;
11398 ip_version_traffic_class_and_flow_label = 0;
11401 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11404 ip_version_traffic_class_and_flow_label |=
11405 (traffic_class_val & 0xFF) << 20;
11408 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11410 ip->ip_version_traffic_class_and_flow_label =
11411 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11413 if (payload_length)
11414 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11417 ip->hop_limit = hop_limit_val;
11424 unformat_l3_match (unformat_input_t * input, va_list * args)
11426 u8 **matchp = va_arg (*args, u8 **);
11428 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11430 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11432 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11441 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11443 u8 *tagp = va_arg (*args, u8 *);
11446 if (unformat (input, "%d", &tag))
11448 tagp[0] = (tag >> 8) & 0x0F;
11449 tagp[1] = tag & 0xFF;
11457 unformat_l2_match (unformat_input_t * input, va_list * args)
11459 u8 **matchp = va_arg (*args, u8 **);
11472 u8 ignore_tag1 = 0;
11473 u8 ignore_tag2 = 0;
11479 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11481 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11484 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11486 else if (unformat (input, "proto %U",
11487 unformat_ethernet_type_host_byte_order, &proto_val))
11489 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11491 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11493 else if (unformat (input, "ignore-tag1"))
11495 else if (unformat (input, "ignore-tag2"))
11497 else if (unformat (input, "cos1 %d", &cos1_val))
11499 else if (unformat (input, "cos2 %d", &cos2_val))
11504 if ((src + dst + proto + tag1 + tag2 +
11505 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11508 if (tag1 || ignore_tag1 || cos1)
11510 if (tag2 || ignore_tag2 || cos2)
11513 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11516 clib_memcpy (match, dst_val, 6);
11519 clib_memcpy (match + 6, src_val, 6);
11523 /* inner vlan tag */
11524 match[19] = tag2_val[1];
11525 match[18] = tag2_val[0];
11527 match[18] |= (cos2_val & 0x7) << 5;
11530 match[21] = proto_val & 0xff;
11531 match[20] = proto_val >> 8;
11535 match[15] = tag1_val[1];
11536 match[14] = tag1_val[0];
11539 match[14] |= (cos1_val & 0x7) << 5;
11545 match[15] = tag1_val[1];
11546 match[14] = tag1_val[0];
11549 match[17] = proto_val & 0xff;
11550 match[16] = proto_val >> 8;
11553 match[14] |= (cos1_val & 0x7) << 5;
11559 match[18] |= (cos2_val & 0x7) << 5;
11561 match[14] |= (cos1_val & 0x7) << 5;
11564 match[13] = proto_val & 0xff;
11565 match[12] = proto_val >> 8;
11574 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11576 u8 **matchp = va_arg (*args, u8 **);
11577 u32 skip_n_vectors = va_arg (*args, u32);
11578 u32 match_n_vectors = va_arg (*args, u32);
11585 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11587 if (unformat (input, "hex %U", unformat_hex_string, &match))
11589 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11591 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11593 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11607 if (match || l2 || l3 || l4)
11609 if (l2 || l3 || l4)
11611 /* "Win a free Ethernet header in every packet" */
11613 vec_validate_aligned (l2, 13, sizeof (u32x4));
11617 vec_append_aligned (match, l3, sizeof (u32x4));
11622 vec_append_aligned (match, l4, sizeof (u32x4));
11627 /* Make sure the vector is big enough even if key is all 0's */
11628 vec_validate_aligned
11629 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11632 /* Set size, include skipped vectors */
11633 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11644 api_classify_add_del_session (vat_main_t * vam)
11646 unformat_input_t *i = vam->input;
11647 vl_api_classify_add_del_session_t *mp;
11649 u32 table_index = ~0;
11650 u32 hit_next_index = ~0;
11651 u32 opaque_index = ~0;
11654 u32 skip_n_vectors = 0;
11655 u32 match_n_vectors = 0;
11661 * Warning: you have to supply skip_n and match_n
11662 * because the API client cant simply look at the classify
11666 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11668 if (unformat (i, "del"))
11670 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11673 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11676 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11679 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11681 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11683 else if (unformat (i, "opaque-index %d", &opaque_index))
11685 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11687 else if (unformat (i, "match_n %d", &match_n_vectors))
11689 else if (unformat (i, "match %U", api_unformat_classify_match,
11690 &match, skip_n_vectors, match_n_vectors))
11692 else if (unformat (i, "advance %d", &advance))
11694 else if (unformat (i, "table-index %d", &table_index))
11696 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11698 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11700 else if (unformat (i, "action %d", &action))
11702 else if (unformat (i, "metadata %d", &metadata))
11708 if (table_index == ~0)
11710 errmsg ("Table index required");
11714 if (is_add && match == 0)
11716 errmsg ("Match value required");
11720 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11722 mp->is_add = is_add;
11723 mp->table_index = ntohl (table_index);
11724 mp->hit_next_index = ntohl (hit_next_index);
11725 mp->opaque_index = ntohl (opaque_index);
11726 mp->advance = ntohl (advance);
11727 mp->action = action;
11728 mp->metadata = ntohl (metadata);
11729 clib_memcpy (mp->match, match, vec_len (match));
11738 api_classify_set_interface_ip_table (vat_main_t * vam)
11740 unformat_input_t *i = vam->input;
11741 vl_api_classify_set_interface_ip_table_t *mp;
11743 int sw_if_index_set;
11744 u32 table_index = ~0;
11748 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11750 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11751 sw_if_index_set = 1;
11752 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11753 sw_if_index_set = 1;
11754 else if (unformat (i, "table %d", &table_index))
11758 clib_warning ("parse error '%U'", format_unformat_error, i);
11763 if (sw_if_index_set == 0)
11765 errmsg ("missing interface name or sw_if_index");
11770 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11772 mp->sw_if_index = ntohl (sw_if_index);
11773 mp->table_index = ntohl (table_index);
11774 mp->is_ipv6 = is_ipv6;
11782 api_classify_set_interface_l2_tables (vat_main_t * vam)
11784 unformat_input_t *i = vam->input;
11785 vl_api_classify_set_interface_l2_tables_t *mp;
11787 int sw_if_index_set;
11788 u32 ip4_table_index = ~0;
11789 u32 ip6_table_index = ~0;
11790 u32 other_table_index = ~0;
11794 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11796 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11797 sw_if_index_set = 1;
11798 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11799 sw_if_index_set = 1;
11800 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11802 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11804 else if (unformat (i, "other-table %d", &other_table_index))
11806 else if (unformat (i, "is-input %d", &is_input))
11810 clib_warning ("parse error '%U'", format_unformat_error, i);
11815 if (sw_if_index_set == 0)
11817 errmsg ("missing interface name or sw_if_index");
11822 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11824 mp->sw_if_index = ntohl (sw_if_index);
11825 mp->ip4_table_index = ntohl (ip4_table_index);
11826 mp->ip6_table_index = ntohl (ip6_table_index);
11827 mp->other_table_index = ntohl (other_table_index);
11828 mp->is_input = (u8) is_input;
11836 api_set_ipfix_exporter (vat_main_t * vam)
11838 unformat_input_t *i = vam->input;
11839 vl_api_set_ipfix_exporter_t *mp;
11840 ip4_address_t collector_address;
11841 u8 collector_address_set = 0;
11842 u32 collector_port = ~0;
11843 ip4_address_t src_address;
11844 u8 src_address_set = 0;
11847 u32 template_interval = ~0;
11848 u8 udp_checksum = 0;
11851 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11853 if (unformat (i, "collector_address %U", unformat_ip4_address,
11854 &collector_address))
11855 collector_address_set = 1;
11856 else if (unformat (i, "collector_port %d", &collector_port))
11858 else if (unformat (i, "src_address %U", unformat_ip4_address,
11860 src_address_set = 1;
11861 else if (unformat (i, "vrf_id %d", &vrf_id))
11863 else if (unformat (i, "path_mtu %d", &path_mtu))
11865 else if (unformat (i, "template_interval %d", &template_interval))
11867 else if (unformat (i, "udp_checksum"))
11873 if (collector_address_set == 0)
11875 errmsg ("collector_address required");
11879 if (src_address_set == 0)
11881 errmsg ("src_address required");
11885 M (SET_IPFIX_EXPORTER, mp);
11887 memcpy (mp->collector_address, collector_address.data,
11888 sizeof (collector_address.data));
11889 mp->collector_port = htons ((u16) collector_port);
11890 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11891 mp->vrf_id = htonl (vrf_id);
11892 mp->path_mtu = htonl (path_mtu);
11893 mp->template_interval = htonl (template_interval);
11894 mp->udp_checksum = udp_checksum;
11902 api_set_ipfix_classify_stream (vat_main_t * vam)
11904 unformat_input_t *i = vam->input;
11905 vl_api_set_ipfix_classify_stream_t *mp;
11907 u32 src_port = UDP_DST_PORT_ipfix;
11910 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11912 if (unformat (i, "domain %d", &domain_id))
11914 else if (unformat (i, "src_port %d", &src_port))
11918 errmsg ("unknown input `%U'", format_unformat_error, i);
11923 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11925 mp->domain_id = htonl (domain_id);
11926 mp->src_port = htons ((u16) src_port);
11934 api_ipfix_classify_table_add_del (vat_main_t * vam)
11936 unformat_input_t *i = vam->input;
11937 vl_api_ipfix_classify_table_add_del_t *mp;
11939 u32 classify_table_index = ~0;
11941 u8 transport_protocol = 255;
11944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11946 if (unformat (i, "add"))
11948 else if (unformat (i, "del"))
11950 else if (unformat (i, "table %d", &classify_table_index))
11952 else if (unformat (i, "ip4"))
11954 else if (unformat (i, "ip6"))
11956 else if (unformat (i, "tcp"))
11957 transport_protocol = 6;
11958 else if (unformat (i, "udp"))
11959 transport_protocol = 17;
11962 errmsg ("unknown input `%U'", format_unformat_error, i);
11969 errmsg ("expecting: add|del");
11972 if (classify_table_index == ~0)
11974 errmsg ("classifier table not specified");
11977 if (ip_version == 0)
11979 errmsg ("IP version not specified");
11983 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11985 mp->is_add = is_add;
11986 mp->table_id = htonl (classify_table_index);
11987 mp->ip_version = ip_version;
11988 mp->transport_protocol = transport_protocol;
11996 api_get_node_index (vat_main_t * vam)
11998 unformat_input_t *i = vam->input;
11999 vl_api_get_node_index_t *mp;
12003 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12005 if (unformat (i, "node %s", &name))
12012 errmsg ("node name required");
12015 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12017 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12021 M (GET_NODE_INDEX, mp);
12022 clib_memcpy (mp->node_name, name, vec_len (name));
12031 api_get_next_index (vat_main_t * vam)
12033 unformat_input_t *i = vam->input;
12034 vl_api_get_next_index_t *mp;
12035 u8 *node_name = 0, *next_node_name = 0;
12038 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12040 if (unformat (i, "node-name %s", &node_name))
12042 else if (unformat (i, "next-node-name %s", &next_node_name))
12046 if (node_name == 0)
12048 errmsg ("node name required");
12051 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12053 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12057 if (next_node_name == 0)
12059 errmsg ("next node name required");
12062 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12064 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12068 M (GET_NEXT_INDEX, mp);
12069 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12070 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12071 vec_free (node_name);
12072 vec_free (next_node_name);
12080 api_add_node_next (vat_main_t * vam)
12082 unformat_input_t *i = vam->input;
12083 vl_api_add_node_next_t *mp;
12088 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12090 if (unformat (i, "node %s", &name))
12092 else if (unformat (i, "next %s", &next))
12099 errmsg ("node name required");
12102 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12104 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12109 errmsg ("next node required");
12112 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12114 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12118 M (ADD_NODE_NEXT, mp);
12119 clib_memcpy (mp->node_name, name, vec_len (name));
12120 clib_memcpy (mp->next_name, next, vec_len (next));
12130 api_l2tpv3_create_tunnel (vat_main_t * vam)
12132 unformat_input_t *i = vam->input;
12133 ip6_address_t client_address, our_address;
12134 int client_address_set = 0;
12135 int our_address_set = 0;
12136 u32 local_session_id = 0;
12137 u32 remote_session_id = 0;
12138 u64 local_cookie = 0;
12139 u64 remote_cookie = 0;
12140 u8 l2_sublayer_present = 0;
12141 vl_api_l2tpv3_create_tunnel_t *mp;
12144 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12146 if (unformat (i, "client_address %U", unformat_ip6_address,
12148 client_address_set = 1;
12149 else if (unformat (i, "our_address %U", unformat_ip6_address,
12151 our_address_set = 1;
12152 else if (unformat (i, "local_session_id %d", &local_session_id))
12154 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12156 else if (unformat (i, "local_cookie %lld", &local_cookie))
12158 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12160 else if (unformat (i, "l2-sublayer-present"))
12161 l2_sublayer_present = 1;
12166 if (client_address_set == 0)
12168 errmsg ("client_address required");
12172 if (our_address_set == 0)
12174 errmsg ("our_address required");
12178 M (L2TPV3_CREATE_TUNNEL, mp);
12180 clib_memcpy (mp->client_address, client_address.as_u8,
12181 sizeof (mp->client_address));
12183 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12185 mp->local_session_id = ntohl (local_session_id);
12186 mp->remote_session_id = ntohl (remote_session_id);
12187 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12188 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12189 mp->l2_sublayer_present = l2_sublayer_present;
12198 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12200 unformat_input_t *i = vam->input;
12202 u8 sw_if_index_set = 0;
12203 u64 new_local_cookie = 0;
12204 u64 new_remote_cookie = 0;
12205 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12208 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12210 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12211 sw_if_index_set = 1;
12212 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12213 sw_if_index_set = 1;
12214 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12216 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12222 if (sw_if_index_set == 0)
12224 errmsg ("missing interface name or sw_if_index");
12228 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12230 mp->sw_if_index = ntohl (sw_if_index);
12231 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12232 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12240 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12242 unformat_input_t *i = vam->input;
12243 vl_api_l2tpv3_interface_enable_disable_t *mp;
12245 u8 sw_if_index_set = 0;
12246 u8 enable_disable = 1;
12249 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12251 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12252 sw_if_index_set = 1;
12253 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12254 sw_if_index_set = 1;
12255 else if (unformat (i, "enable"))
12256 enable_disable = 1;
12257 else if (unformat (i, "disable"))
12258 enable_disable = 0;
12263 if (sw_if_index_set == 0)
12265 errmsg ("missing interface name or sw_if_index");
12269 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12271 mp->sw_if_index = ntohl (sw_if_index);
12272 mp->enable_disable = enable_disable;
12280 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12282 unformat_input_t *i = vam->input;
12283 vl_api_l2tpv3_set_lookup_key_t *mp;
12287 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12289 if (unformat (i, "lookup_v6_src"))
12290 key = L2T_LOOKUP_SRC_ADDRESS;
12291 else if (unformat (i, "lookup_v6_dst"))
12292 key = L2T_LOOKUP_DST_ADDRESS;
12293 else if (unformat (i, "lookup_session_id"))
12294 key = L2T_LOOKUP_SESSION_ID;
12299 if (key == (u8) ~ 0)
12301 errmsg ("l2tp session lookup key unset");
12305 M (L2TPV3_SET_LOOKUP_KEY, mp);
12314 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12315 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12317 vat_main_t *vam = &vat_main;
12319 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12320 format_ip6_address, mp->our_address,
12321 format_ip6_address, mp->client_address,
12322 clib_net_to_host_u32 (mp->sw_if_index));
12325 " local cookies %016llx %016llx remote cookie %016llx",
12326 clib_net_to_host_u64 (mp->local_cookie[0]),
12327 clib_net_to_host_u64 (mp->local_cookie[1]),
12328 clib_net_to_host_u64 (mp->remote_cookie));
12330 print (vam->ofp, " local session-id %d remote session-id %d",
12331 clib_net_to_host_u32 (mp->local_session_id),
12332 clib_net_to_host_u32 (mp->remote_session_id));
12334 print (vam->ofp, " l2 specific sublayer %s\n",
12335 mp->l2_sublayer_present ? "preset" : "absent");
12339 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12340 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12342 vat_main_t *vam = &vat_main;
12343 vat_json_node_t *node = NULL;
12344 struct in6_addr addr;
12346 if (VAT_JSON_ARRAY != vam->json_tree.type)
12348 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12349 vat_json_init_array (&vam->json_tree);
12351 node = vat_json_array_add (&vam->json_tree);
12353 vat_json_init_object (node);
12355 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12356 vat_json_object_add_ip6 (node, "our_address", addr);
12357 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12358 vat_json_object_add_ip6 (node, "client_address", addr);
12360 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12361 vat_json_init_array (lc);
12362 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12363 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12364 vat_json_object_add_uint (node, "remote_cookie",
12365 clib_net_to_host_u64 (mp->remote_cookie));
12367 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12368 vat_json_object_add_uint (node, "local_session_id",
12369 clib_net_to_host_u32 (mp->local_session_id));
12370 vat_json_object_add_uint (node, "remote_session_id",
12371 clib_net_to_host_u32 (mp->remote_session_id));
12372 vat_json_object_add_string_copy (node, "l2_sublayer",
12373 mp->l2_sublayer_present ? (u8 *) "present"
12374 : (u8 *) "absent");
12378 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12380 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12381 vl_api_control_ping_t *mp_ping;
12384 /* Get list of l2tpv3-tunnel interfaces */
12385 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12388 /* Use a control ping for synchronization */
12389 MPING (CONTROL_PING, mp_ping);
12397 static void vl_api_sw_interface_tap_details_t_handler
12398 (vl_api_sw_interface_tap_details_t * mp)
12400 vat_main_t *vam = &vat_main;
12402 print (vam->ofp, "%-16s %d",
12403 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12406 static void vl_api_sw_interface_tap_details_t_handler_json
12407 (vl_api_sw_interface_tap_details_t * mp)
12409 vat_main_t *vam = &vat_main;
12410 vat_json_node_t *node = NULL;
12412 if (VAT_JSON_ARRAY != vam->json_tree.type)
12414 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12415 vat_json_init_array (&vam->json_tree);
12417 node = vat_json_array_add (&vam->json_tree);
12419 vat_json_init_object (node);
12420 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12421 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12425 api_sw_interface_tap_dump (vat_main_t * vam)
12427 vl_api_sw_interface_tap_dump_t *mp;
12428 vl_api_control_ping_t *mp_ping;
12431 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12432 /* Get list of tap interfaces */
12433 M (SW_INTERFACE_TAP_DUMP, mp);
12436 /* Use a control ping for synchronization */
12437 MPING (CONTROL_PING, mp_ping);
12444 static void vl_api_sw_interface_tap_v2_details_t_handler
12445 (vl_api_sw_interface_tap_v2_details_t * mp)
12447 vat_main_t *vam = &vat_main;
12449 print (vam->ofp, "%-16s %d",
12450 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12453 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12454 (vl_api_sw_interface_tap_v2_details_t * mp)
12456 vat_main_t *vam = &vat_main;
12457 vat_json_node_t *node = NULL;
12459 if (VAT_JSON_ARRAY != vam->json_tree.type)
12461 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12462 vat_json_init_array (&vam->json_tree);
12464 node = vat_json_array_add (&vam->json_tree);
12466 vat_json_init_object (node);
12467 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12468 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12472 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12474 vl_api_sw_interface_tap_v2_dump_t *mp;
12475 vl_api_control_ping_t *mp_ping;
12478 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12479 /* Get list of tap interfaces */
12480 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12483 /* Use a control ping for synchronization */
12484 MPING (CONTROL_PING, mp_ping);
12491 static uword unformat_vxlan_decap_next
12492 (unformat_input_t * input, va_list * args)
12494 u32 *result = va_arg (*args, u32 *);
12497 if (unformat (input, "l2"))
12498 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12499 else if (unformat (input, "%d", &tmp))
12507 api_vxlan_add_del_tunnel (vat_main_t * vam)
12509 unformat_input_t *line_input = vam->input;
12510 vl_api_vxlan_add_del_tunnel_t *mp;
12511 ip46_address_t src, dst;
12513 u8 ipv4_set = 0, ipv6_set = 0;
12517 u32 mcast_sw_if_index = ~0;
12518 u32 encap_vrf_id = 0;
12519 u32 decap_next_index = ~0;
12523 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12524 memset (&src, 0, sizeof src);
12525 memset (&dst, 0, sizeof dst);
12527 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12529 if (unformat (line_input, "del"))
12532 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12538 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12544 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12550 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12555 else if (unformat (line_input, "group %U %U",
12556 unformat_ip4_address, &dst.ip4,
12557 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12559 grp_set = dst_set = 1;
12562 else if (unformat (line_input, "group %U",
12563 unformat_ip4_address, &dst.ip4))
12565 grp_set = dst_set = 1;
12568 else if (unformat (line_input, "group %U %U",
12569 unformat_ip6_address, &dst.ip6,
12570 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12572 grp_set = dst_set = 1;
12575 else if (unformat (line_input, "group %U",
12576 unformat_ip6_address, &dst.ip6))
12578 grp_set = dst_set = 1;
12582 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12584 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12586 else if (unformat (line_input, "decap-next %U",
12587 unformat_vxlan_decap_next, &decap_next_index))
12589 else if (unformat (line_input, "vni %d", &vni))
12593 errmsg ("parse error '%U'", format_unformat_error, line_input);
12600 errmsg ("tunnel src address not specified");
12605 errmsg ("tunnel dst address not specified");
12609 if (grp_set && !ip46_address_is_multicast (&dst))
12611 errmsg ("tunnel group address not multicast");
12614 if (grp_set && mcast_sw_if_index == ~0)
12616 errmsg ("tunnel nonexistent multicast device");
12619 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12621 errmsg ("tunnel dst address must be unicast");
12626 if (ipv4_set && ipv6_set)
12628 errmsg ("both IPv4 and IPv6 addresses specified");
12632 if ((vni == 0) || (vni >> 24))
12634 errmsg ("vni not specified or out of range");
12638 M (VXLAN_ADD_DEL_TUNNEL, mp);
12642 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12643 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12647 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12648 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12650 mp->encap_vrf_id = ntohl (encap_vrf_id);
12651 mp->decap_next_index = ntohl (decap_next_index);
12652 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12653 mp->vni = ntohl (vni);
12654 mp->is_add = is_add;
12655 mp->is_ipv6 = ipv6_set;
12662 static void vl_api_vxlan_tunnel_details_t_handler
12663 (vl_api_vxlan_tunnel_details_t * mp)
12665 vat_main_t *vam = &vat_main;
12666 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12667 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12669 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12670 ntohl (mp->sw_if_index),
12671 format_ip46_address, &src, IP46_TYPE_ANY,
12672 format_ip46_address, &dst, IP46_TYPE_ANY,
12673 ntohl (mp->encap_vrf_id),
12674 ntohl (mp->decap_next_index), ntohl (mp->vni),
12675 ntohl (mp->mcast_sw_if_index));
12678 static void vl_api_vxlan_tunnel_details_t_handler_json
12679 (vl_api_vxlan_tunnel_details_t * mp)
12681 vat_main_t *vam = &vat_main;
12682 vat_json_node_t *node = NULL;
12684 if (VAT_JSON_ARRAY != vam->json_tree.type)
12686 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12687 vat_json_init_array (&vam->json_tree);
12689 node = vat_json_array_add (&vam->json_tree);
12691 vat_json_init_object (node);
12692 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12695 struct in6_addr ip6;
12697 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12698 vat_json_object_add_ip6 (node, "src_address", ip6);
12699 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12700 vat_json_object_add_ip6 (node, "dst_address", ip6);
12704 struct in_addr ip4;
12706 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12707 vat_json_object_add_ip4 (node, "src_address", ip4);
12708 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12709 vat_json_object_add_ip4 (node, "dst_address", ip4);
12711 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12712 vat_json_object_add_uint (node, "decap_next_index",
12713 ntohl (mp->decap_next_index));
12714 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12715 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12716 vat_json_object_add_uint (node, "mcast_sw_if_index",
12717 ntohl (mp->mcast_sw_if_index));
12721 api_vxlan_tunnel_dump (vat_main_t * vam)
12723 unformat_input_t *i = vam->input;
12724 vl_api_vxlan_tunnel_dump_t *mp;
12725 vl_api_control_ping_t *mp_ping;
12727 u8 sw_if_index_set = 0;
12730 /* Parse args required to build the message */
12731 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12733 if (unformat (i, "sw_if_index %d", &sw_if_index))
12734 sw_if_index_set = 1;
12739 if (sw_if_index_set == 0)
12744 if (!vam->json_output)
12746 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12747 "sw_if_index", "src_address", "dst_address",
12748 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12751 /* Get list of vxlan-tunnel interfaces */
12752 M (VXLAN_TUNNEL_DUMP, mp);
12754 mp->sw_if_index = htonl (sw_if_index);
12758 /* Use a control ping for synchronization */
12759 MPING (CONTROL_PING, mp_ping);
12766 static uword unformat_geneve_decap_next
12767 (unformat_input_t * input, va_list * args)
12769 u32 *result = va_arg (*args, u32 *);
12772 if (unformat (input, "l2"))
12773 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12774 else if (unformat (input, "%d", &tmp))
12782 api_geneve_add_del_tunnel (vat_main_t * vam)
12784 unformat_input_t *line_input = vam->input;
12785 vl_api_geneve_add_del_tunnel_t *mp;
12786 ip46_address_t src, dst;
12788 u8 ipv4_set = 0, ipv6_set = 0;
12792 u32 mcast_sw_if_index = ~0;
12793 u32 encap_vrf_id = 0;
12794 u32 decap_next_index = ~0;
12798 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12799 memset (&src, 0, sizeof src);
12800 memset (&dst, 0, sizeof dst);
12802 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12804 if (unformat (line_input, "del"))
12807 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12813 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12819 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12825 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12830 else if (unformat (line_input, "group %U %U",
12831 unformat_ip4_address, &dst.ip4,
12832 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12834 grp_set = dst_set = 1;
12837 else if (unformat (line_input, "group %U",
12838 unformat_ip4_address, &dst.ip4))
12840 grp_set = dst_set = 1;
12843 else if (unformat (line_input, "group %U %U",
12844 unformat_ip6_address, &dst.ip6,
12845 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12847 grp_set = dst_set = 1;
12850 else if (unformat (line_input, "group %U",
12851 unformat_ip6_address, &dst.ip6))
12853 grp_set = dst_set = 1;
12857 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12859 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12861 else if (unformat (line_input, "decap-next %U",
12862 unformat_geneve_decap_next, &decap_next_index))
12864 else if (unformat (line_input, "vni %d", &vni))
12868 errmsg ("parse error '%U'", format_unformat_error, line_input);
12875 errmsg ("tunnel src address not specified");
12880 errmsg ("tunnel dst address not specified");
12884 if (grp_set && !ip46_address_is_multicast (&dst))
12886 errmsg ("tunnel group address not multicast");
12889 if (grp_set && mcast_sw_if_index == ~0)
12891 errmsg ("tunnel nonexistent multicast device");
12894 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12896 errmsg ("tunnel dst address must be unicast");
12901 if (ipv4_set && ipv6_set)
12903 errmsg ("both IPv4 and IPv6 addresses specified");
12907 if ((vni == 0) || (vni >> 24))
12909 errmsg ("vni not specified or out of range");
12913 M (GENEVE_ADD_DEL_TUNNEL, mp);
12917 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12918 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12922 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12923 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12925 mp->encap_vrf_id = ntohl (encap_vrf_id);
12926 mp->decap_next_index = ntohl (decap_next_index);
12927 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12928 mp->vni = ntohl (vni);
12929 mp->is_add = is_add;
12930 mp->is_ipv6 = ipv6_set;
12937 static void vl_api_geneve_tunnel_details_t_handler
12938 (vl_api_geneve_tunnel_details_t * mp)
12940 vat_main_t *vam = &vat_main;
12941 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12942 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12944 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12945 ntohl (mp->sw_if_index),
12946 format_ip46_address, &src, IP46_TYPE_ANY,
12947 format_ip46_address, &dst, IP46_TYPE_ANY,
12948 ntohl (mp->encap_vrf_id),
12949 ntohl (mp->decap_next_index), ntohl (mp->vni),
12950 ntohl (mp->mcast_sw_if_index));
12953 static void vl_api_geneve_tunnel_details_t_handler_json
12954 (vl_api_geneve_tunnel_details_t * mp)
12956 vat_main_t *vam = &vat_main;
12957 vat_json_node_t *node = NULL;
12959 if (VAT_JSON_ARRAY != vam->json_tree.type)
12961 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12962 vat_json_init_array (&vam->json_tree);
12964 node = vat_json_array_add (&vam->json_tree);
12966 vat_json_init_object (node);
12967 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12970 struct in6_addr ip6;
12972 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12973 vat_json_object_add_ip6 (node, "src_address", ip6);
12974 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12975 vat_json_object_add_ip6 (node, "dst_address", ip6);
12979 struct in_addr ip4;
12981 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12982 vat_json_object_add_ip4 (node, "src_address", ip4);
12983 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12984 vat_json_object_add_ip4 (node, "dst_address", ip4);
12986 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12987 vat_json_object_add_uint (node, "decap_next_index",
12988 ntohl (mp->decap_next_index));
12989 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12990 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12991 vat_json_object_add_uint (node, "mcast_sw_if_index",
12992 ntohl (mp->mcast_sw_if_index));
12996 api_geneve_tunnel_dump (vat_main_t * vam)
12998 unformat_input_t *i = vam->input;
12999 vl_api_geneve_tunnel_dump_t *mp;
13000 vl_api_control_ping_t *mp_ping;
13002 u8 sw_if_index_set = 0;
13005 /* Parse args required to build the message */
13006 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13008 if (unformat (i, "sw_if_index %d", &sw_if_index))
13009 sw_if_index_set = 1;
13014 if (sw_if_index_set == 0)
13019 if (!vam->json_output)
13021 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13022 "sw_if_index", "local_address", "remote_address",
13023 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13026 /* Get list of geneve-tunnel interfaces */
13027 M (GENEVE_TUNNEL_DUMP, mp);
13029 mp->sw_if_index = htonl (sw_if_index);
13033 /* Use a control ping for synchronization */
13034 M (CONTROL_PING, mp_ping);
13042 api_gre_add_del_tunnel (vat_main_t * vam)
13044 unformat_input_t *line_input = vam->input;
13045 vl_api_gre_add_del_tunnel_t *mp;
13046 ip4_address_t src4, dst4;
13047 ip6_address_t src6, dst6;
13054 u32 outer_fib_id = 0;
13057 memset (&src4, 0, sizeof src4);
13058 memset (&dst4, 0, sizeof dst4);
13059 memset (&src6, 0, sizeof src6);
13060 memset (&dst6, 0, sizeof dst6);
13062 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13064 if (unformat (line_input, "del"))
13066 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13071 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13076 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13081 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13086 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13088 else if (unformat (line_input, "teb"))
13092 errmsg ("parse error '%U'", format_unformat_error, line_input);
13099 errmsg ("tunnel src address not specified");
13104 errmsg ("tunnel dst address not specified");
13107 if (ipv4_set && ipv6_set)
13109 errmsg ("both IPv4 and IPv6 addresses specified");
13114 M (GRE_ADD_DEL_TUNNEL, mp);
13118 clib_memcpy (&mp->src_address, &src4, 4);
13119 clib_memcpy (&mp->dst_address, &dst4, 4);
13123 clib_memcpy (&mp->src_address, &src6, 16);
13124 clib_memcpy (&mp->dst_address, &dst6, 16);
13126 mp->outer_fib_id = ntohl (outer_fib_id);
13127 mp->is_add = is_add;
13129 mp->is_ipv6 = ipv6_set;
13136 static void vl_api_gre_tunnel_details_t_handler
13137 (vl_api_gre_tunnel_details_t * mp)
13139 vat_main_t *vam = &vat_main;
13140 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13141 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13143 print (vam->ofp, "%11d%24U%24U%6d%14d",
13144 ntohl (mp->sw_if_index),
13145 format_ip46_address, &src, IP46_TYPE_ANY,
13146 format_ip46_address, &dst, IP46_TYPE_ANY,
13147 mp->teb, ntohl (mp->outer_fib_id));
13150 static void vl_api_gre_tunnel_details_t_handler_json
13151 (vl_api_gre_tunnel_details_t * mp)
13153 vat_main_t *vam = &vat_main;
13154 vat_json_node_t *node = NULL;
13155 struct in_addr ip4;
13156 struct in6_addr ip6;
13158 if (VAT_JSON_ARRAY != vam->json_tree.type)
13160 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13161 vat_json_init_array (&vam->json_tree);
13163 node = vat_json_array_add (&vam->json_tree);
13165 vat_json_init_object (node);
13166 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13169 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13170 vat_json_object_add_ip4 (node, "src_address", ip4);
13171 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13172 vat_json_object_add_ip4 (node, "dst_address", ip4);
13176 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13177 vat_json_object_add_ip6 (node, "src_address", ip6);
13178 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13179 vat_json_object_add_ip6 (node, "dst_address", ip6);
13181 vat_json_object_add_uint (node, "teb", mp->teb);
13182 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13183 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13187 api_gre_tunnel_dump (vat_main_t * vam)
13189 unformat_input_t *i = vam->input;
13190 vl_api_gre_tunnel_dump_t *mp;
13191 vl_api_control_ping_t *mp_ping;
13193 u8 sw_if_index_set = 0;
13196 /* Parse args required to build the message */
13197 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13199 if (unformat (i, "sw_if_index %d", &sw_if_index))
13200 sw_if_index_set = 1;
13205 if (sw_if_index_set == 0)
13210 if (!vam->json_output)
13212 print (vam->ofp, "%11s%24s%24s%6s%14s",
13213 "sw_if_index", "src_address", "dst_address", "teb",
13217 /* Get list of gre-tunnel interfaces */
13218 M (GRE_TUNNEL_DUMP, mp);
13220 mp->sw_if_index = htonl (sw_if_index);
13224 /* Use a control ping for synchronization */
13225 MPING (CONTROL_PING, mp_ping);
13233 api_l2_fib_clear_table (vat_main_t * vam)
13235 // unformat_input_t * i = vam->input;
13236 vl_api_l2_fib_clear_table_t *mp;
13239 M (L2_FIB_CLEAR_TABLE, mp);
13247 api_l2_interface_efp_filter (vat_main_t * vam)
13249 unformat_input_t *i = vam->input;
13250 vl_api_l2_interface_efp_filter_t *mp;
13253 u8 sw_if_index_set = 0;
13256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13258 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13259 sw_if_index_set = 1;
13260 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13261 sw_if_index_set = 1;
13262 else if (unformat (i, "enable"))
13264 else if (unformat (i, "disable"))
13268 clib_warning ("parse error '%U'", format_unformat_error, i);
13273 if (sw_if_index_set == 0)
13275 errmsg ("missing sw_if_index");
13279 M (L2_INTERFACE_EFP_FILTER, mp);
13281 mp->sw_if_index = ntohl (sw_if_index);
13282 mp->enable_disable = enable;
13289 #define foreach_vtr_op \
13290 _("disable", L2_VTR_DISABLED) \
13291 _("push-1", L2_VTR_PUSH_1) \
13292 _("push-2", L2_VTR_PUSH_2) \
13293 _("pop-1", L2_VTR_POP_1) \
13294 _("pop-2", L2_VTR_POP_2) \
13295 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13296 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13297 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13298 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13301 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13303 unformat_input_t *i = vam->input;
13304 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13306 u8 sw_if_index_set = 0;
13309 u32 push_dot1q = 1;
13314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13316 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13317 sw_if_index_set = 1;
13318 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13319 sw_if_index_set = 1;
13320 else if (unformat (i, "vtr_op %d", &vtr_op))
13322 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13325 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13327 else if (unformat (i, "tag1 %d", &tag1))
13329 else if (unformat (i, "tag2 %d", &tag2))
13333 clib_warning ("parse error '%U'", format_unformat_error, i);
13338 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13340 errmsg ("missing vtr operation or sw_if_index");
13344 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13345 mp->sw_if_index = ntohl (sw_if_index);
13346 mp->vtr_op = ntohl (vtr_op);
13347 mp->push_dot1q = ntohl (push_dot1q);
13348 mp->tag1 = ntohl (tag1);
13349 mp->tag2 = ntohl (tag2);
13357 api_create_vhost_user_if (vat_main_t * vam)
13359 unformat_input_t *i = vam->input;
13360 vl_api_create_vhost_user_if_t *mp;
13363 u8 file_name_set = 0;
13364 u32 custom_dev_instance = ~0;
13366 u8 use_custom_mac = 0;
13370 /* Shut up coverity */
13371 memset (hwaddr, 0, sizeof (hwaddr));
13373 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13375 if (unformat (i, "socket %s", &file_name))
13379 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13381 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13382 use_custom_mac = 1;
13383 else if (unformat (i, "server"))
13385 else if (unformat (i, "tag %s", &tag))
13391 if (file_name_set == 0)
13393 errmsg ("missing socket file name");
13397 if (vec_len (file_name) > 255)
13399 errmsg ("socket file name too long");
13402 vec_add1 (file_name, 0);
13404 M (CREATE_VHOST_USER_IF, mp);
13406 mp->is_server = is_server;
13407 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13408 vec_free (file_name);
13409 if (custom_dev_instance != ~0)
13412 mp->custom_dev_instance = ntohl (custom_dev_instance);
13414 mp->use_custom_mac = use_custom_mac;
13415 clib_memcpy (mp->mac_address, hwaddr, 6);
13417 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13426 api_modify_vhost_user_if (vat_main_t * vam)
13428 unformat_input_t *i = vam->input;
13429 vl_api_modify_vhost_user_if_t *mp;
13432 u8 file_name_set = 0;
13433 u32 custom_dev_instance = ~0;
13434 u8 sw_if_index_set = 0;
13435 u32 sw_if_index = (u32) ~ 0;
13438 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13440 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13441 sw_if_index_set = 1;
13442 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13443 sw_if_index_set = 1;
13444 else if (unformat (i, "socket %s", &file_name))
13448 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13450 else if (unformat (i, "server"))
13456 if (sw_if_index_set == 0)
13458 errmsg ("missing sw_if_index or interface name");
13462 if (file_name_set == 0)
13464 errmsg ("missing socket file name");
13468 if (vec_len (file_name) > 255)
13470 errmsg ("socket file name too long");
13473 vec_add1 (file_name, 0);
13475 M (MODIFY_VHOST_USER_IF, mp);
13477 mp->sw_if_index = ntohl (sw_if_index);
13478 mp->is_server = is_server;
13479 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13480 vec_free (file_name);
13481 if (custom_dev_instance != ~0)
13484 mp->custom_dev_instance = ntohl (custom_dev_instance);
13493 api_delete_vhost_user_if (vat_main_t * vam)
13495 unformat_input_t *i = vam->input;
13496 vl_api_delete_vhost_user_if_t *mp;
13497 u32 sw_if_index = ~0;
13498 u8 sw_if_index_set = 0;
13501 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13503 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13504 sw_if_index_set = 1;
13505 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13506 sw_if_index_set = 1;
13511 if (sw_if_index_set == 0)
13513 errmsg ("missing sw_if_index or interface name");
13518 M (DELETE_VHOST_USER_IF, mp);
13520 mp->sw_if_index = ntohl (sw_if_index);
13527 static void vl_api_sw_interface_vhost_user_details_t_handler
13528 (vl_api_sw_interface_vhost_user_details_t * mp)
13530 vat_main_t *vam = &vat_main;
13532 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13533 (char *) mp->interface_name,
13534 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13535 clib_net_to_host_u64 (mp->features), mp->is_server,
13536 ntohl (mp->num_regions), (char *) mp->sock_filename);
13537 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13540 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13541 (vl_api_sw_interface_vhost_user_details_t * mp)
13543 vat_main_t *vam = &vat_main;
13544 vat_json_node_t *node = NULL;
13546 if (VAT_JSON_ARRAY != vam->json_tree.type)
13548 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13549 vat_json_init_array (&vam->json_tree);
13551 node = vat_json_array_add (&vam->json_tree);
13553 vat_json_init_object (node);
13554 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13555 vat_json_object_add_string_copy (node, "interface_name",
13556 mp->interface_name);
13557 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13558 ntohl (mp->virtio_net_hdr_sz));
13559 vat_json_object_add_uint (node, "features",
13560 clib_net_to_host_u64 (mp->features));
13561 vat_json_object_add_uint (node, "is_server", mp->is_server);
13562 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13563 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13564 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13568 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13570 vl_api_sw_interface_vhost_user_dump_t *mp;
13571 vl_api_control_ping_t *mp_ping;
13574 "Interface name idx hdr_sz features server regions filename");
13576 /* Get list of vhost-user interfaces */
13577 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13580 /* Use a control ping for synchronization */
13581 MPING (CONTROL_PING, mp_ping);
13589 api_show_version (vat_main_t * vam)
13591 vl_api_show_version_t *mp;
13594 M (SHOW_VERSION, mp);
13603 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13605 unformat_input_t *line_input = vam->input;
13606 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13607 ip4_address_t local4, remote4;
13608 ip6_address_t local6, remote6;
13610 u8 ipv4_set = 0, ipv6_set = 0;
13614 u32 mcast_sw_if_index = ~0;
13615 u32 encap_vrf_id = 0;
13616 u32 decap_vrf_id = 0;
13622 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13623 memset (&local4, 0, sizeof local4);
13624 memset (&remote4, 0, sizeof remote4);
13625 memset (&local6, 0, sizeof local6);
13626 memset (&remote6, 0, sizeof remote6);
13628 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13630 if (unformat (line_input, "del"))
13632 else if (unformat (line_input, "local %U",
13633 unformat_ip4_address, &local4))
13638 else if (unformat (line_input, "remote %U",
13639 unformat_ip4_address, &remote4))
13644 else if (unformat (line_input, "local %U",
13645 unformat_ip6_address, &local6))
13650 else if (unformat (line_input, "remote %U",
13651 unformat_ip6_address, &remote6))
13656 else if (unformat (line_input, "group %U %U",
13657 unformat_ip4_address, &remote4,
13658 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13660 grp_set = remote_set = 1;
13663 else if (unformat (line_input, "group %U",
13664 unformat_ip4_address, &remote4))
13666 grp_set = remote_set = 1;
13669 else if (unformat (line_input, "group %U %U",
13670 unformat_ip6_address, &remote6,
13671 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13673 grp_set = remote_set = 1;
13676 else if (unformat (line_input, "group %U",
13677 unformat_ip6_address, &remote6))
13679 grp_set = remote_set = 1;
13683 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13685 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13687 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13689 else if (unformat (line_input, "vni %d", &vni))
13691 else if (unformat (line_input, "next-ip4"))
13693 else if (unformat (line_input, "next-ip6"))
13695 else if (unformat (line_input, "next-ethernet"))
13697 else if (unformat (line_input, "next-nsh"))
13701 errmsg ("parse error '%U'", format_unformat_error, line_input);
13706 if (local_set == 0)
13708 errmsg ("tunnel local address not specified");
13711 if (remote_set == 0)
13713 errmsg ("tunnel remote address not specified");
13716 if (grp_set && mcast_sw_if_index == ~0)
13718 errmsg ("tunnel nonexistent multicast device");
13721 if (ipv4_set && ipv6_set)
13723 errmsg ("both IPv4 and IPv6 addresses specified");
13729 errmsg ("vni not specified");
13733 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13738 clib_memcpy (&mp->local, &local6, sizeof (local6));
13739 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13743 clib_memcpy (&mp->local, &local4, sizeof (local4));
13744 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13747 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13748 mp->encap_vrf_id = ntohl (encap_vrf_id);
13749 mp->decap_vrf_id = ntohl (decap_vrf_id);
13750 mp->protocol = protocol;
13751 mp->vni = ntohl (vni);
13752 mp->is_add = is_add;
13753 mp->is_ipv6 = ipv6_set;
13760 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13761 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13763 vat_main_t *vam = &vat_main;
13764 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13765 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13767 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13768 ntohl (mp->sw_if_index),
13769 format_ip46_address, &local, IP46_TYPE_ANY,
13770 format_ip46_address, &remote, IP46_TYPE_ANY,
13771 ntohl (mp->vni), mp->protocol,
13772 ntohl (mp->mcast_sw_if_index),
13773 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13777 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13778 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13780 vat_main_t *vam = &vat_main;
13781 vat_json_node_t *node = NULL;
13782 struct in_addr ip4;
13783 struct in6_addr ip6;
13785 if (VAT_JSON_ARRAY != vam->json_tree.type)
13787 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13788 vat_json_init_array (&vam->json_tree);
13790 node = vat_json_array_add (&vam->json_tree);
13792 vat_json_init_object (node);
13793 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13796 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13797 vat_json_object_add_ip6 (node, "local", ip6);
13798 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13799 vat_json_object_add_ip6 (node, "remote", ip6);
13803 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13804 vat_json_object_add_ip4 (node, "local", ip4);
13805 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13806 vat_json_object_add_ip4 (node, "remote", ip4);
13808 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13809 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13810 vat_json_object_add_uint (node, "mcast_sw_if_index",
13811 ntohl (mp->mcast_sw_if_index));
13812 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13813 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13814 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13818 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13820 unformat_input_t *i = vam->input;
13821 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13822 vl_api_control_ping_t *mp_ping;
13824 u8 sw_if_index_set = 0;
13827 /* Parse args required to build the message */
13828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13830 if (unformat (i, "sw_if_index %d", &sw_if_index))
13831 sw_if_index_set = 1;
13836 if (sw_if_index_set == 0)
13841 if (!vam->json_output)
13843 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13844 "sw_if_index", "local", "remote", "vni",
13845 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13848 /* Get list of vxlan-tunnel interfaces */
13849 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13851 mp->sw_if_index = htonl (sw_if_index);
13855 /* Use a control ping for synchronization */
13856 MPING (CONTROL_PING, mp_ping);
13863 static void vl_api_l2_fib_table_details_t_handler
13864 (vl_api_l2_fib_table_details_t * mp)
13866 vat_main_t *vam = &vat_main;
13868 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13870 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
13871 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13875 static void vl_api_l2_fib_table_details_t_handler_json
13876 (vl_api_l2_fib_table_details_t * mp)
13878 vat_main_t *vam = &vat_main;
13879 vat_json_node_t *node = NULL;
13881 if (VAT_JSON_ARRAY != vam->json_tree.type)
13883 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13884 vat_json_init_array (&vam->json_tree);
13886 node = vat_json_array_add (&vam->json_tree);
13888 vat_json_init_object (node);
13889 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13890 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
13891 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13892 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13893 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13894 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13898 api_l2_fib_table_dump (vat_main_t * vam)
13900 unformat_input_t *i = vam->input;
13901 vl_api_l2_fib_table_dump_t *mp;
13902 vl_api_control_ping_t *mp_ping;
13907 /* Parse args required to build the message */
13908 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13910 if (unformat (i, "bd_id %d", &bd_id))
13916 if (bd_id_set == 0)
13918 errmsg ("missing bridge domain");
13922 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13924 /* Get list of l2 fib entries */
13925 M (L2_FIB_TABLE_DUMP, mp);
13927 mp->bd_id = ntohl (bd_id);
13930 /* Use a control ping for synchronization */
13931 MPING (CONTROL_PING, mp_ping);
13940 api_interface_name_renumber (vat_main_t * vam)
13942 unformat_input_t *line_input = vam->input;
13943 vl_api_interface_name_renumber_t *mp;
13944 u32 sw_if_index = ~0;
13945 u32 new_show_dev_instance = ~0;
13948 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13950 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13953 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13955 else if (unformat (line_input, "new_show_dev_instance %d",
13956 &new_show_dev_instance))
13962 if (sw_if_index == ~0)
13964 errmsg ("missing interface name or sw_if_index");
13968 if (new_show_dev_instance == ~0)
13970 errmsg ("missing new_show_dev_instance");
13974 M (INTERFACE_NAME_RENUMBER, mp);
13976 mp->sw_if_index = ntohl (sw_if_index);
13977 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13985 api_want_ip4_arp_events (vat_main_t * vam)
13987 unformat_input_t *line_input = vam->input;
13988 vl_api_want_ip4_arp_events_t *mp;
13989 ip4_address_t address;
13990 int address_set = 0;
13991 u32 enable_disable = 1;
13994 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13996 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
13998 else if (unformat (line_input, "del"))
13999 enable_disable = 0;
14004 if (address_set == 0)
14006 errmsg ("missing addresses");
14010 M (WANT_IP4_ARP_EVENTS, mp);
14011 mp->enable_disable = enable_disable;
14012 mp->pid = htonl (getpid ());
14013 mp->address = address.as_u32;
14021 api_want_ip6_nd_events (vat_main_t * vam)
14023 unformat_input_t *line_input = vam->input;
14024 vl_api_want_ip6_nd_events_t *mp;
14025 ip6_address_t address;
14026 int address_set = 0;
14027 u32 enable_disable = 1;
14030 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14032 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
14034 else if (unformat (line_input, "del"))
14035 enable_disable = 0;
14040 if (address_set == 0)
14042 errmsg ("missing addresses");
14046 M (WANT_IP6_ND_EVENTS, mp);
14047 mp->enable_disable = enable_disable;
14048 mp->pid = htonl (getpid ());
14049 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
14057 api_want_l2_macs_events (vat_main_t * vam)
14059 unformat_input_t *line_input = vam->input;
14060 vl_api_want_l2_macs_events_t *mp;
14061 u8 enable_disable = 1;
14062 u32 scan_delay = 0;
14063 u32 max_macs_in_event = 0;
14064 u32 learn_limit = 0;
14067 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14069 if (unformat (line_input, "learn-limit %d", &learn_limit))
14071 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14073 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14075 else if (unformat (line_input, "disable"))
14076 enable_disable = 0;
14081 M (WANT_L2_MACS_EVENTS, mp);
14082 mp->enable_disable = enable_disable;
14083 mp->pid = htonl (getpid ());
14084 mp->learn_limit = htonl (learn_limit);
14085 mp->scan_delay = (u8) scan_delay;
14086 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14093 api_input_acl_set_interface (vat_main_t * vam)
14095 unformat_input_t *i = vam->input;
14096 vl_api_input_acl_set_interface_t *mp;
14098 int sw_if_index_set;
14099 u32 ip4_table_index = ~0;
14100 u32 ip6_table_index = ~0;
14101 u32 l2_table_index = ~0;
14105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14107 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14108 sw_if_index_set = 1;
14109 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14110 sw_if_index_set = 1;
14111 else if (unformat (i, "del"))
14113 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14115 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14117 else if (unformat (i, "l2-table %d", &l2_table_index))
14121 clib_warning ("parse error '%U'", format_unformat_error, i);
14126 if (sw_if_index_set == 0)
14128 errmsg ("missing interface name or sw_if_index");
14132 M (INPUT_ACL_SET_INTERFACE, mp);
14134 mp->sw_if_index = ntohl (sw_if_index);
14135 mp->ip4_table_index = ntohl (ip4_table_index);
14136 mp->ip6_table_index = ntohl (ip6_table_index);
14137 mp->l2_table_index = ntohl (l2_table_index);
14138 mp->is_add = is_add;
14146 api_ip_address_dump (vat_main_t * vam)
14148 unformat_input_t *i = vam->input;
14149 vl_api_ip_address_dump_t *mp;
14150 vl_api_control_ping_t *mp_ping;
14151 u32 sw_if_index = ~0;
14152 u8 sw_if_index_set = 0;
14157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14159 if (unformat (i, "sw_if_index %d", &sw_if_index))
14160 sw_if_index_set = 1;
14162 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14163 sw_if_index_set = 1;
14164 else if (unformat (i, "ipv4"))
14166 else if (unformat (i, "ipv6"))
14172 if (ipv4_set && ipv6_set)
14174 errmsg ("ipv4 and ipv6 flags cannot be both set");
14178 if ((!ipv4_set) && (!ipv6_set))
14180 errmsg ("no ipv4 nor ipv6 flag set");
14184 if (sw_if_index_set == 0)
14186 errmsg ("missing interface name or sw_if_index");
14190 vam->current_sw_if_index = sw_if_index;
14191 vam->is_ipv6 = ipv6_set;
14193 M (IP_ADDRESS_DUMP, mp);
14194 mp->sw_if_index = ntohl (sw_if_index);
14195 mp->is_ipv6 = ipv6_set;
14198 /* Use a control ping for synchronization */
14199 MPING (CONTROL_PING, mp_ping);
14207 api_ip_dump (vat_main_t * vam)
14209 vl_api_ip_dump_t *mp;
14210 vl_api_control_ping_t *mp_ping;
14211 unformat_input_t *in = vam->input;
14218 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14220 if (unformat (in, "ipv4"))
14222 else if (unformat (in, "ipv6"))
14228 if (ipv4_set && ipv6_set)
14230 errmsg ("ipv4 and ipv6 flags cannot be both set");
14234 if ((!ipv4_set) && (!ipv6_set))
14236 errmsg ("no ipv4 nor ipv6 flag set");
14240 is_ipv6 = ipv6_set;
14241 vam->is_ipv6 = is_ipv6;
14243 /* free old data */
14244 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14246 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14248 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14251 mp->is_ipv6 = ipv6_set;
14254 /* Use a control ping for synchronization */
14255 MPING (CONTROL_PING, mp_ping);
14263 api_ipsec_spd_add_del (vat_main_t * vam)
14265 unformat_input_t *i = vam->input;
14266 vl_api_ipsec_spd_add_del_t *mp;
14271 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14273 if (unformat (i, "spd_id %d", &spd_id))
14275 else if (unformat (i, "del"))
14279 clib_warning ("parse error '%U'", format_unformat_error, i);
14285 errmsg ("spd_id must be set");
14289 M (IPSEC_SPD_ADD_DEL, mp);
14291 mp->spd_id = ntohl (spd_id);
14292 mp->is_add = is_add;
14300 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14302 unformat_input_t *i = vam->input;
14303 vl_api_ipsec_interface_add_del_spd_t *mp;
14305 u8 sw_if_index_set = 0;
14306 u32 spd_id = (u32) ~ 0;
14310 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14312 if (unformat (i, "del"))
14314 else if (unformat (i, "spd_id %d", &spd_id))
14317 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14318 sw_if_index_set = 1;
14319 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14320 sw_if_index_set = 1;
14323 clib_warning ("parse error '%U'", format_unformat_error, i);
14329 if (spd_id == (u32) ~ 0)
14331 errmsg ("spd_id must be set");
14335 if (sw_if_index_set == 0)
14337 errmsg ("missing interface name or sw_if_index");
14341 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14343 mp->spd_id = ntohl (spd_id);
14344 mp->sw_if_index = ntohl (sw_if_index);
14345 mp->is_add = is_add;
14353 api_ipsec_spd_add_del_entry (vat_main_t * vam)
14355 unformat_input_t *i = vam->input;
14356 vl_api_ipsec_spd_add_del_entry_t *mp;
14357 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
14358 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14360 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14361 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14362 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
14363 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
14366 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
14367 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
14368 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
14369 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
14370 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
14371 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
14373 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14375 if (unformat (i, "del"))
14377 if (unformat (i, "outbound"))
14379 if (unformat (i, "inbound"))
14381 else if (unformat (i, "spd_id %d", &spd_id))
14383 else if (unformat (i, "sa_id %d", &sa_id))
14385 else if (unformat (i, "priority %d", &priority))
14387 else if (unformat (i, "protocol %d", &protocol))
14389 else if (unformat (i, "lport_start %d", &lport_start))
14391 else if (unformat (i, "lport_stop %d", &lport_stop))
14393 else if (unformat (i, "rport_start %d", &rport_start))
14395 else if (unformat (i, "rport_stop %d", &rport_stop))
14399 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
14405 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
14412 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
14418 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
14425 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
14431 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
14438 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
14444 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
14450 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14452 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14454 clib_warning ("unsupported action: 'resolve'");
14460 clib_warning ("parse error '%U'", format_unformat_error, i);
14466 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
14468 mp->spd_id = ntohl (spd_id);
14469 mp->priority = ntohl (priority);
14470 mp->is_outbound = is_outbound;
14472 mp->is_ipv6 = is_ipv6;
14473 if (is_ipv6 || is_ip_any)
14475 clib_memcpy (mp->remote_address_start, &raddr6_start,
14476 sizeof (ip6_address_t));
14477 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
14478 sizeof (ip6_address_t));
14479 clib_memcpy (mp->local_address_start, &laddr6_start,
14480 sizeof (ip6_address_t));
14481 clib_memcpy (mp->local_address_stop, &laddr6_stop,
14482 sizeof (ip6_address_t));
14486 clib_memcpy (mp->remote_address_start, &raddr4_start,
14487 sizeof (ip4_address_t));
14488 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
14489 sizeof (ip4_address_t));
14490 clib_memcpy (mp->local_address_start, &laddr4_start,
14491 sizeof (ip4_address_t));
14492 clib_memcpy (mp->local_address_stop, &laddr4_stop,
14493 sizeof (ip4_address_t));
14495 mp->protocol = (u8) protocol;
14496 mp->local_port_start = ntohs ((u16) lport_start);
14497 mp->local_port_stop = ntohs ((u16) lport_stop);
14498 mp->remote_port_start = ntohs ((u16) rport_start);
14499 mp->remote_port_stop = ntohs ((u16) rport_stop);
14500 mp->policy = (u8) policy;
14501 mp->sa_id = ntohl (sa_id);
14502 mp->is_add = is_add;
14503 mp->is_ip_any = is_ip_any;
14510 api_ipsec_sad_add_del_entry (vat_main_t * vam)
14512 unformat_input_t *i = vam->input;
14513 vl_api_ipsec_sad_add_del_entry_t *mp;
14514 u32 sad_id = 0, spi = 0;
14515 u8 *ck = 0, *ik = 0;
14518 u8 protocol = IPSEC_PROTOCOL_AH;
14519 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
14520 u32 crypto_alg = 0, integ_alg = 0;
14521 ip4_address_t tun_src4;
14522 ip4_address_t tun_dst4;
14523 ip6_address_t tun_src6;
14524 ip6_address_t tun_dst6;
14527 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14529 if (unformat (i, "del"))
14531 else if (unformat (i, "sad_id %d", &sad_id))
14533 else if (unformat (i, "spi %d", &spi))
14535 else if (unformat (i, "esp"))
14536 protocol = IPSEC_PROTOCOL_ESP;
14537 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
14540 is_tunnel_ipv6 = 0;
14542 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
14545 is_tunnel_ipv6 = 0;
14547 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
14550 is_tunnel_ipv6 = 1;
14552 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
14555 is_tunnel_ipv6 = 1;
14559 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14561 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14562 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14564 clib_warning ("unsupported crypto-alg: '%U'",
14565 format_ipsec_crypto_alg, crypto_alg);
14569 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14573 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14575 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14576 integ_alg >= IPSEC_INTEG_N_ALG)
14578 clib_warning ("unsupported integ-alg: '%U'",
14579 format_ipsec_integ_alg, integ_alg);
14583 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14587 clib_warning ("parse error '%U'", format_unformat_error, i);
14593 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
14595 mp->sad_id = ntohl (sad_id);
14596 mp->is_add = is_add;
14597 mp->protocol = protocol;
14598 mp->spi = ntohl (spi);
14599 mp->is_tunnel = is_tunnel;
14600 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
14601 mp->crypto_algorithm = crypto_alg;
14602 mp->integrity_algorithm = integ_alg;
14603 mp->crypto_key_length = vec_len (ck);
14604 mp->integrity_key_length = vec_len (ik);
14606 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14607 mp->crypto_key_length = sizeof (mp->crypto_key);
14609 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14610 mp->integrity_key_length = sizeof (mp->integrity_key);
14613 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14615 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14619 if (is_tunnel_ipv6)
14621 clib_memcpy (mp->tunnel_src_address, &tun_src6,
14622 sizeof (ip6_address_t));
14623 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
14624 sizeof (ip6_address_t));
14628 clib_memcpy (mp->tunnel_src_address, &tun_src4,
14629 sizeof (ip4_address_t));
14630 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
14631 sizeof (ip4_address_t));
14641 api_ipsec_sa_set_key (vat_main_t * vam)
14643 unformat_input_t *i = vam->input;
14644 vl_api_ipsec_sa_set_key_t *mp;
14646 u8 *ck = 0, *ik = 0;
14649 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14651 if (unformat (i, "sa_id %d", &sa_id))
14653 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14655 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14659 clib_warning ("parse error '%U'", format_unformat_error, i);
14664 M (IPSEC_SA_SET_KEY, mp);
14666 mp->sa_id = ntohl (sa_id);
14667 mp->crypto_key_length = vec_len (ck);
14668 mp->integrity_key_length = vec_len (ik);
14670 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14671 mp->crypto_key_length = sizeof (mp->crypto_key);
14673 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14674 mp->integrity_key_length = sizeof (mp->integrity_key);
14677 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14679 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14687 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14689 unformat_input_t *i = vam->input;
14690 vl_api_ipsec_tunnel_if_add_del_t *mp;
14691 u32 local_spi = 0, remote_spi = 0;
14692 u32 crypto_alg = 0, integ_alg = 0;
14693 u8 *lck = NULL, *rck = NULL;
14694 u8 *lik = NULL, *rik = NULL;
14695 ip4_address_t local_ip = { {0} };
14696 ip4_address_t remote_ip = { {0} };
14699 u8 anti_replay = 0;
14702 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14704 if (unformat (i, "del"))
14706 else if (unformat (i, "esn"))
14708 else if (unformat (i, "anti_replay"))
14710 else if (unformat (i, "local_spi %d", &local_spi))
14712 else if (unformat (i, "remote_spi %d", &remote_spi))
14714 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
14716 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
14718 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14721 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14723 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14725 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14729 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14731 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14732 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14734 errmsg ("unsupported crypto-alg: '%U'\n",
14735 format_ipsec_crypto_alg, crypto_alg);
14741 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14743 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14744 integ_alg >= IPSEC_INTEG_N_ALG)
14746 errmsg ("unsupported integ-alg: '%U'\n",
14747 format_ipsec_integ_alg, integ_alg);
14753 errmsg ("parse error '%U'\n", format_unformat_error, i);
14758 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14760 mp->is_add = is_add;
14762 mp->anti_replay = anti_replay;
14764 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
14765 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
14767 mp->local_spi = htonl (local_spi);
14768 mp->remote_spi = htonl (remote_spi);
14769 mp->crypto_alg = (u8) crypto_alg;
14771 mp->local_crypto_key_len = 0;
14774 mp->local_crypto_key_len = vec_len (lck);
14775 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14776 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14777 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14780 mp->remote_crypto_key_len = 0;
14783 mp->remote_crypto_key_len = vec_len (rck);
14784 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14785 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14786 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14789 mp->integ_alg = (u8) integ_alg;
14791 mp->local_integ_key_len = 0;
14794 mp->local_integ_key_len = vec_len (lik);
14795 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14796 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14797 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14800 mp->remote_integ_key_len = 0;
14803 mp->remote_integ_key_len = vec_len (rik);
14804 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14805 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14806 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14815 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14817 vat_main_t *vam = &vat_main;
14819 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14820 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
14821 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
14822 "tunnel_src_addr %U tunnel_dst_addr %U "
14823 "salt %u seq_outbound %lu last_seq_inbound %lu "
14824 "replay_window %lu total_data_size %lu\n",
14825 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
14827 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
14828 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
14829 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
14830 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14831 mp->tunnel_src_addr,
14832 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14833 mp->tunnel_dst_addr,
14835 clib_net_to_host_u64 (mp->seq_outbound),
14836 clib_net_to_host_u64 (mp->last_seq_inbound),
14837 clib_net_to_host_u64 (mp->replay_window),
14838 clib_net_to_host_u64 (mp->total_data_size));
14841 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14842 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14844 static void vl_api_ipsec_sa_details_t_handler_json
14845 (vl_api_ipsec_sa_details_t * mp)
14847 vat_main_t *vam = &vat_main;
14848 vat_json_node_t *node = NULL;
14849 struct in_addr src_ip4, dst_ip4;
14850 struct in6_addr src_ip6, dst_ip6;
14852 if (VAT_JSON_ARRAY != vam->json_tree.type)
14854 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14855 vat_json_init_array (&vam->json_tree);
14857 node = vat_json_array_add (&vam->json_tree);
14859 vat_json_init_object (node);
14860 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
14861 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14862 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
14863 vat_json_object_add_uint (node, "proto", mp->protocol);
14864 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
14865 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
14866 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
14867 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
14868 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
14869 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
14870 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
14871 mp->crypto_key_len);
14872 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
14873 mp->integ_key_len);
14874 if (mp->is_tunnel_ip6)
14876 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
14877 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
14878 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
14879 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
14883 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
14884 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
14885 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
14886 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
14888 vat_json_object_add_uint (node, "replay_window",
14889 clib_net_to_host_u64 (mp->replay_window));
14890 vat_json_object_add_uint (node, "total_data_size",
14891 clib_net_to_host_u64 (mp->total_data_size));
14896 api_ipsec_sa_dump (vat_main_t * vam)
14898 unformat_input_t *i = vam->input;
14899 vl_api_ipsec_sa_dump_t *mp;
14900 vl_api_control_ping_t *mp_ping;
14904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14906 if (unformat (i, "sa_id %d", &sa_id))
14910 clib_warning ("parse error '%U'", format_unformat_error, i);
14915 M (IPSEC_SA_DUMP, mp);
14917 mp->sa_id = ntohl (sa_id);
14921 /* Use a control ping for synchronization */
14922 M (CONTROL_PING, mp_ping);
14930 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
14932 unformat_input_t *i = vam->input;
14933 vl_api_ipsec_tunnel_if_set_key_t *mp;
14934 u32 sw_if_index = ~0;
14935 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
14940 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14942 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14945 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
14946 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
14948 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
14949 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
14950 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
14951 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
14953 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
14954 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
14955 else if (unformat (i, "%U", unformat_hex_string, &key))
14959 clib_warning ("parse error '%U'", format_unformat_error, i);
14964 if (sw_if_index == ~0)
14966 errmsg ("interface must be specified");
14970 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
14972 errmsg ("key type must be specified");
14978 errmsg ("algorithm must be specified");
14982 if (vec_len (key) == 0)
14984 errmsg ("key must be specified");
14988 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
14990 mp->sw_if_index = htonl (sw_if_index);
14992 mp->key_type = key_type;
14993 mp->key_len = vec_len (key);
14994 clib_memcpy (mp->key, key, vec_len (key));
15003 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15005 unformat_input_t *i = vam->input;
15006 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15007 u32 sw_if_index = ~0;
15009 u8 is_outbound = (u8) ~ 0;
15012 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15014 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15016 else if (unformat (i, "sa_id %d", &sa_id))
15018 else if (unformat (i, "outbound"))
15020 else if (unformat (i, "inbound"))
15024 clib_warning ("parse error '%U'", format_unformat_error, i);
15029 if (sw_if_index == ~0)
15031 errmsg ("interface must be specified");
15037 errmsg ("SA ID must be specified");
15041 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15043 mp->sw_if_index = htonl (sw_if_index);
15044 mp->sa_id = htonl (sa_id);
15045 mp->is_outbound = is_outbound;
15054 api_ikev2_profile_add_del (vat_main_t * vam)
15056 unformat_input_t *i = vam->input;
15057 vl_api_ikev2_profile_add_del_t *mp;
15062 const char *valid_chars = "a-zA-Z0-9_";
15064 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15066 if (unformat (i, "del"))
15068 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15069 vec_add1 (name, 0);
15072 errmsg ("parse error '%U'", format_unformat_error, i);
15077 if (!vec_len (name))
15079 errmsg ("profile name must be specified");
15083 if (vec_len (name) > 64)
15085 errmsg ("profile name too long");
15089 M (IKEV2_PROFILE_ADD_DEL, mp);
15091 clib_memcpy (mp->name, name, vec_len (name));
15092 mp->is_add = is_add;
15101 api_ikev2_profile_set_auth (vat_main_t * vam)
15103 unformat_input_t *i = vam->input;
15104 vl_api_ikev2_profile_set_auth_t *mp;
15107 u32 auth_method = 0;
15111 const char *valid_chars = "a-zA-Z0-9_";
15113 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15115 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15116 vec_add1 (name, 0);
15117 else if (unformat (i, "auth_method %U",
15118 unformat_ikev2_auth_method, &auth_method))
15120 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
15122 else if (unformat (i, "auth_data %v", &data))
15126 errmsg ("parse error '%U'", format_unformat_error, i);
15131 if (!vec_len (name))
15133 errmsg ("profile name must be specified");
15137 if (vec_len (name) > 64)
15139 errmsg ("profile name too long");
15143 if (!vec_len (data))
15145 errmsg ("auth_data must be specified");
15151 errmsg ("auth_method must be specified");
15155 M (IKEV2_PROFILE_SET_AUTH, mp);
15157 mp->is_hex = is_hex;
15158 mp->auth_method = (u8) auth_method;
15159 mp->data_len = vec_len (data);
15160 clib_memcpy (mp->name, name, vec_len (name));
15161 clib_memcpy (mp->data, data, vec_len (data));
15171 api_ikev2_profile_set_id (vat_main_t * vam)
15173 unformat_input_t *i = vam->input;
15174 vl_api_ikev2_profile_set_id_t *mp;
15182 const char *valid_chars = "a-zA-Z0-9_";
15184 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15186 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15187 vec_add1 (name, 0);
15188 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
15190 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
15192 data = vec_new (u8, 4);
15193 clib_memcpy (data, ip4.as_u8, 4);
15195 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
15197 else if (unformat (i, "id_data %v", &data))
15199 else if (unformat (i, "local"))
15201 else if (unformat (i, "remote"))
15205 errmsg ("parse error '%U'", format_unformat_error, i);
15210 if (!vec_len (name))
15212 errmsg ("profile name must be specified");
15216 if (vec_len (name) > 64)
15218 errmsg ("profile name too long");
15222 if (!vec_len (data))
15224 errmsg ("id_data must be specified");
15230 errmsg ("id_type must be specified");
15234 M (IKEV2_PROFILE_SET_ID, mp);
15236 mp->is_local = is_local;
15237 mp->id_type = (u8) id_type;
15238 mp->data_len = vec_len (data);
15239 clib_memcpy (mp->name, name, vec_len (name));
15240 clib_memcpy (mp->data, data, vec_len (data));
15250 api_ikev2_profile_set_ts (vat_main_t * vam)
15252 unformat_input_t *i = vam->input;
15253 vl_api_ikev2_profile_set_ts_t *mp;
15256 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
15257 ip4_address_t start_addr, end_addr;
15259 const char *valid_chars = "a-zA-Z0-9_";
15262 start_addr.as_u32 = 0;
15263 end_addr.as_u32 = (u32) ~ 0;
15265 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15267 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15268 vec_add1 (name, 0);
15269 else if (unformat (i, "protocol %d", &proto))
15271 else if (unformat (i, "start_port %d", &start_port))
15273 else if (unformat (i, "end_port %d", &end_port))
15276 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
15278 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
15280 else if (unformat (i, "local"))
15282 else if (unformat (i, "remote"))
15286 errmsg ("parse error '%U'", format_unformat_error, i);
15291 if (!vec_len (name))
15293 errmsg ("profile name must be specified");
15297 if (vec_len (name) > 64)
15299 errmsg ("profile name too long");
15303 M (IKEV2_PROFILE_SET_TS, mp);
15305 mp->is_local = is_local;
15306 mp->proto = (u8) proto;
15307 mp->start_port = (u16) start_port;
15308 mp->end_port = (u16) end_port;
15309 mp->start_addr = start_addr.as_u32;
15310 mp->end_addr = end_addr.as_u32;
15311 clib_memcpy (mp->name, name, vec_len (name));
15320 api_ikev2_set_local_key (vat_main_t * vam)
15322 unformat_input_t *i = vam->input;
15323 vl_api_ikev2_set_local_key_t *mp;
15327 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15329 if (unformat (i, "file %v", &file))
15330 vec_add1 (file, 0);
15333 errmsg ("parse error '%U'", format_unformat_error, i);
15338 if (!vec_len (file))
15340 errmsg ("RSA key file must be specified");
15344 if (vec_len (file) > 256)
15346 errmsg ("file name too long");
15350 M (IKEV2_SET_LOCAL_KEY, mp);
15352 clib_memcpy (mp->key_file, file, vec_len (file));
15361 api_ikev2_set_responder (vat_main_t * vam)
15363 unformat_input_t *i = vam->input;
15364 vl_api_ikev2_set_responder_t *mp;
15367 u32 sw_if_index = ~0;
15368 ip4_address_t address;
15370 const char *valid_chars = "a-zA-Z0-9_";
15372 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15375 (i, "%U interface %d address %U", unformat_token, valid_chars,
15376 &name, &sw_if_index, unformat_ip4_address, &address))
15377 vec_add1 (name, 0);
15380 errmsg ("parse error '%U'", format_unformat_error, i);
15385 if (!vec_len (name))
15387 errmsg ("profile name must be specified");
15391 if (vec_len (name) > 64)
15393 errmsg ("profile name too long");
15397 M (IKEV2_SET_RESPONDER, mp);
15399 clib_memcpy (mp->name, name, vec_len (name));
15402 mp->sw_if_index = sw_if_index;
15403 clib_memcpy (mp->address, &address, sizeof (address));
15411 api_ikev2_set_ike_transforms (vat_main_t * vam)
15413 unformat_input_t *i = vam->input;
15414 vl_api_ikev2_set_ike_transforms_t *mp;
15417 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15419 const char *valid_chars = "a-zA-Z0-9_";
15421 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15423 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15424 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15425 vec_add1 (name, 0);
15428 errmsg ("parse error '%U'", format_unformat_error, i);
15433 if (!vec_len (name))
15435 errmsg ("profile name must be specified");
15439 if (vec_len (name) > 64)
15441 errmsg ("profile name too long");
15445 M (IKEV2_SET_IKE_TRANSFORMS, mp);
15447 clib_memcpy (mp->name, name, vec_len (name));
15449 mp->crypto_alg = crypto_alg;
15450 mp->crypto_key_size = crypto_key_size;
15451 mp->integ_alg = integ_alg;
15452 mp->dh_group = dh_group;
15461 api_ikev2_set_esp_transforms (vat_main_t * vam)
15463 unformat_input_t *i = vam->input;
15464 vl_api_ikev2_set_esp_transforms_t *mp;
15467 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15469 const char *valid_chars = "a-zA-Z0-9_";
15471 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15473 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15474 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15475 vec_add1 (name, 0);
15478 errmsg ("parse error '%U'", format_unformat_error, i);
15483 if (!vec_len (name))
15485 errmsg ("profile name must be specified");
15489 if (vec_len (name) > 64)
15491 errmsg ("profile name too long");
15495 M (IKEV2_SET_ESP_TRANSFORMS, mp);
15497 clib_memcpy (mp->name, name, vec_len (name));
15499 mp->crypto_alg = crypto_alg;
15500 mp->crypto_key_size = crypto_key_size;
15501 mp->integ_alg = integ_alg;
15502 mp->dh_group = dh_group;
15510 api_ikev2_set_sa_lifetime (vat_main_t * vam)
15512 unformat_input_t *i = vam->input;
15513 vl_api_ikev2_set_sa_lifetime_t *mp;
15516 u64 lifetime, lifetime_maxdata;
15517 u32 lifetime_jitter, handover;
15519 const char *valid_chars = "a-zA-Z0-9_";
15521 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15523 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
15524 &lifetime, &lifetime_jitter, &handover,
15525 &lifetime_maxdata))
15526 vec_add1 (name, 0);
15529 errmsg ("parse error '%U'", format_unformat_error, i);
15534 if (!vec_len (name))
15536 errmsg ("profile name must be specified");
15540 if (vec_len (name) > 64)
15542 errmsg ("profile name too long");
15546 M (IKEV2_SET_SA_LIFETIME, mp);
15548 clib_memcpy (mp->name, name, vec_len (name));
15550 mp->lifetime = lifetime;
15551 mp->lifetime_jitter = lifetime_jitter;
15552 mp->handover = handover;
15553 mp->lifetime_maxdata = lifetime_maxdata;
15561 api_ikev2_initiate_sa_init (vat_main_t * vam)
15563 unformat_input_t *i = vam->input;
15564 vl_api_ikev2_initiate_sa_init_t *mp;
15568 const char *valid_chars = "a-zA-Z0-9_";
15570 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15572 if (unformat (i, "%U", unformat_token, valid_chars, &name))
15573 vec_add1 (name, 0);
15576 errmsg ("parse error '%U'", format_unformat_error, i);
15581 if (!vec_len (name))
15583 errmsg ("profile name must be specified");
15587 if (vec_len (name) > 64)
15589 errmsg ("profile name too long");
15593 M (IKEV2_INITIATE_SA_INIT, mp);
15595 clib_memcpy (mp->name, name, vec_len (name));
15604 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
15606 unformat_input_t *i = vam->input;
15607 vl_api_ikev2_initiate_del_ike_sa_t *mp;
15612 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15614 if (unformat (i, "%lx", &ispi))
15618 errmsg ("parse error '%U'", format_unformat_error, i);
15623 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
15633 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
15635 unformat_input_t *i = vam->input;
15636 vl_api_ikev2_initiate_del_child_sa_t *mp;
15641 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15643 if (unformat (i, "%x", &ispi))
15647 errmsg ("parse error '%U'", format_unformat_error, i);
15652 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
15662 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
15664 unformat_input_t *i = vam->input;
15665 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
15670 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15672 if (unformat (i, "%x", &ispi))
15676 errmsg ("parse error '%U'", format_unformat_error, i);
15681 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
15694 api_map_add_domain (vat_main_t * vam)
15696 unformat_input_t *i = vam->input;
15697 vl_api_map_add_domain_t *mp;
15699 ip4_address_t ip4_prefix;
15700 ip6_address_t ip6_prefix;
15701 ip6_address_t ip6_src;
15702 u32 num_m_args = 0;
15703 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
15704 0, psid_length = 0;
15705 u8 is_translation = 0;
15707 u32 ip6_src_len = 128;
15710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15712 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
15713 &ip4_prefix, &ip4_prefix_len))
15715 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
15716 &ip6_prefix, &ip6_prefix_len))
15720 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
15723 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
15725 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
15727 else if (unformat (i, "psid-offset %d", &psid_offset))
15729 else if (unformat (i, "psid-len %d", &psid_length))
15731 else if (unformat (i, "mtu %d", &mtu))
15733 else if (unformat (i, "map-t"))
15734 is_translation = 1;
15737 clib_warning ("parse error '%U'", format_unformat_error, i);
15742 if (num_m_args < 3)
15744 errmsg ("mandatory argument(s) missing");
15748 /* Construct the API message */
15749 M (MAP_ADD_DOMAIN, mp);
15751 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
15752 mp->ip4_prefix_len = ip4_prefix_len;
15754 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
15755 mp->ip6_prefix_len = ip6_prefix_len;
15757 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
15758 mp->ip6_src_prefix_len = ip6_src_len;
15760 mp->ea_bits_len = ea_bits_len;
15761 mp->psid_offset = psid_offset;
15762 mp->psid_length = psid_length;
15763 mp->is_translation = is_translation;
15764 mp->mtu = htons (mtu);
15769 /* Wait for a reply, return good/bad news */
15775 api_map_del_domain (vat_main_t * vam)
15777 unformat_input_t *i = vam->input;
15778 vl_api_map_del_domain_t *mp;
15780 u32 num_m_args = 0;
15784 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15786 if (unformat (i, "index %d", &index))
15790 clib_warning ("parse error '%U'", format_unformat_error, i);
15795 if (num_m_args != 1)
15797 errmsg ("mandatory argument(s) missing");
15801 /* Construct the API message */
15802 M (MAP_DEL_DOMAIN, mp);
15804 mp->index = ntohl (index);
15809 /* Wait for a reply, return good/bad news */
15815 api_map_add_del_rule (vat_main_t * vam)
15817 unformat_input_t *i = vam->input;
15818 vl_api_map_add_del_rule_t *mp;
15820 ip6_address_t ip6_dst;
15821 u32 num_m_args = 0, index, psid = 0;
15824 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15826 if (unformat (i, "index %d", &index))
15828 else if (unformat (i, "psid %d", &psid))
15830 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
15832 else if (unformat (i, "del"))
15838 clib_warning ("parse error '%U'", format_unformat_error, i);
15843 /* Construct the API message */
15844 M (MAP_ADD_DEL_RULE, mp);
15846 mp->index = ntohl (index);
15847 mp->is_add = is_add;
15848 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
15849 mp->psid = ntohs (psid);
15854 /* Wait for a reply, return good/bad news */
15860 api_map_domain_dump (vat_main_t * vam)
15862 vl_api_map_domain_dump_t *mp;
15863 vl_api_control_ping_t *mp_ping;
15866 /* Construct the API message */
15867 M (MAP_DOMAIN_DUMP, mp);
15872 /* Use a control ping for synchronization */
15873 MPING (CONTROL_PING, mp_ping);
15881 api_map_rule_dump (vat_main_t * vam)
15883 unformat_input_t *i = vam->input;
15884 vl_api_map_rule_dump_t *mp;
15885 vl_api_control_ping_t *mp_ping;
15886 u32 domain_index = ~0;
15889 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15891 if (unformat (i, "index %u", &domain_index))
15897 if (domain_index == ~0)
15899 clib_warning ("parse error: domain index expected");
15903 /* Construct the API message */
15904 M (MAP_RULE_DUMP, mp);
15906 mp->domain_index = htonl (domain_index);
15911 /* Use a control ping for synchronization */
15912 MPING (CONTROL_PING, mp_ping);
15919 static void vl_api_map_add_domain_reply_t_handler
15920 (vl_api_map_add_domain_reply_t * mp)
15922 vat_main_t *vam = &vat_main;
15923 i32 retval = ntohl (mp->retval);
15925 if (vam->async_mode)
15927 vam->async_errors += (retval < 0);
15931 vam->retval = retval;
15932 vam->result_ready = 1;
15936 static void vl_api_map_add_domain_reply_t_handler_json
15937 (vl_api_map_add_domain_reply_t * mp)
15939 vat_main_t *vam = &vat_main;
15940 vat_json_node_t node;
15942 vat_json_init_object (&node);
15943 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
15944 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
15946 vat_json_print (vam->ofp, &node);
15947 vat_json_free (&node);
15949 vam->retval = ntohl (mp->retval);
15950 vam->result_ready = 1;
15954 api_get_first_msg_id (vat_main_t * vam)
15956 vl_api_get_first_msg_id_t *mp;
15957 unformat_input_t *i = vam->input;
15962 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15964 if (unformat (i, "client %s", &name))
15972 errmsg ("missing client name");
15975 vec_add1 (name, 0);
15977 if (vec_len (name) > 63)
15979 errmsg ("client name too long");
15983 M (GET_FIRST_MSG_ID, mp);
15984 clib_memcpy (mp->name, name, vec_len (name));
15991 api_cop_interface_enable_disable (vat_main_t * vam)
15993 unformat_input_t *line_input = vam->input;
15994 vl_api_cop_interface_enable_disable_t *mp;
15995 u32 sw_if_index = ~0;
15996 u8 enable_disable = 1;
15999 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16001 if (unformat (line_input, "disable"))
16002 enable_disable = 0;
16003 if (unformat (line_input, "enable"))
16004 enable_disable = 1;
16005 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16006 vam, &sw_if_index))
16008 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16014 if (sw_if_index == ~0)
16016 errmsg ("missing interface name or sw_if_index");
16020 /* Construct the API message */
16021 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16022 mp->sw_if_index = ntohl (sw_if_index);
16023 mp->enable_disable = enable_disable;
16027 /* Wait for the reply */
16033 api_cop_whitelist_enable_disable (vat_main_t * vam)
16035 unformat_input_t *line_input = vam->input;
16036 vl_api_cop_whitelist_enable_disable_t *mp;
16037 u32 sw_if_index = ~0;
16038 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16042 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16044 if (unformat (line_input, "ip4"))
16046 else if (unformat (line_input, "ip6"))
16048 else if (unformat (line_input, "default"))
16050 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16051 vam, &sw_if_index))
16053 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16055 else if (unformat (line_input, "fib-id %d", &fib_id))
16061 if (sw_if_index == ~0)
16063 errmsg ("missing interface name or sw_if_index");
16067 /* Construct the API message */
16068 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16069 mp->sw_if_index = ntohl (sw_if_index);
16070 mp->fib_id = ntohl (fib_id);
16073 mp->default_cop = default_cop;
16077 /* Wait for the reply */
16083 api_get_node_graph (vat_main_t * vam)
16085 vl_api_get_node_graph_t *mp;
16088 M (GET_NODE_GRAPH, mp);
16092 /* Wait for the reply */
16098 /** Used for parsing LISP eids */
16099 typedef CLIB_PACKED(struct{
16100 u8 addr[16]; /**< eid address */
16101 u32 len; /**< prefix length if IP */
16102 u8 type; /**< type of eid */
16107 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16109 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16111 memset (a, 0, sizeof (a[0]));
16113 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16115 a->type = 0; /* ipv4 type */
16117 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16119 a->type = 1; /* ipv6 type */
16121 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16123 a->type = 2; /* mac type */
16125 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16127 a->type = 3; /* NSH type */
16128 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16129 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16136 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16145 lisp_eid_size_vat (u8 type)
16162 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16164 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16168 api_one_add_del_locator_set (vat_main_t * vam)
16170 unformat_input_t *input = vam->input;
16171 vl_api_one_add_del_locator_set_t *mp;
16173 u8 *locator_set_name = NULL;
16174 u8 locator_set_name_set = 0;
16175 vl_api_local_locator_t locator, *locators = 0;
16176 u32 sw_if_index, priority, weight;
16180 /* Parse args required to build the message */
16181 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16183 if (unformat (input, "del"))
16187 else if (unformat (input, "locator-set %s", &locator_set_name))
16189 locator_set_name_set = 1;
16191 else if (unformat (input, "sw_if_index %u p %u w %u",
16192 &sw_if_index, &priority, &weight))
16194 locator.sw_if_index = htonl (sw_if_index);
16195 locator.priority = priority;
16196 locator.weight = weight;
16197 vec_add1 (locators, locator);
16201 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16202 &sw_if_index, &priority, &weight))
16204 locator.sw_if_index = htonl (sw_if_index);
16205 locator.priority = priority;
16206 locator.weight = weight;
16207 vec_add1 (locators, locator);
16213 if (locator_set_name_set == 0)
16215 errmsg ("missing locator-set name");
16216 vec_free (locators);
16220 if (vec_len (locator_set_name) > 64)
16222 errmsg ("locator-set name too long");
16223 vec_free (locator_set_name);
16224 vec_free (locators);
16227 vec_add1 (locator_set_name, 0);
16229 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
16231 /* Construct the API message */
16232 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
16234 mp->is_add = is_add;
16235 clib_memcpy (mp->locator_set_name, locator_set_name,
16236 vec_len (locator_set_name));
16237 vec_free (locator_set_name);
16239 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
16241 clib_memcpy (mp->locators, locators, data_len);
16242 vec_free (locators);
16247 /* Wait for a reply... */
16252 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
16255 api_one_add_del_locator (vat_main_t * vam)
16257 unformat_input_t *input = vam->input;
16258 vl_api_one_add_del_locator_t *mp;
16259 u32 tmp_if_index = ~0;
16260 u32 sw_if_index = ~0;
16261 u8 sw_if_index_set = 0;
16262 u8 sw_if_index_if_name_set = 0;
16264 u8 priority_set = 0;
16268 u8 *locator_set_name = NULL;
16269 u8 locator_set_name_set = 0;
16272 /* Parse args required to build the message */
16273 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16275 if (unformat (input, "del"))
16279 else if (unformat (input, "locator-set %s", &locator_set_name))
16281 locator_set_name_set = 1;
16283 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16286 sw_if_index_if_name_set = 1;
16287 sw_if_index = tmp_if_index;
16289 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
16291 sw_if_index_set = 1;
16292 sw_if_index = tmp_if_index;
16294 else if (unformat (input, "p %d", &priority))
16298 else if (unformat (input, "w %d", &weight))
16306 if (locator_set_name_set == 0)
16308 errmsg ("missing locator-set name");
16312 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16314 errmsg ("missing sw_if_index");
16315 vec_free (locator_set_name);
16319 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
16321 errmsg ("cannot use both params interface name and sw_if_index");
16322 vec_free (locator_set_name);
16326 if (priority_set == 0)
16328 errmsg ("missing locator-set priority");
16329 vec_free (locator_set_name);
16333 if (weight_set == 0)
16335 errmsg ("missing locator-set weight");
16336 vec_free (locator_set_name);
16340 if (vec_len (locator_set_name) > 64)
16342 errmsg ("locator-set name too long");
16343 vec_free (locator_set_name);
16346 vec_add1 (locator_set_name, 0);
16348 /* Construct the API message */
16349 M (ONE_ADD_DEL_LOCATOR, mp);
16351 mp->is_add = is_add;
16352 mp->sw_if_index = ntohl (sw_if_index);
16353 mp->priority = priority;
16354 mp->weight = weight;
16355 clib_memcpy (mp->locator_set_name, locator_set_name,
16356 vec_len (locator_set_name));
16357 vec_free (locator_set_name);
16362 /* Wait for a reply... */
16367 #define api_lisp_add_del_locator api_one_add_del_locator
16370 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
16372 u32 *key_id = va_arg (*args, u32 *);
16375 if (unformat (input, "%s", &s))
16377 if (!strcmp ((char *) s, "sha1"))
16378 key_id[0] = HMAC_SHA_1_96;
16379 else if (!strcmp ((char *) s, "sha256"))
16380 key_id[0] = HMAC_SHA_256_128;
16383 clib_warning ("invalid key_id: '%s'", s);
16384 key_id[0] = HMAC_NO_KEY;
16395 api_one_add_del_local_eid (vat_main_t * vam)
16397 unformat_input_t *input = vam->input;
16398 vl_api_one_add_del_local_eid_t *mp;
16401 lisp_eid_vat_t _eid, *eid = &_eid;
16402 u8 *locator_set_name = 0;
16403 u8 locator_set_name_set = 0;
16409 /* Parse args required to build the message */
16410 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16412 if (unformat (input, "del"))
16416 else if (unformat (input, "vni %d", &vni))
16420 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16424 else if (unformat (input, "locator-set %s", &locator_set_name))
16426 locator_set_name_set = 1;
16428 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
16430 else if (unformat (input, "secret-key %_%v%_", &key))
16436 if (locator_set_name_set == 0)
16438 errmsg ("missing locator-set name");
16444 errmsg ("EID address not set!");
16445 vec_free (locator_set_name);
16449 if (key && (0 == key_id))
16451 errmsg ("invalid key_id!");
16455 if (vec_len (key) > 64)
16457 errmsg ("key too long");
16462 if (vec_len (locator_set_name) > 64)
16464 errmsg ("locator-set name too long");
16465 vec_free (locator_set_name);
16468 vec_add1 (locator_set_name, 0);
16470 /* Construct the API message */
16471 M (ONE_ADD_DEL_LOCAL_EID, mp);
16473 mp->is_add = is_add;
16474 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16475 mp->eid_type = eid->type;
16476 mp->prefix_len = eid->len;
16477 mp->vni = clib_host_to_net_u32 (vni);
16478 mp->key_id = clib_host_to_net_u16 (key_id);
16479 clib_memcpy (mp->locator_set_name, locator_set_name,
16480 vec_len (locator_set_name));
16481 clib_memcpy (mp->key, key, vec_len (key));
16483 vec_free (locator_set_name);
16489 /* Wait for a reply... */
16494 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
16497 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
16499 u32 dp_table = 0, vni = 0;;
16500 unformat_input_t *input = vam->input;
16501 vl_api_gpe_add_del_fwd_entry_t *mp;
16503 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
16504 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
16505 u8 rmt_eid_set = 0, lcl_eid_set = 0;
16506 u32 action = ~0, w;
16507 ip4_address_t rmt_rloc4, lcl_rloc4;
16508 ip6_address_t rmt_rloc6, lcl_rloc6;
16509 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
16512 memset (&rloc, 0, sizeof (rloc));
16514 /* Parse args required to build the message */
16515 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16517 if (unformat (input, "del"))
16519 else if (unformat (input, "add"))
16521 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
16525 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
16529 else if (unformat (input, "vrf %d", &dp_table))
16531 else if (unformat (input, "bd %d", &dp_table))
16533 else if (unformat (input, "vni %d", &vni))
16535 else if (unformat (input, "w %d", &w))
16539 errmsg ("No RLOC configured for setting priority/weight!");
16542 curr_rloc->weight = w;
16544 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
16545 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
16549 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
16551 vec_add1 (lcl_locs, rloc);
16553 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
16554 vec_add1 (rmt_locs, rloc);
16555 /* weight saved in rmt loc */
16556 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16558 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
16559 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
16562 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
16564 vec_add1 (lcl_locs, rloc);
16566 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
16567 vec_add1 (rmt_locs, rloc);
16568 /* weight saved in rmt loc */
16569 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16571 else if (unformat (input, "action %d", &action))
16577 clib_warning ("parse error '%U'", format_unformat_error, input);
16584 errmsg ("remote eid addresses not set");
16588 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
16590 errmsg ("eid types don't match");
16594 if (0 == rmt_locs && (u32) ~ 0 == action)
16596 errmsg ("action not set for negative mapping");
16600 /* Construct the API message */
16601 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
16602 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
16604 mp->is_add = is_add;
16605 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
16606 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
16607 mp->eid_type = rmt_eid->type;
16608 mp->dp_table = clib_host_to_net_u32 (dp_table);
16609 mp->vni = clib_host_to_net_u32 (vni);
16610 mp->rmt_len = rmt_eid->len;
16611 mp->lcl_len = lcl_eid->len;
16612 mp->action = action;
16614 if (0 != rmt_locs && 0 != lcl_locs)
16616 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
16617 clib_memcpy (mp->locs, lcl_locs,
16618 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
16620 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
16621 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
16622 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
16624 vec_free (lcl_locs);
16625 vec_free (rmt_locs);
16630 /* Wait for a reply... */
16636 api_one_add_del_map_server (vat_main_t * vam)
16638 unformat_input_t *input = vam->input;
16639 vl_api_one_add_del_map_server_t *mp;
16643 ip4_address_t ipv4;
16644 ip6_address_t ipv6;
16647 /* Parse args required to build the message */
16648 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16650 if (unformat (input, "del"))
16654 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16658 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16666 if (ipv4_set && ipv6_set)
16668 errmsg ("both eid v4 and v6 addresses set");
16672 if (!ipv4_set && !ipv6_set)
16674 errmsg ("eid addresses not set");
16678 /* Construct the API message */
16679 M (ONE_ADD_DEL_MAP_SERVER, mp);
16681 mp->is_add = is_add;
16685 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16690 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16696 /* Wait for a reply... */
16701 #define api_lisp_add_del_map_server api_one_add_del_map_server
16704 api_one_add_del_map_resolver (vat_main_t * vam)
16706 unformat_input_t *input = vam->input;
16707 vl_api_one_add_del_map_resolver_t *mp;
16711 ip4_address_t ipv4;
16712 ip6_address_t ipv6;
16715 /* Parse args required to build the message */
16716 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16718 if (unformat (input, "del"))
16722 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16726 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16734 if (ipv4_set && ipv6_set)
16736 errmsg ("both eid v4 and v6 addresses set");
16740 if (!ipv4_set && !ipv6_set)
16742 errmsg ("eid addresses not set");
16746 /* Construct the API message */
16747 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
16749 mp->is_add = is_add;
16753 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16758 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16764 /* Wait for a reply... */
16769 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
16772 api_lisp_gpe_enable_disable (vat_main_t * vam)
16774 unformat_input_t *input = vam->input;
16775 vl_api_gpe_enable_disable_t *mp;
16780 /* Parse args required to build the message */
16781 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16783 if (unformat (input, "enable"))
16788 else if (unformat (input, "disable"))
16799 errmsg ("Value not set");
16803 /* Construct the API message */
16804 M (GPE_ENABLE_DISABLE, mp);
16811 /* Wait for a reply... */
16817 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16819 unformat_input_t *input = vam->input;
16820 vl_api_one_rloc_probe_enable_disable_t *mp;
16825 /* Parse args required to build the message */
16826 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16828 if (unformat (input, "enable"))
16833 else if (unformat (input, "disable"))
16841 errmsg ("Value not set");
16845 /* Construct the API message */
16846 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16848 mp->is_enabled = is_en;
16853 /* Wait for a reply... */
16858 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16861 api_one_map_register_enable_disable (vat_main_t * vam)
16863 unformat_input_t *input = vam->input;
16864 vl_api_one_map_register_enable_disable_t *mp;
16869 /* Parse args required to build the message */
16870 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16872 if (unformat (input, "enable"))
16877 else if (unformat (input, "disable"))
16885 errmsg ("Value not set");
16889 /* Construct the API message */
16890 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16892 mp->is_enabled = is_en;
16897 /* Wait for a reply... */
16902 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16905 api_one_enable_disable (vat_main_t * vam)
16907 unformat_input_t *input = vam->input;
16908 vl_api_one_enable_disable_t *mp;
16913 /* Parse args required to build the message */
16914 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16916 if (unformat (input, "enable"))
16921 else if (unformat (input, "disable"))
16931 errmsg ("Value not set");
16935 /* Construct the API message */
16936 M (ONE_ENABLE_DISABLE, mp);
16943 /* Wait for a reply... */
16948 #define api_lisp_enable_disable api_one_enable_disable
16951 api_one_enable_disable_xtr_mode (vat_main_t * vam)
16953 unformat_input_t *input = vam->input;
16954 vl_api_one_enable_disable_xtr_mode_t *mp;
16959 /* Parse args required to build the message */
16960 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16962 if (unformat (input, "enable"))
16967 else if (unformat (input, "disable"))
16977 errmsg ("Value not set");
16981 /* Construct the API message */
16982 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
16989 /* Wait for a reply... */
16995 api_one_show_xtr_mode (vat_main_t * vam)
16997 vl_api_one_show_xtr_mode_t *mp;
17000 /* Construct the API message */
17001 M (ONE_SHOW_XTR_MODE, mp);
17006 /* Wait for a reply... */
17012 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17014 unformat_input_t *input = vam->input;
17015 vl_api_one_enable_disable_pitr_mode_t *mp;
17020 /* Parse args required to build the message */
17021 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17023 if (unformat (input, "enable"))
17028 else if (unformat (input, "disable"))
17038 errmsg ("Value not set");
17042 /* Construct the API message */
17043 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17050 /* Wait for a reply... */
17056 api_one_show_pitr_mode (vat_main_t * vam)
17058 vl_api_one_show_pitr_mode_t *mp;
17061 /* Construct the API message */
17062 M (ONE_SHOW_PITR_MODE, mp);
17067 /* Wait for a reply... */
17073 api_one_enable_disable_petr_mode (vat_main_t * vam)
17075 unformat_input_t *input = vam->input;
17076 vl_api_one_enable_disable_petr_mode_t *mp;
17081 /* Parse args required to build the message */
17082 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17084 if (unformat (input, "enable"))
17089 else if (unformat (input, "disable"))
17099 errmsg ("Value not set");
17103 /* Construct the API message */
17104 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17111 /* Wait for a reply... */
17117 api_one_show_petr_mode (vat_main_t * vam)
17119 vl_api_one_show_petr_mode_t *mp;
17122 /* Construct the API message */
17123 M (ONE_SHOW_PETR_MODE, mp);
17128 /* Wait for a reply... */
17134 api_show_one_map_register_state (vat_main_t * vam)
17136 vl_api_show_one_map_register_state_t *mp;
17139 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17144 /* wait for reply */
17149 #define api_show_lisp_map_register_state api_show_one_map_register_state
17152 api_show_one_rloc_probe_state (vat_main_t * vam)
17154 vl_api_show_one_rloc_probe_state_t *mp;
17157 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17162 /* wait for reply */
17167 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17170 api_one_add_del_ndp_entry (vat_main_t * vam)
17172 vl_api_one_add_del_ndp_entry_t *mp;
17173 unformat_input_t *input = vam->input;
17178 u8 mac[6] = { 0, };
17179 u8 ip6[16] = { 0, };
17183 /* Parse args required to build the message */
17184 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17186 if (unformat (input, "del"))
17188 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17190 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17192 else if (unformat (input, "bd %d", &bd))
17196 errmsg ("parse error '%U'", format_unformat_error, input);
17201 if (!bd_set || !ip_set || (!mac_set && is_add))
17203 errmsg ("Missing BD, IP or MAC!");
17207 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17208 mp->is_add = is_add;
17209 clib_memcpy (mp->mac, mac, 6);
17210 mp->bd = clib_host_to_net_u32 (bd);
17211 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17216 /* wait for reply */
17222 api_one_add_del_l2_arp_entry (vat_main_t * vam)
17224 vl_api_one_add_del_l2_arp_entry_t *mp;
17225 unformat_input_t *input = vam->input;
17230 u8 mac[6] = { 0, };
17231 u32 ip4 = 0, bd = ~0;
17234 /* Parse args required to build the message */
17235 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17237 if (unformat (input, "del"))
17239 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17241 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
17243 else if (unformat (input, "bd %d", &bd))
17247 errmsg ("parse error '%U'", format_unformat_error, input);
17252 if (!bd_set || !ip_set || (!mac_set && is_add))
17254 errmsg ("Missing BD, IP or MAC!");
17258 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
17259 mp->is_add = is_add;
17260 clib_memcpy (mp->mac, mac, 6);
17261 mp->bd = clib_host_to_net_u32 (bd);
17267 /* wait for reply */
17273 api_one_ndp_bd_get (vat_main_t * vam)
17275 vl_api_one_ndp_bd_get_t *mp;
17278 M (ONE_NDP_BD_GET, mp);
17283 /* wait for reply */
17289 api_one_ndp_entries_get (vat_main_t * vam)
17291 vl_api_one_ndp_entries_get_t *mp;
17292 unformat_input_t *input = vam->input;
17297 /* Parse args required to build the message */
17298 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17300 if (unformat (input, "bd %d", &bd))
17304 errmsg ("parse error '%U'", format_unformat_error, input);
17311 errmsg ("Expected bridge domain!");
17315 M (ONE_NDP_ENTRIES_GET, mp);
17316 mp->bd = clib_host_to_net_u32 (bd);
17321 /* wait for reply */
17327 api_one_l2_arp_bd_get (vat_main_t * vam)
17329 vl_api_one_l2_arp_bd_get_t *mp;
17332 M (ONE_L2_ARP_BD_GET, mp);
17337 /* wait for reply */
17343 api_one_l2_arp_entries_get (vat_main_t * vam)
17345 vl_api_one_l2_arp_entries_get_t *mp;
17346 unformat_input_t *input = vam->input;
17351 /* Parse args required to build the message */
17352 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17354 if (unformat (input, "bd %d", &bd))
17358 errmsg ("parse error '%U'", format_unformat_error, input);
17365 errmsg ("Expected bridge domain!");
17369 M (ONE_L2_ARP_ENTRIES_GET, mp);
17370 mp->bd = clib_host_to_net_u32 (bd);
17375 /* wait for reply */
17381 api_one_stats_enable_disable (vat_main_t * vam)
17383 vl_api_one_stats_enable_disable_t *mp;
17384 unformat_input_t *input = vam->input;
17389 /* Parse args required to build the message */
17390 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17392 if (unformat (input, "enable"))
17397 else if (unformat (input, "disable"))
17407 errmsg ("Value not set");
17411 M (ONE_STATS_ENABLE_DISABLE, mp);
17417 /* wait for reply */
17423 api_show_one_stats_enable_disable (vat_main_t * vam)
17425 vl_api_show_one_stats_enable_disable_t *mp;
17428 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
17433 /* wait for reply */
17439 api_show_one_map_request_mode (vat_main_t * vam)
17441 vl_api_show_one_map_request_mode_t *mp;
17444 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
17449 /* wait for reply */
17454 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
17457 api_one_map_request_mode (vat_main_t * vam)
17459 unformat_input_t *input = vam->input;
17460 vl_api_one_map_request_mode_t *mp;
17464 /* Parse args required to build the message */
17465 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17467 if (unformat (input, "dst-only"))
17469 else if (unformat (input, "src-dst"))
17473 errmsg ("parse error '%U'", format_unformat_error, input);
17478 M (ONE_MAP_REQUEST_MODE, mp);
17485 /* wait for reply */
17490 #define api_lisp_map_request_mode api_one_map_request_mode
17493 * Enable/disable ONE proxy ITR.
17495 * @param vam vpp API test context
17496 * @return return code
17499 api_one_pitr_set_locator_set (vat_main_t * vam)
17501 u8 ls_name_set = 0;
17502 unformat_input_t *input = vam->input;
17503 vl_api_one_pitr_set_locator_set_t *mp;
17508 /* Parse args required to build the message */
17509 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17511 if (unformat (input, "del"))
17513 else if (unformat (input, "locator-set %s", &ls_name))
17517 errmsg ("parse error '%U'", format_unformat_error, input);
17524 errmsg ("locator-set name not set!");
17528 M (ONE_PITR_SET_LOCATOR_SET, mp);
17530 mp->is_add = is_add;
17531 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17532 vec_free (ls_name);
17537 /* wait for reply */
17542 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
17545 api_one_nsh_set_locator_set (vat_main_t * vam)
17547 u8 ls_name_set = 0;
17548 unformat_input_t *input = vam->input;
17549 vl_api_one_nsh_set_locator_set_t *mp;
17554 /* Parse args required to build the message */
17555 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17557 if (unformat (input, "del"))
17559 else if (unformat (input, "ls %s", &ls_name))
17563 errmsg ("parse error '%U'", format_unformat_error, input);
17568 if (!ls_name_set && is_add)
17570 errmsg ("locator-set name not set!");
17574 M (ONE_NSH_SET_LOCATOR_SET, mp);
17576 mp->is_add = is_add;
17577 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17578 vec_free (ls_name);
17583 /* wait for reply */
17589 api_show_one_pitr (vat_main_t * vam)
17591 vl_api_show_one_pitr_t *mp;
17594 if (!vam->json_output)
17596 print (vam->ofp, "%=20s", "lisp status:");
17599 M (SHOW_ONE_PITR, mp);
17603 /* Wait for a reply... */
17608 #define api_show_lisp_pitr api_show_one_pitr
17611 api_one_use_petr (vat_main_t * vam)
17613 unformat_input_t *input = vam->input;
17614 vl_api_one_use_petr_t *mp;
17619 memset (&ip, 0, sizeof (ip));
17621 /* Parse args required to build the message */
17622 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17624 if (unformat (input, "disable"))
17627 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
17630 ip_addr_version (&ip) = IP4;
17633 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
17636 ip_addr_version (&ip) = IP6;
17640 errmsg ("parse error '%U'", format_unformat_error, input);
17645 M (ONE_USE_PETR, mp);
17647 mp->is_add = is_add;
17650 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
17652 clib_memcpy (mp->address, &ip, 4);
17654 clib_memcpy (mp->address, &ip, 16);
17660 /* wait for reply */
17665 #define api_lisp_use_petr api_one_use_petr
17668 api_show_one_nsh_mapping (vat_main_t * vam)
17670 vl_api_show_one_use_petr_t *mp;
17673 if (!vam->json_output)
17675 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
17678 M (SHOW_ONE_NSH_MAPPING, mp);
17682 /* Wait for a reply... */
17688 api_show_one_use_petr (vat_main_t * vam)
17690 vl_api_show_one_use_petr_t *mp;
17693 if (!vam->json_output)
17695 print (vam->ofp, "%=20s", "Proxy-ETR status:");
17698 M (SHOW_ONE_USE_PETR, mp);
17702 /* Wait for a reply... */
17707 #define api_show_lisp_use_petr api_show_one_use_petr
17710 * Add/delete mapping between vni and vrf
17713 api_one_eid_table_add_del_map (vat_main_t * vam)
17715 unformat_input_t *input = vam->input;
17716 vl_api_one_eid_table_add_del_map_t *mp;
17717 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
17718 u32 vni, vrf, bd_index;
17721 /* Parse args required to build the message */
17722 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17724 if (unformat (input, "del"))
17726 else if (unformat (input, "vrf %d", &vrf))
17728 else if (unformat (input, "bd_index %d", &bd_index))
17730 else if (unformat (input, "vni %d", &vni))
17736 if (!vni_set || (!vrf_set && !bd_index_set))
17738 errmsg ("missing arguments!");
17742 if (vrf_set && bd_index_set)
17744 errmsg ("error: both vrf and bd entered!");
17748 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
17750 mp->is_add = is_add;
17751 mp->vni = htonl (vni);
17752 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
17753 mp->is_l2 = bd_index_set;
17758 /* wait for reply */
17763 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
17766 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
17768 u32 *action = va_arg (*args, u32 *);
17771 if (unformat (input, "%s", &s))
17773 if (!strcmp ((char *) s, "no-action"))
17775 else if (!strcmp ((char *) s, "natively-forward"))
17777 else if (!strcmp ((char *) s, "send-map-request"))
17779 else if (!strcmp ((char *) s, "drop"))
17783 clib_warning ("invalid action: '%s'", s);
17795 * Add/del remote mapping to/from ONE control plane
17797 * @param vam vpp API test context
17798 * @return return code
17801 api_one_add_del_remote_mapping (vat_main_t * vam)
17803 unformat_input_t *input = vam->input;
17804 vl_api_one_add_del_remote_mapping_t *mp;
17806 lisp_eid_vat_t _eid, *eid = &_eid;
17807 lisp_eid_vat_t _seid, *seid = &_seid;
17808 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
17809 u32 action = ~0, p, w, data_len;
17810 ip4_address_t rloc4;
17811 ip6_address_t rloc6;
17812 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
17815 memset (&rloc, 0, sizeof (rloc));
17817 /* Parse args required to build the message */
17818 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17820 if (unformat (input, "del-all"))
17824 else if (unformat (input, "del"))
17828 else if (unformat (input, "add"))
17832 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17836 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
17840 else if (unformat (input, "vni %d", &vni))
17844 else if (unformat (input, "p %d w %d", &p, &w))
17848 errmsg ("No RLOC configured for setting priority/weight!");
17851 curr_rloc->priority = p;
17852 curr_rloc->weight = w;
17854 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
17857 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
17858 vec_add1 (rlocs, rloc);
17859 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17861 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
17864 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
17865 vec_add1 (rlocs, rloc);
17866 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17868 else if (unformat (input, "action %U",
17869 unformat_negative_mapping_action, &action))
17875 clib_warning ("parse error '%U'", format_unformat_error, input);
17882 errmsg ("missing params!");
17886 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
17888 errmsg ("no action set for negative map-reply!");
17892 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
17894 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
17895 mp->is_add = is_add;
17896 mp->vni = htonl (vni);
17897 mp->action = (u8) action;
17898 mp->is_src_dst = seid_set;
17899 mp->eid_len = eid->len;
17900 mp->seid_len = seid->len;
17901 mp->del_all = del_all;
17902 mp->eid_type = eid->type;
17903 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17904 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
17906 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
17907 clib_memcpy (mp->rlocs, rlocs, data_len);
17913 /* Wait for a reply... */
17918 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
17921 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
17922 * forwarding entries in data-plane accordingly.
17924 * @param vam vpp API test context
17925 * @return return code
17928 api_one_add_del_adjacency (vat_main_t * vam)
17930 unformat_input_t *input = vam->input;
17931 vl_api_one_add_del_adjacency_t *mp;
17933 ip4_address_t leid4, reid4;
17934 ip6_address_t leid6, reid6;
17935 u8 reid_mac[6] = { 0 };
17936 u8 leid_mac[6] = { 0 };
17937 u8 reid_type, leid_type;
17938 u32 leid_len = 0, reid_len = 0, len;
17942 leid_type = reid_type = (u8) ~ 0;
17944 /* Parse args required to build the message */
17945 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17947 if (unformat (input, "del"))
17951 else if (unformat (input, "add"))
17955 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17958 reid_type = 0; /* ipv4 */
17961 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17964 reid_type = 1; /* ipv6 */
17967 else if (unformat (input, "reid %U", unformat_ethernet_address,
17970 reid_type = 2; /* mac */
17972 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17975 leid_type = 0; /* ipv4 */
17978 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17981 leid_type = 1; /* ipv6 */
17984 else if (unformat (input, "leid %U", unformat_ethernet_address,
17987 leid_type = 2; /* mac */
17989 else if (unformat (input, "vni %d", &vni))
17995 errmsg ("parse error '%U'", format_unformat_error, input);
18000 if ((u8) ~ 0 == reid_type)
18002 errmsg ("missing params!");
18006 if (leid_type != reid_type)
18008 errmsg ("remote and local EIDs are of different types!");
18012 M (ONE_ADD_DEL_ADJACENCY, mp);
18013 mp->is_add = is_add;
18014 mp->vni = htonl (vni);
18015 mp->leid_len = leid_len;
18016 mp->reid_len = reid_len;
18017 mp->eid_type = reid_type;
18019 switch (mp->eid_type)
18022 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18023 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18026 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18027 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18030 clib_memcpy (mp->leid, leid_mac, 6);
18031 clib_memcpy (mp->reid, reid_mac, 6);
18034 errmsg ("unknown EID type %d!", mp->eid_type);
18041 /* Wait for a reply... */
18046 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18049 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18051 u32 *mode = va_arg (*args, u32 *);
18053 if (unformat (input, "lisp"))
18055 else if (unformat (input, "vxlan"))
18064 api_gpe_get_encap_mode (vat_main_t * vam)
18066 vl_api_gpe_get_encap_mode_t *mp;
18069 /* Construct the API message */
18070 M (GPE_GET_ENCAP_MODE, mp);
18075 /* Wait for a reply... */
18081 api_gpe_set_encap_mode (vat_main_t * vam)
18083 unformat_input_t *input = vam->input;
18084 vl_api_gpe_set_encap_mode_t *mp;
18088 /* Parse args required to build the message */
18089 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18091 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18097 /* Construct the API message */
18098 M (GPE_SET_ENCAP_MODE, mp);
18105 /* Wait for a reply... */
18111 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18113 unformat_input_t *input = vam->input;
18114 vl_api_gpe_add_del_iface_t *mp;
18115 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18116 u32 dp_table = 0, vni = 0;
18119 /* Parse args required to build the message */
18120 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18122 if (unformat (input, "up"))
18127 else if (unformat (input, "down"))
18132 else if (unformat (input, "table_id %d", &dp_table))
18136 else if (unformat (input, "bd_id %d", &dp_table))
18141 else if (unformat (input, "vni %d", &vni))
18149 if (action_set == 0)
18151 errmsg ("Action not set");
18154 if (dp_table_set == 0 || vni_set == 0)
18156 errmsg ("vni and dp_table must be set");
18160 /* Construct the API message */
18161 M (GPE_ADD_DEL_IFACE, mp);
18163 mp->is_add = is_add;
18164 mp->dp_table = clib_host_to_net_u32 (dp_table);
18166 mp->vni = clib_host_to_net_u32 (vni);
18171 /* Wait for a reply... */
18177 api_one_map_register_fallback_threshold (vat_main_t * vam)
18179 unformat_input_t *input = vam->input;
18180 vl_api_one_map_register_fallback_threshold_t *mp;
18185 /* Parse args required to build the message */
18186 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18188 if (unformat (input, "%u", &value))
18192 clib_warning ("parse error '%U'", format_unformat_error, input);
18199 errmsg ("fallback threshold value is missing!");
18203 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18204 mp->value = clib_host_to_net_u32 (value);
18209 /* Wait for a reply... */
18215 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
18217 vl_api_show_one_map_register_fallback_threshold_t *mp;
18220 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18225 /* Wait for a reply... */
18231 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
18233 u32 *proto = va_arg (*args, u32 *);
18235 if (unformat (input, "udp"))
18237 else if (unformat (input, "api"))
18246 api_one_set_transport_protocol (vat_main_t * vam)
18248 unformat_input_t *input = vam->input;
18249 vl_api_one_set_transport_protocol_t *mp;
18254 /* Parse args required to build the message */
18255 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18257 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
18261 clib_warning ("parse error '%U'", format_unformat_error, input);
18268 errmsg ("Transport protocol missing!");
18272 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18273 mp->protocol = (u8) protocol;
18278 /* Wait for a reply... */
18284 api_one_get_transport_protocol (vat_main_t * vam)
18286 vl_api_one_get_transport_protocol_t *mp;
18289 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
18294 /* Wait for a reply... */
18300 api_one_map_register_set_ttl (vat_main_t * vam)
18302 unformat_input_t *input = vam->input;
18303 vl_api_one_map_register_set_ttl_t *mp;
18308 /* Parse args required to build the message */
18309 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18311 if (unformat (input, "%u", &ttl))
18315 clib_warning ("parse error '%U'", format_unformat_error, input);
18322 errmsg ("TTL value missing!");
18326 M (ONE_MAP_REGISTER_SET_TTL, mp);
18327 mp->ttl = clib_host_to_net_u32 (ttl);
18332 /* Wait for a reply... */
18338 api_show_one_map_register_ttl (vat_main_t * vam)
18340 vl_api_show_one_map_register_ttl_t *mp;
18343 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
18348 /* Wait for a reply... */
18354 * Add/del map request itr rlocs from ONE control plane and updates
18356 * @param vam vpp API test context
18357 * @return return code
18360 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
18362 unformat_input_t *input = vam->input;
18363 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
18364 u8 *locator_set_name = 0;
18365 u8 locator_set_name_set = 0;
18369 /* Parse args required to build the message */
18370 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18372 if (unformat (input, "del"))
18376 else if (unformat (input, "%_%v%_", &locator_set_name))
18378 locator_set_name_set = 1;
18382 clib_warning ("parse error '%U'", format_unformat_error, input);
18387 if (is_add && !locator_set_name_set)
18389 errmsg ("itr-rloc is not set!");
18393 if (is_add && vec_len (locator_set_name) > 64)
18395 errmsg ("itr-rloc locator-set name too long");
18396 vec_free (locator_set_name);
18400 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
18401 mp->is_add = is_add;
18404 clib_memcpy (mp->locator_set_name, locator_set_name,
18405 vec_len (locator_set_name));
18409 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
18411 vec_free (locator_set_name);
18416 /* Wait for a reply... */
18421 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
18424 api_one_locator_dump (vat_main_t * vam)
18426 unformat_input_t *input = vam->input;
18427 vl_api_one_locator_dump_t *mp;
18428 vl_api_control_ping_t *mp_ping;
18429 u8 is_index_set = 0, is_name_set = 0;
18434 /* Parse args required to build the message */
18435 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18437 if (unformat (input, "ls_name %_%v%_", &ls_name))
18441 else if (unformat (input, "ls_index %d", &ls_index))
18447 errmsg ("parse error '%U'", format_unformat_error, input);
18452 if (!is_index_set && !is_name_set)
18454 errmsg ("error: expected one of index or name!");
18458 if (is_index_set && is_name_set)
18460 errmsg ("error: only one param expected!");
18464 if (vec_len (ls_name) > 62)
18466 errmsg ("error: locator set name too long!");
18470 if (!vam->json_output)
18472 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
18475 M (ONE_LOCATOR_DUMP, mp);
18476 mp->is_index_set = is_index_set;
18479 mp->ls_index = clib_host_to_net_u32 (ls_index);
18482 vec_add1 (ls_name, 0);
18483 strncpy ((char *) mp->ls_name, (char *) ls_name,
18484 sizeof (mp->ls_name) - 1);
18490 /* Use a control ping for synchronization */
18491 MPING (CONTROL_PING, mp_ping);
18494 /* Wait for a reply... */
18499 #define api_lisp_locator_dump api_one_locator_dump
18502 api_one_locator_set_dump (vat_main_t * vam)
18504 vl_api_one_locator_set_dump_t *mp;
18505 vl_api_control_ping_t *mp_ping;
18506 unformat_input_t *input = vam->input;
18510 /* Parse args required to build the message */
18511 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18513 if (unformat (input, "local"))
18517 else if (unformat (input, "remote"))
18523 errmsg ("parse error '%U'", format_unformat_error, input);
18528 if (!vam->json_output)
18530 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
18533 M (ONE_LOCATOR_SET_DUMP, mp);
18535 mp->filter = filter;
18540 /* Use a control ping for synchronization */
18541 MPING (CONTROL_PING, mp_ping);
18544 /* Wait for a reply... */
18549 #define api_lisp_locator_set_dump api_one_locator_set_dump
18552 api_one_eid_table_map_dump (vat_main_t * vam)
18556 unformat_input_t *input = vam->input;
18557 vl_api_one_eid_table_map_dump_t *mp;
18558 vl_api_control_ping_t *mp_ping;
18561 /* Parse args required to build the message */
18562 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18564 if (unformat (input, "l2"))
18569 else if (unformat (input, "l3"))
18576 errmsg ("parse error '%U'", format_unformat_error, input);
18583 errmsg ("expected one of 'l2' or 'l3' parameter!");
18587 if (!vam->json_output)
18589 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
18592 M (ONE_EID_TABLE_MAP_DUMP, mp);
18598 /* Use a control ping for synchronization */
18599 MPING (CONTROL_PING, mp_ping);
18602 /* Wait for a reply... */
18607 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
18610 api_one_eid_table_vni_dump (vat_main_t * vam)
18612 vl_api_one_eid_table_vni_dump_t *mp;
18613 vl_api_control_ping_t *mp_ping;
18616 if (!vam->json_output)
18618 print (vam->ofp, "VNI");
18621 M (ONE_EID_TABLE_VNI_DUMP, mp);
18626 /* Use a control ping for synchronization */
18627 MPING (CONTROL_PING, mp_ping);
18630 /* Wait for a reply... */
18635 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
18638 api_one_eid_table_dump (vat_main_t * vam)
18640 unformat_input_t *i = vam->input;
18641 vl_api_one_eid_table_dump_t *mp;
18642 vl_api_control_ping_t *mp_ping;
18643 struct in_addr ip4;
18644 struct in6_addr ip6;
18646 u8 eid_type = ~0, eid_set = 0;
18647 u32 prefix_length = ~0, t, vni = 0;
18650 lisp_nsh_api_t nsh;
18652 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18654 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
18660 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
18666 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
18671 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
18676 else if (unformat (i, "vni %d", &t))
18680 else if (unformat (i, "local"))
18684 else if (unformat (i, "remote"))
18690 errmsg ("parse error '%U'", format_unformat_error, i);
18695 if (!vam->json_output)
18697 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
18698 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
18701 M (ONE_EID_TABLE_DUMP, mp);
18703 mp->filter = filter;
18707 mp->vni = htonl (vni);
18708 mp->eid_type = eid_type;
18712 mp->prefix_length = prefix_length;
18713 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
18716 mp->prefix_length = prefix_length;
18717 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
18720 clib_memcpy (mp->eid, mac, sizeof (mac));
18723 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
18726 errmsg ("unknown EID type %d!", eid_type);
18734 /* Use a control ping for synchronization */
18735 MPING (CONTROL_PING, mp_ping);
18738 /* Wait for a reply... */
18743 #define api_lisp_eid_table_dump api_one_eid_table_dump
18746 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
18748 unformat_input_t *i = vam->input;
18749 vl_api_gpe_fwd_entries_get_t *mp;
18754 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18756 if (unformat (i, "vni %d", &vni))
18762 errmsg ("parse error '%U'", format_unformat_error, i);
18769 errmsg ("vni not set!");
18773 if (!vam->json_output)
18775 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
18779 M (GPE_FWD_ENTRIES_GET, mp);
18780 mp->vni = clib_host_to_net_u32 (vni);
18785 /* Wait for a reply... */
18790 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
18791 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
18792 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
18793 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
18794 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
18795 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
18796 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
18797 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
18800 api_one_adjacencies_get (vat_main_t * vam)
18802 unformat_input_t *i = vam->input;
18803 vl_api_one_adjacencies_get_t *mp;
18808 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18810 if (unformat (i, "vni %d", &vni))
18816 errmsg ("parse error '%U'", format_unformat_error, i);
18823 errmsg ("vni not set!");
18827 if (!vam->json_output)
18829 print (vam->ofp, "%s %40s", "leid", "reid");
18832 M (ONE_ADJACENCIES_GET, mp);
18833 mp->vni = clib_host_to_net_u32 (vni);
18838 /* Wait for a reply... */
18843 #define api_lisp_adjacencies_get api_one_adjacencies_get
18846 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
18848 unformat_input_t *i = vam->input;
18849 vl_api_gpe_native_fwd_rpaths_get_t *mp;
18851 u8 ip_family_set = 0, is_ip4 = 1;
18853 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18855 if (unformat (i, "ip4"))
18860 else if (unformat (i, "ip6"))
18867 errmsg ("parse error '%U'", format_unformat_error, i);
18872 if (!ip_family_set)
18874 errmsg ("ip family not set!");
18878 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
18879 mp->is_ip4 = is_ip4;
18884 /* Wait for a reply... */
18890 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
18892 vl_api_gpe_fwd_entry_vnis_get_t *mp;
18895 if (!vam->json_output)
18897 print (vam->ofp, "VNIs");
18900 M (GPE_FWD_ENTRY_VNIS_GET, mp);
18905 /* Wait for a reply... */
18911 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
18913 unformat_input_t *i = vam->input;
18914 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
18916 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
18917 struct in_addr ip4;
18918 struct in6_addr ip6;
18919 u32 table_id = 0, nh_sw_if_index = ~0;
18921 memset (&ip4, 0, sizeof (ip4));
18922 memset (&ip6, 0, sizeof (ip6));
18924 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18926 if (unformat (i, "del"))
18928 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
18929 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18934 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
18935 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18940 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18944 nh_sw_if_index = ~0;
18946 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18950 nh_sw_if_index = ~0;
18952 else if (unformat (i, "table %d", &table_id))
18956 errmsg ("parse error '%U'", format_unformat_error, i);
18963 errmsg ("nh addr not set!");
18967 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18968 mp->is_add = is_add;
18969 mp->table_id = clib_host_to_net_u32 (table_id);
18970 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18971 mp->is_ip4 = is_ip4;
18973 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18975 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18980 /* Wait for a reply... */
18986 api_one_map_server_dump (vat_main_t * vam)
18988 vl_api_one_map_server_dump_t *mp;
18989 vl_api_control_ping_t *mp_ping;
18992 if (!vam->json_output)
18994 print (vam->ofp, "%=20s", "Map server");
18997 M (ONE_MAP_SERVER_DUMP, mp);
19001 /* Use a control ping for synchronization */
19002 MPING (CONTROL_PING, mp_ping);
19005 /* Wait for a reply... */
19010 #define api_lisp_map_server_dump api_one_map_server_dump
19013 api_one_map_resolver_dump (vat_main_t * vam)
19015 vl_api_one_map_resolver_dump_t *mp;
19016 vl_api_control_ping_t *mp_ping;
19019 if (!vam->json_output)
19021 print (vam->ofp, "%=20s", "Map resolver");
19024 M (ONE_MAP_RESOLVER_DUMP, mp);
19028 /* Use a control ping for synchronization */
19029 MPING (CONTROL_PING, mp_ping);
19032 /* Wait for a reply... */
19037 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19040 api_one_stats_flush (vat_main_t * vam)
19042 vl_api_one_stats_flush_t *mp;
19045 M (ONE_STATS_FLUSH, mp);
19052 api_one_stats_dump (vat_main_t * vam)
19054 vl_api_one_stats_dump_t *mp;
19055 vl_api_control_ping_t *mp_ping;
19058 M (ONE_STATS_DUMP, mp);
19062 /* Use a control ping for synchronization */
19063 MPING (CONTROL_PING, mp_ping);
19066 /* Wait for a reply... */
19072 api_show_one_status (vat_main_t * vam)
19074 vl_api_show_one_status_t *mp;
19077 if (!vam->json_output)
19079 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19082 M (SHOW_ONE_STATUS, mp);
19085 /* Wait for a reply... */
19090 #define api_show_lisp_status api_show_one_status
19093 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19095 vl_api_gpe_fwd_entry_path_dump_t *mp;
19096 vl_api_control_ping_t *mp_ping;
19097 unformat_input_t *i = vam->input;
19098 u32 fwd_entry_index = ~0;
19101 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19103 if (unformat (i, "index %d", &fwd_entry_index))
19109 if (~0 == fwd_entry_index)
19111 errmsg ("no index specified!");
19115 if (!vam->json_output)
19117 print (vam->ofp, "first line");
19120 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19124 /* Use a control ping for synchronization */
19125 MPING (CONTROL_PING, mp_ping);
19128 /* Wait for a reply... */
19134 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19136 vl_api_one_get_map_request_itr_rlocs_t *mp;
19139 if (!vam->json_output)
19141 print (vam->ofp, "%=20s", "itr-rlocs:");
19144 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19147 /* Wait for a reply... */
19152 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19155 api_af_packet_create (vat_main_t * vam)
19157 unformat_input_t *i = vam->input;
19158 vl_api_af_packet_create_t *mp;
19159 u8 *host_if_name = 0;
19161 u8 random_hw_addr = 1;
19164 memset (hw_addr, 0, sizeof (hw_addr));
19166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19168 if (unformat (i, "name %s", &host_if_name))
19169 vec_add1 (host_if_name, 0);
19170 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19171 random_hw_addr = 0;
19176 if (!vec_len (host_if_name))
19178 errmsg ("host-interface name must be specified");
19182 if (vec_len (host_if_name) > 64)
19184 errmsg ("host-interface name too long");
19188 M (AF_PACKET_CREATE, mp);
19190 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19191 clib_memcpy (mp->hw_addr, hw_addr, 6);
19192 mp->use_random_hw_addr = random_hw_addr;
19193 vec_free (host_if_name);
19201 fprintf (vam->ofp ? vam->ofp : stderr,
19202 " new sw_if_index = %d\n", vam->sw_if_index);
19209 api_af_packet_delete (vat_main_t * vam)
19211 unformat_input_t *i = vam->input;
19212 vl_api_af_packet_delete_t *mp;
19213 u8 *host_if_name = 0;
19216 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19218 if (unformat (i, "name %s", &host_if_name))
19219 vec_add1 (host_if_name, 0);
19224 if (!vec_len (host_if_name))
19226 errmsg ("host-interface name must be specified");
19230 if (vec_len (host_if_name) > 64)
19232 errmsg ("host-interface name too long");
19236 M (AF_PACKET_DELETE, mp);
19238 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19239 vec_free (host_if_name);
19247 api_policer_add_del (vat_main_t * vam)
19249 unformat_input_t *i = vam->input;
19250 vl_api_policer_add_del_t *mp;
19260 u8 color_aware = 0;
19261 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
19264 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
19265 conform_action.dscp = 0;
19266 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
19267 exceed_action.dscp = 0;
19268 violate_action.action_type = SSE2_QOS_ACTION_DROP;
19269 violate_action.dscp = 0;
19271 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19273 if (unformat (i, "del"))
19275 else if (unformat (i, "name %s", &name))
19276 vec_add1 (name, 0);
19277 else if (unformat (i, "cir %u", &cir))
19279 else if (unformat (i, "eir %u", &eir))
19281 else if (unformat (i, "cb %u", &cb))
19283 else if (unformat (i, "eb %u", &eb))
19285 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
19288 else if (unformat (i, "round_type %U", unformat_policer_round_type,
19291 else if (unformat (i, "type %U", unformat_policer_type, &type))
19293 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
19296 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
19299 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
19302 else if (unformat (i, "color-aware"))
19308 if (!vec_len (name))
19310 errmsg ("policer name must be specified");
19314 if (vec_len (name) > 64)
19316 errmsg ("policer name too long");
19320 M (POLICER_ADD_DEL, mp);
19322 clib_memcpy (mp->name, name, vec_len (name));
19324 mp->is_add = is_add;
19325 mp->cir = ntohl (cir);
19326 mp->eir = ntohl (eir);
19327 mp->cb = clib_net_to_host_u64 (cb);
19328 mp->eb = clib_net_to_host_u64 (eb);
19329 mp->rate_type = rate_type;
19330 mp->round_type = round_type;
19332 mp->conform_action_type = conform_action.action_type;
19333 mp->conform_dscp = conform_action.dscp;
19334 mp->exceed_action_type = exceed_action.action_type;
19335 mp->exceed_dscp = exceed_action.dscp;
19336 mp->violate_action_type = violate_action.action_type;
19337 mp->violate_dscp = violate_action.dscp;
19338 mp->color_aware = color_aware;
19346 api_policer_dump (vat_main_t * vam)
19348 unformat_input_t *i = vam->input;
19349 vl_api_policer_dump_t *mp;
19350 vl_api_control_ping_t *mp_ping;
19351 u8 *match_name = 0;
19352 u8 match_name_valid = 0;
19355 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19357 if (unformat (i, "name %s", &match_name))
19359 vec_add1 (match_name, 0);
19360 match_name_valid = 1;
19366 M (POLICER_DUMP, mp);
19367 mp->match_name_valid = match_name_valid;
19368 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
19369 vec_free (match_name);
19373 /* Use a control ping for synchronization */
19374 MPING (CONTROL_PING, mp_ping);
19377 /* Wait for a reply... */
19383 api_policer_classify_set_interface (vat_main_t * vam)
19385 unformat_input_t *i = vam->input;
19386 vl_api_policer_classify_set_interface_t *mp;
19388 int sw_if_index_set;
19389 u32 ip4_table_index = ~0;
19390 u32 ip6_table_index = ~0;
19391 u32 l2_table_index = ~0;
19395 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19397 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19398 sw_if_index_set = 1;
19399 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19400 sw_if_index_set = 1;
19401 else if (unformat (i, "del"))
19403 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19405 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19407 else if (unformat (i, "l2-table %d", &l2_table_index))
19411 clib_warning ("parse error '%U'", format_unformat_error, i);
19416 if (sw_if_index_set == 0)
19418 errmsg ("missing interface name or sw_if_index");
19422 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
19424 mp->sw_if_index = ntohl (sw_if_index);
19425 mp->ip4_table_index = ntohl (ip4_table_index);
19426 mp->ip6_table_index = ntohl (ip6_table_index);
19427 mp->l2_table_index = ntohl (l2_table_index);
19428 mp->is_add = is_add;
19436 api_policer_classify_dump (vat_main_t * vam)
19438 unformat_input_t *i = vam->input;
19439 vl_api_policer_classify_dump_t *mp;
19440 vl_api_control_ping_t *mp_ping;
19441 u8 type = POLICER_CLASSIFY_N_TABLES;
19444 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
19448 errmsg ("classify table type must be specified");
19452 if (!vam->json_output)
19454 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19457 M (POLICER_CLASSIFY_DUMP, mp);
19462 /* Use a control ping for synchronization */
19463 MPING (CONTROL_PING, mp_ping);
19466 /* Wait for a reply... */
19472 api_netmap_create (vat_main_t * vam)
19474 unformat_input_t *i = vam->input;
19475 vl_api_netmap_create_t *mp;
19478 u8 random_hw_addr = 1;
19483 memset (hw_addr, 0, sizeof (hw_addr));
19485 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19487 if (unformat (i, "name %s", &if_name))
19488 vec_add1 (if_name, 0);
19489 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19490 random_hw_addr = 0;
19491 else if (unformat (i, "pipe"))
19493 else if (unformat (i, "master"))
19495 else if (unformat (i, "slave"))
19501 if (!vec_len (if_name))
19503 errmsg ("interface name must be specified");
19507 if (vec_len (if_name) > 64)
19509 errmsg ("interface name too long");
19513 M (NETMAP_CREATE, mp);
19515 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19516 clib_memcpy (mp->hw_addr, hw_addr, 6);
19517 mp->use_random_hw_addr = random_hw_addr;
19518 mp->is_pipe = is_pipe;
19519 mp->is_master = is_master;
19520 vec_free (if_name);
19528 api_netmap_delete (vat_main_t * vam)
19530 unformat_input_t *i = vam->input;
19531 vl_api_netmap_delete_t *mp;
19535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19537 if (unformat (i, "name %s", &if_name))
19538 vec_add1 (if_name, 0);
19543 if (!vec_len (if_name))
19545 errmsg ("interface name must be specified");
19549 if (vec_len (if_name) > 64)
19551 errmsg ("interface name too long");
19555 M (NETMAP_DELETE, mp);
19557 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19558 vec_free (if_name);
19566 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
19568 if (fp->afi == IP46_TYPE_IP6)
19570 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19571 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19572 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19573 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19574 format_ip6_address, fp->next_hop);
19575 else if (fp->afi == IP46_TYPE_IP4)
19577 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19578 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19579 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19580 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19581 format_ip4_address, fp->next_hop);
19585 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
19586 vl_api_fib_path2_t * fp)
19588 struct in_addr ip4;
19589 struct in6_addr ip6;
19591 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19592 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19593 vat_json_object_add_uint (node, "is_local", fp->is_local);
19594 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19595 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19596 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19597 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19598 if (fp->afi == IP46_TYPE_IP4)
19600 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19601 vat_json_object_add_ip4 (node, "next_hop", ip4);
19603 else if (fp->afi == IP46_TYPE_IP6)
19605 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19606 vat_json_object_add_ip6 (node, "next_hop", ip6);
19611 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
19613 vat_main_t *vam = &vat_main;
19614 int count = ntohl (mp->mt_count);
19615 vl_api_fib_path2_t *fp;
19618 print (vam->ofp, "[%d]: sw_if_index %d via:",
19619 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
19621 for (i = 0; i < count; i++)
19623 vl_api_mpls_fib_path_print (vam, fp);
19627 print (vam->ofp, "");
19630 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
19631 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
19634 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
19636 vat_main_t *vam = &vat_main;
19637 vat_json_node_t *node = NULL;
19638 int count = ntohl (mp->mt_count);
19639 vl_api_fib_path2_t *fp;
19642 if (VAT_JSON_ARRAY != vam->json_tree.type)
19644 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19645 vat_json_init_array (&vam->json_tree);
19647 node = vat_json_array_add (&vam->json_tree);
19649 vat_json_init_object (node);
19650 vat_json_object_add_uint (node, "tunnel_index",
19651 ntohl (mp->mt_tunnel_index));
19652 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
19654 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
19657 for (i = 0; i < count; i++)
19659 vl_api_mpls_fib_path_json_print (node, fp);
19665 api_mpls_tunnel_dump (vat_main_t * vam)
19667 vl_api_mpls_tunnel_dump_t *mp;
19668 vl_api_control_ping_t *mp_ping;
19672 /* Parse args required to build the message */
19673 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
19675 if (!unformat (vam->input, "tunnel_index %d", &index))
19682 print (vam->ofp, " tunnel_index %d", index);
19684 M (MPLS_TUNNEL_DUMP, mp);
19685 mp->tunnel_index = htonl (index);
19688 /* Use a control ping for synchronization */
19689 MPING (CONTROL_PING, mp_ping);
19696 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
19697 #define vl_api_mpls_fib_details_t_print vl_noop_handler
19701 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
19703 vat_main_t *vam = &vat_main;
19704 int count = ntohl (mp->count);
19705 vl_api_fib_path2_t *fp;
19709 "table-id %d, label %u, ess_bit %u",
19710 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
19712 for (i = 0; i < count; i++)
19714 vl_api_mpls_fib_path_print (vam, fp);
19719 static void vl_api_mpls_fib_details_t_handler_json
19720 (vl_api_mpls_fib_details_t * mp)
19722 vat_main_t *vam = &vat_main;
19723 int count = ntohl (mp->count);
19724 vat_json_node_t *node = NULL;
19725 vl_api_fib_path2_t *fp;
19728 if (VAT_JSON_ARRAY != vam->json_tree.type)
19730 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19731 vat_json_init_array (&vam->json_tree);
19733 node = vat_json_array_add (&vam->json_tree);
19735 vat_json_init_object (node);
19736 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19737 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
19738 vat_json_object_add_uint (node, "label", ntohl (mp->label));
19739 vat_json_object_add_uint (node, "path_count", count);
19741 for (i = 0; i < count; i++)
19743 vl_api_mpls_fib_path_json_print (node, fp);
19749 api_mpls_fib_dump (vat_main_t * vam)
19751 vl_api_mpls_fib_dump_t *mp;
19752 vl_api_control_ping_t *mp_ping;
19755 M (MPLS_FIB_DUMP, mp);
19758 /* Use a control ping for synchronization */
19759 MPING (CONTROL_PING, mp_ping);
19766 #define vl_api_ip_fib_details_t_endian vl_noop_handler
19767 #define vl_api_ip_fib_details_t_print vl_noop_handler
19770 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
19772 vat_main_t *vam = &vat_main;
19773 int count = ntohl (mp->count);
19774 vl_api_fib_path_t *fp;
19778 "table-id %d, prefix %U/%d",
19779 ntohl (mp->table_id), format_ip4_address, mp->address,
19780 mp->address_length);
19782 for (i = 0; i < count; i++)
19784 if (fp->afi == IP46_TYPE_IP6)
19786 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19787 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19788 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19789 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19790 format_ip6_address, fp->next_hop);
19791 else if (fp->afi == IP46_TYPE_IP4)
19793 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19794 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19795 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19796 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19797 format_ip4_address, fp->next_hop);
19802 static void vl_api_ip_fib_details_t_handler_json
19803 (vl_api_ip_fib_details_t * mp)
19805 vat_main_t *vam = &vat_main;
19806 int count = ntohl (mp->count);
19807 vat_json_node_t *node = NULL;
19808 struct in_addr ip4;
19809 struct in6_addr ip6;
19810 vl_api_fib_path_t *fp;
19813 if (VAT_JSON_ARRAY != vam->json_tree.type)
19815 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19816 vat_json_init_array (&vam->json_tree);
19818 node = vat_json_array_add (&vam->json_tree);
19820 vat_json_init_object (node);
19821 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19822 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
19823 vat_json_object_add_ip4 (node, "prefix", ip4);
19824 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19825 vat_json_object_add_uint (node, "path_count", count);
19827 for (i = 0; i < count; i++)
19829 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19830 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19831 vat_json_object_add_uint (node, "is_local", fp->is_local);
19832 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19833 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19834 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19835 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19836 if (fp->afi == IP46_TYPE_IP4)
19838 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19839 vat_json_object_add_ip4 (node, "next_hop", ip4);
19841 else if (fp->afi == IP46_TYPE_IP6)
19843 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19844 vat_json_object_add_ip6 (node, "next_hop", ip6);
19850 api_ip_fib_dump (vat_main_t * vam)
19852 vl_api_ip_fib_dump_t *mp;
19853 vl_api_control_ping_t *mp_ping;
19856 M (IP_FIB_DUMP, mp);
19859 /* Use a control ping for synchronization */
19860 MPING (CONTROL_PING, mp_ping);
19868 api_ip_mfib_dump (vat_main_t * vam)
19870 vl_api_ip_mfib_dump_t *mp;
19871 vl_api_control_ping_t *mp_ping;
19874 M (IP_MFIB_DUMP, mp);
19877 /* Use a control ping for synchronization */
19878 MPING (CONTROL_PING, mp_ping);
19885 static void vl_api_ip_neighbor_details_t_handler
19886 (vl_api_ip_neighbor_details_t * mp)
19888 vat_main_t *vam = &vat_main;
19890 print (vam->ofp, "%c %U %U",
19891 (mp->is_static) ? 'S' : 'D',
19892 format_ethernet_address, &mp->mac_address,
19893 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
19897 static void vl_api_ip_neighbor_details_t_handler_json
19898 (vl_api_ip_neighbor_details_t * mp)
19901 vat_main_t *vam = &vat_main;
19902 vat_json_node_t *node;
19903 struct in_addr ip4;
19904 struct in6_addr ip6;
19906 if (VAT_JSON_ARRAY != vam->json_tree.type)
19908 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19909 vat_json_init_array (&vam->json_tree);
19911 node = vat_json_array_add (&vam->json_tree);
19913 vat_json_init_object (node);
19914 vat_json_object_add_string_copy (node, "flag",
19915 (mp->is_static) ? (u8 *) "static" : (u8 *)
19918 vat_json_object_add_string_copy (node, "link_layer",
19919 format (0, "%U", format_ethernet_address,
19920 &mp->mac_address));
19924 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
19925 vat_json_object_add_ip6 (node, "ip_address", ip6);
19929 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
19930 vat_json_object_add_ip4 (node, "ip_address", ip4);
19935 api_ip_neighbor_dump (vat_main_t * vam)
19937 unformat_input_t *i = vam->input;
19938 vl_api_ip_neighbor_dump_t *mp;
19939 vl_api_control_ping_t *mp_ping;
19941 u32 sw_if_index = ~0;
19944 /* Parse args required to build the message */
19945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19947 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19949 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19951 else if (unformat (i, "ip6"))
19957 if (sw_if_index == ~0)
19959 errmsg ("missing interface name or sw_if_index");
19963 M (IP_NEIGHBOR_DUMP, mp);
19964 mp->is_ipv6 = (u8) is_ipv6;
19965 mp->sw_if_index = ntohl (sw_if_index);
19968 /* Use a control ping for synchronization */
19969 MPING (CONTROL_PING, mp_ping);
19976 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
19977 #define vl_api_ip6_fib_details_t_print vl_noop_handler
19980 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
19982 vat_main_t *vam = &vat_main;
19983 int count = ntohl (mp->count);
19984 vl_api_fib_path_t *fp;
19988 "table-id %d, prefix %U/%d",
19989 ntohl (mp->table_id), format_ip6_address, mp->address,
19990 mp->address_length);
19992 for (i = 0; i < count; i++)
19994 if (fp->afi == IP46_TYPE_IP6)
19996 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19997 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19998 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19999 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20000 format_ip6_address, fp->next_hop);
20001 else if (fp->afi == IP46_TYPE_IP4)
20003 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20004 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20005 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20006 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20007 format_ip4_address, fp->next_hop);
20012 static void vl_api_ip6_fib_details_t_handler_json
20013 (vl_api_ip6_fib_details_t * mp)
20015 vat_main_t *vam = &vat_main;
20016 int count = ntohl (mp->count);
20017 vat_json_node_t *node = NULL;
20018 struct in_addr ip4;
20019 struct in6_addr ip6;
20020 vl_api_fib_path_t *fp;
20023 if (VAT_JSON_ARRAY != vam->json_tree.type)
20025 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20026 vat_json_init_array (&vam->json_tree);
20028 node = vat_json_array_add (&vam->json_tree);
20030 vat_json_init_object (node);
20031 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20032 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20033 vat_json_object_add_ip6 (node, "prefix", ip6);
20034 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20035 vat_json_object_add_uint (node, "path_count", count);
20037 for (i = 0; i < count; i++)
20039 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20040 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20041 vat_json_object_add_uint (node, "is_local", fp->is_local);
20042 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20043 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20044 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20045 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20046 if (fp->afi == IP46_TYPE_IP4)
20048 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20049 vat_json_object_add_ip4 (node, "next_hop", ip4);
20051 else if (fp->afi == IP46_TYPE_IP6)
20053 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20054 vat_json_object_add_ip6 (node, "next_hop", ip6);
20060 api_ip6_fib_dump (vat_main_t * vam)
20062 vl_api_ip6_fib_dump_t *mp;
20063 vl_api_control_ping_t *mp_ping;
20066 M (IP6_FIB_DUMP, mp);
20069 /* Use a control ping for synchronization */
20070 MPING (CONTROL_PING, mp_ping);
20078 api_ip6_mfib_dump (vat_main_t * vam)
20080 vl_api_ip6_mfib_dump_t *mp;
20081 vl_api_control_ping_t *mp_ping;
20084 M (IP6_MFIB_DUMP, mp);
20087 /* Use a control ping for synchronization */
20088 MPING (CONTROL_PING, mp_ping);
20096 api_classify_table_ids (vat_main_t * vam)
20098 vl_api_classify_table_ids_t *mp;
20101 /* Construct the API message */
20102 M (CLASSIFY_TABLE_IDS, mp);
20111 api_classify_table_by_interface (vat_main_t * vam)
20113 unformat_input_t *input = vam->input;
20114 vl_api_classify_table_by_interface_t *mp;
20116 u32 sw_if_index = ~0;
20118 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20120 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20122 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20127 if (sw_if_index == ~0)
20129 errmsg ("missing interface name or sw_if_index");
20133 /* Construct the API message */
20134 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20136 mp->sw_if_index = ntohl (sw_if_index);
20144 api_classify_table_info (vat_main_t * vam)
20146 unformat_input_t *input = vam->input;
20147 vl_api_classify_table_info_t *mp;
20151 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20153 if (unformat (input, "table_id %d", &table_id))
20158 if (table_id == ~0)
20160 errmsg ("missing table id");
20164 /* Construct the API message */
20165 M (CLASSIFY_TABLE_INFO, mp);
20167 mp->table_id = ntohl (table_id);
20175 api_classify_session_dump (vat_main_t * vam)
20177 unformat_input_t *input = vam->input;
20178 vl_api_classify_session_dump_t *mp;
20179 vl_api_control_ping_t *mp_ping;
20183 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20185 if (unformat (input, "table_id %d", &table_id))
20190 if (table_id == ~0)
20192 errmsg ("missing table id");
20196 /* Construct the API message */
20197 M (CLASSIFY_SESSION_DUMP, mp);
20199 mp->table_id = ntohl (table_id);
20202 /* Use a control ping for synchronization */
20203 MPING (CONTROL_PING, mp_ping);
20211 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
20213 vat_main_t *vam = &vat_main;
20215 print (vam->ofp, "collector_address %U, collector_port %d, "
20216 "src_address %U, vrf_id %d, path_mtu %u, "
20217 "template_interval %u, udp_checksum %d",
20218 format_ip4_address, mp->collector_address,
20219 ntohs (mp->collector_port),
20220 format_ip4_address, mp->src_address,
20221 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
20222 ntohl (mp->template_interval), mp->udp_checksum);
20225 vam->result_ready = 1;
20229 vl_api_ipfix_exporter_details_t_handler_json
20230 (vl_api_ipfix_exporter_details_t * mp)
20232 vat_main_t *vam = &vat_main;
20233 vat_json_node_t node;
20234 struct in_addr collector_address;
20235 struct in_addr src_address;
20237 vat_json_init_object (&node);
20238 clib_memcpy (&collector_address, &mp->collector_address,
20239 sizeof (collector_address));
20240 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
20241 vat_json_object_add_uint (&node, "collector_port",
20242 ntohs (mp->collector_port));
20243 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
20244 vat_json_object_add_ip4 (&node, "src_address", src_address);
20245 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
20246 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
20247 vat_json_object_add_uint (&node, "template_interval",
20248 ntohl (mp->template_interval));
20249 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
20251 vat_json_print (vam->ofp, &node);
20252 vat_json_free (&node);
20254 vam->result_ready = 1;
20258 api_ipfix_exporter_dump (vat_main_t * vam)
20260 vl_api_ipfix_exporter_dump_t *mp;
20263 /* Construct the API message */
20264 M (IPFIX_EXPORTER_DUMP, mp);
20273 api_ipfix_classify_stream_dump (vat_main_t * vam)
20275 vl_api_ipfix_classify_stream_dump_t *mp;
20278 /* Construct the API message */
20279 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
20290 vl_api_ipfix_classify_stream_details_t_handler
20291 (vl_api_ipfix_classify_stream_details_t * mp)
20293 vat_main_t *vam = &vat_main;
20294 print (vam->ofp, "domain_id %d, src_port %d",
20295 ntohl (mp->domain_id), ntohs (mp->src_port));
20297 vam->result_ready = 1;
20301 vl_api_ipfix_classify_stream_details_t_handler_json
20302 (vl_api_ipfix_classify_stream_details_t * mp)
20304 vat_main_t *vam = &vat_main;
20305 vat_json_node_t node;
20307 vat_json_init_object (&node);
20308 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
20309 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
20311 vat_json_print (vam->ofp, &node);
20312 vat_json_free (&node);
20314 vam->result_ready = 1;
20318 api_ipfix_classify_table_dump (vat_main_t * vam)
20320 vl_api_ipfix_classify_table_dump_t *mp;
20321 vl_api_control_ping_t *mp_ping;
20324 if (!vam->json_output)
20326 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
20327 "transport_protocol");
20330 /* Construct the API message */
20331 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
20336 /* Use a control ping for synchronization */
20337 MPING (CONTROL_PING, mp_ping);
20345 vl_api_ipfix_classify_table_details_t_handler
20346 (vl_api_ipfix_classify_table_details_t * mp)
20348 vat_main_t *vam = &vat_main;
20349 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
20350 mp->transport_protocol);
20354 vl_api_ipfix_classify_table_details_t_handler_json
20355 (vl_api_ipfix_classify_table_details_t * mp)
20357 vat_json_node_t *node = NULL;
20358 vat_main_t *vam = &vat_main;
20360 if (VAT_JSON_ARRAY != vam->json_tree.type)
20362 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20363 vat_json_init_array (&vam->json_tree);
20366 node = vat_json_array_add (&vam->json_tree);
20367 vat_json_init_object (node);
20369 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
20370 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
20371 vat_json_object_add_uint (node, "transport_protocol",
20372 mp->transport_protocol);
20376 api_sw_interface_span_enable_disable (vat_main_t * vam)
20378 unformat_input_t *i = vam->input;
20379 vl_api_sw_interface_span_enable_disable_t *mp;
20380 u32 src_sw_if_index = ~0;
20381 u32 dst_sw_if_index = ~0;
20386 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20389 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
20391 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
20395 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
20397 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
20399 else if (unformat (i, "disable"))
20401 else if (unformat (i, "rx"))
20403 else if (unformat (i, "tx"))
20405 else if (unformat (i, "both"))
20407 else if (unformat (i, "l2"))
20413 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
20415 mp->sw_if_index_from = htonl (src_sw_if_index);
20416 mp->sw_if_index_to = htonl (dst_sw_if_index);
20426 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
20429 vat_main_t *vam = &vat_main;
20430 u8 *sw_if_from_name = 0;
20431 u8 *sw_if_to_name = 0;
20432 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20433 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20434 char *states[] = { "none", "rx", "tx", "both" };
20438 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20440 if ((u32) p->value[0] == sw_if_index_from)
20442 sw_if_from_name = (u8 *)(p->key);
20446 if ((u32) p->value[0] == sw_if_index_to)
20448 sw_if_to_name = (u8 *)(p->key);
20449 if (sw_if_from_name)
20454 print (vam->ofp, "%20s => %20s (%s)",
20455 sw_if_from_name, sw_if_to_name, states[mp->state]);
20459 vl_api_sw_interface_span_details_t_handler_json
20460 (vl_api_sw_interface_span_details_t * mp)
20462 vat_main_t *vam = &vat_main;
20463 vat_json_node_t *node = NULL;
20464 u8 *sw_if_from_name = 0;
20465 u8 *sw_if_to_name = 0;
20466 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20467 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20471 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20473 if ((u32) p->value[0] == sw_if_index_from)
20475 sw_if_from_name = (u8 *)(p->key);
20479 if ((u32) p->value[0] == sw_if_index_to)
20481 sw_if_to_name = (u8 *)(p->key);
20482 if (sw_if_from_name)
20488 if (VAT_JSON_ARRAY != vam->json_tree.type)
20490 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20491 vat_json_init_array (&vam->json_tree);
20493 node = vat_json_array_add (&vam->json_tree);
20495 vat_json_init_object (node);
20496 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
20497 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
20498 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
20499 if (0 != sw_if_to_name)
20501 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
20503 vat_json_object_add_uint (node, "state", mp->state);
20507 api_sw_interface_span_dump (vat_main_t * vam)
20509 unformat_input_t *input = vam->input;
20510 vl_api_sw_interface_span_dump_t *mp;
20511 vl_api_control_ping_t *mp_ping;
20515 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20517 if (unformat (input, "l2"))
20523 M (SW_INTERFACE_SPAN_DUMP, mp);
20527 /* Use a control ping for synchronization */
20528 MPING (CONTROL_PING, mp_ping);
20536 api_pg_create_interface (vat_main_t * vam)
20538 unformat_input_t *input = vam->input;
20539 vl_api_pg_create_interface_t *mp;
20543 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20545 if (unformat (input, "if_id %d", &if_id))
20552 errmsg ("missing pg interface index");
20556 /* Construct the API message */
20557 M (PG_CREATE_INTERFACE, mp);
20559 mp->interface_id = ntohl (if_id);
20567 api_pg_capture (vat_main_t * vam)
20569 unformat_input_t *input = vam->input;
20570 vl_api_pg_capture_t *mp;
20575 u8 pcap_file_set = 0;
20578 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20580 if (unformat (input, "if_id %d", &if_id))
20582 else if (unformat (input, "pcap %s", &pcap_file))
20584 else if (unformat (input, "count %d", &count))
20586 else if (unformat (input, "disable"))
20593 errmsg ("missing pg interface index");
20596 if (pcap_file_set > 0)
20598 if (vec_len (pcap_file) > 255)
20600 errmsg ("pcap file name is too long");
20605 u32 name_len = vec_len (pcap_file);
20606 /* Construct the API message */
20607 M (PG_CAPTURE, mp);
20609 mp->interface_id = ntohl (if_id);
20610 mp->is_enabled = enable;
20611 mp->count = ntohl (count);
20612 mp->pcap_name_length = ntohl (name_len);
20613 if (pcap_file_set != 0)
20615 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
20617 vec_free (pcap_file);
20625 api_pg_enable_disable (vat_main_t * vam)
20627 unformat_input_t *input = vam->input;
20628 vl_api_pg_enable_disable_t *mp;
20631 u8 stream_name_set = 0;
20632 u8 *stream_name = 0;
20634 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20636 if (unformat (input, "stream %s", &stream_name))
20637 stream_name_set = 1;
20638 else if (unformat (input, "disable"))
20644 if (stream_name_set > 0)
20646 if (vec_len (stream_name) > 255)
20648 errmsg ("stream name too long");
20653 u32 name_len = vec_len (stream_name);
20654 /* Construct the API message */
20655 M (PG_ENABLE_DISABLE, mp);
20657 mp->is_enabled = enable;
20658 if (stream_name_set != 0)
20660 mp->stream_name_length = ntohl (name_len);
20661 clib_memcpy (mp->stream_name, stream_name, name_len);
20663 vec_free (stream_name);
20671 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
20673 unformat_input_t *input = vam->input;
20674 vl_api_ip_source_and_port_range_check_add_del_t *mp;
20676 u16 *low_ports = 0;
20677 u16 *high_ports = 0;
20680 ip4_address_t ip4_addr;
20681 ip6_address_t ip6_addr;
20690 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20692 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
20698 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
20703 else if (unformat (input, "vrf %d", &vrf_id))
20705 else if (unformat (input, "del"))
20707 else if (unformat (input, "port %d", &tmp))
20709 if (tmp == 0 || tmp > 65535)
20711 errmsg ("port %d out of range", tmp);
20715 this_hi = this_low + 1;
20716 vec_add1 (low_ports, this_low);
20717 vec_add1 (high_ports, this_hi);
20719 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
20721 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
20723 errmsg ("incorrect range parameters");
20727 /* Note: in debug CLI +1 is added to high before
20728 passing to real fn that does "the work"
20729 (ip_source_and_port_range_check_add_del).
20730 This fn is a wrapper around the binary API fn a
20731 control plane will call, which expects this increment
20732 to have occurred. Hence letting the binary API control
20733 plane fn do the increment for consistency between VAT
20734 and other control planes.
20737 vec_add1 (low_ports, this_low);
20738 vec_add1 (high_ports, this_hi);
20744 if (prefix_set == 0)
20746 errmsg ("<address>/<mask> not specified");
20752 errmsg ("VRF ID required, not specified");
20759 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20763 if (vec_len (low_ports) == 0)
20765 errmsg ("At least one port or port range required");
20769 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
20771 mp->is_add = is_add;
20776 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
20781 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
20784 mp->mask_length = length;
20785 mp->number_of_ranges = vec_len (low_ports);
20787 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
20788 vec_free (low_ports);
20790 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
20791 vec_free (high_ports);
20793 mp->vrf_id = ntohl (vrf_id);
20801 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
20803 unformat_input_t *input = vam->input;
20804 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
20805 u32 sw_if_index = ~0;
20807 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
20808 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
20812 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20814 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20816 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20818 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
20820 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
20822 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
20824 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
20826 else if (unformat (input, "del"))
20832 if (sw_if_index == ~0)
20834 errmsg ("Interface required but not specified");
20840 errmsg ("VRF ID required but not specified");
20844 if (tcp_out_vrf_id == 0
20845 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
20848 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20852 /* Construct the API message */
20853 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
20855 mp->sw_if_index = ntohl (sw_if_index);
20856 mp->is_add = is_add;
20857 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20858 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20859 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20860 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20865 /* Wait for a reply... */
20871 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
20873 unformat_input_t *i = vam->input;
20874 vl_api_ipsec_gre_add_del_tunnel_t *mp;
20875 u32 local_sa_id = 0;
20876 u32 remote_sa_id = 0;
20877 ip4_address_t src_address;
20878 ip4_address_t dst_address;
20882 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20884 if (unformat (i, "local_sa %d", &local_sa_id))
20886 else if (unformat (i, "remote_sa %d", &remote_sa_id))
20888 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
20890 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
20892 else if (unformat (i, "del"))
20896 clib_warning ("parse error '%U'", format_unformat_error, i);
20901 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
20903 mp->local_sa_id = ntohl (local_sa_id);
20904 mp->remote_sa_id = ntohl (remote_sa_id);
20905 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
20906 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
20907 mp->is_add = is_add;
20915 api_punt (vat_main_t * vam)
20917 unformat_input_t *i = vam->input;
20925 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20927 if (unformat (i, "ip %d", &ipv))
20929 else if (unformat (i, "protocol %d", &protocol))
20931 else if (unformat (i, "port %d", &port))
20933 else if (unformat (i, "del"))
20937 clib_warning ("parse error '%U'", format_unformat_error, i);
20944 mp->is_add = (u8) is_add;
20945 mp->ipv = (u8) ipv;
20946 mp->l4_protocol = (u8) protocol;
20947 mp->l4_port = htons ((u16) port);
20954 static void vl_api_ipsec_gre_tunnel_details_t_handler
20955 (vl_api_ipsec_gre_tunnel_details_t * mp)
20957 vat_main_t *vam = &vat_main;
20959 print (vam->ofp, "%11d%15U%15U%14d%14d",
20960 ntohl (mp->sw_if_index),
20961 format_ip4_address, &mp->src_address,
20962 format_ip4_address, &mp->dst_address,
20963 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
20966 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
20967 (vl_api_ipsec_gre_tunnel_details_t * mp)
20969 vat_main_t *vam = &vat_main;
20970 vat_json_node_t *node = NULL;
20971 struct in_addr ip4;
20973 if (VAT_JSON_ARRAY != vam->json_tree.type)
20975 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20976 vat_json_init_array (&vam->json_tree);
20978 node = vat_json_array_add (&vam->json_tree);
20980 vat_json_init_object (node);
20981 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20982 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
20983 vat_json_object_add_ip4 (node, "src_address", ip4);
20984 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
20985 vat_json_object_add_ip4 (node, "dst_address", ip4);
20986 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
20987 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
20991 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
20993 unformat_input_t *i = vam->input;
20994 vl_api_ipsec_gre_tunnel_dump_t *mp;
20995 vl_api_control_ping_t *mp_ping;
20997 u8 sw_if_index_set = 0;
21000 /* Parse args required to build the message */
21001 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21003 if (unformat (i, "sw_if_index %d", &sw_if_index))
21004 sw_if_index_set = 1;
21009 if (sw_if_index_set == 0)
21014 if (!vam->json_output)
21016 print (vam->ofp, "%11s%15s%15s%14s%14s",
21017 "sw_if_index", "src_address", "dst_address",
21018 "local_sa_id", "remote_sa_id");
21021 /* Get list of gre-tunnel interfaces */
21022 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21024 mp->sw_if_index = htonl (sw_if_index);
21028 /* Use a control ping for synchronization */
21029 MPING (CONTROL_PING, mp_ping);
21037 api_delete_subif (vat_main_t * vam)
21039 unformat_input_t *i = vam->input;
21040 vl_api_delete_subif_t *mp;
21041 u32 sw_if_index = ~0;
21044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21046 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21048 if (unformat (i, "sw_if_index %d", &sw_if_index))
21054 if (sw_if_index == ~0)
21056 errmsg ("missing sw_if_index");
21060 /* Construct the API message */
21061 M (DELETE_SUBIF, mp);
21062 mp->sw_if_index = ntohl (sw_if_index);
21069 #define foreach_pbb_vtr_op \
21070 _("disable", L2_VTR_DISABLED) \
21071 _("pop", L2_VTR_POP_2) \
21072 _("push", L2_VTR_PUSH_2)
21075 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21077 unformat_input_t *i = vam->input;
21078 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21079 u32 sw_if_index = ~0, vtr_op = ~0;
21080 u16 outer_tag = ~0;
21081 u8 dmac[6], smac[6];
21082 u8 dmac_set = 0, smac_set = 0;
21088 /* Shut up coverity */
21089 memset (dmac, 0, sizeof (dmac));
21090 memset (smac, 0, sizeof (smac));
21092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21094 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21096 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21098 else if (unformat (i, "vtr_op %d", &vtr_op))
21100 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21103 else if (unformat (i, "translate_pbb_stag"))
21105 if (unformat (i, "%d", &tmp))
21107 vtr_op = L2_VTR_TRANSLATE_2_1;
21113 ("translate_pbb_stag operation requires outer tag definition");
21117 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21119 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21121 else if (unformat (i, "sid %d", &sid))
21123 else if (unformat (i, "vlanid %d", &tmp))
21127 clib_warning ("parse error '%U'", format_unformat_error, i);
21132 if ((sw_if_index == ~0) || (vtr_op == ~0))
21134 errmsg ("missing sw_if_index or vtr operation");
21137 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21138 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21141 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21145 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21146 mp->sw_if_index = ntohl (sw_if_index);
21147 mp->vtr_op = ntohl (vtr_op);
21148 mp->outer_tag = ntohs (outer_tag);
21149 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21150 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21151 mp->b_vlanid = ntohs (vlanid);
21152 mp->i_sid = ntohl (sid);
21160 api_flow_classify_set_interface (vat_main_t * vam)
21162 unformat_input_t *i = vam->input;
21163 vl_api_flow_classify_set_interface_t *mp;
21165 int sw_if_index_set;
21166 u32 ip4_table_index = ~0;
21167 u32 ip6_table_index = ~0;
21171 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21173 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21174 sw_if_index_set = 1;
21175 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21176 sw_if_index_set = 1;
21177 else if (unformat (i, "del"))
21179 else if (unformat (i, "ip4-table %d", &ip4_table_index))
21181 else if (unformat (i, "ip6-table %d", &ip6_table_index))
21185 clib_warning ("parse error '%U'", format_unformat_error, i);
21190 if (sw_if_index_set == 0)
21192 errmsg ("missing interface name or sw_if_index");
21196 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
21198 mp->sw_if_index = ntohl (sw_if_index);
21199 mp->ip4_table_index = ntohl (ip4_table_index);
21200 mp->ip6_table_index = ntohl (ip6_table_index);
21201 mp->is_add = is_add;
21209 api_flow_classify_dump (vat_main_t * vam)
21211 unformat_input_t *i = vam->input;
21212 vl_api_flow_classify_dump_t *mp;
21213 vl_api_control_ping_t *mp_ping;
21214 u8 type = FLOW_CLASSIFY_N_TABLES;
21217 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
21221 errmsg ("classify table type must be specified");
21225 if (!vam->json_output)
21227 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
21230 M (FLOW_CLASSIFY_DUMP, mp);
21235 /* Use a control ping for synchronization */
21236 MPING (CONTROL_PING, mp_ping);
21239 /* Wait for a reply... */
21245 api_feature_enable_disable (vat_main_t * vam)
21247 unformat_input_t *i = vam->input;
21248 vl_api_feature_enable_disable_t *mp;
21250 u8 *feature_name = 0;
21251 u32 sw_if_index = ~0;
21255 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21257 if (unformat (i, "arc_name %s", &arc_name))
21259 else if (unformat (i, "feature_name %s", &feature_name))
21262 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21264 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21266 else if (unformat (i, "disable"))
21274 errmsg ("missing arc name");
21277 if (vec_len (arc_name) > 63)
21279 errmsg ("arc name too long");
21282 if (feature_name == 0)
21284 errmsg ("missing feature name");
21287 if (vec_len (feature_name) > 63)
21289 errmsg ("feature name too long");
21292 if (sw_if_index == ~0)
21294 errmsg ("missing interface name or sw_if_index");
21298 /* Construct the API message */
21299 M (FEATURE_ENABLE_DISABLE, mp);
21300 mp->sw_if_index = ntohl (sw_if_index);
21301 mp->enable = enable;
21302 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
21303 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
21304 vec_free (arc_name);
21305 vec_free (feature_name);
21313 api_sw_interface_tag_add_del (vat_main_t * vam)
21315 unformat_input_t *i = vam->input;
21316 vl_api_sw_interface_tag_add_del_t *mp;
21317 u32 sw_if_index = ~0;
21322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21324 if (unformat (i, "tag %s", &tag))
21326 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21328 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21330 else if (unformat (i, "del"))
21336 if (sw_if_index == ~0)
21338 errmsg ("missing interface name or sw_if_index");
21342 if (enable && (tag == 0))
21344 errmsg ("no tag specified");
21348 /* Construct the API message */
21349 M (SW_INTERFACE_TAG_ADD_DEL, mp);
21350 mp->sw_if_index = ntohl (sw_if_index);
21351 mp->is_add = enable;
21353 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
21361 static void vl_api_l2_xconnect_details_t_handler
21362 (vl_api_l2_xconnect_details_t * mp)
21364 vat_main_t *vam = &vat_main;
21366 print (vam->ofp, "%15d%15d",
21367 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
21370 static void vl_api_l2_xconnect_details_t_handler_json
21371 (vl_api_l2_xconnect_details_t * mp)
21373 vat_main_t *vam = &vat_main;
21374 vat_json_node_t *node = NULL;
21376 if (VAT_JSON_ARRAY != vam->json_tree.type)
21378 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21379 vat_json_init_array (&vam->json_tree);
21381 node = vat_json_array_add (&vam->json_tree);
21383 vat_json_init_object (node);
21384 vat_json_object_add_uint (node, "rx_sw_if_index",
21385 ntohl (mp->rx_sw_if_index));
21386 vat_json_object_add_uint (node, "tx_sw_if_index",
21387 ntohl (mp->tx_sw_if_index));
21391 api_l2_xconnect_dump (vat_main_t * vam)
21393 vl_api_l2_xconnect_dump_t *mp;
21394 vl_api_control_ping_t *mp_ping;
21397 if (!vam->json_output)
21399 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
21402 M (L2_XCONNECT_DUMP, mp);
21406 /* Use a control ping for synchronization */
21407 MPING (CONTROL_PING, mp_ping);
21415 api_sw_interface_set_mtu (vat_main_t * vam)
21417 unformat_input_t *i = vam->input;
21418 vl_api_sw_interface_set_mtu_t *mp;
21419 u32 sw_if_index = ~0;
21423 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21425 if (unformat (i, "mtu %d", &mtu))
21427 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21429 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21435 if (sw_if_index == ~0)
21437 errmsg ("missing interface name or sw_if_index");
21443 errmsg ("no mtu specified");
21447 /* Construct the API message */
21448 M (SW_INTERFACE_SET_MTU, mp);
21449 mp->sw_if_index = ntohl (sw_if_index);
21450 mp->mtu = ntohs ((u16) mtu);
21458 api_p2p_ethernet_add (vat_main_t * vam)
21460 unformat_input_t *i = vam->input;
21461 vl_api_p2p_ethernet_add_t *mp;
21462 u32 parent_if_index = ~0;
21468 memset (remote_mac, 0, sizeof (remote_mac));
21469 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21471 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21473 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21477 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21479 else if (unformat (i, "sub_id %d", &sub_id))
21483 clib_warning ("parse error '%U'", format_unformat_error, i);
21488 if (parent_if_index == ~0)
21490 errmsg ("missing interface name or sw_if_index");
21495 errmsg ("missing remote mac address");
21500 errmsg ("missing sub-interface id");
21504 M (P2P_ETHERNET_ADD, mp);
21505 mp->parent_if_index = ntohl (parent_if_index);
21506 mp->subif_id = ntohl (sub_id);
21507 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21515 api_p2p_ethernet_del (vat_main_t * vam)
21517 unformat_input_t *i = vam->input;
21518 vl_api_p2p_ethernet_del_t *mp;
21519 u32 parent_if_index = ~0;
21524 memset (remote_mac, 0, sizeof (remote_mac));
21525 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21527 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21529 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21533 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21537 clib_warning ("parse error '%U'", format_unformat_error, i);
21542 if (parent_if_index == ~0)
21544 errmsg ("missing interface name or sw_if_index");
21549 errmsg ("missing remote mac address");
21553 M (P2P_ETHERNET_DEL, mp);
21554 mp->parent_if_index = ntohl (parent_if_index);
21555 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21563 api_lldp_config (vat_main_t * vam)
21565 unformat_input_t *i = vam->input;
21566 vl_api_lldp_config_t *mp;
21568 int tx_interval = 0;
21569 u8 *sys_name = NULL;
21572 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21574 if (unformat (i, "system-name %s", &sys_name))
21576 else if (unformat (i, "tx-hold %d", &tx_hold))
21578 else if (unformat (i, "tx-interval %d", &tx_interval))
21582 clib_warning ("parse error '%U'", format_unformat_error, i);
21587 vec_add1 (sys_name, 0);
21589 M (LLDP_CONFIG, mp);
21590 mp->tx_hold = htonl (tx_hold);
21591 mp->tx_interval = htonl (tx_interval);
21592 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
21593 vec_free (sys_name);
21601 api_sw_interface_set_lldp (vat_main_t * vam)
21603 unformat_input_t *i = vam->input;
21604 vl_api_sw_interface_set_lldp_t *mp;
21605 u32 sw_if_index = ~0;
21607 u8 *port_desc = NULL, *mgmt_oid = NULL;
21608 ip4_address_t ip4_addr;
21609 ip6_address_t ip6_addr;
21612 memset (&ip4_addr, 0, sizeof (ip4_addr));
21613 memset (&ip6_addr, 0, sizeof (ip6_addr));
21615 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21617 if (unformat (i, "disable"))
21620 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21622 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21624 else if (unformat (i, "port-desc %s", &port_desc))
21626 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
21628 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
21630 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
21636 if (sw_if_index == ~0)
21638 errmsg ("missing interface name or sw_if_index");
21642 /* Construct the API message */
21643 vec_add1 (port_desc, 0);
21644 vec_add1 (mgmt_oid, 0);
21645 M (SW_INTERFACE_SET_LLDP, mp);
21646 mp->sw_if_index = ntohl (sw_if_index);
21647 mp->enable = enable;
21648 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
21649 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
21650 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
21651 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
21652 vec_free (port_desc);
21653 vec_free (mgmt_oid);
21661 api_tcp_configure_src_addresses (vat_main_t * vam)
21663 vl_api_tcp_configure_src_addresses_t *mp;
21664 unformat_input_t *i = vam->input;
21665 ip4_address_t v4first, v4last;
21666 ip6_address_t v6first, v6last;
21671 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21673 if (unformat (i, "%U - %U",
21674 unformat_ip4_address, &v4first,
21675 unformat_ip4_address, &v4last))
21679 errmsg ("one range per message (range already set)");
21684 else if (unformat (i, "%U - %U",
21685 unformat_ip6_address, &v6first,
21686 unformat_ip6_address, &v6last))
21690 errmsg ("one range per message (range already set)");
21695 else if (unformat (i, "vrf %d", &vrf_id))
21701 if (range_set == 0)
21703 errmsg ("address range not set");
21707 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
21708 mp->vrf_id = ntohl (vrf_id);
21710 if (range_set == 2)
21713 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
21714 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
21719 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
21720 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
21727 static void vl_api_app_namespace_add_del_reply_t_handler
21728 (vl_api_app_namespace_add_del_reply_t * mp)
21730 vat_main_t *vam = &vat_main;
21731 i32 retval = ntohl (mp->retval);
21732 if (vam->async_mode)
21734 vam->async_errors += (retval < 0);
21738 vam->retval = retval;
21740 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
21741 vam->result_ready = 1;
21745 static void vl_api_app_namespace_add_del_reply_t_handler_json
21746 (vl_api_app_namespace_add_del_reply_t * mp)
21748 vat_main_t *vam = &vat_main;
21749 vat_json_node_t node;
21751 vat_json_init_object (&node);
21752 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
21753 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
21755 vat_json_print (vam->ofp, &node);
21756 vat_json_free (&node);
21758 vam->retval = ntohl (mp->retval);
21759 vam->result_ready = 1;
21763 api_app_namespace_add_del (vat_main_t * vam)
21765 vl_api_app_namespace_add_del_t *mp;
21766 unformat_input_t *i = vam->input;
21767 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
21768 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
21772 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21774 if (unformat (i, "id %_%v%_", &ns_id))
21776 else if (unformat (i, "secret %lu", &secret))
21778 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21779 sw_if_index_set = 1;
21780 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
21782 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
21787 if (!ns_id || !secret_set || !sw_if_index_set)
21789 errmsg ("namespace id, secret and sw_if_index must be set");
21792 if (vec_len (ns_id) > 64)
21794 errmsg ("namespace id too long");
21797 M (APP_NAMESPACE_ADD_DEL, mp);
21799 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
21800 mp->namespace_id_len = vec_len (ns_id);
21801 mp->secret = clib_host_to_net_u64 (secret);
21802 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21803 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
21804 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
21812 api_memfd_segment_create (vat_main_t * vam)
21814 #if VPP_API_TEST_BUILTIN == 0
21815 unformat_input_t *i = vam->input;
21816 vl_api_memfd_segment_create_t *mp;
21817 u64 size = 64 << 20;
21820 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21822 if (unformat (i, "size %U", unformat_memory_size, &size))
21828 M (MEMFD_SEGMENT_CREATE, mp);
21829 mp->requested_size = size;
21835 errmsg ("memfd_segment_create (builtin) not supported");
21841 api_dns_enable_disable (vat_main_t * vam)
21843 unformat_input_t *line_input = vam->input;
21844 vl_api_dns_enable_disable_t *mp;
21845 u8 enable_disable = 1;
21848 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21850 if (unformat (line_input, "disable"))
21851 enable_disable = 0;
21852 if (unformat (line_input, "enable"))
21853 enable_disable = 1;
21858 /* Construct the API message */
21859 M (DNS_ENABLE_DISABLE, mp);
21860 mp->enable = enable_disable;
21864 /* Wait for the reply */
21870 api_dns_resolve_name (vat_main_t * vam)
21872 unformat_input_t *line_input = vam->input;
21873 vl_api_dns_resolve_name_t *mp;
21877 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21879 if (unformat (line_input, "%s", &name))
21885 if (vec_len (name) > 127)
21887 errmsg ("name too long");
21891 /* Construct the API message */
21892 M (DNS_RESOLVE_NAME, mp);
21893 memcpy (mp->name, name, vec_len (name));
21898 /* Wait for the reply */
21904 api_dns_resolve_ip (vat_main_t * vam)
21906 unformat_input_t *line_input = vam->input;
21907 vl_api_dns_resolve_ip_t *mp;
21909 ip4_address_t addr4;
21910 ip6_address_t addr6;
21913 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21915 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
21917 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
21925 errmsg ("missing address");
21929 /* Construct the API message */
21930 M (DNS_RESOLVE_IP, mp);
21931 mp->is_ip6 = is_ip6;
21933 memcpy (mp->address, &addr6, sizeof (addr6));
21935 memcpy (mp->address, &addr4, sizeof (addr4));
21939 /* Wait for the reply */
21945 api_dns_name_server_add_del (vat_main_t * vam)
21947 unformat_input_t *i = vam->input;
21948 vl_api_dns_name_server_add_del_t *mp;
21950 ip6_address_t ip6_server;
21951 ip4_address_t ip4_server;
21956 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21958 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
21960 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
21962 else if (unformat (i, "del"))
21966 clib_warning ("parse error '%U'", format_unformat_error, i);
21971 if (ip4_set && ip6_set)
21973 errmsg ("Only one server address allowed per message");
21976 if ((ip4_set + ip6_set) == 0)
21978 errmsg ("Server address required");
21982 /* Construct the API message */
21983 M (DNS_NAME_SERVER_ADD_DEL, mp);
21987 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
21992 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
21996 mp->is_add = is_add;
22001 /* Wait for a reply, return good/bad news */
22007 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22009 vat_main_t *vam = &vat_main;
22014 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22015 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22016 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22017 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22018 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22019 clib_net_to_host_u32 (mp->action_index), mp->tag);
22024 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22025 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22026 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22027 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22028 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22029 clib_net_to_host_u32 (mp->action_index), mp->tag);
22034 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22037 vat_main_t *vam = &vat_main;
22038 vat_json_node_t *node = NULL;
22039 struct in6_addr ip6;
22040 struct in_addr ip4;
22042 if (VAT_JSON_ARRAY != vam->json_tree.type)
22044 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22045 vat_json_init_array (&vam->json_tree);
22047 node = vat_json_array_add (&vam->json_tree);
22048 vat_json_init_object (node);
22050 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22051 vat_json_object_add_uint (node, "appns_index",
22052 clib_net_to_host_u32 (mp->appns_index));
22053 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22054 vat_json_object_add_uint (node, "scope", mp->scope);
22055 vat_json_object_add_uint (node, "action_index",
22056 clib_net_to_host_u32 (mp->action_index));
22057 vat_json_object_add_uint (node, "lcl_port",
22058 clib_net_to_host_u16 (mp->lcl_port));
22059 vat_json_object_add_uint (node, "rmt_port",
22060 clib_net_to_host_u16 (mp->rmt_port));
22061 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22062 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22063 vat_json_object_add_string_copy (node, "tag", mp->tag);
22066 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22067 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22068 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22069 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22073 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22074 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22075 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22076 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22081 api_session_rule_add_del (vat_main_t * vam)
22083 vl_api_session_rule_add_del_t *mp;
22084 unformat_input_t *i = vam->input;
22085 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22086 u32 appns_index = 0, scope = 0;
22087 ip4_address_t lcl_ip4, rmt_ip4;
22088 ip6_address_t lcl_ip6, rmt_ip6;
22089 u8 is_ip4 = 1, conn_set = 0;
22090 u8 is_add = 1, *tag = 0;
22093 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22095 if (unformat (i, "del"))
22097 else if (unformat (i, "add"))
22099 else if (unformat (i, "proto tcp"))
22101 else if (unformat (i, "proto udp"))
22103 else if (unformat (i, "appns %d", &appns_index))
22105 else if (unformat (i, "scope %d", &scope))
22107 else if (unformat (i, "tag %_%v%_", &tag))
22111 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22112 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22120 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22121 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22127 else if (unformat (i, "action %d", &action))
22132 if (proto == ~0 || !conn_set || action == ~0)
22134 errmsg ("transport proto, connection and action must be set");
22140 errmsg ("scope should be 0-3");
22144 M (SESSION_RULE_ADD_DEL, mp);
22146 mp->is_ip4 = is_ip4;
22147 mp->transport_proto = proto;
22148 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
22149 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
22150 mp->lcl_plen = lcl_plen;
22151 mp->rmt_plen = rmt_plen;
22152 mp->action_index = clib_host_to_net_u32 (action);
22153 mp->appns_index = clib_host_to_net_u32 (appns_index);
22155 mp->is_add = is_add;
22158 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
22159 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
22163 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
22164 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
22168 clib_memcpy (mp->tag, tag, vec_len (tag));
22178 api_session_rules_dump (vat_main_t * vam)
22180 vl_api_session_rules_dump_t *mp;
22181 vl_api_control_ping_t *mp_ping;
22184 if (!vam->json_output)
22186 print (vam->ofp, "%=20s", "Session Rules");
22189 M (SESSION_RULES_DUMP, mp);
22193 /* Use a control ping for synchronization */
22194 MPING (CONTROL_PING, mp_ping);
22197 /* Wait for a reply... */
22203 api_ip_container_proxy_add_del (vat_main_t * vam)
22205 vl_api_ip_container_proxy_add_del_t *mp;
22206 unformat_input_t *i = vam->input;
22207 u32 plen = ~0, sw_if_index = ~0;
22214 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22216 if (unformat (i, "del"))
22218 else if (unformat (i, "add"))
22220 if (unformat (i, "%U", unformat_ip4_address, &ip4))
22225 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
22230 else if (unformat (i, "sw_if_index %u", &sw_if_index))
22235 if (sw_if_index == ~0 || plen == ~0)
22237 errmsg ("address and sw_if_index must be set");
22241 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
22243 mp->is_ip4 = is_ip4;
22244 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22246 mp->is_add = is_add;
22248 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
22250 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
22258 q_or_quit (vat_main_t * vam)
22260 #if VPP_API_TEST_BUILTIN == 0
22261 longjmp (vam->jump_buf, 1);
22263 return 0; /* not so much */
22267 q (vat_main_t * vam)
22269 return q_or_quit (vam);
22273 quit (vat_main_t * vam)
22275 return q_or_quit (vam);
22279 comment (vat_main_t * vam)
22285 cmd_cmp (void *a1, void *a2)
22290 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
22294 help (vat_main_t * vam)
22299 unformat_input_t *i = vam->input;
22302 if (unformat (i, "%s", &name))
22306 vec_add1 (name, 0);
22308 hs = hash_get_mem (vam->help_by_name, name);
22310 print (vam->ofp, "usage: %s %s", name, hs[0]);
22312 print (vam->ofp, "No such msg / command '%s'", name);
22317 print (vam->ofp, "Help is available for the following:");
22320 hash_foreach_pair (p, vam->function_by_name,
22322 vec_add1 (cmds, (u8 *)(p->key));
22326 vec_sort_with_function (cmds, cmd_cmp);
22328 for (j = 0; j < vec_len (cmds); j++)
22329 print (vam->ofp, "%s", cmds[j]);
22336 set (vat_main_t * vam)
22338 u8 *name = 0, *value = 0;
22339 unformat_input_t *i = vam->input;
22341 if (unformat (i, "%s", &name))
22343 /* The input buffer is a vector, not a string. */
22344 value = vec_dup (i->buffer);
22345 vec_delete (value, i->index, 0);
22346 /* Almost certainly has a trailing newline */
22347 if (value[vec_len (value) - 1] == '\n')
22348 value[vec_len (value) - 1] = 0;
22349 /* Make sure it's a proper string, one way or the other */
22350 vec_add1 (value, 0);
22351 (void) clib_macro_set_value (&vam->macro_main,
22352 (char *) name, (char *) value);
22355 errmsg ("usage: set <name> <value>");
22363 unset (vat_main_t * vam)
22367 if (unformat (vam->input, "%s", &name))
22368 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
22369 errmsg ("unset: %s wasn't set", name);
22382 macro_sort_cmp (void *a1, void *a2)
22384 macro_sort_t *s1 = a1;
22385 macro_sort_t *s2 = a2;
22387 return strcmp ((char *) (s1->name), (char *) (s2->name));
22391 dump_macro_table (vat_main_t * vam)
22393 macro_sort_t *sort_me = 0, *sm;
22398 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
22400 vec_add2 (sort_me, sm, 1);
22401 sm->name = (u8 *)(p->key);
22402 sm->value = (u8 *) (p->value[0]);
22406 vec_sort_with_function (sort_me, macro_sort_cmp);
22408 if (vec_len (sort_me))
22409 print (vam->ofp, "%-15s%s", "Name", "Value");
22411 print (vam->ofp, "The macro table is empty...");
22413 for (i = 0; i < vec_len (sort_me); i++)
22414 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
22419 dump_node_table (vat_main_t * vam)
22422 vlib_node_t *node, *next_node;
22424 if (vec_len (vam->graph_nodes) == 0)
22426 print (vam->ofp, "Node table empty, issue get_node_graph...");
22430 for (i = 0; i < vec_len (vam->graph_nodes); i++)
22432 node = vam->graph_nodes[i];
22433 print (vam->ofp, "[%d] %s", i, node->name);
22434 for (j = 0; j < vec_len (node->next_nodes); j++)
22436 if (node->next_nodes[j] != ~0)
22438 next_node = vam->graph_nodes[node->next_nodes[j]];
22439 print (vam->ofp, " [%d] %s", j, next_node->name);
22447 value_sort_cmp (void *a1, void *a2)
22449 name_sort_t *n1 = a1;
22450 name_sort_t *n2 = a2;
22452 if (n1->value < n2->value)
22454 if (n1->value > n2->value)
22461 dump_msg_api_table (vat_main_t * vam)
22463 api_main_t *am = &api_main;
22464 name_sort_t *nses = 0, *ns;
22469 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
22471 vec_add2 (nses, ns, 1);
22472 ns->name = (u8 *)(hp->key);
22473 ns->value = (u32) hp->value[0];
22477 vec_sort_with_function (nses, value_sort_cmp);
22479 for (i = 0; i < vec_len (nses); i++)
22480 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
22486 get_msg_id (vat_main_t * vam)
22491 if (unformat (vam->input, "%s", &name_and_crc))
22493 message_index = vl_api_get_msg_index (name_and_crc);
22494 if (message_index == ~0)
22496 print (vam->ofp, " '%s' not found", name_and_crc);
22499 print (vam->ofp, " '%s' has message index %d",
22500 name_and_crc, message_index);
22503 errmsg ("name_and_crc required...");
22508 search_node_table (vat_main_t * vam)
22510 unformat_input_t *line_input = vam->input;
22513 vlib_node_t *node, *next_node;
22516 if (vam->graph_node_index_by_name == 0)
22518 print (vam->ofp, "Node table empty, issue get_node_graph...");
22522 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22524 if (unformat (line_input, "%s", &node_to_find))
22526 vec_add1 (node_to_find, 0);
22527 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
22530 print (vam->ofp, "%s not found...", node_to_find);
22533 node = vam->graph_nodes[p[0]];
22534 print (vam->ofp, "[%d] %s", p[0], node->name);
22535 for (j = 0; j < vec_len (node->next_nodes); j++)
22537 if (node->next_nodes[j] != ~0)
22539 next_node = vam->graph_nodes[node->next_nodes[j]];
22540 print (vam->ofp, " [%d] %s", j, next_node->name);
22547 clib_warning ("parse error '%U'", format_unformat_error,
22553 vec_free (node_to_find);
22562 script (vat_main_t * vam)
22564 #if (VPP_API_TEST_BUILTIN==0)
22566 char *save_current_file;
22567 unformat_input_t save_input;
22568 jmp_buf save_jump_buf;
22569 u32 save_line_number;
22571 FILE *new_fp, *save_ifp;
22573 if (unformat (vam->input, "%s", &s))
22575 new_fp = fopen ((char *) s, "r");
22578 errmsg ("Couldn't open script file %s", s);
22585 errmsg ("Missing script name");
22589 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
22590 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
22591 save_ifp = vam->ifp;
22592 save_line_number = vam->input_line_number;
22593 save_current_file = (char *) vam->current_file;
22595 vam->input_line_number = 0;
22597 vam->current_file = s;
22600 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
22601 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
22602 vam->ifp = save_ifp;
22603 vam->input_line_number = save_line_number;
22604 vam->current_file = (u8 *) save_current_file;
22609 clib_warning ("use the exec command...");
22615 echo (vat_main_t * vam)
22617 print (vam->ofp, "%v", vam->input->buffer);
22621 /* List of API message constructors, CLI names map to api_xxx */
22622 #define foreach_vpe_api_msg \
22623 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
22624 _(sw_interface_dump,"") \
22625 _(sw_interface_set_flags, \
22626 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
22627 _(sw_interface_add_del_address, \
22628 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
22629 _(sw_interface_set_rx_mode, \
22630 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
22631 _(sw_interface_set_table, \
22632 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
22633 _(sw_interface_set_mpls_enable, \
22634 "<intfc> | sw_if_index [disable | dis]") \
22635 _(sw_interface_set_vpath, \
22636 "<intfc> | sw_if_index <id> enable | disable") \
22637 _(sw_interface_set_vxlan_bypass, \
22638 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22639 _(sw_interface_set_geneve_bypass, \
22640 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22641 _(sw_interface_set_l2_xconnect, \
22642 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22643 "enable | disable") \
22644 _(sw_interface_set_l2_bridge, \
22645 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
22646 "[shg <split-horizon-group>] [bvi]\n" \
22647 "enable | disable") \
22648 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
22649 _(bridge_domain_add_del, \
22650 "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") \
22651 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
22653 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
22654 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
22655 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
22657 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22659 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22661 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
22663 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
22665 "<vpp-if-name> | sw_if_index <id>") \
22666 _(sw_interface_tap_dump, "") \
22668 "name <name> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
22670 "<vpp-if-name> | sw_if_index <id>") \
22671 _(sw_interface_tap_v2_dump, "") \
22672 _(ip_table_add_del, \
22673 "table-id <n> [ipv6]\n") \
22674 _(ip_add_del_route, \
22675 "<addr>/<mask> via <addr> [table-id <n>]\n" \
22676 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
22677 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
22678 "[multipath] [count <n>]") \
22679 _(ip_mroute_add_del, \
22680 "<src> <grp>/<mask> [table-id <n>]\n" \
22681 "[<intfc> | sw_if_index <id>] [local] [del]") \
22682 _(mpls_table_add_del, \
22683 "table-id <n>\n") \
22684 _(mpls_route_add_del, \
22685 "<label> <eos> via <addr> [table-id <n>]\n" \
22686 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
22687 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
22688 "[multipath] [count <n>]") \
22689 _(mpls_ip_bind_unbind, \
22690 "<label> <addr/len>") \
22691 _(mpls_tunnel_add_del, \
22692 " via <addr> [table-id <n>]\n" \
22693 "sw_if_index <id>] [l2] [del]") \
22694 _(bier_table_add_del, \
22695 "<label> <sub-domain> <set> <bsl> [del]") \
22696 _(bier_route_add_del, \
22697 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
22698 "[<intfc> | sw_if_index <id>]" \
22699 "[weight <n>] [del] [multipath]") \
22700 _(proxy_arp_add_del, \
22701 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
22702 _(proxy_arp_intfc_enable_disable, \
22703 "<intfc> | sw_if_index <id> enable | disable") \
22704 _(sw_interface_set_unnumbered, \
22705 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
22706 _(ip_neighbor_add_del, \
22707 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
22708 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
22709 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
22710 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
22711 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
22712 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
22713 "[outer_vlan_id_any][inner_vlan_id_any]") \
22714 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
22715 _(reset_fib, "vrf <n> [ipv6]") \
22716 _(dhcp_proxy_config, \
22717 "svr <v46-address> src <v46-address>\n" \
22718 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
22719 _(dhcp_proxy_set_vss, \
22720 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
22721 _(dhcp_proxy_dump, "ip6") \
22722 _(dhcp_client_config, \
22723 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
22724 _(set_ip_flow_hash, \
22725 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
22726 _(sw_interface_ip6_enable_disable, \
22727 "<intfc> | sw_if_index <id> enable | disable") \
22728 _(sw_interface_ip6_set_link_local_address, \
22729 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
22730 _(ip6nd_proxy_add_del, \
22731 "<intfc> | sw_if_index <id> <ip6-address>") \
22732 _(ip6nd_proxy_dump, "") \
22733 _(sw_interface_ip6nd_ra_prefix, \
22734 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
22735 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
22736 "[nolink] [isno]") \
22737 _(sw_interface_ip6nd_ra_config, \
22738 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
22739 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
22740 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
22741 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
22742 _(l2_patch_add_del, \
22743 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22744 "enable | disable") \
22745 _(sr_localsid_add_del, \
22746 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
22747 "fib-table <num> (end.psp) sw_if_index <num>") \
22748 _(classify_add_del_table, \
22749 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
22750 " [del] [del-chain] mask <mask-value>\n" \
22751 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
22752 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
22753 _(classify_add_del_session, \
22754 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
22755 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
22756 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
22757 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
22758 _(classify_set_interface_ip_table, \
22759 "<intfc> | sw_if_index <nn> table <nn>") \
22760 _(classify_set_interface_l2_tables, \
22761 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22762 " [other-table <nn>]") \
22763 _(get_node_index, "node <node-name") \
22764 _(add_node_next, "node <node-name> next <next-node-name>") \
22765 _(l2tpv3_create_tunnel, \
22766 "client_address <ip6-addr> our_address <ip6-addr>\n" \
22767 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
22768 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
22769 _(l2tpv3_set_tunnel_cookies, \
22770 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
22771 "[new_remote_cookie <nn>]\n") \
22772 _(l2tpv3_interface_enable_disable, \
22773 "<intfc> | sw_if_index <nn> enable | disable") \
22774 _(l2tpv3_set_lookup_key, \
22775 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
22776 _(sw_if_l2tpv3_tunnel_dump, "") \
22777 _(vxlan_add_del_tunnel, \
22778 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22779 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22780 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22781 _(geneve_add_del_tunnel, \
22782 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22783 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22784 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22785 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22786 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22787 _(gre_add_del_tunnel, \
22788 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
22789 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22790 _(l2_fib_clear_table, "") \
22791 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
22792 _(l2_interface_vlan_tag_rewrite, \
22793 "<intfc> | sw_if_index <nn> \n" \
22794 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
22795 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
22796 _(create_vhost_user_if, \
22797 "socket <filename> [server] [renumber <dev_instance>] " \
22798 "[mac <mac_address>]") \
22799 _(modify_vhost_user_if, \
22800 "<intfc> | sw_if_index <nn> socket <filename>\n" \
22801 "[server] [renumber <dev_instance>]") \
22802 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
22803 _(sw_interface_vhost_user_dump, "") \
22804 _(show_version, "") \
22805 _(vxlan_gpe_add_del_tunnel, \
22806 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
22807 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22808 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
22809 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
22810 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22811 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
22812 _(interface_name_renumber, \
22813 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
22814 _(input_acl_set_interface, \
22815 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22816 " [l2-table <nn>] [del]") \
22817 _(want_ip4_arp_events, "address <ip4-address> [del]") \
22818 _(want_ip6_nd_events, "address <ip6-address> [del]") \
22819 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
22820 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
22821 _(ip_dump, "ipv4 | ipv6") \
22822 _(ipsec_spd_add_del, "spd_id <n> [del]") \
22823 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
22825 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
22826 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
22827 " integ_alg <alg> integ_key <hex>") \
22828 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
22829 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
22830 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
22831 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
22832 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
22833 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
22834 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
22835 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
22836 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
22837 _(ipsec_sa_dump, "[sa_id <n>]") \
22838 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
22839 " <alg> <hex>\n") \
22840 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
22841 _(ikev2_profile_add_del, "name <profile_name> [del]") \
22842 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
22843 "(auth_data 0x<data> | auth_data <data>)") \
22844 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
22845 "(id_data 0x<data> | id_data <data>) (local|remote)") \
22846 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
22847 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
22848 "(local|remote)") \
22849 _(ikev2_set_local_key, "file <absolute_file_path>") \
22850 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
22851 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
22852 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
22853 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
22854 _(ikev2_initiate_sa_init, "<profile_name>") \
22855 _(ikev2_initiate_del_ike_sa, "<ispi>") \
22856 _(ikev2_initiate_del_child_sa, "<ispi>") \
22857 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
22858 _(delete_loopback,"sw_if_index <nn>") \
22859 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
22860 _(map_add_domain, \
22861 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
22862 "ip6-src <ip6addr> " \
22863 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
22864 _(map_del_domain, "index <n>") \
22865 _(map_add_del_rule, \
22866 "index <n> psid <n> dst <ip6addr> [del]") \
22867 _(map_domain_dump, "") \
22868 _(map_rule_dump, "index <map-domain>") \
22869 _(want_interface_events, "enable|disable") \
22870 _(want_stats,"enable|disable") \
22871 _(get_first_msg_id, "client <name>") \
22872 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
22873 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
22874 "fib-id <nn> [ip4][ip6][default]") \
22875 _(get_node_graph, " ") \
22876 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
22877 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
22878 _(ioam_disable, "") \
22879 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
22880 " sw_if_index <sw_if_index> p <priority> " \
22881 "w <weight>] [del]") \
22882 _(one_add_del_locator, "locator-set <locator_name> " \
22883 "iface <intf> | sw_if_index <sw_if_index> " \
22884 "p <priority> w <weight> [del]") \
22885 _(one_add_del_local_eid,"vni <vni> eid " \
22886 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22887 "locator-set <locator_name> [del]" \
22888 "[key-id sha1|sha256 secret-key <secret-key>]")\
22889 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
22890 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
22891 _(one_enable_disable, "enable|disable") \
22892 _(one_map_register_enable_disable, "enable|disable") \
22893 _(one_map_register_fallback_threshold, "<value>") \
22894 _(one_rloc_probe_enable_disable, "enable|disable") \
22895 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22897 "rloc <locator> p <prio> " \
22898 "w <weight> [rloc <loc> ... ] " \
22899 "action <action> [del-all]") \
22900 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22902 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22903 _(one_use_petr, "ip-address> | disable") \
22904 _(one_map_request_mode, "src-dst|dst-only") \
22905 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22906 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22907 _(one_locator_set_dump, "[local | remote]") \
22908 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
22909 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22910 "[local] | [remote]") \
22911 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
22912 _(one_ndp_bd_get, "") \
22913 _(one_ndp_entries_get, "bd <bridge-domain>") \
22914 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
22915 _(one_l2_arp_bd_get, "") \
22916 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
22917 _(one_stats_enable_disable, "enable|disalbe") \
22918 _(show_one_stats_enable_disable, "") \
22919 _(one_eid_table_vni_dump, "") \
22920 _(one_eid_table_map_dump, "l2|l3") \
22921 _(one_map_resolver_dump, "") \
22922 _(one_map_server_dump, "") \
22923 _(one_adjacencies_get, "vni <vni>") \
22924 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
22925 _(show_one_rloc_probe_state, "") \
22926 _(show_one_map_register_state, "") \
22927 _(show_one_status, "") \
22928 _(one_stats_dump, "") \
22929 _(one_stats_flush, "") \
22930 _(one_get_map_request_itr_rlocs, "") \
22931 _(one_map_register_set_ttl, "<ttl>") \
22932 _(one_set_transport_protocol, "udp|api") \
22933 _(one_get_transport_protocol, "") \
22934 _(one_enable_disable_xtr_mode, "enable|disable") \
22935 _(one_show_xtr_mode, "") \
22936 _(one_enable_disable_pitr_mode, "enable|disable") \
22937 _(one_show_pitr_mode, "") \
22938 _(one_enable_disable_petr_mode, "enable|disable") \
22939 _(one_show_petr_mode, "") \
22940 _(show_one_nsh_mapping, "") \
22941 _(show_one_pitr, "") \
22942 _(show_one_use_petr, "") \
22943 _(show_one_map_request_mode, "") \
22944 _(show_one_map_register_ttl, "") \
22945 _(show_one_map_register_fallback_threshold, "") \
22946 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
22947 " sw_if_index <sw_if_index> p <priority> " \
22948 "w <weight>] [del]") \
22949 _(lisp_add_del_locator, "locator-set <locator_name> " \
22950 "iface <intf> | sw_if_index <sw_if_index> " \
22951 "p <priority> w <weight> [del]") \
22952 _(lisp_add_del_local_eid,"vni <vni> eid " \
22953 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22954 "locator-set <locator_name> [del]" \
22955 "[key-id sha1|sha256 secret-key <secret-key>]") \
22956 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
22957 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
22958 _(lisp_enable_disable, "enable|disable") \
22959 _(lisp_map_register_enable_disable, "enable|disable") \
22960 _(lisp_rloc_probe_enable_disable, "enable|disable") \
22961 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22963 "rloc <locator> p <prio> " \
22964 "w <weight> [rloc <loc> ... ] " \
22965 "action <action> [del-all]") \
22966 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22968 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22969 _(lisp_use_petr, "<ip-address> | disable") \
22970 _(lisp_map_request_mode, "src-dst|dst-only") \
22971 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22972 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22973 _(lisp_locator_set_dump, "[local | remote]") \
22974 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
22975 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22976 "[local] | [remote]") \
22977 _(lisp_eid_table_vni_dump, "") \
22978 _(lisp_eid_table_map_dump, "l2|l3") \
22979 _(lisp_map_resolver_dump, "") \
22980 _(lisp_map_server_dump, "") \
22981 _(lisp_adjacencies_get, "vni <vni>") \
22982 _(gpe_fwd_entry_vnis_get, "") \
22983 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
22984 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
22985 "[table <table-id>]") \
22986 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
22987 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
22988 _(gpe_set_encap_mode, "lisp|vxlan") \
22989 _(gpe_get_encap_mode, "") \
22990 _(lisp_gpe_add_del_iface, "up|down") \
22991 _(lisp_gpe_enable_disable, "enable|disable") \
22992 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
22993 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
22994 _(show_lisp_rloc_probe_state, "") \
22995 _(show_lisp_map_register_state, "") \
22996 _(show_lisp_status, "") \
22997 _(lisp_get_map_request_itr_rlocs, "") \
22998 _(show_lisp_pitr, "") \
22999 _(show_lisp_use_petr, "") \
23000 _(show_lisp_map_request_mode, "") \
23001 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
23002 _(af_packet_delete, "name <host interface name>") \
23003 _(policer_add_del, "name <policer name> <params> [del]") \
23004 _(policer_dump, "[name <policer name>]") \
23005 _(policer_classify_set_interface, \
23006 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23007 " [l2-table <nn>] [del]") \
23008 _(policer_classify_dump, "type [ip4|ip6|l2]") \
23009 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
23010 "[master|slave]") \
23011 _(netmap_delete, "name <interface name>") \
23012 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
23013 _(mpls_fib_dump, "") \
23014 _(classify_table_ids, "") \
23015 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
23016 _(classify_table_info, "table_id <nn>") \
23017 _(classify_session_dump, "table_id <nn>") \
23018 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
23019 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
23020 "[template_interval <nn>] [udp_checksum]") \
23021 _(ipfix_exporter_dump, "") \
23022 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
23023 _(ipfix_classify_stream_dump, "") \
23024 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
23025 _(ipfix_classify_table_dump, "") \
23026 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
23027 _(sw_interface_span_dump, "[l2]") \
23028 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
23029 _(pg_create_interface, "if_id <nn>") \
23030 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
23031 _(pg_enable_disable, "[stream <id>] disable") \
23032 _(ip_source_and_port_range_check_add_del, \
23033 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
23034 _(ip_source_and_port_range_check_interface_add_del, \
23035 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
23036 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
23037 _(ipsec_gre_add_del_tunnel, \
23038 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
23039 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
23040 _(delete_subif,"<intfc> | sw_if_index <nn>") \
23041 _(l2_interface_pbb_tag_rewrite, \
23042 "<intfc> | sw_if_index <nn> \n" \
23043 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
23044 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
23045 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
23046 _(flow_classify_set_interface, \
23047 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
23048 _(flow_classify_dump, "type [ip4|ip6]") \
23049 _(ip_fib_dump, "") \
23050 _(ip_mfib_dump, "") \
23051 _(ip6_fib_dump, "") \
23052 _(ip6_mfib_dump, "") \
23053 _(feature_enable_disable, "arc_name <arc_name> " \
23054 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
23055 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
23057 _(l2_xconnect_dump, "") \
23058 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
23059 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
23060 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
23061 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
23062 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
23063 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
23064 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
23065 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
23066 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
23067 _(memfd_segment_create,"size <nnn>") \
23068 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
23069 _(dns_enable_disable, "[enable][disable]") \
23070 _(dns_name_server_add_del, "<ip-address> [del]") \
23071 _(dns_resolve_name, "<hostname>") \
23072 _(dns_resolve_ip, "<ip4|ip6>") \
23073 _(dns_name_server_add_del, "<ip-address> [del]") \
23074 _(dns_resolve_name, "<hostname>") \
23075 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
23076 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
23077 _(session_rules_dump, "") \
23078 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
23080 /* List of command functions, CLI names map directly to functions */
23081 #define foreach_cli_function \
23082 _(comment, "usage: comment <ignore-rest-of-line>") \
23083 _(dump_interface_table, "usage: dump_interface_table") \
23084 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
23085 _(dump_ipv4_table, "usage: dump_ipv4_table") \
23086 _(dump_ipv6_table, "usage: dump_ipv6_table") \
23087 _(dump_stats_table, "usage: dump_stats_table") \
23088 _(dump_macro_table, "usage: dump_macro_table ") \
23089 _(dump_node_table, "usage: dump_node_table") \
23090 _(dump_msg_api_table, "usage: dump_msg_api_table") \
23091 _(get_msg_id, "usage: get_msg_id name_and_crc") \
23092 _(echo, "usage: echo <message>") \
23093 _(exec, "usage: exec <vpe-debug-CLI-command>") \
23094 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
23095 _(help, "usage: help") \
23096 _(q, "usage: quit") \
23097 _(quit, "usage: quit") \
23098 _(search_node_table, "usage: search_node_table <name>...") \
23099 _(set, "usage: set <variable-name> <value>") \
23100 _(script, "usage: script <file-name>") \
23101 _(unset, "usage: unset <variable-name>")
23103 static void vl_api_##n##_t_handler_uni \
23104 (vl_api_##n##_t * mp) \
23106 vat_main_t * vam = &vat_main; \
23107 if (vam->json_output) { \
23108 vl_api_##n##_t_handler_json(mp); \
23110 vl_api_##n##_t_handler(mp); \
23113 foreach_vpe_api_reply_msg;
23114 #if VPP_API_TEST_BUILTIN == 0
23115 foreach_standalone_reply_msg;
23120 vat_api_hookup (vat_main_t * vam)
23123 vl_msg_api_set_handlers(VL_API_##N, #n, \
23124 vl_api_##n##_t_handler_uni, \
23126 vl_api_##n##_t_endian, \
23127 vl_api_##n##_t_print, \
23128 sizeof(vl_api_##n##_t), 1);
23129 foreach_vpe_api_reply_msg;
23130 #if VPP_API_TEST_BUILTIN == 0
23131 foreach_standalone_reply_msg;
23135 #if (VPP_API_TEST_BUILTIN==0)
23136 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
23138 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
23140 vam->function_by_name = hash_create_string (0, sizeof (uword));
23142 vam->help_by_name = hash_create_string (0, sizeof (uword));
23145 /* API messages we can send */
23146 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
23147 foreach_vpe_api_msg;
23151 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23152 foreach_vpe_api_msg;
23155 /* CLI functions */
23156 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
23157 foreach_cli_function;
23161 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23162 foreach_cli_function;
23166 #if VPP_API_TEST_BUILTIN
23167 static clib_error_t *
23168 vat_api_hookup_shim (vlib_main_t * vm)
23170 vat_api_hookup (&vat_main);
23174 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
23178 * fd.io coding-style-patch-verification: ON
23181 * eval: (c-set-style "gnu")