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 <vlibapi/api.h>
22 #include <vlibmemory/api.h>
23 #include <vlibsocket/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/sr/sr_packet.h>
26 #include <vnet/l2/l2_input.h>
27 #include <vnet/l2tp/l2tp.h>
28 #include <vnet/vxlan/vxlan.h>
29 #include <vnet/gre/gre.h>
30 #include <vnet/vxlan-gpe/vxlan_gpe.h>
31 #include <vnet/lisp-gpe/lisp_gpe.h>
33 #include <vpp/api/vpe_msg_enum.h>
34 #include <vnet/l2/l2_classify.h>
35 #include <vnet/l2/l2_vtr.h>
36 #include <vnet/classify/input_acl.h>
37 #include <vnet/classify/policer_classify.h>
38 #include <vnet/classify/flow_classify.h>
39 #include <vnet/mpls/mpls.h>
40 #include <vnet/ipsec/ipsec.h>
41 #include <vnet/ipsec/ikev2.h>
43 #include <vnet/map/map.h>
44 #include <vnet/cop/cop.h>
45 #include <vnet/ip/ip6_hop_by_hop.h>
46 #include <vnet/ip/ip_source_and_port_range_check.h>
47 #include <vnet/policer/xlate.h>
48 #include <vnet/span/span.h>
49 #include <vnet/policer/policer.h>
50 #include <vnet/policer/police.h>
52 #include "vat/json_format.h"
57 #define vl_typedefs /* define message structures */
58 #include <vpp/api/vpe_all_api_h.h>
61 /* declare message handlers for each api */
63 #define vl_endianfun /* define message structures */
64 #include <vpp/api/vpe_all_api_h.h>
67 /* instantiate all the print functions we know about */
68 #define vl_print(handle, ...)
70 #include <vpp/api/vpe_all_api_h.h>
73 #define __plugin_msg_base 0
74 #include <vlibapi/vat_helper_macros.h>
77 vat_time_now (vat_main_t * vam)
79 #if VPP_API_TEST_BUILTIN
80 return vlib_time_now (vam->vlib_main);
82 return clib_time_now (&vam->clib_time);
87 errmsg (char *fmt, ...)
89 vat_main_t *vam = &vat_main;
94 s = va_format (0, fmt, &va);
99 #if VPP_API_TEST_BUILTIN
100 vlib_cli_output (vam->vlib_main, (char *) s);
103 if (vam->ifp != stdin)
104 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
105 vam->input_line_number);
106 fformat (vam->ofp, (char *) s);
115 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
117 vat_main_t *vam = va_arg (*args, vat_main_t *);
118 u32 *result = va_arg (*args, u32 *);
122 if (!unformat (input, "%s", &if_name))
125 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
132 #if VPP_API_TEST_BUILTIN == 0
133 /* Parse an IP4 address %d.%d.%d.%d. */
135 unformat_ip4_address (unformat_input_t * input, va_list * args)
137 u8 *result = va_arg (*args, u8 *);
140 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
143 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
155 unformat_ethernet_address (unformat_input_t * input, va_list * args)
157 u8 *result = va_arg (*args, u8 *);
160 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
161 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
165 for (i = 0; i < 6; i++)
166 if (a[i] >= (1 << 8))
169 for (i = 0; i < 6; i++)
175 /* Returns ethernet type as an int in host byte order. */
177 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
180 u16 *result = va_arg (*args, u16 *);
184 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
186 if (type >= (1 << 16))
194 /* Parse an IP6 address. */
196 unformat_ip6_address (unformat_input_t * input, va_list * args)
198 ip6_address_t *result = va_arg (*args, ip6_address_t *);
200 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
201 uword c, n_colon, double_colon_index;
203 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
204 double_colon_index = ARRAY_LEN (hex_quads);
205 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
208 if (c >= '0' && c <= '9')
210 else if (c >= 'a' && c <= 'f')
211 hex_digit = c + 10 - 'a';
212 else if (c >= 'A' && c <= 'F')
213 hex_digit = c + 10 - 'A';
214 else if (c == ':' && n_colon < 2)
218 unformat_put_input (input);
222 /* Too many hex quads. */
223 if (n_hex_quads >= ARRAY_LEN (hex_quads))
228 hex_quad = (hex_quad << 4) | hex_digit;
230 /* Hex quad must fit in 16 bits. */
231 if (n_hex_digits >= 4)
238 /* Save position of :: */
241 /* More than one :: ? */
242 if (double_colon_index < ARRAY_LEN (hex_quads))
244 double_colon_index = n_hex_quads;
247 if (n_colon > 0 && n_hex_digits > 0)
249 hex_quads[n_hex_quads++] = hex_quad;
255 if (n_hex_digits > 0)
256 hex_quads[n_hex_quads++] = hex_quad;
261 /* Expand :: to appropriate number of zero hex quads. */
262 if (double_colon_index < ARRAY_LEN (hex_quads))
264 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
266 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
267 hex_quads[n_zero + i] = hex_quads[i];
269 for (i = 0; i < n_zero; i++)
270 hex_quads[double_colon_index + i] = 0;
272 n_hex_quads = ARRAY_LEN (hex_quads);
275 /* Too few hex quads given. */
276 if (n_hex_quads < ARRAY_LEN (hex_quads))
279 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
280 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
287 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
289 u32 *r = va_arg (*args, u32 *);
292 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
293 foreach_ipsec_policy_action
301 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
303 u32 *r = va_arg (*args, u32 *);
306 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
307 foreach_ipsec_crypto_alg
315 format_ipsec_crypto_alg (u8 * s, va_list * args)
317 u32 i = va_arg (*args, u32);
322 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
323 foreach_ipsec_crypto_alg
326 return format (s, "unknown");
328 return format (s, "%s", t);
332 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
334 u32 *r = va_arg (*args, u32 *);
337 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
338 foreach_ipsec_integ_alg
346 format_ipsec_integ_alg (u8 * s, va_list * args)
348 u32 i = va_arg (*args, u32);
353 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
354 foreach_ipsec_integ_alg
357 return format (s, "unknown");
359 return format (s, "%s", t);
363 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
365 u32 *r = va_arg (*args, u32 *);
368 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
369 foreach_ikev2_auth_method
377 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
379 u32 *r = va_arg (*args, u32 *);
382 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
383 foreach_ikev2_id_type
389 #endif /* VPP_API_TEST_BUILTIN */
392 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
394 u8 *r = va_arg (*args, u8 *);
396 if (unformat (input, "kbps"))
397 *r = SSE2_QOS_RATE_KBPS;
398 else if (unformat (input, "pps"))
399 *r = SSE2_QOS_RATE_PPS;
406 unformat_policer_round_type (unformat_input_t * input, va_list * args)
408 u8 *r = va_arg (*args, u8 *);
410 if (unformat (input, "closest"))
411 *r = SSE2_QOS_ROUND_TO_CLOSEST;
412 else if (unformat (input, "up"))
413 *r = SSE2_QOS_ROUND_TO_UP;
414 else if (unformat (input, "down"))
415 *r = SSE2_QOS_ROUND_TO_DOWN;
422 unformat_policer_type (unformat_input_t * input, va_list * args)
424 u8 *r = va_arg (*args, u8 *);
426 if (unformat (input, "1r2c"))
427 *r = SSE2_QOS_POLICER_TYPE_1R2C;
428 else if (unformat (input, "1r3c"))
429 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
430 else if (unformat (input, "2r3c-2698"))
431 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
432 else if (unformat (input, "2r3c-4115"))
433 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
434 else if (unformat (input, "2r3c-mef5cf1"))
435 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
442 unformat_dscp (unformat_input_t * input, va_list * va)
444 u8 *r = va_arg (*va, u8 *);
447 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
456 unformat_policer_action_type (unformat_input_t * input, va_list * va)
458 sse2_qos_pol_action_params_st *a
459 = va_arg (*va, sse2_qos_pol_action_params_st *);
461 if (unformat (input, "drop"))
462 a->action_type = SSE2_QOS_ACTION_DROP;
463 else if (unformat (input, "transmit"))
464 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
465 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
466 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
473 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
475 u32 *r = va_arg (*va, u32 *);
478 if (unformat (input, "ip4"))
479 tid = POLICER_CLASSIFY_TABLE_IP4;
480 else if (unformat (input, "ip6"))
481 tid = POLICER_CLASSIFY_TABLE_IP6;
482 else if (unformat (input, "l2"))
483 tid = POLICER_CLASSIFY_TABLE_L2;
492 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
494 u32 *r = va_arg (*va, u32 *);
497 if (unformat (input, "ip4"))
498 tid = FLOW_CLASSIFY_TABLE_IP4;
499 else if (unformat (input, "ip6"))
500 tid = FLOW_CLASSIFY_TABLE_IP6;
508 #if (VPP_API_TEST_BUILTIN==0)
510 format_ip4_address (u8 * s, va_list * args)
512 u8 *a = va_arg (*args, u8 *);
513 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
517 format_ip6_address (u8 * s, va_list * args)
519 ip6_address_t *a = va_arg (*args, ip6_address_t *);
520 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
522 i_max_n_zero = ARRAY_LEN (a->as_u16);
524 i_first_zero = i_max_n_zero;
526 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
528 u32 is_zero = a->as_u16[i] == 0;
529 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
535 if ((!is_zero && n_zeros > max_n_zeros)
536 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
538 i_max_n_zero = i_first_zero;
539 max_n_zeros = n_zeros;
540 i_first_zero = ARRAY_LEN (a->as_u16);
545 last_double_colon = 0;
546 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
548 if (i == i_max_n_zero && max_n_zeros > 1)
550 s = format (s, "::");
551 i += max_n_zeros - 1;
552 last_double_colon = 1;
556 s = format (s, "%s%x",
557 (last_double_colon || i == 0) ? "" : ":",
558 clib_net_to_host_u16 (a->as_u16[i]));
559 last_double_colon = 0;
566 /* Format an IP46 address. */
568 format_ip46_address (u8 * s, va_list * args)
570 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
571 ip46_type_t type = va_arg (*args, ip46_type_t);
577 is_ip4 = ip46_address_is_ip4 (ip46);
588 format (s, "%U", format_ip4_address, &ip46->ip4) :
589 format (s, "%U", format_ip6_address, &ip46->ip6);
593 format_ethernet_address (u8 * s, va_list * args)
595 u8 *a = va_arg (*args, u8 *);
597 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
598 a[0], a[1], a[2], a[3], a[4], a[5]);
603 increment_v4_address (ip4_address_t * a)
607 v = ntohl (a->as_u32) + 1;
608 a->as_u32 = ntohl (v);
612 increment_v6_address (ip6_address_t * a)
616 v0 = clib_net_to_host_u64 (a->as_u64[0]);
617 v1 = clib_net_to_host_u64 (a->as_u64[1]);
622 a->as_u64[0] = clib_net_to_host_u64 (v0);
623 a->as_u64[1] = clib_net_to_host_u64 (v1);
627 increment_mac_address (u64 * mac)
631 tmp = clib_net_to_host_u64 (tmp);
632 tmp += 1 << 16; /* skip unused (least significant) octets */
633 tmp = clib_host_to_net_u64 (tmp);
637 static void vl_api_create_loopback_reply_t_handler
638 (vl_api_create_loopback_reply_t * mp)
640 vat_main_t *vam = &vat_main;
641 i32 retval = ntohl (mp->retval);
643 vam->retval = retval;
644 vam->regenerate_interface_table = 1;
645 vam->sw_if_index = ntohl (mp->sw_if_index);
646 vam->result_ready = 1;
649 static void vl_api_create_loopback_reply_t_handler_json
650 (vl_api_create_loopback_reply_t * mp)
652 vat_main_t *vam = &vat_main;
653 vat_json_node_t node;
655 vat_json_init_object (&node);
656 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
657 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
659 vat_json_print (vam->ofp, &node);
660 vat_json_free (&node);
661 vam->retval = ntohl (mp->retval);
662 vam->result_ready = 1;
665 static void vl_api_af_packet_create_reply_t_handler
666 (vl_api_af_packet_create_reply_t * mp)
668 vat_main_t *vam = &vat_main;
669 i32 retval = ntohl (mp->retval);
671 vam->retval = retval;
672 vam->regenerate_interface_table = 1;
673 vam->sw_if_index = ntohl (mp->sw_if_index);
674 vam->result_ready = 1;
677 static void vl_api_af_packet_create_reply_t_handler_json
678 (vl_api_af_packet_create_reply_t * mp)
680 vat_main_t *vam = &vat_main;
681 vat_json_node_t node;
683 vat_json_init_object (&node);
684 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
685 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
687 vat_json_print (vam->ofp, &node);
688 vat_json_free (&node);
690 vam->retval = ntohl (mp->retval);
691 vam->result_ready = 1;
694 static void vl_api_create_vlan_subif_reply_t_handler
695 (vl_api_create_vlan_subif_reply_t * mp)
697 vat_main_t *vam = &vat_main;
698 i32 retval = ntohl (mp->retval);
700 vam->retval = retval;
701 vam->regenerate_interface_table = 1;
702 vam->sw_if_index = ntohl (mp->sw_if_index);
703 vam->result_ready = 1;
706 static void vl_api_create_vlan_subif_reply_t_handler_json
707 (vl_api_create_vlan_subif_reply_t * mp)
709 vat_main_t *vam = &vat_main;
710 vat_json_node_t node;
712 vat_json_init_object (&node);
713 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
714 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
716 vat_json_print (vam->ofp, &node);
717 vat_json_free (&node);
719 vam->retval = ntohl (mp->retval);
720 vam->result_ready = 1;
723 static void vl_api_create_subif_reply_t_handler
724 (vl_api_create_subif_reply_t * mp)
726 vat_main_t *vam = &vat_main;
727 i32 retval = ntohl (mp->retval);
729 vam->retval = retval;
730 vam->regenerate_interface_table = 1;
731 vam->sw_if_index = ntohl (mp->sw_if_index);
732 vam->result_ready = 1;
735 static void vl_api_create_subif_reply_t_handler_json
736 (vl_api_create_subif_reply_t * mp)
738 vat_main_t *vam = &vat_main;
739 vat_json_node_t node;
741 vat_json_init_object (&node);
742 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
743 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
745 vat_json_print (vam->ofp, &node);
746 vat_json_free (&node);
748 vam->retval = ntohl (mp->retval);
749 vam->result_ready = 1;
752 static void vl_api_interface_name_renumber_reply_t_handler
753 (vl_api_interface_name_renumber_reply_t * mp)
755 vat_main_t *vam = &vat_main;
756 i32 retval = ntohl (mp->retval);
758 vam->retval = retval;
759 vam->regenerate_interface_table = 1;
760 vam->result_ready = 1;
763 static void vl_api_interface_name_renumber_reply_t_handler_json
764 (vl_api_interface_name_renumber_reply_t * mp)
766 vat_main_t *vam = &vat_main;
767 vat_json_node_t node;
769 vat_json_init_object (&node);
770 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
772 vat_json_print (vam->ofp, &node);
773 vat_json_free (&node);
775 vam->retval = ntohl (mp->retval);
776 vam->result_ready = 1;
780 * Special-case: build the interface table, maintain
781 * the next loopback sw_if_index vbl.
783 static void vl_api_sw_interface_details_t_handler
784 (vl_api_sw_interface_details_t * mp)
786 vat_main_t *vam = &vat_main;
787 u8 *s = format (0, "%s%c", mp->interface_name, 0);
789 hash_set_mem (vam->sw_if_index_by_interface_name, s,
790 ntohl (mp->sw_if_index));
792 /* In sub interface case, fill the sub interface table entry */
793 if (mp->sw_if_index != mp->sup_sw_if_index)
795 sw_interface_subif_t *sub = NULL;
797 vec_add2 (vam->sw_if_subif_table, sub, 1);
799 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
800 strncpy ((char *) sub->interface_name, (char *) s,
801 vec_len (sub->interface_name));
802 sub->sw_if_index = ntohl (mp->sw_if_index);
803 sub->sub_id = ntohl (mp->sub_id);
805 sub->sub_dot1ad = mp->sub_dot1ad;
806 sub->sub_number_of_tags = mp->sub_number_of_tags;
807 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
808 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
809 sub->sub_exact_match = mp->sub_exact_match;
810 sub->sub_default = mp->sub_default;
811 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
812 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
814 /* vlan tag rewrite */
815 sub->vtr_op = ntohl (mp->vtr_op);
816 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
817 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
818 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
822 static void vl_api_sw_interface_details_t_handler_json
823 (vl_api_sw_interface_details_t * mp)
825 vat_main_t *vam = &vat_main;
826 vat_json_node_t *node = NULL;
828 if (VAT_JSON_ARRAY != vam->json_tree.type)
830 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
831 vat_json_init_array (&vam->json_tree);
833 node = vat_json_array_add (&vam->json_tree);
835 vat_json_init_object (node);
836 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
837 vat_json_object_add_uint (node, "sup_sw_if_index",
838 ntohl (mp->sup_sw_if_index));
839 vat_json_object_add_uint (node, "l2_address_length",
840 ntohl (mp->l2_address_length));
841 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
842 sizeof (mp->l2_address));
843 vat_json_object_add_string_copy (node, "interface_name",
845 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
846 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
847 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
848 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
849 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
850 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
851 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
852 vat_json_object_add_uint (node, "sub_number_of_tags",
853 mp->sub_number_of_tags);
854 vat_json_object_add_uint (node, "sub_outer_vlan_id",
855 ntohs (mp->sub_outer_vlan_id));
856 vat_json_object_add_uint (node, "sub_inner_vlan_id",
857 ntohs (mp->sub_inner_vlan_id));
858 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
859 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
860 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
861 mp->sub_outer_vlan_id_any);
862 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
863 mp->sub_inner_vlan_id_any);
864 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
865 vat_json_object_add_uint (node, "vtr_push_dot1q",
866 ntohl (mp->vtr_push_dot1q));
867 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
868 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
871 static void vl_api_sw_interface_set_flags_t_handler
872 (vl_api_sw_interface_set_flags_t * mp)
874 vat_main_t *vam = &vat_main;
875 if (vam->interface_event_display)
876 errmsg ("interface flags: sw_if_index %d %s %s",
877 ntohl (mp->sw_if_index),
878 mp->admin_up_down ? "admin-up" : "admin-down",
879 mp->link_up_down ? "link-up" : "link-down");
882 static void vl_api_sw_interface_set_flags_t_handler_json
883 (vl_api_sw_interface_set_flags_t * mp)
885 /* JSON output not supported */
889 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
891 vat_main_t *vam = &vat_main;
892 i32 retval = ntohl (mp->retval);
894 vam->retval = retval;
895 vam->shmem_result = (u8 *) mp->reply_in_shmem;
896 vam->result_ready = 1;
900 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
902 vat_main_t *vam = &vat_main;
903 vat_json_node_t node;
904 api_main_t *am = &api_main;
908 vat_json_init_object (&node);
909 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
910 vat_json_object_add_uint (&node, "reply_in_shmem",
911 ntohl (mp->reply_in_shmem));
912 /* Toss the shared-memory original... */
913 pthread_mutex_lock (&am->vlib_rp->mutex);
914 oldheap = svm_push_data_heap (am->vlib_rp);
916 reply = (u8 *) (mp->reply_in_shmem);
919 svm_pop_heap (oldheap);
920 pthread_mutex_unlock (&am->vlib_rp->mutex);
922 vat_json_print (vam->ofp, &node);
923 vat_json_free (&node);
925 vam->retval = ntohl (mp->retval);
926 vam->result_ready = 1;
930 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
932 vat_main_t *vam = &vat_main;
933 i32 retval = ntohl (mp->retval);
935 vam->retval = retval;
936 vam->cmd_reply = mp->reply;
937 vam->result_ready = 1;
941 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
943 vat_main_t *vam = &vat_main;
944 vat_json_node_t node;
946 vat_json_init_object (&node);
947 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
948 vat_json_object_add_string_copy (&node, "reply", mp->reply);
950 vat_json_print (vam->ofp, &node);
951 vat_json_free (&node);
953 vam->retval = ntohl (mp->retval);
954 vam->result_ready = 1;
957 static void vl_api_classify_add_del_table_reply_t_handler
958 (vl_api_classify_add_del_table_reply_t * mp)
960 vat_main_t *vam = &vat_main;
961 i32 retval = ntohl (mp->retval);
964 vam->async_errors += (retval < 0);
968 vam->retval = retval;
970 ((mp->new_table_index != 0xFFFFFFFF) ||
971 (mp->skip_n_vectors != 0xFFFFFFFF) ||
972 (mp->match_n_vectors != 0xFFFFFFFF)))
974 * Note: this is just barely thread-safe, depends on
975 * the main thread spinning waiting for an answer...
977 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
978 ntohl (mp->new_table_index),
979 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
980 vam->result_ready = 1;
984 static void vl_api_classify_add_del_table_reply_t_handler_json
985 (vl_api_classify_add_del_table_reply_t * mp)
987 vat_main_t *vam = &vat_main;
988 vat_json_node_t node;
990 vat_json_init_object (&node);
991 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
992 vat_json_object_add_uint (&node, "new_table_index",
993 ntohl (mp->new_table_index));
994 vat_json_object_add_uint (&node, "skip_n_vectors",
995 ntohl (mp->skip_n_vectors));
996 vat_json_object_add_uint (&node, "match_n_vectors",
997 ntohl (mp->match_n_vectors));
999 vat_json_print (vam->ofp, &node);
1000 vat_json_free (&node);
1002 vam->retval = ntohl (mp->retval);
1003 vam->result_ready = 1;
1006 static void vl_api_get_node_index_reply_t_handler
1007 (vl_api_get_node_index_reply_t * mp)
1009 vat_main_t *vam = &vat_main;
1010 i32 retval = ntohl (mp->retval);
1011 if (vam->async_mode)
1013 vam->async_errors += (retval < 0);
1017 vam->retval = retval;
1019 errmsg ("node index %d", ntohl (mp->node_index));
1020 vam->result_ready = 1;
1024 static void vl_api_get_node_index_reply_t_handler_json
1025 (vl_api_get_node_index_reply_t * mp)
1027 vat_main_t *vam = &vat_main;
1028 vat_json_node_t node;
1030 vat_json_init_object (&node);
1031 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1032 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1034 vat_json_print (vam->ofp, &node);
1035 vat_json_free (&node);
1037 vam->retval = ntohl (mp->retval);
1038 vam->result_ready = 1;
1041 static void vl_api_get_next_index_reply_t_handler
1042 (vl_api_get_next_index_reply_t * mp)
1044 vat_main_t *vam = &vat_main;
1045 i32 retval = ntohl (mp->retval);
1046 if (vam->async_mode)
1048 vam->async_errors += (retval < 0);
1052 vam->retval = retval;
1054 errmsg ("next node index %d", ntohl (mp->next_index));
1055 vam->result_ready = 1;
1059 static void vl_api_get_next_index_reply_t_handler_json
1060 (vl_api_get_next_index_reply_t * mp)
1062 vat_main_t *vam = &vat_main;
1063 vat_json_node_t node;
1065 vat_json_init_object (&node);
1066 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1067 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1069 vat_json_print (vam->ofp, &node);
1070 vat_json_free (&node);
1072 vam->retval = ntohl (mp->retval);
1073 vam->result_ready = 1;
1076 static void vl_api_add_node_next_reply_t_handler
1077 (vl_api_add_node_next_reply_t * mp)
1079 vat_main_t *vam = &vat_main;
1080 i32 retval = ntohl (mp->retval);
1081 if (vam->async_mode)
1083 vam->async_errors += (retval < 0);
1087 vam->retval = retval;
1089 errmsg ("next index %d", ntohl (mp->next_index));
1090 vam->result_ready = 1;
1094 static void vl_api_add_node_next_reply_t_handler_json
1095 (vl_api_add_node_next_reply_t * mp)
1097 vat_main_t *vam = &vat_main;
1098 vat_json_node_t node;
1100 vat_json_init_object (&node);
1101 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1102 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1104 vat_json_print (vam->ofp, &node);
1105 vat_json_free (&node);
1107 vam->retval = ntohl (mp->retval);
1108 vam->result_ready = 1;
1111 static void vl_api_show_version_reply_t_handler
1112 (vl_api_show_version_reply_t * mp)
1114 vat_main_t *vam = &vat_main;
1115 i32 retval = ntohl (mp->retval);
1119 errmsg (" program: %s", mp->program);
1120 errmsg (" version: %s", mp->version);
1121 errmsg (" build date: %s", mp->build_date);
1122 errmsg ("build directory: %s", mp->build_directory);
1124 vam->retval = retval;
1125 vam->result_ready = 1;
1128 static void vl_api_show_version_reply_t_handler_json
1129 (vl_api_show_version_reply_t * mp)
1131 vat_main_t *vam = &vat_main;
1132 vat_json_node_t node;
1134 vat_json_init_object (&node);
1135 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1136 vat_json_object_add_string_copy (&node, "program", mp->program);
1137 vat_json_object_add_string_copy (&node, "version", mp->version);
1138 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1139 vat_json_object_add_string_copy (&node, "build_directory",
1140 mp->build_directory);
1142 vat_json_print (vam->ofp, &node);
1143 vat_json_free (&node);
1145 vam->retval = ntohl (mp->retval);
1146 vam->result_ready = 1;
1150 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1152 errmsg ("arp %s event: address %U new mac %U sw_if_index %d",
1153 mp->mac_ip ? "mac/ip binding" : "address resolution",
1154 format_ip4_address, &mp->address,
1155 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1159 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1161 /* JSON output not supported */
1165 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1167 errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d",
1168 mp->mac_ip ? "mac/ip binding" : "address resolution",
1169 format_ip6_address, mp->address,
1170 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1174 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1176 /* JSON output not supported */
1180 * Special-case: build the bridge domain table, maintain
1181 * the next bd id vbl.
1183 static void vl_api_bridge_domain_details_t_handler
1184 (vl_api_bridge_domain_details_t * mp)
1186 vat_main_t *vam = &vat_main;
1187 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1189 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1190 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1192 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1193 ntohl (mp->bd_id), mp->learn, mp->forward,
1194 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1197 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG", "Interface Name");
1200 static void vl_api_bridge_domain_details_t_handler_json
1201 (vl_api_bridge_domain_details_t * mp)
1203 vat_main_t *vam = &vat_main;
1204 vat_json_node_t *node, *array = NULL;
1206 if (VAT_JSON_ARRAY != vam->json_tree.type)
1208 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1209 vat_json_init_array (&vam->json_tree);
1211 node = vat_json_array_add (&vam->json_tree);
1213 vat_json_init_object (node);
1214 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1215 vat_json_object_add_uint (node, "flood", mp->flood);
1216 vat_json_object_add_uint (node, "forward", mp->forward);
1217 vat_json_object_add_uint (node, "learn", mp->learn);
1218 vat_json_object_add_uint (node, "bvi_sw_if_index",
1219 ntohl (mp->bvi_sw_if_index));
1220 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1221 array = vat_json_object_add (node, "sw_if");
1222 vat_json_init_array (array);
1226 * Special-case: build the bridge domain sw if table.
1228 static void vl_api_bridge_domain_sw_if_details_t_handler
1229 (vl_api_bridge_domain_sw_if_details_t * mp)
1231 vat_main_t *vam = &vat_main;
1236 sw_if_index = ntohl (mp->sw_if_index);
1238 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1240 if ((u32) p->value[0] == sw_if_index)
1242 sw_if_name = (u8 *)(p->key);
1248 print (vam->ofp, "%7d %3d %s", sw_if_index,
1249 mp->shg, sw_if_name ? (char *) sw_if_name :
1250 "sw_if_index not found!");
1253 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1254 (vl_api_bridge_domain_sw_if_details_t * mp)
1256 vat_main_t *vam = &vat_main;
1257 vat_json_node_t *node = NULL;
1258 uword last_index = 0;
1260 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1261 ASSERT (vec_len (vam->json_tree.array) >= 1);
1262 last_index = vec_len (vam->json_tree.array) - 1;
1263 node = &vam->json_tree.array[last_index];
1264 node = vat_json_object_get_element (node, "sw_if");
1265 ASSERT (NULL != node);
1266 node = vat_json_array_add (node);
1268 vat_json_init_object (node);
1269 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1270 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1271 vat_json_object_add_uint (node, "shg", mp->shg);
1274 static void vl_api_control_ping_reply_t_handler
1275 (vl_api_control_ping_reply_t * mp)
1277 vat_main_t *vam = &vat_main;
1278 i32 retval = ntohl (mp->retval);
1279 if (vam->async_mode)
1281 vam->async_errors += (retval < 0);
1285 vam->retval = retval;
1286 vam->result_ready = 1;
1290 static void vl_api_control_ping_reply_t_handler_json
1291 (vl_api_control_ping_reply_t * mp)
1293 vat_main_t *vam = &vat_main;
1294 i32 retval = ntohl (mp->retval);
1296 if (VAT_JSON_NONE != vam->json_tree.type)
1298 vat_json_print (vam->ofp, &vam->json_tree);
1299 vat_json_free (&vam->json_tree);
1300 vam->json_tree.type = VAT_JSON_NONE;
1305 vat_json_init_array (&vam->json_tree);
1306 vat_json_print (vam->ofp, &vam->json_tree);
1307 vam->json_tree.type = VAT_JSON_NONE;
1310 vam->retval = retval;
1311 vam->result_ready = 1;
1315 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1317 vat_main_t *vam = &vat_main;
1318 i32 retval = ntohl (mp->retval);
1319 if (vam->async_mode)
1321 vam->async_errors += (retval < 0);
1325 vam->retval = retval;
1326 vam->result_ready = 1;
1330 static void vl_api_l2_flags_reply_t_handler_json
1331 (vl_api_l2_flags_reply_t * mp)
1333 vat_main_t *vam = &vat_main;
1334 vat_json_node_t node;
1336 vat_json_init_object (&node);
1337 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1338 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1339 ntohl (mp->resulting_feature_bitmap));
1341 vat_json_print (vam->ofp, &node);
1342 vat_json_free (&node);
1344 vam->retval = ntohl (mp->retval);
1345 vam->result_ready = 1;
1348 static void vl_api_bridge_flags_reply_t_handler
1349 (vl_api_bridge_flags_reply_t * mp)
1351 vat_main_t *vam = &vat_main;
1352 i32 retval = ntohl (mp->retval);
1353 if (vam->async_mode)
1355 vam->async_errors += (retval < 0);
1359 vam->retval = retval;
1360 vam->result_ready = 1;
1364 static void vl_api_bridge_flags_reply_t_handler_json
1365 (vl_api_bridge_flags_reply_t * mp)
1367 vat_main_t *vam = &vat_main;
1368 vat_json_node_t node;
1370 vat_json_init_object (&node);
1371 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1372 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1373 ntohl (mp->resulting_feature_bitmap));
1375 vat_json_print (vam->ofp, &node);
1376 vat_json_free (&node);
1378 vam->retval = ntohl (mp->retval);
1379 vam->result_ready = 1;
1382 static void vl_api_tap_connect_reply_t_handler
1383 (vl_api_tap_connect_reply_t * mp)
1385 vat_main_t *vam = &vat_main;
1386 i32 retval = ntohl (mp->retval);
1387 if (vam->async_mode)
1389 vam->async_errors += (retval < 0);
1393 vam->retval = retval;
1394 vam->sw_if_index = ntohl (mp->sw_if_index);
1395 vam->result_ready = 1;
1400 static void vl_api_tap_connect_reply_t_handler_json
1401 (vl_api_tap_connect_reply_t * mp)
1403 vat_main_t *vam = &vat_main;
1404 vat_json_node_t node;
1406 vat_json_init_object (&node);
1407 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1408 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1410 vat_json_print (vam->ofp, &node);
1411 vat_json_free (&node);
1413 vam->retval = ntohl (mp->retval);
1414 vam->result_ready = 1;
1419 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1421 vat_main_t *vam = &vat_main;
1422 i32 retval = ntohl (mp->retval);
1423 if (vam->async_mode)
1425 vam->async_errors += (retval < 0);
1429 vam->retval = retval;
1430 vam->sw_if_index = ntohl (mp->sw_if_index);
1431 vam->result_ready = 1;
1435 static void vl_api_tap_modify_reply_t_handler_json
1436 (vl_api_tap_modify_reply_t * mp)
1438 vat_main_t *vam = &vat_main;
1439 vat_json_node_t node;
1441 vat_json_init_object (&node);
1442 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1443 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1445 vat_json_print (vam->ofp, &node);
1446 vat_json_free (&node);
1448 vam->retval = ntohl (mp->retval);
1449 vam->result_ready = 1;
1453 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1455 vat_main_t *vam = &vat_main;
1456 i32 retval = ntohl (mp->retval);
1457 if (vam->async_mode)
1459 vam->async_errors += (retval < 0);
1463 vam->retval = retval;
1464 vam->result_ready = 1;
1468 static void vl_api_tap_delete_reply_t_handler_json
1469 (vl_api_tap_delete_reply_t * mp)
1471 vat_main_t *vam = &vat_main;
1472 vat_json_node_t node;
1474 vat_json_init_object (&node);
1475 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1477 vat_json_print (vam->ofp, &node);
1478 vat_json_free (&node);
1480 vam->retval = ntohl (mp->retval);
1481 vam->result_ready = 1;
1484 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1485 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1487 vat_main_t *vam = &vat_main;
1488 i32 retval = ntohl (mp->retval);
1489 if (vam->async_mode)
1491 vam->async_errors += (retval < 0);
1495 vam->retval = retval;
1496 vam->result_ready = 1;
1500 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1501 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1503 vat_main_t *vam = &vat_main;
1504 vat_json_node_t node;
1506 vat_json_init_object (&node);
1507 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1508 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1509 ntohl (mp->sw_if_index));
1511 vat_json_print (vam->ofp, &node);
1512 vat_json_free (&node);
1514 vam->retval = ntohl (mp->retval);
1515 vam->result_ready = 1;
1518 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1519 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1521 vat_main_t *vam = &vat_main;
1522 i32 retval = ntohl (mp->retval);
1523 if (vam->async_mode)
1525 vam->async_errors += (retval < 0);
1529 vam->retval = retval;
1530 vam->sw_if_index = ntohl (mp->sw_if_index);
1531 vam->result_ready = 1;
1535 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1536 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1538 vat_main_t *vam = &vat_main;
1539 vat_json_node_t node;
1541 vat_json_init_object (&node);
1542 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1543 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1545 vat_json_print (vam->ofp, &node);
1546 vat_json_free (&node);
1548 vam->retval = ntohl (mp->retval);
1549 vam->result_ready = 1;
1553 static void vl_api_lisp_add_del_locator_set_reply_t_handler
1554 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1556 vat_main_t *vam = &vat_main;
1557 i32 retval = ntohl (mp->retval);
1558 if (vam->async_mode)
1560 vam->async_errors += (retval < 0);
1564 vam->retval = retval;
1565 vam->result_ready = 1;
1569 static void vl_api_lisp_add_del_locator_set_reply_t_handler_json
1570 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1572 vat_main_t *vam = &vat_main;
1573 vat_json_node_t node;
1575 vat_json_init_object (&node);
1576 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1577 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1579 vat_json_print (vam->ofp, &node);
1580 vat_json_free (&node);
1582 vam->retval = ntohl (mp->retval);
1583 vam->result_ready = 1;
1586 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1587 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1589 vat_main_t *vam = &vat_main;
1590 i32 retval = ntohl (mp->retval);
1591 if (vam->async_mode)
1593 vam->async_errors += (retval < 0);
1597 vam->retval = retval;
1598 vam->sw_if_index = ntohl (mp->sw_if_index);
1599 vam->result_ready = 1;
1603 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1604 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1606 vat_main_t *vam = &vat_main;
1607 vat_json_node_t node;
1609 vat_json_init_object (&node);
1610 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1611 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1613 vat_json_print (vam->ofp, &node);
1614 vat_json_free (&node);
1616 vam->retval = ntohl (mp->retval);
1617 vam->result_ready = 1;
1620 static void vl_api_gre_add_del_tunnel_reply_t_handler
1621 (vl_api_gre_add_del_tunnel_reply_t * mp)
1623 vat_main_t *vam = &vat_main;
1624 i32 retval = ntohl (mp->retval);
1625 if (vam->async_mode)
1627 vam->async_errors += (retval < 0);
1631 vam->retval = retval;
1632 vam->sw_if_index = ntohl (mp->sw_if_index);
1633 vam->result_ready = 1;
1637 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1638 (vl_api_gre_add_del_tunnel_reply_t * mp)
1640 vat_main_t *vam = &vat_main;
1641 vat_json_node_t node;
1643 vat_json_init_object (&node);
1644 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1645 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1647 vat_json_print (vam->ofp, &node);
1648 vat_json_free (&node);
1650 vam->retval = ntohl (mp->retval);
1651 vam->result_ready = 1;
1654 static void vl_api_create_vhost_user_if_reply_t_handler
1655 (vl_api_create_vhost_user_if_reply_t * mp)
1657 vat_main_t *vam = &vat_main;
1658 i32 retval = ntohl (mp->retval);
1659 if (vam->async_mode)
1661 vam->async_errors += (retval < 0);
1665 vam->retval = retval;
1666 vam->sw_if_index = ntohl (mp->sw_if_index);
1667 vam->result_ready = 1;
1671 static void vl_api_create_vhost_user_if_reply_t_handler_json
1672 (vl_api_create_vhost_user_if_reply_t * mp)
1674 vat_main_t *vam = &vat_main;
1675 vat_json_node_t node;
1677 vat_json_init_object (&node);
1678 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1679 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1681 vat_json_print (vam->ofp, &node);
1682 vat_json_free (&node);
1684 vam->retval = ntohl (mp->retval);
1685 vam->result_ready = 1;
1688 static void vl_api_ip_address_details_t_handler
1689 (vl_api_ip_address_details_t * mp)
1691 vat_main_t *vam = &vat_main;
1692 static ip_address_details_t empty_ip_address_details = { {0} };
1693 ip_address_details_t *address = NULL;
1694 ip_details_t *current_ip_details = NULL;
1695 ip_details_t *details = NULL;
1697 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1699 if (!details || vam->current_sw_if_index >= vec_len (details)
1700 || !details[vam->current_sw_if_index].present)
1702 errmsg ("ip address details arrived but not stored");
1703 errmsg ("ip_dump should be called first");
1707 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1709 #define addresses (current_ip_details->addr)
1711 vec_validate_init_empty (addresses, vec_len (addresses),
1712 empty_ip_address_details);
1714 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1716 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1717 address->prefix_length = mp->prefix_length;
1721 static void vl_api_ip_address_details_t_handler_json
1722 (vl_api_ip_address_details_t * mp)
1724 vat_main_t *vam = &vat_main;
1725 vat_json_node_t *node = NULL;
1726 struct in6_addr ip6;
1729 if (VAT_JSON_ARRAY != vam->json_tree.type)
1731 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1732 vat_json_init_array (&vam->json_tree);
1734 node = vat_json_array_add (&vam->json_tree);
1736 vat_json_init_object (node);
1739 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1740 vat_json_object_add_ip6 (node, "ip", ip6);
1744 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1745 vat_json_object_add_ip4 (node, "ip", ip4);
1747 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1751 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1753 vat_main_t *vam = &vat_main;
1754 static ip_details_t empty_ip_details = { 0 };
1755 ip_details_t *ip = NULL;
1756 u32 sw_if_index = ~0;
1758 sw_if_index = ntohl (mp->sw_if_index);
1760 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1761 sw_if_index, empty_ip_details);
1763 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1770 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1772 vat_main_t *vam = &vat_main;
1774 if (VAT_JSON_ARRAY != vam->json_tree.type)
1776 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1777 vat_json_init_array (&vam->json_tree);
1779 vat_json_array_add_uint (&vam->json_tree,
1780 clib_net_to_host_u32 (mp->sw_if_index));
1783 static void vl_api_map_domain_details_t_handler_json
1784 (vl_api_map_domain_details_t * mp)
1786 vat_json_node_t *node = NULL;
1787 vat_main_t *vam = &vat_main;
1788 struct in6_addr ip6;
1791 if (VAT_JSON_ARRAY != vam->json_tree.type)
1793 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1794 vat_json_init_array (&vam->json_tree);
1797 node = vat_json_array_add (&vam->json_tree);
1798 vat_json_init_object (node);
1800 vat_json_object_add_uint (node, "domain_index",
1801 clib_net_to_host_u32 (mp->domain_index));
1802 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1803 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1804 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1805 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1806 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1807 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1808 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1809 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1810 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1811 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1812 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1813 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1814 vat_json_object_add_uint (node, "flags", mp->flags);
1815 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1816 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1819 static void vl_api_map_domain_details_t_handler
1820 (vl_api_map_domain_details_t * mp)
1822 vat_main_t *vam = &vat_main;
1824 if (mp->is_translation)
1827 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
1828 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1829 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1830 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1831 clib_net_to_host_u32 (mp->domain_index));
1836 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
1837 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1838 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1839 format_ip6_address, mp->ip6_src,
1840 clib_net_to_host_u32 (mp->domain_index));
1842 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
1843 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1844 mp->is_translation ? "map-t" : "");
1847 static void vl_api_map_rule_details_t_handler_json
1848 (vl_api_map_rule_details_t * mp)
1850 struct in6_addr ip6;
1851 vat_json_node_t *node = NULL;
1852 vat_main_t *vam = &vat_main;
1854 if (VAT_JSON_ARRAY != vam->json_tree.type)
1856 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1857 vat_json_init_array (&vam->json_tree);
1860 node = vat_json_array_add (&vam->json_tree);
1861 vat_json_init_object (node);
1863 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1864 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1865 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1869 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1871 vat_main_t *vam = &vat_main;
1872 print (vam->ofp, " %d (psid) %U (ip6-dst)",
1873 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1877 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1879 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1880 "router_addr %U host_mac %U",
1881 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1882 format_ip4_address, &mp->host_address,
1883 format_ip4_address, &mp->router_address,
1884 format_ethernet_address, mp->host_mac);
1887 static void vl_api_dhcp_compl_event_t_handler_json
1888 (vl_api_dhcp_compl_event_t * mp)
1890 /* JSON output not supported */
1894 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1897 vat_main_t *vam = &vat_main;
1898 static u64 default_counter = 0;
1900 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
1902 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
1903 sw_if_index, default_counter);
1904 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
1908 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1909 interface_counter_t counter)
1911 vat_main_t *vam = &vat_main;
1912 static interface_counter_t default_counter = { 0, };
1914 vec_validate_init_empty (vam->combined_interface_counters,
1915 vnet_counter_type, NULL);
1916 vec_validate_init_empty (vam->combined_interface_counters
1917 [vnet_counter_type], sw_if_index, default_counter);
1918 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
1921 static void vl_api_vnet_interface_counters_t_handler
1922 (vl_api_vnet_interface_counters_t * mp)
1927 static void vl_api_vnet_interface_counters_t_handler_json
1928 (vl_api_vnet_interface_counters_t * mp)
1930 interface_counter_t counter;
1935 u32 first_sw_if_index;
1938 count = ntohl (mp->count);
1939 first_sw_if_index = ntohl (mp->first_sw_if_index);
1941 if (!mp->is_combined)
1943 v_packets = (u64 *) & mp->data;
1944 for (i = 0; i < count; i++)
1947 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
1948 set_simple_interface_counter (mp->vnet_counter_type,
1949 first_sw_if_index + i, packets);
1955 v = (vlib_counter_t *) & mp->data;
1956 for (i = 0; i < count; i++)
1959 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
1961 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
1962 set_combined_interface_counter (mp->vnet_counter_type,
1963 first_sw_if_index + i, counter);
1970 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
1972 vat_main_t *vam = &vat_main;
1975 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
1977 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
1986 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
1988 vat_main_t *vam = &vat_main;
1991 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
1993 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2001 static void vl_api_vnet_ip4_fib_counters_t_handler
2002 (vl_api_vnet_ip4_fib_counters_t * mp)
2007 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2008 (vl_api_vnet_ip4_fib_counters_t * mp)
2010 vat_main_t *vam = &vat_main;
2011 vl_api_ip4_fib_counter_t *v;
2012 ip4_fib_counter_t *counter;
2019 vrf_id = ntohl (mp->vrf_id);
2020 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2021 if (~0 == vrf_index)
2023 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2024 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2025 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2026 vec_validate (vam->ip4_fib_counters, vrf_index);
2027 vam->ip4_fib_counters[vrf_index] = NULL;
2030 vec_free (vam->ip4_fib_counters[vrf_index]);
2031 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2032 count = ntohl (mp->count);
2033 for (i = 0; i < count; i++)
2035 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2036 counter = &vam->ip4_fib_counters[vrf_index][i];
2037 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2038 counter->address = ip4;
2039 counter->address_length = v->address_length;
2040 counter->packets = clib_net_to_host_u64 (v->packets);
2041 counter->bytes = clib_net_to_host_u64 (v->bytes);
2046 static void vl_api_vnet_ip4_nbr_counters_t_handler
2047 (vl_api_vnet_ip4_nbr_counters_t * mp)
2052 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2053 (vl_api_vnet_ip4_nbr_counters_t * mp)
2055 vat_main_t *vam = &vat_main;
2056 vl_api_ip4_nbr_counter_t *v;
2057 ip4_nbr_counter_t *counter;
2062 sw_if_index = ntohl (mp->sw_if_index);
2063 count = ntohl (mp->count);
2064 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2067 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2069 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2070 for (i = 0; i < count; i++)
2072 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2073 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2074 counter->address.s_addr = v->address;
2075 counter->packets = clib_net_to_host_u64 (v->packets);
2076 counter->bytes = clib_net_to_host_u64 (v->bytes);
2077 counter->linkt = v->link_type;
2082 static void vl_api_vnet_ip6_fib_counters_t_handler
2083 (vl_api_vnet_ip6_fib_counters_t * mp)
2088 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2089 (vl_api_vnet_ip6_fib_counters_t * mp)
2091 vat_main_t *vam = &vat_main;
2092 vl_api_ip6_fib_counter_t *v;
2093 ip6_fib_counter_t *counter;
2094 struct in6_addr ip6;
2100 vrf_id = ntohl (mp->vrf_id);
2101 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2102 if (~0 == vrf_index)
2104 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2105 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2106 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2107 vec_validate (vam->ip6_fib_counters, vrf_index);
2108 vam->ip6_fib_counters[vrf_index] = NULL;
2111 vec_free (vam->ip6_fib_counters[vrf_index]);
2112 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2113 count = ntohl (mp->count);
2114 for (i = 0; i < count; i++)
2116 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2117 counter = &vam->ip6_fib_counters[vrf_index][i];
2118 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2119 counter->address = ip6;
2120 counter->address_length = v->address_length;
2121 counter->packets = clib_net_to_host_u64 (v->packets);
2122 counter->bytes = clib_net_to_host_u64 (v->bytes);
2127 static void vl_api_vnet_ip6_nbr_counters_t_handler
2128 (vl_api_vnet_ip6_nbr_counters_t * mp)
2133 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2134 (vl_api_vnet_ip6_nbr_counters_t * mp)
2136 vat_main_t *vam = &vat_main;
2137 vl_api_ip6_nbr_counter_t *v;
2138 ip6_nbr_counter_t *counter;
2139 struct in6_addr ip6;
2144 sw_if_index = ntohl (mp->sw_if_index);
2145 count = ntohl (mp->count);
2146 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2149 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2151 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2152 for (i = 0; i < count; i++)
2154 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2155 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2156 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2157 counter->address = ip6;
2158 counter->packets = clib_net_to_host_u64 (v->packets);
2159 counter->bytes = clib_net_to_host_u64 (v->bytes);
2164 static void vl_api_get_first_msg_id_reply_t_handler
2165 (vl_api_get_first_msg_id_reply_t * mp)
2167 vat_main_t *vam = &vat_main;
2168 i32 retval = ntohl (mp->retval);
2170 if (vam->async_mode)
2172 vam->async_errors += (retval < 0);
2176 vam->retval = retval;
2177 vam->result_ready = 1;
2181 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2185 static void vl_api_get_first_msg_id_reply_t_handler_json
2186 (vl_api_get_first_msg_id_reply_t * mp)
2188 vat_main_t *vam = &vat_main;
2189 vat_json_node_t node;
2191 vat_json_init_object (&node);
2192 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2193 vat_json_object_add_uint (&node, "first_msg_id",
2194 (uint) ntohs (mp->first_msg_id));
2196 vat_json_print (vam->ofp, &node);
2197 vat_json_free (&node);
2199 vam->retval = ntohl (mp->retval);
2200 vam->result_ready = 1;
2203 static void vl_api_get_node_graph_reply_t_handler
2204 (vl_api_get_node_graph_reply_t * mp)
2206 vat_main_t *vam = &vat_main;
2207 api_main_t *am = &api_main;
2208 i32 retval = ntohl (mp->retval);
2209 u8 *pvt_copy, *reply;
2214 if (vam->async_mode)
2216 vam->async_errors += (retval < 0);
2220 vam->retval = retval;
2221 vam->result_ready = 1;
2224 /* "Should never happen..." */
2228 reply = (u8 *) (mp->reply_in_shmem);
2229 pvt_copy = vec_dup (reply);
2231 /* Toss the shared-memory original... */
2232 pthread_mutex_lock (&am->vlib_rp->mutex);
2233 oldheap = svm_push_data_heap (am->vlib_rp);
2237 svm_pop_heap (oldheap);
2238 pthread_mutex_unlock (&am->vlib_rp->mutex);
2240 if (vam->graph_nodes)
2242 hash_free (vam->graph_node_index_by_name);
2244 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2246 node = vam->graph_nodes[i];
2247 vec_free (node->name);
2248 vec_free (node->next_nodes);
2251 vec_free (vam->graph_nodes);
2254 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2255 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2256 vec_free (pvt_copy);
2258 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2260 node = vam->graph_nodes[i];
2261 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2265 static void vl_api_get_node_graph_reply_t_handler_json
2266 (vl_api_get_node_graph_reply_t * mp)
2268 vat_main_t *vam = &vat_main;
2269 api_main_t *am = &api_main;
2271 vat_json_node_t node;
2274 /* $$$$ make this real? */
2275 vat_json_init_object (&node);
2276 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2277 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2279 reply = (u8 *) (mp->reply_in_shmem);
2281 /* Toss the shared-memory original... */
2282 pthread_mutex_lock (&am->vlib_rp->mutex);
2283 oldheap = svm_push_data_heap (am->vlib_rp);
2287 svm_pop_heap (oldheap);
2288 pthread_mutex_unlock (&am->vlib_rp->mutex);
2290 vat_json_print (vam->ofp, &node);
2291 vat_json_free (&node);
2293 vam->retval = ntohl (mp->retval);
2294 vam->result_ready = 1;
2298 vl_api_lisp_locator_details_t_handler (vl_api_lisp_locator_details_t * mp)
2300 vat_main_t *vam = &vat_main;
2305 s = format (s, "%=16d%=16d%=16d",
2306 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2310 s = format (s, "%=16U%=16d%=16d",
2311 mp->is_ipv6 ? format_ip6_address :
2313 mp->ip_address, mp->priority, mp->weight);
2316 print (vam->ofp, "%v", s);
2321 vl_api_lisp_locator_details_t_handler_json (vl_api_lisp_locator_details_t *
2324 vat_main_t *vam = &vat_main;
2325 vat_json_node_t *node = NULL;
2326 struct in6_addr ip6;
2329 if (VAT_JSON_ARRAY != vam->json_tree.type)
2331 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2332 vat_json_init_array (&vam->json_tree);
2334 node = vat_json_array_add (&vam->json_tree);
2335 vat_json_init_object (node);
2337 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2338 vat_json_object_add_uint (node, "priority", mp->priority);
2339 vat_json_object_add_uint (node, "weight", mp->weight);
2342 vat_json_object_add_uint (node, "sw_if_index",
2343 clib_net_to_host_u32 (mp->sw_if_index));
2348 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2349 vat_json_object_add_ip6 (node, "address", ip6);
2353 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2354 vat_json_object_add_ip4 (node, "address", ip4);
2360 vl_api_lisp_locator_set_details_t_handler (vl_api_lisp_locator_set_details_t *
2363 vat_main_t *vam = &vat_main;
2366 ls_name = format (0, "%s", mp->ls_name);
2368 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2374 vl_api_lisp_locator_set_details_t_handler_json
2375 (vl_api_lisp_locator_set_details_t * mp)
2377 vat_main_t *vam = &vat_main;
2378 vat_json_node_t *node = 0;
2381 ls_name = format (0, "%s", mp->ls_name);
2382 vec_add1 (ls_name, 0);
2384 if (VAT_JSON_ARRAY != vam->json_tree.type)
2386 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2387 vat_json_init_array (&vam->json_tree);
2389 node = vat_json_array_add (&vam->json_tree);
2391 vat_json_init_object (node);
2392 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2393 vat_json_object_add_uint (node, "ls_index",
2394 clib_net_to_host_u32 (mp->ls_index));
2399 format_lisp_flat_eid (u8 * s, va_list * args)
2401 u32 type = va_arg (*args, u32);
2402 u8 *eid = va_arg (*args, u8 *);
2403 u32 eid_len = va_arg (*args, u32);
2408 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2410 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2412 return format (s, "%U", format_ethernet_address, eid);
2418 format_lisp_eid_vat (u8 * s, va_list * args)
2420 u32 type = va_arg (*args, u32);
2421 u8 *eid = va_arg (*args, u8 *);
2422 u32 eid_len = va_arg (*args, u32);
2423 u8 *seid = va_arg (*args, u8 *);
2424 u32 seid_len = va_arg (*args, u32);
2425 u32 is_src_dst = va_arg (*args, u32);
2428 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2430 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2436 vl_api_lisp_eid_table_details_t_handler (vl_api_lisp_eid_table_details_t * mp)
2438 vat_main_t *vam = &vat_main;
2439 u8 *s = 0, *eid = 0;
2441 if (~0 == mp->locator_set_index)
2442 s = format (0, "action: %d", mp->action);
2444 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2446 eid = format (0, "%U", format_lisp_eid_vat,
2450 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2453 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2454 clib_net_to_host_u32 (mp->vni),
2456 mp->is_local ? "local" : "remote",
2457 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2458 clib_net_to_host_u16 (mp->key_id), mp->key);
2465 vl_api_lisp_eid_table_details_t_handler_json (vl_api_lisp_eid_table_details_t
2468 vat_main_t *vam = &vat_main;
2469 vat_json_node_t *node = 0;
2472 if (VAT_JSON_ARRAY != vam->json_tree.type)
2474 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2475 vat_json_init_array (&vam->json_tree);
2477 node = vat_json_array_add (&vam->json_tree);
2479 vat_json_init_object (node);
2480 if (~0 == mp->locator_set_index)
2481 vat_json_object_add_uint (node, "action", mp->action);
2483 vat_json_object_add_uint (node, "locator_set_index",
2484 clib_net_to_host_u32 (mp->locator_set_index));
2486 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2487 eid = format (0, "%U", format_lisp_eid_vat,
2491 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2493 vat_json_object_add_string_copy (node, "eid", eid);
2494 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2495 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2496 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2500 vat_json_object_add_uint (node, "key_id",
2501 clib_net_to_host_u16 (mp->key_id));
2502 vat_json_object_add_string_copy (node, "key", mp->key);
2508 vl_api_lisp_eid_table_map_details_t_handler
2509 (vl_api_lisp_eid_table_map_details_t * mp)
2511 vat_main_t *vam = &vat_main;
2513 u8 *line = format (0, "%=10d%=10d",
2514 clib_net_to_host_u32 (mp->vni),
2515 clib_net_to_host_u32 (mp->dp_table));
2516 print (vam->ofp, "%v", line);
2521 vl_api_lisp_eid_table_map_details_t_handler_json
2522 (vl_api_lisp_eid_table_map_details_t * mp)
2524 vat_main_t *vam = &vat_main;
2525 vat_json_node_t *node = NULL;
2527 if (VAT_JSON_ARRAY != vam->json_tree.type)
2529 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2530 vat_json_init_array (&vam->json_tree);
2532 node = vat_json_array_add (&vam->json_tree);
2533 vat_json_init_object (node);
2534 vat_json_object_add_uint (node, "dp_table",
2535 clib_net_to_host_u32 (mp->dp_table));
2536 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2540 vl_api_lisp_eid_table_vni_details_t_handler
2541 (vl_api_lisp_eid_table_vni_details_t * mp)
2543 vat_main_t *vam = &vat_main;
2545 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2546 print (vam->ofp, "%v", line);
2551 vl_api_lisp_eid_table_vni_details_t_handler_json
2552 (vl_api_lisp_eid_table_vni_details_t * mp)
2554 vat_main_t *vam = &vat_main;
2555 vat_json_node_t *node = NULL;
2557 if (VAT_JSON_ARRAY != vam->json_tree.type)
2559 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2560 vat_json_init_array (&vam->json_tree);
2562 node = vat_json_array_add (&vam->json_tree);
2563 vat_json_init_object (node);
2564 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2568 vl_api_show_lisp_map_register_state_reply_t_handler
2569 (vl_api_show_lisp_map_register_state_reply_t * mp)
2571 vat_main_t *vam = &vat_main;
2572 int retval = clib_net_to_host_u32 (mp->retval);
2574 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2576 vam->retval = retval;
2577 vam->result_ready = 1;
2581 vl_api_show_lisp_map_register_state_reply_t_handler_json
2582 (vl_api_show_lisp_map_register_state_reply_t * mp)
2584 vat_main_t *vam = &vat_main;
2585 vat_json_node_t _node, *node = &_node;
2586 int retval = clib_net_to_host_u32 (mp->retval);
2588 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2590 vat_json_init_object (node);
2591 vat_json_object_add_string_copy (node, "state", s);
2593 vat_json_print (vam->ofp, node);
2594 vat_json_free (node);
2596 vam->retval = retval;
2597 vam->result_ready = 1;
2602 vl_api_show_lisp_rloc_probe_state_reply_t_handler
2603 (vl_api_show_lisp_rloc_probe_state_reply_t * mp)
2605 vat_main_t *vam = &vat_main;
2606 int retval = clib_net_to_host_u32 (mp->retval);
2611 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2613 vam->retval = retval;
2614 vam->result_ready = 1;
2618 vl_api_show_lisp_rloc_probe_state_reply_t_handler_json
2619 (vl_api_show_lisp_rloc_probe_state_reply_t * mp)
2621 vat_main_t *vam = &vat_main;
2622 vat_json_node_t _node, *node = &_node;
2623 int retval = clib_net_to_host_u32 (mp->retval);
2625 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2626 vat_json_init_object (node);
2627 vat_json_object_add_string_copy (node, "state", s);
2629 vat_json_print (vam->ofp, node);
2630 vat_json_free (node);
2632 vam->retval = retval;
2633 vam->result_ready = 1;
2638 vl_api_lisp_adjacencies_get_reply_t_handler
2639 (vl_api_lisp_adjacencies_get_reply_t * mp)
2641 vat_main_t *vam = &vat_main;
2643 int retval = clib_net_to_host_u32 (mp->retval);
2644 vl_api_lisp_adjacency_t *a;
2649 n = clib_net_to_host_u32 (mp->count);
2651 for (i = 0; i < n; i++)
2653 a = &mp->adjacencies[i];
2654 print (vam->ofp, "%U %40U",
2655 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
2656 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
2660 vam->retval = retval;
2661 vam->result_ready = 1;
2665 vl_api_lisp_adjacencies_get_reply_t_handler_json
2666 (vl_api_lisp_adjacencies_get_reply_t * mp)
2669 vat_main_t *vam = &vat_main;
2670 vat_json_node_t *e = 0, root;
2672 int retval = clib_net_to_host_u32 (mp->retval);
2673 vl_api_lisp_adjacency_t *a;
2678 n = clib_net_to_host_u32 (mp->count);
2679 vat_json_init_array (&root);
2681 for (i = 0; i < n; i++)
2683 e = vat_json_array_add (&root);
2684 a = &mp->adjacencies[i];
2686 vat_json_init_object (e);
2687 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
2688 a->leid_prefix_len);
2690 vat_json_object_add_string_copy (e, "leid", s);
2693 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
2694 a->reid_prefix_len);
2696 vat_json_object_add_string_copy (e, "reid", s);
2700 vat_json_print (vam->ofp, &root);
2701 vat_json_free (&root);
2704 vam->retval = retval;
2705 vam->result_ready = 1;
2709 vl_api_lisp_map_server_details_t_handler (vl_api_lisp_map_server_details_t
2712 vat_main_t *vam = &vat_main;
2714 print (vam->ofp, "%=20U",
2715 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2720 vl_api_lisp_map_server_details_t_handler_json
2721 (vl_api_lisp_map_server_details_t * mp)
2723 vat_main_t *vam = &vat_main;
2724 vat_json_node_t *node = NULL;
2725 struct in6_addr ip6;
2728 if (VAT_JSON_ARRAY != vam->json_tree.type)
2730 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2731 vat_json_init_array (&vam->json_tree);
2733 node = vat_json_array_add (&vam->json_tree);
2735 vat_json_init_object (node);
2738 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2739 vat_json_object_add_ip6 (node, "map-server", ip6);
2743 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2744 vat_json_object_add_ip4 (node, "map-server", ip4);
2749 vl_api_lisp_map_resolver_details_t_handler (vl_api_lisp_map_resolver_details_t
2752 vat_main_t *vam = &vat_main;
2754 print (vam->ofp, "%=20U",
2755 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2760 vl_api_lisp_map_resolver_details_t_handler_json
2761 (vl_api_lisp_map_resolver_details_t * mp)
2763 vat_main_t *vam = &vat_main;
2764 vat_json_node_t *node = NULL;
2765 struct in6_addr ip6;
2768 if (VAT_JSON_ARRAY != vam->json_tree.type)
2770 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2771 vat_json_init_array (&vam->json_tree);
2773 node = vat_json_array_add (&vam->json_tree);
2775 vat_json_init_object (node);
2778 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2779 vat_json_object_add_ip6 (node, "map resolver", ip6);
2783 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2784 vat_json_object_add_ip4 (node, "map resolver", ip4);
2789 vl_api_show_lisp_status_reply_t_handler
2790 (vl_api_show_lisp_status_reply_t * mp)
2792 vat_main_t *vam = &vat_main;
2793 i32 retval = ntohl (mp->retval);
2797 print (vam->ofp, "feature: %s\ngpe: %s",
2798 mp->feature_status ? "enabled" : "disabled",
2799 mp->gpe_status ? "enabled" : "disabled");
2802 vam->retval = retval;
2803 vam->result_ready = 1;
2807 vl_api_show_lisp_status_reply_t_handler_json
2808 (vl_api_show_lisp_status_reply_t * mp)
2810 vat_main_t *vam = &vat_main;
2811 vat_json_node_t node;
2812 u8 *gpe_status = NULL;
2813 u8 *feature_status = NULL;
2815 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
2816 feature_status = format (0, "%s",
2817 mp->feature_status ? "enabled" : "disabled");
2818 vec_add1 (gpe_status, 0);
2819 vec_add1 (feature_status, 0);
2821 vat_json_init_object (&node);
2822 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
2823 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
2825 vec_free (gpe_status);
2826 vec_free (feature_status);
2828 vat_json_print (vam->ofp, &node);
2829 vat_json_free (&node);
2831 vam->retval = ntohl (mp->retval);
2832 vam->result_ready = 1;
2836 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler
2837 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2839 vat_main_t *vam = &vat_main;
2840 i32 retval = ntohl (mp->retval);
2844 print (vam->ofp, "%=20s", mp->locator_set_name);
2847 vam->retval = retval;
2848 vam->result_ready = 1;
2852 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler_json
2853 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2855 vat_main_t *vam = &vat_main;
2856 vat_json_node_t *node = NULL;
2858 if (VAT_JSON_ARRAY != vam->json_tree.type)
2860 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2861 vat_json_init_array (&vam->json_tree);
2863 node = vat_json_array_add (&vam->json_tree);
2865 vat_json_init_object (node);
2866 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
2868 vat_json_print (vam->ofp, node);
2869 vat_json_free (node);
2871 vam->retval = ntohl (mp->retval);
2872 vam->result_ready = 1;
2876 format_lisp_map_request_mode (u8 * s, va_list * args)
2878 u32 mode = va_arg (*args, u32);
2883 return format (0, "dst-only");
2885 return format (0, "src-dst");
2891 vl_api_show_lisp_map_request_mode_reply_t_handler
2892 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2894 vat_main_t *vam = &vat_main;
2895 i32 retval = ntohl (mp->retval);
2899 u32 mode = mp->mode;
2900 print (vam->ofp, "map_request_mode: %U",
2901 format_lisp_map_request_mode, mode);
2904 vam->retval = retval;
2905 vam->result_ready = 1;
2909 vl_api_show_lisp_map_request_mode_reply_t_handler_json
2910 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2912 vat_main_t *vam = &vat_main;
2913 vat_json_node_t node;
2918 s = format (0, "%U", format_lisp_map_request_mode, mode);
2921 vat_json_init_object (&node);
2922 vat_json_object_add_string_copy (&node, "map_request_mode", s);
2923 vat_json_print (vam->ofp, &node);
2924 vat_json_free (&node);
2927 vam->retval = ntohl (mp->retval);
2928 vam->result_ready = 1;
2932 vl_api_show_lisp_pitr_reply_t_handler (vl_api_show_lisp_pitr_reply_t * mp)
2934 vat_main_t *vam = &vat_main;
2935 i32 retval = ntohl (mp->retval);
2939 print (vam->ofp, "%-20s%-16s",
2940 mp->status ? "enabled" : "disabled",
2941 mp->status ? (char *) mp->locator_set_name : "");
2944 vam->retval = retval;
2945 vam->result_ready = 1;
2949 vl_api_show_lisp_pitr_reply_t_handler_json (vl_api_show_lisp_pitr_reply_t *
2952 vat_main_t *vam = &vat_main;
2953 vat_json_node_t node;
2956 status = format (0, "%s", mp->status ? "enabled" : "disabled");
2957 vec_add1 (status, 0);
2959 vat_json_init_object (&node);
2960 vat_json_object_add_string_copy (&node, "status", status);
2963 vat_json_object_add_string_copy (&node, "locator_set",
2964 mp->locator_set_name);
2969 vat_json_print (vam->ofp, &node);
2970 vat_json_free (&node);
2972 vam->retval = ntohl (mp->retval);
2973 vam->result_ready = 1;
2977 format_policer_type (u8 * s, va_list * va)
2979 u32 i = va_arg (*va, u32);
2981 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
2982 s = format (s, "1r2c");
2983 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
2984 s = format (s, "1r3c");
2985 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
2986 s = format (s, "2r3c-2698");
2987 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
2988 s = format (s, "2r3c-4115");
2989 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
2990 s = format (s, "2r3c-mef5cf1");
2992 s = format (s, "ILLEGAL");
2997 format_policer_rate_type (u8 * s, va_list * va)
2999 u32 i = va_arg (*va, u32);
3001 if (i == SSE2_QOS_RATE_KBPS)
3002 s = format (s, "kbps");
3003 else if (i == SSE2_QOS_RATE_PPS)
3004 s = format (s, "pps");
3006 s = format (s, "ILLEGAL");
3011 format_policer_round_type (u8 * s, va_list * va)
3013 u32 i = va_arg (*va, u32);
3015 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3016 s = format (s, "closest");
3017 else if (i == SSE2_QOS_ROUND_TO_UP)
3018 s = format (s, "up");
3019 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3020 s = format (s, "down");
3022 s = format (s, "ILLEGAL");
3027 format_policer_action_type (u8 * s, va_list * va)
3029 u32 i = va_arg (*va, u32);
3031 if (i == SSE2_QOS_ACTION_DROP)
3032 s = format (s, "drop");
3033 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3034 s = format (s, "transmit");
3035 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3036 s = format (s, "mark-and-transmit");
3038 s = format (s, "ILLEGAL");
3043 format_dscp (u8 * s, va_list * va)
3045 u32 i = va_arg (*va, u32);
3050 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3054 return format (s, "ILLEGAL");
3056 s = format (s, "%s", t);
3061 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3063 vat_main_t *vam = &vat_main;
3064 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3066 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3067 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3069 conform_dscp_str = format (0, "");
3071 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3072 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3074 exceed_dscp_str = format (0, "");
3076 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3077 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3079 violate_dscp_str = format (0, "");
3081 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3082 "rate type %U, round type %U, %s rate, %s color-aware, "
3083 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3084 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3085 "conform action %U%s, exceed action %U%s, violate action %U%s",
3087 format_policer_type, mp->type,
3090 clib_net_to_host_u64 (mp->cb),
3091 clib_net_to_host_u64 (mp->eb),
3092 format_policer_rate_type, mp->rate_type,
3093 format_policer_round_type, mp->round_type,
3094 mp->single_rate ? "single" : "dual",
3095 mp->color_aware ? "is" : "not",
3096 ntohl (mp->cir_tokens_per_period),
3097 ntohl (mp->pir_tokens_per_period),
3099 ntohl (mp->current_limit),
3100 ntohl (mp->current_bucket),
3101 ntohl (mp->extended_limit),
3102 ntohl (mp->extended_bucket),
3103 clib_net_to_host_u64 (mp->last_update_time),
3104 format_policer_action_type, mp->conform_action_type,
3106 format_policer_action_type, mp->exceed_action_type,
3108 format_policer_action_type, mp->violate_action_type,
3111 vec_free (conform_dscp_str);
3112 vec_free (exceed_dscp_str);
3113 vec_free (violate_dscp_str);
3116 static void vl_api_policer_details_t_handler_json
3117 (vl_api_policer_details_t * mp)
3119 vat_main_t *vam = &vat_main;
3120 vat_json_node_t *node;
3121 u8 *rate_type_str, *round_type_str, *type_str;
3122 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3124 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3126 format (0, "%U", format_policer_round_type, mp->round_type);
3127 type_str = format (0, "%U", format_policer_type, mp->type);
3128 conform_action_str = format (0, "%U", format_policer_action_type,
3129 mp->conform_action_type);
3130 exceed_action_str = format (0, "%U", format_policer_action_type,
3131 mp->exceed_action_type);
3132 violate_action_str = format (0, "%U", format_policer_action_type,
3133 mp->violate_action_type);
3135 if (VAT_JSON_ARRAY != vam->json_tree.type)
3137 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3138 vat_json_init_array (&vam->json_tree);
3140 node = vat_json_array_add (&vam->json_tree);
3142 vat_json_init_object (node);
3143 vat_json_object_add_string_copy (node, "name", mp->name);
3144 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3145 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3146 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3147 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3148 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3149 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3150 vat_json_object_add_string_copy (node, "type", type_str);
3151 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3152 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3153 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3154 vat_json_object_add_uint (node, "cir_tokens_per_period",
3155 ntohl (mp->cir_tokens_per_period));
3156 vat_json_object_add_uint (node, "eir_tokens_per_period",
3157 ntohl (mp->pir_tokens_per_period));
3158 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3159 vat_json_object_add_uint (node, "current_bucket",
3160 ntohl (mp->current_bucket));
3161 vat_json_object_add_uint (node, "extended_limit",
3162 ntohl (mp->extended_limit));
3163 vat_json_object_add_uint (node, "extended_bucket",
3164 ntohl (mp->extended_bucket));
3165 vat_json_object_add_uint (node, "last_update_time",
3166 ntohl (mp->last_update_time));
3167 vat_json_object_add_string_copy (node, "conform_action",
3168 conform_action_str);
3169 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3171 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3172 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3173 vec_free (dscp_str);
3175 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3176 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3178 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3179 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3180 vec_free (dscp_str);
3182 vat_json_object_add_string_copy (node, "violate_action",
3183 violate_action_str);
3184 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3186 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3187 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3188 vec_free (dscp_str);
3191 vec_free (rate_type_str);
3192 vec_free (round_type_str);
3193 vec_free (type_str);
3194 vec_free (conform_action_str);
3195 vec_free (exceed_action_str);
3196 vec_free (violate_action_str);
3200 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3203 vat_main_t *vam = &vat_main;
3204 int i, count = ntohl (mp->count);
3207 print (vam->ofp, "classify table ids (%d) : ", count);
3208 for (i = 0; i < count; i++)
3210 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3211 print (vam->ofp, (i < count - 1) ? "," : "");
3213 vam->retval = ntohl (mp->retval);
3214 vam->result_ready = 1;
3218 vl_api_classify_table_ids_reply_t_handler_json
3219 (vl_api_classify_table_ids_reply_t * mp)
3221 vat_main_t *vam = &vat_main;
3222 int i, count = ntohl (mp->count);
3226 vat_json_node_t node;
3228 vat_json_init_object (&node);
3229 for (i = 0; i < count; i++)
3231 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3233 vat_json_print (vam->ofp, &node);
3234 vat_json_free (&node);
3236 vam->retval = ntohl (mp->retval);
3237 vam->result_ready = 1;
3241 vl_api_classify_table_by_interface_reply_t_handler
3242 (vl_api_classify_table_by_interface_reply_t * mp)
3244 vat_main_t *vam = &vat_main;
3247 table_id = ntohl (mp->l2_table_id);
3249 print (vam->ofp, "l2 table id : %d", table_id);
3251 print (vam->ofp, "l2 table id : No input ACL tables configured");
3252 table_id = ntohl (mp->ip4_table_id);
3254 print (vam->ofp, "ip4 table id : %d", table_id);
3256 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3257 table_id = ntohl (mp->ip6_table_id);
3259 print (vam->ofp, "ip6 table id : %d", table_id);
3261 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3262 vam->retval = ntohl (mp->retval);
3263 vam->result_ready = 1;
3267 vl_api_classify_table_by_interface_reply_t_handler_json
3268 (vl_api_classify_table_by_interface_reply_t * mp)
3270 vat_main_t *vam = &vat_main;
3271 vat_json_node_t node;
3273 vat_json_init_object (&node);
3275 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3276 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3277 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3279 vat_json_print (vam->ofp, &node);
3280 vat_json_free (&node);
3282 vam->retval = ntohl (mp->retval);
3283 vam->result_ready = 1;
3286 static void vl_api_policer_add_del_reply_t_handler
3287 (vl_api_policer_add_del_reply_t * mp)
3289 vat_main_t *vam = &vat_main;
3290 i32 retval = ntohl (mp->retval);
3291 if (vam->async_mode)
3293 vam->async_errors += (retval < 0);
3297 vam->retval = retval;
3298 vam->result_ready = 1;
3299 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3301 * Note: this is just barely thread-safe, depends on
3302 * the main thread spinning waiting for an answer...
3304 errmsg ("policer index %d", ntohl (mp->policer_index));
3308 static void vl_api_policer_add_del_reply_t_handler_json
3309 (vl_api_policer_add_del_reply_t * mp)
3311 vat_main_t *vam = &vat_main;
3312 vat_json_node_t node;
3314 vat_json_init_object (&node);
3315 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3316 vat_json_object_add_uint (&node, "policer_index",
3317 ntohl (mp->policer_index));
3319 vat_json_print (vam->ofp, &node);
3320 vat_json_free (&node);
3322 vam->retval = ntohl (mp->retval);
3323 vam->result_ready = 1;
3326 /* Format hex dump. */
3328 format_hex_bytes (u8 * s, va_list * va)
3330 u8 *bytes = va_arg (*va, u8 *);
3331 int n_bytes = va_arg (*va, int);
3334 /* Print short or long form depending on byte count. */
3335 uword short_form = n_bytes <= 32;
3336 uword indent = format_get_indent (s);
3341 for (i = 0; i < n_bytes; i++)
3343 if (!short_form && (i % 32) == 0)
3344 s = format (s, "%08x: ", i);
3345 s = format (s, "%02x", bytes[i]);
3346 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3347 s = format (s, "\n%U", format_white_space, indent);
3354 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3357 vat_main_t *vam = &vat_main;
3358 i32 retval = ntohl (mp->retval);
3361 print (vam->ofp, "classify table info :");
3362 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3363 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3364 ntohl (mp->miss_next_index));
3365 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3366 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3367 ntohl (mp->match_n_vectors));
3368 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3369 ntohl (mp->mask_length));
3371 vam->retval = retval;
3372 vam->result_ready = 1;
3376 vl_api_classify_table_info_reply_t_handler_json
3377 (vl_api_classify_table_info_reply_t * mp)
3379 vat_main_t *vam = &vat_main;
3380 vat_json_node_t node;
3382 i32 retval = ntohl (mp->retval);
3385 vat_json_init_object (&node);
3387 vat_json_object_add_int (&node, "sessions",
3388 ntohl (mp->active_sessions));
3389 vat_json_object_add_int (&node, "nexttbl",
3390 ntohl (mp->next_table_index));
3391 vat_json_object_add_int (&node, "nextnode",
3392 ntohl (mp->miss_next_index));
3393 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3394 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3395 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3396 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3397 ntohl (mp->mask_length), 0);
3398 vat_json_object_add_string_copy (&node, "mask", s);
3400 vat_json_print (vam->ofp, &node);
3401 vat_json_free (&node);
3403 vam->retval = ntohl (mp->retval);
3404 vam->result_ready = 1;
3408 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3411 vat_main_t *vam = &vat_main;
3413 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3414 ntohl (mp->hit_next_index), ntohl (mp->advance),
3415 ntohl (mp->opaque_index));
3416 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
3417 ntohl (mp->match_length));
3421 vl_api_classify_session_details_t_handler_json
3422 (vl_api_classify_session_details_t * mp)
3424 vat_main_t *vam = &vat_main;
3425 vat_json_node_t *node = NULL;
3427 if (VAT_JSON_ARRAY != vam->json_tree.type)
3429 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3430 vat_json_init_array (&vam->json_tree);
3432 node = vat_json_array_add (&vam->json_tree);
3434 vat_json_init_object (node);
3435 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3436 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3437 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3439 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3441 vat_json_object_add_string_copy (node, "match", s);
3444 static void vl_api_pg_create_interface_reply_t_handler
3445 (vl_api_pg_create_interface_reply_t * mp)
3447 vat_main_t *vam = &vat_main;
3449 vam->retval = ntohl (mp->retval);
3450 vam->result_ready = 1;
3453 static void vl_api_pg_create_interface_reply_t_handler_json
3454 (vl_api_pg_create_interface_reply_t * mp)
3456 vat_main_t *vam = &vat_main;
3457 vat_json_node_t node;
3459 i32 retval = ntohl (mp->retval);
3462 vat_json_init_object (&node);
3464 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3466 vat_json_print (vam->ofp, &node);
3467 vat_json_free (&node);
3469 vam->retval = ntohl (mp->retval);
3470 vam->result_ready = 1;
3473 static void vl_api_policer_classify_details_t_handler
3474 (vl_api_policer_classify_details_t * mp)
3476 vat_main_t *vam = &vat_main;
3478 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3479 ntohl (mp->table_index));
3482 static void vl_api_policer_classify_details_t_handler_json
3483 (vl_api_policer_classify_details_t * mp)
3485 vat_main_t *vam = &vat_main;
3486 vat_json_node_t *node;
3488 if (VAT_JSON_ARRAY != vam->json_tree.type)
3490 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3491 vat_json_init_array (&vam->json_tree);
3493 node = vat_json_array_add (&vam->json_tree);
3495 vat_json_init_object (node);
3496 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3497 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3500 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3501 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3503 vat_main_t *vam = &vat_main;
3504 i32 retval = ntohl (mp->retval);
3505 if (vam->async_mode)
3507 vam->async_errors += (retval < 0);
3511 vam->retval = retval;
3512 vam->sw_if_index = ntohl (mp->sw_if_index);
3513 vam->result_ready = 1;
3517 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3518 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3520 vat_main_t *vam = &vat_main;
3521 vat_json_node_t node;
3523 vat_json_init_object (&node);
3524 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3525 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3527 vat_json_print (vam->ofp, &node);
3528 vat_json_free (&node);
3530 vam->retval = ntohl (mp->retval);
3531 vam->result_ready = 1;
3534 static void vl_api_flow_classify_details_t_handler
3535 (vl_api_flow_classify_details_t * mp)
3537 vat_main_t *vam = &vat_main;
3539 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3540 ntohl (mp->table_index));
3543 static void vl_api_flow_classify_details_t_handler_json
3544 (vl_api_flow_classify_details_t * mp)
3546 vat_main_t *vam = &vat_main;
3547 vat_json_node_t *node;
3549 if (VAT_JSON_ARRAY != vam->json_tree.type)
3551 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3552 vat_json_init_array (&vam->json_tree);
3554 node = vat_json_array_add (&vam->json_tree);
3556 vat_json_init_object (node);
3557 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3558 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3563 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3564 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3565 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3566 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3567 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
3568 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
3569 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
3570 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
3571 #define vl_api_lisp_adjacencies_get_reply_t_endian vl_noop_handler
3572 #define vl_api_lisp_adjacencies_get_reply_t_print vl_noop_handler
3575 * Generate boilerplate reply handlers, which
3576 * dig the return value out of the xxx_reply_t API message,
3577 * stick it into vam->retval, and set vam->result_ready
3579 * Could also do this by pointing N message decode slots at
3580 * a single function, but that could break in subtle ways.
3583 #define foreach_standard_reply_retval_handler \
3584 _(sw_interface_set_flags_reply) \
3585 _(sw_interface_add_del_address_reply) \
3586 _(sw_interface_set_table_reply) \
3587 _(sw_interface_set_mpls_enable_reply) \
3588 _(sw_interface_set_vpath_reply) \
3589 _(sw_interface_set_vxlan_bypass_reply) \
3590 _(sw_interface_set_l2_bridge_reply) \
3591 _(bridge_domain_add_del_reply) \
3592 _(sw_interface_set_l2_xconnect_reply) \
3593 _(l2fib_add_del_reply) \
3594 _(ip_add_del_route_reply) \
3595 _(mpls_route_add_del_reply) \
3596 _(mpls_ip_bind_unbind_reply) \
3597 _(proxy_arp_add_del_reply) \
3598 _(proxy_arp_intfc_enable_disable_reply) \
3599 _(sw_interface_set_unnumbered_reply) \
3600 _(ip_neighbor_add_del_reply) \
3601 _(reset_vrf_reply) \
3602 _(oam_add_del_reply) \
3603 _(reset_fib_reply) \
3604 _(dhcp_proxy_config_reply) \
3605 _(dhcp_proxy_config_2_reply) \
3606 _(dhcp_proxy_set_vss_reply) \
3607 _(dhcp_client_config_reply) \
3608 _(set_ip_flow_hash_reply) \
3609 _(sw_interface_ip6_enable_disable_reply) \
3610 _(sw_interface_ip6_set_link_local_address_reply) \
3611 _(sw_interface_ip6nd_ra_prefix_reply) \
3612 _(sw_interface_ip6nd_ra_config_reply) \
3613 _(set_arp_neighbor_limit_reply) \
3614 _(l2_patch_add_del_reply) \
3615 _(sr_tunnel_add_del_reply) \
3616 _(sr_policy_add_del_reply) \
3617 _(sr_multicast_map_add_del_reply) \
3618 _(classify_add_del_session_reply) \
3619 _(classify_set_interface_ip_table_reply) \
3620 _(classify_set_interface_l2_tables_reply) \
3621 _(l2tpv3_set_tunnel_cookies_reply) \
3622 _(l2tpv3_interface_enable_disable_reply) \
3623 _(l2tpv3_set_lookup_key_reply) \
3624 _(l2_fib_clear_table_reply) \
3625 _(l2_interface_efp_filter_reply) \
3626 _(l2_interface_vlan_tag_rewrite_reply) \
3627 _(modify_vhost_user_if_reply) \
3628 _(delete_vhost_user_if_reply) \
3629 _(want_ip4_arp_events_reply) \
3630 _(want_ip6_nd_events_reply) \
3631 _(input_acl_set_interface_reply) \
3632 _(ipsec_spd_add_del_reply) \
3633 _(ipsec_interface_add_del_spd_reply) \
3634 _(ipsec_spd_add_del_entry_reply) \
3635 _(ipsec_sad_add_del_entry_reply) \
3636 _(ipsec_sa_set_key_reply) \
3637 _(ikev2_profile_add_del_reply) \
3638 _(ikev2_profile_set_auth_reply) \
3639 _(ikev2_profile_set_id_reply) \
3640 _(ikev2_profile_set_ts_reply) \
3641 _(ikev2_set_local_key_reply) \
3642 _(delete_loopback_reply) \
3643 _(bd_ip_mac_add_del_reply) \
3644 _(map_del_domain_reply) \
3645 _(map_add_del_rule_reply) \
3646 _(want_interface_events_reply) \
3647 _(want_stats_reply) \
3648 _(cop_interface_enable_disable_reply) \
3649 _(cop_whitelist_enable_disable_reply) \
3650 _(sw_interface_clear_stats_reply) \
3651 _(ioam_enable_reply) \
3652 _(ioam_disable_reply) \
3653 _(lisp_add_del_locator_reply) \
3654 _(lisp_add_del_local_eid_reply) \
3655 _(lisp_add_del_remote_mapping_reply) \
3656 _(lisp_add_del_adjacency_reply) \
3657 _(lisp_gpe_add_del_fwd_entry_reply) \
3658 _(lisp_add_del_map_resolver_reply) \
3659 _(lisp_add_del_map_server_reply) \
3660 _(lisp_gpe_enable_disable_reply) \
3661 _(lisp_gpe_add_del_iface_reply) \
3662 _(lisp_enable_disable_reply) \
3663 _(lisp_rloc_probe_enable_disable_reply) \
3664 _(lisp_map_register_enable_disable_reply) \
3665 _(lisp_pitr_set_locator_set_reply) \
3666 _(lisp_map_request_mode_reply) \
3667 _(lisp_add_del_map_request_itr_rlocs_reply) \
3668 _(lisp_eid_table_add_del_map_reply) \
3669 _(vxlan_gpe_add_del_tunnel_reply) \
3670 _(af_packet_delete_reply) \
3671 _(policer_classify_set_interface_reply) \
3672 _(netmap_create_reply) \
3673 _(netmap_delete_reply) \
3674 _(set_ipfix_exporter_reply) \
3675 _(set_ipfix_classify_stream_reply) \
3676 _(ipfix_classify_table_add_del_reply) \
3677 _(flow_classify_set_interface_reply) \
3678 _(sw_interface_span_enable_disable_reply) \
3679 _(pg_capture_reply) \
3680 _(pg_enable_disable_reply) \
3681 _(ip_source_and_port_range_check_add_del_reply) \
3682 _(ip_source_and_port_range_check_interface_add_del_reply)\
3683 _(delete_subif_reply) \
3684 _(l2_interface_pbb_tag_rewrite_reply) \
3686 _(feature_enable_disable_reply) \
3687 _(sw_interface_tag_add_del_reply) \
3688 _(sw_interface_set_mtu_reply)
3691 #define foreach_standard_dpdk_reply_retval_handler \
3692 _(sw_interface_set_dpdk_hqos_pipe_reply) \
3693 _(sw_interface_set_dpdk_hqos_subport_reply) \
3694 _(sw_interface_set_dpdk_hqos_tctbl_reply)
3698 static void vl_api_##n##_t_handler \
3699 (vl_api_##n##_t * mp) \
3701 vat_main_t * vam = &vat_main; \
3702 i32 retval = ntohl(mp->retval); \
3703 if (vam->async_mode) { \
3704 vam->async_errors += (retval < 0); \
3706 vam->retval = retval; \
3707 vam->result_ready = 1; \
3710 foreach_standard_reply_retval_handler;
3714 static void vl_api_##n##_t_handler_json \
3715 (vl_api_##n##_t * mp) \
3717 vat_main_t * vam = &vat_main; \
3718 vat_json_node_t node; \
3719 vat_json_init_object(&node); \
3720 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3721 vat_json_print(vam->ofp, &node); \
3722 vam->retval = ntohl(mp->retval); \
3723 vam->result_ready = 1; \
3725 foreach_standard_reply_retval_handler;
3730 static void vl_api_##n##_t_handler \
3731 (vl_api_##n##_t * mp) \
3733 vat_main_t * vam = &vat_main; \
3734 i32 retval = ntohl(mp->retval); \
3735 if (vam->async_mode) { \
3736 vam->async_errors += (retval < 0); \
3738 vam->retval = retval; \
3739 vam->result_ready = 1; \
3742 foreach_standard_dpdk_reply_retval_handler;
3746 static void vl_api_##n##_t_handler_json \
3747 (vl_api_##n##_t * mp) \
3749 vat_main_t * vam = &vat_main; \
3750 vat_json_node_t node; \
3751 vat_json_init_object(&node); \
3752 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3753 vat_json_print(vam->ofp, &node); \
3754 vam->retval = ntohl(mp->retval); \
3755 vam->result_ready = 1; \
3757 foreach_standard_dpdk_reply_retval_handler;
3762 * Table of message reply handlers, must include boilerplate handlers
3766 #define foreach_vpe_api_reply_msg \
3767 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3768 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3769 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
3770 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3771 _(CONTROL_PING_REPLY, control_ping_reply) \
3772 _(CLI_REPLY, cli_reply) \
3773 _(CLI_INBAND_REPLY, cli_inband_reply) \
3774 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
3775 sw_interface_add_del_address_reply) \
3776 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
3777 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
3778 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
3779 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
3780 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
3781 sw_interface_set_l2_xconnect_reply) \
3782 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
3783 sw_interface_set_l2_bridge_reply) \
3784 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
3785 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
3786 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
3787 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
3788 _(L2_FLAGS_REPLY, l2_flags_reply) \
3789 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
3790 _(TAP_CONNECT_REPLY, tap_connect_reply) \
3791 _(TAP_MODIFY_REPLY, tap_modify_reply) \
3792 _(TAP_DELETE_REPLY, tap_delete_reply) \
3793 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
3794 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
3795 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
3796 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
3797 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
3798 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
3799 proxy_arp_intfc_enable_disable_reply) \
3800 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
3801 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
3802 sw_interface_set_unnumbered_reply) \
3803 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
3804 _(RESET_VRF_REPLY, reset_vrf_reply) \
3805 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
3806 _(CREATE_SUBIF_REPLY, create_subif_reply) \
3807 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
3808 _(RESET_FIB_REPLY, reset_fib_reply) \
3809 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
3810 _(DHCP_PROXY_CONFIG_2_REPLY, dhcp_proxy_config_2_reply) \
3811 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
3812 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
3813 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
3814 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
3815 sw_interface_ip6_enable_disable_reply) \
3816 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
3817 sw_interface_ip6_set_link_local_address_reply) \
3818 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
3819 sw_interface_ip6nd_ra_prefix_reply) \
3820 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
3821 sw_interface_ip6nd_ra_config_reply) \
3822 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
3823 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
3824 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
3825 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
3826 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
3827 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
3828 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
3829 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
3830 classify_set_interface_ip_table_reply) \
3831 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
3832 classify_set_interface_l2_tables_reply) \
3833 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
3834 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
3835 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
3836 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
3837 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
3838 l2tpv3_interface_enable_disable_reply) \
3839 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
3840 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
3841 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
3842 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
3843 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
3844 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
3845 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
3846 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
3847 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
3848 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
3849 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
3850 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
3851 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
3852 _(SHOW_VERSION_REPLY, show_version_reply) \
3853 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
3854 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
3855 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
3856 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
3857 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
3858 _(IP4_ARP_EVENT, ip4_arp_event) \
3859 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
3860 _(IP6_ND_EVENT, ip6_nd_event) \
3861 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
3862 _(IP_ADDRESS_DETAILS, ip_address_details) \
3863 _(IP_DETAILS, ip_details) \
3864 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
3865 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
3866 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
3867 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
3868 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
3869 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
3870 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
3871 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
3872 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
3873 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
3874 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
3875 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
3876 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
3877 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
3878 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
3879 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
3880 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
3881 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
3882 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
3883 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
3884 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
3885 _(MAP_DOMAIN_DETAILS, map_domain_details) \
3886 _(MAP_RULE_DETAILS, map_rule_details) \
3887 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
3888 _(WANT_STATS_REPLY, want_stats_reply) \
3889 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
3890 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
3891 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
3892 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
3893 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
3894 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
3895 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
3896 _(LISP_ADD_DEL_LOCATOR_SET_REPLY, lisp_add_del_locator_set_reply) \
3897 _(LISP_ADD_DEL_LOCATOR_REPLY, lisp_add_del_locator_reply) \
3898 _(LISP_ADD_DEL_LOCAL_EID_REPLY, lisp_add_del_local_eid_reply) \
3899 _(LISP_ADD_DEL_REMOTE_MAPPING_REPLY, lisp_add_del_remote_mapping_reply) \
3900 _(LISP_ADD_DEL_ADJACENCY_REPLY, lisp_add_del_adjacency_reply) \
3901 _(LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY, lisp_gpe_add_del_fwd_entry_reply) \
3902 _(LISP_ADD_DEL_MAP_RESOLVER_REPLY, lisp_add_del_map_resolver_reply) \
3903 _(LISP_ADD_DEL_MAP_SERVER_REPLY, lisp_add_del_map_server_reply) \
3904 _(LISP_GPE_ENABLE_DISABLE_REPLY, lisp_gpe_enable_disable_reply) \
3905 _(LISP_ENABLE_DISABLE_REPLY, lisp_enable_disable_reply) \
3906 _(LISP_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
3907 lisp_map_register_enable_disable_reply) \
3908 _(LISP_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
3909 lisp_rloc_probe_enable_disable_reply) \
3910 _(LISP_PITR_SET_LOCATOR_SET_REPLY, lisp_pitr_set_locator_set_reply) \
3911 _(LISP_MAP_REQUEST_MODE_REPLY, lisp_map_request_mode_reply) \
3912 _(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \
3913 _(LISP_GPE_ADD_DEL_IFACE_REPLY, lisp_gpe_add_del_iface_reply) \
3914 _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \
3915 _(LISP_LOCATOR_DETAILS, lisp_locator_details) \
3916 _(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \
3917 _(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \
3918 _(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \
3919 _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
3920 _(LISP_MAP_SERVER_DETAILS, lisp_map_server_details) \
3921 _(LISP_ADJACENCIES_GET_REPLY, lisp_adjacencies_get_reply) \
3922 _(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
3923 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
3924 lisp_add_del_map_request_itr_rlocs_reply) \
3925 _(LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
3926 lisp_get_map_request_itr_rlocs_reply) \
3927 _(SHOW_LISP_PITR_REPLY, show_lisp_pitr_reply) \
3928 _(SHOW_LISP_MAP_REQUEST_MODE_REPLY, show_lisp_map_request_mode_reply) \
3929 _(SHOW_LISP_RLOC_PROBE_STATE_REPLY, show_lisp_rloc_probe_state_reply) \
3930 _(SHOW_LISP_MAP_REGISTER_STATE_REPLY, \
3931 show_lisp_map_register_state_reply) \
3932 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
3933 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
3934 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
3935 _(POLICER_DETAILS, policer_details) \
3936 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
3937 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
3938 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
3939 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
3940 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
3941 _(MPLS_FIB_DETAILS, mpls_fib_details) \
3942 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
3943 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
3944 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
3945 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
3946 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
3947 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
3948 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
3949 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
3950 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
3951 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
3952 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
3953 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
3954 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
3955 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
3956 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
3957 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
3958 _(PG_CAPTURE_REPLY, pg_capture_reply) \
3959 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
3960 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
3961 ip_source_and_port_range_check_add_del_reply) \
3962 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
3963 ip_source_and_port_range_check_interface_add_del_reply) \
3964 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
3965 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
3966 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
3967 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
3968 _(PUNT_REPLY, punt_reply) \
3969 _(IP_FIB_DETAILS, ip_fib_details) \
3970 _(IP6_FIB_DETAILS, ip6_fib_details) \
3971 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
3972 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
3973 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
3974 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
3975 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
3976 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
3979 #define foreach_vpe_dpdk_api_reply_msg \
3980 _(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
3981 sw_interface_set_dpdk_hqos_pipe_reply) \
3982 _(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
3983 sw_interface_set_dpdk_hqos_subport_reply) \
3984 _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
3985 sw_interface_set_dpdk_hqos_tctbl_reply)
3995 #define STR_VTR_OP_CASE(op) \
3996 case L2_VTR_ ## op: \
4000 str_vtr_op (u32 vtr_op)
4004 STR_VTR_OP_CASE (DISABLED);
4005 STR_VTR_OP_CASE (PUSH_1);
4006 STR_VTR_OP_CASE (PUSH_2);
4007 STR_VTR_OP_CASE (POP_1);
4008 STR_VTR_OP_CASE (POP_2);
4009 STR_VTR_OP_CASE (TRANSLATE_1_1);
4010 STR_VTR_OP_CASE (TRANSLATE_1_2);
4011 STR_VTR_OP_CASE (TRANSLATE_2_1);
4012 STR_VTR_OP_CASE (TRANSLATE_2_2);
4019 dump_sub_interface_table (vat_main_t * vam)
4021 const sw_interface_subif_t *sub = NULL;
4023 if (vam->json_output)
4026 ("JSON output supported only for VPE API calls and dump_stats_table");
4031 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4032 "Interface", "sw_if_index",
4033 "sub id", "dot1ad", "tags", "outer id",
4034 "inner id", "exact", "default", "outer any", "inner any");
4036 vec_foreach (sub, vam->sw_if_subif_table)
4039 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4040 sub->interface_name,
4042 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4043 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4044 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4045 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4046 if (sub->vtr_op != L2_VTR_DISABLED)
4049 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4050 "tag1: %d tag2: %d ]",
4051 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4052 sub->vtr_tag1, sub->vtr_tag2);
4060 name_sort_cmp (void *a1, void *a2)
4062 name_sort_t *n1 = a1;
4063 name_sort_t *n2 = a2;
4065 return strcmp ((char *) n1->name, (char *) n2->name);
4069 dump_interface_table (vat_main_t * vam)
4072 name_sort_t *nses = 0, *ns;
4074 if (vam->json_output)
4077 ("JSON output supported only for VPE API calls and dump_stats_table");
4082 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4084 vec_add2 (nses, ns, 1);
4085 ns->name = (u8 *)(p->key);
4086 ns->value = (u32) p->value[0];
4090 vec_sort_with_function (nses, name_sort_cmp);
4092 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4093 vec_foreach (ns, nses)
4095 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4102 dump_ip_table (vat_main_t * vam, int is_ipv6)
4104 const ip_details_t *det = NULL;
4105 const ip_address_details_t *address = NULL;
4108 print (vam->ofp, "%-12s", "sw_if_index");
4110 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4117 print (vam->ofp, "%-12d", i);
4118 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4123 vec_foreach (address, det->addr)
4127 is_ipv6 ? format_ip6_address : format_ip4_address,
4128 address->ip, address->prefix_length);
4136 dump_ipv4_table (vat_main_t * vam)
4138 if (vam->json_output)
4141 ("JSON output supported only for VPE API calls and dump_stats_table");
4145 return dump_ip_table (vam, 0);
4149 dump_ipv6_table (vat_main_t * vam)
4151 if (vam->json_output)
4154 ("JSON output supported only for VPE API calls and dump_stats_table");
4158 return dump_ip_table (vam, 1);
4162 counter_type_to_str (u8 counter_type, u8 is_combined)
4166 switch (counter_type)
4168 case VNET_INTERFACE_COUNTER_DROP:
4170 case VNET_INTERFACE_COUNTER_PUNT:
4172 case VNET_INTERFACE_COUNTER_IP4:
4174 case VNET_INTERFACE_COUNTER_IP6:
4176 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4178 case VNET_INTERFACE_COUNTER_RX_MISS:
4180 case VNET_INTERFACE_COUNTER_RX_ERROR:
4182 case VNET_INTERFACE_COUNTER_TX_ERROR:
4185 return "INVALID-COUNTER-TYPE";
4190 switch (counter_type)
4192 case VNET_INTERFACE_COUNTER_RX:
4194 case VNET_INTERFACE_COUNTER_TX:
4197 return "INVALID-COUNTER-TYPE";
4203 dump_stats_table (vat_main_t * vam)
4205 vat_json_node_t node;
4206 vat_json_node_t *msg_array;
4207 vat_json_node_t *msg;
4208 vat_json_node_t *counter_array;
4209 vat_json_node_t *counter;
4210 interface_counter_t c;
4212 ip4_fib_counter_t *c4;
4213 ip6_fib_counter_t *c6;
4214 ip4_nbr_counter_t *n4;
4215 ip6_nbr_counter_t *n6;
4218 if (!vam->json_output)
4220 clib_warning ("dump_stats_table supported only in JSON format");
4224 vat_json_init_object (&node);
4226 /* interface counters */
4227 msg_array = vat_json_object_add (&node, "interface_counters");
4228 vat_json_init_array (msg_array);
4229 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4231 msg = vat_json_array_add (msg_array);
4232 vat_json_init_object (msg);
4233 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4234 (u8 *) counter_type_to_str (i, 0));
4235 vat_json_object_add_int (msg, "is_combined", 0);
4236 counter_array = vat_json_object_add (msg, "data");
4237 vat_json_init_array (counter_array);
4238 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4240 packets = vam->simple_interface_counters[i][j];
4241 vat_json_array_add_uint (counter_array, packets);
4244 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4246 msg = vat_json_array_add (msg_array);
4247 vat_json_init_object (msg);
4248 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4249 (u8 *) counter_type_to_str (i, 1));
4250 vat_json_object_add_int (msg, "is_combined", 1);
4251 counter_array = vat_json_object_add (msg, "data");
4252 vat_json_init_array (counter_array);
4253 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4255 c = vam->combined_interface_counters[i][j];
4256 counter = vat_json_array_add (counter_array);
4257 vat_json_init_object (counter);
4258 vat_json_object_add_uint (counter, "packets", c.packets);
4259 vat_json_object_add_uint (counter, "bytes", c.bytes);
4263 /* ip4 fib counters */
4264 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4265 vat_json_init_array (msg_array);
4266 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4268 msg = vat_json_array_add (msg_array);
4269 vat_json_init_object (msg);
4270 vat_json_object_add_uint (msg, "vrf_id",
4271 vam->ip4_fib_counters_vrf_id_by_index[i]);
4272 counter_array = vat_json_object_add (msg, "c");
4273 vat_json_init_array (counter_array);
4274 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4276 counter = vat_json_array_add (counter_array);
4277 vat_json_init_object (counter);
4278 c4 = &vam->ip4_fib_counters[i][j];
4279 vat_json_object_add_ip4 (counter, "address", c4->address);
4280 vat_json_object_add_uint (counter, "address_length",
4281 c4->address_length);
4282 vat_json_object_add_uint (counter, "packets", c4->packets);
4283 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4287 /* ip6 fib counters */
4288 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4289 vat_json_init_array (msg_array);
4290 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4292 msg = vat_json_array_add (msg_array);
4293 vat_json_init_object (msg);
4294 vat_json_object_add_uint (msg, "vrf_id",
4295 vam->ip6_fib_counters_vrf_id_by_index[i]);
4296 counter_array = vat_json_object_add (msg, "c");
4297 vat_json_init_array (counter_array);
4298 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4300 counter = vat_json_array_add (counter_array);
4301 vat_json_init_object (counter);
4302 c6 = &vam->ip6_fib_counters[i][j];
4303 vat_json_object_add_ip6 (counter, "address", c6->address);
4304 vat_json_object_add_uint (counter, "address_length",
4305 c6->address_length);
4306 vat_json_object_add_uint (counter, "packets", c6->packets);
4307 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4311 /* ip4 nbr counters */
4312 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
4313 vat_json_init_array (msg_array);
4314 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
4316 msg = vat_json_array_add (msg_array);
4317 vat_json_init_object (msg);
4318 vat_json_object_add_uint (msg, "sw_if_index", i);
4319 counter_array = vat_json_object_add (msg, "c");
4320 vat_json_init_array (counter_array);
4321 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
4323 counter = vat_json_array_add (counter_array);
4324 vat_json_init_object (counter);
4325 n4 = &vam->ip4_nbr_counters[i][j];
4326 vat_json_object_add_ip4 (counter, "address", n4->address);
4327 vat_json_object_add_uint (counter, "link-type", n4->linkt);
4328 vat_json_object_add_uint (counter, "packets", n4->packets);
4329 vat_json_object_add_uint (counter, "bytes", n4->bytes);
4333 /* ip6 nbr counters */
4334 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
4335 vat_json_init_array (msg_array);
4336 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
4338 msg = vat_json_array_add (msg_array);
4339 vat_json_init_object (msg);
4340 vat_json_object_add_uint (msg, "sw_if_index", i);
4341 counter_array = vat_json_object_add (msg, "c");
4342 vat_json_init_array (counter_array);
4343 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
4345 counter = vat_json_array_add (counter_array);
4346 vat_json_init_object (counter);
4347 n6 = &vam->ip6_nbr_counters[i][j];
4348 vat_json_object_add_ip6 (counter, "address", n6->address);
4349 vat_json_object_add_uint (counter, "packets", n6->packets);
4350 vat_json_object_add_uint (counter, "bytes", n6->bytes);
4354 vat_json_print (vam->ofp, &node);
4355 vat_json_free (&node);
4361 exec (vat_main_t * vam)
4363 api_main_t *am = &api_main;
4364 vl_api_cli_request_t *mp;
4368 unformat_input_t *i = vam->input;
4370 if (vec_len (i->buffer) == 0)
4373 if (vam->exec_mode == 0 && unformat (i, "mode"))
4378 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4385 M (CLI_REQUEST, cli_request);
4388 * Copy cmd into shared memory.
4389 * In order for the CLI command to work, it
4390 * must be a vector ending in \n, not a C-string ending
4393 pthread_mutex_lock (&am->vlib_rp->mutex);
4394 oldheap = svm_push_data_heap (am->vlib_rp);
4396 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4397 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4399 svm_pop_heap (oldheap);
4400 pthread_mutex_unlock (&am->vlib_rp->mutex);
4402 mp->cmd_in_shmem = (u64) cmd;
4404 timeout = vat_time_now (vam) + 10.0;
4406 while (vat_time_now (vam) < timeout)
4408 if (vam->result_ready == 1)
4411 if (vam->shmem_result != NULL)
4412 print (vam->ofp, "%s", vam->shmem_result);
4413 pthread_mutex_lock (&am->vlib_rp->mutex);
4414 oldheap = svm_push_data_heap (am->vlib_rp);
4416 free_me = (u8 *) vam->shmem_result;
4419 svm_pop_heap (oldheap);
4420 pthread_mutex_unlock (&am->vlib_rp->mutex);
4428 * Future replacement of exec() that passes CLI buffers directly in
4429 * the API messages instead of an additional shared memory area.
4432 exec_inband (vat_main_t * vam)
4434 vl_api_cli_inband_t *mp;
4436 unformat_input_t *i = vam->input;
4438 if (vec_len (i->buffer) == 0)
4441 if (vam->exec_mode == 0 && unformat (i, "mode"))
4446 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4453 * In order for the CLI command to work, it
4454 * must be a vector ending in \n, not a C-string ending
4457 u32 len = vec_len (vam->input->buffer);
4458 M2 (CLI_INBAND, cli_inband, len);
4459 clib_memcpy (mp->cmd, vam->input->buffer, len);
4460 mp->length = htonl (len);
4463 W2 (print (vam->ofp, "%s", vam->cmd_reply));
4467 api_create_loopback (vat_main_t * vam)
4469 unformat_input_t *i = vam->input;
4470 vl_api_create_loopback_t *mp;
4475 memset (mac_address, 0, sizeof (mac_address));
4477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4479 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4485 /* Construct the API message */
4486 M (CREATE_LOOPBACK, create_loopback);
4488 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4495 api_delete_loopback (vat_main_t * vam)
4497 unformat_input_t *i = vam->input;
4498 vl_api_delete_loopback_t *mp;
4500 u32 sw_if_index = ~0;
4502 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4504 if (unformat (i, "sw_if_index %d", &sw_if_index))
4510 if (sw_if_index == ~0)
4512 errmsg ("missing sw_if_index");
4516 /* Construct the API message */
4517 M (DELETE_LOOPBACK, delete_loopback);
4518 mp->sw_if_index = ntohl (sw_if_index);
4525 api_want_stats (vat_main_t * vam)
4527 unformat_input_t *i = vam->input;
4528 vl_api_want_stats_t *mp;
4532 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4534 if (unformat (i, "enable"))
4536 else if (unformat (i, "disable"))
4544 errmsg ("missing enable|disable");
4548 M (WANT_STATS, want_stats);
4549 mp->enable_disable = enable;
4556 api_want_interface_events (vat_main_t * vam)
4558 unformat_input_t *i = vam->input;
4559 vl_api_want_interface_events_t *mp;
4563 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4565 if (unformat (i, "enable"))
4567 else if (unformat (i, "disable"))
4575 errmsg ("missing enable|disable");
4579 M (WANT_INTERFACE_EVENTS, want_interface_events);
4580 mp->enable_disable = enable;
4582 vam->interface_event_display = enable;
4589 /* Note: non-static, called once to set up the initial intfc table */
4591 api_sw_interface_dump (vat_main_t * vam)
4593 vl_api_sw_interface_dump_t *mp;
4596 name_sort_t *nses = 0, *ns;
4597 sw_interface_subif_t *sub = NULL;
4599 /* Toss the old name table */
4601 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4603 vec_add2 (nses, ns, 1);
4604 ns->name = (u8 *)(p->key);
4605 ns->value = (u32) p->value[0];
4609 hash_free (vam->sw_if_index_by_interface_name);
4611 vec_foreach (ns, nses) vec_free (ns->name);
4615 vec_foreach (sub, vam->sw_if_subif_table)
4617 vec_free (sub->interface_name);
4619 vec_free (vam->sw_if_subif_table);
4621 /* recreate the interface name hash table */
4622 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4624 /* Get list of ethernets */
4625 M (SW_INTERFACE_DUMP, sw_interface_dump);
4626 mp->name_filter_valid = 1;
4627 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4630 /* and local / loopback interfaces */
4631 M (SW_INTERFACE_DUMP, sw_interface_dump);
4632 mp->name_filter_valid = 1;
4633 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4636 /* and packet-generator interfaces */
4637 M (SW_INTERFACE_DUMP, sw_interface_dump);
4638 mp->name_filter_valid = 1;
4639 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4642 /* and vxlan-gpe tunnel interfaces */
4643 M (SW_INTERFACE_DUMP, sw_interface_dump);
4644 mp->name_filter_valid = 1;
4645 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4646 sizeof (mp->name_filter) - 1);
4649 /* and vxlan tunnel interfaces */
4650 M (SW_INTERFACE_DUMP, sw_interface_dump);
4651 mp->name_filter_valid = 1;
4652 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4655 /* and host (af_packet) interfaces */
4656 M (SW_INTERFACE_DUMP, sw_interface_dump);
4657 mp->name_filter_valid = 1;
4658 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4661 /* and l2tpv3 tunnel interfaces */
4662 M (SW_INTERFACE_DUMP, sw_interface_dump);
4663 mp->name_filter_valid = 1;
4664 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4665 sizeof (mp->name_filter) - 1);
4668 /* and GRE tunnel interfaces */
4669 M (SW_INTERFACE_DUMP, sw_interface_dump);
4670 mp->name_filter_valid = 1;
4671 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4674 /* and LISP-GPE interfaces */
4675 M (SW_INTERFACE_DUMP, sw_interface_dump);
4676 mp->name_filter_valid = 1;
4677 strncpy ((char *) mp->name_filter, "lisp_gpe",
4678 sizeof (mp->name_filter) - 1);
4681 /* and IPSEC tunnel interfaces */
4682 M (SW_INTERFACE_DUMP, sw_interface_dump);
4683 mp->name_filter_valid = 1;
4684 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4687 /* Use a control ping for synchronization */
4689 vl_api_control_ping_t *mp;
4690 M (CONTROL_PING, control_ping);
4697 api_sw_interface_set_flags (vat_main_t * vam)
4699 unformat_input_t *i = vam->input;
4700 vl_api_sw_interface_set_flags_t *mp;
4703 u8 sw_if_index_set = 0;
4704 u8 admin_up = 0, link_up = 0;
4706 /* Parse args required to build the message */
4707 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4709 if (unformat (i, "admin-up"))
4711 else if (unformat (i, "admin-down"))
4713 else if (unformat (i, "link-up"))
4715 else if (unformat (i, "link-down"))
4718 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4719 sw_if_index_set = 1;
4720 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4721 sw_if_index_set = 1;
4726 if (sw_if_index_set == 0)
4728 errmsg ("missing interface name or sw_if_index");
4732 /* Construct the API message */
4733 M (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags);
4734 mp->sw_if_index = ntohl (sw_if_index);
4735 mp->admin_up_down = admin_up;
4736 mp->link_up_down = link_up;
4741 /* Wait for a reply, return the good/bad news... */
4746 api_sw_interface_clear_stats (vat_main_t * vam)
4748 unformat_input_t *i = vam->input;
4749 vl_api_sw_interface_clear_stats_t *mp;
4752 u8 sw_if_index_set = 0;
4754 /* Parse args required to build the message */
4755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4757 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4758 sw_if_index_set = 1;
4759 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4760 sw_if_index_set = 1;
4765 /* Construct the API message */
4766 M (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats);
4768 if (sw_if_index_set == 1)
4769 mp->sw_if_index = ntohl (sw_if_index);
4771 mp->sw_if_index = ~0;
4776 /* Wait for a reply, return the good/bad news... */
4782 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
4784 unformat_input_t *i = vam->input;
4785 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
4788 u8 sw_if_index_set = 0;
4796 /* Parse args required to build the message */
4797 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4799 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
4800 sw_if_index_set = 1;
4801 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4802 sw_if_index_set = 1;
4803 else if (unformat (i, "subport %u", &subport))
4806 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4807 sw_if_index_set = 1;
4808 else if (unformat (i, "pipe %u", &pipe))
4810 else if (unformat (i, "profile %u", &profile))
4816 if (sw_if_index_set == 0)
4818 errmsg ("missing interface name or sw_if_index");
4822 if (subport_set == 0)
4824 errmsg ("missing subport ");
4830 errmsg ("missing pipe");
4834 if (profile_set == 0)
4836 errmsg ("missing profile");
4840 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe);
4842 mp->sw_if_index = ntohl (sw_if_index);
4843 mp->subport = ntohl (subport);
4844 mp->pipe = ntohl (pipe);
4845 mp->profile = ntohl (profile);
4855 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
4857 unformat_input_t *i = vam->input;
4858 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
4861 u8 sw_if_index_set = 0;
4864 u32 tb_rate = 1250000000; /* 10GbE */
4865 u32 tb_size = 1000000;
4866 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
4869 /* Parse args required to build the message */
4870 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4872 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
4873 sw_if_index_set = 1;
4874 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4875 sw_if_index_set = 1;
4876 else if (unformat (i, "subport %u", &subport))
4879 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4880 sw_if_index_set = 1;
4881 else if (unformat (i, "rate %u", &tb_rate))
4885 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
4887 tc_rate[tc_id] = tb_rate;
4889 else if (unformat (i, "bktsize %u", &tb_size))
4891 else if (unformat (i, "tc0 %u", &tc_rate[0]))
4893 else if (unformat (i, "tc1 %u", &tc_rate[1]))
4895 else if (unformat (i, "tc2 %u", &tc_rate[2]))
4897 else if (unformat (i, "tc3 %u", &tc_rate[3]))
4899 else if (unformat (i, "period %u", &tc_period))
4905 if (sw_if_index_set == 0)
4907 errmsg ("missing interface name or sw_if_index");
4911 if (subport_set == 0)
4913 errmsg ("missing subport ");
4917 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport);
4919 mp->sw_if_index = ntohl (sw_if_index);
4920 mp->subport = ntohl (subport);
4921 mp->tb_rate = ntohl (tb_rate);
4922 mp->tb_size = ntohl (tb_size);
4923 mp->tc_rate[0] = ntohl (tc_rate[0]);
4924 mp->tc_rate[1] = ntohl (tc_rate[1]);
4925 mp->tc_rate[2] = ntohl (tc_rate[2]);
4926 mp->tc_rate[3] = ntohl (tc_rate[3]);
4927 mp->tc_period = ntohl (tc_period);
4936 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
4938 unformat_input_t *i = vam->input;
4939 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
4942 u8 sw_if_index_set = 0;
4946 u32 entry, tc, queue;
4948 /* Parse args required to build the message */
4949 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4951 if (unformat (i, "rx %U", api_unformat_sw_if_index, vam, &sw_if_index))
4952 sw_if_index_set = 1;
4953 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4954 sw_if_index_set = 1;
4955 else if (unformat (i, "entry %d", &entry))
4957 else if (unformat (i, "tc %d", &tc))
4959 else if (unformat (i, "queue %d", &queue))
4965 if (sw_if_index_set == 0)
4967 errmsg ("missing interface name or sw_if_index");
4973 errmsg ("missing entry ");
4979 errmsg ("missing traffic class ");
4985 errmsg ("missing queue ");
4989 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl);
4991 mp->sw_if_index = ntohl (sw_if_index);
4992 mp->entry = ntohl (entry);
4993 mp->tc = ntohl (tc);
4994 mp->queue = ntohl (queue);
5004 api_sw_interface_add_del_address (vat_main_t * vam)
5006 unformat_input_t *i = vam->input;
5007 vl_api_sw_interface_add_del_address_t *mp;
5010 u8 sw_if_index_set = 0;
5011 u8 is_add = 1, del_all = 0;
5012 u32 address_length = 0;
5013 u8 v4_address_set = 0;
5014 u8 v6_address_set = 0;
5015 ip4_address_t v4address;
5016 ip6_address_t v6address;
5018 /* Parse args required to build the message */
5019 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5021 if (unformat (i, "del-all"))
5023 else if (unformat (i, "del"))
5026 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5027 sw_if_index_set = 1;
5028 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5029 sw_if_index_set = 1;
5030 else if (unformat (i, "%U/%d",
5031 unformat_ip4_address, &v4address, &address_length))
5033 else if (unformat (i, "%U/%d",
5034 unformat_ip6_address, &v6address, &address_length))
5040 if (sw_if_index_set == 0)
5042 errmsg ("missing interface name or sw_if_index");
5045 if (v4_address_set && v6_address_set)
5047 errmsg ("both v4 and v6 addresses set");
5050 if (!v4_address_set && !v6_address_set && !del_all)
5052 errmsg ("no addresses set");
5056 /* Construct the API message */
5057 M (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address);
5059 mp->sw_if_index = ntohl (sw_if_index);
5060 mp->is_add = is_add;
5061 mp->del_all = del_all;
5065 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5069 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5071 mp->address_length = address_length;
5076 /* Wait for a reply, return good/bad news */
5081 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5083 unformat_input_t *i = vam->input;
5084 vl_api_sw_interface_set_mpls_enable_t *mp;
5087 u8 sw_if_index_set = 0;
5090 /* Parse args required to build the message */
5091 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5093 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5094 sw_if_index_set = 1;
5095 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5096 sw_if_index_set = 1;
5097 else if (unformat (i, "disable"))
5099 else if (unformat (i, "dis"))
5105 if (sw_if_index_set == 0)
5107 errmsg ("missing interface name or sw_if_index");
5111 /* Construct the API message */
5112 M (SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable);
5114 mp->sw_if_index = ntohl (sw_if_index);
5115 mp->enable = enable;
5120 /* Wait for a reply... */
5125 api_sw_interface_set_table (vat_main_t * vam)
5127 unformat_input_t *i = vam->input;
5128 vl_api_sw_interface_set_table_t *mp;
5130 u32 sw_if_index, vrf_id = 0;
5131 u8 sw_if_index_set = 0;
5134 /* Parse args required to build the message */
5135 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5137 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5138 sw_if_index_set = 1;
5139 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5140 sw_if_index_set = 1;
5141 else if (unformat (i, "vrf %d", &vrf_id))
5143 else if (unformat (i, "ipv6"))
5149 if (sw_if_index_set == 0)
5151 errmsg ("missing interface name or sw_if_index");
5155 /* Construct the API message */
5156 M (SW_INTERFACE_SET_TABLE, sw_interface_set_table);
5158 mp->sw_if_index = ntohl (sw_if_index);
5159 mp->is_ipv6 = is_ipv6;
5160 mp->vrf_id = ntohl (vrf_id);
5165 /* Wait for a reply... */
5169 static void vl_api_sw_interface_get_table_reply_t_handler
5170 (vl_api_sw_interface_get_table_reply_t * mp)
5172 vat_main_t *vam = &vat_main;
5174 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5176 vam->retval = ntohl (mp->retval);
5177 vam->result_ready = 1;
5181 static void vl_api_sw_interface_get_table_reply_t_handler_json
5182 (vl_api_sw_interface_get_table_reply_t * mp)
5184 vat_main_t *vam = &vat_main;
5185 vat_json_node_t node;
5187 vat_json_init_object (&node);
5188 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5189 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5191 vat_json_print (vam->ofp, &node);
5192 vat_json_free (&node);
5194 vam->retval = ntohl (mp->retval);
5195 vam->result_ready = 1;
5199 api_sw_interface_get_table (vat_main_t * vam)
5201 unformat_input_t *i = vam->input;
5202 vl_api_sw_interface_get_table_t *mp;
5204 u8 sw_if_index_set = 0;
5208 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5210 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5211 sw_if_index_set = 1;
5212 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5213 sw_if_index_set = 1;
5214 else if (unformat (i, "ipv6"))
5220 if (sw_if_index_set == 0)
5222 errmsg ("missing interface name or sw_if_index");
5226 M (SW_INTERFACE_GET_TABLE, sw_interface_get_table);
5227 mp->sw_if_index = htonl (sw_if_index);
5228 mp->is_ipv6 = is_ipv6;
5235 api_sw_interface_set_vpath (vat_main_t * vam)
5237 unformat_input_t *i = vam->input;
5238 vl_api_sw_interface_set_vpath_t *mp;
5240 u32 sw_if_index = 0;
5241 u8 sw_if_index_set = 0;
5244 /* Parse args required to build the message */
5245 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5247 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5248 sw_if_index_set = 1;
5249 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5250 sw_if_index_set = 1;
5251 else if (unformat (i, "enable"))
5253 else if (unformat (i, "disable"))
5259 if (sw_if_index_set == 0)
5261 errmsg ("missing interface name or sw_if_index");
5265 /* Construct the API message */
5266 M (SW_INTERFACE_SET_VPATH, sw_interface_set_vpath);
5268 mp->sw_if_index = ntohl (sw_if_index);
5269 mp->enable = is_enable;
5274 /* Wait for a reply... */
5279 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5281 unformat_input_t *i = vam->input;
5282 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5284 u32 sw_if_index = 0;
5285 u8 sw_if_index_set = 0;
5289 /* Parse args required to build the message */
5290 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5292 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5293 sw_if_index_set = 1;
5294 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5295 sw_if_index_set = 1;
5296 else if (unformat (i, "enable"))
5298 else if (unformat (i, "disable"))
5300 else if (unformat (i, "ip4"))
5302 else if (unformat (i, "ip6"))
5308 if (sw_if_index_set == 0)
5310 errmsg ("missing interface name or sw_if_index");
5314 /* Construct the API message */
5315 M (SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass);
5317 mp->sw_if_index = ntohl (sw_if_index);
5318 mp->enable = is_enable;
5319 mp->is_ipv6 = is_ipv6;
5324 /* Wait for a reply... */
5329 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5331 unformat_input_t *i = vam->input;
5332 vl_api_sw_interface_set_l2_xconnect_t *mp;
5335 u8 rx_sw_if_index_set = 0;
5337 u8 tx_sw_if_index_set = 0;
5340 /* Parse args required to build the message */
5341 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5343 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5344 rx_sw_if_index_set = 1;
5345 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5346 tx_sw_if_index_set = 1;
5347 else if (unformat (i, "rx"))
5349 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5351 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5353 rx_sw_if_index_set = 1;
5358 else if (unformat (i, "tx"))
5360 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5362 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5364 tx_sw_if_index_set = 1;
5369 else if (unformat (i, "enable"))
5371 else if (unformat (i, "disable"))
5377 if (rx_sw_if_index_set == 0)
5379 errmsg ("missing rx interface name or rx_sw_if_index");
5383 if (enable && (tx_sw_if_index_set == 0))
5385 errmsg ("missing tx interface name or tx_sw_if_index");
5389 M (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect);
5391 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5392 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5393 mp->enable = enable;
5402 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5404 unformat_input_t *i = vam->input;
5405 vl_api_sw_interface_set_l2_bridge_t *mp;
5408 u8 rx_sw_if_index_set = 0;
5415 /* Parse args required to build the message */
5416 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5418 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5419 rx_sw_if_index_set = 1;
5420 else if (unformat (i, "bd_id %d", &bd_id))
5424 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5425 rx_sw_if_index_set = 1;
5426 else if (unformat (i, "shg %d", &shg))
5428 else if (unformat (i, "bvi"))
5430 else if (unformat (i, "enable"))
5432 else if (unformat (i, "disable"))
5438 if (rx_sw_if_index_set == 0)
5440 errmsg ("missing rx interface name or sw_if_index");
5444 if (enable && (bd_id_set == 0))
5446 errmsg ("missing bridge domain");
5450 M (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge);
5452 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5453 mp->bd_id = ntohl (bd_id);
5456 mp->enable = enable;
5465 api_bridge_domain_dump (vat_main_t * vam)
5467 unformat_input_t *i = vam->input;
5468 vl_api_bridge_domain_dump_t *mp;
5472 /* Parse args required to build the message */
5473 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5475 if (unformat (i, "bd_id %d", &bd_id))
5481 M (BRIDGE_DOMAIN_DUMP, bridge_domain_dump);
5482 mp->bd_id = ntohl (bd_id);
5485 /* Use a control ping for synchronization */
5487 vl_api_control_ping_t *mp;
5488 M (CONTROL_PING, control_ping);
5498 api_bridge_domain_add_del (vat_main_t * vam)
5500 unformat_input_t *i = vam->input;
5501 vl_api_bridge_domain_add_del_t *mp;
5505 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5508 /* Parse args required to build the message */
5509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5511 if (unformat (i, "bd_id %d", &bd_id))
5513 else if (unformat (i, "flood %d", &flood))
5515 else if (unformat (i, "uu-flood %d", &uu_flood))
5517 else if (unformat (i, "forward %d", &forward))
5519 else if (unformat (i, "learn %d", &learn))
5521 else if (unformat (i, "arp-term %d", &arp_term))
5523 else if (unformat (i, "mac-age %d", &mac_age))
5525 else if (unformat (i, "del"))
5528 flood = uu_flood = forward = learn = 0;
5536 errmsg ("missing bridge domain");
5542 errmsg ("mac age must be less than 256 ");
5546 M (BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del);
5548 mp->bd_id = ntohl (bd_id);
5550 mp->uu_flood = uu_flood;
5551 mp->forward = forward;
5553 mp->arp_term = arp_term;
5554 mp->is_add = is_add;
5555 mp->mac_age = (u8) mac_age;
5564 api_l2fib_add_del (vat_main_t * vam)
5566 unformat_input_t *i = vam->input;
5567 vl_api_l2fib_add_del_t *mp;
5573 u32 sw_if_index = ~0;
5574 u8 sw_if_index_set = 0;
5583 /* Parse args required to build the message */
5584 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5586 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5588 else if (unformat (i, "bd_id %d", &bd_id))
5590 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5591 sw_if_index_set = 1;
5592 else if (unformat (i, "sw_if"))
5594 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5597 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5598 sw_if_index_set = 1;
5603 else if (unformat (i, "static"))
5605 else if (unformat (i, "filter"))
5610 else if (unformat (i, "bvi"))
5615 else if (unformat (i, "del"))
5617 else if (unformat (i, "count %d", &count))
5625 errmsg ("missing mac address");
5631 errmsg ("missing bridge domain");
5635 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5637 errmsg ("missing interface name or sw_if_index");
5643 /* Turn on async mode */
5644 vam->async_mode = 1;
5645 vam->async_errors = 0;
5646 before = vat_time_now (vam);
5649 for (j = 0; j < count; j++)
5651 M (L2FIB_ADD_DEL, l2fib_add_del);
5654 mp->bd_id = ntohl (bd_id);
5655 mp->is_add = is_add;
5659 mp->sw_if_index = ntohl (sw_if_index);
5660 mp->static_mac = static_mac;
5661 mp->filter_mac = filter_mac;
5662 mp->bvi_mac = bvi_mac;
5664 increment_mac_address (&mac);
5671 vl_api_control_ping_t *mp;
5674 /* Shut off async mode */
5675 vam->async_mode = 0;
5677 M (CONTROL_PING, control_ping);
5680 timeout = vat_time_now (vam) + 1.0;
5681 while (vat_time_now (vam) < timeout)
5682 if (vam->result_ready == 1)
5687 if (vam->retval == -99)
5690 if (vam->async_errors > 0)
5692 errmsg ("%d asynchronous errors", vam->async_errors);
5695 vam->async_errors = 0;
5696 after = vat_time_now (vam);
5698 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
5699 count, after - before, count / (after - before));
5703 /* Wait for a reply... */
5706 /* Return the good/bad news */
5707 return (vam->retval);
5711 api_l2_flags (vat_main_t * vam)
5713 unformat_input_t *i = vam->input;
5714 vl_api_l2_flags_t *mp;
5717 u32 feature_bitmap = 0;
5718 u8 sw_if_index_set = 0;
5720 /* Parse args required to build the message */
5721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5723 if (unformat (i, "sw_if_index %d", &sw_if_index))
5724 sw_if_index_set = 1;
5725 else if (unformat (i, "sw_if"))
5727 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5730 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5731 sw_if_index_set = 1;
5736 else if (unformat (i, "learn"))
5737 feature_bitmap |= L2INPUT_FEAT_LEARN;
5738 else if (unformat (i, "forward"))
5739 feature_bitmap |= L2INPUT_FEAT_FWD;
5740 else if (unformat (i, "flood"))
5741 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5742 else if (unformat (i, "uu-flood"))
5743 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5748 if (sw_if_index_set == 0)
5750 errmsg ("missing interface name or sw_if_index");
5754 M (L2_FLAGS, l2_flags);
5756 mp->sw_if_index = ntohl (sw_if_index);
5757 mp->feature_bitmap = ntohl (feature_bitmap);
5766 api_bridge_flags (vat_main_t * vam)
5768 unformat_input_t *i = vam->input;
5769 vl_api_bridge_flags_t *mp;
5776 /* Parse args required to build the message */
5777 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5779 if (unformat (i, "bd_id %d", &bd_id))
5781 else if (unformat (i, "learn"))
5783 else if (unformat (i, "forward"))
5785 else if (unformat (i, "flood"))
5787 else if (unformat (i, "uu-flood"))
5788 flags |= L2_UU_FLOOD;
5789 else if (unformat (i, "arp-term"))
5790 flags |= L2_ARP_TERM;
5791 else if (unformat (i, "off"))
5793 else if (unformat (i, "disable"))
5801 errmsg ("missing bridge domain");
5805 M (BRIDGE_FLAGS, bridge_flags);
5807 mp->bd_id = ntohl (bd_id);
5808 mp->feature_bitmap = ntohl (flags);
5809 mp->is_set = is_set;
5818 api_bd_ip_mac_add_del (vat_main_t * vam)
5820 unformat_input_t *i = vam->input;
5821 vl_api_bd_ip_mac_add_del_t *mp;
5829 ip4_address_t v4addr;
5830 ip6_address_t v6addr;
5834 /* Parse args required to build the message */
5835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5837 if (unformat (i, "bd_id %d", &bd_id))
5841 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5845 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5850 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5854 else if (unformat (i, "del"))
5862 errmsg ("missing bridge domain");
5865 else if (ip_set == 0)
5867 errmsg ("missing IP address");
5870 else if (mac_set == 0)
5872 errmsg ("missing MAC address");
5876 M (BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del);
5878 mp->bd_id = ntohl (bd_id);
5879 mp->is_ipv6 = is_ipv6;
5880 mp->is_add = is_add;
5882 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5884 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5885 clib_memcpy (mp->mac_address, macaddr, 6);
5893 api_tap_connect (vat_main_t * vam)
5895 unformat_input_t *i = vam->input;
5896 vl_api_tap_connect_t *mp;
5903 ip4_address_t ip4_address;
5905 int ip4_address_set = 0;
5906 ip6_address_t ip6_address;
5908 int ip6_address_set = 0;
5910 memset (mac_address, 0, sizeof (mac_address));
5912 /* Parse args required to build the message */
5913 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5915 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5919 else if (unformat (i, "random-mac"))
5921 else if (unformat (i, "tapname %s", &tap_name))
5923 else if (unformat (i, "tag %s", &tag))
5925 else if (unformat (i, "address %U/%d",
5926 unformat_ip4_address, &ip4_address, &ip4_mask_width))
5927 ip4_address_set = 1;
5928 else if (unformat (i, "address %U/%d",
5929 unformat_ip6_address, &ip6_address, &ip6_mask_width))
5930 ip6_address_set = 1;
5937 errmsg ("missing tap name");
5940 if (vec_len (tap_name) > 63)
5942 errmsg ("tap name too long");
5945 vec_add1 (tap_name, 0);
5947 if (vec_len (tag) > 63)
5949 errmsg ("tag too long");
5953 /* Construct the API message */
5954 M (TAP_CONNECT, tap_connect);
5956 mp->use_random_mac = random_mac;
5957 clib_memcpy (mp->mac_address, mac_address, 6);
5958 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5960 clib_memcpy (mp->tag, tag, vec_len (tag));
5962 if (ip4_address_set)
5964 mp->ip4_address_set = 1;
5965 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
5966 mp->ip4_mask_width = ip4_mask_width;
5968 if (ip6_address_set)
5970 mp->ip6_address_set = 1;
5971 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
5972 mp->ip6_mask_width = ip6_mask_width;
5975 vec_free (tap_name);
5981 /* Wait for a reply... */
5986 api_tap_modify (vat_main_t * vam)
5988 unformat_input_t *i = vam->input;
5989 vl_api_tap_modify_t *mp;
5995 u32 sw_if_index = ~0;
5996 u8 sw_if_index_set = 0;
5998 memset (mac_address, 0, sizeof (mac_address));
6000 /* Parse args required to build the message */
6001 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6003 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6004 sw_if_index_set = 1;
6005 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6006 sw_if_index_set = 1;
6007 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6011 else if (unformat (i, "random-mac"))
6013 else if (unformat (i, "tapname %s", &tap_name))
6019 if (sw_if_index_set == 0)
6021 errmsg ("missing vpp interface name");
6026 errmsg ("missing tap name");
6029 if (vec_len (tap_name) > 63)
6031 errmsg ("tap name too long");
6033 vec_add1 (tap_name, 0);
6035 /* Construct the API message */
6036 M (TAP_MODIFY, tap_modify);
6038 mp->use_random_mac = random_mac;
6039 mp->sw_if_index = ntohl (sw_if_index);
6040 clib_memcpy (mp->mac_address, mac_address, 6);
6041 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6042 vec_free (tap_name);
6047 /* Wait for a reply... */
6052 api_tap_delete (vat_main_t * vam)
6054 unformat_input_t *i = vam->input;
6055 vl_api_tap_delete_t *mp;
6057 u32 sw_if_index = ~0;
6058 u8 sw_if_index_set = 0;
6060 /* Parse args required to build the message */
6061 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6063 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6064 sw_if_index_set = 1;
6065 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6066 sw_if_index_set = 1;
6071 if (sw_if_index_set == 0)
6073 errmsg ("missing vpp interface name");
6077 /* Construct the API message */
6078 M (TAP_DELETE, tap_delete);
6080 mp->sw_if_index = ntohl (sw_if_index);
6085 /* Wait for a reply... */
6090 api_ip_add_del_route (vat_main_t * vam)
6092 unformat_input_t *i = vam->input;
6093 vl_api_ip_add_del_route_t *mp;
6095 u32 sw_if_index = ~0, vrf_id = 0;
6097 u8 is_local = 0, is_drop = 0;
6098 u8 is_unreach = 0, is_prohibit = 0;
6099 u8 create_vrf_if_needed = 0;
6101 u32 next_hop_weight = 1;
6103 u8 is_multipath = 0;
6105 u8 address_length_set = 0;
6106 u32 next_hop_table_id = 0;
6107 u32 resolve_attempts = 0;
6108 u32 dst_address_length = 0;
6109 u8 next_hop_set = 0;
6110 ip4_address_t v4_dst_address, v4_next_hop_address;
6111 ip6_address_t v6_dst_address, v6_next_hop_address;
6115 u32 random_add_del = 0;
6116 u32 *random_vector = 0;
6118 u32 random_seed = 0xdeaddabe;
6119 u32 classify_table_index = ~0;
6121 u8 resolve_host = 0, resolve_attached = 0;
6122 mpls_label_t *next_hop_out_label_stack = NULL;
6123 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6124 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6126 /* Parse args required to build the message */
6127 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6129 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6131 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6133 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6138 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6143 else if (unformat (i, "/%d", &dst_address_length))
6145 address_length_set = 1;
6148 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6149 &v4_next_hop_address))
6153 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6154 &v6_next_hop_address))
6158 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6160 else if (unformat (i, "weight %d", &next_hop_weight))
6162 else if (unformat (i, "drop"))
6166 else if (unformat (i, "null-send-unreach"))
6170 else if (unformat (i, "null-send-prohibit"))
6174 else if (unformat (i, "local"))
6178 else if (unformat (i, "classify %d", &classify_table_index))
6182 else if (unformat (i, "del"))
6184 else if (unformat (i, "add"))
6186 else if (unformat (i, "not-last"))
6188 else if (unformat (i, "resolve-via-host"))
6190 else if (unformat (i, "resolve-via-attached"))
6191 resolve_attached = 1;
6192 else if (unformat (i, "multipath"))
6194 else if (unformat (i, "vrf %d", &vrf_id))
6196 else if (unformat (i, "create-vrf"))
6197 create_vrf_if_needed = 1;
6198 else if (unformat (i, "count %d", &count))
6200 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6202 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6204 else if (unformat (i, "out-label %d", &next_hop_out_label))
6205 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6206 else if (unformat (i, "via-label %d", &next_hop_via_label))
6208 else if (unformat (i, "random"))
6210 else if (unformat (i, "seed %d", &random_seed))
6214 clib_warning ("parse error '%U'", format_unformat_error, i);
6219 if (!next_hop_set && !is_drop && !is_local &&
6220 !is_classify && !is_unreach && !is_prohibit &&
6221 MPLS_LABEL_INVALID == next_hop_via_label)
6224 ("next hop / local / drop / unreach / prohibit / classify not set");
6228 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6230 errmsg ("next hop and next-hop via label set");
6233 if (address_set == 0)
6235 errmsg ("missing addresses");
6239 if (address_length_set == 0)
6241 errmsg ("missing address length");
6245 /* Generate a pile of unique, random routes */
6248 u32 this_random_address;
6249 random_hash = hash_create (count, sizeof (uword));
6251 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6252 for (j = 0; j <= count; j++)
6256 this_random_address = random_u32 (&random_seed);
6257 this_random_address =
6258 clib_host_to_net_u32 (this_random_address);
6260 while (hash_get (random_hash, this_random_address));
6261 vec_add1 (random_vector, this_random_address);
6262 hash_set (random_hash, this_random_address, 1);
6264 hash_free (random_hash);
6265 v4_dst_address.as_u32 = random_vector[0];
6270 /* Turn on async mode */
6271 vam->async_mode = 1;
6272 vam->async_errors = 0;
6273 before = vat_time_now (vam);
6276 for (j = 0; j < count; j++)
6278 /* Construct the API message */
6279 M2 (IP_ADD_DEL_ROUTE, ip_add_del_route,
6280 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6282 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6283 mp->table_id = ntohl (vrf_id);
6284 mp->create_vrf_if_needed = create_vrf_if_needed;
6286 mp->is_add = is_add;
6287 mp->is_drop = is_drop;
6288 mp->is_unreach = is_unreach;
6289 mp->is_prohibit = is_prohibit;
6290 mp->is_ipv6 = is_ipv6;
6291 mp->is_local = is_local;
6292 mp->is_classify = is_classify;
6293 mp->is_multipath = is_multipath;
6294 mp->is_resolve_host = resolve_host;
6295 mp->is_resolve_attached = resolve_attached;
6296 mp->not_last = not_last;
6297 mp->next_hop_weight = next_hop_weight;
6298 mp->dst_address_length = dst_address_length;
6299 mp->next_hop_table_id = ntohl (next_hop_table_id);
6300 mp->classify_table_index = ntohl (classify_table_index);
6301 mp->next_hop_via_label = ntohl (next_hop_via_label);
6302 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6303 if (0 != mp->next_hop_n_out_labels)
6305 memcpy (mp->next_hop_out_label_stack,
6306 next_hop_out_label_stack,
6307 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6308 vec_free (next_hop_out_label_stack);
6313 clib_memcpy (mp->dst_address, &v6_dst_address,
6314 sizeof (v6_dst_address));
6316 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6317 sizeof (v6_next_hop_address));
6318 increment_v6_address (&v6_dst_address);
6322 clib_memcpy (mp->dst_address, &v4_dst_address,
6323 sizeof (v4_dst_address));
6325 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6326 sizeof (v4_next_hop_address));
6328 v4_dst_address.as_u32 = random_vector[j + 1];
6330 increment_v4_address (&v4_dst_address);
6334 /* If we receive SIGTERM, stop now... */
6339 /* When testing multiple add/del ops, use a control-ping to sync */
6342 vl_api_control_ping_t *mp;
6345 /* Shut off async mode */
6346 vam->async_mode = 0;
6348 M (CONTROL_PING, control_ping);
6351 timeout = vat_time_now (vam) + 1.0;
6352 while (vat_time_now (vam) < timeout)
6353 if (vam->result_ready == 1)
6358 if (vam->retval == -99)
6361 if (vam->async_errors > 0)
6363 errmsg ("%d asynchronous errors", vam->async_errors);
6366 vam->async_errors = 0;
6367 after = vat_time_now (vam);
6369 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6373 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6374 count, after - before, count / (after - before));
6378 /* Wait for a reply... */
6382 /* Return the good/bad news */
6383 return (vam->retval);
6387 api_mpls_route_add_del (vat_main_t * vam)
6389 unformat_input_t *i = vam->input;
6390 vl_api_mpls_route_add_del_t *mp;
6392 u32 sw_if_index = ~0, table_id = 0;
6393 u8 create_table_if_needed = 0;
6395 u32 next_hop_weight = 1;
6396 u8 is_multipath = 0;
6397 u32 next_hop_table_id = 0;
6398 u8 next_hop_set = 0;
6399 ip4_address_t v4_next_hop_address = {
6402 ip6_address_t v6_next_hop_address = { {0} };
6406 u32 classify_table_index = ~0;
6408 u8 resolve_host = 0, resolve_attached = 0;
6409 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6410 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6411 mpls_label_t *next_hop_out_label_stack = NULL;
6412 mpls_label_t local_label = MPLS_LABEL_INVALID;
6414 u8 next_hop_proto_is_ip4 = 1;
6416 /* Parse args required to build the message */
6417 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6419 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6421 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6423 else if (unformat (i, "%d", &local_label))
6425 else if (unformat (i, "eos"))
6427 else if (unformat (i, "non-eos"))
6429 else if (unformat (i, "via %U", unformat_ip4_address,
6430 &v4_next_hop_address))
6433 next_hop_proto_is_ip4 = 1;
6435 else if (unformat (i, "via %U", unformat_ip6_address,
6436 &v6_next_hop_address))
6439 next_hop_proto_is_ip4 = 0;
6441 else if (unformat (i, "weight %d", &next_hop_weight))
6443 else if (unformat (i, "create-table"))
6444 create_table_if_needed = 1;
6445 else if (unformat (i, "classify %d", &classify_table_index))
6449 else if (unformat (i, "del"))
6451 else if (unformat (i, "add"))
6453 else if (unformat (i, "resolve-via-host"))
6455 else if (unformat (i, "resolve-via-attached"))
6456 resolve_attached = 1;
6457 else if (unformat (i, "multipath"))
6459 else if (unformat (i, "count %d", &count))
6461 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6464 next_hop_proto_is_ip4 = 1;
6466 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6469 next_hop_proto_is_ip4 = 0;
6471 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6473 else if (unformat (i, "via-label %d", &next_hop_via_label))
6475 else if (unformat (i, "out-label %d", &next_hop_out_label))
6476 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6479 clib_warning ("parse error '%U'", format_unformat_error, i);
6484 if (!next_hop_set && !is_classify)
6486 errmsg ("next hop / classify not set");
6490 if (MPLS_LABEL_INVALID == local_label)
6492 errmsg ("missing label");
6498 /* Turn on async mode */
6499 vam->async_mode = 1;
6500 vam->async_errors = 0;
6501 before = vat_time_now (vam);
6504 for (j = 0; j < count; j++)
6506 /* Construct the API message */
6507 M2 (MPLS_ROUTE_ADD_DEL, mpls_route_add_del,
6508 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6510 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6511 mp->mr_table_id = ntohl (table_id);
6512 mp->mr_create_table_if_needed = create_table_if_needed;
6514 mp->mr_is_add = is_add;
6515 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6516 mp->mr_is_classify = is_classify;
6517 mp->mr_is_multipath = is_multipath;
6518 mp->mr_is_resolve_host = resolve_host;
6519 mp->mr_is_resolve_attached = resolve_attached;
6520 mp->mr_next_hop_weight = next_hop_weight;
6521 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6522 mp->mr_classify_table_index = ntohl (classify_table_index);
6523 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6524 mp->mr_label = ntohl (local_label);
6525 mp->mr_eos = is_eos;
6527 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6528 if (0 != mp->mr_next_hop_n_out_labels)
6530 memcpy (mp->mr_next_hop_out_label_stack,
6531 next_hop_out_label_stack,
6532 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6533 vec_free (next_hop_out_label_stack);
6538 if (next_hop_proto_is_ip4)
6540 clib_memcpy (mp->mr_next_hop,
6541 &v4_next_hop_address,
6542 sizeof (v4_next_hop_address));
6546 clib_memcpy (mp->mr_next_hop,
6547 &v6_next_hop_address,
6548 sizeof (v6_next_hop_address));
6555 /* If we receive SIGTERM, stop now... */
6560 /* When testing multiple add/del ops, use a control-ping to sync */
6563 vl_api_control_ping_t *mp;
6566 /* Shut off async mode */
6567 vam->async_mode = 0;
6569 M (CONTROL_PING, control_ping);
6572 timeout = vat_time_now (vam) + 1.0;
6573 while (vat_time_now (vam) < timeout)
6574 if (vam->result_ready == 1)
6579 if (vam->retval == -99)
6582 if (vam->async_errors > 0)
6584 errmsg ("%d asynchronous errors", vam->async_errors);
6587 vam->async_errors = 0;
6588 after = vat_time_now (vam);
6590 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6594 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6595 count, after - before, count / (after - before));
6599 /* Wait for a reply... */
6603 /* Return the good/bad news */
6604 return (vam->retval);
6608 api_mpls_ip_bind_unbind (vat_main_t * vam)
6610 unformat_input_t *i = vam->input;
6611 vl_api_mpls_ip_bind_unbind_t *mp;
6613 u32 ip_table_id = 0;
6614 u8 create_table_if_needed = 0;
6617 ip4_address_t v4_address;
6618 ip6_address_t v6_address;
6621 mpls_label_t local_label = MPLS_LABEL_INVALID;
6623 /* Parse args required to build the message */
6624 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6626 if (unformat (i, "%U/%d", unformat_ip4_address,
6627 &v4_address, &address_length))
6632 else if (unformat (i, "%U/%d", unformat_ip6_address,
6633 &v6_address, &address_length))
6638 else if (unformat (i, "%d", &local_label))
6640 else if (unformat (i, "create-table"))
6641 create_table_if_needed = 1;
6642 else if (unformat (i, "table-id %d", &ip_table_id))
6644 else if (unformat (i, "unbind"))
6646 else if (unformat (i, "bind"))
6650 clib_warning ("parse error '%U'", format_unformat_error, i);
6657 errmsg ("IP addres not set");
6661 if (MPLS_LABEL_INVALID == local_label)
6663 errmsg ("missing label");
6667 /* Construct the API message */
6668 M (MPLS_IP_BIND_UNBIND, mpls_ip_bind_unbind);
6670 mp->mb_create_table_if_needed = create_table_if_needed;
6671 mp->mb_is_bind = is_bind;
6672 mp->mb_is_ip4 = is_ip4;
6673 mp->mb_ip_table_id = ntohl (ip_table_id);
6674 mp->mb_mpls_table_id = 0;
6675 mp->mb_label = ntohl (local_label);
6676 mp->mb_address_length = address_length;
6679 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
6681 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
6686 /* Wait for a reply... */
6691 api_proxy_arp_add_del (vat_main_t * vam)
6693 unformat_input_t *i = vam->input;
6694 vl_api_proxy_arp_add_del_t *mp;
6698 ip4_address_t lo, hi;
6701 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6703 if (unformat (i, "vrf %d", &vrf_id))
6705 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
6706 unformat_ip4_address, &hi))
6708 else if (unformat (i, "del"))
6712 clib_warning ("parse error '%U'", format_unformat_error, i);
6719 errmsg ("address range not set");
6723 M (PROXY_ARP_ADD_DEL, proxy_arp_add_del);
6725 mp->vrf_id = ntohl (vrf_id);
6726 mp->is_add = is_add;
6727 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
6728 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
6737 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
6739 unformat_input_t *i = vam->input;
6740 vl_api_proxy_arp_intfc_enable_disable_t *mp;
6744 u8 sw_if_index_set = 0;
6746 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6748 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6749 sw_if_index_set = 1;
6750 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6751 sw_if_index_set = 1;
6752 else if (unformat (i, "enable"))
6754 else if (unformat (i, "disable"))
6758 clib_warning ("parse error '%U'", format_unformat_error, i);
6763 if (sw_if_index_set == 0)
6765 errmsg ("missing interface name or sw_if_index");
6769 M (PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable);
6771 mp->sw_if_index = ntohl (sw_if_index);
6772 mp->enable_disable = enable;
6781 api_mpls_tunnel_add_del (vat_main_t * vam)
6783 unformat_input_t *i = vam->input;
6784 vl_api_mpls_tunnel_add_del_t *mp;
6789 u32 sw_if_index = ~0;
6790 u32 next_hop_sw_if_index = ~0;
6791 u32 next_hop_proto_is_ip4 = 1;
6793 u32 next_hop_table_id = 0;
6794 ip4_address_t v4_next_hop_address = {
6797 ip6_address_t v6_next_hop_address = { {0} };
6798 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
6800 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6802 if (unformat (i, "add"))
6804 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
6806 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
6808 else if (unformat (i, "via %U",
6809 unformat_ip4_address, &v4_next_hop_address))
6811 next_hop_proto_is_ip4 = 1;
6813 else if (unformat (i, "via %U",
6814 unformat_ip6_address, &v6_next_hop_address))
6816 next_hop_proto_is_ip4 = 0;
6818 else if (unformat (i, "l2-only"))
6820 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6822 else if (unformat (i, "out-label %d", &next_hop_out_label))
6823 vec_add1 (labels, ntohl (next_hop_out_label));
6826 clib_warning ("parse error '%U'", format_unformat_error, i);
6831 M2 (MPLS_TUNNEL_ADD_DEL, mpls_tunnel_add_del,
6832 sizeof (mpls_label_t) * vec_len (labels));
6834 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
6835 mp->mt_sw_if_index = ntohl (sw_if_index);
6836 mp->mt_is_add = is_add;
6837 mp->mt_l2_only = l2_only;
6838 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
6839 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6841 mp->mt_next_hop_n_out_labels = vec_len (labels);
6843 if (0 != mp->mt_next_hop_n_out_labels)
6845 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
6846 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
6850 if (next_hop_proto_is_ip4)
6852 clib_memcpy (mp->mt_next_hop,
6853 &v4_next_hop_address, sizeof (v4_next_hop_address));
6857 clib_memcpy (mp->mt_next_hop,
6858 &v6_next_hop_address, sizeof (v6_next_hop_address));
6868 api_sw_interface_set_unnumbered (vat_main_t * vam)
6870 unformat_input_t *i = vam->input;
6871 vl_api_sw_interface_set_unnumbered_t *mp;
6874 u32 unnum_sw_index = ~0;
6876 u8 sw_if_index_set = 0;
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, "unnum_if_index %d", &unnum_sw_index))
6886 else if (unformat (i, "del"))
6890 clib_warning ("parse error '%U'", format_unformat_error, i);
6895 if (sw_if_index_set == 0)
6897 errmsg ("missing interface name or sw_if_index");
6901 M (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered);
6903 mp->sw_if_index = ntohl (sw_if_index);
6904 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
6905 mp->is_add = is_add;
6914 api_ip_neighbor_add_del (vat_main_t * vam)
6916 unformat_input_t *i = vam->input;
6917 vl_api_ip_neighbor_add_del_t *mp;
6920 u8 sw_if_index_set = 0;
6926 u8 v4_address_set = 0;
6927 u8 v6_address_set = 0;
6928 ip4_address_t v4address;
6929 ip6_address_t v6address;
6931 memset (mac_address, 0, sizeof (mac_address));
6933 /* Parse args required to build the message */
6934 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6936 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6940 else if (unformat (i, "del"))
6943 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6944 sw_if_index_set = 1;
6945 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6946 sw_if_index_set = 1;
6947 else if (unformat (i, "is_static"))
6949 else if (unformat (i, "vrf %d", &vrf_id))
6951 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
6953 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
6957 clib_warning ("parse error '%U'", format_unformat_error, i);
6962 if (sw_if_index_set == 0)
6964 errmsg ("missing interface name or sw_if_index");
6967 if (v4_address_set && v6_address_set)
6969 errmsg ("both v4 and v6 addresses set");
6972 if (!v4_address_set && !v6_address_set)
6974 errmsg ("no address set");
6978 /* Construct the API message */
6979 M (IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del);
6981 mp->sw_if_index = ntohl (sw_if_index);
6982 mp->is_add = is_add;
6983 mp->vrf_id = ntohl (vrf_id);
6984 mp->is_static = is_static;
6986 clib_memcpy (mp->mac_address, mac_address, 6);
6990 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
6994 /* mp->is_ipv6 = 0; via memset in M macro above */
6995 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7001 /* Wait for a reply, return good/bad news */
7009 api_reset_vrf (vat_main_t * vam)
7011 unformat_input_t *i = vam->input;
7012 vl_api_reset_vrf_t *mp;
7018 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7020 if (unformat (i, "vrf %d", &vrf_id))
7022 else if (unformat (i, "ipv6"))
7026 clib_warning ("parse error '%U'", format_unformat_error, i);
7031 if (vrf_id_set == 0)
7033 errmsg ("missing vrf id");
7037 M (RESET_VRF, reset_vrf);
7039 mp->vrf_id = ntohl (vrf_id);
7040 mp->is_ipv6 = is_ipv6;
7049 api_create_vlan_subif (vat_main_t * vam)
7051 unformat_input_t *i = vam->input;
7052 vl_api_create_vlan_subif_t *mp;
7055 u8 sw_if_index_set = 0;
7059 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7061 if (unformat (i, "sw_if_index %d", &sw_if_index))
7062 sw_if_index_set = 1;
7064 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7065 sw_if_index_set = 1;
7066 else if (unformat (i, "vlan %d", &vlan_id))
7070 clib_warning ("parse error '%U'", format_unformat_error, i);
7075 if (sw_if_index_set == 0)
7077 errmsg ("missing interface name or sw_if_index");
7081 if (vlan_id_set == 0)
7083 errmsg ("missing vlan_id");
7086 M (CREATE_VLAN_SUBIF, create_vlan_subif);
7088 mp->sw_if_index = ntohl (sw_if_index);
7089 mp->vlan_id = ntohl (vlan_id);
7097 #define foreach_create_subif_bit \
7104 _(outer_vlan_id_any) \
7105 _(inner_vlan_id_any)
7108 api_create_subif (vat_main_t * vam)
7110 unformat_input_t *i = vam->input;
7111 vl_api_create_subif_t *mp;
7114 u8 sw_if_index_set = 0;
7121 u32 exact_match = 0;
7122 u32 default_sub = 0;
7123 u32 outer_vlan_id_any = 0;
7124 u32 inner_vlan_id_any = 0;
7126 u16 outer_vlan_id = 0;
7127 u16 inner_vlan_id = 0;
7129 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7131 if (unformat (i, "sw_if_index %d", &sw_if_index))
7132 sw_if_index_set = 1;
7134 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7135 sw_if_index_set = 1;
7136 else if (unformat (i, "sub_id %d", &sub_id))
7138 else if (unformat (i, "outer_vlan_id %d", &tmp))
7139 outer_vlan_id = tmp;
7140 else if (unformat (i, "inner_vlan_id %d", &tmp))
7141 inner_vlan_id = tmp;
7143 #define _(a) else if (unformat (i, #a)) a = 1 ;
7144 foreach_create_subif_bit
7148 clib_warning ("parse error '%U'", format_unformat_error, i);
7153 if (sw_if_index_set == 0)
7155 errmsg ("missing interface name or sw_if_index");
7159 if (sub_id_set == 0)
7161 errmsg ("missing sub_id");
7164 M (CREATE_SUBIF, create_subif);
7166 mp->sw_if_index = ntohl (sw_if_index);
7167 mp->sub_id = ntohl (sub_id);
7169 #define _(a) mp->a = a;
7170 foreach_create_subif_bit;
7173 mp->outer_vlan_id = ntohs (outer_vlan_id);
7174 mp->inner_vlan_id = ntohs (inner_vlan_id);
7183 api_oam_add_del (vat_main_t * vam)
7185 unformat_input_t *i = vam->input;
7186 vl_api_oam_add_del_t *mp;
7190 ip4_address_t src, dst;
7194 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7196 if (unformat (i, "vrf %d", &vrf_id))
7198 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7200 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7202 else if (unformat (i, "del"))
7206 clib_warning ("parse error '%U'", format_unformat_error, i);
7213 errmsg ("missing src addr");
7219 errmsg ("missing dst addr");
7223 M (OAM_ADD_DEL, oam_add_del);
7225 mp->vrf_id = ntohl (vrf_id);
7226 mp->is_add = is_add;
7227 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7228 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7237 api_reset_fib (vat_main_t * vam)
7239 unformat_input_t *i = vam->input;
7240 vl_api_reset_fib_t *mp;
7246 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7248 if (unformat (i, "vrf %d", &vrf_id))
7250 else if (unformat (i, "ipv6"))
7254 clib_warning ("parse error '%U'", format_unformat_error, i);
7259 if (vrf_id_set == 0)
7261 errmsg ("missing vrf id");
7265 M (RESET_FIB, reset_fib);
7267 mp->vrf_id = ntohl (vrf_id);
7268 mp->is_ipv6 = is_ipv6;
7277 api_dhcp_proxy_config (vat_main_t * vam)
7279 unformat_input_t *i = vam->input;
7280 vl_api_dhcp_proxy_config_t *mp;
7285 u8 v4_address_set = 0;
7286 u8 v6_address_set = 0;
7287 ip4_address_t v4address;
7288 ip6_address_t v6address;
7289 u8 v4_src_address_set = 0;
7290 u8 v6_src_address_set = 0;
7291 ip4_address_t v4srcaddress;
7292 ip6_address_t v6srcaddress;
7294 /* Parse args required to build the message */
7295 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7297 if (unformat (i, "del"))
7299 else if (unformat (i, "vrf %d", &vrf_id))
7301 else if (unformat (i, "insert-cid %d", &insert_cid))
7303 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7305 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7307 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7308 v4_src_address_set = 1;
7309 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7310 v6_src_address_set = 1;
7315 if (v4_address_set && v6_address_set)
7317 errmsg ("both v4 and v6 server addresses set");
7320 if (!v4_address_set && !v6_address_set)
7322 errmsg ("no server addresses set");
7326 if (v4_src_address_set && v6_src_address_set)
7328 errmsg ("both v4 and v6 src addresses set");
7331 if (!v4_src_address_set && !v6_src_address_set)
7333 errmsg ("no src addresses set");
7337 if (!(v4_src_address_set && v4_address_set) &&
7338 !(v6_src_address_set && v6_address_set))
7340 errmsg ("no matching server and src addresses set");
7344 /* Construct the API message */
7345 M (DHCP_PROXY_CONFIG, dhcp_proxy_config);
7347 mp->insert_circuit_id = insert_cid;
7348 mp->is_add = is_add;
7349 mp->vrf_id = ntohl (vrf_id);
7353 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7354 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7358 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7359 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7365 /* Wait for a reply, return good/bad news */
7372 api_dhcp_proxy_config_2 (vat_main_t * vam)
7374 unformat_input_t *i = vam->input;
7375 vl_api_dhcp_proxy_config_2_t *mp;
7378 u32 server_vrf_id = 0;
7381 u8 v4_address_set = 0;
7382 u8 v6_address_set = 0;
7383 ip4_address_t v4address;
7384 ip6_address_t v6address;
7385 u8 v4_src_address_set = 0;
7386 u8 v6_src_address_set = 0;
7387 ip4_address_t v4srcaddress;
7388 ip6_address_t v6srcaddress;
7390 /* Parse args required to build the message */
7391 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7393 if (unformat (i, "del"))
7395 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7397 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7399 else if (unformat (i, "insert-cid %d", &insert_cid))
7401 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7403 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7405 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7406 v4_src_address_set = 1;
7407 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7408 v6_src_address_set = 1;
7413 if (v4_address_set && v6_address_set)
7415 errmsg ("both v4 and v6 server addresses set");
7418 if (!v4_address_set && !v6_address_set)
7420 errmsg ("no server addresses set");
7424 if (v4_src_address_set && v6_src_address_set)
7426 errmsg ("both v4 and v6 src addresses set");
7429 if (!v4_src_address_set && !v6_src_address_set)
7431 errmsg ("no src addresses set");
7435 if (!(v4_src_address_set && v4_address_set) &&
7436 !(v6_src_address_set && v6_address_set))
7438 errmsg ("no matching server and src addresses set");
7442 /* Construct the API message */
7443 M (DHCP_PROXY_CONFIG_2, dhcp_proxy_config_2);
7445 mp->insert_circuit_id = insert_cid;
7446 mp->is_add = is_add;
7447 mp->rx_vrf_id = ntohl (rx_vrf_id);
7448 mp->server_vrf_id = ntohl (server_vrf_id);
7452 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7453 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7457 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7458 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7464 /* Wait for a reply, return good/bad news */
7471 api_dhcp_proxy_set_vss (vat_main_t * vam)
7473 unformat_input_t *i = vam->input;
7474 vl_api_dhcp_proxy_set_vss_t *mp;
7485 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7487 if (unformat (i, "tbl_id %d", &tbl_id))
7489 if (unformat (i, "fib_id %d", &fib_id))
7491 if (unformat (i, "oui %d", &oui))
7493 else if (unformat (i, "ipv6"))
7495 else if (unformat (i, "del"))
7499 clib_warning ("parse error '%U'", format_unformat_error, i);
7504 if (tbl_id_set == 0)
7506 errmsg ("missing tbl id");
7510 if (fib_id_set == 0)
7512 errmsg ("missing fib id");
7517 errmsg ("missing oui");
7521 M (DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss);
7522 mp->tbl_id = ntohl (tbl_id);
7523 mp->fib_id = ntohl (fib_id);
7524 mp->oui = ntohl (oui);
7525 mp->is_ipv6 = is_ipv6;
7526 mp->is_add = is_add;
7535 api_dhcp_client_config (vat_main_t * vam)
7537 unformat_input_t *i = vam->input;
7538 vl_api_dhcp_client_config_t *mp;
7541 u8 sw_if_index_set = 0;
7544 u8 disable_event = 0;
7546 /* Parse args required to build the message */
7547 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7549 if (unformat (i, "del"))
7552 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7553 sw_if_index_set = 1;
7554 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7555 sw_if_index_set = 1;
7556 else if (unformat (i, "hostname %s", &hostname))
7558 else if (unformat (i, "disable_event"))
7564 if (sw_if_index_set == 0)
7566 errmsg ("missing interface name or sw_if_index");
7570 if (vec_len (hostname) > 63)
7572 errmsg ("hostname too long");
7574 vec_add1 (hostname, 0);
7576 /* Construct the API message */
7577 M (DHCP_CLIENT_CONFIG, dhcp_client_config);
7579 mp->sw_if_index = ntohl (sw_if_index);
7580 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7581 vec_free (hostname);
7582 mp->is_add = is_add;
7583 mp->want_dhcp_event = disable_event ? 0 : 1;
7584 mp->pid = getpid ();
7589 /* Wait for a reply, return good/bad news */
7596 api_set_ip_flow_hash (vat_main_t * vam)
7598 unformat_input_t *i = vam->input;
7599 vl_api_set_ip_flow_hash_t *mp;
7611 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7613 if (unformat (i, "vrf %d", &vrf_id))
7615 else if (unformat (i, "ipv6"))
7617 else if (unformat (i, "src"))
7619 else if (unformat (i, "dst"))
7621 else if (unformat (i, "sport"))
7623 else if (unformat (i, "dport"))
7625 else if (unformat (i, "proto"))
7627 else if (unformat (i, "reverse"))
7632 clib_warning ("parse error '%U'", format_unformat_error, i);
7637 if (vrf_id_set == 0)
7639 errmsg ("missing vrf id");
7643 M (SET_IP_FLOW_HASH, set_ip_flow_hash);
7649 mp->reverse = reverse;
7650 mp->vrf_id = ntohl (vrf_id);
7651 mp->is_ipv6 = is_ipv6;
7660 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7662 unformat_input_t *i = vam->input;
7663 vl_api_sw_interface_ip6_enable_disable_t *mp;
7666 u8 sw_if_index_set = 0;
7669 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7671 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7672 sw_if_index_set = 1;
7673 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7674 sw_if_index_set = 1;
7675 else if (unformat (i, "enable"))
7677 else if (unformat (i, "disable"))
7681 clib_warning ("parse error '%U'", format_unformat_error, i);
7686 if (sw_if_index_set == 0)
7688 errmsg ("missing interface name or sw_if_index");
7692 M (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable);
7694 mp->sw_if_index = ntohl (sw_if_index);
7695 mp->enable = enable;
7704 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7706 unformat_input_t *i = vam->input;
7707 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7710 u8 sw_if_index_set = 0;
7711 u8 v6_address_set = 0;
7712 ip6_address_t v6address;
7714 /* Parse args required to build the message */
7715 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7717 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7718 sw_if_index_set = 1;
7719 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7720 sw_if_index_set = 1;
7721 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
7727 if (sw_if_index_set == 0)
7729 errmsg ("missing interface name or sw_if_index");
7732 if (!v6_address_set)
7734 errmsg ("no address set");
7738 /* Construct the API message */
7739 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,
7740 sw_interface_ip6_set_link_local_address);
7742 mp->sw_if_index = ntohl (sw_if_index);
7743 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7748 /* Wait for a reply, return good/bad news */
7757 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
7759 unformat_input_t *i = vam->input;
7760 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
7763 u8 sw_if_index_set = 0;
7764 u32 address_length = 0;
7765 u8 v6_address_set = 0;
7766 ip6_address_t v6address;
7768 u8 no_advertise = 0;
7770 u8 no_autoconfig = 0;
7773 u32 val_lifetime = 0;
7774 u32 pref_lifetime = 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;
7783 else if (unformat (i, "%U/%d",
7784 unformat_ip6_address, &v6address, &address_length))
7786 else if (unformat (i, "val_life %d", &val_lifetime))
7788 else if (unformat (i, "pref_life %d", &pref_lifetime))
7790 else if (unformat (i, "def"))
7792 else if (unformat (i, "noadv"))
7794 else if (unformat (i, "offl"))
7796 else if (unformat (i, "noauto"))
7798 else if (unformat (i, "nolink"))
7800 else if (unformat (i, "isno"))
7804 clib_warning ("parse error '%U'", format_unformat_error, i);
7809 if (sw_if_index_set == 0)
7811 errmsg ("missing interface name or sw_if_index");
7814 if (!v6_address_set)
7816 errmsg ("no address set");
7820 /* Construct the API message */
7821 M (SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix);
7823 mp->sw_if_index = ntohl (sw_if_index);
7824 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7825 mp->address_length = address_length;
7826 mp->use_default = use_default;
7827 mp->no_advertise = no_advertise;
7828 mp->off_link = off_link;
7829 mp->no_autoconfig = no_autoconfig;
7830 mp->no_onlink = no_onlink;
7832 mp->val_lifetime = ntohl (val_lifetime);
7833 mp->pref_lifetime = ntohl (pref_lifetime);
7838 /* Wait for a reply, return good/bad news */
7846 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
7848 unformat_input_t *i = vam->input;
7849 vl_api_sw_interface_ip6nd_ra_config_t *mp;
7852 u8 sw_if_index_set = 0;
7857 u8 send_unicast = 0;
7860 u8 default_router = 0;
7861 u32 max_interval = 0;
7862 u32 min_interval = 0;
7864 u32 initial_count = 0;
7865 u32 initial_interval = 0;
7868 /* Parse args required to build the message */
7869 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7871 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7872 sw_if_index_set = 1;
7873 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7874 sw_if_index_set = 1;
7875 else if (unformat (i, "maxint %d", &max_interval))
7877 else if (unformat (i, "minint %d", &min_interval))
7879 else if (unformat (i, "life %d", &lifetime))
7881 else if (unformat (i, "count %d", &initial_count))
7883 else if (unformat (i, "interval %d", &initial_interval))
7885 else if (unformat (i, "suppress") || unformat (i, "surpress"))
7887 else if (unformat (i, "managed"))
7889 else if (unformat (i, "other"))
7891 else if (unformat (i, "ll"))
7893 else if (unformat (i, "send"))
7895 else if (unformat (i, "cease"))
7897 else if (unformat (i, "isno"))
7899 else if (unformat (i, "def"))
7903 clib_warning ("parse error '%U'", format_unformat_error, i);
7908 if (sw_if_index_set == 0)
7910 errmsg ("missing interface name or sw_if_index");
7914 /* Construct the API message */
7915 M (SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config);
7917 mp->sw_if_index = ntohl (sw_if_index);
7918 mp->max_interval = ntohl (max_interval);
7919 mp->min_interval = ntohl (min_interval);
7920 mp->lifetime = ntohl (lifetime);
7921 mp->initial_count = ntohl (initial_count);
7922 mp->initial_interval = ntohl (initial_interval);
7923 mp->suppress = suppress;
7924 mp->managed = managed;
7926 mp->ll_option = ll_option;
7927 mp->send_unicast = send_unicast;
7930 mp->default_router = default_router;
7935 /* Wait for a reply, return good/bad news */
7943 api_set_arp_neighbor_limit (vat_main_t * vam)
7945 unformat_input_t *i = vam->input;
7946 vl_api_set_arp_neighbor_limit_t *mp;
7952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7954 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
7956 else if (unformat (i, "ipv6"))
7960 clib_warning ("parse error '%U'", format_unformat_error, i);
7967 errmsg ("missing limit value");
7971 M (SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit);
7973 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
7974 mp->is_ipv6 = is_ipv6;
7983 api_l2_patch_add_del (vat_main_t * vam)
7985 unformat_input_t *i = vam->input;
7986 vl_api_l2_patch_add_del_t *mp;
7989 u8 rx_sw_if_index_set = 0;
7991 u8 tx_sw_if_index_set = 0;
7994 /* Parse args required to build the message */
7995 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7997 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7998 rx_sw_if_index_set = 1;
7999 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8000 tx_sw_if_index_set = 1;
8001 else if (unformat (i, "rx"))
8003 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8005 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8007 rx_sw_if_index_set = 1;
8012 else if (unformat (i, "tx"))
8014 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8016 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8018 tx_sw_if_index_set = 1;
8023 else if (unformat (i, "del"))
8029 if (rx_sw_if_index_set == 0)
8031 errmsg ("missing rx interface name or rx_sw_if_index");
8035 if (tx_sw_if_index_set == 0)
8037 errmsg ("missing tx interface name or tx_sw_if_index");
8041 M (L2_PATCH_ADD_DEL, l2_patch_add_del);
8043 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8044 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8045 mp->is_add = is_add;
8054 api_ioam_enable (vat_main_t * vam)
8056 unformat_input_t *input = vam->input;
8057 vl_api_ioam_enable_t *mp;
8060 int has_trace_option = 0;
8061 int has_pot_option = 0;
8062 int has_seqno_option = 0;
8063 int has_analyse_option = 0;
8065 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8067 if (unformat (input, "trace"))
8068 has_trace_option = 1;
8069 else if (unformat (input, "pot"))
8071 else if (unformat (input, "seqno"))
8072 has_seqno_option = 1;
8073 else if (unformat (input, "analyse"))
8074 has_analyse_option = 1;
8078 M (IOAM_ENABLE, ioam_enable);
8079 mp->id = htons (id);
8080 mp->seqno = has_seqno_option;
8081 mp->analyse = has_analyse_option;
8082 mp->pot_enable = has_pot_option;
8083 mp->trace_enable = has_trace_option;
8094 api_ioam_disable (vat_main_t * vam)
8096 vl_api_ioam_disable_t *mp;
8099 M (IOAM_DISABLE, ioam_disable);
8106 api_sr_tunnel_add_del (vat_main_t * vam)
8108 unformat_input_t *i = vam->input;
8109 vl_api_sr_tunnel_add_del_t *mp;
8113 ip6_address_t src_address;
8114 int src_address_set = 0;
8115 ip6_address_t dst_address;
8117 int dst_address_set = 0;
8119 u32 rx_table_id = 0;
8120 u32 tx_table_id = 0;
8121 ip6_address_t *segments = 0;
8122 ip6_address_t *this_seg;
8123 ip6_address_t *tags = 0;
8124 ip6_address_t *this_tag;
8125 ip6_address_t next_address, tag;
8127 u8 *policy_name = 0;
8129 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8131 if (unformat (i, "del"))
8133 else if (unformat (i, "name %s", &name))
8135 else if (unformat (i, "policy %s", &policy_name))
8137 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
8139 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
8141 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
8142 src_address_set = 1;
8143 else if (unformat (i, "dst %U/%d",
8144 unformat_ip6_address, &dst_address, &dst_mask_width))
8145 dst_address_set = 1;
8146 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
8148 vec_add2 (segments, this_seg, 1);
8149 clib_memcpy (this_seg->as_u8, next_address.as_u8,
8150 sizeof (*this_seg));
8152 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
8154 vec_add2 (tags, this_tag, 1);
8155 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
8157 else if (unformat (i, "clean"))
8158 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
8159 else if (unformat (i, "protected"))
8160 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
8161 else if (unformat (i, "InPE %d", &pl_index))
8163 if (pl_index <= 0 || pl_index > 4)
8165 pl_index_range_error:
8166 errmsg ("pl index %d out of range", pl_index);
8170 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
8172 else if (unformat (i, "EgPE %d", &pl_index))
8174 if (pl_index <= 0 || pl_index > 4)
8175 goto pl_index_range_error;
8177 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
8179 else if (unformat (i, "OrgSrc %d", &pl_index))
8181 if (pl_index <= 0 || pl_index > 4)
8182 goto pl_index_range_error;
8184 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
8190 if (!src_address_set)
8192 errmsg ("src address required");
8196 if (!dst_address_set)
8198 errmsg ("dst address required");
8204 errmsg ("at least one sr segment required");
8208 M2 (SR_TUNNEL_ADD_DEL, sr_tunnel_add_del,
8209 vec_len (segments) * sizeof (ip6_address_t)
8210 + vec_len (tags) * sizeof (ip6_address_t));
8212 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
8213 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
8214 mp->dst_mask_width = dst_mask_width;
8215 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
8216 mp->n_segments = vec_len (segments);
8217 mp->n_tags = vec_len (tags);
8218 mp->is_add = is_del == 0;
8219 clib_memcpy (mp->segs_and_tags, segments,
8220 vec_len (segments) * sizeof (ip6_address_t));
8221 clib_memcpy (mp->segs_and_tags +
8222 vec_len (segments) * sizeof (ip6_address_t), tags,
8223 vec_len (tags) * sizeof (ip6_address_t));
8225 mp->outer_vrf_id = ntohl (rx_table_id);
8226 mp->inner_vrf_id = ntohl (tx_table_id);
8227 memcpy (mp->name, name, vec_len (name));
8228 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8230 vec_free (segments);
8239 api_sr_policy_add_del (vat_main_t * vam)
8241 unformat_input_t *input = vam->input;
8242 vl_api_sr_policy_add_del_t *mp;
8246 u8 *tunnel_name = 0;
8247 u8 **tunnel_names = 0;
8252 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
8253 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
8255 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8257 if (unformat (input, "del"))
8259 else if (unformat (input, "name %s", &name))
8261 else if (unformat (input, "tunnel %s", &tunnel_name))
8265 vec_add1 (tunnel_names, tunnel_name);
8267 - length = #bytes to store in serial vector
8268 - +1 = byte to store that length
8270 tunnel_names_length += (vec_len (tunnel_name) + 1);
8281 errmsg ("policy name required");
8285 if ((!tunnel_set) && (!is_del))
8287 errmsg ("tunnel name required");
8291 M2 (SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length);
8295 mp->is_add = !is_del;
8297 memcpy (mp->name, name, vec_len (name));
8298 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
8299 u8 *serial_orig = 0;
8300 vec_validate (serial_orig, tunnel_names_length);
8301 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
8302 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
8304 for (j = 0; j < vec_len (tunnel_names); j++)
8306 tun_name_len = vec_len (tunnel_names[j]);
8307 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
8308 serial_orig += 1; // Move along one byte to store the actual tunnel name
8309 memcpy (serial_orig, tunnel_names[j], tun_name_len);
8310 serial_orig += tun_name_len; // Advance past the copy
8312 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
8314 vec_free (tunnel_names);
8315 vec_free (tunnel_name);
8323 api_sr_multicast_map_add_del (vat_main_t * vam)
8325 unformat_input_t *input = vam->input;
8326 vl_api_sr_multicast_map_add_del_t *mp;
8329 ip6_address_t multicast_address;
8330 u8 *policy_name = 0;
8331 int multicast_address_set = 0;
8333 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8335 if (unformat (input, "del"))
8339 (input, "address %U", unformat_ip6_address, &multicast_address))
8340 multicast_address_set = 1;
8341 else if (unformat (input, "sr-policy %s", &policy_name))
8347 if (!is_del && !policy_name)
8349 errmsg ("sr-policy name required");
8354 if (!multicast_address_set)
8356 errmsg ("address required");
8360 M (SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del);
8362 mp->is_add = !is_del;
8363 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8364 clib_memcpy (mp->multicast_address, &multicast_address,
8365 sizeof (mp->multicast_address));
8368 vec_free (policy_name);
8376 #define foreach_tcp_proto_field \
8380 #define foreach_udp_proto_field \
8384 #define foreach_ip4_proto_field \
8395 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8397 u8 **maskp = va_arg (*args, u8 **);
8399 u8 found_something = 0;
8402 #define _(a) u8 a=0;
8403 foreach_tcp_proto_field;
8406 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8409 #define _(a) else if (unformat (input, #a)) a=1;
8410 foreach_tcp_proto_field
8416 #define _(a) found_something += a;
8417 foreach_tcp_proto_field;
8420 if (found_something == 0)
8423 vec_validate (mask, sizeof (*tcp) - 1);
8425 tcp = (tcp_header_t *) mask;
8427 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8428 foreach_tcp_proto_field;
8436 unformat_udp_mask (unformat_input_t * input, va_list * args)
8438 u8 **maskp = va_arg (*args, u8 **);
8440 u8 found_something = 0;
8443 #define _(a) u8 a=0;
8444 foreach_udp_proto_field;
8447 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8450 #define _(a) else if (unformat (input, #a)) a=1;
8451 foreach_udp_proto_field
8457 #define _(a) found_something += a;
8458 foreach_udp_proto_field;
8461 if (found_something == 0)
8464 vec_validate (mask, sizeof (*udp) - 1);
8466 udp = (udp_header_t *) mask;
8468 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8469 foreach_udp_proto_field;
8478 u16 src_port, dst_port;
8482 unformat_l4_mask (unformat_input_t * input, va_list * args)
8484 u8 **maskp = va_arg (*args, u8 **);
8485 u16 src_port = 0, dst_port = 0;
8486 tcpudp_header_t *tcpudp;
8488 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8490 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8492 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8494 else if (unformat (input, "src_port"))
8496 else if (unformat (input, "dst_port"))
8502 if (!src_port && !dst_port)
8506 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8508 tcpudp = (tcpudp_header_t *) mask;
8509 tcpudp->src_port = src_port;
8510 tcpudp->dst_port = dst_port;
8518 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8520 u8 **maskp = va_arg (*args, u8 **);
8522 u8 found_something = 0;
8525 #define _(a) u8 a=0;
8526 foreach_ip4_proto_field;
8532 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8534 if (unformat (input, "version"))
8536 else if (unformat (input, "hdr_length"))
8538 else if (unformat (input, "src"))
8540 else if (unformat (input, "dst"))
8542 else if (unformat (input, "proto"))
8545 #define _(a) else if (unformat (input, #a)) a=1;
8546 foreach_ip4_proto_field
8552 #define _(a) found_something += a;
8553 foreach_ip4_proto_field;
8556 if (found_something == 0)
8559 vec_validate (mask, sizeof (*ip) - 1);
8561 ip = (ip4_header_t *) mask;
8563 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8564 foreach_ip4_proto_field;
8567 ip->ip_version_and_header_length = 0;
8570 ip->ip_version_and_header_length |= 0xF0;
8573 ip->ip_version_and_header_length |= 0x0F;
8579 #define foreach_ip6_proto_field \
8587 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8589 u8 **maskp = va_arg (*args, u8 **);
8591 u8 found_something = 0;
8593 u32 ip_version_traffic_class_and_flow_label;
8595 #define _(a) u8 a=0;
8596 foreach_ip6_proto_field;
8599 u8 traffic_class = 0;
8602 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8604 if (unformat (input, "version"))
8606 else if (unformat (input, "traffic-class"))
8608 else if (unformat (input, "flow-label"))
8610 else if (unformat (input, "src"))
8612 else if (unformat (input, "dst"))
8614 else if (unformat (input, "proto"))
8617 #define _(a) else if (unformat (input, #a)) a=1;
8618 foreach_ip6_proto_field
8624 #define _(a) found_something += a;
8625 foreach_ip6_proto_field;
8628 if (found_something == 0)
8631 vec_validate (mask, sizeof (*ip) - 1);
8633 ip = (ip6_header_t *) mask;
8635 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8636 foreach_ip6_proto_field;
8639 ip_version_traffic_class_and_flow_label = 0;
8642 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8645 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8648 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8650 ip->ip_version_traffic_class_and_flow_label =
8651 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8658 unformat_l3_mask (unformat_input_t * input, va_list * args)
8660 u8 **maskp = va_arg (*args, u8 **);
8662 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8664 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8666 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8675 unformat_l2_mask (unformat_input_t * input, va_list * args)
8677 u8 **maskp = va_arg (*args, u8 **);
8692 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8694 if (unformat (input, "src"))
8696 else if (unformat (input, "dst"))
8698 else if (unformat (input, "proto"))
8700 else if (unformat (input, "tag1"))
8702 else if (unformat (input, "tag2"))
8704 else if (unformat (input, "ignore-tag1"))
8706 else if (unformat (input, "ignore-tag2"))
8708 else if (unformat (input, "cos1"))
8710 else if (unformat (input, "cos2"))
8712 else if (unformat (input, "dot1q"))
8714 else if (unformat (input, "dot1ad"))
8719 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8720 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8723 if (tag1 || ignore_tag1 || cos1 || dot1q)
8725 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8728 vec_validate (mask, len - 1);
8731 memset (mask, 0xff, 6);
8734 memset (mask + 6, 0xff, 6);
8738 /* inner vlan tag */
8747 mask[21] = mask[20] = 0xff;
8768 mask[16] = mask[17] = 0xff;
8778 mask[12] = mask[13] = 0xff;
8785 unformat_classify_mask (unformat_input_t * input, va_list * args)
8787 u8 **maskp = va_arg (*args, u8 **);
8788 u32 *skipp = va_arg (*args, u32 *);
8789 u32 *matchp = va_arg (*args, u32 *);
8797 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8799 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8801 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8803 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8805 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
8819 if (mask || l2 || l3 || l4)
8823 /* "With a free Ethernet header in every package" */
8825 vec_validate (l2, 13);
8829 vec_append (mask, l3);
8834 vec_append (mask, l4);
8839 /* Scan forward looking for the first significant mask octet */
8840 for (i = 0; i < vec_len (mask); i++)
8844 /* compute (skip, match) params */
8845 *skipp = i / sizeof (u32x4);
8846 vec_delete (mask, *skipp * sizeof (u32x4), 0);
8848 /* Pad mask to an even multiple of the vector size */
8849 while (vec_len (mask) % sizeof (u32x4))
8852 match = vec_len (mask) / sizeof (u32x4);
8854 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
8856 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
8857 if (*tmp || *(tmp + 1))
8862 clib_warning ("BUG: match 0");
8864 _vec_len (mask) = match * sizeof (u32x4);
8875 #define foreach_l2_next \
8877 _(ethernet, ETHERNET_INPUT) \
8882 unformat_l2_next_index (unformat_input_t * input, va_list * args)
8884 u32 *miss_next_indexp = va_arg (*args, u32 *);
8889 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
8893 if (unformat (input, "%d", &tmp))
8902 *miss_next_indexp = next_index;
8906 #define foreach_ip_next \
8912 unformat_ip_next_index (unformat_input_t * input, va_list * args)
8914 u32 *miss_next_indexp = va_arg (*args, u32 *);
8919 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
8923 if (unformat (input, "%d", &tmp))
8932 *miss_next_indexp = next_index;
8936 #define foreach_acl_next \
8940 unformat_acl_next_index (unformat_input_t * input, va_list * args)
8942 u32 *miss_next_indexp = va_arg (*args, u32 *);
8947 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
8951 if (unformat (input, "permit"))
8956 else if (unformat (input, "%d", &tmp))
8965 *miss_next_indexp = next_index;
8970 unformat_policer_precolor (unformat_input_t * input, va_list * args)
8972 u32 *r = va_arg (*args, u32 *);
8974 if (unformat (input, "conform-color"))
8975 *r = POLICE_CONFORM;
8976 else if (unformat (input, "exceed-color"))
8985 api_classify_add_del_table (vat_main_t * vam)
8987 unformat_input_t *i = vam->input;
8988 vl_api_classify_add_del_table_t *mp;
8995 u32 table_index = ~0;
8996 u32 next_table_index = ~0;
8997 u32 miss_next_index = ~0;
8998 u32 memory_size = 32 << 20;
9001 u32 current_data_flag = 0;
9002 int current_data_offset = 0;
9004 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9006 if (unformat (i, "del"))
9008 else if (unformat (i, "del-chain"))
9013 else if (unformat (i, "buckets %d", &nbuckets))
9015 else if (unformat (i, "memory_size %d", &memory_size))
9017 else if (unformat (i, "skip %d", &skip))
9019 else if (unformat (i, "match %d", &match))
9021 else if (unformat (i, "table %d", &table_index))
9023 else if (unformat (i, "mask %U", unformat_classify_mask,
9024 &mask, &skip, &match))
9026 else if (unformat (i, "next-table %d", &next_table_index))
9028 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
9031 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9034 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
9037 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9039 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9045 if (is_add && mask == 0)
9047 errmsg ("Mask required");
9051 if (is_add && skip == ~0)
9053 errmsg ("skip count required");
9057 if (is_add && match == ~0)
9059 errmsg ("match count required");
9063 if (!is_add && table_index == ~0)
9065 errmsg ("table index required for delete");
9069 M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask));
9071 mp->is_add = is_add;
9072 mp->del_chain = del_chain;
9073 mp->table_index = ntohl (table_index);
9074 mp->nbuckets = ntohl (nbuckets);
9075 mp->memory_size = ntohl (memory_size);
9076 mp->skip_n_vectors = ntohl (skip);
9077 mp->match_n_vectors = ntohl (match);
9078 mp->next_table_index = ntohl (next_table_index);
9079 mp->miss_next_index = ntohl (miss_next_index);
9080 mp->current_data_flag = ntohl (current_data_flag);
9081 mp->current_data_offset = ntohl (current_data_offset);
9082 clib_memcpy (mp->mask, mask, vec_len (mask));
9092 unformat_l4_match (unformat_input_t * input, va_list * args)
9094 u8 **matchp = va_arg (*args, u8 **);
9096 u8 *proto_header = 0;
9102 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9104 if (unformat (input, "src_port %d", &src_port))
9106 else if (unformat (input, "dst_port %d", &dst_port))
9112 h.src_port = clib_host_to_net_u16 (src_port);
9113 h.dst_port = clib_host_to_net_u16 (dst_port);
9114 vec_validate (proto_header, sizeof (h) - 1);
9115 memcpy (proto_header, &h, sizeof (h));
9117 *matchp = proto_header;
9123 unformat_ip4_match (unformat_input_t * input, va_list * args)
9125 u8 **matchp = va_arg (*args, u8 **);
9132 int src = 0, dst = 0;
9133 ip4_address_t src_val, dst_val;
9140 int fragment_id = 0;
9141 u32 fragment_id_val;
9147 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9149 if (unformat (input, "version %d", &version_val))
9151 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9153 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9155 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9157 else if (unformat (input, "proto %d", &proto_val))
9159 else if (unformat (input, "tos %d", &tos_val))
9161 else if (unformat (input, "length %d", &length_val))
9163 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9165 else if (unformat (input, "ttl %d", &ttl_val))
9167 else if (unformat (input, "checksum %d", &checksum_val))
9173 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9174 + ttl + checksum == 0)
9178 * Aligned because we use the real comparison functions
9180 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9182 ip = (ip4_header_t *) match;
9184 /* These are realistically matched in practice */
9186 ip->src_address.as_u32 = src_val.as_u32;
9189 ip->dst_address.as_u32 = dst_val.as_u32;
9192 ip->protocol = proto_val;
9195 /* These are not, but they're included for completeness */
9197 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9200 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9206 ip->length = clib_host_to_net_u16 (length_val);
9212 ip->checksum = clib_host_to_net_u16 (checksum_val);
9219 unformat_ip6_match (unformat_input_t * input, va_list * args)
9221 u8 **matchp = va_arg (*args, u8 **);
9226 u8 traffic_class = 0;
9227 u32 traffic_class_val = 0;
9230 int src = 0, dst = 0;
9231 ip6_address_t src_val, dst_val;
9234 int payload_length = 0;
9235 u32 payload_length_val;
9238 u32 ip_version_traffic_class_and_flow_label;
9240 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9242 if (unformat (input, "version %d", &version_val))
9244 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9246 else if (unformat (input, "flow_label %d", &flow_label_val))
9248 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9250 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9252 else if (unformat (input, "proto %d", &proto_val))
9254 else if (unformat (input, "payload_length %d", &payload_length_val))
9256 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9262 if (version + traffic_class + flow_label + src + dst + proto +
9263 payload_length + hop_limit == 0)
9267 * Aligned because we use the real comparison functions
9269 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9271 ip = (ip6_header_t *) match;
9274 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9277 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9280 ip->protocol = proto_val;
9282 ip_version_traffic_class_and_flow_label = 0;
9285 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9288 ip_version_traffic_class_and_flow_label |=
9289 (traffic_class_val & 0xFF) << 20;
9292 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9294 ip->ip_version_traffic_class_and_flow_label =
9295 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9298 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9301 ip->hop_limit = hop_limit_val;
9308 unformat_l3_match (unformat_input_t * input, va_list * args)
9310 u8 **matchp = va_arg (*args, u8 **);
9312 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9314 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9316 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9325 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9327 u8 *tagp = va_arg (*args, u8 *);
9330 if (unformat (input, "%d", &tag))
9332 tagp[0] = (tag >> 8) & 0x0F;
9333 tagp[1] = tag & 0xFF;
9341 unformat_l2_match (unformat_input_t * input, va_list * args)
9343 u8 **matchp = va_arg (*args, u8 **);
9363 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9365 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9368 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9370 else if (unformat (input, "proto %U",
9371 unformat_ethernet_type_host_byte_order, &proto_val))
9373 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9375 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9377 else if (unformat (input, "ignore-tag1"))
9379 else if (unformat (input, "ignore-tag2"))
9381 else if (unformat (input, "cos1 %d", &cos1_val))
9383 else if (unformat (input, "cos2 %d", &cos2_val))
9388 if ((src + dst + proto + tag1 + tag2 +
9389 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9392 if (tag1 || ignore_tag1 || cos1)
9394 if (tag2 || ignore_tag2 || cos2)
9397 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9400 clib_memcpy (match, dst_val, 6);
9403 clib_memcpy (match + 6, src_val, 6);
9407 /* inner vlan tag */
9408 match[19] = tag2_val[1];
9409 match[18] = tag2_val[0];
9411 match[18] |= (cos2_val & 0x7) << 5;
9414 match[21] = proto_val & 0xff;
9415 match[20] = proto_val >> 8;
9419 match[15] = tag1_val[1];
9420 match[14] = tag1_val[0];
9423 match[14] |= (cos1_val & 0x7) << 5;
9429 match[15] = tag1_val[1];
9430 match[14] = tag1_val[0];
9433 match[17] = proto_val & 0xff;
9434 match[16] = proto_val >> 8;
9437 match[14] |= (cos1_val & 0x7) << 5;
9443 match[18] |= (cos2_val & 0x7) << 5;
9445 match[14] |= (cos1_val & 0x7) << 5;
9448 match[13] = proto_val & 0xff;
9449 match[12] = proto_val >> 8;
9458 unformat_classify_match (unformat_input_t * input, va_list * args)
9460 u8 **matchp = va_arg (*args, u8 **);
9461 u32 skip_n_vectors = va_arg (*args, u32);
9462 u32 match_n_vectors = va_arg (*args, u32);
9469 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9471 if (unformat (input, "hex %U", unformat_hex_string, &match))
9473 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9475 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9477 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9491 if (match || l2 || l3 || l4)
9495 /* "Win a free Ethernet header in every packet" */
9497 vec_validate_aligned (l2, 13, sizeof (u32x4));
9501 vec_append_aligned (match, l3, sizeof (u32x4));
9506 vec_append_aligned (match, l4, sizeof (u32x4));
9511 /* Make sure the vector is big enough even if key is all 0's */
9512 vec_validate_aligned
9513 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9516 /* Set size, include skipped vectors */
9517 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9528 api_classify_add_del_session (vat_main_t * vam)
9530 unformat_input_t *i = vam->input;
9531 vl_api_classify_add_del_session_t *mp;
9533 u32 table_index = ~0;
9534 u32 hit_next_index = ~0;
9535 u32 opaque_index = ~0;
9539 u32 skip_n_vectors = 0;
9540 u32 match_n_vectors = 0;
9545 * Warning: you have to supply skip_n and match_n
9546 * because the API client cant simply look at the classify
9550 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9552 if (unformat (i, "del"))
9554 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
9557 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9560 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
9563 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9565 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9567 else if (unformat (i, "opaque-index %d", &opaque_index))
9569 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9571 else if (unformat (i, "match_n %d", &match_n_vectors))
9573 else if (unformat (i, "match %U", unformat_classify_match,
9574 &match, skip_n_vectors, match_n_vectors))
9576 else if (unformat (i, "advance %d", &advance))
9578 else if (unformat (i, "table-index %d", &table_index))
9580 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9582 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9584 else if (unformat (i, "action %d", &action))
9586 else if (unformat (i, "metadata %d", &metadata))
9592 if (table_index == ~0)
9594 errmsg ("Table index required");
9598 if (is_add && match == 0)
9600 errmsg ("Match value required");
9604 M2 (CLASSIFY_ADD_DEL_SESSION, classify_add_del_session, vec_len (match));
9606 mp->is_add = is_add;
9607 mp->table_index = ntohl (table_index);
9608 mp->hit_next_index = ntohl (hit_next_index);
9609 mp->opaque_index = ntohl (opaque_index);
9610 mp->advance = ntohl (advance);
9611 mp->action = action;
9612 mp->metadata = ntohl (metadata);
9613 clib_memcpy (mp->match, match, vec_len (match));
9622 api_classify_set_interface_ip_table (vat_main_t * vam)
9624 unformat_input_t *i = vam->input;
9625 vl_api_classify_set_interface_ip_table_t *mp;
9628 int sw_if_index_set;
9629 u32 table_index = ~0;
9632 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9634 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9635 sw_if_index_set = 1;
9636 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9637 sw_if_index_set = 1;
9638 else if (unformat (i, "table %d", &table_index))
9642 clib_warning ("parse error '%U'", format_unformat_error, i);
9647 if (sw_if_index_set == 0)
9649 errmsg ("missing interface name or sw_if_index");
9654 M (CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table);
9656 mp->sw_if_index = ntohl (sw_if_index);
9657 mp->table_index = ntohl (table_index);
9658 mp->is_ipv6 = is_ipv6;
9667 api_classify_set_interface_l2_tables (vat_main_t * vam)
9669 unformat_input_t *i = vam->input;
9670 vl_api_classify_set_interface_l2_tables_t *mp;
9673 int sw_if_index_set;
9674 u32 ip4_table_index = ~0;
9675 u32 ip6_table_index = ~0;
9676 u32 other_table_index = ~0;
9679 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9681 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9682 sw_if_index_set = 1;
9683 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9684 sw_if_index_set = 1;
9685 else if (unformat (i, "ip4-table %d", &ip4_table_index))
9687 else if (unformat (i, "ip6-table %d", &ip6_table_index))
9689 else if (unformat (i, "other-table %d", &other_table_index))
9691 else if (unformat (i, "is-input %d", &is_input))
9695 clib_warning ("parse error '%U'", format_unformat_error, i);
9700 if (sw_if_index_set == 0)
9702 errmsg ("missing interface name or sw_if_index");
9707 M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables);
9709 mp->sw_if_index = ntohl (sw_if_index);
9710 mp->ip4_table_index = ntohl (ip4_table_index);
9711 mp->ip6_table_index = ntohl (ip6_table_index);
9712 mp->other_table_index = ntohl (other_table_index);
9713 mp->is_input = (u8) is_input;
9722 api_set_ipfix_exporter (vat_main_t * vam)
9724 unformat_input_t *i = vam->input;
9725 vl_api_set_ipfix_exporter_t *mp;
9726 ip4_address_t collector_address;
9727 u8 collector_address_set = 0;
9728 u32 collector_port = ~0;
9729 ip4_address_t src_address;
9730 u8 src_address_set = 0;
9733 u32 template_interval = ~0;
9734 u8 udp_checksum = 0;
9737 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9739 if (unformat (i, "collector_address %U", unformat_ip4_address,
9740 &collector_address))
9741 collector_address_set = 1;
9742 else if (unformat (i, "collector_port %d", &collector_port))
9744 else if (unformat (i, "src_address %U", unformat_ip4_address,
9746 src_address_set = 1;
9747 else if (unformat (i, "vrf_id %d", &vrf_id))
9749 else if (unformat (i, "path_mtu %d", &path_mtu))
9751 else if (unformat (i, "template_interval %d", &template_interval))
9753 else if (unformat (i, "udp_checksum"))
9759 if (collector_address_set == 0)
9761 errmsg ("collector_address required");
9765 if (src_address_set == 0)
9767 errmsg ("src_address required");
9771 M (SET_IPFIX_EXPORTER, set_ipfix_exporter);
9773 memcpy (mp->collector_address, collector_address.data,
9774 sizeof (collector_address.data));
9775 mp->collector_port = htons ((u16) collector_port);
9776 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
9777 mp->vrf_id = htonl (vrf_id);
9778 mp->path_mtu = htonl (path_mtu);
9779 mp->template_interval = htonl (template_interval);
9780 mp->udp_checksum = udp_checksum;
9788 api_set_ipfix_classify_stream (vat_main_t * vam)
9790 unformat_input_t *i = vam->input;
9791 vl_api_set_ipfix_classify_stream_t *mp;
9793 u32 src_port = UDP_DST_PORT_ipfix;
9796 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9798 if (unformat (i, "domain %d", &domain_id))
9800 else if (unformat (i, "src_port %d", &src_port))
9804 errmsg ("unknown input `%U'", format_unformat_error, i);
9809 M (SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream);
9811 mp->domain_id = htonl (domain_id);
9812 mp->src_port = htons ((u16) src_port);
9820 api_ipfix_classify_table_add_del (vat_main_t * vam)
9822 unformat_input_t *i = vam->input;
9823 vl_api_ipfix_classify_table_add_del_t *mp;
9825 u32 classify_table_index = ~0;
9827 u8 transport_protocol = 255;
9830 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9832 if (unformat (i, "add"))
9834 else if (unformat (i, "del"))
9836 else if (unformat (i, "table %d", &classify_table_index))
9838 else if (unformat (i, "ip4"))
9840 else if (unformat (i, "ip6"))
9842 else if (unformat (i, "tcp"))
9843 transport_protocol = 6;
9844 else if (unformat (i, "udp"))
9845 transport_protocol = 17;
9848 errmsg ("unknown input `%U'", format_unformat_error, i);
9855 errmsg ("expecting: add|del");
9858 if (classify_table_index == ~0)
9860 errmsg ("classifier table not specified");
9863 if (ip_version == 0)
9865 errmsg ("IP version not specified");
9869 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del);
9871 mp->is_add = is_add;
9872 mp->table_id = htonl (classify_table_index);
9873 mp->ip_version = ip_version;
9874 mp->transport_protocol = transport_protocol;
9882 api_get_node_index (vat_main_t * vam)
9884 unformat_input_t *i = vam->input;
9885 vl_api_get_node_index_t *mp;
9889 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9891 if (unformat (i, "node %s", &name))
9898 errmsg ("node name required");
9901 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9903 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9907 M (GET_NODE_INDEX, get_node_index);
9908 clib_memcpy (mp->node_name, name, vec_len (name));
9918 api_get_next_index (vat_main_t * vam)
9920 unformat_input_t *i = vam->input;
9921 vl_api_get_next_index_t *mp;
9923 u8 *node_name = 0, *next_node_name = 0;
9925 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9927 if (unformat (i, "node-name %s", &node_name))
9929 else if (unformat (i, "next-node-name %s", &next_node_name))
9935 errmsg ("node name required");
9938 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
9940 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9944 if (next_node_name == 0)
9946 errmsg ("next node name required");
9949 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
9951 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
9955 M (GET_NEXT_INDEX, get_next_index);
9956 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
9957 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
9958 vec_free (node_name);
9959 vec_free (next_node_name);
9968 api_add_node_next (vat_main_t * vam)
9970 unformat_input_t *i = vam->input;
9971 vl_api_add_node_next_t *mp;
9976 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9978 if (unformat (i, "node %s", &name))
9980 else if (unformat (i, "next %s", &next))
9987 errmsg ("node name required");
9990 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9992 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9997 errmsg ("next node required");
10000 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
10002 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10006 M (ADD_NODE_NEXT, add_node_next);
10007 clib_memcpy (mp->node_name, name, vec_len (name));
10008 clib_memcpy (mp->next_name, next, vec_len (next));
10019 api_l2tpv3_create_tunnel (vat_main_t * vam)
10021 unformat_input_t *i = vam->input;
10022 ip6_address_t client_address, our_address;
10023 int client_address_set = 0;
10024 int our_address_set = 0;
10025 u32 local_session_id = 0;
10026 u32 remote_session_id = 0;
10027 u64 local_cookie = 0;
10028 u64 remote_cookie = 0;
10029 u8 l2_sublayer_present = 0;
10030 vl_api_l2tpv3_create_tunnel_t *mp;
10033 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10035 if (unformat (i, "client_address %U", unformat_ip6_address,
10037 client_address_set = 1;
10038 else if (unformat (i, "our_address %U", unformat_ip6_address,
10040 our_address_set = 1;
10041 else if (unformat (i, "local_session_id %d", &local_session_id))
10043 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10045 else if (unformat (i, "local_cookie %lld", &local_cookie))
10047 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10049 else if (unformat (i, "l2-sublayer-present"))
10050 l2_sublayer_present = 1;
10055 if (client_address_set == 0)
10057 errmsg ("client_address required");
10061 if (our_address_set == 0)
10063 errmsg ("our_address required");
10067 M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel);
10069 clib_memcpy (mp->client_address, client_address.as_u8,
10070 sizeof (mp->client_address));
10072 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10074 mp->local_session_id = ntohl (local_session_id);
10075 mp->remote_session_id = ntohl (remote_session_id);
10076 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10077 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10078 mp->l2_sublayer_present = l2_sublayer_present;
10088 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10090 unformat_input_t *i = vam->input;
10092 u8 sw_if_index_set = 0;
10093 u64 new_local_cookie = 0;
10094 u64 new_remote_cookie = 0;
10095 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10098 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10100 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10101 sw_if_index_set = 1;
10102 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10103 sw_if_index_set = 1;
10104 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10106 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10112 if (sw_if_index_set == 0)
10114 errmsg ("missing interface name or sw_if_index");
10118 M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies);
10120 mp->sw_if_index = ntohl (sw_if_index);
10121 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10122 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10131 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10133 unformat_input_t *i = vam->input;
10134 vl_api_l2tpv3_interface_enable_disable_t *mp;
10137 u8 sw_if_index_set = 0;
10138 u8 enable_disable = 1;
10140 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10142 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10143 sw_if_index_set = 1;
10144 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10145 sw_if_index_set = 1;
10146 else if (unformat (i, "enable"))
10147 enable_disable = 1;
10148 else if (unformat (i, "disable"))
10149 enable_disable = 0;
10154 if (sw_if_index_set == 0)
10156 errmsg ("missing interface name or sw_if_index");
10160 M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable);
10162 mp->sw_if_index = ntohl (sw_if_index);
10163 mp->enable_disable = enable_disable;
10172 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10174 unformat_input_t *i = vam->input;
10175 vl_api_l2tpv3_set_lookup_key_t *mp;
10179 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10181 if (unformat (i, "lookup_v6_src"))
10182 key = L2T_LOOKUP_SRC_ADDRESS;
10183 else if (unformat (i, "lookup_v6_dst"))
10184 key = L2T_LOOKUP_DST_ADDRESS;
10185 else if (unformat (i, "lookup_session_id"))
10186 key = L2T_LOOKUP_SESSION_ID;
10191 if (key == (u8) ~ 0)
10193 errmsg ("l2tp session lookup key unset");
10197 M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key);
10207 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10208 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10210 vat_main_t *vam = &vat_main;
10212 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10213 format_ip6_address, mp->our_address,
10214 format_ip6_address, mp->client_address,
10215 clib_net_to_host_u32 (mp->sw_if_index));
10218 " local cookies %016llx %016llx remote cookie %016llx",
10219 clib_net_to_host_u64 (mp->local_cookie[0]),
10220 clib_net_to_host_u64 (mp->local_cookie[1]),
10221 clib_net_to_host_u64 (mp->remote_cookie));
10223 print (vam->ofp, " local session-id %d remote session-id %d",
10224 clib_net_to_host_u32 (mp->local_session_id),
10225 clib_net_to_host_u32 (mp->remote_session_id));
10227 print (vam->ofp, " l2 specific sublayer %s\n",
10228 mp->l2_sublayer_present ? "preset" : "absent");
10232 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10233 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10235 vat_main_t *vam = &vat_main;
10236 vat_json_node_t *node = NULL;
10237 struct in6_addr addr;
10239 if (VAT_JSON_ARRAY != vam->json_tree.type)
10241 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10242 vat_json_init_array (&vam->json_tree);
10244 node = vat_json_array_add (&vam->json_tree);
10246 vat_json_init_object (node);
10248 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10249 vat_json_object_add_ip6 (node, "our_address", addr);
10250 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10251 vat_json_object_add_ip6 (node, "client_address", addr);
10253 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10254 vat_json_init_array (lc);
10255 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10256 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10257 vat_json_object_add_uint (node, "remote_cookie",
10258 clib_net_to_host_u64 (mp->remote_cookie));
10260 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10261 vat_json_object_add_uint (node, "local_session_id",
10262 clib_net_to_host_u32 (mp->local_session_id));
10263 vat_json_object_add_uint (node, "remote_session_id",
10264 clib_net_to_host_u32 (mp->remote_session_id));
10265 vat_json_object_add_string_copy (node, "l2_sublayer",
10266 mp->l2_sublayer_present ? (u8 *) "present"
10267 : (u8 *) "absent");
10271 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10273 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10276 /* Get list of l2tpv3-tunnel interfaces */
10277 M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump);
10280 /* Use a control ping for synchronization */
10282 vl_api_control_ping_t *mp;
10283 M (CONTROL_PING, control_ping);
10290 static void vl_api_sw_interface_tap_details_t_handler
10291 (vl_api_sw_interface_tap_details_t * mp)
10293 vat_main_t *vam = &vat_main;
10295 print (vam->ofp, "%-16s %d",
10296 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10299 static void vl_api_sw_interface_tap_details_t_handler_json
10300 (vl_api_sw_interface_tap_details_t * mp)
10302 vat_main_t *vam = &vat_main;
10303 vat_json_node_t *node = NULL;
10305 if (VAT_JSON_ARRAY != vam->json_tree.type)
10307 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10308 vat_json_init_array (&vam->json_tree);
10310 node = vat_json_array_add (&vam->json_tree);
10312 vat_json_init_object (node);
10313 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10314 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10318 api_sw_interface_tap_dump (vat_main_t * vam)
10320 vl_api_sw_interface_tap_dump_t *mp;
10323 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10324 /* Get list of tap interfaces */
10325 M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump);
10328 /* Use a control ping for synchronization */
10330 vl_api_control_ping_t *mp;
10331 M (CONTROL_PING, control_ping);
10337 static uword unformat_vxlan_decap_next
10338 (unformat_input_t * input, va_list * args)
10340 u32 *result = va_arg (*args, u32 *);
10343 if (unformat (input, "l2"))
10344 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10345 else if (unformat (input, "%d", &tmp))
10353 api_vxlan_add_del_tunnel (vat_main_t * vam)
10355 unformat_input_t *line_input = vam->input;
10356 vl_api_vxlan_add_del_tunnel_t *mp;
10358 ip46_address_t src, dst;
10360 u8 ipv4_set = 0, ipv6_set = 0;
10364 u32 mcast_sw_if_index = ~0;
10365 u32 encap_vrf_id = 0;
10366 u32 decap_next_index = ~0;
10369 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10370 memset (&src, 0, sizeof src);
10371 memset (&dst, 0, sizeof dst);
10373 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10375 if (unformat (line_input, "del"))
10378 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10384 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10390 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10396 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10401 else if (unformat (line_input, "group %U %U",
10402 unformat_ip4_address, &dst.ip4,
10403 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10405 grp_set = dst_set = 1;
10408 else if (unformat (line_input, "group %U",
10409 unformat_ip4_address, &dst.ip4))
10411 grp_set = dst_set = 1;
10414 else if (unformat (line_input, "group %U %U",
10415 unformat_ip6_address, &dst.ip6,
10416 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10418 grp_set = dst_set = 1;
10421 else if (unformat (line_input, "group %U",
10422 unformat_ip6_address, &dst.ip6))
10424 grp_set = dst_set = 1;
10428 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10430 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10432 else if (unformat (line_input, "decap-next %U",
10433 unformat_vxlan_decap_next, &decap_next_index))
10435 else if (unformat (line_input, "vni %d", &vni))
10439 errmsg ("parse error '%U'", format_unformat_error, line_input);
10446 errmsg ("tunnel src address not specified");
10451 errmsg ("tunnel dst address not specified");
10455 if (grp_set && !ip46_address_is_multicast (&dst))
10457 errmsg ("tunnel group address not multicast");
10460 if (grp_set && mcast_sw_if_index == ~0)
10462 errmsg ("tunnel nonexistent multicast device");
10465 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10467 errmsg ("tunnel dst address must be unicast");
10472 if (ipv4_set && ipv6_set)
10474 errmsg ("both IPv4 and IPv6 addresses specified");
10478 if ((vni == 0) || (vni >> 24))
10480 errmsg ("vni not specified or out of range");
10484 M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel);
10488 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10489 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10493 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10494 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10496 mp->encap_vrf_id = ntohl (encap_vrf_id);
10497 mp->decap_next_index = ntohl (decap_next_index);
10498 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10499 mp->vni = ntohl (vni);
10500 mp->is_add = is_add;
10501 mp->is_ipv6 = ipv6_set;
10509 static void vl_api_vxlan_tunnel_details_t_handler
10510 (vl_api_vxlan_tunnel_details_t * mp)
10512 vat_main_t *vam = &vat_main;
10513 ip46_address_t src, dst;
10515 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10516 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10518 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10519 ntohl (mp->sw_if_index),
10520 format_ip46_address, &src, IP46_TYPE_ANY,
10521 format_ip46_address, &dst, IP46_TYPE_ANY,
10522 ntohl (mp->encap_vrf_id),
10523 ntohl (mp->decap_next_index), ntohl (mp->vni),
10524 ntohl (mp->mcast_sw_if_index));
10527 static void vl_api_vxlan_tunnel_details_t_handler_json
10528 (vl_api_vxlan_tunnel_details_t * mp)
10530 vat_main_t *vam = &vat_main;
10531 vat_json_node_t *node = NULL;
10533 if (VAT_JSON_ARRAY != vam->json_tree.type)
10535 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10536 vat_json_init_array (&vam->json_tree);
10538 node = vat_json_array_add (&vam->json_tree);
10540 vat_json_init_object (node);
10541 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10544 struct in6_addr ip6;
10546 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10547 vat_json_object_add_ip6 (node, "src_address", ip6);
10548 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10549 vat_json_object_add_ip6 (node, "dst_address", ip6);
10553 struct in_addr ip4;
10555 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10556 vat_json_object_add_ip4 (node, "src_address", ip4);
10557 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10558 vat_json_object_add_ip4 (node, "dst_address", ip4);
10560 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10561 vat_json_object_add_uint (node, "decap_next_index",
10562 ntohl (mp->decap_next_index));
10563 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10564 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10565 vat_json_object_add_uint (node, "mcast_sw_if_index",
10566 ntohl (mp->mcast_sw_if_index));
10570 api_vxlan_tunnel_dump (vat_main_t * vam)
10572 unformat_input_t *i = vam->input;
10573 vl_api_vxlan_tunnel_dump_t *mp;
10576 u8 sw_if_index_set = 0;
10578 /* Parse args required to build the message */
10579 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10581 if (unformat (i, "sw_if_index %d", &sw_if_index))
10582 sw_if_index_set = 1;
10587 if (sw_if_index_set == 0)
10592 if (!vam->json_output)
10594 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10595 "sw_if_index", "src_address", "dst_address",
10596 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10599 /* Get list of vxlan-tunnel interfaces */
10600 M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
10602 mp->sw_if_index = htonl (sw_if_index);
10606 /* Use a control ping for synchronization */
10608 vl_api_control_ping_t *mp;
10609 M (CONTROL_PING, control_ping);
10616 api_gre_add_del_tunnel (vat_main_t * vam)
10618 unformat_input_t *line_input = vam->input;
10619 vl_api_gre_add_del_tunnel_t *mp;
10621 ip4_address_t src4, dst4;
10626 u32 outer_fib_id = 0;
10628 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10630 if (unformat (line_input, "del"))
10632 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10634 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10636 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10638 else if (unformat (line_input, "teb"))
10642 errmsg ("parse error '%U'", format_unformat_error, line_input);
10649 errmsg ("tunnel src address not specified");
10654 errmsg ("tunnel dst address not specified");
10659 M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel);
10661 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10662 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10663 mp->outer_fib_id = ntohl (outer_fib_id);
10664 mp->is_add = is_add;
10673 static void vl_api_gre_tunnel_details_t_handler
10674 (vl_api_gre_tunnel_details_t * mp)
10676 vat_main_t *vam = &vat_main;
10678 print (vam->ofp, "%11d%15U%15U%6d%14d",
10679 ntohl (mp->sw_if_index),
10680 format_ip4_address, &mp->src_address,
10681 format_ip4_address, &mp->dst_address,
10682 mp->teb, ntohl (mp->outer_fib_id));
10685 static void vl_api_gre_tunnel_details_t_handler_json
10686 (vl_api_gre_tunnel_details_t * mp)
10688 vat_main_t *vam = &vat_main;
10689 vat_json_node_t *node = NULL;
10690 struct in_addr ip4;
10692 if (VAT_JSON_ARRAY != vam->json_tree.type)
10694 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10695 vat_json_init_array (&vam->json_tree);
10697 node = vat_json_array_add (&vam->json_tree);
10699 vat_json_init_object (node);
10700 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10701 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10702 vat_json_object_add_ip4 (node, "src_address", ip4);
10703 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10704 vat_json_object_add_ip4 (node, "dst_address", ip4);
10705 vat_json_object_add_uint (node, "teb", mp->teb);
10706 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10710 api_gre_tunnel_dump (vat_main_t * vam)
10712 unformat_input_t *i = vam->input;
10713 vl_api_gre_tunnel_dump_t *mp;
10716 u8 sw_if_index_set = 0;
10718 /* Parse args required to build the message */
10719 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10721 if (unformat (i, "sw_if_index %d", &sw_if_index))
10722 sw_if_index_set = 1;
10727 if (sw_if_index_set == 0)
10732 if (!vam->json_output)
10734 print (vam->ofp, "%11s%15s%15s%6s%14s",
10735 "sw_if_index", "src_address", "dst_address", "teb",
10739 /* Get list of gre-tunnel interfaces */
10740 M (GRE_TUNNEL_DUMP, gre_tunnel_dump);
10742 mp->sw_if_index = htonl (sw_if_index);
10746 /* Use a control ping for synchronization */
10748 vl_api_control_ping_t *mp;
10749 M (CONTROL_PING, control_ping);
10756 api_l2_fib_clear_table (vat_main_t * vam)
10758 // unformat_input_t * i = vam->input;
10759 vl_api_l2_fib_clear_table_t *mp;
10762 M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table);
10771 api_l2_interface_efp_filter (vat_main_t * vam)
10773 unformat_input_t *i = vam->input;
10774 vl_api_l2_interface_efp_filter_t *mp;
10778 u8 sw_if_index_set = 0;
10780 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10782 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10783 sw_if_index_set = 1;
10784 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10785 sw_if_index_set = 1;
10786 else if (unformat (i, "enable"))
10788 else if (unformat (i, "disable"))
10792 clib_warning ("parse error '%U'", format_unformat_error, i);
10797 if (sw_if_index_set == 0)
10799 errmsg ("missing sw_if_index");
10803 M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter);
10805 mp->sw_if_index = ntohl (sw_if_index);
10806 mp->enable_disable = enable;
10814 #define foreach_vtr_op \
10815 _("disable", L2_VTR_DISABLED) \
10816 _("push-1", L2_VTR_PUSH_1) \
10817 _("push-2", L2_VTR_PUSH_2) \
10818 _("pop-1", L2_VTR_POP_1) \
10819 _("pop-2", L2_VTR_POP_2) \
10820 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10821 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10822 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10823 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10826 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10828 unformat_input_t *i = vam->input;
10829 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
10832 u8 sw_if_index_set = 0;
10835 u32 push_dot1q = 1;
10839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10841 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10842 sw_if_index_set = 1;
10843 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10844 sw_if_index_set = 1;
10845 else if (unformat (i, "vtr_op %d", &vtr_op))
10847 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
10850 else if (unformat (i, "push_dot1q %d", &push_dot1q))
10852 else if (unformat (i, "tag1 %d", &tag1))
10854 else if (unformat (i, "tag2 %d", &tag2))
10858 clib_warning ("parse error '%U'", format_unformat_error, i);
10863 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
10865 errmsg ("missing vtr operation or sw_if_index");
10869 M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)
10870 mp->sw_if_index = ntohl (sw_if_index);
10871 mp->vtr_op = ntohl (vtr_op);
10872 mp->push_dot1q = ntohl (push_dot1q);
10873 mp->tag1 = ntohl (tag1);
10874 mp->tag2 = ntohl (tag2);
10883 api_create_vhost_user_if (vat_main_t * vam)
10885 unformat_input_t *i = vam->input;
10886 vl_api_create_vhost_user_if_t *mp;
10890 u8 file_name_set = 0;
10891 u32 custom_dev_instance = ~0;
10893 u8 use_custom_mac = 0;
10896 /* Shut up coverity */
10897 memset (hwaddr, 0, sizeof (hwaddr));
10899 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10901 if (unformat (i, "socket %s", &file_name))
10905 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10907 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
10908 use_custom_mac = 1;
10909 else if (unformat (i, "server"))
10911 else if (unformat (i, "tag %s", &tag))
10917 if (file_name_set == 0)
10919 errmsg ("missing socket file name");
10923 if (vec_len (file_name) > 255)
10925 errmsg ("socket file name too long");
10928 vec_add1 (file_name, 0);
10930 M (CREATE_VHOST_USER_IF, create_vhost_user_if);
10932 mp->is_server = is_server;
10933 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10934 vec_free (file_name);
10935 if (custom_dev_instance != ~0)
10938 mp->custom_dev_instance = ntohl (custom_dev_instance);
10940 mp->use_custom_mac = use_custom_mac;
10941 clib_memcpy (mp->mac_address, hwaddr, 6);
10943 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
10953 api_modify_vhost_user_if (vat_main_t * vam)
10955 unformat_input_t *i = vam->input;
10956 vl_api_modify_vhost_user_if_t *mp;
10960 u8 file_name_set = 0;
10961 u32 custom_dev_instance = ~0;
10962 u8 sw_if_index_set = 0;
10963 u32 sw_if_index = (u32) ~ 0;
10965 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10967 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10968 sw_if_index_set = 1;
10969 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10970 sw_if_index_set = 1;
10971 else if (unformat (i, "socket %s", &file_name))
10975 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10977 else if (unformat (i, "server"))
10983 if (sw_if_index_set == 0)
10985 errmsg ("missing sw_if_index or interface name");
10989 if (file_name_set == 0)
10991 errmsg ("missing socket file name");
10995 if (vec_len (file_name) > 255)
10997 errmsg ("socket file name too long");
11000 vec_add1 (file_name, 0);
11002 M (MODIFY_VHOST_USER_IF, modify_vhost_user_if);
11004 mp->sw_if_index = ntohl (sw_if_index);
11005 mp->is_server = is_server;
11006 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
11007 vec_free (file_name);
11008 if (custom_dev_instance != ~0)
11011 mp->custom_dev_instance = ntohl (custom_dev_instance);
11021 api_delete_vhost_user_if (vat_main_t * vam)
11023 unformat_input_t *i = vam->input;
11024 vl_api_delete_vhost_user_if_t *mp;
11026 u32 sw_if_index = ~0;
11027 u8 sw_if_index_set = 0;
11029 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11031 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11032 sw_if_index_set = 1;
11033 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11034 sw_if_index_set = 1;
11039 if (sw_if_index_set == 0)
11041 errmsg ("missing sw_if_index or interface name");
11046 M (DELETE_VHOST_USER_IF, delete_vhost_user_if);
11048 mp->sw_if_index = ntohl (sw_if_index);
11056 static void vl_api_sw_interface_vhost_user_details_t_handler
11057 (vl_api_sw_interface_vhost_user_details_t * mp)
11059 vat_main_t *vam = &vat_main;
11061 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11062 (char *) mp->interface_name,
11063 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11064 clib_net_to_host_u64 (mp->features), mp->is_server,
11065 ntohl (mp->num_regions), (char *) mp->sock_filename);
11066 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11069 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11070 (vl_api_sw_interface_vhost_user_details_t * mp)
11072 vat_main_t *vam = &vat_main;
11073 vat_json_node_t *node = NULL;
11075 if (VAT_JSON_ARRAY != vam->json_tree.type)
11077 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11078 vat_json_init_array (&vam->json_tree);
11080 node = vat_json_array_add (&vam->json_tree);
11082 vat_json_init_object (node);
11083 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11084 vat_json_object_add_string_copy (node, "interface_name",
11085 mp->interface_name);
11086 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11087 ntohl (mp->virtio_net_hdr_sz));
11088 vat_json_object_add_uint (node, "features",
11089 clib_net_to_host_u64 (mp->features));
11090 vat_json_object_add_uint (node, "is_server", mp->is_server);
11091 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11092 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11093 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11097 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11099 vl_api_sw_interface_vhost_user_dump_t *mp;
11102 "Interface name idx hdr_sz features server regions filename");
11104 /* Get list of vhost-user interfaces */
11105 M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump);
11108 /* Use a control ping for synchronization */
11110 vl_api_control_ping_t *mp;
11111 M (CONTROL_PING, control_ping);
11118 api_show_version (vat_main_t * vam)
11120 vl_api_show_version_t *mp;
11123 M (SHOW_VERSION, show_version);
11133 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11135 unformat_input_t *line_input = vam->input;
11136 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11138 ip4_address_t local4, remote4;
11139 ip6_address_t local6, remote6;
11141 u8 ipv4_set = 0, ipv6_set = 0;
11144 u32 encap_vrf_id = 0;
11145 u32 decap_vrf_id = 0;
11150 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11152 if (unformat (line_input, "del"))
11154 else if (unformat (line_input, "local %U",
11155 unformat_ip4_address, &local4))
11160 else if (unformat (line_input, "remote %U",
11161 unformat_ip4_address, &remote4))
11166 else if (unformat (line_input, "local %U",
11167 unformat_ip6_address, &local6))
11172 else if (unformat (line_input, "remote %U",
11173 unformat_ip6_address, &remote6))
11178 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11180 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11182 else if (unformat (line_input, "vni %d", &vni))
11184 else if (unformat (line_input, "next-ip4"))
11186 else if (unformat (line_input, "next-ip6"))
11188 else if (unformat (line_input, "next-ethernet"))
11190 else if (unformat (line_input, "next-nsh"))
11194 errmsg ("parse error '%U'", format_unformat_error, line_input);
11199 if (local_set == 0)
11201 errmsg ("tunnel local address not specified");
11204 if (remote_set == 0)
11206 errmsg ("tunnel remote address not specified");
11209 if (ipv4_set && ipv6_set)
11211 errmsg ("both IPv4 and IPv6 addresses specified");
11217 errmsg ("vni not specified");
11221 M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel);
11226 clib_memcpy (&mp->local, &local6, sizeof (local6));
11227 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11231 clib_memcpy (&mp->local, &local4, sizeof (local4));
11232 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11235 mp->encap_vrf_id = ntohl (encap_vrf_id);
11236 mp->decap_vrf_id = ntohl (decap_vrf_id);
11237 mp->protocol = protocol;
11238 mp->vni = ntohl (vni);
11239 mp->is_add = is_add;
11240 mp->is_ipv6 = ipv6_set;
11248 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11249 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11251 vat_main_t *vam = &vat_main;
11253 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11254 ntohl (mp->sw_if_index),
11255 format_ip46_address, &(mp->local[0]),
11256 format_ip46_address, &(mp->remote[0]),
11258 ntohl (mp->protocol),
11259 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11262 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11263 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11265 vat_main_t *vam = &vat_main;
11266 vat_json_node_t *node = NULL;
11267 struct in_addr ip4;
11268 struct in6_addr ip6;
11270 if (VAT_JSON_ARRAY != vam->json_tree.type)
11272 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11273 vat_json_init_array (&vam->json_tree);
11275 node = vat_json_array_add (&vam->json_tree);
11277 vat_json_init_object (node);
11278 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11281 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11282 vat_json_object_add_ip6 (node, "local", ip6);
11283 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11284 vat_json_object_add_ip6 (node, "remote", ip6);
11288 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11289 vat_json_object_add_ip4 (node, "local", ip4);
11290 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11291 vat_json_object_add_ip4 (node, "remote", ip4);
11293 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11294 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11295 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11296 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11297 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11301 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11303 unformat_input_t *i = vam->input;
11304 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11307 u8 sw_if_index_set = 0;
11309 /* Parse args required to build the message */
11310 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11312 if (unformat (i, "sw_if_index %d", &sw_if_index))
11313 sw_if_index_set = 1;
11318 if (sw_if_index_set == 0)
11323 if (!vam->json_output)
11325 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11326 "sw_if_index", "local", "remote", "vni",
11327 "protocol", "encap_vrf_id", "decap_vrf_id");
11330 /* Get list of vxlan-tunnel interfaces */
11331 M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump);
11333 mp->sw_if_index = htonl (sw_if_index);
11337 /* Use a control ping for synchronization */
11339 vl_api_control_ping_t *mp;
11340 M (CONTROL_PING, control_ping);
11347 format_l2_fib_mac_address (u8 * s, va_list * args)
11349 u8 *a = va_arg (*args, u8 *);
11351 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11352 a[2], a[3], a[4], a[5], a[6], a[7]);
11355 static void vl_api_l2_fib_table_entry_t_handler
11356 (vl_api_l2_fib_table_entry_t * mp)
11358 vat_main_t *vam = &vat_main;
11360 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11362 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11363 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11367 static void vl_api_l2_fib_table_entry_t_handler_json
11368 (vl_api_l2_fib_table_entry_t * mp)
11370 vat_main_t *vam = &vat_main;
11371 vat_json_node_t *node = NULL;
11373 if (VAT_JSON_ARRAY != vam->json_tree.type)
11375 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11376 vat_json_init_array (&vam->json_tree);
11378 node = vat_json_array_add (&vam->json_tree);
11380 vat_json_init_object (node);
11381 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11382 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11383 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11384 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11385 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11386 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11390 api_l2_fib_table_dump (vat_main_t * vam)
11392 unformat_input_t *i = vam->input;
11393 vl_api_l2_fib_table_dump_t *mp;
11398 /* Parse args required to build the message */
11399 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11401 if (unformat (i, "bd_id %d", &bd_id))
11407 if (bd_id_set == 0)
11409 errmsg ("missing bridge domain");
11413 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11415 /* Get list of l2 fib entries */
11416 M (L2_FIB_TABLE_DUMP, l2_fib_table_dump);
11418 mp->bd_id = ntohl (bd_id);
11421 /* Use a control ping for synchronization */
11423 vl_api_control_ping_t *mp;
11424 M (CONTROL_PING, control_ping);
11432 api_interface_name_renumber (vat_main_t * vam)
11434 unformat_input_t *line_input = vam->input;
11435 vl_api_interface_name_renumber_t *mp;
11436 u32 sw_if_index = ~0;
11438 u32 new_show_dev_instance = ~0;
11440 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11442 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11445 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11447 else if (unformat (line_input, "new_show_dev_instance %d",
11448 &new_show_dev_instance))
11454 if (sw_if_index == ~0)
11456 errmsg ("missing interface name or sw_if_index");
11460 if (new_show_dev_instance == ~0)
11462 errmsg ("missing new_show_dev_instance");
11466 M (INTERFACE_NAME_RENUMBER, interface_name_renumber);
11468 mp->sw_if_index = ntohl (sw_if_index);
11469 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11476 api_want_ip4_arp_events (vat_main_t * vam)
11478 unformat_input_t *line_input = vam->input;
11479 vl_api_want_ip4_arp_events_t *mp;
11481 ip4_address_t address;
11482 int address_set = 0;
11483 u32 enable_disable = 1;
11485 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11487 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11489 else if (unformat (line_input, "del"))
11490 enable_disable = 0;
11495 if (address_set == 0)
11497 errmsg ("missing addresses");
11501 M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events);
11502 mp->enable_disable = enable_disable;
11503 mp->pid = getpid ();
11504 mp->address = address.as_u32;
11511 api_want_ip6_nd_events (vat_main_t * vam)
11513 unformat_input_t *line_input = vam->input;
11514 vl_api_want_ip6_nd_events_t *mp;
11516 ip6_address_t address;
11517 int address_set = 0;
11518 u32 enable_disable = 1;
11520 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11522 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11524 else if (unformat (line_input, "del"))
11525 enable_disable = 0;
11530 if (address_set == 0)
11532 errmsg ("missing addresses");
11536 M (WANT_IP6_ND_EVENTS, want_ip6_nd_events);
11537 mp->enable_disable = enable_disable;
11538 mp->pid = getpid ();
11539 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11546 api_input_acl_set_interface (vat_main_t * vam)
11548 unformat_input_t *i = vam->input;
11549 vl_api_input_acl_set_interface_t *mp;
11552 int sw_if_index_set;
11553 u32 ip4_table_index = ~0;
11554 u32 ip6_table_index = ~0;
11555 u32 l2_table_index = ~0;
11558 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11560 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11561 sw_if_index_set = 1;
11562 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11563 sw_if_index_set = 1;
11564 else if (unformat (i, "del"))
11566 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11568 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11570 else if (unformat (i, "l2-table %d", &l2_table_index))
11574 clib_warning ("parse error '%U'", format_unformat_error, i);
11579 if (sw_if_index_set == 0)
11581 errmsg ("missing interface name or sw_if_index");
11585 M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface);
11587 mp->sw_if_index = ntohl (sw_if_index);
11588 mp->ip4_table_index = ntohl (ip4_table_index);
11589 mp->ip6_table_index = ntohl (ip6_table_index);
11590 mp->l2_table_index = ntohl (l2_table_index);
11591 mp->is_add = is_add;
11600 api_ip_address_dump (vat_main_t * vam)
11602 unformat_input_t *i = vam->input;
11603 vl_api_ip_address_dump_t *mp;
11604 u32 sw_if_index = ~0;
11605 u8 sw_if_index_set = 0;
11610 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11612 if (unformat (i, "sw_if_index %d", &sw_if_index))
11613 sw_if_index_set = 1;
11615 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11616 sw_if_index_set = 1;
11617 else if (unformat (i, "ipv4"))
11619 else if (unformat (i, "ipv6"))
11625 if (ipv4_set && ipv6_set)
11627 errmsg ("ipv4 and ipv6 flags cannot be both set");
11631 if ((!ipv4_set) && (!ipv6_set))
11633 errmsg ("no ipv4 nor ipv6 flag set");
11637 if (sw_if_index_set == 0)
11639 errmsg ("missing interface name or sw_if_index");
11643 vam->current_sw_if_index = sw_if_index;
11644 vam->is_ipv6 = ipv6_set;
11646 M (IP_ADDRESS_DUMP, ip_address_dump);
11647 mp->sw_if_index = ntohl (sw_if_index);
11648 mp->is_ipv6 = ipv6_set;
11651 /* Use a control ping for synchronization */
11653 vl_api_control_ping_t *mp;
11654 M (CONTROL_PING, control_ping);
11661 api_ip_dump (vat_main_t * vam)
11663 vl_api_ip_dump_t *mp;
11664 unformat_input_t *in = vam->input;
11671 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11673 if (unformat (in, "ipv4"))
11675 else if (unformat (in, "ipv6"))
11681 if (ipv4_set && ipv6_set)
11683 errmsg ("ipv4 and ipv6 flags cannot be both set");
11687 if ((!ipv4_set) && (!ipv6_set))
11689 errmsg ("no ipv4 nor ipv6 flag set");
11693 is_ipv6 = ipv6_set;
11694 vam->is_ipv6 = is_ipv6;
11696 /* free old data */
11697 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11699 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11701 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11703 M (IP_DUMP, ip_dump);
11704 mp->is_ipv6 = ipv6_set;
11707 /* Use a control ping for synchronization */
11709 vl_api_control_ping_t *mp;
11710 M (CONTROL_PING, control_ping);
11717 api_ipsec_spd_add_del (vat_main_t * vam)
11719 unformat_input_t *i = vam->input;
11720 vl_api_ipsec_spd_add_del_t *mp;
11725 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11727 if (unformat (i, "spd_id %d", &spd_id))
11729 else if (unformat (i, "del"))
11733 clib_warning ("parse error '%U'", format_unformat_error, i);
11739 errmsg ("spd_id must be set");
11743 M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del);
11745 mp->spd_id = ntohl (spd_id);
11746 mp->is_add = is_add;
11755 api_ipsec_interface_add_del_spd (vat_main_t * vam)
11757 unformat_input_t *i = vam->input;
11758 vl_api_ipsec_interface_add_del_spd_t *mp;
11761 u8 sw_if_index_set = 0;
11762 u32 spd_id = (u32) ~ 0;
11765 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11767 if (unformat (i, "del"))
11769 else if (unformat (i, "spd_id %d", &spd_id))
11772 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11773 sw_if_index_set = 1;
11774 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11775 sw_if_index_set = 1;
11778 clib_warning ("parse error '%U'", format_unformat_error, i);
11784 if (spd_id == (u32) ~ 0)
11786 errmsg ("spd_id must be set");
11790 if (sw_if_index_set == 0)
11792 errmsg ("missing interface name or sw_if_index");
11796 M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd);
11798 mp->spd_id = ntohl (spd_id);
11799 mp->sw_if_index = ntohl (sw_if_index);
11800 mp->is_add = is_add;
11809 api_ipsec_spd_add_del_entry (vat_main_t * vam)
11811 unformat_input_t *i = vam->input;
11812 vl_api_ipsec_spd_add_del_entry_t *mp;
11814 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11815 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11817 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11818 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11819 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11820 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11822 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11823 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11824 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11825 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11826 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11827 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11829 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11831 if (unformat (i, "del"))
11833 if (unformat (i, "outbound"))
11835 if (unformat (i, "inbound"))
11837 else if (unformat (i, "spd_id %d", &spd_id))
11839 else if (unformat (i, "sa_id %d", &sa_id))
11841 else if (unformat (i, "priority %d", &priority))
11843 else if (unformat (i, "protocol %d", &protocol))
11845 else if (unformat (i, "lport_start %d", &lport_start))
11847 else if (unformat (i, "lport_stop %d", &lport_stop))
11849 else if (unformat (i, "rport_start %d", &rport_start))
11851 else if (unformat (i, "rport_stop %d", &rport_stop))
11855 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
11861 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
11868 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
11874 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
11881 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
11887 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
11894 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
11900 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
11906 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
11908 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
11910 clib_warning ("unsupported action: 'resolve'");
11916 clib_warning ("parse error '%U'", format_unformat_error, i);
11922 M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry);
11924 mp->spd_id = ntohl (spd_id);
11925 mp->priority = ntohl (priority);
11926 mp->is_outbound = is_outbound;
11928 mp->is_ipv6 = is_ipv6;
11929 if (is_ipv6 || is_ip_any)
11931 clib_memcpy (mp->remote_address_start, &raddr6_start,
11932 sizeof (ip6_address_t));
11933 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
11934 sizeof (ip6_address_t));
11935 clib_memcpy (mp->local_address_start, &laddr6_start,
11936 sizeof (ip6_address_t));
11937 clib_memcpy (mp->local_address_stop, &laddr6_stop,
11938 sizeof (ip6_address_t));
11942 clib_memcpy (mp->remote_address_start, &raddr4_start,
11943 sizeof (ip4_address_t));
11944 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
11945 sizeof (ip4_address_t));
11946 clib_memcpy (mp->local_address_start, &laddr4_start,
11947 sizeof (ip4_address_t));
11948 clib_memcpy (mp->local_address_stop, &laddr4_stop,
11949 sizeof (ip4_address_t));
11951 mp->protocol = (u8) protocol;
11952 mp->local_port_start = ntohs ((u16) lport_start);
11953 mp->local_port_stop = ntohs ((u16) lport_stop);
11954 mp->remote_port_start = ntohs ((u16) rport_start);
11955 mp->remote_port_stop = ntohs ((u16) rport_stop);
11956 mp->policy = (u8) policy;
11957 mp->sa_id = ntohl (sa_id);
11958 mp->is_add = is_add;
11959 mp->is_ip_any = is_ip_any;
11967 api_ipsec_sad_add_del_entry (vat_main_t * vam)
11969 unformat_input_t *i = vam->input;
11970 vl_api_ipsec_sad_add_del_entry_t *mp;
11972 u32 sad_id = 0, spi = 0;
11973 u8 *ck = 0, *ik = 0;
11976 u8 protocol = IPSEC_PROTOCOL_AH;
11977 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
11978 u32 crypto_alg = 0, integ_alg = 0;
11979 ip4_address_t tun_src4;
11980 ip4_address_t tun_dst4;
11981 ip6_address_t tun_src6;
11982 ip6_address_t tun_dst6;
11984 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11986 if (unformat (i, "del"))
11988 else if (unformat (i, "sad_id %d", &sad_id))
11990 else if (unformat (i, "spi %d", &spi))
11992 else if (unformat (i, "esp"))
11993 protocol = IPSEC_PROTOCOL_ESP;
11994 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
11997 is_tunnel_ipv6 = 0;
11999 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
12002 is_tunnel_ipv6 = 0;
12004 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
12007 is_tunnel_ipv6 = 1;
12009 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
12012 is_tunnel_ipv6 = 1;
12016 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
12018 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
12019 crypto_alg >= IPSEC_CRYPTO_N_ALG)
12021 clib_warning ("unsupported crypto-alg: '%U'",
12022 format_ipsec_crypto_alg, crypto_alg);
12026 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12030 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12033 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
12035 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12037 integ_alg >= IPSEC_INTEG_N_ALG)
12039 clib_warning ("unsupported integ-alg: '%U'",
12040 format_ipsec_integ_alg, integ_alg);
12044 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12048 clib_warning ("parse error '%U'", format_unformat_error, i);
12055 /*Special cases, aes-gcm-128 encryption */
12056 if (crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128)
12058 if (integ_alg != IPSEC_INTEG_ALG_NONE
12059 && integ_alg != IPSEC_INTEG_ALG_AES_GCM_128)
12062 ("unsupported: aes-gcm-128 crypto-alg needs none as integ-alg");
12065 else /*set integ-alg internally to aes-gcm-128 */
12066 integ_alg = IPSEC_INTEG_ALG_AES_GCM_128;
12068 else if (integ_alg == IPSEC_INTEG_ALG_AES_GCM_128)
12070 clib_warning ("unsupported integ-alg: aes-gcm-128");
12073 else if (integ_alg == IPSEC_INTEG_ALG_NONE)
12075 clib_warning ("unsupported integ-alg: none");
12081 M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
12083 mp->sad_id = ntohl (sad_id);
12084 mp->is_add = is_add;
12085 mp->protocol = protocol;
12086 mp->spi = ntohl (spi);
12087 mp->is_tunnel = is_tunnel;
12088 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12089 mp->crypto_algorithm = crypto_alg;
12090 mp->integrity_algorithm = integ_alg;
12091 mp->crypto_key_length = vec_len (ck);
12092 mp->integrity_key_length = vec_len (ik);
12094 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12095 mp->crypto_key_length = sizeof (mp->crypto_key);
12097 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12098 mp->integrity_key_length = sizeof (mp->integrity_key);
12101 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12103 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12107 if (is_tunnel_ipv6)
12109 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12110 sizeof (ip6_address_t));
12111 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12112 sizeof (ip6_address_t));
12116 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12117 sizeof (ip4_address_t));
12118 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12119 sizeof (ip4_address_t));
12130 api_ipsec_sa_set_key (vat_main_t * vam)
12132 unformat_input_t *i = vam->input;
12133 vl_api_ipsec_sa_set_key_t *mp;
12136 u8 *ck = 0, *ik = 0;
12138 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12140 if (unformat (i, "sa_id %d", &sa_id))
12142 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12144 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12148 clib_warning ("parse error '%U'", format_unformat_error, i);
12153 M (IPSEC_SA_SET_KEY, ipsec_set_sa_key);
12155 mp->sa_id = ntohl (sa_id);
12156 mp->crypto_key_length = vec_len (ck);
12157 mp->integrity_key_length = vec_len (ik);
12159 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12160 mp->crypto_key_length = sizeof (mp->crypto_key);
12162 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12163 mp->integrity_key_length = sizeof (mp->integrity_key);
12166 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12168 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12177 api_ikev2_profile_add_del (vat_main_t * vam)
12179 unformat_input_t *i = vam->input;
12180 vl_api_ikev2_profile_add_del_t *mp;
12185 const char *valid_chars = "a-zA-Z0-9_";
12187 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12189 if (unformat (i, "del"))
12191 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12192 vec_add1 (name, 0);
12195 errmsg ("parse error '%U'", format_unformat_error, i);
12200 if (!vec_len (name))
12202 errmsg ("profile name must be specified");
12206 if (vec_len (name) > 64)
12208 errmsg ("profile name too long");
12212 M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del);
12214 clib_memcpy (mp->name, name, vec_len (name));
12215 mp->is_add = is_add;
12225 api_ikev2_profile_set_auth (vat_main_t * vam)
12227 unformat_input_t *i = vam->input;
12228 vl_api_ikev2_profile_set_auth_t *mp;
12232 u32 auth_method = 0;
12235 const char *valid_chars = "a-zA-Z0-9_";
12237 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12239 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12240 vec_add1 (name, 0);
12241 else if (unformat (i, "auth_method %U",
12242 unformat_ikev2_auth_method, &auth_method))
12244 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12246 else if (unformat (i, "auth_data %v", &data))
12250 errmsg ("parse error '%U'", format_unformat_error, i);
12255 if (!vec_len (name))
12257 errmsg ("profile name must be specified");
12261 if (vec_len (name) > 64)
12263 errmsg ("profile name too long");
12267 if (!vec_len (data))
12269 errmsg ("auth_data must be specified");
12275 errmsg ("auth_method must be specified");
12279 M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth);
12281 mp->is_hex = is_hex;
12282 mp->auth_method = (u8) auth_method;
12283 mp->data_len = vec_len (data);
12284 clib_memcpy (mp->name, name, vec_len (name));
12285 clib_memcpy (mp->data, data, vec_len (data));
12296 api_ikev2_profile_set_id (vat_main_t * vam)
12298 unformat_input_t *i = vam->input;
12299 vl_api_ikev2_profile_set_id_t *mp;
12307 const char *valid_chars = "a-zA-Z0-9_";
12309 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12311 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12312 vec_add1 (name, 0);
12313 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12315 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12317 data = vec_new (u8, 4);
12318 clib_memcpy (data, ip4.as_u8, 4);
12320 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12322 else if (unformat (i, "id_data %v", &data))
12324 else if (unformat (i, "local"))
12326 else if (unformat (i, "remote"))
12330 errmsg ("parse error '%U'", format_unformat_error, i);
12335 if (!vec_len (name))
12337 errmsg ("profile name must be specified");
12341 if (vec_len (name) > 64)
12343 errmsg ("profile name too long");
12347 if (!vec_len (data))
12349 errmsg ("id_data must be specified");
12355 errmsg ("id_type must be specified");
12359 M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id);
12361 mp->is_local = is_local;
12362 mp->id_type = (u8) id_type;
12363 mp->data_len = vec_len (data);
12364 clib_memcpy (mp->name, name, vec_len (name));
12365 clib_memcpy (mp->data, data, vec_len (data));
12376 api_ikev2_profile_set_ts (vat_main_t * vam)
12378 unformat_input_t *i = vam->input;
12379 vl_api_ikev2_profile_set_ts_t *mp;
12383 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12384 ip4_address_t start_addr, end_addr;
12386 const char *valid_chars = "a-zA-Z0-9_";
12388 start_addr.as_u32 = 0;
12389 end_addr.as_u32 = (u32) ~ 0;
12391 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12393 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12394 vec_add1 (name, 0);
12395 else if (unformat (i, "protocol %d", &proto))
12397 else if (unformat (i, "start_port %d", &start_port))
12399 else if (unformat (i, "end_port %d", &end_port))
12402 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12404 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12406 else if (unformat (i, "local"))
12408 else if (unformat (i, "remote"))
12412 errmsg ("parse error '%U'", format_unformat_error, i);
12417 if (!vec_len (name))
12419 errmsg ("profile name must be specified");
12423 if (vec_len (name) > 64)
12425 errmsg ("profile name too long");
12429 M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts);
12431 mp->is_local = is_local;
12432 mp->proto = (u8) proto;
12433 mp->start_port = (u16) start_port;
12434 mp->end_port = (u16) end_port;
12435 mp->start_addr = start_addr.as_u32;
12436 mp->end_addr = end_addr.as_u32;
12437 clib_memcpy (mp->name, name, vec_len (name));
12447 api_ikev2_set_local_key (vat_main_t * vam)
12449 unformat_input_t *i = vam->input;
12450 vl_api_ikev2_set_local_key_t *mp;
12454 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12456 if (unformat (i, "file %v", &file))
12457 vec_add1 (file, 0);
12460 errmsg ("parse error '%U'", format_unformat_error, i);
12465 if (!vec_len (file))
12467 errmsg ("RSA key file must be specified");
12471 if (vec_len (file) > 256)
12473 errmsg ("file name too long");
12477 M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key);
12479 clib_memcpy (mp->key_file, file, vec_len (file));
12492 api_map_add_domain (vat_main_t * vam)
12494 unformat_input_t *i = vam->input;
12495 vl_api_map_add_domain_t *mp;
12498 ip4_address_t ip4_prefix;
12499 ip6_address_t ip6_prefix;
12500 ip6_address_t ip6_src;
12501 u32 num_m_args = 0;
12502 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12503 0, psid_length = 0;
12504 u8 is_translation = 0;
12506 u32 ip6_src_len = 128;
12508 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12510 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12511 &ip4_prefix, &ip4_prefix_len))
12513 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12514 &ip6_prefix, &ip6_prefix_len))
12518 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12521 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12523 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12525 else if (unformat (i, "psid-offset %d", &psid_offset))
12527 else if (unformat (i, "psid-len %d", &psid_length))
12529 else if (unformat (i, "mtu %d", &mtu))
12531 else if (unformat (i, "map-t"))
12532 is_translation = 1;
12535 clib_warning ("parse error '%U'", format_unformat_error, i);
12540 if (num_m_args < 3)
12542 errmsg ("mandatory argument(s) missing");
12546 /* Construct the API message */
12547 M (MAP_ADD_DOMAIN, map_add_domain);
12549 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12550 mp->ip4_prefix_len = ip4_prefix_len;
12552 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12553 mp->ip6_prefix_len = ip6_prefix_len;
12555 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12556 mp->ip6_src_prefix_len = ip6_src_len;
12558 mp->ea_bits_len = ea_bits_len;
12559 mp->psid_offset = psid_offset;
12560 mp->psid_length = psid_length;
12561 mp->is_translation = is_translation;
12562 mp->mtu = htons (mtu);
12567 /* Wait for a reply, return good/bad news */
12572 api_map_del_domain (vat_main_t * vam)
12574 unformat_input_t *i = vam->input;
12575 vl_api_map_del_domain_t *mp;
12578 u32 num_m_args = 0;
12581 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12583 if (unformat (i, "index %d", &index))
12587 clib_warning ("parse error '%U'", format_unformat_error, i);
12592 if (num_m_args != 1)
12594 errmsg ("mandatory argument(s) missing");
12598 /* Construct the API message */
12599 M (MAP_DEL_DOMAIN, map_del_domain);
12601 mp->index = ntohl (index);
12606 /* Wait for a reply, return good/bad news */
12611 api_map_add_del_rule (vat_main_t * vam)
12613 unformat_input_t *i = vam->input;
12614 vl_api_map_add_del_rule_t *mp;
12617 ip6_address_t ip6_dst;
12618 u32 num_m_args = 0, index, psid = 0;
12620 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12622 if (unformat (i, "index %d", &index))
12624 else if (unformat (i, "psid %d", &psid))
12626 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
12628 else if (unformat (i, "del"))
12634 clib_warning ("parse error '%U'", format_unformat_error, i);
12639 /* Construct the API message */
12640 M (MAP_ADD_DEL_RULE, map_add_del_rule);
12642 mp->index = ntohl (index);
12643 mp->is_add = is_add;
12644 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
12645 mp->psid = ntohs (psid);
12650 /* Wait for a reply, return good/bad news */
12655 api_map_domain_dump (vat_main_t * vam)
12657 vl_api_map_domain_dump_t *mp;
12660 /* Construct the API message */
12661 M (MAP_DOMAIN_DUMP, map_domain_dump);
12666 /* Use a control ping for synchronization */
12668 vl_api_control_ping_t *mp;
12669 M (CONTROL_PING, control_ping);
12676 api_map_rule_dump (vat_main_t * vam)
12678 unformat_input_t *i = vam->input;
12679 vl_api_map_rule_dump_t *mp;
12681 u32 domain_index = ~0;
12683 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12685 if (unformat (i, "index %u", &domain_index))
12691 if (domain_index == ~0)
12693 clib_warning ("parse error: domain index expected");
12697 /* Construct the API message */
12698 M (MAP_RULE_DUMP, map_rule_dump);
12700 mp->domain_index = htonl (domain_index);
12705 /* Use a control ping for synchronization */
12707 vl_api_control_ping_t *mp;
12708 M (CONTROL_PING, control_ping);
12714 static void vl_api_map_add_domain_reply_t_handler
12715 (vl_api_map_add_domain_reply_t * mp)
12717 vat_main_t *vam = &vat_main;
12718 i32 retval = ntohl (mp->retval);
12720 if (vam->async_mode)
12722 vam->async_errors += (retval < 0);
12726 vam->retval = retval;
12727 vam->result_ready = 1;
12731 static void vl_api_map_add_domain_reply_t_handler_json
12732 (vl_api_map_add_domain_reply_t * mp)
12734 vat_main_t *vam = &vat_main;
12735 vat_json_node_t node;
12737 vat_json_init_object (&node);
12738 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
12739 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
12741 vat_json_print (vam->ofp, &node);
12742 vat_json_free (&node);
12744 vam->retval = ntohl (mp->retval);
12745 vam->result_ready = 1;
12749 api_get_first_msg_id (vat_main_t * vam)
12751 vl_api_get_first_msg_id_t *mp;
12753 unformat_input_t *i = vam->input;
12757 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12759 if (unformat (i, "client %s", &name))
12767 errmsg ("missing client name");
12770 vec_add1 (name, 0);
12772 if (vec_len (name) > 63)
12774 errmsg ("client name too long");
12778 M (GET_FIRST_MSG_ID, get_first_msg_id);
12779 clib_memcpy (mp->name, name, vec_len (name));
12787 api_cop_interface_enable_disable (vat_main_t * vam)
12789 unformat_input_t *line_input = vam->input;
12790 vl_api_cop_interface_enable_disable_t *mp;
12792 u32 sw_if_index = ~0;
12793 u8 enable_disable = 1;
12795 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12797 if (unformat (line_input, "disable"))
12798 enable_disable = 0;
12799 if (unformat (line_input, "enable"))
12800 enable_disable = 1;
12801 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
12802 vam, &sw_if_index))
12804 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12810 if (sw_if_index == ~0)
12812 errmsg ("missing interface name or sw_if_index");
12816 /* Construct the API message */
12817 M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable);
12818 mp->sw_if_index = ntohl (sw_if_index);
12819 mp->enable_disable = enable_disable;
12823 /* Wait for the reply */
12828 api_cop_whitelist_enable_disable (vat_main_t * vam)
12830 unformat_input_t *line_input = vam->input;
12831 vl_api_cop_whitelist_enable_disable_t *mp;
12833 u32 sw_if_index = ~0;
12834 u8 ip4 = 0, ip6 = 0, default_cop = 0;
12837 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12839 if (unformat (line_input, "ip4"))
12841 else if (unformat (line_input, "ip6"))
12843 else if (unformat (line_input, "default"))
12845 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
12846 vam, &sw_if_index))
12848 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12850 else if (unformat (line_input, "fib-id %d", &fib_id))
12856 if (sw_if_index == ~0)
12858 errmsg ("missing interface name or sw_if_index");
12862 /* Construct the API message */
12863 M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable);
12864 mp->sw_if_index = ntohl (sw_if_index);
12865 mp->fib_id = ntohl (fib_id);
12868 mp->default_cop = default_cop;
12872 /* Wait for the reply */
12877 api_get_node_graph (vat_main_t * vam)
12879 vl_api_get_node_graph_t *mp;
12882 M (GET_NODE_GRAPH, get_node_graph);
12886 /* Wait for the reply */
12891 /** Used for parsing LISP eids */
12892 typedef CLIB_PACKED(struct{
12893 u8 addr[16]; /**< eid address */
12894 u32 len; /**< prefix length if IP */
12895 u8 type; /**< type of eid */
12900 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
12902 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
12904 memset (a, 0, sizeof (a[0]));
12906 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
12908 a->type = 0; /* ipv4 type */
12910 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
12912 a->type = 1; /* ipv6 type */
12914 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
12916 a->type = 2; /* mac type */
12923 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
12932 lisp_eid_size_vat (u8 type)
12947 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
12949 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
12953 /** Used for transferring locators via VPP API */
12954 typedef CLIB_PACKED(struct
12956 u32 sw_if_index; /**< locator sw_if_index */
12957 u8 priority; /**< locator priority */
12958 u8 weight; /**< locator weight */
12963 api_lisp_add_del_locator_set (vat_main_t * vam)
12965 unformat_input_t *input = vam->input;
12966 vl_api_lisp_add_del_locator_set_t *mp;
12969 u8 *locator_set_name = NULL;
12970 u8 locator_set_name_set = 0;
12971 ls_locator_t locator, *locators = 0;
12972 u32 sw_if_index, priority, weight;
12975 /* Parse args required to build the message */
12976 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12978 if (unformat (input, "del"))
12982 else if (unformat (input, "locator-set %s", &locator_set_name))
12984 locator_set_name_set = 1;
12986 else if (unformat (input, "sw_if_index %u p %u w %u",
12987 &sw_if_index, &priority, &weight))
12989 locator.sw_if_index = htonl (sw_if_index);
12990 locator.priority = priority;
12991 locator.weight = weight;
12992 vec_add1 (locators, locator);
12996 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
12997 &sw_if_index, &priority, &weight))
12999 locator.sw_if_index = htonl (sw_if_index);
13000 locator.priority = priority;
13001 locator.weight = weight;
13002 vec_add1 (locators, locator);
13008 if (locator_set_name_set == 0)
13010 errmsg ("missing locator-set name");
13011 vec_free (locators);
13015 if (vec_len (locator_set_name) > 64)
13017 errmsg ("locator-set name too long");
13018 vec_free (locator_set_name);
13019 vec_free (locators);
13022 vec_add1 (locator_set_name, 0);
13024 data_len = sizeof (ls_locator_t) * vec_len (locators);
13026 /* Construct the API message */
13027 M2 (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set, data_len);
13029 mp->is_add = is_add;
13030 clib_memcpy (mp->locator_set_name, locator_set_name,
13031 vec_len (locator_set_name));
13032 vec_free (locator_set_name);
13034 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13036 clib_memcpy (mp->locators, locators, data_len);
13037 vec_free (locators);
13042 /* Wait for a reply... */
13050 api_lisp_add_del_locator (vat_main_t * vam)
13052 unformat_input_t *input = vam->input;
13053 vl_api_lisp_add_del_locator_t *mp;
13055 u32 tmp_if_index = ~0;
13056 u32 sw_if_index = ~0;
13057 u8 sw_if_index_set = 0;
13058 u8 sw_if_index_if_name_set = 0;
13060 u8 priority_set = 0;
13064 u8 *locator_set_name = NULL;
13065 u8 locator_set_name_set = 0;
13067 /* Parse args required to build the message */
13068 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13070 if (unformat (input, "del"))
13074 else if (unformat (input, "locator-set %s", &locator_set_name))
13076 locator_set_name_set = 1;
13078 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13081 sw_if_index_if_name_set = 1;
13082 sw_if_index = tmp_if_index;
13084 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13086 sw_if_index_set = 1;
13087 sw_if_index = tmp_if_index;
13089 else if (unformat (input, "p %d", &priority))
13093 else if (unformat (input, "w %d", &weight))
13101 if (locator_set_name_set == 0)
13103 errmsg ("missing locator-set name");
13107 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13109 errmsg ("missing sw_if_index");
13110 vec_free (locator_set_name);
13114 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13116 errmsg ("cannot use both params interface name and sw_if_index");
13117 vec_free (locator_set_name);
13121 if (priority_set == 0)
13123 errmsg ("missing locator-set priority");
13124 vec_free (locator_set_name);
13128 if (weight_set == 0)
13130 errmsg ("missing locator-set weight");
13131 vec_free (locator_set_name);
13135 if (vec_len (locator_set_name) > 64)
13137 errmsg ("locator-set name too long");
13138 vec_free (locator_set_name);
13141 vec_add1 (locator_set_name, 0);
13143 /* Construct the API message */
13144 M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
13146 mp->is_add = is_add;
13147 mp->sw_if_index = ntohl (sw_if_index);
13148 mp->priority = priority;
13149 mp->weight = weight;
13150 clib_memcpy (mp->locator_set_name, locator_set_name,
13151 vec_len (locator_set_name));
13152 vec_free (locator_set_name);
13157 /* Wait for a reply... */
13165 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13167 u32 *key_id = va_arg (*args, u32 *);
13170 if (unformat (input, "%s", &s))
13172 if (!strcmp ((char *) s, "sha1"))
13173 key_id[0] = HMAC_SHA_1_96;
13174 else if (!strcmp ((char *) s, "sha256"))
13175 key_id[0] = HMAC_SHA_256_128;
13178 clib_warning ("invalid key_id: '%s'", s);
13179 key_id[0] = HMAC_NO_KEY;
13190 api_lisp_add_del_local_eid (vat_main_t * vam)
13192 unformat_input_t *input = vam->input;
13193 vl_api_lisp_add_del_local_eid_t *mp;
13197 lisp_eid_vat_t _eid, *eid = &_eid;
13198 u8 *locator_set_name = 0;
13199 u8 locator_set_name_set = 0;
13204 /* Parse args required to build the message */
13205 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13207 if (unformat (input, "del"))
13211 else if (unformat (input, "vni %d", &vni))
13215 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13219 else if (unformat (input, "locator-set %s", &locator_set_name))
13221 locator_set_name_set = 1;
13223 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13225 else if (unformat (input, "secret-key %_%v%_", &key))
13231 if (locator_set_name_set == 0)
13233 errmsg ("missing locator-set name");
13239 errmsg ("EID address not set!");
13240 vec_free (locator_set_name);
13244 if (key && (0 == key_id))
13246 errmsg ("invalid key_id!");
13250 if (vec_len (key) > 64)
13252 errmsg ("key too long");
13257 if (vec_len (locator_set_name) > 64)
13259 errmsg ("locator-set name too long");
13260 vec_free (locator_set_name);
13263 vec_add1 (locator_set_name, 0);
13265 /* Construct the API message */
13266 M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
13268 mp->is_add = is_add;
13269 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13270 mp->eid_type = eid->type;
13271 mp->prefix_len = eid->len;
13272 mp->vni = clib_host_to_net_u32 (vni);
13273 mp->key_id = clib_host_to_net_u16 (key_id);
13274 clib_memcpy (mp->locator_set_name, locator_set_name,
13275 vec_len (locator_set_name));
13276 clib_memcpy (mp->key, key, vec_len (key));
13278 vec_free (locator_set_name);
13284 /* Wait for a reply... */
13292 /** Used for transferring locators via VPP API */
13293 typedef CLIB_PACKED(struct
13295 u8 is_ip4; /**< is locator an IPv4 address? */
13296 u8 priority; /**< locator priority */
13297 u8 weight; /**< locator weight */
13298 u8 addr[16]; /**< IPv4/IPv6 address */
13303 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13305 u32 dp_table = 0, vni = 0;;
13306 unformat_input_t *input = vam->input;
13307 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
13310 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13311 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13312 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13313 u32 action = ~0, w;
13314 ip4_address_t rmt_rloc4, lcl_rloc4;
13315 ip6_address_t rmt_rloc6, lcl_rloc6;
13316 vl_api_lisp_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc =
13319 memset (&rloc, 0, sizeof (rloc));
13321 /* Parse args required to build the message */
13322 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13324 if (unformat (input, "del"))
13326 else if (unformat (input, "add"))
13328 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
13332 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
13336 else if (unformat (input, "vrf %d", &dp_table))
13338 else if (unformat (input, "bd %d", &dp_table))
13340 else if (unformat (input, "vni %d", &vni))
13342 else if (unformat (input, "w %d", &w))
13346 errmsg ("No RLOC configured for setting priority/weight!");
13349 curr_rloc->weight = w;
13351 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13352 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13356 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13358 vec_add1 (lcl_locs, rloc);
13360 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13361 vec_add1 (rmt_locs, rloc);
13362 /* weight saved in rmt loc */
13363 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13365 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13366 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13369 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13371 vec_add1 (lcl_locs, rloc);
13373 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13374 vec_add1 (rmt_locs, rloc);
13375 /* weight saved in rmt loc */
13376 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13378 else if (unformat (input, "action %d", &action))
13384 clib_warning ("parse error '%U'", format_unformat_error, input);
13391 errmsg ("remote eid addresses not set");
13395 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13397 errmsg ("eid types don't match");
13401 if (0 == rmt_locs && (u32) ~ 0 == action)
13403 errmsg ("action not set for negative mapping");
13407 /* Construct the API message */
13408 M2 (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry,
13409 sizeof (vl_api_lisp_gpe_locator_t) * vec_len (rmt_locs) * 2);
13411 mp->is_add = is_add;
13412 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13413 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13414 mp->eid_type = rmt_eid->type;
13415 mp->dp_table = clib_host_to_net_u32 (dp_table);
13416 mp->vni = clib_host_to_net_u32 (vni);
13417 mp->rmt_len = rmt_eid->len;
13418 mp->lcl_len = lcl_eid->len;
13419 mp->action = action;
13421 if (0 != rmt_locs && 0 != lcl_locs)
13423 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
13424 clib_memcpy (mp->locs, lcl_locs,
13425 (sizeof (vl_api_lisp_gpe_locator_t) * vec_len (lcl_locs)));
13427 u32 offset = sizeof (vl_api_lisp_gpe_locator_t) * vec_len (lcl_locs);
13428 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
13429 (sizeof (vl_api_lisp_gpe_locator_t) * vec_len (rmt_locs)));
13431 vec_free (lcl_locs);
13432 vec_free (rmt_locs);
13437 /* Wait for a reply... */
13445 api_lisp_add_del_map_server (vat_main_t * vam)
13447 unformat_input_t *input = vam->input;
13448 vl_api_lisp_add_del_map_server_t *mp;
13453 ip4_address_t ipv4;
13454 ip6_address_t ipv6;
13456 /* Parse args required to build the message */
13457 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13459 if (unformat (input, "del"))
13463 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13467 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13475 if (ipv4_set && ipv6_set)
13477 errmsg ("both eid v4 and v6 addresses set");
13481 if (!ipv4_set && !ipv6_set)
13483 errmsg ("eid addresses not set");
13487 /* Construct the API message */
13488 M (LISP_ADD_DEL_MAP_SERVER, lisp_add_del_map_server);
13490 mp->is_add = is_add;
13494 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13499 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13505 /* Wait for a reply... */
13513 api_lisp_add_del_map_resolver (vat_main_t * vam)
13515 unformat_input_t *input = vam->input;
13516 vl_api_lisp_add_del_map_resolver_t *mp;
13521 ip4_address_t ipv4;
13522 ip6_address_t ipv6;
13524 /* Parse args required to build the message */
13525 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13527 if (unformat (input, "del"))
13531 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13535 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13543 if (ipv4_set && ipv6_set)
13545 errmsg ("both eid v4 and v6 addresses set");
13549 if (!ipv4_set && !ipv6_set)
13551 errmsg ("eid addresses not set");
13555 /* Construct the API message */
13556 M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
13558 mp->is_add = is_add;
13562 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13567 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13573 /* Wait for a reply... */
13581 api_lisp_gpe_enable_disable (vat_main_t * vam)
13583 unformat_input_t *input = vam->input;
13584 vl_api_lisp_gpe_enable_disable_t *mp;
13589 /* Parse args required to build the message */
13590 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13592 if (unformat (input, "enable"))
13597 else if (unformat (input, "disable"))
13608 errmsg ("Value not set");
13612 /* Construct the API message */
13613 M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
13620 /* Wait for a reply... */
13628 api_lisp_rloc_probe_enable_disable (vat_main_t * vam)
13630 unformat_input_t *input = vam->input;
13631 vl_api_lisp_rloc_probe_enable_disable_t *mp;
13636 /* Parse args required to build the message */
13637 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13639 if (unformat (input, "enable"))
13644 else if (unformat (input, "disable"))
13652 errmsg ("Value not set");
13656 /* Construct the API message */
13657 M (LISP_RLOC_PROBE_ENABLE_DISABLE, lisp_rloc_probe_enable_disable);
13659 mp->is_enabled = is_en;
13664 /* Wait for a reply... */
13672 api_lisp_map_register_enable_disable (vat_main_t * vam)
13674 unformat_input_t *input = vam->input;
13675 vl_api_lisp_map_register_enable_disable_t *mp;
13680 /* Parse args required to build the message */
13681 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13683 if (unformat (input, "enable"))
13688 else if (unformat (input, "disable"))
13696 errmsg ("Value not set");
13700 /* Construct the API message */
13701 M (LISP_MAP_REGISTER_ENABLE_DISABLE, lisp_map_register_enable_disable);
13703 mp->is_enabled = is_en;
13708 /* Wait for a reply... */
13716 api_lisp_enable_disable (vat_main_t * vam)
13718 unformat_input_t *input = vam->input;
13719 vl_api_lisp_enable_disable_t *mp;
13724 /* Parse args required to build the message */
13725 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13727 if (unformat (input, "enable"))
13732 else if (unformat (input, "disable"))
13742 errmsg ("Value not set");
13746 /* Construct the API message */
13747 M (LISP_ENABLE_DISABLE, lisp_enable_disable);
13754 /* Wait for a reply... */
13762 api_show_lisp_map_register_state (vat_main_t * vam)
13765 vl_api_show_lisp_map_register_state_t *mp;
13767 M (SHOW_LISP_MAP_REGISTER_STATE, show_lisp_map_register_state);
13772 /* wait for reply */
13779 api_show_lisp_rloc_probe_state (vat_main_t * vam)
13782 vl_api_show_lisp_rloc_probe_state_t *mp;
13784 M (SHOW_LISP_RLOC_PROBE_STATE, show_lisp_rloc_probe_state);
13789 /* wait for reply */
13796 api_show_lisp_map_request_mode (vat_main_t * vam)
13799 vl_api_show_lisp_map_request_mode_t *mp;
13801 M (SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode);
13806 /* wait for reply */
13813 api_lisp_map_request_mode (vat_main_t * vam)
13816 unformat_input_t *input = vam->input;
13817 vl_api_lisp_map_request_mode_t *mp;
13820 /* Parse args required to build the message */
13821 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13823 if (unformat (input, "dst-only"))
13825 else if (unformat (input, "src-dst"))
13829 errmsg ("parse error '%U'", format_unformat_error, input);
13834 M (LISP_MAP_REQUEST_MODE, lisp_map_request_mode);
13841 /* wait for reply */
13849 * Enable/disable LISP proxy ITR.
13851 * @param vam vpp API test context
13852 * @return return code
13855 api_lisp_pitr_set_locator_set (vat_main_t * vam)
13858 u8 ls_name_set = 0;
13859 unformat_input_t *input = vam->input;
13860 vl_api_lisp_pitr_set_locator_set_t *mp;
13864 /* Parse args required to build the message */
13865 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13867 if (unformat (input, "del"))
13869 else if (unformat (input, "locator-set %s", &ls_name))
13873 errmsg ("parse error '%U'", format_unformat_error, input);
13880 errmsg ("locator-set name not set!");
13884 M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set);
13886 mp->is_add = is_add;
13887 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
13888 vec_free (ls_name);
13893 /* wait for reply */
13901 api_show_lisp_pitr (vat_main_t * vam)
13903 vl_api_show_lisp_pitr_t *mp;
13906 if (!vam->json_output)
13908 print (vam->ofp, "%=20s", "lisp status:");
13911 M (SHOW_LISP_PITR, show_lisp_pitr);
13915 /* Wait for a reply... */
13923 * Add/delete mapping between vni and vrf
13926 api_lisp_eid_table_add_del_map (vat_main_t * vam)
13929 unformat_input_t *input = vam->input;
13930 vl_api_lisp_eid_table_add_del_map_t *mp;
13931 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
13932 u32 vni, vrf, bd_index;
13934 /* Parse args required to build the message */
13935 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13937 if (unformat (input, "del"))
13939 else if (unformat (input, "vrf %d", &vrf))
13941 else if (unformat (input, "bd_index %d", &bd_index))
13943 else if (unformat (input, "vni %d", &vni))
13949 if (!vni_set || (!vrf_set && !bd_index_set))
13951 errmsg ("missing arguments!");
13955 if (vrf_set && bd_index_set)
13957 errmsg ("error: both vrf and bd entered!");
13961 M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
13963 mp->is_add = is_add;
13964 mp->vni = htonl (vni);
13965 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
13966 mp->is_l2 = bd_index_set;
13971 /* wait for reply */
13979 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
13981 u32 *action = va_arg (*args, u32 *);
13984 if (unformat (input, "%s", &s))
13986 if (!strcmp ((char *) s, "no-action"))
13988 else if (!strcmp ((char *) s, "natively-forward"))
13990 else if (!strcmp ((char *) s, "send-map-request"))
13992 else if (!strcmp ((char *) s, "drop"))
13996 clib_warning ("invalid action: '%s'", s);
14008 * Add/del remote mapping to/from LISP control plane
14010 * @param vam vpp API test context
14011 * @return return code
14014 api_lisp_add_del_remote_mapping (vat_main_t * vam)
14016 unformat_input_t *input = vam->input;
14017 vl_api_lisp_add_del_remote_mapping_t *mp;
14020 lisp_eid_vat_t _eid, *eid = &_eid;
14021 lisp_eid_vat_t _seid, *seid = &_seid;
14022 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
14023 u32 action = ~0, p, w, data_len;
14024 ip4_address_t rloc4;
14025 ip6_address_t rloc6;
14026 rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
14028 memset (&rloc, 0, sizeof (rloc));
14030 /* Parse args required to build the message */
14031 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14033 if (unformat (input, "del-all"))
14037 else if (unformat (input, "del"))
14041 else if (unformat (input, "add"))
14045 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14049 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
14053 else if (unformat (input, "vni %d", &vni))
14057 else if (unformat (input, "p %d w %d", &p, &w))
14061 errmsg ("No RLOC configured for setting priority/weight!");
14064 curr_rloc->priority = p;
14065 curr_rloc->weight = w;
14067 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
14070 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
14071 vec_add1 (rlocs, rloc);
14072 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14074 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
14077 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
14078 vec_add1 (rlocs, rloc);
14079 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14081 else if (unformat (input, "action %U",
14082 unformat_negative_mapping_action, &action))
14088 clib_warning ("parse error '%U'", format_unformat_error, input);
14095 errmsg ("missing params!");
14099 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14101 errmsg ("no action set for negative map-reply!");
14105 data_len = vec_len (rlocs) * sizeof (rloc_t);
14107 M2 (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping, data_len);
14108 mp->is_add = is_add;
14109 mp->vni = htonl (vni);
14110 mp->action = (u8) action;
14111 mp->is_src_dst = seid_set;
14112 mp->eid_len = eid->len;
14113 mp->seid_len = seid->len;
14114 mp->del_all = del_all;
14115 mp->eid_type = eid->type;
14116 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14117 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14119 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14120 clib_memcpy (mp->rlocs, rlocs, data_len);
14126 /* Wait for a reply... */
14134 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
14135 * forwarding entries in data-plane accordingly.
14137 * @param vam vpp API test context
14138 * @return return code
14141 api_lisp_add_del_adjacency (vat_main_t * vam)
14143 unformat_input_t *input = vam->input;
14144 vl_api_lisp_add_del_adjacency_t *mp;
14147 ip4_address_t leid4, reid4;
14148 ip6_address_t leid6, reid6;
14149 u8 reid_mac[6] = { 0 };
14150 u8 leid_mac[6] = { 0 };
14151 u8 reid_type, leid_type;
14152 u32 leid_len = 0, reid_len = 0, len;
14155 leid_type = reid_type = (u8) ~ 0;
14157 /* Parse args required to build the message */
14158 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14160 if (unformat (input, "del"))
14164 else if (unformat (input, "add"))
14168 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14171 reid_type = 0; /* ipv4 */
14174 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14177 reid_type = 1; /* ipv6 */
14180 else if (unformat (input, "reid %U", unformat_ethernet_address,
14183 reid_type = 2; /* mac */
14185 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14188 leid_type = 0; /* ipv4 */
14191 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14194 leid_type = 1; /* ipv6 */
14197 else if (unformat (input, "leid %U", unformat_ethernet_address,
14200 leid_type = 2; /* mac */
14202 else if (unformat (input, "vni %d", &vni))
14208 errmsg ("parse error '%U'", format_unformat_error, input);
14213 if ((u8) ~ 0 == reid_type)
14215 errmsg ("missing params!");
14219 if (leid_type != reid_type)
14221 errmsg ("remote and local EIDs are of different types!");
14225 M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency);
14226 mp->is_add = is_add;
14227 mp->vni = htonl (vni);
14228 mp->leid_len = leid_len;
14229 mp->reid_len = reid_len;
14230 mp->eid_type = reid_type;
14232 switch (mp->eid_type)
14235 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14236 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14239 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14240 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14243 clib_memcpy (mp->leid, leid_mac, 6);
14244 clib_memcpy (mp->reid, reid_mac, 6);
14247 errmsg ("unknown EID type %d!", mp->eid_type);
14254 /* Wait for a reply... */
14262 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14264 unformat_input_t *input = vam->input;
14265 vl_api_lisp_gpe_add_del_iface_t *mp;
14267 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14268 u32 dp_table = 0, vni = 0;
14270 /* Parse args required to build the message */
14271 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14273 if (unformat (input, "up"))
14278 else if (unformat (input, "down"))
14283 else if (unformat (input, "table_id %d", &dp_table))
14287 else if (unformat (input, "bd_id %d", &dp_table))
14292 else if (unformat (input, "vni %d", &vni))
14300 if (action_set == 0)
14302 errmsg ("Action not set");
14305 if (dp_table_set == 0 || vni_set == 0)
14307 errmsg ("vni and dp_table must be set");
14311 /* Construct the API message */
14312 M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
14314 mp->is_add = is_add;
14315 mp->dp_table = dp_table;
14322 /* Wait for a reply... */
14330 * Add/del map request itr rlocs from LISP control plane and updates
14332 * @param vam vpp API test context
14333 * @return return code
14336 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
14338 unformat_input_t *input = vam->input;
14339 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
14341 u8 *locator_set_name = 0;
14342 u8 locator_set_name_set = 0;
14345 /* Parse args required to build the message */
14346 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14348 if (unformat (input, "del"))
14352 else if (unformat (input, "%_%v%_", &locator_set_name))
14354 locator_set_name_set = 1;
14358 clib_warning ("parse error '%U'", format_unformat_error, input);
14363 if (is_add && !locator_set_name_set)
14365 errmsg ("itr-rloc is not set!");
14369 if (is_add && vec_len (locator_set_name) > 64)
14371 errmsg ("itr-rloc locator-set name too long");
14372 vec_free (locator_set_name);
14376 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs);
14377 mp->is_add = is_add;
14380 clib_memcpy (mp->locator_set_name, locator_set_name,
14381 vec_len (locator_set_name));
14385 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14387 vec_free (locator_set_name);
14392 /* Wait for a reply... */
14400 api_lisp_locator_dump (vat_main_t * vam)
14402 unformat_input_t *input = vam->input;
14403 vl_api_lisp_locator_dump_t *mp;
14405 u8 is_index_set = 0, is_name_set = 0;
14409 /* Parse args required to build the message */
14410 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14412 if (unformat (input, "ls_name %_%v%_", &ls_name))
14416 else if (unformat (input, "ls_index %d", &ls_index))
14422 errmsg ("parse error '%U'", format_unformat_error, input);
14427 if (!is_index_set && !is_name_set)
14429 errmsg ("error: expected one of index or name!");
14433 if (is_index_set && is_name_set)
14435 errmsg ("error: only one param expected!");
14439 if (vec_len (ls_name) > 62)
14441 errmsg ("error: locator set name too long!");
14445 if (!vam->json_output)
14447 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
14450 M (LISP_LOCATOR_DUMP, lisp_locator_dump);
14451 mp->is_index_set = is_index_set;
14454 mp->ls_index = clib_host_to_net_u32 (ls_index);
14457 vec_add1 (ls_name, 0);
14458 strncpy ((char *) mp->ls_name, (char *) ls_name,
14459 sizeof (mp->ls_name) - 1);
14465 /* Use a control ping for synchronization */
14467 vl_api_control_ping_t *mp;
14468 M (CONTROL_PING, control_ping);
14471 /* Wait for a reply... */
14479 api_lisp_locator_set_dump (vat_main_t * vam)
14481 vl_api_lisp_locator_set_dump_t *mp;
14482 unformat_input_t *input = vam->input;
14486 /* Parse args required to build the message */
14487 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14489 if (unformat (input, "local"))
14493 else if (unformat (input, "remote"))
14499 errmsg ("parse error '%U'", format_unformat_error, input);
14504 if (!vam->json_output)
14506 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
14509 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
14511 mp->filter = filter;
14516 /* Use a control ping for synchronization */
14518 vl_api_control_ping_t *mp;
14519 M (CONTROL_PING, control_ping);
14522 /* Wait for a reply... */
14530 api_lisp_eid_table_map_dump (vat_main_t * vam)
14534 unformat_input_t *input = vam->input;
14535 vl_api_lisp_eid_table_map_dump_t *mp;
14538 /* Parse args required to build the message */
14539 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14541 if (unformat (input, "l2"))
14546 else if (unformat (input, "l3"))
14553 errmsg ("parse error '%U'", format_unformat_error, input);
14560 errmsg ("expected one of 'l2' or 'l3' parameter!");
14564 if (!vam->json_output)
14566 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
14569 M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump);
14575 /* Use a control ping for synchronization */
14577 vl_api_control_ping_t *mp;
14578 M (CONTROL_PING, control_ping);
14581 /* Wait for a reply... */
14589 api_lisp_eid_table_vni_dump (vat_main_t * vam)
14591 vl_api_lisp_eid_table_vni_dump_t *mp;
14594 if (!vam->json_output)
14596 print (vam->ofp, "VNI");
14599 M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
14604 /* Use a control ping for synchronization */
14606 vl_api_control_ping_t *mp;
14607 M (CONTROL_PING, control_ping);
14610 /* Wait for a reply... */
14618 api_lisp_eid_table_dump (vat_main_t * vam)
14620 unformat_input_t *i = vam->input;
14621 vl_api_lisp_eid_table_dump_t *mp;
14623 struct in_addr ip4;
14624 struct in6_addr ip6;
14626 u8 eid_type = ~0, eid_set = 0;
14627 u32 prefix_length = ~0, t, vni = 0;
14630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14632 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
14638 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
14644 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
14649 else if (unformat (i, "vni %d", &t))
14653 else if (unformat (i, "local"))
14657 else if (unformat (i, "remote"))
14663 errmsg ("parse error '%U'", format_unformat_error, i);
14668 if (!vam->json_output)
14670 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
14671 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
14674 M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump);
14676 mp->filter = filter;
14680 mp->vni = htonl (vni);
14681 mp->eid_type = eid_type;
14685 mp->prefix_length = prefix_length;
14686 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
14689 mp->prefix_length = prefix_length;
14690 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
14693 clib_memcpy (mp->eid, mac, sizeof (mac));
14696 errmsg ("unknown EID type %d!", eid_type);
14704 /* Use a control ping for synchronization */
14706 vl_api_control_ping_t *mp;
14707 M (CONTROL_PING, control_ping);
14711 /* Wait for a reply... */
14719 api_lisp_adjacencies_get (vat_main_t * vam)
14721 unformat_input_t *i = vam->input;
14722 vl_api_lisp_adjacencies_get_t *mp;
14727 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14729 if (unformat (i, "vni %d", &vni))
14735 errmsg ("parse error '%U'", format_unformat_error, i);
14742 errmsg ("vni not set!");
14746 if (!vam->json_output)
14748 print (vam->ofp, "%s %40s", "leid", "reid");
14751 M (LISP_ADJACENCIES_GET, lisp_adjacencies_get);
14752 mp->vni = clib_host_to_net_u32 (vni);
14757 /* Wait for a reply... */
14765 api_lisp_map_server_dump (vat_main_t * vam)
14767 vl_api_lisp_map_server_dump_t *mp;
14770 if (!vam->json_output)
14772 print (vam->ofp, "%=20s", "Map server");
14775 M (LISP_MAP_SERVER_DUMP, lisp_map_server_dump);
14779 /* Use a control ping for synchronization */
14781 vl_api_control_ping_t *mp;
14782 M (CONTROL_PING, control_ping);
14785 /* Wait for a reply... */
14793 api_lisp_map_resolver_dump (vat_main_t * vam)
14795 vl_api_lisp_map_resolver_dump_t *mp;
14798 if (!vam->json_output)
14800 print (vam->ofp, "%=20s", "Map resolver");
14803 M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
14807 /* Use a control ping for synchronization */
14809 vl_api_control_ping_t *mp;
14810 M (CONTROL_PING, control_ping);
14813 /* Wait for a reply... */
14821 api_show_lisp_status (vat_main_t * vam)
14823 vl_api_show_lisp_status_t *mp;
14826 if (!vam->json_output)
14828 print (vam->ofp, "%-20s%-16s", "lisp status", "locator-set");
14831 M (SHOW_LISP_STATUS, show_lisp_status);
14834 /* Wait for a reply... */
14842 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
14844 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
14847 if (!vam->json_output)
14849 print (vam->ofp, "%=20s", "itr-rlocs:");
14852 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
14855 /* Wait for a reply... */
14863 api_af_packet_create (vat_main_t * vam)
14865 unformat_input_t *i = vam->input;
14866 vl_api_af_packet_create_t *mp;
14868 u8 *host_if_name = 0;
14870 u8 random_hw_addr = 1;
14872 memset (hw_addr, 0, sizeof (hw_addr));
14874 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14876 if (unformat (i, "name %s", &host_if_name))
14877 vec_add1 (host_if_name, 0);
14878 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14879 random_hw_addr = 0;
14884 if (!vec_len (host_if_name))
14886 errmsg ("host-interface name must be specified");
14890 if (vec_len (host_if_name) > 64)
14892 errmsg ("host-interface name too long");
14896 M (AF_PACKET_CREATE, af_packet_create);
14898 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14899 clib_memcpy (mp->hw_addr, hw_addr, 6);
14900 mp->use_random_hw_addr = random_hw_addr;
14901 vec_free (host_if_name);
14904 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
14910 api_af_packet_delete (vat_main_t * vam)
14912 unformat_input_t *i = vam->input;
14913 vl_api_af_packet_delete_t *mp;
14915 u8 *host_if_name = 0;
14917 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14919 if (unformat (i, "name %s", &host_if_name))
14920 vec_add1 (host_if_name, 0);
14925 if (!vec_len (host_if_name))
14927 errmsg ("host-interface name must be specified");
14931 if (vec_len (host_if_name) > 64)
14933 errmsg ("host-interface name too long");
14937 M (AF_PACKET_DELETE, af_packet_delete);
14939 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14940 vec_free (host_if_name);
14949 api_policer_add_del (vat_main_t * vam)
14951 unformat_input_t *i = vam->input;
14952 vl_api_policer_add_del_t *mp;
14963 u8 color_aware = 0;
14964 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
14966 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
14967 conform_action.dscp = 0;
14968 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
14969 exceed_action.dscp = 0;
14970 violate_action.action_type = SSE2_QOS_ACTION_DROP;
14971 violate_action.dscp = 0;
14973 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14975 if (unformat (i, "del"))
14977 else if (unformat (i, "name %s", &name))
14978 vec_add1 (name, 0);
14979 else if (unformat (i, "cir %u", &cir))
14981 else if (unformat (i, "eir %u", &eir))
14983 else if (unformat (i, "cb %u", &cb))
14985 else if (unformat (i, "eb %u", &eb))
14987 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
14990 else if (unformat (i, "round_type %U", unformat_policer_round_type,
14993 else if (unformat (i, "type %U", unformat_policer_type, &type))
14995 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
14998 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
15001 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
15004 else if (unformat (i, "color-aware"))
15010 if (!vec_len (name))
15012 errmsg ("policer name must be specified");
15016 if (vec_len (name) > 64)
15018 errmsg ("policer name too long");
15022 M (POLICER_ADD_DEL, policer_add_del);
15024 clib_memcpy (mp->name, name, vec_len (name));
15026 mp->is_add = is_add;
15031 mp->rate_type = rate_type;
15032 mp->round_type = round_type;
15034 mp->conform_action_type = conform_action.action_type;
15035 mp->conform_dscp = conform_action.dscp;
15036 mp->exceed_action_type = exceed_action.action_type;
15037 mp->exceed_dscp = exceed_action.dscp;
15038 mp->violate_action_type = violate_action.action_type;
15039 mp->violate_dscp = violate_action.dscp;
15040 mp->color_aware = color_aware;
15049 api_policer_dump (vat_main_t * vam)
15051 unformat_input_t *i = vam->input;
15052 vl_api_policer_dump_t *mp;
15054 u8 *match_name = 0;
15055 u8 match_name_valid = 0;
15057 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15059 if (unformat (i, "name %s", &match_name))
15061 vec_add1 (match_name, 0);
15062 match_name_valid = 1;
15068 M (POLICER_DUMP, policer_dump);
15069 mp->match_name_valid = match_name_valid;
15070 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15071 vec_free (match_name);
15075 /* Use a control ping for synchronization */
15077 vl_api_control_ping_t *mp;
15078 M (CONTROL_PING, control_ping);
15081 /* Wait for a reply... */
15089 api_policer_classify_set_interface (vat_main_t * vam)
15091 unformat_input_t *i = vam->input;
15092 vl_api_policer_classify_set_interface_t *mp;
15095 int sw_if_index_set;
15096 u32 ip4_table_index = ~0;
15097 u32 ip6_table_index = ~0;
15098 u32 l2_table_index = ~0;
15101 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15103 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15104 sw_if_index_set = 1;
15105 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15106 sw_if_index_set = 1;
15107 else if (unformat (i, "del"))
15109 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15111 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15113 else if (unformat (i, "l2-table %d", &l2_table_index))
15117 clib_warning ("parse error '%U'", format_unformat_error, i);
15122 if (sw_if_index_set == 0)
15124 errmsg ("missing interface name or sw_if_index");
15128 M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface);
15130 mp->sw_if_index = ntohl (sw_if_index);
15131 mp->ip4_table_index = ntohl (ip4_table_index);
15132 mp->ip6_table_index = ntohl (ip6_table_index);
15133 mp->l2_table_index = ntohl (l2_table_index);
15134 mp->is_add = is_add;
15143 api_policer_classify_dump (vat_main_t * vam)
15145 unformat_input_t *i = vam->input;
15146 vl_api_policer_classify_dump_t *mp;
15148 u8 type = POLICER_CLASSIFY_N_TABLES;
15150 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15154 errmsg ("classify table type must be specified");
15158 if (!vam->json_output)
15160 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15163 M (POLICER_CLASSIFY_DUMP, policer_classify_dump);
15168 /* Use a control ping for synchronization */
15170 vl_api_control_ping_t *mp;
15171 M (CONTROL_PING, control_ping);
15174 /* Wait for a reply... */
15182 api_netmap_create (vat_main_t * vam)
15184 unformat_input_t *i = vam->input;
15185 vl_api_netmap_create_t *mp;
15189 u8 random_hw_addr = 1;
15193 memset (hw_addr, 0, sizeof (hw_addr));
15195 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15197 if (unformat (i, "name %s", &if_name))
15198 vec_add1 (if_name, 0);
15199 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15200 random_hw_addr = 0;
15201 else if (unformat (i, "pipe"))
15203 else if (unformat (i, "master"))
15205 else if (unformat (i, "slave"))
15211 if (!vec_len (if_name))
15213 errmsg ("interface name must be specified");
15217 if (vec_len (if_name) > 64)
15219 errmsg ("interface name too long");
15223 M (NETMAP_CREATE, netmap_create);
15225 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15226 clib_memcpy (mp->hw_addr, hw_addr, 6);
15227 mp->use_random_hw_addr = random_hw_addr;
15228 mp->is_pipe = is_pipe;
15229 mp->is_master = is_master;
15230 vec_free (if_name);
15239 api_netmap_delete (vat_main_t * vam)
15241 unformat_input_t *i = vam->input;
15242 vl_api_netmap_delete_t *mp;
15246 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15248 if (unformat (i, "name %s", &if_name))
15249 vec_add1 (if_name, 0);
15254 if (!vec_len (if_name))
15256 errmsg ("interface name must be specified");
15260 if (vec_len (if_name) > 64)
15262 errmsg ("interface name too long");
15266 M (NETMAP_DELETE, netmap_delete);
15268 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15269 vec_free (if_name);
15277 static void vl_api_mpls_tunnel_details_t_handler
15278 (vl_api_mpls_tunnel_details_t * mp)
15280 vat_main_t *vam = &vat_main;
15281 i32 len = mp->mt_next_hop_n_labels;
15284 print (vam->ofp, "[%d]: via %U %d labels ",
15286 format_ip4_address, mp->mt_next_hop,
15287 ntohl (mp->mt_next_hop_sw_if_index));
15288 for (i = 0; i < len; i++)
15290 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15292 print (vam->ofp, "");
15295 static void vl_api_mpls_tunnel_details_t_handler_json
15296 (vl_api_mpls_tunnel_details_t * mp)
15298 vat_main_t *vam = &vat_main;
15299 vat_json_node_t *node = NULL;
15300 struct in_addr ip4;
15302 i32 len = mp->mt_next_hop_n_labels;
15304 if (VAT_JSON_ARRAY != vam->json_tree.type)
15306 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15307 vat_json_init_array (&vam->json_tree);
15309 node = vat_json_array_add (&vam->json_tree);
15311 vat_json_init_object (node);
15312 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15313 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15314 vat_json_object_add_ip4 (node, "next_hop", ip4);
15315 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15316 ntohl (mp->mt_next_hop_sw_if_index));
15317 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15318 vat_json_object_add_uint (node, "label_count", len);
15319 for (i = 0; i < len; i++)
15321 vat_json_object_add_uint (node, "label",
15322 ntohl (mp->mt_next_hop_out_labels[i]));
15327 api_mpls_tunnel_dump (vat_main_t * vam)
15329 vl_api_mpls_tunnel_dump_t *mp;
15333 /* Parse args required to build the message */
15334 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15336 if (!unformat (vam->input, "tunnel_index %d", &index))
15343 print (vam->ofp, " tunnel_index %d", index);
15345 M (MPLS_TUNNEL_DUMP, mpls_tunnel_dump);
15346 mp->tunnel_index = htonl (index);
15349 /* Use a control ping for synchronization */
15351 vl_api_control_ping_t *mp;
15352 M (CONTROL_PING, control_ping);
15358 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
15359 #define vl_api_mpls_fib_details_t_print vl_noop_handler
15362 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
15364 vat_main_t *vam = &vat_main;
15365 int count = ntohl (mp->count);
15366 vl_api_fib_path2_t *fp;
15370 "table-id %d, label %u, ess_bit %u",
15371 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
15373 for (i = 0; i < count; i++)
15375 if (fp->afi == IP46_TYPE_IP6)
15377 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15378 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15379 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15380 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15381 format_ip6_address, fp->next_hop);
15382 else if (fp->afi == IP46_TYPE_IP4)
15384 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15385 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15386 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15387 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15388 format_ip4_address, fp->next_hop);
15393 static void vl_api_mpls_fib_details_t_handler_json
15394 (vl_api_mpls_fib_details_t * mp)
15396 vat_main_t *vam = &vat_main;
15397 int count = ntohl (mp->count);
15398 vat_json_node_t *node = NULL;
15399 struct in_addr ip4;
15400 struct in6_addr ip6;
15401 vl_api_fib_path2_t *fp;
15404 if (VAT_JSON_ARRAY != vam->json_tree.type)
15406 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15407 vat_json_init_array (&vam->json_tree);
15409 node = vat_json_array_add (&vam->json_tree);
15411 vat_json_init_object (node);
15412 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15413 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
15414 vat_json_object_add_uint (node, "label", ntohl (mp->label));
15415 vat_json_object_add_uint (node, "path_count", count);
15417 for (i = 0; i < count; i++)
15419 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15420 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15421 vat_json_object_add_uint (node, "is_local", fp->is_local);
15422 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15423 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15424 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15425 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15426 if (fp->afi == IP46_TYPE_IP4)
15428 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15429 vat_json_object_add_ip4 (node, "next_hop", ip4);
15431 else if (fp->afi == IP46_TYPE_IP6)
15433 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15434 vat_json_object_add_ip6 (node, "next_hop", ip6);
15440 api_mpls_fib_dump (vat_main_t * vam)
15442 vl_api_mpls_fib_dump_t *mp;
15445 M (MPLS_FIB_DUMP, mpls_fib_dump);
15448 /* Use a control ping for synchronization */
15450 vl_api_control_ping_t *mp;
15451 M (CONTROL_PING, control_ping);
15457 #define vl_api_ip_fib_details_t_endian vl_noop_handler
15458 #define vl_api_ip_fib_details_t_print vl_noop_handler
15461 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
15463 vat_main_t *vam = &vat_main;
15464 int count = ntohl (mp->count);
15465 vl_api_fib_path_t *fp;
15469 "table-id %d, prefix %U/%d",
15470 ntohl (mp->table_id), format_ip4_address, mp->address,
15471 mp->address_length);
15473 for (i = 0; i < count; i++)
15475 if (fp->afi == IP46_TYPE_IP6)
15477 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15478 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15479 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15480 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15481 format_ip6_address, fp->next_hop);
15482 else if (fp->afi == IP46_TYPE_IP4)
15484 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15485 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15486 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15487 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15488 format_ip4_address, fp->next_hop);
15493 static void vl_api_ip_fib_details_t_handler_json
15494 (vl_api_ip_fib_details_t * mp)
15496 vat_main_t *vam = &vat_main;
15497 int count = ntohl (mp->count);
15498 vat_json_node_t *node = NULL;
15499 struct in_addr ip4;
15500 struct in6_addr ip6;
15501 vl_api_fib_path_t *fp;
15504 if (VAT_JSON_ARRAY != vam->json_tree.type)
15506 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15507 vat_json_init_array (&vam->json_tree);
15509 node = vat_json_array_add (&vam->json_tree);
15511 vat_json_init_object (node);
15512 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15513 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
15514 vat_json_object_add_ip4 (node, "prefix", ip4);
15515 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15516 vat_json_object_add_uint (node, "path_count", count);
15518 for (i = 0; i < count; i++)
15520 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15521 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15522 vat_json_object_add_uint (node, "is_local", fp->is_local);
15523 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15524 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15525 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15526 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15527 if (fp->afi == IP46_TYPE_IP4)
15529 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15530 vat_json_object_add_ip4 (node, "next_hop", ip4);
15532 else if (fp->afi == IP46_TYPE_IP6)
15534 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15535 vat_json_object_add_ip6 (node, "next_hop", ip6);
15541 api_ip_fib_dump (vat_main_t * vam)
15543 vl_api_ip_fib_dump_t *mp;
15546 M (IP_FIB_DUMP, ip_fib_dump);
15549 /* Use a control ping for synchronization */
15551 vl_api_control_ping_t *mp;
15552 M (CONTROL_PING, control_ping);
15558 static void vl_api_ip_neighbor_details_t_handler
15559 (vl_api_ip_neighbor_details_t * mp)
15561 vat_main_t *vam = &vat_main;
15563 print (vam->ofp, "%c %U %U",
15564 (mp->is_static) ? 'S' : 'D',
15565 format_ethernet_address, &mp->mac_address,
15566 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
15570 static void vl_api_ip_neighbor_details_t_handler_json
15571 (vl_api_ip_neighbor_details_t * mp)
15574 vat_main_t *vam = &vat_main;
15575 vat_json_node_t *node;
15576 struct in_addr ip4;
15577 struct in6_addr ip6;
15579 if (VAT_JSON_ARRAY != vam->json_tree.type)
15581 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15582 vat_json_init_array (&vam->json_tree);
15584 node = vat_json_array_add (&vam->json_tree);
15586 vat_json_init_object (node);
15587 vat_json_object_add_string_copy (node, "flag",
15588 (mp->is_static) ? (u8 *) "static" : (u8 *)
15591 vat_json_object_add_string_copy (node, "link_layer",
15592 format (0, "%U", format_ethernet_address,
15593 &mp->mac_address));
15597 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
15598 vat_json_object_add_ip6 (node, "ip_address", ip6);
15602 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
15603 vat_json_object_add_ip4 (node, "ip_address", ip4);
15608 api_ip_neighbor_dump (vat_main_t * vam)
15610 unformat_input_t *i = vam->input;
15611 vl_api_ip_neighbor_dump_t *mp;
15614 u32 sw_if_index = ~0;
15616 /* Parse args required to build the message */
15617 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15619 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15621 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15623 else if (unformat (i, "ip6"))
15629 if (sw_if_index == ~0)
15631 errmsg ("missing interface name or sw_if_index");
15635 M (IP_NEIGHBOR_DUMP, ip_neighbor_dump);
15636 mp->is_ipv6 = (u8) is_ipv6;
15637 mp->sw_if_index = ntohl (sw_if_index);
15640 /* Use a control ping for synchronization */
15642 vl_api_control_ping_t *mp;
15643 M (CONTROL_PING, control_ping);
15649 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
15650 #define vl_api_ip6_fib_details_t_print vl_noop_handler
15653 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
15655 vat_main_t *vam = &vat_main;
15656 int count = ntohl (mp->count);
15657 vl_api_fib_path_t *fp;
15661 "table-id %d, prefix %U/%d",
15662 ntohl (mp->table_id), format_ip6_address, mp->address,
15663 mp->address_length);
15665 for (i = 0; i < count; i++)
15667 if (fp->afi == IP46_TYPE_IP6)
15669 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15670 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15671 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15672 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15673 format_ip6_address, fp->next_hop);
15674 else if (fp->afi == IP46_TYPE_IP4)
15676 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15677 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15678 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15679 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15680 format_ip4_address, fp->next_hop);
15685 static void vl_api_ip6_fib_details_t_handler_json
15686 (vl_api_ip6_fib_details_t * mp)
15688 vat_main_t *vam = &vat_main;
15689 int count = ntohl (mp->count);
15690 vat_json_node_t *node = NULL;
15691 struct in_addr ip4;
15692 struct in6_addr ip6;
15693 vl_api_fib_path_t *fp;
15696 if (VAT_JSON_ARRAY != vam->json_tree.type)
15698 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15699 vat_json_init_array (&vam->json_tree);
15701 node = vat_json_array_add (&vam->json_tree);
15703 vat_json_init_object (node);
15704 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15705 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
15706 vat_json_object_add_ip6 (node, "prefix", ip6);
15707 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15708 vat_json_object_add_uint (node, "path_count", count);
15710 for (i = 0; i < count; i++)
15712 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15713 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15714 vat_json_object_add_uint (node, "is_local", fp->is_local);
15715 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15716 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15717 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15718 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15719 if (fp->afi == IP46_TYPE_IP4)
15721 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15722 vat_json_object_add_ip4 (node, "next_hop", ip4);
15724 else if (fp->afi == IP46_TYPE_IP6)
15726 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15727 vat_json_object_add_ip6 (node, "next_hop", ip6);
15733 api_ip6_fib_dump (vat_main_t * vam)
15735 vl_api_ip6_fib_dump_t *mp;
15738 M (IP6_FIB_DUMP, ip6_fib_dump);
15741 /* Use a control ping for synchronization */
15743 vl_api_control_ping_t *mp;
15744 M (CONTROL_PING, control_ping);
15751 api_classify_table_ids (vat_main_t * vam)
15753 vl_api_classify_table_ids_t *mp;
15756 /* Construct the API message */
15757 M (CLASSIFY_TABLE_IDS, classify_table_ids);
15767 api_classify_table_by_interface (vat_main_t * vam)
15769 unformat_input_t *input = vam->input;
15770 vl_api_classify_table_by_interface_t *mp;
15773 u32 sw_if_index = ~0;
15774 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15776 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15778 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15783 if (sw_if_index == ~0)
15785 errmsg ("missing interface name or sw_if_index");
15789 /* Construct the API message */
15790 M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
15792 mp->sw_if_index = ntohl (sw_if_index);
15801 api_classify_table_info (vat_main_t * vam)
15803 unformat_input_t *input = vam->input;
15804 vl_api_classify_table_info_t *mp;
15808 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15810 if (unformat (input, "table_id %d", &table_id))
15815 if (table_id == ~0)
15817 errmsg ("missing table id");
15821 /* Construct the API message */
15822 M (CLASSIFY_TABLE_INFO, classify_table_info);
15824 mp->table_id = ntohl (table_id);
15833 api_classify_session_dump (vat_main_t * vam)
15835 unformat_input_t *input = vam->input;
15836 vl_api_classify_session_dump_t *mp;
15840 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15842 if (unformat (input, "table_id %d", &table_id))
15847 if (table_id == ~0)
15849 errmsg ("missing table id");
15853 /* Construct the API message */
15854 M (CLASSIFY_SESSION_DUMP, classify_session_dump);
15856 mp->table_id = ntohl (table_id);
15859 /* Use a control ping for synchronization */
15861 vl_api_control_ping_t *mp;
15862 M (CONTROL_PING, control_ping);
15871 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
15873 vat_main_t *vam = &vat_main;
15875 print (vam->ofp, "collector_address %U, collector_port %d, "
15876 "src_address %U, vrf_id %d, path_mtu %u, "
15877 "template_interval %u, udp_checksum %d",
15878 format_ip4_address, mp->collector_address,
15879 ntohs (mp->collector_port),
15880 format_ip4_address, mp->src_address,
15881 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
15882 ntohl (mp->template_interval), mp->udp_checksum);
15885 vam->result_ready = 1;
15889 vl_api_ipfix_exporter_details_t_handler_json
15890 (vl_api_ipfix_exporter_details_t * mp)
15892 vat_main_t *vam = &vat_main;
15893 vat_json_node_t node;
15894 struct in_addr collector_address;
15895 struct in_addr src_address;
15897 vat_json_init_object (&node);
15898 clib_memcpy (&collector_address, &mp->collector_address,
15899 sizeof (collector_address));
15900 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
15901 vat_json_object_add_uint (&node, "collector_port",
15902 ntohs (mp->collector_port));
15903 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
15904 vat_json_object_add_ip4 (&node, "src_address", src_address);
15905 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
15906 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
15907 vat_json_object_add_uint (&node, "template_interval",
15908 ntohl (mp->template_interval));
15909 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
15911 vat_json_print (vam->ofp, &node);
15912 vat_json_free (&node);
15914 vam->result_ready = 1;
15918 api_ipfix_exporter_dump (vat_main_t * vam)
15920 vl_api_ipfix_exporter_dump_t *mp;
15923 /* Construct the API message */
15924 M (IPFIX_EXPORTER_DUMP, ipfix_exporter_dump);
15934 api_ipfix_classify_stream_dump (vat_main_t * vam)
15936 vl_api_ipfix_classify_stream_dump_t *mp;
15939 /* Construct the API message */
15940 M (IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump);
15950 vl_api_ipfix_classify_stream_details_t_handler
15951 (vl_api_ipfix_classify_stream_details_t * mp)
15953 vat_main_t *vam = &vat_main;
15954 print (vam->ofp, "domain_id %d, src_port %d",
15955 ntohl (mp->domain_id), ntohs (mp->src_port));
15957 vam->result_ready = 1;
15961 vl_api_ipfix_classify_stream_details_t_handler_json
15962 (vl_api_ipfix_classify_stream_details_t * mp)
15964 vat_main_t *vam = &vat_main;
15965 vat_json_node_t node;
15967 vat_json_init_object (&node);
15968 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
15969 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
15971 vat_json_print (vam->ofp, &node);
15972 vat_json_free (&node);
15974 vam->result_ready = 1;
15978 api_ipfix_classify_table_dump (vat_main_t * vam)
15980 vl_api_ipfix_classify_table_dump_t *mp;
15983 if (!vam->json_output)
15985 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
15986 "transport_protocol");
15989 /* Construct the API message */
15990 M (IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump);
15995 /* Use a control ping for synchronization */
15997 vl_api_control_ping_t *mp;
15998 M (CONTROL_PING, control_ping);
16005 vl_api_ipfix_classify_table_details_t_handler
16006 (vl_api_ipfix_classify_table_details_t * mp)
16008 vat_main_t *vam = &vat_main;
16009 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
16010 mp->transport_protocol);
16014 vl_api_ipfix_classify_table_details_t_handler_json
16015 (vl_api_ipfix_classify_table_details_t * mp)
16017 vat_json_node_t *node = NULL;
16018 vat_main_t *vam = &vat_main;
16020 if (VAT_JSON_ARRAY != vam->json_tree.type)
16022 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16023 vat_json_init_array (&vam->json_tree);
16026 node = vat_json_array_add (&vam->json_tree);
16027 vat_json_init_object (node);
16029 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
16030 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
16031 vat_json_object_add_uint (node, "transport_protocol",
16032 mp->transport_protocol);
16036 api_sw_interface_span_enable_disable (vat_main_t * vam)
16038 unformat_input_t *i = vam->input;
16039 vl_api_sw_interface_span_enable_disable_t *mp;
16041 u32 src_sw_if_index = ~0;
16042 u32 dst_sw_if_index = ~0;
16045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16048 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
16050 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
16054 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
16056 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
16058 else if (unformat (i, "disable"))
16060 else if (unformat (i, "rx"))
16062 else if (unformat (i, "tx"))
16064 else if (unformat (i, "both"))
16070 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, sw_interface_span_enable_disable);
16072 mp->sw_if_index_from = htonl (src_sw_if_index);
16073 mp->sw_if_index_to = htonl (dst_sw_if_index);
16083 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16086 vat_main_t *vam = &vat_main;
16087 u8 *sw_if_from_name = 0;
16088 u8 *sw_if_to_name = 0;
16089 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16090 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16091 char *states[] = { "none", "rx", "tx", "both" };
16095 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16097 if ((u32) p->value[0] == sw_if_index_from)
16099 sw_if_from_name = (u8 *)(p->key);
16103 if ((u32) p->value[0] == sw_if_index_to)
16105 sw_if_to_name = (u8 *)(p->key);
16106 if (sw_if_from_name)
16111 print (vam->ofp, "%20s => %20s (%s)",
16112 sw_if_from_name, sw_if_to_name, states[mp->state]);
16116 vl_api_sw_interface_span_details_t_handler_json
16117 (vl_api_sw_interface_span_details_t * mp)
16119 vat_main_t *vam = &vat_main;
16120 vat_json_node_t *node = NULL;
16121 u8 *sw_if_from_name = 0;
16122 u8 *sw_if_to_name = 0;
16123 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16124 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16128 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16130 if ((u32) p->value[0] == sw_if_index_from)
16132 sw_if_from_name = (u8 *)(p->key);
16136 if ((u32) p->value[0] == sw_if_index_to)
16138 sw_if_to_name = (u8 *)(p->key);
16139 if (sw_if_from_name)
16145 if (VAT_JSON_ARRAY != vam->json_tree.type)
16147 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16148 vat_json_init_array (&vam->json_tree);
16150 node = vat_json_array_add (&vam->json_tree);
16152 vat_json_init_object (node);
16153 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16154 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16155 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16156 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16157 vat_json_object_add_uint (node, "state", mp->state);
16161 api_sw_interface_span_dump (vat_main_t * vam)
16163 vl_api_sw_interface_span_dump_t *mp;
16166 M (SW_INTERFACE_SPAN_DUMP, sw_interface_span_dump);
16169 /* Use a control ping for synchronization */
16171 vl_api_control_ping_t *mp;
16172 M (CONTROL_PING, control_ping);
16179 api_pg_create_interface (vat_main_t * vam)
16181 unformat_input_t *input = vam->input;
16182 vl_api_pg_create_interface_t *mp;
16186 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16188 if (unformat (input, "if_id %d", &if_id))
16195 errmsg ("missing pg interface index");
16199 /* Construct the API message */
16200 M (PG_CREATE_INTERFACE, pg_create_interface);
16202 mp->interface_id = ntohl (if_id);
16211 api_pg_capture (vat_main_t * vam)
16213 unformat_input_t *input = vam->input;
16214 vl_api_pg_capture_t *mp;
16220 u8 pcap_file_set = 0;
16222 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16224 if (unformat (input, "if_id %d", &if_id))
16226 else if (unformat (input, "pcap %s", &pcap_file))
16228 else if (unformat (input, "count %d", &count))
16230 else if (unformat (input, "disable"))
16237 errmsg ("missing pg interface index");
16240 if (pcap_file_set > 0)
16242 if (vec_len (pcap_file) > 255)
16244 errmsg ("pcap file name is too long");
16249 u32 name_len = vec_len (pcap_file);
16250 /* Construct the API message */
16251 M (PG_CAPTURE, pg_capture);
16253 mp->interface_id = ntohl (if_id);
16254 mp->is_enabled = enable;
16255 mp->count = ntohl (count);
16256 mp->pcap_name_length = ntohl (name_len);
16257 if (pcap_file_set != 0)
16259 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16261 vec_free (pcap_file);
16270 api_pg_enable_disable (vat_main_t * vam)
16272 unformat_input_t *input = vam->input;
16273 vl_api_pg_enable_disable_t *mp;
16277 u8 stream_name_set = 0;
16278 u8 *stream_name = 0;
16279 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16281 if (unformat (input, "stream %s", &stream_name))
16282 stream_name_set = 1;
16283 else if (unformat (input, "disable"))
16289 if (stream_name_set > 0)
16291 if (vec_len (stream_name) > 255)
16293 errmsg ("stream name too long");
16298 u32 name_len = vec_len (stream_name);
16299 /* Construct the API message */
16300 M (PG_ENABLE_DISABLE, pg_enable_disable);
16302 mp->is_enabled = enable;
16303 if (stream_name_set != 0)
16305 mp->stream_name_length = ntohl (name_len);
16306 clib_memcpy (mp->stream_name, stream_name, name_len);
16308 vec_free (stream_name);
16317 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
16319 unformat_input_t *input = vam->input;
16320 vl_api_ip_source_and_port_range_check_add_del_t *mp;
16323 u16 *low_ports = 0;
16324 u16 *high_ports = 0;
16327 ip4_address_t ip4_addr;
16328 ip6_address_t ip6_addr;
16336 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16338 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
16344 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
16349 else if (unformat (input, "vrf %d", &vrf_id))
16351 else if (unformat (input, "del"))
16353 else if (unformat (input, "port %d", &tmp))
16355 if (tmp == 0 || tmp > 65535)
16357 errmsg ("port %d out of range", tmp);
16361 this_hi = this_low + 1;
16362 vec_add1 (low_ports, this_low);
16363 vec_add1 (high_ports, this_hi);
16365 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
16367 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
16369 errmsg ("incorrect range parameters");
16373 /* Note: in debug CLI +1 is added to high before
16374 passing to real fn that does "the work"
16375 (ip_source_and_port_range_check_add_del).
16376 This fn is a wrapper around the binary API fn a
16377 control plane will call, which expects this increment
16378 to have occurred. Hence letting the binary API control
16379 plane fn do the increment for consistency between VAT
16380 and other control planes.
16383 vec_add1 (low_ports, this_low);
16384 vec_add1 (high_ports, this_hi);
16390 if (prefix_set == 0)
16392 errmsg ("<address>/<mask> not specified");
16398 errmsg ("VRF ID required, not specified");
16405 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16409 if (vec_len (low_ports) == 0)
16411 errmsg ("At least one port or port range required");
16415 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,
16416 ip_source_and_port_range_check_add_del);
16418 mp->is_add = is_add;
16423 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
16428 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
16431 mp->mask_length = length;
16432 mp->number_of_ranges = vec_len (low_ports);
16434 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
16435 vec_free (low_ports);
16437 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
16438 vec_free (high_ports);
16440 mp->vrf_id = ntohl (vrf_id);
16449 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
16451 unformat_input_t *input = vam->input;
16452 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
16454 u32 sw_if_index = ~0;
16456 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
16457 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
16460 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16462 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16464 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16466 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
16468 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
16470 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
16472 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
16474 else if (unformat (input, "del"))
16480 if (sw_if_index == ~0)
16482 errmsg ("Interface required but not specified");
16488 errmsg ("VRF ID required but not specified");
16492 if (tcp_out_vrf_id == 0
16493 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
16496 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16500 /* Construct the API message */
16501 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,
16502 ip_source_and_port_range_check_interface_add_del);
16504 mp->sw_if_index = ntohl (sw_if_index);
16505 mp->is_add = is_add;
16506 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
16507 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
16508 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
16509 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
16514 /* Wait for a reply... */
16519 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
16521 unformat_input_t *i = vam->input;
16522 vl_api_ipsec_gre_add_del_tunnel_t *mp;
16524 u32 local_sa_id = 0;
16525 u32 remote_sa_id = 0;
16526 ip4_address_t src_address;
16527 ip4_address_t dst_address;
16530 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16532 if (unformat (i, "local_sa %d", &local_sa_id))
16534 else if (unformat (i, "remote_sa %d", &remote_sa_id))
16536 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
16538 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
16540 else if (unformat (i, "del"))
16544 clib_warning ("parse error '%U'", format_unformat_error, i);
16549 M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel);
16551 mp->local_sa_id = ntohl (local_sa_id);
16552 mp->remote_sa_id = ntohl (remote_sa_id);
16553 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
16554 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
16555 mp->is_add = is_add;
16564 api_punt (vat_main_t * vam)
16566 unformat_input_t *i = vam->input;
16574 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16576 if (unformat (i, "ip %d", &ipv))
16578 else if (unformat (i, "protocol %d", &protocol))
16580 else if (unformat (i, "port %d", &port))
16582 else if (unformat (i, "del"))
16586 clib_warning ("parse error '%U'", format_unformat_error, i);
16593 mp->is_add = (u8) is_add;
16594 mp->ipv = (u8) ipv;
16595 mp->l4_protocol = (u8) protocol;
16596 mp->l4_port = htons ((u16) port);
16604 static void vl_api_ipsec_gre_tunnel_details_t_handler
16605 (vl_api_ipsec_gre_tunnel_details_t * mp)
16607 vat_main_t *vam = &vat_main;
16609 print (vam->ofp, "%11d%15U%15U%14d%14d",
16610 ntohl (mp->sw_if_index),
16611 format_ip4_address, &mp->src_address,
16612 format_ip4_address, &mp->dst_address,
16613 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
16616 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
16617 (vl_api_ipsec_gre_tunnel_details_t * mp)
16619 vat_main_t *vam = &vat_main;
16620 vat_json_node_t *node = NULL;
16621 struct in_addr ip4;
16623 if (VAT_JSON_ARRAY != vam->json_tree.type)
16625 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16626 vat_json_init_array (&vam->json_tree);
16628 node = vat_json_array_add (&vam->json_tree);
16630 vat_json_init_object (node);
16631 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
16632 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
16633 vat_json_object_add_ip4 (node, "src_address", ip4);
16634 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
16635 vat_json_object_add_ip4 (node, "dst_address", ip4);
16636 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
16637 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
16641 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
16643 unformat_input_t *i = vam->input;
16644 vl_api_ipsec_gre_tunnel_dump_t *mp;
16647 u8 sw_if_index_set = 0;
16649 /* Parse args required to build the message */
16650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16652 if (unformat (i, "sw_if_index %d", &sw_if_index))
16653 sw_if_index_set = 1;
16658 if (sw_if_index_set == 0)
16663 if (!vam->json_output)
16665 print (vam->ofp, "%11s%15s%15s%14s%14s",
16666 "sw_if_index", "src_address", "dst_address",
16667 "local_sa_id", "remote_sa_id");
16670 /* Get list of gre-tunnel interfaces */
16671 M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump);
16673 mp->sw_if_index = htonl (sw_if_index);
16677 /* Use a control ping for synchronization */
16679 vl_api_control_ping_t *mp;
16680 M (CONTROL_PING, control_ping);
16687 api_delete_subif (vat_main_t * vam)
16689 unformat_input_t *i = vam->input;
16690 vl_api_delete_subif_t *mp;
16692 u32 sw_if_index = ~0;
16694 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16696 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16698 if (unformat (i, "sw_if_index %d", &sw_if_index))
16704 if (sw_if_index == ~0)
16706 errmsg ("missing sw_if_index");
16710 /* Construct the API message */
16711 M (DELETE_SUBIF, delete_subif);
16712 mp->sw_if_index = ntohl (sw_if_index);
16718 #define foreach_pbb_vtr_op \
16719 _("disable", L2_VTR_DISABLED) \
16720 _("pop", L2_VTR_POP_2) \
16721 _("push", L2_VTR_PUSH_2)
16724 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
16726 unformat_input_t *i = vam->input;
16727 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
16729 u32 sw_if_index = ~0, vtr_op = ~0;
16730 u16 outer_tag = ~0;
16731 u8 dmac[6], smac[6];
16732 u8 dmac_set = 0, smac_set = 0;
16737 /* Shut up coverity */
16738 memset (dmac, 0, sizeof (dmac));
16739 memset (smac, 0, sizeof (smac));
16741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16743 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16745 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16747 else if (unformat (i, "vtr_op %d", &vtr_op))
16749 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
16752 else if (unformat (i, "translate_pbb_stag"))
16754 if (unformat (i, "%d", &tmp))
16756 vtr_op = L2_VTR_TRANSLATE_2_1;
16762 ("translate_pbb_stag operation requires outer tag definition");
16766 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
16768 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
16770 else if (unformat (i, "sid %d", &sid))
16772 else if (unformat (i, "vlanid %d", &tmp))
16776 clib_warning ("parse error '%U'", format_unformat_error, i);
16781 if ((sw_if_index == ~0) || (vtr_op == ~0))
16783 errmsg ("missing sw_if_index or vtr operation");
16786 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
16787 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
16790 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
16794 M (L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite);
16795 mp->sw_if_index = ntohl (sw_if_index);
16796 mp->vtr_op = ntohl (vtr_op);
16797 mp->outer_tag = ntohs (outer_tag);
16798 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
16799 clib_memcpy (mp->b_smac, smac, sizeof (smac));
16800 mp->b_vlanid = ntohs (vlanid);
16801 mp->i_sid = ntohl (sid);
16810 api_flow_classify_set_interface (vat_main_t * vam)
16812 unformat_input_t *i = vam->input;
16813 vl_api_flow_classify_set_interface_t *mp;
16816 int sw_if_index_set;
16817 u32 ip4_table_index = ~0;
16818 u32 ip6_table_index = ~0;
16821 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16823 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16824 sw_if_index_set = 1;
16825 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16826 sw_if_index_set = 1;
16827 else if (unformat (i, "del"))
16829 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16831 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16835 clib_warning ("parse error '%U'", format_unformat_error, i);
16840 if (sw_if_index_set == 0)
16842 errmsg ("missing interface name or sw_if_index");
16846 M (FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface);
16848 mp->sw_if_index = ntohl (sw_if_index);
16849 mp->ip4_table_index = ntohl (ip4_table_index);
16850 mp->ip6_table_index = ntohl (ip6_table_index);
16851 mp->is_add = is_add;
16860 api_flow_classify_dump (vat_main_t * vam)
16862 unformat_input_t *i = vam->input;
16863 vl_api_flow_classify_dump_t *mp;
16865 u8 type = FLOW_CLASSIFY_N_TABLES;
16867 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
16871 errmsg ("classify table type must be specified");
16875 if (!vam->json_output)
16877 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
16880 M (FLOW_CLASSIFY_DUMP, flow_classify_dump);
16885 /* Use a control ping for synchronization */
16887 vl_api_control_ping_t *mp;
16888 M (CONTROL_PING, control_ping);
16891 /* Wait for a reply... */
16899 api_feature_enable_disable (vat_main_t * vam)
16901 unformat_input_t *i = vam->input;
16902 vl_api_feature_enable_disable_t *mp;
16905 u8 *feature_name = 0;
16906 u32 sw_if_index = ~0;
16909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16911 if (unformat (i, "arc_name %s", &arc_name))
16913 else if (unformat (i, "feature_name %s", &feature_name))
16916 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16918 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16920 else if (unformat (i, "disable"))
16928 errmsg ("missing arc name");
16931 if (vec_len (arc_name) > 63)
16933 errmsg ("arc name too long");
16936 if (feature_name == 0)
16938 errmsg ("missing feature name");
16941 if (vec_len (feature_name) > 63)
16943 errmsg ("feature name too long");
16946 if (sw_if_index == ~0)
16948 errmsg ("missing interface name or sw_if_index");
16952 /* Construct the API message */
16953 M (FEATURE_ENABLE_DISABLE, feature_enable_disable);
16954 mp->sw_if_index = ntohl (sw_if_index);
16955 mp->enable = enable;
16956 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
16957 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
16958 vec_free (arc_name);
16959 vec_free (feature_name);
16966 api_sw_interface_tag_add_del (vat_main_t * vam)
16968 unformat_input_t *i = vam->input;
16969 vl_api_sw_interface_tag_add_del_t *mp;
16971 u32 sw_if_index = ~0;
16975 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16977 if (unformat (i, "tag %s", &tag))
16979 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16981 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16983 else if (unformat (i, "del"))
16989 if (sw_if_index == ~0)
16991 errmsg ("missing interface name or sw_if_index");
16995 if (enable && (tag == 0))
16997 errmsg ("no tag specified");
17001 /* Construct the API message */
17002 M (SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del);
17003 mp->sw_if_index = ntohl (sw_if_index);
17004 mp->is_add = enable;
17006 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
17013 static void vl_api_l2_xconnect_details_t_handler
17014 (vl_api_l2_xconnect_details_t * mp)
17016 vat_main_t *vam = &vat_main;
17018 print (vam->ofp, "%15d%15d",
17019 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
17022 static void vl_api_l2_xconnect_details_t_handler_json
17023 (vl_api_l2_xconnect_details_t * mp)
17025 vat_main_t *vam = &vat_main;
17026 vat_json_node_t *node = NULL;
17028 if (VAT_JSON_ARRAY != vam->json_tree.type)
17030 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17031 vat_json_init_array (&vam->json_tree);
17033 node = vat_json_array_add (&vam->json_tree);
17035 vat_json_init_object (node);
17036 vat_json_object_add_uint (node, "rx_sw_if_index",
17037 ntohl (mp->rx_sw_if_index));
17038 vat_json_object_add_uint (node, "tx_sw_if_index",
17039 ntohl (mp->tx_sw_if_index));
17043 api_l2_xconnect_dump (vat_main_t * vam)
17045 vl_api_l2_xconnect_dump_t *mp;
17048 if (!vam->json_output)
17050 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
17053 M (L2_XCONNECT_DUMP, l2_xconnect_dump);
17057 /* Use a control ping for synchronization */
17059 vl_api_control_ping_t *mp;
17060 M (CONTROL_PING, control_ping);
17067 api_sw_interface_set_mtu (vat_main_t * vam)
17069 unformat_input_t *i = vam->input;
17070 vl_api_sw_interface_set_mtu_t *mp;
17072 u32 sw_if_index = ~0;
17075 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17077 if (unformat (i, "mtu %d", &mtu))
17079 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17081 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17087 if (sw_if_index == ~0)
17089 errmsg ("missing interface name or sw_if_index");
17095 errmsg ("no mtu specified");
17099 /* Construct the API message */
17100 M (SW_INTERFACE_SET_MTU, sw_interface_set_mtu);
17101 mp->sw_if_index = ntohl (sw_if_index);
17102 mp->mtu = ntohs ((u16) mtu);
17110 q_or_quit (vat_main_t * vam)
17112 longjmp (vam->jump_buf, 1);
17113 return 0; /* not so much */
17117 q (vat_main_t * vam)
17119 return q_or_quit (vam);
17123 quit (vat_main_t * vam)
17125 return q_or_quit (vam);
17129 comment (vat_main_t * vam)
17135 cmd_cmp (void *a1, void *a2)
17140 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17144 help (vat_main_t * vam)
17149 unformat_input_t *i = vam->input;
17152 if (unformat (i, "%s", &name))
17156 vec_add1 (name, 0);
17158 hs = hash_get_mem (vam->help_by_name, name);
17160 print (vam->ofp, "usage: %s %s", name, hs[0]);
17162 print (vam->ofp, "No such msg / command '%s'", name);
17167 print (vam->ofp, "Help is available for the following:");
17170 hash_foreach_pair (p, vam->function_by_name,
17172 vec_add1 (cmds, (u8 *)(p->key));
17176 vec_sort_with_function (cmds, cmd_cmp);
17178 for (j = 0; j < vec_len (cmds); j++)
17179 print (vam->ofp, "%s", cmds[j]);
17186 set (vat_main_t * vam)
17188 u8 *name = 0, *value = 0;
17189 unformat_input_t *i = vam->input;
17191 if (unformat (i, "%s", &name))
17193 /* The input buffer is a vector, not a string. */
17194 value = vec_dup (i->buffer);
17195 vec_delete (value, i->index, 0);
17196 /* Almost certainly has a trailing newline */
17197 if (value[vec_len (value) - 1] == '\n')
17198 value[vec_len (value) - 1] = 0;
17199 /* Make sure it's a proper string, one way or the other */
17200 vec_add1 (value, 0);
17201 (void) clib_macro_set_value (&vam->macro_main,
17202 (char *) name, (char *) value);
17205 errmsg ("usage: set <name> <value>");
17213 unset (vat_main_t * vam)
17217 if (unformat (vam->input, "%s", &name))
17218 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17219 errmsg ("unset: %s wasn't set", name);
17232 macro_sort_cmp (void *a1, void *a2)
17234 macro_sort_t *s1 = a1;
17235 macro_sort_t *s2 = a2;
17237 return strcmp ((char *) (s1->name), (char *) (s2->name));
17241 dump_macro_table (vat_main_t * vam)
17243 macro_sort_t *sort_me = 0, *sm;
17248 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17250 vec_add2 (sort_me, sm, 1);
17251 sm->name = (u8 *)(p->key);
17252 sm->value = (u8 *) (p->value[0]);
17256 vec_sort_with_function (sort_me, macro_sort_cmp);
17258 if (vec_len (sort_me))
17259 print (vam->ofp, "%-15s%s", "Name", "Value");
17261 print (vam->ofp, "The macro table is empty...");
17263 for (i = 0; i < vec_len (sort_me); i++)
17264 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
17269 dump_node_table (vat_main_t * vam)
17272 vlib_node_t *node, *next_node;
17274 if (vec_len (vam->graph_nodes) == 0)
17276 print (vam->ofp, "Node table empty, issue get_node_graph...");
17280 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17282 node = vam->graph_nodes[i];
17283 print (vam->ofp, "[%d] %s", i, node->name);
17284 for (j = 0; j < vec_len (node->next_nodes); j++)
17286 if (node->next_nodes[j] != ~0)
17288 next_node = vam->graph_nodes[node->next_nodes[j]];
17289 print (vam->ofp, " [%d] %s", j, next_node->name);
17297 value_sort_cmp (void *a1, void *a2)
17299 name_sort_t *n1 = a1;
17300 name_sort_t *n2 = a2;
17302 if (n1->value < n2->value)
17304 if (n1->value > n2->value)
17311 dump_msg_api_table (vat_main_t * vam)
17313 api_main_t *am = &api_main;
17314 name_sort_t *nses = 0, *ns;
17319 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
17321 vec_add2 (nses, ns, 1);
17322 ns->name = (u8 *)(hp->key);
17323 ns->value = (u32) hp->value[0];
17327 vec_sort_with_function (nses, value_sort_cmp);
17329 for (i = 0; i < vec_len (nses); i++)
17330 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
17336 get_msg_id (vat_main_t * vam)
17341 if (unformat (vam->input, "%s", &name_and_crc))
17343 message_index = vl_api_get_msg_index (name_and_crc);
17344 if (message_index == ~0)
17346 print (vam->ofp, " '%s' not found", name_and_crc);
17349 print (vam->ofp, " '%s' has message index %d",
17350 name_and_crc, message_index);
17353 errmsg ("name_and_crc required...");
17358 search_node_table (vat_main_t * vam)
17360 unformat_input_t *line_input = vam->input;
17363 vlib_node_t *node, *next_node;
17366 if (vam->graph_node_index_by_name == 0)
17368 print (vam->ofp, "Node table empty, issue get_node_graph...");
17372 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
17374 if (unformat (line_input, "%s", &node_to_find))
17376 vec_add1 (node_to_find, 0);
17377 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
17380 print (vam->ofp, "%s not found...", node_to_find);
17383 node = vam->graph_nodes[p[0]];
17384 print (vam->ofp, "[%d] %s", p[0], node->name);
17385 for (j = 0; j < vec_len (node->next_nodes); j++)
17387 if (node->next_nodes[j] != ~0)
17389 next_node = vam->graph_nodes[node->next_nodes[j]];
17390 print (vam->ofp, " [%d] %s", j, next_node->name);
17397 clib_warning ("parse error '%U'", format_unformat_error,
17403 vec_free (node_to_find);
17412 script (vat_main_t * vam)
17414 #if (VPP_API_TEST_BUILTIN==0)
17416 char *save_current_file;
17417 unformat_input_t save_input;
17418 jmp_buf save_jump_buf;
17419 u32 save_line_number;
17421 FILE *new_fp, *save_ifp;
17423 if (unformat (vam->input, "%s", &s))
17425 new_fp = fopen ((char *) s, "r");
17428 errmsg ("Couldn't open script file %s", s);
17435 errmsg ("Missing script name");
17439 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
17440 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
17441 save_ifp = vam->ifp;
17442 save_line_number = vam->input_line_number;
17443 save_current_file = (char *) vam->current_file;
17445 vam->input_line_number = 0;
17447 vam->current_file = s;
17450 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
17451 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
17452 vam->ifp = save_ifp;
17453 vam->input_line_number = save_line_number;
17454 vam->current_file = (u8 *) save_current_file;
17459 clib_warning ("use the exec command...");
17465 echo (vat_main_t * vam)
17467 print (vam->ofp, "%v", vam->input->buffer);
17471 /* List of API message constructors, CLI names map to api_xxx */
17472 #define foreach_vpe_api_msg \
17473 _(create_loopback,"[mac <mac-addr>]") \
17474 _(sw_interface_dump,"") \
17475 _(sw_interface_set_flags, \
17476 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
17477 _(sw_interface_add_del_address, \
17478 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
17479 _(sw_interface_set_table, \
17480 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
17481 _(sw_interface_set_mpls_enable, \
17482 "<intfc> | sw_if_index [disable | dis]") \
17483 _(sw_interface_set_vpath, \
17484 "<intfc> | sw_if_index <id> enable | disable") \
17485 _(sw_interface_set_vxlan_bypass, \
17486 "<intfc> | sw_if_index <id> [ip4 | ip6] enable | disable") \
17487 _(sw_interface_set_l2_xconnect, \
17488 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17489 "enable | disable") \
17490 _(sw_interface_set_l2_bridge, \
17491 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
17492 "[shg <split-horizon-group>] [bvi]\n" \
17493 "enable | disable") \
17494 _(bridge_domain_add_del, \
17495 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
17496 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
17498 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
17500 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
17502 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
17504 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
17506 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
17508 "<vpp-if-name> | sw_if_index <id>") \
17509 _(sw_interface_tap_dump, "") \
17510 _(ip_add_del_route, \
17511 "<addr>/<mask> via <addr> [table-id <n>]\n" \
17512 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17513 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17514 "[multipath] [count <n>]") \
17515 _(mpls_route_add_del, \
17516 "<label> <eos> via <addr> [table-id <n>]\n" \
17517 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17518 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17519 "[multipath] [count <n>]") \
17520 _(mpls_ip_bind_unbind, \
17521 "<label> <addr/len>") \
17522 _(mpls_tunnel_add_del, \
17523 " via <addr> [table-id <n>]\n" \
17524 "sw_if_index <id>] [l2] [del]") \
17525 _(proxy_arp_add_del, \
17526 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
17527 _(proxy_arp_intfc_enable_disable, \
17528 "<intfc> | sw_if_index <id> enable | disable") \
17529 _(sw_interface_set_unnumbered, \
17530 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
17531 _(ip_neighbor_add_del, \
17532 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
17533 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
17534 _(reset_vrf, "vrf <id> [ipv6]") \
17535 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
17536 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
17537 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
17538 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
17539 "[outer_vlan_id_any][inner_vlan_id_any]") \
17540 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
17541 _(reset_fib, "vrf <n> [ipv6]") \
17542 _(dhcp_proxy_config, \
17543 "svr <v46-address> src <v46-address>\n" \
17544 "insert-cid <n> [del]") \
17545 _(dhcp_proxy_config_2, \
17546 "svr <v46-address> src <v46-address>\n" \
17547 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
17548 _(dhcp_proxy_set_vss, \
17549 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
17550 _(dhcp_client_config, \
17551 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
17552 _(set_ip_flow_hash, \
17553 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
17554 _(sw_interface_ip6_enable_disable, \
17555 "<intfc> | sw_if_index <id> enable | disable") \
17556 _(sw_interface_ip6_set_link_local_address, \
17557 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
17558 _(sw_interface_ip6nd_ra_prefix, \
17559 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
17560 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
17561 "[nolink] [isno]") \
17562 _(sw_interface_ip6nd_ra_config, \
17563 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
17564 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
17565 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
17566 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
17567 _(l2_patch_add_del, \
17568 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17569 "enable | disable") \
17570 _(sr_tunnel_add_del, \
17571 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
17572 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
17573 "[policy <policy_name>]") \
17574 _(sr_policy_add_del, \
17575 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
17576 _(sr_multicast_map_add_del, \
17577 "address [ip6 multicast address] sr-policy [policy name] [del]") \
17578 _(classify_add_del_table, \
17579 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
17580 " [del] [del-chain] mask <mask-value>\n" \
17581 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
17582 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
17583 _(classify_add_del_session, \
17584 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
17585 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
17586 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
17587 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
17588 _(classify_set_interface_ip_table, \
17589 "<intfc> | sw_if_index <nn> table <nn>") \
17590 _(classify_set_interface_l2_tables, \
17591 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17592 " [other-table <nn>]") \
17593 _(get_node_index, "node <node-name") \
17594 _(add_node_next, "node <node-name> next <next-node-name>") \
17595 _(l2tpv3_create_tunnel, \
17596 "client_address <ip6-addr> our_address <ip6-addr>\n" \
17597 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
17598 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
17599 _(l2tpv3_set_tunnel_cookies, \
17600 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
17601 "[new_remote_cookie <nn>]\n") \
17602 _(l2tpv3_interface_enable_disable, \
17603 "<intfc> | sw_if_index <nn> enable | disable") \
17604 _(l2tpv3_set_lookup_key, \
17605 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
17606 _(sw_if_l2tpv3_tunnel_dump, "") \
17607 _(vxlan_add_del_tunnel, \
17608 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
17609 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
17610 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
17611 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17612 _(gre_add_del_tunnel, \
17613 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
17614 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17615 _(l2_fib_clear_table, "") \
17616 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
17617 _(l2_interface_vlan_tag_rewrite, \
17618 "<intfc> | sw_if_index <nn> \n" \
17619 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
17620 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
17621 _(create_vhost_user_if, \
17622 "socket <filename> [server] [renumber <dev_instance>] " \
17623 "[mac <mac_address>]") \
17624 _(modify_vhost_user_if, \
17625 "<intfc> | sw_if_index <nn> socket <filename>\n" \
17626 "[server] [renumber <dev_instance>]") \
17627 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
17628 _(sw_interface_vhost_user_dump, "") \
17629 _(show_version, "") \
17630 _(vxlan_gpe_add_del_tunnel, \
17631 "local <addr> remote <addr> vni <nn>\n" \
17632 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
17633 "[next-ethernet] [next-nsh]\n") \
17634 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17635 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
17636 _(interface_name_renumber, \
17637 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
17638 _(input_acl_set_interface, \
17639 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17640 " [l2-table <nn>] [del]") \
17641 _(want_ip4_arp_events, "address <ip4-address> [del]") \
17642 _(want_ip6_nd_events, "address <ip6-address> [del]") \
17643 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
17644 _(ip_dump, "ipv4 | ipv6") \
17645 _(ipsec_spd_add_del, "spd_id <n> [del]") \
17646 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
17648 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
17649 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
17650 " integ_alg <alg> integ_key <hex>") \
17651 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
17652 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
17653 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
17654 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
17655 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
17656 _(ikev2_profile_add_del, "name <profile_name> [del]") \
17657 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
17658 "(auth_data 0x<data> | auth_data <data>)") \
17659 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
17660 "(id_data 0x<data> | id_data <data>) (local|remote)") \
17661 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
17662 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
17663 "(local|remote)") \
17664 _(ikev2_set_local_key, "file <absolute_file_path>") \
17665 _(delete_loopback,"sw_if_index <nn>") \
17666 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
17667 _(map_add_domain, \
17668 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
17669 "ip6-src <ip6addr> " \
17670 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
17671 _(map_del_domain, "index <n>") \
17672 _(map_add_del_rule, \
17673 "index <n> psid <n> dst <ip6addr> [del]") \
17674 _(map_domain_dump, "") \
17675 _(map_rule_dump, "index <map-domain>") \
17676 _(want_interface_events, "enable|disable") \
17677 _(want_stats,"enable|disable") \
17678 _(get_first_msg_id, "client <name>") \
17679 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
17680 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
17681 "fib-id <nn> [ip4][ip6][default]") \
17682 _(get_node_graph, " ") \
17683 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
17684 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
17685 _(ioam_disable, "") \
17686 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
17687 " sw_if_index <sw_if_index> p <priority> " \
17688 "w <weight>] [del]") \
17689 _(lisp_add_del_locator, "locator-set <locator_name> " \
17690 "iface <intf> | sw_if_index <sw_if_index> " \
17691 "p <priority> w <weight> [del]") \
17692 _(lisp_add_del_local_eid,"vni <vni> eid " \
17693 "<ipv4|ipv6>/<prefix> | <L2 address> " \
17694 "locator-set <locator_name> [del]" \
17695 "[key-id sha1|sha256 secret-key <secret-key>]") \
17696 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
17697 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
17698 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
17699 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
17700 _(lisp_gpe_enable_disable, "enable|disable") \
17701 _(lisp_enable_disable, "enable|disable") \
17702 _(lisp_map_register_enable_disable, "enable|disable") \
17703 _(lisp_rloc_probe_enable_disable, "enable|disable") \
17704 _(lisp_gpe_add_del_iface, "up|down") \
17705 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
17707 "rloc <locator> p <prio> " \
17708 "w <weight> [rloc <loc> ... ] " \
17709 "action <action> [del-all]") \
17710 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
17712 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
17713 _(lisp_map_request_mode, "src-dst|dst-only") \
17714 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
17715 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
17716 _(lisp_locator_set_dump, "[local | remote]") \
17717 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
17718 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
17719 "[local] | [remote]") \
17720 _(lisp_eid_table_vni_dump, "") \
17721 _(lisp_eid_table_map_dump, "l2|l3") \
17722 _(lisp_map_resolver_dump, "") \
17723 _(lisp_map_server_dump, "") \
17724 _(lisp_adjacencies_get, "vni <vni>") \
17725 _(show_lisp_rloc_probe_state, "") \
17726 _(show_lisp_map_register_state, "") \
17727 _(show_lisp_status, "") \
17728 _(lisp_get_map_request_itr_rlocs, "") \
17729 _(show_lisp_pitr, "") \
17730 _(show_lisp_map_request_mode, "") \
17731 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
17732 _(af_packet_delete, "name <host interface name>") \
17733 _(policer_add_del, "name <policer name> <params> [del]") \
17734 _(policer_dump, "[name <policer name>]") \
17735 _(policer_classify_set_interface, \
17736 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17737 " [l2-table <nn>] [del]") \
17738 _(policer_classify_dump, "type [ip4|ip6|l2]") \
17739 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
17740 "[master|slave]") \
17741 _(netmap_delete, "name <interface name>") \
17742 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
17743 _(mpls_fib_dump, "") \
17744 _(classify_table_ids, "") \
17745 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
17746 _(classify_table_info, "table_id <nn>") \
17747 _(classify_session_dump, "table_id <nn>") \
17748 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
17749 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
17750 "[template_interval <nn>] [udp_checksum]") \
17751 _(ipfix_exporter_dump, "") \
17752 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
17753 _(ipfix_classify_stream_dump, "") \
17754 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
17755 _(ipfix_classify_table_dump, "") \
17756 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
17757 _(sw_interface_span_dump, "") \
17758 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
17759 _(pg_create_interface, "if_id <nn>") \
17760 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
17761 _(pg_enable_disable, "[stream <id>] disable") \
17762 _(ip_source_and_port_range_check_add_del, \
17763 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
17764 _(ip_source_and_port_range_check_interface_add_del, \
17765 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
17766 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
17767 _(ipsec_gre_add_del_tunnel, \
17768 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
17769 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
17770 _(delete_subif,"<intfc> | sw_if_index <nn>") \
17771 _(l2_interface_pbb_tag_rewrite, \
17772 "<intfc> | sw_if_index <nn> \n" \
17773 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
17774 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
17775 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
17776 _(flow_classify_set_interface, \
17777 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
17778 _(flow_classify_dump, "type [ip4|ip6]") \
17779 _(ip_fib_dump, "") \
17780 _(ip6_fib_dump, "") \
17781 _(feature_enable_disable, "arc_name <arc_name> " \
17782 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
17783 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
17785 _(l2_xconnect_dump, "") \
17786 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
17787 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
17788 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
17791 #define foreach_vpe_dpdk_api_msg \
17792 _(sw_interface_set_dpdk_hqos_pipe, \
17793 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
17794 "profile <profile-id>\n") \
17795 _(sw_interface_set_dpdk_hqos_subport, \
17796 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
17797 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
17798 _(sw_interface_set_dpdk_hqos_tctbl, \
17799 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n")
17802 /* List of command functions, CLI names map directly to functions */
17803 #define foreach_cli_function \
17804 _(comment, "usage: comment <ignore-rest-of-line>") \
17805 _(dump_interface_table, "usage: dump_interface_table") \
17806 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
17807 _(dump_ipv4_table, "usage: dump_ipv4_table") \
17808 _(dump_ipv6_table, "usage: dump_ipv6_table") \
17809 _(dump_stats_table, "usage: dump_stats_table") \
17810 _(dump_macro_table, "usage: dump_macro_table ") \
17811 _(dump_node_table, "usage: dump_node_table") \
17812 _(dump_msg_api_table, "usage: dump_msg_api_table") \
17813 _(get_msg_id, "usage: get_msg_id name_and_crc") \
17814 _(echo, "usage: echo <message>") \
17815 _(exec, "usage: exec <vpe-debug-CLI-command>") \
17816 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
17817 _(help, "usage: help") \
17818 _(q, "usage: quit") \
17819 _(quit, "usage: quit") \
17820 _(search_node_table, "usage: search_node_table <name>...") \
17821 _(set, "usage: set <variable-name> <value>") \
17822 _(script, "usage: script <file-name>") \
17823 _(unset, "usage: unset <variable-name>")
17826 static void vl_api_##n##_t_handler_uni \
17827 (vl_api_##n##_t * mp) \
17829 vat_main_t * vam = &vat_main; \
17830 if (vam->json_output) { \
17831 vl_api_##n##_t_handler_json(mp); \
17833 vl_api_##n##_t_handler(mp); \
17836 foreach_vpe_api_reply_msg;
17841 static void vl_api_##n##_t_handler_uni \
17842 (vl_api_##n##_t * mp) \
17844 vat_main_t * vam = &vat_main; \
17845 if (vam->json_output) { \
17846 vl_api_##n##_t_handler_json(mp); \
17848 vl_api_##n##_t_handler(mp); \
17851 foreach_vpe_dpdk_api_reply_msg;
17856 vat_api_hookup (vat_main_t * vam)
17859 vl_msg_api_set_handlers(VL_API_##N, #n, \
17860 vl_api_##n##_t_handler_uni, \
17862 vl_api_##n##_t_endian, \
17863 vl_api_##n##_t_print, \
17864 sizeof(vl_api_##n##_t), 1);
17865 foreach_vpe_api_reply_msg;
17870 vl_msg_api_set_handlers(VL_API_##N, #n, \
17871 vl_api_##n##_t_handler_uni, \
17873 vl_api_##n##_t_endian, \
17874 vl_api_##n##_t_print, \
17875 sizeof(vl_api_##n##_t), 1);
17876 foreach_vpe_dpdk_api_reply_msg;
17880 #if (VPP_API_TEST_BUILTIN==0)
17881 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
17884 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
17886 vam->function_by_name = hash_create_string (0, sizeof (uword));
17888 vam->help_by_name = hash_create_string (0, sizeof (uword));
17890 /* API messages we can send */
17891 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
17892 foreach_vpe_api_msg;
17895 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
17896 foreach_vpe_dpdk_api_msg;
17901 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17902 foreach_vpe_api_msg;
17905 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17906 foreach_vpe_dpdk_api_msg;
17910 /* CLI functions */
17911 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
17912 foreach_cli_function;
17916 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17917 foreach_cli_function;
17922 * fd.io coding-style-patch-verification: ON
17925 * eval: (c-set-style "gnu")