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/mpls/mpls.h>
40 #include <vnet/ipsec/ipsec.h>
41 #include <vnet/ipsec/ikev2.h>
45 #include <vnet/map/map.h>
46 #include <vnet/cop/cop.h>
47 #include <vnet/ip/ip6_hop_by_hop.h>
48 #include <vnet/ip/ip_source_and_port_range_check.h>
49 #include <vnet/policer/xlate.h>
50 #include <vnet/policer/policer.h>
51 #include <vnet/policer/police.h>
53 #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>
74 unformat_sw_if_index (unformat_input_t * input, va_list * args)
76 vat_main_t *vam = va_arg (*args, vat_main_t *);
77 u32 *result = va_arg (*args, u32 *);
81 if (!unformat (input, "%s", &if_name))
84 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
91 /* Parse an IP4 address %d.%d.%d.%d. */
93 unformat_ip4_address (unformat_input_t * input, va_list * args)
95 u8 *result = va_arg (*args, u8 *);
98 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
101 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
114 unformat_ethernet_address (unformat_input_t * input, va_list * args)
116 u8 *result = va_arg (*args, u8 *);
119 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
120 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
124 for (i = 0; i < 6; i++)
125 if (a[i] >= (1 << 8))
128 for (i = 0; i < 6; i++)
134 /* Returns ethernet type as an int in host byte order. */
136 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
139 u16 *result = va_arg (*args, u16 *);
143 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
145 if (type >= (1 << 16))
153 /* Parse an IP6 address. */
155 unformat_ip6_address (unformat_input_t * input, va_list * args)
157 ip6_address_t *result = va_arg (*args, ip6_address_t *);
159 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
160 uword c, n_colon, double_colon_index;
162 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
163 double_colon_index = ARRAY_LEN (hex_quads);
164 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
167 if (c >= '0' && c <= '9')
169 else if (c >= 'a' && c <= 'f')
170 hex_digit = c + 10 - 'a';
171 else if (c >= 'A' && c <= 'F')
172 hex_digit = c + 10 - 'A';
173 else if (c == ':' && n_colon < 2)
177 unformat_put_input (input);
181 /* Too many hex quads. */
182 if (n_hex_quads >= ARRAY_LEN (hex_quads))
187 hex_quad = (hex_quad << 4) | hex_digit;
189 /* Hex quad must fit in 16 bits. */
190 if (n_hex_digits >= 4)
197 /* Save position of :: */
200 /* More than one :: ? */
201 if (double_colon_index < ARRAY_LEN (hex_quads))
203 double_colon_index = n_hex_quads;
206 if (n_colon > 0 && n_hex_digits > 0)
208 hex_quads[n_hex_quads++] = hex_quad;
214 if (n_hex_digits > 0)
215 hex_quads[n_hex_quads++] = hex_quad;
220 /* Expand :: to appropriate number of zero hex quads. */
221 if (double_colon_index < ARRAY_LEN (hex_quads))
223 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
225 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
226 hex_quads[n_zero + i] = hex_quads[i];
228 for (i = 0; i < n_zero; i++)
229 hex_quads[double_colon_index + i] = 0;
231 n_hex_quads = ARRAY_LEN (hex_quads);
234 /* Too few hex quads given. */
235 if (n_hex_quads < ARRAY_LEN (hex_quads))
238 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
239 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
246 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
249 u32 *r = va_arg (*args, u32 *);
252 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
253 foreach_ipsec_policy_action
264 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
267 u32 *r = va_arg (*args, u32 *);
270 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
271 foreach_ipsec_crypto_alg
282 format_ipsec_crypto_alg (u8 * s, va_list * args)
285 u32 i = va_arg (*args, u32);
290 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
291 foreach_ipsec_crypto_alg
294 return format (s, "unknown");
296 return format (s, "%s", t);
298 return format (s, "Unimplemented");
303 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
306 u32 *r = va_arg (*args, u32 *);
309 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
310 foreach_ipsec_integ_alg
321 format_ipsec_integ_alg (u8 * s, va_list * args)
324 u32 i = va_arg (*args, u32);
329 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
330 foreach_ipsec_integ_alg
333 return format (s, "unknown");
335 return format (s, "%s", t);
337 return format (s, "Unsupported");
342 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
345 u32 *r = va_arg (*args, u32 *);
348 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
349 foreach_ikev2_auth_method
360 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
363 u32 *r = va_arg (*args, u32 *);
366 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
367 foreach_ikev2_id_type
378 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
380 u8 *r = va_arg (*args, u8 *);
382 if (unformat (input, "kbps"))
383 *r = SSE2_QOS_RATE_KBPS;
384 else if (unformat (input, "pps"))
385 *r = SSE2_QOS_RATE_PPS;
392 unformat_policer_round_type (unformat_input_t * input, va_list * args)
394 u8 *r = va_arg (*args, u8 *);
396 if (unformat (input, "closest"))
397 *r = SSE2_QOS_ROUND_TO_CLOSEST;
398 else if (unformat (input, "up"))
399 *r = SSE2_QOS_ROUND_TO_UP;
400 else if (unformat (input, "down"))
401 *r = SSE2_QOS_ROUND_TO_DOWN;
408 unformat_policer_type (unformat_input_t * input, va_list * args)
410 u8 *r = va_arg (*args, u8 *);
412 if (unformat (input, "1r2c"))
413 *r = SSE2_QOS_POLICER_TYPE_1R2C;
414 else if (unformat (input, "1r3c"))
415 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
416 else if (unformat (input, "2r3c-2698"))
417 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
418 else if (unformat (input, "2r3c-4115"))
419 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
420 else if (unformat (input, "2r3c-mef5cf1"))
421 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
428 unformat_dscp (unformat_input_t * input, va_list * va)
430 u8 *r = va_arg (*va, u8 *);
433 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
442 unformat_policer_action_type (unformat_input_t * input, va_list * va)
444 sse2_qos_pol_action_params_st *a
445 = va_arg (*va, sse2_qos_pol_action_params_st *);
447 if (unformat (input, "drop"))
448 a->action_type = SSE2_QOS_ACTION_DROP;
449 else if (unformat (input, "transmit"))
450 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
451 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
452 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
459 unformat_classify_table_type (unformat_input_t * input, va_list * va)
461 u32 *r = va_arg (*va, u32 *);
464 if (unformat (input, "ip4"))
465 tid = POLICER_CLASSIFY_TABLE_IP4;
466 else if (unformat (input, "ip6"))
467 tid = POLICER_CLASSIFY_TABLE_IP6;
468 else if (unformat (input, "l2"))
469 tid = POLICER_CLASSIFY_TABLE_L2;
478 format_ip4_address (u8 * s, va_list * args)
480 u8 *a = va_arg (*args, u8 *);
481 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
485 format_ip6_address (u8 * s, va_list * args)
487 ip6_address_t *a = va_arg (*args, ip6_address_t *);
488 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
490 i_max_n_zero = ARRAY_LEN (a->as_u16);
492 i_first_zero = i_max_n_zero;
494 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
496 u32 is_zero = a->as_u16[i] == 0;
497 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
503 if ((!is_zero && n_zeros > max_n_zeros)
504 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
506 i_max_n_zero = i_first_zero;
507 max_n_zeros = n_zeros;
508 i_first_zero = ARRAY_LEN (a->as_u16);
513 last_double_colon = 0;
514 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
516 if (i == i_max_n_zero && max_n_zeros > 1)
518 s = format (s, "::");
519 i += max_n_zeros - 1;
520 last_double_colon = 1;
524 s = format (s, "%s%x",
525 (last_double_colon || i == 0) ? "" : ":",
526 clib_net_to_host_u16 (a->as_u16[i]));
527 last_double_colon = 0;
534 /* Format an IP46 address. */
536 format_ip46_address (u8 * s, va_list * args)
538 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
539 ip46_type_t type = va_arg (*args, ip46_type_t);
545 is_ip4 = ip46_address_is_ip4 (ip46);
556 format (s, "%U", format_ip4_address, &ip46->ip4) :
557 format (s, "%U", format_ip6_address, &ip46->ip6);
561 format_ethernet_address (u8 * s, va_list * args)
563 u8 *a = va_arg (*args, u8 *);
565 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
566 a[0], a[1], a[2], a[3], a[4], a[5]);
570 increment_v4_address (ip4_address_t * a)
574 v = ntohl (a->as_u32) + 1;
575 a->as_u32 = ntohl (v);
579 increment_v6_address (ip6_address_t * a)
583 v0 = clib_net_to_host_u64 (a->as_u64[0]);
584 v1 = clib_net_to_host_u64 (a->as_u64[1]);
589 a->as_u64[0] = clib_net_to_host_u64 (v0);
590 a->as_u64[1] = clib_net_to_host_u64 (v1);
594 increment_mac_address (u64 * mac)
598 tmp = clib_net_to_host_u64 (tmp);
599 tmp += 1 << 16; /* skip unused (least significant) octets */
600 tmp = clib_host_to_net_u64 (tmp);
604 static void vl_api_create_loopback_reply_t_handler
605 (vl_api_create_loopback_reply_t * mp)
607 vat_main_t *vam = &vat_main;
608 i32 retval = ntohl (mp->retval);
610 vam->retval = retval;
611 vam->regenerate_interface_table = 1;
612 vam->sw_if_index = ntohl (mp->sw_if_index);
613 vam->result_ready = 1;
616 static void vl_api_create_loopback_reply_t_handler_json
617 (vl_api_create_loopback_reply_t * mp)
619 vat_main_t *vam = &vat_main;
620 vat_json_node_t node;
622 vat_json_init_object (&node);
623 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
624 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
626 vat_json_print (vam->ofp, &node);
627 vat_json_free (&node);
628 vam->retval = ntohl (mp->retval);
629 vam->result_ready = 1;
632 static void vl_api_af_packet_create_reply_t_handler
633 (vl_api_af_packet_create_reply_t * mp)
635 vat_main_t *vam = &vat_main;
636 i32 retval = ntohl (mp->retval);
638 vam->retval = retval;
639 vam->regenerate_interface_table = 1;
640 vam->sw_if_index = ntohl (mp->sw_if_index);
641 vam->result_ready = 1;
644 static void vl_api_af_packet_create_reply_t_handler_json
645 (vl_api_af_packet_create_reply_t * mp)
647 vat_main_t *vam = &vat_main;
648 vat_json_node_t node;
650 vat_json_init_object (&node);
651 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
652 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
654 vat_json_print (vam->ofp, &node);
655 vat_json_free (&node);
657 vam->retval = ntohl (mp->retval);
658 vam->result_ready = 1;
661 static void vl_api_create_vlan_subif_reply_t_handler
662 (vl_api_create_vlan_subif_reply_t * mp)
664 vat_main_t *vam = &vat_main;
665 i32 retval = ntohl (mp->retval);
667 vam->retval = retval;
668 vam->regenerate_interface_table = 1;
669 vam->sw_if_index = ntohl (mp->sw_if_index);
670 vam->result_ready = 1;
673 static void vl_api_create_vlan_subif_reply_t_handler_json
674 (vl_api_create_vlan_subif_reply_t * mp)
676 vat_main_t *vam = &vat_main;
677 vat_json_node_t node;
679 vat_json_init_object (&node);
680 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
681 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
683 vat_json_print (vam->ofp, &node);
684 vat_json_free (&node);
686 vam->retval = ntohl (mp->retval);
687 vam->result_ready = 1;
690 static void vl_api_create_subif_reply_t_handler
691 (vl_api_create_subif_reply_t * mp)
693 vat_main_t *vam = &vat_main;
694 i32 retval = ntohl (mp->retval);
696 vam->retval = retval;
697 vam->regenerate_interface_table = 1;
698 vam->sw_if_index = ntohl (mp->sw_if_index);
699 vam->result_ready = 1;
702 static void vl_api_create_subif_reply_t_handler_json
703 (vl_api_create_subif_reply_t * mp)
705 vat_main_t *vam = &vat_main;
706 vat_json_node_t node;
708 vat_json_init_object (&node);
709 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
710 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
712 vat_json_print (vam->ofp, &node);
713 vat_json_free (&node);
715 vam->retval = ntohl (mp->retval);
716 vam->result_ready = 1;
719 static void vl_api_interface_name_renumber_reply_t_handler
720 (vl_api_interface_name_renumber_reply_t * mp)
722 vat_main_t *vam = &vat_main;
723 i32 retval = ntohl (mp->retval);
725 vam->retval = retval;
726 vam->regenerate_interface_table = 1;
727 vam->result_ready = 1;
730 static void vl_api_interface_name_renumber_reply_t_handler_json
731 (vl_api_interface_name_renumber_reply_t * mp)
733 vat_main_t *vam = &vat_main;
734 vat_json_node_t node;
736 vat_json_init_object (&node);
737 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
739 vat_json_print (vam->ofp, &node);
740 vat_json_free (&node);
742 vam->retval = ntohl (mp->retval);
743 vam->result_ready = 1;
747 * Special-case: build the interface table, maintain
748 * the next loopback sw_if_index vbl.
750 static void vl_api_sw_interface_details_t_handler
751 (vl_api_sw_interface_details_t * mp)
753 vat_main_t *vam = &vat_main;
754 u8 *s = format (0, "%s%c", mp->interface_name, 0);
756 hash_set_mem (vam->sw_if_index_by_interface_name, s,
757 ntohl (mp->sw_if_index));
759 /* In sub interface case, fill the sub interface table entry */
760 if (mp->sw_if_index != mp->sup_sw_if_index)
762 sw_interface_subif_t *sub = NULL;
764 vec_add2 (vam->sw_if_subif_table, sub, 1);
766 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
767 strncpy ((char *) sub->interface_name, (char *) s,
768 vec_len (sub->interface_name));
769 sub->sw_if_index = ntohl (mp->sw_if_index);
770 sub->sub_id = ntohl (mp->sub_id);
772 sub->sub_dot1ad = mp->sub_dot1ad;
773 sub->sub_number_of_tags = mp->sub_number_of_tags;
774 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
775 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
776 sub->sub_exact_match = mp->sub_exact_match;
777 sub->sub_default = mp->sub_default;
778 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
779 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
781 /* vlan tag rewrite */
782 sub->vtr_op = ntohl (mp->vtr_op);
783 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
784 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
785 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
789 static void vl_api_sw_interface_details_t_handler_json
790 (vl_api_sw_interface_details_t * mp)
792 vat_main_t *vam = &vat_main;
793 vat_json_node_t *node = NULL;
795 if (VAT_JSON_ARRAY != vam->json_tree.type)
797 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
798 vat_json_init_array (&vam->json_tree);
800 node = vat_json_array_add (&vam->json_tree);
802 vat_json_init_object (node);
803 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
804 vat_json_object_add_uint (node, "sup_sw_if_index",
805 ntohl (mp->sup_sw_if_index));
806 vat_json_object_add_uint (node, "l2_address_length",
807 ntohl (mp->l2_address_length));
808 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
809 sizeof (mp->l2_address));
810 vat_json_object_add_string_copy (node, "interface_name",
812 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
813 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
814 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
815 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
816 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
817 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
818 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
819 vat_json_object_add_uint (node, "sub_number_of_tags",
820 mp->sub_number_of_tags);
821 vat_json_object_add_uint (node, "sub_outer_vlan_id",
822 ntohs (mp->sub_outer_vlan_id));
823 vat_json_object_add_uint (node, "sub_inner_vlan_id",
824 ntohs (mp->sub_inner_vlan_id));
825 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
826 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
827 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
828 mp->sub_outer_vlan_id_any);
829 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
830 mp->sub_inner_vlan_id_any);
831 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
832 vat_json_object_add_uint (node, "vtr_push_dot1q",
833 ntohl (mp->vtr_push_dot1q));
834 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
835 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
838 static void vl_api_sw_interface_set_flags_t_handler
839 (vl_api_sw_interface_set_flags_t * mp)
841 vat_main_t *vam = &vat_main;
842 if (vam->interface_event_display)
843 errmsg ("interface flags: sw_if_index %d %s %s\n",
844 ntohl (mp->sw_if_index),
845 mp->admin_up_down ? "admin-up" : "admin-down",
846 mp->link_up_down ? "link-up" : "link-down");
849 static void vl_api_sw_interface_set_flags_t_handler_json
850 (vl_api_sw_interface_set_flags_t * mp)
852 /* JSON output not supported */
856 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
858 vat_main_t *vam = &vat_main;
859 i32 retval = ntohl (mp->retval);
861 vam->retval = retval;
862 vam->shmem_result = (u8 *) mp->reply_in_shmem;
863 vam->result_ready = 1;
867 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
869 vat_main_t *vam = &vat_main;
870 vat_json_node_t node;
871 api_main_t *am = &api_main;
875 vat_json_init_object (&node);
876 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
877 vat_json_object_add_uint (&node, "reply_in_shmem",
878 ntohl (mp->reply_in_shmem));
879 /* Toss the shared-memory original... */
880 pthread_mutex_lock (&am->vlib_rp->mutex);
881 oldheap = svm_push_data_heap (am->vlib_rp);
883 reply = (u8 *) (mp->reply_in_shmem);
886 svm_pop_heap (oldheap);
887 pthread_mutex_unlock (&am->vlib_rp->mutex);
889 vat_json_print (vam->ofp, &node);
890 vat_json_free (&node);
892 vam->retval = ntohl (mp->retval);
893 vam->result_ready = 1;
897 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
899 vat_main_t *vam = &vat_main;
900 i32 retval = ntohl (mp->retval);
902 vam->retval = retval;
903 vam->cmd_reply = mp->reply;
904 vam->result_ready = 1;
908 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
910 vat_main_t *vam = &vat_main;
911 vat_json_node_t node;
913 vat_json_init_object (&node);
914 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
915 vat_json_object_add_string_copy (&node, "reply", mp->reply);
917 vat_json_print (vam->ofp, &node);
918 vat_json_free (&node);
920 vam->retval = ntohl (mp->retval);
921 vam->result_ready = 1;
924 static void vl_api_classify_add_del_table_reply_t_handler
925 (vl_api_classify_add_del_table_reply_t * mp)
927 vat_main_t *vam = &vat_main;
928 i32 retval = ntohl (mp->retval);
931 vam->async_errors += (retval < 0);
935 vam->retval = retval;
937 ((mp->new_table_index != 0xFFFFFFFF) ||
938 (mp->skip_n_vectors != 0xFFFFFFFF) ||
939 (mp->match_n_vectors != 0xFFFFFFFF)))
941 * Note: this is just barely thread-safe, depends on
942 * the main thread spinning waiting for an answer...
944 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d\n",
945 ntohl (mp->new_table_index),
946 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
947 vam->result_ready = 1;
951 static void vl_api_classify_add_del_table_reply_t_handler_json
952 (vl_api_classify_add_del_table_reply_t * mp)
954 vat_main_t *vam = &vat_main;
955 vat_json_node_t node;
957 vat_json_init_object (&node);
958 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
959 vat_json_object_add_uint (&node, "new_table_index",
960 ntohl (mp->new_table_index));
961 vat_json_object_add_uint (&node, "skip_n_vectors",
962 ntohl (mp->skip_n_vectors));
963 vat_json_object_add_uint (&node, "match_n_vectors",
964 ntohl (mp->match_n_vectors));
966 vat_json_print (vam->ofp, &node);
967 vat_json_free (&node);
969 vam->retval = ntohl (mp->retval);
970 vam->result_ready = 1;
973 static void vl_api_get_node_index_reply_t_handler
974 (vl_api_get_node_index_reply_t * mp)
976 vat_main_t *vam = &vat_main;
977 i32 retval = ntohl (mp->retval);
980 vam->async_errors += (retval < 0);
984 vam->retval = retval;
986 errmsg ("node index %d\n", ntohl (mp->node_index));
987 vam->result_ready = 1;
991 static void vl_api_get_node_index_reply_t_handler_json
992 (vl_api_get_node_index_reply_t * mp)
994 vat_main_t *vam = &vat_main;
995 vat_json_node_t node;
997 vat_json_init_object (&node);
998 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
999 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1001 vat_json_print (vam->ofp, &node);
1002 vat_json_free (&node);
1004 vam->retval = ntohl (mp->retval);
1005 vam->result_ready = 1;
1008 static void vl_api_get_next_index_reply_t_handler
1009 (vl_api_get_next_index_reply_t * mp)
1011 vat_main_t *vam = &vat_main;
1012 i32 retval = ntohl (mp->retval);
1013 if (vam->async_mode)
1015 vam->async_errors += (retval < 0);
1019 vam->retval = retval;
1021 errmsg ("next node index %d\n", ntohl (mp->next_index));
1022 vam->result_ready = 1;
1026 static void vl_api_get_next_index_reply_t_handler_json
1027 (vl_api_get_next_index_reply_t * mp)
1029 vat_main_t *vam = &vat_main;
1030 vat_json_node_t node;
1032 vat_json_init_object (&node);
1033 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1034 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1036 vat_json_print (vam->ofp, &node);
1037 vat_json_free (&node);
1039 vam->retval = ntohl (mp->retval);
1040 vam->result_ready = 1;
1043 static void vl_api_add_node_next_reply_t_handler
1044 (vl_api_add_node_next_reply_t * mp)
1046 vat_main_t *vam = &vat_main;
1047 i32 retval = ntohl (mp->retval);
1048 if (vam->async_mode)
1050 vam->async_errors += (retval < 0);
1054 vam->retval = retval;
1056 errmsg ("next index %d\n", ntohl (mp->next_index));
1057 vam->result_ready = 1;
1061 static void vl_api_add_node_next_reply_t_handler_json
1062 (vl_api_add_node_next_reply_t * mp)
1064 vat_main_t *vam = &vat_main;
1065 vat_json_node_t node;
1067 vat_json_init_object (&node);
1068 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1069 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1071 vat_json_print (vam->ofp, &node);
1072 vat_json_free (&node);
1074 vam->retval = ntohl (mp->retval);
1075 vam->result_ready = 1;
1078 static void vl_api_mpls_gre_add_del_tunnel_reply_t_handler
1079 (vl_api_mpls_gre_add_del_tunnel_reply_t * mp)
1081 vat_main_t *vam = &vat_main;
1082 i32 retval = ntohl (mp->retval);
1083 u32 sw_if_index = ntohl (mp->tunnel_sw_if_index);
1085 if (retval >= 0 && sw_if_index != (u32) ~ 0)
1087 errmsg ("tunnel_sw_if_index %d\n", sw_if_index);
1089 vam->retval = retval;
1090 vam->result_ready = 1;
1093 static void vl_api_mpls_gre_add_del_tunnel_reply_t_handler_json
1094 (vl_api_mpls_gre_add_del_tunnel_reply_t * mp)
1096 vat_main_t *vam = &vat_main;
1097 vat_json_node_t node;
1099 vat_json_init_object (&node);
1100 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1101 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1102 ntohl (mp->tunnel_sw_if_index));
1104 vat_json_print (vam->ofp, &node);
1105 vat_json_free (&node);
1107 vam->retval = ntohl (mp->retval);
1108 vam->result_ready = 1;
1112 static void vl_api_show_version_reply_t_handler
1113 (vl_api_show_version_reply_t * mp)
1115 vat_main_t *vam = &vat_main;
1116 i32 retval = ntohl (mp->retval);
1120 errmsg (" program: %s\n", mp->program);
1121 errmsg (" version: %s\n", mp->version);
1122 errmsg (" build date: %s\n", mp->build_date);
1123 errmsg ("build directory: %s\n", mp->build_directory);
1125 vam->retval = retval;
1126 vam->result_ready = 1;
1129 static void vl_api_show_version_reply_t_handler_json
1130 (vl_api_show_version_reply_t * mp)
1132 vat_main_t *vam = &vat_main;
1133 vat_json_node_t node;
1135 vat_json_init_object (&node);
1136 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1137 vat_json_object_add_string_copy (&node, "program", mp->program);
1138 vat_json_object_add_string_copy (&node, "version", mp->version);
1139 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1140 vat_json_object_add_string_copy (&node, "build_directory",
1141 mp->build_directory);
1143 vat_json_print (vam->ofp, &node);
1144 vat_json_free (&node);
1146 vam->retval = ntohl (mp->retval);
1147 vam->result_ready = 1;
1151 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1153 vat_main_t *vam = &vat_main;
1154 errmsg ("arp %s event: address %U new mac %U sw_if_index %d\n",
1155 mp->mac_ip ? "mac/ip binding" : "address resolution",
1156 format_ip4_address, &mp->address,
1157 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1161 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1163 /* JSON output not supported */
1167 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1169 vat_main_t *vam = &vat_main;
1170 errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d\n",
1171 mp->mac_ip ? "mac/ip binding" : "address resolution",
1172 format_ip6_address, mp->address,
1173 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1177 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1179 /* JSON output not supported */
1183 * Special-case: build the bridge domain table, maintain
1184 * the next bd id vbl.
1186 static void vl_api_bridge_domain_details_t_handler
1187 (vl_api_bridge_domain_details_t * mp)
1189 vat_main_t *vam = &vat_main;
1190 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1192 fformat (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s\n",
1193 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1195 fformat (vam->ofp, "%3d %3d %3d %3d %3d %3d\n",
1196 ntohl (mp->bd_id), mp->learn, mp->forward,
1197 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1200 fformat (vam->ofp, "\n\n%s %s %s\n", "sw_if_index", "SHG",
1204 static void vl_api_bridge_domain_details_t_handler_json
1205 (vl_api_bridge_domain_details_t * mp)
1207 vat_main_t *vam = &vat_main;
1208 vat_json_node_t *node, *array = NULL;
1210 if (VAT_JSON_ARRAY != vam->json_tree.type)
1212 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1213 vat_json_init_array (&vam->json_tree);
1215 node = vat_json_array_add (&vam->json_tree);
1217 vat_json_init_object (node);
1218 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1219 vat_json_object_add_uint (node, "flood", mp->flood);
1220 vat_json_object_add_uint (node, "forward", mp->forward);
1221 vat_json_object_add_uint (node, "learn", mp->learn);
1222 vat_json_object_add_uint (node, "bvi_sw_if_index",
1223 ntohl (mp->bvi_sw_if_index));
1224 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1225 array = vat_json_object_add (node, "sw_if");
1226 vat_json_init_array (array);
1230 * Special-case: build the bridge domain sw if table.
1232 static void vl_api_bridge_domain_sw_if_details_t_handler
1233 (vl_api_bridge_domain_sw_if_details_t * mp)
1235 vat_main_t *vam = &vat_main;
1240 sw_if_index = ntohl (mp->sw_if_index);
1242 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1244 if ((u32) p->value[0] == sw_if_index)
1246 sw_if_name = (u8 *)(p->key);
1252 fformat (vam->ofp, "%7d %3d %s", sw_if_index,
1253 mp->shg, sw_if_name ? (char *) sw_if_name :
1254 "sw_if_index not found!");
1257 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1258 (vl_api_bridge_domain_sw_if_details_t * mp)
1260 vat_main_t *vam = &vat_main;
1261 vat_json_node_t *node = NULL;
1262 uword last_index = 0;
1264 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1265 ASSERT (vec_len (vam->json_tree.array) >= 1);
1266 last_index = vec_len (vam->json_tree.array) - 1;
1267 node = &vam->json_tree.array[last_index];
1268 node = vat_json_object_get_element (node, "sw_if");
1269 ASSERT (NULL != node);
1270 node = vat_json_array_add (node);
1272 vat_json_init_object (node);
1273 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1274 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1275 vat_json_object_add_uint (node, "shg", mp->shg);
1278 static void vl_api_control_ping_reply_t_handler
1279 (vl_api_control_ping_reply_t * mp)
1281 vat_main_t *vam = &vat_main;
1282 i32 retval = ntohl (mp->retval);
1283 if (vam->async_mode)
1285 vam->async_errors += (retval < 0);
1289 vam->retval = retval;
1290 vam->result_ready = 1;
1294 static void vl_api_control_ping_reply_t_handler_json
1295 (vl_api_control_ping_reply_t * mp)
1297 vat_main_t *vam = &vat_main;
1298 i32 retval = ntohl (mp->retval);
1300 if (VAT_JSON_NONE != vam->json_tree.type)
1302 vat_json_print (vam->ofp, &vam->json_tree);
1303 vat_json_free (&vam->json_tree);
1304 vam->json_tree.type = VAT_JSON_NONE;
1309 vat_json_init_array (&vam->json_tree);
1310 vat_json_print (vam->ofp, &vam->json_tree);
1311 vam->json_tree.type = VAT_JSON_NONE;
1314 vam->retval = retval;
1315 vam->result_ready = 1;
1319 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1321 vat_main_t *vam = &vat_main;
1322 i32 retval = ntohl (mp->retval);
1323 if (vam->async_mode)
1325 vam->async_errors += (retval < 0);
1329 vam->retval = retval;
1330 vam->result_ready = 1;
1334 static void vl_api_l2_flags_reply_t_handler_json
1335 (vl_api_l2_flags_reply_t * mp)
1337 vat_main_t *vam = &vat_main;
1338 vat_json_node_t node;
1340 vat_json_init_object (&node);
1341 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1342 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1343 ntohl (mp->resulting_feature_bitmap));
1345 vat_json_print (vam->ofp, &node);
1346 vat_json_free (&node);
1348 vam->retval = ntohl (mp->retval);
1349 vam->result_ready = 1;
1352 static void vl_api_bridge_flags_reply_t_handler
1353 (vl_api_bridge_flags_reply_t * mp)
1355 vat_main_t *vam = &vat_main;
1356 i32 retval = ntohl (mp->retval);
1357 if (vam->async_mode)
1359 vam->async_errors += (retval < 0);
1363 vam->retval = retval;
1364 vam->result_ready = 1;
1368 static void vl_api_bridge_flags_reply_t_handler_json
1369 (vl_api_bridge_flags_reply_t * mp)
1371 vat_main_t *vam = &vat_main;
1372 vat_json_node_t node;
1374 vat_json_init_object (&node);
1375 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1376 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1377 ntohl (mp->resulting_feature_bitmap));
1379 vat_json_print (vam->ofp, &node);
1380 vat_json_free (&node);
1382 vam->retval = ntohl (mp->retval);
1383 vam->result_ready = 1;
1386 static void vl_api_tap_connect_reply_t_handler
1387 (vl_api_tap_connect_reply_t * mp)
1389 vat_main_t *vam = &vat_main;
1390 i32 retval = ntohl (mp->retval);
1391 if (vam->async_mode)
1393 vam->async_errors += (retval < 0);
1397 vam->retval = retval;
1398 vam->sw_if_index = ntohl (mp->sw_if_index);
1399 vam->result_ready = 1;
1404 static void vl_api_tap_connect_reply_t_handler_json
1405 (vl_api_tap_connect_reply_t * mp)
1407 vat_main_t *vam = &vat_main;
1408 vat_json_node_t node;
1410 vat_json_init_object (&node);
1411 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1412 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1414 vat_json_print (vam->ofp, &node);
1415 vat_json_free (&node);
1417 vam->retval = ntohl (mp->retval);
1418 vam->result_ready = 1;
1423 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1425 vat_main_t *vam = &vat_main;
1426 i32 retval = ntohl (mp->retval);
1427 if (vam->async_mode)
1429 vam->async_errors += (retval < 0);
1433 vam->retval = retval;
1434 vam->sw_if_index = ntohl (mp->sw_if_index);
1435 vam->result_ready = 1;
1439 static void vl_api_tap_modify_reply_t_handler_json
1440 (vl_api_tap_modify_reply_t * mp)
1442 vat_main_t *vam = &vat_main;
1443 vat_json_node_t node;
1445 vat_json_init_object (&node);
1446 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1447 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1449 vat_json_print (vam->ofp, &node);
1450 vat_json_free (&node);
1452 vam->retval = ntohl (mp->retval);
1453 vam->result_ready = 1;
1457 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1459 vat_main_t *vam = &vat_main;
1460 i32 retval = ntohl (mp->retval);
1461 if (vam->async_mode)
1463 vam->async_errors += (retval < 0);
1467 vam->retval = retval;
1468 vam->result_ready = 1;
1472 static void vl_api_tap_delete_reply_t_handler_json
1473 (vl_api_tap_delete_reply_t * mp)
1475 vat_main_t *vam = &vat_main;
1476 vat_json_node_t node;
1478 vat_json_init_object (&node);
1479 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1481 vat_json_print (vam->ofp, &node);
1482 vat_json_free (&node);
1484 vam->retval = ntohl (mp->retval);
1485 vam->result_ready = 1;
1488 static void vl_api_mpls_ethernet_add_del_tunnel_reply_t_handler
1489 (vl_api_mpls_ethernet_add_del_tunnel_reply_t * mp)
1491 vat_main_t *vam = &vat_main;
1492 i32 retval = ntohl (mp->retval);
1493 if (vam->async_mode)
1495 vam->async_errors += (retval < 0);
1499 vam->retval = retval;
1500 vam->result_ready = 1;
1504 static void vl_api_mpls_ethernet_add_del_tunnel_reply_t_handler_json
1505 (vl_api_mpls_ethernet_add_del_tunnel_reply_t * mp)
1507 vat_main_t *vam = &vat_main;
1508 vat_json_node_t node;
1510 vat_json_init_object (&node);
1511 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1512 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1513 ntohl (mp->tunnel_sw_if_index));
1515 vat_json_print (vam->ofp, &node);
1516 vat_json_free (&node);
1518 vam->retval = ntohl (mp->retval);
1519 vam->result_ready = 1;
1522 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1523 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1525 vat_main_t *vam = &vat_main;
1526 i32 retval = ntohl (mp->retval);
1527 if (vam->async_mode)
1529 vam->async_errors += (retval < 0);
1533 vam->retval = retval;
1534 vam->sw_if_index = ntohl (mp->sw_if_index);
1535 vam->result_ready = 1;
1539 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1540 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1542 vat_main_t *vam = &vat_main;
1543 vat_json_node_t node;
1545 vat_json_init_object (&node);
1546 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1547 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1549 vat_json_print (vam->ofp, &node);
1550 vat_json_free (&node);
1552 vam->retval = ntohl (mp->retval);
1553 vam->result_ready = 1;
1557 static void vl_api_lisp_add_del_locator_set_reply_t_handler
1558 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1560 vat_main_t *vam = &vat_main;
1561 i32 retval = ntohl (mp->retval);
1562 if (vam->async_mode)
1564 vam->async_errors += (retval < 0);
1568 vam->retval = retval;
1569 vam->result_ready = 1;
1573 static void vl_api_lisp_add_del_locator_set_reply_t_handler_json
1574 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1576 vat_main_t *vam = &vat_main;
1577 vat_json_node_t node;
1579 vat_json_init_object (&node);
1580 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1581 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1583 vat_json_print (vam->ofp, &node);
1584 vat_json_free (&node);
1586 vam->retval = ntohl (mp->retval);
1587 vam->result_ready = 1;
1590 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1591 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1593 vat_main_t *vam = &vat_main;
1594 i32 retval = ntohl (mp->retval);
1595 if (vam->async_mode)
1597 vam->async_errors += (retval < 0);
1601 vam->retval = retval;
1602 vam->sw_if_index = ntohl (mp->sw_if_index);
1603 vam->result_ready = 1;
1607 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1608 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1610 vat_main_t *vam = &vat_main;
1611 vat_json_node_t node;
1613 vat_json_init_object (&node);
1614 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1615 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1617 vat_json_print (vam->ofp, &node);
1618 vat_json_free (&node);
1620 vam->retval = ntohl (mp->retval);
1621 vam->result_ready = 1;
1624 static void vl_api_gre_add_del_tunnel_reply_t_handler
1625 (vl_api_gre_add_del_tunnel_reply_t * mp)
1627 vat_main_t *vam = &vat_main;
1628 i32 retval = ntohl (mp->retval);
1629 if (vam->async_mode)
1631 vam->async_errors += (retval < 0);
1635 vam->retval = retval;
1636 vam->sw_if_index = ntohl (mp->sw_if_index);
1637 vam->result_ready = 1;
1641 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1642 (vl_api_gre_add_del_tunnel_reply_t * mp)
1644 vat_main_t *vam = &vat_main;
1645 vat_json_node_t node;
1647 vat_json_init_object (&node);
1648 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1649 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1651 vat_json_print (vam->ofp, &node);
1652 vat_json_free (&node);
1654 vam->retval = ntohl (mp->retval);
1655 vam->result_ready = 1;
1658 static void vl_api_create_vhost_user_if_reply_t_handler
1659 (vl_api_create_vhost_user_if_reply_t * mp)
1661 vat_main_t *vam = &vat_main;
1662 i32 retval = ntohl (mp->retval);
1663 if (vam->async_mode)
1665 vam->async_errors += (retval < 0);
1669 vam->retval = retval;
1670 vam->sw_if_index = ntohl (mp->sw_if_index);
1671 vam->result_ready = 1;
1675 static void vl_api_create_vhost_user_if_reply_t_handler_json
1676 (vl_api_create_vhost_user_if_reply_t * mp)
1678 vat_main_t *vam = &vat_main;
1679 vat_json_node_t node;
1681 vat_json_init_object (&node);
1682 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1683 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1685 vat_json_print (vam->ofp, &node);
1686 vat_json_free (&node);
1688 vam->retval = ntohl (mp->retval);
1689 vam->result_ready = 1;
1692 static void vl_api_ip_address_details_t_handler
1693 (vl_api_ip_address_details_t * mp)
1695 vat_main_t *vam = &vat_main;
1696 static ip_address_details_t empty_ip_address_details = { {0} };
1697 ip_address_details_t *address = NULL;
1698 ip_details_t *current_ip_details = NULL;
1699 ip_details_t *details = NULL;
1701 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1703 if (!details || vam->current_sw_if_index >= vec_len (details)
1704 || !details[vam->current_sw_if_index].present)
1706 errmsg ("ip address details arrived but not stored\n");
1707 errmsg ("ip_dump should be called first\n");
1711 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1713 #define addresses (current_ip_details->addr)
1715 vec_validate_init_empty (addresses, vec_len (addresses),
1716 empty_ip_address_details);
1718 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1720 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1721 address->prefix_length = mp->prefix_length;
1725 static void vl_api_ip_address_details_t_handler_json
1726 (vl_api_ip_address_details_t * mp)
1728 vat_main_t *vam = &vat_main;
1729 vat_json_node_t *node = NULL;
1730 struct in6_addr ip6;
1733 if (VAT_JSON_ARRAY != vam->json_tree.type)
1735 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1736 vat_json_init_array (&vam->json_tree);
1738 node = vat_json_array_add (&vam->json_tree);
1740 vat_json_init_object (node);
1743 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1744 vat_json_object_add_ip6 (node, "ip", ip6);
1748 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1749 vat_json_object_add_ip4 (node, "ip", ip4);
1751 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1755 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1757 vat_main_t *vam = &vat_main;
1758 static ip_details_t empty_ip_details = { 0 };
1759 ip_details_t *ip = NULL;
1760 u32 sw_if_index = ~0;
1762 sw_if_index = ntohl (mp->sw_if_index);
1764 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1765 sw_if_index, empty_ip_details);
1767 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1774 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1776 vat_main_t *vam = &vat_main;
1778 if (VAT_JSON_ARRAY != vam->json_tree.type)
1780 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1781 vat_json_init_array (&vam->json_tree);
1783 vat_json_array_add_uint (&vam->json_tree,
1784 clib_net_to_host_u32 (mp->sw_if_index));
1787 static void vl_api_map_domain_details_t_handler_json
1788 (vl_api_map_domain_details_t * mp)
1790 vat_json_node_t *node = NULL;
1791 vat_main_t *vam = &vat_main;
1792 struct in6_addr ip6;
1795 if (VAT_JSON_ARRAY != vam->json_tree.type)
1797 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1798 vat_json_init_array (&vam->json_tree);
1801 node = vat_json_array_add (&vam->json_tree);
1802 vat_json_init_object (node);
1804 vat_json_object_add_uint (node, "domain_index",
1805 clib_net_to_host_u32 (mp->domain_index));
1806 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1807 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1808 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1809 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1810 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1811 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1812 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1813 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1814 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1815 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1816 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1817 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1818 vat_json_object_add_uint (node, "flags", mp->flags);
1819 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1820 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1823 static void vl_api_map_domain_details_t_handler
1824 (vl_api_map_domain_details_t * mp)
1826 vat_main_t *vam = &vat_main;
1828 if (mp->is_translation)
1831 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u\n",
1832 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1833 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1834 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1835 clib_net_to_host_u32 (mp->domain_index));
1840 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u\n",
1841 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1842 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1843 format_ip6_address, mp->ip6_src,
1844 clib_net_to_host_u32 (mp->domain_index));
1846 fformat (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s\n",
1847 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1848 mp->is_translation ? "map-t" : "");
1851 static void vl_api_map_rule_details_t_handler_json
1852 (vl_api_map_rule_details_t * mp)
1854 struct in6_addr ip6;
1855 vat_json_node_t *node = NULL;
1856 vat_main_t *vam = &vat_main;
1858 if (VAT_JSON_ARRAY != vam->json_tree.type)
1860 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1861 vat_json_init_array (&vam->json_tree);
1864 node = vat_json_array_add (&vam->json_tree);
1865 vat_json_init_object (node);
1867 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1868 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1869 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1873 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1875 vat_main_t *vam = &vat_main;
1876 fformat (vam->ofp, " %d (psid) %U (ip6-dst)\n",
1877 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1881 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1883 vat_main_t *vam = &vat_main;
1884 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1885 "router_addr %U host_mac %U\n",
1886 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1887 format_ip4_address, &mp->host_address,
1888 format_ip4_address, &mp->router_address,
1889 format_ethernet_address, mp->host_mac);
1892 static void vl_api_dhcp_compl_event_t_handler_json
1893 (vl_api_dhcp_compl_event_t * mp)
1895 /* JSON output not supported */
1899 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1902 vat_main_t *vam = &vat_main;
1903 static u64 default_counter = 0;
1905 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
1907 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
1908 sw_if_index, default_counter);
1909 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
1913 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1914 interface_counter_t counter)
1916 vat_main_t *vam = &vat_main;
1917 static interface_counter_t default_counter = { 0, };
1919 vec_validate_init_empty (vam->combined_interface_counters,
1920 vnet_counter_type, NULL);
1921 vec_validate_init_empty (vam->combined_interface_counters
1922 [vnet_counter_type], sw_if_index, default_counter);
1923 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
1926 static void vl_api_vnet_interface_counters_t_handler
1927 (vl_api_vnet_interface_counters_t * mp)
1932 static void vl_api_vnet_interface_counters_t_handler_json
1933 (vl_api_vnet_interface_counters_t * mp)
1935 interface_counter_t counter;
1940 u32 first_sw_if_index;
1943 count = ntohl (mp->count);
1944 first_sw_if_index = ntohl (mp->first_sw_if_index);
1946 if (!mp->is_combined)
1948 v_packets = (u64 *) & mp->data;
1949 for (i = 0; i < count; i++)
1952 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
1953 set_simple_interface_counter (mp->vnet_counter_type,
1954 first_sw_if_index + i, packets);
1960 v = (vlib_counter_t *) & mp->data;
1961 for (i = 0; i < count; i++)
1964 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
1966 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
1967 set_combined_interface_counter (mp->vnet_counter_type,
1968 first_sw_if_index + i, counter);
1975 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
1977 vat_main_t *vam = &vat_main;
1980 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
1982 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
1991 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
1993 vat_main_t *vam = &vat_main;
1996 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
1998 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2006 static void vl_api_vnet_ip4_fib_counters_t_handler
2007 (vl_api_vnet_ip4_fib_counters_t * mp)
2012 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2013 (vl_api_vnet_ip4_fib_counters_t * mp)
2015 vat_main_t *vam = &vat_main;
2016 vl_api_ip4_fib_counter_t *v;
2017 ip4_fib_counter_t *counter;
2024 vrf_id = ntohl (mp->vrf_id);
2025 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2026 if (~0 == vrf_index)
2028 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2029 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2030 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2031 vec_validate (vam->ip4_fib_counters, vrf_index);
2032 vam->ip4_fib_counters[vrf_index] = NULL;
2035 vec_free (vam->ip4_fib_counters[vrf_index]);
2036 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2037 count = ntohl (mp->count);
2038 for (i = 0; i < count; i++)
2040 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2041 counter = &vam->ip4_fib_counters[vrf_index][i];
2042 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2043 counter->address = ip4;
2044 counter->address_length = v->address_length;
2045 counter->packets = clib_net_to_host_u64 (v->packets);
2046 counter->bytes = clib_net_to_host_u64 (v->bytes);
2051 static void vl_api_vnet_ip6_fib_counters_t_handler
2052 (vl_api_vnet_ip6_fib_counters_t * mp)
2057 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2058 (vl_api_vnet_ip6_fib_counters_t * mp)
2060 vat_main_t *vam = &vat_main;
2061 vl_api_ip6_fib_counter_t *v;
2062 ip6_fib_counter_t *counter;
2063 struct in6_addr ip6;
2069 vrf_id = ntohl (mp->vrf_id);
2070 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2071 if (~0 == vrf_index)
2073 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2074 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2075 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2076 vec_validate (vam->ip6_fib_counters, vrf_index);
2077 vam->ip6_fib_counters[vrf_index] = NULL;
2080 vec_free (vam->ip6_fib_counters[vrf_index]);
2081 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2082 count = ntohl (mp->count);
2083 for (i = 0; i < count; i++)
2085 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2086 counter = &vam->ip6_fib_counters[vrf_index][i];
2087 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2088 counter->address = ip6;
2089 counter->address_length = v->address_length;
2090 counter->packets = clib_net_to_host_u64 (v->packets);
2091 counter->bytes = clib_net_to_host_u64 (v->bytes);
2096 static void vl_api_get_first_msg_id_reply_t_handler
2097 (vl_api_get_first_msg_id_reply_t * mp)
2099 vat_main_t *vam = &vat_main;
2100 i32 retval = ntohl (mp->retval);
2102 if (vam->async_mode)
2104 vam->async_errors += (retval < 0);
2108 vam->retval = retval;
2109 vam->result_ready = 1;
2113 errmsg ("first message id %d\n", ntohs (mp->first_msg_id));
2117 static void vl_api_get_first_msg_id_reply_t_handler_json
2118 (vl_api_get_first_msg_id_reply_t * mp)
2120 vat_main_t *vam = &vat_main;
2121 vat_json_node_t node;
2123 vat_json_init_object (&node);
2124 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2125 vat_json_object_add_uint (&node, "first_msg_id",
2126 (uint) ntohs (mp->first_msg_id));
2128 vat_json_print (vam->ofp, &node);
2129 vat_json_free (&node);
2131 vam->retval = ntohl (mp->retval);
2132 vam->result_ready = 1;
2135 static void vl_api_get_node_graph_reply_t_handler
2136 (vl_api_get_node_graph_reply_t * mp)
2138 vat_main_t *vam = &vat_main;
2139 api_main_t *am = &api_main;
2140 i32 retval = ntohl (mp->retval);
2141 u8 *pvt_copy, *reply;
2146 if (vam->async_mode)
2148 vam->async_errors += (retval < 0);
2152 vam->retval = retval;
2153 vam->result_ready = 1;
2156 /* "Should never happen..." */
2160 reply = (u8 *) (mp->reply_in_shmem);
2161 pvt_copy = vec_dup (reply);
2163 /* Toss the shared-memory original... */
2164 pthread_mutex_lock (&am->vlib_rp->mutex);
2165 oldheap = svm_push_data_heap (am->vlib_rp);
2169 svm_pop_heap (oldheap);
2170 pthread_mutex_unlock (&am->vlib_rp->mutex);
2172 if (vam->graph_nodes)
2174 hash_free (vam->graph_node_index_by_name);
2176 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2178 node = vam->graph_nodes[i];
2179 vec_free (node->name);
2180 vec_free (node->next_nodes);
2183 vec_free (vam->graph_nodes);
2186 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2187 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2188 vec_free (pvt_copy);
2190 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2192 node = vam->graph_nodes[i];
2193 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2197 static void vl_api_get_node_graph_reply_t_handler_json
2198 (vl_api_get_node_graph_reply_t * mp)
2200 vat_main_t *vam = &vat_main;
2201 api_main_t *am = &api_main;
2203 vat_json_node_t node;
2206 /* $$$$ make this real? */
2207 vat_json_init_object (&node);
2208 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2209 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2211 reply = (u8 *) (mp->reply_in_shmem);
2213 /* Toss the shared-memory original... */
2214 pthread_mutex_lock (&am->vlib_rp->mutex);
2215 oldheap = svm_push_data_heap (am->vlib_rp);
2219 svm_pop_heap (oldheap);
2220 pthread_mutex_unlock (&am->vlib_rp->mutex);
2222 vat_json_print (vam->ofp, &node);
2223 vat_json_free (&node);
2225 vam->retval = ntohl (mp->retval);
2226 vam->result_ready = 1;
2230 vl_api_lisp_locator_details_t_handler (vl_api_lisp_locator_details_t * mp)
2232 vat_main_t *vam = &vat_main;
2237 s = format (s, "%=16d%=16d%=16d\n",
2238 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2242 s = format (s, "%=16U%=16d%=16d\n",
2243 mp->is_ipv6 ? format_ip6_address :
2245 mp->ip_address, mp->priority, mp->weight);
2248 fformat (vam->ofp, "%v", s);
2253 vl_api_lisp_locator_details_t_handler_json (vl_api_lisp_locator_details_t *
2256 vat_main_t *vam = &vat_main;
2257 vat_json_node_t *node = NULL;
2258 struct in6_addr ip6;
2261 if (VAT_JSON_ARRAY != vam->json_tree.type)
2263 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2264 vat_json_init_array (&vam->json_tree);
2266 node = vat_json_array_add (&vam->json_tree);
2267 vat_json_init_object (node);
2269 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2270 vat_json_object_add_uint (node, "priority", mp->priority);
2271 vat_json_object_add_uint (node, "weight", mp->weight);
2274 vat_json_object_add_uint (node, "sw_if_index",
2275 clib_net_to_host_u32 (mp->sw_if_index));
2280 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2281 vat_json_object_add_ip6 (node, "address", ip6);
2285 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2286 vat_json_object_add_ip4 (node, "address", ip4);
2292 vl_api_lisp_locator_set_details_t_handler (vl_api_lisp_locator_set_details_t *
2295 vat_main_t *vam = &vat_main;
2298 ls_name = format (0, "%s", mp->ls_name);
2300 fformat (vam->ofp, "%=10d%=15v\n", clib_net_to_host_u32 (mp->ls_index),
2306 vl_api_lisp_locator_set_details_t_handler_json
2307 (vl_api_lisp_locator_set_details_t * mp)
2309 vat_main_t *vam = &vat_main;
2310 vat_json_node_t *node = 0;
2313 ls_name = format (0, "%s", mp->ls_name);
2314 vec_add1 (ls_name, 0);
2316 if (VAT_JSON_ARRAY != vam->json_tree.type)
2318 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2319 vat_json_init_array (&vam->json_tree);
2321 node = vat_json_array_add (&vam->json_tree);
2323 vat_json_init_object (node);
2324 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2325 vat_json_object_add_uint (node, "ls_index",
2326 clib_net_to_host_u32 (mp->ls_index));
2331 format_lisp_flat_eid (u8 * s, va_list * args)
2333 u32 type = va_arg (*args, u32);
2334 u8 *eid = va_arg (*args, u8 *);
2335 u32 eid_len = va_arg (*args, u32);
2340 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2342 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2344 return format (s, "%U", format_ethernet_address, eid);
2350 format_lisp_eid_vat (u8 * s, va_list * args)
2352 u32 type = va_arg (*args, u32);
2353 u8 *eid = va_arg (*args, u8 *);
2354 u32 eid_len = va_arg (*args, u32);
2355 u8 *seid = va_arg (*args, u8 *);
2356 u32 seid_len = va_arg (*args, u32);
2357 u32 is_src_dst = va_arg (*args, u32);
2360 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2362 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2368 vl_api_lisp_eid_table_details_t_handler (vl_api_lisp_eid_table_details_t * mp)
2370 vat_main_t *vam = &vat_main;
2371 u8 *s = 0, *eid = 0;
2373 if (~0 == mp->locator_set_index)
2374 s = format (0, "action: %d", mp->action);
2376 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2378 eid = format (0, "%U", format_lisp_eid_vat,
2382 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2385 fformat (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-d\n",
2386 clib_net_to_host_u32 (mp->vni),
2388 mp->is_local ? "local" : "remote",
2389 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative);
2395 vl_api_lisp_eid_table_details_t_handler_json (vl_api_lisp_eid_table_details_t
2398 vat_main_t *vam = &vat_main;
2399 vat_json_node_t *node = 0;
2402 if (VAT_JSON_ARRAY != vam->json_tree.type)
2404 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2405 vat_json_init_array (&vam->json_tree);
2407 node = vat_json_array_add (&vam->json_tree);
2409 vat_json_init_object (node);
2410 if (~0 == mp->locator_set_index)
2411 vat_json_object_add_uint (node, "action", mp->action);
2413 vat_json_object_add_uint (node, "locator_set_index",
2414 clib_net_to_host_u32 (mp->locator_set_index));
2416 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2417 eid = format (0, "%U", format_lisp_eid_vat,
2421 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2423 vat_json_object_add_string_copy (node, "eid", eid);
2424 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2425 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2426 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2431 vl_api_lisp_eid_table_map_details_t_handler
2432 (vl_api_lisp_eid_table_map_details_t * mp)
2434 vat_main_t *vam = &vat_main;
2436 u8 *line = format (0, "%=10d%=10d",
2437 clib_net_to_host_u32 (mp->vni),
2438 clib_net_to_host_u32 (mp->dp_table));
2439 fformat (vam->ofp, "%v\n", line);
2444 vl_api_lisp_eid_table_map_details_t_handler_json
2445 (vl_api_lisp_eid_table_map_details_t * mp)
2447 vat_main_t *vam = &vat_main;
2448 vat_json_node_t *node = NULL;
2450 if (VAT_JSON_ARRAY != vam->json_tree.type)
2452 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2453 vat_json_init_array (&vam->json_tree);
2455 node = vat_json_array_add (&vam->json_tree);
2456 vat_json_init_object (node);
2457 vat_json_object_add_uint (node, "dp_table",
2458 clib_net_to_host_u32 (mp->dp_table));
2459 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2463 vl_api_lisp_eid_table_vni_details_t_handler
2464 (vl_api_lisp_eid_table_vni_details_t * mp)
2466 vat_main_t *vam = &vat_main;
2468 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2469 fformat (vam->ofp, "%v\n", line);
2474 vl_api_lisp_eid_table_vni_details_t_handler_json
2475 (vl_api_lisp_eid_table_vni_details_t * mp)
2477 vat_main_t *vam = &vat_main;
2478 vat_json_node_t *node = NULL;
2480 if (VAT_JSON_ARRAY != vam->json_tree.type)
2482 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2483 vat_json_init_array (&vam->json_tree);
2485 node = vat_json_array_add (&vam->json_tree);
2486 vat_json_init_object (node);
2487 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2491 format_decap_next (u8 * s, va_list * args)
2493 u32 next_index = va_arg (*args, u32);
2497 case LISP_GPE_INPUT_NEXT_DROP:
2498 return format (s, "drop");
2499 case LISP_GPE_INPUT_NEXT_IP4_INPUT:
2500 return format (s, "ip4");
2501 case LISP_GPE_INPUT_NEXT_IP6_INPUT:
2502 return format (s, "ip6");
2504 return format (s, "unknown %d", next_index);
2510 vl_api_lisp_gpe_tunnel_details_t_handler (vl_api_lisp_gpe_tunnel_details_t *
2513 vat_main_t *vam = &vat_main;
2515 u8 *flag_str = NULL;
2517 iid_str = format (0, "%d (0x%x)", ntohl (mp->iid), ntohl (mp->iid));
2519 #define _(n,v) if (mp->flags & v) flag_str = format (flag_str, "%s-bit ", #n);
2520 foreach_lisp_gpe_flag_bit;
2523 fformat (vam->ofp, "%=20d%=30U%=16U%=16d%=16d%=16U"
2524 "%=16d%=16d%=16sd=16d%=16s%=16s\n",
2526 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2528 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2530 ntohl (mp->encap_fib_id),
2531 ntohl (mp->decap_fib_id),
2532 format_decap_next, ntohl (mp->dcap_next),
2534 flag_str, mp->next_protocol, mp->ver_res, mp->res, iid_str);
2540 vl_api_lisp_gpe_tunnel_details_t_handler_json
2541 (vl_api_lisp_gpe_tunnel_details_t * mp)
2543 vat_main_t *vam = &vat_main;
2544 vat_json_node_t *node = NULL;
2545 struct in6_addr ip6;
2549 next_decap_str = format (0, "%U", format_decap_next, htonl (mp->dcap_next));
2551 if (VAT_JSON_ARRAY != vam->json_tree.type)
2553 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2554 vat_json_init_array (&vam->json_tree);
2556 node = vat_json_array_add (&vam->json_tree);
2558 vat_json_init_object (node);
2559 vat_json_object_add_uint (node, "tunel", mp->tunnels);
2562 clib_memcpy (&ip6, mp->source_ip, sizeof (ip6));
2563 vat_json_object_add_ip6 (node, "source address", ip6);
2564 clib_memcpy (&ip6, mp->destination_ip, sizeof (ip6));
2565 vat_json_object_add_ip6 (node, "destination address", ip6);
2569 clib_memcpy (&ip4, mp->source_ip, sizeof (ip4));
2570 vat_json_object_add_ip4 (node, "source address", ip4);
2571 clib_memcpy (&ip4, mp->destination_ip, sizeof (ip4));
2572 vat_json_object_add_ip4 (node, "destination address", ip4);
2574 vat_json_object_add_uint (node, "fib encap", ntohl (mp->encap_fib_id));
2575 vat_json_object_add_uint (node, "fib decap", ntohl (mp->decap_fib_id));
2576 vat_json_object_add_string_copy (node, "decap next", next_decap_str);
2577 vat_json_object_add_uint (node, "lisp version", mp->ver_res >> 6);
2578 vat_json_object_add_uint (node, "flags", mp->flags);
2579 vat_json_object_add_uint (node, "next protocol", mp->next_protocol);
2580 vat_json_object_add_uint (node, "ver_res", mp->ver_res);
2581 vat_json_object_add_uint (node, "res", mp->res);
2582 vat_json_object_add_uint (node, "iid", ntohl (mp->iid));
2584 vec_free (next_decap_str);
2588 vl_api_lisp_map_resolver_details_t_handler (vl_api_lisp_map_resolver_details_t
2591 vat_main_t *vam = &vat_main;
2593 fformat (vam->ofp, "%=20U\n",
2594 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2599 vl_api_lisp_map_resolver_details_t_handler_json
2600 (vl_api_lisp_map_resolver_details_t * mp)
2602 vat_main_t *vam = &vat_main;
2603 vat_json_node_t *node = NULL;
2604 struct in6_addr ip6;
2607 if (VAT_JSON_ARRAY != vam->json_tree.type)
2609 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2610 vat_json_init_array (&vam->json_tree);
2612 node = vat_json_array_add (&vam->json_tree);
2614 vat_json_init_object (node);
2617 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2618 vat_json_object_add_ip6 (node, "map resolver", ip6);
2622 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2623 vat_json_object_add_ip4 (node, "map resolver", ip4);
2628 vl_api_show_lisp_status_reply_t_handler
2629 (vl_api_show_lisp_status_reply_t * mp)
2631 vat_main_t *vam = &vat_main;
2632 i32 retval = ntohl (mp->retval);
2636 fformat (vam->ofp, "feature: %s\ngpe: %s\n",
2637 mp->feature_status ? "enabled" : "disabled",
2638 mp->gpe_status ? "enabled" : "disabled");
2641 vam->retval = retval;
2642 vam->result_ready = 1;
2646 vl_api_show_lisp_status_reply_t_handler_json
2647 (vl_api_show_lisp_status_reply_t * mp)
2649 vat_main_t *vam = &vat_main;
2650 vat_json_node_t node;
2651 u8 *gpe_status = NULL;
2652 u8 *feature_status = NULL;
2654 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
2655 feature_status = format (0, "%s",
2656 mp->feature_status ? "enabled" : "disabled");
2657 vec_add1 (gpe_status, 0);
2658 vec_add1 (feature_status, 0);
2660 vat_json_init_object (&node);
2661 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
2662 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
2664 vec_free (gpe_status);
2665 vec_free (feature_status);
2667 vat_json_print (vam->ofp, &node);
2668 vat_json_free (&node);
2670 vam->retval = ntohl (mp->retval);
2671 vam->result_ready = 1;
2675 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler
2676 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2678 vat_main_t *vam = &vat_main;
2679 i32 retval = ntohl (mp->retval);
2683 fformat (vam->ofp, "%=20s\n", mp->locator_set_name);
2686 vam->retval = retval;
2687 vam->result_ready = 1;
2691 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler_json
2692 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2694 vat_main_t *vam = &vat_main;
2695 vat_json_node_t *node = NULL;
2697 if (VAT_JSON_ARRAY != vam->json_tree.type)
2699 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2700 vat_json_init_array (&vam->json_tree);
2702 node = vat_json_array_add (&vam->json_tree);
2704 vat_json_init_object (node);
2705 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
2707 vat_json_print (vam->ofp, node);
2708 vat_json_free (node);
2710 vam->retval = ntohl (mp->retval);
2711 vam->result_ready = 1;
2715 format_lisp_map_request_mode (u8 * s, va_list * args)
2717 u32 mode = va_arg (*args, u32);
2722 return format (0, "dst-only");
2724 return format (0, "src-dst");
2730 vl_api_show_lisp_map_request_mode_reply_t_handler
2731 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2733 vat_main_t *vam = &vat_main;
2734 i32 retval = ntohl (mp->retval);
2738 u32 mode = mp->mode;
2739 fformat (vam->ofp, "map_request_mode: %U\n",
2740 format_lisp_map_request_mode, mode);
2743 vam->retval = retval;
2744 vam->result_ready = 1;
2748 vl_api_show_lisp_map_request_mode_reply_t_handler_json
2749 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2751 vat_main_t *vam = &vat_main;
2752 vat_json_node_t node;
2757 s = format (0, "%U", format_lisp_map_request_mode, mode);
2760 vat_json_init_object (&node);
2761 vat_json_object_add_string_copy (&node, "map_request_mode", s);
2762 vat_json_print (vam->ofp, &node);
2763 vat_json_free (&node);
2766 vam->retval = ntohl (mp->retval);
2767 vam->result_ready = 1;
2771 vl_api_show_lisp_pitr_reply_t_handler (vl_api_show_lisp_pitr_reply_t * mp)
2773 vat_main_t *vam = &vat_main;
2774 i32 retval = ntohl (mp->retval);
2778 fformat (vam->ofp, "%-20s%-16s\n",
2779 mp->status ? "enabled" : "disabled",
2780 mp->status ? (char *) mp->locator_set_name : "");
2783 vam->retval = retval;
2784 vam->result_ready = 1;
2788 vl_api_show_lisp_pitr_reply_t_handler_json (vl_api_show_lisp_pitr_reply_t *
2791 vat_main_t *vam = &vat_main;
2792 vat_json_node_t node;
2795 status = format (0, "%s", mp->status ? "enabled" : "disabled");
2796 vec_add1 (status, 0);
2798 vat_json_init_object (&node);
2799 vat_json_object_add_string_copy (&node, "status", status);
2802 vat_json_object_add_string_copy (&node, "locator_set",
2803 mp->locator_set_name);
2808 vat_json_print (vam->ofp, &node);
2809 vat_json_free (&node);
2811 vam->retval = ntohl (mp->retval);
2812 vam->result_ready = 1;
2816 format_policer_type (u8 * s, va_list * va)
2818 u32 i = va_arg (*va, u32);
2820 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
2821 s = format (s, "1r2c");
2822 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
2823 s = format (s, "1r3c");
2824 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
2825 s = format (s, "2r3c-2698");
2826 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
2827 s = format (s, "2r3c-4115");
2828 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
2829 s = format (s, "2r3c-mef5cf1");
2831 s = format (s, "ILLEGAL");
2836 format_policer_rate_type (u8 * s, va_list * va)
2838 u32 i = va_arg (*va, u32);
2840 if (i == SSE2_QOS_RATE_KBPS)
2841 s = format (s, "kbps");
2842 else if (i == SSE2_QOS_RATE_PPS)
2843 s = format (s, "pps");
2845 s = format (s, "ILLEGAL");
2850 format_policer_round_type (u8 * s, va_list * va)
2852 u32 i = va_arg (*va, u32);
2854 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
2855 s = format (s, "closest");
2856 else if (i == SSE2_QOS_ROUND_TO_UP)
2857 s = format (s, "up");
2858 else if (i == SSE2_QOS_ROUND_TO_DOWN)
2859 s = format (s, "down");
2861 s = format (s, "ILLEGAL");
2866 format_policer_action_type (u8 * s, va_list * va)
2868 u32 i = va_arg (*va, u32);
2870 if (i == SSE2_QOS_ACTION_DROP)
2871 s = format (s, "drop");
2872 else if (i == SSE2_QOS_ACTION_TRANSMIT)
2873 s = format (s, "transmit");
2874 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2875 s = format (s, "mark-and-transmit");
2877 s = format (s, "ILLEGAL");
2882 format_dscp (u8 * s, va_list * va)
2884 u32 i = va_arg (*va, u32);
2889 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
2893 return format (s, "ILLEGAL");
2895 s = format (s, "%s", t);
2900 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
2902 vat_main_t *vam = &vat_main;
2903 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
2905 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2906 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
2908 conform_dscp_str = format (0, "");
2910 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2911 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
2913 exceed_dscp_str = format (0, "");
2915 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2916 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
2918 violate_dscp_str = format (0, "");
2920 fformat (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
2921 "rate type %U, round type %U, %s rate, %s color-aware, "
2922 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
2923 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
2924 "conform action %U%s, exceed action %U%s, violate action %U%s\n",
2926 format_policer_type, mp->type,
2929 clib_net_to_host_u64 (mp->cb),
2930 clib_net_to_host_u64 (mp->eb),
2931 format_policer_rate_type, mp->rate_type,
2932 format_policer_round_type, mp->round_type,
2933 mp->single_rate ? "single" : "dual",
2934 mp->color_aware ? "is" : "not",
2935 ntohl (mp->cir_tokens_per_period),
2936 ntohl (mp->pir_tokens_per_period),
2938 ntohl (mp->current_limit),
2939 ntohl (mp->current_bucket),
2940 ntohl (mp->extended_limit),
2941 ntohl (mp->extended_bucket),
2942 clib_net_to_host_u64 (mp->last_update_time),
2943 format_policer_action_type, mp->conform_action_type,
2945 format_policer_action_type, mp->exceed_action_type,
2947 format_policer_action_type, mp->violate_action_type,
2950 vec_free (conform_dscp_str);
2951 vec_free (exceed_dscp_str);
2952 vec_free (violate_dscp_str);
2955 static void vl_api_policer_details_t_handler_json
2956 (vl_api_policer_details_t * mp)
2958 vat_main_t *vam = &vat_main;
2959 vat_json_node_t *node;
2960 u8 *rate_type_str, *round_type_str, *type_str;
2961 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
2963 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
2965 format (0, "%U", format_policer_round_type, mp->round_type);
2966 type_str = format (0, "%U", format_policer_type, mp->type);
2967 conform_action_str = format (0, "%U", format_policer_action_type,
2968 mp->conform_action_type);
2969 exceed_action_str = format (0, "%U", format_policer_action_type,
2970 mp->exceed_action_type);
2971 violate_action_str = format (0, "%U", format_policer_action_type,
2972 mp->violate_action_type);
2974 if (VAT_JSON_ARRAY != vam->json_tree.type)
2976 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2977 vat_json_init_array (&vam->json_tree);
2979 node = vat_json_array_add (&vam->json_tree);
2981 vat_json_init_object (node);
2982 vat_json_object_add_string_copy (node, "name", mp->name);
2983 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
2984 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
2985 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
2986 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
2987 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
2988 vat_json_object_add_string_copy (node, "round_type", round_type_str);
2989 vat_json_object_add_string_copy (node, "type", type_str);
2990 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
2991 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
2992 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
2993 vat_json_object_add_uint (node, "cir_tokens_per_period",
2994 ntohl (mp->cir_tokens_per_period));
2995 vat_json_object_add_uint (node, "eir_tokens_per_period",
2996 ntohl (mp->pir_tokens_per_period));
2997 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
2998 vat_json_object_add_uint (node, "current_bucket",
2999 ntohl (mp->current_bucket));
3000 vat_json_object_add_uint (node, "extended_limit",
3001 ntohl (mp->extended_limit));
3002 vat_json_object_add_uint (node, "extended_bucket",
3003 ntohl (mp->extended_bucket));
3004 vat_json_object_add_uint (node, "last_update_time",
3005 ntohl (mp->last_update_time));
3006 vat_json_object_add_string_copy (node, "conform_action",
3007 conform_action_str);
3008 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3010 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3011 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3012 vec_free (dscp_str);
3014 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3015 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3017 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3018 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3019 vec_free (dscp_str);
3021 vat_json_object_add_string_copy (node, "violate_action",
3022 violate_action_str);
3023 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3025 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3026 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3027 vec_free (dscp_str);
3030 vec_free (rate_type_str);
3031 vec_free (round_type_str);
3032 vec_free (type_str);
3033 vec_free (conform_action_str);
3034 vec_free (exceed_action_str);
3035 vec_free (violate_action_str);
3039 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3042 vat_main_t *vam = &vat_main;
3043 int i, count = ntohl (mp->count);
3046 fformat (vam->ofp, "classify table ids (%d) : ", count);
3047 for (i = 0; i < count; i++)
3049 fformat (vam->ofp, "%d", ntohl (mp->ids[i]));
3050 fformat (vam->ofp, (i < count - 1) ? "," : "\n");
3052 vam->retval = ntohl (mp->retval);
3053 vam->result_ready = 1;
3057 vl_api_classify_table_ids_reply_t_handler_json
3058 (vl_api_classify_table_ids_reply_t * mp)
3060 vat_main_t *vam = &vat_main;
3061 int i, count = ntohl (mp->count);
3065 vat_json_node_t node;
3067 vat_json_init_object (&node);
3068 for (i = 0; i < count; i++)
3070 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3072 vat_json_print (vam->ofp, &node);
3073 vat_json_free (&node);
3075 vam->retval = ntohl (mp->retval);
3076 vam->result_ready = 1;
3080 vl_api_classify_table_by_interface_reply_t_handler
3081 (vl_api_classify_table_by_interface_reply_t * mp)
3083 vat_main_t *vam = &vat_main;
3086 table_id = ntohl (mp->l2_table_id);
3088 fformat (vam->ofp, "l2 table id : %d\n", table_id);
3090 fformat (vam->ofp, "l2 table id : No input ACL tables configured\n");
3091 table_id = ntohl (mp->ip4_table_id);
3093 fformat (vam->ofp, "ip4 table id : %d\n", table_id);
3095 fformat (vam->ofp, "ip4 table id : No input ACL tables configured\n");
3096 table_id = ntohl (mp->ip6_table_id);
3098 fformat (vam->ofp, "ip6 table id : %d\n", table_id);
3100 fformat (vam->ofp, "ip6 table id : No input ACL tables configured\n");
3101 vam->retval = ntohl (mp->retval);
3102 vam->result_ready = 1;
3106 vl_api_classify_table_by_interface_reply_t_handler_json
3107 (vl_api_classify_table_by_interface_reply_t * mp)
3109 vat_main_t *vam = &vat_main;
3110 vat_json_node_t node;
3112 vat_json_init_object (&node);
3114 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3115 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3116 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3118 vat_json_print (vam->ofp, &node);
3119 vat_json_free (&node);
3121 vam->retval = ntohl (mp->retval);
3122 vam->result_ready = 1;
3125 static void vl_api_policer_add_del_reply_t_handler
3126 (vl_api_policer_add_del_reply_t * mp)
3128 vat_main_t *vam = &vat_main;
3129 i32 retval = ntohl (mp->retval);
3130 if (vam->async_mode)
3132 vam->async_errors += (retval < 0);
3136 vam->retval = retval;
3137 vam->result_ready = 1;
3138 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3140 * Note: this is just barely thread-safe, depends on
3141 * the main thread spinning waiting for an answer...
3143 errmsg ("policer index %d\n", ntohl (mp->policer_index));
3147 static void vl_api_policer_add_del_reply_t_handler_json
3148 (vl_api_policer_add_del_reply_t * mp)
3150 vat_main_t *vam = &vat_main;
3151 vat_json_node_t node;
3153 vat_json_init_object (&node);
3154 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3155 vat_json_object_add_uint (&node, "policer_index",
3156 ntohl (mp->policer_index));
3158 vat_json_print (vam->ofp, &node);
3159 vat_json_free (&node);
3161 vam->retval = ntohl (mp->retval);
3162 vam->result_ready = 1;
3165 /* Format hex dump. */
3167 format_hex_bytes (u8 * s, va_list * va)
3169 u8 *bytes = va_arg (*va, u8 *);
3170 int n_bytes = va_arg (*va, int);
3173 /* Print short or long form depending on byte count. */
3174 uword short_form = n_bytes <= 32;
3175 uword indent = format_get_indent (s);
3180 for (i = 0; i < n_bytes; i++)
3182 if (!short_form && (i % 32) == 0)
3183 s = format (s, "%08x: ", i);
3184 s = format (s, "%02x", bytes[i]);
3185 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3186 s = format (s, "\n%U", format_white_space, indent);
3193 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3196 vat_main_t *vam = &vat_main;
3197 i32 retval = ntohl (mp->retval);
3200 fformat (vam->ofp, "classify table info :\n");
3201 fformat (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d\n",
3202 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3203 ntohl (mp->miss_next_index));
3204 fformat (vam->ofp, "nbuckets: %d skip: %d match: %d\n",
3205 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3206 ntohl (mp->match_n_vectors));
3207 fformat (vam->ofp, "mask: %U\n", format_hex_bytes, mp->mask,
3208 ntohl (mp->mask_length));
3210 vam->retval = retval;
3211 vam->result_ready = 1;
3215 vl_api_classify_table_info_reply_t_handler_json
3216 (vl_api_classify_table_info_reply_t * mp)
3218 vat_main_t *vam = &vat_main;
3219 vat_json_node_t node;
3221 i32 retval = ntohl (mp->retval);
3224 vat_json_init_object (&node);
3226 vat_json_object_add_int (&node, "sessions",
3227 ntohl (mp->active_sessions));
3228 vat_json_object_add_int (&node, "nexttbl",
3229 ntohl (mp->next_table_index));
3230 vat_json_object_add_int (&node, "nextnode",
3231 ntohl (mp->miss_next_index));
3232 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3233 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3234 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3235 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3236 ntohl (mp->mask_length), 0);
3237 vat_json_object_add_string_copy (&node, "mask", s);
3239 vat_json_print (vam->ofp, &node);
3240 vat_json_free (&node);
3242 vam->retval = ntohl (mp->retval);
3243 vam->result_ready = 1;
3247 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3250 vat_main_t *vam = &vat_main;
3252 fformat (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3253 ntohl (mp->hit_next_index), ntohl (mp->advance),
3254 ntohl (mp->opaque_index));
3255 fformat (vam->ofp, "mask: %U\n", format_hex_bytes, mp->match,
3256 ntohl (mp->match_length));
3260 vl_api_classify_session_details_t_handler_json
3261 (vl_api_classify_session_details_t * mp)
3263 vat_main_t *vam = &vat_main;
3264 vat_json_node_t *node = NULL;
3266 if (VAT_JSON_ARRAY != vam->json_tree.type)
3268 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3269 vat_json_init_array (&vam->json_tree);
3271 node = vat_json_array_add (&vam->json_tree);
3273 vat_json_init_object (node);
3274 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3275 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3276 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3278 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3280 vat_json_object_add_string_copy (node, "match", s);
3283 static void vl_api_pg_create_interface_reply_t_handler
3284 (vl_api_pg_create_interface_reply_t * mp)
3286 vat_main_t *vam = &vat_main;
3288 vam->retval = ntohl (mp->retval);
3289 vam->result_ready = 1;
3292 static void vl_api_pg_create_interface_reply_t_handler_json
3293 (vl_api_pg_create_interface_reply_t * mp)
3295 vat_main_t *vam = &vat_main;
3296 vat_json_node_t node;
3298 i32 retval = ntohl (mp->retval);
3301 vat_json_init_object (&node);
3303 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3305 vat_json_print (vam->ofp, &node);
3306 vat_json_free (&node);
3308 vam->retval = ntohl (mp->retval);
3309 vam->result_ready = 1;
3312 static void vl_api_policer_classify_details_t_handler
3313 (vl_api_policer_classify_details_t * mp)
3315 vat_main_t *vam = &vat_main;
3317 fformat (vam->ofp, "%10d%20d\n", ntohl (mp->sw_if_index),
3318 ntohl (mp->table_index));
3321 static void vl_api_policer_classify_details_t_handler_json
3322 (vl_api_policer_classify_details_t * mp)
3324 vat_main_t *vam = &vat_main;
3325 vat_json_node_t *node;
3327 if (VAT_JSON_ARRAY != vam->json_tree.type)
3329 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3330 vat_json_init_array (&vam->json_tree);
3332 node = vat_json_array_add (&vam->json_tree);
3334 vat_json_init_object (node);
3335 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3336 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3339 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3340 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3342 vat_main_t *vam = &vat_main;
3343 i32 retval = ntohl (mp->retval);
3344 if (vam->async_mode)
3346 vam->async_errors += (retval < 0);
3350 vam->retval = retval;
3351 vam->sw_if_index = ntohl (mp->sw_if_index);
3352 vam->result_ready = 1;
3356 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3357 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3359 vat_main_t *vam = &vat_main;
3360 vat_json_node_t node;
3362 vat_json_init_object (&node);
3363 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3364 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3366 vat_json_print (vam->ofp, &node);
3367 vat_json_free (&node);
3369 vam->retval = ntohl (mp->retval);
3370 vam->result_ready = 1;
3373 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3374 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3375 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3376 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3379 * Generate boilerplate reply handlers, which
3380 * dig the return value out of the xxx_reply_t API message,
3381 * stick it into vam->retval, and set vam->result_ready
3383 * Could also do this by pointing N message decode slots at
3384 * a single function, but that could break in subtle ways.
3387 #define foreach_standard_reply_retval_handler \
3388 _(sw_interface_set_flags_reply) \
3389 _(sw_interface_add_del_address_reply) \
3390 _(sw_interface_set_table_reply) \
3391 _(sw_interface_set_vpath_reply) \
3392 _(sw_interface_set_l2_bridge_reply) \
3393 _(sw_interface_set_dpdk_hqos_pipe_reply) \
3394 _(sw_interface_set_dpdk_hqos_subport_reply) \
3395 _(sw_interface_set_dpdk_hqos_tctbl_reply) \
3396 _(bridge_domain_add_del_reply) \
3397 _(sw_interface_set_l2_xconnect_reply) \
3398 _(l2fib_add_del_reply) \
3399 _(ip_add_del_route_reply) \
3400 _(proxy_arp_add_del_reply) \
3401 _(proxy_arp_intfc_enable_disable_reply) \
3402 _(mpls_add_del_encap_reply) \
3403 _(mpls_add_del_decap_reply) \
3404 _(mpls_ethernet_add_del_tunnel_2_reply) \
3405 _(sw_interface_set_unnumbered_reply) \
3406 _(ip_neighbor_add_del_reply) \
3407 _(reset_vrf_reply) \
3408 _(oam_add_del_reply) \
3409 _(reset_fib_reply) \
3410 _(dhcp_proxy_config_reply) \
3411 _(dhcp_proxy_config_2_reply) \
3412 _(dhcp_proxy_set_vss_reply) \
3413 _(dhcp_client_config_reply) \
3414 _(set_ip_flow_hash_reply) \
3415 _(sw_interface_ip6_enable_disable_reply) \
3416 _(sw_interface_ip6_set_link_local_address_reply) \
3417 _(sw_interface_ip6nd_ra_prefix_reply) \
3418 _(sw_interface_ip6nd_ra_config_reply) \
3419 _(set_arp_neighbor_limit_reply) \
3420 _(l2_patch_add_del_reply) \
3421 _(sr_tunnel_add_del_reply) \
3422 _(sr_policy_add_del_reply) \
3423 _(sr_multicast_map_add_del_reply) \
3424 _(classify_add_del_session_reply) \
3425 _(classify_set_interface_ip_table_reply) \
3426 _(classify_set_interface_l2_tables_reply) \
3427 _(l2tpv3_set_tunnel_cookies_reply) \
3428 _(l2tpv3_interface_enable_disable_reply) \
3429 _(l2tpv3_set_lookup_key_reply) \
3430 _(l2_fib_clear_table_reply) \
3431 _(l2_interface_efp_filter_reply) \
3432 _(l2_interface_vlan_tag_rewrite_reply) \
3433 _(modify_vhost_user_if_reply) \
3434 _(delete_vhost_user_if_reply) \
3435 _(want_ip4_arp_events_reply) \
3436 _(want_ip6_nd_events_reply) \
3437 _(input_acl_set_interface_reply) \
3438 _(ipsec_spd_add_del_reply) \
3439 _(ipsec_interface_add_del_spd_reply) \
3440 _(ipsec_spd_add_del_entry_reply) \
3441 _(ipsec_sad_add_del_entry_reply) \
3442 _(ipsec_sa_set_key_reply) \
3443 _(ikev2_profile_add_del_reply) \
3444 _(ikev2_profile_set_auth_reply) \
3445 _(ikev2_profile_set_id_reply) \
3446 _(ikev2_profile_set_ts_reply) \
3447 _(ikev2_set_local_key_reply) \
3448 _(delete_loopback_reply) \
3449 _(bd_ip_mac_add_del_reply) \
3450 _(map_del_domain_reply) \
3451 _(map_add_del_rule_reply) \
3452 _(want_interface_events_reply) \
3453 _(want_stats_reply) \
3454 _(cop_interface_enable_disable_reply) \
3455 _(cop_whitelist_enable_disable_reply) \
3456 _(sw_interface_clear_stats_reply) \
3457 _(ioam_enable_reply) \
3458 _(ioam_disable_reply) \
3459 _(lisp_add_del_locator_reply) \
3460 _(lisp_add_del_local_eid_reply) \
3461 _(lisp_add_del_remote_mapping_reply) \
3462 _(lisp_add_del_adjacency_reply) \
3463 _(lisp_gpe_add_del_fwd_entry_reply) \
3464 _(lisp_add_del_map_resolver_reply) \
3465 _(lisp_gpe_enable_disable_reply) \
3466 _(lisp_gpe_add_del_iface_reply) \
3467 _(lisp_enable_disable_reply) \
3468 _(lisp_pitr_set_locator_set_reply) \
3469 _(lisp_map_request_mode_reply) \
3470 _(lisp_add_del_map_request_itr_rlocs_reply) \
3471 _(lisp_eid_table_add_del_map_reply) \
3472 _(vxlan_gpe_add_del_tunnel_reply) \
3473 _(af_packet_delete_reply) \
3474 _(policer_classify_set_interface_reply) \
3475 _(netmap_create_reply) \
3476 _(netmap_delete_reply) \
3477 _(set_ipfix_exporter_reply) \
3478 _(set_ipfix_classify_stream_reply) \
3479 _(ipfix_classify_table_add_del_reply) \
3480 _(pg_capture_reply) \
3481 _(pg_enable_disable_reply) \
3482 _(ip_source_and_port_range_check_add_del_reply) \
3483 _(ip_source_and_port_range_check_interface_add_del_reply)\
3484 _(delete_subif_reply) \
3485 _(l2_interface_pbb_tag_rewrite_reply) \
3489 static void vl_api_##n##_t_handler \
3490 (vl_api_##n##_t * mp) \
3492 vat_main_t * vam = &vat_main; \
3493 i32 retval = ntohl(mp->retval); \
3494 if (vam->async_mode) { \
3495 vam->async_errors += (retval < 0); \
3497 vam->retval = retval; \
3498 vam->result_ready = 1; \
3501 foreach_standard_reply_retval_handler;
3505 static void vl_api_##n##_t_handler_json \
3506 (vl_api_##n##_t * mp) \
3508 vat_main_t * vam = &vat_main; \
3509 vat_json_node_t node; \
3510 vat_json_init_object(&node); \
3511 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3512 vat_json_print(vam->ofp, &node); \
3513 vam->retval = ntohl(mp->retval); \
3514 vam->result_ready = 1; \
3516 foreach_standard_reply_retval_handler;
3520 * Table of message reply handlers, must include boilerplate handlers
3524 #define foreach_vpe_api_reply_msg \
3525 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3526 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3527 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
3528 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3529 _(CONTROL_PING_REPLY, control_ping_reply) \
3530 _(CLI_REPLY, cli_reply) \
3531 _(CLI_INBAND_REPLY, cli_inband_reply) \
3532 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
3533 sw_interface_add_del_address_reply) \
3534 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
3535 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
3536 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
3537 sw_interface_set_l2_xconnect_reply) \
3538 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
3539 sw_interface_set_l2_bridge_reply) \
3540 _(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
3541 sw_interface_set_dpdk_hqos_pipe_reply) \
3542 _(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
3543 sw_interface_set_dpdk_hqos_subport_reply) \
3544 _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
3545 sw_interface_set_dpdk_hqos_tctbl_reply) \
3546 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
3547 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
3548 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
3549 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
3550 _(L2_FLAGS_REPLY, l2_flags_reply) \
3551 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
3552 _(TAP_CONNECT_REPLY, tap_connect_reply) \
3553 _(TAP_MODIFY_REPLY, tap_modify_reply) \
3554 _(TAP_DELETE_REPLY, tap_delete_reply) \
3555 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
3556 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
3557 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
3558 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
3559 proxy_arp_intfc_enable_disable_reply) \
3560 _(MPLS_ADD_DEL_ENCAP_REPLY, mpls_add_del_encap_reply) \
3561 _(MPLS_ADD_DEL_DECAP_REPLY, mpls_add_del_decap_reply) \
3562 _(MPLS_GRE_ADD_DEL_TUNNEL_REPLY, mpls_gre_add_del_tunnel_reply) \
3563 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_REPLY, \
3564 mpls_ethernet_add_del_tunnel_reply) \
3565 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_2_REPLY, \
3566 mpls_ethernet_add_del_tunnel_2_reply) \
3567 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
3568 sw_interface_set_unnumbered_reply) \
3569 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
3570 _(RESET_VRF_REPLY, reset_vrf_reply) \
3571 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
3572 _(CREATE_SUBIF_REPLY, create_subif_reply) \
3573 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
3574 _(RESET_FIB_REPLY, reset_fib_reply) \
3575 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
3576 _(DHCP_PROXY_CONFIG_2_REPLY, dhcp_proxy_config_2_reply) \
3577 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
3578 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
3579 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
3580 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
3581 sw_interface_ip6_enable_disable_reply) \
3582 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
3583 sw_interface_ip6_set_link_local_address_reply) \
3584 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
3585 sw_interface_ip6nd_ra_prefix_reply) \
3586 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
3587 sw_interface_ip6nd_ra_config_reply) \
3588 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
3589 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
3590 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
3591 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
3592 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
3593 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
3594 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
3595 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
3596 classify_set_interface_ip_table_reply) \
3597 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
3598 classify_set_interface_l2_tables_reply) \
3599 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
3600 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
3601 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
3602 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
3603 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
3604 l2tpv3_interface_enable_disable_reply) \
3605 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
3606 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
3607 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
3608 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
3609 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
3610 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
3611 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
3612 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
3613 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
3614 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
3615 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
3616 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
3617 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
3618 _(SHOW_VERSION_REPLY, show_version_reply) \
3619 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
3620 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
3621 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
3622 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
3623 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
3624 _(IP4_ARP_EVENT, ip4_arp_event) \
3625 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
3626 _(IP6_ND_EVENT, ip6_nd_event) \
3627 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
3628 _(IP_ADDRESS_DETAILS, ip_address_details) \
3629 _(IP_DETAILS, ip_details) \
3630 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
3631 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
3632 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
3633 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
3634 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
3635 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
3636 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
3637 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
3638 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
3639 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
3640 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
3641 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
3642 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
3643 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
3644 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
3645 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
3646 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
3647 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
3648 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
3649 _(MAP_DOMAIN_DETAILS, map_domain_details) \
3650 _(MAP_RULE_DETAILS, map_rule_details) \
3651 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
3652 _(WANT_STATS_REPLY, want_stats_reply) \
3653 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
3654 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
3655 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
3656 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
3657 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
3658 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
3659 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
3660 _(LISP_ADD_DEL_LOCATOR_SET_REPLY, lisp_add_del_locator_set_reply) \
3661 _(LISP_ADD_DEL_LOCATOR_REPLY, lisp_add_del_locator_reply) \
3662 _(LISP_ADD_DEL_LOCAL_EID_REPLY, lisp_add_del_local_eid_reply) \
3663 _(LISP_ADD_DEL_REMOTE_MAPPING_REPLY, lisp_add_del_remote_mapping_reply) \
3664 _(LISP_ADD_DEL_ADJACENCY_REPLY, lisp_add_del_adjacency_reply) \
3665 _(LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY, lisp_gpe_add_del_fwd_entry_reply) \
3666 _(LISP_ADD_DEL_MAP_RESOLVER_REPLY, lisp_add_del_map_resolver_reply) \
3667 _(LISP_GPE_ENABLE_DISABLE_REPLY, lisp_gpe_enable_disable_reply) \
3668 _(LISP_ENABLE_DISABLE_REPLY, lisp_enable_disable_reply) \
3669 _(LISP_PITR_SET_LOCATOR_SET_REPLY, lisp_pitr_set_locator_set_reply) \
3670 _(LISP_MAP_REQUEST_MODE_REPLY, lisp_map_request_mode_reply) \
3671 _(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \
3672 _(LISP_GPE_ADD_DEL_IFACE_REPLY, lisp_gpe_add_del_iface_reply) \
3673 _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \
3674 _(LISP_LOCATOR_DETAILS, lisp_locator_details) \
3675 _(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \
3676 _(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \
3677 _(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \
3678 _(LISP_GPE_TUNNEL_DETAILS, lisp_gpe_tunnel_details) \
3679 _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
3680 _(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
3681 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
3682 lisp_add_del_map_request_itr_rlocs_reply) \
3683 _(LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
3684 lisp_get_map_request_itr_rlocs_reply) \
3685 _(SHOW_LISP_PITR_REPLY, show_lisp_pitr_reply) \
3686 _(SHOW_LISP_MAP_REQUEST_MODE_REPLY, show_lisp_map_request_mode_reply) \
3687 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
3688 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
3689 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
3690 _(POLICER_DETAILS, policer_details) \
3691 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
3692 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
3693 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
3694 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
3695 _(MPLS_GRE_TUNNEL_DETAILS, mpls_gre_tunnel_details) \
3696 _(MPLS_ETH_TUNNEL_DETAILS, mpls_eth_tunnel_details) \
3697 _(MPLS_FIB_ENCAP_DETAILS, mpls_fib_encap_details) \
3698 _(MPLS_FIB_DECAP_DETAILS, mpls_fib_decap_details) \
3699 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
3700 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
3701 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
3702 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
3703 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
3704 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
3705 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
3706 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
3707 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
3708 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
3709 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
3710 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
3711 _(PG_CAPTURE_REPLY, pg_capture_reply) \
3712 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
3713 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
3714 ip_source_and_port_range_check_add_del_reply) \
3715 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
3716 ip_source_and_port_range_check_interface_add_del_reply) \
3717 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
3718 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
3719 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
3720 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
3721 _(PUNT_REPLY, punt_reply)
3723 /* M: construct, but don't yet send a message */
3727 vam->result_ready = 0; \
3728 mp = vl_msg_api_alloc(sizeof(*mp)); \
3729 memset (mp, 0, sizeof (*mp)); \
3730 mp->_vl_msg_id = ntohs (VL_API_##T); \
3731 mp->client_index = vam->my_client_index; \
3736 vam->result_ready = 0; \
3737 mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
3738 memset (mp, 0, sizeof (*mp)); \
3739 mp->_vl_msg_id = ntohs (VL_API_##T); \
3740 mp->client_index = vam->my_client_index; \
3744 /* S: send a message */
3745 #define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
3747 /* W: wait for results, with timeout */
3750 timeout = vat_time_now (vam) + 1.0; \
3752 while (vat_time_now (vam) < timeout) { \
3753 if (vam->result_ready == 1) { \
3754 return (vam->retval); \
3760 /* W2: wait for results, with timeout */
3763 timeout = vat_time_now (vam) + 1.0; \
3765 while (vat_time_now (vam) < timeout) { \
3766 if (vam->result_ready == 1) { \
3768 return (vam->retval); \
3781 #define STR_VTR_OP_CASE(op) \
3782 case L2_VTR_ ## op: \
3786 str_vtr_op (u32 vtr_op)
3790 STR_VTR_OP_CASE (DISABLED);
3791 STR_VTR_OP_CASE (PUSH_1);
3792 STR_VTR_OP_CASE (PUSH_2);
3793 STR_VTR_OP_CASE (POP_1);
3794 STR_VTR_OP_CASE (POP_2);
3795 STR_VTR_OP_CASE (TRANSLATE_1_1);
3796 STR_VTR_OP_CASE (TRANSLATE_1_2);
3797 STR_VTR_OP_CASE (TRANSLATE_2_1);
3798 STR_VTR_OP_CASE (TRANSLATE_2_2);
3805 dump_sub_interface_table (vat_main_t * vam)
3807 const sw_interface_subif_t *sub = NULL;
3809 if (vam->json_output)
3812 ("JSON output supported only for VPE API calls and dump_stats_table");
3817 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s\n",
3818 "Interface", "sw_if_index",
3819 "sub id", "dot1ad", "tags", "outer id",
3820 "inner id", "exact", "default", "outer any", "inner any");
3822 vec_foreach (sub, vam->sw_if_subif_table)
3825 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d\n",
3826 sub->interface_name,
3828 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
3829 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
3830 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
3831 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
3832 if (sub->vtr_op != L2_VTR_DISABLED)
3835 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
3836 "tag1: %d tag2: %d ]\n",
3837 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
3838 sub->vtr_tag1, sub->vtr_tag2);
3846 name_sort_cmp (void *a1, void *a2)
3848 name_sort_t *n1 = a1;
3849 name_sort_t *n2 = a2;
3851 return strcmp ((char *) n1->name, (char *) n2->name);
3855 dump_interface_table (vat_main_t * vam)
3858 name_sort_t *nses = 0, *ns;
3860 if (vam->json_output)
3863 ("JSON output supported only for VPE API calls and dump_stats_table");
3868 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
3870 vec_add2 (nses, ns, 1);
3871 ns->name = (u8 *)(p->key);
3872 ns->value = (u32) p->value[0];
3876 vec_sort_with_function (nses, name_sort_cmp);
3878 fformat (vam->ofp, "%-25s%-15s\n", "Interface", "sw_if_index");
3879 vec_foreach (ns, nses)
3881 fformat (vam->ofp, "%-25s%-15d\n", ns->name, ns->value);
3888 dump_ip_table (vat_main_t * vam, int is_ipv6)
3890 const ip_details_t *det = NULL;
3891 const ip_address_details_t *address = NULL;
3894 fformat (vam->ofp, "%-12s\n", "sw_if_index");
3896 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
3903 fformat (vam->ofp, "%-12d\n", i);
3905 " %-30s%-13s\n", "Address", "Prefix length");
3910 vec_foreach (address, det->addr)
3914 is_ipv6 ? format_ip6_address : format_ip4_address,
3915 address->ip, address->prefix_length);
3923 dump_ipv4_table (vat_main_t * vam)
3925 if (vam->json_output)
3928 ("JSON output supported only for VPE API calls and dump_stats_table");
3932 return dump_ip_table (vam, 0);
3936 dump_ipv6_table (vat_main_t * vam)
3938 if (vam->json_output)
3941 ("JSON output supported only for VPE API calls and dump_stats_table");
3945 return dump_ip_table (vam, 1);
3949 counter_type_to_str (u8 counter_type, u8 is_combined)
3953 switch (counter_type)
3955 case VNET_INTERFACE_COUNTER_DROP:
3957 case VNET_INTERFACE_COUNTER_PUNT:
3959 case VNET_INTERFACE_COUNTER_IP4:
3961 case VNET_INTERFACE_COUNTER_IP6:
3963 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
3965 case VNET_INTERFACE_COUNTER_RX_MISS:
3967 case VNET_INTERFACE_COUNTER_RX_ERROR:
3969 case VNET_INTERFACE_COUNTER_TX_ERROR:
3972 return "INVALID-COUNTER-TYPE";
3977 switch (counter_type)
3979 case VNET_INTERFACE_COUNTER_RX:
3981 case VNET_INTERFACE_COUNTER_TX:
3984 return "INVALID-COUNTER-TYPE";
3990 dump_stats_table (vat_main_t * vam)
3992 vat_json_node_t node;
3993 vat_json_node_t *msg_array;
3994 vat_json_node_t *msg;
3995 vat_json_node_t *counter_array;
3996 vat_json_node_t *counter;
3997 interface_counter_t c;
3999 ip4_fib_counter_t *c4;
4000 ip6_fib_counter_t *c6;
4003 if (!vam->json_output)
4005 clib_warning ("dump_stats_table supported only in JSON format");
4009 vat_json_init_object (&node);
4011 /* interface counters */
4012 msg_array = vat_json_object_add (&node, "interface_counters");
4013 vat_json_init_array (msg_array);
4014 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4016 msg = vat_json_array_add (msg_array);
4017 vat_json_init_object (msg);
4018 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4019 (u8 *) counter_type_to_str (i, 0));
4020 vat_json_object_add_int (msg, "is_combined", 0);
4021 counter_array = vat_json_object_add (msg, "data");
4022 vat_json_init_array (counter_array);
4023 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4025 packets = vam->simple_interface_counters[i][j];
4026 vat_json_array_add_uint (counter_array, packets);
4029 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4031 msg = vat_json_array_add (msg_array);
4032 vat_json_init_object (msg);
4033 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4034 (u8 *) counter_type_to_str (i, 1));
4035 vat_json_object_add_int (msg, "is_combined", 1);
4036 counter_array = vat_json_object_add (msg, "data");
4037 vat_json_init_array (counter_array);
4038 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4040 c = vam->combined_interface_counters[i][j];
4041 counter = vat_json_array_add (counter_array);
4042 vat_json_init_object (counter);
4043 vat_json_object_add_uint (counter, "packets", c.packets);
4044 vat_json_object_add_uint (counter, "bytes", c.bytes);
4048 /* ip4 fib counters */
4049 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4050 vat_json_init_array (msg_array);
4051 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4053 msg = vat_json_array_add (msg_array);
4054 vat_json_init_object (msg);
4055 vat_json_object_add_uint (msg, "vrf_id",
4056 vam->ip4_fib_counters_vrf_id_by_index[i]);
4057 counter_array = vat_json_object_add (msg, "c");
4058 vat_json_init_array (counter_array);
4059 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4061 counter = vat_json_array_add (counter_array);
4062 vat_json_init_object (counter);
4063 c4 = &vam->ip4_fib_counters[i][j];
4064 vat_json_object_add_ip4 (counter, "address", c4->address);
4065 vat_json_object_add_uint (counter, "address_length",
4066 c4->address_length);
4067 vat_json_object_add_uint (counter, "packets", c4->packets);
4068 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4072 /* ip6 fib counters */
4073 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4074 vat_json_init_array (msg_array);
4075 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4077 msg = vat_json_array_add (msg_array);
4078 vat_json_init_object (msg);
4079 vat_json_object_add_uint (msg, "vrf_id",
4080 vam->ip6_fib_counters_vrf_id_by_index[i]);
4081 counter_array = vat_json_object_add (msg, "c");
4082 vat_json_init_array (counter_array);
4083 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4085 counter = vat_json_array_add (counter_array);
4086 vat_json_init_object (counter);
4087 c6 = &vam->ip6_fib_counters[i][j];
4088 vat_json_object_add_ip6 (counter, "address", c6->address);
4089 vat_json_object_add_uint (counter, "address_length",
4090 c6->address_length);
4091 vat_json_object_add_uint (counter, "packets", c6->packets);
4092 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4096 vat_json_print (vam->ofp, &node);
4097 vat_json_free (&node);
4103 exec (vat_main_t * vam)
4105 api_main_t *am = &api_main;
4106 vl_api_cli_request_t *mp;
4110 unformat_input_t *i = vam->input;
4112 if (vec_len (i->buffer) == 0)
4115 if (vam->exec_mode == 0 && unformat (i, "mode"))
4120 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4127 M (CLI_REQUEST, cli_request);
4130 * Copy cmd into shared memory.
4131 * In order for the CLI command to work, it
4132 * must be a vector ending in \n, not a C-string ending
4135 pthread_mutex_lock (&am->vlib_rp->mutex);
4136 oldheap = svm_push_data_heap (am->vlib_rp);
4138 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4139 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4141 svm_pop_heap (oldheap);
4142 pthread_mutex_unlock (&am->vlib_rp->mutex);
4144 mp->cmd_in_shmem = (u64) cmd;
4146 timeout = vat_time_now (vam) + 10.0;
4148 while (vat_time_now (vam) < timeout)
4150 if (vam->result_ready == 1)
4153 if (vam->shmem_result != NULL)
4154 fformat (vam->ofp, "%s", vam->shmem_result);
4155 pthread_mutex_lock (&am->vlib_rp->mutex);
4156 oldheap = svm_push_data_heap (am->vlib_rp);
4158 free_me = (u8 *) vam->shmem_result;
4161 svm_pop_heap (oldheap);
4162 pthread_mutex_unlock (&am->vlib_rp->mutex);
4170 * Future replacement of exec() that passes CLI buffers directly in
4171 * the API messages instead of an additional shared memory area.
4174 exec_inband (vat_main_t * vam)
4176 vl_api_cli_inband_t *mp;
4178 unformat_input_t *i = vam->input;
4180 if (vec_len (i->buffer) == 0)
4183 if (vam->exec_mode == 0 && unformat (i, "mode"))
4188 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4195 * In order for the CLI command to work, it
4196 * must be a vector ending in \n, not a C-string ending
4199 u32 len = vec_len (vam->input->buffer);
4200 M2 (CLI_INBAND, cli_inband, len);
4201 clib_memcpy (mp->cmd, vam->input->buffer, len);
4202 mp->length = htonl (len);
4205 W2 (fformat (vam->ofp, "%s", vam->cmd_reply));
4209 api_create_loopback (vat_main_t * vam)
4211 unformat_input_t *i = vam->input;
4212 vl_api_create_loopback_t *mp;
4217 memset (mac_address, 0, sizeof (mac_address));
4219 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4221 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4227 /* Construct the API message */
4228 M (CREATE_LOOPBACK, create_loopback);
4230 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4237 api_delete_loopback (vat_main_t * vam)
4239 unformat_input_t *i = vam->input;
4240 vl_api_delete_loopback_t *mp;
4242 u32 sw_if_index = ~0;
4244 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4246 if (unformat (i, "sw_if_index %d", &sw_if_index))
4252 if (sw_if_index == ~0)
4254 errmsg ("missing sw_if_index\n");
4258 /* Construct the API message */
4259 M (DELETE_LOOPBACK, delete_loopback);
4260 mp->sw_if_index = ntohl (sw_if_index);
4267 api_want_stats (vat_main_t * vam)
4269 unformat_input_t *i = vam->input;
4270 vl_api_want_stats_t *mp;
4274 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4276 if (unformat (i, "enable"))
4278 else if (unformat (i, "disable"))
4286 errmsg ("missing enable|disable\n");
4290 M (WANT_STATS, want_stats);
4291 mp->enable_disable = enable;
4298 api_want_interface_events (vat_main_t * vam)
4300 unformat_input_t *i = vam->input;
4301 vl_api_want_interface_events_t *mp;
4305 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4307 if (unformat (i, "enable"))
4309 else if (unformat (i, "disable"))
4317 errmsg ("missing enable|disable\n");
4321 M (WANT_INTERFACE_EVENTS, want_interface_events);
4322 mp->enable_disable = enable;
4324 vam->interface_event_display = enable;
4331 /* Note: non-static, called once to set up the initial intfc table */
4333 api_sw_interface_dump (vat_main_t * vam)
4335 vl_api_sw_interface_dump_t *mp;
4338 name_sort_t *nses = 0, *ns;
4339 sw_interface_subif_t *sub = NULL;
4341 /* Toss the old name table */
4343 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4345 vec_add2 (nses, ns, 1);
4346 ns->name = (u8 *)(p->key);
4347 ns->value = (u32) p->value[0];
4351 hash_free (vam->sw_if_index_by_interface_name);
4353 vec_foreach (ns, nses) vec_free (ns->name);
4357 vec_foreach (sub, vam->sw_if_subif_table)
4359 vec_free (sub->interface_name);
4361 vec_free (vam->sw_if_subif_table);
4363 /* recreate the interface name hash table */
4364 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4366 /* Get list of ethernets */
4367 M (SW_INTERFACE_DUMP, sw_interface_dump);
4368 mp->name_filter_valid = 1;
4369 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4372 /* and local / loopback interfaces */
4373 M (SW_INTERFACE_DUMP, sw_interface_dump);
4374 mp->name_filter_valid = 1;
4375 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4378 /* and packet-generator interfaces */
4379 M (SW_INTERFACE_DUMP, sw_interface_dump);
4380 mp->name_filter_valid = 1;
4381 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4384 /* and vxlan-gpe tunnel interfaces */
4385 M (SW_INTERFACE_DUMP, sw_interface_dump);
4386 mp->name_filter_valid = 1;
4387 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4388 sizeof (mp->name_filter) - 1);
4391 /* and vxlan tunnel interfaces */
4392 M (SW_INTERFACE_DUMP, sw_interface_dump);
4393 mp->name_filter_valid = 1;
4394 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4397 /* and host (af_packet) interfaces */
4398 M (SW_INTERFACE_DUMP, sw_interface_dump);
4399 mp->name_filter_valid = 1;
4400 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4403 /* and l2tpv3 tunnel interfaces */
4404 M (SW_INTERFACE_DUMP, sw_interface_dump);
4405 mp->name_filter_valid = 1;
4406 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4407 sizeof (mp->name_filter) - 1);
4410 /* and GRE tunnel interfaces */
4411 M (SW_INTERFACE_DUMP, sw_interface_dump);
4412 mp->name_filter_valid = 1;
4413 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4416 /* and LISP-GPE interfaces */
4417 M (SW_INTERFACE_DUMP, sw_interface_dump);
4418 mp->name_filter_valid = 1;
4419 strncpy ((char *) mp->name_filter, "lisp_gpe",
4420 sizeof (mp->name_filter) - 1);
4423 /* and IPSEC tunnel interfaces */
4424 M (SW_INTERFACE_DUMP, sw_interface_dump);
4425 mp->name_filter_valid = 1;
4426 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4429 /* Use a control ping for synchronization */
4431 vl_api_control_ping_t *mp;
4432 M (CONTROL_PING, control_ping);
4439 api_sw_interface_set_flags (vat_main_t * vam)
4441 unformat_input_t *i = vam->input;
4442 vl_api_sw_interface_set_flags_t *mp;
4445 u8 sw_if_index_set = 0;
4446 u8 admin_up = 0, link_up = 0;
4448 /* Parse args required to build the message */
4449 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4451 if (unformat (i, "admin-up"))
4453 else if (unformat (i, "admin-down"))
4455 else if (unformat (i, "link-up"))
4457 else if (unformat (i, "link-down"))
4459 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4460 sw_if_index_set = 1;
4461 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4462 sw_if_index_set = 1;
4467 if (sw_if_index_set == 0)
4469 errmsg ("missing interface name or sw_if_index\n");
4473 /* Construct the API message */
4474 M (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags);
4475 mp->sw_if_index = ntohl (sw_if_index);
4476 mp->admin_up_down = admin_up;
4477 mp->link_up_down = link_up;
4482 /* Wait for a reply, return the good/bad news... */
4487 api_sw_interface_clear_stats (vat_main_t * vam)
4489 unformat_input_t *i = vam->input;
4490 vl_api_sw_interface_clear_stats_t *mp;
4493 u8 sw_if_index_set = 0;
4495 /* Parse args required to build the message */
4496 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4498 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4499 sw_if_index_set = 1;
4500 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4501 sw_if_index_set = 1;
4506 /* Construct the API message */
4507 M (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats);
4509 if (sw_if_index_set == 1)
4510 mp->sw_if_index = ntohl (sw_if_index);
4512 mp->sw_if_index = ~0;
4517 /* Wait for a reply, return the good/bad news... */
4522 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
4524 unformat_input_t *i = vam->input;
4525 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
4528 u8 sw_if_index_set = 0;
4536 /* Parse args required to build the message */
4537 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4539 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4540 sw_if_index_set = 1;
4541 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4542 sw_if_index_set = 1;
4543 else if (unformat (i, "subport %u", &subport))
4545 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4546 sw_if_index_set = 1;
4547 else if (unformat (i, "pipe %u", &pipe))
4549 else if (unformat (i, "profile %u", &profile))
4555 if (sw_if_index_set == 0)
4557 errmsg ("missing interface name or sw_if_index\n");
4561 if (subport_set == 0)
4563 errmsg ("missing subport \n");
4569 errmsg ("missing pipe\n");
4573 if (profile_set == 0)
4575 errmsg ("missing profile\n");
4579 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe);
4581 mp->sw_if_index = ntohl (sw_if_index);
4582 mp->subport = ntohl (subport);
4583 mp->pipe = ntohl (pipe);
4584 mp->profile = ntohl (profile);
4594 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
4596 unformat_input_t *i = vam->input;
4597 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
4600 u8 sw_if_index_set = 0;
4603 u32 tb_rate = 1250000000; /* 10GbE */
4604 u32 tb_size = 1000000;
4605 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
4608 /* Parse args required to build the message */
4609 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4611 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4612 sw_if_index_set = 1;
4613 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4614 sw_if_index_set = 1;
4615 else if (unformat (i, "subport %u", &subport))
4617 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4618 sw_if_index_set = 1;
4619 else if (unformat (i, "rate %u", &tb_rate))
4623 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
4625 tc_rate[tc_id] = tb_rate;
4627 else if (unformat (i, "bktsize %u", &tb_size))
4629 else if (unformat (i, "tc0 %u", &tc_rate[0]))
4631 else if (unformat (i, "tc1 %u", &tc_rate[1]))
4633 else if (unformat (i, "tc2 %u", &tc_rate[2]))
4635 else if (unformat (i, "tc3 %u", &tc_rate[3]))
4637 else if (unformat (i, "period %u", &tc_period))
4643 if (sw_if_index_set == 0)
4645 errmsg ("missing interface name or sw_if_index\n");
4649 if (subport_set == 0)
4651 errmsg ("missing subport \n");
4655 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport);
4657 mp->sw_if_index = ntohl (sw_if_index);
4658 mp->subport = ntohl (subport);
4659 mp->tb_rate = ntohl (tb_rate);
4660 mp->tb_size = ntohl (tb_size);
4661 mp->tc_rate[0] = ntohl (tc_rate[0]);
4662 mp->tc_rate[1] = ntohl (tc_rate[1]);
4663 mp->tc_rate[2] = ntohl (tc_rate[2]);
4664 mp->tc_rate[3] = ntohl (tc_rate[3]);
4665 mp->tc_period = ntohl (tc_period);
4674 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
4676 unformat_input_t *i = vam->input;
4677 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
4680 u8 sw_if_index_set = 0;
4684 u32 entry, tc, queue;
4686 /* Parse args required to build the message */
4687 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4689 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4690 sw_if_index_set = 1;
4691 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4692 sw_if_index_set = 1;
4693 else if (unformat (i, "entry %d", &entry))
4695 else if (unformat (i, "tc %d", &tc))
4697 else if (unformat (i, "queue %d", &queue))
4703 if (sw_if_index_set == 0)
4705 errmsg ("missing interface name or sw_if_index\n");
4711 errmsg ("missing entry \n");
4717 errmsg ("missing traffic class \n");
4723 errmsg ("missing queue \n");
4727 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl);
4729 mp->sw_if_index = ntohl (sw_if_index);
4730 mp->entry = ntohl (entry);
4731 mp->tc = ntohl (tc);
4732 mp->queue = ntohl (queue);
4741 api_sw_interface_add_del_address (vat_main_t * vam)
4743 unformat_input_t *i = vam->input;
4744 vl_api_sw_interface_add_del_address_t *mp;
4747 u8 sw_if_index_set = 0;
4748 u8 is_add = 1, del_all = 0;
4749 u32 address_length = 0;
4750 u8 v4_address_set = 0;
4751 u8 v6_address_set = 0;
4752 ip4_address_t v4address;
4753 ip6_address_t v6address;
4755 /* Parse args required to build the message */
4756 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4758 if (unformat (i, "del-all"))
4760 else if (unformat (i, "del"))
4762 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4763 sw_if_index_set = 1;
4764 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4765 sw_if_index_set = 1;
4766 else if (unformat (i, "%U/%d",
4767 unformat_ip4_address, &v4address, &address_length))
4769 else if (unformat (i, "%U/%d",
4770 unformat_ip6_address, &v6address, &address_length))
4776 if (sw_if_index_set == 0)
4778 errmsg ("missing interface name or sw_if_index\n");
4781 if (v4_address_set && v6_address_set)
4783 errmsg ("both v4 and v6 addresses set\n");
4786 if (!v4_address_set && !v6_address_set && !del_all)
4788 errmsg ("no addresses set\n");
4792 /* Construct the API message */
4793 M (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address);
4795 mp->sw_if_index = ntohl (sw_if_index);
4796 mp->is_add = is_add;
4797 mp->del_all = del_all;
4801 clib_memcpy (mp->address, &v6address, sizeof (v6address));
4805 clib_memcpy (mp->address, &v4address, sizeof (v4address));
4807 mp->address_length = address_length;
4812 /* Wait for a reply, return good/bad news */
4817 api_sw_interface_set_table (vat_main_t * vam)
4819 unformat_input_t *i = vam->input;
4820 vl_api_sw_interface_set_table_t *mp;
4822 u32 sw_if_index, vrf_id = 0;
4823 u8 sw_if_index_set = 0;
4826 /* Parse args required to build the message */
4827 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4829 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4830 sw_if_index_set = 1;
4831 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4832 sw_if_index_set = 1;
4833 else if (unformat (i, "vrf %d", &vrf_id))
4835 else if (unformat (i, "ipv6"))
4841 if (sw_if_index_set == 0)
4843 errmsg ("missing interface name or sw_if_index\n");
4847 /* Construct the API message */
4848 M (SW_INTERFACE_SET_TABLE, sw_interface_set_table);
4850 mp->sw_if_index = ntohl (sw_if_index);
4851 mp->is_ipv6 = is_ipv6;
4852 mp->vrf_id = ntohl (vrf_id);
4857 /* Wait for a reply... */
4862 api_sw_interface_set_vpath (vat_main_t * vam)
4864 unformat_input_t *i = vam->input;
4865 vl_api_sw_interface_set_vpath_t *mp;
4867 u32 sw_if_index = 0;
4868 u8 sw_if_index_set = 0;
4871 /* Parse args required to build the message */
4872 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4874 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4875 sw_if_index_set = 1;
4876 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4877 sw_if_index_set = 1;
4878 else if (unformat (i, "enable"))
4880 else if (unformat (i, "disable"))
4886 if (sw_if_index_set == 0)
4888 errmsg ("missing interface name or sw_if_index\n");
4892 /* Construct the API message */
4893 M (SW_INTERFACE_SET_VPATH, sw_interface_set_vpath);
4895 mp->sw_if_index = ntohl (sw_if_index);
4896 mp->enable = is_enable;
4901 /* Wait for a reply... */
4906 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
4908 unformat_input_t *i = vam->input;
4909 vl_api_sw_interface_set_l2_xconnect_t *mp;
4912 u8 rx_sw_if_index_set = 0;
4914 u8 tx_sw_if_index_set = 0;
4917 /* Parse args required to build the message */
4918 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4920 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
4921 rx_sw_if_index_set = 1;
4922 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
4923 tx_sw_if_index_set = 1;
4924 else if (unformat (i, "rx"))
4926 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4928 if (unformat (i, "%U", unformat_sw_if_index, vam,
4930 rx_sw_if_index_set = 1;
4935 else if (unformat (i, "tx"))
4937 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4939 if (unformat (i, "%U", unformat_sw_if_index, vam,
4941 tx_sw_if_index_set = 1;
4946 else if (unformat (i, "enable"))
4948 else if (unformat (i, "disable"))
4954 if (rx_sw_if_index_set == 0)
4956 errmsg ("missing rx interface name or rx_sw_if_index\n");
4960 if (enable && (tx_sw_if_index_set == 0))
4962 errmsg ("missing tx interface name or tx_sw_if_index\n");
4966 M (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect);
4968 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
4969 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
4970 mp->enable = enable;
4979 api_sw_interface_set_l2_bridge (vat_main_t * vam)
4981 unformat_input_t *i = vam->input;
4982 vl_api_sw_interface_set_l2_bridge_t *mp;
4985 u8 rx_sw_if_index_set = 0;
4992 /* Parse args required to build the message */
4993 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4995 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
4996 rx_sw_if_index_set = 1;
4997 else if (unformat (i, "bd_id %d", &bd_id))
4999 else if (unformat (i, "%U", unformat_sw_if_index, vam, &rx_sw_if_index))
5000 rx_sw_if_index_set = 1;
5001 else if (unformat (i, "shg %d", &shg))
5003 else if (unformat (i, "bvi"))
5005 else if (unformat (i, "enable"))
5007 else if (unformat (i, "disable"))
5013 if (rx_sw_if_index_set == 0)
5015 errmsg ("missing rx interface name or sw_if_index\n");
5019 if (enable && (bd_id_set == 0))
5021 errmsg ("missing bridge domain\n");
5025 M (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge);
5027 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5028 mp->bd_id = ntohl (bd_id);
5031 mp->enable = enable;
5040 api_bridge_domain_dump (vat_main_t * vam)
5042 unformat_input_t *i = vam->input;
5043 vl_api_bridge_domain_dump_t *mp;
5047 /* Parse args required to build the message */
5048 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5050 if (unformat (i, "bd_id %d", &bd_id))
5056 M (BRIDGE_DOMAIN_DUMP, bridge_domain_dump);
5057 mp->bd_id = ntohl (bd_id);
5060 /* Use a control ping for synchronization */
5062 vl_api_control_ping_t *mp;
5063 M (CONTROL_PING, control_ping);
5073 api_bridge_domain_add_del (vat_main_t * vam)
5075 unformat_input_t *i = vam->input;
5076 vl_api_bridge_domain_add_del_t *mp;
5080 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5082 /* Parse args required to build the message */
5083 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5085 if (unformat (i, "bd_id %d", &bd_id))
5087 else if (unformat (i, "flood %d", &flood))
5089 else if (unformat (i, "uu-flood %d", &uu_flood))
5091 else if (unformat (i, "forward %d", &forward))
5093 else if (unformat (i, "learn %d", &learn))
5095 else if (unformat (i, "arp-term %d", &arp_term))
5097 else if (unformat (i, "del"))
5100 flood = uu_flood = forward = learn = 0;
5108 errmsg ("missing bridge domain\n");
5112 M (BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del);
5114 mp->bd_id = ntohl (bd_id);
5116 mp->uu_flood = uu_flood;
5117 mp->forward = forward;
5119 mp->arp_term = arp_term;
5120 mp->is_add = is_add;
5129 api_l2fib_add_del (vat_main_t * vam)
5131 unformat_input_t *i = vam->input;
5132 vl_api_l2fib_add_del_t *mp;
5139 u8 sw_if_index_set = 0;
5148 /* Parse args required to build the message */
5149 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5151 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5153 else if (unformat (i, "bd_id %d", &bd_id))
5155 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5156 sw_if_index_set = 1;
5157 else if (unformat (i, "sw_if"))
5159 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5161 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5162 sw_if_index_set = 1;
5167 else if (unformat (i, "static"))
5169 else if (unformat (i, "filter"))
5174 else if (unformat (i, "bvi"))
5179 else if (unformat (i, "del"))
5181 else if (unformat (i, "count %d", &count))
5189 errmsg ("missing mac address\n");
5195 errmsg ("missing bridge domain\n");
5199 if (is_add && (sw_if_index_set == 0))
5201 errmsg ("missing interface name or sw_if_index\n");
5207 /* Turn on async mode */
5208 vam->async_mode = 1;
5209 vam->async_errors = 0;
5210 before = vat_time_now (vam);
5213 for (j = 0; j < count; j++)
5215 M (L2FIB_ADD_DEL, l2fib_add_del);
5218 mp->bd_id = ntohl (bd_id);
5219 mp->is_add = is_add;
5223 mp->sw_if_index = ntohl (sw_if_index);
5224 mp->static_mac = static_mac;
5225 mp->filter_mac = filter_mac;
5226 mp->bvi_mac = bvi_mac;
5228 increment_mac_address (&mac);
5235 vl_api_control_ping_t *mp;
5238 /* Shut off async mode */
5239 vam->async_mode = 0;
5241 M (CONTROL_PING, control_ping);
5244 timeout = vat_time_now (vam) + 1.0;
5245 while (vat_time_now (vam) < timeout)
5246 if (vam->result_ready == 1)
5251 if (vam->retval == -99)
5252 errmsg ("timeout\n");
5254 if (vam->async_errors > 0)
5256 errmsg ("%d asynchronous errors\n", vam->async_errors);
5259 vam->async_errors = 0;
5260 after = vat_time_now (vam);
5262 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
5263 count, after - before, count / (after - before));
5267 /* Wait for a reply... */
5270 /* Return the good/bad news */
5271 return (vam->retval);
5275 api_l2_flags (vat_main_t * vam)
5277 unformat_input_t *i = vam->input;
5278 vl_api_l2_flags_t *mp;
5281 u32 feature_bitmap = 0;
5282 u8 sw_if_index_set = 0;
5284 /* Parse args required to build the message */
5285 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5287 if (unformat (i, "sw_if_index %d", &sw_if_index))
5288 sw_if_index_set = 1;
5289 else if (unformat (i, "sw_if"))
5291 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5293 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5294 sw_if_index_set = 1;
5299 else if (unformat (i, "learn"))
5300 feature_bitmap |= L2INPUT_FEAT_LEARN;
5301 else if (unformat (i, "forward"))
5302 feature_bitmap |= L2INPUT_FEAT_FWD;
5303 else if (unformat (i, "flood"))
5304 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5305 else if (unformat (i, "uu-flood"))
5306 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5311 if (sw_if_index_set == 0)
5313 errmsg ("missing interface name or sw_if_index\n");
5317 M (L2_FLAGS, l2_flags);
5319 mp->sw_if_index = ntohl (sw_if_index);
5320 mp->feature_bitmap = ntohl (feature_bitmap);
5329 api_bridge_flags (vat_main_t * vam)
5331 unformat_input_t *i = vam->input;
5332 vl_api_bridge_flags_t *mp;
5339 /* Parse args required to build the message */
5340 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5342 if (unformat (i, "bd_id %d", &bd_id))
5344 else if (unformat (i, "learn"))
5346 else if (unformat (i, "forward"))
5348 else if (unformat (i, "flood"))
5350 else if (unformat (i, "uu-flood"))
5351 flags |= L2_UU_FLOOD;
5352 else if (unformat (i, "arp-term"))
5353 flags |= L2_ARP_TERM;
5354 else if (unformat (i, "off"))
5356 else if (unformat (i, "disable"))
5364 errmsg ("missing bridge domain\n");
5368 M (BRIDGE_FLAGS, bridge_flags);
5370 mp->bd_id = ntohl (bd_id);
5371 mp->feature_bitmap = ntohl (flags);
5372 mp->is_set = is_set;
5381 api_bd_ip_mac_add_del (vat_main_t * vam)
5383 unformat_input_t *i = vam->input;
5384 vl_api_bd_ip_mac_add_del_t *mp;
5392 ip4_address_t v4addr;
5393 ip6_address_t v6addr;
5397 /* Parse args required to build the message */
5398 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5400 if (unformat (i, "bd_id %d", &bd_id))
5404 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5408 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5413 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5417 else if (unformat (i, "del"))
5425 errmsg ("missing bridge domain\n");
5428 else if (ip_set == 0)
5430 errmsg ("missing IP address\n");
5433 else if (mac_set == 0)
5435 errmsg ("missing MAC address\n");
5439 M (BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del);
5441 mp->bd_id = ntohl (bd_id);
5442 mp->is_ipv6 = is_ipv6;
5443 mp->is_add = is_add;
5445 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5447 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5448 clib_memcpy (mp->mac_address, macaddr, 6);
5456 api_tap_connect (vat_main_t * vam)
5458 unformat_input_t *i = vam->input;
5459 vl_api_tap_connect_t *mp;
5466 memset (mac_address, 0, sizeof (mac_address));
5468 /* Parse args required to build the message */
5469 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5471 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5475 else if (unformat (i, "random-mac"))
5477 else if (unformat (i, "tapname %s", &tap_name))
5485 errmsg ("missing tap name\n");
5488 if (vec_len (tap_name) > 63)
5490 errmsg ("tap name too long\n");
5492 vec_add1 (tap_name, 0);
5494 /* Construct the API message */
5495 M (TAP_CONNECT, tap_connect);
5497 mp->use_random_mac = random_mac;
5498 clib_memcpy (mp->mac_address, mac_address, 6);
5499 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5500 vec_free (tap_name);
5505 /* Wait for a reply... */
5510 api_tap_modify (vat_main_t * vam)
5512 unformat_input_t *i = vam->input;
5513 vl_api_tap_modify_t *mp;
5519 u32 sw_if_index = ~0;
5520 u8 sw_if_index_set = 0;
5522 memset (mac_address, 0, sizeof (mac_address));
5524 /* Parse args required to build the message */
5525 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5527 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5528 sw_if_index_set = 1;
5529 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5530 sw_if_index_set = 1;
5531 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5535 else if (unformat (i, "random-mac"))
5537 else if (unformat (i, "tapname %s", &tap_name))
5543 if (sw_if_index_set == 0)
5545 errmsg ("missing vpp interface name");
5550 errmsg ("missing tap name\n");
5553 if (vec_len (tap_name) > 63)
5555 errmsg ("tap name too long\n");
5557 vec_add1 (tap_name, 0);
5559 /* Construct the API message */
5560 M (TAP_MODIFY, tap_modify);
5562 mp->use_random_mac = random_mac;
5563 mp->sw_if_index = ntohl (sw_if_index);
5564 clib_memcpy (mp->mac_address, mac_address, 6);
5565 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5566 vec_free (tap_name);
5571 /* Wait for a reply... */
5576 api_tap_delete (vat_main_t * vam)
5578 unformat_input_t *i = vam->input;
5579 vl_api_tap_delete_t *mp;
5581 u32 sw_if_index = ~0;
5582 u8 sw_if_index_set = 0;
5584 /* Parse args required to build the message */
5585 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5587 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5588 sw_if_index_set = 1;
5589 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5590 sw_if_index_set = 1;
5595 if (sw_if_index_set == 0)
5597 errmsg ("missing vpp interface name");
5601 /* Construct the API message */
5602 M (TAP_DELETE, tap_delete);
5604 mp->sw_if_index = ntohl (sw_if_index);
5609 /* Wait for a reply... */
5614 api_ip_add_del_route (vat_main_t * vam)
5616 unformat_input_t *i = vam->input;
5617 vl_api_ip_add_del_route_t *mp;
5619 u32 sw_if_index = ~0, vrf_id = 0;
5620 u8 sw_if_index_set = 0;
5622 u8 is_local = 0, is_drop = 0;
5623 u8 create_vrf_if_needed = 0;
5625 u8 next_hop_weight = 1;
5627 u8 is_multipath = 0;
5629 u8 address_length_set = 0;
5630 u32 lookup_in_vrf = 0;
5631 u32 resolve_attempts = 0;
5632 u32 dst_address_length = 0;
5633 u8 next_hop_set = 0;
5634 ip4_address_t v4_dst_address, v4_next_hop_address;
5635 ip6_address_t v6_dst_address, v6_next_hop_address;
5639 u32 random_add_del = 0;
5640 u32 *random_vector = 0;
5642 u32 random_seed = 0xdeaddabe;
5643 u32 classify_table_index = ~0;
5645 u8 resolve_host = 0, resolve_attached = 0;
5647 /* Parse args required to build the message */
5648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5650 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5651 sw_if_index_set = 1;
5652 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5653 sw_if_index_set = 1;
5654 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
5659 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
5664 else if (unformat (i, "/%d", &dst_address_length))
5666 address_length_set = 1;
5669 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
5670 &v4_next_hop_address))
5674 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
5675 &v6_next_hop_address))
5679 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
5681 else if (unformat (i, "weight %d", &next_hop_weight))
5683 else if (unformat (i, "drop"))
5687 else if (unformat (i, "local"))
5691 else if (unformat (i, "classify %d", &classify_table_index))
5695 else if (unformat (i, "del"))
5697 else if (unformat (i, "add"))
5699 else if (unformat (i, "not-last"))
5701 else if (unformat (i, "resolve-via-host"))
5703 else if (unformat (i, "resolve-via-attached"))
5704 resolve_attached = 1;
5705 else if (unformat (i, "multipath"))
5707 else if (unformat (i, "vrf %d", &vrf_id))
5709 else if (unformat (i, "create-vrf"))
5710 create_vrf_if_needed = 1;
5711 else if (unformat (i, "count %d", &count))
5713 else if (unformat (i, "lookup-in-vrf %d", &lookup_in_vrf))
5715 else if (unformat (i, "random"))
5717 else if (unformat (i, "seed %d", &random_seed))
5721 clib_warning ("parse error '%U'", format_unformat_error, i);
5726 if (resolve_attempts > 0 && sw_if_index_set == 0)
5728 errmsg ("ARP resolution needs explicit interface or sw_if_index\n");
5732 if (!next_hop_set && !is_drop && !is_local && !is_classify)
5734 errmsg ("next hop / local / drop / classify not set\n");
5738 if (address_set == 0)
5740 errmsg ("missing addresses\n");
5744 if (address_length_set == 0)
5746 errmsg ("missing address length\n");
5750 /* Generate a pile of unique, random routes */
5753 u32 this_random_address;
5754 random_hash = hash_create (count, sizeof (uword));
5756 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
5757 for (j = 0; j <= count; j++)
5761 this_random_address = random_u32 (&random_seed);
5762 this_random_address =
5763 clib_host_to_net_u32 (this_random_address);
5765 while (hash_get (random_hash, this_random_address));
5766 vec_add1 (random_vector, this_random_address);
5767 hash_set (random_hash, this_random_address, 1);
5769 hash_free (random_hash);
5770 v4_dst_address.as_u32 = random_vector[0];
5775 /* Turn on async mode */
5776 vam->async_mode = 1;
5777 vam->async_errors = 0;
5778 before = vat_time_now (vam);
5781 for (j = 0; j < count; j++)
5783 /* Construct the API message */
5784 M (IP_ADD_DEL_ROUTE, ip_add_del_route);
5786 mp->next_hop_sw_if_index = ntohl (sw_if_index);
5787 mp->vrf_id = ntohl (vrf_id);
5788 if (resolve_attempts > 0)
5790 mp->resolve_attempts = ntohl (resolve_attempts);
5791 mp->resolve_if_needed = 1;
5793 mp->create_vrf_if_needed = create_vrf_if_needed;
5795 mp->is_add = is_add;
5796 mp->is_drop = is_drop;
5797 mp->is_ipv6 = is_ipv6;
5798 mp->is_local = is_local;
5799 mp->is_classify = is_classify;
5800 mp->is_multipath = is_multipath;
5801 mp->is_resolve_host = resolve_host;
5802 mp->is_resolve_attached = resolve_attached;
5803 mp->not_last = not_last;
5804 mp->next_hop_weight = next_hop_weight;
5805 mp->dst_address_length = dst_address_length;
5806 mp->lookup_in_vrf = ntohl (lookup_in_vrf);
5807 mp->classify_table_index = ntohl (classify_table_index);
5811 clib_memcpy (mp->dst_address, &v6_dst_address,
5812 sizeof (v6_dst_address));
5814 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
5815 sizeof (v6_next_hop_address));
5816 increment_v6_address (&v6_dst_address);
5820 clib_memcpy (mp->dst_address, &v4_dst_address,
5821 sizeof (v4_dst_address));
5823 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
5824 sizeof (v4_next_hop_address));
5826 v4_dst_address.as_u32 = random_vector[j + 1];
5828 increment_v4_address (&v4_dst_address);
5832 /* If we receive SIGTERM, stop now... */
5837 /* When testing multiple add/del ops, use a control-ping to sync */
5840 vl_api_control_ping_t *mp;
5843 /* Shut off async mode */
5844 vam->async_mode = 0;
5846 M (CONTROL_PING, control_ping);
5849 timeout = vat_time_now (vam) + 1.0;
5850 while (vat_time_now (vam) < timeout)
5851 if (vam->result_ready == 1)
5856 if (vam->retval == -99)
5857 errmsg ("timeout\n");
5859 if (vam->async_errors > 0)
5861 errmsg ("%d asynchronous errors\n", vam->async_errors);
5864 vam->async_errors = 0;
5865 after = vat_time_now (vam);
5867 /* slim chance, but we might have eaten SIGTERM on the first iteration */
5871 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
5872 count, after - before, count / (after - before));
5876 /* Wait for a reply... */
5880 /* Return the good/bad news */
5881 return (vam->retval);
5885 api_proxy_arp_add_del (vat_main_t * vam)
5887 unformat_input_t *i = vam->input;
5888 vl_api_proxy_arp_add_del_t *mp;
5892 ip4_address_t lo, hi;
5895 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5897 if (unformat (i, "vrf %d", &vrf_id))
5899 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
5900 unformat_ip4_address, &hi))
5902 else if (unformat (i, "del"))
5906 clib_warning ("parse error '%U'", format_unformat_error, i);
5913 errmsg ("address range not set\n");
5917 M (PROXY_ARP_ADD_DEL, proxy_arp_add_del);
5919 mp->vrf_id = ntohl (vrf_id);
5920 mp->is_add = is_add;
5921 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
5922 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
5931 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
5933 unformat_input_t *i = vam->input;
5934 vl_api_proxy_arp_intfc_enable_disable_t *mp;
5938 u8 sw_if_index_set = 0;
5940 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5942 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5943 sw_if_index_set = 1;
5944 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5945 sw_if_index_set = 1;
5946 else if (unformat (i, "enable"))
5948 else if (unformat (i, "disable"))
5952 clib_warning ("parse error '%U'", format_unformat_error, i);
5957 if (sw_if_index_set == 0)
5959 errmsg ("missing interface name or sw_if_index\n");
5963 M (PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable);
5965 mp->sw_if_index = ntohl (sw_if_index);
5966 mp->enable_disable = enable;
5975 api_mpls_add_del_decap (vat_main_t * vam)
5977 unformat_input_t *i = vam->input;
5978 vl_api_mpls_add_del_decap_t *mp;
5987 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5989 if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
5991 else if (unformat (i, "tx_vrf_id %d", &tx_vrf_id))
5993 else if (unformat (i, "label %d", &label))
5995 else if (unformat (i, "next-index %d", &next_index))
5997 else if (unformat (i, "del"))
5999 else if (unformat (i, "s-bit-clear"))
6003 clib_warning ("parse error '%U'", format_unformat_error, i);
6008 M (MPLS_ADD_DEL_DECAP, mpls_add_del_decap);
6010 mp->rx_vrf_id = ntohl (rx_vrf_id);
6011 mp->tx_vrf_id = ntohl (tx_vrf_id);
6012 mp->label = ntohl (label);
6013 mp->next_index = ntohl (next_index);
6015 mp->is_add = is_add;
6024 api_mpls_add_del_encap (vat_main_t * vam)
6026 unformat_input_t *i = vam->input;
6027 vl_api_mpls_add_del_encap_t *mp;
6032 ip4_address_t dst_address;
6035 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6037 if (unformat (i, "vrf %d", &vrf_id))
6039 else if (unformat (i, "label %d", &label))
6040 vec_add1 (labels, ntohl (label));
6041 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
6043 else if (unformat (i, "del"))
6047 clib_warning ("parse error '%U'", format_unformat_error, i);
6052 if (vec_len (labels) == 0)
6054 errmsg ("missing encap label stack\n");
6058 M2 (MPLS_ADD_DEL_ENCAP, mpls_add_del_encap,
6059 sizeof (u32) * vec_len (labels));
6061 mp->vrf_id = ntohl (vrf_id);
6062 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
6063 mp->is_add = is_add;
6064 mp->nlabels = vec_len (labels);
6065 clib_memcpy (mp->labels, labels, sizeof (u32) * mp->nlabels);
6076 api_mpls_gre_add_del_tunnel (vat_main_t * vam)
6078 unformat_input_t *i = vam->input;
6079 vl_api_mpls_gre_add_del_tunnel_t *mp;
6081 u32 inner_vrf_id = 0;
6082 u32 outer_vrf_id = 0;
6083 ip4_address_t src_address;
6084 ip4_address_t dst_address;
6085 ip4_address_t intfc_address;
6087 u8 intfc_address_length = 0;
6091 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6093 if (unformat (i, "inner_vrf_id %d", &inner_vrf_id))
6095 else if (unformat (i, "outer_vrf_id %d", &outer_vrf_id))
6097 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
6099 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
6101 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
6102 &intfc_address, &tmp))
6103 intfc_address_length = tmp;
6104 else if (unformat (i, "l2-only"))
6106 else if (unformat (i, "del"))
6110 clib_warning ("parse error '%U'", format_unformat_error, i);
6115 M (MPLS_GRE_ADD_DEL_TUNNEL, mpls_gre_add_del_tunnel);
6117 mp->inner_vrf_id = ntohl (inner_vrf_id);
6118 mp->outer_vrf_id = ntohl (outer_vrf_id);
6119 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
6120 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
6121 clib_memcpy (mp->intfc_address, &intfc_address, sizeof (intfc_address));
6122 mp->intfc_address_length = intfc_address_length;
6123 mp->l2_only = l2_only;
6124 mp->is_add = is_add;
6133 api_mpls_ethernet_add_del_tunnel (vat_main_t * vam)
6135 unformat_input_t *i = vam->input;
6136 vl_api_mpls_ethernet_add_del_tunnel_t *mp;
6138 u32 inner_vrf_id = 0;
6139 ip4_address_t intfc_address;
6140 u8 dst_mac_address[6];
6143 u8 intfc_address_length = 0;
6147 int tx_sw_if_index_set = 0;
6149 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6151 if (unformat (i, "vrf %d", &inner_vrf_id))
6153 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
6154 &intfc_address, &tmp))
6155 intfc_address_length = tmp;
6156 else if (unformat (i, "%U", unformat_sw_if_index, vam, &tx_sw_if_index))
6157 tx_sw_if_index_set = 1;
6158 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6159 tx_sw_if_index_set = 1;
6160 else if (unformat (i, "dst %U", unformat_ethernet_address,
6163 else if (unformat (i, "l2-only"))
6165 else if (unformat (i, "del"))
6169 clib_warning ("parse error '%U'", format_unformat_error, i);
6176 errmsg ("dst (mac address) not set\n");
6179 if (!tx_sw_if_index_set)
6181 errmsg ("tx-intfc not set\n");
6185 M (MPLS_ETHERNET_ADD_DEL_TUNNEL, mpls_ethernet_add_del_tunnel);
6187 mp->vrf_id = ntohl (inner_vrf_id);
6188 clib_memcpy (mp->adj_address, &intfc_address, sizeof (intfc_address));
6189 mp->adj_address_length = intfc_address_length;
6190 clib_memcpy (mp->dst_mac_address, dst_mac_address,
6191 sizeof (dst_mac_address));
6192 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6193 mp->l2_only = l2_only;
6194 mp->is_add = is_add;
6203 api_mpls_ethernet_add_del_tunnel_2 (vat_main_t * vam)
6205 unformat_input_t *i = vam->input;
6206 vl_api_mpls_ethernet_add_del_tunnel_2_t *mp;
6208 u32 inner_vrf_id = 0;
6209 u32 outer_vrf_id = 0;
6210 ip4_address_t adj_address;
6211 int adj_address_set = 0;
6212 ip4_address_t next_hop_address;
6213 int next_hop_address_set = 0;
6215 u8 adj_address_length = 0;
6218 u32 resolve_attempts = 5;
6219 u8 resolve_if_needed = 1;
6221 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6223 if (unformat (i, "inner_vrf_id %d", &inner_vrf_id))
6225 else if (unformat (i, "outer_vrf_id %d", &outer_vrf_id))
6227 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
6228 &adj_address, &tmp))
6230 adj_address_length = tmp;
6231 adj_address_set = 1;
6233 else if (unformat (i, "next-hop %U", unformat_ip4_address,
6235 next_hop_address_set = 1;
6236 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6238 else if (unformat (i, "resolve-if-needed %d", &tmp))
6239 resolve_if_needed = tmp;
6240 else if (unformat (i, "l2-only"))
6242 else if (unformat (i, "del"))
6246 clib_warning ("parse error '%U'", format_unformat_error, i);
6251 if (!adj_address_set)
6253 errmsg ("adjacency address/mask not set\n");
6256 if (!next_hop_address_set)
6258 errmsg ("ip4 next hop address (in outer fib) not set\n");
6262 M (MPLS_ETHERNET_ADD_DEL_TUNNEL_2, mpls_ethernet_add_del_tunnel_2);
6264 mp->inner_vrf_id = ntohl (inner_vrf_id);
6265 mp->outer_vrf_id = ntohl (outer_vrf_id);
6266 mp->resolve_attempts = ntohl (resolve_attempts);
6267 mp->resolve_if_needed = resolve_if_needed;
6268 mp->is_add = is_add;
6269 mp->l2_only = l2_only;
6270 clib_memcpy (mp->adj_address, &adj_address, sizeof (adj_address));
6271 mp->adj_address_length = adj_address_length;
6272 clib_memcpy (mp->next_hop_ip4_address_in_outer_vrf, &next_hop_address,
6273 sizeof (next_hop_address));
6282 api_sw_interface_set_unnumbered (vat_main_t * vam)
6284 unformat_input_t *i = vam->input;
6285 vl_api_sw_interface_set_unnumbered_t *mp;
6288 u32 unnum_sw_index = ~0;
6290 u8 sw_if_index_set = 0;
6292 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6294 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6295 sw_if_index_set = 1;
6296 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6297 sw_if_index_set = 1;
6298 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
6300 else if (unformat (i, "del"))
6304 clib_warning ("parse error '%U'", format_unformat_error, i);
6309 if (sw_if_index_set == 0)
6311 errmsg ("missing interface name or sw_if_index\n");
6315 M (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered);
6317 mp->sw_if_index = ntohl (sw_if_index);
6318 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
6319 mp->is_add = is_add;
6328 api_ip_neighbor_add_del (vat_main_t * vam)
6330 unformat_input_t *i = vam->input;
6331 vl_api_ip_neighbor_add_del_t *mp;
6334 u8 sw_if_index_set = 0;
6340 u8 v4_address_set = 0;
6341 u8 v6_address_set = 0;
6342 ip4_address_t v4address;
6343 ip6_address_t v6address;
6345 memset (mac_address, 0, sizeof (mac_address));
6347 /* Parse args required to build the message */
6348 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6350 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6354 else if (unformat (i, "del"))
6356 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6357 sw_if_index_set = 1;
6358 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6359 sw_if_index_set = 1;
6360 else if (unformat (i, "is_static"))
6362 else if (unformat (i, "vrf %d", &vrf_id))
6364 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
6366 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
6370 clib_warning ("parse error '%U'", format_unformat_error, i);
6375 if (sw_if_index_set == 0)
6377 errmsg ("missing interface name or sw_if_index\n");
6380 if (v4_address_set && v6_address_set)
6382 errmsg ("both v4 and v6 addresses set\n");
6385 if (!v4_address_set && !v6_address_set)
6387 errmsg ("no address set\n");
6391 /* Construct the API message */
6392 M (IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del);
6394 mp->sw_if_index = ntohl (sw_if_index);
6395 mp->is_add = is_add;
6396 mp->vrf_id = ntohl (vrf_id);
6397 mp->is_static = is_static;
6399 clib_memcpy (mp->mac_address, mac_address, 6);
6403 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
6407 /* mp->is_ipv6 = 0; via memset in M macro above */
6408 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
6414 /* Wait for a reply, return good/bad news */
6422 api_reset_vrf (vat_main_t * vam)
6424 unformat_input_t *i = vam->input;
6425 vl_api_reset_vrf_t *mp;
6431 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6433 if (unformat (i, "vrf %d", &vrf_id))
6435 else if (unformat (i, "ipv6"))
6439 clib_warning ("parse error '%U'", format_unformat_error, i);
6444 if (vrf_id_set == 0)
6446 errmsg ("missing vrf id\n");
6450 M (RESET_VRF, reset_vrf);
6452 mp->vrf_id = ntohl (vrf_id);
6453 mp->is_ipv6 = is_ipv6;
6462 api_create_vlan_subif (vat_main_t * vam)
6464 unformat_input_t *i = vam->input;
6465 vl_api_create_vlan_subif_t *mp;
6468 u8 sw_if_index_set = 0;
6472 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6474 if (unformat (i, "sw_if_index %d", &sw_if_index))
6475 sw_if_index_set = 1;
6476 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6477 sw_if_index_set = 1;
6478 else if (unformat (i, "vlan %d", &vlan_id))
6482 clib_warning ("parse error '%U'", format_unformat_error, i);
6487 if (sw_if_index_set == 0)
6489 errmsg ("missing interface name or sw_if_index\n");
6493 if (vlan_id_set == 0)
6495 errmsg ("missing vlan_id\n");
6498 M (CREATE_VLAN_SUBIF, create_vlan_subif);
6500 mp->sw_if_index = ntohl (sw_if_index);
6501 mp->vlan_id = ntohl (vlan_id);
6509 #define foreach_create_subif_bit \
6516 _(outer_vlan_id_any) \
6517 _(inner_vlan_id_any)
6520 api_create_subif (vat_main_t * vam)
6522 unformat_input_t *i = vam->input;
6523 vl_api_create_subif_t *mp;
6526 u8 sw_if_index_set = 0;
6533 u32 exact_match = 0;
6534 u32 default_sub = 0;
6535 u32 outer_vlan_id_any = 0;
6536 u32 inner_vlan_id_any = 0;
6538 u16 outer_vlan_id = 0;
6539 u16 inner_vlan_id = 0;
6541 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6543 if (unformat (i, "sw_if_index %d", &sw_if_index))
6544 sw_if_index_set = 1;
6545 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6546 sw_if_index_set = 1;
6547 else if (unformat (i, "sub_id %d", &sub_id))
6549 else if (unformat (i, "outer_vlan_id %d", &tmp))
6550 outer_vlan_id = tmp;
6551 else if (unformat (i, "inner_vlan_id %d", &tmp))
6552 inner_vlan_id = tmp;
6554 #define _(a) else if (unformat (i, #a)) a = 1 ;
6555 foreach_create_subif_bit
6559 clib_warning ("parse error '%U'", format_unformat_error, i);
6564 if (sw_if_index_set == 0)
6566 errmsg ("missing interface name or sw_if_index\n");
6570 if (sub_id_set == 0)
6572 errmsg ("missing sub_id\n");
6575 M (CREATE_SUBIF, create_subif);
6577 mp->sw_if_index = ntohl (sw_if_index);
6578 mp->sub_id = ntohl (sub_id);
6580 #define _(a) mp->a = a;
6581 foreach_create_subif_bit;
6584 mp->outer_vlan_id = ntohs (outer_vlan_id);
6585 mp->inner_vlan_id = ntohs (inner_vlan_id);
6594 api_oam_add_del (vat_main_t * vam)
6596 unformat_input_t *i = vam->input;
6597 vl_api_oam_add_del_t *mp;
6601 ip4_address_t src, dst;
6605 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6607 if (unformat (i, "vrf %d", &vrf_id))
6609 else if (unformat (i, "src %U", unformat_ip4_address, &src))
6611 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
6613 else if (unformat (i, "del"))
6617 clib_warning ("parse error '%U'", format_unformat_error, i);
6624 errmsg ("missing src addr\n");
6630 errmsg ("missing dst addr\n");
6634 M (OAM_ADD_DEL, oam_add_del);
6636 mp->vrf_id = ntohl (vrf_id);
6637 mp->is_add = is_add;
6638 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
6639 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
6648 api_reset_fib (vat_main_t * vam)
6650 unformat_input_t *i = vam->input;
6651 vl_api_reset_fib_t *mp;
6657 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6659 if (unformat (i, "vrf %d", &vrf_id))
6661 else if (unformat (i, "ipv6"))
6665 clib_warning ("parse error '%U'", format_unformat_error, i);
6670 if (vrf_id_set == 0)
6672 errmsg ("missing vrf id\n");
6676 M (RESET_FIB, reset_fib);
6678 mp->vrf_id = ntohl (vrf_id);
6679 mp->is_ipv6 = is_ipv6;
6688 api_dhcp_proxy_config (vat_main_t * vam)
6690 unformat_input_t *i = vam->input;
6691 vl_api_dhcp_proxy_config_t *mp;
6696 u8 v4_address_set = 0;
6697 u8 v6_address_set = 0;
6698 ip4_address_t v4address;
6699 ip6_address_t v6address;
6700 u8 v4_src_address_set = 0;
6701 u8 v6_src_address_set = 0;
6702 ip4_address_t v4srcaddress;
6703 ip6_address_t v6srcaddress;
6705 /* Parse args required to build the message */
6706 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6708 if (unformat (i, "del"))
6710 else if (unformat (i, "vrf %d", &vrf_id))
6712 else if (unformat (i, "insert-cid %d", &insert_cid))
6714 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
6716 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
6718 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
6719 v4_src_address_set = 1;
6720 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
6721 v6_src_address_set = 1;
6726 if (v4_address_set && v6_address_set)
6728 errmsg ("both v4 and v6 server addresses set\n");
6731 if (!v4_address_set && !v6_address_set)
6733 errmsg ("no server addresses set\n");
6737 if (v4_src_address_set && v6_src_address_set)
6739 errmsg ("both v4 and v6 src addresses set\n");
6742 if (!v4_src_address_set && !v6_src_address_set)
6744 errmsg ("no src addresses set\n");
6748 if (!(v4_src_address_set && v4_address_set) &&
6749 !(v6_src_address_set && v6_address_set))
6751 errmsg ("no matching server and src addresses set\n");
6755 /* Construct the API message */
6756 M (DHCP_PROXY_CONFIG, dhcp_proxy_config);
6758 mp->insert_circuit_id = insert_cid;
6759 mp->is_add = is_add;
6760 mp->vrf_id = ntohl (vrf_id);
6764 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
6765 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
6769 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
6770 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
6776 /* Wait for a reply, return good/bad news */
6783 api_dhcp_proxy_config_2 (vat_main_t * vam)
6785 unformat_input_t *i = vam->input;
6786 vl_api_dhcp_proxy_config_2_t *mp;
6789 u32 server_vrf_id = 0;
6792 u8 v4_address_set = 0;
6793 u8 v6_address_set = 0;
6794 ip4_address_t v4address;
6795 ip6_address_t v6address;
6796 u8 v4_src_address_set = 0;
6797 u8 v6_src_address_set = 0;
6798 ip4_address_t v4srcaddress;
6799 ip6_address_t v6srcaddress;
6801 /* Parse args required to build the message */
6802 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6804 if (unformat (i, "del"))
6806 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
6808 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
6810 else if (unformat (i, "insert-cid %d", &insert_cid))
6812 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
6814 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
6816 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
6817 v4_src_address_set = 1;
6818 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
6819 v6_src_address_set = 1;
6824 if (v4_address_set && v6_address_set)
6826 errmsg ("both v4 and v6 server addresses set\n");
6829 if (!v4_address_set && !v6_address_set)
6831 errmsg ("no server addresses set\n");
6835 if (v4_src_address_set && v6_src_address_set)
6837 errmsg ("both v4 and v6 src addresses set\n");
6840 if (!v4_src_address_set && !v6_src_address_set)
6842 errmsg ("no src addresses set\n");
6846 if (!(v4_src_address_set && v4_address_set) &&
6847 !(v6_src_address_set && v6_address_set))
6849 errmsg ("no matching server and src addresses set\n");
6853 /* Construct the API message */
6854 M (DHCP_PROXY_CONFIG_2, dhcp_proxy_config_2);
6856 mp->insert_circuit_id = insert_cid;
6857 mp->is_add = is_add;
6858 mp->rx_vrf_id = ntohl (rx_vrf_id);
6859 mp->server_vrf_id = ntohl (server_vrf_id);
6863 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
6864 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
6868 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
6869 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
6875 /* Wait for a reply, return good/bad news */
6882 api_dhcp_proxy_set_vss (vat_main_t * vam)
6884 unformat_input_t *i = vam->input;
6885 vl_api_dhcp_proxy_set_vss_t *mp;
6896 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6898 if (unformat (i, "tbl_id %d", &tbl_id))
6900 if (unformat (i, "fib_id %d", &fib_id))
6902 if (unformat (i, "oui %d", &oui))
6904 else if (unformat (i, "ipv6"))
6906 else if (unformat (i, "del"))
6910 clib_warning ("parse error '%U'", format_unformat_error, i);
6915 if (tbl_id_set == 0)
6917 errmsg ("missing tbl id\n");
6921 if (fib_id_set == 0)
6923 errmsg ("missing fib id\n");
6928 errmsg ("missing oui\n");
6932 M (DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss);
6933 mp->tbl_id = ntohl (tbl_id);
6934 mp->fib_id = ntohl (fib_id);
6935 mp->oui = ntohl (oui);
6936 mp->is_ipv6 = is_ipv6;
6937 mp->is_add = is_add;
6946 api_dhcp_client_config (vat_main_t * vam)
6948 unformat_input_t *i = vam->input;
6949 vl_api_dhcp_client_config_t *mp;
6952 u8 sw_if_index_set = 0;
6955 u8 disable_event = 0;
6957 /* Parse args required to build the message */
6958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6960 if (unformat (i, "del"))
6962 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6963 sw_if_index_set = 1;
6964 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6965 sw_if_index_set = 1;
6966 else if (unformat (i, "hostname %s", &hostname))
6968 else if (unformat (i, "disable_event"))
6974 if (sw_if_index_set == 0)
6976 errmsg ("missing interface name or sw_if_index\n");
6980 if (vec_len (hostname) > 63)
6982 errmsg ("hostname too long\n");
6984 vec_add1 (hostname, 0);
6986 /* Construct the API message */
6987 M (DHCP_CLIENT_CONFIG, dhcp_client_config);
6989 mp->sw_if_index = ntohl (sw_if_index);
6990 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
6991 vec_free (hostname);
6992 mp->is_add = is_add;
6993 mp->want_dhcp_event = disable_event ? 0 : 1;
6994 mp->pid = getpid ();
6999 /* Wait for a reply, return good/bad news */
7006 api_set_ip_flow_hash (vat_main_t * vam)
7008 unformat_input_t *i = vam->input;
7009 vl_api_set_ip_flow_hash_t *mp;
7021 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7023 if (unformat (i, "vrf %d", &vrf_id))
7025 else if (unformat (i, "ipv6"))
7027 else if (unformat (i, "src"))
7029 else if (unformat (i, "dst"))
7031 else if (unformat (i, "sport"))
7033 else if (unformat (i, "dport"))
7035 else if (unformat (i, "proto"))
7037 else if (unformat (i, "reverse"))
7042 clib_warning ("parse error '%U'", format_unformat_error, i);
7047 if (vrf_id_set == 0)
7049 errmsg ("missing vrf id\n");
7053 M (SET_IP_FLOW_HASH, set_ip_flow_hash);
7059 mp->reverse = reverse;
7060 mp->vrf_id = ntohl (vrf_id);
7061 mp->is_ipv6 = is_ipv6;
7070 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7072 unformat_input_t *i = vam->input;
7073 vl_api_sw_interface_ip6_enable_disable_t *mp;
7076 u8 sw_if_index_set = 0;
7079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7081 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7082 sw_if_index_set = 1;
7083 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7084 sw_if_index_set = 1;
7085 else if (unformat (i, "enable"))
7087 else if (unformat (i, "disable"))
7091 clib_warning ("parse error '%U'", format_unformat_error, i);
7096 if (sw_if_index_set == 0)
7098 errmsg ("missing interface name or sw_if_index\n");
7102 M (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable);
7104 mp->sw_if_index = ntohl (sw_if_index);
7105 mp->enable = enable;
7114 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7116 unformat_input_t *i = vam->input;
7117 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7120 u8 sw_if_index_set = 0;
7121 u32 address_length = 0;
7122 u8 v6_address_set = 0;
7123 ip6_address_t v6address;
7125 /* Parse args required to build the message */
7126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7128 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7129 sw_if_index_set = 1;
7130 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7131 sw_if_index_set = 1;
7132 else if (unformat (i, "%U/%d",
7133 unformat_ip6_address, &v6address, &address_length))
7139 if (sw_if_index_set == 0)
7141 errmsg ("missing interface name or sw_if_index\n");
7144 if (!v6_address_set)
7146 errmsg ("no address set\n");
7150 /* Construct the API message */
7151 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,
7152 sw_interface_ip6_set_link_local_address);
7154 mp->sw_if_index = ntohl (sw_if_index);
7155 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7156 mp->address_length = address_length;
7161 /* Wait for a reply, return good/bad news */
7170 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
7172 unformat_input_t *i = vam->input;
7173 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
7176 u8 sw_if_index_set = 0;
7177 u32 address_length = 0;
7178 u8 v6_address_set = 0;
7179 ip6_address_t v6address;
7181 u8 no_advertise = 0;
7183 u8 no_autoconfig = 0;
7186 u32 val_lifetime = 0;
7187 u32 pref_lifetime = 0;
7189 /* Parse args required to build the message */
7190 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7192 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7193 sw_if_index_set = 1;
7194 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7195 sw_if_index_set = 1;
7196 else if (unformat (i, "%U/%d",
7197 unformat_ip6_address, &v6address, &address_length))
7199 else if (unformat (i, "val_life %d", &val_lifetime))
7201 else if (unformat (i, "pref_life %d", &pref_lifetime))
7203 else if (unformat (i, "def"))
7205 else if (unformat (i, "noadv"))
7207 else if (unformat (i, "offl"))
7209 else if (unformat (i, "noauto"))
7211 else if (unformat (i, "nolink"))
7213 else if (unformat (i, "isno"))
7217 clib_warning ("parse error '%U'", format_unformat_error, i);
7222 if (sw_if_index_set == 0)
7224 errmsg ("missing interface name or sw_if_index\n");
7227 if (!v6_address_set)
7229 errmsg ("no address set\n");
7233 /* Construct the API message */
7234 M (SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix);
7236 mp->sw_if_index = ntohl (sw_if_index);
7237 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7238 mp->address_length = address_length;
7239 mp->use_default = use_default;
7240 mp->no_advertise = no_advertise;
7241 mp->off_link = off_link;
7242 mp->no_autoconfig = no_autoconfig;
7243 mp->no_onlink = no_onlink;
7245 mp->val_lifetime = ntohl (val_lifetime);
7246 mp->pref_lifetime = ntohl (pref_lifetime);
7251 /* Wait for a reply, return good/bad news */
7259 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
7261 unformat_input_t *i = vam->input;
7262 vl_api_sw_interface_ip6nd_ra_config_t *mp;
7265 u8 sw_if_index_set = 0;
7270 u8 send_unicast = 0;
7273 u8 default_router = 0;
7274 u32 max_interval = 0;
7275 u32 min_interval = 0;
7277 u32 initial_count = 0;
7278 u32 initial_interval = 0;
7281 /* Parse args required to build the message */
7282 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7284 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7285 sw_if_index_set = 1;
7286 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7287 sw_if_index_set = 1;
7288 else if (unformat (i, "maxint %d", &max_interval))
7290 else if (unformat (i, "minint %d", &min_interval))
7292 else if (unformat (i, "life %d", &lifetime))
7294 else if (unformat (i, "count %d", &initial_count))
7296 else if (unformat (i, "interval %d", &initial_interval))
7298 else if (unformat (i, "suppress") || unformat (i, "surpress"))
7300 else if (unformat (i, "managed"))
7302 else if (unformat (i, "other"))
7304 else if (unformat (i, "ll"))
7306 else if (unformat (i, "send"))
7308 else if (unformat (i, "cease"))
7310 else if (unformat (i, "isno"))
7312 else if (unformat (i, "def"))
7316 clib_warning ("parse error '%U'", format_unformat_error, i);
7321 if (sw_if_index_set == 0)
7323 errmsg ("missing interface name or sw_if_index\n");
7327 /* Construct the API message */
7328 M (SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config);
7330 mp->sw_if_index = ntohl (sw_if_index);
7331 mp->max_interval = ntohl (max_interval);
7332 mp->min_interval = ntohl (min_interval);
7333 mp->lifetime = ntohl (lifetime);
7334 mp->initial_count = ntohl (initial_count);
7335 mp->initial_interval = ntohl (initial_interval);
7336 mp->suppress = suppress;
7337 mp->managed = managed;
7339 mp->ll_option = ll_option;
7340 mp->send_unicast = send_unicast;
7343 mp->default_router = default_router;
7348 /* Wait for a reply, return good/bad news */
7356 api_set_arp_neighbor_limit (vat_main_t * vam)
7358 unformat_input_t *i = vam->input;
7359 vl_api_set_arp_neighbor_limit_t *mp;
7365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7367 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
7369 else if (unformat (i, "ipv6"))
7373 clib_warning ("parse error '%U'", format_unformat_error, i);
7380 errmsg ("missing limit value\n");
7384 M (SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit);
7386 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
7387 mp->is_ipv6 = is_ipv6;
7396 api_l2_patch_add_del (vat_main_t * vam)
7398 unformat_input_t *i = vam->input;
7399 vl_api_l2_patch_add_del_t *mp;
7402 u8 rx_sw_if_index_set = 0;
7404 u8 tx_sw_if_index_set = 0;
7407 /* Parse args required to build the message */
7408 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7410 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7411 rx_sw_if_index_set = 1;
7412 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7413 tx_sw_if_index_set = 1;
7414 else if (unformat (i, "rx"))
7416 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7418 if (unformat (i, "%U", unformat_sw_if_index, vam,
7420 rx_sw_if_index_set = 1;
7425 else if (unformat (i, "tx"))
7427 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7429 if (unformat (i, "%U", unformat_sw_if_index, vam,
7431 tx_sw_if_index_set = 1;
7436 else if (unformat (i, "del"))
7442 if (rx_sw_if_index_set == 0)
7444 errmsg ("missing rx interface name or rx_sw_if_index\n");
7448 if (tx_sw_if_index_set == 0)
7450 errmsg ("missing tx interface name or tx_sw_if_index\n");
7454 M (L2_PATCH_ADD_DEL, l2_patch_add_del);
7456 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7457 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7458 mp->is_add = is_add;
7467 api_ioam_enable (vat_main_t * vam)
7469 unformat_input_t *input = vam->input;
7470 vl_api_ioam_enable_t *mp;
7473 int has_trace_option = 0;
7474 int has_pow_option = 0;
7475 int has_ppc_option = 0;
7477 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7479 if (unformat (input, "trace"))
7480 has_trace_option = 1;
7481 else if (unformat (input, "pow"))
7483 else if (unformat (input, "ppc encap"))
7484 has_ppc_option = PPC_ENCAP;
7485 else if (unformat (input, "ppc decap"))
7486 has_ppc_option = PPC_DECAP;
7487 else if (unformat (input, "ppc none"))
7488 has_ppc_option = PPC_NONE;
7492 M (IOAM_ENABLE, ioam_enable);
7493 mp->id = htons (id);
7494 mp->trace_ppc = has_ppc_option;
7495 mp->pow_enable = has_pow_option;
7496 mp->trace_enable = has_trace_option;
7507 api_ioam_disable (vat_main_t * vam)
7509 vl_api_ioam_disable_t *mp;
7512 M (IOAM_DISABLE, ioam_disable);
7519 api_sr_tunnel_add_del (vat_main_t * vam)
7521 unformat_input_t *i = vam->input;
7522 vl_api_sr_tunnel_add_del_t *mp;
7526 ip6_address_t src_address;
7527 int src_address_set = 0;
7528 ip6_address_t dst_address;
7530 int dst_address_set = 0;
7532 u32 rx_table_id = 0;
7533 u32 tx_table_id = 0;
7534 ip6_address_t *segments = 0;
7535 ip6_address_t *this_seg;
7536 ip6_address_t *tags = 0;
7537 ip6_address_t *this_tag;
7538 ip6_address_t next_address, tag;
7540 u8 *policy_name = 0;
7542 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7544 if (unformat (i, "del"))
7546 else if (unformat (i, "name %s", &name))
7548 else if (unformat (i, "policy %s", &policy_name))
7550 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
7552 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
7554 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
7555 src_address_set = 1;
7556 else if (unformat (i, "dst %U/%d",
7557 unformat_ip6_address, &dst_address, &dst_mask_width))
7558 dst_address_set = 1;
7559 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
7561 vec_add2 (segments, this_seg, 1);
7562 clib_memcpy (this_seg->as_u8, next_address.as_u8,
7563 sizeof (*this_seg));
7565 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
7567 vec_add2 (tags, this_tag, 1);
7568 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
7570 else if (unformat (i, "clean"))
7571 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
7572 else if (unformat (i, "protected"))
7573 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
7574 else if (unformat (i, "InPE %d", &pl_index))
7576 if (pl_index <= 0 || pl_index > 4)
7578 pl_index_range_error:
7579 errmsg ("pl index %d out of range\n", pl_index);
7583 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
7585 else if (unformat (i, "EgPE %d", &pl_index))
7587 if (pl_index <= 0 || pl_index > 4)
7588 goto pl_index_range_error;
7590 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
7592 else if (unformat (i, "OrgSrc %d", &pl_index))
7594 if (pl_index <= 0 || pl_index > 4)
7595 goto pl_index_range_error;
7597 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
7603 if (!src_address_set)
7605 errmsg ("src address required\n");
7609 if (!dst_address_set)
7611 errmsg ("dst address required\n");
7617 errmsg ("at least one sr segment required\n");
7621 M2 (SR_TUNNEL_ADD_DEL, sr_tunnel_add_del,
7622 vec_len (segments) * sizeof (ip6_address_t)
7623 + vec_len (tags) * sizeof (ip6_address_t));
7625 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
7626 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
7627 mp->dst_mask_width = dst_mask_width;
7628 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
7629 mp->n_segments = vec_len (segments);
7630 mp->n_tags = vec_len (tags);
7631 mp->is_add = is_del == 0;
7632 clib_memcpy (mp->segs_and_tags, segments,
7633 vec_len (segments) * sizeof (ip6_address_t));
7634 clib_memcpy (mp->segs_and_tags +
7635 vec_len (segments) * sizeof (ip6_address_t), tags,
7636 vec_len (tags) * sizeof (ip6_address_t));
7638 mp->outer_vrf_id = ntohl (rx_table_id);
7639 mp->inner_vrf_id = ntohl (tx_table_id);
7640 memcpy (mp->name, name, vec_len (name));
7641 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
7643 vec_free (segments);
7652 api_sr_policy_add_del (vat_main_t * vam)
7654 unformat_input_t *input = vam->input;
7655 vl_api_sr_policy_add_del_t *mp;
7659 u8 *tunnel_name = 0;
7660 u8 **tunnel_names = 0;
7665 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
7666 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
7668 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7670 if (unformat (input, "del"))
7672 else if (unformat (input, "name %s", &name))
7674 else if (unformat (input, "tunnel %s", &tunnel_name))
7678 vec_add1 (tunnel_names, tunnel_name);
7680 - length = #bytes to store in serial vector
7681 - +1 = byte to store that length
7683 tunnel_names_length += (vec_len (tunnel_name) + 1);
7694 errmsg ("policy name required\n");
7698 if ((!tunnel_set) && (!is_del))
7700 errmsg ("tunnel name required\n");
7704 M2 (SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length);
7708 mp->is_add = !is_del;
7710 memcpy (mp->name, name, vec_len (name));
7711 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
7712 u8 *serial_orig = 0;
7713 vec_validate (serial_orig, tunnel_names_length);
7714 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
7715 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
7717 for (j = 0; j < vec_len (tunnel_names); j++)
7719 tun_name_len = vec_len (tunnel_names[j]);
7720 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
7721 serial_orig += 1; // Move along one byte to store the actual tunnel name
7722 memcpy (serial_orig, tunnel_names[j], tun_name_len);
7723 serial_orig += tun_name_len; // Advance past the copy
7725 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
7727 vec_free (tunnel_names);
7728 vec_free (tunnel_name);
7736 api_sr_multicast_map_add_del (vat_main_t * vam)
7738 unformat_input_t *input = vam->input;
7739 vl_api_sr_multicast_map_add_del_t *mp;
7742 ip6_address_t multicast_address;
7743 u8 *policy_name = 0;
7744 int multicast_address_set = 0;
7746 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7748 if (unformat (input, "del"))
7752 (input, "address %U", unformat_ip6_address, &multicast_address))
7753 multicast_address_set = 1;
7754 else if (unformat (input, "sr-policy %s", &policy_name))
7760 if (!is_del && !policy_name)
7762 errmsg ("sr-policy name required\n");
7767 if (!multicast_address_set)
7769 errmsg ("address required\n");
7773 M (SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del);
7775 mp->is_add = !is_del;
7776 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
7777 clib_memcpy (mp->multicast_address, &multicast_address,
7778 sizeof (mp->multicast_address));
7781 vec_free (policy_name);
7789 #define foreach_ip4_proto_field \
7800 unformat_ip4_mask (unformat_input_t * input, va_list * args)
7802 u8 **maskp = va_arg (*args, u8 **);
7804 u8 found_something = 0;
7807 #define _(a) u8 a=0;
7808 foreach_ip4_proto_field;
7814 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7816 if (unformat (input, "version"))
7818 else if (unformat (input, "hdr_length"))
7820 else if (unformat (input, "src"))
7822 else if (unformat (input, "dst"))
7824 else if (unformat (input, "proto"))
7827 #define _(a) else if (unformat (input, #a)) a=1;
7828 foreach_ip4_proto_field
7834 #define _(a) found_something += a;
7835 foreach_ip4_proto_field;
7838 if (found_something == 0)
7841 vec_validate (mask, sizeof (*ip) - 1);
7843 ip = (ip4_header_t *) mask;
7845 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
7846 foreach_ip4_proto_field;
7849 ip->ip_version_and_header_length = 0;
7852 ip->ip_version_and_header_length |= 0xF0;
7855 ip->ip_version_and_header_length |= 0x0F;
7861 #define foreach_ip6_proto_field \
7869 unformat_ip6_mask (unformat_input_t * input, va_list * args)
7871 u8 **maskp = va_arg (*args, u8 **);
7873 u8 found_something = 0;
7875 u32 ip_version_traffic_class_and_flow_label;
7877 #define _(a) u8 a=0;
7878 foreach_ip6_proto_field;
7881 u8 traffic_class = 0;
7884 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7886 if (unformat (input, "version"))
7888 else if (unformat (input, "traffic-class"))
7890 else if (unformat (input, "flow-label"))
7892 else if (unformat (input, "src"))
7894 else if (unformat (input, "dst"))
7896 else if (unformat (input, "proto"))
7899 #define _(a) else if (unformat (input, #a)) a=1;
7900 foreach_ip6_proto_field
7906 #define _(a) found_something += a;
7907 foreach_ip6_proto_field;
7910 if (found_something == 0)
7913 vec_validate (mask, sizeof (*ip) - 1);
7915 ip = (ip6_header_t *) mask;
7917 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
7918 foreach_ip6_proto_field;
7921 ip_version_traffic_class_and_flow_label = 0;
7924 ip_version_traffic_class_and_flow_label |= 0xF0000000;
7927 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
7930 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
7932 ip->ip_version_traffic_class_and_flow_label =
7933 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
7940 unformat_l3_mask (unformat_input_t * input, va_list * args)
7942 u8 **maskp = va_arg (*args, u8 **);
7944 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7946 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
7948 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
7957 unformat_l2_mask (unformat_input_t * input, va_list * args)
7959 u8 **maskp = va_arg (*args, u8 **);
7974 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7976 if (unformat (input, "src"))
7978 else if (unformat (input, "dst"))
7980 else if (unformat (input, "proto"))
7982 else if (unformat (input, "tag1"))
7984 else if (unformat (input, "tag2"))
7986 else if (unformat (input, "ignore-tag1"))
7988 else if (unformat (input, "ignore-tag2"))
7990 else if (unformat (input, "cos1"))
7992 else if (unformat (input, "cos2"))
7994 else if (unformat (input, "dot1q"))
7996 else if (unformat (input, "dot1ad"))
8001 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8002 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8005 if (tag1 || ignore_tag1 || cos1 || dot1q)
8007 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8010 vec_validate (mask, len - 1);
8013 memset (mask, 0xff, 6);
8016 memset (mask + 6, 0xff, 6);
8020 /* inner vlan tag */
8029 mask[21] = mask[20] = 0xff;
8050 mask[16] = mask[17] = 0xff;
8060 mask[12] = mask[13] = 0xff;
8067 unformat_classify_mask (unformat_input_t * input, va_list * args)
8069 u8 **maskp = va_arg (*args, u8 **);
8070 u32 *skipp = va_arg (*args, u32 *);
8071 u32 *matchp = va_arg (*args, u32 *);
8078 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8080 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8082 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8084 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8090 if (mask || l2 || l3)
8094 /* "With a free Ethernet header in every package" */
8096 vec_validate (l2, 13);
8100 vec_append (mask, l3);
8105 /* Scan forward looking for the first significant mask octet */
8106 for (i = 0; i < vec_len (mask); i++)
8110 /* compute (skip, match) params */
8111 *skipp = i / sizeof (u32x4);
8112 vec_delete (mask, *skipp * sizeof (u32x4), 0);
8114 /* Pad mask to an even multiple of the vector size */
8115 while (vec_len (mask) % sizeof (u32x4))
8118 match = vec_len (mask) / sizeof (u32x4);
8120 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
8122 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
8123 if (*tmp || *(tmp + 1))
8128 clib_warning ("BUG: match 0");
8130 _vec_len (mask) = match * sizeof (u32x4);
8141 #define foreach_l2_next \
8143 _(ethernet, ETHERNET_INPUT) \
8148 unformat_l2_next_index (unformat_input_t * input, va_list * args)
8150 u32 *miss_next_indexp = va_arg (*args, u32 *);
8155 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
8159 if (unformat (input, "%d", &tmp))
8168 *miss_next_indexp = next_index;
8172 #define foreach_ip_next \
8178 unformat_ip_next_index (unformat_input_t * input, va_list * args)
8180 u32 *miss_next_indexp = va_arg (*args, u32 *);
8185 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
8189 if (unformat (input, "%d", &tmp))
8198 *miss_next_indexp = next_index;
8202 #define foreach_acl_next \
8206 unformat_acl_next_index (unformat_input_t * input, va_list * args)
8208 u32 *miss_next_indexp = va_arg (*args, u32 *);
8213 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
8217 if (unformat (input, "permit"))
8222 else if (unformat (input, "%d", &tmp))
8231 *miss_next_indexp = next_index;
8236 unformat_policer_precolor (unformat_input_t * input, va_list * args)
8238 u32 *r = va_arg (*args, u32 *);
8240 if (unformat (input, "conform-color"))
8241 *r = POLICE_CONFORM;
8242 else if (unformat (input, "exceed-color"))
8251 api_classify_add_del_table (vat_main_t * vam)
8253 unformat_input_t *i = vam->input;
8254 vl_api_classify_add_del_table_t *mp;
8260 u32 table_index = ~0;
8261 u32 next_table_index = ~0;
8262 u32 miss_next_index = ~0;
8263 u32 memory_size = 32 << 20;
8267 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8269 if (unformat (i, "del"))
8271 else if (unformat (i, "buckets %d", &nbuckets))
8273 else if (unformat (i, "memory_size %d", &memory_size))
8275 else if (unformat (i, "skip %d", &skip))
8277 else if (unformat (i, "match %d", &match))
8279 else if (unformat (i, "table %d", &table_index))
8281 else if (unformat (i, "mask %U", unformat_classify_mask,
8282 &mask, &skip, &match))
8284 else if (unformat (i, "next-table %d", &next_table_index))
8286 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
8289 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
8292 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
8299 if (is_add && mask == 0)
8301 errmsg ("Mask required\n");
8305 if (is_add && skip == ~0)
8307 errmsg ("skip count required\n");
8311 if (is_add && match == ~0)
8313 errmsg ("match count required\n");
8317 if (!is_add && table_index == ~0)
8319 errmsg ("table index required for delete\n");
8323 M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask));
8325 mp->is_add = is_add;
8326 mp->table_index = ntohl (table_index);
8327 mp->nbuckets = ntohl (nbuckets);
8328 mp->memory_size = ntohl (memory_size);
8329 mp->skip_n_vectors = ntohl (skip);
8330 mp->match_n_vectors = ntohl (match);
8331 mp->next_table_index = ntohl (next_table_index);
8332 mp->miss_next_index = ntohl (miss_next_index);
8333 clib_memcpy (mp->mask, mask, vec_len (mask));
8343 unformat_ip4_match (unformat_input_t * input, va_list * args)
8345 u8 **matchp = va_arg (*args, u8 **);
8352 int src = 0, dst = 0;
8353 ip4_address_t src_val, dst_val;
8360 int fragment_id = 0;
8361 u32 fragment_id_val;
8367 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8369 if (unformat (input, "version %d", &version_val))
8371 else if (unformat (input, "hdr_length %d", &hdr_length_val))
8373 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
8375 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
8377 else if (unformat (input, "proto %d", &proto_val))
8379 else if (unformat (input, "tos %d", &tos_val))
8381 else if (unformat (input, "length %d", &length_val))
8383 else if (unformat (input, "fragment_id %d", &fragment_id_val))
8385 else if (unformat (input, "ttl %d", &ttl_val))
8387 else if (unformat (input, "checksum %d", &checksum_val))
8393 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
8394 + ttl + checksum == 0)
8398 * Aligned because we use the real comparison functions
8400 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
8402 ip = (ip4_header_t *) match;
8404 /* These are realistically matched in practice */
8406 ip->src_address.as_u32 = src_val.as_u32;
8409 ip->dst_address.as_u32 = dst_val.as_u32;
8412 ip->protocol = proto_val;
8415 /* These are not, but they're included for completeness */
8417 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
8420 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
8426 ip->length = length_val;
8432 ip->checksum = checksum_val;
8439 unformat_ip6_match (unformat_input_t * input, va_list * args)
8441 u8 **matchp = va_arg (*args, u8 **);
8446 u8 traffic_class = 0;
8447 u32 traffic_class_val = 0;
8450 int src = 0, dst = 0;
8451 ip6_address_t src_val, dst_val;
8454 int payload_length = 0;
8455 u32 payload_length_val;
8458 u32 ip_version_traffic_class_and_flow_label;
8460 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8462 if (unformat (input, "version %d", &version_val))
8464 else if (unformat (input, "traffic_class %d", &traffic_class_val))
8466 else if (unformat (input, "flow_label %d", &flow_label_val))
8468 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
8470 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
8472 else if (unformat (input, "proto %d", &proto_val))
8474 else if (unformat (input, "payload_length %d", &payload_length_val))
8476 else if (unformat (input, "hop_limit %d", &hop_limit_val))
8482 if (version + traffic_class + flow_label + src + dst + proto +
8483 payload_length + hop_limit == 0)
8487 * Aligned because we use the real comparison functions
8489 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
8491 ip = (ip6_header_t *) match;
8494 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
8497 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
8500 ip->protocol = proto_val;
8502 ip_version_traffic_class_and_flow_label = 0;
8505 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
8508 ip_version_traffic_class_and_flow_label |=
8509 (traffic_class_val & 0xFF) << 20;
8512 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
8514 ip->ip_version_traffic_class_and_flow_label =
8515 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8518 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
8521 ip->hop_limit = hop_limit_val;
8528 unformat_l3_match (unformat_input_t * input, va_list * args)
8530 u8 **matchp = va_arg (*args, u8 **);
8532 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8534 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
8536 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
8545 unformat_vlan_tag (unformat_input_t * input, va_list * args)
8547 u8 *tagp = va_arg (*args, u8 *);
8550 if (unformat (input, "%d", &tag))
8552 tagp[0] = (tag >> 8) & 0x0F;
8553 tagp[1] = tag & 0xFF;
8561 unformat_l2_match (unformat_input_t * input, va_list * args)
8563 u8 **matchp = va_arg (*args, u8 **);
8583 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8585 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
8588 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
8590 else if (unformat (input, "proto %U",
8591 unformat_ethernet_type_host_byte_order, &proto_val))
8593 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
8595 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
8597 else if (unformat (input, "ignore-tag1"))
8599 else if (unformat (input, "ignore-tag2"))
8601 else if (unformat (input, "cos1 %d", &cos1_val))
8603 else if (unformat (input, "cos2 %d", &cos2_val))
8608 if ((src + dst + proto + tag1 + tag2 +
8609 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8612 if (tag1 || ignore_tag1 || cos1)
8614 if (tag2 || ignore_tag2 || cos2)
8617 vec_validate_aligned (match, len - 1, sizeof (u32x4));
8620 clib_memcpy (match, dst_val, 6);
8623 clib_memcpy (match + 6, src_val, 6);
8627 /* inner vlan tag */
8628 match[19] = tag2_val[1];
8629 match[18] = tag2_val[0];
8631 match[18] |= (cos2_val & 0x7) << 5;
8634 match[21] = proto_val & 0xff;
8635 match[20] = proto_val >> 8;
8639 match[15] = tag1_val[1];
8640 match[14] = tag1_val[0];
8643 match[14] |= (cos1_val & 0x7) << 5;
8649 match[15] = tag1_val[1];
8650 match[14] = tag1_val[0];
8653 match[17] = proto_val & 0xff;
8654 match[16] = proto_val >> 8;
8657 match[14] |= (cos1_val & 0x7) << 5;
8663 match[18] |= (cos2_val & 0x7) << 5;
8665 match[14] |= (cos1_val & 0x7) << 5;
8668 match[13] = proto_val & 0xff;
8669 match[12] = proto_val >> 8;
8678 unformat_classify_match (unformat_input_t * input, va_list * args)
8680 u8 **matchp = va_arg (*args, u8 **);
8681 u32 skip_n_vectors = va_arg (*args, u32);
8682 u32 match_n_vectors = va_arg (*args, u32);
8688 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8690 if (unformat (input, "hex %U", unformat_hex_string, &match))
8692 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
8694 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
8700 if (match || l2 || l3)
8704 /* "Win a free Ethernet header in every packet" */
8706 vec_validate_aligned (l2, 13, sizeof (u32x4));
8710 vec_append_aligned (match, l3, sizeof (u32x4));
8715 /* Make sure the vector is big enough even if key is all 0's */
8716 vec_validate_aligned
8717 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
8720 /* Set size, include skipped vectors */
8721 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
8732 api_classify_add_del_session (vat_main_t * vam)
8734 unformat_input_t *i = vam->input;
8735 vl_api_classify_add_del_session_t *mp;
8737 u32 table_index = ~0;
8738 u32 hit_next_index = ~0;
8739 u32 opaque_index = ~0;
8743 u32 skip_n_vectors = 0;
8744 u32 match_n_vectors = 0;
8747 * Warning: you have to supply skip_n and match_n
8748 * because the API client cant simply look at the classify
8752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8754 if (unformat (i, "del"))
8756 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
8759 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
8762 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
8765 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
8767 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
8769 else if (unformat (i, "opaque-index %d", &opaque_index))
8771 else if (unformat (i, "skip_n %d", &skip_n_vectors))
8773 else if (unformat (i, "match_n %d", &match_n_vectors))
8775 else if (unformat (i, "match %U", unformat_classify_match,
8776 &match, skip_n_vectors, match_n_vectors))
8778 else if (unformat (i, "advance %d", &advance))
8780 else if (unformat (i, "table-index %d", &table_index))
8786 if (table_index == ~0)
8788 errmsg ("Table index required\n");
8792 if (is_add && match == 0)
8794 errmsg ("Match value required\n");
8798 M2 (CLASSIFY_ADD_DEL_SESSION, classify_add_del_session, vec_len (match));
8800 mp->is_add = is_add;
8801 mp->table_index = ntohl (table_index);
8802 mp->hit_next_index = ntohl (hit_next_index);
8803 mp->opaque_index = ntohl (opaque_index);
8804 mp->advance = ntohl (advance);
8805 clib_memcpy (mp->match, match, vec_len (match));
8814 api_classify_set_interface_ip_table (vat_main_t * vam)
8816 unformat_input_t *i = vam->input;
8817 vl_api_classify_set_interface_ip_table_t *mp;
8820 int sw_if_index_set;
8821 u32 table_index = ~0;
8824 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8826 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8827 sw_if_index_set = 1;
8828 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8829 sw_if_index_set = 1;
8830 else if (unformat (i, "table %d", &table_index))
8834 clib_warning ("parse error '%U'", format_unformat_error, i);
8839 if (sw_if_index_set == 0)
8841 errmsg ("missing interface name or sw_if_index\n");
8846 M (CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table);
8848 mp->sw_if_index = ntohl (sw_if_index);
8849 mp->table_index = ntohl (table_index);
8850 mp->is_ipv6 = is_ipv6;
8859 api_classify_set_interface_l2_tables (vat_main_t * vam)
8861 unformat_input_t *i = vam->input;
8862 vl_api_classify_set_interface_l2_tables_t *mp;
8865 int sw_if_index_set;
8866 u32 ip4_table_index = ~0;
8867 u32 ip6_table_index = ~0;
8868 u32 other_table_index = ~0;
8871 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8873 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8874 sw_if_index_set = 1;
8875 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8876 sw_if_index_set = 1;
8877 else if (unformat (i, "ip4-table %d", &ip4_table_index))
8879 else if (unformat (i, "ip6-table %d", &ip6_table_index))
8881 else if (unformat (i, "other-table %d", &other_table_index))
8883 else if (unformat (i, "is-input %d", &is_input))
8887 clib_warning ("parse error '%U'", format_unformat_error, i);
8892 if (sw_if_index_set == 0)
8894 errmsg ("missing interface name or sw_if_index\n");
8899 M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables);
8901 mp->sw_if_index = ntohl (sw_if_index);
8902 mp->ip4_table_index = ntohl (ip4_table_index);
8903 mp->ip6_table_index = ntohl (ip6_table_index);
8904 mp->other_table_index = ntohl (other_table_index);
8905 mp->is_input = (u8) is_input;
8914 api_set_ipfix_exporter (vat_main_t * vam)
8916 unformat_input_t *i = vam->input;
8917 vl_api_set_ipfix_exporter_t *mp;
8918 ip4_address_t collector_address;
8919 u8 collector_address_set = 0;
8920 u32 collector_port = ~0;
8921 ip4_address_t src_address;
8922 u8 src_address_set = 0;
8925 u32 template_interval = ~0;
8926 u8 udp_checksum = 0;
8929 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8931 if (unformat (i, "collector_address %U", unformat_ip4_address,
8932 &collector_address))
8933 collector_address_set = 1;
8934 else if (unformat (i, "collector_port %d", &collector_port))
8936 else if (unformat (i, "src_address %U", unformat_ip4_address,
8938 src_address_set = 1;
8939 else if (unformat (i, "vrf_id %d", &vrf_id))
8941 else if (unformat (i, "path_mtu %d", &path_mtu))
8943 else if (unformat (i, "template_interval %d", &template_interval))
8945 else if (unformat (i, "udp_checksum"))
8951 if (collector_address_set == 0)
8953 errmsg ("collector_address required\n");
8957 if (src_address_set == 0)
8959 errmsg ("src_address required\n");
8963 M (SET_IPFIX_EXPORTER, set_ipfix_exporter);
8965 memcpy (mp->collector_address, collector_address.data,
8966 sizeof (collector_address.data));
8967 mp->collector_port = htons ((u16) collector_port);
8968 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
8969 mp->vrf_id = htonl (vrf_id);
8970 mp->path_mtu = htonl (path_mtu);
8971 mp->template_interval = htonl (template_interval);
8972 mp->udp_checksum = udp_checksum;
8980 api_set_ipfix_classify_stream (vat_main_t * vam)
8982 unformat_input_t *i = vam->input;
8983 vl_api_set_ipfix_classify_stream_t *mp;
8985 u32 src_port = UDP_DST_PORT_ipfix;
8988 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8990 if (unformat (i, "domain %d", &domain_id))
8992 else if (unformat (i, "src_port %d", &src_port))
8996 errmsg ("unknown input `%U'", format_unformat_error, i);
9001 M (SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream);
9003 mp->domain_id = htonl (domain_id);
9004 mp->src_port = htons ((u16) src_port);
9012 api_ipfix_classify_table_add_del (vat_main_t * vam)
9014 unformat_input_t *i = vam->input;
9015 vl_api_ipfix_classify_table_add_del_t *mp;
9017 u32 classify_table_index = ~0;
9019 u8 transport_protocol = 255;
9022 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9024 if (unformat (i, "add"))
9026 else if (unformat (i, "del"))
9028 else if (unformat (i, "table %d", &classify_table_index))
9030 else if (unformat (i, "ip4"))
9032 else if (unformat (i, "ip6"))
9034 else if (unformat (i, "tcp"))
9035 transport_protocol = 6;
9036 else if (unformat (i, "udp"))
9037 transport_protocol = 17;
9040 errmsg ("unknown input `%U'", format_unformat_error, i);
9047 errmsg ("expecting: add|del");
9050 if (classify_table_index == ~0)
9052 errmsg ("classifier table not specified");
9055 if (ip_version == 0)
9057 errmsg ("IP version not specified");
9061 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del);
9063 mp->is_add = is_add;
9064 mp->table_id = htonl (classify_table_index);
9065 mp->ip_version = ip_version;
9066 mp->transport_protocol = transport_protocol;
9074 api_get_node_index (vat_main_t * vam)
9076 unformat_input_t *i = vam->input;
9077 vl_api_get_node_index_t *mp;
9081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9083 if (unformat (i, "node %s", &name))
9090 errmsg ("node name required\n");
9093 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9095 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9099 M (GET_NODE_INDEX, get_node_index);
9100 clib_memcpy (mp->node_name, name, vec_len (name));
9110 api_get_next_index (vat_main_t * vam)
9112 unformat_input_t *i = vam->input;
9113 vl_api_get_next_index_t *mp;
9115 u8 *node_name = 0, *next_node_name = 0;
9117 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9119 if (unformat (i, "node-name %s", &node_name))
9121 else if (unformat (i, "next-node-name %s", &next_node_name))
9127 errmsg ("node name required\n");
9130 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
9132 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9136 if (next_node_name == 0)
9138 errmsg ("next node name required\n");
9141 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
9143 errmsg ("next node name too long, max %d\n", ARRAY_LEN (mp->next_name));
9147 M (GET_NEXT_INDEX, get_next_index);
9148 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
9149 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
9150 vec_free (node_name);
9151 vec_free (next_node_name);
9160 api_add_node_next (vat_main_t * vam)
9162 unformat_input_t *i = vam->input;
9163 vl_api_add_node_next_t *mp;
9168 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9170 if (unformat (i, "node %s", &name))
9172 else if (unformat (i, "next %s", &next))
9179 errmsg ("node name required\n");
9182 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9184 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9189 errmsg ("next node required\n");
9192 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
9194 errmsg ("next name too long, max %d\n", ARRAY_LEN (mp->next_name));
9198 M (ADD_NODE_NEXT, add_node_next);
9199 clib_memcpy (mp->node_name, name, vec_len (name));
9200 clib_memcpy (mp->next_name, next, vec_len (next));
9211 api_l2tpv3_create_tunnel (vat_main_t * vam)
9213 unformat_input_t *i = vam->input;
9214 ip6_address_t client_address, our_address;
9215 int client_address_set = 0;
9216 int our_address_set = 0;
9217 u32 local_session_id = 0;
9218 u32 remote_session_id = 0;
9219 u64 local_cookie = 0;
9220 u64 remote_cookie = 0;
9221 u8 l2_sublayer_present = 0;
9222 vl_api_l2tpv3_create_tunnel_t *mp;
9225 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9227 if (unformat (i, "client_address %U", unformat_ip6_address,
9229 client_address_set = 1;
9230 else if (unformat (i, "our_address %U", unformat_ip6_address,
9232 our_address_set = 1;
9233 else if (unformat (i, "local_session_id %d", &local_session_id))
9235 else if (unformat (i, "remote_session_id %d", &remote_session_id))
9237 else if (unformat (i, "local_cookie %lld", &local_cookie))
9239 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
9241 else if (unformat (i, "l2-sublayer-present"))
9242 l2_sublayer_present = 1;
9247 if (client_address_set == 0)
9249 errmsg ("client_address required\n");
9253 if (our_address_set == 0)
9255 errmsg ("our_address required\n");
9259 M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel);
9261 clib_memcpy (mp->client_address, client_address.as_u8,
9262 sizeof (mp->client_address));
9264 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
9266 mp->local_session_id = ntohl (local_session_id);
9267 mp->remote_session_id = ntohl (remote_session_id);
9268 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
9269 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
9270 mp->l2_sublayer_present = l2_sublayer_present;
9280 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
9282 unformat_input_t *i = vam->input;
9284 u8 sw_if_index_set = 0;
9285 u64 new_local_cookie = 0;
9286 u64 new_remote_cookie = 0;
9287 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
9290 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9292 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9293 sw_if_index_set = 1;
9294 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9295 sw_if_index_set = 1;
9296 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
9298 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
9304 if (sw_if_index_set == 0)
9306 errmsg ("missing interface name or sw_if_index\n");
9310 M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies);
9312 mp->sw_if_index = ntohl (sw_if_index);
9313 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
9314 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
9323 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
9325 unformat_input_t *i = vam->input;
9326 vl_api_l2tpv3_interface_enable_disable_t *mp;
9329 u8 sw_if_index_set = 0;
9330 u8 enable_disable = 1;
9332 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9334 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9335 sw_if_index_set = 1;
9336 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9337 sw_if_index_set = 1;
9338 else if (unformat (i, "enable"))
9340 else if (unformat (i, "disable"))
9346 if (sw_if_index_set == 0)
9348 errmsg ("missing interface name or sw_if_index\n");
9352 M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable);
9354 mp->sw_if_index = ntohl (sw_if_index);
9355 mp->enable_disable = enable_disable;
9364 api_l2tpv3_set_lookup_key (vat_main_t * vam)
9366 unformat_input_t *i = vam->input;
9367 vl_api_l2tpv3_set_lookup_key_t *mp;
9371 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9373 if (unformat (i, "lookup_v6_src"))
9374 key = L2T_LOOKUP_SRC_ADDRESS;
9375 else if (unformat (i, "lookup_v6_dst"))
9376 key = L2T_LOOKUP_DST_ADDRESS;
9377 else if (unformat (i, "lookup_session_id"))
9378 key = L2T_LOOKUP_SESSION_ID;
9383 if (key == (u8) ~ 0)
9385 errmsg ("l2tp session lookup key unset\n");
9389 M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key);
9399 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
9400 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
9402 vat_main_t *vam = &vat_main;
9404 fformat (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)\n",
9405 format_ip6_address, mp->our_address,
9406 format_ip6_address, mp->client_address,
9407 clib_net_to_host_u32 (mp->sw_if_index));
9410 " local cookies %016llx %016llx remote cookie %016llx\n",
9411 clib_net_to_host_u64 (mp->local_cookie[0]),
9412 clib_net_to_host_u64 (mp->local_cookie[1]),
9413 clib_net_to_host_u64 (mp->remote_cookie));
9415 fformat (vam->ofp, " local session-id %d remote session-id %d\n",
9416 clib_net_to_host_u32 (mp->local_session_id),
9417 clib_net_to_host_u32 (mp->remote_session_id));
9419 fformat (vam->ofp, " l2 specific sublayer %s\n\n",
9420 mp->l2_sublayer_present ? "preset" : "absent");
9424 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
9425 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
9427 vat_main_t *vam = &vat_main;
9428 vat_json_node_t *node = NULL;
9429 struct in6_addr addr;
9431 if (VAT_JSON_ARRAY != vam->json_tree.type)
9433 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9434 vat_json_init_array (&vam->json_tree);
9436 node = vat_json_array_add (&vam->json_tree);
9438 vat_json_init_object (node);
9440 clib_memcpy (&addr, mp->our_address, sizeof (addr));
9441 vat_json_object_add_ip6 (node, "our_address", addr);
9442 clib_memcpy (&addr, mp->client_address, sizeof (addr));
9443 vat_json_object_add_ip6 (node, "client_address", addr);
9445 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
9446 vat_json_init_array (lc);
9447 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
9448 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
9449 vat_json_object_add_uint (node, "remote_cookie",
9450 clib_net_to_host_u64 (mp->remote_cookie));
9452 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
9453 vat_json_object_add_uint (node, "local_session_id",
9454 clib_net_to_host_u32 (mp->local_session_id));
9455 vat_json_object_add_uint (node, "remote_session_id",
9456 clib_net_to_host_u32 (mp->remote_session_id));
9457 vat_json_object_add_string_copy (node, "l2_sublayer",
9458 mp->l2_sublayer_present ? (u8 *) "present"
9463 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
9465 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
9468 /* Get list of l2tpv3-tunnel interfaces */
9469 M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump);
9472 /* Use a control ping for synchronization */
9474 vl_api_control_ping_t *mp;
9475 M (CONTROL_PING, control_ping);
9482 static void vl_api_sw_interface_tap_details_t_handler
9483 (vl_api_sw_interface_tap_details_t * mp)
9485 vat_main_t *vam = &vat_main;
9487 fformat (vam->ofp, "%-16s %d\n",
9488 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
9491 static void vl_api_sw_interface_tap_details_t_handler_json
9492 (vl_api_sw_interface_tap_details_t * mp)
9494 vat_main_t *vam = &vat_main;
9495 vat_json_node_t *node = NULL;
9497 if (VAT_JSON_ARRAY != vam->json_tree.type)
9499 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9500 vat_json_init_array (&vam->json_tree);
9502 node = vat_json_array_add (&vam->json_tree);
9504 vat_json_init_object (node);
9505 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9506 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
9510 api_sw_interface_tap_dump (vat_main_t * vam)
9512 vl_api_sw_interface_tap_dump_t *mp;
9515 fformat (vam->ofp, "\n%-16s %s\n", "dev_name", "sw_if_index");
9516 /* Get list of tap interfaces */
9517 M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump);
9520 /* Use a control ping for synchronization */
9522 vl_api_control_ping_t *mp;
9523 M (CONTROL_PING, control_ping);
9529 static uword unformat_vxlan_decap_next
9530 (unformat_input_t * input, va_list * args)
9532 u32 *result = va_arg (*args, u32 *);
9535 if (unformat (input, "drop"))
9536 *result = VXLAN_INPUT_NEXT_DROP;
9537 else if (unformat (input, "ip4"))
9538 *result = VXLAN_INPUT_NEXT_IP4_INPUT;
9539 else if (unformat (input, "ip6"))
9540 *result = VXLAN_INPUT_NEXT_IP6_INPUT;
9541 else if (unformat (input, "l2"))
9542 *result = VXLAN_INPUT_NEXT_L2_INPUT;
9543 else if (unformat (input, "%d", &tmp))
9551 api_vxlan_add_del_tunnel (vat_main_t * vam)
9553 unformat_input_t *line_input = vam->input;
9554 vl_api_vxlan_add_del_tunnel_t *mp;
9556 ip4_address_t src4, dst4;
9557 ip6_address_t src6, dst6;
9559 u8 ipv4_set = 0, ipv6_set = 0;
9562 u32 encap_vrf_id = 0;
9563 u32 decap_next_index = ~0;
9566 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9568 if (unformat (line_input, "del"))
9570 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
9575 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
9580 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
9585 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
9590 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
9592 else if (unformat (line_input, "decap-next %U",
9593 unformat_vxlan_decap_next, &decap_next_index))
9595 else if (unformat (line_input, "vni %d", &vni))
9599 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
9606 errmsg ("tunnel src address not specified\n");
9611 errmsg ("tunnel dst address not specified\n");
9615 if (ipv4_set && ipv6_set)
9617 errmsg ("both IPv4 and IPv6 addresses specified");
9621 if ((vni == 0) || (vni >> 24))
9623 errmsg ("vni not specified or out of range\n");
9627 M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel);
9631 clib_memcpy (&mp->src_address, &src6, sizeof (src6));
9632 clib_memcpy (&mp->dst_address, &dst6, sizeof (dst6));
9636 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
9637 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
9639 mp->encap_vrf_id = ntohl (encap_vrf_id);
9640 mp->decap_next_index = ntohl (decap_next_index);
9641 mp->vni = ntohl (vni);
9642 mp->is_add = is_add;
9643 mp->is_ipv6 = ipv6_set;
9651 static void vl_api_vxlan_tunnel_details_t_handler
9652 (vl_api_vxlan_tunnel_details_t * mp)
9654 vat_main_t *vam = &vat_main;
9656 fformat (vam->ofp, "%11d%24U%24U%14d%18d%13d\n",
9657 ntohl (mp->sw_if_index),
9658 format_ip46_address, &(mp->src_address[0]),
9660 format_ip46_address, &(mp->dst_address[0]),
9662 ntohl (mp->encap_vrf_id),
9663 ntohl (mp->decap_next_index), ntohl (mp->vni));
9666 static void vl_api_vxlan_tunnel_details_t_handler_json
9667 (vl_api_vxlan_tunnel_details_t * mp)
9669 vat_main_t *vam = &vat_main;
9670 vat_json_node_t *node = NULL;
9672 struct in6_addr ip6;
9674 if (VAT_JSON_ARRAY != vam->json_tree.type)
9676 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9677 vat_json_init_array (&vam->json_tree);
9679 node = vat_json_array_add (&vam->json_tree);
9681 vat_json_init_object (node);
9682 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9685 clib_memcpy (&ip6, &(mp->src_address[0]), sizeof (ip6));
9686 vat_json_object_add_ip6 (node, "src_address", ip6);
9687 clib_memcpy (&ip6, &(mp->dst_address[0]), sizeof (ip6));
9688 vat_json_object_add_ip6 (node, "dst_address", ip6);
9692 clib_memcpy (&ip4, &(mp->src_address[0]), sizeof (ip4));
9693 vat_json_object_add_ip4 (node, "src_address", ip4);
9694 clib_memcpy (&ip4, &(mp->dst_address[0]), sizeof (ip4));
9695 vat_json_object_add_ip4 (node, "dst_address", ip4);
9697 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
9698 vat_json_object_add_uint (node, "decap_next_index",
9699 ntohl (mp->decap_next_index));
9700 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
9701 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
9705 api_vxlan_tunnel_dump (vat_main_t * vam)
9707 unformat_input_t *i = vam->input;
9708 vl_api_vxlan_tunnel_dump_t *mp;
9711 u8 sw_if_index_set = 0;
9713 /* Parse args required to build the message */
9714 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9716 if (unformat (i, "sw_if_index %d", &sw_if_index))
9717 sw_if_index_set = 1;
9722 if (sw_if_index_set == 0)
9727 if (!vam->json_output)
9729 fformat (vam->ofp, "%11s%24s%24s%14s%18s%13s\n",
9730 "sw_if_index", "src_address", "dst_address",
9731 "encap_vrf_id", "decap_next_index", "vni");
9734 /* Get list of vxlan-tunnel interfaces */
9735 M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
9737 mp->sw_if_index = htonl (sw_if_index);
9741 /* Use a control ping for synchronization */
9743 vl_api_control_ping_t *mp;
9744 M (CONTROL_PING, control_ping);
9751 api_gre_add_del_tunnel (vat_main_t * vam)
9753 unformat_input_t *line_input = vam->input;
9754 vl_api_gre_add_del_tunnel_t *mp;
9756 ip4_address_t src4, dst4;
9761 u32 outer_fib_id = 0;
9763 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9765 if (unformat (line_input, "del"))
9767 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
9769 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
9771 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
9773 else if (unformat (line_input, "teb"))
9777 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
9784 errmsg ("tunnel src address not specified\n");
9789 errmsg ("tunnel dst address not specified\n");
9794 M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel);
9796 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
9797 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
9798 mp->outer_fib_id = ntohl (outer_fib_id);
9799 mp->is_add = is_add;
9808 static void vl_api_gre_tunnel_details_t_handler
9809 (vl_api_gre_tunnel_details_t * mp)
9811 vat_main_t *vam = &vat_main;
9813 fformat (vam->ofp, "%11d%15U%15U%6d%14d\n",
9814 ntohl (mp->sw_if_index),
9815 format_ip4_address, &mp->src_address,
9816 format_ip4_address, &mp->dst_address,
9817 mp->teb, ntohl (mp->outer_fib_id));
9820 static void vl_api_gre_tunnel_details_t_handler_json
9821 (vl_api_gre_tunnel_details_t * mp)
9823 vat_main_t *vam = &vat_main;
9824 vat_json_node_t *node = NULL;
9827 if (VAT_JSON_ARRAY != vam->json_tree.type)
9829 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9830 vat_json_init_array (&vam->json_tree);
9832 node = vat_json_array_add (&vam->json_tree);
9834 vat_json_init_object (node);
9835 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9836 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
9837 vat_json_object_add_ip4 (node, "src_address", ip4);
9838 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
9839 vat_json_object_add_ip4 (node, "dst_address", ip4);
9840 vat_json_object_add_uint (node, "teb", mp->teb);
9841 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
9845 api_gre_tunnel_dump (vat_main_t * vam)
9847 unformat_input_t *i = vam->input;
9848 vl_api_gre_tunnel_dump_t *mp;
9851 u8 sw_if_index_set = 0;
9853 /* Parse args required to build the message */
9854 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9856 if (unformat (i, "sw_if_index %d", &sw_if_index))
9857 sw_if_index_set = 1;
9862 if (sw_if_index_set == 0)
9867 if (!vam->json_output)
9869 fformat (vam->ofp, "%11s%15s%15s%6s%14s\n",
9870 "sw_if_index", "src_address", "dst_address", "teb",
9874 /* Get list of gre-tunnel interfaces */
9875 M (GRE_TUNNEL_DUMP, gre_tunnel_dump);
9877 mp->sw_if_index = htonl (sw_if_index);
9881 /* Use a control ping for synchronization */
9883 vl_api_control_ping_t *mp;
9884 M (CONTROL_PING, control_ping);
9891 api_l2_fib_clear_table (vat_main_t * vam)
9893 // unformat_input_t * i = vam->input;
9894 vl_api_l2_fib_clear_table_t *mp;
9897 M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table);
9906 api_l2_interface_efp_filter (vat_main_t * vam)
9908 unformat_input_t *i = vam->input;
9909 vl_api_l2_interface_efp_filter_t *mp;
9913 u8 sw_if_index_set = 0;
9915 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9917 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9918 sw_if_index_set = 1;
9919 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9920 sw_if_index_set = 1;
9921 else if (unformat (i, "enable"))
9923 else if (unformat (i, "disable"))
9927 clib_warning ("parse error '%U'", format_unformat_error, i);
9932 if (sw_if_index_set == 0)
9934 errmsg ("missing sw_if_index\n");
9938 M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter);
9940 mp->sw_if_index = ntohl (sw_if_index);
9941 mp->enable_disable = enable;
9949 #define foreach_vtr_op \
9950 _("disable", L2_VTR_DISABLED) \
9951 _("push-1", L2_VTR_PUSH_1) \
9952 _("push-2", L2_VTR_PUSH_2) \
9953 _("pop-1", L2_VTR_POP_1) \
9954 _("pop-2", L2_VTR_POP_2) \
9955 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
9956 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
9957 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
9958 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
9961 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
9963 unformat_input_t *i = vam->input;
9964 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
9967 u8 sw_if_index_set = 0;
9974 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9976 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9977 sw_if_index_set = 1;
9978 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9979 sw_if_index_set = 1;
9980 else if (unformat (i, "vtr_op %d", &vtr_op))
9982 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
9985 else if (unformat (i, "push_dot1q %d", &push_dot1q))
9987 else if (unformat (i, "tag1 %d", &tag1))
9989 else if (unformat (i, "tag2 %d", &tag2))
9993 clib_warning ("parse error '%U'", format_unformat_error, i);
9998 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
10000 errmsg ("missing vtr operation or sw_if_index\n");
10004 M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)
10005 mp->sw_if_index = ntohl (sw_if_index);
10006 mp->vtr_op = ntohl (vtr_op);
10007 mp->push_dot1q = ntohl (push_dot1q);
10008 mp->tag1 = ntohl (tag1);
10009 mp->tag2 = ntohl (tag2);
10018 api_create_vhost_user_if (vat_main_t * vam)
10020 unformat_input_t *i = vam->input;
10021 vl_api_create_vhost_user_if_t *mp;
10025 u8 file_name_set = 0;
10026 u32 custom_dev_instance = ~0;
10028 u8 use_custom_mac = 0;
10030 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10032 if (unformat (i, "socket %s", &file_name))
10036 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10038 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
10039 use_custom_mac = 1;
10040 else if (unformat (i, "server"))
10046 if (file_name_set == 0)
10048 errmsg ("missing socket file name\n");
10052 if (vec_len (file_name) > 255)
10054 errmsg ("socket file name too long\n");
10057 vec_add1 (file_name, 0);
10059 M (CREATE_VHOST_USER_IF, create_vhost_user_if);
10061 mp->is_server = is_server;
10062 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10063 vec_free (file_name);
10064 if (custom_dev_instance != ~0)
10067 mp->custom_dev_instance = ntohl (custom_dev_instance);
10069 mp->use_custom_mac = use_custom_mac;
10070 clib_memcpy (mp->mac_address, hwaddr, 6);
10079 api_modify_vhost_user_if (vat_main_t * vam)
10081 unformat_input_t *i = vam->input;
10082 vl_api_modify_vhost_user_if_t *mp;
10086 u8 file_name_set = 0;
10087 u32 custom_dev_instance = ~0;
10088 u8 sw_if_index_set = 0;
10089 u32 sw_if_index = (u32) ~ 0;
10091 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10093 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10094 sw_if_index_set = 1;
10095 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10096 sw_if_index_set = 1;
10097 else if (unformat (i, "socket %s", &file_name))
10101 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10103 else if (unformat (i, "server"))
10109 if (sw_if_index_set == 0)
10111 errmsg ("missing sw_if_index or interface name\n");
10115 if (file_name_set == 0)
10117 errmsg ("missing socket file name\n");
10121 if (vec_len (file_name) > 255)
10123 errmsg ("socket file name too long\n");
10126 vec_add1 (file_name, 0);
10128 M (MODIFY_VHOST_USER_IF, modify_vhost_user_if);
10130 mp->sw_if_index = ntohl (sw_if_index);
10131 mp->is_server = is_server;
10132 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10133 vec_free (file_name);
10134 if (custom_dev_instance != ~0)
10137 mp->custom_dev_instance = ntohl (custom_dev_instance);
10147 api_delete_vhost_user_if (vat_main_t * vam)
10149 unformat_input_t *i = vam->input;
10150 vl_api_delete_vhost_user_if_t *mp;
10152 u32 sw_if_index = ~0;
10153 u8 sw_if_index_set = 0;
10155 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10157 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10158 sw_if_index_set = 1;
10159 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10160 sw_if_index_set = 1;
10165 if (sw_if_index_set == 0)
10167 errmsg ("missing sw_if_index or interface name\n");
10172 M (DELETE_VHOST_USER_IF, delete_vhost_user_if);
10174 mp->sw_if_index = ntohl (sw_if_index);
10182 static void vl_api_sw_interface_vhost_user_details_t_handler
10183 (vl_api_sw_interface_vhost_user_details_t * mp)
10185 vat_main_t *vam = &vat_main;
10187 fformat (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s\n",
10188 (char *) mp->interface_name,
10189 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
10190 clib_net_to_host_u64 (mp->features), mp->is_server,
10191 ntohl (mp->num_regions), (char *) mp->sock_filename);
10192 fformat (vam->ofp, " Status: '%s'\n", strerror (ntohl (mp->sock_errno)));
10195 static void vl_api_sw_interface_vhost_user_details_t_handler_json
10196 (vl_api_sw_interface_vhost_user_details_t * mp)
10198 vat_main_t *vam = &vat_main;
10199 vat_json_node_t *node = NULL;
10201 if (VAT_JSON_ARRAY != vam->json_tree.type)
10203 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10204 vat_json_init_array (&vam->json_tree);
10206 node = vat_json_array_add (&vam->json_tree);
10208 vat_json_init_object (node);
10209 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10210 vat_json_object_add_string_copy (node, "interface_name",
10211 mp->interface_name);
10212 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
10213 ntohl (mp->virtio_net_hdr_sz));
10214 vat_json_object_add_uint (node, "features",
10215 clib_net_to_host_u64 (mp->features));
10216 vat_json_object_add_uint (node, "is_server", mp->is_server);
10217 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
10218 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
10219 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
10223 api_sw_interface_vhost_user_dump (vat_main_t * vam)
10225 vl_api_sw_interface_vhost_user_dump_t *mp;
10228 "Interface name idx hdr_sz features server regions filename\n");
10230 /* Get list of vhost-user interfaces */
10231 M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump);
10234 /* Use a control ping for synchronization */
10236 vl_api_control_ping_t *mp;
10237 M (CONTROL_PING, control_ping);
10244 api_show_version (vat_main_t * vam)
10246 vl_api_show_version_t *mp;
10249 M (SHOW_VERSION, show_version);
10259 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
10261 unformat_input_t *line_input = vam->input;
10262 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
10264 ip4_address_t local4, remote4;
10265 ip6_address_t local6, remote6;
10267 u8 ipv4_set = 0, ipv6_set = 0;
10270 u32 encap_vrf_id = 0;
10271 u32 decap_vrf_id = 0;
10276 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10278 if (unformat (line_input, "del"))
10280 else if (unformat (line_input, "local %U",
10281 unformat_ip4_address, &local4))
10286 else if (unformat (line_input, "remote %U",
10287 unformat_ip4_address, &remote4))
10292 else if (unformat (line_input, "local %U",
10293 unformat_ip6_address, &local6))
10298 else if (unformat (line_input, "remote %U",
10299 unformat_ip6_address, &remote6))
10304 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10306 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
10308 else if (unformat (line_input, "vni %d", &vni))
10310 else if (unformat (line_input, "next-ip4"))
10312 else if (unformat (line_input, "next-ip6"))
10314 else if (unformat (line_input, "next-ethernet"))
10316 else if (unformat (line_input, "next-nsh"))
10320 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
10325 if (local_set == 0)
10327 errmsg ("tunnel local address not specified\n");
10330 if (remote_set == 0)
10332 errmsg ("tunnel remote address not specified\n");
10335 if (ipv4_set && ipv6_set)
10337 errmsg ("both IPv4 and IPv6 addresses specified");
10343 errmsg ("vni not specified\n");
10347 M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel);
10352 clib_memcpy (&mp->local, &local6, sizeof (local6));
10353 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
10357 clib_memcpy (&mp->local, &local4, sizeof (local4));
10358 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
10361 mp->encap_vrf_id = ntohl (encap_vrf_id);
10362 mp->decap_vrf_id = ntohl (decap_vrf_id);
10363 mp->protocol = ntohl (protocol);
10364 mp->vni = ntohl (vni);
10365 mp->is_add = is_add;
10366 mp->is_ipv6 = ipv6_set;
10374 static void vl_api_vxlan_gpe_tunnel_details_t_handler
10375 (vl_api_vxlan_gpe_tunnel_details_t * mp)
10377 vat_main_t *vam = &vat_main;
10379 fformat (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d\n",
10380 ntohl (mp->sw_if_index),
10381 format_ip46_address, &(mp->local[0]),
10382 format_ip46_address, &(mp->remote[0]),
10384 ntohl (mp->protocol),
10385 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
10388 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
10389 (vl_api_vxlan_gpe_tunnel_details_t * mp)
10391 vat_main_t *vam = &vat_main;
10392 vat_json_node_t *node = NULL;
10393 struct in_addr ip4;
10394 struct in6_addr ip6;
10396 if (VAT_JSON_ARRAY != vam->json_tree.type)
10398 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10399 vat_json_init_array (&vam->json_tree);
10401 node = vat_json_array_add (&vam->json_tree);
10403 vat_json_init_object (node);
10404 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10407 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
10408 vat_json_object_add_ip6 (node, "local", ip6);
10409 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
10410 vat_json_object_add_ip6 (node, "remote", ip6);
10414 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
10415 vat_json_object_add_ip4 (node, "local", ip4);
10416 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
10417 vat_json_object_add_ip4 (node, "remote", ip4);
10419 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10420 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
10421 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10422 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
10423 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10427 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
10429 unformat_input_t *i = vam->input;
10430 vl_api_vxlan_gpe_tunnel_dump_t *mp;
10433 u8 sw_if_index_set = 0;
10435 /* Parse args required to build the message */
10436 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10438 if (unformat (i, "sw_if_index %d", &sw_if_index))
10439 sw_if_index_set = 1;
10444 if (sw_if_index_set == 0)
10449 if (!vam->json_output)
10451 fformat (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s\n",
10452 "sw_if_index", "local", "remote", "vni",
10453 "protocol", "encap_vrf_id", "decap_vrf_id");
10456 /* Get list of vxlan-tunnel interfaces */
10457 M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump);
10459 mp->sw_if_index = htonl (sw_if_index);
10463 /* Use a control ping for synchronization */
10465 vl_api_control_ping_t *mp;
10466 M (CONTROL_PING, control_ping);
10473 format_l2_fib_mac_address (u8 * s, va_list * args)
10475 u8 *a = va_arg (*args, u8 *);
10477 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
10478 a[2], a[3], a[4], a[5], a[6], a[7]);
10481 static void vl_api_l2_fib_table_entry_t_handler
10482 (vl_api_l2_fib_table_entry_t * mp)
10484 vat_main_t *vam = &vat_main;
10486 fformat (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
10488 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
10489 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
10493 static void vl_api_l2_fib_table_entry_t_handler_json
10494 (vl_api_l2_fib_table_entry_t * mp)
10496 vat_main_t *vam = &vat_main;
10497 vat_json_node_t *node = NULL;
10499 if (VAT_JSON_ARRAY != vam->json_tree.type)
10501 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10502 vat_json_init_array (&vam->json_tree);
10504 node = vat_json_array_add (&vam->json_tree);
10506 vat_json_init_object (node);
10507 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
10508 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
10509 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10510 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
10511 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
10512 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
10516 api_l2_fib_table_dump (vat_main_t * vam)
10518 unformat_input_t *i = vam->input;
10519 vl_api_l2_fib_table_dump_t *mp;
10524 /* Parse args required to build the message */
10525 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10527 if (unformat (i, "bd_id %d", &bd_id))
10533 if (bd_id_set == 0)
10535 errmsg ("missing bridge domain\n");
10540 "BD-ID Mac Address sw-ndx Static Filter BVI\n");
10542 /* Get list of l2 fib entries */
10543 M (L2_FIB_TABLE_DUMP, l2_fib_table_dump);
10545 mp->bd_id = ntohl (bd_id);
10548 /* Use a control ping for synchronization */
10550 vl_api_control_ping_t *mp;
10551 M (CONTROL_PING, control_ping);
10559 api_interface_name_renumber (vat_main_t * vam)
10561 unformat_input_t *line_input = vam->input;
10562 vl_api_interface_name_renumber_t *mp;
10563 u32 sw_if_index = ~0;
10565 u32 new_show_dev_instance = ~0;
10567 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10569 if (unformat (line_input, "%U", unformat_sw_if_index, vam,
10572 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
10574 else if (unformat (line_input, "new_show_dev_instance %d",
10575 &new_show_dev_instance))
10581 if (sw_if_index == ~0)
10583 errmsg ("missing interface name or sw_if_index\n");
10587 if (new_show_dev_instance == ~0)
10589 errmsg ("missing new_show_dev_instance\n");
10593 M (INTERFACE_NAME_RENUMBER, interface_name_renumber);
10595 mp->sw_if_index = ntohl (sw_if_index);
10596 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
10603 api_want_ip4_arp_events (vat_main_t * vam)
10605 unformat_input_t *line_input = vam->input;
10606 vl_api_want_ip4_arp_events_t *mp;
10608 ip4_address_t address;
10609 int address_set = 0;
10610 u32 enable_disable = 1;
10612 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10614 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
10616 else if (unformat (line_input, "del"))
10617 enable_disable = 0;
10622 if (address_set == 0)
10624 errmsg ("missing addresses\n");
10628 M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events);
10629 mp->enable_disable = enable_disable;
10630 mp->pid = getpid ();
10631 mp->address = address.as_u32;
10638 api_want_ip6_nd_events (vat_main_t * vam)
10640 unformat_input_t *line_input = vam->input;
10641 vl_api_want_ip6_nd_events_t *mp;
10643 ip6_address_t address;
10644 int address_set = 0;
10645 u32 enable_disable = 1;
10647 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10649 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
10651 else if (unformat (line_input, "del"))
10652 enable_disable = 0;
10657 if (address_set == 0)
10659 errmsg ("missing addresses\n");
10663 M (WANT_IP6_ND_EVENTS, want_ip6_nd_events);
10664 mp->enable_disable = enable_disable;
10665 mp->pid = getpid ();
10666 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
10673 api_input_acl_set_interface (vat_main_t * vam)
10675 unformat_input_t *i = vam->input;
10676 vl_api_input_acl_set_interface_t *mp;
10679 int sw_if_index_set;
10680 u32 ip4_table_index = ~0;
10681 u32 ip6_table_index = ~0;
10682 u32 l2_table_index = ~0;
10685 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10687 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10688 sw_if_index_set = 1;
10689 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10690 sw_if_index_set = 1;
10691 else if (unformat (i, "del"))
10693 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10695 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10697 else if (unformat (i, "l2-table %d", &l2_table_index))
10701 clib_warning ("parse error '%U'", format_unformat_error, i);
10706 if (sw_if_index_set == 0)
10708 errmsg ("missing interface name or sw_if_index\n");
10712 M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface);
10714 mp->sw_if_index = ntohl (sw_if_index);
10715 mp->ip4_table_index = ntohl (ip4_table_index);
10716 mp->ip6_table_index = ntohl (ip6_table_index);
10717 mp->l2_table_index = ntohl (l2_table_index);
10718 mp->is_add = is_add;
10727 api_ip_address_dump (vat_main_t * vam)
10729 unformat_input_t *i = vam->input;
10730 vl_api_ip_address_dump_t *mp;
10731 u32 sw_if_index = ~0;
10732 u8 sw_if_index_set = 0;
10737 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10739 if (unformat (i, "sw_if_index %d", &sw_if_index))
10740 sw_if_index_set = 1;
10741 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10742 sw_if_index_set = 1;
10743 else if (unformat (i, "ipv4"))
10745 else if (unformat (i, "ipv6"))
10751 if (ipv4_set && ipv6_set)
10753 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
10757 if ((!ipv4_set) && (!ipv6_set))
10759 errmsg ("no ipv4 nor ipv6 flag set\n");
10763 if (sw_if_index_set == 0)
10765 errmsg ("missing interface name or sw_if_index\n");
10769 vam->current_sw_if_index = sw_if_index;
10770 vam->is_ipv6 = ipv6_set;
10772 M (IP_ADDRESS_DUMP, ip_address_dump);
10773 mp->sw_if_index = ntohl (sw_if_index);
10774 mp->is_ipv6 = ipv6_set;
10777 /* Use a control ping for synchronization */
10779 vl_api_control_ping_t *mp;
10780 M (CONTROL_PING, control_ping);
10787 api_ip_dump (vat_main_t * vam)
10789 vl_api_ip_dump_t *mp;
10790 unformat_input_t *in = vam->input;
10797 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
10799 if (unformat (in, "ipv4"))
10801 else if (unformat (in, "ipv6"))
10807 if (ipv4_set && ipv6_set)
10809 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
10813 if ((!ipv4_set) && (!ipv6_set))
10815 errmsg ("no ipv4 nor ipv6 flag set\n");
10819 is_ipv6 = ipv6_set;
10820 vam->is_ipv6 = is_ipv6;
10822 /* free old data */
10823 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
10825 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
10827 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
10829 M (IP_DUMP, ip_dump);
10830 mp->is_ipv6 = ipv6_set;
10833 /* Use a control ping for synchronization */
10835 vl_api_control_ping_t *mp;
10836 M (CONTROL_PING, control_ping);
10843 api_ipsec_spd_add_del (vat_main_t * vam)
10846 unformat_input_t *i = vam->input;
10847 vl_api_ipsec_spd_add_del_t *mp;
10852 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10854 if (unformat (i, "spd_id %d", &spd_id))
10856 else if (unformat (i, "del"))
10860 clib_warning ("parse error '%U'", format_unformat_error, i);
10866 errmsg ("spd_id must be set\n");
10870 M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del);
10872 mp->spd_id = ntohl (spd_id);
10873 mp->is_add = is_add;
10880 clib_warning ("unsupported (no dpdk)");
10886 api_ipsec_interface_add_del_spd (vat_main_t * vam)
10889 unformat_input_t *i = vam->input;
10890 vl_api_ipsec_interface_add_del_spd_t *mp;
10893 u8 sw_if_index_set = 0;
10894 u32 spd_id = (u32) ~ 0;
10897 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10899 if (unformat (i, "del"))
10901 else if (unformat (i, "spd_id %d", &spd_id))
10903 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10904 sw_if_index_set = 1;
10905 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10906 sw_if_index_set = 1;
10909 clib_warning ("parse error '%U'", format_unformat_error, i);
10915 if (spd_id == (u32) ~ 0)
10917 errmsg ("spd_id must be set\n");
10921 if (sw_if_index_set == 0)
10923 errmsg ("missing interface name or sw_if_index\n");
10927 M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd);
10929 mp->spd_id = ntohl (spd_id);
10930 mp->sw_if_index = ntohl (sw_if_index);
10931 mp->is_add = is_add;
10938 clib_warning ("unsupported (no dpdk)");
10944 api_ipsec_spd_add_del_entry (vat_main_t * vam)
10947 unformat_input_t *i = vam->input;
10948 vl_api_ipsec_spd_add_del_entry_t *mp;
10950 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
10951 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
10953 u32 rport_start = 0, rport_stop = (u32) ~ 0;
10954 u32 lport_start = 0, lport_stop = (u32) ~ 0;
10955 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
10956 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
10958 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
10959 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
10960 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
10961 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
10962 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
10963 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
10965 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10967 if (unformat (i, "del"))
10969 if (unformat (i, "outbound"))
10971 if (unformat (i, "inbound"))
10973 else if (unformat (i, "spd_id %d", &spd_id))
10975 else if (unformat (i, "sa_id %d", &sa_id))
10977 else if (unformat (i, "priority %d", &priority))
10979 else if (unformat (i, "protocol %d", &protocol))
10981 else if (unformat (i, "lport_start %d", &lport_start))
10983 else if (unformat (i, "lport_stop %d", &lport_stop))
10985 else if (unformat (i, "rport_start %d", &rport_start))
10987 else if (unformat (i, "rport_stop %d", &rport_stop))
10991 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
10997 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
11004 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
11010 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
11017 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
11023 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
11030 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
11036 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
11042 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
11044 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
11046 clib_warning ("unsupported action: 'resolve'");
11052 clib_warning ("parse error '%U'", format_unformat_error, i);
11058 M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry);
11060 mp->spd_id = ntohl (spd_id);
11061 mp->priority = ntohl (priority);
11062 mp->is_outbound = is_outbound;
11064 mp->is_ipv6 = is_ipv6;
11065 if (is_ipv6 || is_ip_any)
11067 clib_memcpy (mp->remote_address_start, &raddr6_start,
11068 sizeof (ip6_address_t));
11069 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
11070 sizeof (ip6_address_t));
11071 clib_memcpy (mp->local_address_start, &laddr6_start,
11072 sizeof (ip6_address_t));
11073 clib_memcpy (mp->local_address_stop, &laddr6_stop,
11074 sizeof (ip6_address_t));
11078 clib_memcpy (mp->remote_address_start, &raddr4_start,
11079 sizeof (ip4_address_t));
11080 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
11081 sizeof (ip4_address_t));
11082 clib_memcpy (mp->local_address_start, &laddr4_start,
11083 sizeof (ip4_address_t));
11084 clib_memcpy (mp->local_address_stop, &laddr4_stop,
11085 sizeof (ip4_address_t));
11087 mp->protocol = (u8) protocol;
11088 mp->local_port_start = ntohs ((u16) lport_start);
11089 mp->local_port_stop = ntohs ((u16) lport_stop);
11090 mp->remote_port_start = ntohs ((u16) rport_start);
11091 mp->remote_port_stop = ntohs ((u16) rport_stop);
11092 mp->policy = (u8) policy;
11093 mp->sa_id = ntohl (sa_id);
11094 mp->is_add = is_add;
11095 mp->is_ip_any = is_ip_any;
11101 clib_warning ("unsupported (no dpdk)");
11107 api_ipsec_sad_add_del_entry (vat_main_t * vam)
11110 unformat_input_t *i = vam->input;
11111 vl_api_ipsec_sad_add_del_entry_t *mp;
11113 u32 sad_id = 0, spi = 0;
11114 u8 *ck = 0, *ik = 0;
11117 u8 protocol = IPSEC_PROTOCOL_AH;
11118 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
11119 u32 crypto_alg = 0, integ_alg = 0;
11120 ip4_address_t tun_src4;
11121 ip4_address_t tun_dst4;
11122 ip6_address_t tun_src6;
11123 ip6_address_t tun_dst6;
11125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11127 if (unformat (i, "del"))
11129 else if (unformat (i, "sad_id %d", &sad_id))
11131 else if (unformat (i, "spi %d", &spi))
11133 else if (unformat (i, "esp"))
11134 protocol = IPSEC_PROTOCOL_ESP;
11135 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
11138 is_tunnel_ipv6 = 0;
11140 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
11143 is_tunnel_ipv6 = 0;
11145 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
11148 is_tunnel_ipv6 = 1;
11150 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
11153 is_tunnel_ipv6 = 1;
11157 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
11159 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
11160 crypto_alg > IPSEC_INTEG_ALG_SHA_512_256)
11162 clib_warning ("unsupported crypto-alg: '%U'",
11163 format_ipsec_crypto_alg, crypto_alg);
11167 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11171 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
11173 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
11174 integ_alg > IPSEC_INTEG_ALG_SHA_512_256)
11176 clib_warning ("unsupported integ-alg: '%U'",
11177 format_ipsec_integ_alg, integ_alg);
11181 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
11185 clib_warning ("parse error '%U'", format_unformat_error, i);
11191 M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
11193 mp->sad_id = ntohl (sad_id);
11194 mp->is_add = is_add;
11195 mp->protocol = protocol;
11196 mp->spi = ntohl (spi);
11197 mp->is_tunnel = is_tunnel;
11198 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
11199 mp->crypto_algorithm = crypto_alg;
11200 mp->integrity_algorithm = integ_alg;
11201 mp->crypto_key_length = vec_len (ck);
11202 mp->integrity_key_length = vec_len (ik);
11204 if (mp->crypto_key_length > sizeof (mp->crypto_key))
11205 mp->crypto_key_length = sizeof (mp->crypto_key);
11207 if (mp->integrity_key_length > sizeof (mp->integrity_key))
11208 mp->integrity_key_length = sizeof (mp->integrity_key);
11211 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
11213 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
11217 if (is_tunnel_ipv6)
11219 clib_memcpy (mp->tunnel_src_address, &tun_src6,
11220 sizeof (ip6_address_t));
11221 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
11222 sizeof (ip6_address_t));
11226 clib_memcpy (mp->tunnel_src_address, &tun_src4,
11227 sizeof (ip4_address_t));
11228 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
11229 sizeof (ip4_address_t));
11238 clib_warning ("unsupported (no dpdk)");
11244 api_ipsec_sa_set_key (vat_main_t * vam)
11247 unformat_input_t *i = vam->input;
11248 vl_api_ipsec_sa_set_key_t *mp;
11251 u8 *ck = 0, *ik = 0;
11253 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11255 if (unformat (i, "sa_id %d", &sa_id))
11257 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11259 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
11263 clib_warning ("parse error '%U'", format_unformat_error, i);
11268 M (IPSEC_SA_SET_KEY, ipsec_set_sa_key);
11270 mp->sa_id = ntohl (sa_id);
11271 mp->crypto_key_length = vec_len (ck);
11272 mp->integrity_key_length = vec_len (ik);
11274 if (mp->crypto_key_length > sizeof (mp->crypto_key))
11275 mp->crypto_key_length = sizeof (mp->crypto_key);
11277 if (mp->integrity_key_length > sizeof (mp->integrity_key))
11278 mp->integrity_key_length = sizeof (mp->integrity_key);
11281 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
11283 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
11290 clib_warning ("unsupported (no dpdk)");
11296 api_ikev2_profile_add_del (vat_main_t * vam)
11299 unformat_input_t *i = vam->input;
11300 vl_api_ikev2_profile_add_del_t *mp;
11305 const char *valid_chars = "a-zA-Z0-9_";
11307 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11309 if (unformat (i, "del"))
11311 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11312 vec_add1 (name, 0);
11315 errmsg ("parse error '%U'", format_unformat_error, i);
11320 if (!vec_len (name))
11322 errmsg ("profile name must be specified");
11326 if (vec_len (name) > 64)
11328 errmsg ("profile name too long");
11332 M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del);
11334 clib_memcpy (mp->name, name, vec_len (name));
11335 mp->is_add = is_add;
11343 clib_warning ("unsupported (no dpdk)");
11349 api_ikev2_profile_set_auth (vat_main_t * vam)
11352 unformat_input_t *i = vam->input;
11353 vl_api_ikev2_profile_set_auth_t *mp;
11357 u32 auth_method = 0;
11360 const char *valid_chars = "a-zA-Z0-9_";
11362 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11364 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11365 vec_add1 (name, 0);
11366 else if (unformat (i, "auth_method %U",
11367 unformat_ikev2_auth_method, &auth_method))
11369 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
11371 else if (unformat (i, "auth_data %v", &data))
11375 errmsg ("parse error '%U'", format_unformat_error, i);
11380 if (!vec_len (name))
11382 errmsg ("profile name must be specified");
11386 if (vec_len (name) > 64)
11388 errmsg ("profile name too long");
11392 if (!vec_len (data))
11394 errmsg ("auth_data must be specified");
11400 errmsg ("auth_method must be specified");
11404 M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth);
11406 mp->is_hex = is_hex;
11407 mp->auth_method = (u8) auth_method;
11408 mp->data_len = vec_len (data);
11409 clib_memcpy (mp->name, name, vec_len (name));
11410 clib_memcpy (mp->data, data, vec_len (data));
11419 clib_warning ("unsupported (no dpdk)");
11425 api_ikev2_profile_set_id (vat_main_t * vam)
11428 unformat_input_t *i = vam->input;
11429 vl_api_ikev2_profile_set_id_t *mp;
11437 const char *valid_chars = "a-zA-Z0-9_";
11439 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11441 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11442 vec_add1 (name, 0);
11443 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
11445 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
11447 data = vec_new (u8, 4);
11448 clib_memcpy (data, ip4.as_u8, 4);
11450 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
11452 else if (unformat (i, "id_data %v", &data))
11454 else if (unformat (i, "local"))
11456 else if (unformat (i, "remote"))
11460 errmsg ("parse error '%U'", format_unformat_error, i);
11465 if (!vec_len (name))
11467 errmsg ("profile name must be specified");
11471 if (vec_len (name) > 64)
11473 errmsg ("profile name too long");
11477 if (!vec_len (data))
11479 errmsg ("id_data must be specified");
11485 errmsg ("id_type must be specified");
11489 M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id);
11491 mp->is_local = is_local;
11492 mp->id_type = (u8) id_type;
11493 mp->data_len = vec_len (data);
11494 clib_memcpy (mp->name, name, vec_len (name));
11495 clib_memcpy (mp->data, data, vec_len (data));
11504 clib_warning ("unsupported (no dpdk)");
11510 api_ikev2_profile_set_ts (vat_main_t * vam)
11513 unformat_input_t *i = vam->input;
11514 vl_api_ikev2_profile_set_ts_t *mp;
11518 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
11519 ip4_address_t start_addr, end_addr;
11521 const char *valid_chars = "a-zA-Z0-9_";
11523 start_addr.as_u32 = 0;
11524 end_addr.as_u32 = (u32) ~ 0;
11526 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11528 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11529 vec_add1 (name, 0);
11530 else if (unformat (i, "protocol %d", &proto))
11532 else if (unformat (i, "start_port %d", &start_port))
11534 else if (unformat (i, "end_port %d", &end_port))
11537 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
11539 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
11541 else if (unformat (i, "local"))
11543 else if (unformat (i, "remote"))
11547 errmsg ("parse error '%U'", format_unformat_error, i);
11552 if (!vec_len (name))
11554 errmsg ("profile name must be specified");
11558 if (vec_len (name) > 64)
11560 errmsg ("profile name too long");
11564 M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts);
11566 mp->is_local = is_local;
11567 mp->proto = (u8) proto;
11568 mp->start_port = (u16) start_port;
11569 mp->end_port = (u16) end_port;
11570 mp->start_addr = start_addr.as_u32;
11571 mp->end_addr = end_addr.as_u32;
11572 clib_memcpy (mp->name, name, vec_len (name));
11580 clib_warning ("unsupported (no dpdk)");
11586 api_ikev2_set_local_key (vat_main_t * vam)
11589 unformat_input_t *i = vam->input;
11590 vl_api_ikev2_set_local_key_t *mp;
11594 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11596 if (unformat (i, "file %v", &file))
11597 vec_add1 (file, 0);
11600 errmsg ("parse error '%U'", format_unformat_error, i);
11605 if (!vec_len (file))
11607 errmsg ("RSA key file must be specified");
11611 if (vec_len (file) > 256)
11613 errmsg ("file name too long");
11617 M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key);
11619 clib_memcpy (mp->key_file, file, vec_len (file));
11627 clib_warning ("unsupported (no dpdk)");
11636 api_map_add_domain (vat_main_t * vam)
11638 unformat_input_t *i = vam->input;
11639 vl_api_map_add_domain_t *mp;
11642 ip4_address_t ip4_prefix;
11643 ip6_address_t ip6_prefix;
11644 ip6_address_t ip6_src;
11645 u32 num_m_args = 0;
11646 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
11647 0, psid_length = 0;
11648 u8 is_translation = 0;
11650 u32 ip6_src_len = 128;
11652 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11654 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
11655 &ip4_prefix, &ip4_prefix_len))
11657 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
11658 &ip6_prefix, &ip6_prefix_len))
11662 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
11665 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
11667 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
11669 else if (unformat (i, "psid-offset %d", &psid_offset))
11671 else if (unformat (i, "psid-len %d", &psid_length))
11673 else if (unformat (i, "mtu %d", &mtu))
11675 else if (unformat (i, "map-t"))
11676 is_translation = 1;
11679 clib_warning ("parse error '%U'", format_unformat_error, i);
11684 if (num_m_args < 3)
11686 errmsg ("mandatory argument(s) missing\n");
11690 /* Construct the API message */
11691 M (MAP_ADD_DOMAIN, map_add_domain);
11693 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
11694 mp->ip4_prefix_len = ip4_prefix_len;
11696 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
11697 mp->ip6_prefix_len = ip6_prefix_len;
11699 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
11700 mp->ip6_src_prefix_len = ip6_src_len;
11702 mp->ea_bits_len = ea_bits_len;
11703 mp->psid_offset = psid_offset;
11704 mp->psid_length = psid_length;
11705 mp->is_translation = is_translation;
11706 mp->mtu = htons (mtu);
11711 /* Wait for a reply, return good/bad news */
11716 api_map_del_domain (vat_main_t * vam)
11718 unformat_input_t *i = vam->input;
11719 vl_api_map_del_domain_t *mp;
11722 u32 num_m_args = 0;
11725 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11727 if (unformat (i, "index %d", &index))
11731 clib_warning ("parse error '%U'", format_unformat_error, i);
11736 if (num_m_args != 1)
11738 errmsg ("mandatory argument(s) missing\n");
11742 /* Construct the API message */
11743 M (MAP_DEL_DOMAIN, map_del_domain);
11745 mp->index = ntohl (index);
11750 /* Wait for a reply, return good/bad news */
11755 api_map_add_del_rule (vat_main_t * vam)
11757 unformat_input_t *i = vam->input;
11758 vl_api_map_add_del_rule_t *mp;
11761 ip6_address_t ip6_dst;
11762 u32 num_m_args = 0, index, psid = 0;
11764 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11766 if (unformat (i, "index %d", &index))
11768 else if (unformat (i, "psid %d", &psid))
11770 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
11772 else if (unformat (i, "del"))
11778 clib_warning ("parse error '%U'", format_unformat_error, i);
11783 /* Construct the API message */
11784 M (MAP_ADD_DEL_RULE, map_add_del_rule);
11786 mp->index = ntohl (index);
11787 mp->is_add = is_add;
11788 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
11789 mp->psid = ntohs (psid);
11794 /* Wait for a reply, return good/bad news */
11799 api_map_domain_dump (vat_main_t * vam)
11801 vl_api_map_domain_dump_t *mp;
11804 /* Construct the API message */
11805 M (MAP_DOMAIN_DUMP, map_domain_dump);
11810 /* Use a control ping for synchronization */
11812 vl_api_control_ping_t *mp;
11813 M (CONTROL_PING, control_ping);
11820 api_map_rule_dump (vat_main_t * vam)
11822 unformat_input_t *i = vam->input;
11823 vl_api_map_rule_dump_t *mp;
11825 u32 domain_index = ~0;
11827 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11829 if (unformat (i, "index %u", &domain_index))
11835 if (domain_index == ~0)
11837 clib_warning ("parse error: domain index expected");
11841 /* Construct the API message */
11842 M (MAP_RULE_DUMP, map_rule_dump);
11844 mp->domain_index = htonl (domain_index);
11849 /* Use a control ping for synchronization */
11851 vl_api_control_ping_t *mp;
11852 M (CONTROL_PING, control_ping);
11858 static void vl_api_map_add_domain_reply_t_handler
11859 (vl_api_map_add_domain_reply_t * mp)
11861 vat_main_t *vam = &vat_main;
11862 i32 retval = ntohl (mp->retval);
11864 if (vam->async_mode)
11866 vam->async_errors += (retval < 0);
11870 vam->retval = retval;
11871 vam->result_ready = 1;
11875 static void vl_api_map_add_domain_reply_t_handler_json
11876 (vl_api_map_add_domain_reply_t * mp)
11878 vat_main_t *vam = &vat_main;
11879 vat_json_node_t node;
11881 vat_json_init_object (&node);
11882 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
11883 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
11885 vat_json_print (vam->ofp, &node);
11886 vat_json_free (&node);
11888 vam->retval = ntohl (mp->retval);
11889 vam->result_ready = 1;
11893 api_get_first_msg_id (vat_main_t * vam)
11895 vl_api_get_first_msg_id_t *mp;
11897 unformat_input_t *i = vam->input;
11901 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11903 if (unformat (i, "client %s", &name))
11911 errmsg ("missing client name\n");
11914 vec_add1 (name, 0);
11916 if (vec_len (name) > 63)
11918 errmsg ("client name too long\n");
11922 M (GET_FIRST_MSG_ID, get_first_msg_id);
11923 clib_memcpy (mp->name, name, vec_len (name));
11931 api_cop_interface_enable_disable (vat_main_t * vam)
11933 unformat_input_t *line_input = vam->input;
11934 vl_api_cop_interface_enable_disable_t *mp;
11936 u32 sw_if_index = ~0;
11937 u8 enable_disable = 1;
11939 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11941 if (unformat (line_input, "disable"))
11942 enable_disable = 0;
11943 if (unformat (line_input, "enable"))
11944 enable_disable = 1;
11945 else if (unformat (line_input, "%U", unformat_sw_if_index,
11946 vam, &sw_if_index))
11948 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11954 if (sw_if_index == ~0)
11956 errmsg ("missing interface name or sw_if_index\n");
11960 /* Construct the API message */
11961 M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable);
11962 mp->sw_if_index = ntohl (sw_if_index);
11963 mp->enable_disable = enable_disable;
11967 /* Wait for the reply */
11972 api_cop_whitelist_enable_disable (vat_main_t * vam)
11974 unformat_input_t *line_input = vam->input;
11975 vl_api_cop_whitelist_enable_disable_t *mp;
11977 u32 sw_if_index = ~0;
11978 u8 ip4 = 0, ip6 = 0, default_cop = 0;
11981 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11983 if (unformat (line_input, "ip4"))
11985 else if (unformat (line_input, "ip6"))
11987 else if (unformat (line_input, "default"))
11989 else if (unformat (line_input, "%U", unformat_sw_if_index,
11990 vam, &sw_if_index))
11992 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11994 else if (unformat (line_input, "fib-id %d", &fib_id))
12000 if (sw_if_index == ~0)
12002 errmsg ("missing interface name or sw_if_index\n");
12006 /* Construct the API message */
12007 M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable);
12008 mp->sw_if_index = ntohl (sw_if_index);
12009 mp->fib_id = ntohl (fib_id);
12012 mp->default_cop = default_cop;
12016 /* Wait for the reply */
12021 api_get_node_graph (vat_main_t * vam)
12023 vl_api_get_node_graph_t *mp;
12026 M (GET_NODE_GRAPH, get_node_graph);
12030 /* Wait for the reply */
12035 /** Used for parsing LISP eids */
12036 typedef CLIB_PACKED(struct{
12037 u8 addr[16]; /**< eid address */
12038 u32 len; /**< prefix length if IP */
12039 u8 type; /**< type of eid */
12044 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
12046 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
12048 memset (a, 0, sizeof (a[0]));
12050 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
12052 a->type = 0; /* ipv4 type */
12054 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
12056 a->type = 1; /* ipv6 type */
12058 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
12060 a->type = 2; /* mac type */
12067 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
12076 lisp_eid_size_vat (u8 type)
12091 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
12093 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
12097 /** Used for transferring locators via VPP API */
12098 typedef CLIB_PACKED(struct
12100 u32 sw_if_index; /**< locator sw_if_index */
12101 u8 priority; /**< locator priority */
12102 u8 weight; /**< locator weight */
12107 api_lisp_add_del_locator_set (vat_main_t * vam)
12109 unformat_input_t *input = vam->input;
12110 vl_api_lisp_add_del_locator_set_t *mp;
12113 u8 *locator_set_name = NULL;
12114 u8 locator_set_name_set = 0;
12115 ls_locator_t locator, *locators = 0;
12116 u32 sw_if_index, priority, weight;
12119 /* Parse args required to build the message */
12120 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12122 if (unformat (input, "del"))
12126 else if (unformat (input, "locator-set %s", &locator_set_name))
12128 locator_set_name_set = 1;
12130 else if (unformat (input, "sw_if_index %u p %u w %u",
12131 &sw_if_index, &priority, &weight))
12133 locator.sw_if_index = htonl (sw_if_index);
12134 locator.priority = priority;
12135 locator.weight = weight;
12136 vec_add1 (locators, locator);
12138 else if (unformat (input, "iface %U p %u w %u", unformat_sw_if_index,
12139 vam, &sw_if_index, &priority, &weight))
12141 locator.sw_if_index = htonl (sw_if_index);
12142 locator.priority = priority;
12143 locator.weight = weight;
12144 vec_add1 (locators, locator);
12150 if (locator_set_name_set == 0)
12152 errmsg ("missing locator-set name");
12153 vec_free (locators);
12157 if (vec_len (locator_set_name) > 64)
12159 errmsg ("locator-set name too long\n");
12160 vec_free (locator_set_name);
12161 vec_free (locators);
12164 vec_add1 (locator_set_name, 0);
12166 data_len = sizeof (ls_locator_t) * vec_len (locators);
12168 /* Construct the API message */
12169 M2 (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set, data_len);
12171 mp->is_add = is_add;
12172 clib_memcpy (mp->locator_set_name, locator_set_name,
12173 vec_len (locator_set_name));
12174 vec_free (locator_set_name);
12176 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
12178 clib_memcpy (mp->locators, locators, data_len);
12179 vec_free (locators);
12184 /* Wait for a reply... */
12192 api_lisp_add_del_locator (vat_main_t * vam)
12194 unformat_input_t *input = vam->input;
12195 vl_api_lisp_add_del_locator_t *mp;
12197 u32 tmp_if_index = ~0;
12198 u32 sw_if_index = ~0;
12199 u8 sw_if_index_set = 0;
12200 u8 sw_if_index_if_name_set = 0;
12202 u8 priority_set = 0;
12206 u8 *locator_set_name = NULL;
12207 u8 locator_set_name_set = 0;
12209 /* Parse args required to build the message */
12210 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12212 if (unformat (input, "del"))
12216 else if (unformat (input, "locator-set %s", &locator_set_name))
12218 locator_set_name_set = 1;
12220 else if (unformat (input, "iface %U", unformat_sw_if_index, vam,
12223 sw_if_index_if_name_set = 1;
12224 sw_if_index = tmp_if_index;
12226 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
12228 sw_if_index_set = 1;
12229 sw_if_index = tmp_if_index;
12231 else if (unformat (input, "p %d", &priority))
12235 else if (unformat (input, "w %d", &weight))
12243 if (locator_set_name_set == 0)
12245 errmsg ("missing locator-set name");
12249 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
12251 errmsg ("missing sw_if_index");
12252 vec_free (locator_set_name);
12256 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
12258 errmsg ("cannot use both params interface name and sw_if_index");
12259 vec_free (locator_set_name);
12263 if (priority_set == 0)
12265 errmsg ("missing locator-set priority\n");
12266 vec_free (locator_set_name);
12270 if (weight_set == 0)
12272 errmsg ("missing locator-set weight\n");
12273 vec_free (locator_set_name);
12277 if (vec_len (locator_set_name) > 64)
12279 errmsg ("locator-set name too long\n");
12280 vec_free (locator_set_name);
12283 vec_add1 (locator_set_name, 0);
12285 /* Construct the API message */
12286 M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
12288 mp->is_add = is_add;
12289 mp->sw_if_index = ntohl (sw_if_index);
12290 mp->priority = priority;
12291 mp->weight = weight;
12292 clib_memcpy (mp->locator_set_name, locator_set_name,
12293 vec_len (locator_set_name));
12294 vec_free (locator_set_name);
12299 /* Wait for a reply... */
12307 api_lisp_add_del_local_eid (vat_main_t * vam)
12309 unformat_input_t *input = vam->input;
12310 vl_api_lisp_add_del_local_eid_t *mp;
12314 lisp_eid_vat_t _eid, *eid = &_eid;
12315 u8 *locator_set_name = 0;
12316 u8 locator_set_name_set = 0;
12319 /* Parse args required to build the message */
12320 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12322 if (unformat (input, "del"))
12326 else if (unformat (input, "vni %d", &vni))
12330 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
12334 else if (unformat (input, "locator-set %s", &locator_set_name))
12336 locator_set_name_set = 1;
12342 if (locator_set_name_set == 0)
12344 errmsg ("missing locator-set name\n");
12350 errmsg ("EID address not set!");
12351 vec_free (locator_set_name);
12355 if (vec_len (locator_set_name) > 64)
12357 errmsg ("locator-set name too long\n");
12358 vec_free (locator_set_name);
12361 vec_add1 (locator_set_name, 0);
12363 /* Construct the API message */
12364 M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
12366 mp->is_add = is_add;
12367 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
12368 mp->eid_type = eid->type;
12369 mp->prefix_len = eid->len;
12370 mp->vni = clib_host_to_net_u32 (vni);
12371 clib_memcpy (mp->locator_set_name, locator_set_name,
12372 vec_len (locator_set_name));
12374 vec_free (locator_set_name);
12379 /* Wait for a reply... */
12387 /** Used for transferring locators via VPP API */
12388 typedef CLIB_PACKED(struct
12390 u8 is_ip4; /**< is locator an IPv4 address? */
12391 u8 priority; /**< locator priority */
12392 u8 weight; /**< locator weight */
12393 u8 addr[16]; /**< IPv4/IPv6 address */
12398 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
12400 unformat_input_t *input = vam->input;
12401 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
12404 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
12405 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
12406 u8 rmt_eid_set = 0, lcl_eid_set = 0;
12407 u32 action = ~0, p, w;
12408 ip4_address_t rmt_rloc4, lcl_rloc4;
12409 ip6_address_t rmt_rloc6, lcl_rloc6;
12410 rloc_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
12412 memset (&rloc, 0, sizeof (rloc));
12414 /* Parse args required to build the message */
12415 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12417 if (unformat (input, "del"))
12421 else if (unformat (input, "rmt_eid %U", unformat_lisp_eid_vat, rmt_eid))
12425 else if (unformat (input, "lcl_eid %U", unformat_lisp_eid_vat, lcl_eid))
12429 else if (unformat (input, "p %d w %d", &p, &w))
12433 errmsg ("No RLOC configured for setting priority/weight!");
12436 curr_rloc->priority = p;
12437 curr_rloc->weight = w;
12439 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
12440 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
12444 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
12445 rloc.priority = rloc.weight = 0;
12446 vec_add1 (lcl_locs, rloc);
12448 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
12449 vec_add1 (rmt_locs, rloc);
12450 /* priority and weight saved in rmt loc */
12451 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
12453 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
12454 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
12457 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
12458 rloc.priority = rloc.weight = 0;
12459 vec_add1 (lcl_locs, rloc);
12461 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
12462 vec_add1 (rmt_locs, rloc);
12463 /* priority and weight saved in rmt loc */
12464 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
12466 else if (unformat (input, "action %d", &action))
12472 clib_warning ("parse error '%U'", format_unformat_error, input);
12479 errmsg ("remote eid addresses not set\n");
12483 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
12485 errmsg ("eid types don't match\n");
12489 if (0 == rmt_locs && (u32) ~ 0 == action)
12491 errmsg ("action not set for negative mapping\n");
12495 /* Construct the API message */
12496 M (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry);
12498 mp->is_add = is_add;
12499 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
12500 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
12501 mp->eid_type = rmt_eid->type;
12502 mp->rmt_len = rmt_eid->len;
12503 mp->lcl_len = lcl_eid->len;
12504 mp->action = action;
12506 if (0 != rmt_locs && 0 != lcl_locs)
12508 mp->loc_num = vec_len (rmt_locs);
12509 clib_memcpy (mp->lcl_locs, lcl_locs,
12510 (sizeof (rloc_t) * vec_len (lcl_locs)));
12511 clib_memcpy (mp->rmt_locs, rmt_locs,
12512 (sizeof (rloc_t) * vec_len (rmt_locs)));
12514 vec_free (lcl_locs);
12515 vec_free (rmt_locs);
12520 /* Wait for a reply... */
12528 api_lisp_add_del_map_resolver (vat_main_t * vam)
12530 unformat_input_t *input = vam->input;
12531 vl_api_lisp_add_del_map_resolver_t *mp;
12536 ip4_address_t ipv4;
12537 ip6_address_t ipv6;
12539 /* Parse args required to build the message */
12540 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12542 if (unformat (input, "del"))
12546 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
12550 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
12558 if (ipv4_set && ipv6_set)
12560 errmsg ("both eid v4 and v6 addresses set\n");
12564 if (!ipv4_set && !ipv6_set)
12566 errmsg ("eid addresses not set\n");
12570 /* Construct the API message */
12571 M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
12573 mp->is_add = is_add;
12577 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
12582 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
12588 /* Wait for a reply... */
12596 api_lisp_gpe_enable_disable (vat_main_t * vam)
12598 unformat_input_t *input = vam->input;
12599 vl_api_lisp_gpe_enable_disable_t *mp;
12604 /* Parse args required to build the message */
12605 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12607 if (unformat (input, "enable"))
12612 else if (unformat (input, "disable"))
12623 errmsg ("Value not set\n");
12627 /* Construct the API message */
12628 M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
12635 /* Wait for a reply... */
12643 api_lisp_enable_disable (vat_main_t * vam)
12645 unformat_input_t *input = vam->input;
12646 vl_api_lisp_enable_disable_t *mp;
12651 /* Parse args required to build the message */
12652 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12654 if (unformat (input, "enable"))
12659 else if (unformat (input, "disable"))
12669 errmsg ("Value not set\n");
12673 /* Construct the API message */
12674 M (LISP_ENABLE_DISABLE, lisp_enable_disable);
12681 /* Wait for a reply... */
12689 api_show_lisp_map_request_mode (vat_main_t * vam)
12692 vl_api_show_lisp_map_request_mode_t *mp;
12694 M (SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode);
12699 /* wait for reply */
12706 api_lisp_map_request_mode (vat_main_t * vam)
12709 unformat_input_t *input = vam->input;
12710 vl_api_lisp_map_request_mode_t *mp;
12713 /* Parse args required to build the message */
12714 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12716 if (unformat (input, "dst-only"))
12718 else if (unformat (input, "src-dst"))
12722 errmsg ("parse error '%U'", format_unformat_error, input);
12727 M (LISP_MAP_REQUEST_MODE, lisp_map_request_mode);
12734 /* wait for reply */
12742 * Enable/disable LISP proxy ITR.
12744 * @param vam vpp API test context
12745 * @return return code
12748 api_lisp_pitr_set_locator_set (vat_main_t * vam)
12751 u8 ls_name_set = 0;
12752 unformat_input_t *input = vam->input;
12753 vl_api_lisp_pitr_set_locator_set_t *mp;
12757 /* Parse args required to build the message */
12758 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12760 if (unformat (input, "del"))
12762 else if (unformat (input, "locator-set %s", &ls_name))
12766 errmsg ("parse error '%U'", format_unformat_error, input);
12773 errmsg ("locator-set name not set!");
12777 M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set);
12779 mp->is_add = is_add;
12780 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
12781 vec_free (ls_name);
12786 /* wait for reply */
12794 api_show_lisp_pitr (vat_main_t * vam)
12796 vl_api_show_lisp_pitr_t *mp;
12799 if (!vam->json_output)
12801 fformat (vam->ofp, "%=20s\n", "lisp status:");
12804 M (SHOW_LISP_PITR, show_lisp_pitr);
12808 /* Wait for a reply... */
12816 * Add/delete mapping between vni and vrf
12819 api_lisp_eid_table_add_del_map (vat_main_t * vam)
12822 unformat_input_t *input = vam->input;
12823 vl_api_lisp_eid_table_add_del_map_t *mp;
12824 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
12825 u32 vni, vrf, bd_index;
12827 /* Parse args required to build the message */
12828 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12830 if (unformat (input, "del"))
12832 else if (unformat (input, "vrf %d", &vrf))
12834 else if (unformat (input, "bd_index %d", &bd_index))
12836 else if (unformat (input, "vni %d", &vni))
12842 if (!vni_set || (!vrf_set && !bd_index_set))
12844 errmsg ("missing arguments!");
12848 if (vrf_set && bd_index_set)
12850 errmsg ("error: both vrf and bd entered!");
12854 M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
12856 mp->is_add = is_add;
12857 mp->vni = htonl (vni);
12858 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
12859 mp->is_l2 = bd_index_set;
12864 /* wait for reply */
12872 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
12874 u32 *action = va_arg (*args, u32 *);
12877 if (unformat (input, "%s", &s))
12879 if (!strcmp ((char *) s, "no-action"))
12881 else if (!strcmp ((char *) s, "natively-forward"))
12883 else if (!strcmp ((char *) s, "send-map-request"))
12885 else if (!strcmp ((char *) s, "drop"))
12889 clib_warning ("invalid action: '%s'", s);
12901 * Add/del remote mapping to/from LISP control plane
12903 * @param vam vpp API test context
12904 * @return return code
12907 api_lisp_add_del_remote_mapping (vat_main_t * vam)
12909 unformat_input_t *input = vam->input;
12910 vl_api_lisp_add_del_remote_mapping_t *mp;
12913 lisp_eid_vat_t _eid, *eid = &_eid;
12914 lisp_eid_vat_t _seid, *seid = &_seid;
12915 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
12916 u32 action = ~0, p, w, data_len;
12917 ip4_address_t rloc4;
12918 ip6_address_t rloc6;
12919 rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
12921 memset (&rloc, 0, sizeof (rloc));
12923 /* Parse args required to build the message */
12924 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12926 if (unformat (input, "del-all"))
12930 else if (unformat (input, "del"))
12934 else if (unformat (input, "add"))
12938 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
12942 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
12946 else if (unformat (input, "vni %d", &vni))
12950 else if (unformat (input, "p %d w %d", &p, &w))
12954 errmsg ("No RLOC configured for setting priority/weight!");
12957 curr_rloc->priority = p;
12958 curr_rloc->weight = w;
12960 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
12963 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
12964 vec_add1 (rlocs, rloc);
12965 curr_rloc = &rlocs[vec_len (rlocs) - 1];
12967 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
12970 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
12971 vec_add1 (rlocs, rloc);
12972 curr_rloc = &rlocs[vec_len (rlocs) - 1];
12974 else if (unformat (input, "action %U",
12975 unformat_negative_mapping_action, &action))
12981 clib_warning ("parse error '%U'", format_unformat_error, input);
12988 errmsg ("missing params!");
12992 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
12994 errmsg ("no action set for negative map-reply!");
12998 data_len = vec_len (rlocs) * sizeof (rloc_t);
13000 M2 (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping, data_len);
13001 mp->is_add = is_add;
13002 mp->vni = htonl (vni);
13003 mp->action = (u8) action;
13004 mp->is_src_dst = seid_set;
13005 mp->eid_len = eid->len;
13006 mp->seid_len = seid->len;
13007 mp->del_all = del_all;
13008 mp->eid_type = eid->type;
13009 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13010 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
13012 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
13013 clib_memcpy (mp->rlocs, rlocs, data_len);
13019 /* Wait for a reply... */
13027 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
13028 * forwarding entries in data-plane accordingly.
13030 * @param vam vpp API test context
13031 * @return return code
13034 api_lisp_add_del_adjacency (vat_main_t * vam)
13036 unformat_input_t *input = vam->input;
13037 vl_api_lisp_add_del_adjacency_t *mp;
13040 ip4_address_t leid4, reid4;
13041 ip6_address_t leid6, reid6;
13042 u8 reid_mac[6] = { 0 };
13043 u8 leid_mac[6] = { 0 };
13044 u8 reid_type, leid_type;
13045 u32 leid_len = 0, reid_len = 0, len;
13048 leid_type = reid_type = (u8) ~ 0;
13050 /* Parse args required to build the message */
13051 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13053 if (unformat (input, "del"))
13057 else if (unformat (input, "add"))
13061 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
13064 reid_type = 0; /* ipv4 */
13067 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
13070 reid_type = 1; /* ipv6 */
13073 else if (unformat (input, "reid %U", unformat_ethernet_address,
13076 reid_type = 2; /* mac */
13078 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
13081 leid_type = 0; /* ipv4 */
13084 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
13087 leid_type = 1; /* ipv6 */
13090 else if (unformat (input, "leid %U", unformat_ethernet_address,
13093 leid_type = 2; /* mac */
13095 else if (unformat (input, "vni %d", &vni))
13101 errmsg ("parse error '%U'", format_unformat_error, input);
13106 if ((u8) ~ 0 == reid_type)
13108 errmsg ("missing params!");
13112 if (leid_type != reid_type)
13114 errmsg ("remote and local EIDs are of different types!");
13118 M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency);
13119 mp->is_add = is_add;
13120 mp->vni = htonl (vni);
13121 mp->leid_len = leid_len;
13122 mp->reid_len = reid_len;
13123 mp->eid_type = reid_type;
13125 switch (mp->eid_type)
13128 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
13129 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
13132 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
13133 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
13136 clib_memcpy (mp->leid, leid_mac, 6);
13137 clib_memcpy (mp->reid, reid_mac, 6);
13140 errmsg ("unknown EID type %d!", mp->eid_type);
13147 /* Wait for a reply... */
13155 api_lisp_gpe_add_del_iface (vat_main_t * vam)
13157 unformat_input_t *input = vam->input;
13158 vl_api_lisp_gpe_add_del_iface_t *mp;
13160 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
13161 u32 dp_table = 0, vni = 0;
13163 /* Parse args required to build the message */
13164 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13166 if (unformat (input, "up"))
13171 else if (unformat (input, "down"))
13176 else if (unformat (input, "table_id %d", &dp_table))
13180 else if (unformat (input, "bd_id %d", &dp_table))
13185 else if (unformat (input, "vni %d", &vni))
13193 if (action_set == 0)
13195 errmsg ("Action not set\n");
13198 if (dp_table_set == 0 || vni_set == 0)
13200 errmsg ("vni and dp_table must be set\n");
13204 /* Construct the API message */
13205 M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
13207 mp->is_add = is_add;
13208 mp->dp_table = dp_table;
13215 /* Wait for a reply... */
13223 * Add/del map request itr rlocs from LISP control plane and updates
13225 * @param vam vpp API test context
13226 * @return return code
13229 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
13231 unformat_input_t *input = vam->input;
13232 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
13234 u8 *locator_set_name = 0;
13235 u8 locator_set_name_set = 0;
13238 /* Parse args required to build the message */
13239 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13241 if (unformat (input, "del"))
13245 else if (unformat (input, "%_%v%_", &locator_set_name))
13247 locator_set_name_set = 1;
13251 clib_warning ("parse error '%U'", format_unformat_error, input);
13256 if (is_add && !locator_set_name_set)
13258 errmsg ("itr-rloc is not set!");
13262 if (is_add && vec_len (locator_set_name) > 64)
13264 errmsg ("itr-rloc locator-set name too long\n");
13265 vec_free (locator_set_name);
13269 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs);
13270 mp->is_add = is_add;
13273 clib_memcpy (mp->locator_set_name, locator_set_name,
13274 vec_len (locator_set_name));
13278 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
13280 vec_free (locator_set_name);
13285 /* Wait for a reply... */
13293 api_lisp_locator_dump (vat_main_t * vam)
13295 unformat_input_t *input = vam->input;
13296 vl_api_lisp_locator_dump_t *mp;
13298 u8 is_index_set = 0, is_name_set = 0;
13302 /* Parse args required to build the message */
13303 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13305 if (unformat (input, "ls_name %_%v%_", &ls_name))
13309 else if (unformat (input, "ls_index %d", &ls_index))
13315 errmsg ("parse error '%U'", format_unformat_error, input);
13320 if (!is_index_set && !is_name_set)
13322 errmsg ("error: expected one of index or name!\n");
13326 if (is_index_set && is_name_set)
13328 errmsg ("error: only one param expected!\n");
13332 if (vec_len (ls_name) > 62)
13334 errmsg ("error: locator set name too long!");
13338 if (!vam->json_output)
13340 fformat (vam->ofp, "%=16s%=16s%=16s\n", "locator", "priority",
13344 M (LISP_LOCATOR_DUMP, lisp_locator_dump);
13345 mp->is_index_set = is_index_set;
13348 mp->ls_index = clib_host_to_net_u32 (ls_index);
13351 vec_add1 (ls_name, 0);
13352 strncpy ((char *) mp->ls_name, (char *) ls_name,
13353 sizeof (mp->ls_name) - 1);
13359 /* Use a control ping for synchronization */
13361 vl_api_control_ping_t *mp;
13362 M (CONTROL_PING, control_ping);
13365 /* Wait for a reply... */
13373 api_lisp_locator_set_dump (vat_main_t * vam)
13375 vl_api_lisp_locator_set_dump_t *mp;
13376 unformat_input_t *input = vam->input;
13380 /* Parse args required to build the message */
13381 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13383 if (unformat (input, "local"))
13387 else if (unformat (input, "remote"))
13393 errmsg ("parse error '%U'", format_unformat_error, input);
13398 if (!vam->json_output)
13400 fformat (vam->ofp, "%=10s%=15s\n", "ls_index", "ls_name");
13403 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
13405 mp->filter = filter;
13410 /* Use a control ping for synchronization */
13412 vl_api_control_ping_t *mp;
13413 M (CONTROL_PING, control_ping);
13416 /* Wait for a reply... */
13424 api_lisp_eid_table_map_dump (vat_main_t * vam)
13428 unformat_input_t *input = vam->input;
13429 vl_api_lisp_eid_table_map_dump_t *mp;
13432 /* Parse args required to build the message */
13433 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13435 if (unformat (input, "l2"))
13440 else if (unformat (input, "l3"))
13447 errmsg ("parse error '%U'", format_unformat_error, input);
13454 errmsg ("expected one of 'l2' or 'l3' parameter!\n");
13458 if (!vam->json_output)
13460 fformat (vam->ofp, "%=10s%=10s\n", "VNI", is_l2 ? "BD" : "VRF");
13463 M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump);
13469 /* Use a control ping for synchronization */
13471 vl_api_control_ping_t *mp;
13472 M (CONTROL_PING, control_ping);
13475 /* Wait for a reply... */
13483 api_lisp_eid_table_vni_dump (vat_main_t * vam)
13485 vl_api_lisp_eid_table_vni_dump_t *mp;
13488 if (!vam->json_output)
13490 fformat (vam->ofp, "VNI\n");
13493 M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
13498 /* Use a control ping for synchronization */
13500 vl_api_control_ping_t *mp;
13501 M (CONTROL_PING, control_ping);
13504 /* Wait for a reply... */
13512 api_lisp_eid_table_dump (vat_main_t * vam)
13514 unformat_input_t *i = vam->input;
13515 vl_api_lisp_eid_table_dump_t *mp;
13517 struct in_addr ip4;
13518 struct in6_addr ip6;
13520 u8 eid_type = ~0, eid_set = 0;
13521 u32 prefix_length = ~0, t, vni = 0;
13524 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13526 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
13532 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
13538 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
13543 else if (unformat (i, "vni %d", &t))
13547 else if (unformat (i, "local"))
13551 else if (unformat (i, "remote"))
13557 errmsg ("parse error '%U'", format_unformat_error, i);
13562 if (!vam->json_output)
13564 fformat (vam->ofp, "%-35s%-20s%-30s%-20s%-s\n", "EID", "type",
13565 "ls_index", "ttl", "authoritative");
13568 M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump);
13570 mp->filter = filter;
13574 mp->vni = htonl (vni);
13575 mp->eid_type = eid_type;
13579 mp->prefix_length = prefix_length;
13580 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
13583 mp->prefix_length = prefix_length;
13584 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
13587 clib_memcpy (mp->eid, mac, sizeof (mac));
13590 errmsg ("unknown EID type %d!", eid_type);
13598 /* Use a control ping for synchronization */
13600 vl_api_control_ping_t *mp;
13601 M (CONTROL_PING, control_ping);
13605 /* Wait for a reply... */
13613 api_lisp_gpe_tunnel_dump (vat_main_t * vam)
13615 vl_api_lisp_gpe_tunnel_dump_t *mp;
13618 if (!vam->json_output)
13620 fformat (vam->ofp, "%=20s%=30s%=16s%=16s%=16s%=16s"
13621 "%=16s%=16s%=16s%=16s%=16s\n",
13622 "Tunel", "Source", "Destination", "Fib encap", "Fib decap",
13623 "Decap next", "Lisp version", "Flags", "Next protocol",
13624 "ver_res", "res", "iid");
13627 M (LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump);
13631 /* Use a control ping for synchronization */
13633 vl_api_control_ping_t *mp;
13634 M (CONTROL_PING, control_ping);
13637 /* Wait for a reply... */
13645 api_lisp_map_resolver_dump (vat_main_t * vam)
13647 vl_api_lisp_map_resolver_dump_t *mp;
13650 if (!vam->json_output)
13652 fformat (vam->ofp, "%=20s\n", "Map resolver");
13655 M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
13659 /* Use a control ping for synchronization */
13661 vl_api_control_ping_t *mp;
13662 M (CONTROL_PING, control_ping);
13665 /* Wait for a reply... */
13673 api_show_lisp_status (vat_main_t * vam)
13675 vl_api_show_lisp_status_t *mp;
13678 if (!vam->json_output)
13680 fformat (vam->ofp, "%-20s%-16s\n", "lisp status", "locator-set");
13683 M (SHOW_LISP_STATUS, show_lisp_status);
13686 /* Wait for a reply... */
13694 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
13696 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
13699 if (!vam->json_output)
13701 fformat (vam->ofp, "%=20s\n", "itr-rlocs:");
13704 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
13707 /* Wait for a reply... */
13715 api_af_packet_create (vat_main_t * vam)
13717 unformat_input_t *i = vam->input;
13718 vl_api_af_packet_create_t *mp;
13720 u8 *host_if_name = 0;
13722 u8 random_hw_addr = 1;
13724 memset (hw_addr, 0, sizeof (hw_addr));
13726 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13728 if (unformat (i, "name %s", &host_if_name))
13729 vec_add1 (host_if_name, 0);
13730 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
13731 random_hw_addr = 0;
13736 if (!vec_len (host_if_name))
13738 errmsg ("host-interface name must be specified");
13742 if (vec_len (host_if_name) > 64)
13744 errmsg ("host-interface name too long");
13748 M (AF_PACKET_CREATE, af_packet_create);
13750 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
13751 clib_memcpy (mp->hw_addr, hw_addr, 6);
13752 mp->use_random_hw_addr = random_hw_addr;
13753 vec_free (host_if_name);
13756 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
13762 api_af_packet_delete (vat_main_t * vam)
13764 unformat_input_t *i = vam->input;
13765 vl_api_af_packet_delete_t *mp;
13767 u8 *host_if_name = 0;
13769 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13771 if (unformat (i, "name %s", &host_if_name))
13772 vec_add1 (host_if_name, 0);
13777 if (!vec_len (host_if_name))
13779 errmsg ("host-interface name must be specified");
13783 if (vec_len (host_if_name) > 64)
13785 errmsg ("host-interface name too long");
13789 M (AF_PACKET_DELETE, af_packet_delete);
13791 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
13792 vec_free (host_if_name);
13801 api_policer_add_del (vat_main_t * vam)
13803 unformat_input_t *i = vam->input;
13804 vl_api_policer_add_del_t *mp;
13815 u8 color_aware = 0;
13816 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
13818 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
13819 conform_action.dscp = 0;
13820 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
13821 exceed_action.dscp = 0;
13822 violate_action.action_type = SSE2_QOS_ACTION_DROP;
13823 violate_action.dscp = 0;
13825 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13827 if (unformat (i, "del"))
13829 else if (unformat (i, "name %s", &name))
13830 vec_add1 (name, 0);
13831 else if (unformat (i, "cir %u", &cir))
13833 else if (unformat (i, "eir %u", &eir))
13835 else if (unformat (i, "cb %u", &cb))
13837 else if (unformat (i, "eb %u", &eb))
13839 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
13842 else if (unformat (i, "round_type %U", unformat_policer_round_type,
13845 else if (unformat (i, "type %U", unformat_policer_type, &type))
13847 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
13850 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
13853 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
13856 else if (unformat (i, "color-aware"))
13862 if (!vec_len (name))
13864 errmsg ("policer name must be specified");
13868 if (vec_len (name) > 64)
13870 errmsg ("policer name too long");
13874 M (POLICER_ADD_DEL, policer_add_del);
13876 clib_memcpy (mp->name, name, vec_len (name));
13878 mp->is_add = is_add;
13883 mp->rate_type = rate_type;
13884 mp->round_type = round_type;
13886 mp->conform_action_type = conform_action.action_type;
13887 mp->conform_dscp = conform_action.dscp;
13888 mp->exceed_action_type = exceed_action.action_type;
13889 mp->exceed_dscp = exceed_action.dscp;
13890 mp->violate_action_type = violate_action.action_type;
13891 mp->violate_dscp = violate_action.dscp;
13892 mp->color_aware = color_aware;
13901 api_policer_dump (vat_main_t * vam)
13903 unformat_input_t *i = vam->input;
13904 vl_api_policer_dump_t *mp;
13906 u8 *match_name = 0;
13907 u8 match_name_valid = 0;
13909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13911 if (unformat (i, "name %s", &match_name))
13913 vec_add1 (match_name, 0);
13914 match_name_valid = 1;
13920 M (POLICER_DUMP, policer_dump);
13921 mp->match_name_valid = match_name_valid;
13922 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
13923 vec_free (match_name);
13927 /* Use a control ping for synchronization */
13929 vl_api_control_ping_t *mp;
13930 M (CONTROL_PING, control_ping);
13933 /* Wait for a reply... */
13941 api_policer_classify_set_interface (vat_main_t * vam)
13943 unformat_input_t *i = vam->input;
13944 vl_api_policer_classify_set_interface_t *mp;
13947 int sw_if_index_set;
13948 u32 ip4_table_index = ~0;
13949 u32 ip6_table_index = ~0;
13950 u32 l2_table_index = ~0;
13953 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13955 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
13956 sw_if_index_set = 1;
13957 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13958 sw_if_index_set = 1;
13959 else if (unformat (i, "del"))
13961 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13963 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13965 else if (unformat (i, "l2-table %d", &l2_table_index))
13969 clib_warning ("parse error '%U'", format_unformat_error, i);
13974 if (sw_if_index_set == 0)
13976 errmsg ("missing interface name or sw_if_index\n");
13980 M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface);
13982 mp->sw_if_index = ntohl (sw_if_index);
13983 mp->ip4_table_index = ntohl (ip4_table_index);
13984 mp->ip6_table_index = ntohl (ip6_table_index);
13985 mp->l2_table_index = ntohl (l2_table_index);
13986 mp->is_add = is_add;
13995 api_policer_classify_dump (vat_main_t * vam)
13997 unformat_input_t *i = vam->input;
13998 vl_api_policer_classify_dump_t *mp;
14000 u8 type = POLICER_CLASSIFY_N_TABLES;
14002 if (unformat (i, "type %U", unformat_classify_table_type, &type))
14006 errmsg ("classify table type must be specified\n");
14010 if (!vam->json_output)
14012 fformat (vam->ofp, "%10s%20s\n", "Intfc idx", "Classify table");
14015 M (POLICER_CLASSIFY_DUMP, policer_classify_dump);
14020 /* Use a control ping for synchronization */
14022 vl_api_control_ping_t *mp;
14023 M (CONTROL_PING, control_ping);
14026 /* Wait for a reply... */
14034 api_netmap_create (vat_main_t * vam)
14036 unformat_input_t *i = vam->input;
14037 vl_api_netmap_create_t *mp;
14041 u8 random_hw_addr = 1;
14045 memset (hw_addr, 0, sizeof (hw_addr));
14047 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14049 if (unformat (i, "name %s", &if_name))
14050 vec_add1 (if_name, 0);
14051 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14052 random_hw_addr = 0;
14053 else if (unformat (i, "pipe"))
14055 else if (unformat (i, "master"))
14057 else if (unformat (i, "slave"))
14063 if (!vec_len (if_name))
14065 errmsg ("interface name must be specified");
14069 if (vec_len (if_name) > 64)
14071 errmsg ("interface name too long");
14075 M (NETMAP_CREATE, netmap_create);
14077 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
14078 clib_memcpy (mp->hw_addr, hw_addr, 6);
14079 mp->use_random_hw_addr = random_hw_addr;
14080 mp->is_pipe = is_pipe;
14081 mp->is_master = is_master;
14082 vec_free (if_name);
14091 api_netmap_delete (vat_main_t * vam)
14093 unformat_input_t *i = vam->input;
14094 vl_api_netmap_delete_t *mp;
14098 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14100 if (unformat (i, "name %s", &if_name))
14101 vec_add1 (if_name, 0);
14106 if (!vec_len (if_name))
14108 errmsg ("interface name must be specified");
14112 if (vec_len (if_name) > 64)
14114 errmsg ("interface name too long");
14118 M (NETMAP_DELETE, netmap_delete);
14120 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
14121 vec_free (if_name);
14129 static void vl_api_mpls_gre_tunnel_details_t_handler
14130 (vl_api_mpls_gre_tunnel_details_t * mp)
14132 vat_main_t *vam = &vat_main;
14134 i32 len = ntohl (mp->nlabels);
14136 if (mp->l2_only == 0)
14138 fformat (vam->ofp, "[%d]: src %U, dst %U, adj %U/%d, labels ",
14139 ntohl (mp->tunnel_index),
14140 format_ip4_address, &mp->tunnel_src,
14141 format_ip4_address, &mp->tunnel_dst,
14142 format_ip4_address, &mp->intfc_address,
14143 ntohl (mp->mask_width));
14144 for (i = 0; i < len; i++)
14146 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14148 fformat (vam->ofp, "\n");
14149 fformat (vam->ofp, " inner fib index %d, outer fib index %d\n",
14150 ntohl (mp->inner_fib_index), ntohl (mp->outer_fib_index));
14154 fformat (vam->ofp, "[%d]: src %U, dst %U, key %U, labels ",
14155 ntohl (mp->tunnel_index),
14156 format_ip4_address, &mp->tunnel_src,
14157 format_ip4_address, &mp->tunnel_dst,
14158 format_ip4_address, &mp->intfc_address);
14159 for (i = 0; i < len; i++)
14161 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14163 fformat (vam->ofp, "\n");
14164 fformat (vam->ofp, " l2 interface %d, outer fib index %d\n",
14165 ntohl (mp->hw_if_index), ntohl (mp->outer_fib_index));
14169 static void vl_api_mpls_gre_tunnel_details_t_handler_json
14170 (vl_api_mpls_gre_tunnel_details_t * mp)
14172 vat_main_t *vam = &vat_main;
14173 vat_json_node_t *node = NULL;
14174 struct in_addr ip4;
14176 i32 len = ntohl (mp->nlabels);
14178 if (VAT_JSON_ARRAY != vam->json_tree.type)
14180 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14181 vat_json_init_array (&vam->json_tree);
14183 node = vat_json_array_add (&vam->json_tree);
14185 vat_json_init_object (node);
14186 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
14187 clib_memcpy (&ip4, &(mp->intfc_address), sizeof (ip4));
14188 vat_json_object_add_ip4 (node, "intfc_address", ip4);
14189 vat_json_object_add_uint (node, "inner_fib_index",
14190 ntohl (mp->inner_fib_index));
14191 vat_json_object_add_uint (node, "mask_width", ntohl (mp->mask_width));
14192 vat_json_object_add_uint (node, "encap_index", ntohl (mp->encap_index));
14193 vat_json_object_add_uint (node, "hw_if_index", ntohl (mp->hw_if_index));
14194 vat_json_object_add_uint (node, "l2_only", ntohl (mp->l2_only));
14195 clib_memcpy (&ip4, &(mp->tunnel_src), sizeof (ip4));
14196 vat_json_object_add_ip4 (node, "tunnel_src", ip4);
14197 clib_memcpy (&ip4, &(mp->tunnel_dst), sizeof (ip4));
14198 vat_json_object_add_ip4 (node, "tunnel_dst", ip4);
14199 vat_json_object_add_uint (node, "outer_fib_index",
14200 ntohl (mp->outer_fib_index));
14201 vat_json_object_add_uint (node, "label_count", len);
14202 for (i = 0; i < len; i++)
14204 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14209 api_mpls_gre_tunnel_dump (vat_main_t * vam)
14211 vl_api_mpls_gre_tunnel_dump_t *mp;
14215 /* Parse args required to build the message */
14216 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
14218 if (!unformat (vam->input, "tunnel_index %d", &index))
14225 fformat (vam->ofp, " tunnel_index %d\n", index);
14227 M (MPLS_GRE_TUNNEL_DUMP, mpls_gre_tunnel_dump);
14228 mp->tunnel_index = htonl (index);
14231 /* Use a control ping for synchronization */
14233 vl_api_control_ping_t *mp;
14234 M (CONTROL_PING, control_ping);
14240 static void vl_api_mpls_eth_tunnel_details_t_handler
14241 (vl_api_mpls_eth_tunnel_details_t * mp)
14243 vat_main_t *vam = &vat_main;
14245 i32 len = ntohl (mp->nlabels);
14247 fformat (vam->ofp, "[%d]: dst %U, adj %U/%d, labels ",
14248 ntohl (mp->tunnel_index),
14249 format_ethernet_address, &mp->tunnel_dst_mac,
14250 format_ip4_address, &mp->intfc_address, ntohl (mp->mask_width));
14251 for (i = 0; i < len; i++)
14253 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14255 fformat (vam->ofp, "\n");
14256 fformat (vam->ofp, " tx on %d, rx fib index %d\n",
14257 ntohl (mp->tx_sw_if_index), ntohl (mp->inner_fib_index));
14260 static void vl_api_mpls_eth_tunnel_details_t_handler_json
14261 (vl_api_mpls_eth_tunnel_details_t * mp)
14263 vat_main_t *vam = &vat_main;
14264 vat_json_node_t *node = NULL;
14265 struct in_addr ip4;
14267 i32 len = ntohl (mp->nlabels);
14269 if (VAT_JSON_ARRAY != vam->json_tree.type)
14271 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14272 vat_json_init_array (&vam->json_tree);
14274 node = vat_json_array_add (&vam->json_tree);
14276 vat_json_init_object (node);
14277 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
14278 clib_memcpy (&ip4, &(mp->intfc_address), sizeof (ip4));
14279 vat_json_object_add_ip4 (node, "intfc_address", ip4);
14280 vat_json_object_add_uint (node, "inner_fib_index",
14281 ntohl (mp->inner_fib_index));
14282 vat_json_object_add_uint (node, "mask_width", ntohl (mp->mask_width));
14283 vat_json_object_add_uint (node, "encap_index", ntohl (mp->encap_index));
14284 vat_json_object_add_uint (node, "hw_if_index", ntohl (mp->hw_if_index));
14285 vat_json_object_add_uint (node, "l2_only", ntohl (mp->l2_only));
14286 vat_json_object_add_string_copy (node, "tunnel_dst_mac",
14287 format (0, "%U", format_ethernet_address,
14288 &mp->tunnel_dst_mac));
14289 vat_json_object_add_uint (node, "tx_sw_if_index",
14290 ntohl (mp->tx_sw_if_index));
14291 vat_json_object_add_uint (node, "label_count", len);
14292 for (i = 0; i < len; i++)
14294 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14299 api_mpls_eth_tunnel_dump (vat_main_t * vam)
14301 vl_api_mpls_eth_tunnel_dump_t *mp;
14305 /* Parse args required to build the message */
14306 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
14308 if (!unformat (vam->input, "tunnel_index %d", &index))
14315 fformat (vam->ofp, " tunnel_index %d\n", index);
14317 M (MPLS_ETH_TUNNEL_DUMP, mpls_eth_tunnel_dump);
14318 mp->tunnel_index = htonl (index);
14321 /* Use a control ping for synchronization */
14323 vl_api_control_ping_t *mp;
14324 M (CONTROL_PING, control_ping);
14330 static void vl_api_mpls_fib_encap_details_t_handler
14331 (vl_api_mpls_fib_encap_details_t * mp)
14333 vat_main_t *vam = &vat_main;
14335 i32 len = ntohl (mp->nlabels);
14337 fformat (vam->ofp, "table %d, dest %U, label ",
14338 ntohl (mp->fib_index), format_ip4_address, &mp->dest, len);
14339 for (i = 0; i < len; i++)
14341 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14343 fformat (vam->ofp, "\n");
14346 static void vl_api_mpls_fib_encap_details_t_handler_json
14347 (vl_api_mpls_fib_encap_details_t * mp)
14349 vat_main_t *vam = &vat_main;
14350 vat_json_node_t *node = NULL;
14352 i32 len = ntohl (mp->nlabels);
14353 struct in_addr ip4;
14355 if (VAT_JSON_ARRAY != vam->json_tree.type)
14357 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14358 vat_json_init_array (&vam->json_tree);
14360 node = vat_json_array_add (&vam->json_tree);
14362 vat_json_init_object (node);
14363 vat_json_object_add_uint (node, "table", ntohl (mp->fib_index));
14364 vat_json_object_add_uint (node, "entry_index", ntohl (mp->entry_index));
14365 clib_memcpy (&ip4, &(mp->dest), sizeof (ip4));
14366 vat_json_object_add_ip4 (node, "dest", ip4);
14367 vat_json_object_add_uint (node, "s_bit", ntohl (mp->s_bit));
14368 vat_json_object_add_uint (node, "label_count", len);
14369 for (i = 0; i < len; i++)
14371 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14376 api_mpls_fib_encap_dump (vat_main_t * vam)
14378 vl_api_mpls_fib_encap_dump_t *mp;
14381 M (MPLS_FIB_ENCAP_DUMP, mpls_fib_encap_dump);
14384 /* Use a control ping for synchronization */
14386 vl_api_control_ping_t *mp;
14387 M (CONTROL_PING, control_ping);
14393 static void vl_api_mpls_fib_decap_details_t_handler
14394 (vl_api_mpls_fib_decap_details_t * mp)
14396 vat_main_t *vam = &vat_main;
14399 "RX table %d, TX table/intfc %u, swif_tag '%s', label %u, s_bit %u\n",
14400 ntohl (mp->rx_table_id), ntohl (mp->tx_table_id), mp->swif_tag,
14401 ntohl (mp->label), ntohl (mp->s_bit));
14404 static void vl_api_mpls_fib_decap_details_t_handler_json
14405 (vl_api_mpls_fib_decap_details_t * mp)
14407 vat_main_t *vam = &vat_main;
14408 vat_json_node_t *node = NULL;
14409 struct in_addr ip4;
14411 if (VAT_JSON_ARRAY != vam->json_tree.type)
14413 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14414 vat_json_init_array (&vam->json_tree);
14416 node = vat_json_array_add (&vam->json_tree);
14418 vat_json_init_object (node);
14419 vat_json_object_add_uint (node, "table", ntohl (mp->fib_index));
14420 vat_json_object_add_uint (node, "entry_index", ntohl (mp->entry_index));
14421 clib_memcpy (&ip4, &(mp->dest), sizeof (ip4));
14422 vat_json_object_add_ip4 (node, "dest", ip4);
14423 vat_json_object_add_uint (node, "s_bit", ntohl (mp->s_bit));
14424 vat_json_object_add_uint (node, "label", ntohl (mp->label));
14425 vat_json_object_add_uint (node, "rx_table_id", ntohl (mp->rx_table_id));
14426 vat_json_object_add_uint (node, "tx_table_id", ntohl (mp->tx_table_id));
14427 vat_json_object_add_string_copy (node, "swif_tag", mp->swif_tag);
14431 api_mpls_fib_decap_dump (vat_main_t * vam)
14433 vl_api_mpls_fib_decap_dump_t *mp;
14436 M (MPLS_FIB_DECAP_DUMP, mpls_fib_decap_dump);
14439 /* Use a control ping for synchronization */
14441 vl_api_control_ping_t *mp;
14442 M (CONTROL_PING, control_ping);
14449 api_classify_table_ids (vat_main_t * vam)
14451 vl_api_classify_table_ids_t *mp;
14454 /* Construct the API message */
14455 M (CLASSIFY_TABLE_IDS, classify_table_ids);
14465 api_classify_table_by_interface (vat_main_t * vam)
14467 unformat_input_t *input = vam->input;
14468 vl_api_classify_table_by_interface_t *mp;
14471 u32 sw_if_index = ~0;
14472 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14474 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
14476 else if (unformat (input, "sw_if_index %d", &sw_if_index))
14481 if (sw_if_index == ~0)
14483 errmsg ("missing interface name or sw_if_index\n");
14487 /* Construct the API message */
14488 M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
14490 mp->sw_if_index = ntohl (sw_if_index);
14499 api_classify_table_info (vat_main_t * vam)
14501 unformat_input_t *input = vam->input;
14502 vl_api_classify_table_info_t *mp;
14506 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14508 if (unformat (input, "table_id %d", &table_id))
14513 if (table_id == ~0)
14515 errmsg ("missing table id\n");
14519 /* Construct the API message */
14520 M (CLASSIFY_TABLE_INFO, classify_table_info);
14522 mp->table_id = ntohl (table_id);
14531 api_classify_session_dump (vat_main_t * vam)
14533 unformat_input_t *input = vam->input;
14534 vl_api_classify_session_dump_t *mp;
14538 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14540 if (unformat (input, "table_id %d", &table_id))
14545 if (table_id == ~0)
14547 errmsg ("missing table id\n");
14551 /* Construct the API message */
14552 M (CLASSIFY_SESSION_DUMP, classify_session_dump);
14554 mp->table_id = ntohl (table_id);
14557 /* Use a control ping for synchronization */
14559 vl_api_control_ping_t *mp;
14560 M (CONTROL_PING, control_ping);
14569 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
14571 vat_main_t *vam = &vat_main;
14573 fformat (vam->ofp, "collector_address %U, collector_port %d, "
14574 "src_address %U, vrf_id %d, path_mtu %u, "
14575 "template_interval %u, udp_checksum %d\n",
14576 format_ip4_address, mp->collector_address,
14577 ntohs (mp->collector_port),
14578 format_ip4_address, mp->src_address,
14579 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
14580 ntohl (mp->template_interval), mp->udp_checksum);
14583 vam->result_ready = 1;
14587 vl_api_ipfix_exporter_details_t_handler_json
14588 (vl_api_ipfix_exporter_details_t * mp)
14590 vat_main_t *vam = &vat_main;
14591 vat_json_node_t node;
14592 struct in_addr collector_address;
14593 struct in_addr src_address;
14595 vat_json_init_object (&node);
14596 clib_memcpy (&collector_address, &mp->collector_address,
14597 sizeof (collector_address));
14598 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
14599 vat_json_object_add_uint (&node, "collector_port",
14600 ntohs (mp->collector_port));
14601 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
14602 vat_json_object_add_ip4 (&node, "src_address", src_address);
14603 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
14604 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
14605 vat_json_object_add_uint (&node, "template_interval",
14606 ntohl (mp->template_interval));
14607 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
14609 vat_json_print (vam->ofp, &node);
14610 vat_json_free (&node);
14612 vam->result_ready = 1;
14616 api_ipfix_exporter_dump (vat_main_t * vam)
14618 vl_api_ipfix_exporter_dump_t *mp;
14621 /* Construct the API message */
14622 M (IPFIX_EXPORTER_DUMP, ipfix_exporter_dump);
14632 api_ipfix_classify_stream_dump (vat_main_t * vam)
14634 vl_api_ipfix_classify_stream_dump_t *mp;
14637 /* Construct the API message */
14638 M (IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump);
14648 vl_api_ipfix_classify_stream_details_t_handler
14649 (vl_api_ipfix_classify_stream_details_t * mp)
14651 vat_main_t *vam = &vat_main;
14652 fformat (vam->ofp, "domain_id %d, src_port %d\n",
14653 ntohl (mp->domain_id), ntohs (mp->src_port));
14655 vam->result_ready = 1;
14659 vl_api_ipfix_classify_stream_details_t_handler_json
14660 (vl_api_ipfix_classify_stream_details_t * mp)
14662 vat_main_t *vam = &vat_main;
14663 vat_json_node_t node;
14665 vat_json_init_object (&node);
14666 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
14667 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
14669 vat_json_print (vam->ofp, &node);
14670 vat_json_free (&node);
14672 vam->result_ready = 1;
14676 api_ipfix_classify_table_dump (vat_main_t * vam)
14678 vl_api_ipfix_classify_table_dump_t *mp;
14681 if (!vam->json_output)
14683 fformat (vam->ofp, "%15s%15s%20s\n", "table_id", "ip_version",
14684 "transport_protocol");
14687 /* Construct the API message */
14688 M (IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump);
14693 /* Use a control ping for synchronization */
14695 vl_api_control_ping_t *mp;
14696 M (CONTROL_PING, control_ping);
14703 vl_api_ipfix_classify_table_details_t_handler
14704 (vl_api_ipfix_classify_table_details_t * mp)
14706 vat_main_t *vam = &vat_main;
14707 fformat (vam->ofp, "%15d%15d%20d\n", ntohl (mp->table_id), mp->ip_version,
14708 mp->transport_protocol);
14712 vl_api_ipfix_classify_table_details_t_handler_json
14713 (vl_api_ipfix_classify_table_details_t * mp)
14715 vat_json_node_t *node = NULL;
14716 vat_main_t *vam = &vat_main;
14718 if (VAT_JSON_ARRAY != vam->json_tree.type)
14720 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14721 vat_json_init_array (&vam->json_tree);
14724 node = vat_json_array_add (&vam->json_tree);
14725 vat_json_init_object (node);
14727 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
14728 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
14729 vat_json_object_add_uint (node, "transport_protocol",
14730 mp->transport_protocol);
14734 api_pg_create_interface (vat_main_t * vam)
14736 unformat_input_t *input = vam->input;
14737 vl_api_pg_create_interface_t *mp;
14741 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14743 if (unformat (input, "if_id %d", &if_id))
14750 errmsg ("missing pg interface index\n");
14754 /* Construct the API message */
14755 M (PG_CREATE_INTERFACE, pg_create_interface);
14757 mp->interface_id = ntohl (if_id);
14766 api_pg_capture (vat_main_t * vam)
14768 unformat_input_t *input = vam->input;
14769 vl_api_pg_capture_t *mp;
14775 u8 pcap_file_set = 0;
14777 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14779 if (unformat (input, "if_id %d", &if_id))
14781 else if (unformat (input, "pcap %s", &pcap_file))
14783 else if (unformat (input, "count %d", &count))
14785 else if (unformat (input, "disable"))
14792 errmsg ("missing pg interface index\n");
14795 if (pcap_file_set > 0)
14797 if (vec_len (pcap_file) > 255)
14799 errmsg ("pcap file name is too long\n");
14804 u32 name_len = vec_len (pcap_file);
14805 /* Construct the API message */
14806 M (PG_CAPTURE, pg_capture);
14808 mp->interface_id = ntohl (if_id);
14809 mp->is_enabled = enable;
14810 mp->count = ntohl (count);
14811 mp->pcap_name_length = ntohl (name_len);
14812 if (pcap_file_set != 0)
14814 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
14816 vec_free (pcap_file);
14825 api_pg_enable_disable (vat_main_t * vam)
14827 unformat_input_t *input = vam->input;
14828 vl_api_pg_enable_disable_t *mp;
14832 u8 stream_name_set = 0;
14833 u8 *stream_name = 0;
14834 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14836 if (unformat (input, "stream %s", &stream_name))
14837 stream_name_set = 1;
14838 else if (unformat (input, "disable"))
14844 if (stream_name_set > 0)
14846 if (vec_len (stream_name) > 255)
14848 errmsg ("stream name too long\n");
14853 u32 name_len = vec_len (stream_name);
14854 /* Construct the API message */
14855 M (PG_ENABLE_DISABLE, pg_enable_disable);
14857 mp->is_enabled = enable;
14858 if (stream_name_set != 0)
14860 mp->stream_name_length = ntohl (name_len);
14861 clib_memcpy (mp->stream_name, stream_name, name_len);
14863 vec_free (stream_name);
14872 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
14874 unformat_input_t *input = vam->input;
14875 vl_api_ip_source_and_port_range_check_add_del_t *mp;
14878 u16 *low_ports = 0;
14879 u16 *high_ports = 0;
14882 ip4_address_t ip4_addr;
14883 ip6_address_t ip6_addr;
14891 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14893 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
14899 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
14904 else if (unformat (input, "vrf %d", &vrf_id))
14906 else if (unformat (input, "del"))
14908 else if (unformat (input, "port %d", &tmp))
14910 if (tmp == 0 || tmp > 65535)
14912 errmsg ("port %d out of range", tmp);
14916 this_hi = this_low + 1;
14917 vec_add1 (low_ports, this_low);
14918 vec_add1 (high_ports, this_hi);
14920 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
14922 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
14924 errmsg ("incorrect range parameters\n");
14928 /* Note: in debug CLI +1 is added to high before
14929 passing to real fn that does "the work"
14930 (ip_source_and_port_range_check_add_del).
14931 This fn is a wrapper around the binary API fn a
14932 control plane will call, which expects this increment
14933 to have occurred. Hence letting the binary API control
14934 plane fn do the increment for consistency between VAT
14935 and other control planes.
14938 vec_add1 (low_ports, this_low);
14939 vec_add1 (high_ports, this_hi);
14945 if (prefix_set == 0)
14947 errmsg ("<address>/<mask> not specified\n");
14953 errmsg ("VRF ID required, not specified\n");
14960 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
14964 if (vec_len (low_ports) == 0)
14966 errmsg ("At least one port or port range required\n");
14970 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,
14971 ip_source_and_port_range_check_add_del);
14973 mp->is_add = is_add;
14978 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
14983 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
14986 mp->mask_length = length;
14987 mp->number_of_ranges = vec_len (low_ports);
14989 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
14990 vec_free (low_ports);
14992 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
14993 vec_free (high_ports);
14995 mp->vrf_id = ntohl (vrf_id);
15004 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
15006 unformat_input_t *input = vam->input;
15007 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
15009 u32 sw_if_index = ~0;
15011 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
15012 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
15015 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15017 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
15019 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15021 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
15023 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
15025 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
15027 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
15029 else if (unformat (input, "del"))
15035 if (sw_if_index == ~0)
15037 errmsg ("Interface required but not specified\n");
15043 errmsg ("VRF ID required but not specified\n");
15047 if (tcp_out_vrf_id == 0
15048 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
15051 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
15055 /* Construct the API message */
15056 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,
15057 ip_source_and_port_range_check_interface_add_del);
15059 mp->sw_if_index = ntohl (sw_if_index);
15060 mp->is_add = is_add;
15061 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
15062 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
15063 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
15064 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
15069 /* Wait for a reply... */
15074 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
15076 unformat_input_t *i = vam->input;
15077 vl_api_ipsec_gre_add_del_tunnel_t *mp;
15079 u32 local_sa_id = 0;
15080 u32 remote_sa_id = 0;
15081 ip4_address_t src_address;
15082 ip4_address_t dst_address;
15085 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15087 if (unformat (i, "local_sa %d", &local_sa_id))
15089 else if (unformat (i, "remote_sa %d", &remote_sa_id))
15091 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
15093 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
15095 else if (unformat (i, "del"))
15099 clib_warning ("parse error '%U'", format_unformat_error, i);
15104 M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel);
15106 mp->local_sa_id = ntohl (local_sa_id);
15107 mp->remote_sa_id = ntohl (remote_sa_id);
15108 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
15109 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
15110 mp->is_add = is_add;
15119 api_punt (vat_main_t * vam)
15121 unformat_input_t *i = vam->input;
15129 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15131 if (unformat (i, "ip %d", &ipv))
15133 else if (unformat (i, "protocol %d", &protocol))
15135 else if (unformat (i, "port %d", &port))
15137 else if (unformat (i, "del"))
15141 clib_warning ("parse error '%U'", format_unformat_error, i);
15148 mp->is_add = (u8) is_add;
15149 mp->ipv = (u8) ipv;
15150 mp->l4_protocol = (u8) protocol;
15151 mp->l4_port = htons ((u16) port);
15159 static void vl_api_ipsec_gre_tunnel_details_t_handler
15160 (vl_api_ipsec_gre_tunnel_details_t * mp)
15162 vat_main_t *vam = &vat_main;
15164 fformat (vam->ofp, "%11d%15U%15U%14d%14d\n",
15165 ntohl (mp->sw_if_index),
15166 format_ip4_address, &mp->src_address,
15167 format_ip4_address, &mp->dst_address,
15168 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
15171 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
15172 (vl_api_ipsec_gre_tunnel_details_t * mp)
15174 vat_main_t *vam = &vat_main;
15175 vat_json_node_t *node = NULL;
15176 struct in_addr ip4;
15178 if (VAT_JSON_ARRAY != vam->json_tree.type)
15180 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15181 vat_json_init_array (&vam->json_tree);
15183 node = vat_json_array_add (&vam->json_tree);
15185 vat_json_init_object (node);
15186 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15187 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
15188 vat_json_object_add_ip4 (node, "src_address", ip4);
15189 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
15190 vat_json_object_add_ip4 (node, "dst_address", ip4);
15191 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
15192 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
15196 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
15198 unformat_input_t *i = vam->input;
15199 vl_api_ipsec_gre_tunnel_dump_t *mp;
15202 u8 sw_if_index_set = 0;
15204 /* Parse args required to build the message */
15205 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15207 if (unformat (i, "sw_if_index %d", &sw_if_index))
15208 sw_if_index_set = 1;
15213 if (sw_if_index_set == 0)
15218 if (!vam->json_output)
15220 fformat (vam->ofp, "%11s%15s%15s%14s%14s\n",
15221 "sw_if_index", "src_address", "dst_address",
15222 "local_sa_id", "remote_sa_id");
15225 /* Get list of gre-tunnel interfaces */
15226 M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump);
15228 mp->sw_if_index = htonl (sw_if_index);
15232 /* Use a control ping for synchronization */
15234 vl_api_control_ping_t *mp;
15235 M (CONTROL_PING, control_ping);
15242 api_delete_subif (vat_main_t * vam)
15244 unformat_input_t *i = vam->input;
15245 vl_api_delete_subif_t *mp;
15247 u32 sw_if_index = ~0;
15249 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15251 if (unformat (i, "sw_if_index %d", &sw_if_index))
15257 if (sw_if_index == ~0)
15259 errmsg ("missing sw_if_index\n");
15263 /* Construct the API message */
15264 M (DELETE_SUBIF, delete_subif);
15265 mp->sw_if_index = ntohl (sw_if_index);
15271 #define foreach_pbb_vtr_op \
15272 _("disable", L2_VTR_DISABLED) \
15273 _("pop", L2_VTR_POP_2) \
15274 _("push", L2_VTR_PUSH_2)
15277 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
15279 unformat_input_t *i = vam->input;
15280 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
15282 u32 sw_if_index = ~0, vtr_op = ~0;
15283 u16 outer_tag = ~0;
15284 u8 dmac[6], smac[6];
15285 u8 dmac_set = 0, smac_set = 0;
15290 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15292 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
15294 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15296 else if (unformat (i, "vtr_op %d", &vtr_op))
15298 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
15301 else if (unformat (i, "translate_pbb_stag"))
15303 if (unformat (i, "%d", &tmp))
15305 vtr_op = L2_VTR_TRANSLATE_2_1;
15311 ("translate_pbb_stag operation requires outer tag definition\n");
15315 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
15317 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
15319 else if (unformat (i, "sid %d", &sid))
15321 else if (unformat (i, "vlanid %d", &tmp))
15325 clib_warning ("parse error '%U'", format_unformat_error, i);
15330 if ((sw_if_index == ~0) || (vtr_op == ~0))
15332 errmsg ("missing sw_if_index or vtr operation\n");
15335 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
15336 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
15339 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid\n");
15343 M (L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite);
15344 mp->sw_if_index = ntohl (sw_if_index);
15345 mp->vtr_op = ntohl (vtr_op);
15346 mp->outer_tag = ntohs (outer_tag);
15347 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
15348 clib_memcpy (mp->b_smac, smac, sizeof (smac));
15349 mp->b_vlanid = ntohs (vlanid);
15350 mp->i_sid = ntohl (sid);
15359 q_or_quit (vat_main_t * vam)
15361 longjmp (vam->jump_buf, 1);
15362 return 0; /* not so much */
15366 q (vat_main_t * vam)
15368 return q_or_quit (vam);
15372 quit (vat_main_t * vam)
15374 return q_or_quit (vam);
15378 comment (vat_main_t * vam)
15384 cmd_cmp (void *a1, void *a2)
15389 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
15393 help (vat_main_t * vam)
15398 unformat_input_t *i = vam->input;
15401 if (unformat (i, "%s", &name))
15405 vec_add1 (name, 0);
15407 hs = hash_get_mem (vam->help_by_name, name);
15409 fformat (vam->ofp, "usage: %s %s\n", name, hs[0]);
15411 fformat (vam->ofp, "No such msg / command '%s'\n", name);
15416 fformat (vam->ofp, "Help is available for the following:\n");
15419 hash_foreach_pair (p, vam->function_by_name,
15421 vec_add1 (cmds, (u8 *)(p->key));
15425 vec_sort_with_function (cmds, cmd_cmp);
15427 for (j = 0; j < vec_len (cmds); j++)
15428 fformat (vam->ofp, "%s\n", cmds[j]);
15435 set (vat_main_t * vam)
15437 u8 *name = 0, *value = 0;
15438 unformat_input_t *i = vam->input;
15440 if (unformat (i, "%s", &name))
15442 /* The input buffer is a vector, not a string. */
15443 value = vec_dup (i->buffer);
15444 vec_delete (value, i->index, 0);
15445 /* Almost certainly has a trailing newline */
15446 if (value[vec_len (value) - 1] == '\n')
15447 value[vec_len (value) - 1] = 0;
15448 /* Make sure it's a proper string, one way or the other */
15449 vec_add1 (value, 0);
15450 (void) clib_macro_set_value (&vam->macro_main,
15451 (char *) name, (char *) value);
15454 errmsg ("usage: set <name> <value>\n");
15462 unset (vat_main_t * vam)
15466 if (unformat (vam->input, "%s", &name))
15467 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
15468 errmsg ("unset: %s wasn't set\n", name);
15481 macro_sort_cmp (void *a1, void *a2)
15483 macro_sort_t *s1 = a1;
15484 macro_sort_t *s2 = a2;
15486 return strcmp ((char *) (s1->name), (char *) (s2->name));
15490 dump_macro_table (vat_main_t * vam)
15492 macro_sort_t *sort_me = 0, *sm;
15497 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
15499 vec_add2 (sort_me, sm, 1);
15500 sm->name = (u8 *)(p->key);
15501 sm->value = (u8 *) (p->value[0]);
15505 vec_sort_with_function (sort_me, macro_sort_cmp);
15507 if (vec_len (sort_me))
15508 fformat (vam->ofp, "%-15s%s\n", "Name", "Value");
15510 fformat (vam->ofp, "The macro table is empty...\n");
15512 for (i = 0; i < vec_len (sort_me); i++)
15513 fformat (vam->ofp, "%-15s%s\n", sort_me[i].name, sort_me[i].value);
15518 dump_node_table (vat_main_t * vam)
15521 vlib_node_t *node, *next_node;
15523 if (vec_len (vam->graph_nodes) == 0)
15525 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
15529 for (i = 0; i < vec_len (vam->graph_nodes); i++)
15531 node = vam->graph_nodes[i];
15532 fformat (vam->ofp, "[%d] %s\n", i, node->name);
15533 for (j = 0; j < vec_len (node->next_nodes); j++)
15535 if (node->next_nodes[j] != ~0)
15537 next_node = vam->graph_nodes[node->next_nodes[j]];
15538 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
15546 search_node_table (vat_main_t * vam)
15548 unformat_input_t *line_input = vam->input;
15551 vlib_node_t *node, *next_node;
15554 if (vam->graph_node_index_by_name == 0)
15556 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
15560 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15562 if (unformat (line_input, "%s", &node_to_find))
15564 vec_add1 (node_to_find, 0);
15565 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
15568 fformat (vam->ofp, "%s not found...\n", node_to_find);
15571 node = vam->graph_nodes[p[0]];
15572 fformat (vam->ofp, "[%d] %s\n", p[0], node->name);
15573 for (j = 0; j < vec_len (node->next_nodes); j++)
15575 if (node->next_nodes[j] != ~0)
15577 next_node = vam->graph_nodes[node->next_nodes[j]];
15578 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
15585 clib_warning ("parse error '%U'", format_unformat_error,
15591 vec_free (node_to_find);
15600 script (vat_main_t * vam)
15603 char *save_current_file;
15604 unformat_input_t save_input;
15605 jmp_buf save_jump_buf;
15606 u32 save_line_number;
15608 FILE *new_fp, *save_ifp;
15610 if (unformat (vam->input, "%s", &s))
15612 new_fp = fopen ((char *) s, "r");
15615 errmsg ("Couldn't open script file %s\n", s);
15622 errmsg ("Missing script name\n");
15626 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
15627 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
15628 save_ifp = vam->ifp;
15629 save_line_number = vam->input_line_number;
15630 save_current_file = (char *) vam->current_file;
15632 vam->input_line_number = 0;
15634 vam->current_file = s;
15637 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
15638 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
15639 vam->ifp = save_ifp;
15640 vam->input_line_number = save_line_number;
15641 vam->current_file = (u8 *) save_current_file;
15648 echo (vat_main_t * vam)
15650 fformat (vam->ofp, "%v", vam->input->buffer);
15654 /* List of API message constructors, CLI names map to api_xxx */
15655 #define foreach_vpe_api_msg \
15656 _(create_loopback,"[mac <mac-addr>]") \
15657 _(sw_interface_dump,"") \
15658 _(sw_interface_set_flags, \
15659 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
15660 _(sw_interface_add_del_address, \
15661 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
15662 _(sw_interface_set_table, \
15663 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
15664 _(sw_interface_set_vpath, \
15665 "<intfc> | sw_if_index <id> enable | disable") \
15666 _(sw_interface_set_l2_xconnect, \
15667 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
15668 "enable | disable") \
15669 _(sw_interface_set_l2_bridge, \
15670 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
15671 "[shg <split-horizon-group>] [bvi]\n" \
15672 "enable | disable") \
15673 _(sw_interface_set_dpdk_hqos_pipe, \
15674 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
15675 "profile <profile-id>\n") \
15676 _(sw_interface_set_dpdk_hqos_subport, \
15677 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
15678 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
15679 _(sw_interface_set_dpdk_hqos_tctbl, \
15680 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n") \
15681 _(bridge_domain_add_del, \
15682 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n")\
15683 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
15685 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
15687 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
15689 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
15691 "tapname <name> mac <mac-addr> | random-mac") \
15693 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
15695 "<vpp-if-name> | sw_if_index <id>") \
15696 _(sw_interface_tap_dump, "") \
15697 _(ip_add_del_route, \
15698 "<addr>/<mask> via <addr> [vrf <n>]\n" \
15699 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
15700 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
15701 "[multipath] [count <n>]") \
15702 _(proxy_arp_add_del, \
15703 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
15704 _(proxy_arp_intfc_enable_disable, \
15705 "<intfc> | sw_if_index <id> enable | disable") \
15706 _(mpls_add_del_encap, \
15707 "label <n> dst <ip4-addr> [vrf <n>] [del]") \
15708 _(mpls_add_del_decap, \
15709 "label <n> [rx_vrf_id <n>] [tx_vrf_id] [s-bit-clear][del]") \
15710 _(mpls_gre_add_del_tunnel, \
15711 "inner_vrf_id <n> outer_vrf_id <n> src <ip4-address> dst <ip4-address>\n" \
15712 "adj <ip4-address>/<mask-width> [del]") \
15713 _(sw_interface_set_unnumbered, \
15714 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
15715 _(ip_neighbor_add_del, \
15716 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
15717 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
15718 _(reset_vrf, "vrf <id> [ipv6]") \
15719 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
15720 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
15721 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
15722 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
15723 "[outer_vlan_id_any][inner_vlan_id_any]") \
15724 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
15725 _(reset_fib, "vrf <n> [ipv6]") \
15726 _(dhcp_proxy_config, \
15727 "svr <v46-address> src <v46-address>\n" \
15728 "insert-cid <n> [del]") \
15729 _(dhcp_proxy_config_2, \
15730 "svr <v46-address> src <v46-address>\n" \
15731 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
15732 _(dhcp_proxy_set_vss, \
15733 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
15734 _(dhcp_client_config, \
15735 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
15736 _(set_ip_flow_hash, \
15737 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
15738 _(sw_interface_ip6_enable_disable, \
15739 "<intfc> | sw_if_index <id> enable | disable") \
15740 _(sw_interface_ip6_set_link_local_address, \
15741 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
15742 _(sw_interface_ip6nd_ra_prefix, \
15743 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
15744 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
15745 "[nolink] [isno]") \
15746 _(sw_interface_ip6nd_ra_config, \
15747 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
15748 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
15749 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
15750 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
15751 _(l2_patch_add_del, \
15752 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
15753 "enable | disable") \
15754 _(mpls_ethernet_add_del_tunnel, \
15755 "tx <intfc> | tx_sw_if_index <n> dst <mac-addr>\n" \
15756 "adj <ip4-addr>/<mw> dst <mac-addr> [del]") \
15757 _(mpls_ethernet_add_del_tunnel_2, \
15758 "inner_vrf_id <n> outer_vrf_id <n> next-hop <ip4-addr>\n" \
15759 "resolve-attempts <n> resolve-if-needed 0 | 1 [del]") \
15760 _(sr_tunnel_add_del, \
15761 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
15762 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
15763 "[policy <policy_name>]") \
15764 _(sr_policy_add_del, \
15765 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
15766 _(sr_multicast_map_add_del, \
15767 "address [ip6 multicast address] sr-policy [policy name] [del]") \
15768 _(classify_add_del_table, \
15769 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
15770 "[del] mask <mask-value>\n" \
15771 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>") \
15772 _(classify_add_del_session, \
15773 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
15774 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
15775 " [l3 [ip4|ip6]]") \
15776 _(classify_set_interface_ip_table, \
15777 "<intfc> | sw_if_index <nn> table <nn>") \
15778 _(classify_set_interface_l2_tables, \
15779 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
15780 " [other-table <nn>]") \
15781 _(get_node_index, "node <node-name") \
15782 _(add_node_next, "node <node-name> next <next-node-name>") \
15783 _(l2tpv3_create_tunnel, \
15784 "client_address <ip6-addr> our_address <ip6-addr>\n" \
15785 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n"\
15786 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
15787 _(l2tpv3_set_tunnel_cookies, \
15788 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
15789 "[new_remote_cookie <nn>]\n") \
15790 _(l2tpv3_interface_enable_disable, \
15791 "<intfc> | sw_if_index <nn> enable | disable") \
15792 _(l2tpv3_set_lookup_key, \
15793 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
15794 _(sw_if_l2tpv3_tunnel_dump, "") \
15795 _(vxlan_add_del_tunnel, \
15796 "src <ip-addr> dst <ip-addr> vni <vni> [encap-vrf-id <nn>]\n" \
15797 " [decap-next l2|ip4|ip6] [del]") \
15798 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
15799 _(gre_add_del_tunnel, \
15800 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
15801 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
15802 _(l2_fib_clear_table, "") \
15803 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
15804 _(l2_interface_vlan_tag_rewrite, \
15805 "<intfc> | sw_if_index <nn> \n" \
15806 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
15807 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
15808 _(create_vhost_user_if, \
15809 "socket <filename> [server] [renumber <dev_instance>] " \
15810 "[mac <mac_address>]") \
15811 _(modify_vhost_user_if, \
15812 "<intfc> | sw_if_index <nn> socket <filename>\n" \
15813 "[server] [renumber <dev_instance>]") \
15814 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
15815 _(sw_interface_vhost_user_dump, "") \
15816 _(show_version, "") \
15817 _(vxlan_gpe_add_del_tunnel, \
15818 "local <addr> remote <addr> vni <nn>\n" \
15819 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
15820 "[next-ethernet] [next-nsh]\n") \
15821 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
15822 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
15823 _(interface_name_renumber, \
15824 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
15825 _(input_acl_set_interface, \
15826 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
15827 " [l2-table <nn>] [del]") \
15828 _(want_ip4_arp_events, "address <ip4-address> [del]") \
15829 _(want_ip6_nd_events, "address <ip6-address> [del]") \
15830 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
15831 _(ip_dump, "ipv4 | ipv6") \
15832 _(ipsec_spd_add_del, "spd_id <n> [del]") \
15833 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
15835 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
15836 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
15837 " integ_alg <alg> integ_key <hex>") \
15838 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
15839 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
15840 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
15841 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" )\
15842 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
15843 _(ikev2_profile_add_del, "name <profile_name> [del]") \
15844 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
15845 "(auth_data 0x<data> | auth_data <data>)") \
15846 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
15847 "(id_data 0x<data> | id_data <data>) (local|remote)") \
15848 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
15849 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
15850 "(local|remote)") \
15851 _(ikev2_set_local_key, "file <absolute_file_path>") \
15852 _(delete_loopback,"sw_if_index <nn>") \
15853 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
15854 _(map_add_domain, \
15855 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
15856 "ip6-src <ip6addr> " \
15857 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
15858 _(map_del_domain, "index <n>") \
15859 _(map_add_del_rule, \
15860 "index <n> psid <n> dst <ip6addr> [del]") \
15861 _(map_domain_dump, "") \
15862 _(map_rule_dump, "index <map-domain>") \
15863 _(want_interface_events, "enable|disable") \
15864 _(want_stats,"enable|disable") \
15865 _(get_first_msg_id, "client <name>") \
15866 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
15867 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
15868 "fib-id <nn> [ip4][ip6][default]") \
15869 _(get_node_graph, " ") \
15870 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
15871 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
15872 _(ioam_disable, "") \
15873 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
15874 " sw_if_index <sw_if_index> p <priority> " \
15875 "w <weight>] [del]") \
15876 _(lisp_add_del_locator, "locator-set <locator_name> " \
15877 "iface <intf> | sw_if_index <sw_if_index> " \
15878 "p <priority> w <weight> [del]") \
15879 _(lisp_add_del_local_eid,"vni <vni> eid " \
15880 "<ipv4|ipv6>/<prefix> | <L2 address> " \
15881 "locator-set <locator_name> [del]") \
15882 _(lisp_gpe_add_del_fwd_entry, "rmt_eid <eid> [lcl_eid <eid>] vni <vni>" \
15883 "dp_table <table> loc-pair <lcl_loc> <rmt_loc> ... [del]") \
15884 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
15885 _(lisp_gpe_enable_disable, "enable|disable") \
15886 _(lisp_enable_disable, "enable|disable") \
15887 _(lisp_gpe_add_del_iface, "up|down") \
15888 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
15890 "rloc <locator> p <prio> " \
15891 "w <weight> [rloc <loc> ... ] " \
15892 "action <action> [del-all]") \
15893 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
15895 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
15896 _(lisp_map_request_mode, "src-dst|dst-only") \
15897 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
15898 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
15899 _(lisp_locator_set_dump, "[local | remote]") \
15900 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
15901 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
15902 "[local] | [remote]") \
15903 _(lisp_eid_table_vni_dump, "") \
15904 _(lisp_eid_table_map_dump, "l2|l3") \
15905 _(lisp_gpe_tunnel_dump, "") \
15906 _(lisp_map_resolver_dump, "") \
15907 _(show_lisp_status, "") \
15908 _(lisp_get_map_request_itr_rlocs, "") \
15909 _(show_lisp_pitr, "") \
15910 _(show_lisp_map_request_mode, "") \
15911 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
15912 _(af_packet_delete, "name <host interface name>") \
15913 _(policer_add_del, "name <policer name> <params> [del]") \
15914 _(policer_dump, "[name <policer name>]") \
15915 _(policer_classify_set_interface, \
15916 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
15917 " [l2-table <nn>] [del]") \
15918 _(policer_classify_dump, "type [ip4|ip6|l2]") \
15919 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
15920 "[master|slave]") \
15921 _(netmap_delete, "name <interface name>") \
15922 _(mpls_gre_tunnel_dump, "tunnel_index <tunnel-id>") \
15923 _(mpls_eth_tunnel_dump, "tunnel_index <tunnel-id>") \
15924 _(mpls_fib_encap_dump, "") \
15925 _(mpls_fib_decap_dump, "") \
15926 _(classify_table_ids, "") \
15927 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
15928 _(classify_table_info, "table_id <nn>") \
15929 _(classify_session_dump, "table_id <nn>") \
15930 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
15931 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
15932 "[template_interval <nn>] [udp_checksum]") \
15933 _(ipfix_exporter_dump, "") \
15934 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
15935 _(ipfix_classify_stream_dump, "") \
15936 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]")\
15937 _(ipfix_classify_table_dump, "") \
15938 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
15939 _(pg_create_interface, "if_id <nn>") \
15940 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
15941 _(pg_enable_disable, "[stream <id>] disable") \
15942 _(ip_source_and_port_range_check_add_del, \
15943 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
15944 _(ip_source_and_port_range_check_interface_add_del, \
15945 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
15946 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
15947 _(ipsec_gre_add_del_tunnel, \
15948 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
15949 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
15950 _(delete_subif,"sub_sw_if_index <nn> sub_if_id <nn>") \
15951 _(l2_interface_pbb_tag_rewrite, \
15952 "<intfc> | sw_if_index <nn> \n" \
15953 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
15954 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
15955 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]")
15957 /* List of command functions, CLI names map directly to functions */
15958 #define foreach_cli_function \
15959 _(comment, "usage: comment <ignore-rest-of-line>") \
15960 _(dump_interface_table, "usage: dump_interface_table") \
15961 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
15962 _(dump_ipv4_table, "usage: dump_ipv4_table") \
15963 _(dump_ipv6_table, "usage: dump_ipv6_table") \
15964 _(dump_stats_table, "usage: dump_stats_table") \
15965 _(dump_macro_table, "usage: dump_macro_table ") \
15966 _(dump_node_table, "usage: dump_node_table") \
15967 _(echo, "usage: echo <message>") \
15968 _(exec, "usage: exec <vpe-debug-CLI-command>") \
15969 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
15970 _(help, "usage: help") \
15971 _(q, "usage: quit") \
15972 _(quit, "usage: quit") \
15973 _(search_node_table, "usage: search_node_table <name>...") \
15974 _(set, "usage: set <variable-name> <value>") \
15975 _(script, "usage: script <file-name>") \
15976 _(unset, "usage: unset <variable-name>")
15979 static void vl_api_##n##_t_handler_uni \
15980 (vl_api_##n##_t * mp) \
15982 vat_main_t * vam = &vat_main; \
15983 if (vam->json_output) { \
15984 vl_api_##n##_t_handler_json(mp); \
15986 vl_api_##n##_t_handler(mp); \
15989 foreach_vpe_api_reply_msg;
15993 vat_api_hookup (vat_main_t * vam)
15996 vl_msg_api_set_handlers(VL_API_##N, #n, \
15997 vl_api_##n##_t_handler_uni, \
15999 vl_api_##n##_t_endian, \
16000 vl_api_##n##_t_print, \
16001 sizeof(vl_api_##n##_t), 1);
16002 foreach_vpe_api_reply_msg;
16005 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
16007 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
16009 vam->function_by_name = hash_create_string (0, sizeof (uword));
16011 vam->help_by_name = hash_create_string (0, sizeof (uword));
16013 /* API messages we can send */
16014 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
16015 foreach_vpe_api_msg;
16019 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
16020 foreach_vpe_api_msg;
16023 /* CLI functions */
16024 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
16025 foreach_cli_function;
16029 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
16030 foreach_cli_function;
16034 #undef vl_api_version
16035 #define vl_api_version(n,v) static u32 vpe_api_version = v;
16036 #include <vpp-api/vpe.api.h>
16037 #undef vl_api_version
16040 vl_client_add_api_signatures (vl_api_memclnt_create_t * mp)
16043 * Send the main API signature in slot 0. This bit of code must
16044 * match the checks in ../vpe/api/api.c: vl_msg_api_version_check().
16046 mp->api_versions[0] = clib_host_to_net_u32 (vpe_api_version);
16050 * fd.io coding-style-patch-verification: ON
16053 * eval: (c-set-style "gnu")