2 *------------------------------------------------------------------
5 * Copyright (c) 2014 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-gre/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 vl_api_show_lisp_pitr_reply_t_handler (vl_api_show_lisp_pitr_reply_t * mp)
2717 vat_main_t *vam = &vat_main;
2718 i32 retval = ntohl (mp->retval);
2722 fformat (vam->ofp, "%-20s%-16s\n",
2723 mp->status ? "enabled" : "disabled",
2724 mp->status ? (char *) mp->locator_set_name : "");
2727 vam->retval = retval;
2728 vam->result_ready = 1;
2732 vl_api_show_lisp_pitr_reply_t_handler_json (vl_api_show_lisp_pitr_reply_t *
2735 vat_main_t *vam = &vat_main;
2736 vat_json_node_t node;
2739 status = format (0, "%s", mp->status ? "enabled" : "disabled");
2740 vec_add1 (status, 0);
2742 vat_json_init_object (&node);
2743 vat_json_object_add_string_copy (&node, "status", status);
2746 vat_json_object_add_string_copy (&node, "locator_set",
2747 mp->locator_set_name);
2752 vat_json_print (vam->ofp, &node);
2753 vat_json_free (&node);
2755 vam->retval = ntohl (mp->retval);
2756 vam->result_ready = 1;
2760 format_policer_type (u8 * s, va_list * va)
2762 u32 i = va_arg (*va, u32);
2764 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
2765 s = format (s, "1r2c");
2766 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
2767 s = format (s, "1r3c");
2768 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
2769 s = format (s, "2r3c-2698");
2770 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
2771 s = format (s, "2r3c-4115");
2772 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
2773 s = format (s, "2r3c-mef5cf1");
2775 s = format (s, "ILLEGAL");
2780 format_policer_rate_type (u8 * s, va_list * va)
2782 u32 i = va_arg (*va, u32);
2784 if (i == SSE2_QOS_RATE_KBPS)
2785 s = format (s, "kbps");
2786 else if (i == SSE2_QOS_RATE_PPS)
2787 s = format (s, "pps");
2789 s = format (s, "ILLEGAL");
2794 format_policer_round_type (u8 * s, va_list * va)
2796 u32 i = va_arg (*va, u32);
2798 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
2799 s = format (s, "closest");
2800 else if (i == SSE2_QOS_ROUND_TO_UP)
2801 s = format (s, "up");
2802 else if (i == SSE2_QOS_ROUND_TO_DOWN)
2803 s = format (s, "down");
2805 s = format (s, "ILLEGAL");
2810 format_policer_action_type (u8 * s, va_list * va)
2812 u32 i = va_arg (*va, u32);
2814 if (i == SSE2_QOS_ACTION_DROP)
2815 s = format (s, "drop");
2816 else if (i == SSE2_QOS_ACTION_TRANSMIT)
2817 s = format (s, "transmit");
2818 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2819 s = format (s, "mark-and-transmit");
2821 s = format (s, "ILLEGAL");
2826 format_dscp (u8 * s, va_list * va)
2828 u32 i = va_arg (*va, u32);
2833 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
2837 return format (s, "ILLEGAL");
2839 s = format (s, "%s", t);
2844 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
2846 vat_main_t *vam = &vat_main;
2847 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
2849 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2850 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
2852 conform_dscp_str = format (0, "");
2854 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2855 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
2857 exceed_dscp_str = format (0, "");
2859 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2860 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
2862 violate_dscp_str = format (0, "");
2864 fformat (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
2865 "rate type %U, round type %U, %s rate, %s color-aware, "
2866 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
2867 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
2868 "conform action %U%s, exceed action %U%s, violate action %U%s\n",
2870 format_policer_type, mp->type,
2873 clib_net_to_host_u64 (mp->cb),
2874 clib_net_to_host_u64 (mp->eb),
2875 format_policer_rate_type, mp->rate_type,
2876 format_policer_round_type, mp->round_type,
2877 mp->single_rate ? "single" : "dual",
2878 mp->color_aware ? "is" : "not",
2879 ntohl (mp->cir_tokens_per_period),
2880 ntohl (mp->pir_tokens_per_period),
2882 ntohl (mp->current_limit),
2883 ntohl (mp->current_bucket),
2884 ntohl (mp->extended_limit),
2885 ntohl (mp->extended_bucket),
2886 clib_net_to_host_u64 (mp->last_update_time),
2887 format_policer_action_type, mp->conform_action_type,
2889 format_policer_action_type, mp->exceed_action_type,
2891 format_policer_action_type, mp->violate_action_type,
2894 vec_free (conform_dscp_str);
2895 vec_free (exceed_dscp_str);
2896 vec_free (violate_dscp_str);
2899 static void vl_api_policer_details_t_handler_json
2900 (vl_api_policer_details_t * mp)
2902 vat_main_t *vam = &vat_main;
2903 vat_json_node_t *node;
2904 u8 *rate_type_str, *round_type_str, *type_str;
2905 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
2907 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
2909 format (0, "%U", format_policer_round_type, mp->round_type);
2910 type_str = format (0, "%U", format_policer_type, mp->type);
2911 conform_action_str = format (0, "%U", format_policer_action_type,
2912 mp->conform_action_type);
2913 exceed_action_str = format (0, "%U", format_policer_action_type,
2914 mp->exceed_action_type);
2915 violate_action_str = format (0, "%U", format_policer_action_type,
2916 mp->violate_action_type);
2918 if (VAT_JSON_ARRAY != vam->json_tree.type)
2920 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2921 vat_json_init_array (&vam->json_tree);
2923 node = vat_json_array_add (&vam->json_tree);
2925 vat_json_init_object (node);
2926 vat_json_object_add_string_copy (node, "name", mp->name);
2927 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
2928 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
2929 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
2930 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
2931 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
2932 vat_json_object_add_string_copy (node, "round_type", round_type_str);
2933 vat_json_object_add_string_copy (node, "type", type_str);
2934 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
2935 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
2936 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
2937 vat_json_object_add_uint (node, "cir_tokens_per_period",
2938 ntohl (mp->cir_tokens_per_period));
2939 vat_json_object_add_uint (node, "eir_tokens_per_period",
2940 ntohl (mp->pir_tokens_per_period));
2941 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
2942 vat_json_object_add_uint (node, "current_bucket",
2943 ntohl (mp->current_bucket));
2944 vat_json_object_add_uint (node, "extended_limit",
2945 ntohl (mp->extended_limit));
2946 vat_json_object_add_uint (node, "extended_bucket",
2947 ntohl (mp->extended_bucket));
2948 vat_json_object_add_uint (node, "last_update_time",
2949 ntohl (mp->last_update_time));
2950 vat_json_object_add_string_copy (node, "conform_action",
2951 conform_action_str);
2952 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2954 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
2955 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
2956 vec_free (dscp_str);
2958 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
2959 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2961 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
2962 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
2963 vec_free (dscp_str);
2965 vat_json_object_add_string_copy (node, "violate_action",
2966 violate_action_str);
2967 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2969 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
2970 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
2971 vec_free (dscp_str);
2974 vec_free (rate_type_str);
2975 vec_free (round_type_str);
2976 vec_free (type_str);
2977 vec_free (conform_action_str);
2978 vec_free (exceed_action_str);
2979 vec_free (violate_action_str);
2983 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
2986 vat_main_t *vam = &vat_main;
2987 int i, count = ntohl (mp->count);
2990 fformat (vam->ofp, "classify table ids (%d) : ", count);
2991 for (i = 0; i < count; i++)
2993 fformat (vam->ofp, "%d", ntohl (mp->ids[i]));
2994 fformat (vam->ofp, (i < count - 1) ? "," : "\n");
2996 vam->retval = ntohl (mp->retval);
2997 vam->result_ready = 1;
3001 vl_api_classify_table_ids_reply_t_handler_json
3002 (vl_api_classify_table_ids_reply_t * mp)
3004 vat_main_t *vam = &vat_main;
3005 int i, count = ntohl (mp->count);
3009 vat_json_node_t node;
3011 vat_json_init_object (&node);
3012 for (i = 0; i < count; i++)
3014 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3016 vat_json_print (vam->ofp, &node);
3017 vat_json_free (&node);
3019 vam->retval = ntohl (mp->retval);
3020 vam->result_ready = 1;
3024 vl_api_classify_table_by_interface_reply_t_handler
3025 (vl_api_classify_table_by_interface_reply_t * mp)
3027 vat_main_t *vam = &vat_main;
3030 table_id = ntohl (mp->l2_table_id);
3032 fformat (vam->ofp, "l2 table id : %d\n", table_id);
3034 fformat (vam->ofp, "l2 table id : No input ACL tables configured\n");
3035 table_id = ntohl (mp->ip4_table_id);
3037 fformat (vam->ofp, "ip4 table id : %d\n", table_id);
3039 fformat (vam->ofp, "ip4 table id : No input ACL tables configured\n");
3040 table_id = ntohl (mp->ip6_table_id);
3042 fformat (vam->ofp, "ip6 table id : %d\n", table_id);
3044 fformat (vam->ofp, "ip6 table id : No input ACL tables configured\n");
3045 vam->retval = ntohl (mp->retval);
3046 vam->result_ready = 1;
3050 vl_api_classify_table_by_interface_reply_t_handler_json
3051 (vl_api_classify_table_by_interface_reply_t * mp)
3053 vat_main_t *vam = &vat_main;
3054 vat_json_node_t node;
3056 vat_json_init_object (&node);
3058 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3059 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3060 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3062 vat_json_print (vam->ofp, &node);
3063 vat_json_free (&node);
3065 vam->retval = ntohl (mp->retval);
3066 vam->result_ready = 1;
3069 static void vl_api_policer_add_del_reply_t_handler
3070 (vl_api_policer_add_del_reply_t * mp)
3072 vat_main_t *vam = &vat_main;
3073 i32 retval = ntohl (mp->retval);
3074 if (vam->async_mode)
3076 vam->async_errors += (retval < 0);
3080 vam->retval = retval;
3081 vam->result_ready = 1;
3082 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3084 * Note: this is just barely thread-safe, depends on
3085 * the main thread spinning waiting for an answer...
3087 errmsg ("policer index %d\n", ntohl (mp->policer_index));
3091 static void vl_api_policer_add_del_reply_t_handler_json
3092 (vl_api_policer_add_del_reply_t * mp)
3094 vat_main_t *vam = &vat_main;
3095 vat_json_node_t node;
3097 vat_json_init_object (&node);
3098 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3099 vat_json_object_add_uint (&node, "policer_index",
3100 ntohl (mp->policer_index));
3102 vat_json_print (vam->ofp, &node);
3103 vat_json_free (&node);
3105 vam->retval = ntohl (mp->retval);
3106 vam->result_ready = 1;
3109 /* Format hex dump. */
3111 format_hex_bytes (u8 * s, va_list * va)
3113 u8 *bytes = va_arg (*va, u8 *);
3114 int n_bytes = va_arg (*va, int);
3117 /* Print short or long form depending on byte count. */
3118 uword short_form = n_bytes <= 32;
3119 uword indent = format_get_indent (s);
3124 for (i = 0; i < n_bytes; i++)
3126 if (!short_form && (i % 32) == 0)
3127 s = format (s, "%08x: ", i);
3128 s = format (s, "%02x", bytes[i]);
3129 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3130 s = format (s, "\n%U", format_white_space, indent);
3137 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3140 vat_main_t *vam = &vat_main;
3141 i32 retval = ntohl (mp->retval);
3144 fformat (vam->ofp, "classify table info :\n");
3145 fformat (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d\n",
3146 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3147 ntohl (mp->miss_next_index));
3148 fformat (vam->ofp, "nbuckets: %d skip: %d match: %d\n",
3149 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3150 ntohl (mp->match_n_vectors));
3151 fformat (vam->ofp, "mask: %U\n", format_hex_bytes, mp->mask,
3152 ntohl (mp->mask_length));
3154 vam->retval = retval;
3155 vam->result_ready = 1;
3159 vl_api_classify_table_info_reply_t_handler_json
3160 (vl_api_classify_table_info_reply_t * mp)
3162 vat_main_t *vam = &vat_main;
3163 vat_json_node_t node;
3165 i32 retval = ntohl (mp->retval);
3168 vat_json_init_object (&node);
3170 vat_json_object_add_int (&node, "sessions",
3171 ntohl (mp->active_sessions));
3172 vat_json_object_add_int (&node, "nexttbl",
3173 ntohl (mp->next_table_index));
3174 vat_json_object_add_int (&node, "nextnode",
3175 ntohl (mp->miss_next_index));
3176 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3177 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3178 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3179 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3180 ntohl (mp->mask_length), 0);
3181 vat_json_object_add_string_copy (&node, "mask", s);
3183 vat_json_print (vam->ofp, &node);
3184 vat_json_free (&node);
3186 vam->retval = ntohl (mp->retval);
3187 vam->result_ready = 1;
3191 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3194 vat_main_t *vam = &vat_main;
3196 fformat (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3197 ntohl (mp->hit_next_index), ntohl (mp->advance),
3198 ntohl (mp->opaque_index));
3199 fformat (vam->ofp, "mask: %U\n", format_hex_bytes, mp->match,
3200 ntohl (mp->match_length));
3204 vl_api_classify_session_details_t_handler_json
3205 (vl_api_classify_session_details_t * mp)
3207 vat_main_t *vam = &vat_main;
3208 vat_json_node_t *node = NULL;
3210 if (VAT_JSON_ARRAY != vam->json_tree.type)
3212 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3213 vat_json_init_array (&vam->json_tree);
3215 node = vat_json_array_add (&vam->json_tree);
3217 vat_json_init_object (node);
3218 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3219 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3220 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3222 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3224 vat_json_object_add_string_copy (node, "match", s);
3227 static void vl_api_pg_create_interface_reply_t_handler
3228 (vl_api_pg_create_interface_reply_t * mp)
3230 vat_main_t *vam = &vat_main;
3232 vam->retval = ntohl (mp->retval);
3233 vam->result_ready = 1;
3236 static void vl_api_pg_create_interface_reply_t_handler_json
3237 (vl_api_pg_create_interface_reply_t * mp)
3239 vat_main_t *vam = &vat_main;
3240 vat_json_node_t node;
3242 i32 retval = ntohl (mp->retval);
3245 vat_json_init_object (&node);
3247 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3249 vat_json_print (vam->ofp, &node);
3250 vat_json_free (&node);
3252 vam->retval = ntohl (mp->retval);
3253 vam->result_ready = 1;
3256 static void vl_api_policer_classify_details_t_handler
3257 (vl_api_policer_classify_details_t * mp)
3259 vat_main_t *vam = &vat_main;
3261 fformat (vam->ofp, "%10d%20d\n", ntohl (mp->sw_if_index),
3262 ntohl (mp->table_index));
3265 static void vl_api_policer_classify_details_t_handler_json
3266 (vl_api_policer_classify_details_t * mp)
3268 vat_main_t *vam = &vat_main;
3269 vat_json_node_t *node;
3271 if (VAT_JSON_ARRAY != vam->json_tree.type)
3273 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3274 vat_json_init_array (&vam->json_tree);
3276 node = vat_json_array_add (&vam->json_tree);
3278 vat_json_init_object (node);
3279 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3280 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3283 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3284 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3286 vat_main_t *vam = &vat_main;
3287 i32 retval = ntohl (mp->retval);
3288 if (vam->async_mode)
3290 vam->async_errors += (retval < 0);
3294 vam->retval = retval;
3295 vam->sw_if_index = ntohl (mp->sw_if_index);
3296 vam->result_ready = 1;
3300 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3301 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3303 vat_main_t *vam = &vat_main;
3304 vat_json_node_t node;
3306 vat_json_init_object (&node);
3307 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3308 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3310 vat_json_print (vam->ofp, &node);
3311 vat_json_free (&node);
3313 vam->retval = ntohl (mp->retval);
3314 vam->result_ready = 1;
3317 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3318 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3319 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3320 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3323 * Generate boilerplate reply handlers, which
3324 * dig the return value out of the xxx_reply_t API message,
3325 * stick it into vam->retval, and set vam->result_ready
3327 * Could also do this by pointing N message decode slots at
3328 * a single function, but that could break in subtle ways.
3331 #define foreach_standard_reply_retval_handler \
3332 _(sw_interface_set_flags_reply) \
3333 _(sw_interface_add_del_address_reply) \
3334 _(sw_interface_set_table_reply) \
3335 _(sw_interface_set_vpath_reply) \
3336 _(sw_interface_set_l2_bridge_reply) \
3337 _(bridge_domain_add_del_reply) \
3338 _(sw_interface_set_l2_xconnect_reply) \
3339 _(l2fib_add_del_reply) \
3340 _(ip_add_del_route_reply) \
3341 _(proxy_arp_add_del_reply) \
3342 _(proxy_arp_intfc_enable_disable_reply) \
3343 _(mpls_add_del_encap_reply) \
3344 _(mpls_add_del_decap_reply) \
3345 _(mpls_ethernet_add_del_tunnel_2_reply) \
3346 _(sw_interface_set_unnumbered_reply) \
3347 _(ip_neighbor_add_del_reply) \
3348 _(reset_vrf_reply) \
3349 _(oam_add_del_reply) \
3350 _(reset_fib_reply) \
3351 _(dhcp_proxy_config_reply) \
3352 _(dhcp_proxy_config_2_reply) \
3353 _(dhcp_proxy_set_vss_reply) \
3354 _(dhcp_client_config_reply) \
3355 _(set_ip_flow_hash_reply) \
3356 _(sw_interface_ip6_enable_disable_reply) \
3357 _(sw_interface_ip6_set_link_local_address_reply) \
3358 _(sw_interface_ip6nd_ra_prefix_reply) \
3359 _(sw_interface_ip6nd_ra_config_reply) \
3360 _(set_arp_neighbor_limit_reply) \
3361 _(l2_patch_add_del_reply) \
3362 _(sr_tunnel_add_del_reply) \
3363 _(sr_policy_add_del_reply) \
3364 _(sr_multicast_map_add_del_reply) \
3365 _(classify_add_del_session_reply) \
3366 _(classify_set_interface_ip_table_reply) \
3367 _(classify_set_interface_l2_tables_reply) \
3368 _(l2tpv3_set_tunnel_cookies_reply) \
3369 _(l2tpv3_interface_enable_disable_reply) \
3370 _(l2tpv3_set_lookup_key_reply) \
3371 _(l2_fib_clear_table_reply) \
3372 _(l2_interface_efp_filter_reply) \
3373 _(l2_interface_vlan_tag_rewrite_reply) \
3374 _(modify_vhost_user_if_reply) \
3375 _(delete_vhost_user_if_reply) \
3376 _(want_ip4_arp_events_reply) \
3377 _(want_ip6_nd_events_reply) \
3378 _(input_acl_set_interface_reply) \
3379 _(ipsec_spd_add_del_reply) \
3380 _(ipsec_interface_add_del_spd_reply) \
3381 _(ipsec_spd_add_del_entry_reply) \
3382 _(ipsec_sad_add_del_entry_reply) \
3383 _(ipsec_sa_set_key_reply) \
3384 _(ikev2_profile_add_del_reply) \
3385 _(ikev2_profile_set_auth_reply) \
3386 _(ikev2_profile_set_id_reply) \
3387 _(ikev2_profile_set_ts_reply) \
3388 _(ikev2_set_local_key_reply) \
3389 _(delete_loopback_reply) \
3390 _(bd_ip_mac_add_del_reply) \
3391 _(map_del_domain_reply) \
3392 _(map_add_del_rule_reply) \
3393 _(want_interface_events_reply) \
3394 _(want_stats_reply) \
3395 _(cop_interface_enable_disable_reply) \
3396 _(cop_whitelist_enable_disable_reply) \
3397 _(sw_interface_clear_stats_reply) \
3398 _(ioam_enable_reply) \
3399 _(ioam_disable_reply) \
3400 _(lisp_add_del_locator_reply) \
3401 _(lisp_add_del_local_eid_reply) \
3402 _(lisp_add_del_remote_mapping_reply) \
3403 _(lisp_add_del_adjacency_reply) \
3404 _(lisp_gpe_add_del_fwd_entry_reply) \
3405 _(lisp_add_del_map_resolver_reply) \
3406 _(lisp_gpe_enable_disable_reply) \
3407 _(lisp_gpe_add_del_iface_reply) \
3408 _(lisp_enable_disable_reply) \
3409 _(lisp_pitr_set_locator_set_reply) \
3410 _(lisp_add_del_map_request_itr_rlocs_reply) \
3411 _(lisp_eid_table_add_del_map_reply) \
3412 _(vxlan_gpe_add_del_tunnel_reply) \
3413 _(af_packet_delete_reply) \
3414 _(policer_classify_set_interface_reply) \
3415 _(netmap_create_reply) \
3416 _(netmap_delete_reply) \
3417 _(set_ipfix_exporter_reply) \
3418 _(set_ipfix_classify_stream_reply) \
3419 _(ipfix_classify_table_add_del_reply) \
3420 _(pg_capture_reply) \
3421 _(pg_enable_disable_reply) \
3422 _(ip_source_and_port_range_check_add_del_reply) \
3423 _(ip_source_and_port_range_check_interface_add_del_reply)\
3424 _(delete_subif_reply)
3427 static void vl_api_##n##_t_handler \
3428 (vl_api_##n##_t * mp) \
3430 vat_main_t * vam = &vat_main; \
3431 i32 retval = ntohl(mp->retval); \
3432 if (vam->async_mode) { \
3433 vam->async_errors += (retval < 0); \
3435 vam->retval = retval; \
3436 vam->result_ready = 1; \
3439 foreach_standard_reply_retval_handler;
3443 static void vl_api_##n##_t_handler_json \
3444 (vl_api_##n##_t * mp) \
3446 vat_main_t * vam = &vat_main; \
3447 vat_json_node_t node; \
3448 vat_json_init_object(&node); \
3449 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3450 vat_json_print(vam->ofp, &node); \
3451 vam->retval = ntohl(mp->retval); \
3452 vam->result_ready = 1; \
3454 foreach_standard_reply_retval_handler;
3458 * Table of message reply handlers, must include boilerplate handlers
3462 #define foreach_vpe_api_reply_msg \
3463 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3464 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3465 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
3466 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3467 _(CONTROL_PING_REPLY, control_ping_reply) \
3468 _(CLI_REPLY, cli_reply) \
3469 _(CLI_INBAND_REPLY, cli_inband_reply) \
3470 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
3471 sw_interface_add_del_address_reply) \
3472 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
3473 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
3474 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
3475 sw_interface_set_l2_xconnect_reply) \
3476 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
3477 sw_interface_set_l2_bridge_reply) \
3478 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
3479 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
3480 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
3481 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
3482 _(L2_FLAGS_REPLY, l2_flags_reply) \
3483 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
3484 _(TAP_CONNECT_REPLY, tap_connect_reply) \
3485 _(TAP_MODIFY_REPLY, tap_modify_reply) \
3486 _(TAP_DELETE_REPLY, tap_delete_reply) \
3487 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
3488 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
3489 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
3490 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
3491 proxy_arp_intfc_enable_disable_reply) \
3492 _(MPLS_ADD_DEL_ENCAP_REPLY, mpls_add_del_encap_reply) \
3493 _(MPLS_ADD_DEL_DECAP_REPLY, mpls_add_del_decap_reply) \
3494 _(MPLS_GRE_ADD_DEL_TUNNEL_REPLY, mpls_gre_add_del_tunnel_reply) \
3495 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_REPLY, \
3496 mpls_ethernet_add_del_tunnel_reply) \
3497 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_2_REPLY, \
3498 mpls_ethernet_add_del_tunnel_2_reply) \
3499 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
3500 sw_interface_set_unnumbered_reply) \
3501 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
3502 _(RESET_VRF_REPLY, reset_vrf_reply) \
3503 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
3504 _(CREATE_SUBIF_REPLY, create_subif_reply) \
3505 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
3506 _(RESET_FIB_REPLY, reset_fib_reply) \
3507 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
3508 _(DHCP_PROXY_CONFIG_2_REPLY, dhcp_proxy_config_2_reply) \
3509 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
3510 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
3511 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
3512 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
3513 sw_interface_ip6_enable_disable_reply) \
3514 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
3515 sw_interface_ip6_set_link_local_address_reply) \
3516 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
3517 sw_interface_ip6nd_ra_prefix_reply) \
3518 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
3519 sw_interface_ip6nd_ra_config_reply) \
3520 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
3521 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
3522 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
3523 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
3524 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
3525 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
3526 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
3527 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
3528 classify_set_interface_ip_table_reply) \
3529 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
3530 classify_set_interface_l2_tables_reply) \
3531 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
3532 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
3533 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
3534 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
3535 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
3536 l2tpv3_interface_enable_disable_reply) \
3537 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
3538 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
3539 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
3540 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
3541 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
3542 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
3543 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
3544 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
3545 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
3546 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
3547 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
3548 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
3549 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
3550 _(SHOW_VERSION_REPLY, show_version_reply) \
3551 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
3552 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
3553 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
3554 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
3555 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
3556 _(IP4_ARP_EVENT, ip4_arp_event) \
3557 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
3558 _(IP6_ND_EVENT, ip6_nd_event) \
3559 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
3560 _(IP_ADDRESS_DETAILS, ip_address_details) \
3561 _(IP_DETAILS, ip_details) \
3562 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
3563 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
3564 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
3565 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
3566 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
3567 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
3568 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
3569 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
3570 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
3571 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
3572 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
3573 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
3574 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
3575 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
3576 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
3577 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
3578 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
3579 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
3580 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
3581 _(MAP_DOMAIN_DETAILS, map_domain_details) \
3582 _(MAP_RULE_DETAILS, map_rule_details) \
3583 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
3584 _(WANT_STATS_REPLY, want_stats_reply) \
3585 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
3586 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
3587 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
3588 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
3589 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
3590 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
3591 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
3592 _(LISP_ADD_DEL_LOCATOR_SET_REPLY, lisp_add_del_locator_set_reply) \
3593 _(LISP_ADD_DEL_LOCATOR_REPLY, lisp_add_del_locator_reply) \
3594 _(LISP_ADD_DEL_LOCAL_EID_REPLY, lisp_add_del_local_eid_reply) \
3595 _(LISP_ADD_DEL_REMOTE_MAPPING_REPLY, lisp_add_del_remote_mapping_reply) \
3596 _(LISP_ADD_DEL_ADJACENCY_REPLY, lisp_add_del_adjacency_reply) \
3597 _(LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY, lisp_gpe_add_del_fwd_entry_reply) \
3598 _(LISP_ADD_DEL_MAP_RESOLVER_REPLY, lisp_add_del_map_resolver_reply) \
3599 _(LISP_GPE_ENABLE_DISABLE_REPLY, lisp_gpe_enable_disable_reply) \
3600 _(LISP_ENABLE_DISABLE_REPLY, lisp_enable_disable_reply) \
3601 _(LISP_PITR_SET_LOCATOR_SET_REPLY, lisp_pitr_set_locator_set_reply) \
3602 _(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \
3603 _(LISP_GPE_ADD_DEL_IFACE_REPLY, lisp_gpe_add_del_iface_reply) \
3604 _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \
3605 _(LISP_LOCATOR_DETAILS, lisp_locator_details) \
3606 _(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \
3607 _(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \
3608 _(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \
3609 _(LISP_GPE_TUNNEL_DETAILS, lisp_gpe_tunnel_details) \
3610 _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
3611 _(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
3612 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
3613 lisp_add_del_map_request_itr_rlocs_reply) \
3614 _(LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
3615 lisp_get_map_request_itr_rlocs_reply) \
3616 _(SHOW_LISP_PITR_REPLY, show_lisp_pitr_reply) \
3617 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
3618 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
3619 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
3620 _(POLICER_DETAILS, policer_details) \
3621 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
3622 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
3623 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
3624 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
3625 _(MPLS_GRE_TUNNEL_DETAILS, mpls_gre_tunnel_details) \
3626 _(MPLS_ETH_TUNNEL_DETAILS, mpls_eth_tunnel_details) \
3627 _(MPLS_FIB_ENCAP_DETAILS, mpls_fib_encap_details) \
3628 _(MPLS_FIB_DECAP_DETAILS, mpls_fib_decap_details) \
3629 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
3630 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
3631 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
3632 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
3633 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
3634 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
3635 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
3636 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
3637 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
3638 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
3639 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
3640 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
3641 _(PG_CAPTURE_REPLY, pg_capture_reply) \
3642 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
3643 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
3644 ip_source_and_port_range_check_add_del_reply) \
3645 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
3646 ip_source_and_port_range_check_interface_add_del_reply) \
3647 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
3648 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
3649 _(DELETE_SUBIF_REPLY, delete_subif_reply)
3651 /* M: construct, but don't yet send a message */
3655 vam->result_ready = 0; \
3656 mp = vl_msg_api_alloc(sizeof(*mp)); \
3657 memset (mp, 0, sizeof (*mp)); \
3658 mp->_vl_msg_id = ntohs (VL_API_##T); \
3659 mp->client_index = vam->my_client_index; \
3664 vam->result_ready = 0; \
3665 mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
3666 memset (mp, 0, sizeof (*mp)); \
3667 mp->_vl_msg_id = ntohs (VL_API_##T); \
3668 mp->client_index = vam->my_client_index; \
3672 /* S: send a message */
3673 #define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
3675 /* W: wait for results, with timeout */
3678 timeout = vat_time_now (vam) + 1.0; \
3680 while (vat_time_now (vam) < timeout) { \
3681 if (vam->result_ready == 1) { \
3682 return (vam->retval); \
3688 /* W2: wait for results, with timeout */
3691 timeout = vat_time_now (vam) + 1.0; \
3693 while (vat_time_now (vam) < timeout) { \
3694 if (vam->result_ready == 1) { \
3696 return (vam->retval); \
3709 #define STR_VTR_OP_CASE(op) \
3710 case L2_VTR_ ## op: \
3714 str_vtr_op (u32 vtr_op)
3718 STR_VTR_OP_CASE (DISABLED);
3719 STR_VTR_OP_CASE (PUSH_1);
3720 STR_VTR_OP_CASE (PUSH_2);
3721 STR_VTR_OP_CASE (POP_1);
3722 STR_VTR_OP_CASE (POP_2);
3723 STR_VTR_OP_CASE (TRANSLATE_1_1);
3724 STR_VTR_OP_CASE (TRANSLATE_1_2);
3725 STR_VTR_OP_CASE (TRANSLATE_2_1);
3726 STR_VTR_OP_CASE (TRANSLATE_2_2);
3733 dump_sub_interface_table (vat_main_t * vam)
3735 const sw_interface_subif_t *sub = NULL;
3737 if (vam->json_output)
3740 ("JSON output supported only for VPE API calls and dump_stats_table");
3745 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s\n",
3746 "Interface", "sw_if_index",
3747 "sub id", "dot1ad", "tags", "outer id",
3748 "inner id", "exact", "default", "outer any", "inner any");
3750 vec_foreach (sub, vam->sw_if_subif_table)
3753 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d\n",
3754 sub->interface_name,
3756 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
3757 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
3758 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
3759 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
3760 if (sub->vtr_op != L2_VTR_DISABLED)
3763 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
3764 "tag1: %d tag2: %d ]\n",
3765 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
3766 sub->vtr_tag1, sub->vtr_tag2);
3774 name_sort_cmp (void *a1, void *a2)
3776 name_sort_t *n1 = a1;
3777 name_sort_t *n2 = a2;
3779 return strcmp ((char *) n1->name, (char *) n2->name);
3783 dump_interface_table (vat_main_t * vam)
3786 name_sort_t *nses = 0, *ns;
3788 if (vam->json_output)
3791 ("JSON output supported only for VPE API calls and dump_stats_table");
3796 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
3798 vec_add2 (nses, ns, 1);
3799 ns->name = (u8 *)(p->key);
3800 ns->value = (u32) p->value[0];
3804 vec_sort_with_function (nses, name_sort_cmp);
3806 fformat (vam->ofp, "%-25s%-15s\n", "Interface", "sw_if_index");
3807 vec_foreach (ns, nses)
3809 fformat (vam->ofp, "%-25s%-15d\n", ns->name, ns->value);
3816 dump_ip_table (vat_main_t * vam, int is_ipv6)
3818 const ip_details_t *det = NULL;
3819 const ip_address_details_t *address = NULL;
3822 fformat (vam->ofp, "%-12s\n", "sw_if_index");
3824 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
3831 fformat (vam->ofp, "%-12d\n", i);
3833 " %-30s%-13s\n", "Address", "Prefix length");
3838 vec_foreach (address, det->addr)
3842 is_ipv6 ? format_ip6_address : format_ip4_address,
3843 address->ip, address->prefix_length);
3851 dump_ipv4_table (vat_main_t * vam)
3853 if (vam->json_output)
3856 ("JSON output supported only for VPE API calls and dump_stats_table");
3860 return dump_ip_table (vam, 0);
3864 dump_ipv6_table (vat_main_t * vam)
3866 if (vam->json_output)
3869 ("JSON output supported only for VPE API calls and dump_stats_table");
3873 return dump_ip_table (vam, 1);
3877 counter_type_to_str (u8 counter_type, u8 is_combined)
3881 switch (counter_type)
3883 case VNET_INTERFACE_COUNTER_DROP:
3885 case VNET_INTERFACE_COUNTER_PUNT:
3887 case VNET_INTERFACE_COUNTER_IP4:
3889 case VNET_INTERFACE_COUNTER_IP6:
3891 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
3893 case VNET_INTERFACE_COUNTER_RX_MISS:
3895 case VNET_INTERFACE_COUNTER_RX_ERROR:
3897 case VNET_INTERFACE_COUNTER_TX_ERROR:
3900 return "INVALID-COUNTER-TYPE";
3905 switch (counter_type)
3907 case VNET_INTERFACE_COUNTER_RX:
3909 case VNET_INTERFACE_COUNTER_TX:
3912 return "INVALID-COUNTER-TYPE";
3918 dump_stats_table (vat_main_t * vam)
3920 vat_json_node_t node;
3921 vat_json_node_t *msg_array;
3922 vat_json_node_t *msg;
3923 vat_json_node_t *counter_array;
3924 vat_json_node_t *counter;
3925 interface_counter_t c;
3927 ip4_fib_counter_t *c4;
3928 ip6_fib_counter_t *c6;
3931 if (!vam->json_output)
3933 clib_warning ("dump_stats_table supported only in JSON format");
3937 vat_json_init_object (&node);
3939 /* interface counters */
3940 msg_array = vat_json_object_add (&node, "interface_counters");
3941 vat_json_init_array (msg_array);
3942 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
3944 msg = vat_json_array_add (msg_array);
3945 vat_json_init_object (msg);
3946 vat_json_object_add_string_copy (msg, "vnet_counter_type",
3947 (u8 *) counter_type_to_str (i, 0));
3948 vat_json_object_add_int (msg, "is_combined", 0);
3949 counter_array = vat_json_object_add (msg, "data");
3950 vat_json_init_array (counter_array);
3951 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
3953 packets = vam->simple_interface_counters[i][j];
3954 vat_json_array_add_uint (counter_array, packets);
3957 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
3959 msg = vat_json_array_add (msg_array);
3960 vat_json_init_object (msg);
3961 vat_json_object_add_string_copy (msg, "vnet_counter_type",
3962 (u8 *) counter_type_to_str (i, 1));
3963 vat_json_object_add_int (msg, "is_combined", 1);
3964 counter_array = vat_json_object_add (msg, "data");
3965 vat_json_init_array (counter_array);
3966 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
3968 c = vam->combined_interface_counters[i][j];
3969 counter = vat_json_array_add (counter_array);
3970 vat_json_init_object (counter);
3971 vat_json_object_add_uint (counter, "packets", c.packets);
3972 vat_json_object_add_uint (counter, "bytes", c.bytes);
3976 /* ip4 fib counters */
3977 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
3978 vat_json_init_array (msg_array);
3979 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
3981 msg = vat_json_array_add (msg_array);
3982 vat_json_init_object (msg);
3983 vat_json_object_add_uint (msg, "vrf_id",
3984 vam->ip4_fib_counters_vrf_id_by_index[i]);
3985 counter_array = vat_json_object_add (msg, "c");
3986 vat_json_init_array (counter_array);
3987 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
3989 counter = vat_json_array_add (counter_array);
3990 vat_json_init_object (counter);
3991 c4 = &vam->ip4_fib_counters[i][j];
3992 vat_json_object_add_ip4 (counter, "address", c4->address);
3993 vat_json_object_add_uint (counter, "address_length",
3994 c4->address_length);
3995 vat_json_object_add_uint (counter, "packets", c4->packets);
3996 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4000 /* ip6 fib counters */
4001 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4002 vat_json_init_array (msg_array);
4003 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4005 msg = vat_json_array_add (msg_array);
4006 vat_json_init_object (msg);
4007 vat_json_object_add_uint (msg, "vrf_id",
4008 vam->ip6_fib_counters_vrf_id_by_index[i]);
4009 counter_array = vat_json_object_add (msg, "c");
4010 vat_json_init_array (counter_array);
4011 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4013 counter = vat_json_array_add (counter_array);
4014 vat_json_init_object (counter);
4015 c6 = &vam->ip6_fib_counters[i][j];
4016 vat_json_object_add_ip6 (counter, "address", c6->address);
4017 vat_json_object_add_uint (counter, "address_length",
4018 c6->address_length);
4019 vat_json_object_add_uint (counter, "packets", c6->packets);
4020 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4024 vat_json_print (vam->ofp, &node);
4025 vat_json_free (&node);
4031 exec (vat_main_t * vam)
4033 api_main_t *am = &api_main;
4034 vl_api_cli_request_t *mp;
4038 unformat_input_t *i = vam->input;
4040 if (vec_len (i->buffer) == 0)
4043 if (vam->exec_mode == 0 && unformat (i, "mode"))
4048 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4055 M (CLI_REQUEST, cli_request);
4058 * Copy cmd into shared memory.
4059 * In order for the CLI command to work, it
4060 * must be a vector ending in \n, not a C-string ending
4063 pthread_mutex_lock (&am->vlib_rp->mutex);
4064 oldheap = svm_push_data_heap (am->vlib_rp);
4066 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4067 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4069 svm_pop_heap (oldheap);
4070 pthread_mutex_unlock (&am->vlib_rp->mutex);
4072 mp->cmd_in_shmem = (u64) cmd;
4074 timeout = vat_time_now (vam) + 10.0;
4076 while (vat_time_now (vam) < timeout)
4078 if (vam->result_ready == 1)
4081 if (vam->shmem_result != NULL)
4082 fformat (vam->ofp, "%s", vam->shmem_result);
4083 pthread_mutex_lock (&am->vlib_rp->mutex);
4084 oldheap = svm_push_data_heap (am->vlib_rp);
4086 free_me = (u8 *) vam->shmem_result;
4089 svm_pop_heap (oldheap);
4090 pthread_mutex_unlock (&am->vlib_rp->mutex);
4098 * Future replacement of exec() that passes CLI buffers directly in
4099 * the API messages instead of an additional shared memory area.
4102 exec_inband (vat_main_t * vam)
4104 vl_api_cli_inband_t *mp;
4106 unformat_input_t *i = vam->input;
4108 if (vec_len (i->buffer) == 0)
4111 if (vam->exec_mode == 0 && unformat (i, "mode"))
4116 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4123 * In order for the CLI command to work, it
4124 * must be a vector ending in \n, not a C-string ending
4127 u32 len = vec_len (vam->input->buffer);
4128 M2 (CLI_INBAND, cli_inband, len);
4129 clib_memcpy (mp->cmd, vam->input->buffer, len);
4130 mp->length = htonl (len);
4133 W2 (fformat (vam->ofp, "%s", vam->cmd_reply));
4137 api_create_loopback (vat_main_t * vam)
4139 unformat_input_t *i = vam->input;
4140 vl_api_create_loopback_t *mp;
4145 memset (mac_address, 0, sizeof (mac_address));
4147 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4149 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4155 /* Construct the API message */
4156 M (CREATE_LOOPBACK, create_loopback);
4158 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4165 api_delete_loopback (vat_main_t * vam)
4167 unformat_input_t *i = vam->input;
4168 vl_api_delete_loopback_t *mp;
4170 u32 sw_if_index = ~0;
4172 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4174 if (unformat (i, "sw_if_index %d", &sw_if_index))
4180 if (sw_if_index == ~0)
4182 errmsg ("missing sw_if_index\n");
4186 /* Construct the API message */
4187 M (DELETE_LOOPBACK, delete_loopback);
4188 mp->sw_if_index = ntohl (sw_if_index);
4195 api_want_stats (vat_main_t * vam)
4197 unformat_input_t *i = vam->input;
4198 vl_api_want_stats_t *mp;
4202 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4204 if (unformat (i, "enable"))
4206 else if (unformat (i, "disable"))
4214 errmsg ("missing enable|disable\n");
4218 M (WANT_STATS, want_stats);
4219 mp->enable_disable = enable;
4226 api_want_interface_events (vat_main_t * vam)
4228 unformat_input_t *i = vam->input;
4229 vl_api_want_interface_events_t *mp;
4233 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4235 if (unformat (i, "enable"))
4237 else if (unformat (i, "disable"))
4245 errmsg ("missing enable|disable\n");
4249 M (WANT_INTERFACE_EVENTS, want_interface_events);
4250 mp->enable_disable = enable;
4252 vam->interface_event_display = enable;
4259 /* Note: non-static, called once to set up the initial intfc table */
4261 api_sw_interface_dump (vat_main_t * vam)
4263 vl_api_sw_interface_dump_t *mp;
4266 name_sort_t *nses = 0, *ns;
4267 sw_interface_subif_t *sub = NULL;
4269 /* Toss the old name table */
4271 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4273 vec_add2 (nses, ns, 1);
4274 ns->name = (u8 *)(p->key);
4275 ns->value = (u32) p->value[0];
4279 hash_free (vam->sw_if_index_by_interface_name);
4281 vec_foreach (ns, nses) vec_free (ns->name);
4285 vec_foreach (sub, vam->sw_if_subif_table)
4287 vec_free (sub->interface_name);
4289 vec_free (vam->sw_if_subif_table);
4291 /* recreate the interface name hash table */
4292 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4294 /* Get list of ethernets */
4295 M (SW_INTERFACE_DUMP, sw_interface_dump);
4296 mp->name_filter_valid = 1;
4297 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4300 /* and local / loopback interfaces */
4301 M (SW_INTERFACE_DUMP, sw_interface_dump);
4302 mp->name_filter_valid = 1;
4303 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4307 /* and vxlan-gpe tunnel interfaces */
4308 M (SW_INTERFACE_DUMP, sw_interface_dump);
4309 mp->name_filter_valid = 1;
4310 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4311 sizeof (mp->name_filter) - 1);
4314 /* and vxlan tunnel interfaces */
4315 M (SW_INTERFACE_DUMP, sw_interface_dump);
4316 mp->name_filter_valid = 1;
4317 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4320 /* and host (af_packet) interfaces */
4321 M (SW_INTERFACE_DUMP, sw_interface_dump);
4322 mp->name_filter_valid = 1;
4323 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4326 /* and l2tpv3 tunnel interfaces */
4327 M (SW_INTERFACE_DUMP, sw_interface_dump);
4328 mp->name_filter_valid = 1;
4329 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4330 sizeof (mp->name_filter) - 1);
4333 /* and GRE tunnel interfaces */
4334 M (SW_INTERFACE_DUMP, sw_interface_dump);
4335 mp->name_filter_valid = 1;
4336 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4339 /* and LISP-GPE interfaces */
4340 M (SW_INTERFACE_DUMP, sw_interface_dump);
4341 mp->name_filter_valid = 1;
4342 strncpy ((char *) mp->name_filter, "lisp_gpe",
4343 sizeof (mp->name_filter) - 1);
4346 /* and IPSEC tunnel interfaces */
4347 M (SW_INTERFACE_DUMP, sw_interface_dump);
4348 mp->name_filter_valid = 1;
4349 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4352 /* Use a control ping for synchronization */
4354 vl_api_control_ping_t *mp;
4355 M (CONTROL_PING, control_ping);
4362 api_sw_interface_set_flags (vat_main_t * vam)
4364 unformat_input_t *i = vam->input;
4365 vl_api_sw_interface_set_flags_t *mp;
4368 u8 sw_if_index_set = 0;
4369 u8 admin_up = 0, link_up = 0;
4371 /* Parse args required to build the message */
4372 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4374 if (unformat (i, "admin-up"))
4376 else if (unformat (i, "admin-down"))
4378 else if (unformat (i, "link-up"))
4380 else if (unformat (i, "link-down"))
4382 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4383 sw_if_index_set = 1;
4384 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4385 sw_if_index_set = 1;
4390 if (sw_if_index_set == 0)
4392 errmsg ("missing interface name or sw_if_index\n");
4396 /* Construct the API message */
4397 M (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags);
4398 mp->sw_if_index = ntohl (sw_if_index);
4399 mp->admin_up_down = admin_up;
4400 mp->link_up_down = link_up;
4405 /* Wait for a reply, return the good/bad news... */
4410 api_sw_interface_clear_stats (vat_main_t * vam)
4412 unformat_input_t *i = vam->input;
4413 vl_api_sw_interface_clear_stats_t *mp;
4416 u8 sw_if_index_set = 0;
4418 /* Parse args required to build the message */
4419 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4421 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4422 sw_if_index_set = 1;
4423 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4424 sw_if_index_set = 1;
4429 /* Construct the API message */
4430 M (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats);
4432 if (sw_if_index_set == 1)
4433 mp->sw_if_index = ntohl (sw_if_index);
4435 mp->sw_if_index = ~0;
4440 /* Wait for a reply, return the good/bad news... */
4445 api_sw_interface_add_del_address (vat_main_t * vam)
4447 unformat_input_t *i = vam->input;
4448 vl_api_sw_interface_add_del_address_t *mp;
4451 u8 sw_if_index_set = 0;
4452 u8 is_add = 1, del_all = 0;
4453 u32 address_length = 0;
4454 u8 v4_address_set = 0;
4455 u8 v6_address_set = 0;
4456 ip4_address_t v4address;
4457 ip6_address_t v6address;
4459 /* Parse args required to build the message */
4460 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4462 if (unformat (i, "del-all"))
4464 else if (unformat (i, "del"))
4466 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4467 sw_if_index_set = 1;
4468 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4469 sw_if_index_set = 1;
4470 else if (unformat (i, "%U/%d",
4471 unformat_ip4_address, &v4address, &address_length))
4473 else if (unformat (i, "%U/%d",
4474 unformat_ip6_address, &v6address, &address_length))
4480 if (sw_if_index_set == 0)
4482 errmsg ("missing interface name or sw_if_index\n");
4485 if (v4_address_set && v6_address_set)
4487 errmsg ("both v4 and v6 addresses set\n");
4490 if (!v4_address_set && !v6_address_set && !del_all)
4492 errmsg ("no addresses set\n");
4496 /* Construct the API message */
4497 M (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address);
4499 mp->sw_if_index = ntohl (sw_if_index);
4500 mp->is_add = is_add;
4501 mp->del_all = del_all;
4505 clib_memcpy (mp->address, &v6address, sizeof (v6address));
4509 clib_memcpy (mp->address, &v4address, sizeof (v4address));
4511 mp->address_length = address_length;
4516 /* Wait for a reply, return good/bad news */
4521 api_sw_interface_set_table (vat_main_t * vam)
4523 unformat_input_t *i = vam->input;
4524 vl_api_sw_interface_set_table_t *mp;
4526 u32 sw_if_index, vrf_id = 0;
4527 u8 sw_if_index_set = 0;
4530 /* Parse args required to build the message */
4531 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4533 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4534 sw_if_index_set = 1;
4535 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4536 sw_if_index_set = 1;
4537 else if (unformat (i, "vrf %d", &vrf_id))
4539 else if (unformat (i, "ipv6"))
4545 if (sw_if_index_set == 0)
4547 errmsg ("missing interface name or sw_if_index\n");
4551 /* Construct the API message */
4552 M (SW_INTERFACE_SET_TABLE, sw_interface_set_table);
4554 mp->sw_if_index = ntohl (sw_if_index);
4555 mp->is_ipv6 = is_ipv6;
4556 mp->vrf_id = ntohl (vrf_id);
4561 /* Wait for a reply... */
4566 api_sw_interface_set_vpath (vat_main_t * vam)
4568 unformat_input_t *i = vam->input;
4569 vl_api_sw_interface_set_vpath_t *mp;
4571 u32 sw_if_index = 0;
4572 u8 sw_if_index_set = 0;
4575 /* Parse args required to build the message */
4576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4578 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4579 sw_if_index_set = 1;
4580 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4581 sw_if_index_set = 1;
4582 else if (unformat (i, "enable"))
4584 else if (unformat (i, "disable"))
4590 if (sw_if_index_set == 0)
4592 errmsg ("missing interface name or sw_if_index\n");
4596 /* Construct the API message */
4597 M (SW_INTERFACE_SET_VPATH, sw_interface_set_vpath);
4599 mp->sw_if_index = ntohl (sw_if_index);
4600 mp->enable = is_enable;
4605 /* Wait for a reply... */
4610 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
4612 unformat_input_t *i = vam->input;
4613 vl_api_sw_interface_set_l2_xconnect_t *mp;
4616 u8 rx_sw_if_index_set = 0;
4618 u8 tx_sw_if_index_set = 0;
4621 /* Parse args required to build the message */
4622 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4624 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
4625 rx_sw_if_index_set = 1;
4626 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
4627 tx_sw_if_index_set = 1;
4628 else if (unformat (i, "rx"))
4630 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4632 if (unformat (i, "%U", unformat_sw_if_index, vam,
4634 rx_sw_if_index_set = 1;
4639 else if (unformat (i, "tx"))
4641 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4643 if (unformat (i, "%U", unformat_sw_if_index, vam,
4645 tx_sw_if_index_set = 1;
4650 else if (unformat (i, "enable"))
4652 else if (unformat (i, "disable"))
4658 if (rx_sw_if_index_set == 0)
4660 errmsg ("missing rx interface name or rx_sw_if_index\n");
4664 if (enable && (tx_sw_if_index_set == 0))
4666 errmsg ("missing tx interface name or tx_sw_if_index\n");
4670 M (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect);
4672 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
4673 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
4674 mp->enable = enable;
4683 api_sw_interface_set_l2_bridge (vat_main_t * vam)
4685 unformat_input_t *i = vam->input;
4686 vl_api_sw_interface_set_l2_bridge_t *mp;
4689 u8 rx_sw_if_index_set = 0;
4696 /* Parse args required to build the message */
4697 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4699 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
4700 rx_sw_if_index_set = 1;
4701 else if (unformat (i, "bd_id %d", &bd_id))
4703 else if (unformat (i, "%U", unformat_sw_if_index, vam, &rx_sw_if_index))
4704 rx_sw_if_index_set = 1;
4705 else if (unformat (i, "shg %d", &shg))
4707 else if (unformat (i, "bvi"))
4709 else if (unformat (i, "enable"))
4711 else if (unformat (i, "disable"))
4717 if (rx_sw_if_index_set == 0)
4719 errmsg ("missing rx interface name or sw_if_index\n");
4723 if (enable && (bd_id_set == 0))
4725 errmsg ("missing bridge domain\n");
4729 M (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge);
4731 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
4732 mp->bd_id = ntohl (bd_id);
4735 mp->enable = enable;
4744 api_bridge_domain_dump (vat_main_t * vam)
4746 unformat_input_t *i = vam->input;
4747 vl_api_bridge_domain_dump_t *mp;
4751 /* Parse args required to build the message */
4752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4754 if (unformat (i, "bd_id %d", &bd_id))
4760 M (BRIDGE_DOMAIN_DUMP, bridge_domain_dump);
4761 mp->bd_id = ntohl (bd_id);
4764 /* Use a control ping for synchronization */
4766 vl_api_control_ping_t *mp;
4767 M (CONTROL_PING, control_ping);
4777 api_bridge_domain_add_del (vat_main_t * vam)
4779 unformat_input_t *i = vam->input;
4780 vl_api_bridge_domain_add_del_t *mp;
4784 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
4786 /* Parse args required to build the message */
4787 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4789 if (unformat (i, "bd_id %d", &bd_id))
4791 else if (unformat (i, "flood %d", &flood))
4793 else if (unformat (i, "uu-flood %d", &uu_flood))
4795 else if (unformat (i, "forward %d", &forward))
4797 else if (unformat (i, "learn %d", &learn))
4799 else if (unformat (i, "arp-term %d", &arp_term))
4801 else if (unformat (i, "del"))
4804 flood = uu_flood = forward = learn = 0;
4812 errmsg ("missing bridge domain\n");
4816 M (BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del);
4818 mp->bd_id = ntohl (bd_id);
4820 mp->uu_flood = uu_flood;
4821 mp->forward = forward;
4823 mp->arp_term = arp_term;
4824 mp->is_add = is_add;
4833 api_l2fib_add_del (vat_main_t * vam)
4835 unformat_input_t *i = vam->input;
4836 vl_api_l2fib_add_del_t *mp;
4843 u8 sw_if_index_set = 0;
4852 /* Parse args required to build the message */
4853 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4855 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
4857 else if (unformat (i, "bd_id %d", &bd_id))
4859 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4860 sw_if_index_set = 1;
4861 else if (unformat (i, "sw_if"))
4863 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4865 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4866 sw_if_index_set = 1;
4871 else if (unformat (i, "static"))
4873 else if (unformat (i, "filter"))
4878 else if (unformat (i, "bvi"))
4883 else if (unformat (i, "del"))
4885 else if (unformat (i, "count %d", &count))
4893 errmsg ("missing mac address\n");
4899 errmsg ("missing bridge domain\n");
4903 if (is_add && (sw_if_index_set == 0))
4905 errmsg ("missing interface name or sw_if_index\n");
4911 /* Turn on async mode */
4912 vam->async_mode = 1;
4913 vam->async_errors = 0;
4914 before = vat_time_now (vam);
4917 for (j = 0; j < count; j++)
4919 M (L2FIB_ADD_DEL, l2fib_add_del);
4922 mp->bd_id = ntohl (bd_id);
4923 mp->is_add = is_add;
4927 mp->sw_if_index = ntohl (sw_if_index);
4928 mp->static_mac = static_mac;
4929 mp->filter_mac = filter_mac;
4930 mp->bvi_mac = bvi_mac;
4932 increment_mac_address (&mac);
4939 vl_api_control_ping_t *mp;
4942 /* Shut off async mode */
4943 vam->async_mode = 0;
4945 M (CONTROL_PING, control_ping);
4948 timeout = vat_time_now (vam) + 1.0;
4949 while (vat_time_now (vam) < timeout)
4950 if (vam->result_ready == 1)
4955 if (vam->retval == -99)
4956 errmsg ("timeout\n");
4958 if (vam->async_errors > 0)
4960 errmsg ("%d asynchronous errors\n", vam->async_errors);
4963 vam->async_errors = 0;
4964 after = vat_time_now (vam);
4966 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
4967 count, after - before, count / (after - before));
4971 /* Wait for a reply... */
4974 /* Return the good/bad news */
4975 return (vam->retval);
4979 api_l2_flags (vat_main_t * vam)
4981 unformat_input_t *i = vam->input;
4982 vl_api_l2_flags_t *mp;
4985 u32 feature_bitmap = 0;
4986 u8 sw_if_index_set = 0;
4988 /* Parse args required to build the message */
4989 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4991 if (unformat (i, "sw_if_index %d", &sw_if_index))
4992 sw_if_index_set = 1;
4993 else if (unformat (i, "sw_if"))
4995 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4997 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4998 sw_if_index_set = 1;
5003 else if (unformat (i, "learn"))
5004 feature_bitmap |= L2INPUT_FEAT_LEARN;
5005 else if (unformat (i, "forward"))
5006 feature_bitmap |= L2INPUT_FEAT_FWD;
5007 else if (unformat (i, "flood"))
5008 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5009 else if (unformat (i, "uu-flood"))
5010 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5015 if (sw_if_index_set == 0)
5017 errmsg ("missing interface name or sw_if_index\n");
5021 M (L2_FLAGS, l2_flags);
5023 mp->sw_if_index = ntohl (sw_if_index);
5024 mp->feature_bitmap = ntohl (feature_bitmap);
5033 api_bridge_flags (vat_main_t * vam)
5035 unformat_input_t *i = vam->input;
5036 vl_api_bridge_flags_t *mp;
5043 /* Parse args required to build the message */
5044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5046 if (unformat (i, "bd_id %d", &bd_id))
5048 else if (unformat (i, "learn"))
5050 else if (unformat (i, "forward"))
5052 else if (unformat (i, "flood"))
5054 else if (unformat (i, "uu-flood"))
5055 flags |= L2_UU_FLOOD;
5056 else if (unformat (i, "arp-term"))
5057 flags |= L2_ARP_TERM;
5058 else if (unformat (i, "off"))
5060 else if (unformat (i, "disable"))
5068 errmsg ("missing bridge domain\n");
5072 M (BRIDGE_FLAGS, bridge_flags);
5074 mp->bd_id = ntohl (bd_id);
5075 mp->feature_bitmap = ntohl (flags);
5076 mp->is_set = is_set;
5085 api_bd_ip_mac_add_del (vat_main_t * vam)
5087 unformat_input_t *i = vam->input;
5088 vl_api_bd_ip_mac_add_del_t *mp;
5096 ip4_address_t v4addr;
5097 ip6_address_t v6addr;
5101 /* Parse args required to build the message */
5102 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5104 if (unformat (i, "bd_id %d", &bd_id))
5108 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5112 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5117 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5121 else if (unformat (i, "del"))
5129 errmsg ("missing bridge domain\n");
5132 else if (ip_set == 0)
5134 errmsg ("missing IP address\n");
5137 else if (mac_set == 0)
5139 errmsg ("missing MAC address\n");
5143 M (BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del);
5145 mp->bd_id = ntohl (bd_id);
5146 mp->is_ipv6 = is_ipv6;
5147 mp->is_add = is_add;
5149 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5151 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5152 clib_memcpy (mp->mac_address, macaddr, 6);
5160 api_tap_connect (vat_main_t * vam)
5162 unformat_input_t *i = vam->input;
5163 vl_api_tap_connect_t *mp;
5170 memset (mac_address, 0, sizeof (mac_address));
5172 /* Parse args required to build the message */
5173 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5175 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5179 else if (unformat (i, "random-mac"))
5181 else if (unformat (i, "tapname %s", &tap_name))
5189 errmsg ("missing tap name\n");
5192 if (vec_len (tap_name) > 63)
5194 errmsg ("tap name too long\n");
5196 vec_add1 (tap_name, 0);
5198 /* Construct the API message */
5199 M (TAP_CONNECT, tap_connect);
5201 mp->use_random_mac = random_mac;
5202 clib_memcpy (mp->mac_address, mac_address, 6);
5203 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5204 vec_free (tap_name);
5209 /* Wait for a reply... */
5214 api_tap_modify (vat_main_t * vam)
5216 unformat_input_t *i = vam->input;
5217 vl_api_tap_modify_t *mp;
5223 u32 sw_if_index = ~0;
5224 u8 sw_if_index_set = 0;
5226 memset (mac_address, 0, sizeof (mac_address));
5228 /* Parse args required to build the message */
5229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5231 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5232 sw_if_index_set = 1;
5233 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5234 sw_if_index_set = 1;
5235 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5239 else if (unformat (i, "random-mac"))
5241 else if (unformat (i, "tapname %s", &tap_name))
5247 if (sw_if_index_set == 0)
5249 errmsg ("missing vpp interface name");
5254 errmsg ("missing tap name\n");
5257 if (vec_len (tap_name) > 63)
5259 errmsg ("tap name too long\n");
5261 vec_add1 (tap_name, 0);
5263 /* Construct the API message */
5264 M (TAP_MODIFY, tap_modify);
5266 mp->use_random_mac = random_mac;
5267 mp->sw_if_index = ntohl (sw_if_index);
5268 clib_memcpy (mp->mac_address, mac_address, 6);
5269 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5270 vec_free (tap_name);
5275 /* Wait for a reply... */
5280 api_tap_delete (vat_main_t * vam)
5282 unformat_input_t *i = vam->input;
5283 vl_api_tap_delete_t *mp;
5285 u32 sw_if_index = ~0;
5286 u8 sw_if_index_set = 0;
5288 /* Parse args required to build the message */
5289 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5291 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5292 sw_if_index_set = 1;
5293 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5294 sw_if_index_set = 1;
5299 if (sw_if_index_set == 0)
5301 errmsg ("missing vpp interface name");
5305 /* Construct the API message */
5306 M (TAP_DELETE, tap_delete);
5308 mp->sw_if_index = ntohl (sw_if_index);
5313 /* Wait for a reply... */
5318 api_ip_add_del_route (vat_main_t * vam)
5320 unformat_input_t *i = vam->input;
5321 vl_api_ip_add_del_route_t *mp;
5323 u32 sw_if_index = ~0, vrf_id = 0;
5324 u8 sw_if_index_set = 0;
5326 u8 is_local = 0, is_drop = 0;
5327 u8 create_vrf_if_needed = 0;
5329 u8 next_hop_weight = 1;
5331 u8 is_multipath = 0;
5333 u8 address_length_set = 0;
5334 u32 lookup_in_vrf = 0;
5335 u32 resolve_attempts = 0;
5336 u32 dst_address_length = 0;
5337 u8 next_hop_set = 0;
5338 ip4_address_t v4_dst_address, v4_next_hop_address;
5339 ip6_address_t v6_dst_address, v6_next_hop_address;
5343 u32 random_add_del = 0;
5344 u32 *random_vector = 0;
5346 u32 random_seed = 0xdeaddabe;
5347 u32 classify_table_index = ~0;
5350 /* Parse args required to build the message */
5351 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5353 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5354 sw_if_index_set = 1;
5355 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5356 sw_if_index_set = 1;
5357 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
5362 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
5367 else if (unformat (i, "/%d", &dst_address_length))
5369 address_length_set = 1;
5372 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
5373 &v4_next_hop_address))
5377 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
5378 &v6_next_hop_address))
5382 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
5384 else if (unformat (i, "weight %d", &next_hop_weight))
5386 else if (unformat (i, "drop"))
5390 else if (unformat (i, "local"))
5394 else if (unformat (i, "classify %d", &classify_table_index))
5398 else if (unformat (i, "del"))
5400 else if (unformat (i, "add"))
5402 else if (unformat (i, "not-last"))
5404 else if (unformat (i, "multipath"))
5406 else if (unformat (i, "vrf %d", &vrf_id))
5408 else if (unformat (i, "create-vrf"))
5409 create_vrf_if_needed = 1;
5410 else if (unformat (i, "count %d", &count))
5412 else if (unformat (i, "lookup-in-vrf %d", &lookup_in_vrf))
5414 else if (unformat (i, "random"))
5416 else if (unformat (i, "seed %d", &random_seed))
5420 clib_warning ("parse error '%U'", format_unformat_error, i);
5425 if (resolve_attempts > 0 && sw_if_index_set == 0)
5427 errmsg ("ARP resolution needs explicit interface or sw_if_index\n");
5431 if (!next_hop_set && !is_drop && !is_local && !is_classify)
5433 errmsg ("next hop / local / drop / classify not set\n");
5437 if (address_set == 0)
5439 errmsg ("missing addresses\n");
5443 if (address_length_set == 0)
5445 errmsg ("missing address length\n");
5449 /* Generate a pile of unique, random routes */
5452 u32 this_random_address;
5453 random_hash = hash_create (count, sizeof (uword));
5455 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
5456 for (j = 0; j <= count; j++)
5460 this_random_address = random_u32 (&random_seed);
5461 this_random_address =
5462 clib_host_to_net_u32 (this_random_address);
5464 while (hash_get (random_hash, this_random_address));
5465 vec_add1 (random_vector, this_random_address);
5466 hash_set (random_hash, this_random_address, 1);
5468 hash_free (random_hash);
5469 v4_dst_address.as_u32 = random_vector[0];
5474 /* Turn on async mode */
5475 vam->async_mode = 1;
5476 vam->async_errors = 0;
5477 before = vat_time_now (vam);
5480 for (j = 0; j < count; j++)
5482 /* Construct the API message */
5483 M (IP_ADD_DEL_ROUTE, ip_add_del_route);
5485 mp->next_hop_sw_if_index = ntohl (sw_if_index);
5486 mp->vrf_id = ntohl (vrf_id);
5487 if (resolve_attempts > 0)
5489 mp->resolve_attempts = ntohl (resolve_attempts);
5490 mp->resolve_if_needed = 1;
5492 mp->create_vrf_if_needed = create_vrf_if_needed;
5494 mp->is_add = is_add;
5495 mp->is_drop = is_drop;
5496 mp->is_ipv6 = is_ipv6;
5497 mp->is_local = is_local;
5498 mp->is_classify = is_classify;
5499 mp->is_multipath = is_multipath;
5500 mp->not_last = not_last;
5501 mp->next_hop_weight = next_hop_weight;
5502 mp->dst_address_length = dst_address_length;
5503 mp->lookup_in_vrf = ntohl (lookup_in_vrf);
5504 mp->classify_table_index = ntohl (classify_table_index);
5508 clib_memcpy (mp->dst_address, &v6_dst_address,
5509 sizeof (v6_dst_address));
5511 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
5512 sizeof (v6_next_hop_address));
5513 increment_v6_address (&v6_dst_address);
5517 clib_memcpy (mp->dst_address, &v4_dst_address,
5518 sizeof (v4_dst_address));
5520 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
5521 sizeof (v4_next_hop_address));
5523 v4_dst_address.as_u32 = random_vector[j + 1];
5525 increment_v4_address (&v4_dst_address);
5531 /* When testing multiple add/del ops, use a control-ping to sync */
5534 vl_api_control_ping_t *mp;
5537 /* Shut off async mode */
5538 vam->async_mode = 0;
5540 M (CONTROL_PING, control_ping);
5543 timeout = vat_time_now (vam) + 1.0;
5544 while (vat_time_now (vam) < timeout)
5545 if (vam->result_ready == 1)
5550 if (vam->retval == -99)
5551 errmsg ("timeout\n");
5553 if (vam->async_errors > 0)
5555 errmsg ("%d asynchronous errors\n", vam->async_errors);
5558 vam->async_errors = 0;
5559 after = vat_time_now (vam);
5561 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
5562 count, after - before, count / (after - before));
5566 /* Wait for a reply... */
5570 /* Return the good/bad news */
5571 return (vam->retval);
5575 api_proxy_arp_add_del (vat_main_t * vam)
5577 unformat_input_t *i = vam->input;
5578 vl_api_proxy_arp_add_del_t *mp;
5582 ip4_address_t lo, hi;
5585 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5587 if (unformat (i, "vrf %d", &vrf_id))
5589 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
5590 unformat_ip4_address, &hi))
5592 else if (unformat (i, "del"))
5596 clib_warning ("parse error '%U'", format_unformat_error, i);
5603 errmsg ("address range not set\n");
5607 M (PROXY_ARP_ADD_DEL, proxy_arp_add_del);
5609 mp->vrf_id = ntohl (vrf_id);
5610 mp->is_add = is_add;
5611 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
5612 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
5621 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
5623 unformat_input_t *i = vam->input;
5624 vl_api_proxy_arp_intfc_enable_disable_t *mp;
5628 u8 sw_if_index_set = 0;
5630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5632 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5633 sw_if_index_set = 1;
5634 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5635 sw_if_index_set = 1;
5636 else if (unformat (i, "enable"))
5638 else if (unformat (i, "disable"))
5642 clib_warning ("parse error '%U'", format_unformat_error, i);
5647 if (sw_if_index_set == 0)
5649 errmsg ("missing interface name or sw_if_index\n");
5653 M (PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable);
5655 mp->sw_if_index = ntohl (sw_if_index);
5656 mp->enable_disable = enable;
5665 api_mpls_add_del_decap (vat_main_t * vam)
5667 unformat_input_t *i = vam->input;
5668 vl_api_mpls_add_del_decap_t *mp;
5677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5679 if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
5681 else if (unformat (i, "tx_vrf_id %d", &tx_vrf_id))
5683 else if (unformat (i, "label %d", &label))
5685 else if (unformat (i, "next-index %d", &next_index))
5687 else if (unformat (i, "del"))
5689 else if (unformat (i, "s-bit-clear"))
5693 clib_warning ("parse error '%U'", format_unformat_error, i);
5698 M (MPLS_ADD_DEL_DECAP, mpls_add_del_decap);
5700 mp->rx_vrf_id = ntohl (rx_vrf_id);
5701 mp->tx_vrf_id = ntohl (tx_vrf_id);
5702 mp->label = ntohl (label);
5703 mp->next_index = ntohl (next_index);
5705 mp->is_add = is_add;
5714 api_mpls_add_del_encap (vat_main_t * vam)
5716 unformat_input_t *i = vam->input;
5717 vl_api_mpls_add_del_encap_t *mp;
5722 ip4_address_t dst_address;
5725 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5727 if (unformat (i, "vrf %d", &vrf_id))
5729 else if (unformat (i, "label %d", &label))
5730 vec_add1 (labels, ntohl (label));
5731 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
5733 else if (unformat (i, "del"))
5737 clib_warning ("parse error '%U'", format_unformat_error, i);
5742 if (vec_len (labels) == 0)
5744 errmsg ("missing encap label stack\n");
5748 M2 (MPLS_ADD_DEL_ENCAP, mpls_add_del_encap,
5749 sizeof (u32) * vec_len (labels));
5751 mp->vrf_id = ntohl (vrf_id);
5752 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
5753 mp->is_add = is_add;
5754 mp->nlabels = vec_len (labels);
5755 clib_memcpy (mp->labels, labels, sizeof (u32) * mp->nlabels);
5766 api_mpls_gre_add_del_tunnel (vat_main_t * vam)
5768 unformat_input_t *i = vam->input;
5769 vl_api_mpls_gre_add_del_tunnel_t *mp;
5771 u32 inner_vrf_id = 0;
5772 u32 outer_vrf_id = 0;
5773 ip4_address_t src_address;
5774 ip4_address_t dst_address;
5775 ip4_address_t intfc_address;
5777 u8 intfc_address_length = 0;
5781 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5783 if (unformat (i, "inner_vrf_id %d", &inner_vrf_id))
5785 else if (unformat (i, "outer_vrf_id %d", &outer_vrf_id))
5787 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
5789 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
5791 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
5792 &intfc_address, &tmp))
5793 intfc_address_length = tmp;
5794 else if (unformat (i, "l2-only"))
5796 else if (unformat (i, "del"))
5800 clib_warning ("parse error '%U'", format_unformat_error, i);
5805 M (MPLS_GRE_ADD_DEL_TUNNEL, mpls_gre_add_del_tunnel);
5807 mp->inner_vrf_id = ntohl (inner_vrf_id);
5808 mp->outer_vrf_id = ntohl (outer_vrf_id);
5809 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
5810 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
5811 clib_memcpy (mp->intfc_address, &intfc_address, sizeof (intfc_address));
5812 mp->intfc_address_length = intfc_address_length;
5813 mp->l2_only = l2_only;
5814 mp->is_add = is_add;
5823 api_mpls_ethernet_add_del_tunnel (vat_main_t * vam)
5825 unformat_input_t *i = vam->input;
5826 vl_api_mpls_ethernet_add_del_tunnel_t *mp;
5828 u32 inner_vrf_id = 0;
5829 ip4_address_t intfc_address;
5830 u8 dst_mac_address[6];
5833 u8 intfc_address_length = 0;
5837 int tx_sw_if_index_set = 0;
5839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5841 if (unformat (i, "vrf %d", &inner_vrf_id))
5843 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
5844 &intfc_address, &tmp))
5845 intfc_address_length = tmp;
5846 else if (unformat (i, "%U", unformat_sw_if_index, vam, &tx_sw_if_index))
5847 tx_sw_if_index_set = 1;
5848 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5849 tx_sw_if_index_set = 1;
5850 else if (unformat (i, "dst %U", unformat_ethernet_address,
5853 else if (unformat (i, "l2-only"))
5855 else if (unformat (i, "del"))
5859 clib_warning ("parse error '%U'", format_unformat_error, i);
5866 errmsg ("dst (mac address) not set\n");
5869 if (!tx_sw_if_index_set)
5871 errmsg ("tx-intfc not set\n");
5875 M (MPLS_ETHERNET_ADD_DEL_TUNNEL, mpls_ethernet_add_del_tunnel);
5877 mp->vrf_id = ntohl (inner_vrf_id);
5878 clib_memcpy (mp->adj_address, &intfc_address, sizeof (intfc_address));
5879 mp->adj_address_length = intfc_address_length;
5880 clib_memcpy (mp->dst_mac_address, dst_mac_address,
5881 sizeof (dst_mac_address));
5882 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5883 mp->l2_only = l2_only;
5884 mp->is_add = is_add;
5893 api_mpls_ethernet_add_del_tunnel_2 (vat_main_t * vam)
5895 unformat_input_t *i = vam->input;
5896 vl_api_mpls_ethernet_add_del_tunnel_2_t *mp;
5898 u32 inner_vrf_id = 0;
5899 u32 outer_vrf_id = 0;
5900 ip4_address_t adj_address;
5901 int adj_address_set = 0;
5902 ip4_address_t next_hop_address;
5903 int next_hop_address_set = 0;
5905 u8 adj_address_length = 0;
5908 u32 resolve_attempts = 5;
5909 u8 resolve_if_needed = 1;
5911 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5913 if (unformat (i, "inner_vrf_id %d", &inner_vrf_id))
5915 else if (unformat (i, "outer_vrf_id %d", &outer_vrf_id))
5917 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
5918 &adj_address, &tmp))
5920 adj_address_length = tmp;
5921 adj_address_set = 1;
5923 else if (unformat (i, "next-hop %U", unformat_ip4_address,
5925 next_hop_address_set = 1;
5926 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
5928 else if (unformat (i, "resolve-if-needed %d", &tmp))
5929 resolve_if_needed = tmp;
5930 else if (unformat (i, "l2-only"))
5932 else if (unformat (i, "del"))
5936 clib_warning ("parse error '%U'", format_unformat_error, i);
5941 if (!adj_address_set)
5943 errmsg ("adjacency address/mask not set\n");
5946 if (!next_hop_address_set)
5948 errmsg ("ip4 next hop address (in outer fib) not set\n");
5952 M (MPLS_ETHERNET_ADD_DEL_TUNNEL_2, mpls_ethernet_add_del_tunnel_2);
5954 mp->inner_vrf_id = ntohl (inner_vrf_id);
5955 mp->outer_vrf_id = ntohl (outer_vrf_id);
5956 mp->resolve_attempts = ntohl (resolve_attempts);
5957 mp->resolve_if_needed = resolve_if_needed;
5958 mp->is_add = is_add;
5959 mp->l2_only = l2_only;
5960 clib_memcpy (mp->adj_address, &adj_address, sizeof (adj_address));
5961 mp->adj_address_length = adj_address_length;
5962 clib_memcpy (mp->next_hop_ip4_address_in_outer_vrf, &next_hop_address,
5963 sizeof (next_hop_address));
5972 api_sw_interface_set_unnumbered (vat_main_t * vam)
5974 unformat_input_t *i = vam->input;
5975 vl_api_sw_interface_set_unnumbered_t *mp;
5978 u32 unnum_sw_index = ~0;
5980 u8 sw_if_index_set = 0;
5982 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5984 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5985 sw_if_index_set = 1;
5986 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5987 sw_if_index_set = 1;
5988 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
5990 else if (unformat (i, "del"))
5994 clib_warning ("parse error '%U'", format_unformat_error, i);
5999 if (sw_if_index_set == 0)
6001 errmsg ("missing interface name or sw_if_index\n");
6005 M (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered);
6007 mp->sw_if_index = ntohl (sw_if_index);
6008 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
6009 mp->is_add = is_add;
6018 api_ip_neighbor_add_del (vat_main_t * vam)
6020 unformat_input_t *i = vam->input;
6021 vl_api_ip_neighbor_add_del_t *mp;
6024 u8 sw_if_index_set = 0;
6030 u8 v4_address_set = 0;
6031 u8 v6_address_set = 0;
6032 ip4_address_t v4address;
6033 ip6_address_t v6address;
6035 memset (mac_address, 0, sizeof (mac_address));
6037 /* Parse args required to build the message */
6038 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6040 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6044 else if (unformat (i, "del"))
6046 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6047 sw_if_index_set = 1;
6048 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6049 sw_if_index_set = 1;
6050 else if (unformat (i, "is_static"))
6052 else if (unformat (i, "vrf %d", &vrf_id))
6054 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
6056 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
6060 clib_warning ("parse error '%U'", format_unformat_error, i);
6065 if (sw_if_index_set == 0)
6067 errmsg ("missing interface name or sw_if_index\n");
6070 if (v4_address_set && v6_address_set)
6072 errmsg ("both v4 and v6 addresses set\n");
6075 if (!v4_address_set && !v6_address_set)
6077 errmsg ("no address set\n");
6081 /* Construct the API message */
6082 M (IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del);
6084 mp->sw_if_index = ntohl (sw_if_index);
6085 mp->is_add = is_add;
6086 mp->vrf_id = ntohl (vrf_id);
6087 mp->is_static = is_static;
6089 clib_memcpy (mp->mac_address, mac_address, 6);
6093 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
6097 /* mp->is_ipv6 = 0; via memset in M macro above */
6098 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
6104 /* Wait for a reply, return good/bad news */
6112 api_reset_vrf (vat_main_t * vam)
6114 unformat_input_t *i = vam->input;
6115 vl_api_reset_vrf_t *mp;
6121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6123 if (unformat (i, "vrf %d", &vrf_id))
6125 else if (unformat (i, "ipv6"))
6129 clib_warning ("parse error '%U'", format_unformat_error, i);
6134 if (vrf_id_set == 0)
6136 errmsg ("missing vrf id\n");
6140 M (RESET_VRF, reset_vrf);
6142 mp->vrf_id = ntohl (vrf_id);
6143 mp->is_ipv6 = is_ipv6;
6152 api_create_vlan_subif (vat_main_t * vam)
6154 unformat_input_t *i = vam->input;
6155 vl_api_create_vlan_subif_t *mp;
6158 u8 sw_if_index_set = 0;
6162 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6164 if (unformat (i, "sw_if_index %d", &sw_if_index))
6165 sw_if_index_set = 1;
6166 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6167 sw_if_index_set = 1;
6168 else if (unformat (i, "vlan %d", &vlan_id))
6172 clib_warning ("parse error '%U'", format_unformat_error, i);
6177 if (sw_if_index_set == 0)
6179 errmsg ("missing interface name or sw_if_index\n");
6183 if (vlan_id_set == 0)
6185 errmsg ("missing vlan_id\n");
6188 M (CREATE_VLAN_SUBIF, create_vlan_subif);
6190 mp->sw_if_index = ntohl (sw_if_index);
6191 mp->vlan_id = ntohl (vlan_id);
6199 #define foreach_create_subif_bit \
6206 _(outer_vlan_id_any) \
6207 _(inner_vlan_id_any)
6210 api_create_subif (vat_main_t * vam)
6212 unformat_input_t *i = vam->input;
6213 vl_api_create_subif_t *mp;
6216 u8 sw_if_index_set = 0;
6223 u32 exact_match = 0;
6224 u32 default_sub = 0;
6225 u32 outer_vlan_id_any = 0;
6226 u32 inner_vlan_id_any = 0;
6228 u16 outer_vlan_id = 0;
6229 u16 inner_vlan_id = 0;
6231 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6233 if (unformat (i, "sw_if_index %d", &sw_if_index))
6234 sw_if_index_set = 1;
6235 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6236 sw_if_index_set = 1;
6237 else if (unformat (i, "sub_id %d", &sub_id))
6239 else if (unformat (i, "outer_vlan_id %d", &tmp))
6240 outer_vlan_id = tmp;
6241 else if (unformat (i, "inner_vlan_id %d", &tmp))
6242 inner_vlan_id = tmp;
6244 #define _(a) else if (unformat (i, #a)) a = 1 ;
6245 foreach_create_subif_bit
6249 clib_warning ("parse error '%U'", format_unformat_error, i);
6254 if (sw_if_index_set == 0)
6256 errmsg ("missing interface name or sw_if_index\n");
6260 if (sub_id_set == 0)
6262 errmsg ("missing sub_id\n");
6265 M (CREATE_SUBIF, create_subif);
6267 mp->sw_if_index = ntohl (sw_if_index);
6268 mp->sub_id = ntohl (sub_id);
6270 #define _(a) mp->a = a;
6271 foreach_create_subif_bit;
6274 mp->outer_vlan_id = ntohs (outer_vlan_id);
6275 mp->inner_vlan_id = ntohs (inner_vlan_id);
6284 api_oam_add_del (vat_main_t * vam)
6286 unformat_input_t *i = vam->input;
6287 vl_api_oam_add_del_t *mp;
6291 ip4_address_t src, dst;
6295 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6297 if (unformat (i, "vrf %d", &vrf_id))
6299 else if (unformat (i, "src %U", unformat_ip4_address, &src))
6301 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
6303 else if (unformat (i, "del"))
6307 clib_warning ("parse error '%U'", format_unformat_error, i);
6314 errmsg ("missing src addr\n");
6320 errmsg ("missing dst addr\n");
6324 M (OAM_ADD_DEL, oam_add_del);
6326 mp->vrf_id = ntohl (vrf_id);
6327 mp->is_add = is_add;
6328 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
6329 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
6338 api_reset_fib (vat_main_t * vam)
6340 unformat_input_t *i = vam->input;
6341 vl_api_reset_fib_t *mp;
6347 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6349 if (unformat (i, "vrf %d", &vrf_id))
6351 else if (unformat (i, "ipv6"))
6355 clib_warning ("parse error '%U'", format_unformat_error, i);
6360 if (vrf_id_set == 0)
6362 errmsg ("missing vrf id\n");
6366 M (RESET_FIB, reset_fib);
6368 mp->vrf_id = ntohl (vrf_id);
6369 mp->is_ipv6 = is_ipv6;
6378 api_dhcp_proxy_config (vat_main_t * vam)
6380 unformat_input_t *i = vam->input;
6381 vl_api_dhcp_proxy_config_t *mp;
6386 u8 v4_address_set = 0;
6387 u8 v6_address_set = 0;
6388 ip4_address_t v4address;
6389 ip6_address_t v6address;
6390 u8 v4_src_address_set = 0;
6391 u8 v6_src_address_set = 0;
6392 ip4_address_t v4srcaddress;
6393 ip6_address_t v6srcaddress;
6395 /* Parse args required to build the message */
6396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6398 if (unformat (i, "del"))
6400 else if (unformat (i, "vrf %d", &vrf_id))
6402 else if (unformat (i, "insert-cid %d", &insert_cid))
6404 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
6406 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
6408 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
6409 v4_src_address_set = 1;
6410 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
6411 v6_src_address_set = 1;
6416 if (v4_address_set && v6_address_set)
6418 errmsg ("both v4 and v6 server addresses set\n");
6421 if (!v4_address_set && !v6_address_set)
6423 errmsg ("no server addresses set\n");
6427 if (v4_src_address_set && v6_src_address_set)
6429 errmsg ("both v4 and v6 src addresses set\n");
6432 if (!v4_src_address_set && !v6_src_address_set)
6434 errmsg ("no src addresses set\n");
6438 if (!(v4_src_address_set && v4_address_set) &&
6439 !(v6_src_address_set && v6_address_set))
6441 errmsg ("no matching server and src addresses set\n");
6445 /* Construct the API message */
6446 M (DHCP_PROXY_CONFIG, dhcp_proxy_config);
6448 mp->insert_circuit_id = insert_cid;
6449 mp->is_add = is_add;
6450 mp->vrf_id = ntohl (vrf_id);
6454 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
6455 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
6459 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
6460 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
6466 /* Wait for a reply, return good/bad news */
6473 api_dhcp_proxy_config_2 (vat_main_t * vam)
6475 unformat_input_t *i = vam->input;
6476 vl_api_dhcp_proxy_config_2_t *mp;
6479 u32 server_vrf_id = 0;
6482 u8 v4_address_set = 0;
6483 u8 v6_address_set = 0;
6484 ip4_address_t v4address;
6485 ip6_address_t v6address;
6486 u8 v4_src_address_set = 0;
6487 u8 v6_src_address_set = 0;
6488 ip4_address_t v4srcaddress;
6489 ip6_address_t v6srcaddress;
6491 /* Parse args required to build the message */
6492 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6494 if (unformat (i, "del"))
6496 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
6498 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
6500 else if (unformat (i, "insert-cid %d", &insert_cid))
6502 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
6504 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
6506 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
6507 v4_src_address_set = 1;
6508 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
6509 v6_src_address_set = 1;
6514 if (v4_address_set && v6_address_set)
6516 errmsg ("both v4 and v6 server addresses set\n");
6519 if (!v4_address_set && !v6_address_set)
6521 errmsg ("no server addresses set\n");
6525 if (v4_src_address_set && v6_src_address_set)
6527 errmsg ("both v4 and v6 src addresses set\n");
6530 if (!v4_src_address_set && !v6_src_address_set)
6532 errmsg ("no src addresses set\n");
6536 if (!(v4_src_address_set && v4_address_set) &&
6537 !(v6_src_address_set && v6_address_set))
6539 errmsg ("no matching server and src addresses set\n");
6543 /* Construct the API message */
6544 M (DHCP_PROXY_CONFIG_2, dhcp_proxy_config_2);
6546 mp->insert_circuit_id = insert_cid;
6547 mp->is_add = is_add;
6548 mp->rx_vrf_id = ntohl (rx_vrf_id);
6549 mp->server_vrf_id = ntohl (server_vrf_id);
6553 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
6554 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
6558 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
6559 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
6565 /* Wait for a reply, return good/bad news */
6572 api_dhcp_proxy_set_vss (vat_main_t * vam)
6574 unformat_input_t *i = vam->input;
6575 vl_api_dhcp_proxy_set_vss_t *mp;
6586 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6588 if (unformat (i, "tbl_id %d", &tbl_id))
6590 if (unformat (i, "fib_id %d", &fib_id))
6592 if (unformat (i, "oui %d", &oui))
6594 else if (unformat (i, "ipv6"))
6596 else if (unformat (i, "del"))
6600 clib_warning ("parse error '%U'", format_unformat_error, i);
6605 if (tbl_id_set == 0)
6607 errmsg ("missing tbl id\n");
6611 if (fib_id_set == 0)
6613 errmsg ("missing fib id\n");
6618 errmsg ("missing oui\n");
6622 M (DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss);
6623 mp->tbl_id = ntohl (tbl_id);
6624 mp->fib_id = ntohl (fib_id);
6625 mp->oui = ntohl (oui);
6626 mp->is_ipv6 = is_ipv6;
6627 mp->is_add = is_add;
6636 api_dhcp_client_config (vat_main_t * vam)
6638 unformat_input_t *i = vam->input;
6639 vl_api_dhcp_client_config_t *mp;
6642 u8 sw_if_index_set = 0;
6645 u8 disable_event = 0;
6647 /* Parse args required to build the message */
6648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6650 if (unformat (i, "del"))
6652 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6653 sw_if_index_set = 1;
6654 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6655 sw_if_index_set = 1;
6656 else if (unformat (i, "hostname %s", &hostname))
6658 else if (unformat (i, "disable_event"))
6664 if (sw_if_index_set == 0)
6666 errmsg ("missing interface name or sw_if_index\n");
6670 if (vec_len (hostname) > 63)
6672 errmsg ("hostname too long\n");
6674 vec_add1 (hostname, 0);
6676 /* Construct the API message */
6677 M (DHCP_CLIENT_CONFIG, dhcp_client_config);
6679 mp->sw_if_index = ntohl (sw_if_index);
6680 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
6681 vec_free (hostname);
6682 mp->is_add = is_add;
6683 mp->want_dhcp_event = disable_event ? 0 : 1;
6684 mp->pid = getpid ();
6689 /* Wait for a reply, return good/bad news */
6696 api_set_ip_flow_hash (vat_main_t * vam)
6698 unformat_input_t *i = vam->input;
6699 vl_api_set_ip_flow_hash_t *mp;
6711 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6713 if (unformat (i, "vrf %d", &vrf_id))
6715 else if (unformat (i, "ipv6"))
6717 else if (unformat (i, "src"))
6719 else if (unformat (i, "dst"))
6721 else if (unformat (i, "sport"))
6723 else if (unformat (i, "dport"))
6725 else if (unformat (i, "proto"))
6727 else if (unformat (i, "reverse"))
6732 clib_warning ("parse error '%U'", format_unformat_error, i);
6737 if (vrf_id_set == 0)
6739 errmsg ("missing vrf id\n");
6743 M (SET_IP_FLOW_HASH, set_ip_flow_hash);
6749 mp->reverse = reverse;
6750 mp->vrf_id = ntohl (vrf_id);
6751 mp->is_ipv6 = is_ipv6;
6760 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
6762 unformat_input_t *i = vam->input;
6763 vl_api_sw_interface_ip6_enable_disable_t *mp;
6766 u8 sw_if_index_set = 0;
6769 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6771 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6772 sw_if_index_set = 1;
6773 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6774 sw_if_index_set = 1;
6775 else if (unformat (i, "enable"))
6777 else if (unformat (i, "disable"))
6781 clib_warning ("parse error '%U'", format_unformat_error, i);
6786 if (sw_if_index_set == 0)
6788 errmsg ("missing interface name or sw_if_index\n");
6792 M (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable);
6794 mp->sw_if_index = ntohl (sw_if_index);
6795 mp->enable = enable;
6804 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
6806 unformat_input_t *i = vam->input;
6807 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
6810 u8 sw_if_index_set = 0;
6811 u32 address_length = 0;
6812 u8 v6_address_set = 0;
6813 ip6_address_t v6address;
6815 /* Parse args required to build the message */
6816 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6818 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6819 sw_if_index_set = 1;
6820 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6821 sw_if_index_set = 1;
6822 else if (unformat (i, "%U/%d",
6823 unformat_ip6_address, &v6address, &address_length))
6829 if (sw_if_index_set == 0)
6831 errmsg ("missing interface name or sw_if_index\n");
6834 if (!v6_address_set)
6836 errmsg ("no address set\n");
6840 /* Construct the API message */
6841 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,
6842 sw_interface_ip6_set_link_local_address);
6844 mp->sw_if_index = ntohl (sw_if_index);
6845 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6846 mp->address_length = address_length;
6851 /* Wait for a reply, return good/bad news */
6860 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
6862 unformat_input_t *i = vam->input;
6863 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
6866 u8 sw_if_index_set = 0;
6867 u32 address_length = 0;
6868 u8 v6_address_set = 0;
6869 ip6_address_t v6address;
6871 u8 no_advertise = 0;
6873 u8 no_autoconfig = 0;
6876 u32 val_lifetime = 0;
6877 u32 pref_lifetime = 0;
6879 /* Parse args required to build the message */
6880 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6882 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6883 sw_if_index_set = 1;
6884 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6885 sw_if_index_set = 1;
6886 else if (unformat (i, "%U/%d",
6887 unformat_ip6_address, &v6address, &address_length))
6889 else if (unformat (i, "val_life %d", &val_lifetime))
6891 else if (unformat (i, "pref_life %d", &pref_lifetime))
6893 else if (unformat (i, "def"))
6895 else if (unformat (i, "noadv"))
6897 else if (unformat (i, "offl"))
6899 else if (unformat (i, "noauto"))
6901 else if (unformat (i, "nolink"))
6903 else if (unformat (i, "isno"))
6907 clib_warning ("parse error '%U'", format_unformat_error, i);
6912 if (sw_if_index_set == 0)
6914 errmsg ("missing interface name or sw_if_index\n");
6917 if (!v6_address_set)
6919 errmsg ("no address set\n");
6923 /* Construct the API message */
6924 M (SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix);
6926 mp->sw_if_index = ntohl (sw_if_index);
6927 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6928 mp->address_length = address_length;
6929 mp->use_default = use_default;
6930 mp->no_advertise = no_advertise;
6931 mp->off_link = off_link;
6932 mp->no_autoconfig = no_autoconfig;
6933 mp->no_onlink = no_onlink;
6935 mp->val_lifetime = ntohl (val_lifetime);
6936 mp->pref_lifetime = ntohl (pref_lifetime);
6941 /* Wait for a reply, return good/bad news */
6949 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
6951 unformat_input_t *i = vam->input;
6952 vl_api_sw_interface_ip6nd_ra_config_t *mp;
6955 u8 sw_if_index_set = 0;
6960 u8 send_unicast = 0;
6963 u8 default_router = 0;
6964 u32 max_interval = 0;
6965 u32 min_interval = 0;
6967 u32 initial_count = 0;
6968 u32 initial_interval = 0;
6971 /* Parse args required to build the message */
6972 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6974 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6975 sw_if_index_set = 1;
6976 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6977 sw_if_index_set = 1;
6978 else if (unformat (i, "maxint %d", &max_interval))
6980 else if (unformat (i, "minint %d", &min_interval))
6982 else if (unformat (i, "life %d", &lifetime))
6984 else if (unformat (i, "count %d", &initial_count))
6986 else if (unformat (i, "interval %d", &initial_interval))
6988 else if (unformat (i, "suppress") || unformat (i, "surpress"))
6990 else if (unformat (i, "managed"))
6992 else if (unformat (i, "other"))
6994 else if (unformat (i, "ll"))
6996 else if (unformat (i, "send"))
6998 else if (unformat (i, "cease"))
7000 else if (unformat (i, "isno"))
7002 else if (unformat (i, "def"))
7006 clib_warning ("parse error '%U'", format_unformat_error, i);
7011 if (sw_if_index_set == 0)
7013 errmsg ("missing interface name or sw_if_index\n");
7017 /* Construct the API message */
7018 M (SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config);
7020 mp->sw_if_index = ntohl (sw_if_index);
7021 mp->max_interval = ntohl (max_interval);
7022 mp->min_interval = ntohl (min_interval);
7023 mp->lifetime = ntohl (lifetime);
7024 mp->initial_count = ntohl (initial_count);
7025 mp->initial_interval = ntohl (initial_interval);
7026 mp->suppress = suppress;
7027 mp->managed = managed;
7029 mp->ll_option = ll_option;
7030 mp->send_unicast = send_unicast;
7033 mp->default_router = default_router;
7038 /* Wait for a reply, return good/bad news */
7046 api_set_arp_neighbor_limit (vat_main_t * vam)
7048 unformat_input_t *i = vam->input;
7049 vl_api_set_arp_neighbor_limit_t *mp;
7055 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7057 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
7059 else if (unformat (i, "ipv6"))
7063 clib_warning ("parse error '%U'", format_unformat_error, i);
7070 errmsg ("missing limit value\n");
7074 M (SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit);
7076 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
7077 mp->is_ipv6 = is_ipv6;
7086 api_l2_patch_add_del (vat_main_t * vam)
7088 unformat_input_t *i = vam->input;
7089 vl_api_l2_patch_add_del_t *mp;
7092 u8 rx_sw_if_index_set = 0;
7094 u8 tx_sw_if_index_set = 0;
7097 /* Parse args required to build the message */
7098 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7100 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7101 rx_sw_if_index_set = 1;
7102 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7103 tx_sw_if_index_set = 1;
7104 else if (unformat (i, "rx"))
7106 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7108 if (unformat (i, "%U", unformat_sw_if_index, vam,
7110 rx_sw_if_index_set = 1;
7115 else if (unformat (i, "tx"))
7117 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7119 if (unformat (i, "%U", unformat_sw_if_index, vam,
7121 tx_sw_if_index_set = 1;
7126 else if (unformat (i, "del"))
7132 if (rx_sw_if_index_set == 0)
7134 errmsg ("missing rx interface name or rx_sw_if_index\n");
7138 if (tx_sw_if_index_set == 0)
7140 errmsg ("missing tx interface name or tx_sw_if_index\n");
7144 M (L2_PATCH_ADD_DEL, l2_patch_add_del);
7146 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7147 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7148 mp->is_add = is_add;
7157 api_ioam_enable (vat_main_t * vam)
7159 unformat_input_t *input = vam->input;
7160 vl_api_ioam_enable_t *mp;
7163 int has_trace_option = 0;
7164 int has_pow_option = 0;
7165 int has_ppc_option = 0;
7167 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7169 if (unformat (input, "trace"))
7170 has_trace_option = 1;
7171 else if (unformat (input, "pow"))
7173 else if (unformat (input, "ppc encap"))
7174 has_ppc_option = PPC_ENCAP;
7175 else if (unformat (input, "ppc decap"))
7176 has_ppc_option = PPC_DECAP;
7177 else if (unformat (input, "ppc none"))
7178 has_ppc_option = PPC_NONE;
7182 M (IOAM_ENABLE, ioam_enable);
7183 mp->id = htons (id);
7184 mp->trace_ppc = has_ppc_option;
7185 mp->pow_enable = has_pow_option;
7186 mp->trace_enable = has_trace_option;
7197 api_ioam_disable (vat_main_t * vam)
7199 vl_api_ioam_disable_t *mp;
7202 M (IOAM_DISABLE, ioam_disable);
7209 api_sr_tunnel_add_del (vat_main_t * vam)
7211 unformat_input_t *i = vam->input;
7212 vl_api_sr_tunnel_add_del_t *mp;
7216 ip6_address_t src_address;
7217 int src_address_set = 0;
7218 ip6_address_t dst_address;
7220 int dst_address_set = 0;
7222 u32 rx_table_id = 0;
7223 u32 tx_table_id = 0;
7224 ip6_address_t *segments = 0;
7225 ip6_address_t *this_seg;
7226 ip6_address_t *tags = 0;
7227 ip6_address_t *this_tag;
7228 ip6_address_t next_address, tag;
7230 u8 *policy_name = 0;
7232 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7234 if (unformat (i, "del"))
7236 else if (unformat (i, "name %s", &name))
7238 else if (unformat (i, "policy %s", &policy_name))
7240 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
7242 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
7244 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
7245 src_address_set = 1;
7246 else if (unformat (i, "dst %U/%d",
7247 unformat_ip6_address, &dst_address, &dst_mask_width))
7248 dst_address_set = 1;
7249 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
7251 vec_add2 (segments, this_seg, 1);
7252 clib_memcpy (this_seg->as_u8, next_address.as_u8,
7253 sizeof (*this_seg));
7255 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
7257 vec_add2 (tags, this_tag, 1);
7258 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
7260 else if (unformat (i, "clean"))
7261 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
7262 else if (unformat (i, "protected"))
7263 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
7264 else if (unformat (i, "InPE %d", &pl_index))
7266 if (pl_index <= 0 || pl_index > 4)
7268 pl_index_range_error:
7269 errmsg ("pl index %d out of range\n", pl_index);
7273 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
7275 else if (unformat (i, "EgPE %d", &pl_index))
7277 if (pl_index <= 0 || pl_index > 4)
7278 goto pl_index_range_error;
7280 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
7282 else if (unformat (i, "OrgSrc %d", &pl_index))
7284 if (pl_index <= 0 || pl_index > 4)
7285 goto pl_index_range_error;
7287 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
7293 if (!src_address_set)
7295 errmsg ("src address required\n");
7299 if (!dst_address_set)
7301 errmsg ("dst address required\n");
7307 errmsg ("at least one sr segment required\n");
7311 M2 (SR_TUNNEL_ADD_DEL, sr_tunnel_add_del,
7312 vec_len (segments) * sizeof (ip6_address_t)
7313 + vec_len (tags) * sizeof (ip6_address_t));
7315 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
7316 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
7317 mp->dst_mask_width = dst_mask_width;
7318 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
7319 mp->n_segments = vec_len (segments);
7320 mp->n_tags = vec_len (tags);
7321 mp->is_add = is_del == 0;
7322 clib_memcpy (mp->segs_and_tags, segments,
7323 vec_len (segments) * sizeof (ip6_address_t));
7324 clib_memcpy (mp->segs_and_tags +
7325 vec_len (segments) * sizeof (ip6_address_t), tags,
7326 vec_len (tags) * sizeof (ip6_address_t));
7328 mp->outer_vrf_id = ntohl (rx_table_id);
7329 mp->inner_vrf_id = ntohl (tx_table_id);
7330 memcpy (mp->name, name, vec_len (name));
7331 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
7333 vec_free (segments);
7342 api_sr_policy_add_del (vat_main_t * vam)
7344 unformat_input_t *input = vam->input;
7345 vl_api_sr_policy_add_del_t *mp;
7349 u8 *tunnel_name = 0;
7350 u8 **tunnel_names = 0;
7355 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
7356 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
7358 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7360 if (unformat (input, "del"))
7362 else if (unformat (input, "name %s", &name))
7364 else if (unformat (input, "tunnel %s", &tunnel_name))
7368 vec_add1 (tunnel_names, tunnel_name);
7370 - length = #bytes to store in serial vector
7371 - +1 = byte to store that length
7373 tunnel_names_length += (vec_len (tunnel_name) + 1);
7384 errmsg ("policy name required\n");
7388 if ((!tunnel_set) && (!is_del))
7390 errmsg ("tunnel name required\n");
7394 M2 (SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length);
7398 mp->is_add = !is_del;
7400 memcpy (mp->name, name, vec_len (name));
7401 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
7402 u8 *serial_orig = 0;
7403 vec_validate (serial_orig, tunnel_names_length);
7404 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
7405 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
7407 for (j = 0; j < vec_len (tunnel_names); j++)
7409 tun_name_len = vec_len (tunnel_names[j]);
7410 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
7411 serial_orig += 1; // Move along one byte to store the actual tunnel name
7412 memcpy (serial_orig, tunnel_names[j], tun_name_len);
7413 serial_orig += tun_name_len; // Advance past the copy
7415 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
7417 vec_free (tunnel_names);
7418 vec_free (tunnel_name);
7426 api_sr_multicast_map_add_del (vat_main_t * vam)
7428 unformat_input_t *input = vam->input;
7429 vl_api_sr_multicast_map_add_del_t *mp;
7432 ip6_address_t multicast_address;
7433 u8 *policy_name = 0;
7434 int multicast_address_set = 0;
7436 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7438 if (unformat (input, "del"))
7442 (input, "address %U", unformat_ip6_address, &multicast_address))
7443 multicast_address_set = 1;
7444 else if (unformat (input, "sr-policy %s", &policy_name))
7450 if (!is_del && !policy_name)
7452 errmsg ("sr-policy name required\n");
7457 if (!multicast_address_set)
7459 errmsg ("address required\n");
7463 M (SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del);
7465 mp->is_add = !is_del;
7466 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
7467 clib_memcpy (mp->multicast_address, &multicast_address,
7468 sizeof (mp->multicast_address));
7471 vec_free (policy_name);
7479 #define foreach_ip4_proto_field \
7490 unformat_ip4_mask (unformat_input_t * input, va_list * args)
7492 u8 **maskp = va_arg (*args, u8 **);
7494 u8 found_something = 0;
7497 #define _(a) u8 a=0;
7498 foreach_ip4_proto_field;
7504 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7506 if (unformat (input, "version"))
7508 else if (unformat (input, "hdr_length"))
7510 else if (unformat (input, "src"))
7512 else if (unformat (input, "dst"))
7514 else if (unformat (input, "proto"))
7517 #define _(a) else if (unformat (input, #a)) a=1;
7518 foreach_ip4_proto_field
7524 #define _(a) found_something += a;
7525 foreach_ip4_proto_field;
7528 if (found_something == 0)
7531 vec_validate (mask, sizeof (*ip) - 1);
7533 ip = (ip4_header_t *) mask;
7535 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
7536 foreach_ip4_proto_field;
7539 ip->ip_version_and_header_length = 0;
7542 ip->ip_version_and_header_length |= 0xF0;
7545 ip->ip_version_and_header_length |= 0x0F;
7551 #define foreach_ip6_proto_field \
7559 unformat_ip6_mask (unformat_input_t * input, va_list * args)
7561 u8 **maskp = va_arg (*args, u8 **);
7563 u8 found_something = 0;
7565 u32 ip_version_traffic_class_and_flow_label;
7567 #define _(a) u8 a=0;
7568 foreach_ip6_proto_field;
7571 u8 traffic_class = 0;
7574 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7576 if (unformat (input, "version"))
7578 else if (unformat (input, "traffic-class"))
7580 else if (unformat (input, "flow-label"))
7582 else if (unformat (input, "src"))
7584 else if (unformat (input, "dst"))
7586 else if (unformat (input, "proto"))
7589 #define _(a) else if (unformat (input, #a)) a=1;
7590 foreach_ip6_proto_field
7596 #define _(a) found_something += a;
7597 foreach_ip6_proto_field;
7600 if (found_something == 0)
7603 vec_validate (mask, sizeof (*ip) - 1);
7605 ip = (ip6_header_t *) mask;
7607 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
7608 foreach_ip6_proto_field;
7611 ip_version_traffic_class_and_flow_label = 0;
7614 ip_version_traffic_class_and_flow_label |= 0xF0000000;
7617 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
7620 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
7622 ip->ip_version_traffic_class_and_flow_label =
7623 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
7630 unformat_l3_mask (unformat_input_t * input, va_list * args)
7632 u8 **maskp = va_arg (*args, u8 **);
7634 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7636 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
7638 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
7647 unformat_l2_mask (unformat_input_t * input, va_list * args)
7649 u8 **maskp = va_arg (*args, u8 **);
7664 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7666 if (unformat (input, "src"))
7668 else if (unformat (input, "dst"))
7670 else if (unformat (input, "proto"))
7672 else if (unformat (input, "tag1"))
7674 else if (unformat (input, "tag2"))
7676 else if (unformat (input, "ignore-tag1"))
7678 else if (unformat (input, "ignore-tag2"))
7680 else if (unformat (input, "cos1"))
7682 else if (unformat (input, "cos2"))
7684 else if (unformat (input, "dot1q"))
7686 else if (unformat (input, "dot1ad"))
7691 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
7692 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
7695 if (tag1 || ignore_tag1 || cos1 || dot1q)
7697 if (tag2 || ignore_tag2 || cos2 || dot1ad)
7700 vec_validate (mask, len - 1);
7703 memset (mask, 0xff, 6);
7706 memset (mask + 6, 0xff, 6);
7710 /* inner vlan tag */
7719 mask[21] = mask[20] = 0xff;
7740 mask[16] = mask[17] = 0xff;
7750 mask[12] = mask[13] = 0xff;
7757 unformat_classify_mask (unformat_input_t * input, va_list * args)
7759 u8 **maskp = va_arg (*args, u8 **);
7760 u32 *skipp = va_arg (*args, u32 *);
7761 u32 *matchp = va_arg (*args, u32 *);
7768 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7770 if (unformat (input, "hex %U", unformat_hex_string, &mask))
7772 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
7774 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
7780 if (mask || l2 || l3)
7784 /* "With a free Ethernet header in every package" */
7786 vec_validate (l2, 13);
7790 vec_append (mask, l3);
7795 /* Scan forward looking for the first significant mask octet */
7796 for (i = 0; i < vec_len (mask); i++)
7800 /* compute (skip, match) params */
7801 *skipp = i / sizeof (u32x4);
7802 vec_delete (mask, *skipp * sizeof (u32x4), 0);
7804 /* Pad mask to an even multiple of the vector size */
7805 while (vec_len (mask) % sizeof (u32x4))
7808 match = vec_len (mask) / sizeof (u32x4);
7810 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
7812 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
7813 if (*tmp || *(tmp + 1))
7818 clib_warning ("BUG: match 0");
7820 _vec_len (mask) = match * sizeof (u32x4);
7831 #define foreach_l2_next \
7833 _(ethernet, ETHERNET_INPUT) \
7838 unformat_l2_next_index (unformat_input_t * input, va_list * args)
7840 u32 *miss_next_indexp = va_arg (*args, u32 *);
7845 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
7849 if (unformat (input, "%d", &tmp))
7858 *miss_next_indexp = next_index;
7862 #define foreach_ip_next \
7869 unformat_ip_next_index (unformat_input_t * input, va_list * args)
7871 u32 *miss_next_indexp = va_arg (*args, u32 *);
7876 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
7880 if (unformat (input, "%d", &tmp))
7889 *miss_next_indexp = next_index;
7893 #define foreach_acl_next \
7897 unformat_acl_next_index (unformat_input_t * input, va_list * args)
7899 u32 *miss_next_indexp = va_arg (*args, u32 *);
7904 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
7908 if (unformat (input, "permit"))
7913 else if (unformat (input, "%d", &tmp))
7922 *miss_next_indexp = next_index;
7927 unformat_policer_precolor (unformat_input_t * input, va_list * args)
7929 u32 *r = va_arg (*args, u32 *);
7931 if (unformat (input, "conform-color"))
7932 *r = POLICE_CONFORM;
7933 else if (unformat (input, "exceed-color"))
7942 api_classify_add_del_table (vat_main_t * vam)
7944 unformat_input_t *i = vam->input;
7945 vl_api_classify_add_del_table_t *mp;
7951 u32 table_index = ~0;
7952 u32 next_table_index = ~0;
7953 u32 miss_next_index = ~0;
7954 u32 memory_size = 32 << 20;
7958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7960 if (unformat (i, "del"))
7962 else if (unformat (i, "buckets %d", &nbuckets))
7964 else if (unformat (i, "memory_size %d", &memory_size))
7966 else if (unformat (i, "skip %d", &skip))
7968 else if (unformat (i, "match %d", &match))
7970 else if (unformat (i, "table %d", &table_index))
7972 else if (unformat (i, "mask %U", unformat_classify_mask,
7973 &mask, &skip, &match))
7975 else if (unformat (i, "next-table %d", &next_table_index))
7977 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
7980 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
7983 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
7990 if (is_add && mask == 0)
7992 errmsg ("Mask required\n");
7996 if (is_add && skip == ~0)
7998 errmsg ("skip count required\n");
8002 if (is_add && match == ~0)
8004 errmsg ("match count required\n");
8008 if (!is_add && table_index == ~0)
8010 errmsg ("table index required for delete\n");
8014 M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask));
8016 mp->is_add = is_add;
8017 mp->table_index = ntohl (table_index);
8018 mp->nbuckets = ntohl (nbuckets);
8019 mp->memory_size = ntohl (memory_size);
8020 mp->skip_n_vectors = ntohl (skip);
8021 mp->match_n_vectors = ntohl (match);
8022 mp->next_table_index = ntohl (next_table_index);
8023 mp->miss_next_index = ntohl (miss_next_index);
8024 clib_memcpy (mp->mask, mask, vec_len (mask));
8034 unformat_ip4_match (unformat_input_t * input, va_list * args)
8036 u8 **matchp = va_arg (*args, u8 **);
8043 int src = 0, dst = 0;
8044 ip4_address_t src_val, dst_val;
8051 int fragment_id = 0;
8052 u32 fragment_id_val;
8058 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8060 if (unformat (input, "version %d", &version_val))
8062 else if (unformat (input, "hdr_length %d", &hdr_length_val))
8064 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
8066 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
8068 else if (unformat (input, "proto %d", &proto_val))
8070 else if (unformat (input, "tos %d", &tos_val))
8072 else if (unformat (input, "length %d", &length_val))
8074 else if (unformat (input, "fragment_id %d", &fragment_id_val))
8076 else if (unformat (input, "ttl %d", &ttl_val))
8078 else if (unformat (input, "checksum %d", &checksum_val))
8084 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
8085 + ttl + checksum == 0)
8089 * Aligned because we use the real comparison functions
8091 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
8093 ip = (ip4_header_t *) match;
8095 /* These are realistically matched in practice */
8097 ip->src_address.as_u32 = src_val.as_u32;
8100 ip->dst_address.as_u32 = dst_val.as_u32;
8103 ip->protocol = proto_val;
8106 /* These are not, but they're included for completeness */
8108 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
8111 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
8117 ip->length = length_val;
8123 ip->checksum = checksum_val;
8130 unformat_ip6_match (unformat_input_t * input, va_list * args)
8132 u8 **matchp = va_arg (*args, u8 **);
8137 u8 traffic_class = 0;
8138 u32 traffic_class_val = 0;
8141 int src = 0, dst = 0;
8142 ip6_address_t src_val, dst_val;
8145 int payload_length = 0;
8146 u32 payload_length_val;
8149 u32 ip_version_traffic_class_and_flow_label;
8151 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8153 if (unformat (input, "version %d", &version_val))
8155 else if (unformat (input, "traffic_class %d", &traffic_class_val))
8157 else if (unformat (input, "flow_label %d", &flow_label_val))
8159 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
8161 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
8163 else if (unformat (input, "proto %d", &proto_val))
8165 else if (unformat (input, "payload_length %d", &payload_length_val))
8167 else if (unformat (input, "hop_limit %d", &hop_limit_val))
8173 if (version + traffic_class + flow_label + src + dst + proto +
8174 payload_length + hop_limit == 0)
8178 * Aligned because we use the real comparison functions
8180 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
8182 ip = (ip6_header_t *) match;
8185 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
8188 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
8191 ip->protocol = proto_val;
8193 ip_version_traffic_class_and_flow_label = 0;
8196 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
8199 ip_version_traffic_class_and_flow_label |=
8200 (traffic_class_val & 0xFF) << 20;
8203 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
8205 ip->ip_version_traffic_class_and_flow_label =
8206 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8209 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
8212 ip->hop_limit = hop_limit_val;
8219 unformat_l3_match (unformat_input_t * input, va_list * args)
8221 u8 **matchp = va_arg (*args, u8 **);
8223 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8225 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
8227 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
8236 unformat_vlan_tag (unformat_input_t * input, va_list * args)
8238 u8 *tagp = va_arg (*args, u8 *);
8241 if (unformat (input, "%d", &tag))
8243 tagp[0] = (tag >> 8) & 0x0F;
8244 tagp[1] = tag & 0xFF;
8252 unformat_l2_match (unformat_input_t * input, va_list * args)
8254 u8 **matchp = va_arg (*args, u8 **);
8274 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8276 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
8279 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
8281 else if (unformat (input, "proto %U",
8282 unformat_ethernet_type_host_byte_order, &proto_val))
8284 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
8286 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
8288 else if (unformat (input, "ignore-tag1"))
8290 else if (unformat (input, "ignore-tag2"))
8292 else if (unformat (input, "cos1 %d", &cos1_val))
8294 else if (unformat (input, "cos2 %d", &cos2_val))
8299 if ((src + dst + proto + tag1 + tag2 +
8300 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8303 if (tag1 || ignore_tag1 || cos1)
8305 if (tag2 || ignore_tag2 || cos2)
8308 vec_validate_aligned (match, len - 1, sizeof (u32x4));
8311 clib_memcpy (match, dst_val, 6);
8314 clib_memcpy (match + 6, src_val, 6);
8318 /* inner vlan tag */
8319 match[19] = tag2_val[1];
8320 match[18] = tag2_val[0];
8322 match[18] |= (cos2_val & 0x7) << 5;
8325 match[21] = proto_val & 0xff;
8326 match[20] = proto_val >> 8;
8330 match[15] = tag1_val[1];
8331 match[14] = tag1_val[0];
8334 match[14] |= (cos1_val & 0x7) << 5;
8340 match[15] = tag1_val[1];
8341 match[14] = tag1_val[0];
8344 match[17] = proto_val & 0xff;
8345 match[16] = proto_val >> 8;
8348 match[14] |= (cos1_val & 0x7) << 5;
8354 match[18] |= (cos2_val & 0x7) << 5;
8356 match[14] |= (cos1_val & 0x7) << 5;
8359 match[13] = proto_val & 0xff;
8360 match[12] = proto_val >> 8;
8369 unformat_classify_match (unformat_input_t * input, va_list * args)
8371 u8 **matchp = va_arg (*args, u8 **);
8372 u32 skip_n_vectors = va_arg (*args, u32);
8373 u32 match_n_vectors = va_arg (*args, u32);
8379 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8381 if (unformat (input, "hex %U", unformat_hex_string, &match))
8383 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
8385 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
8391 if (match || l2 || l3)
8395 /* "Win a free Ethernet header in every packet" */
8397 vec_validate_aligned (l2, 13, sizeof (u32x4));
8401 vec_append_aligned (match, l3, sizeof (u32x4));
8406 /* Make sure the vector is big enough even if key is all 0's */
8407 vec_validate_aligned
8408 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
8411 /* Set size, include skipped vectors */
8412 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
8423 api_classify_add_del_session (vat_main_t * vam)
8425 unformat_input_t *i = vam->input;
8426 vl_api_classify_add_del_session_t *mp;
8428 u32 table_index = ~0;
8429 u32 hit_next_index = ~0;
8430 u32 opaque_index = ~0;
8434 u32 skip_n_vectors = 0;
8435 u32 match_n_vectors = 0;
8438 * Warning: you have to supply skip_n and match_n
8439 * because the API client cant simply look at the classify
8443 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8445 if (unformat (i, "del"))
8447 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
8450 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
8453 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
8456 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
8458 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
8460 else if (unformat (i, "opaque-index %d", &opaque_index))
8462 else if (unformat (i, "skip_n %d", &skip_n_vectors))
8464 else if (unformat (i, "match_n %d", &match_n_vectors))
8466 else if (unformat (i, "match %U", unformat_classify_match,
8467 &match, skip_n_vectors, match_n_vectors))
8469 else if (unformat (i, "advance %d", &advance))
8471 else if (unformat (i, "table-index %d", &table_index))
8477 if (table_index == ~0)
8479 errmsg ("Table index required\n");
8483 if (is_add && match == 0)
8485 errmsg ("Match value required\n");
8489 M2 (CLASSIFY_ADD_DEL_SESSION, classify_add_del_session, vec_len (match));
8491 mp->is_add = is_add;
8492 mp->table_index = ntohl (table_index);
8493 mp->hit_next_index = ntohl (hit_next_index);
8494 mp->opaque_index = ntohl (opaque_index);
8495 mp->advance = ntohl (advance);
8496 clib_memcpy (mp->match, match, vec_len (match));
8505 api_classify_set_interface_ip_table (vat_main_t * vam)
8507 unformat_input_t *i = vam->input;
8508 vl_api_classify_set_interface_ip_table_t *mp;
8511 int sw_if_index_set;
8512 u32 table_index = ~0;
8515 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8517 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8518 sw_if_index_set = 1;
8519 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8520 sw_if_index_set = 1;
8521 else if (unformat (i, "table %d", &table_index))
8525 clib_warning ("parse error '%U'", format_unformat_error, i);
8530 if (sw_if_index_set == 0)
8532 errmsg ("missing interface name or sw_if_index\n");
8537 M (CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table);
8539 mp->sw_if_index = ntohl (sw_if_index);
8540 mp->table_index = ntohl (table_index);
8541 mp->is_ipv6 = is_ipv6;
8550 api_classify_set_interface_l2_tables (vat_main_t * vam)
8552 unformat_input_t *i = vam->input;
8553 vl_api_classify_set_interface_l2_tables_t *mp;
8556 int sw_if_index_set;
8557 u32 ip4_table_index = ~0;
8558 u32 ip6_table_index = ~0;
8559 u32 other_table_index = ~0;
8562 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8564 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8565 sw_if_index_set = 1;
8566 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8567 sw_if_index_set = 1;
8568 else if (unformat (i, "ip4-table %d", &ip4_table_index))
8570 else if (unformat (i, "ip6-table %d", &ip6_table_index))
8572 else if (unformat (i, "other-table %d", &other_table_index))
8574 else if (unformat (i, "is-input %d", &is_input))
8578 clib_warning ("parse error '%U'", format_unformat_error, i);
8583 if (sw_if_index_set == 0)
8585 errmsg ("missing interface name or sw_if_index\n");
8590 M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables);
8592 mp->sw_if_index = ntohl (sw_if_index);
8593 mp->ip4_table_index = ntohl (ip4_table_index);
8594 mp->ip6_table_index = ntohl (ip6_table_index);
8595 mp->other_table_index = ntohl (other_table_index);
8596 mp->is_input = (u8) is_input;
8605 api_set_ipfix_exporter (vat_main_t * vam)
8607 unformat_input_t *i = vam->input;
8608 vl_api_set_ipfix_exporter_t *mp;
8609 ip4_address_t collector_address;
8610 u8 collector_address_set = 0;
8611 u32 collector_port = ~0;
8612 ip4_address_t src_address;
8613 u8 src_address_set = 0;
8616 u32 template_interval = ~0;
8617 u8 udp_checksum = 0;
8620 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8622 if (unformat (i, "collector_address %U", unformat_ip4_address,
8623 &collector_address))
8624 collector_address_set = 1;
8625 else if (unformat (i, "collector_port %d", &collector_port))
8627 else if (unformat (i, "src_address %U", unformat_ip4_address,
8629 src_address_set = 1;
8630 else if (unformat (i, "vrf_id %d", &vrf_id))
8632 else if (unformat (i, "path_mtu %d", &path_mtu))
8634 else if (unformat (i, "template_interval %d", &template_interval))
8636 else if (unformat (i, "udp_checksum"))
8642 if (collector_address_set == 0)
8644 errmsg ("collector_address required\n");
8648 if (src_address_set == 0)
8650 errmsg ("src_address required\n");
8654 M (SET_IPFIX_EXPORTER, set_ipfix_exporter);
8656 memcpy (mp->collector_address, collector_address.data,
8657 sizeof (collector_address.data));
8658 mp->collector_port = htons ((u16) collector_port);
8659 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
8660 mp->vrf_id = htonl (vrf_id);
8661 mp->path_mtu = htonl (path_mtu);
8662 mp->template_interval = htonl (template_interval);
8663 mp->udp_checksum = udp_checksum;
8671 api_set_ipfix_classify_stream (vat_main_t * vam)
8673 unformat_input_t *i = vam->input;
8674 vl_api_set_ipfix_classify_stream_t *mp;
8676 u32 src_port = UDP_DST_PORT_ipfix;
8679 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8681 if (unformat (i, "domain %d", &domain_id))
8683 else if (unformat (i, "src_port %d", &src_port))
8687 errmsg ("unknown input `%U'", format_unformat_error, i);
8692 M (SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream);
8694 mp->domain_id = htonl (domain_id);
8695 mp->src_port = htons ((u16) src_port);
8703 api_ipfix_classify_table_add_del (vat_main_t * vam)
8705 unformat_input_t *i = vam->input;
8706 vl_api_ipfix_classify_table_add_del_t *mp;
8708 u32 classify_table_index = ~0;
8710 u8 transport_protocol = 255;
8713 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8715 if (unformat (i, "add"))
8717 else if (unformat (i, "del"))
8719 else if (unformat (i, "table %d", &classify_table_index))
8721 else if (unformat (i, "ip4"))
8723 else if (unformat (i, "ip6"))
8725 else if (unformat (i, "tcp"))
8726 transport_protocol = 6;
8727 else if (unformat (i, "udp"))
8728 transport_protocol = 17;
8731 errmsg ("unknown input `%U'", format_unformat_error, i);
8738 errmsg ("expecting: add|del");
8741 if (classify_table_index == ~0)
8743 errmsg ("classifier table not specified");
8746 if (ip_version == 0)
8748 errmsg ("IP version not specified");
8752 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del);
8754 mp->is_add = is_add;
8755 mp->table_id = htonl (classify_table_index);
8756 mp->ip_version = ip_version;
8757 mp->transport_protocol = transport_protocol;
8765 api_get_node_index (vat_main_t * vam)
8767 unformat_input_t *i = vam->input;
8768 vl_api_get_node_index_t *mp;
8772 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8774 if (unformat (i, "node %s", &name))
8781 errmsg ("node name required\n");
8784 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
8786 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
8790 M (GET_NODE_INDEX, get_node_index);
8791 clib_memcpy (mp->node_name, name, vec_len (name));
8801 api_get_next_index (vat_main_t * vam)
8803 unformat_input_t *i = vam->input;
8804 vl_api_get_next_index_t *mp;
8806 u8 *node_name = 0, *next_node_name = 0;
8808 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8810 if (unformat (i, "node-name %s", &node_name))
8812 else if (unformat (i, "next-node-name %s", &next_node_name))
8818 errmsg ("node name required\n");
8821 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
8823 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
8827 if (next_node_name == 0)
8829 errmsg ("next node name required\n");
8832 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
8834 errmsg ("next node name too long, max %d\n", ARRAY_LEN (mp->next_name));
8838 M (GET_NEXT_INDEX, get_next_index);
8839 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
8840 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
8841 vec_free (node_name);
8842 vec_free (next_node_name);
8851 api_add_node_next (vat_main_t * vam)
8853 unformat_input_t *i = vam->input;
8854 vl_api_add_node_next_t *mp;
8859 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8861 if (unformat (i, "node %s", &name))
8863 else if (unformat (i, "next %s", &next))
8870 errmsg ("node name required\n");
8873 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
8875 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
8880 errmsg ("next node required\n");
8883 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
8885 errmsg ("next name too long, max %d\n", ARRAY_LEN (mp->next_name));
8889 M (ADD_NODE_NEXT, add_node_next);
8890 clib_memcpy (mp->node_name, name, vec_len (name));
8891 clib_memcpy (mp->next_name, next, vec_len (next));
8902 api_l2tpv3_create_tunnel (vat_main_t * vam)
8904 unformat_input_t *i = vam->input;
8905 ip6_address_t client_address, our_address;
8906 int client_address_set = 0;
8907 int our_address_set = 0;
8908 u32 local_session_id = 0;
8909 u32 remote_session_id = 0;
8910 u64 local_cookie = 0;
8911 u64 remote_cookie = 0;
8912 u8 l2_sublayer_present = 0;
8913 vl_api_l2tpv3_create_tunnel_t *mp;
8916 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8918 if (unformat (i, "client_address %U", unformat_ip6_address,
8920 client_address_set = 1;
8921 else if (unformat (i, "our_address %U", unformat_ip6_address,
8923 our_address_set = 1;
8924 else if (unformat (i, "local_session_id %d", &local_session_id))
8926 else if (unformat (i, "remote_session_id %d", &remote_session_id))
8928 else if (unformat (i, "local_cookie %lld", &local_cookie))
8930 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
8932 else if (unformat (i, "l2-sublayer-present"))
8933 l2_sublayer_present = 1;
8938 if (client_address_set == 0)
8940 errmsg ("client_address required\n");
8944 if (our_address_set == 0)
8946 errmsg ("our_address required\n");
8950 M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel);
8952 clib_memcpy (mp->client_address, client_address.as_u8,
8953 sizeof (mp->client_address));
8955 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
8957 mp->local_session_id = ntohl (local_session_id);
8958 mp->remote_session_id = ntohl (remote_session_id);
8959 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
8960 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
8961 mp->l2_sublayer_present = l2_sublayer_present;
8971 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
8973 unformat_input_t *i = vam->input;
8975 u8 sw_if_index_set = 0;
8976 u64 new_local_cookie = 0;
8977 u64 new_remote_cookie = 0;
8978 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
8981 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8983 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8984 sw_if_index_set = 1;
8985 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8986 sw_if_index_set = 1;
8987 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
8989 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
8995 if (sw_if_index_set == 0)
8997 errmsg ("missing interface name or sw_if_index\n");
9001 M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies);
9003 mp->sw_if_index = ntohl (sw_if_index);
9004 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
9005 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
9014 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
9016 unformat_input_t *i = vam->input;
9017 vl_api_l2tpv3_interface_enable_disable_t *mp;
9020 u8 sw_if_index_set = 0;
9021 u8 enable_disable = 1;
9023 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9025 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9026 sw_if_index_set = 1;
9027 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9028 sw_if_index_set = 1;
9029 else if (unformat (i, "enable"))
9031 else if (unformat (i, "disable"))
9037 if (sw_if_index_set == 0)
9039 errmsg ("missing interface name or sw_if_index\n");
9043 M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable);
9045 mp->sw_if_index = ntohl (sw_if_index);
9046 mp->enable_disable = enable_disable;
9055 api_l2tpv3_set_lookup_key (vat_main_t * vam)
9057 unformat_input_t *i = vam->input;
9058 vl_api_l2tpv3_set_lookup_key_t *mp;
9062 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9064 if (unformat (i, "lookup_v6_src"))
9065 key = L2T_LOOKUP_SRC_ADDRESS;
9066 else if (unformat (i, "lookup_v6_dst"))
9067 key = L2T_LOOKUP_DST_ADDRESS;
9068 else if (unformat (i, "lookup_session_id"))
9069 key = L2T_LOOKUP_SESSION_ID;
9074 if (key == (u8) ~ 0)
9076 errmsg ("l2tp session lookup key unset\n");
9080 M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key);
9090 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
9091 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
9093 vat_main_t *vam = &vat_main;
9095 fformat (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)\n",
9096 format_ip6_address, mp->our_address,
9097 format_ip6_address, mp->client_address,
9098 clib_net_to_host_u32 (mp->sw_if_index));
9101 " local cookies %016llx %016llx remote cookie %016llx\n",
9102 clib_net_to_host_u64 (mp->local_cookie[0]),
9103 clib_net_to_host_u64 (mp->local_cookie[1]),
9104 clib_net_to_host_u64 (mp->remote_cookie));
9106 fformat (vam->ofp, " local session-id %d remote session-id %d\n",
9107 clib_net_to_host_u32 (mp->local_session_id),
9108 clib_net_to_host_u32 (mp->remote_session_id));
9110 fformat (vam->ofp, " l2 specific sublayer %s\n\n",
9111 mp->l2_sublayer_present ? "preset" : "absent");
9115 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
9116 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
9118 vat_main_t *vam = &vat_main;
9119 vat_json_node_t *node = NULL;
9120 struct in6_addr addr;
9122 if (VAT_JSON_ARRAY != vam->json_tree.type)
9124 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9125 vat_json_init_array (&vam->json_tree);
9127 node = vat_json_array_add (&vam->json_tree);
9129 vat_json_init_object (node);
9131 clib_memcpy (&addr, mp->our_address, sizeof (addr));
9132 vat_json_object_add_ip6 (node, "our_address", addr);
9133 clib_memcpy (&addr, mp->client_address, sizeof (addr));
9134 vat_json_object_add_ip6 (node, "client_address", addr);
9136 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
9137 vat_json_init_array (lc);
9138 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
9139 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
9140 vat_json_object_add_uint (node, "remote_cookie",
9141 clib_net_to_host_u64 (mp->remote_cookie));
9143 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
9144 vat_json_object_add_uint (node, "local_session_id",
9145 clib_net_to_host_u32 (mp->local_session_id));
9146 vat_json_object_add_uint (node, "remote_session_id",
9147 clib_net_to_host_u32 (mp->remote_session_id));
9148 vat_json_object_add_string_copy (node, "l2_sublayer",
9149 mp->l2_sublayer_present ? (u8 *) "present"
9154 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
9156 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
9159 /* Get list of l2tpv3-tunnel interfaces */
9160 M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump);
9163 /* Use a control ping for synchronization */
9165 vl_api_control_ping_t *mp;
9166 M (CONTROL_PING, control_ping);
9173 static void vl_api_sw_interface_tap_details_t_handler
9174 (vl_api_sw_interface_tap_details_t * mp)
9176 vat_main_t *vam = &vat_main;
9178 fformat (vam->ofp, "%-16s %d\n",
9179 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
9182 static void vl_api_sw_interface_tap_details_t_handler_json
9183 (vl_api_sw_interface_tap_details_t * mp)
9185 vat_main_t *vam = &vat_main;
9186 vat_json_node_t *node = NULL;
9188 if (VAT_JSON_ARRAY != vam->json_tree.type)
9190 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9191 vat_json_init_array (&vam->json_tree);
9193 node = vat_json_array_add (&vam->json_tree);
9195 vat_json_init_object (node);
9196 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9197 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
9201 api_sw_interface_tap_dump (vat_main_t * vam)
9203 vl_api_sw_interface_tap_dump_t *mp;
9206 fformat (vam->ofp, "\n%-16s %s\n", "dev_name", "sw_if_index");
9207 /* Get list of tap interfaces */
9208 M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump);
9211 /* Use a control ping for synchronization */
9213 vl_api_control_ping_t *mp;
9214 M (CONTROL_PING, control_ping);
9220 static uword unformat_vxlan_decap_next
9221 (unformat_input_t * input, va_list * args)
9223 u32 *result = va_arg (*args, u32 *);
9226 if (unformat (input, "drop"))
9227 *result = VXLAN_INPUT_NEXT_DROP;
9228 else if (unformat (input, "ip4"))
9229 *result = VXLAN_INPUT_NEXT_IP4_INPUT;
9230 else if (unformat (input, "ip6"))
9231 *result = VXLAN_INPUT_NEXT_IP6_INPUT;
9232 else if (unformat (input, "l2"))
9233 *result = VXLAN_INPUT_NEXT_L2_INPUT;
9234 else if (unformat (input, "%d", &tmp))
9242 api_vxlan_add_del_tunnel (vat_main_t * vam)
9244 unformat_input_t *line_input = vam->input;
9245 vl_api_vxlan_add_del_tunnel_t *mp;
9247 ip4_address_t src4, dst4;
9248 ip6_address_t src6, dst6;
9250 u8 ipv4_set = 0, ipv6_set = 0;
9253 u32 encap_vrf_id = 0;
9254 u32 decap_next_index = ~0;
9257 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9259 if (unformat (line_input, "del"))
9261 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
9266 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
9271 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
9276 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
9281 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
9283 else if (unformat (line_input, "decap-next %U",
9284 unformat_vxlan_decap_next, &decap_next_index))
9286 else if (unformat (line_input, "vni %d", &vni))
9290 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
9297 errmsg ("tunnel src address not specified\n");
9302 errmsg ("tunnel dst address not specified\n");
9306 if (ipv4_set && ipv6_set)
9308 errmsg ("both IPv4 and IPv6 addresses specified");
9312 if ((vni == 0) || (vni >> 24))
9314 errmsg ("vni not specified or out of range\n");
9318 M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel);
9322 clib_memcpy (&mp->src_address, &src6, sizeof (src6));
9323 clib_memcpy (&mp->dst_address, &dst6, sizeof (dst6));
9327 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
9328 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
9330 mp->encap_vrf_id = ntohl (encap_vrf_id);
9331 mp->decap_next_index = ntohl (decap_next_index);
9332 mp->vni = ntohl (vni);
9333 mp->is_add = is_add;
9334 mp->is_ipv6 = ipv6_set;
9342 static void vl_api_vxlan_tunnel_details_t_handler
9343 (vl_api_vxlan_tunnel_details_t * mp)
9345 vat_main_t *vam = &vat_main;
9347 fformat (vam->ofp, "%11d%24U%24U%14d%18d%13d\n",
9348 ntohl (mp->sw_if_index),
9349 format_ip46_address, &(mp->src_address[0]),
9351 format_ip46_address, &(mp->dst_address[0]),
9353 ntohl (mp->encap_vrf_id),
9354 ntohl (mp->decap_next_index), ntohl (mp->vni));
9357 static void vl_api_vxlan_tunnel_details_t_handler_json
9358 (vl_api_vxlan_tunnel_details_t * mp)
9360 vat_main_t *vam = &vat_main;
9361 vat_json_node_t *node = NULL;
9363 struct in6_addr ip6;
9365 if (VAT_JSON_ARRAY != vam->json_tree.type)
9367 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9368 vat_json_init_array (&vam->json_tree);
9370 node = vat_json_array_add (&vam->json_tree);
9372 vat_json_init_object (node);
9373 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9376 clib_memcpy (&ip6, &(mp->src_address[0]), sizeof (ip6));
9377 vat_json_object_add_ip6 (node, "src_address", ip6);
9378 clib_memcpy (&ip6, &(mp->dst_address[0]), sizeof (ip6));
9379 vat_json_object_add_ip6 (node, "dst_address", ip6);
9383 clib_memcpy (&ip4, &(mp->src_address[0]), sizeof (ip4));
9384 vat_json_object_add_ip4 (node, "src_address", ip4);
9385 clib_memcpy (&ip4, &(mp->dst_address[0]), sizeof (ip4));
9386 vat_json_object_add_ip4 (node, "dst_address", ip4);
9388 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
9389 vat_json_object_add_uint (node, "decap_next_index",
9390 ntohl (mp->decap_next_index));
9391 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
9392 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
9396 api_vxlan_tunnel_dump (vat_main_t * vam)
9398 unformat_input_t *i = vam->input;
9399 vl_api_vxlan_tunnel_dump_t *mp;
9402 u8 sw_if_index_set = 0;
9404 /* Parse args required to build the message */
9405 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9407 if (unformat (i, "sw_if_index %d", &sw_if_index))
9408 sw_if_index_set = 1;
9413 if (sw_if_index_set == 0)
9418 if (!vam->json_output)
9420 fformat (vam->ofp, "%11s%24s%24s%14s%18s%13s\n",
9421 "sw_if_index", "src_address", "dst_address",
9422 "encap_vrf_id", "decap_next_index", "vni");
9425 /* Get list of vxlan-tunnel interfaces */
9426 M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
9428 mp->sw_if_index = htonl (sw_if_index);
9432 /* Use a control ping for synchronization */
9434 vl_api_control_ping_t *mp;
9435 M (CONTROL_PING, control_ping);
9442 api_gre_add_del_tunnel (vat_main_t * vam)
9444 unformat_input_t *line_input = vam->input;
9445 vl_api_gre_add_del_tunnel_t *mp;
9447 ip4_address_t src4, dst4;
9452 u32 outer_fib_id = 0;
9454 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9456 if (unformat (line_input, "del"))
9458 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
9460 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
9462 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
9464 else if (unformat (line_input, "teb"))
9468 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
9475 errmsg ("tunnel src address not specified\n");
9480 errmsg ("tunnel dst address not specified\n");
9485 M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel);
9487 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
9488 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
9489 mp->outer_fib_id = ntohl (outer_fib_id);
9490 mp->is_add = is_add;
9499 static void vl_api_gre_tunnel_details_t_handler
9500 (vl_api_gre_tunnel_details_t * mp)
9502 vat_main_t *vam = &vat_main;
9504 fformat (vam->ofp, "%11d%15U%15U%6d%14d\n",
9505 ntohl (mp->sw_if_index),
9506 format_ip4_address, &mp->src_address,
9507 format_ip4_address, &mp->dst_address,
9508 mp->teb, ntohl (mp->outer_fib_id));
9511 static void vl_api_gre_tunnel_details_t_handler_json
9512 (vl_api_gre_tunnel_details_t * mp)
9514 vat_main_t *vam = &vat_main;
9515 vat_json_node_t *node = NULL;
9518 if (VAT_JSON_ARRAY != vam->json_tree.type)
9520 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9521 vat_json_init_array (&vam->json_tree);
9523 node = vat_json_array_add (&vam->json_tree);
9525 vat_json_init_object (node);
9526 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9527 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
9528 vat_json_object_add_ip4 (node, "src_address", ip4);
9529 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
9530 vat_json_object_add_ip4 (node, "dst_address", ip4);
9531 vat_json_object_add_uint (node, "teb", mp->teb);
9532 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
9536 api_gre_tunnel_dump (vat_main_t * vam)
9538 unformat_input_t *i = vam->input;
9539 vl_api_gre_tunnel_dump_t *mp;
9542 u8 sw_if_index_set = 0;
9544 /* Parse args required to build the message */
9545 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9547 if (unformat (i, "sw_if_index %d", &sw_if_index))
9548 sw_if_index_set = 1;
9553 if (sw_if_index_set == 0)
9558 if (!vam->json_output)
9560 fformat (vam->ofp, "%11s%15s%15s%6s%14s\n",
9561 "sw_if_index", "src_address", "dst_address", "teb",
9565 /* Get list of gre-tunnel interfaces */
9566 M (GRE_TUNNEL_DUMP, gre_tunnel_dump);
9568 mp->sw_if_index = htonl (sw_if_index);
9572 /* Use a control ping for synchronization */
9574 vl_api_control_ping_t *mp;
9575 M (CONTROL_PING, control_ping);
9582 api_l2_fib_clear_table (vat_main_t * vam)
9584 // unformat_input_t * i = vam->input;
9585 vl_api_l2_fib_clear_table_t *mp;
9588 M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table);
9597 api_l2_interface_efp_filter (vat_main_t * vam)
9599 unformat_input_t *i = vam->input;
9600 vl_api_l2_interface_efp_filter_t *mp;
9604 u8 sw_if_index_set = 0;
9606 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9608 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9609 sw_if_index_set = 1;
9610 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9611 sw_if_index_set = 1;
9612 else if (unformat (i, "enable"))
9614 else if (unformat (i, "disable"))
9618 clib_warning ("parse error '%U'", format_unformat_error, i);
9623 if (sw_if_index_set == 0)
9625 errmsg ("missing sw_if_index\n");
9629 M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter);
9631 mp->sw_if_index = ntohl (sw_if_index);
9632 mp->enable_disable = enable;
9640 #define foreach_vtr_op \
9641 _("disable", L2_VTR_DISABLED) \
9642 _("push-1", L2_VTR_PUSH_1) \
9643 _("push-2", L2_VTR_PUSH_2) \
9644 _("pop-1", L2_VTR_POP_1) \
9645 _("pop-2", L2_VTR_POP_2) \
9646 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
9647 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
9648 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
9649 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
9652 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
9654 unformat_input_t *i = vam->input;
9655 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
9658 u8 sw_if_index_set = 0;
9665 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9667 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9668 sw_if_index_set = 1;
9669 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9670 sw_if_index_set = 1;
9671 else if (unformat (i, "vtr_op %d", &vtr_op))
9673 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
9676 else if (unformat (i, "push_dot1q %d", &push_dot1q))
9678 else if (unformat (i, "tag1 %d", &tag1))
9680 else if (unformat (i, "tag2 %d", &tag2))
9684 clib_warning ("parse error '%U'", format_unformat_error, i);
9689 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
9691 errmsg ("missing vtr operation or sw_if_index\n");
9695 M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)
9696 mp->sw_if_index = ntohl (sw_if_index);
9697 mp->vtr_op = ntohl (vtr_op);
9698 mp->push_dot1q = ntohl (push_dot1q);
9699 mp->tag1 = ntohl (tag1);
9700 mp->tag2 = ntohl (tag2);
9709 api_create_vhost_user_if (vat_main_t * vam)
9711 unformat_input_t *i = vam->input;
9712 vl_api_create_vhost_user_if_t *mp;
9716 u8 file_name_set = 0;
9717 u32 custom_dev_instance = ~0;
9719 u8 use_custom_mac = 0;
9721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9723 if (unformat (i, "socket %s", &file_name))
9727 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
9729 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
9731 else if (unformat (i, "server"))
9737 if (file_name_set == 0)
9739 errmsg ("missing socket file name\n");
9743 if (vec_len (file_name) > 255)
9745 errmsg ("socket file name too long\n");
9748 vec_add1 (file_name, 0);
9750 M (CREATE_VHOST_USER_IF, create_vhost_user_if);
9752 mp->is_server = is_server;
9753 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
9754 vec_free (file_name);
9755 if (custom_dev_instance != ~0)
9758 mp->custom_dev_instance = ntohl (custom_dev_instance);
9760 mp->use_custom_mac = use_custom_mac;
9761 clib_memcpy (mp->mac_address, hwaddr, 6);
9770 api_modify_vhost_user_if (vat_main_t * vam)
9772 unformat_input_t *i = vam->input;
9773 vl_api_modify_vhost_user_if_t *mp;
9777 u8 file_name_set = 0;
9778 u32 custom_dev_instance = ~0;
9779 u8 sw_if_index_set = 0;
9780 u32 sw_if_index = (u32) ~ 0;
9782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9784 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9785 sw_if_index_set = 1;
9786 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9787 sw_if_index_set = 1;
9788 else if (unformat (i, "socket %s", &file_name))
9792 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
9794 else if (unformat (i, "server"))
9800 if (sw_if_index_set == 0)
9802 errmsg ("missing sw_if_index or interface name\n");
9806 if (file_name_set == 0)
9808 errmsg ("missing socket file name\n");
9812 if (vec_len (file_name) > 255)
9814 errmsg ("socket file name too long\n");
9817 vec_add1 (file_name, 0);
9819 M (MODIFY_VHOST_USER_IF, modify_vhost_user_if);
9821 mp->sw_if_index = ntohl (sw_if_index);
9822 mp->is_server = is_server;
9823 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
9824 vec_free (file_name);
9825 if (custom_dev_instance != ~0)
9828 mp->custom_dev_instance = ntohl (custom_dev_instance);
9838 api_delete_vhost_user_if (vat_main_t * vam)
9840 unformat_input_t *i = vam->input;
9841 vl_api_delete_vhost_user_if_t *mp;
9843 u32 sw_if_index = ~0;
9844 u8 sw_if_index_set = 0;
9846 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9848 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9849 sw_if_index_set = 1;
9850 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9851 sw_if_index_set = 1;
9856 if (sw_if_index_set == 0)
9858 errmsg ("missing sw_if_index or interface name\n");
9863 M (DELETE_VHOST_USER_IF, delete_vhost_user_if);
9865 mp->sw_if_index = ntohl (sw_if_index);
9873 static void vl_api_sw_interface_vhost_user_details_t_handler
9874 (vl_api_sw_interface_vhost_user_details_t * mp)
9876 vat_main_t *vam = &vat_main;
9878 fformat (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s\n",
9879 (char *) mp->interface_name,
9880 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
9881 clib_net_to_host_u64 (mp->features), mp->is_server,
9882 ntohl (mp->num_regions), (char *) mp->sock_filename);
9883 fformat (vam->ofp, " Status: '%s'\n", strerror (ntohl (mp->sock_errno)));
9886 static void vl_api_sw_interface_vhost_user_details_t_handler_json
9887 (vl_api_sw_interface_vhost_user_details_t * mp)
9889 vat_main_t *vam = &vat_main;
9890 vat_json_node_t *node = NULL;
9892 if (VAT_JSON_ARRAY != vam->json_tree.type)
9894 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9895 vat_json_init_array (&vam->json_tree);
9897 node = vat_json_array_add (&vam->json_tree);
9899 vat_json_init_object (node);
9900 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9901 vat_json_object_add_string_copy (node, "interface_name",
9902 mp->interface_name);
9903 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
9904 ntohl (mp->virtio_net_hdr_sz));
9905 vat_json_object_add_uint (node, "features",
9906 clib_net_to_host_u64 (mp->features));
9907 vat_json_object_add_uint (node, "is_server", mp->is_server);
9908 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
9909 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
9910 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
9914 api_sw_interface_vhost_user_dump (vat_main_t * vam)
9916 vl_api_sw_interface_vhost_user_dump_t *mp;
9919 "Interface name idx hdr_sz features server regions filename\n");
9921 /* Get list of vhost-user interfaces */
9922 M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump);
9925 /* Use a control ping for synchronization */
9927 vl_api_control_ping_t *mp;
9928 M (CONTROL_PING, control_ping);
9935 api_show_version (vat_main_t * vam)
9937 vl_api_show_version_t *mp;
9940 M (SHOW_VERSION, show_version);
9950 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
9952 unformat_input_t *line_input = vam->input;
9953 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
9955 ip4_address_t local4, remote4;
9956 ip6_address_t local6, remote6;
9958 u8 ipv4_set = 0, ipv6_set = 0;
9961 u32 encap_vrf_id = 0;
9962 u32 decap_vrf_id = 0;
9967 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9969 if (unformat (line_input, "del"))
9971 else if (unformat (line_input, "local %U",
9972 unformat_ip4_address, &local4))
9977 else if (unformat (line_input, "remote %U",
9978 unformat_ip4_address, &remote4))
9983 else if (unformat (line_input, "local %U",
9984 unformat_ip6_address, &local6))
9989 else if (unformat (line_input, "remote %U",
9990 unformat_ip6_address, &remote6))
9995 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
9997 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
9999 else if (unformat (line_input, "vni %d", &vni))
10001 else if (unformat (line_input, "next-ip4"))
10003 else if (unformat (line_input, "next-ip6"))
10005 else if (unformat (line_input, "next-ethernet"))
10007 else if (unformat (line_input, "next-nsh"))
10011 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
10016 if (local_set == 0)
10018 errmsg ("tunnel local address not specified\n");
10021 if (remote_set == 0)
10023 errmsg ("tunnel remote address not specified\n");
10026 if (ipv4_set && ipv6_set)
10028 errmsg ("both IPv4 and IPv6 addresses specified");
10034 errmsg ("vni not specified\n");
10038 M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel);
10043 clib_memcpy (&mp->local, &local6, sizeof (local6));
10044 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
10048 clib_memcpy (&mp->local, &local4, sizeof (local4));
10049 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
10052 mp->encap_vrf_id = ntohl (encap_vrf_id);
10053 mp->decap_vrf_id = ntohl (decap_vrf_id);
10054 mp->protocol = ntohl (protocol);
10055 mp->vni = ntohl (vni);
10056 mp->is_add = is_add;
10057 mp->is_ipv6 = ipv6_set;
10065 static void vl_api_vxlan_gpe_tunnel_details_t_handler
10066 (vl_api_vxlan_gpe_tunnel_details_t * mp)
10068 vat_main_t *vam = &vat_main;
10070 fformat (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d\n",
10071 ntohl (mp->sw_if_index),
10072 format_ip46_address, &(mp->local[0]),
10073 format_ip46_address, &(mp->remote[0]),
10075 ntohl (mp->protocol),
10076 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
10079 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
10080 (vl_api_vxlan_gpe_tunnel_details_t * mp)
10082 vat_main_t *vam = &vat_main;
10083 vat_json_node_t *node = NULL;
10084 struct in_addr ip4;
10085 struct in6_addr ip6;
10087 if (VAT_JSON_ARRAY != vam->json_tree.type)
10089 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10090 vat_json_init_array (&vam->json_tree);
10092 node = vat_json_array_add (&vam->json_tree);
10094 vat_json_init_object (node);
10095 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10098 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
10099 vat_json_object_add_ip6 (node, "local", ip6);
10100 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
10101 vat_json_object_add_ip6 (node, "remote", ip6);
10105 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
10106 vat_json_object_add_ip4 (node, "local", ip4);
10107 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
10108 vat_json_object_add_ip4 (node, "remote", ip4);
10110 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10111 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
10112 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10113 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
10114 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10118 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
10120 unformat_input_t *i = vam->input;
10121 vl_api_vxlan_gpe_tunnel_dump_t *mp;
10124 u8 sw_if_index_set = 0;
10126 /* Parse args required to build the message */
10127 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10129 if (unformat (i, "sw_if_index %d", &sw_if_index))
10130 sw_if_index_set = 1;
10135 if (sw_if_index_set == 0)
10140 if (!vam->json_output)
10142 fformat (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s\n",
10143 "sw_if_index", "local", "remote", "vni",
10144 "protocol", "encap_vrf_id", "decap_vrf_id");
10147 /* Get list of vxlan-tunnel interfaces */
10148 M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump);
10150 mp->sw_if_index = htonl (sw_if_index);
10154 /* Use a control ping for synchronization */
10156 vl_api_control_ping_t *mp;
10157 M (CONTROL_PING, control_ping);
10164 format_l2_fib_mac_address (u8 * s, va_list * args)
10166 u8 *a = va_arg (*args, u8 *);
10168 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
10169 a[2], a[3], a[4], a[5], a[6], a[7]);
10172 static void vl_api_l2_fib_table_entry_t_handler
10173 (vl_api_l2_fib_table_entry_t * mp)
10175 vat_main_t *vam = &vat_main;
10177 fformat (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
10179 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
10180 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
10184 static void vl_api_l2_fib_table_entry_t_handler_json
10185 (vl_api_l2_fib_table_entry_t * mp)
10187 vat_main_t *vam = &vat_main;
10188 vat_json_node_t *node = NULL;
10190 if (VAT_JSON_ARRAY != vam->json_tree.type)
10192 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10193 vat_json_init_array (&vam->json_tree);
10195 node = vat_json_array_add (&vam->json_tree);
10197 vat_json_init_object (node);
10198 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
10199 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
10200 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10201 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
10202 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
10203 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
10207 api_l2_fib_table_dump (vat_main_t * vam)
10209 unformat_input_t *i = vam->input;
10210 vl_api_l2_fib_table_dump_t *mp;
10215 /* Parse args required to build the message */
10216 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10218 if (unformat (i, "bd_id %d", &bd_id))
10224 if (bd_id_set == 0)
10226 errmsg ("missing bridge domain\n");
10231 "BD-ID Mac Address sw-ndx Static Filter BVI\n");
10233 /* Get list of l2 fib entries */
10234 M (L2_FIB_TABLE_DUMP, l2_fib_table_dump);
10236 mp->bd_id = ntohl (bd_id);
10239 /* Use a control ping for synchronization */
10241 vl_api_control_ping_t *mp;
10242 M (CONTROL_PING, control_ping);
10250 api_interface_name_renumber (vat_main_t * vam)
10252 unformat_input_t *line_input = vam->input;
10253 vl_api_interface_name_renumber_t *mp;
10254 u32 sw_if_index = ~0;
10256 u32 new_show_dev_instance = ~0;
10258 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10260 if (unformat (line_input, "%U", unformat_sw_if_index, vam,
10263 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
10265 else if (unformat (line_input, "new_show_dev_instance %d",
10266 &new_show_dev_instance))
10272 if (sw_if_index == ~0)
10274 errmsg ("missing interface name or sw_if_index\n");
10278 if (new_show_dev_instance == ~0)
10280 errmsg ("missing new_show_dev_instance\n");
10284 M (INTERFACE_NAME_RENUMBER, interface_name_renumber);
10286 mp->sw_if_index = ntohl (sw_if_index);
10287 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
10294 api_want_ip4_arp_events (vat_main_t * vam)
10296 unformat_input_t *line_input = vam->input;
10297 vl_api_want_ip4_arp_events_t *mp;
10299 ip4_address_t address;
10300 int address_set = 0;
10301 u32 enable_disable = 1;
10303 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10305 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
10307 else if (unformat (line_input, "del"))
10308 enable_disable = 0;
10313 if (address_set == 0)
10315 errmsg ("missing addresses\n");
10319 M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events);
10320 mp->enable_disable = enable_disable;
10321 mp->pid = getpid ();
10322 mp->address = address.as_u32;
10329 api_want_ip6_nd_events (vat_main_t * vam)
10331 unformat_input_t *line_input = vam->input;
10332 vl_api_want_ip6_nd_events_t *mp;
10334 ip6_address_t address;
10335 int address_set = 0;
10336 u32 enable_disable = 1;
10338 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10340 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
10342 else if (unformat (line_input, "del"))
10343 enable_disable = 0;
10348 if (address_set == 0)
10350 errmsg ("missing addresses\n");
10354 M (WANT_IP6_ND_EVENTS, want_ip6_nd_events);
10355 mp->enable_disable = enable_disable;
10356 mp->pid = getpid ();
10357 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
10364 api_input_acl_set_interface (vat_main_t * vam)
10366 unformat_input_t *i = vam->input;
10367 vl_api_input_acl_set_interface_t *mp;
10370 int sw_if_index_set;
10371 u32 ip4_table_index = ~0;
10372 u32 ip6_table_index = ~0;
10373 u32 l2_table_index = ~0;
10376 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10378 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10379 sw_if_index_set = 1;
10380 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10381 sw_if_index_set = 1;
10382 else if (unformat (i, "del"))
10384 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10386 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10388 else if (unformat (i, "l2-table %d", &l2_table_index))
10392 clib_warning ("parse error '%U'", format_unformat_error, i);
10397 if (sw_if_index_set == 0)
10399 errmsg ("missing interface name or sw_if_index\n");
10403 M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface);
10405 mp->sw_if_index = ntohl (sw_if_index);
10406 mp->ip4_table_index = ntohl (ip4_table_index);
10407 mp->ip6_table_index = ntohl (ip6_table_index);
10408 mp->l2_table_index = ntohl (l2_table_index);
10409 mp->is_add = is_add;
10418 api_ip_address_dump (vat_main_t * vam)
10420 unformat_input_t *i = vam->input;
10421 vl_api_ip_address_dump_t *mp;
10422 u32 sw_if_index = ~0;
10423 u8 sw_if_index_set = 0;
10428 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10430 if (unformat (i, "sw_if_index %d", &sw_if_index))
10431 sw_if_index_set = 1;
10432 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10433 sw_if_index_set = 1;
10434 else if (unformat (i, "ipv4"))
10436 else if (unformat (i, "ipv6"))
10442 if (ipv4_set && ipv6_set)
10444 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
10448 if ((!ipv4_set) && (!ipv6_set))
10450 errmsg ("no ipv4 nor ipv6 flag set\n");
10454 if (sw_if_index_set == 0)
10456 errmsg ("missing interface name or sw_if_index\n");
10460 vam->current_sw_if_index = sw_if_index;
10461 vam->is_ipv6 = ipv6_set;
10463 M (IP_ADDRESS_DUMP, ip_address_dump);
10464 mp->sw_if_index = ntohl (sw_if_index);
10465 mp->is_ipv6 = ipv6_set;
10468 /* Use a control ping for synchronization */
10470 vl_api_control_ping_t *mp;
10471 M (CONTROL_PING, control_ping);
10478 api_ip_dump (vat_main_t * vam)
10480 vl_api_ip_dump_t *mp;
10481 unformat_input_t *in = vam->input;
10488 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
10490 if (unformat (in, "ipv4"))
10492 else if (unformat (in, "ipv6"))
10498 if (ipv4_set && ipv6_set)
10500 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
10504 if ((!ipv4_set) && (!ipv6_set))
10506 errmsg ("no ipv4 nor ipv6 flag set\n");
10510 is_ipv6 = ipv6_set;
10511 vam->is_ipv6 = is_ipv6;
10513 /* free old data */
10514 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
10516 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
10518 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
10520 M (IP_DUMP, ip_dump);
10521 mp->is_ipv6 = ipv6_set;
10524 /* Use a control ping for synchronization */
10526 vl_api_control_ping_t *mp;
10527 M (CONTROL_PING, control_ping);
10534 api_ipsec_spd_add_del (vat_main_t * vam)
10537 unformat_input_t *i = vam->input;
10538 vl_api_ipsec_spd_add_del_t *mp;
10543 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10545 if (unformat (i, "spd_id %d", &spd_id))
10547 else if (unformat (i, "del"))
10551 clib_warning ("parse error '%U'", format_unformat_error, i);
10557 errmsg ("spd_id must be set\n");
10561 M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del);
10563 mp->spd_id = ntohl (spd_id);
10564 mp->is_add = is_add;
10571 clib_warning ("unsupported (no dpdk)");
10577 api_ipsec_interface_add_del_spd (vat_main_t * vam)
10580 unformat_input_t *i = vam->input;
10581 vl_api_ipsec_interface_add_del_spd_t *mp;
10584 u8 sw_if_index_set = 0;
10585 u32 spd_id = (u32) ~ 0;
10588 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10590 if (unformat (i, "del"))
10592 else if (unformat (i, "spd_id %d", &spd_id))
10594 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10595 sw_if_index_set = 1;
10596 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10597 sw_if_index_set = 1;
10600 clib_warning ("parse error '%U'", format_unformat_error, i);
10606 if (spd_id == (u32) ~ 0)
10608 errmsg ("spd_id must be set\n");
10612 if (sw_if_index_set == 0)
10614 errmsg ("missing interface name or sw_if_index\n");
10618 M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd);
10620 mp->spd_id = ntohl (spd_id);
10621 mp->sw_if_index = ntohl (sw_if_index);
10622 mp->is_add = is_add;
10629 clib_warning ("unsupported (no dpdk)");
10635 api_ipsec_spd_add_del_entry (vat_main_t * vam)
10638 unformat_input_t *i = vam->input;
10639 vl_api_ipsec_spd_add_del_entry_t *mp;
10641 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
10642 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
10644 u32 rport_start = 0, rport_stop = (u32) ~ 0;
10645 u32 lport_start = 0, lport_stop = (u32) ~ 0;
10646 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
10647 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
10649 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
10650 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
10651 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
10652 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
10653 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
10654 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
10656 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10658 if (unformat (i, "del"))
10660 if (unformat (i, "outbound"))
10662 if (unformat (i, "inbound"))
10664 else if (unformat (i, "spd_id %d", &spd_id))
10666 else if (unformat (i, "sa_id %d", &sa_id))
10668 else if (unformat (i, "priority %d", &priority))
10670 else if (unformat (i, "protocol %d", &protocol))
10672 else if (unformat (i, "lport_start %d", &lport_start))
10674 else if (unformat (i, "lport_stop %d", &lport_stop))
10676 else if (unformat (i, "rport_start %d", &rport_start))
10678 else if (unformat (i, "rport_stop %d", &rport_stop))
10682 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
10688 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
10695 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
10701 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
10708 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
10714 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
10721 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
10727 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
10733 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
10735 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
10737 clib_warning ("unsupported action: 'resolve'");
10743 clib_warning ("parse error '%U'", format_unformat_error, i);
10749 M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry);
10751 mp->spd_id = ntohl (spd_id);
10752 mp->priority = ntohl (priority);
10753 mp->is_outbound = is_outbound;
10755 mp->is_ipv6 = is_ipv6;
10756 if (is_ipv6 || is_ip_any)
10758 clib_memcpy (mp->remote_address_start, &raddr6_start,
10759 sizeof (ip6_address_t));
10760 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
10761 sizeof (ip6_address_t));
10762 clib_memcpy (mp->local_address_start, &laddr6_start,
10763 sizeof (ip6_address_t));
10764 clib_memcpy (mp->local_address_stop, &laddr6_stop,
10765 sizeof (ip6_address_t));
10769 clib_memcpy (mp->remote_address_start, &raddr4_start,
10770 sizeof (ip4_address_t));
10771 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
10772 sizeof (ip4_address_t));
10773 clib_memcpy (mp->local_address_start, &laddr4_start,
10774 sizeof (ip4_address_t));
10775 clib_memcpy (mp->local_address_stop, &laddr4_stop,
10776 sizeof (ip4_address_t));
10778 mp->protocol = (u8) protocol;
10779 mp->local_port_start = ntohs ((u16) lport_start);
10780 mp->local_port_stop = ntohs ((u16) lport_stop);
10781 mp->remote_port_start = ntohs ((u16) rport_start);
10782 mp->remote_port_stop = ntohs ((u16) rport_stop);
10783 mp->policy = (u8) policy;
10784 mp->sa_id = ntohl (sa_id);
10785 mp->is_add = is_add;
10786 mp->is_ip_any = is_ip_any;
10792 clib_warning ("unsupported (no dpdk)");
10798 api_ipsec_sad_add_del_entry (vat_main_t * vam)
10801 unformat_input_t *i = vam->input;
10802 vl_api_ipsec_sad_add_del_entry_t *mp;
10804 u32 sad_id = 0, spi = 0;
10805 u8 *ck = 0, *ik = 0;
10808 u8 protocol = IPSEC_PROTOCOL_AH;
10809 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
10810 u32 crypto_alg = 0, integ_alg = 0;
10811 ip4_address_t tun_src4;
10812 ip4_address_t tun_dst4;
10813 ip6_address_t tun_src6;
10814 ip6_address_t tun_dst6;
10816 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10818 if (unformat (i, "del"))
10820 else if (unformat (i, "sad_id %d", &sad_id))
10822 else if (unformat (i, "spi %d", &spi))
10824 else if (unformat (i, "esp"))
10825 protocol = IPSEC_PROTOCOL_ESP;
10826 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
10829 is_tunnel_ipv6 = 0;
10831 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
10834 is_tunnel_ipv6 = 0;
10836 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
10839 is_tunnel_ipv6 = 1;
10841 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
10844 is_tunnel_ipv6 = 1;
10848 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
10850 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
10851 crypto_alg > IPSEC_INTEG_ALG_SHA_512_256)
10853 clib_warning ("unsupported crypto-alg: '%U'",
10854 format_ipsec_crypto_alg, crypto_alg);
10858 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
10862 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
10864 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
10865 integ_alg > IPSEC_INTEG_ALG_SHA_512_256)
10867 clib_warning ("unsupported integ-alg: '%U'",
10868 format_ipsec_integ_alg, integ_alg);
10872 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
10876 clib_warning ("parse error '%U'", format_unformat_error, i);
10882 M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
10884 mp->sad_id = ntohl (sad_id);
10885 mp->is_add = is_add;
10886 mp->protocol = protocol;
10887 mp->spi = ntohl (spi);
10888 mp->is_tunnel = is_tunnel;
10889 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
10890 mp->crypto_algorithm = crypto_alg;
10891 mp->integrity_algorithm = integ_alg;
10892 mp->crypto_key_length = vec_len (ck);
10893 mp->integrity_key_length = vec_len (ik);
10895 if (mp->crypto_key_length > sizeof (mp->crypto_key))
10896 mp->crypto_key_length = sizeof (mp->crypto_key);
10898 if (mp->integrity_key_length > sizeof (mp->integrity_key))
10899 mp->integrity_key_length = sizeof (mp->integrity_key);
10902 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
10904 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
10908 if (is_tunnel_ipv6)
10910 clib_memcpy (mp->tunnel_src_address, &tun_src6,
10911 sizeof (ip6_address_t));
10912 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
10913 sizeof (ip6_address_t));
10917 clib_memcpy (mp->tunnel_src_address, &tun_src4,
10918 sizeof (ip4_address_t));
10919 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
10920 sizeof (ip4_address_t));
10929 clib_warning ("unsupported (no dpdk)");
10935 api_ipsec_sa_set_key (vat_main_t * vam)
10938 unformat_input_t *i = vam->input;
10939 vl_api_ipsec_sa_set_key_t *mp;
10942 u8 *ck = 0, *ik = 0;
10944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10946 if (unformat (i, "sa_id %d", &sa_id))
10948 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
10950 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
10954 clib_warning ("parse error '%U'", format_unformat_error, i);
10959 M (IPSEC_SA_SET_KEY, ipsec_set_sa_key);
10961 mp->sa_id = ntohl (sa_id);
10962 mp->crypto_key_length = vec_len (ck);
10963 mp->integrity_key_length = vec_len (ik);
10965 if (mp->crypto_key_length > sizeof (mp->crypto_key))
10966 mp->crypto_key_length = sizeof (mp->crypto_key);
10968 if (mp->integrity_key_length > sizeof (mp->integrity_key))
10969 mp->integrity_key_length = sizeof (mp->integrity_key);
10972 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
10974 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
10981 clib_warning ("unsupported (no dpdk)");
10987 api_ikev2_profile_add_del (vat_main_t * vam)
10990 unformat_input_t *i = vam->input;
10991 vl_api_ikev2_profile_add_del_t *mp;
10996 const char *valid_chars = "a-zA-Z0-9_";
10998 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11000 if (unformat (i, "del"))
11002 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11003 vec_add1 (name, 0);
11006 errmsg ("parse error '%U'", format_unformat_error, i);
11011 if (!vec_len (name))
11013 errmsg ("profile name must be specified");
11017 if (vec_len (name) > 64)
11019 errmsg ("profile name too long");
11023 M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del);
11025 clib_memcpy (mp->name, name, vec_len (name));
11026 mp->is_add = is_add;
11034 clib_warning ("unsupported (no dpdk)");
11040 api_ikev2_profile_set_auth (vat_main_t * vam)
11043 unformat_input_t *i = vam->input;
11044 vl_api_ikev2_profile_set_auth_t *mp;
11048 u32 auth_method = 0;
11051 const char *valid_chars = "a-zA-Z0-9_";
11053 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11055 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11056 vec_add1 (name, 0);
11057 else if (unformat (i, "auth_method %U",
11058 unformat_ikev2_auth_method, &auth_method))
11060 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
11062 else if (unformat (i, "auth_data %v", &data))
11066 errmsg ("parse error '%U'", format_unformat_error, i);
11071 if (!vec_len (name))
11073 errmsg ("profile name must be specified");
11077 if (vec_len (name) > 64)
11079 errmsg ("profile name too long");
11083 if (!vec_len (data))
11085 errmsg ("auth_data must be specified");
11091 errmsg ("auth_method must be specified");
11095 M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth);
11097 mp->is_hex = is_hex;
11098 mp->auth_method = (u8) auth_method;
11099 mp->data_len = vec_len (data);
11100 clib_memcpy (mp->name, name, vec_len (name));
11101 clib_memcpy (mp->data, data, vec_len (data));
11110 clib_warning ("unsupported (no dpdk)");
11116 api_ikev2_profile_set_id (vat_main_t * vam)
11119 unformat_input_t *i = vam->input;
11120 vl_api_ikev2_profile_set_id_t *mp;
11128 const char *valid_chars = "a-zA-Z0-9_";
11130 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11132 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11133 vec_add1 (name, 0);
11134 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
11136 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
11138 data = vec_new (u8, 4);
11139 clib_memcpy (data, ip4.as_u8, 4);
11141 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
11143 else if (unformat (i, "id_data %v", &data))
11145 else if (unformat (i, "local"))
11147 else if (unformat (i, "remote"))
11151 errmsg ("parse error '%U'", format_unformat_error, i);
11156 if (!vec_len (name))
11158 errmsg ("profile name must be specified");
11162 if (vec_len (name) > 64)
11164 errmsg ("profile name too long");
11168 if (!vec_len (data))
11170 errmsg ("id_data must be specified");
11176 errmsg ("id_type must be specified");
11180 M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id);
11182 mp->is_local = is_local;
11183 mp->id_type = (u8) id_type;
11184 mp->data_len = vec_len (data);
11185 clib_memcpy (mp->name, name, vec_len (name));
11186 clib_memcpy (mp->data, data, vec_len (data));
11195 clib_warning ("unsupported (no dpdk)");
11201 api_ikev2_profile_set_ts (vat_main_t * vam)
11204 unformat_input_t *i = vam->input;
11205 vl_api_ikev2_profile_set_ts_t *mp;
11209 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
11210 ip4_address_t start_addr, end_addr;
11212 const char *valid_chars = "a-zA-Z0-9_";
11214 start_addr.as_u32 = 0;
11215 end_addr.as_u32 = (u32) ~ 0;
11217 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11219 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11220 vec_add1 (name, 0);
11221 else if (unformat (i, "protocol %d", &proto))
11223 else if (unformat (i, "start_port %d", &start_port))
11225 else if (unformat (i, "end_port %d", &end_port))
11228 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
11230 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
11232 else if (unformat (i, "local"))
11234 else if (unformat (i, "remote"))
11238 errmsg ("parse error '%U'", format_unformat_error, i);
11243 if (!vec_len (name))
11245 errmsg ("profile name must be specified");
11249 if (vec_len (name) > 64)
11251 errmsg ("profile name too long");
11255 M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts);
11257 mp->is_local = is_local;
11258 mp->proto = (u8) proto;
11259 mp->start_port = (u16) start_port;
11260 mp->end_port = (u16) end_port;
11261 mp->start_addr = start_addr.as_u32;
11262 mp->end_addr = end_addr.as_u32;
11263 clib_memcpy (mp->name, name, vec_len (name));
11271 clib_warning ("unsupported (no dpdk)");
11277 api_ikev2_set_local_key (vat_main_t * vam)
11280 unformat_input_t *i = vam->input;
11281 vl_api_ikev2_set_local_key_t *mp;
11285 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11287 if (unformat (i, "file %v", &file))
11288 vec_add1 (file, 0);
11291 errmsg ("parse error '%U'", format_unformat_error, i);
11296 if (!vec_len (file))
11298 errmsg ("RSA key file must be specified");
11302 if (vec_len (file) > 256)
11304 errmsg ("file name too long");
11308 M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key);
11310 clib_memcpy (mp->key_file, file, vec_len (file));
11318 clib_warning ("unsupported (no dpdk)");
11327 api_map_add_domain (vat_main_t * vam)
11329 unformat_input_t *i = vam->input;
11330 vl_api_map_add_domain_t *mp;
11333 ip4_address_t ip4_prefix;
11334 ip6_address_t ip6_prefix;
11335 ip6_address_t ip6_src;
11336 u32 num_m_args = 0;
11337 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
11338 0, psid_length = 0;
11339 u8 is_translation = 0;
11341 u32 ip6_src_len = 128;
11343 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11345 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
11346 &ip4_prefix, &ip4_prefix_len))
11348 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
11349 &ip6_prefix, &ip6_prefix_len))
11353 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
11356 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
11358 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
11360 else if (unformat (i, "psid-offset %d", &psid_offset))
11362 else if (unformat (i, "psid-len %d", &psid_length))
11364 else if (unformat (i, "mtu %d", &mtu))
11366 else if (unformat (i, "map-t"))
11367 is_translation = 1;
11370 clib_warning ("parse error '%U'", format_unformat_error, i);
11375 if (num_m_args < 3)
11377 errmsg ("mandatory argument(s) missing\n");
11381 /* Construct the API message */
11382 M (MAP_ADD_DOMAIN, map_add_domain);
11384 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
11385 mp->ip4_prefix_len = ip4_prefix_len;
11387 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
11388 mp->ip6_prefix_len = ip6_prefix_len;
11390 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
11391 mp->ip6_src_prefix_len = ip6_src_len;
11393 mp->ea_bits_len = ea_bits_len;
11394 mp->psid_offset = psid_offset;
11395 mp->psid_length = psid_length;
11396 mp->is_translation = is_translation;
11397 mp->mtu = htons (mtu);
11402 /* Wait for a reply, return good/bad news */
11407 api_map_del_domain (vat_main_t * vam)
11409 unformat_input_t *i = vam->input;
11410 vl_api_map_del_domain_t *mp;
11413 u32 num_m_args = 0;
11416 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11418 if (unformat (i, "index %d", &index))
11422 clib_warning ("parse error '%U'", format_unformat_error, i);
11427 if (num_m_args != 1)
11429 errmsg ("mandatory argument(s) missing\n");
11433 /* Construct the API message */
11434 M (MAP_DEL_DOMAIN, map_del_domain);
11436 mp->index = ntohl (index);
11441 /* Wait for a reply, return good/bad news */
11446 api_map_add_del_rule (vat_main_t * vam)
11448 unformat_input_t *i = vam->input;
11449 vl_api_map_add_del_rule_t *mp;
11452 ip6_address_t ip6_dst;
11453 u32 num_m_args = 0, index, psid = 0;
11455 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11457 if (unformat (i, "index %d", &index))
11459 else if (unformat (i, "psid %d", &psid))
11461 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
11463 else if (unformat (i, "del"))
11469 clib_warning ("parse error '%U'", format_unformat_error, i);
11474 /* Construct the API message */
11475 M (MAP_ADD_DEL_RULE, map_add_del_rule);
11477 mp->index = ntohl (index);
11478 mp->is_add = is_add;
11479 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
11480 mp->psid = ntohs (psid);
11485 /* Wait for a reply, return good/bad news */
11490 api_map_domain_dump (vat_main_t * vam)
11492 vl_api_map_domain_dump_t *mp;
11495 /* Construct the API message */
11496 M (MAP_DOMAIN_DUMP, map_domain_dump);
11501 /* Use a control ping for synchronization */
11503 vl_api_control_ping_t *mp;
11504 M (CONTROL_PING, control_ping);
11511 api_map_rule_dump (vat_main_t * vam)
11513 unformat_input_t *i = vam->input;
11514 vl_api_map_rule_dump_t *mp;
11516 u32 domain_index = ~0;
11518 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11520 if (unformat (i, "index %u", &domain_index))
11526 if (domain_index == ~0)
11528 clib_warning ("parse error: domain index expected");
11532 /* Construct the API message */
11533 M (MAP_RULE_DUMP, map_rule_dump);
11535 mp->domain_index = htonl (domain_index);
11540 /* Use a control ping for synchronization */
11542 vl_api_control_ping_t *mp;
11543 M (CONTROL_PING, control_ping);
11549 static void vl_api_map_add_domain_reply_t_handler
11550 (vl_api_map_add_domain_reply_t * mp)
11552 vat_main_t *vam = &vat_main;
11553 i32 retval = ntohl (mp->retval);
11555 if (vam->async_mode)
11557 vam->async_errors += (retval < 0);
11561 vam->retval = retval;
11562 vam->result_ready = 1;
11566 static void vl_api_map_add_domain_reply_t_handler_json
11567 (vl_api_map_add_domain_reply_t * mp)
11569 vat_main_t *vam = &vat_main;
11570 vat_json_node_t node;
11572 vat_json_init_object (&node);
11573 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
11574 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
11576 vat_json_print (vam->ofp, &node);
11577 vat_json_free (&node);
11579 vam->retval = ntohl (mp->retval);
11580 vam->result_ready = 1;
11584 api_get_first_msg_id (vat_main_t * vam)
11586 vl_api_get_first_msg_id_t *mp;
11588 unformat_input_t *i = vam->input;
11592 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11594 if (unformat (i, "client %s", &name))
11602 errmsg ("missing client name\n");
11605 vec_add1 (name, 0);
11607 if (vec_len (name) > 63)
11609 errmsg ("client name too long\n");
11613 M (GET_FIRST_MSG_ID, get_first_msg_id);
11614 clib_memcpy (mp->name, name, vec_len (name));
11622 api_cop_interface_enable_disable (vat_main_t * vam)
11624 unformat_input_t *line_input = vam->input;
11625 vl_api_cop_interface_enable_disable_t *mp;
11627 u32 sw_if_index = ~0;
11628 u8 enable_disable = 1;
11630 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11632 if (unformat (line_input, "disable"))
11633 enable_disable = 0;
11634 if (unformat (line_input, "enable"))
11635 enable_disable = 1;
11636 else if (unformat (line_input, "%U", unformat_sw_if_index,
11637 vam, &sw_if_index))
11639 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11645 if (sw_if_index == ~0)
11647 errmsg ("missing interface name or sw_if_index\n");
11651 /* Construct the API message */
11652 M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable);
11653 mp->sw_if_index = ntohl (sw_if_index);
11654 mp->enable_disable = enable_disable;
11658 /* Wait for the reply */
11663 api_cop_whitelist_enable_disable (vat_main_t * vam)
11665 unformat_input_t *line_input = vam->input;
11666 vl_api_cop_whitelist_enable_disable_t *mp;
11668 u32 sw_if_index = ~0;
11669 u8 ip4 = 0, ip6 = 0, default_cop = 0;
11672 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11674 if (unformat (line_input, "ip4"))
11676 else if (unformat (line_input, "ip6"))
11678 else if (unformat (line_input, "default"))
11680 else if (unformat (line_input, "%U", unformat_sw_if_index,
11681 vam, &sw_if_index))
11683 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11685 else if (unformat (line_input, "fib-id %d", &fib_id))
11691 if (sw_if_index == ~0)
11693 errmsg ("missing interface name or sw_if_index\n");
11697 /* Construct the API message */
11698 M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable);
11699 mp->sw_if_index = ntohl (sw_if_index);
11700 mp->fib_id = ntohl (fib_id);
11703 mp->default_cop = default_cop;
11707 /* Wait for the reply */
11712 api_get_node_graph (vat_main_t * vam)
11714 vl_api_get_node_graph_t *mp;
11717 M (GET_NODE_GRAPH, get_node_graph);
11721 /* Wait for the reply */
11726 /** Used for parsing LISP eids */
11727 typedef CLIB_PACKED(struct{
11728 u8 addr[16]; /**< eid address */
11729 u32 len; /**< prefix length if IP */
11730 u8 type; /**< type of eid */
11735 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
11737 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
11739 memset (a, 0, sizeof (a[0]));
11741 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
11743 a->type = 0; /* ipv4 type */
11745 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
11747 a->type = 1; /* ipv6 type */
11749 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
11751 a->type = 2; /* mac type */
11758 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
11767 lisp_eid_size_vat (u8 type)
11782 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
11784 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
11788 /** Used for transferring locators via VPP API */
11789 typedef CLIB_PACKED(struct
11791 u32 sw_if_index; /**< locator sw_if_index */
11792 u8 priority; /**< locator priority */
11793 u8 weight; /**< locator weight */
11798 api_lisp_add_del_locator_set (vat_main_t * vam)
11800 unformat_input_t *input = vam->input;
11801 vl_api_lisp_add_del_locator_set_t *mp;
11804 u8 *locator_set_name = NULL;
11805 u8 locator_set_name_set = 0;
11806 ls_locator_t locator, *locators = 0;
11807 u32 sw_if_index, priority, weight;
11809 /* Parse args required to build the message */
11810 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11812 if (unformat (input, "del"))
11816 else if (unformat (input, "locator-set %s", &locator_set_name))
11818 locator_set_name_set = 1;
11820 else if (unformat (input, "sw_if_index %u p %u w %u",
11821 &sw_if_index, &priority, &weight))
11823 locator.sw_if_index = htonl (sw_if_index);
11824 locator.priority = priority;
11825 locator.weight = weight;
11826 vec_add1 (locators, locator);
11828 else if (unformat (input, "iface %U p %u w %u", unformat_sw_if_index,
11829 vam, &sw_if_index, &priority, &weight))
11831 locator.sw_if_index = htonl (sw_if_index);
11832 locator.priority = priority;
11833 locator.weight = weight;
11834 vec_add1 (locators, locator);
11840 if (locator_set_name_set == 0)
11842 errmsg ("missing locator-set name");
11843 vec_free (locators);
11847 if (vec_len (locator_set_name) > 64)
11849 errmsg ("locator-set name too long\n");
11850 vec_free (locator_set_name);
11851 vec_free (locators);
11854 vec_add1 (locator_set_name, 0);
11856 /* Construct the API message */
11857 M (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set);
11859 mp->is_add = is_add;
11860 clib_memcpy (mp->locator_set_name, locator_set_name,
11861 vec_len (locator_set_name));
11862 vec_free (locator_set_name);
11864 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
11866 clib_memcpy (mp->locators, locators,
11867 (sizeof (ls_locator_t) * vec_len (locators)));
11868 vec_free (locators);
11873 /* Wait for a reply... */
11881 api_lisp_add_del_locator (vat_main_t * vam)
11883 unformat_input_t *input = vam->input;
11884 vl_api_lisp_add_del_locator_t *mp;
11886 u32 tmp_if_index = ~0;
11887 u32 sw_if_index = ~0;
11888 u8 sw_if_index_set = 0;
11889 u8 sw_if_index_if_name_set = 0;
11891 u8 priority_set = 0;
11895 u8 *locator_set_name = NULL;
11896 u8 locator_set_name_set = 0;
11898 /* Parse args required to build the message */
11899 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11901 if (unformat (input, "del"))
11905 else if (unformat (input, "locator-set %s", &locator_set_name))
11907 locator_set_name_set = 1;
11909 else if (unformat (input, "iface %U", unformat_sw_if_index, vam,
11912 sw_if_index_if_name_set = 1;
11913 sw_if_index = tmp_if_index;
11915 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
11917 sw_if_index_set = 1;
11918 sw_if_index = tmp_if_index;
11920 else if (unformat (input, "p %d", &priority))
11924 else if (unformat (input, "w %d", &weight))
11932 if (locator_set_name_set == 0)
11934 errmsg ("missing locator-set name");
11938 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
11940 errmsg ("missing sw_if_index");
11941 vec_free (locator_set_name);
11945 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
11947 errmsg ("cannot use both params interface name and sw_if_index");
11948 vec_free (locator_set_name);
11952 if (priority_set == 0)
11954 errmsg ("missing locator-set priority\n");
11955 vec_free (locator_set_name);
11959 if (weight_set == 0)
11961 errmsg ("missing locator-set weight\n");
11962 vec_free (locator_set_name);
11966 if (vec_len (locator_set_name) > 64)
11968 errmsg ("locator-set name too long\n");
11969 vec_free (locator_set_name);
11972 vec_add1 (locator_set_name, 0);
11974 /* Construct the API message */
11975 M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
11977 mp->is_add = is_add;
11978 mp->sw_if_index = ntohl (sw_if_index);
11979 mp->priority = priority;
11980 mp->weight = weight;
11981 clib_memcpy (mp->locator_set_name, locator_set_name,
11982 vec_len (locator_set_name));
11983 vec_free (locator_set_name);
11988 /* Wait for a reply... */
11996 api_lisp_add_del_local_eid (vat_main_t * vam)
11998 unformat_input_t *input = vam->input;
11999 vl_api_lisp_add_del_local_eid_t *mp;
12003 lisp_eid_vat_t _eid, *eid = &_eid;
12004 u8 *locator_set_name = 0;
12005 u8 locator_set_name_set = 0;
12008 /* Parse args required to build the message */
12009 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12011 if (unformat (input, "del"))
12015 else if (unformat (input, "vni %d", &vni))
12019 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
12023 else if (unformat (input, "locator-set %s", &locator_set_name))
12025 locator_set_name_set = 1;
12031 if (locator_set_name_set == 0)
12033 errmsg ("missing locator-set name\n");
12039 errmsg ("EID address not set!");
12040 vec_free (locator_set_name);
12044 if (vec_len (locator_set_name) > 64)
12046 errmsg ("locator-set name too long\n");
12047 vec_free (locator_set_name);
12050 vec_add1 (locator_set_name, 0);
12052 /* Construct the API message */
12053 M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
12055 mp->is_add = is_add;
12056 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
12057 mp->eid_type = eid->type;
12058 mp->prefix_len = eid->len;
12059 mp->vni = clib_host_to_net_u32 (vni);
12060 clib_memcpy (mp->locator_set_name, locator_set_name,
12061 vec_len (locator_set_name));
12063 vec_free (locator_set_name);
12068 /* Wait for a reply... */
12076 /** Used for transferring locators via VPP API */
12077 typedef CLIB_PACKED(struct
12079 u8 is_ip4; /**< is locator an IPv4 address? */
12080 u8 priority; /**< locator priority */
12081 u8 weight; /**< locator weight */
12082 u8 addr[16]; /**< IPv4/IPv6 address */
12087 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
12089 unformat_input_t *input = vam->input;
12090 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
12093 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
12094 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
12095 u8 rmt_eid_set = 0, lcl_eid_set = 0;
12096 u32 action = ~0, p, w;
12097 ip4_address_t rmt_rloc4, lcl_rloc4;
12098 ip6_address_t rmt_rloc6, lcl_rloc6;
12099 rloc_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
12101 memset (&rloc, 0, sizeof (rloc));
12103 /* Parse args required to build the message */
12104 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12106 if (unformat (input, "del"))
12110 else if (unformat (input, "rmt_eid %U", unformat_lisp_eid_vat, rmt_eid))
12114 else if (unformat (input, "lcl_eid %U", unformat_lisp_eid_vat, lcl_eid))
12118 else if (unformat (input, "p %d w %d", &p, &w))
12122 errmsg ("No RLOC configured for setting priority/weight!");
12125 curr_rloc->priority = p;
12126 curr_rloc->weight = w;
12128 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
12129 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
12133 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
12134 rloc.priority = rloc.weight = 0;
12135 vec_add1 (lcl_locs, rloc);
12137 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
12138 vec_add1 (rmt_locs, rloc);
12139 /* priority and weight saved in rmt loc */
12140 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
12142 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
12143 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
12146 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
12147 rloc.priority = rloc.weight = 0;
12148 vec_add1 (lcl_locs, rloc);
12150 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
12151 vec_add1 (rmt_locs, rloc);
12152 /* priority and weight saved in rmt loc */
12153 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
12155 else if (unformat (input, "action %d", &action))
12161 clib_warning ("parse error '%U'", format_unformat_error, input);
12168 errmsg ("remote eid addresses not set\n");
12172 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
12174 errmsg ("eid types don't match\n");
12178 if (0 == rmt_locs && (u32) ~ 0 == action)
12180 errmsg ("action not set for negative mapping\n");
12184 /* Construct the API message */
12185 M (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry);
12187 mp->is_add = is_add;
12188 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
12189 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
12190 mp->eid_type = rmt_eid->type;
12191 mp->rmt_len = rmt_eid->len;
12192 mp->lcl_len = lcl_eid->len;
12193 mp->action = action;
12195 if (0 != rmt_locs && 0 != lcl_locs)
12197 mp->loc_num = vec_len (rmt_locs);
12198 clib_memcpy (mp->lcl_locs, lcl_locs,
12199 (sizeof (rloc_t) * vec_len (lcl_locs)));
12200 clib_memcpy (mp->rmt_locs, rmt_locs,
12201 (sizeof (rloc_t) * vec_len (rmt_locs)));
12203 vec_free (lcl_locs);
12204 vec_free (rmt_locs);
12209 /* Wait for a reply... */
12217 api_lisp_add_del_map_resolver (vat_main_t * vam)
12219 unformat_input_t *input = vam->input;
12220 vl_api_lisp_add_del_map_resolver_t *mp;
12225 ip4_address_t ipv4;
12226 ip6_address_t ipv6;
12228 /* Parse args required to build the message */
12229 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12231 if (unformat (input, "del"))
12235 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
12239 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
12247 if (ipv4_set && ipv6_set)
12249 errmsg ("both eid v4 and v6 addresses set\n");
12253 if (!ipv4_set && !ipv6_set)
12255 errmsg ("eid addresses not set\n");
12259 /* Construct the API message */
12260 M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
12262 mp->is_add = is_add;
12266 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
12271 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
12277 /* Wait for a reply... */
12285 api_lisp_gpe_enable_disable (vat_main_t * vam)
12287 unformat_input_t *input = vam->input;
12288 vl_api_lisp_gpe_enable_disable_t *mp;
12293 /* Parse args required to build the message */
12294 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12296 if (unformat (input, "enable"))
12301 else if (unformat (input, "disable"))
12312 errmsg ("Value not set\n");
12316 /* Construct the API message */
12317 M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
12324 /* Wait for a reply... */
12332 api_lisp_enable_disable (vat_main_t * vam)
12334 unformat_input_t *input = vam->input;
12335 vl_api_lisp_enable_disable_t *mp;
12340 /* Parse args required to build the message */
12341 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12343 if (unformat (input, "enable"))
12348 else if (unformat (input, "disable"))
12358 errmsg ("Value not set\n");
12362 /* Construct the API message */
12363 M (LISP_ENABLE_DISABLE, lisp_enable_disable);
12370 /* Wait for a reply... */
12378 * Enable/disable LISP proxy ITR.
12380 * @param vam vpp API test context
12381 * @return return code
12384 api_lisp_pitr_set_locator_set (vat_main_t * vam)
12387 u8 ls_name_set = 0;
12388 unformat_input_t *input = vam->input;
12389 vl_api_lisp_pitr_set_locator_set_t *mp;
12393 /* Parse args required to build the message */
12394 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12396 if (unformat (input, "del"))
12398 else if (unformat (input, "locator-set %s", &ls_name))
12402 errmsg ("parse error '%U'", format_unformat_error, input);
12409 errmsg ("locator-set name not set!");
12413 M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set);
12415 mp->is_add = is_add;
12416 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
12417 vec_free (ls_name);
12422 /* wait for reply */
12430 api_show_lisp_pitr (vat_main_t * vam)
12432 vl_api_show_lisp_pitr_t *mp;
12435 if (!vam->json_output)
12437 fformat (vam->ofp, "%=20s\n", "lisp status:");
12440 M (SHOW_LISP_PITR, show_lisp_pitr);
12444 /* Wait for a reply... */
12452 * Add/delete mapping between vni and vrf
12455 api_lisp_eid_table_add_del_map (vat_main_t * vam)
12458 unformat_input_t *input = vam->input;
12459 vl_api_lisp_eid_table_add_del_map_t *mp;
12460 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
12461 u32 vni, vrf, bd_index;
12463 /* Parse args required to build the message */
12464 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12466 if (unformat (input, "del"))
12468 else if (unformat (input, "vrf %d", &vrf))
12470 else if (unformat (input, "bd_index %d", &bd_index))
12472 else if (unformat (input, "vni %d", &vni))
12478 if (!vni_set || (!vrf_set && !bd_index_set))
12480 errmsg ("missing arguments!");
12484 if (vrf_set && bd_index_set)
12486 errmsg ("error: both vrf and bd entered!");
12490 M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
12492 mp->is_add = is_add;
12493 mp->vni = htonl (vni);
12494 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
12495 mp->is_l2 = bd_index_set;
12500 /* wait for reply */
12508 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
12510 u32 *action = va_arg (*args, u32 *);
12513 if (unformat (input, "%s", &s))
12515 if (!strcmp ((char *) s, "no-action"))
12517 else if (!strcmp ((char *) s, "natively-forward"))
12519 else if (!strcmp ((char *) s, "send-map-request"))
12521 else if (!strcmp ((char *) s, "drop"))
12525 clib_warning ("invalid action: '%s'", s);
12537 * Add/del remote mapping to/from LISP control plane
12539 * @param vam vpp API test context
12540 * @return return code
12543 api_lisp_add_del_remote_mapping (vat_main_t * vam)
12545 unformat_input_t *input = vam->input;
12546 vl_api_lisp_add_del_remote_mapping_t *mp;
12549 lisp_eid_vat_t _eid, *eid = &_eid;
12550 lisp_eid_vat_t _seid, *seid = &_seid;
12551 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
12552 u32 action = ~0, p, w;
12553 ip4_address_t rloc4;
12554 ip6_address_t rloc6;
12555 rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
12557 memset (&rloc, 0, sizeof (rloc));
12559 /* Parse args required to build the message */
12560 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12562 if (unformat (input, "del-all"))
12566 else if (unformat (input, "del"))
12570 else if (unformat (input, "add"))
12574 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
12578 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
12582 else if (unformat (input, "vni %d", &vni))
12586 else if (unformat (input, "p %d w %d", &p, &w))
12590 errmsg ("No RLOC configured for setting priority/weight!");
12593 curr_rloc->priority = p;
12594 curr_rloc->weight = w;
12596 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
12599 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
12600 vec_add1 (rlocs, rloc);
12601 curr_rloc = &rlocs[vec_len (rlocs) - 1];
12603 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
12606 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
12607 vec_add1 (rlocs, rloc);
12608 curr_rloc = &rlocs[vec_len (rlocs) - 1];
12610 else if (unformat (input, "action %U",
12611 unformat_negative_mapping_action, &action))
12617 clib_warning ("parse error '%U'", format_unformat_error, input);
12624 errmsg ("missing params!");
12628 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
12630 errmsg ("no action set for negative map-reply!");
12634 M (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping);
12635 mp->is_add = is_add;
12636 mp->vni = htonl (vni);
12637 mp->action = (u8) action;
12638 mp->is_src_dst = seid_set;
12639 mp->eid_len = eid->len;
12640 mp->seid_len = seid->len;
12641 mp->del_all = del_all;
12642 mp->eid_type = eid->type;
12643 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
12644 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
12646 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
12647 clib_memcpy (mp->rlocs, rlocs, (sizeof (rloc_t) * vec_len (rlocs)));
12653 /* Wait for a reply... */
12661 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
12662 * forwarding entries in data-plane accordingly.
12664 * @param vam vpp API test context
12665 * @return return code
12668 api_lisp_add_del_adjacency (vat_main_t * vam)
12670 unformat_input_t *input = vam->input;
12671 vl_api_lisp_add_del_adjacency_t *mp;
12674 ip4_address_t seid4, deid4;
12675 ip6_address_t seid6, deid6;
12676 u8 deid_mac[6] = { 0 };
12677 u8 seid_mac[6] = { 0 };
12678 u8 deid_type, seid_type;
12679 u32 seid_len = 0, deid_len = 0, len;
12682 seid_type = deid_type = (u8) ~ 0;
12684 /* Parse args required to build the message */
12685 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12687 if (unformat (input, "del"))
12691 else if (unformat (input, "add"))
12695 else if (unformat (input, "deid %U/%d", unformat_ip4_address,
12698 deid_type = 0; /* ipv4 */
12701 else if (unformat (input, "deid %U/%d", unformat_ip6_address,
12704 deid_type = 1; /* ipv6 */
12707 else if (unformat (input, "deid %U", unformat_ethernet_address,
12710 deid_type = 2; /* mac */
12712 else if (unformat (input, "seid %U/%d", unformat_ip4_address,
12715 seid_type = 0; /* ipv4 */
12718 else if (unformat (input, "seid %U/%d", unformat_ip6_address,
12721 seid_type = 1; /* ipv6 */
12724 else if (unformat (input, "seid %U", unformat_ethernet_address,
12727 seid_type = 2; /* mac */
12729 else if (unformat (input, "vni %d", &vni))
12735 errmsg ("parse error '%U'", format_unformat_error, input);
12740 if ((u8) ~ 0 == deid_type)
12742 errmsg ("missing params!");
12746 if (seid_type != deid_type)
12748 errmsg ("source and destination EIDs are of different types!");
12752 M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency);
12753 mp->is_add = is_add;
12754 mp->vni = htonl (vni);
12755 mp->seid_len = seid_len;
12756 mp->deid_len = deid_len;
12757 mp->eid_type = deid_type;
12759 switch (mp->eid_type)
12762 clib_memcpy (mp->seid, &seid4, sizeof (seid4));
12763 clib_memcpy (mp->deid, &deid4, sizeof (deid4));
12766 clib_memcpy (mp->seid, &seid6, sizeof (seid6));
12767 clib_memcpy (mp->deid, &deid6, sizeof (deid6));
12770 clib_memcpy (mp->seid, seid_mac, 6);
12771 clib_memcpy (mp->deid, deid_mac, 6);
12774 errmsg ("unknown EID type %d!", mp->eid_type);
12781 /* Wait for a reply... */
12789 api_lisp_gpe_add_del_iface (vat_main_t * vam)
12791 unformat_input_t *input = vam->input;
12792 vl_api_lisp_gpe_add_del_iface_t *mp;
12794 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
12795 u32 dp_table = 0, vni = 0;
12797 /* Parse args required to build the message */
12798 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12800 if (unformat (input, "up"))
12805 else if (unformat (input, "down"))
12810 else if (unformat (input, "table_id %d", &dp_table))
12814 else if (unformat (input, "bd_id %d", &dp_table))
12819 else if (unformat (input, "vni %d", &vni))
12827 if (action_set == 0)
12829 errmsg ("Action not set\n");
12832 if (dp_table_set == 0 || vni_set == 0)
12834 errmsg ("vni and dp_table must be set\n");
12838 /* Construct the API message */
12839 M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
12841 mp->is_add = is_add;
12842 mp->dp_table = dp_table;
12849 /* Wait for a reply... */
12857 * Add/del map request itr rlocs from LISP control plane and updates
12859 * @param vam vpp API test context
12860 * @return return code
12863 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
12865 unformat_input_t *input = vam->input;
12866 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
12868 u8 *locator_set_name = 0;
12869 u8 locator_set_name_set = 0;
12872 /* Parse args required to build the message */
12873 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12875 if (unformat (input, "del"))
12879 else if (unformat (input, "%_%v%_", &locator_set_name))
12881 locator_set_name_set = 1;
12885 clib_warning ("parse error '%U'", format_unformat_error, input);
12890 if (is_add && !locator_set_name_set)
12892 errmsg ("itr-rloc is not set!");
12896 if (is_add && vec_len (locator_set_name) > 64)
12898 errmsg ("itr-rloc locator-set name too long\n");
12899 vec_free (locator_set_name);
12903 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs);
12904 mp->is_add = is_add;
12907 clib_memcpy (mp->locator_set_name, locator_set_name,
12908 vec_len (locator_set_name));
12912 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
12914 vec_free (locator_set_name);
12919 /* Wait for a reply... */
12927 api_lisp_locator_dump (vat_main_t * vam)
12929 unformat_input_t *input = vam->input;
12930 vl_api_lisp_locator_dump_t *mp;
12932 u8 is_index_set = 0, is_name_set = 0;
12936 /* Parse args required to build the message */
12937 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12939 if (unformat (input, "ls_name %_%v%_", &ls_name))
12943 else if (unformat (input, "ls_index %d", &ls_index))
12949 errmsg ("parse error '%U'", format_unformat_error, input);
12954 if (!is_index_set && !is_name_set)
12956 errmsg ("error: expected one of index or name!\n");
12960 if (is_index_set && is_name_set)
12962 errmsg ("error: only one param expected!\n");
12966 if (vec_len (ls_name) > 63)
12968 errmsg ("error: locator set name too long!");
12972 if (!vam->json_output)
12974 fformat (vam->ofp, "%=16s%=16s%=16s\n", "locator", "priority",
12978 M (LISP_LOCATOR_DUMP, lisp_locator_dump);
12979 mp->is_index_set = is_index_set;
12982 mp->ls_index = clib_host_to_net_u32 (ls_index);
12985 vec_add1 (ls_name, 0);
12986 strncpy ((char *) mp->ls_name, (char *) ls_name, sizeof (mp->ls_name));
12992 /* Use a control ping for synchronization */
12994 vl_api_control_ping_t *mp;
12995 M (CONTROL_PING, control_ping);
12998 /* Wait for a reply... */
13006 api_lisp_locator_set_dump (vat_main_t * vam)
13008 vl_api_lisp_locator_set_dump_t *mp;
13009 unformat_input_t *input = vam->input;
13013 /* Parse args required to build the message */
13014 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13016 if (unformat (input, "local"))
13020 else if (unformat (input, "remote"))
13026 errmsg ("parse error '%U'", format_unformat_error, input);
13031 if (!vam->json_output)
13033 fformat (vam->ofp, "%=10s%=15s\n", "ls_index", "ls_name");
13036 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
13038 mp->filter = filter;
13043 /* Use a control ping for synchronization */
13045 vl_api_control_ping_t *mp;
13046 M (CONTROL_PING, control_ping);
13049 /* Wait for a reply... */
13057 api_lisp_eid_table_map_dump (vat_main_t * vam)
13061 unformat_input_t *input = vam->input;
13062 vl_api_lisp_eid_table_map_dump_t *mp;
13065 /* Parse args required to build the message */
13066 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13068 if (unformat (input, "l2"))
13073 else if (unformat (input, "l3"))
13080 errmsg ("parse error '%U'", format_unformat_error, input);
13087 errmsg ("expected one of 'l2' or 'l3' parameter!\n");
13091 if (!vam->json_output)
13093 fformat (vam->ofp, "%=10s%=10s\n", "VNI", is_l2 ? "BD" : "VRF");
13096 M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump);
13102 /* Use a control ping for synchronization */
13104 vl_api_control_ping_t *mp;
13105 M (CONTROL_PING, control_ping);
13108 /* Wait for a reply... */
13116 api_lisp_eid_table_vni_dump (vat_main_t * vam)
13118 vl_api_lisp_eid_table_vni_dump_t *mp;
13121 if (!vam->json_output)
13123 fformat (vam->ofp, "VNI\n");
13126 M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
13131 /* Use a control ping for synchronization */
13133 vl_api_control_ping_t *mp;
13134 M (CONTROL_PING, control_ping);
13137 /* Wait for a reply... */
13145 api_lisp_eid_table_dump (vat_main_t * vam)
13147 unformat_input_t *i = vam->input;
13148 vl_api_lisp_eid_table_dump_t *mp;
13150 struct in_addr ip4;
13151 struct in6_addr ip6;
13153 u8 eid_type = ~0, eid_set = 0;
13154 u32 prefix_length = ~0, t, vni = 0;
13157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13159 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
13165 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
13171 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
13176 else if (unformat (i, "vni %d", &t))
13180 else if (unformat (i, "local"))
13184 else if (unformat (i, "remote"))
13190 errmsg ("parse error '%U'", format_unformat_error, i);
13195 if (!vam->json_output)
13197 fformat (vam->ofp, "%-35s%-20s%-30s%-20s%-s\n", "EID", "type",
13198 "ls_index", "ttl", "authoritative");
13201 M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump);
13203 mp->filter = filter;
13207 mp->vni = htonl (vni);
13208 mp->eid_type = eid_type;
13212 mp->prefix_length = prefix_length;
13213 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
13216 mp->prefix_length = prefix_length;
13217 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
13220 clib_memcpy (mp->eid, mac, sizeof (mac));
13223 errmsg ("unknown EID type %d!", eid_type);
13231 /* Use a control ping for synchronization */
13233 vl_api_control_ping_t *mp;
13234 M (CONTROL_PING, control_ping);
13238 /* Wait for a reply... */
13246 api_lisp_gpe_tunnel_dump (vat_main_t * vam)
13248 vl_api_lisp_gpe_tunnel_dump_t *mp;
13251 if (!vam->json_output)
13253 fformat (vam->ofp, "%=20s%=30s%=16s%=16s%=16s%=16s"
13254 "%=16s%=16s%=16s%=16s%=16s\n",
13255 "Tunel", "Source", "Destination", "Fib encap", "Fib decap",
13256 "Decap next", "Lisp version", "Flags", "Next protocol",
13257 "ver_res", "res", "iid");
13260 M (LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump);
13264 /* Use a control ping for synchronization */
13266 vl_api_control_ping_t *mp;
13267 M (CONTROL_PING, control_ping);
13270 /* Wait for a reply... */
13278 api_lisp_map_resolver_dump (vat_main_t * vam)
13280 vl_api_lisp_map_resolver_dump_t *mp;
13283 if (!vam->json_output)
13285 fformat (vam->ofp, "%=20s\n", "Map resolver");
13288 M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
13292 /* Use a control ping for synchronization */
13294 vl_api_control_ping_t *mp;
13295 M (CONTROL_PING, control_ping);
13298 /* Wait for a reply... */
13306 api_show_lisp_status (vat_main_t * vam)
13308 vl_api_show_lisp_status_t *mp;
13311 if (!vam->json_output)
13313 fformat (vam->ofp, "%-20s%-16s\n", "lisp status", "locator-set");
13316 M (SHOW_LISP_STATUS, show_lisp_status);
13319 /* Wait for a reply... */
13327 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
13329 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
13332 if (!vam->json_output)
13334 fformat (vam->ofp, "%=20s\n", "itr-rlocs:");
13337 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
13340 /* Wait for a reply... */
13348 api_af_packet_create (vat_main_t * vam)
13350 unformat_input_t *i = vam->input;
13351 vl_api_af_packet_create_t *mp;
13353 u8 *host_if_name = 0;
13355 u8 random_hw_addr = 1;
13357 memset (hw_addr, 0, sizeof (hw_addr));
13359 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13361 if (unformat (i, "name %s", &host_if_name))
13362 vec_add1 (host_if_name, 0);
13363 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
13364 random_hw_addr = 0;
13369 if (!vec_len (host_if_name))
13371 errmsg ("host-interface name must be specified");
13375 if (vec_len (host_if_name) > 64)
13377 errmsg ("host-interface name too long");
13381 M (AF_PACKET_CREATE, af_packet_create);
13383 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
13384 clib_memcpy (mp->hw_addr, hw_addr, 6);
13385 mp->use_random_hw_addr = random_hw_addr;
13386 vec_free (host_if_name);
13389 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
13395 api_af_packet_delete (vat_main_t * vam)
13397 unformat_input_t *i = vam->input;
13398 vl_api_af_packet_delete_t *mp;
13400 u8 *host_if_name = 0;
13402 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13404 if (unformat (i, "name %s", &host_if_name))
13405 vec_add1 (host_if_name, 0);
13410 if (!vec_len (host_if_name))
13412 errmsg ("host-interface name must be specified");
13416 if (vec_len (host_if_name) > 64)
13418 errmsg ("host-interface name too long");
13422 M (AF_PACKET_DELETE, af_packet_delete);
13424 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
13425 vec_free (host_if_name);
13434 api_policer_add_del (vat_main_t * vam)
13436 unformat_input_t *i = vam->input;
13437 vl_api_policer_add_del_t *mp;
13448 u8 color_aware = 0;
13449 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
13451 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
13452 conform_action.dscp = 0;
13453 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
13454 exceed_action.dscp = 0;
13455 violate_action.action_type = SSE2_QOS_ACTION_DROP;
13456 violate_action.dscp = 0;
13458 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13460 if (unformat (i, "del"))
13462 else if (unformat (i, "name %s", &name))
13463 vec_add1 (name, 0);
13464 else if (unformat (i, "cir %u", &cir))
13466 else if (unformat (i, "eir %u", &eir))
13468 else if (unformat (i, "cb %u", &cb))
13470 else if (unformat (i, "eb %u", &eb))
13472 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
13475 else if (unformat (i, "round_type %U", unformat_policer_round_type,
13478 else if (unformat (i, "type %U", unformat_policer_type, &type))
13480 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
13483 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
13486 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
13489 else if (unformat (i, "color-aware"))
13495 if (!vec_len (name))
13497 errmsg ("policer name must be specified");
13501 if (vec_len (name) > 64)
13503 errmsg ("policer name too long");
13507 M (POLICER_ADD_DEL, policer_add_del);
13509 clib_memcpy (mp->name, name, vec_len (name));
13511 mp->is_add = is_add;
13516 mp->rate_type = rate_type;
13517 mp->round_type = round_type;
13519 mp->conform_action_type = conform_action.action_type;
13520 mp->conform_dscp = conform_action.dscp;
13521 mp->exceed_action_type = exceed_action.action_type;
13522 mp->exceed_dscp = exceed_action.dscp;
13523 mp->violate_action_type = violate_action.action_type;
13524 mp->violate_dscp = violate_action.dscp;
13525 mp->color_aware = color_aware;
13534 api_policer_dump (vat_main_t * vam)
13536 unformat_input_t *i = vam->input;
13537 vl_api_policer_dump_t *mp;
13539 u8 *match_name = 0;
13540 u8 match_name_valid = 0;
13542 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13544 if (unformat (i, "name %s", &match_name))
13546 vec_add1 (match_name, 0);
13547 match_name_valid = 1;
13553 M (POLICER_DUMP, policer_dump);
13554 mp->match_name_valid = match_name_valid;
13555 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
13556 vec_free (match_name);
13560 /* Use a control ping for synchronization */
13562 vl_api_control_ping_t *mp;
13563 M (CONTROL_PING, control_ping);
13566 /* Wait for a reply... */
13574 api_policer_classify_set_interface (vat_main_t * vam)
13576 unformat_input_t *i = vam->input;
13577 vl_api_policer_classify_set_interface_t *mp;
13580 int sw_if_index_set;
13581 u32 ip4_table_index = ~0;
13582 u32 ip6_table_index = ~0;
13583 u32 l2_table_index = ~0;
13586 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13588 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
13589 sw_if_index_set = 1;
13590 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13591 sw_if_index_set = 1;
13592 else if (unformat (i, "del"))
13594 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13596 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13598 else if (unformat (i, "l2-table %d", &l2_table_index))
13602 clib_warning ("parse error '%U'", format_unformat_error, i);
13607 if (sw_if_index_set == 0)
13609 errmsg ("missing interface name or sw_if_index\n");
13613 M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface);
13615 mp->sw_if_index = ntohl (sw_if_index);
13616 mp->ip4_table_index = ntohl (ip4_table_index);
13617 mp->ip6_table_index = ntohl (ip6_table_index);
13618 mp->l2_table_index = ntohl (l2_table_index);
13619 mp->is_add = is_add;
13628 api_policer_classify_dump (vat_main_t * vam)
13630 unformat_input_t *i = vam->input;
13631 vl_api_policer_classify_dump_t *mp;
13633 u8 type = POLICER_CLASSIFY_N_TABLES;
13635 if (unformat (i, "type %U", unformat_classify_table_type, &type))
13639 errmsg ("classify table type must be specified\n");
13643 if (!vam->json_output)
13645 fformat (vam->ofp, "%10s%20s\n", "Intfc idx", "Classify table");
13648 M (POLICER_CLASSIFY_DUMP, policer_classify_dump);
13653 /* Use a control ping for synchronization */
13655 vl_api_control_ping_t *mp;
13656 M (CONTROL_PING, control_ping);
13659 /* Wait for a reply... */
13667 api_netmap_create (vat_main_t * vam)
13669 unformat_input_t *i = vam->input;
13670 vl_api_netmap_create_t *mp;
13674 u8 random_hw_addr = 1;
13678 memset (hw_addr, 0, sizeof (hw_addr));
13680 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13682 if (unformat (i, "name %s", &if_name))
13683 vec_add1 (if_name, 0);
13684 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
13685 random_hw_addr = 0;
13686 else if (unformat (i, "pipe"))
13688 else if (unformat (i, "master"))
13690 else if (unformat (i, "slave"))
13696 if (!vec_len (if_name))
13698 errmsg ("interface name must be specified");
13702 if (vec_len (if_name) > 64)
13704 errmsg ("interface name too long");
13708 M (NETMAP_CREATE, netmap_create);
13710 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
13711 clib_memcpy (mp->hw_addr, hw_addr, 6);
13712 mp->use_random_hw_addr = random_hw_addr;
13713 mp->is_pipe = is_pipe;
13714 mp->is_master = is_master;
13715 vec_free (if_name);
13724 api_netmap_delete (vat_main_t * vam)
13726 unformat_input_t *i = vam->input;
13727 vl_api_netmap_delete_t *mp;
13731 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13733 if (unformat (i, "name %s", &if_name))
13734 vec_add1 (if_name, 0);
13739 if (!vec_len (if_name))
13741 errmsg ("interface name must be specified");
13745 if (vec_len (if_name) > 64)
13747 errmsg ("interface name too long");
13751 M (NETMAP_DELETE, netmap_delete);
13753 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
13754 vec_free (if_name);
13762 static void vl_api_mpls_gre_tunnel_details_t_handler
13763 (vl_api_mpls_gre_tunnel_details_t * mp)
13765 vat_main_t *vam = &vat_main;
13767 i32 len = ntohl (mp->nlabels);
13769 if (mp->l2_only == 0)
13771 fformat (vam->ofp, "[%d]: src %U, dst %U, adj %U/%d, labels ",
13772 ntohl (mp->tunnel_index),
13773 format_ip4_address, &mp->tunnel_src,
13774 format_ip4_address, &mp->tunnel_dst,
13775 format_ip4_address, &mp->intfc_address,
13776 ntohl (mp->mask_width));
13777 for (i = 0; i < len; i++)
13779 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
13781 fformat (vam->ofp, "\n");
13782 fformat (vam->ofp, " inner fib index %d, outer fib index %d\n",
13783 ntohl (mp->inner_fib_index), ntohl (mp->outer_fib_index));
13787 fformat (vam->ofp, "[%d]: src %U, dst %U, key %U, labels ",
13788 ntohl (mp->tunnel_index),
13789 format_ip4_address, &mp->tunnel_src,
13790 format_ip4_address, &mp->tunnel_dst,
13791 format_ip4_address, &mp->intfc_address);
13792 for (i = 0; i < len; i++)
13794 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
13796 fformat (vam->ofp, "\n");
13797 fformat (vam->ofp, " l2 interface %d, outer fib index %d\n",
13798 ntohl (mp->hw_if_index), ntohl (mp->outer_fib_index));
13802 static void vl_api_mpls_gre_tunnel_details_t_handler_json
13803 (vl_api_mpls_gre_tunnel_details_t * mp)
13805 vat_main_t *vam = &vat_main;
13806 vat_json_node_t *node = NULL;
13807 struct in_addr ip4;
13809 i32 len = ntohl (mp->nlabels);
13811 if (VAT_JSON_ARRAY != vam->json_tree.type)
13813 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13814 vat_json_init_array (&vam->json_tree);
13816 node = vat_json_array_add (&vam->json_tree);
13818 vat_json_init_object (node);
13819 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
13820 clib_memcpy (&ip4, &(mp->intfc_address), sizeof (ip4));
13821 vat_json_object_add_ip4 (node, "intfc_address", ip4);
13822 vat_json_object_add_uint (node, "inner_fib_index",
13823 ntohl (mp->inner_fib_index));
13824 vat_json_object_add_uint (node, "mask_width", ntohl (mp->mask_width));
13825 vat_json_object_add_uint (node, "encap_index", ntohl (mp->encap_index));
13826 vat_json_object_add_uint (node, "hw_if_index", ntohl (mp->hw_if_index));
13827 vat_json_object_add_uint (node, "l2_only", ntohl (mp->l2_only));
13828 clib_memcpy (&ip4, &(mp->tunnel_src), sizeof (ip4));
13829 vat_json_object_add_ip4 (node, "tunnel_src", ip4);
13830 clib_memcpy (&ip4, &(mp->tunnel_dst), sizeof (ip4));
13831 vat_json_object_add_ip4 (node, "tunnel_dst", ip4);
13832 vat_json_object_add_uint (node, "outer_fib_index",
13833 ntohl (mp->outer_fib_index));
13834 vat_json_object_add_uint (node, "label_count", len);
13835 for (i = 0; i < len; i++)
13837 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
13842 api_mpls_gre_tunnel_dump (vat_main_t * vam)
13844 vl_api_mpls_gre_tunnel_dump_t *mp;
13848 /* Parse args required to build the message */
13849 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
13851 if (!unformat (vam->input, "tunnel_index %d", &index))
13858 fformat (vam->ofp, " tunnel_index %d\n", index);
13860 M (MPLS_GRE_TUNNEL_DUMP, mpls_gre_tunnel_dump);
13861 mp->tunnel_index = htonl (index);
13864 /* Use a control ping for synchronization */
13866 vl_api_control_ping_t *mp;
13867 M (CONTROL_PING, control_ping);
13873 static void vl_api_mpls_eth_tunnel_details_t_handler
13874 (vl_api_mpls_eth_tunnel_details_t * mp)
13876 vat_main_t *vam = &vat_main;
13878 i32 len = ntohl (mp->nlabels);
13880 fformat (vam->ofp, "[%d]: dst %U, adj %U/%d, labels ",
13881 ntohl (mp->tunnel_index),
13882 format_ethernet_address, &mp->tunnel_dst_mac,
13883 format_ip4_address, &mp->intfc_address, ntohl (mp->mask_width));
13884 for (i = 0; i < len; i++)
13886 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
13888 fformat (vam->ofp, "\n");
13889 fformat (vam->ofp, " tx on %d, rx fib index %d\n",
13890 ntohl (mp->tx_sw_if_index), ntohl (mp->inner_fib_index));
13893 static void vl_api_mpls_eth_tunnel_details_t_handler_json
13894 (vl_api_mpls_eth_tunnel_details_t * mp)
13896 vat_main_t *vam = &vat_main;
13897 vat_json_node_t *node = NULL;
13898 struct in_addr ip4;
13900 i32 len = ntohl (mp->nlabels);
13902 if (VAT_JSON_ARRAY != vam->json_tree.type)
13904 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13905 vat_json_init_array (&vam->json_tree);
13907 node = vat_json_array_add (&vam->json_tree);
13909 vat_json_init_object (node);
13910 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
13911 clib_memcpy (&ip4, &(mp->intfc_address), sizeof (ip4));
13912 vat_json_object_add_ip4 (node, "intfc_address", ip4);
13913 vat_json_object_add_uint (node, "inner_fib_index",
13914 ntohl (mp->inner_fib_index));
13915 vat_json_object_add_uint (node, "mask_width", ntohl (mp->mask_width));
13916 vat_json_object_add_uint (node, "encap_index", ntohl (mp->encap_index));
13917 vat_json_object_add_uint (node, "hw_if_index", ntohl (mp->hw_if_index));
13918 vat_json_object_add_uint (node, "l2_only", ntohl (mp->l2_only));
13919 vat_json_object_add_string_copy (node, "tunnel_dst_mac",
13920 format (0, "%U", format_ethernet_address,
13921 &mp->tunnel_dst_mac));
13922 vat_json_object_add_uint (node, "tx_sw_if_index",
13923 ntohl (mp->tx_sw_if_index));
13924 vat_json_object_add_uint (node, "label_count", len);
13925 for (i = 0; i < len; i++)
13927 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
13932 api_mpls_eth_tunnel_dump (vat_main_t * vam)
13934 vl_api_mpls_eth_tunnel_dump_t *mp;
13938 /* Parse args required to build the message */
13939 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
13941 if (!unformat (vam->input, "tunnel_index %d", &index))
13948 fformat (vam->ofp, " tunnel_index %d\n", index);
13950 M (MPLS_ETH_TUNNEL_DUMP, mpls_eth_tunnel_dump);
13951 mp->tunnel_index = htonl (index);
13954 /* Use a control ping for synchronization */
13956 vl_api_control_ping_t *mp;
13957 M (CONTROL_PING, control_ping);
13963 static void vl_api_mpls_fib_encap_details_t_handler
13964 (vl_api_mpls_fib_encap_details_t * mp)
13966 vat_main_t *vam = &vat_main;
13968 i32 len = ntohl (mp->nlabels);
13970 fformat (vam->ofp, "table %d, dest %U, label ",
13971 ntohl (mp->fib_index), format_ip4_address, &mp->dest, len);
13972 for (i = 0; i < len; i++)
13974 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
13976 fformat (vam->ofp, "\n");
13979 static void vl_api_mpls_fib_encap_details_t_handler_json
13980 (vl_api_mpls_fib_encap_details_t * mp)
13982 vat_main_t *vam = &vat_main;
13983 vat_json_node_t *node = NULL;
13985 i32 len = ntohl (mp->nlabels);
13986 struct in_addr ip4;
13988 if (VAT_JSON_ARRAY != vam->json_tree.type)
13990 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13991 vat_json_init_array (&vam->json_tree);
13993 node = vat_json_array_add (&vam->json_tree);
13995 vat_json_init_object (node);
13996 vat_json_object_add_uint (node, "table", ntohl (mp->fib_index));
13997 vat_json_object_add_uint (node, "entry_index", ntohl (mp->entry_index));
13998 clib_memcpy (&ip4, &(mp->dest), sizeof (ip4));
13999 vat_json_object_add_ip4 (node, "dest", ip4);
14000 vat_json_object_add_uint (node, "s_bit", ntohl (mp->s_bit));
14001 vat_json_object_add_uint (node, "label_count", len);
14002 for (i = 0; i < len; i++)
14004 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14009 api_mpls_fib_encap_dump (vat_main_t * vam)
14011 vl_api_mpls_fib_encap_dump_t *mp;
14014 M (MPLS_FIB_ENCAP_DUMP, mpls_fib_encap_dump);
14017 /* Use a control ping for synchronization */
14019 vl_api_control_ping_t *mp;
14020 M (CONTROL_PING, control_ping);
14026 static void vl_api_mpls_fib_decap_details_t_handler
14027 (vl_api_mpls_fib_decap_details_t * mp)
14029 vat_main_t *vam = &vat_main;
14032 "RX table %d, TX table/intfc %u, swif_tag '%s', label %u, s_bit %u\n",
14033 ntohl (mp->rx_table_id), ntohl (mp->tx_table_id), mp->swif_tag,
14034 ntohl (mp->label), ntohl (mp->s_bit));
14037 static void vl_api_mpls_fib_decap_details_t_handler_json
14038 (vl_api_mpls_fib_decap_details_t * mp)
14040 vat_main_t *vam = &vat_main;
14041 vat_json_node_t *node = NULL;
14042 struct in_addr ip4;
14044 if (VAT_JSON_ARRAY != vam->json_tree.type)
14046 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14047 vat_json_init_array (&vam->json_tree);
14049 node = vat_json_array_add (&vam->json_tree);
14051 vat_json_init_object (node);
14052 vat_json_object_add_uint (node, "table", ntohl (mp->fib_index));
14053 vat_json_object_add_uint (node, "entry_index", ntohl (mp->entry_index));
14054 clib_memcpy (&ip4, &(mp->dest), sizeof (ip4));
14055 vat_json_object_add_ip4 (node, "dest", ip4);
14056 vat_json_object_add_uint (node, "s_bit", ntohl (mp->s_bit));
14057 vat_json_object_add_uint (node, "label", ntohl (mp->label));
14058 vat_json_object_add_uint (node, "rx_table_id", ntohl (mp->rx_table_id));
14059 vat_json_object_add_uint (node, "tx_table_id", ntohl (mp->tx_table_id));
14060 vat_json_object_add_string_copy (node, "swif_tag", mp->swif_tag);
14064 api_mpls_fib_decap_dump (vat_main_t * vam)
14066 vl_api_mpls_fib_decap_dump_t *mp;
14069 M (MPLS_FIB_DECAP_DUMP, mpls_fib_decap_dump);
14072 /* Use a control ping for synchronization */
14074 vl_api_control_ping_t *mp;
14075 M (CONTROL_PING, control_ping);
14082 api_classify_table_ids (vat_main_t * vam)
14084 vl_api_classify_table_ids_t *mp;
14087 /* Construct the API message */
14088 M (CLASSIFY_TABLE_IDS, classify_table_ids);
14098 api_classify_table_by_interface (vat_main_t * vam)
14100 unformat_input_t *input = vam->input;
14101 vl_api_classify_table_by_interface_t *mp;
14104 u32 sw_if_index = ~0;
14105 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14107 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
14109 else if (unformat (input, "sw_if_index %d", &sw_if_index))
14114 if (sw_if_index == ~0)
14116 errmsg ("missing interface name or sw_if_index\n");
14120 /* Construct the API message */
14121 M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
14123 mp->sw_if_index = ntohl (sw_if_index);
14132 api_classify_table_info (vat_main_t * vam)
14134 unformat_input_t *input = vam->input;
14135 vl_api_classify_table_info_t *mp;
14139 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14141 if (unformat (input, "table_id %d", &table_id))
14146 if (table_id == ~0)
14148 errmsg ("missing table id\n");
14152 /* Construct the API message */
14153 M (CLASSIFY_TABLE_INFO, classify_table_info);
14155 mp->table_id = ntohl (table_id);
14164 api_classify_session_dump (vat_main_t * vam)
14166 unformat_input_t *input = vam->input;
14167 vl_api_classify_session_dump_t *mp;
14171 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14173 if (unformat (input, "table_id %d", &table_id))
14178 if (table_id == ~0)
14180 errmsg ("missing table id\n");
14184 /* Construct the API message */
14185 M (CLASSIFY_SESSION_DUMP, classify_session_dump);
14187 mp->table_id = ntohl (table_id);
14190 /* Use a control ping for synchronization */
14192 vl_api_control_ping_t *mp;
14193 M (CONTROL_PING, control_ping);
14202 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
14204 vat_main_t *vam = &vat_main;
14206 fformat (vam->ofp, "collector_address %U, collector_port %d, "
14207 "src_address %U, vrf_id %d, path_mtu %u, "
14208 "template_interval %u, udp_checksum %d\n",
14209 format_ip4_address, mp->collector_address,
14210 ntohs (mp->collector_port),
14211 format_ip4_address, mp->src_address,
14212 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
14213 ntohl (mp->template_interval), mp->udp_checksum);
14216 vam->result_ready = 1;
14220 vl_api_ipfix_exporter_details_t_handler_json
14221 (vl_api_ipfix_exporter_details_t * mp)
14223 vat_main_t *vam = &vat_main;
14224 vat_json_node_t node;
14225 struct in_addr collector_address;
14226 struct in_addr src_address;
14228 vat_json_init_object (&node);
14229 clib_memcpy (&collector_address, &mp->collector_address,
14230 sizeof (collector_address));
14231 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
14232 vat_json_object_add_uint (&node, "collector_port",
14233 ntohs (mp->collector_port));
14234 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
14235 vat_json_object_add_ip4 (&node, "src_address", src_address);
14236 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
14237 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
14238 vat_json_object_add_uint (&node, "template_interval",
14239 ntohl (mp->template_interval));
14240 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
14242 vat_json_print (vam->ofp, &node);
14243 vat_json_free (&node);
14245 vam->result_ready = 1;
14249 api_ipfix_exporter_dump (vat_main_t * vam)
14251 vl_api_ipfix_exporter_dump_t *mp;
14254 /* Construct the API message */
14255 M (IPFIX_EXPORTER_DUMP, ipfix_exporter_dump);
14265 api_ipfix_classify_stream_dump (vat_main_t * vam)
14267 vl_api_ipfix_classify_stream_dump_t *mp;
14270 /* Construct the API message */
14271 M (IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump);
14281 vl_api_ipfix_classify_stream_details_t_handler
14282 (vl_api_ipfix_classify_stream_details_t * mp)
14284 vat_main_t *vam = &vat_main;
14285 fformat (vam->ofp, "domain_id %d, src_port %d\n",
14286 ntohl (mp->domain_id), ntohs (mp->src_port));
14288 vam->result_ready = 1;
14292 vl_api_ipfix_classify_stream_details_t_handler_json
14293 (vl_api_ipfix_classify_stream_details_t * mp)
14295 vat_main_t *vam = &vat_main;
14296 vat_json_node_t node;
14298 vat_json_init_object (&node);
14299 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
14300 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
14302 vat_json_print (vam->ofp, &node);
14303 vat_json_free (&node);
14305 vam->result_ready = 1;
14309 api_ipfix_classify_table_dump (vat_main_t * vam)
14311 vl_api_ipfix_classify_table_dump_t *mp;
14314 if (!vam->json_output)
14316 fformat (vam->ofp, "%15s%15s%20s\n", "table_id", "ip_version",
14317 "transport_protocol");
14320 /* Construct the API message */
14321 M (IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump);
14326 /* Use a control ping for synchronization */
14328 vl_api_control_ping_t *mp;
14329 M (CONTROL_PING, control_ping);
14336 vl_api_ipfix_classify_table_details_t_handler
14337 (vl_api_ipfix_classify_table_details_t * mp)
14339 vat_main_t *vam = &vat_main;
14340 fformat (vam->ofp, "%15d%15d%20d\n", ntohl (mp->table_id), mp->ip_version,
14341 mp->transport_protocol);
14345 vl_api_ipfix_classify_table_details_t_handler_json
14346 (vl_api_ipfix_classify_table_details_t * mp)
14348 vat_json_node_t *node = NULL;
14349 vat_main_t *vam = &vat_main;
14351 if (VAT_JSON_ARRAY != vam->json_tree.type)
14353 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14354 vat_json_init_array (&vam->json_tree);
14357 node = vat_json_array_add (&vam->json_tree);
14358 vat_json_init_object (node);
14360 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
14361 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
14362 vat_json_object_add_uint (node, "transport_protocol",
14363 mp->transport_protocol);
14367 api_pg_create_interface (vat_main_t * vam)
14369 unformat_input_t *input = vam->input;
14370 vl_api_pg_create_interface_t *mp;
14374 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14376 if (unformat (input, "if_id %d", &if_id))
14383 errmsg ("missing pg interface index\n");
14387 /* Construct the API message */
14388 M (PG_CREATE_INTERFACE, pg_create_interface);
14390 mp->interface_id = ntohl (if_id);
14399 api_pg_capture (vat_main_t * vam)
14401 unformat_input_t *input = vam->input;
14402 vl_api_pg_capture_t *mp;
14408 u8 pcap_file_set = 0;
14410 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14412 if (unformat (input, "if_id %d", &if_id))
14414 else if (unformat (input, "pcap %s", &pcap_file))
14416 else if (unformat (input, "count %d", &count))
14418 else if (unformat (input, "disable"))
14425 errmsg ("missing pg interface index\n");
14428 if (pcap_file_set > 0)
14430 if (vec_len (pcap_file) > 255)
14432 errmsg ("pcap file name is too long\n");
14437 u32 name_len = vec_len (pcap_file);
14438 /* Construct the API message */
14439 M (PG_CAPTURE, pg_capture);
14441 mp->interface_id = ntohl (if_id);
14442 mp->is_enabled = enable;
14443 mp->count = ntohl (count);
14444 mp->pcap_name_length = ntohl (name_len);
14445 if (pcap_file_set != 0)
14447 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
14449 vec_free (pcap_file);
14458 api_pg_enable_disable (vat_main_t * vam)
14460 unformat_input_t *input = vam->input;
14461 vl_api_pg_enable_disable_t *mp;
14465 u8 stream_name_set = 0;
14466 u8 *stream_name = 0;
14467 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14469 if (unformat (input, "stream %s", &stream_name))
14470 stream_name_set = 1;
14471 else if (unformat (input, "disable"))
14477 if (stream_name_set > 0)
14479 if (vec_len (stream_name) > 255)
14481 errmsg ("stream name too long\n");
14486 u32 name_len = vec_len (stream_name);
14487 /* Construct the API message */
14488 M (PG_ENABLE_DISABLE, pg_enable_disable);
14490 mp->is_enabled = enable;
14491 if (stream_name_set != 0)
14493 mp->stream_name_length = ntohl (name_len);
14494 clib_memcpy (mp->stream_name, stream_name, name_len);
14496 vec_free (stream_name);
14505 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
14507 unformat_input_t *input = vam->input;
14508 vl_api_ip_source_and_port_range_check_add_del_t *mp;
14511 u16 *low_ports = 0;
14512 u16 *high_ports = 0;
14515 ip4_address_t ip4_addr;
14516 ip6_address_t ip6_addr;
14524 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14526 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
14532 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
14537 else if (unformat (input, "vrf %d", &vrf_id))
14539 else if (unformat (input, "del"))
14541 else if (unformat (input, "port %d", &tmp))
14543 if (tmp == 0 || tmp > 65535)
14545 errmsg ("port %d out of range", tmp);
14549 this_hi = this_low + 1;
14550 vec_add1 (low_ports, this_low);
14551 vec_add1 (high_ports, this_hi);
14553 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
14555 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
14557 errmsg ("incorrect range parameters\n");
14561 /* Note: in debug CLI +1 is added to high before
14562 passing to real fn that does "the work"
14563 (ip_source_and_port_range_check_add_del).
14564 This fn is a wrapper around the binary API fn a
14565 control plane will call, which expects this increment
14566 to have occurred. Hence letting the binary API control
14567 plane fn do the increment for consistency between VAT
14568 and other control planes.
14571 vec_add1 (low_ports, this_low);
14572 vec_add1 (high_ports, this_hi);
14578 if (prefix_set == 0)
14580 errmsg ("<address>/<mask> not specified\n");
14586 errmsg ("VRF ID required, not specified\n");
14593 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
14597 if (vec_len (low_ports) == 0)
14599 errmsg ("At least one port or port range required\n");
14603 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,
14604 ip_source_and_port_range_check_add_del);
14606 mp->is_add = is_add;
14611 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
14616 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
14619 mp->mask_length = length;
14620 mp->number_of_ranges = vec_len (low_ports);
14622 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
14623 vec_free (low_ports);
14625 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
14626 vec_free (high_ports);
14628 mp->vrf_id = ntohl (vrf_id);
14637 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
14639 unformat_input_t *input = vam->input;
14640 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
14642 u32 sw_if_index = ~0;
14644 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
14645 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
14648 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14650 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
14652 else if (unformat (input, "sw_if_index %d", &sw_if_index))
14654 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
14656 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
14658 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
14660 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
14662 else if (unformat (input, "del"))
14668 if (sw_if_index == ~0)
14670 errmsg ("Interface required but not specified\n");
14676 errmsg ("VRF ID required but not specified\n");
14680 if (tcp_out_vrf_id == 0
14681 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
14684 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
14688 /* Construct the API message */
14689 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,
14690 ip_source_and_port_range_check_interface_add_del);
14692 mp->sw_if_index = ntohl (sw_if_index);
14693 mp->is_add = is_add;
14694 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
14695 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
14696 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
14697 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
14702 /* Wait for a reply... */
14707 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
14709 unformat_input_t *i = vam->input;
14710 vl_api_ipsec_gre_add_del_tunnel_t *mp;
14712 u32 local_sa_id = 0;
14713 u32 remote_sa_id = 0;
14714 ip4_address_t src_address;
14715 ip4_address_t dst_address;
14718 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14720 if (unformat (i, "local_sa %d", &local_sa_id))
14722 else if (unformat (i, "remote_sa %d", &remote_sa_id))
14724 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
14726 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
14728 else if (unformat (i, "del"))
14732 clib_warning ("parse error '%U'", format_unformat_error, i);
14737 M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel);
14739 mp->local_sa_id = ntohl (local_sa_id);
14740 mp->remote_sa_id = ntohl (remote_sa_id);
14741 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
14742 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
14743 mp->is_add = is_add;
14751 static void vl_api_ipsec_gre_tunnel_details_t_handler
14752 (vl_api_ipsec_gre_tunnel_details_t * mp)
14754 vat_main_t *vam = &vat_main;
14756 fformat (vam->ofp, "%11d%15U%15U%14d%14d\n",
14757 ntohl (mp->sw_if_index),
14758 format_ip4_address, &mp->src_address,
14759 format_ip4_address, &mp->dst_address,
14760 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
14763 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
14764 (vl_api_ipsec_gre_tunnel_details_t * mp)
14766 vat_main_t *vam = &vat_main;
14767 vat_json_node_t *node = NULL;
14768 struct in_addr ip4;
14770 if (VAT_JSON_ARRAY != vam->json_tree.type)
14772 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14773 vat_json_init_array (&vam->json_tree);
14775 node = vat_json_array_add (&vam->json_tree);
14777 vat_json_init_object (node);
14778 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14779 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
14780 vat_json_object_add_ip4 (node, "src_address", ip4);
14781 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
14782 vat_json_object_add_ip4 (node, "dst_address", ip4);
14783 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
14784 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
14788 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
14790 unformat_input_t *i = vam->input;
14791 vl_api_ipsec_gre_tunnel_dump_t *mp;
14794 u8 sw_if_index_set = 0;
14796 /* Parse args required to build the message */
14797 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14799 if (unformat (i, "sw_if_index %d", &sw_if_index))
14800 sw_if_index_set = 1;
14805 if (sw_if_index_set == 0)
14810 if (!vam->json_output)
14812 fformat (vam->ofp, "%11s%15s%15s%14s%14s\n",
14813 "sw_if_index", "src_address", "dst_address",
14814 "local_sa_id", "remote_sa_id");
14817 /* Get list of gre-tunnel interfaces */
14818 M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump);
14820 mp->sw_if_index = htonl (sw_if_index);
14824 /* Use a control ping for synchronization */
14826 vl_api_control_ping_t *mp;
14827 M (CONTROL_PING, control_ping);
14834 api_delete_subif (vat_main_t * vam)
14836 unformat_input_t *i = vam->input;
14837 vl_api_delete_subif_t *mp;
14839 u32 sw_if_index = ~0;
14841 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14843 if (unformat (i, "sw_if_index %d", &sw_if_index))
14849 if (sw_if_index == ~0)
14851 errmsg ("missing sw_if_index\n");
14855 /* Construct the API message */
14856 M (DELETE_SUBIF, delete_subif);
14857 mp->sw_if_index = ntohl (sw_if_index);
14864 q_or_quit (vat_main_t * vam)
14866 longjmp (vam->jump_buf, 1);
14867 return 0; /* not so much */
14871 q (vat_main_t * vam)
14873 return q_or_quit (vam);
14877 quit (vat_main_t * vam)
14879 return q_or_quit (vam);
14883 comment (vat_main_t * vam)
14889 cmd_cmp (void *a1, void *a2)
14894 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
14898 help (vat_main_t * vam)
14903 unformat_input_t *i = vam->input;
14906 if (unformat (i, "%s", &name))
14910 vec_add1 (name, 0);
14912 hs = hash_get_mem (vam->help_by_name, name);
14914 fformat (vam->ofp, "usage: %s %s\n", name, hs[0]);
14916 fformat (vam->ofp, "No such msg / command '%s'\n", name);
14921 fformat (vam->ofp, "Help is available for the following:\n");
14924 hash_foreach_pair (p, vam->function_by_name,
14926 vec_add1 (cmds, (u8 *)(p->key));
14930 vec_sort_with_function (cmds, cmd_cmp);
14932 for (j = 0; j < vec_len (cmds); j++)
14933 fformat (vam->ofp, "%s\n", cmds[j]);
14940 set (vat_main_t * vam)
14942 u8 *name = 0, *value = 0;
14943 unformat_input_t *i = vam->input;
14945 if (unformat (i, "%s", &name))
14947 /* The input buffer is a vector, not a string. */
14948 value = vec_dup (i->buffer);
14949 vec_delete (value, i->index, 0);
14950 /* Almost certainly has a trailing newline */
14951 if (value[vec_len (value) - 1] == '\n')
14952 value[vec_len (value) - 1] = 0;
14953 /* Make sure it's a proper string, one way or the other */
14954 vec_add1 (value, 0);
14955 (void) clib_macro_set_value (&vam->macro_main,
14956 (char *) name, (char *) value);
14959 errmsg ("usage: set <name> <value>\n");
14967 unset (vat_main_t * vam)
14971 if (unformat (vam->input, "%s", &name))
14972 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
14973 errmsg ("unset: %s wasn't set\n", name);
14986 macro_sort_cmp (void *a1, void *a2)
14988 macro_sort_t *s1 = a1;
14989 macro_sort_t *s2 = a2;
14991 return strcmp ((char *) (s1->name), (char *) (s2->name));
14995 dump_macro_table (vat_main_t * vam)
14997 macro_sort_t *sort_me = 0, *sm;
15002 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
15004 vec_add2 (sort_me, sm, 1);
15005 sm->name = (u8 *)(p->key);
15006 sm->value = (u8 *) (p->value[0]);
15010 vec_sort_with_function (sort_me, macro_sort_cmp);
15012 if (vec_len (sort_me))
15013 fformat (vam->ofp, "%-15s%s\n", "Name", "Value");
15015 fformat (vam->ofp, "The macro table is empty...\n");
15017 for (i = 0; i < vec_len (sort_me); i++)
15018 fformat (vam->ofp, "%-15s%s\n", sort_me[i].name, sort_me[i].value);
15023 dump_node_table (vat_main_t * vam)
15026 vlib_node_t *node, *next_node;
15028 if (vec_len (vam->graph_nodes) == 0)
15030 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
15034 for (i = 0; i < vec_len (vam->graph_nodes); i++)
15036 node = vam->graph_nodes[i];
15037 fformat (vam->ofp, "[%d] %s\n", i, node->name);
15038 for (j = 0; j < vec_len (node->next_nodes); j++)
15040 if (node->next_nodes[j] != ~0)
15042 next_node = vam->graph_nodes[node->next_nodes[j]];
15043 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
15051 search_node_table (vat_main_t * vam)
15053 unformat_input_t *line_input = vam->input;
15056 vlib_node_t *node, *next_node;
15059 if (vam->graph_node_index_by_name == 0)
15061 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
15065 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15067 if (unformat (line_input, "%s", &node_to_find))
15069 vec_add1 (node_to_find, 0);
15070 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
15073 fformat (vam->ofp, "%s not found...\n", node_to_find);
15076 node = vam->graph_nodes[p[0]];
15077 fformat (vam->ofp, "[%d] %s\n", p[0], node->name);
15078 for (j = 0; j < vec_len (node->next_nodes); j++)
15080 if (node->next_nodes[j] != ~0)
15082 next_node = vam->graph_nodes[node->next_nodes[j]];
15083 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
15090 clib_warning ("parse error '%U'", format_unformat_error,
15096 vec_free (node_to_find);
15105 script (vat_main_t * vam)
15108 char *save_current_file;
15109 unformat_input_t save_input;
15110 jmp_buf save_jump_buf;
15111 u32 save_line_number;
15113 FILE *new_fp, *save_ifp;
15115 if (unformat (vam->input, "%s", &s))
15117 new_fp = fopen ((char *) s, "r");
15120 errmsg ("Couldn't open script file %s\n", s);
15127 errmsg ("Missing script name\n");
15131 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
15132 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
15133 save_ifp = vam->ifp;
15134 save_line_number = vam->input_line_number;
15135 save_current_file = (char *) vam->current_file;
15137 vam->input_line_number = 0;
15139 vam->current_file = s;
15142 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
15143 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
15144 vam->ifp = save_ifp;
15145 vam->input_line_number = save_line_number;
15146 vam->current_file = (u8 *) save_current_file;
15153 echo (vat_main_t * vam)
15155 fformat (vam->ofp, "%v", vam->input->buffer);
15159 /* List of API message constructors, CLI names map to api_xxx */
15160 #define foreach_vpe_api_msg \
15161 _(create_loopback,"[mac <mac-addr>]") \
15162 _(sw_interface_dump,"") \
15163 _(sw_interface_set_flags, \
15164 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
15165 _(sw_interface_add_del_address, \
15166 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
15167 _(sw_interface_set_table, \
15168 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
15169 _(sw_interface_set_vpath, \
15170 "<intfc> | sw_if_index <id> enable | disable") \
15171 _(sw_interface_set_l2_xconnect, \
15172 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
15173 "enable | disable") \
15174 _(sw_interface_set_l2_bridge, \
15175 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
15176 "[shg <split-horizon-group>] [bvi]\n" \
15177 "enable | disable") \
15178 _(bridge_domain_add_del, \
15179 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n")\
15180 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
15182 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
15184 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
15186 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
15188 "tapname <name> mac <mac-addr> | random-mac") \
15190 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
15192 "<vpp-if-name> | sw_if_index <id>") \
15193 _(sw_interface_tap_dump, "") \
15194 _(ip_add_del_route, \
15195 "<addr>/<mask> via <addr> [vrf <n>]\n" \
15196 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
15197 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
15198 "[multipath] [count <n>]") \
15199 _(proxy_arp_add_del, \
15200 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
15201 _(proxy_arp_intfc_enable_disable, \
15202 "<intfc> | sw_if_index <id> enable | disable") \
15203 _(mpls_add_del_encap, \
15204 "label <n> dst <ip4-addr> [vrf <n>] [del]") \
15205 _(mpls_add_del_decap, \
15206 "label <n> [rx_vrf_id <n>] [tx_vrf_id] [s-bit-clear][del]") \
15207 _(mpls_gre_add_del_tunnel, \
15208 "inner_vrf_id <n> outer_vrf_id <n> src <ip4-address> dst <ip4-address>\n" \
15209 "adj <ip4-address>/<mask-width> [del]") \
15210 _(sw_interface_set_unnumbered, \
15211 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
15212 _(ip_neighbor_add_del, \
15213 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
15214 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
15215 _(reset_vrf, "vrf <id> [ipv6]") \
15216 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
15217 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
15218 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
15219 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
15220 "[outer_vlan_id_any][inner_vlan_id_any]") \
15221 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
15222 _(reset_fib, "vrf <n> [ipv6]") \
15223 _(dhcp_proxy_config, \
15224 "svr <v46-address> src <v46-address>\n" \
15225 "insert-cid <n> [del]") \
15226 _(dhcp_proxy_config_2, \
15227 "svr <v46-address> src <v46-address>\n" \
15228 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
15229 _(dhcp_proxy_set_vss, \
15230 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
15231 _(dhcp_client_config, \
15232 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
15233 _(set_ip_flow_hash, \
15234 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
15235 _(sw_interface_ip6_enable_disable, \
15236 "<intfc> | sw_if_index <id> enable | disable") \
15237 _(sw_interface_ip6_set_link_local_address, \
15238 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
15239 _(sw_interface_ip6nd_ra_prefix, \
15240 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
15241 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
15242 "[nolink] [isno]") \
15243 _(sw_interface_ip6nd_ra_config, \
15244 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
15245 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
15246 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
15247 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
15248 _(l2_patch_add_del, \
15249 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
15250 "enable | disable") \
15251 _(mpls_ethernet_add_del_tunnel, \
15252 "tx <intfc> | tx_sw_if_index <n> dst <mac-addr>\n" \
15253 "adj <ip4-addr>/<mw> dst <mac-addr> [del]") \
15254 _(mpls_ethernet_add_del_tunnel_2, \
15255 "inner_vrf_id <n> outer_vrf_id <n> next-hop <ip4-addr>\n" \
15256 "resolve-attempts <n> resolve-if-needed 0 | 1 [del]") \
15257 _(sr_tunnel_add_del, \
15258 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
15259 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
15260 "[policy <policy_name>]") \
15261 _(sr_policy_add_del, \
15262 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
15263 _(sr_multicast_map_add_del, \
15264 "address [ip6 multicast address] sr-policy [policy name] [del]") \
15265 _(classify_add_del_table, \
15266 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
15267 "[del] mask <mask-value>\n" \
15268 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>") \
15269 _(classify_add_del_session, \
15270 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
15271 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
15272 " [l3 [ip4|ip6]]") \
15273 _(classify_set_interface_ip_table, \
15274 "<intfc> | sw_if_index <nn> table <nn>") \
15275 _(classify_set_interface_l2_tables, \
15276 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
15277 " [other-table <nn>]") \
15278 _(get_node_index, "node <node-name") \
15279 _(add_node_next, "node <node-name> next <next-node-name>") \
15280 _(l2tpv3_create_tunnel, \
15281 "client_address <ip6-addr> our_address <ip6-addr>\n" \
15282 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n"\
15283 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
15284 _(l2tpv3_set_tunnel_cookies, \
15285 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
15286 "[new_remote_cookie <nn>]\n") \
15287 _(l2tpv3_interface_enable_disable, \
15288 "<intfc> | sw_if_index <nn> enable | disable") \
15289 _(l2tpv3_set_lookup_key, \
15290 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
15291 _(sw_if_l2tpv3_tunnel_dump, "") \
15292 _(vxlan_add_del_tunnel, \
15293 "src <ip-addr> dst <ip-addr> vni <vni> [encap-vrf-id <nn>]\n" \
15294 " [decap-next l2|ip4|ip6] [del]") \
15295 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
15296 _(gre_add_del_tunnel, \
15297 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
15298 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
15299 _(l2_fib_clear_table, "") \
15300 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
15301 _(l2_interface_vlan_tag_rewrite, \
15302 "<intfc> | sw_if_index <nn> \n" \
15303 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
15304 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
15305 _(create_vhost_user_if, \
15306 "socket <filename> [server] [renumber <dev_instance>] " \
15307 "[mac <mac_address>]") \
15308 _(modify_vhost_user_if, \
15309 "<intfc> | sw_if_index <nn> socket <filename>\n" \
15310 "[server] [renumber <dev_instance>]") \
15311 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
15312 _(sw_interface_vhost_user_dump, "") \
15313 _(show_version, "") \
15314 _(vxlan_gpe_add_del_tunnel, \
15315 "local <addr> remote <addr> vni <nn>\n" \
15316 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
15317 "[next-ethernet] [next-nsh]\n") \
15318 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
15319 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
15320 _(interface_name_renumber, \
15321 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
15322 _(input_acl_set_interface, \
15323 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
15324 " [l2-table <nn>] [del]") \
15325 _(want_ip4_arp_events, "address <ip4-address> [del]") \
15326 _(want_ip6_nd_events, "address <ip6-address> [del]") \
15327 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
15328 _(ip_dump, "ipv4 | ipv6") \
15329 _(ipsec_spd_add_del, "spd_id <n> [del]") \
15330 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
15332 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
15333 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
15334 " integ_alg <alg> integ_key <hex>") \
15335 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
15336 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
15337 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
15338 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" )\
15339 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
15340 _(ikev2_profile_add_del, "name <profile_name> [del]") \
15341 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
15342 "(auth_data 0x<data> | auth_data <data>)") \
15343 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
15344 "(id_data 0x<data> | id_data <data>) (local|remote)") \
15345 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
15346 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
15347 "(local|remote)") \
15348 _(ikev2_set_local_key, "file <absolute_file_path>") \
15349 _(delete_loopback,"sw_if_index <nn>") \
15350 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
15351 _(map_add_domain, \
15352 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
15353 "ip6-src <ip6addr> " \
15354 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
15355 _(map_del_domain, "index <n>") \
15356 _(map_add_del_rule, \
15357 "index <n> psid <n> dst <ip6addr> [del]") \
15358 _(map_domain_dump, "") \
15359 _(map_rule_dump, "index <map-domain>") \
15360 _(want_interface_events, "enable|disable") \
15361 _(want_stats,"enable|disable") \
15362 _(get_first_msg_id, "client <name>") \
15363 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
15364 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
15365 "fib-id <nn> [ip4][ip6][default]") \
15366 _(get_node_graph, " ") \
15367 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
15368 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
15369 _(ioam_disable, "") \
15370 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
15371 " sw_if_index <sw_if_index> p <priority> " \
15372 "w <weight>] [del]") \
15373 _(lisp_add_del_locator, "locator-set <locator_name> " \
15374 "iface <intf> | sw_if_index <sw_if_index> " \
15375 "p <priority> w <weight> [del]") \
15376 _(lisp_add_del_local_eid,"vni <vni> eid " \
15377 "<ipv4|ipv6>/<prefix> | <L2 address> " \
15378 "locator-set <locator_name> [del]") \
15379 _(lisp_gpe_add_del_fwd_entry, "rmt_eid <eid> [lcl_eid <eid>] vni <vni>" \
15380 "dp_table <table> loc-pair <lcl_loc> <rmt_loc> ... [del]") \
15381 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
15382 _(lisp_gpe_enable_disable, "enable|disable") \
15383 _(lisp_enable_disable, "enable|disable") \
15384 _(lisp_gpe_add_del_iface, "up|down") \
15385 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
15387 "rloc <locator> p <prio> " \
15388 "w <weight> [rloc <loc> ... ] " \
15389 "action <action> [del-all]") \
15390 _(lisp_add_del_adjacency, "add|del vni <vni> deid <dest-eid> seid " \
15391 "<src-eid> rloc <locator> p <prio> w <weight>"\
15392 "[rloc <loc> ... ] action <action>") \
15393 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
15394 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
15395 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
15396 _(lisp_locator_set_dump, "[local | remote]") \
15397 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
15398 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
15399 "[local] | [remote]") \
15400 _(lisp_eid_table_vni_dump, "") \
15401 _(lisp_eid_table_map_dump, "l2|l3") \
15402 _(lisp_gpe_tunnel_dump, "") \
15403 _(lisp_map_resolver_dump, "") \
15404 _(show_lisp_status, "") \
15405 _(lisp_get_map_request_itr_rlocs, "") \
15406 _(show_lisp_pitr, "") \
15407 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
15408 _(af_packet_delete, "name <host interface name>") \
15409 _(policer_add_del, "name <policer name> <params> [del]") \
15410 _(policer_dump, "[name <policer name>]") \
15411 _(policer_classify_set_interface, \
15412 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
15413 " [l2-table <nn>] [del]") \
15414 _(policer_classify_dump, "type [ip4|ip6|l2]") \
15415 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
15416 "[master|slave]") \
15417 _(netmap_delete, "name <interface name>") \
15418 _(mpls_gre_tunnel_dump, "tunnel_index <tunnel-id>") \
15419 _(mpls_eth_tunnel_dump, "tunnel_index <tunnel-id>") \
15420 _(mpls_fib_encap_dump, "") \
15421 _(mpls_fib_decap_dump, "") \
15422 _(classify_table_ids, "") \
15423 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
15424 _(classify_table_info, "table_id <nn>") \
15425 _(classify_session_dump, "table_id <nn>") \
15426 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
15427 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
15428 "[template_interval <nn>] [udp_checksum]") \
15429 _(ipfix_exporter_dump, "") \
15430 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
15431 _(ipfix_classify_stream_dump, "") \
15432 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]")\
15433 _(ipfix_classify_table_dump, "") \
15434 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
15435 _(pg_create_interface, "if_id <nn>") \
15436 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
15437 _(pg_enable_disable, "[stream <id>] disable") \
15438 _(ip_source_and_port_range_check_add_del, \
15439 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
15440 _(ip_source_and_port_range_check_interface_add_del, \
15441 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
15442 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
15443 _(ipsec_gre_add_del_tunnel, \
15444 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
15445 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
15446 _(delete_subif,"sub_sw_if_index <nn> sub_if_id <nn>")
15448 /* List of command functions, CLI names map directly to functions */
15449 #define foreach_cli_function \
15450 _(comment, "usage: comment <ignore-rest-of-line>") \
15451 _(dump_interface_table, "usage: dump_interface_table") \
15452 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
15453 _(dump_ipv4_table, "usage: dump_ipv4_table") \
15454 _(dump_ipv6_table, "usage: dump_ipv6_table") \
15455 _(dump_stats_table, "usage: dump_stats_table") \
15456 _(dump_macro_table, "usage: dump_macro_table ") \
15457 _(dump_node_table, "usage: dump_node_table") \
15458 _(echo, "usage: echo <message>") \
15459 _(exec, "usage: exec <vpe-debug-CLI-command>") \
15460 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
15461 _(help, "usage: help") \
15462 _(q, "usage: quit") \
15463 _(quit, "usage: quit") \
15464 _(search_node_table, "usage: search_node_table <name>...") \
15465 _(set, "usage: set <variable-name> <value>") \
15466 _(script, "usage: script <file-name>") \
15467 _(unset, "usage: unset <variable-name>")
15470 static void vl_api_##n##_t_handler_uni \
15471 (vl_api_##n##_t * mp) \
15473 vat_main_t * vam = &vat_main; \
15474 if (vam->json_output) { \
15475 vl_api_##n##_t_handler_json(mp); \
15477 vl_api_##n##_t_handler(mp); \
15480 foreach_vpe_api_reply_msg;
15484 vat_api_hookup (vat_main_t * vam)
15487 vl_msg_api_set_handlers(VL_API_##N, #n, \
15488 vl_api_##n##_t_handler_uni, \
15490 vl_api_##n##_t_endian, \
15491 vl_api_##n##_t_print, \
15492 sizeof(vl_api_##n##_t), 1);
15493 foreach_vpe_api_reply_msg;
15496 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
15498 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
15500 vam->function_by_name = hash_create_string (0, sizeof (uword));
15502 vam->help_by_name = hash_create_string (0, sizeof (uword));
15504 /* API messages we can send */
15505 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
15506 foreach_vpe_api_msg;
15510 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
15511 foreach_vpe_api_msg;
15514 /* CLI functions */
15515 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
15516 foreach_cli_function;
15520 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
15521 foreach_cli_function;
15525 #undef vl_api_version
15526 #define vl_api_version(n,v) static u32 vpe_api_version = v;
15527 #include <vpp-api/vpe.api.h>
15528 #undef vl_api_version
15531 vl_client_add_api_signatures (vl_api_memclnt_create_t * mp)
15534 * Send the main API signature in slot 0. This bit of code must
15535 * match the checks in ../vpe/api/api.c: vl_msg_api_version_check().
15537 mp->api_versions[0] = clib_host_to_net_u32 (vpe_api_version);
15541 * fd.io coding-style-patch-verification: ON
15544 * eval: (c-set-style "gnu")