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;
1318 static void vl_api_noprint_control_ping_reply_t_handler
1319 (vl_api_noprint_control_ping_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_noprint_control_ping_reply_t_handler_json
1335 (vl_api_noprint_control_ping_reply_t * mp)
1337 vat_main_t *vam = &vat_main;
1338 i32 retval = ntohl (mp->retval);
1340 if (vam->noprint_msg)
1342 vam->retval = retval;
1343 vam->result_ready = 1;
1347 if (VAT_JSON_NONE != vam->json_tree.type)
1349 vat_json_print (vam->ofp, &vam->json_tree);
1350 vat_json_free (&vam->json_tree);
1351 vam->json_tree.type = VAT_JSON_NONE;
1356 vat_json_init_array (&vam->json_tree);
1357 vat_json_print (vam->ofp, &vam->json_tree);
1358 vam->json_tree.type = VAT_JSON_NONE;
1361 vam->retval = retval;
1362 vam->result_ready = 1;
1366 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1368 vat_main_t *vam = &vat_main;
1369 i32 retval = ntohl (mp->retval);
1370 if (vam->async_mode)
1372 vam->async_errors += (retval < 0);
1376 vam->retval = retval;
1377 vam->result_ready = 1;
1381 static void vl_api_l2_flags_reply_t_handler_json
1382 (vl_api_l2_flags_reply_t * mp)
1384 vat_main_t *vam = &vat_main;
1385 vat_json_node_t node;
1387 vat_json_init_object (&node);
1388 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1389 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1390 ntohl (mp->resulting_feature_bitmap));
1392 vat_json_print (vam->ofp, &node);
1393 vat_json_free (&node);
1395 vam->retval = ntohl (mp->retval);
1396 vam->result_ready = 1;
1399 static void vl_api_bridge_flags_reply_t_handler
1400 (vl_api_bridge_flags_reply_t * mp)
1402 vat_main_t *vam = &vat_main;
1403 i32 retval = ntohl (mp->retval);
1404 if (vam->async_mode)
1406 vam->async_errors += (retval < 0);
1410 vam->retval = retval;
1411 vam->result_ready = 1;
1415 static void vl_api_bridge_flags_reply_t_handler_json
1416 (vl_api_bridge_flags_reply_t * mp)
1418 vat_main_t *vam = &vat_main;
1419 vat_json_node_t node;
1421 vat_json_init_object (&node);
1422 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1423 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1424 ntohl (mp->resulting_feature_bitmap));
1426 vat_json_print (vam->ofp, &node);
1427 vat_json_free (&node);
1429 vam->retval = ntohl (mp->retval);
1430 vam->result_ready = 1;
1433 static void vl_api_tap_connect_reply_t_handler
1434 (vl_api_tap_connect_reply_t * mp)
1436 vat_main_t *vam = &vat_main;
1437 i32 retval = ntohl (mp->retval);
1438 if (vam->async_mode)
1440 vam->async_errors += (retval < 0);
1444 vam->retval = retval;
1445 vam->sw_if_index = ntohl (mp->sw_if_index);
1446 vam->result_ready = 1;
1451 static void vl_api_tap_connect_reply_t_handler_json
1452 (vl_api_tap_connect_reply_t * mp)
1454 vat_main_t *vam = &vat_main;
1455 vat_json_node_t node;
1457 vat_json_init_object (&node);
1458 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1459 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1461 vat_json_print (vam->ofp, &node);
1462 vat_json_free (&node);
1464 vam->retval = ntohl (mp->retval);
1465 vam->result_ready = 1;
1470 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1472 vat_main_t *vam = &vat_main;
1473 i32 retval = ntohl (mp->retval);
1474 if (vam->async_mode)
1476 vam->async_errors += (retval < 0);
1480 vam->retval = retval;
1481 vam->sw_if_index = ntohl (mp->sw_if_index);
1482 vam->result_ready = 1;
1486 static void vl_api_tap_modify_reply_t_handler_json
1487 (vl_api_tap_modify_reply_t * mp)
1489 vat_main_t *vam = &vat_main;
1490 vat_json_node_t node;
1492 vat_json_init_object (&node);
1493 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1494 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1496 vat_json_print (vam->ofp, &node);
1497 vat_json_free (&node);
1499 vam->retval = ntohl (mp->retval);
1500 vam->result_ready = 1;
1504 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1506 vat_main_t *vam = &vat_main;
1507 i32 retval = ntohl (mp->retval);
1508 if (vam->async_mode)
1510 vam->async_errors += (retval < 0);
1514 vam->retval = retval;
1515 vam->result_ready = 1;
1519 static void vl_api_tap_delete_reply_t_handler_json
1520 (vl_api_tap_delete_reply_t * mp)
1522 vat_main_t *vam = &vat_main;
1523 vat_json_node_t node;
1525 vat_json_init_object (&node);
1526 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1528 vat_json_print (vam->ofp, &node);
1529 vat_json_free (&node);
1531 vam->retval = ntohl (mp->retval);
1532 vam->result_ready = 1;
1535 static void vl_api_mpls_ethernet_add_del_tunnel_reply_t_handler
1536 (vl_api_mpls_ethernet_add_del_tunnel_reply_t * mp)
1538 vat_main_t *vam = &vat_main;
1539 i32 retval = ntohl (mp->retval);
1540 if (vam->async_mode)
1542 vam->async_errors += (retval < 0);
1546 vam->retval = retval;
1547 vam->result_ready = 1;
1551 static void vl_api_mpls_ethernet_add_del_tunnel_reply_t_handler_json
1552 (vl_api_mpls_ethernet_add_del_tunnel_reply_t * mp)
1554 vat_main_t *vam = &vat_main;
1555 vat_json_node_t node;
1557 vat_json_init_object (&node);
1558 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1559 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1560 ntohl (mp->tunnel_sw_if_index));
1562 vat_json_print (vam->ofp, &node);
1563 vat_json_free (&node);
1565 vam->retval = ntohl (mp->retval);
1566 vam->result_ready = 1;
1569 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1570 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1572 vat_main_t *vam = &vat_main;
1573 i32 retval = ntohl (mp->retval);
1574 if (vam->async_mode)
1576 vam->async_errors += (retval < 0);
1580 vam->retval = retval;
1581 vam->sw_if_index = ntohl (mp->sw_if_index);
1582 vam->result_ready = 1;
1586 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1587 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1589 vat_main_t *vam = &vat_main;
1590 vat_json_node_t node;
1592 vat_json_init_object (&node);
1593 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1594 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1596 vat_json_print (vam->ofp, &node);
1597 vat_json_free (&node);
1599 vam->retval = ntohl (mp->retval);
1600 vam->result_ready = 1;
1604 static void vl_api_lisp_add_del_locator_set_reply_t_handler
1605 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1607 vat_main_t *vam = &vat_main;
1608 i32 retval = ntohl (mp->retval);
1609 if (vam->async_mode)
1611 vam->async_errors += (retval < 0);
1615 vam->retval = retval;
1616 vam->result_ready = 1;
1620 static void vl_api_lisp_add_del_locator_set_reply_t_handler_json
1621 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1623 vat_main_t *vam = &vat_main;
1624 vat_json_node_t node;
1626 vat_json_init_object (&node);
1627 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1628 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1630 vat_json_print (vam->ofp, &node);
1631 vat_json_free (&node);
1633 vam->retval = ntohl (mp->retval);
1634 vam->result_ready = 1;
1637 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1638 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1640 vat_main_t *vam = &vat_main;
1641 i32 retval = ntohl (mp->retval);
1642 if (vam->async_mode)
1644 vam->async_errors += (retval < 0);
1648 vam->retval = retval;
1649 vam->sw_if_index = ntohl (mp->sw_if_index);
1650 vam->result_ready = 1;
1654 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1655 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1657 vat_main_t *vam = &vat_main;
1658 vat_json_node_t node;
1660 vat_json_init_object (&node);
1661 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1662 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1664 vat_json_print (vam->ofp, &node);
1665 vat_json_free (&node);
1667 vam->retval = ntohl (mp->retval);
1668 vam->result_ready = 1;
1671 static void vl_api_gre_add_del_tunnel_reply_t_handler
1672 (vl_api_gre_add_del_tunnel_reply_t * mp)
1674 vat_main_t *vam = &vat_main;
1675 i32 retval = ntohl (mp->retval);
1676 if (vam->async_mode)
1678 vam->async_errors += (retval < 0);
1682 vam->retval = retval;
1683 vam->sw_if_index = ntohl (mp->sw_if_index);
1684 vam->result_ready = 1;
1688 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1689 (vl_api_gre_add_del_tunnel_reply_t * mp)
1691 vat_main_t *vam = &vat_main;
1692 vat_json_node_t node;
1694 vat_json_init_object (&node);
1695 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1696 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1698 vat_json_print (vam->ofp, &node);
1699 vat_json_free (&node);
1701 vam->retval = ntohl (mp->retval);
1702 vam->result_ready = 1;
1705 static void vl_api_create_vhost_user_if_reply_t_handler
1706 (vl_api_create_vhost_user_if_reply_t * mp)
1708 vat_main_t *vam = &vat_main;
1709 i32 retval = ntohl (mp->retval);
1710 if (vam->async_mode)
1712 vam->async_errors += (retval < 0);
1716 vam->retval = retval;
1717 vam->sw_if_index = ntohl (mp->sw_if_index);
1718 vam->result_ready = 1;
1722 static void vl_api_create_vhost_user_if_reply_t_handler_json
1723 (vl_api_create_vhost_user_if_reply_t * mp)
1725 vat_main_t *vam = &vat_main;
1726 vat_json_node_t node;
1728 vat_json_init_object (&node);
1729 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1730 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1732 vat_json_print (vam->ofp, &node);
1733 vat_json_free (&node);
1735 vam->retval = ntohl (mp->retval);
1736 vam->result_ready = 1;
1739 static void vl_api_ip_address_details_t_handler
1740 (vl_api_ip_address_details_t * mp)
1742 vat_main_t *vam = &vat_main;
1743 static ip_address_details_t empty_ip_address_details = { {0} };
1744 ip_address_details_t *address = NULL;
1745 ip_details_t *current_ip_details = NULL;
1746 ip_details_t *details = NULL;
1748 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1750 if (!details || vam->current_sw_if_index >= vec_len (details)
1751 || !details[vam->current_sw_if_index].present)
1753 errmsg ("ip address details arrived but not stored\n");
1754 errmsg ("ip_dump should be called first\n");
1758 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1760 #define addresses (current_ip_details->addr)
1762 vec_validate_init_empty (addresses, vec_len (addresses),
1763 empty_ip_address_details);
1765 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1767 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1768 address->prefix_length = mp->prefix_length;
1772 static void vl_api_ip_address_details_t_handler_json
1773 (vl_api_ip_address_details_t * mp)
1775 vat_main_t *vam = &vat_main;
1776 vat_json_node_t *node = NULL;
1777 struct in6_addr ip6;
1780 if (VAT_JSON_ARRAY != vam->json_tree.type)
1782 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1783 vat_json_init_array (&vam->json_tree);
1785 node = vat_json_array_add (&vam->json_tree);
1787 vat_json_init_object (node);
1790 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1791 vat_json_object_add_ip6 (node, "ip", ip6);
1795 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1796 vat_json_object_add_ip4 (node, "ip", ip4);
1798 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1802 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1804 vat_main_t *vam = &vat_main;
1805 static ip_details_t empty_ip_details = { 0 };
1806 ip_details_t *ip = NULL;
1807 u32 sw_if_index = ~0;
1809 sw_if_index = ntohl (mp->sw_if_index);
1811 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1812 sw_if_index, empty_ip_details);
1814 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1821 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1823 vat_main_t *vam = &vat_main;
1825 if (VAT_JSON_ARRAY != vam->json_tree.type)
1827 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1828 vat_json_init_array (&vam->json_tree);
1830 vat_json_array_add_uint (&vam->json_tree,
1831 clib_net_to_host_u32 (mp->sw_if_index));
1834 static void vl_api_map_domain_details_t_handler_json
1835 (vl_api_map_domain_details_t * mp)
1837 vat_json_node_t *node = NULL;
1838 vat_main_t *vam = &vat_main;
1839 struct in6_addr ip6;
1842 if (VAT_JSON_ARRAY != vam->json_tree.type)
1844 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1845 vat_json_init_array (&vam->json_tree);
1848 node = vat_json_array_add (&vam->json_tree);
1849 vat_json_init_object (node);
1851 vat_json_object_add_uint (node, "domain_index",
1852 clib_net_to_host_u32 (mp->domain_index));
1853 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1854 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1855 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1856 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1857 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1858 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1859 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1860 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1861 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1862 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1863 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1864 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1865 vat_json_object_add_uint (node, "flags", mp->flags);
1866 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1867 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1870 static void vl_api_map_domain_details_t_handler
1871 (vl_api_map_domain_details_t * mp)
1873 vat_main_t *vam = &vat_main;
1875 if (mp->is_translation)
1878 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u\n",
1879 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1880 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1881 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1882 clib_net_to_host_u32 (mp->domain_index));
1887 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u\n",
1888 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1889 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1890 format_ip6_address, mp->ip6_src,
1891 clib_net_to_host_u32 (mp->domain_index));
1893 fformat (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s\n",
1894 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1895 mp->is_translation ? "map-t" : "");
1898 static void vl_api_map_rule_details_t_handler_json
1899 (vl_api_map_rule_details_t * mp)
1901 struct in6_addr ip6;
1902 vat_json_node_t *node = NULL;
1903 vat_main_t *vam = &vat_main;
1905 if (VAT_JSON_ARRAY != vam->json_tree.type)
1907 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1908 vat_json_init_array (&vam->json_tree);
1911 node = vat_json_array_add (&vam->json_tree);
1912 vat_json_init_object (node);
1914 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1915 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1916 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1920 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1922 vat_main_t *vam = &vat_main;
1923 fformat (vam->ofp, " %d (psid) %U (ip6-dst)\n",
1924 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1928 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1930 vat_main_t *vam = &vat_main;
1931 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1932 "router_addr %U host_mac %U\n",
1933 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1934 format_ip4_address, &mp->host_address,
1935 format_ip4_address, &mp->router_address,
1936 format_ethernet_address, mp->host_mac);
1939 static void vl_api_dhcp_compl_event_t_handler_json
1940 (vl_api_dhcp_compl_event_t * mp)
1942 /* JSON output not supported */
1946 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1949 vat_main_t *vam = &vat_main;
1950 static u64 default_counter = 0;
1952 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
1954 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
1955 sw_if_index, default_counter);
1956 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
1960 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1961 interface_counter_t counter)
1963 vat_main_t *vam = &vat_main;
1964 static interface_counter_t default_counter = { 0, };
1966 vec_validate_init_empty (vam->combined_interface_counters,
1967 vnet_counter_type, NULL);
1968 vec_validate_init_empty (vam->combined_interface_counters
1969 [vnet_counter_type], sw_if_index, default_counter);
1970 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
1973 static void vl_api_vnet_interface_counters_t_handler
1974 (vl_api_vnet_interface_counters_t * mp)
1979 static void vl_api_vnet_interface_counters_t_handler_json
1980 (vl_api_vnet_interface_counters_t * mp)
1982 interface_counter_t counter;
1987 u32 first_sw_if_index;
1990 count = ntohl (mp->count);
1991 first_sw_if_index = ntohl (mp->first_sw_if_index);
1993 if (!mp->is_combined)
1995 v_packets = (u64 *) & mp->data;
1996 for (i = 0; i < count; i++)
1999 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2000 set_simple_interface_counter (mp->vnet_counter_type,
2001 first_sw_if_index + i, packets);
2007 v = (vlib_counter_t *) & mp->data;
2008 for (i = 0; i < count; i++)
2011 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2013 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2014 set_combined_interface_counter (mp->vnet_counter_type,
2015 first_sw_if_index + i, counter);
2022 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2024 vat_main_t *vam = &vat_main;
2027 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2029 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2038 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2040 vat_main_t *vam = &vat_main;
2043 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2045 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2053 static void vl_api_vnet_ip4_fib_counters_t_handler
2054 (vl_api_vnet_ip4_fib_counters_t * mp)
2059 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2060 (vl_api_vnet_ip4_fib_counters_t * mp)
2062 vat_main_t *vam = &vat_main;
2063 vl_api_ip4_fib_counter_t *v;
2064 ip4_fib_counter_t *counter;
2071 vrf_id = ntohl (mp->vrf_id);
2072 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2073 if (~0 == vrf_index)
2075 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2076 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2077 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2078 vec_validate (vam->ip4_fib_counters, vrf_index);
2079 vam->ip4_fib_counters[vrf_index] = NULL;
2082 vec_free (vam->ip4_fib_counters[vrf_index]);
2083 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2084 count = ntohl (mp->count);
2085 for (i = 0; i < count; i++)
2087 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2088 counter = &vam->ip4_fib_counters[vrf_index][i];
2089 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2090 counter->address = ip4;
2091 counter->address_length = v->address_length;
2092 counter->packets = clib_net_to_host_u64 (v->packets);
2093 counter->bytes = clib_net_to_host_u64 (v->bytes);
2098 static void vl_api_vnet_ip6_fib_counters_t_handler
2099 (vl_api_vnet_ip6_fib_counters_t * mp)
2104 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2105 (vl_api_vnet_ip6_fib_counters_t * mp)
2107 vat_main_t *vam = &vat_main;
2108 vl_api_ip6_fib_counter_t *v;
2109 ip6_fib_counter_t *counter;
2110 struct in6_addr ip6;
2116 vrf_id = ntohl (mp->vrf_id);
2117 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2118 if (~0 == vrf_index)
2120 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2121 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2122 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2123 vec_validate (vam->ip6_fib_counters, vrf_index);
2124 vam->ip6_fib_counters[vrf_index] = NULL;
2127 vec_free (vam->ip6_fib_counters[vrf_index]);
2128 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2129 count = ntohl (mp->count);
2130 for (i = 0; i < count; i++)
2132 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2133 counter = &vam->ip6_fib_counters[vrf_index][i];
2134 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2135 counter->address = ip6;
2136 counter->address_length = v->address_length;
2137 counter->packets = clib_net_to_host_u64 (v->packets);
2138 counter->bytes = clib_net_to_host_u64 (v->bytes);
2143 static void vl_api_get_first_msg_id_reply_t_handler
2144 (vl_api_get_first_msg_id_reply_t * mp)
2146 vat_main_t *vam = &vat_main;
2147 i32 retval = ntohl (mp->retval);
2149 if (vam->async_mode)
2151 vam->async_errors += (retval < 0);
2155 vam->retval = retval;
2156 vam->result_ready = 1;
2160 errmsg ("first message id %d\n", ntohs (mp->first_msg_id));
2164 static void vl_api_get_first_msg_id_reply_t_handler_json
2165 (vl_api_get_first_msg_id_reply_t * mp)
2167 vat_main_t *vam = &vat_main;
2168 vat_json_node_t node;
2170 vat_json_init_object (&node);
2171 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2172 vat_json_object_add_uint (&node, "first_msg_id",
2173 (uint) ntohs (mp->first_msg_id));
2175 vat_json_print (vam->ofp, &node);
2176 vat_json_free (&node);
2178 vam->retval = ntohl (mp->retval);
2179 vam->result_ready = 1;
2182 static void vl_api_get_node_graph_reply_t_handler
2183 (vl_api_get_node_graph_reply_t * mp)
2185 vat_main_t *vam = &vat_main;
2186 api_main_t *am = &api_main;
2187 i32 retval = ntohl (mp->retval);
2188 u8 *pvt_copy, *reply;
2193 if (vam->async_mode)
2195 vam->async_errors += (retval < 0);
2199 vam->retval = retval;
2200 vam->result_ready = 1;
2203 /* "Should never happen..." */
2207 reply = (u8 *) (mp->reply_in_shmem);
2208 pvt_copy = vec_dup (reply);
2210 /* Toss the shared-memory original... */
2211 pthread_mutex_lock (&am->vlib_rp->mutex);
2212 oldheap = svm_push_data_heap (am->vlib_rp);
2216 svm_pop_heap (oldheap);
2217 pthread_mutex_unlock (&am->vlib_rp->mutex);
2219 if (vam->graph_nodes)
2221 hash_free (vam->graph_node_index_by_name);
2223 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2225 node = vam->graph_nodes[i];
2226 vec_free (node->name);
2227 vec_free (node->next_nodes);
2230 vec_free (vam->graph_nodes);
2233 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2234 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2235 vec_free (pvt_copy);
2237 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2239 node = vam->graph_nodes[i];
2240 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2244 static void vl_api_get_node_graph_reply_t_handler_json
2245 (vl_api_get_node_graph_reply_t * mp)
2247 vat_main_t *vam = &vat_main;
2248 api_main_t *am = &api_main;
2250 vat_json_node_t node;
2253 /* $$$$ make this real? */
2254 vat_json_init_object (&node);
2255 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2256 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2258 reply = (u8 *) (mp->reply_in_shmem);
2260 /* Toss the shared-memory original... */
2261 pthread_mutex_lock (&am->vlib_rp->mutex);
2262 oldheap = svm_push_data_heap (am->vlib_rp);
2266 svm_pop_heap (oldheap);
2267 pthread_mutex_unlock (&am->vlib_rp->mutex);
2269 vat_json_print (vam->ofp, &node);
2270 vat_json_free (&node);
2272 vam->retval = ntohl (mp->retval);
2273 vam->result_ready = 1;
2277 vl_api_lisp_locator_details_t_handler (vl_api_lisp_locator_details_t * mp)
2279 vat_main_t *vam = &vat_main;
2283 memset (&loc, 0, sizeof (loc));
2284 if (vam->noprint_msg)
2286 loc.local = mp->local;
2287 loc.priority = mp->priority;
2288 loc.weight = mp->weight;
2291 loc.sw_if_index = ntohl (mp->sw_if_index);
2295 loc.is_ipv6 = mp->is_ipv6;
2296 clib_memcpy (loc.ip_address, mp->ip_address,
2297 sizeof (loc.ip_address));
2299 vec_add1 (vam->locator_msg, loc);
2305 tmp_str = format (tmp_str, "%=16d%=16d%=16d\n",
2306 ntohl (mp->sw_if_index),
2307 mp->priority, mp->weight);
2311 tmp_str = format (tmp_str, "%=16U%=16d%=16d\n",
2312 mp->is_ipv6 ? format_ip6_address :
2314 mp->ip_address, mp->priority, mp->weight);
2317 fformat (vam->ofp, "%s", tmp_str);
2324 vl_api_lisp_locator_details_t_handler_json (vl_api_lisp_locator_details_t *
2327 vat_main_t *vam = &vat_main;
2328 vat_json_node_t *node = NULL;
2330 struct in6_addr ip6;
2333 memset (&loc, 0, sizeof (loc));
2334 if (vam->noprint_msg)
2336 loc.local = mp->local;
2337 loc.priority = mp->priority;
2338 loc.weight = mp->weight;
2341 loc.sw_if_index = ntohl (mp->sw_if_index);
2345 loc.is_ipv6 = mp->is_ipv6;
2346 clib_memcpy (loc.ip_address, mp->ip_address,
2347 sizeof (loc.ip_address));
2349 vec_add1 (vam->locator_msg, loc);
2353 if (VAT_JSON_ARRAY != vam->json_tree.type)
2355 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2356 vat_json_init_array (&vam->json_tree);
2358 node = vat_json_array_add (&vam->json_tree);
2360 vat_json_init_object (node);
2364 vat_json_object_add_uint (node, "locator_index",
2365 ntohl (mp->sw_if_index));
2371 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2372 vat_json_object_add_ip6 (node, "locator", ip6);
2376 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2377 vat_json_object_add_ip4 (node, "locator", ip4);
2380 vat_json_object_add_uint (node, "priority", mp->priority);
2381 vat_json_object_add_uint (node, "weight", mp->weight);
2385 vl_api_lisp_locator_set_details_t_handler (vl_api_lisp_locator_set_details_t *
2388 vat_main_t *vam = &vat_main;
2389 locator_set_msg_t ls;
2391 ls.locator_set_index = ntohl (mp->locator_set_index);
2392 ls.locator_set_name = format (0, "%s", mp->locator_set_name);
2393 vec_add1 (vam->locator_set_msg, ls);
2397 vl_api_lisp_locator_set_details_t_handler_json
2398 (vl_api_lisp_locator_set_details_t * mp)
2400 vat_main_t *vam = &vat_main;
2401 locator_set_msg_t ls;
2403 ls.locator_set_index = ntohl (mp->locator_set_index);
2404 ls.locator_set_name = format (0, "%s", mp->locator_set_name);
2405 vec_add1 (vam->locator_set_msg, ls);
2409 add_lisp_eid_table_entry (vat_main_t * vam,
2410 vl_api_lisp_eid_table_details_t * mp)
2412 eid_table_t eid_table;
2414 memset (&eid_table, 0, sizeof (eid_table));
2415 eid_table.is_local = mp->is_local;
2416 eid_table.locator_set_index = clib_net_to_host_u32 (mp->locator_set_index);
2417 eid_table.eid_type = mp->eid_type;
2418 eid_table.vni = clib_net_to_host_u32 (mp->vni);
2419 eid_table.eid_prefix_len = mp->eid_prefix_len;
2420 eid_table.ttl = clib_net_to_host_u32 (mp->ttl);
2421 eid_table.action = mp->action;
2422 eid_table.authoritative = mp->authoritative;
2423 clib_memcpy (eid_table.eid, mp->eid, sizeof (eid_table.eid));
2424 vec_add1 (vam->eid_tables, eid_table);
2428 vl_api_lisp_eid_table_details_t_handler (vl_api_lisp_eid_table_details_t * mp)
2430 vat_main_t *vam = &vat_main;
2431 add_lisp_eid_table_entry (vam, mp);
2435 vl_api_lisp_eid_table_details_t_handler_json (vl_api_lisp_eid_table_details_t
2438 vat_main_t *vam = &vat_main;
2439 add_lisp_eid_table_entry (vam, mp);
2443 vl_api_lisp_eid_table_map_details_t_handler
2444 (vl_api_lisp_eid_table_map_details_t * mp)
2446 vat_main_t *vam = &vat_main;
2448 u8 *line = format (0, "%=10d%=10d",
2449 clib_net_to_host_u32 (mp->vni),
2450 clib_net_to_host_u32 (mp->dp_table));
2451 fformat (vam->ofp, "%v\n", line);
2456 vl_api_lisp_eid_table_map_details_t_handler_json
2457 (vl_api_lisp_eid_table_map_details_t * mp)
2459 vat_main_t *vam = &vat_main;
2460 vat_json_node_t *node = NULL;
2462 if (VAT_JSON_ARRAY != vam->json_tree.type)
2464 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2465 vat_json_init_array (&vam->json_tree);
2467 node = vat_json_array_add (&vam->json_tree);
2468 vat_json_init_object (node);
2469 vat_json_object_add_uint (node, "dp_table",
2470 clib_net_to_host_u32 (mp->dp_table));
2471 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2475 vl_api_lisp_eid_table_vni_details_t_handler
2476 (vl_api_lisp_eid_table_vni_details_t * mp)
2478 vat_main_t *vam = &vat_main;
2480 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2481 fformat (vam->ofp, "%v\n", line);
2486 vl_api_lisp_eid_table_vni_details_t_handler_json
2487 (vl_api_lisp_eid_table_vni_details_t * mp)
2489 vat_main_t *vam = &vat_main;
2490 vat_json_node_t *node = NULL;
2492 if (VAT_JSON_ARRAY != vam->json_tree.type)
2494 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2495 vat_json_init_array (&vam->json_tree);
2497 node = vat_json_array_add (&vam->json_tree);
2498 vat_json_init_object (node);
2499 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2503 format_decap_next (u8 * s, va_list * args)
2505 u32 next_index = va_arg (*args, u32);
2509 case LISP_GPE_INPUT_NEXT_DROP:
2510 return format (s, "drop");
2511 case LISP_GPE_INPUT_NEXT_IP4_INPUT:
2512 return format (s, "ip4");
2513 case LISP_GPE_INPUT_NEXT_IP6_INPUT:
2514 return format (s, "ip6");
2516 return format (s, "unknown %d", next_index);
2522 vl_api_lisp_gpe_tunnel_details_t_handler (vl_api_lisp_gpe_tunnel_details_t *
2525 vat_main_t *vam = &vat_main;
2527 u8 *flag_str = NULL;
2529 iid_str = format (0, "%d (0x%x)", ntohl (mp->iid), ntohl (mp->iid));
2531 #define _(n,v) if (mp->flags & v) flag_str = format (flag_str, "%s-bit ", #n);
2532 foreach_lisp_gpe_flag_bit;
2535 fformat (vam->ofp, "%=20d%=30U%=16U%=16d%=16d%=16U"
2536 "%=16d%=16d%=16sd=16d%=16s%=16s\n",
2538 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2540 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2542 ntohl (mp->encap_fib_id),
2543 ntohl (mp->decap_fib_id),
2544 format_decap_next, ntohl (mp->dcap_next),
2546 flag_str, mp->next_protocol, mp->ver_res, mp->res, iid_str);
2552 vl_api_lisp_gpe_tunnel_details_t_handler_json
2553 (vl_api_lisp_gpe_tunnel_details_t * mp)
2555 vat_main_t *vam = &vat_main;
2556 vat_json_node_t *node = NULL;
2557 struct in6_addr ip6;
2561 next_decap_str = format (0, "%U", format_decap_next, htonl (mp->dcap_next));
2563 if (VAT_JSON_ARRAY != vam->json_tree.type)
2565 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2566 vat_json_init_array (&vam->json_tree);
2568 node = vat_json_array_add (&vam->json_tree);
2570 vat_json_init_object (node);
2571 vat_json_object_add_uint (node, "tunel", mp->tunnels);
2574 clib_memcpy (&ip6, mp->source_ip, sizeof (ip6));
2575 vat_json_object_add_ip6 (node, "source address", ip6);
2576 clib_memcpy (&ip6, mp->destination_ip, sizeof (ip6));
2577 vat_json_object_add_ip6 (node, "destination address", ip6);
2581 clib_memcpy (&ip4, mp->source_ip, sizeof (ip4));
2582 vat_json_object_add_ip4 (node, "source address", ip4);
2583 clib_memcpy (&ip4, mp->destination_ip, sizeof (ip4));
2584 vat_json_object_add_ip4 (node, "destination address", ip4);
2586 vat_json_object_add_uint (node, "fib encap", ntohl (mp->encap_fib_id));
2587 vat_json_object_add_uint (node, "fib decap", ntohl (mp->decap_fib_id));
2588 vat_json_object_add_string_copy (node, "decap next", next_decap_str);
2589 vat_json_object_add_uint (node, "lisp version", mp->ver_res >> 6);
2590 vat_json_object_add_uint (node, "flags", mp->flags);
2591 vat_json_object_add_uint (node, "next protocol", mp->next_protocol);
2592 vat_json_object_add_uint (node, "ver_res", mp->ver_res);
2593 vat_json_object_add_uint (node, "res", mp->res);
2594 vat_json_object_add_uint (node, "iid", ntohl (mp->iid));
2596 vec_free (next_decap_str);
2600 vl_api_lisp_map_resolver_details_t_handler (vl_api_lisp_map_resolver_details_t
2603 vat_main_t *vam = &vat_main;
2605 fformat (vam->ofp, "%=20U\n",
2606 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2611 vl_api_lisp_map_resolver_details_t_handler_json
2612 (vl_api_lisp_map_resolver_details_t * mp)
2614 vat_main_t *vam = &vat_main;
2615 vat_json_node_t *node = NULL;
2616 struct in6_addr ip6;
2619 if (VAT_JSON_ARRAY != vam->json_tree.type)
2621 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2622 vat_json_init_array (&vam->json_tree);
2624 node = vat_json_array_add (&vam->json_tree);
2626 vat_json_init_object (node);
2629 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2630 vat_json_object_add_ip6 (node, "map resolver", ip6);
2634 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2635 vat_json_object_add_ip4 (node, "map resolver", ip4);
2640 vl_api_show_lisp_status_reply_t_handler
2641 (vl_api_show_lisp_status_reply_t * mp)
2643 vat_main_t *vam = &vat_main;
2644 i32 retval = ntohl (mp->retval);
2648 fformat (vam->ofp, "feature: %s\ngpe: %s\n",
2649 mp->feature_status ? "enabled" : "disabled",
2650 mp->gpe_status ? "enabled" : "disabled");
2653 vam->retval = retval;
2654 vam->result_ready = 1;
2658 vl_api_show_lisp_status_reply_t_handler_json
2659 (vl_api_show_lisp_status_reply_t * mp)
2661 vat_main_t *vam = &vat_main;
2662 vat_json_node_t node;
2663 u8 *gpe_status = NULL;
2664 u8 *feature_status = NULL;
2666 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
2667 feature_status = format (0, "%s",
2668 mp->feature_status ? "enabled" : "disabled");
2669 vec_add1 (gpe_status, 0);
2670 vec_add1 (feature_status, 0);
2672 vat_json_init_object (&node);
2673 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
2674 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
2676 vec_free (gpe_status);
2677 vec_free (feature_status);
2679 vat_json_print (vam->ofp, &node);
2680 vat_json_free (&node);
2682 vam->retval = ntohl (mp->retval);
2683 vam->result_ready = 1;
2687 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler
2688 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2690 vat_main_t *vam = &vat_main;
2691 i32 retval = ntohl (mp->retval);
2695 fformat (vam->ofp, "%=20s\n", mp->locator_set_name);
2698 vam->retval = retval;
2699 vam->result_ready = 1;
2703 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler_json
2704 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2706 vat_main_t *vam = &vat_main;
2707 vat_json_node_t *node = NULL;
2709 if (VAT_JSON_ARRAY != vam->json_tree.type)
2711 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2712 vat_json_init_array (&vam->json_tree);
2714 node = vat_json_array_add (&vam->json_tree);
2716 vat_json_init_object (node);
2717 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
2719 vat_json_print (vam->ofp, node);
2720 vat_json_free (node);
2722 vam->retval = ntohl (mp->retval);
2723 vam->result_ready = 1;
2727 vl_api_show_lisp_pitr_reply_t_handler (vl_api_show_lisp_pitr_reply_t * mp)
2729 vat_main_t *vam = &vat_main;
2730 i32 retval = ntohl (mp->retval);
2734 fformat (vam->ofp, "%-20s%-16s\n",
2735 mp->status ? "enabled" : "disabled",
2736 mp->status ? (char *) mp->locator_set_name : "");
2739 vam->retval = retval;
2740 vam->result_ready = 1;
2744 vl_api_show_lisp_pitr_reply_t_handler_json (vl_api_show_lisp_pitr_reply_t *
2747 vat_main_t *vam = &vat_main;
2748 vat_json_node_t node;
2751 status = format (0, "%s", mp->status ? "enabled" : "disabled");
2752 vec_add1 (status, 0);
2754 vat_json_init_object (&node);
2755 vat_json_object_add_string_copy (&node, "status", status);
2758 vat_json_object_add_string_copy (&node, "locator_set",
2759 mp->locator_set_name);
2764 vat_json_print (vam->ofp, &node);
2765 vat_json_free (&node);
2767 vam->retval = ntohl (mp->retval);
2768 vam->result_ready = 1;
2772 format_policer_type (u8 * s, va_list * va)
2774 u32 i = va_arg (*va, u32);
2776 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
2777 s = format (s, "1r2c");
2778 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
2779 s = format (s, "1r3c");
2780 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
2781 s = format (s, "2r3c-2698");
2782 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
2783 s = format (s, "2r3c-4115");
2784 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
2785 s = format (s, "2r3c-mef5cf1");
2787 s = format (s, "ILLEGAL");
2792 format_policer_rate_type (u8 * s, va_list * va)
2794 u32 i = va_arg (*va, u32);
2796 if (i == SSE2_QOS_RATE_KBPS)
2797 s = format (s, "kbps");
2798 else if (i == SSE2_QOS_RATE_PPS)
2799 s = format (s, "pps");
2801 s = format (s, "ILLEGAL");
2806 format_policer_round_type (u8 * s, va_list * va)
2808 u32 i = va_arg (*va, u32);
2810 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
2811 s = format (s, "closest");
2812 else if (i == SSE2_QOS_ROUND_TO_UP)
2813 s = format (s, "up");
2814 else if (i == SSE2_QOS_ROUND_TO_DOWN)
2815 s = format (s, "down");
2817 s = format (s, "ILLEGAL");
2822 format_policer_action_type (u8 * s, va_list * va)
2824 u32 i = va_arg (*va, u32);
2826 if (i == SSE2_QOS_ACTION_DROP)
2827 s = format (s, "drop");
2828 else if (i == SSE2_QOS_ACTION_TRANSMIT)
2829 s = format (s, "transmit");
2830 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2831 s = format (s, "mark-and-transmit");
2833 s = format (s, "ILLEGAL");
2838 format_dscp (u8 * s, va_list * va)
2840 u32 i = va_arg (*va, u32);
2845 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
2849 return format (s, "ILLEGAL");
2851 s = format (s, "%s", t);
2856 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
2858 vat_main_t *vam = &vat_main;
2859 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
2861 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2862 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
2864 conform_dscp_str = format (0, "");
2866 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2867 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
2869 exceed_dscp_str = format (0, "");
2871 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2872 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
2874 violate_dscp_str = format (0, "");
2876 fformat (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
2877 "rate type %U, round type %U, %s rate, %s color-aware, "
2878 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
2879 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
2880 "conform action %U%s, exceed action %U%s, violate action %U%s\n",
2882 format_policer_type, mp->type,
2885 clib_net_to_host_u64 (mp->cb),
2886 clib_net_to_host_u64 (mp->eb),
2887 format_policer_rate_type, mp->rate_type,
2888 format_policer_round_type, mp->round_type,
2889 mp->single_rate ? "single" : "dual",
2890 mp->color_aware ? "is" : "not",
2891 ntohl (mp->cir_tokens_per_period),
2892 ntohl (mp->pir_tokens_per_period),
2894 ntohl (mp->current_limit),
2895 ntohl (mp->current_bucket),
2896 ntohl (mp->extended_limit),
2897 ntohl (mp->extended_bucket),
2898 clib_net_to_host_u64 (mp->last_update_time),
2899 format_policer_action_type, mp->conform_action_type,
2901 format_policer_action_type, mp->exceed_action_type,
2903 format_policer_action_type, mp->violate_action_type,
2906 vec_free (conform_dscp_str);
2907 vec_free (exceed_dscp_str);
2908 vec_free (violate_dscp_str);
2911 static void vl_api_policer_details_t_handler_json
2912 (vl_api_policer_details_t * mp)
2914 vat_main_t *vam = &vat_main;
2915 vat_json_node_t *node;
2916 u8 *rate_type_str, *round_type_str, *type_str;
2917 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
2919 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
2921 format (0, "%U", format_policer_round_type, mp->round_type);
2922 type_str = format (0, "%U", format_policer_type, mp->type);
2923 conform_action_str = format (0, "%U", format_policer_action_type,
2924 mp->conform_action_type);
2925 exceed_action_str = format (0, "%U", format_policer_action_type,
2926 mp->exceed_action_type);
2927 violate_action_str = format (0, "%U", format_policer_action_type,
2928 mp->violate_action_type);
2930 if (VAT_JSON_ARRAY != vam->json_tree.type)
2932 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2933 vat_json_init_array (&vam->json_tree);
2935 node = vat_json_array_add (&vam->json_tree);
2937 vat_json_init_object (node);
2938 vat_json_object_add_string_copy (node, "name", mp->name);
2939 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
2940 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
2941 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
2942 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
2943 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
2944 vat_json_object_add_string_copy (node, "round_type", round_type_str);
2945 vat_json_object_add_string_copy (node, "type", type_str);
2946 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
2947 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
2948 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
2949 vat_json_object_add_uint (node, "cir_tokens_per_period",
2950 ntohl (mp->cir_tokens_per_period));
2951 vat_json_object_add_uint (node, "eir_tokens_per_period",
2952 ntohl (mp->pir_tokens_per_period));
2953 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
2954 vat_json_object_add_uint (node, "current_bucket",
2955 ntohl (mp->current_bucket));
2956 vat_json_object_add_uint (node, "extended_limit",
2957 ntohl (mp->extended_limit));
2958 vat_json_object_add_uint (node, "extended_bucket",
2959 ntohl (mp->extended_bucket));
2960 vat_json_object_add_uint (node, "last_update_time",
2961 ntohl (mp->last_update_time));
2962 vat_json_object_add_string_copy (node, "conform_action",
2963 conform_action_str);
2964 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2966 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
2967 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
2968 vec_free (dscp_str);
2970 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
2971 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2973 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
2974 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
2975 vec_free (dscp_str);
2977 vat_json_object_add_string_copy (node, "violate_action",
2978 violate_action_str);
2979 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2981 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
2982 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
2983 vec_free (dscp_str);
2986 vec_free (rate_type_str);
2987 vec_free (round_type_str);
2988 vec_free (type_str);
2989 vec_free (conform_action_str);
2990 vec_free (exceed_action_str);
2991 vec_free (violate_action_str);
2995 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
2998 vat_main_t *vam = &vat_main;
2999 int i, count = ntohl (mp->count);
3002 fformat (vam->ofp, "classify table ids (%d) : ", count);
3003 for (i = 0; i < count; i++)
3005 fformat (vam->ofp, "%d", ntohl (mp->ids[i]));
3006 fformat (vam->ofp, (i < count - 1) ? "," : "\n");
3008 vam->retval = ntohl (mp->retval);
3009 vam->result_ready = 1;
3013 vl_api_classify_table_ids_reply_t_handler_json
3014 (vl_api_classify_table_ids_reply_t * mp)
3016 vat_main_t *vam = &vat_main;
3017 int i, count = ntohl (mp->count);
3021 vat_json_node_t node;
3023 vat_json_init_object (&node);
3024 for (i = 0; i < count; i++)
3026 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3028 vat_json_print (vam->ofp, &node);
3029 vat_json_free (&node);
3031 vam->retval = ntohl (mp->retval);
3032 vam->result_ready = 1;
3036 vl_api_classify_table_by_interface_reply_t_handler
3037 (vl_api_classify_table_by_interface_reply_t * mp)
3039 vat_main_t *vam = &vat_main;
3042 table_id = ntohl (mp->l2_table_id);
3044 fformat (vam->ofp, "l2 table id : %d\n", table_id);
3046 fformat (vam->ofp, "l2 table id : No input ACL tables configured\n");
3047 table_id = ntohl (mp->ip4_table_id);
3049 fformat (vam->ofp, "ip4 table id : %d\n", table_id);
3051 fformat (vam->ofp, "ip4 table id : No input ACL tables configured\n");
3052 table_id = ntohl (mp->ip6_table_id);
3054 fformat (vam->ofp, "ip6 table id : %d\n", table_id);
3056 fformat (vam->ofp, "ip6 table id : No input ACL tables configured\n");
3057 vam->retval = ntohl (mp->retval);
3058 vam->result_ready = 1;
3062 vl_api_classify_table_by_interface_reply_t_handler_json
3063 (vl_api_classify_table_by_interface_reply_t * mp)
3065 vat_main_t *vam = &vat_main;
3066 vat_json_node_t node;
3068 vat_json_init_object (&node);
3070 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3071 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3072 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3074 vat_json_print (vam->ofp, &node);
3075 vat_json_free (&node);
3077 vam->retval = ntohl (mp->retval);
3078 vam->result_ready = 1;
3081 static void vl_api_policer_add_del_reply_t_handler
3082 (vl_api_policer_add_del_reply_t * mp)
3084 vat_main_t *vam = &vat_main;
3085 i32 retval = ntohl (mp->retval);
3086 if (vam->async_mode)
3088 vam->async_errors += (retval < 0);
3092 vam->retval = retval;
3093 vam->result_ready = 1;
3094 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3096 * Note: this is just barely thread-safe, depends on
3097 * the main thread spinning waiting for an answer...
3099 errmsg ("policer index %d\n", ntohl (mp->policer_index));
3103 static void vl_api_policer_add_del_reply_t_handler_json
3104 (vl_api_policer_add_del_reply_t * mp)
3106 vat_main_t *vam = &vat_main;
3107 vat_json_node_t node;
3109 vat_json_init_object (&node);
3110 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3111 vat_json_object_add_uint (&node, "policer_index",
3112 ntohl (mp->policer_index));
3114 vat_json_print (vam->ofp, &node);
3115 vat_json_free (&node);
3117 vam->retval = ntohl (mp->retval);
3118 vam->result_ready = 1;
3121 /* Format hex dump. */
3123 format_hex_bytes (u8 * s, va_list * va)
3125 u8 *bytes = va_arg (*va, u8 *);
3126 int n_bytes = va_arg (*va, int);
3129 /* Print short or long form depending on byte count. */
3130 uword short_form = n_bytes <= 32;
3131 uword indent = format_get_indent (s);
3136 for (i = 0; i < n_bytes; i++)
3138 if (!short_form && (i % 32) == 0)
3139 s = format (s, "%08x: ", i);
3140 s = format (s, "%02x", bytes[i]);
3141 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3142 s = format (s, "\n%U", format_white_space, indent);
3149 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3152 vat_main_t *vam = &vat_main;
3153 i32 retval = ntohl (mp->retval);
3156 fformat (vam->ofp, "classify table info :\n");
3157 fformat (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d\n",
3158 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3159 ntohl (mp->miss_next_index));
3160 fformat (vam->ofp, "nbuckets: %d skip: %d match: %d\n",
3161 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3162 ntohl (mp->match_n_vectors));
3163 fformat (vam->ofp, "mask: %U\n", format_hex_bytes, mp->mask,
3164 ntohl (mp->mask_length));
3166 vam->retval = retval;
3167 vam->result_ready = 1;
3171 vl_api_classify_table_info_reply_t_handler_json
3172 (vl_api_classify_table_info_reply_t * mp)
3174 vat_main_t *vam = &vat_main;
3175 vat_json_node_t node;
3177 i32 retval = ntohl (mp->retval);
3180 vat_json_init_object (&node);
3182 vat_json_object_add_int (&node, "sessions",
3183 ntohl (mp->active_sessions));
3184 vat_json_object_add_int (&node, "nexttbl",
3185 ntohl (mp->next_table_index));
3186 vat_json_object_add_int (&node, "nextnode",
3187 ntohl (mp->miss_next_index));
3188 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3189 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3190 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3191 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3192 ntohl (mp->mask_length), 0);
3193 vat_json_object_add_string_copy (&node, "mask", s);
3195 vat_json_print (vam->ofp, &node);
3196 vat_json_free (&node);
3198 vam->retval = ntohl (mp->retval);
3199 vam->result_ready = 1;
3203 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3206 vat_main_t *vam = &vat_main;
3208 fformat (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3209 ntohl (mp->hit_next_index), ntohl (mp->advance),
3210 ntohl (mp->opaque_index));
3211 fformat (vam->ofp, "mask: %U\n", format_hex_bytes, mp->match,
3212 ntohl (mp->match_length));
3216 vl_api_classify_session_details_t_handler_json
3217 (vl_api_classify_session_details_t * mp)
3219 vat_main_t *vam = &vat_main;
3220 vat_json_node_t *node = NULL;
3222 if (VAT_JSON_ARRAY != vam->json_tree.type)
3224 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3225 vat_json_init_array (&vam->json_tree);
3227 node = vat_json_array_add (&vam->json_tree);
3229 vat_json_init_object (node);
3230 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3231 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3232 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3234 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3236 vat_json_object_add_string_copy (node, "match", s);
3239 static void vl_api_pg_create_interface_reply_t_handler
3240 (vl_api_pg_create_interface_reply_t * mp)
3242 vat_main_t *vam = &vat_main;
3244 vam->retval = ntohl (mp->retval);
3245 vam->result_ready = 1;
3248 static void vl_api_pg_create_interface_reply_t_handler_json
3249 (vl_api_pg_create_interface_reply_t * mp)
3251 vat_main_t *vam = &vat_main;
3252 vat_json_node_t node;
3254 i32 retval = ntohl (mp->retval);
3257 vat_json_init_object (&node);
3259 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3261 vat_json_print (vam->ofp, &node);
3262 vat_json_free (&node);
3264 vam->retval = ntohl (mp->retval);
3265 vam->result_ready = 1;
3268 static void vl_api_policer_classify_details_t_handler
3269 (vl_api_policer_classify_details_t * mp)
3271 vat_main_t *vam = &vat_main;
3273 fformat (vam->ofp, "%10d%20d\n", ntohl (mp->sw_if_index),
3274 ntohl (mp->table_index));
3277 static void vl_api_policer_classify_details_t_handler_json
3278 (vl_api_policer_classify_details_t * mp)
3280 vat_main_t *vam = &vat_main;
3281 vat_json_node_t *node;
3283 if (VAT_JSON_ARRAY != vam->json_tree.type)
3285 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3286 vat_json_init_array (&vam->json_tree);
3288 node = vat_json_array_add (&vam->json_tree);
3290 vat_json_init_object (node);
3291 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3292 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3295 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3296 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3298 vat_main_t *vam = &vat_main;
3299 i32 retval = ntohl (mp->retval);
3300 if (vam->async_mode)
3302 vam->async_errors += (retval < 0);
3306 vam->retval = retval;
3307 vam->sw_if_index = ntohl (mp->sw_if_index);
3308 vam->result_ready = 1;
3312 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3313 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3315 vat_main_t *vam = &vat_main;
3316 vat_json_node_t node;
3318 vat_json_init_object (&node);
3319 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3320 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3322 vat_json_print (vam->ofp, &node);
3323 vat_json_free (&node);
3325 vam->retval = ntohl (mp->retval);
3326 vam->result_ready = 1;
3329 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3330 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3331 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3332 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3335 * Generate boilerplate reply handlers, which
3336 * dig the return value out of the xxx_reply_t API message,
3337 * stick it into vam->retval, and set vam->result_ready
3339 * Could also do this by pointing N message decode slots at
3340 * a single function, but that could break in subtle ways.
3343 #define foreach_standard_reply_retval_handler \
3344 _(sw_interface_set_flags_reply) \
3345 _(sw_interface_add_del_address_reply) \
3346 _(sw_interface_set_table_reply) \
3347 _(sw_interface_set_vpath_reply) \
3348 _(sw_interface_set_l2_bridge_reply) \
3349 _(bridge_domain_add_del_reply) \
3350 _(sw_interface_set_l2_xconnect_reply) \
3351 _(l2fib_add_del_reply) \
3352 _(ip_add_del_route_reply) \
3353 _(proxy_arp_add_del_reply) \
3354 _(proxy_arp_intfc_enable_disable_reply) \
3355 _(mpls_add_del_encap_reply) \
3356 _(mpls_add_del_decap_reply) \
3357 _(mpls_ethernet_add_del_tunnel_2_reply) \
3358 _(sw_interface_set_unnumbered_reply) \
3359 _(ip_neighbor_add_del_reply) \
3360 _(reset_vrf_reply) \
3361 _(oam_add_del_reply) \
3362 _(reset_fib_reply) \
3363 _(dhcp_proxy_config_reply) \
3364 _(dhcp_proxy_config_2_reply) \
3365 _(dhcp_proxy_set_vss_reply) \
3366 _(dhcp_client_config_reply) \
3367 _(set_ip_flow_hash_reply) \
3368 _(sw_interface_ip6_enable_disable_reply) \
3369 _(sw_interface_ip6_set_link_local_address_reply) \
3370 _(sw_interface_ip6nd_ra_prefix_reply) \
3371 _(sw_interface_ip6nd_ra_config_reply) \
3372 _(set_arp_neighbor_limit_reply) \
3373 _(l2_patch_add_del_reply) \
3374 _(sr_tunnel_add_del_reply) \
3375 _(sr_policy_add_del_reply) \
3376 _(sr_multicast_map_add_del_reply) \
3377 _(classify_add_del_session_reply) \
3378 _(classify_set_interface_ip_table_reply) \
3379 _(classify_set_interface_l2_tables_reply) \
3380 _(l2tpv3_set_tunnel_cookies_reply) \
3381 _(l2tpv3_interface_enable_disable_reply) \
3382 _(l2tpv3_set_lookup_key_reply) \
3383 _(l2_fib_clear_table_reply) \
3384 _(l2_interface_efp_filter_reply) \
3385 _(l2_interface_vlan_tag_rewrite_reply) \
3386 _(modify_vhost_user_if_reply) \
3387 _(delete_vhost_user_if_reply) \
3388 _(want_ip4_arp_events_reply) \
3389 _(want_ip6_nd_events_reply) \
3390 _(input_acl_set_interface_reply) \
3391 _(ipsec_spd_add_del_reply) \
3392 _(ipsec_interface_add_del_spd_reply) \
3393 _(ipsec_spd_add_del_entry_reply) \
3394 _(ipsec_sad_add_del_entry_reply) \
3395 _(ipsec_sa_set_key_reply) \
3396 _(ikev2_profile_add_del_reply) \
3397 _(ikev2_profile_set_auth_reply) \
3398 _(ikev2_profile_set_id_reply) \
3399 _(ikev2_profile_set_ts_reply) \
3400 _(ikev2_set_local_key_reply) \
3401 _(delete_loopback_reply) \
3402 _(bd_ip_mac_add_del_reply) \
3403 _(map_del_domain_reply) \
3404 _(map_add_del_rule_reply) \
3405 _(want_interface_events_reply) \
3406 _(want_stats_reply) \
3407 _(cop_interface_enable_disable_reply) \
3408 _(cop_whitelist_enable_disable_reply) \
3409 _(sw_interface_clear_stats_reply) \
3410 _(ioam_enable_reply) \
3411 _(ioam_disable_reply) \
3412 _(lisp_add_del_locator_reply) \
3413 _(lisp_add_del_local_eid_reply) \
3414 _(lisp_add_del_remote_mapping_reply) \
3415 _(lisp_add_del_adjacency_reply) \
3416 _(lisp_gpe_add_del_fwd_entry_reply) \
3417 _(lisp_add_del_map_resolver_reply) \
3418 _(lisp_gpe_enable_disable_reply) \
3419 _(lisp_gpe_add_del_iface_reply) \
3420 _(lisp_enable_disable_reply) \
3421 _(lisp_pitr_set_locator_set_reply) \
3422 _(lisp_add_del_map_request_itr_rlocs_reply) \
3423 _(lisp_eid_table_add_del_map_reply) \
3424 _(vxlan_gpe_add_del_tunnel_reply) \
3425 _(af_packet_delete_reply) \
3426 _(policer_classify_set_interface_reply) \
3427 _(netmap_create_reply) \
3428 _(netmap_delete_reply) \
3429 _(ipfix_enable_reply) \
3430 _(pg_capture_reply) \
3431 _(pg_enable_disable_reply) \
3432 _(ip_source_and_port_range_check_add_del_reply) \
3433 _(ip_source_and_port_range_check_interface_add_del_reply)\
3434 _(delete_subif_reply)
3437 static void vl_api_##n##_t_handler \
3438 (vl_api_##n##_t * mp) \
3440 vat_main_t * vam = &vat_main; \
3441 i32 retval = ntohl(mp->retval); \
3442 if (vam->async_mode) { \
3443 vam->async_errors += (retval < 0); \
3445 vam->retval = retval; \
3446 vam->result_ready = 1; \
3449 foreach_standard_reply_retval_handler;
3453 static void vl_api_##n##_t_handler_json \
3454 (vl_api_##n##_t * mp) \
3456 vat_main_t * vam = &vat_main; \
3457 vat_json_node_t node; \
3458 vat_json_init_object(&node); \
3459 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3460 vat_json_print(vam->ofp, &node); \
3461 vam->retval = ntohl(mp->retval); \
3462 vam->result_ready = 1; \
3464 foreach_standard_reply_retval_handler;
3468 * Table of message reply handlers, must include boilerplate handlers
3472 #define foreach_vpe_api_reply_msg \
3473 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3474 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3475 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
3476 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3477 _(CONTROL_PING_REPLY, control_ping_reply) \
3478 _(NOPRINT_CONTROL_PING_REPLY, noprint_control_ping_reply) \
3479 _(CLI_REPLY, cli_reply) \
3480 _(CLI_INBAND_REPLY, cli_inband_reply) \
3481 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
3482 sw_interface_add_del_address_reply) \
3483 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
3484 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
3485 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
3486 sw_interface_set_l2_xconnect_reply) \
3487 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
3488 sw_interface_set_l2_bridge_reply) \
3489 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
3490 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
3491 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
3492 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
3493 _(L2_FLAGS_REPLY, l2_flags_reply) \
3494 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
3495 _(TAP_CONNECT_REPLY, tap_connect_reply) \
3496 _(TAP_MODIFY_REPLY, tap_modify_reply) \
3497 _(TAP_DELETE_REPLY, tap_delete_reply) \
3498 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
3499 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
3500 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
3501 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
3502 proxy_arp_intfc_enable_disable_reply) \
3503 _(MPLS_ADD_DEL_ENCAP_REPLY, mpls_add_del_encap_reply) \
3504 _(MPLS_ADD_DEL_DECAP_REPLY, mpls_add_del_decap_reply) \
3505 _(MPLS_GRE_ADD_DEL_TUNNEL_REPLY, mpls_gre_add_del_tunnel_reply) \
3506 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_REPLY, \
3507 mpls_ethernet_add_del_tunnel_reply) \
3508 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_2_REPLY, \
3509 mpls_ethernet_add_del_tunnel_2_reply) \
3510 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
3511 sw_interface_set_unnumbered_reply) \
3512 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
3513 _(RESET_VRF_REPLY, reset_vrf_reply) \
3514 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
3515 _(CREATE_SUBIF_REPLY, create_subif_reply) \
3516 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
3517 _(RESET_FIB_REPLY, reset_fib_reply) \
3518 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
3519 _(DHCP_PROXY_CONFIG_2_REPLY, dhcp_proxy_config_2_reply) \
3520 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
3521 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
3522 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
3523 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
3524 sw_interface_ip6_enable_disable_reply) \
3525 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
3526 sw_interface_ip6_set_link_local_address_reply) \
3527 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
3528 sw_interface_ip6nd_ra_prefix_reply) \
3529 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
3530 sw_interface_ip6nd_ra_config_reply) \
3531 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
3532 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
3533 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
3534 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
3535 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
3536 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
3537 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
3538 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
3539 classify_set_interface_ip_table_reply) \
3540 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
3541 classify_set_interface_l2_tables_reply) \
3542 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
3543 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
3544 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
3545 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
3546 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
3547 l2tpv3_interface_enable_disable_reply) \
3548 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
3549 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
3550 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
3551 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
3552 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
3553 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
3554 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
3555 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
3556 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
3557 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
3558 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
3559 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
3560 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
3561 _(SHOW_VERSION_REPLY, show_version_reply) \
3562 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
3563 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
3564 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
3565 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
3566 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
3567 _(IP4_ARP_EVENT, ip4_arp_event) \
3568 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
3569 _(IP6_ND_EVENT, ip6_nd_event) \
3570 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
3571 _(IP_ADDRESS_DETAILS, ip_address_details) \
3572 _(IP_DETAILS, ip_details) \
3573 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
3574 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
3575 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
3576 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
3577 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
3578 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
3579 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
3580 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
3581 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
3582 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
3583 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
3584 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
3585 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
3586 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
3587 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
3588 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
3589 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
3590 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
3591 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
3592 _(MAP_DOMAIN_DETAILS, map_domain_details) \
3593 _(MAP_RULE_DETAILS, map_rule_details) \
3594 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
3595 _(WANT_STATS_REPLY, want_stats_reply) \
3596 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
3597 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
3598 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
3599 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
3600 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
3601 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
3602 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
3603 _(LISP_ADD_DEL_LOCATOR_SET_REPLY, lisp_add_del_locator_set_reply) \
3604 _(LISP_ADD_DEL_LOCATOR_REPLY, lisp_add_del_locator_reply) \
3605 _(LISP_ADD_DEL_LOCAL_EID_REPLY, lisp_add_del_local_eid_reply) \
3606 _(LISP_ADD_DEL_REMOTE_MAPPING_REPLY, lisp_add_del_remote_mapping_reply) \
3607 _(LISP_ADD_DEL_ADJACENCY_REPLY, lisp_add_del_adjacency_reply) \
3608 _(LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY, lisp_gpe_add_del_fwd_entry_reply) \
3609 _(LISP_ADD_DEL_MAP_RESOLVER_REPLY, lisp_add_del_map_resolver_reply) \
3610 _(LISP_GPE_ENABLE_DISABLE_REPLY, lisp_gpe_enable_disable_reply) \
3611 _(LISP_ENABLE_DISABLE_REPLY, lisp_enable_disable_reply) \
3612 _(LISP_PITR_SET_LOCATOR_SET_REPLY, lisp_pitr_set_locator_set_reply) \
3613 _(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \
3614 _(LISP_GPE_ADD_DEL_IFACE_REPLY, lisp_gpe_add_del_iface_reply) \
3615 _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \
3616 _(LISP_LOCATOR_DETAILS, lisp_locator_details) \
3617 _(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \
3618 _(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \
3619 _(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \
3620 _(LISP_GPE_TUNNEL_DETAILS, lisp_gpe_tunnel_details) \
3621 _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
3622 _(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
3623 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
3624 lisp_add_del_map_request_itr_rlocs_reply) \
3625 _(LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
3626 lisp_get_map_request_itr_rlocs_reply) \
3627 _(SHOW_LISP_PITR_REPLY, show_lisp_pitr_reply) \
3628 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
3629 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
3630 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
3631 _(POLICER_DETAILS, policer_details) \
3632 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
3633 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
3634 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
3635 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
3636 _(MPLS_GRE_TUNNEL_DETAILS, mpls_gre_tunnel_details) \
3637 _(MPLS_ETH_TUNNEL_DETAILS, mpls_eth_tunnel_details) \
3638 _(MPLS_FIB_ENCAP_DETAILS, mpls_fib_encap_details) \
3639 _(MPLS_FIB_DECAP_DETAILS, mpls_fib_decap_details) \
3640 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
3641 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
3642 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
3643 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
3644 _(IPFIX_ENABLE_REPLY, ipfix_enable_reply) \
3645 _(IPFIX_DETAILS, ipfix_details) \
3646 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
3647 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
3648 _(PG_CAPTURE_REPLY, pg_capture_reply) \
3649 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
3650 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
3651 ip_source_and_port_range_check_add_del_reply) \
3652 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
3653 ip_source_and_port_range_check_interface_add_del_reply) \
3654 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
3655 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
3656 _(DELETE_SUBIF_REPLY, delete_subif_reply)
3658 /* M: construct, but don't yet send a message */
3662 vam->result_ready = 0; \
3663 mp = vl_msg_api_alloc(sizeof(*mp)); \
3664 memset (mp, 0, sizeof (*mp)); \
3665 mp->_vl_msg_id = ntohs (VL_API_##T); \
3666 mp->client_index = vam->my_client_index; \
3671 vam->result_ready = 0; \
3672 mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
3673 memset (mp, 0, sizeof (*mp)); \
3674 mp->_vl_msg_id = ntohs (VL_API_##T); \
3675 mp->client_index = vam->my_client_index; \
3679 /* S: send a message */
3680 #define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
3682 /* W: wait for results, with timeout */
3685 timeout = vat_time_now (vam) + 1.0; \
3687 while (vat_time_now (vam) < timeout) { \
3688 if (vam->result_ready == 1) { \
3689 return (vam->retval); \
3695 /* W2: wait for results, with timeout */
3698 timeout = vat_time_now (vam) + 1.0; \
3700 while (vat_time_now (vam) < timeout) { \
3701 if (vam->result_ready == 1) { \
3703 return (vam->retval); \
3709 /* W_L: wait for results, with timeout */
3712 timeout = vat_time_now (vam) + 1.0; \
3714 while (vat_time_now (vam) < timeout) { \
3715 if (vam->result_ready == 1) { \
3717 return (vam->retval); \
3720 vam->noprint_msg = 0; \
3731 #define STR_VTR_OP_CASE(op) \
3732 case L2_VTR_ ## op: \
3736 str_vtr_op (u32 vtr_op)
3740 STR_VTR_OP_CASE (DISABLED);
3741 STR_VTR_OP_CASE (PUSH_1);
3742 STR_VTR_OP_CASE (PUSH_2);
3743 STR_VTR_OP_CASE (POP_1);
3744 STR_VTR_OP_CASE (POP_2);
3745 STR_VTR_OP_CASE (TRANSLATE_1_1);
3746 STR_VTR_OP_CASE (TRANSLATE_1_2);
3747 STR_VTR_OP_CASE (TRANSLATE_2_1);
3748 STR_VTR_OP_CASE (TRANSLATE_2_2);
3755 dump_sub_interface_table (vat_main_t * vam)
3757 const sw_interface_subif_t *sub = NULL;
3759 if (vam->json_output)
3762 ("JSON output supported only for VPE API calls and dump_stats_table");
3767 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s\n",
3768 "Interface", "sw_if_index",
3769 "sub id", "dot1ad", "tags", "outer id",
3770 "inner id", "exact", "default", "outer any", "inner any");
3772 vec_foreach (sub, vam->sw_if_subif_table)
3775 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d\n",
3776 sub->interface_name,
3778 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
3779 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
3780 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
3781 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
3782 if (sub->vtr_op != L2_VTR_DISABLED)
3785 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
3786 "tag1: %d tag2: %d ]\n",
3787 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
3788 sub->vtr_tag1, sub->vtr_tag2);
3796 name_sort_cmp (void *a1, void *a2)
3798 name_sort_t *n1 = a1;
3799 name_sort_t *n2 = a2;
3801 return strcmp ((char *) n1->name, (char *) n2->name);
3805 dump_interface_table (vat_main_t * vam)
3808 name_sort_t *nses = 0, *ns;
3810 if (vam->json_output)
3813 ("JSON output supported only for VPE API calls and dump_stats_table");
3818 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
3820 vec_add2 (nses, ns, 1);
3821 ns->name = (u8 *)(p->key);
3822 ns->value = (u32) p->value[0];
3826 vec_sort_with_function (nses, name_sort_cmp);
3828 fformat (vam->ofp, "%-25s%-15s\n", "Interface", "sw_if_index");
3829 vec_foreach (ns, nses)
3831 fformat (vam->ofp, "%-25s%-15d\n", ns->name, ns->value);
3838 dump_ip_table (vat_main_t * vam, int is_ipv6)
3840 const ip_details_t *det = NULL;
3841 const ip_address_details_t *address = NULL;
3844 fformat (vam->ofp, "%-12s\n", "sw_if_index");
3846 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
3853 fformat (vam->ofp, "%-12d\n", i);
3855 " %-30s%-13s\n", "Address", "Prefix length");
3860 vec_foreach (address, det->addr)
3864 is_ipv6 ? format_ip6_address : format_ip4_address,
3865 address->ip, address->prefix_length);
3873 dump_ipv4_table (vat_main_t * vam)
3875 if (vam->json_output)
3878 ("JSON output supported only for VPE API calls and dump_stats_table");
3882 return dump_ip_table (vam, 0);
3886 dump_ipv6_table (vat_main_t * vam)
3888 if (vam->json_output)
3891 ("JSON output supported only for VPE API calls and dump_stats_table");
3895 return dump_ip_table (vam, 1);
3899 counter_type_to_str (u8 counter_type, u8 is_combined)
3903 switch (counter_type)
3905 case VNET_INTERFACE_COUNTER_DROP:
3907 case VNET_INTERFACE_COUNTER_PUNT:
3909 case VNET_INTERFACE_COUNTER_IP4:
3911 case VNET_INTERFACE_COUNTER_IP6:
3913 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
3915 case VNET_INTERFACE_COUNTER_RX_MISS:
3917 case VNET_INTERFACE_COUNTER_RX_ERROR:
3919 case VNET_INTERFACE_COUNTER_TX_ERROR:
3922 return "INVALID-COUNTER-TYPE";
3927 switch (counter_type)
3929 case VNET_INTERFACE_COUNTER_RX:
3931 case VNET_INTERFACE_COUNTER_TX:
3934 return "INVALID-COUNTER-TYPE";
3940 dump_stats_table (vat_main_t * vam)
3942 vat_json_node_t node;
3943 vat_json_node_t *msg_array;
3944 vat_json_node_t *msg;
3945 vat_json_node_t *counter_array;
3946 vat_json_node_t *counter;
3947 interface_counter_t c;
3949 ip4_fib_counter_t *c4;
3950 ip6_fib_counter_t *c6;
3953 if (!vam->json_output)
3955 clib_warning ("dump_stats_table supported only in JSON format");
3959 vat_json_init_object (&node);
3961 /* interface counters */
3962 msg_array = vat_json_object_add (&node, "interface_counters");
3963 vat_json_init_array (msg_array);
3964 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
3966 msg = vat_json_array_add (msg_array);
3967 vat_json_init_object (msg);
3968 vat_json_object_add_string_copy (msg, "vnet_counter_type",
3969 (u8 *) counter_type_to_str (i, 0));
3970 vat_json_object_add_int (msg, "is_combined", 0);
3971 counter_array = vat_json_object_add (msg, "data");
3972 vat_json_init_array (counter_array);
3973 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
3975 packets = vam->simple_interface_counters[i][j];
3976 vat_json_array_add_uint (counter_array, packets);
3979 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
3981 msg = vat_json_array_add (msg_array);
3982 vat_json_init_object (msg);
3983 vat_json_object_add_string_copy (msg, "vnet_counter_type",
3984 (u8 *) counter_type_to_str (i, 1));
3985 vat_json_object_add_int (msg, "is_combined", 1);
3986 counter_array = vat_json_object_add (msg, "data");
3987 vat_json_init_array (counter_array);
3988 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
3990 c = vam->combined_interface_counters[i][j];
3991 counter = vat_json_array_add (counter_array);
3992 vat_json_init_object (counter);
3993 vat_json_object_add_uint (counter, "packets", c.packets);
3994 vat_json_object_add_uint (counter, "bytes", c.bytes);
3998 /* ip4 fib counters */
3999 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4000 vat_json_init_array (msg_array);
4001 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4003 msg = vat_json_array_add (msg_array);
4004 vat_json_init_object (msg);
4005 vat_json_object_add_uint (msg, "vrf_id",
4006 vam->ip4_fib_counters_vrf_id_by_index[i]);
4007 counter_array = vat_json_object_add (msg, "c");
4008 vat_json_init_array (counter_array);
4009 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4011 counter = vat_json_array_add (counter_array);
4012 vat_json_init_object (counter);
4013 c4 = &vam->ip4_fib_counters[i][j];
4014 vat_json_object_add_ip4 (counter, "address", c4->address);
4015 vat_json_object_add_uint (counter, "address_length",
4016 c4->address_length);
4017 vat_json_object_add_uint (counter, "packets", c4->packets);
4018 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4022 /* ip6 fib counters */
4023 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4024 vat_json_init_array (msg_array);
4025 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4027 msg = vat_json_array_add (msg_array);
4028 vat_json_init_object (msg);
4029 vat_json_object_add_uint (msg, "vrf_id",
4030 vam->ip6_fib_counters_vrf_id_by_index[i]);
4031 counter_array = vat_json_object_add (msg, "c");
4032 vat_json_init_array (counter_array);
4033 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4035 counter = vat_json_array_add (counter_array);
4036 vat_json_init_object (counter);
4037 c6 = &vam->ip6_fib_counters[i][j];
4038 vat_json_object_add_ip6 (counter, "address", c6->address);
4039 vat_json_object_add_uint (counter, "address_length",
4040 c6->address_length);
4041 vat_json_object_add_uint (counter, "packets", c6->packets);
4042 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4046 vat_json_print (vam->ofp, &node);
4047 vat_json_free (&node);
4053 exec (vat_main_t * vam)
4055 api_main_t *am = &api_main;
4056 vl_api_cli_request_t *mp;
4060 unformat_input_t *i = vam->input;
4062 if (vec_len (i->buffer) == 0)
4065 if (vam->exec_mode == 0 && unformat (i, "mode"))
4070 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4077 M (CLI_REQUEST, cli_request);
4080 * Copy cmd into shared memory.
4081 * In order for the CLI command to work, it
4082 * must be a vector ending in \n, not a C-string ending
4085 pthread_mutex_lock (&am->vlib_rp->mutex);
4086 oldheap = svm_push_data_heap (am->vlib_rp);
4088 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4089 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4091 svm_pop_heap (oldheap);
4092 pthread_mutex_unlock (&am->vlib_rp->mutex);
4094 mp->cmd_in_shmem = (u64) cmd;
4096 timeout = vat_time_now (vam) + 10.0;
4098 while (vat_time_now (vam) < timeout)
4100 if (vam->result_ready == 1)
4103 if (vam->shmem_result != NULL)
4104 fformat (vam->ofp, "%s", vam->shmem_result);
4105 pthread_mutex_lock (&am->vlib_rp->mutex);
4106 oldheap = svm_push_data_heap (am->vlib_rp);
4108 free_me = (u8 *) vam->shmem_result;
4111 svm_pop_heap (oldheap);
4112 pthread_mutex_unlock (&am->vlib_rp->mutex);
4120 * Future replacement of exec() that passes CLI buffers directly in
4121 * the API messages instead of an additional shared memory area.
4124 exec_inband (vat_main_t * vam)
4126 vl_api_cli_inband_t *mp;
4128 unformat_input_t *i = vam->input;
4130 if (vec_len (i->buffer) == 0)
4133 if (vam->exec_mode == 0 && unformat (i, "mode"))
4138 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4145 * In order for the CLI command to work, it
4146 * must be a vector ending in \n, not a C-string ending
4149 u32 len = vec_len (vam->input->buffer);
4150 M2 (CLI_INBAND, cli_inband, len);
4151 clib_memcpy (mp->cmd, vam->input->buffer, len);
4152 mp->length = htonl (len);
4155 W2 (fformat (vam->ofp, "%s", vam->cmd_reply));
4159 api_create_loopback (vat_main_t * vam)
4161 unformat_input_t *i = vam->input;
4162 vl_api_create_loopback_t *mp;
4167 memset (mac_address, 0, sizeof (mac_address));
4169 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4171 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4177 /* Construct the API message */
4178 M (CREATE_LOOPBACK, create_loopback);
4180 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4187 api_delete_loopback (vat_main_t * vam)
4189 unformat_input_t *i = vam->input;
4190 vl_api_delete_loopback_t *mp;
4192 u32 sw_if_index = ~0;
4194 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4196 if (unformat (i, "sw_if_index %d", &sw_if_index))
4202 if (sw_if_index == ~0)
4204 errmsg ("missing sw_if_index\n");
4208 /* Construct the API message */
4209 M (DELETE_LOOPBACK, delete_loopback);
4210 mp->sw_if_index = ntohl (sw_if_index);
4217 api_want_stats (vat_main_t * vam)
4219 unformat_input_t *i = vam->input;
4220 vl_api_want_stats_t *mp;
4224 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4226 if (unformat (i, "enable"))
4228 else if (unformat (i, "disable"))
4236 errmsg ("missing enable|disable\n");
4240 M (WANT_STATS, want_stats);
4241 mp->enable_disable = enable;
4248 api_want_interface_events (vat_main_t * vam)
4250 unformat_input_t *i = vam->input;
4251 vl_api_want_interface_events_t *mp;
4255 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4257 if (unformat (i, "enable"))
4259 else if (unformat (i, "disable"))
4267 errmsg ("missing enable|disable\n");
4271 M (WANT_INTERFACE_EVENTS, want_interface_events);
4272 mp->enable_disable = enable;
4274 vam->interface_event_display = enable;
4281 /* Note: non-static, called once to set up the initial intfc table */
4283 api_sw_interface_dump (vat_main_t * vam)
4285 vl_api_sw_interface_dump_t *mp;
4288 name_sort_t *nses = 0, *ns;
4289 sw_interface_subif_t *sub = NULL;
4291 /* Toss the old name table */
4293 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4295 vec_add2 (nses, ns, 1);
4296 ns->name = (u8 *)(p->key);
4297 ns->value = (u32) p->value[0];
4301 hash_free (vam->sw_if_index_by_interface_name);
4303 vec_foreach (ns, nses) vec_free (ns->name);
4307 vec_foreach (sub, vam->sw_if_subif_table)
4309 vec_free (sub->interface_name);
4311 vec_free (vam->sw_if_subif_table);
4313 /* recreate the interface name hash table */
4314 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4316 /* Get list of ethernets */
4317 M (SW_INTERFACE_DUMP, sw_interface_dump);
4318 mp->name_filter_valid = 1;
4319 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4322 /* and local / loopback interfaces */
4323 M (SW_INTERFACE_DUMP, sw_interface_dump);
4324 mp->name_filter_valid = 1;
4325 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4329 /* and vxlan-gpe tunnel interfaces */
4330 M (SW_INTERFACE_DUMP, sw_interface_dump);
4331 mp->name_filter_valid = 1;
4332 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4333 sizeof (mp->name_filter) - 1);
4336 /* and vxlan tunnel interfaces */
4337 M (SW_INTERFACE_DUMP, sw_interface_dump);
4338 mp->name_filter_valid = 1;
4339 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4342 /* and host (af_packet) interfaces */
4343 M (SW_INTERFACE_DUMP, sw_interface_dump);
4344 mp->name_filter_valid = 1;
4345 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4348 /* and l2tpv3 tunnel interfaces */
4349 M (SW_INTERFACE_DUMP, sw_interface_dump);
4350 mp->name_filter_valid = 1;
4351 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4352 sizeof (mp->name_filter) - 1);
4355 /* and GRE tunnel interfaces */
4356 M (SW_INTERFACE_DUMP, sw_interface_dump);
4357 mp->name_filter_valid = 1;
4358 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4361 /* and LISP-GPE interfaces */
4362 M (SW_INTERFACE_DUMP, sw_interface_dump);
4363 mp->name_filter_valid = 1;
4364 strncpy ((char *) mp->name_filter, "lisp_gpe",
4365 sizeof (mp->name_filter) - 1);
4368 /* Use a control ping for synchronization */
4370 vl_api_control_ping_t *mp;
4371 M (CONTROL_PING, control_ping);
4378 api_sw_interface_set_flags (vat_main_t * vam)
4380 unformat_input_t *i = vam->input;
4381 vl_api_sw_interface_set_flags_t *mp;
4384 u8 sw_if_index_set = 0;
4385 u8 admin_up = 0, link_up = 0;
4387 /* Parse args required to build the message */
4388 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4390 if (unformat (i, "admin-up"))
4392 else if (unformat (i, "admin-down"))
4394 else if (unformat (i, "link-up"))
4396 else if (unformat (i, "link-down"))
4398 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4399 sw_if_index_set = 1;
4400 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4401 sw_if_index_set = 1;
4406 if (sw_if_index_set == 0)
4408 errmsg ("missing interface name or sw_if_index\n");
4412 /* Construct the API message */
4413 M (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags);
4414 mp->sw_if_index = ntohl (sw_if_index);
4415 mp->admin_up_down = admin_up;
4416 mp->link_up_down = link_up;
4421 /* Wait for a reply, return the good/bad news... */
4426 api_sw_interface_clear_stats (vat_main_t * vam)
4428 unformat_input_t *i = vam->input;
4429 vl_api_sw_interface_clear_stats_t *mp;
4432 u8 sw_if_index_set = 0;
4434 /* Parse args required to build the message */
4435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4437 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4438 sw_if_index_set = 1;
4439 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4440 sw_if_index_set = 1;
4445 /* Construct the API message */
4446 M (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats);
4448 if (sw_if_index_set == 1)
4449 mp->sw_if_index = ntohl (sw_if_index);
4451 mp->sw_if_index = ~0;
4456 /* Wait for a reply, return the good/bad news... */
4461 api_sw_interface_add_del_address (vat_main_t * vam)
4463 unformat_input_t *i = vam->input;
4464 vl_api_sw_interface_add_del_address_t *mp;
4467 u8 sw_if_index_set = 0;
4468 u8 is_add = 1, del_all = 0;
4469 u32 address_length = 0;
4470 u8 v4_address_set = 0;
4471 u8 v6_address_set = 0;
4472 ip4_address_t v4address;
4473 ip6_address_t v6address;
4475 /* Parse args required to build the message */
4476 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4478 if (unformat (i, "del-all"))
4480 else if (unformat (i, "del"))
4482 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4483 sw_if_index_set = 1;
4484 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4485 sw_if_index_set = 1;
4486 else if (unformat (i, "%U/%d",
4487 unformat_ip4_address, &v4address, &address_length))
4489 else if (unformat (i, "%U/%d",
4490 unformat_ip6_address, &v6address, &address_length))
4496 if (sw_if_index_set == 0)
4498 errmsg ("missing interface name or sw_if_index\n");
4501 if (v4_address_set && v6_address_set)
4503 errmsg ("both v4 and v6 addresses set\n");
4506 if (!v4_address_set && !v6_address_set && !del_all)
4508 errmsg ("no addresses set\n");
4512 /* Construct the API message */
4513 M (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address);
4515 mp->sw_if_index = ntohl (sw_if_index);
4516 mp->is_add = is_add;
4517 mp->del_all = del_all;
4521 clib_memcpy (mp->address, &v6address, sizeof (v6address));
4525 clib_memcpy (mp->address, &v4address, sizeof (v4address));
4527 mp->address_length = address_length;
4532 /* Wait for a reply, return good/bad news */
4537 api_sw_interface_set_table (vat_main_t * vam)
4539 unformat_input_t *i = vam->input;
4540 vl_api_sw_interface_set_table_t *mp;
4542 u32 sw_if_index, vrf_id = 0;
4543 u8 sw_if_index_set = 0;
4546 /* Parse args required to build the message */
4547 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4549 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4550 sw_if_index_set = 1;
4551 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4552 sw_if_index_set = 1;
4553 else if (unformat (i, "vrf %d", &vrf_id))
4555 else if (unformat (i, "ipv6"))
4561 if (sw_if_index_set == 0)
4563 errmsg ("missing interface name or sw_if_index\n");
4567 /* Construct the API message */
4568 M (SW_INTERFACE_SET_TABLE, sw_interface_set_table);
4570 mp->sw_if_index = ntohl (sw_if_index);
4571 mp->is_ipv6 = is_ipv6;
4572 mp->vrf_id = ntohl (vrf_id);
4577 /* Wait for a reply... */
4582 api_sw_interface_set_vpath (vat_main_t * vam)
4584 unformat_input_t *i = vam->input;
4585 vl_api_sw_interface_set_vpath_t *mp;
4587 u32 sw_if_index = 0;
4588 u8 sw_if_index_set = 0;
4591 /* Parse args required to build the message */
4592 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4594 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4595 sw_if_index_set = 1;
4596 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4597 sw_if_index_set = 1;
4598 else if (unformat (i, "enable"))
4600 else if (unformat (i, "disable"))
4606 if (sw_if_index_set == 0)
4608 errmsg ("missing interface name or sw_if_index\n");
4612 /* Construct the API message */
4613 M (SW_INTERFACE_SET_VPATH, sw_interface_set_vpath);
4615 mp->sw_if_index = ntohl (sw_if_index);
4616 mp->enable = is_enable;
4621 /* Wait for a reply... */
4626 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
4628 unformat_input_t *i = vam->input;
4629 vl_api_sw_interface_set_l2_xconnect_t *mp;
4632 u8 rx_sw_if_index_set = 0;
4634 u8 tx_sw_if_index_set = 0;
4637 /* Parse args required to build the message */
4638 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4640 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
4641 rx_sw_if_index_set = 1;
4642 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
4643 tx_sw_if_index_set = 1;
4644 else if (unformat (i, "rx"))
4646 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4648 if (unformat (i, "%U", unformat_sw_if_index, vam,
4650 rx_sw_if_index_set = 1;
4655 else if (unformat (i, "tx"))
4657 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4659 if (unformat (i, "%U", unformat_sw_if_index, vam,
4661 tx_sw_if_index_set = 1;
4666 else if (unformat (i, "enable"))
4668 else if (unformat (i, "disable"))
4674 if (rx_sw_if_index_set == 0)
4676 errmsg ("missing rx interface name or rx_sw_if_index\n");
4680 if (enable && (tx_sw_if_index_set == 0))
4682 errmsg ("missing tx interface name or tx_sw_if_index\n");
4686 M (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect);
4688 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
4689 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
4690 mp->enable = enable;
4699 api_sw_interface_set_l2_bridge (vat_main_t * vam)
4701 unformat_input_t *i = vam->input;
4702 vl_api_sw_interface_set_l2_bridge_t *mp;
4705 u8 rx_sw_if_index_set = 0;
4712 /* Parse args required to build the message */
4713 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4715 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
4716 rx_sw_if_index_set = 1;
4717 else if (unformat (i, "bd_id %d", &bd_id))
4719 else if (unformat (i, "%U", unformat_sw_if_index, vam, &rx_sw_if_index))
4720 rx_sw_if_index_set = 1;
4721 else if (unformat (i, "shg %d", &shg))
4723 else if (unformat (i, "bvi"))
4725 else if (unformat (i, "enable"))
4727 else if (unformat (i, "disable"))
4733 if (rx_sw_if_index_set == 0)
4735 errmsg ("missing rx interface name or sw_if_index\n");
4739 if (enable && (bd_id_set == 0))
4741 errmsg ("missing bridge domain\n");
4745 M (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge);
4747 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
4748 mp->bd_id = ntohl (bd_id);
4751 mp->enable = enable;
4760 api_bridge_domain_dump (vat_main_t * vam)
4762 unformat_input_t *i = vam->input;
4763 vl_api_bridge_domain_dump_t *mp;
4767 /* Parse args required to build the message */
4768 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4770 if (unformat (i, "bd_id %d", &bd_id))
4776 M (BRIDGE_DOMAIN_DUMP, bridge_domain_dump);
4777 mp->bd_id = ntohl (bd_id);
4780 /* Use a control ping for synchronization */
4782 vl_api_control_ping_t *mp;
4783 M (CONTROL_PING, control_ping);
4793 api_bridge_domain_add_del (vat_main_t * vam)
4795 unformat_input_t *i = vam->input;
4796 vl_api_bridge_domain_add_del_t *mp;
4800 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
4802 /* Parse args required to build the message */
4803 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4805 if (unformat (i, "bd_id %d", &bd_id))
4807 else if (unformat (i, "flood %d", &flood))
4809 else if (unformat (i, "uu-flood %d", &uu_flood))
4811 else if (unformat (i, "forward %d", &forward))
4813 else if (unformat (i, "learn %d", &learn))
4815 else if (unformat (i, "arp-term %d", &arp_term))
4817 else if (unformat (i, "del"))
4820 flood = uu_flood = forward = learn = 0;
4828 errmsg ("missing bridge domain\n");
4832 M (BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del);
4834 mp->bd_id = ntohl (bd_id);
4836 mp->uu_flood = uu_flood;
4837 mp->forward = forward;
4839 mp->arp_term = arp_term;
4840 mp->is_add = is_add;
4849 api_l2fib_add_del (vat_main_t * vam)
4851 unformat_input_t *i = vam->input;
4852 vl_api_l2fib_add_del_t *mp;
4859 u8 sw_if_index_set = 0;
4868 /* Parse args required to build the message */
4869 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4871 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
4873 else if (unformat (i, "bd_id %d", &bd_id))
4875 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4876 sw_if_index_set = 1;
4877 else if (unformat (i, "sw_if"))
4879 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4881 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4882 sw_if_index_set = 1;
4887 else if (unformat (i, "static"))
4889 else if (unformat (i, "filter"))
4894 else if (unformat (i, "bvi"))
4899 else if (unformat (i, "del"))
4901 else if (unformat (i, "count %d", &count))
4909 errmsg ("missing mac address\n");
4915 errmsg ("missing bridge domain\n");
4919 if (is_add && (sw_if_index_set == 0))
4921 errmsg ("missing interface name or sw_if_index\n");
4927 /* Turn on async mode */
4928 vam->async_mode = 1;
4929 vam->async_errors = 0;
4930 before = vat_time_now (vam);
4933 for (j = 0; j < count; j++)
4935 M (L2FIB_ADD_DEL, l2fib_add_del);
4938 mp->bd_id = ntohl (bd_id);
4939 mp->is_add = is_add;
4943 mp->sw_if_index = ntohl (sw_if_index);
4944 mp->static_mac = static_mac;
4945 mp->filter_mac = filter_mac;
4946 mp->bvi_mac = bvi_mac;
4948 increment_mac_address (&mac);
4955 vl_api_control_ping_t *mp;
4958 /* Shut off async mode */
4959 vam->async_mode = 0;
4961 M (CONTROL_PING, control_ping);
4964 timeout = vat_time_now (vam) + 1.0;
4965 while (vat_time_now (vam) < timeout)
4966 if (vam->result_ready == 1)
4971 if (vam->retval == -99)
4972 errmsg ("timeout\n");
4974 if (vam->async_errors > 0)
4976 errmsg ("%d asynchronous errors\n", vam->async_errors);
4979 vam->async_errors = 0;
4980 after = vat_time_now (vam);
4982 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
4983 count, after - before, count / (after - before));
4987 /* Wait for a reply... */
4990 /* Return the good/bad news */
4991 return (vam->retval);
4995 api_l2_flags (vat_main_t * vam)
4997 unformat_input_t *i = vam->input;
4998 vl_api_l2_flags_t *mp;
5001 u32 feature_bitmap = 0;
5002 u8 sw_if_index_set = 0;
5004 /* Parse args required to build the message */
5005 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5007 if (unformat (i, "sw_if_index %d", &sw_if_index))
5008 sw_if_index_set = 1;
5009 else if (unformat (i, "sw_if"))
5011 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5013 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5014 sw_if_index_set = 1;
5019 else if (unformat (i, "learn"))
5020 feature_bitmap |= L2INPUT_FEAT_LEARN;
5021 else if (unformat (i, "forward"))
5022 feature_bitmap |= L2INPUT_FEAT_FWD;
5023 else if (unformat (i, "flood"))
5024 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5025 else if (unformat (i, "uu-flood"))
5026 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5031 if (sw_if_index_set == 0)
5033 errmsg ("missing interface name or sw_if_index\n");
5037 M (L2_FLAGS, l2_flags);
5039 mp->sw_if_index = ntohl (sw_if_index);
5040 mp->feature_bitmap = ntohl (feature_bitmap);
5049 api_bridge_flags (vat_main_t * vam)
5051 unformat_input_t *i = vam->input;
5052 vl_api_bridge_flags_t *mp;
5059 /* Parse args required to build the message */
5060 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5062 if (unformat (i, "bd_id %d", &bd_id))
5064 else if (unformat (i, "learn"))
5066 else if (unformat (i, "forward"))
5068 else if (unformat (i, "flood"))
5070 else if (unformat (i, "uu-flood"))
5071 flags |= L2_UU_FLOOD;
5072 else if (unformat (i, "arp-term"))
5073 flags |= L2_ARP_TERM;
5074 else if (unformat (i, "off"))
5076 else if (unformat (i, "disable"))
5084 errmsg ("missing bridge domain\n");
5088 M (BRIDGE_FLAGS, bridge_flags);
5090 mp->bd_id = ntohl (bd_id);
5091 mp->feature_bitmap = ntohl (flags);
5092 mp->is_set = is_set;
5101 api_bd_ip_mac_add_del (vat_main_t * vam)
5103 unformat_input_t *i = vam->input;
5104 vl_api_bd_ip_mac_add_del_t *mp;
5112 ip4_address_t v4addr;
5113 ip6_address_t v6addr;
5117 /* Parse args required to build the message */
5118 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5120 if (unformat (i, "bd_id %d", &bd_id))
5124 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5128 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5133 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5137 else if (unformat (i, "del"))
5145 errmsg ("missing bridge domain\n");
5148 else if (ip_set == 0)
5150 errmsg ("missing IP address\n");
5153 else if (mac_set == 0)
5155 errmsg ("missing MAC address\n");
5159 M (BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del);
5161 mp->bd_id = ntohl (bd_id);
5162 mp->is_ipv6 = is_ipv6;
5163 mp->is_add = is_add;
5165 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5167 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5168 clib_memcpy (mp->mac_address, macaddr, 6);
5176 api_tap_connect (vat_main_t * vam)
5178 unformat_input_t *i = vam->input;
5179 vl_api_tap_connect_t *mp;
5186 memset (mac_address, 0, sizeof (mac_address));
5188 /* Parse args required to build the message */
5189 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5191 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5195 else if (unformat (i, "random-mac"))
5197 else if (unformat (i, "tapname %s", &tap_name))
5205 errmsg ("missing tap name\n");
5208 if (vec_len (tap_name) > 63)
5210 errmsg ("tap name too long\n");
5212 vec_add1 (tap_name, 0);
5214 /* Construct the API message */
5215 M (TAP_CONNECT, tap_connect);
5217 mp->use_random_mac = random_mac;
5218 clib_memcpy (mp->mac_address, mac_address, 6);
5219 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5220 vec_free (tap_name);
5225 /* Wait for a reply... */
5230 api_tap_modify (vat_main_t * vam)
5232 unformat_input_t *i = vam->input;
5233 vl_api_tap_modify_t *mp;
5239 u32 sw_if_index = ~0;
5240 u8 sw_if_index_set = 0;
5242 memset (mac_address, 0, sizeof (mac_address));
5244 /* Parse args required to build the message */
5245 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5247 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5248 sw_if_index_set = 1;
5249 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5250 sw_if_index_set = 1;
5251 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5255 else if (unformat (i, "random-mac"))
5257 else if (unformat (i, "tapname %s", &tap_name))
5263 if (sw_if_index_set == 0)
5265 errmsg ("missing vpp interface name");
5270 errmsg ("missing tap name\n");
5273 if (vec_len (tap_name) > 63)
5275 errmsg ("tap name too long\n");
5277 vec_add1 (tap_name, 0);
5279 /* Construct the API message */
5280 M (TAP_MODIFY, tap_modify);
5282 mp->use_random_mac = random_mac;
5283 mp->sw_if_index = ntohl (sw_if_index);
5284 clib_memcpy (mp->mac_address, mac_address, 6);
5285 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5286 vec_free (tap_name);
5291 /* Wait for a reply... */
5296 api_tap_delete (vat_main_t * vam)
5298 unformat_input_t *i = vam->input;
5299 vl_api_tap_delete_t *mp;
5301 u32 sw_if_index = ~0;
5302 u8 sw_if_index_set = 0;
5304 /* Parse args required to build the message */
5305 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5307 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5308 sw_if_index_set = 1;
5309 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5310 sw_if_index_set = 1;
5315 if (sw_if_index_set == 0)
5317 errmsg ("missing vpp interface name");
5321 /* Construct the API message */
5322 M (TAP_DELETE, tap_delete);
5324 mp->sw_if_index = ntohl (sw_if_index);
5329 /* Wait for a reply... */
5334 api_ip_add_del_route (vat_main_t * vam)
5336 unformat_input_t *i = vam->input;
5337 vl_api_ip_add_del_route_t *mp;
5339 u32 sw_if_index = ~0, vrf_id = 0;
5340 u8 sw_if_index_set = 0;
5342 u8 is_local = 0, is_drop = 0;
5343 u8 create_vrf_if_needed = 0;
5345 u8 next_hop_weight = 1;
5347 u8 is_multipath = 0;
5349 u8 address_length_set = 0;
5350 u32 lookup_in_vrf = 0;
5351 u32 resolve_attempts = 0;
5352 u32 dst_address_length = 0;
5353 u8 next_hop_set = 0;
5354 ip4_address_t v4_dst_address, v4_next_hop_address;
5355 ip6_address_t v6_dst_address, v6_next_hop_address;
5359 u32 random_add_del = 0;
5360 u32 *random_vector = 0;
5362 u32 random_seed = 0xdeaddabe;
5363 u32 classify_table_index = ~0;
5366 /* Parse args required to build the message */
5367 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5369 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5370 sw_if_index_set = 1;
5371 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5372 sw_if_index_set = 1;
5373 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
5378 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
5383 else if (unformat (i, "/%d", &dst_address_length))
5385 address_length_set = 1;
5388 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
5389 &v4_next_hop_address))
5393 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
5394 &v6_next_hop_address))
5398 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
5400 else if (unformat (i, "weight %d", &next_hop_weight))
5402 else if (unformat (i, "drop"))
5406 else if (unformat (i, "local"))
5410 else if (unformat (i, "classify %d", &classify_table_index))
5414 else if (unformat (i, "del"))
5416 else if (unformat (i, "add"))
5418 else if (unformat (i, "not-last"))
5420 else if (unformat (i, "multipath"))
5422 else if (unformat (i, "vrf %d", &vrf_id))
5424 else if (unformat (i, "create-vrf"))
5425 create_vrf_if_needed = 1;
5426 else if (unformat (i, "count %d", &count))
5428 else if (unformat (i, "lookup-in-vrf %d", &lookup_in_vrf))
5430 else if (unformat (i, "random"))
5432 else if (unformat (i, "seed %d", &random_seed))
5436 clib_warning ("parse error '%U'", format_unformat_error, i);
5441 if (resolve_attempts > 0 && sw_if_index_set == 0)
5443 errmsg ("ARP resolution needs explicit interface or sw_if_index\n");
5447 if (!next_hop_set && !is_drop && !is_local && !is_classify)
5449 errmsg ("next hop / local / drop / classify not set\n");
5453 if (address_set == 0)
5455 errmsg ("missing addresses\n");
5459 if (address_length_set == 0)
5461 errmsg ("missing address length\n");
5465 /* Generate a pile of unique, random routes */
5468 u32 this_random_address;
5469 random_hash = hash_create (count, sizeof (uword));
5471 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
5472 for (j = 0; j <= count; j++)
5476 this_random_address = random_u32 (&random_seed);
5477 this_random_address =
5478 clib_host_to_net_u32 (this_random_address);
5480 while (hash_get (random_hash, this_random_address));
5481 vec_add1 (random_vector, this_random_address);
5482 hash_set (random_hash, this_random_address, 1);
5484 hash_free (random_hash);
5485 v4_dst_address.as_u32 = random_vector[0];
5490 /* Turn on async mode */
5491 vam->async_mode = 1;
5492 vam->async_errors = 0;
5493 before = vat_time_now (vam);
5496 for (j = 0; j < count; j++)
5498 /* Construct the API message */
5499 M (IP_ADD_DEL_ROUTE, ip_add_del_route);
5501 mp->next_hop_sw_if_index = ntohl (sw_if_index);
5502 mp->vrf_id = ntohl (vrf_id);
5503 if (resolve_attempts > 0)
5505 mp->resolve_attempts = ntohl (resolve_attempts);
5506 mp->resolve_if_needed = 1;
5508 mp->create_vrf_if_needed = create_vrf_if_needed;
5510 mp->is_add = is_add;
5511 mp->is_drop = is_drop;
5512 mp->is_ipv6 = is_ipv6;
5513 mp->is_local = is_local;
5514 mp->is_classify = is_classify;
5515 mp->is_multipath = is_multipath;
5516 mp->not_last = not_last;
5517 mp->next_hop_weight = next_hop_weight;
5518 mp->dst_address_length = dst_address_length;
5519 mp->lookup_in_vrf = ntohl (lookup_in_vrf);
5520 mp->classify_table_index = ntohl (classify_table_index);
5524 clib_memcpy (mp->dst_address, &v6_dst_address,
5525 sizeof (v6_dst_address));
5527 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
5528 sizeof (v6_next_hop_address));
5529 increment_v6_address (&v6_dst_address);
5533 clib_memcpy (mp->dst_address, &v4_dst_address,
5534 sizeof (v4_dst_address));
5536 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
5537 sizeof (v4_next_hop_address));
5539 v4_dst_address.as_u32 = random_vector[j + 1];
5541 increment_v4_address (&v4_dst_address);
5547 /* When testing multiple add/del ops, use a control-ping to sync */
5550 vl_api_control_ping_t *mp;
5553 /* Shut off async mode */
5554 vam->async_mode = 0;
5556 M (CONTROL_PING, control_ping);
5559 timeout = vat_time_now (vam) + 1.0;
5560 while (vat_time_now (vam) < timeout)
5561 if (vam->result_ready == 1)
5566 if (vam->retval == -99)
5567 errmsg ("timeout\n");
5569 if (vam->async_errors > 0)
5571 errmsg ("%d asynchronous errors\n", vam->async_errors);
5574 vam->async_errors = 0;
5575 after = vat_time_now (vam);
5577 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
5578 count, after - before, count / (after - before));
5582 /* Wait for a reply... */
5586 /* Return the good/bad news */
5587 return (vam->retval);
5591 api_proxy_arp_add_del (vat_main_t * vam)
5593 unformat_input_t *i = vam->input;
5594 vl_api_proxy_arp_add_del_t *mp;
5598 ip4_address_t lo, hi;
5601 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5603 if (unformat (i, "vrf %d", &vrf_id))
5605 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
5606 unformat_ip4_address, &hi))
5608 else if (unformat (i, "del"))
5612 clib_warning ("parse error '%U'", format_unformat_error, i);
5619 errmsg ("address range not set\n");
5623 M (PROXY_ARP_ADD_DEL, proxy_arp_add_del);
5625 mp->vrf_id = ntohl (vrf_id);
5626 mp->is_add = is_add;
5627 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
5628 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
5637 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
5639 unformat_input_t *i = vam->input;
5640 vl_api_proxy_arp_intfc_enable_disable_t *mp;
5644 u8 sw_if_index_set = 0;
5646 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5648 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5649 sw_if_index_set = 1;
5650 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5651 sw_if_index_set = 1;
5652 else if (unformat (i, "enable"))
5654 else if (unformat (i, "disable"))
5658 clib_warning ("parse error '%U'", format_unformat_error, i);
5663 if (sw_if_index_set == 0)
5665 errmsg ("missing interface name or sw_if_index\n");
5669 M (PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable);
5671 mp->sw_if_index = ntohl (sw_if_index);
5672 mp->enable_disable = enable;
5681 api_mpls_add_del_decap (vat_main_t * vam)
5683 unformat_input_t *i = vam->input;
5684 vl_api_mpls_add_del_decap_t *mp;
5693 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5695 if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
5697 else if (unformat (i, "tx_vrf_id %d", &tx_vrf_id))
5699 else if (unformat (i, "label %d", &label))
5701 else if (unformat (i, "next-index %d", &next_index))
5703 else if (unformat (i, "del"))
5705 else if (unformat (i, "s-bit-clear"))
5709 clib_warning ("parse error '%U'", format_unformat_error, i);
5714 M (MPLS_ADD_DEL_DECAP, mpls_add_del_decap);
5716 mp->rx_vrf_id = ntohl (rx_vrf_id);
5717 mp->tx_vrf_id = ntohl (tx_vrf_id);
5718 mp->label = ntohl (label);
5719 mp->next_index = ntohl (next_index);
5721 mp->is_add = is_add;
5730 api_mpls_add_del_encap (vat_main_t * vam)
5732 unformat_input_t *i = vam->input;
5733 vl_api_mpls_add_del_encap_t *mp;
5738 ip4_address_t dst_address;
5741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5743 if (unformat (i, "vrf %d", &vrf_id))
5745 else if (unformat (i, "label %d", &label))
5746 vec_add1 (labels, ntohl (label));
5747 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
5749 else if (unformat (i, "del"))
5753 clib_warning ("parse error '%U'", format_unformat_error, i);
5758 if (vec_len (labels) == 0)
5760 errmsg ("missing encap label stack\n");
5764 M2 (MPLS_ADD_DEL_ENCAP, mpls_add_del_encap,
5765 sizeof (u32) * vec_len (labels));
5767 mp->vrf_id = ntohl (vrf_id);
5768 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
5769 mp->is_add = is_add;
5770 mp->nlabels = vec_len (labels);
5771 clib_memcpy (mp->labels, labels, sizeof (u32) * mp->nlabels);
5782 api_mpls_gre_add_del_tunnel (vat_main_t * vam)
5784 unformat_input_t *i = vam->input;
5785 vl_api_mpls_gre_add_del_tunnel_t *mp;
5787 u32 inner_vrf_id = 0;
5788 u32 outer_vrf_id = 0;
5789 ip4_address_t src_address;
5790 ip4_address_t dst_address;
5791 ip4_address_t intfc_address;
5793 u8 intfc_address_length = 0;
5797 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5799 if (unformat (i, "inner_vrf_id %d", &inner_vrf_id))
5801 else if (unformat (i, "outer_vrf_id %d", &outer_vrf_id))
5803 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
5805 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
5807 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
5808 &intfc_address, &tmp))
5809 intfc_address_length = tmp;
5810 else if (unformat (i, "l2-only"))
5812 else if (unformat (i, "del"))
5816 clib_warning ("parse error '%U'", format_unformat_error, i);
5821 M (MPLS_GRE_ADD_DEL_TUNNEL, mpls_gre_add_del_tunnel);
5823 mp->inner_vrf_id = ntohl (inner_vrf_id);
5824 mp->outer_vrf_id = ntohl (outer_vrf_id);
5825 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
5826 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
5827 clib_memcpy (mp->intfc_address, &intfc_address, sizeof (intfc_address));
5828 mp->intfc_address_length = intfc_address_length;
5829 mp->l2_only = l2_only;
5830 mp->is_add = is_add;
5839 api_mpls_ethernet_add_del_tunnel (vat_main_t * vam)
5841 unformat_input_t *i = vam->input;
5842 vl_api_mpls_ethernet_add_del_tunnel_t *mp;
5844 u32 inner_vrf_id = 0;
5845 ip4_address_t intfc_address;
5846 u8 dst_mac_address[6];
5849 u8 intfc_address_length = 0;
5853 int tx_sw_if_index_set = 0;
5855 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5857 if (unformat (i, "vrf %d", &inner_vrf_id))
5859 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
5860 &intfc_address, &tmp))
5861 intfc_address_length = tmp;
5862 else if (unformat (i, "%U", unformat_sw_if_index, vam, &tx_sw_if_index))
5863 tx_sw_if_index_set = 1;
5864 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5865 tx_sw_if_index_set = 1;
5866 else if (unformat (i, "dst %U", unformat_ethernet_address,
5869 else if (unformat (i, "l2-only"))
5871 else if (unformat (i, "del"))
5875 clib_warning ("parse error '%U'", format_unformat_error, i);
5882 errmsg ("dst (mac address) not set\n");
5885 if (!tx_sw_if_index_set)
5887 errmsg ("tx-intfc not set\n");
5891 M (MPLS_ETHERNET_ADD_DEL_TUNNEL, mpls_ethernet_add_del_tunnel);
5893 mp->vrf_id = ntohl (inner_vrf_id);
5894 clib_memcpy (mp->adj_address, &intfc_address, sizeof (intfc_address));
5895 mp->adj_address_length = intfc_address_length;
5896 clib_memcpy (mp->dst_mac_address, dst_mac_address,
5897 sizeof (dst_mac_address));
5898 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5899 mp->l2_only = l2_only;
5900 mp->is_add = is_add;
5909 api_mpls_ethernet_add_del_tunnel_2 (vat_main_t * vam)
5911 unformat_input_t *i = vam->input;
5912 vl_api_mpls_ethernet_add_del_tunnel_2_t *mp;
5914 u32 inner_vrf_id = 0;
5915 u32 outer_vrf_id = 0;
5916 ip4_address_t adj_address;
5917 int adj_address_set = 0;
5918 ip4_address_t next_hop_address;
5919 int next_hop_address_set = 0;
5921 u8 adj_address_length = 0;
5924 u32 resolve_attempts = 5;
5925 u8 resolve_if_needed = 1;
5927 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5929 if (unformat (i, "inner_vrf_id %d", &inner_vrf_id))
5931 else if (unformat (i, "outer_vrf_id %d", &outer_vrf_id))
5933 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
5934 &adj_address, &tmp))
5936 adj_address_length = tmp;
5937 adj_address_set = 1;
5939 else if (unformat (i, "next-hop %U", unformat_ip4_address,
5941 next_hop_address_set = 1;
5942 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
5944 else if (unformat (i, "resolve-if-needed %d", &tmp))
5945 resolve_if_needed = tmp;
5946 else if (unformat (i, "l2-only"))
5948 else if (unformat (i, "del"))
5952 clib_warning ("parse error '%U'", format_unformat_error, i);
5957 if (!adj_address_set)
5959 errmsg ("adjacency address/mask not set\n");
5962 if (!next_hop_address_set)
5964 errmsg ("ip4 next hop address (in outer fib) not set\n");
5968 M (MPLS_ETHERNET_ADD_DEL_TUNNEL_2, mpls_ethernet_add_del_tunnel_2);
5970 mp->inner_vrf_id = ntohl (inner_vrf_id);
5971 mp->outer_vrf_id = ntohl (outer_vrf_id);
5972 mp->resolve_attempts = ntohl (resolve_attempts);
5973 mp->resolve_if_needed = resolve_if_needed;
5974 mp->is_add = is_add;
5975 mp->l2_only = l2_only;
5976 clib_memcpy (mp->adj_address, &adj_address, sizeof (adj_address));
5977 mp->adj_address_length = adj_address_length;
5978 clib_memcpy (mp->next_hop_ip4_address_in_outer_vrf, &next_hop_address,
5979 sizeof (next_hop_address));
5988 api_sw_interface_set_unnumbered (vat_main_t * vam)
5990 unformat_input_t *i = vam->input;
5991 vl_api_sw_interface_set_unnumbered_t *mp;
5994 u32 unnum_sw_index = ~0;
5996 u8 sw_if_index_set = 0;
5998 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6000 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6001 sw_if_index_set = 1;
6002 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6003 sw_if_index_set = 1;
6004 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
6006 else if (unformat (i, "del"))
6010 clib_warning ("parse error '%U'", format_unformat_error, i);
6015 if (sw_if_index_set == 0)
6017 errmsg ("missing interface name or sw_if_index\n");
6021 M (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered);
6023 mp->sw_if_index = ntohl (sw_if_index);
6024 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
6025 mp->is_add = is_add;
6034 api_ip_neighbor_add_del (vat_main_t * vam)
6036 unformat_input_t *i = vam->input;
6037 vl_api_ip_neighbor_add_del_t *mp;
6040 u8 sw_if_index_set = 0;
6046 u8 v4_address_set = 0;
6047 u8 v6_address_set = 0;
6048 ip4_address_t v4address;
6049 ip6_address_t v6address;
6051 memset (mac_address, 0, sizeof (mac_address));
6053 /* Parse args required to build the message */
6054 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6056 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6060 else if (unformat (i, "del"))
6062 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6063 sw_if_index_set = 1;
6064 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6065 sw_if_index_set = 1;
6066 else if (unformat (i, "is_static"))
6068 else if (unformat (i, "vrf %d", &vrf_id))
6070 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
6072 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
6076 clib_warning ("parse error '%U'", format_unformat_error, i);
6081 if (sw_if_index_set == 0)
6083 errmsg ("missing interface name or sw_if_index\n");
6086 if (v4_address_set && v6_address_set)
6088 errmsg ("both v4 and v6 addresses set\n");
6091 if (!v4_address_set && !v6_address_set)
6093 errmsg ("no address set\n");
6097 /* Construct the API message */
6098 M (IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del);
6100 mp->sw_if_index = ntohl (sw_if_index);
6101 mp->is_add = is_add;
6102 mp->vrf_id = ntohl (vrf_id);
6103 mp->is_static = is_static;
6105 clib_memcpy (mp->mac_address, mac_address, 6);
6109 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
6113 /* mp->is_ipv6 = 0; via memset in M macro above */
6114 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
6120 /* Wait for a reply, return good/bad news */
6128 api_reset_vrf (vat_main_t * vam)
6130 unformat_input_t *i = vam->input;
6131 vl_api_reset_vrf_t *mp;
6137 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6139 if (unformat (i, "vrf %d", &vrf_id))
6141 else if (unformat (i, "ipv6"))
6145 clib_warning ("parse error '%U'", format_unformat_error, i);
6150 if (vrf_id_set == 0)
6152 errmsg ("missing vrf id\n");
6156 M (RESET_VRF, reset_vrf);
6158 mp->vrf_id = ntohl (vrf_id);
6159 mp->is_ipv6 = is_ipv6;
6168 api_create_vlan_subif (vat_main_t * vam)
6170 unformat_input_t *i = vam->input;
6171 vl_api_create_vlan_subif_t *mp;
6174 u8 sw_if_index_set = 0;
6178 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6180 if (unformat (i, "sw_if_index %d", &sw_if_index))
6181 sw_if_index_set = 1;
6182 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6183 sw_if_index_set = 1;
6184 else if (unformat (i, "vlan %d", &vlan_id))
6188 clib_warning ("parse error '%U'", format_unformat_error, i);
6193 if (sw_if_index_set == 0)
6195 errmsg ("missing interface name or sw_if_index\n");
6199 if (vlan_id_set == 0)
6201 errmsg ("missing vlan_id\n");
6204 M (CREATE_VLAN_SUBIF, create_vlan_subif);
6206 mp->sw_if_index = ntohl (sw_if_index);
6207 mp->vlan_id = ntohl (vlan_id);
6215 #define foreach_create_subif_bit \
6222 _(outer_vlan_id_any) \
6223 _(inner_vlan_id_any)
6226 api_create_subif (vat_main_t * vam)
6228 unformat_input_t *i = vam->input;
6229 vl_api_create_subif_t *mp;
6232 u8 sw_if_index_set = 0;
6239 u32 exact_match = 0;
6240 u32 default_sub = 0;
6241 u32 outer_vlan_id_any = 0;
6242 u32 inner_vlan_id_any = 0;
6244 u16 outer_vlan_id = 0;
6245 u16 inner_vlan_id = 0;
6247 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6249 if (unformat (i, "sw_if_index %d", &sw_if_index))
6250 sw_if_index_set = 1;
6251 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6252 sw_if_index_set = 1;
6253 else if (unformat (i, "sub_id %d", &sub_id))
6255 else if (unformat (i, "outer_vlan_id %d", &tmp))
6256 outer_vlan_id = tmp;
6257 else if (unformat (i, "inner_vlan_id %d", &tmp))
6258 inner_vlan_id = tmp;
6260 #define _(a) else if (unformat (i, #a)) a = 1 ;
6261 foreach_create_subif_bit
6265 clib_warning ("parse error '%U'", format_unformat_error, i);
6270 if (sw_if_index_set == 0)
6272 errmsg ("missing interface name or sw_if_index\n");
6276 if (sub_id_set == 0)
6278 errmsg ("missing sub_id\n");
6281 M (CREATE_SUBIF, create_subif);
6283 mp->sw_if_index = ntohl (sw_if_index);
6284 mp->sub_id = ntohl (sub_id);
6286 #define _(a) mp->a = a;
6287 foreach_create_subif_bit;
6290 mp->outer_vlan_id = ntohs (outer_vlan_id);
6291 mp->inner_vlan_id = ntohs (inner_vlan_id);
6300 api_oam_add_del (vat_main_t * vam)
6302 unformat_input_t *i = vam->input;
6303 vl_api_oam_add_del_t *mp;
6307 ip4_address_t src, dst;
6311 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6313 if (unformat (i, "vrf %d", &vrf_id))
6315 else if (unformat (i, "src %U", unformat_ip4_address, &src))
6317 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
6319 else if (unformat (i, "del"))
6323 clib_warning ("parse error '%U'", format_unformat_error, i);
6330 errmsg ("missing src addr\n");
6336 errmsg ("missing dst addr\n");
6340 M (OAM_ADD_DEL, oam_add_del);
6342 mp->vrf_id = ntohl (vrf_id);
6343 mp->is_add = is_add;
6344 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
6345 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
6354 api_reset_fib (vat_main_t * vam)
6356 unformat_input_t *i = vam->input;
6357 vl_api_reset_fib_t *mp;
6363 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6365 if (unformat (i, "vrf %d", &vrf_id))
6367 else if (unformat (i, "ipv6"))
6371 clib_warning ("parse error '%U'", format_unformat_error, i);
6376 if (vrf_id_set == 0)
6378 errmsg ("missing vrf id\n");
6382 M (RESET_FIB, reset_fib);
6384 mp->vrf_id = ntohl (vrf_id);
6385 mp->is_ipv6 = is_ipv6;
6394 api_dhcp_proxy_config (vat_main_t * vam)
6396 unformat_input_t *i = vam->input;
6397 vl_api_dhcp_proxy_config_t *mp;
6402 u8 v4_address_set = 0;
6403 u8 v6_address_set = 0;
6404 ip4_address_t v4address;
6405 ip6_address_t v6address;
6406 u8 v4_src_address_set = 0;
6407 u8 v6_src_address_set = 0;
6408 ip4_address_t v4srcaddress;
6409 ip6_address_t v6srcaddress;
6411 /* Parse args required to build the message */
6412 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6414 if (unformat (i, "del"))
6416 else if (unformat (i, "vrf %d", &vrf_id))
6418 else if (unformat (i, "insert-cid %d", &insert_cid))
6420 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
6422 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
6424 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
6425 v4_src_address_set = 1;
6426 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
6427 v6_src_address_set = 1;
6432 if (v4_address_set && v6_address_set)
6434 errmsg ("both v4 and v6 server addresses set\n");
6437 if (!v4_address_set && !v6_address_set)
6439 errmsg ("no server addresses set\n");
6443 if (v4_src_address_set && v6_src_address_set)
6445 errmsg ("both v4 and v6 src addresses set\n");
6448 if (!v4_src_address_set && !v6_src_address_set)
6450 errmsg ("no src addresses set\n");
6454 if (!(v4_src_address_set && v4_address_set) &&
6455 !(v6_src_address_set && v6_address_set))
6457 errmsg ("no matching server and src addresses set\n");
6461 /* Construct the API message */
6462 M (DHCP_PROXY_CONFIG, dhcp_proxy_config);
6464 mp->insert_circuit_id = insert_cid;
6465 mp->is_add = is_add;
6466 mp->vrf_id = ntohl (vrf_id);
6470 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
6471 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
6475 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
6476 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
6482 /* Wait for a reply, return good/bad news */
6489 api_dhcp_proxy_config_2 (vat_main_t * vam)
6491 unformat_input_t *i = vam->input;
6492 vl_api_dhcp_proxy_config_2_t *mp;
6495 u32 server_vrf_id = 0;
6498 u8 v4_address_set = 0;
6499 u8 v6_address_set = 0;
6500 ip4_address_t v4address;
6501 ip6_address_t v6address;
6502 u8 v4_src_address_set = 0;
6503 u8 v6_src_address_set = 0;
6504 ip4_address_t v4srcaddress;
6505 ip6_address_t v6srcaddress;
6507 /* Parse args required to build the message */
6508 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6510 if (unformat (i, "del"))
6512 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
6514 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
6516 else if (unformat (i, "insert-cid %d", &insert_cid))
6518 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
6520 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
6522 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
6523 v4_src_address_set = 1;
6524 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
6525 v6_src_address_set = 1;
6530 if (v4_address_set && v6_address_set)
6532 errmsg ("both v4 and v6 server addresses set\n");
6535 if (!v4_address_set && !v6_address_set)
6537 errmsg ("no server addresses set\n");
6541 if (v4_src_address_set && v6_src_address_set)
6543 errmsg ("both v4 and v6 src addresses set\n");
6546 if (!v4_src_address_set && !v6_src_address_set)
6548 errmsg ("no src addresses set\n");
6552 if (!(v4_src_address_set && v4_address_set) &&
6553 !(v6_src_address_set && v6_address_set))
6555 errmsg ("no matching server and src addresses set\n");
6559 /* Construct the API message */
6560 M (DHCP_PROXY_CONFIG_2, dhcp_proxy_config_2);
6562 mp->insert_circuit_id = insert_cid;
6563 mp->is_add = is_add;
6564 mp->rx_vrf_id = ntohl (rx_vrf_id);
6565 mp->server_vrf_id = ntohl (server_vrf_id);
6569 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
6570 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
6574 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
6575 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
6581 /* Wait for a reply, return good/bad news */
6588 api_dhcp_proxy_set_vss (vat_main_t * vam)
6590 unformat_input_t *i = vam->input;
6591 vl_api_dhcp_proxy_set_vss_t *mp;
6602 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6604 if (unformat (i, "tbl_id %d", &tbl_id))
6606 if (unformat (i, "fib_id %d", &fib_id))
6608 if (unformat (i, "oui %d", &oui))
6610 else if (unformat (i, "ipv6"))
6612 else if (unformat (i, "del"))
6616 clib_warning ("parse error '%U'", format_unformat_error, i);
6621 if (tbl_id_set == 0)
6623 errmsg ("missing tbl id\n");
6627 if (fib_id_set == 0)
6629 errmsg ("missing fib id\n");
6634 errmsg ("missing oui\n");
6638 M (DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss);
6639 mp->tbl_id = ntohl (tbl_id);
6640 mp->fib_id = ntohl (fib_id);
6641 mp->oui = ntohl (oui);
6642 mp->is_ipv6 = is_ipv6;
6643 mp->is_add = is_add;
6652 api_dhcp_client_config (vat_main_t * vam)
6654 unformat_input_t *i = vam->input;
6655 vl_api_dhcp_client_config_t *mp;
6658 u8 sw_if_index_set = 0;
6661 u8 disable_event = 0;
6663 /* Parse args required to build the message */
6664 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6666 if (unformat (i, "del"))
6668 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6669 sw_if_index_set = 1;
6670 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6671 sw_if_index_set = 1;
6672 else if (unformat (i, "hostname %s", &hostname))
6674 else if (unformat (i, "disable_event"))
6680 if (sw_if_index_set == 0)
6682 errmsg ("missing interface name or sw_if_index\n");
6686 if (vec_len (hostname) > 63)
6688 errmsg ("hostname too long\n");
6690 vec_add1 (hostname, 0);
6692 /* Construct the API message */
6693 M (DHCP_CLIENT_CONFIG, dhcp_client_config);
6695 mp->sw_if_index = ntohl (sw_if_index);
6696 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
6697 vec_free (hostname);
6698 mp->is_add = is_add;
6699 mp->want_dhcp_event = disable_event ? 0 : 1;
6700 mp->pid = getpid ();
6705 /* Wait for a reply, return good/bad news */
6712 api_set_ip_flow_hash (vat_main_t * vam)
6714 unformat_input_t *i = vam->input;
6715 vl_api_set_ip_flow_hash_t *mp;
6727 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6729 if (unformat (i, "vrf %d", &vrf_id))
6731 else if (unformat (i, "ipv6"))
6733 else if (unformat (i, "src"))
6735 else if (unformat (i, "dst"))
6737 else if (unformat (i, "sport"))
6739 else if (unformat (i, "dport"))
6741 else if (unformat (i, "proto"))
6743 else if (unformat (i, "reverse"))
6748 clib_warning ("parse error '%U'", format_unformat_error, i);
6753 if (vrf_id_set == 0)
6755 errmsg ("missing vrf id\n");
6759 M (SET_IP_FLOW_HASH, set_ip_flow_hash);
6765 mp->reverse = reverse;
6766 mp->vrf_id = ntohl (vrf_id);
6767 mp->is_ipv6 = is_ipv6;
6776 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
6778 unformat_input_t *i = vam->input;
6779 vl_api_sw_interface_ip6_enable_disable_t *mp;
6782 u8 sw_if_index_set = 0;
6785 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6787 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6788 sw_if_index_set = 1;
6789 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6790 sw_if_index_set = 1;
6791 else if (unformat (i, "enable"))
6793 else if (unformat (i, "disable"))
6797 clib_warning ("parse error '%U'", format_unformat_error, i);
6802 if (sw_if_index_set == 0)
6804 errmsg ("missing interface name or sw_if_index\n");
6808 M (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable);
6810 mp->sw_if_index = ntohl (sw_if_index);
6811 mp->enable = enable;
6820 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
6822 unformat_input_t *i = vam->input;
6823 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
6826 u8 sw_if_index_set = 0;
6827 u32 address_length = 0;
6828 u8 v6_address_set = 0;
6829 ip6_address_t v6address;
6831 /* Parse args required to build the message */
6832 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6834 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6835 sw_if_index_set = 1;
6836 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6837 sw_if_index_set = 1;
6838 else if (unformat (i, "%U/%d",
6839 unformat_ip6_address, &v6address, &address_length))
6845 if (sw_if_index_set == 0)
6847 errmsg ("missing interface name or sw_if_index\n");
6850 if (!v6_address_set)
6852 errmsg ("no address set\n");
6856 /* Construct the API message */
6857 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,
6858 sw_interface_ip6_set_link_local_address);
6860 mp->sw_if_index = ntohl (sw_if_index);
6861 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6862 mp->address_length = address_length;
6867 /* Wait for a reply, return good/bad news */
6876 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
6878 unformat_input_t *i = vam->input;
6879 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
6882 u8 sw_if_index_set = 0;
6883 u32 address_length = 0;
6884 u8 v6_address_set = 0;
6885 ip6_address_t v6address;
6887 u8 no_advertise = 0;
6889 u8 no_autoconfig = 0;
6892 u32 val_lifetime = 0;
6893 u32 pref_lifetime = 0;
6895 /* Parse args required to build the message */
6896 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6898 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6899 sw_if_index_set = 1;
6900 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6901 sw_if_index_set = 1;
6902 else if (unformat (i, "%U/%d",
6903 unformat_ip6_address, &v6address, &address_length))
6905 else if (unformat (i, "val_life %d", &val_lifetime))
6907 else if (unformat (i, "pref_life %d", &pref_lifetime))
6909 else if (unformat (i, "def"))
6911 else if (unformat (i, "noadv"))
6913 else if (unformat (i, "offl"))
6915 else if (unformat (i, "noauto"))
6917 else if (unformat (i, "nolink"))
6919 else if (unformat (i, "isno"))
6923 clib_warning ("parse error '%U'", format_unformat_error, i);
6928 if (sw_if_index_set == 0)
6930 errmsg ("missing interface name or sw_if_index\n");
6933 if (!v6_address_set)
6935 errmsg ("no address set\n");
6939 /* Construct the API message */
6940 M (SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix);
6942 mp->sw_if_index = ntohl (sw_if_index);
6943 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6944 mp->address_length = address_length;
6945 mp->use_default = use_default;
6946 mp->no_advertise = no_advertise;
6947 mp->off_link = off_link;
6948 mp->no_autoconfig = no_autoconfig;
6949 mp->no_onlink = no_onlink;
6951 mp->val_lifetime = ntohl (val_lifetime);
6952 mp->pref_lifetime = ntohl (pref_lifetime);
6957 /* Wait for a reply, return good/bad news */
6965 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
6967 unformat_input_t *i = vam->input;
6968 vl_api_sw_interface_ip6nd_ra_config_t *mp;
6971 u8 sw_if_index_set = 0;
6976 u8 send_unicast = 0;
6979 u8 default_router = 0;
6980 u32 max_interval = 0;
6981 u32 min_interval = 0;
6983 u32 initial_count = 0;
6984 u32 initial_interval = 0;
6987 /* Parse args required to build the message */
6988 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6990 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6991 sw_if_index_set = 1;
6992 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6993 sw_if_index_set = 1;
6994 else if (unformat (i, "maxint %d", &max_interval))
6996 else if (unformat (i, "minint %d", &min_interval))
6998 else if (unformat (i, "life %d", &lifetime))
7000 else if (unformat (i, "count %d", &initial_count))
7002 else if (unformat (i, "interval %d", &initial_interval))
7004 else if (unformat (i, "suppress") || unformat (i, "surpress"))
7006 else if (unformat (i, "managed"))
7008 else if (unformat (i, "other"))
7010 else if (unformat (i, "ll"))
7012 else if (unformat (i, "send"))
7014 else if (unformat (i, "cease"))
7016 else if (unformat (i, "isno"))
7018 else if (unformat (i, "def"))
7022 clib_warning ("parse error '%U'", format_unformat_error, i);
7027 if (sw_if_index_set == 0)
7029 errmsg ("missing interface name or sw_if_index\n");
7033 /* Construct the API message */
7034 M (SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config);
7036 mp->sw_if_index = ntohl (sw_if_index);
7037 mp->max_interval = ntohl (max_interval);
7038 mp->min_interval = ntohl (min_interval);
7039 mp->lifetime = ntohl (lifetime);
7040 mp->initial_count = ntohl (initial_count);
7041 mp->initial_interval = ntohl (initial_interval);
7042 mp->suppress = suppress;
7043 mp->managed = managed;
7045 mp->ll_option = ll_option;
7046 mp->send_unicast = send_unicast;
7049 mp->default_router = default_router;
7054 /* Wait for a reply, return good/bad news */
7062 api_set_arp_neighbor_limit (vat_main_t * vam)
7064 unformat_input_t *i = vam->input;
7065 vl_api_set_arp_neighbor_limit_t *mp;
7071 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7073 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
7075 else if (unformat (i, "ipv6"))
7079 clib_warning ("parse error '%U'", format_unformat_error, i);
7086 errmsg ("missing limit value\n");
7090 M (SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit);
7092 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
7093 mp->is_ipv6 = is_ipv6;
7102 api_l2_patch_add_del (vat_main_t * vam)
7104 unformat_input_t *i = vam->input;
7105 vl_api_l2_patch_add_del_t *mp;
7108 u8 rx_sw_if_index_set = 0;
7110 u8 tx_sw_if_index_set = 0;
7113 /* Parse args required to build the message */
7114 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7116 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7117 rx_sw_if_index_set = 1;
7118 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7119 tx_sw_if_index_set = 1;
7120 else if (unformat (i, "rx"))
7122 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7124 if (unformat (i, "%U", unformat_sw_if_index, vam,
7126 rx_sw_if_index_set = 1;
7131 else if (unformat (i, "tx"))
7133 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7135 if (unformat (i, "%U", unformat_sw_if_index, vam,
7137 tx_sw_if_index_set = 1;
7142 else if (unformat (i, "del"))
7148 if (rx_sw_if_index_set == 0)
7150 errmsg ("missing rx interface name or rx_sw_if_index\n");
7154 if (tx_sw_if_index_set == 0)
7156 errmsg ("missing tx interface name or tx_sw_if_index\n");
7160 M (L2_PATCH_ADD_DEL, l2_patch_add_del);
7162 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7163 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7164 mp->is_add = is_add;
7173 api_ioam_enable (vat_main_t * vam)
7175 unformat_input_t *input = vam->input;
7176 vl_api_ioam_enable_t *mp;
7179 int has_trace_option = 0;
7180 int has_pow_option = 0;
7181 int has_ppc_option = 0;
7183 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7185 if (unformat (input, "trace"))
7186 has_trace_option = 1;
7187 else if (unformat (input, "pow"))
7189 else if (unformat (input, "ppc encap"))
7190 has_ppc_option = PPC_ENCAP;
7191 else if (unformat (input, "ppc decap"))
7192 has_ppc_option = PPC_DECAP;
7193 else if (unformat (input, "ppc none"))
7194 has_ppc_option = PPC_NONE;
7198 M (IOAM_ENABLE, ioam_enable);
7199 mp->id = htons (id);
7200 mp->trace_ppc = has_ppc_option;
7201 mp->pow_enable = has_pow_option;
7202 mp->trace_enable = has_trace_option;
7213 api_ioam_disable (vat_main_t * vam)
7215 vl_api_ioam_disable_t *mp;
7218 M (IOAM_DISABLE, ioam_disable);
7225 api_sr_tunnel_add_del (vat_main_t * vam)
7227 unformat_input_t *i = vam->input;
7228 vl_api_sr_tunnel_add_del_t *mp;
7232 ip6_address_t src_address;
7233 int src_address_set = 0;
7234 ip6_address_t dst_address;
7236 int dst_address_set = 0;
7238 u32 rx_table_id = 0;
7239 u32 tx_table_id = 0;
7240 ip6_address_t *segments = 0;
7241 ip6_address_t *this_seg;
7242 ip6_address_t *tags = 0;
7243 ip6_address_t *this_tag;
7244 ip6_address_t next_address, tag;
7246 u8 *policy_name = 0;
7248 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7250 if (unformat (i, "del"))
7252 else if (unformat (i, "name %s", &name))
7254 else if (unformat (i, "policy %s", &policy_name))
7256 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
7258 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
7260 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
7261 src_address_set = 1;
7262 else if (unformat (i, "dst %U/%d",
7263 unformat_ip6_address, &dst_address, &dst_mask_width))
7264 dst_address_set = 1;
7265 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
7267 vec_add2 (segments, this_seg, 1);
7268 clib_memcpy (this_seg->as_u8, next_address.as_u8,
7269 sizeof (*this_seg));
7271 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
7273 vec_add2 (tags, this_tag, 1);
7274 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
7276 else if (unformat (i, "clean"))
7277 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
7278 else if (unformat (i, "protected"))
7279 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
7280 else if (unformat (i, "InPE %d", &pl_index))
7282 if (pl_index <= 0 || pl_index > 4)
7284 pl_index_range_error:
7285 errmsg ("pl index %d out of range\n", pl_index);
7289 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
7291 else if (unformat (i, "EgPE %d", &pl_index))
7293 if (pl_index <= 0 || pl_index > 4)
7294 goto pl_index_range_error;
7296 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
7298 else if (unformat (i, "OrgSrc %d", &pl_index))
7300 if (pl_index <= 0 || pl_index > 4)
7301 goto pl_index_range_error;
7303 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
7309 if (!src_address_set)
7311 errmsg ("src address required\n");
7315 if (!dst_address_set)
7317 errmsg ("dst address required\n");
7323 errmsg ("at least one sr segment required\n");
7327 M2 (SR_TUNNEL_ADD_DEL, sr_tunnel_add_del,
7328 vec_len (segments) * sizeof (ip6_address_t)
7329 + vec_len (tags) * sizeof (ip6_address_t));
7331 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
7332 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
7333 mp->dst_mask_width = dst_mask_width;
7334 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
7335 mp->n_segments = vec_len (segments);
7336 mp->n_tags = vec_len (tags);
7337 mp->is_add = is_del == 0;
7338 clib_memcpy (mp->segs_and_tags, segments,
7339 vec_len (segments) * sizeof (ip6_address_t));
7340 clib_memcpy (mp->segs_and_tags +
7341 vec_len (segments) * sizeof (ip6_address_t), tags,
7342 vec_len (tags) * sizeof (ip6_address_t));
7344 mp->outer_vrf_id = ntohl (rx_table_id);
7345 mp->inner_vrf_id = ntohl (tx_table_id);
7346 memcpy (mp->name, name, vec_len (name));
7347 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
7349 vec_free (segments);
7358 api_sr_policy_add_del (vat_main_t * vam)
7360 unformat_input_t *input = vam->input;
7361 vl_api_sr_policy_add_del_t *mp;
7365 u8 *tunnel_name = 0;
7366 u8 **tunnel_names = 0;
7371 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
7372 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
7374 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7376 if (unformat (input, "del"))
7378 else if (unformat (input, "name %s", &name))
7380 else if (unformat (input, "tunnel %s", &tunnel_name))
7384 vec_add1 (tunnel_names, tunnel_name);
7386 - length = #bytes to store in serial vector
7387 - +1 = byte to store that length
7389 tunnel_names_length += (vec_len (tunnel_name) + 1);
7400 errmsg ("policy name required\n");
7404 if ((!tunnel_set) && (!is_del))
7406 errmsg ("tunnel name required\n");
7410 M2 (SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length);
7414 mp->is_add = !is_del;
7416 memcpy (mp->name, name, vec_len (name));
7417 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
7418 u8 *serial_orig = 0;
7419 vec_validate (serial_orig, tunnel_names_length);
7420 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
7421 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
7423 for (j = 0; j < vec_len (tunnel_names); j++)
7425 tun_name_len = vec_len (tunnel_names[j]);
7426 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
7427 serial_orig += 1; // Move along one byte to store the actual tunnel name
7428 memcpy (serial_orig, tunnel_names[j], tun_name_len);
7429 serial_orig += tun_name_len; // Advance past the copy
7431 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
7433 vec_free (tunnel_names);
7434 vec_free (tunnel_name);
7442 api_sr_multicast_map_add_del (vat_main_t * vam)
7444 unformat_input_t *input = vam->input;
7445 vl_api_sr_multicast_map_add_del_t *mp;
7448 ip6_address_t multicast_address;
7449 u8 *policy_name = 0;
7450 int multicast_address_set = 0;
7452 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7454 if (unformat (input, "del"))
7458 (input, "address %U", unformat_ip6_address, &multicast_address))
7459 multicast_address_set = 1;
7460 else if (unformat (input, "sr-policy %s", &policy_name))
7466 if (!is_del && !policy_name)
7468 errmsg ("sr-policy name required\n");
7473 if (!multicast_address_set)
7475 errmsg ("address required\n");
7479 M (SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del);
7481 mp->is_add = !is_del;
7482 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
7483 clib_memcpy (mp->multicast_address, &multicast_address,
7484 sizeof (mp->multicast_address));
7487 vec_free (policy_name);
7495 #define foreach_ip4_proto_field \
7506 unformat_ip4_mask (unformat_input_t * input, va_list * args)
7508 u8 **maskp = va_arg (*args, u8 **);
7510 u8 found_something = 0;
7513 #define _(a) u8 a=0;
7514 foreach_ip4_proto_field;
7520 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7522 if (unformat (input, "version"))
7524 else if (unformat (input, "hdr_length"))
7526 else if (unformat (input, "src"))
7528 else if (unformat (input, "dst"))
7530 else if (unformat (input, "proto"))
7533 #define _(a) else if (unformat (input, #a)) a=1;
7534 foreach_ip4_proto_field
7540 #define _(a) found_something += a;
7541 foreach_ip4_proto_field;
7544 if (found_something == 0)
7547 vec_validate (mask, sizeof (*ip) - 1);
7549 ip = (ip4_header_t *) mask;
7551 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
7552 foreach_ip4_proto_field;
7555 ip->ip_version_and_header_length = 0;
7558 ip->ip_version_and_header_length |= 0xF0;
7561 ip->ip_version_and_header_length |= 0x0F;
7567 #define foreach_ip6_proto_field \
7575 unformat_ip6_mask (unformat_input_t * input, va_list * args)
7577 u8 **maskp = va_arg (*args, u8 **);
7579 u8 found_something = 0;
7581 u32 ip_version_traffic_class_and_flow_label;
7583 #define _(a) u8 a=0;
7584 foreach_ip6_proto_field;
7587 u8 traffic_class = 0;
7590 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7592 if (unformat (input, "version"))
7594 else if (unformat (input, "traffic-class"))
7596 else if (unformat (input, "flow-label"))
7598 else if (unformat (input, "src"))
7600 else if (unformat (input, "dst"))
7602 else if (unformat (input, "proto"))
7605 #define _(a) else if (unformat (input, #a)) a=1;
7606 foreach_ip6_proto_field
7612 #define _(a) found_something += a;
7613 foreach_ip6_proto_field;
7616 if (found_something == 0)
7619 vec_validate (mask, sizeof (*ip) - 1);
7621 ip = (ip6_header_t *) mask;
7623 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
7624 foreach_ip6_proto_field;
7627 ip_version_traffic_class_and_flow_label = 0;
7630 ip_version_traffic_class_and_flow_label |= 0xF0000000;
7633 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
7636 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
7638 ip->ip_version_traffic_class_and_flow_label =
7639 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
7646 unformat_l3_mask (unformat_input_t * input, va_list * args)
7648 u8 **maskp = va_arg (*args, u8 **);
7650 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7652 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
7654 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
7663 unformat_l2_mask (unformat_input_t * input, va_list * args)
7665 u8 **maskp = va_arg (*args, u8 **);
7680 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7682 if (unformat (input, "src"))
7684 else if (unformat (input, "dst"))
7686 else if (unformat (input, "proto"))
7688 else if (unformat (input, "tag1"))
7690 else if (unformat (input, "tag2"))
7692 else if (unformat (input, "ignore-tag1"))
7694 else if (unformat (input, "ignore-tag2"))
7696 else if (unformat (input, "cos1"))
7698 else if (unformat (input, "cos2"))
7700 else if (unformat (input, "dot1q"))
7702 else if (unformat (input, "dot1ad"))
7707 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
7708 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
7711 if (tag1 || ignore_tag1 || cos1 || dot1q)
7713 if (tag2 || ignore_tag2 || cos2 || dot1ad)
7716 vec_validate (mask, len - 1);
7719 memset (mask, 0xff, 6);
7722 memset (mask + 6, 0xff, 6);
7726 /* inner vlan tag */
7735 mask[21] = mask[20] = 0xff;
7756 mask[16] = mask[17] = 0xff;
7766 mask[12] = mask[13] = 0xff;
7773 unformat_classify_mask (unformat_input_t * input, va_list * args)
7775 u8 **maskp = va_arg (*args, u8 **);
7776 u32 *skipp = va_arg (*args, u32 *);
7777 u32 *matchp = va_arg (*args, u32 *);
7784 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7786 if (unformat (input, "hex %U", unformat_hex_string, &mask))
7788 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
7790 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
7796 if (mask || l2 || l3)
7800 /* "With a free Ethernet header in every package" */
7802 vec_validate (l2, 13);
7806 vec_append (mask, l3);
7811 /* Scan forward looking for the first significant mask octet */
7812 for (i = 0; i < vec_len (mask); i++)
7816 /* compute (skip, match) params */
7817 *skipp = i / sizeof (u32x4);
7818 vec_delete (mask, *skipp * sizeof (u32x4), 0);
7820 /* Pad mask to an even multiple of the vector size */
7821 while (vec_len (mask) % sizeof (u32x4))
7824 match = vec_len (mask) / sizeof (u32x4);
7826 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
7828 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
7829 if (*tmp || *(tmp + 1))
7834 clib_warning ("BUG: match 0");
7836 _vec_len (mask) = match * sizeof (u32x4);
7847 #define foreach_l2_next \
7849 _(ethernet, ETHERNET_INPUT) \
7854 unformat_l2_next_index (unformat_input_t * input, va_list * args)
7856 u32 *miss_next_indexp = va_arg (*args, u32 *);
7861 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
7865 if (unformat (input, "%d", &tmp))
7874 *miss_next_indexp = next_index;
7878 #define foreach_ip_next \
7885 unformat_ip_next_index (unformat_input_t * input, va_list * args)
7887 u32 *miss_next_indexp = va_arg (*args, u32 *);
7892 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
7896 if (unformat (input, "%d", &tmp))
7905 *miss_next_indexp = next_index;
7909 #define foreach_acl_next \
7913 unformat_acl_next_index (unformat_input_t * input, va_list * args)
7915 u32 *miss_next_indexp = va_arg (*args, u32 *);
7920 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
7924 if (unformat (input, "permit"))
7929 else if (unformat (input, "%d", &tmp))
7938 *miss_next_indexp = next_index;
7943 unformat_policer_precolor (unformat_input_t * input, va_list * args)
7945 u32 *r = va_arg (*args, u32 *);
7947 if (unformat (input, "conform-color"))
7948 *r = POLICE_CONFORM;
7949 else if (unformat (input, "exceed-color"))
7958 api_classify_add_del_table (vat_main_t * vam)
7960 unformat_input_t *i = vam->input;
7961 vl_api_classify_add_del_table_t *mp;
7967 u32 table_index = ~0;
7968 u32 next_table_index = ~0;
7969 u32 miss_next_index = ~0;
7970 u32 memory_size = 32 << 20;
7974 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7976 if (unformat (i, "del"))
7978 else if (unformat (i, "buckets %d", &nbuckets))
7980 else if (unformat (i, "memory_size %d", &memory_size))
7982 else if (unformat (i, "skip %d", &skip))
7984 else if (unformat (i, "match %d", &match))
7986 else if (unformat (i, "table %d", &table_index))
7988 else if (unformat (i, "mask %U", unformat_classify_mask,
7989 &mask, &skip, &match))
7991 else if (unformat (i, "next-table %d", &next_table_index))
7993 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
7996 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
7999 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
8006 if (is_add && mask == 0)
8008 errmsg ("Mask required\n");
8012 if (is_add && skip == ~0)
8014 errmsg ("skip count required\n");
8018 if (is_add && match == ~0)
8020 errmsg ("match count required\n");
8024 if (!is_add && table_index == ~0)
8026 errmsg ("table index required for delete\n");
8030 M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask));
8032 mp->is_add = is_add;
8033 mp->table_index = ntohl (table_index);
8034 mp->nbuckets = ntohl (nbuckets);
8035 mp->memory_size = ntohl (memory_size);
8036 mp->skip_n_vectors = ntohl (skip);
8037 mp->match_n_vectors = ntohl (match);
8038 mp->next_table_index = ntohl (next_table_index);
8039 mp->miss_next_index = ntohl (miss_next_index);
8040 clib_memcpy (mp->mask, mask, vec_len (mask));
8050 unformat_ip4_match (unformat_input_t * input, va_list * args)
8052 u8 **matchp = va_arg (*args, u8 **);
8059 int src = 0, dst = 0;
8060 ip4_address_t src_val, dst_val;
8067 int fragment_id = 0;
8068 u32 fragment_id_val;
8074 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8076 if (unformat (input, "version %d", &version_val))
8078 else if (unformat (input, "hdr_length %d", &hdr_length_val))
8080 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
8082 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
8084 else if (unformat (input, "proto %d", &proto_val))
8086 else if (unformat (input, "tos %d", &tos_val))
8088 else if (unformat (input, "length %d", &length_val))
8090 else if (unformat (input, "fragment_id %d", &fragment_id_val))
8092 else if (unformat (input, "ttl %d", &ttl_val))
8094 else if (unformat (input, "checksum %d", &checksum_val))
8100 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
8101 + ttl + checksum == 0)
8105 * Aligned because we use the real comparison functions
8107 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
8109 ip = (ip4_header_t *) match;
8111 /* These are realistically matched in practice */
8113 ip->src_address.as_u32 = src_val.as_u32;
8116 ip->dst_address.as_u32 = dst_val.as_u32;
8119 ip->protocol = proto_val;
8122 /* These are not, but they're included for completeness */
8124 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
8127 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
8133 ip->length = length_val;
8139 ip->checksum = checksum_val;
8146 unformat_ip6_match (unformat_input_t * input, va_list * args)
8148 u8 **matchp = va_arg (*args, u8 **);
8153 u8 traffic_class = 0;
8154 u32 traffic_class_val = 0;
8157 int src = 0, dst = 0;
8158 ip6_address_t src_val, dst_val;
8161 int payload_length = 0;
8162 u32 payload_length_val;
8165 u32 ip_version_traffic_class_and_flow_label;
8167 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8169 if (unformat (input, "version %d", &version_val))
8171 else if (unformat (input, "traffic_class %d", &traffic_class_val))
8173 else if (unformat (input, "flow_label %d", &flow_label_val))
8175 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
8177 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
8179 else if (unformat (input, "proto %d", &proto_val))
8181 else if (unformat (input, "payload_length %d", &payload_length_val))
8183 else if (unformat (input, "hop_limit %d", &hop_limit_val))
8189 if (version + traffic_class + flow_label + src + dst + proto +
8190 payload_length + hop_limit == 0)
8194 * Aligned because we use the real comparison functions
8196 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
8198 ip = (ip6_header_t *) match;
8201 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
8204 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
8207 ip->protocol = proto_val;
8209 ip_version_traffic_class_and_flow_label = 0;
8212 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
8215 ip_version_traffic_class_and_flow_label |=
8216 (traffic_class_val & 0xFF) << 20;
8219 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
8221 ip->ip_version_traffic_class_and_flow_label =
8222 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8225 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
8228 ip->hop_limit = hop_limit_val;
8235 unformat_l3_match (unformat_input_t * input, va_list * args)
8237 u8 **matchp = va_arg (*args, u8 **);
8239 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8241 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
8243 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
8252 unformat_vlan_tag (unformat_input_t * input, va_list * args)
8254 u8 *tagp = va_arg (*args, u8 *);
8257 if (unformat (input, "%d", &tag))
8259 tagp[0] = (tag >> 8) & 0x0F;
8260 tagp[1] = tag & 0xFF;
8268 unformat_l2_match (unformat_input_t * input, va_list * args)
8270 u8 **matchp = va_arg (*args, u8 **);
8290 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8292 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
8295 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
8297 else if (unformat (input, "proto %U",
8298 unformat_ethernet_type_host_byte_order, &proto_val))
8300 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
8302 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
8304 else if (unformat (input, "ignore-tag1"))
8306 else if (unformat (input, "ignore-tag2"))
8308 else if (unformat (input, "cos1 %d", &cos1_val))
8310 else if (unformat (input, "cos2 %d", &cos2_val))
8315 if ((src + dst + proto + tag1 + tag2 +
8316 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8319 if (tag1 || ignore_tag1 || cos1)
8321 if (tag2 || ignore_tag2 || cos2)
8324 vec_validate_aligned (match, len - 1, sizeof (u32x4));
8327 clib_memcpy (match, dst_val, 6);
8330 clib_memcpy (match + 6, src_val, 6);
8334 /* inner vlan tag */
8335 match[19] = tag2_val[1];
8336 match[18] = tag2_val[0];
8338 match[18] |= (cos2_val & 0x7) << 5;
8341 match[21] = proto_val & 0xff;
8342 match[20] = proto_val >> 8;
8346 match[15] = tag1_val[1];
8347 match[14] = tag1_val[0];
8350 match[14] |= (cos1_val & 0x7) << 5;
8356 match[15] = tag1_val[1];
8357 match[14] = tag1_val[0];
8360 match[17] = proto_val & 0xff;
8361 match[16] = proto_val >> 8;
8364 match[14] |= (cos1_val & 0x7) << 5;
8370 match[18] |= (cos2_val & 0x7) << 5;
8372 match[14] |= (cos1_val & 0x7) << 5;
8375 match[13] = proto_val & 0xff;
8376 match[12] = proto_val >> 8;
8385 unformat_classify_match (unformat_input_t * input, va_list * args)
8387 u8 **matchp = va_arg (*args, u8 **);
8388 u32 skip_n_vectors = va_arg (*args, u32);
8389 u32 match_n_vectors = va_arg (*args, u32);
8395 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8397 if (unformat (input, "hex %U", unformat_hex_string, &match))
8399 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
8401 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
8407 if (match || l2 || l3)
8411 /* "Win a free Ethernet header in every packet" */
8413 vec_validate_aligned (l2, 13, sizeof (u32x4));
8417 vec_append_aligned (match, l3, sizeof (u32x4));
8422 /* Make sure the vector is big enough even if key is all 0's */
8423 vec_validate_aligned
8424 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
8427 /* Set size, include skipped vectors */
8428 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
8439 api_classify_add_del_session (vat_main_t * vam)
8441 unformat_input_t *i = vam->input;
8442 vl_api_classify_add_del_session_t *mp;
8444 u32 table_index = ~0;
8445 u32 hit_next_index = ~0;
8446 u32 opaque_index = ~0;
8450 u32 skip_n_vectors = 0;
8451 u32 match_n_vectors = 0;
8454 * Warning: you have to supply skip_n and match_n
8455 * because the API client cant simply look at the classify
8459 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8461 if (unformat (i, "del"))
8463 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
8466 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
8469 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
8472 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
8474 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
8476 else if (unformat (i, "opaque-index %d", &opaque_index))
8478 else if (unformat (i, "skip_n %d", &skip_n_vectors))
8480 else if (unformat (i, "match_n %d", &match_n_vectors))
8482 else if (unformat (i, "match %U", unformat_classify_match,
8483 &match, skip_n_vectors, match_n_vectors))
8485 else if (unformat (i, "advance %d", &advance))
8487 else if (unformat (i, "table-index %d", &table_index))
8493 if (table_index == ~0)
8495 errmsg ("Table index required\n");
8499 if (is_add && match == 0)
8501 errmsg ("Match value required\n");
8505 M2 (CLASSIFY_ADD_DEL_SESSION, classify_add_del_session, vec_len (match));
8507 mp->is_add = is_add;
8508 mp->table_index = ntohl (table_index);
8509 mp->hit_next_index = ntohl (hit_next_index);
8510 mp->opaque_index = ntohl (opaque_index);
8511 mp->advance = ntohl (advance);
8512 clib_memcpy (mp->match, match, vec_len (match));
8521 api_classify_set_interface_ip_table (vat_main_t * vam)
8523 unformat_input_t *i = vam->input;
8524 vl_api_classify_set_interface_ip_table_t *mp;
8527 int sw_if_index_set;
8528 u32 table_index = ~0;
8531 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8533 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8534 sw_if_index_set = 1;
8535 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8536 sw_if_index_set = 1;
8537 else if (unformat (i, "table %d", &table_index))
8541 clib_warning ("parse error '%U'", format_unformat_error, i);
8546 if (sw_if_index_set == 0)
8548 errmsg ("missing interface name or sw_if_index\n");
8553 M (CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table);
8555 mp->sw_if_index = ntohl (sw_if_index);
8556 mp->table_index = ntohl (table_index);
8557 mp->is_ipv6 = is_ipv6;
8566 api_classify_set_interface_l2_tables (vat_main_t * vam)
8568 unformat_input_t *i = vam->input;
8569 vl_api_classify_set_interface_l2_tables_t *mp;
8572 int sw_if_index_set;
8573 u32 ip4_table_index = ~0;
8574 u32 ip6_table_index = ~0;
8575 u32 other_table_index = ~0;
8578 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8580 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8581 sw_if_index_set = 1;
8582 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8583 sw_if_index_set = 1;
8584 else if (unformat (i, "ip4-table %d", &ip4_table_index))
8586 else if (unformat (i, "ip6-table %d", &ip6_table_index))
8588 else if (unformat (i, "other-table %d", &other_table_index))
8590 else if (unformat (i, "is-input %d", &is_input))
8594 clib_warning ("parse error '%U'", format_unformat_error, i);
8599 if (sw_if_index_set == 0)
8601 errmsg ("missing interface name or sw_if_index\n");
8606 M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables);
8608 mp->sw_if_index = ntohl (sw_if_index);
8609 mp->ip4_table_index = ntohl (ip4_table_index);
8610 mp->ip6_table_index = ntohl (ip6_table_index);
8611 mp->other_table_index = ntohl (other_table_index);
8612 mp->is_input = (u8) is_input;
8621 api_ipfix_enable (vat_main_t * vam)
8623 unformat_input_t *i = vam->input;
8624 vl_api_ipfix_enable_t *mp;
8625 ip4_address_t collector_address;
8626 u8 collector_address_set = 0;
8627 u32 collector_port = ~0;
8628 ip4_address_t src_address;
8629 u8 src_address_set = 0;
8632 u32 template_interval = ~0;
8635 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8637 if (unformat (i, "collector_address %U", unformat_ip4_address,
8638 &collector_address))
8639 collector_address_set = 1;
8640 else if (unformat (i, "collector_port %d", &collector_port))
8642 else if (unformat (i, "src_address %U", unformat_ip4_address,
8644 src_address_set = 1;
8645 else if (unformat (i, "vrf_id %d", &vrf_id))
8647 else if (unformat (i, "path_mtu %d", &path_mtu))
8649 else if (unformat (i, "template_interval %d", &template_interval))
8655 if (collector_address_set == 0)
8657 errmsg ("collector_address required\n");
8661 if (src_address_set == 0)
8663 errmsg ("src_address required\n");
8667 M (IPFIX_ENABLE, ipfix_enable);
8669 memcpy (mp->collector_address, collector_address.data,
8670 sizeof (collector_address.data));
8671 mp->collector_port = htons ((u16) collector_port);
8672 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
8673 mp->vrf_id = htonl (vrf_id);
8674 mp->path_mtu = htonl (path_mtu);
8675 mp->template_interval = htonl (template_interval);
8683 api_get_node_index (vat_main_t * vam)
8685 unformat_input_t *i = vam->input;
8686 vl_api_get_node_index_t *mp;
8690 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8692 if (unformat (i, "node %s", &name))
8699 errmsg ("node name required\n");
8702 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
8704 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
8708 M (GET_NODE_INDEX, get_node_index);
8709 clib_memcpy (mp->node_name, name, vec_len (name));
8719 api_get_next_index (vat_main_t * vam)
8721 unformat_input_t *i = vam->input;
8722 vl_api_get_next_index_t *mp;
8724 u8 *node_name = 0, *next_node_name = 0;
8726 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8728 if (unformat (i, "node-name %s", &node_name))
8730 else if (unformat (i, "next-node-name %s", &next_node_name))
8736 errmsg ("node name required\n");
8739 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
8741 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
8745 if (next_node_name == 0)
8747 errmsg ("next node name required\n");
8750 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
8752 errmsg ("next node name too long, max %d\n", ARRAY_LEN (mp->next_name));
8756 M (GET_NEXT_INDEX, get_next_index);
8757 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
8758 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
8759 vec_free (node_name);
8760 vec_free (next_node_name);
8769 api_add_node_next (vat_main_t * vam)
8771 unformat_input_t *i = vam->input;
8772 vl_api_add_node_next_t *mp;
8777 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8779 if (unformat (i, "node %s", &name))
8781 else if (unformat (i, "next %s", &next))
8788 errmsg ("node name required\n");
8791 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
8793 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
8798 errmsg ("next node required\n");
8801 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
8803 errmsg ("next name too long, max %d\n", ARRAY_LEN (mp->next_name));
8807 M (ADD_NODE_NEXT, add_node_next);
8808 clib_memcpy (mp->node_name, name, vec_len (name));
8809 clib_memcpy (mp->next_name, next, vec_len (next));
8820 api_l2tpv3_create_tunnel (vat_main_t * vam)
8822 unformat_input_t *i = vam->input;
8823 ip6_address_t client_address, our_address;
8824 int client_address_set = 0;
8825 int our_address_set = 0;
8826 u32 local_session_id = 0;
8827 u32 remote_session_id = 0;
8828 u64 local_cookie = 0;
8829 u64 remote_cookie = 0;
8830 u8 l2_sublayer_present = 0;
8831 vl_api_l2tpv3_create_tunnel_t *mp;
8834 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8836 if (unformat (i, "client_address %U", unformat_ip6_address,
8838 client_address_set = 1;
8839 else if (unformat (i, "our_address %U", unformat_ip6_address,
8841 our_address_set = 1;
8842 else if (unformat (i, "local_session_id %d", &local_session_id))
8844 else if (unformat (i, "remote_session_id %d", &remote_session_id))
8846 else if (unformat (i, "local_cookie %lld", &local_cookie))
8848 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
8850 else if (unformat (i, "l2-sublayer-present"))
8851 l2_sublayer_present = 1;
8856 if (client_address_set == 0)
8858 errmsg ("client_address required\n");
8862 if (our_address_set == 0)
8864 errmsg ("our_address required\n");
8868 M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel);
8870 clib_memcpy (mp->client_address, client_address.as_u8,
8871 sizeof (mp->client_address));
8873 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
8875 mp->local_session_id = ntohl (local_session_id);
8876 mp->remote_session_id = ntohl (remote_session_id);
8877 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
8878 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
8879 mp->l2_sublayer_present = l2_sublayer_present;
8889 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
8891 unformat_input_t *i = vam->input;
8893 u8 sw_if_index_set = 0;
8894 u64 new_local_cookie = 0;
8895 u64 new_remote_cookie = 0;
8896 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
8899 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8901 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8902 sw_if_index_set = 1;
8903 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8904 sw_if_index_set = 1;
8905 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
8907 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
8913 if (sw_if_index_set == 0)
8915 errmsg ("missing interface name or sw_if_index\n");
8919 M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies);
8921 mp->sw_if_index = ntohl (sw_if_index);
8922 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
8923 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
8932 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
8934 unformat_input_t *i = vam->input;
8935 vl_api_l2tpv3_interface_enable_disable_t *mp;
8938 u8 sw_if_index_set = 0;
8939 u8 enable_disable = 1;
8941 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8943 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8944 sw_if_index_set = 1;
8945 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8946 sw_if_index_set = 1;
8947 else if (unformat (i, "enable"))
8949 else if (unformat (i, "disable"))
8955 if (sw_if_index_set == 0)
8957 errmsg ("missing interface name or sw_if_index\n");
8961 M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable);
8963 mp->sw_if_index = ntohl (sw_if_index);
8964 mp->enable_disable = enable_disable;
8973 api_l2tpv3_set_lookup_key (vat_main_t * vam)
8975 unformat_input_t *i = vam->input;
8976 vl_api_l2tpv3_set_lookup_key_t *mp;
8980 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8982 if (unformat (i, "lookup_v6_src"))
8983 key = L2T_LOOKUP_SRC_ADDRESS;
8984 else if (unformat (i, "lookup_v6_dst"))
8985 key = L2T_LOOKUP_DST_ADDRESS;
8986 else if (unformat (i, "lookup_session_id"))
8987 key = L2T_LOOKUP_SESSION_ID;
8992 if (key == (u8) ~ 0)
8994 errmsg ("l2tp session lookup key unset\n");
8998 M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key);
9008 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
9009 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
9011 vat_main_t *vam = &vat_main;
9013 fformat (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)\n",
9014 format_ip6_address, mp->our_address,
9015 format_ip6_address, mp->client_address,
9016 clib_net_to_host_u32 (mp->sw_if_index));
9019 " local cookies %016llx %016llx remote cookie %016llx\n",
9020 clib_net_to_host_u64 (mp->local_cookie[0]),
9021 clib_net_to_host_u64 (mp->local_cookie[1]),
9022 clib_net_to_host_u64 (mp->remote_cookie));
9024 fformat (vam->ofp, " local session-id %d remote session-id %d\n",
9025 clib_net_to_host_u32 (mp->local_session_id),
9026 clib_net_to_host_u32 (mp->remote_session_id));
9028 fformat (vam->ofp, " l2 specific sublayer %s\n\n",
9029 mp->l2_sublayer_present ? "preset" : "absent");
9033 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
9034 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
9036 vat_main_t *vam = &vat_main;
9037 vat_json_node_t *node = NULL;
9038 struct in6_addr addr;
9040 if (VAT_JSON_ARRAY != vam->json_tree.type)
9042 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9043 vat_json_init_array (&vam->json_tree);
9045 node = vat_json_array_add (&vam->json_tree);
9047 vat_json_init_object (node);
9049 clib_memcpy (&addr, mp->our_address, sizeof (addr));
9050 vat_json_object_add_ip6 (node, "our_address", addr);
9051 clib_memcpy (&addr, mp->client_address, sizeof (addr));
9052 vat_json_object_add_ip6 (node, "client_address", addr);
9054 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
9055 vat_json_init_array (lc);
9056 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
9057 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
9058 vat_json_object_add_uint (node, "remote_cookie",
9059 clib_net_to_host_u64 (mp->remote_cookie));
9061 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
9062 vat_json_object_add_uint (node, "local_session_id",
9063 clib_net_to_host_u32 (mp->local_session_id));
9064 vat_json_object_add_uint (node, "remote_session_id",
9065 clib_net_to_host_u32 (mp->remote_session_id));
9066 vat_json_object_add_string_copy (node, "l2_sublayer",
9067 mp->l2_sublayer_present ? (u8 *) "present"
9072 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
9074 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
9077 /* Get list of l2tpv3-tunnel interfaces */
9078 M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump);
9081 /* Use a control ping for synchronization */
9083 vl_api_control_ping_t *mp;
9084 M (CONTROL_PING, control_ping);
9091 static void vl_api_sw_interface_tap_details_t_handler
9092 (vl_api_sw_interface_tap_details_t * mp)
9094 vat_main_t *vam = &vat_main;
9096 fformat (vam->ofp, "%-16s %d\n",
9097 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
9100 static void vl_api_sw_interface_tap_details_t_handler_json
9101 (vl_api_sw_interface_tap_details_t * mp)
9103 vat_main_t *vam = &vat_main;
9104 vat_json_node_t *node = NULL;
9106 if (VAT_JSON_ARRAY != vam->json_tree.type)
9108 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9109 vat_json_init_array (&vam->json_tree);
9111 node = vat_json_array_add (&vam->json_tree);
9113 vat_json_init_object (node);
9114 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9115 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
9119 api_sw_interface_tap_dump (vat_main_t * vam)
9121 vl_api_sw_interface_tap_dump_t *mp;
9124 fformat (vam->ofp, "\n%-16s %s\n", "dev_name", "sw_if_index");
9125 /* Get list of tap interfaces */
9126 M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump);
9129 /* Use a control ping for synchronization */
9131 vl_api_control_ping_t *mp;
9132 M (CONTROL_PING, control_ping);
9138 static uword unformat_vxlan_decap_next
9139 (unformat_input_t * input, va_list * args)
9141 u32 *result = va_arg (*args, u32 *);
9144 if (unformat (input, "drop"))
9145 *result = VXLAN_INPUT_NEXT_DROP;
9146 else if (unformat (input, "ip4"))
9147 *result = VXLAN_INPUT_NEXT_IP4_INPUT;
9148 else if (unformat (input, "ip6"))
9149 *result = VXLAN_INPUT_NEXT_IP6_INPUT;
9150 else if (unformat (input, "l2"))
9151 *result = VXLAN_INPUT_NEXT_L2_INPUT;
9152 else if (unformat (input, "%d", &tmp))
9160 api_vxlan_add_del_tunnel (vat_main_t * vam)
9162 unformat_input_t *line_input = vam->input;
9163 vl_api_vxlan_add_del_tunnel_t *mp;
9165 ip4_address_t src4, dst4;
9166 ip6_address_t src6, dst6;
9168 u8 ipv4_set = 0, ipv6_set = 0;
9171 u32 encap_vrf_id = 0;
9172 u32 decap_next_index = ~0;
9175 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9177 if (unformat (line_input, "del"))
9179 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
9184 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
9189 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
9194 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
9199 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
9201 else if (unformat (line_input, "decap-next %U",
9202 unformat_vxlan_decap_next, &decap_next_index))
9204 else if (unformat (line_input, "vni %d", &vni))
9208 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
9215 errmsg ("tunnel src address not specified\n");
9220 errmsg ("tunnel dst address not specified\n");
9224 if (ipv4_set && ipv6_set)
9226 errmsg ("both IPv4 and IPv6 addresses specified");
9230 if ((vni == 0) || (vni >> 24))
9232 errmsg ("vni not specified or out of range\n");
9236 M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel);
9240 clib_memcpy (&mp->src_address, &src6, sizeof (src6));
9241 clib_memcpy (&mp->dst_address, &dst6, sizeof (dst6));
9245 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
9246 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
9248 mp->encap_vrf_id = ntohl (encap_vrf_id);
9249 mp->decap_next_index = ntohl (decap_next_index);
9250 mp->vni = ntohl (vni);
9251 mp->is_add = is_add;
9252 mp->is_ipv6 = ipv6_set;
9260 static void vl_api_vxlan_tunnel_details_t_handler
9261 (vl_api_vxlan_tunnel_details_t * mp)
9263 vat_main_t *vam = &vat_main;
9265 fformat (vam->ofp, "%11d%24U%24U%14d%18d%13d\n",
9266 ntohl (mp->sw_if_index),
9267 format_ip46_address, &(mp->src_address[0]),
9269 format_ip46_address, &(mp->dst_address[0]),
9271 ntohl (mp->encap_vrf_id),
9272 ntohl (mp->decap_next_index), ntohl (mp->vni));
9275 static void vl_api_vxlan_tunnel_details_t_handler_json
9276 (vl_api_vxlan_tunnel_details_t * mp)
9278 vat_main_t *vam = &vat_main;
9279 vat_json_node_t *node = NULL;
9281 struct in6_addr ip6;
9283 if (VAT_JSON_ARRAY != vam->json_tree.type)
9285 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9286 vat_json_init_array (&vam->json_tree);
9288 node = vat_json_array_add (&vam->json_tree);
9290 vat_json_init_object (node);
9291 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9294 clib_memcpy (&ip6, &(mp->src_address[0]), sizeof (ip6));
9295 vat_json_object_add_ip6 (node, "src_address", ip6);
9296 clib_memcpy (&ip6, &(mp->dst_address[0]), sizeof (ip6));
9297 vat_json_object_add_ip6 (node, "dst_address", ip6);
9301 clib_memcpy (&ip4, &(mp->src_address[0]), sizeof (ip4));
9302 vat_json_object_add_ip4 (node, "src_address", ip4);
9303 clib_memcpy (&ip4, &(mp->dst_address[0]), sizeof (ip4));
9304 vat_json_object_add_ip4 (node, "dst_address", ip4);
9306 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
9307 vat_json_object_add_uint (node, "decap_next_index",
9308 ntohl (mp->decap_next_index));
9309 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
9310 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
9314 api_vxlan_tunnel_dump (vat_main_t * vam)
9316 unformat_input_t *i = vam->input;
9317 vl_api_vxlan_tunnel_dump_t *mp;
9320 u8 sw_if_index_set = 0;
9322 /* Parse args required to build the message */
9323 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9325 if (unformat (i, "sw_if_index %d", &sw_if_index))
9326 sw_if_index_set = 1;
9331 if (sw_if_index_set == 0)
9336 if (!vam->json_output)
9338 fformat (vam->ofp, "%11s%24s%24s%14s%18s%13s\n",
9339 "sw_if_index", "src_address", "dst_address",
9340 "encap_vrf_id", "decap_next_index", "vni");
9343 /* Get list of vxlan-tunnel interfaces */
9344 M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
9346 mp->sw_if_index = htonl (sw_if_index);
9350 /* Use a control ping for synchronization */
9352 vl_api_control_ping_t *mp;
9353 M (CONTROL_PING, control_ping);
9360 api_gre_add_del_tunnel (vat_main_t * vam)
9362 unformat_input_t *line_input = vam->input;
9363 vl_api_gre_add_del_tunnel_t *mp;
9365 ip4_address_t src4, dst4;
9369 u32 outer_fib_id = 0;
9371 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9373 if (unformat (line_input, "del"))
9375 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
9377 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
9379 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
9383 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
9390 errmsg ("tunnel src address not specified\n");
9395 errmsg ("tunnel dst address not specified\n");
9400 M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel);
9402 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
9403 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
9404 mp->outer_fib_id = ntohl (outer_fib_id);
9405 mp->is_add = is_add;
9413 static void vl_api_gre_tunnel_details_t_handler
9414 (vl_api_gre_tunnel_details_t * mp)
9416 vat_main_t *vam = &vat_main;
9418 fformat (vam->ofp, "%11d%15U%15U%14d\n",
9419 ntohl (mp->sw_if_index),
9420 format_ip4_address, &mp->src_address,
9421 format_ip4_address, &mp->dst_address, ntohl (mp->outer_fib_id));
9424 static void vl_api_gre_tunnel_details_t_handler_json
9425 (vl_api_gre_tunnel_details_t * mp)
9427 vat_main_t *vam = &vat_main;
9428 vat_json_node_t *node = NULL;
9431 if (VAT_JSON_ARRAY != vam->json_tree.type)
9433 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9434 vat_json_init_array (&vam->json_tree);
9436 node = vat_json_array_add (&vam->json_tree);
9438 vat_json_init_object (node);
9439 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9440 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
9441 vat_json_object_add_ip4 (node, "src_address", ip4);
9442 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
9443 vat_json_object_add_ip4 (node, "dst_address", ip4);
9444 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
9448 api_gre_tunnel_dump (vat_main_t * vam)
9450 unformat_input_t *i = vam->input;
9451 vl_api_gre_tunnel_dump_t *mp;
9454 u8 sw_if_index_set = 0;
9456 /* Parse args required to build the message */
9457 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9459 if (unformat (i, "sw_if_index %d", &sw_if_index))
9460 sw_if_index_set = 1;
9465 if (sw_if_index_set == 0)
9470 if (!vam->json_output)
9472 fformat (vam->ofp, "%11s%15s%15s%14s\n",
9473 "sw_if_index", "src_address", "dst_address", "outer_fib_id");
9476 /* Get list of gre-tunnel interfaces */
9477 M (GRE_TUNNEL_DUMP, gre_tunnel_dump);
9479 mp->sw_if_index = htonl (sw_if_index);
9483 /* Use a control ping for synchronization */
9485 vl_api_control_ping_t *mp;
9486 M (CONTROL_PING, control_ping);
9493 api_l2_fib_clear_table (vat_main_t * vam)
9495 // unformat_input_t * i = vam->input;
9496 vl_api_l2_fib_clear_table_t *mp;
9499 M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table);
9508 api_l2_interface_efp_filter (vat_main_t * vam)
9510 unformat_input_t *i = vam->input;
9511 vl_api_l2_interface_efp_filter_t *mp;
9515 u8 sw_if_index_set = 0;
9517 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9519 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9520 sw_if_index_set = 1;
9521 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9522 sw_if_index_set = 1;
9523 else if (unformat (i, "enable"))
9525 else if (unformat (i, "disable"))
9529 clib_warning ("parse error '%U'", format_unformat_error, i);
9534 if (sw_if_index_set == 0)
9536 errmsg ("missing sw_if_index\n");
9540 M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter);
9542 mp->sw_if_index = ntohl (sw_if_index);
9543 mp->enable_disable = enable;
9551 #define foreach_vtr_op \
9552 _("disable", L2_VTR_DISABLED) \
9553 _("push-1", L2_VTR_PUSH_1) \
9554 _("push-2", L2_VTR_PUSH_2) \
9555 _("pop-1", L2_VTR_POP_1) \
9556 _("pop-2", L2_VTR_POP_2) \
9557 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
9558 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
9559 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
9560 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
9563 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
9565 unformat_input_t *i = vam->input;
9566 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
9569 u8 sw_if_index_set = 0;
9576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9578 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9579 sw_if_index_set = 1;
9580 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9581 sw_if_index_set = 1;
9582 else if (unformat (i, "vtr_op %d", &vtr_op))
9584 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
9587 else if (unformat (i, "push_dot1q %d", &push_dot1q))
9589 else if (unformat (i, "tag1 %d", &tag1))
9591 else if (unformat (i, "tag2 %d", &tag2))
9595 clib_warning ("parse error '%U'", format_unformat_error, i);
9600 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
9602 errmsg ("missing vtr operation or sw_if_index\n");
9606 M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)
9607 mp->sw_if_index = ntohl (sw_if_index);
9608 mp->vtr_op = ntohl (vtr_op);
9609 mp->push_dot1q = ntohl (push_dot1q);
9610 mp->tag1 = ntohl (tag1);
9611 mp->tag2 = ntohl (tag2);
9620 api_create_vhost_user_if (vat_main_t * vam)
9622 unformat_input_t *i = vam->input;
9623 vl_api_create_vhost_user_if_t *mp;
9627 u8 file_name_set = 0;
9628 u32 custom_dev_instance = ~0;
9630 u8 use_custom_mac = 0;
9632 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9634 if (unformat (i, "socket %s", &file_name))
9638 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
9640 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
9642 else if (unformat (i, "server"))
9648 if (file_name_set == 0)
9650 errmsg ("missing socket file name\n");
9654 if (vec_len (file_name) > 255)
9656 errmsg ("socket file name too long\n");
9659 vec_add1 (file_name, 0);
9661 M (CREATE_VHOST_USER_IF, create_vhost_user_if);
9663 mp->is_server = is_server;
9664 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
9665 vec_free (file_name);
9666 if (custom_dev_instance != ~0)
9669 mp->custom_dev_instance = ntohl (custom_dev_instance);
9671 mp->use_custom_mac = use_custom_mac;
9672 clib_memcpy (mp->mac_address, hwaddr, 6);
9681 api_modify_vhost_user_if (vat_main_t * vam)
9683 unformat_input_t *i = vam->input;
9684 vl_api_modify_vhost_user_if_t *mp;
9688 u8 file_name_set = 0;
9689 u32 custom_dev_instance = ~0;
9690 u8 sw_if_index_set = 0;
9691 u32 sw_if_index = (u32) ~ 0;
9693 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9695 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9696 sw_if_index_set = 1;
9697 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9698 sw_if_index_set = 1;
9699 else if (unformat (i, "socket %s", &file_name))
9703 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
9705 else if (unformat (i, "server"))
9711 if (sw_if_index_set == 0)
9713 errmsg ("missing sw_if_index or interface name\n");
9717 if (file_name_set == 0)
9719 errmsg ("missing socket file name\n");
9723 if (vec_len (file_name) > 255)
9725 errmsg ("socket file name too long\n");
9728 vec_add1 (file_name, 0);
9730 M (MODIFY_VHOST_USER_IF, modify_vhost_user_if);
9732 mp->sw_if_index = ntohl (sw_if_index);
9733 mp->is_server = is_server;
9734 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
9735 vec_free (file_name);
9736 if (custom_dev_instance != ~0)
9739 mp->custom_dev_instance = ntohl (custom_dev_instance);
9749 api_delete_vhost_user_if (vat_main_t * vam)
9751 unformat_input_t *i = vam->input;
9752 vl_api_delete_vhost_user_if_t *mp;
9754 u32 sw_if_index = ~0;
9755 u8 sw_if_index_set = 0;
9757 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9759 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9760 sw_if_index_set = 1;
9761 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9762 sw_if_index_set = 1;
9767 if (sw_if_index_set == 0)
9769 errmsg ("missing sw_if_index or interface name\n");
9774 M (DELETE_VHOST_USER_IF, delete_vhost_user_if);
9776 mp->sw_if_index = ntohl (sw_if_index);
9784 static void vl_api_sw_interface_vhost_user_details_t_handler
9785 (vl_api_sw_interface_vhost_user_details_t * mp)
9787 vat_main_t *vam = &vat_main;
9789 fformat (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s\n",
9790 (char *) mp->interface_name,
9791 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
9792 clib_net_to_host_u64 (mp->features), mp->is_server,
9793 ntohl (mp->num_regions), (char *) mp->sock_filename);
9794 fformat (vam->ofp, " Status: '%s'\n", strerror (ntohl (mp->sock_errno)));
9797 static void vl_api_sw_interface_vhost_user_details_t_handler_json
9798 (vl_api_sw_interface_vhost_user_details_t * mp)
9800 vat_main_t *vam = &vat_main;
9801 vat_json_node_t *node = NULL;
9803 if (VAT_JSON_ARRAY != vam->json_tree.type)
9805 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9806 vat_json_init_array (&vam->json_tree);
9808 node = vat_json_array_add (&vam->json_tree);
9810 vat_json_init_object (node);
9811 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9812 vat_json_object_add_string_copy (node, "interface_name",
9813 mp->interface_name);
9814 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
9815 ntohl (mp->virtio_net_hdr_sz));
9816 vat_json_object_add_uint (node, "features",
9817 clib_net_to_host_u64 (mp->features));
9818 vat_json_object_add_uint (node, "is_server", mp->is_server);
9819 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
9820 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
9821 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
9825 api_sw_interface_vhost_user_dump (vat_main_t * vam)
9827 vl_api_sw_interface_vhost_user_dump_t *mp;
9830 "Interface name idx hdr_sz features server regions filename\n");
9832 /* Get list of vhost-user interfaces */
9833 M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump);
9836 /* Use a control ping for synchronization */
9838 vl_api_control_ping_t *mp;
9839 M (CONTROL_PING, control_ping);
9846 api_show_version (vat_main_t * vam)
9848 vl_api_show_version_t *mp;
9851 M (SHOW_VERSION, show_version);
9861 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
9863 unformat_input_t *line_input = vam->input;
9864 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
9866 ip4_address_t local4, remote4;
9867 ip6_address_t local6, remote6;
9869 u8 ipv4_set = 0, ipv6_set = 0;
9872 u32 encap_vrf_id = 0;
9873 u32 decap_vrf_id = 0;
9878 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9880 if (unformat (line_input, "del"))
9882 else if (unformat (line_input, "local %U",
9883 unformat_ip4_address, &local4))
9888 else if (unformat (line_input, "remote %U",
9889 unformat_ip4_address, &remote4))
9894 else if (unformat (line_input, "local %U",
9895 unformat_ip6_address, &local6))
9900 else if (unformat (line_input, "remote %U",
9901 unformat_ip6_address, &remote6))
9906 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
9908 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
9910 else if (unformat (line_input, "vni %d", &vni))
9912 else if (unformat (line_input, "next-ip4"))
9914 else if (unformat (line_input, "next-ip6"))
9916 else if (unformat (line_input, "next-ethernet"))
9918 else if (unformat (line_input, "next-nsh"))
9922 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
9929 errmsg ("tunnel local address not specified\n");
9932 if (remote_set == 0)
9934 errmsg ("tunnel remote address not specified\n");
9937 if (ipv4_set && ipv6_set)
9939 errmsg ("both IPv4 and IPv6 addresses specified");
9945 errmsg ("vni not specified\n");
9949 M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel);
9954 clib_memcpy (&mp->local, &local6, sizeof (local6));
9955 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
9959 clib_memcpy (&mp->local, &local4, sizeof (local4));
9960 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
9963 mp->encap_vrf_id = ntohl (encap_vrf_id);
9964 mp->decap_vrf_id = ntohl (decap_vrf_id);
9965 mp->protocol = ntohl (protocol);
9966 mp->vni = ntohl (vni);
9967 mp->is_add = is_add;
9968 mp->is_ipv6 = ipv6_set;
9976 static void vl_api_vxlan_gpe_tunnel_details_t_handler
9977 (vl_api_vxlan_gpe_tunnel_details_t * mp)
9979 vat_main_t *vam = &vat_main;
9981 fformat (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d\n",
9982 ntohl (mp->sw_if_index),
9983 format_ip46_address, &(mp->local[0]),
9984 format_ip46_address, &(mp->remote[0]),
9986 ntohl (mp->protocol),
9987 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
9990 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
9991 (vl_api_vxlan_gpe_tunnel_details_t * mp)
9993 vat_main_t *vam = &vat_main;
9994 vat_json_node_t *node = NULL;
9996 struct in6_addr ip6;
9998 if (VAT_JSON_ARRAY != vam->json_tree.type)
10000 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10001 vat_json_init_array (&vam->json_tree);
10003 node = vat_json_array_add (&vam->json_tree);
10005 vat_json_init_object (node);
10006 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10009 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
10010 vat_json_object_add_ip6 (node, "local", ip6);
10011 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
10012 vat_json_object_add_ip6 (node, "remote", ip6);
10016 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
10017 vat_json_object_add_ip4 (node, "local", ip4);
10018 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
10019 vat_json_object_add_ip4 (node, "remote", ip4);
10021 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10022 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
10023 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10024 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
10025 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10029 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
10031 unformat_input_t *i = vam->input;
10032 vl_api_vxlan_gpe_tunnel_dump_t *mp;
10035 u8 sw_if_index_set = 0;
10037 /* Parse args required to build the message */
10038 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10040 if (unformat (i, "sw_if_index %d", &sw_if_index))
10041 sw_if_index_set = 1;
10046 if (sw_if_index_set == 0)
10051 if (!vam->json_output)
10053 fformat (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s\n",
10054 "sw_if_index", "local", "remote", "vni",
10055 "protocol", "encap_vrf_id", "decap_vrf_id");
10058 /* Get list of vxlan-tunnel interfaces */
10059 M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump);
10061 mp->sw_if_index = htonl (sw_if_index);
10065 /* Use a control ping for synchronization */
10067 vl_api_control_ping_t *mp;
10068 M (CONTROL_PING, control_ping);
10075 format_l2_fib_mac_address (u8 * s, va_list * args)
10077 u8 *a = va_arg (*args, u8 *);
10079 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
10080 a[2], a[3], a[4], a[5], a[6], a[7]);
10083 static void vl_api_l2_fib_table_entry_t_handler
10084 (vl_api_l2_fib_table_entry_t * mp)
10086 vat_main_t *vam = &vat_main;
10088 fformat (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
10090 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
10091 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
10095 static void vl_api_l2_fib_table_entry_t_handler_json
10096 (vl_api_l2_fib_table_entry_t * mp)
10098 vat_main_t *vam = &vat_main;
10099 vat_json_node_t *node = NULL;
10101 if (VAT_JSON_ARRAY != vam->json_tree.type)
10103 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10104 vat_json_init_array (&vam->json_tree);
10106 node = vat_json_array_add (&vam->json_tree);
10108 vat_json_init_object (node);
10109 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
10110 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
10111 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10112 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
10113 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
10114 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
10118 api_l2_fib_table_dump (vat_main_t * vam)
10120 unformat_input_t *i = vam->input;
10121 vl_api_l2_fib_table_dump_t *mp;
10126 /* Parse args required to build the message */
10127 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10129 if (unformat (i, "bd_id %d", &bd_id))
10135 if (bd_id_set == 0)
10137 errmsg ("missing bridge domain\n");
10142 "BD-ID Mac Address sw-ndx Static Filter BVI\n");
10144 /* Get list of l2 fib entries */
10145 M (L2_FIB_TABLE_DUMP, l2_fib_table_dump);
10147 mp->bd_id = ntohl (bd_id);
10150 /* Use a control ping for synchronization */
10152 vl_api_control_ping_t *mp;
10153 M (CONTROL_PING, control_ping);
10161 api_interface_name_renumber (vat_main_t * vam)
10163 unformat_input_t *line_input = vam->input;
10164 vl_api_interface_name_renumber_t *mp;
10165 u32 sw_if_index = ~0;
10167 u32 new_show_dev_instance = ~0;
10169 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10171 if (unformat (line_input, "%U", unformat_sw_if_index, vam,
10174 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
10176 else if (unformat (line_input, "new_show_dev_instance %d",
10177 &new_show_dev_instance))
10183 if (sw_if_index == ~0)
10185 errmsg ("missing interface name or sw_if_index\n");
10189 if (new_show_dev_instance == ~0)
10191 errmsg ("missing new_show_dev_instance\n");
10195 M (INTERFACE_NAME_RENUMBER, interface_name_renumber);
10197 mp->sw_if_index = ntohl (sw_if_index);
10198 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
10205 api_want_ip4_arp_events (vat_main_t * vam)
10207 unformat_input_t *line_input = vam->input;
10208 vl_api_want_ip4_arp_events_t *mp;
10210 ip4_address_t address;
10211 int address_set = 0;
10212 u32 enable_disable = 1;
10214 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10216 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
10218 else if (unformat (line_input, "del"))
10219 enable_disable = 0;
10224 if (address_set == 0)
10226 errmsg ("missing addresses\n");
10230 M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events);
10231 mp->enable_disable = enable_disable;
10232 mp->pid = getpid ();
10233 mp->address = address.as_u32;
10240 api_want_ip6_nd_events (vat_main_t * vam)
10242 unformat_input_t *line_input = vam->input;
10243 vl_api_want_ip6_nd_events_t *mp;
10245 ip6_address_t address;
10246 int address_set = 0;
10247 u32 enable_disable = 1;
10249 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10251 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
10253 else if (unformat (line_input, "del"))
10254 enable_disable = 0;
10259 if (address_set == 0)
10261 errmsg ("missing addresses\n");
10265 M (WANT_IP6_ND_EVENTS, want_ip6_nd_events);
10266 mp->enable_disable = enable_disable;
10267 mp->pid = getpid ();
10268 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
10275 api_input_acl_set_interface (vat_main_t * vam)
10277 unformat_input_t *i = vam->input;
10278 vl_api_input_acl_set_interface_t *mp;
10281 int sw_if_index_set;
10282 u32 ip4_table_index = ~0;
10283 u32 ip6_table_index = ~0;
10284 u32 l2_table_index = ~0;
10287 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10289 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10290 sw_if_index_set = 1;
10291 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10292 sw_if_index_set = 1;
10293 else if (unformat (i, "del"))
10295 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10297 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10299 else if (unformat (i, "l2-table %d", &l2_table_index))
10303 clib_warning ("parse error '%U'", format_unformat_error, i);
10308 if (sw_if_index_set == 0)
10310 errmsg ("missing interface name or sw_if_index\n");
10314 M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface);
10316 mp->sw_if_index = ntohl (sw_if_index);
10317 mp->ip4_table_index = ntohl (ip4_table_index);
10318 mp->ip6_table_index = ntohl (ip6_table_index);
10319 mp->l2_table_index = ntohl (l2_table_index);
10320 mp->is_add = is_add;
10329 api_ip_address_dump (vat_main_t * vam)
10331 unformat_input_t *i = vam->input;
10332 vl_api_ip_address_dump_t *mp;
10333 u32 sw_if_index = ~0;
10334 u8 sw_if_index_set = 0;
10339 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10341 if (unformat (i, "sw_if_index %d", &sw_if_index))
10342 sw_if_index_set = 1;
10343 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10344 sw_if_index_set = 1;
10345 else if (unformat (i, "ipv4"))
10347 else if (unformat (i, "ipv6"))
10353 if (ipv4_set && ipv6_set)
10355 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
10359 if ((!ipv4_set) && (!ipv6_set))
10361 errmsg ("no ipv4 nor ipv6 flag set\n");
10365 if (sw_if_index_set == 0)
10367 errmsg ("missing interface name or sw_if_index\n");
10371 vam->current_sw_if_index = sw_if_index;
10372 vam->is_ipv6 = ipv6_set;
10374 M (IP_ADDRESS_DUMP, ip_address_dump);
10375 mp->sw_if_index = ntohl (sw_if_index);
10376 mp->is_ipv6 = ipv6_set;
10379 /* Use a control ping for synchronization */
10381 vl_api_control_ping_t *mp;
10382 M (CONTROL_PING, control_ping);
10389 api_ip_dump (vat_main_t * vam)
10391 vl_api_ip_dump_t *mp;
10392 unformat_input_t *in = vam->input;
10399 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
10401 if (unformat (in, "ipv4"))
10403 else if (unformat (in, "ipv6"))
10409 if (ipv4_set && ipv6_set)
10411 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
10415 if ((!ipv4_set) && (!ipv6_set))
10417 errmsg ("no ipv4 nor ipv6 flag set\n");
10421 is_ipv6 = ipv6_set;
10422 vam->is_ipv6 = is_ipv6;
10424 /* free old data */
10425 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
10427 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
10429 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
10431 M (IP_DUMP, ip_dump);
10432 mp->is_ipv6 = ipv6_set;
10435 /* Use a control ping for synchronization */
10437 vl_api_control_ping_t *mp;
10438 M (CONTROL_PING, control_ping);
10445 api_ipsec_spd_add_del (vat_main_t * vam)
10448 unformat_input_t *i = vam->input;
10449 vl_api_ipsec_spd_add_del_t *mp;
10454 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10456 if (unformat (i, "spd_id %d", &spd_id))
10458 else if (unformat (i, "del"))
10462 clib_warning ("parse error '%U'", format_unformat_error, i);
10468 errmsg ("spd_id must be set\n");
10472 M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del);
10474 mp->spd_id = ntohl (spd_id);
10475 mp->is_add = is_add;
10482 clib_warning ("unsupported (no dpdk)");
10488 api_ipsec_interface_add_del_spd (vat_main_t * vam)
10491 unformat_input_t *i = vam->input;
10492 vl_api_ipsec_interface_add_del_spd_t *mp;
10495 u8 sw_if_index_set = 0;
10496 u32 spd_id = (u32) ~ 0;
10499 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10501 if (unformat (i, "del"))
10503 else if (unformat (i, "spd_id %d", &spd_id))
10505 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10506 sw_if_index_set = 1;
10507 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10508 sw_if_index_set = 1;
10511 clib_warning ("parse error '%U'", format_unformat_error, i);
10517 if (spd_id == (u32) ~ 0)
10519 errmsg ("spd_id must be set\n");
10523 if (sw_if_index_set == 0)
10525 errmsg ("missing interface name or sw_if_index\n");
10529 M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd);
10531 mp->spd_id = ntohl (spd_id);
10532 mp->sw_if_index = ntohl (sw_if_index);
10533 mp->is_add = is_add;
10540 clib_warning ("unsupported (no dpdk)");
10546 api_ipsec_spd_add_del_entry (vat_main_t * vam)
10549 unformat_input_t *i = vam->input;
10550 vl_api_ipsec_spd_add_del_entry_t *mp;
10552 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
10553 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
10555 u32 rport_start = 0, rport_stop = (u32) ~ 0;
10556 u32 lport_start = 0, lport_stop = (u32) ~ 0;
10557 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
10558 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
10560 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
10561 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
10562 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
10563 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
10564 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
10565 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
10567 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10569 if (unformat (i, "del"))
10571 if (unformat (i, "outbound"))
10573 if (unformat (i, "inbound"))
10575 else if (unformat (i, "spd_id %d", &spd_id))
10577 else if (unformat (i, "sa_id %d", &sa_id))
10579 else if (unformat (i, "priority %d", &priority))
10581 else if (unformat (i, "protocol %d", &protocol))
10583 else if (unformat (i, "lport_start %d", &lport_start))
10585 else if (unformat (i, "lport_stop %d", &lport_stop))
10587 else if (unformat (i, "rport_start %d", &rport_start))
10589 else if (unformat (i, "rport_stop %d", &rport_stop))
10593 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
10599 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
10606 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
10612 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
10619 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
10625 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
10632 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
10638 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
10644 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
10646 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
10648 clib_warning ("unsupported action: 'resolve'");
10654 clib_warning ("parse error '%U'", format_unformat_error, i);
10660 M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry);
10662 mp->spd_id = ntohl (spd_id);
10663 mp->priority = ntohl (priority);
10664 mp->is_outbound = is_outbound;
10666 mp->is_ipv6 = is_ipv6;
10667 if (is_ipv6 || is_ip_any)
10669 clib_memcpy (mp->remote_address_start, &raddr6_start,
10670 sizeof (ip6_address_t));
10671 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
10672 sizeof (ip6_address_t));
10673 clib_memcpy (mp->local_address_start, &laddr6_start,
10674 sizeof (ip6_address_t));
10675 clib_memcpy (mp->local_address_stop, &laddr6_stop,
10676 sizeof (ip6_address_t));
10680 clib_memcpy (mp->remote_address_start, &raddr4_start,
10681 sizeof (ip4_address_t));
10682 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
10683 sizeof (ip4_address_t));
10684 clib_memcpy (mp->local_address_start, &laddr4_start,
10685 sizeof (ip4_address_t));
10686 clib_memcpy (mp->local_address_stop, &laddr4_stop,
10687 sizeof (ip4_address_t));
10689 mp->protocol = (u8) protocol;
10690 mp->local_port_start = ntohs ((u16) lport_start);
10691 mp->local_port_stop = ntohs ((u16) lport_stop);
10692 mp->remote_port_start = ntohs ((u16) rport_start);
10693 mp->remote_port_stop = ntohs ((u16) rport_stop);
10694 mp->policy = (u8) policy;
10695 mp->sa_id = ntohl (sa_id);
10696 mp->is_add = is_add;
10697 mp->is_ip_any = is_ip_any;
10703 clib_warning ("unsupported (no dpdk)");
10709 api_ipsec_sad_add_del_entry (vat_main_t * vam)
10712 unformat_input_t *i = vam->input;
10713 vl_api_ipsec_sad_add_del_entry_t *mp;
10715 u32 sad_id = 0, spi = 0;
10716 u8 *ck = 0, *ik = 0;
10719 u8 protocol = IPSEC_PROTOCOL_AH;
10720 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
10721 u32 crypto_alg = 0, integ_alg = 0;
10722 ip4_address_t tun_src4;
10723 ip4_address_t tun_dst4;
10724 ip6_address_t tun_src6;
10725 ip6_address_t tun_dst6;
10727 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10729 if (unformat (i, "del"))
10731 else if (unformat (i, "sad_id %d", &sad_id))
10733 else if (unformat (i, "spi %d", &spi))
10735 else if (unformat (i, "esp"))
10736 protocol = IPSEC_PROTOCOL_ESP;
10737 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
10740 is_tunnel_ipv6 = 0;
10742 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
10745 is_tunnel_ipv6 = 0;
10747 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
10750 is_tunnel_ipv6 = 1;
10752 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
10755 is_tunnel_ipv6 = 1;
10759 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
10761 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
10762 crypto_alg > IPSEC_INTEG_ALG_SHA_512_256)
10764 clib_warning ("unsupported crypto-alg: '%U'",
10765 format_ipsec_crypto_alg, crypto_alg);
10769 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
10773 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
10775 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
10776 integ_alg > IPSEC_INTEG_ALG_SHA_512_256)
10778 clib_warning ("unsupported integ-alg: '%U'",
10779 format_ipsec_integ_alg, integ_alg);
10783 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
10787 clib_warning ("parse error '%U'", format_unformat_error, i);
10793 M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
10795 mp->sad_id = ntohl (sad_id);
10796 mp->is_add = is_add;
10797 mp->protocol = protocol;
10798 mp->spi = ntohl (spi);
10799 mp->is_tunnel = is_tunnel;
10800 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
10801 mp->crypto_algorithm = crypto_alg;
10802 mp->integrity_algorithm = integ_alg;
10803 mp->crypto_key_length = vec_len (ck);
10804 mp->integrity_key_length = vec_len (ik);
10806 if (mp->crypto_key_length > sizeof (mp->crypto_key))
10807 mp->crypto_key_length = sizeof (mp->crypto_key);
10809 if (mp->integrity_key_length > sizeof (mp->integrity_key))
10810 mp->integrity_key_length = sizeof (mp->integrity_key);
10813 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
10815 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
10819 if (is_tunnel_ipv6)
10821 clib_memcpy (mp->tunnel_src_address, &tun_src6,
10822 sizeof (ip6_address_t));
10823 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
10824 sizeof (ip6_address_t));
10828 clib_memcpy (mp->tunnel_src_address, &tun_src4,
10829 sizeof (ip4_address_t));
10830 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
10831 sizeof (ip4_address_t));
10840 clib_warning ("unsupported (no dpdk)");
10846 api_ipsec_sa_set_key (vat_main_t * vam)
10849 unformat_input_t *i = vam->input;
10850 vl_api_ipsec_sa_set_key_t *mp;
10853 u8 *ck = 0, *ik = 0;
10855 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10857 if (unformat (i, "sa_id %d", &sa_id))
10859 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
10861 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
10865 clib_warning ("parse error '%U'", format_unformat_error, i);
10870 M (IPSEC_SA_SET_KEY, ipsec_set_sa_key);
10872 mp->sa_id = ntohl (sa_id);
10873 mp->crypto_key_length = vec_len (ck);
10874 mp->integrity_key_length = vec_len (ik);
10876 if (mp->crypto_key_length > sizeof (mp->crypto_key))
10877 mp->crypto_key_length = sizeof (mp->crypto_key);
10879 if (mp->integrity_key_length > sizeof (mp->integrity_key))
10880 mp->integrity_key_length = sizeof (mp->integrity_key);
10883 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
10885 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
10892 clib_warning ("unsupported (no dpdk)");
10898 api_ikev2_profile_add_del (vat_main_t * vam)
10901 unformat_input_t *i = vam->input;
10902 vl_api_ikev2_profile_add_del_t *mp;
10907 const char *valid_chars = "a-zA-Z0-9_";
10909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10911 if (unformat (i, "del"))
10913 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
10914 vec_add1 (name, 0);
10917 errmsg ("parse error '%U'", format_unformat_error, i);
10922 if (!vec_len (name))
10924 errmsg ("profile name must be specified");
10928 if (vec_len (name) > 64)
10930 errmsg ("profile name too long");
10934 M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del);
10936 clib_memcpy (mp->name, name, vec_len (name));
10937 mp->is_add = is_add;
10945 clib_warning ("unsupported (no dpdk)");
10951 api_ikev2_profile_set_auth (vat_main_t * vam)
10954 unformat_input_t *i = vam->input;
10955 vl_api_ikev2_profile_set_auth_t *mp;
10959 u32 auth_method = 0;
10962 const char *valid_chars = "a-zA-Z0-9_";
10964 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10966 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
10967 vec_add1 (name, 0);
10968 else if (unformat (i, "auth_method %U",
10969 unformat_ikev2_auth_method, &auth_method))
10971 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
10973 else if (unformat (i, "auth_data %v", &data))
10977 errmsg ("parse error '%U'", format_unformat_error, i);
10982 if (!vec_len (name))
10984 errmsg ("profile name must be specified");
10988 if (vec_len (name) > 64)
10990 errmsg ("profile name too long");
10994 if (!vec_len (data))
10996 errmsg ("auth_data must be specified");
11002 errmsg ("auth_method must be specified");
11006 M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth);
11008 mp->is_hex = is_hex;
11009 mp->auth_method = (u8) auth_method;
11010 mp->data_len = vec_len (data);
11011 clib_memcpy (mp->name, name, vec_len (name));
11012 clib_memcpy (mp->data, data, vec_len (data));
11021 clib_warning ("unsupported (no dpdk)");
11027 api_ikev2_profile_set_id (vat_main_t * vam)
11030 unformat_input_t *i = vam->input;
11031 vl_api_ikev2_profile_set_id_t *mp;
11039 const char *valid_chars = "a-zA-Z0-9_";
11041 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11043 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11044 vec_add1 (name, 0);
11045 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
11047 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
11049 data = vec_new (u8, 4);
11050 clib_memcpy (data, ip4.as_u8, 4);
11052 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
11054 else if (unformat (i, "id_data %v", &data))
11056 else if (unformat (i, "local"))
11058 else if (unformat (i, "remote"))
11062 errmsg ("parse error '%U'", format_unformat_error, i);
11067 if (!vec_len (name))
11069 errmsg ("profile name must be specified");
11073 if (vec_len (name) > 64)
11075 errmsg ("profile name too long");
11079 if (!vec_len (data))
11081 errmsg ("id_data must be specified");
11087 errmsg ("id_type must be specified");
11091 M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id);
11093 mp->is_local = is_local;
11094 mp->id_type = (u8) id_type;
11095 mp->data_len = vec_len (data);
11096 clib_memcpy (mp->name, name, vec_len (name));
11097 clib_memcpy (mp->data, data, vec_len (data));
11106 clib_warning ("unsupported (no dpdk)");
11112 api_ikev2_profile_set_ts (vat_main_t * vam)
11115 unformat_input_t *i = vam->input;
11116 vl_api_ikev2_profile_set_ts_t *mp;
11120 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
11121 ip4_address_t start_addr, end_addr;
11123 const char *valid_chars = "a-zA-Z0-9_";
11125 start_addr.as_u32 = 0;
11126 end_addr.as_u32 = (u32) ~ 0;
11128 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11130 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11131 vec_add1 (name, 0);
11132 else if (unformat (i, "protocol %d", &proto))
11134 else if (unformat (i, "start_port %d", &start_port))
11136 else if (unformat (i, "end_port %d", &end_port))
11139 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
11141 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
11143 else if (unformat (i, "local"))
11145 else if (unformat (i, "remote"))
11149 errmsg ("parse error '%U'", format_unformat_error, i);
11154 if (!vec_len (name))
11156 errmsg ("profile name must be specified");
11160 if (vec_len (name) > 64)
11162 errmsg ("profile name too long");
11166 M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts);
11168 mp->is_local = is_local;
11169 mp->proto = (u8) proto;
11170 mp->start_port = (u16) start_port;
11171 mp->end_port = (u16) end_port;
11172 mp->start_addr = start_addr.as_u32;
11173 mp->end_addr = end_addr.as_u32;
11174 clib_memcpy (mp->name, name, vec_len (name));
11182 clib_warning ("unsupported (no dpdk)");
11188 api_ikev2_set_local_key (vat_main_t * vam)
11191 unformat_input_t *i = vam->input;
11192 vl_api_ikev2_set_local_key_t *mp;
11196 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11198 if (unformat (i, "file %v", &file))
11199 vec_add1 (file, 0);
11202 errmsg ("parse error '%U'", format_unformat_error, i);
11207 if (!vec_len (file))
11209 errmsg ("RSA key file must be specified");
11213 if (vec_len (file) > 256)
11215 errmsg ("file name too long");
11219 M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key);
11221 clib_memcpy (mp->key_file, file, vec_len (file));
11229 clib_warning ("unsupported (no dpdk)");
11238 api_map_add_domain (vat_main_t * vam)
11240 unformat_input_t *i = vam->input;
11241 vl_api_map_add_domain_t *mp;
11244 ip4_address_t ip4_prefix;
11245 ip6_address_t ip6_prefix;
11246 ip6_address_t ip6_src;
11247 u32 num_m_args = 0;
11248 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
11249 0, psid_length = 0;
11250 u8 is_translation = 0;
11252 u32 ip6_src_len = 128;
11254 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11256 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
11257 &ip4_prefix, &ip4_prefix_len))
11259 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
11260 &ip6_prefix, &ip6_prefix_len))
11264 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
11267 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
11269 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
11271 else if (unformat (i, "psid-offset %d", &psid_offset))
11273 else if (unformat (i, "psid-len %d", &psid_length))
11275 else if (unformat (i, "mtu %d", &mtu))
11277 else if (unformat (i, "map-t"))
11278 is_translation = 1;
11281 clib_warning ("parse error '%U'", format_unformat_error, i);
11286 if (num_m_args < 3)
11288 errmsg ("mandatory argument(s) missing\n");
11292 /* Construct the API message */
11293 M (MAP_ADD_DOMAIN, map_add_domain);
11295 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
11296 mp->ip4_prefix_len = ip4_prefix_len;
11298 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
11299 mp->ip6_prefix_len = ip6_prefix_len;
11301 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
11302 mp->ip6_src_prefix_len = ip6_src_len;
11304 mp->ea_bits_len = ea_bits_len;
11305 mp->psid_offset = psid_offset;
11306 mp->psid_length = psid_length;
11307 mp->is_translation = is_translation;
11308 mp->mtu = htons (mtu);
11313 /* Wait for a reply, return good/bad news */
11318 api_map_del_domain (vat_main_t * vam)
11320 unformat_input_t *i = vam->input;
11321 vl_api_map_del_domain_t *mp;
11324 u32 num_m_args = 0;
11327 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11329 if (unformat (i, "index %d", &index))
11333 clib_warning ("parse error '%U'", format_unformat_error, i);
11338 if (num_m_args != 1)
11340 errmsg ("mandatory argument(s) missing\n");
11344 /* Construct the API message */
11345 M (MAP_DEL_DOMAIN, map_del_domain);
11347 mp->index = ntohl (index);
11352 /* Wait for a reply, return good/bad news */
11357 api_map_add_del_rule (vat_main_t * vam)
11359 unformat_input_t *i = vam->input;
11360 vl_api_map_add_del_rule_t *mp;
11363 ip6_address_t ip6_dst;
11364 u32 num_m_args = 0, index, psid = 0;
11366 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11368 if (unformat (i, "index %d", &index))
11370 else if (unformat (i, "psid %d", &psid))
11372 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
11374 else if (unformat (i, "del"))
11380 clib_warning ("parse error '%U'", format_unformat_error, i);
11385 /* Construct the API message */
11386 M (MAP_ADD_DEL_RULE, map_add_del_rule);
11388 mp->index = ntohl (index);
11389 mp->is_add = is_add;
11390 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
11391 mp->psid = ntohs (psid);
11396 /* Wait for a reply, return good/bad news */
11401 api_map_domain_dump (vat_main_t * vam)
11403 vl_api_map_domain_dump_t *mp;
11406 /* Construct the API message */
11407 M (MAP_DOMAIN_DUMP, map_domain_dump);
11412 /* Use a control ping for synchronization */
11414 vl_api_control_ping_t *mp;
11415 M (CONTROL_PING, control_ping);
11422 api_map_rule_dump (vat_main_t * vam)
11424 unformat_input_t *i = vam->input;
11425 vl_api_map_rule_dump_t *mp;
11427 u32 domain_index = ~0;
11429 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11431 if (unformat (i, "index %u", &domain_index))
11437 if (domain_index == ~0)
11439 clib_warning ("parse error: domain index expected");
11443 /* Construct the API message */
11444 M (MAP_RULE_DUMP, map_rule_dump);
11446 mp->domain_index = htonl (domain_index);
11451 /* Use a control ping for synchronization */
11453 vl_api_control_ping_t *mp;
11454 M (CONTROL_PING, control_ping);
11460 static void vl_api_map_add_domain_reply_t_handler
11461 (vl_api_map_add_domain_reply_t * mp)
11463 vat_main_t *vam = &vat_main;
11464 i32 retval = ntohl (mp->retval);
11466 if (vam->async_mode)
11468 vam->async_errors += (retval < 0);
11472 vam->retval = retval;
11473 vam->result_ready = 1;
11477 static void vl_api_map_add_domain_reply_t_handler_json
11478 (vl_api_map_add_domain_reply_t * mp)
11480 vat_main_t *vam = &vat_main;
11481 vat_json_node_t node;
11483 vat_json_init_object (&node);
11484 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
11485 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
11487 vat_json_print (vam->ofp, &node);
11488 vat_json_free (&node);
11490 vam->retval = ntohl (mp->retval);
11491 vam->result_ready = 1;
11495 api_get_first_msg_id (vat_main_t * vam)
11497 vl_api_get_first_msg_id_t *mp;
11499 unformat_input_t *i = vam->input;
11503 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11505 if (unformat (i, "client %s", &name))
11513 errmsg ("missing client name\n");
11516 vec_add1 (name, 0);
11518 if (vec_len (name) > 63)
11520 errmsg ("client name too long\n");
11524 M (GET_FIRST_MSG_ID, get_first_msg_id);
11525 clib_memcpy (mp->name, name, vec_len (name));
11533 api_cop_interface_enable_disable (vat_main_t * vam)
11535 unformat_input_t *line_input = vam->input;
11536 vl_api_cop_interface_enable_disable_t *mp;
11538 u32 sw_if_index = ~0;
11539 u8 enable_disable = 1;
11541 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11543 if (unformat (line_input, "disable"))
11544 enable_disable = 0;
11545 if (unformat (line_input, "enable"))
11546 enable_disable = 1;
11547 else if (unformat (line_input, "%U", unformat_sw_if_index,
11548 vam, &sw_if_index))
11550 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11556 if (sw_if_index == ~0)
11558 errmsg ("missing interface name or sw_if_index\n");
11562 /* Construct the API message */
11563 M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable);
11564 mp->sw_if_index = ntohl (sw_if_index);
11565 mp->enable_disable = enable_disable;
11569 /* Wait for the reply */
11574 api_cop_whitelist_enable_disable (vat_main_t * vam)
11576 unformat_input_t *line_input = vam->input;
11577 vl_api_cop_whitelist_enable_disable_t *mp;
11579 u32 sw_if_index = ~0;
11580 u8 ip4 = 0, ip6 = 0, default_cop = 0;
11583 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11585 if (unformat (line_input, "ip4"))
11587 else if (unformat (line_input, "ip6"))
11589 else if (unformat (line_input, "default"))
11591 else if (unformat (line_input, "%U", unformat_sw_if_index,
11592 vam, &sw_if_index))
11594 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11596 else if (unformat (line_input, "fib-id %d", &fib_id))
11602 if (sw_if_index == ~0)
11604 errmsg ("missing interface name or sw_if_index\n");
11608 /* Construct the API message */
11609 M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable);
11610 mp->sw_if_index = ntohl (sw_if_index);
11611 mp->fib_id = ntohl (fib_id);
11614 mp->default_cop = default_cop;
11618 /* Wait for the reply */
11623 api_get_node_graph (vat_main_t * vam)
11625 vl_api_get_node_graph_t *mp;
11628 M (GET_NODE_GRAPH, get_node_graph);
11632 /* Wait for the reply */
11637 /** Used for parsing LISP eids */
11638 typedef CLIB_PACKED(struct{
11639 u8 addr[16]; /**< eid address */
11640 u32 len; /**< prefix length if IP */
11641 u8 type; /**< type of eid */
11646 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
11648 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
11650 memset (a, 0, sizeof (a[0]));
11652 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
11654 a->type = 0; /* ipv4 type */
11656 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
11658 a->type = 1; /* ipv6 type */
11660 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
11662 a->type = 2; /* mac type */
11669 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
11678 lisp_eid_size_vat (u8 type)
11693 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
11695 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
11699 /** Used for transferring locators via VPP API */
11700 typedef CLIB_PACKED(struct
11702 u32 sw_if_index; /**< locator sw_if_index */
11703 u8 priority; /**< locator priority */
11704 u8 weight; /**< locator weight */
11709 api_lisp_add_del_locator_set (vat_main_t * vam)
11711 unformat_input_t *input = vam->input;
11712 vl_api_lisp_add_del_locator_set_t *mp;
11715 u8 *locator_set_name = NULL;
11716 u8 locator_set_name_set = 0;
11717 ls_locator_t locator, *locators = 0;
11718 u32 sw_if_index, priority, weight;
11720 /* Parse args required to build the message */
11721 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11723 if (unformat (input, "del"))
11727 else if (unformat (input, "locator-set %s", &locator_set_name))
11729 locator_set_name_set = 1;
11731 else if (unformat (input, "sw_if_index %u p %u w %u",
11732 &sw_if_index, &priority, &weight))
11734 locator.sw_if_index = htonl (sw_if_index);
11735 locator.priority = priority;
11736 locator.weight = weight;
11737 vec_add1 (locators, locator);
11739 else if (unformat (input, "iface %U p %u w %u", unformat_sw_if_index,
11740 vam, &sw_if_index, &priority, &weight))
11742 locator.sw_if_index = htonl (sw_if_index);
11743 locator.priority = priority;
11744 locator.weight = weight;
11745 vec_add1 (locators, locator);
11751 if (locator_set_name_set == 0)
11753 errmsg ("missing locator-set name");
11754 vec_free (locators);
11758 if (vec_len (locator_set_name) > 64)
11760 errmsg ("locator-set name too long\n");
11761 vec_free (locator_set_name);
11762 vec_free (locators);
11765 vec_add1 (locator_set_name, 0);
11767 /* Construct the API message */
11768 M (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set);
11770 mp->is_add = is_add;
11771 clib_memcpy (mp->locator_set_name, locator_set_name,
11772 vec_len (locator_set_name));
11773 vec_free (locator_set_name);
11775 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
11777 clib_memcpy (mp->locators, locators,
11778 (sizeof (ls_locator_t) * vec_len (locators)));
11779 vec_free (locators);
11784 /* Wait for a reply... */
11792 api_lisp_add_del_locator (vat_main_t * vam)
11794 unformat_input_t *input = vam->input;
11795 vl_api_lisp_add_del_locator_t *mp;
11797 u32 tmp_if_index = ~0;
11798 u32 sw_if_index = ~0;
11799 u8 sw_if_index_set = 0;
11800 u8 sw_if_index_if_name_set = 0;
11802 u8 priority_set = 0;
11806 u8 *locator_set_name = NULL;
11807 u8 locator_set_name_set = 0;
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, "iface %U", unformat_sw_if_index, vam,
11823 sw_if_index_if_name_set = 1;
11824 sw_if_index = tmp_if_index;
11826 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
11828 sw_if_index_set = 1;
11829 sw_if_index = tmp_if_index;
11831 else if (unformat (input, "p %d", &priority))
11835 else if (unformat (input, "w %d", &weight))
11843 if (locator_set_name_set == 0)
11845 errmsg ("missing locator-set name");
11849 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
11851 errmsg ("missing sw_if_index");
11852 vec_free (locator_set_name);
11856 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
11858 errmsg ("cannot use both params interface name and sw_if_index");
11859 vec_free (locator_set_name);
11863 if (priority_set == 0)
11865 errmsg ("missing locator-set priority\n");
11866 vec_free (locator_set_name);
11870 if (weight_set == 0)
11872 errmsg ("missing locator-set weight\n");
11873 vec_free (locator_set_name);
11877 if (vec_len (locator_set_name) > 64)
11879 errmsg ("locator-set name too long\n");
11880 vec_free (locator_set_name);
11883 vec_add1 (locator_set_name, 0);
11885 /* Construct the API message */
11886 M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
11888 mp->is_add = is_add;
11889 mp->sw_if_index = ntohl (sw_if_index);
11890 mp->priority = priority;
11891 mp->weight = weight;
11892 clib_memcpy (mp->locator_set_name, locator_set_name,
11893 vec_len (locator_set_name));
11894 vec_free (locator_set_name);
11899 /* Wait for a reply... */
11907 api_lisp_add_del_local_eid (vat_main_t * vam)
11909 unformat_input_t *input = vam->input;
11910 vl_api_lisp_add_del_local_eid_t *mp;
11914 lisp_eid_vat_t _eid, *eid = &_eid;
11915 u8 *locator_set_name = 0;
11916 u8 locator_set_name_set = 0;
11919 /* Parse args required to build the message */
11920 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11922 if (unformat (input, "del"))
11926 else if (unformat (input, "vni %d", &vni))
11930 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
11934 else if (unformat (input, "locator-set %s", &locator_set_name))
11936 locator_set_name_set = 1;
11942 if (locator_set_name_set == 0)
11944 errmsg ("missing locator-set name\n");
11950 errmsg ("EID address not set!");
11951 vec_free (locator_set_name);
11955 if (vec_len (locator_set_name) > 64)
11957 errmsg ("locator-set name too long\n");
11958 vec_free (locator_set_name);
11961 vec_add1 (locator_set_name, 0);
11963 /* Construct the API message */
11964 M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
11966 mp->is_add = is_add;
11967 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
11968 mp->eid_type = eid->type;
11969 mp->prefix_len = eid->len;
11970 mp->vni = clib_host_to_net_u32 (vni);
11971 clib_memcpy (mp->locator_set_name, locator_set_name,
11972 vec_len (locator_set_name));
11974 vec_free (locator_set_name);
11979 /* Wait for a reply... */
11987 /** Used for transferring locators via VPP API */
11988 typedef CLIB_PACKED(struct
11990 u8 is_ip4; /**< is locator an IPv4 address? */
11991 u8 priority; /**< locator priority */
11992 u8 weight; /**< locator weight */
11993 u8 addr[16]; /**< IPv4/IPv6 address */
11998 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
12000 unformat_input_t *input = vam->input;
12001 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
12004 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
12005 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
12006 u8 rmt_eid_set = 0, lcl_eid_set = 0;
12007 u32 action = ~0, p, w;
12008 ip4_address_t rmt_rloc4, lcl_rloc4;
12009 ip6_address_t rmt_rloc6, lcl_rloc6;
12010 rloc_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
12012 memset (&rloc, 0, sizeof (rloc));
12014 /* Parse args required to build the message */
12015 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12017 if (unformat (input, "del"))
12021 else if (unformat (input, "rmt_eid %U", unformat_lisp_eid_vat, rmt_eid))
12025 else if (unformat (input, "lcl_eid %U", unformat_lisp_eid_vat, lcl_eid))
12029 else if (unformat (input, "p %d w %d", &p, &w))
12033 errmsg ("No RLOC configured for setting priority/weight!");
12036 curr_rloc->priority = p;
12037 curr_rloc->weight = w;
12039 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
12040 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
12044 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
12045 rloc.priority = rloc.weight = 0;
12046 vec_add1 (lcl_locs, rloc);
12048 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
12049 vec_add1 (rmt_locs, rloc);
12050 /* priority and weight saved in rmt loc */
12051 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
12053 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
12054 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
12057 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
12058 rloc.priority = rloc.weight = 0;
12059 vec_add1 (lcl_locs, rloc);
12061 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
12062 vec_add1 (rmt_locs, rloc);
12063 /* priority and weight saved in rmt loc */
12064 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
12066 else if (unformat (input, "action %d", &action))
12072 clib_warning ("parse error '%U'", format_unformat_error, input);
12079 errmsg ("remote eid addresses not set\n");
12083 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
12085 errmsg ("eid types don't match\n");
12089 if (0 == rmt_locs && (u32) ~ 0 == action)
12091 errmsg ("action not set for negative mapping\n");
12095 /* Construct the API message */
12096 M (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry);
12098 mp->is_add = is_add;
12099 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
12100 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
12101 mp->eid_type = rmt_eid->type;
12102 mp->rmt_len = rmt_eid->len;
12103 mp->lcl_len = lcl_eid->len;
12104 mp->action = action;
12106 if (0 != rmt_locs && 0 != lcl_locs)
12108 mp->loc_num = vec_len (rmt_locs);
12109 clib_memcpy (mp->lcl_locs, lcl_locs,
12110 (sizeof (rloc_t) * vec_len (lcl_locs)));
12111 clib_memcpy (mp->rmt_locs, rmt_locs,
12112 (sizeof (rloc_t) * vec_len (rmt_locs)));
12114 vec_free (lcl_locs);
12115 vec_free (rmt_locs);
12120 /* Wait for a reply... */
12128 api_lisp_add_del_map_resolver (vat_main_t * vam)
12130 unformat_input_t *input = vam->input;
12131 vl_api_lisp_add_del_map_resolver_t *mp;
12136 ip4_address_t ipv4;
12137 ip6_address_t ipv6;
12139 /* Parse args required to build the message */
12140 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12142 if (unformat (input, "del"))
12146 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
12150 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
12158 if (ipv4_set && ipv6_set)
12160 errmsg ("both eid v4 and v6 addresses set\n");
12164 if (!ipv4_set && !ipv6_set)
12166 errmsg ("eid addresses not set\n");
12170 /* Construct the API message */
12171 M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
12173 mp->is_add = is_add;
12177 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
12182 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
12188 /* Wait for a reply... */
12196 api_lisp_gpe_enable_disable (vat_main_t * vam)
12198 unformat_input_t *input = vam->input;
12199 vl_api_lisp_gpe_enable_disable_t *mp;
12204 /* Parse args required to build the message */
12205 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12207 if (unformat (input, "enable"))
12212 else if (unformat (input, "disable"))
12223 errmsg ("Value not set\n");
12227 /* Construct the API message */
12228 M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
12235 /* Wait for a reply... */
12243 api_lisp_enable_disable (vat_main_t * vam)
12245 unformat_input_t *input = vam->input;
12246 vl_api_lisp_enable_disable_t *mp;
12251 /* Parse args required to build the message */
12252 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12254 if (unformat (input, "enable"))
12259 else if (unformat (input, "disable"))
12269 errmsg ("Value not set\n");
12273 /* Construct the API message */
12274 M (LISP_ENABLE_DISABLE, lisp_enable_disable);
12281 /* Wait for a reply... */
12289 * Enable/disable LISP proxy ITR.
12291 * @param vam vpp API test context
12292 * @return return code
12295 api_lisp_pitr_set_locator_set (vat_main_t * vam)
12298 u8 ls_name_set = 0;
12299 unformat_input_t *input = vam->input;
12300 vl_api_lisp_pitr_set_locator_set_t *mp;
12304 /* Parse args required to build the message */
12305 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12307 if (unformat (input, "del"))
12309 else if (unformat (input, "locator-set %s", &ls_name))
12313 errmsg ("parse error '%U'", format_unformat_error, input);
12320 errmsg ("locator-set name not set!");
12324 M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set);
12326 mp->is_add = is_add;
12327 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
12328 vec_free (ls_name);
12333 /* wait for reply */
12341 api_show_lisp_pitr (vat_main_t * vam)
12343 vl_api_show_lisp_pitr_t *mp;
12346 if (!vam->json_output)
12348 fformat (vam->ofp, "%=20s\n", "lisp status:");
12351 M (SHOW_LISP_PITR, show_lisp_pitr);
12355 /* Wait for a reply... */
12363 * Add/delete mapping between vni and vrf
12366 api_lisp_eid_table_add_del_map (vat_main_t * vam)
12369 unformat_input_t *input = vam->input;
12370 vl_api_lisp_eid_table_add_del_map_t *mp;
12371 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
12372 u32 vni, vrf, bd_index;
12374 /* Parse args required to build the message */
12375 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12377 if (unformat (input, "del"))
12379 else if (unformat (input, "vrf %d", &vrf))
12381 else if (unformat (input, "bd_index %d", &bd_index))
12383 else if (unformat (input, "vni %d", &vni))
12389 if (!vni_set || (!vrf_set && !bd_index_set))
12391 errmsg ("missing arguments!");
12395 if (vrf_set && bd_index_set)
12397 errmsg ("error: both vrf and bd entered!");
12401 M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
12403 mp->is_add = is_add;
12404 mp->vni = htonl (vni);
12405 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
12406 mp->is_l2 = bd_index_set;
12411 /* wait for reply */
12419 * Add/del remote mapping to/from LISP control plane
12421 * @param vam vpp API test context
12422 * @return return code
12425 api_lisp_add_del_remote_mapping (vat_main_t * vam)
12427 unformat_input_t *input = vam->input;
12428 vl_api_lisp_add_del_remote_mapping_t *mp;
12431 //TODO: seid need remove
12432 lisp_eid_vat_t _eid, *eid = &_eid;
12433 lisp_eid_vat_t _seid, *seid = &_seid;
12434 u8 is_add = 1, del_all = 0, eid_set = 0;
12435 u32 action = ~0, p, w;
12436 ip4_address_t rloc4;
12437 ip6_address_t rloc6;
12438 rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
12440 memset (&rloc, 0, sizeof (rloc));
12442 /* Parse args required to build the message */
12443 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12445 if (unformat (input, "del-all"))
12449 else if (unformat (input, "del"))
12453 else if (unformat (input, "add"))
12457 else if (unformat (input, "deid %U", unformat_lisp_eid_vat, eid))
12461 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, &seid))
12463 //TODO: Need remove, but first must be remove from CSIT test
12465 else if (unformat (input, "vni %d", &vni))
12469 else if (unformat (input, "p %d w %d", &p, &w))
12473 errmsg ("No RLOC configured for setting priority/weight!");
12476 curr_rloc->priority = p;
12477 curr_rloc->weight = w;
12479 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
12482 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
12483 vec_add1 (rlocs, rloc);
12484 curr_rloc = &rlocs[vec_len (rlocs) - 1];
12486 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
12489 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
12490 vec_add1 (rlocs, rloc);
12491 curr_rloc = &rlocs[vec_len (rlocs) - 1];
12493 else if (unformat (input, "action %d", &action))
12499 clib_warning ("parse error '%U'", format_unformat_error, input);
12506 errmsg ("missing params!");
12510 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
12512 errmsg ("no action set for negative map-reply!");
12516 M (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping);
12517 mp->is_add = is_add;
12518 mp->vni = htonl (vni);
12519 mp->action = (u8) action;
12520 mp->eid_len = eid->len;
12521 mp->del_all = del_all;
12522 mp->eid_type = eid->type;
12523 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
12525 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
12526 clib_memcpy (mp->rlocs, rlocs, (sizeof (rloc_t) * vec_len (rlocs)));
12532 /* Wait for a reply... */
12540 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
12541 * forwarding entries in data-plane accordingly.
12543 * @param vam vpp API test context
12544 * @return return code
12547 api_lisp_add_del_adjacency (vat_main_t * vam)
12549 unformat_input_t *input = vam->input;
12550 vl_api_lisp_add_del_adjacency_t *mp;
12553 ip4_address_t seid4, deid4;
12554 ip6_address_t seid6, deid6;
12555 u8 deid_mac[6] = { 0 };
12556 u8 seid_mac[6] = { 0 };
12557 u8 deid_type, seid_type;
12558 u32 seid_len = 0, deid_len = 0, len;
12561 seid_type = deid_type = (u8) ~ 0;
12563 /* Parse args required to build the message */
12564 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12566 if (unformat (input, "del"))
12570 else if (unformat (input, "add"))
12574 else if (unformat (input, "deid %U/%d", unformat_ip4_address,
12577 deid_type = 0; /* ipv4 */
12580 else if (unformat (input, "deid %U/%d", unformat_ip6_address,
12583 deid_type = 1; /* ipv6 */
12586 else if (unformat (input, "deid %U", unformat_ethernet_address,
12589 deid_type = 2; /* mac */
12591 else if (unformat (input, "seid %U/%d", unformat_ip4_address,
12594 seid_type = 0; /* ipv4 */
12597 else if (unformat (input, "seid %U/%d", unformat_ip6_address,
12600 seid_type = 1; /* ipv6 */
12603 else if (unformat (input, "seid %U", unformat_ethernet_address,
12606 seid_type = 2; /* mac */
12608 else if (unformat (input, "vni %d", &vni))
12614 errmsg ("parse error '%U'", format_unformat_error, input);
12619 if ((u8) ~ 0 == deid_type)
12621 errmsg ("missing params!");
12625 if (seid_type != deid_type)
12627 errmsg ("source and destination EIDs are of different types!");
12631 M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency);
12632 mp->is_add = is_add;
12633 mp->vni = htonl (vni);
12634 mp->seid_len = seid_len;
12635 mp->deid_len = deid_len;
12636 mp->eid_type = deid_type;
12638 switch (mp->eid_type)
12641 clib_memcpy (mp->seid, &seid4, sizeof (seid4));
12642 clib_memcpy (mp->deid, &deid4, sizeof (deid4));
12645 clib_memcpy (mp->seid, &seid6, sizeof (seid6));
12646 clib_memcpy (mp->deid, &deid6, sizeof (deid6));
12649 clib_memcpy (mp->seid, seid_mac, 6);
12650 clib_memcpy (mp->deid, deid_mac, 6);
12653 errmsg ("unknown EID type %d!", mp->eid_type);
12660 /* Wait for a reply... */
12668 api_lisp_gpe_add_del_iface (vat_main_t * vam)
12670 unformat_input_t *input = vam->input;
12671 vl_api_lisp_gpe_add_del_iface_t *mp;
12673 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
12674 u32 dp_table = 0, vni = 0;
12676 /* Parse args required to build the message */
12677 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12679 if (unformat (input, "up"))
12684 else if (unformat (input, "down"))
12689 else if (unformat (input, "table_id %d", &dp_table))
12693 else if (unformat (input, "bd_id %d", &dp_table))
12698 else if (unformat (input, "vni %d", &vni))
12706 if (action_set == 0)
12708 errmsg ("Action not set\n");
12711 if (dp_table_set == 0 || vni_set == 0)
12713 errmsg ("vni and dp_table must be set\n");
12717 /* Construct the API message */
12718 M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
12720 mp->is_add = is_add;
12721 mp->dp_table = dp_table;
12728 /* Wait for a reply... */
12736 * Add/del map request itr rlocs from LISP control plane and updates
12738 * @param vam vpp API test context
12739 * @return return code
12742 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
12744 unformat_input_t *input = vam->input;
12745 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
12747 u8 *locator_set_name = 0;
12748 u8 locator_set_name_set = 0;
12751 /* Parse args required to build the message */
12752 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12754 if (unformat (input, "del"))
12758 else if (unformat (input, "%_%v%_", &locator_set_name))
12760 locator_set_name_set = 1;
12764 clib_warning ("parse error '%U'", format_unformat_error, input);
12769 if (is_add && !locator_set_name_set)
12771 errmsg ("itr-rloc is not set!");
12775 if (is_add && vec_len (locator_set_name) > 64)
12777 errmsg ("itr-rloc locator-set name too long\n");
12778 vec_free (locator_set_name);
12782 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs);
12783 mp->is_add = is_add;
12786 clib_memcpy (mp->locator_set_name, locator_set_name,
12787 vec_len (locator_set_name));
12791 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
12793 vec_free (locator_set_name);
12798 /* Wait for a reply... */
12806 lisp_locator_dump_send_msg (vat_main_t * vam, u32 locator_set_index,
12809 vl_api_lisp_locator_dump_t *mp;
12812 M (LISP_LOCATOR_DUMP, lisp_locator_dump);
12814 mp->locator_set_index = htonl (locator_set_index);
12815 mp->filter = filter;
12820 /* Use a control ping for synchronization */
12822 vl_api_noprint_control_ping_t *mp;
12823 M (NOPRINT_CONTROL_PING, noprint_control_ping);
12826 /* Wait for a reply... */
12831 clean_locator_set_message (vat_main_t * vam)
12833 locator_set_msg_t *ls = 0;
12835 vec_foreach (ls, vam->locator_set_msg)
12837 vec_free (ls->locator_set_name);
12840 vec_free (vam->locator_set_msg);
12844 print_locator_in_locator_set (vat_main_t * vam, u8 filter)
12846 locator_set_msg_t *ls;
12847 locator_msg_t *loc;
12849 int i = 0, ret = 0;
12851 vec_foreach (ls, vam->locator_set_msg)
12853 ret = lisp_locator_dump_send_msg (vam, ls->locator_set_index, filter);
12856 vec_free (vam->locator_msg);
12857 clean_locator_set_message (vam);
12861 tmp_str = format (0, "%=20s%=16d%s", ls->locator_set_name,
12862 ls->locator_set_index,
12863 vec_len (vam->locator_msg) ? "" : "\n");
12865 vec_foreach (loc, vam->locator_msg)
12869 tmp_str = format (tmp_str, "%=37s", " ");
12873 tmp_str = format (tmp_str, "%=16d%=16d%=16d\n",
12874 loc->sw_if_index, loc->priority, loc->weight);
12878 tmp_str = format (tmp_str, "%=16U%=16d%=16d\n",
12879 loc->is_ipv6 ? format_ip6_address :
12880 format_ip4_address,
12881 loc->ip_address, loc->priority, loc->weight);
12886 fformat (vam->ofp, "%s", tmp_str);
12887 vec_free (tmp_str);
12888 vec_free (vam->locator_msg);
12891 clean_locator_set_message (vam);
12897 json_locator_in_locator_set (vat_main_t * vam, u8 filter)
12899 locator_set_msg_t *ls;
12900 locator_msg_t *loc;
12901 vat_json_node_t *node = NULL;
12902 vat_json_node_t *locator_array;
12903 vat_json_node_t *locator;
12904 struct in6_addr ip6;
12905 struct in_addr ip4;
12908 if (!vec_len (vam->locator_set_msg))
12910 /* just print [] */
12911 vat_json_init_array (&vam->json_tree);
12912 vat_json_print (vam->ofp, &vam->json_tree);
12913 vam->json_tree.type = VAT_JSON_NONE;
12917 if (VAT_JSON_ARRAY != vam->json_tree.type)
12919 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12920 vat_json_init_array (&vam->json_tree);
12923 vec_foreach (ls, vam->locator_set_msg)
12925 ret = lisp_locator_dump_send_msg (vam, ls->locator_set_index, filter);
12928 vec_free (ls->locator_set_name);
12929 vec_free (vam->locator_msg);
12930 vec_free (vam->locator_set_msg);
12931 vat_json_free (&vam->json_tree);
12932 vam->json_tree.type = VAT_JSON_NONE;
12936 node = vat_json_array_add (&vam->json_tree);
12937 vat_json_init_object (node);
12939 vat_json_object_add_uint (node, "locator-set-index",
12940 ls->locator_set_index);
12941 vat_json_object_add_string_copy (node, "locator-set",
12942 ls->locator_set_name);
12943 locator_array = vat_json_object_add_list (node, "locator");
12944 vec_foreach (loc, vam->locator_msg)
12946 locator = vat_json_array_add (locator_array);
12947 vat_json_init_object (locator);
12950 vat_json_object_add_uint (locator, "locator-index",
12957 clib_memcpy (&ip6, loc->ip_address, sizeof (ip6));
12958 vat_json_object_add_ip6 (locator, "locator", ip6);
12962 clib_memcpy (&ip4, loc->ip_address, sizeof (ip4));
12963 vat_json_object_add_ip4 (locator, "locator", ip4);
12966 vat_json_object_add_uint (locator, "priority", loc->priority);
12967 vat_json_object_add_uint (locator, "weight", loc->weight);
12970 vec_free (ls->locator_set_name);
12971 vec_free (vam->locator_msg);
12974 vat_json_print (vam->ofp, &vam->json_tree);
12975 vat_json_free (&vam->json_tree);
12976 vam->json_tree.type = VAT_JSON_NONE;
12978 vec_free (vam->locator_set_msg);
12984 get_locator_set_index_from_msg (vat_main_t * vam, u8 * locator_set,
12985 u32 * locator_set_index)
12987 locator_set_msg_t *ls;
12990 *locator_set_index = ~0;
12992 if (!vec_len (vam->locator_set_msg))
12997 vec_foreach (ls, vam->locator_set_msg)
12999 if (!strcmp ((char *) locator_set, (char *) ls->locator_set_name))
13001 *locator_set_index = ls->locator_set_index;
13002 vec_free (vam->locator_set_msg);
13007 vec_free (vam->locator_set_msg);
13013 get_locator_set_index (vat_main_t * vam, u8 * locator_set,
13014 u32 * locator_set_index)
13016 vl_api_lisp_locator_set_dump_t *mp;
13019 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
13023 /* Use a control ping for synchronization */
13025 vl_api_noprint_control_ping_t *mp;
13026 M (NOPRINT_CONTROL_PING, noprint_control_ping);
13030 vam->noprint_msg = 1;
13031 /* Wait for a reply... */
13035 get_locator_set_index_from_msg (vam, locator_set, locator_set_index);
13036 vam->noprint_msg = 0;
13045 lisp_locator_dump (vat_main_t * vam, u32 locator_set_index, u8 * locator_set,
13052 if (!vam->json_output)
13054 fformat (vam->ofp, "%=20s%=16s%=16s\n",
13055 "locator", "priority", "weight");
13060 ret = get_locator_set_index (vam, locator_set, &locator_set_index);
13063 if (!ret && ~0 == locator_set_index)
13068 ret = lisp_locator_dump_send_msg (vam, locator_set_index, filter);
13074 lisp_locator_set_dump (vat_main_t * vam, u8 filter)
13076 vl_api_lisp_locator_set_dump_t *mp;
13079 if (!vam->json_output)
13081 fformat (vam->ofp, "%=20s%=16s%=16s%=16s%=16s\n",
13082 "locator-set", "locator-set-index", "locator", "priority",
13086 vam->noprint_msg = 1;
13088 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
13090 mp->filter = filter;
13095 /* Use a control ping for synchronization */
13097 vl_api_noprint_control_ping_t *mp;
13098 M (NOPRINT_CONTROL_PING, noprint_control_ping);
13102 /* Wait for a reply... */
13106 if (vam->noprint_msg)
13108 if (!vam->json_output)
13110 print_locator_in_locator_set(vam, filter);
13114 json_locator_in_locator_set(vam, filter);
13117 vam->noprint_msg = 0;
13126 api_lisp_locator_set_dump (vat_main_t * vam)
13128 unformat_input_t *input = vam->input;
13129 vam->noprint_msg = 0;
13130 u32 locator_set_index = ~0;
13131 u8 locator_set_index_set = 0;
13132 u8 *locator_set = 0;
13133 u8 locator_set_set = 0;
13137 /* Parse args required to build the message */
13138 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13140 if (unformat (input, "locator-set-index %u", &locator_set_index))
13142 locator_set_index_set = 1;
13144 else if (unformat (input, "locator-set %s", &locator_set))
13146 locator_set_set = 1;
13148 else if (unformat (input, "local"))
13152 else if (unformat (input, "remote"))
13162 if (locator_set_index_set && locator_set_set)
13164 errmsg ("use only input parameter!\n");
13168 if (locator_set_index_set || locator_set_set)
13170 ret = lisp_locator_dump (vam, locator_set_index, locator_set, filter);
13174 ret = lisp_locator_set_dump (vam, filter);
13177 vec_free (locator_set);
13183 api_lisp_eid_table_map_dump (vat_main_t * vam)
13187 unformat_input_t *input = vam->input;
13188 vl_api_lisp_eid_table_map_dump_t *mp;
13191 /* Parse args required to build the message */
13192 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13194 if (unformat (input, "l2"))
13199 else if (unformat (input, "l3"))
13206 errmsg ("parse error '%U'", format_unformat_error, input);
13213 errmsg ("expected one of 'l2' or 'l3' parameter!\n");
13217 if (!vam->json_output)
13219 fformat (vam->ofp, "%=10s%=10s\n", "VNI", is_l2 ? "BD" : "VRF");
13222 M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump);
13228 /* Use a control ping for synchronization */
13230 vl_api_control_ping_t *mp;
13231 M (CONTROL_PING, control_ping);
13234 /* Wait for a reply... */
13242 api_lisp_eid_table_vni_dump (vat_main_t * vam)
13244 vl_api_lisp_eid_table_vni_dump_t *mp;
13247 if (!vam->json_output)
13249 fformat (vam->ofp, "VNI\n");
13252 M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
13257 /* Use a control ping for synchronization */
13259 vl_api_control_ping_t *mp;
13260 M (CONTROL_PING, control_ping);
13263 /* Wait for a reply... */
13271 get_locator_set (vat_main_t * vam)
13273 vl_api_lisp_locator_set_dump_t *mp;
13276 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
13280 /* Use a control ping for synchronization */
13282 vl_api_noprint_control_ping_t *mp;
13283 M (NOPRINT_CONTROL_PING, noprint_control_ping);
13287 /* Wait for a reply... */
13295 format_eid_for_eid_table (vat_main_t * vam, u8 * str, eid_table_t * eid_table,
13298 u8 *(*format_eid) (u8 *, va_list *) = 0;
13300 ASSERT (vam != NULL);
13301 ASSERT (eid_table != NULL);
13308 switch (eid_table->eid_type)
13312 format_eid = (eid_table->eid_type ? format_ip6_address :
13313 format_ip4_address);
13314 str = format (0, "[%d] %U/%d", eid_table->vni,
13315 format_eid, eid_table->eid, eid_table->eid_prefix_len);
13318 str = format (0, "[%d] %U", eid_table->vni,
13319 format_ethernet_address, eid_table->eid);
13322 errmsg ("unknown EID type %d!", eid_table->eid_type);
13334 format_locator_set_for_eid_table (vat_main_t * vam, u8 * str,
13335 eid_table_t * eid_table)
13337 locator_set_msg_t *ls = 0;
13339 ASSERT (vam != NULL);
13340 ASSERT (eid_table != NULL);
13342 if (eid_table->is_local)
13344 vec_foreach (ls, vam->locator_set_msg)
13346 if (ls->locator_set_index == eid_table->locator_set_index)
13348 str = format (0, "local(%s)", ls->locator_set_name);
13353 str = format (0, "local(N/A)");
13357 str = format (0, "remote");
13364 format_locator_for_eid_table (vat_main_t * vam, u8 * str,
13365 eid_table_t * eid_table)
13367 locator_msg_t *loc = 0;
13368 int first_line = 1;
13370 ASSERT (vam != NULL);
13371 ASSERT (eid_table != NULL);
13373 if (~0 == eid_table->locator_set_index)
13375 return format (0, "action: %d\n", eid_table->action);
13378 vec_foreach (loc, vam->locator_msg)
13384 str = format (str, "%-55s%-d\n", " ", loc->sw_if_index);
13388 str = format (str, "%=55s%-U\n", " ",
13389 loc->is_ipv6 ? format_ip6_address :
13390 format_ip4_address, loc->ip_address);
13398 str = format (str, "%-30d%-20u%-u\n", loc->sw_if_index,
13399 eid_table->ttl, eid_table->authoritative);
13403 str = format (str, "%-30U%-20u%-u\n",
13404 loc->is_ipv6 ? format_ip6_address :
13405 format_ip4_address,
13406 loc->ip_address, eid_table->ttl,
13407 eid_table->authoritative);
13416 print_lisp_eid_table_dump (vat_main_t * vam)
13418 eid_table_t *eid_table = 0;
13419 u8 *tmp_str = 0, *tmp_str2 = 0;
13422 ASSERT (vam != NULL);
13424 ret = get_locator_set (vam);
13427 vec_free (vam->eid_tables);
13431 fformat (vam->ofp, "%-35s%-20s%-30s%-20s%-s\n", "EID", "type", "locators",
13432 "ttl", "authoritative");
13434 vec_foreach (eid_table, vam->eid_tables)
13436 if (~0 != eid_table->locator_set_index)
13438 ret = lisp_locator_dump_send_msg (vam, eid_table->locator_set_index,
13442 vec_free (vam->locator_msg);
13443 clean_locator_set_message (vam);
13444 vec_free (vam->eid_tables);
13449 tmp_str2 = format_eid_for_eid_table (vam, tmp_str2, eid_table, &ret);
13452 vec_free (vam->locator_msg);
13453 clean_locator_set_message (vam);
13454 vec_free (vam->eid_tables);
13458 tmp_str = format (0, "%-35s", tmp_str2);
13459 vec_free (tmp_str2);
13461 tmp_str2 = format_locator_set_for_eid_table (vam, tmp_str2, eid_table);
13462 tmp_str = format (tmp_str, "%-20s", tmp_str2);
13463 vec_free (tmp_str2);
13465 tmp_str2 = format_locator_for_eid_table (vam, tmp_str2, eid_table);
13466 tmp_str = format (tmp_str, "%-s", tmp_str2);
13467 vec_free (tmp_str2);
13469 fformat (vam->ofp, "%s", tmp_str);
13470 vec_free (tmp_str);
13471 vec_free (vam->locator_msg);
13474 clean_locator_set_message (vam);
13475 vec_free (vam->eid_tables);
13481 json_locator_set_for_eid_table (vat_main_t * vam, vat_json_node_t * node,
13482 eid_table_t * eid_table)
13484 locator_set_msg_t *ls = 0;
13487 ASSERT (vam != NULL);
13488 ASSERT (node != NULL);
13489 ASSERT (eid_table != NULL);
13491 if (eid_table->is_local)
13493 vec_foreach (ls, vam->locator_set_msg)
13495 if (ls->locator_set_index == eid_table->locator_set_index)
13497 vat_json_object_add_string_copy (node, "locator-set",
13498 ls->locator_set_name);
13503 s = format (0, "N/A");
13505 vat_json_object_add_string_copy (node, "locator-set", s);
13510 s = format (0, "remote");
13512 vat_json_object_add_string_copy (node, "locator-set", s);
13518 json_eid_for_eid_table (vat_main_t * vam, vat_json_node_t * node,
13519 eid_table_t * eid_table)
13522 struct in6_addr ip6;
13523 struct in_addr ip4;
13525 ASSERT (vam != NULL);
13526 ASSERT (node != NULL);
13527 ASSERT (eid_table != NULL);
13529 switch (eid_table->eid_type)
13532 clib_memcpy (&ip4, eid_table->eid, sizeof (ip4));
13533 vat_json_object_add_ip4 (node, "eid", ip4);
13534 vat_json_object_add_uint (node, "eid-prefix-len",
13535 eid_table->eid_prefix_len);
13538 clib_memcpy (&ip6, eid_table->eid, sizeof (ip6));
13539 vat_json_object_add_ip6 (node, "eid", ip6);
13540 vat_json_object_add_uint (node, "eid-prefix-len",
13541 eid_table->eid_prefix_len);
13544 s = format (0, "%U", format_ethernet_address, eid_table->eid);
13546 vat_json_object_add_string_copy (node, "eid", s);
13550 errmsg ("unknown EID type %d!", eid_table->eid_type);
13558 json_locator_for_eid_table (vat_main_t * vam, vat_json_node_t * node,
13559 eid_table_t * eid_table)
13561 locator_msg_t *loc = 0;
13562 vat_json_node_t *locator_array = 0;
13563 vat_json_node_t *locator = 0;
13564 struct in6_addr ip6;
13565 struct in_addr ip4;
13567 ASSERT (vam != NULL);
13568 ASSERT (node != NULL);
13569 ASSERT (eid_table != NULL);
13571 locator_array = vat_json_object_add_list (node, "locator");
13572 vec_foreach (loc, vam->locator_msg)
13574 locator = vat_json_array_add (locator_array);
13575 vat_json_init_object (locator);
13578 vat_json_object_add_uint (locator, "locator-index", loc->sw_if_index);
13584 clib_memcpy (&ip6, loc->ip_address, sizeof (ip6));
13585 vat_json_object_add_ip6 (locator, "locator", ip6);
13589 clib_memcpy (&ip4, loc->ip_address, sizeof (ip4));
13590 vat_json_object_add_ip4 (locator, "locator", ip4);
13597 json_lisp_eid_table_dump (vat_main_t * vam)
13599 eid_table_t *eid_table;
13600 vat_json_node_t *node = 0;
13603 ASSERT (vam != NULL);
13605 ret = get_locator_set (vam);
13608 vec_free (vam->eid_tables);
13612 if (!vec_len (vam->eid_tables))
13614 /* just print [] */
13615 vat_json_init_array (&vam->json_tree);
13616 vat_json_print (vam->ofp, &vam->json_tree);
13617 vam->json_tree.type = VAT_JSON_NONE;
13621 if (VAT_JSON_ARRAY != vam->json_tree.type)
13623 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13624 vat_json_init_array (&vam->json_tree);
13627 vec_foreach (eid_table, vam->eid_tables)
13629 ret = lisp_locator_dump_send_msg (vam, eid_table->locator_set_index, 0);
13632 vec_free (vam->locator_msg);
13633 vec_free (vam->eid_tables);
13634 clean_locator_set_message (vam);
13635 vat_json_free (&vam->json_tree);
13636 vam->json_tree.type = VAT_JSON_NONE;
13640 node = vat_json_array_add (&vam->json_tree);
13641 vat_json_init_object (node);
13643 vat_json_object_add_uint (node, "vni", eid_table->vni);
13645 json_locator_set_for_eid_table (vam, node, eid_table);
13646 ret = json_eid_for_eid_table (vam, node, eid_table);
13649 vec_free (vam->locator_msg);
13650 vec_free (vam->eid_tables);
13651 clean_locator_set_message (vam);
13652 vat_json_free (&vam->json_tree);
13653 vam->json_tree.type = VAT_JSON_NONE;
13657 json_locator_for_eid_table (vam, node, eid_table);
13659 vat_json_object_add_uint (node, "ttl", eid_table->ttl);
13660 vat_json_object_add_uint (node, "authoritative",
13661 eid_table->authoritative);
13663 vec_free (vam->locator_msg);
13666 vat_json_print (vam->ofp, &vam->json_tree);
13667 vat_json_free (&vam->json_tree);
13668 vam->json_tree.type = VAT_JSON_NONE;
13670 clean_locator_set_message (vam);
13671 vec_free (vam->eid_tables);
13677 api_lisp_eid_table_dump (vat_main_t * vam)
13679 unformat_input_t *i = vam->input;
13680 vl_api_lisp_eid_table_dump_t *mp;
13682 struct in_addr ip4;
13683 struct in6_addr ip6;
13685 u8 eid_type = ~0, eid_set = 0;
13686 u32 prefix_length = ~0, t, vni = 0;
13689 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13691 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
13697 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
13703 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
13708 else if (unformat (i, "vni %d", &t))
13712 else if (unformat (i, "local"))
13716 else if (unformat (i, "remote"))
13722 errmsg ("parse error '%U'", format_unformat_error, i);
13727 M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump);
13729 mp->filter = filter;
13733 mp->vni = htonl (vni);
13734 mp->eid_type = eid_type;
13738 mp->prefix_length = prefix_length;
13739 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
13742 mp->prefix_length = prefix_length;
13743 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
13746 clib_memcpy (mp->eid, mac, sizeof (mac));
13749 errmsg ("unknown EID type %d!", eid_type);
13754 vam->noprint_msg = 1;
13759 /* Use a control ping for synchronization */
13761 vl_api_noprint_control_ping_t *mp;
13762 M (NOPRINT_CONTROL_PING, noprint_control_ping);
13766 /* Wait for a reply... */
13770 if (vam->noprint_msg)
13772 if (!vam->json_output)
13774 vam->retval = print_lisp_eid_table_dump(vam);
13778 vam->retval = json_lisp_eid_table_dump(vam);
13781 vam->noprint_msg = 0;
13790 api_lisp_gpe_tunnel_dump (vat_main_t * vam)
13792 vl_api_lisp_gpe_tunnel_dump_t *mp;
13795 if (!vam->json_output)
13797 fformat (vam->ofp, "%=20s%=30s%=16s%=16s%=16s%=16s"
13798 "%=16s%=16s%=16s%=16s%=16s\n",
13799 "Tunel", "Source", "Destination", "Fib encap", "Fib decap",
13800 "Decap next", "Lisp version", "Flags", "Next protocol",
13801 "ver_res", "res", "iid");
13804 M (LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump);
13808 /* Use a control ping for synchronization */
13810 vl_api_control_ping_t *mp;
13811 M (CONTROL_PING, control_ping);
13814 /* Wait for a reply... */
13822 api_lisp_map_resolver_dump (vat_main_t * vam)
13824 vl_api_lisp_map_resolver_dump_t *mp;
13827 if (!vam->json_output)
13829 fformat (vam->ofp, "%=20s\n", "Map resolver");
13832 M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
13836 /* Use a control ping for synchronization */
13838 vl_api_control_ping_t *mp;
13839 M (CONTROL_PING, control_ping);
13842 /* Wait for a reply... */
13850 api_show_lisp_status (vat_main_t * vam)
13852 vl_api_show_lisp_status_t *mp;
13855 if (!vam->json_output)
13857 fformat (vam->ofp, "%-20s%-16s\n", "lisp status", "locator-set");
13860 M (SHOW_LISP_STATUS, show_lisp_status);
13863 /* Wait for a reply... */
13871 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
13873 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
13876 if (!vam->json_output)
13878 fformat (vam->ofp, "%=20s\n", "itr-rlocs:");
13881 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
13884 /* Wait for a reply... */
13892 api_af_packet_create (vat_main_t * vam)
13894 unformat_input_t *i = vam->input;
13895 vl_api_af_packet_create_t *mp;
13897 u8 *host_if_name = 0;
13899 u8 random_hw_addr = 1;
13901 memset (hw_addr, 0, sizeof (hw_addr));
13903 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13905 if (unformat (i, "name %s", &host_if_name))
13906 vec_add1 (host_if_name, 0);
13907 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
13908 random_hw_addr = 0;
13913 if (!vec_len (host_if_name))
13915 errmsg ("host-interface name must be specified");
13919 if (vec_len (host_if_name) > 64)
13921 errmsg ("host-interface name too long");
13925 M (AF_PACKET_CREATE, af_packet_create);
13927 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
13928 clib_memcpy (mp->hw_addr, hw_addr, 6);
13929 mp->use_random_hw_addr = random_hw_addr;
13930 vec_free (host_if_name);
13933 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
13939 api_af_packet_delete (vat_main_t * vam)
13941 unformat_input_t *i = vam->input;
13942 vl_api_af_packet_delete_t *mp;
13944 u8 *host_if_name = 0;
13946 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13948 if (unformat (i, "name %s", &host_if_name))
13949 vec_add1 (host_if_name, 0);
13954 if (!vec_len (host_if_name))
13956 errmsg ("host-interface name must be specified");
13960 if (vec_len (host_if_name) > 64)
13962 errmsg ("host-interface name too long");
13966 M (AF_PACKET_DELETE, af_packet_delete);
13968 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
13969 vec_free (host_if_name);
13978 api_policer_add_del (vat_main_t * vam)
13980 unformat_input_t *i = vam->input;
13981 vl_api_policer_add_del_t *mp;
13992 u8 color_aware = 0;
13993 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
13995 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
13996 conform_action.dscp = 0;
13997 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
13998 exceed_action.dscp = 0;
13999 violate_action.action_type = SSE2_QOS_ACTION_DROP;
14000 violate_action.dscp = 0;
14002 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14004 if (unformat (i, "del"))
14006 else if (unformat (i, "name %s", &name))
14007 vec_add1 (name, 0);
14008 else if (unformat (i, "cir %u", &cir))
14010 else if (unformat (i, "eir %u", &eir))
14012 else if (unformat (i, "cb %u", &cb))
14014 else if (unformat (i, "eb %u", &eb))
14016 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
14019 else if (unformat (i, "round_type %U", unformat_policer_round_type,
14022 else if (unformat (i, "type %U", unformat_policer_type, &type))
14024 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
14027 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
14030 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
14033 else if (unformat (i, "color-aware"))
14039 if (!vec_len (name))
14041 errmsg ("policer name must be specified");
14045 if (vec_len (name) > 64)
14047 errmsg ("policer name too long");
14051 M (POLICER_ADD_DEL, policer_add_del);
14053 clib_memcpy (mp->name, name, vec_len (name));
14055 mp->is_add = is_add;
14060 mp->rate_type = rate_type;
14061 mp->round_type = round_type;
14063 mp->conform_action_type = conform_action.action_type;
14064 mp->conform_dscp = conform_action.dscp;
14065 mp->exceed_action_type = exceed_action.action_type;
14066 mp->exceed_dscp = exceed_action.dscp;
14067 mp->violate_action_type = violate_action.action_type;
14068 mp->violate_dscp = violate_action.dscp;
14069 mp->color_aware = color_aware;
14078 api_policer_dump (vat_main_t * vam)
14080 unformat_input_t *i = vam->input;
14081 vl_api_policer_dump_t *mp;
14083 u8 *match_name = 0;
14084 u8 match_name_valid = 0;
14086 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14088 if (unformat (i, "name %s", &match_name))
14090 vec_add1 (match_name, 0);
14091 match_name_valid = 1;
14097 M (POLICER_DUMP, policer_dump);
14098 mp->match_name_valid = match_name_valid;
14099 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
14100 vec_free (match_name);
14104 /* Use a control ping for synchronization */
14106 vl_api_control_ping_t *mp;
14107 M (CONTROL_PING, control_ping);
14110 /* Wait for a reply... */
14118 api_policer_classify_set_interface (vat_main_t * vam)
14120 unformat_input_t *i = vam->input;
14121 vl_api_policer_classify_set_interface_t *mp;
14124 int sw_if_index_set;
14125 u32 ip4_table_index = ~0;
14126 u32 ip6_table_index = ~0;
14127 u32 l2_table_index = ~0;
14130 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14132 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
14133 sw_if_index_set = 1;
14134 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14135 sw_if_index_set = 1;
14136 else if (unformat (i, "del"))
14138 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14140 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14142 else if (unformat (i, "l2-table %d", &l2_table_index))
14146 clib_warning ("parse error '%U'", format_unformat_error, i);
14151 if (sw_if_index_set == 0)
14153 errmsg ("missing interface name or sw_if_index\n");
14157 M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface);
14159 mp->sw_if_index = ntohl (sw_if_index);
14160 mp->ip4_table_index = ntohl (ip4_table_index);
14161 mp->ip6_table_index = ntohl (ip6_table_index);
14162 mp->l2_table_index = ntohl (l2_table_index);
14163 mp->is_add = is_add;
14172 api_policer_classify_dump (vat_main_t * vam)
14174 unformat_input_t *i = vam->input;
14175 vl_api_policer_classify_dump_t *mp;
14177 u8 type = POLICER_CLASSIFY_N_TABLES;
14179 if (unformat (i, "type %U", unformat_classify_table_type, &type))
14183 errmsg ("classify table type must be specified\n");
14187 if (!vam->json_output)
14189 fformat (vam->ofp, "%10s%20s\n", "Intfc idx", "Classify table");
14192 M (POLICER_CLASSIFY_DUMP, policer_classify_dump);
14197 /* Use a control ping for synchronization */
14199 vl_api_control_ping_t *mp;
14200 M (CONTROL_PING, control_ping);
14203 /* Wait for a reply... */
14211 api_netmap_create (vat_main_t * vam)
14213 unformat_input_t *i = vam->input;
14214 vl_api_netmap_create_t *mp;
14218 u8 random_hw_addr = 1;
14222 memset (hw_addr, 0, sizeof (hw_addr));
14224 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14226 if (unformat (i, "name %s", &if_name))
14227 vec_add1 (if_name, 0);
14228 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14229 random_hw_addr = 0;
14230 else if (unformat (i, "pipe"))
14232 else if (unformat (i, "master"))
14234 else if (unformat (i, "slave"))
14240 if (!vec_len (if_name))
14242 errmsg ("interface name must be specified");
14246 if (vec_len (if_name) > 64)
14248 errmsg ("interface name too long");
14252 M (NETMAP_CREATE, netmap_create);
14254 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
14255 clib_memcpy (mp->hw_addr, hw_addr, 6);
14256 mp->use_random_hw_addr = random_hw_addr;
14257 mp->is_pipe = is_pipe;
14258 mp->is_master = is_master;
14259 vec_free (if_name);
14268 api_netmap_delete (vat_main_t * vam)
14270 unformat_input_t *i = vam->input;
14271 vl_api_netmap_delete_t *mp;
14275 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14277 if (unformat (i, "name %s", &if_name))
14278 vec_add1 (if_name, 0);
14283 if (!vec_len (if_name))
14285 errmsg ("interface name must be specified");
14289 if (vec_len (if_name) > 64)
14291 errmsg ("interface name too long");
14295 M (NETMAP_DELETE, netmap_delete);
14297 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
14298 vec_free (if_name);
14306 static void vl_api_mpls_gre_tunnel_details_t_handler
14307 (vl_api_mpls_gre_tunnel_details_t * mp)
14309 vat_main_t *vam = &vat_main;
14311 i32 len = ntohl (mp->nlabels);
14313 if (mp->l2_only == 0)
14315 fformat (vam->ofp, "[%d]: src %U, dst %U, adj %U/%d, labels ",
14316 ntohl (mp->tunnel_index),
14317 format_ip4_address, &mp->tunnel_src,
14318 format_ip4_address, &mp->tunnel_dst,
14319 format_ip4_address, &mp->intfc_address,
14320 ntohl (mp->mask_width));
14321 for (i = 0; i < len; i++)
14323 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14325 fformat (vam->ofp, "\n");
14326 fformat (vam->ofp, " inner fib index %d, outer fib index %d\n",
14327 ntohl (mp->inner_fib_index), ntohl (mp->outer_fib_index));
14331 fformat (vam->ofp, "[%d]: src %U, dst %U, key %U, labels ",
14332 ntohl (mp->tunnel_index),
14333 format_ip4_address, &mp->tunnel_src,
14334 format_ip4_address, &mp->tunnel_dst,
14335 format_ip4_address, &mp->intfc_address);
14336 for (i = 0; i < len; i++)
14338 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14340 fformat (vam->ofp, "\n");
14341 fformat (vam->ofp, " l2 interface %d, outer fib index %d\n",
14342 ntohl (mp->hw_if_index), ntohl (mp->outer_fib_index));
14346 static void vl_api_mpls_gre_tunnel_details_t_handler_json
14347 (vl_api_mpls_gre_tunnel_details_t * mp)
14349 vat_main_t *vam = &vat_main;
14350 vat_json_node_t *node = NULL;
14351 struct in_addr ip4;
14353 i32 len = ntohl (mp->nlabels);
14355 if (VAT_JSON_ARRAY != vam->json_tree.type)
14357 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14358 vat_json_init_array (&vam->json_tree);
14360 node = vat_json_array_add (&vam->json_tree);
14362 vat_json_init_object (node);
14363 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
14364 clib_memcpy (&ip4, &(mp->intfc_address), sizeof (ip4));
14365 vat_json_object_add_ip4 (node, "intfc_address", ip4);
14366 vat_json_object_add_uint (node, "inner_fib_index",
14367 ntohl (mp->inner_fib_index));
14368 vat_json_object_add_uint (node, "mask_width", ntohl (mp->mask_width));
14369 vat_json_object_add_uint (node, "encap_index", ntohl (mp->encap_index));
14370 vat_json_object_add_uint (node, "hw_if_index", ntohl (mp->hw_if_index));
14371 vat_json_object_add_uint (node, "l2_only", ntohl (mp->l2_only));
14372 clib_memcpy (&ip4, &(mp->tunnel_src), sizeof (ip4));
14373 vat_json_object_add_ip4 (node, "tunnel_src", ip4);
14374 clib_memcpy (&ip4, &(mp->tunnel_dst), sizeof (ip4));
14375 vat_json_object_add_ip4 (node, "tunnel_dst", ip4);
14376 vat_json_object_add_uint (node, "outer_fib_index",
14377 ntohl (mp->outer_fib_index));
14378 vat_json_object_add_uint (node, "label_count", len);
14379 for (i = 0; i < len; i++)
14381 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14386 api_mpls_gre_tunnel_dump (vat_main_t * vam)
14388 vl_api_mpls_gre_tunnel_dump_t *mp;
14392 /* Parse args required to build the message */
14393 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
14395 if (!unformat (vam->input, "tunnel_index %d", &index))
14402 fformat (vam->ofp, " tunnel_index %d\n", index);
14404 M (MPLS_GRE_TUNNEL_DUMP, mpls_gre_tunnel_dump);
14405 mp->tunnel_index = htonl (index);
14408 /* Use a control ping for synchronization */
14410 vl_api_control_ping_t *mp;
14411 M (CONTROL_PING, control_ping);
14417 static void vl_api_mpls_eth_tunnel_details_t_handler
14418 (vl_api_mpls_eth_tunnel_details_t * mp)
14420 vat_main_t *vam = &vat_main;
14422 i32 len = ntohl (mp->nlabels);
14424 fformat (vam->ofp, "[%d]: dst %U, adj %U/%d, labels ",
14425 ntohl (mp->tunnel_index),
14426 format_ethernet_address, &mp->tunnel_dst_mac,
14427 format_ip4_address, &mp->intfc_address, ntohl (mp->mask_width));
14428 for (i = 0; i < len; i++)
14430 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14432 fformat (vam->ofp, "\n");
14433 fformat (vam->ofp, " tx on %d, rx fib index %d\n",
14434 ntohl (mp->tx_sw_if_index), ntohl (mp->inner_fib_index));
14437 static void vl_api_mpls_eth_tunnel_details_t_handler_json
14438 (vl_api_mpls_eth_tunnel_details_t * mp)
14440 vat_main_t *vam = &vat_main;
14441 vat_json_node_t *node = NULL;
14442 struct in_addr ip4;
14444 i32 len = ntohl (mp->nlabels);
14446 if (VAT_JSON_ARRAY != vam->json_tree.type)
14448 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14449 vat_json_init_array (&vam->json_tree);
14451 node = vat_json_array_add (&vam->json_tree);
14453 vat_json_init_object (node);
14454 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
14455 clib_memcpy (&ip4, &(mp->intfc_address), sizeof (ip4));
14456 vat_json_object_add_ip4 (node, "intfc_address", ip4);
14457 vat_json_object_add_uint (node, "inner_fib_index",
14458 ntohl (mp->inner_fib_index));
14459 vat_json_object_add_uint (node, "mask_width", ntohl (mp->mask_width));
14460 vat_json_object_add_uint (node, "encap_index", ntohl (mp->encap_index));
14461 vat_json_object_add_uint (node, "hw_if_index", ntohl (mp->hw_if_index));
14462 vat_json_object_add_uint (node, "l2_only", ntohl (mp->l2_only));
14463 vat_json_object_add_string_copy (node, "tunnel_dst_mac",
14464 format (0, "%U", format_ethernet_address,
14465 &mp->tunnel_dst_mac));
14466 vat_json_object_add_uint (node, "tx_sw_if_index",
14467 ntohl (mp->tx_sw_if_index));
14468 vat_json_object_add_uint (node, "label_count", len);
14469 for (i = 0; i < len; i++)
14471 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14476 api_mpls_eth_tunnel_dump (vat_main_t * vam)
14478 vl_api_mpls_eth_tunnel_dump_t *mp;
14482 /* Parse args required to build the message */
14483 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
14485 if (!unformat (vam->input, "tunnel_index %d", &index))
14492 fformat (vam->ofp, " tunnel_index %d\n", index);
14494 M (MPLS_ETH_TUNNEL_DUMP, mpls_eth_tunnel_dump);
14495 mp->tunnel_index = htonl (index);
14498 /* Use a control ping for synchronization */
14500 vl_api_control_ping_t *mp;
14501 M (CONTROL_PING, control_ping);
14507 static void vl_api_mpls_fib_encap_details_t_handler
14508 (vl_api_mpls_fib_encap_details_t * mp)
14510 vat_main_t *vam = &vat_main;
14512 i32 len = ntohl (mp->nlabels);
14514 fformat (vam->ofp, "table %d, dest %U, label ",
14515 ntohl (mp->fib_index), format_ip4_address, &mp->dest, len);
14516 for (i = 0; i < len; i++)
14518 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14520 fformat (vam->ofp, "\n");
14523 static void vl_api_mpls_fib_encap_details_t_handler_json
14524 (vl_api_mpls_fib_encap_details_t * mp)
14526 vat_main_t *vam = &vat_main;
14527 vat_json_node_t *node = NULL;
14529 i32 len = ntohl (mp->nlabels);
14530 struct in_addr ip4;
14532 if (VAT_JSON_ARRAY != vam->json_tree.type)
14534 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14535 vat_json_init_array (&vam->json_tree);
14537 node = vat_json_array_add (&vam->json_tree);
14539 vat_json_init_object (node);
14540 vat_json_object_add_uint (node, "table", ntohl (mp->fib_index));
14541 vat_json_object_add_uint (node, "entry_index", ntohl (mp->entry_index));
14542 clib_memcpy (&ip4, &(mp->dest), sizeof (ip4));
14543 vat_json_object_add_ip4 (node, "dest", ip4);
14544 vat_json_object_add_uint (node, "s_bit", ntohl (mp->s_bit));
14545 vat_json_object_add_uint (node, "label_count", len);
14546 for (i = 0; i < len; i++)
14548 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14553 api_mpls_fib_encap_dump (vat_main_t * vam)
14555 vl_api_mpls_fib_encap_dump_t *mp;
14558 M (MPLS_FIB_ENCAP_DUMP, mpls_fib_encap_dump);
14561 /* Use a control ping for synchronization */
14563 vl_api_control_ping_t *mp;
14564 M (CONTROL_PING, control_ping);
14570 static void vl_api_mpls_fib_decap_details_t_handler
14571 (vl_api_mpls_fib_decap_details_t * mp)
14573 vat_main_t *vam = &vat_main;
14576 "RX table %d, TX table/intfc %u, swif_tag '%s', label %u, s_bit %u\n",
14577 ntohl (mp->rx_table_id), ntohl (mp->tx_table_id), mp->swif_tag,
14578 ntohl (mp->label), ntohl (mp->s_bit));
14581 static void vl_api_mpls_fib_decap_details_t_handler_json
14582 (vl_api_mpls_fib_decap_details_t * mp)
14584 vat_main_t *vam = &vat_main;
14585 vat_json_node_t *node = NULL;
14586 struct in_addr ip4;
14588 if (VAT_JSON_ARRAY != vam->json_tree.type)
14590 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14591 vat_json_init_array (&vam->json_tree);
14593 node = vat_json_array_add (&vam->json_tree);
14595 vat_json_init_object (node);
14596 vat_json_object_add_uint (node, "table", ntohl (mp->fib_index));
14597 vat_json_object_add_uint (node, "entry_index", ntohl (mp->entry_index));
14598 clib_memcpy (&ip4, &(mp->dest), sizeof (ip4));
14599 vat_json_object_add_ip4 (node, "dest", ip4);
14600 vat_json_object_add_uint (node, "s_bit", ntohl (mp->s_bit));
14601 vat_json_object_add_uint (node, "label", ntohl (mp->label));
14602 vat_json_object_add_uint (node, "rx_table_id", ntohl (mp->rx_table_id));
14603 vat_json_object_add_uint (node, "tx_table_id", ntohl (mp->tx_table_id));
14604 vat_json_object_add_string_copy (node, "swif_tag", mp->swif_tag);
14608 api_mpls_fib_decap_dump (vat_main_t * vam)
14610 vl_api_mpls_fib_decap_dump_t *mp;
14613 M (MPLS_FIB_DECAP_DUMP, mpls_fib_decap_dump);
14616 /* Use a control ping for synchronization */
14618 vl_api_control_ping_t *mp;
14619 M (CONTROL_PING, control_ping);
14626 api_classify_table_ids (vat_main_t * vam)
14628 vl_api_classify_table_ids_t *mp;
14631 /* Construct the API message */
14632 M (CLASSIFY_TABLE_IDS, classify_table_ids);
14642 api_classify_table_by_interface (vat_main_t * vam)
14644 unformat_input_t *input = vam->input;
14645 vl_api_classify_table_by_interface_t *mp;
14648 u32 sw_if_index = ~0;
14649 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14651 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
14653 else if (unformat (input, "sw_if_index %d", &sw_if_index))
14658 if (sw_if_index == ~0)
14660 errmsg ("missing interface name or sw_if_index\n");
14664 /* Construct the API message */
14665 M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
14667 mp->sw_if_index = ntohl (sw_if_index);
14676 api_classify_table_info (vat_main_t * vam)
14678 unformat_input_t *input = vam->input;
14679 vl_api_classify_table_info_t *mp;
14683 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14685 if (unformat (input, "table_id %d", &table_id))
14690 if (table_id == ~0)
14692 errmsg ("missing table id\n");
14696 /* Construct the API message */
14697 M (CLASSIFY_TABLE_INFO, classify_table_info);
14699 mp->table_id = ntohl (table_id);
14708 api_classify_session_dump (vat_main_t * vam)
14710 unformat_input_t *input = vam->input;
14711 vl_api_classify_session_dump_t *mp;
14715 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14717 if (unformat (input, "table_id %d", &table_id))
14722 if (table_id == ~0)
14724 errmsg ("missing table id\n");
14728 /* Construct the API message */
14729 M (CLASSIFY_SESSION_DUMP, classify_session_dump);
14731 mp->table_id = ntohl (table_id);
14734 /* Use a control ping for synchronization */
14736 vl_api_control_ping_t *mp;
14737 M (CONTROL_PING, control_ping);
14746 vl_api_ipfix_details_t_handler (vl_api_ipfix_details_t * mp)
14748 vat_main_t *vam = &vat_main;
14750 fformat (vam->ofp, "collector_address %U, collector_port %d, "
14751 "src_address %U, fib_index %u, path_mtu %u, "
14752 "template_interval %u\n",
14753 format_ip4_address, mp->collector_address,
14754 ntohs (mp->collector_port),
14755 format_ip4_address, mp->src_address,
14756 ntohl (mp->fib_index),
14757 ntohl (mp->path_mtu), ntohl (mp->template_interval));
14760 vam->result_ready = 1;
14764 vl_api_ipfix_details_t_handler_json (vl_api_ipfix_details_t * mp)
14766 vat_main_t *vam = &vat_main;
14767 vat_json_node_t node;
14768 struct in_addr collector_address;
14769 struct in_addr src_address;
14771 vat_json_init_object (&node);
14772 clib_memcpy (&collector_address, &mp->collector_address,
14773 sizeof (collector_address));
14774 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
14775 vat_json_object_add_uint (&node, "collector_port",
14776 ntohs (mp->collector_port));
14777 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
14778 vat_json_object_add_ip4 (&node, "src_address", src_address);
14779 vat_json_object_add_uint (&node, "fib_index", ntohl (mp->fib_index));
14780 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
14781 vat_json_object_add_uint (&node, "template_interval",
14782 ntohl (mp->template_interval));
14784 vat_json_print (vam->ofp, &node);
14785 vat_json_free (&node);
14787 vam->result_ready = 1;
14791 api_ipfix_dump (vat_main_t * vam)
14793 vl_api_ipfix_dump_t *mp;
14796 /* Construct the API message */
14797 M (IPFIX_DUMP, ipfix_dump);
14807 api_pg_create_interface (vat_main_t * vam)
14809 unformat_input_t *input = vam->input;
14810 vl_api_pg_create_interface_t *mp;
14814 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14816 if (unformat (input, "if_id %d", &if_id))
14823 errmsg ("missing pg interface index\n");
14827 /* Construct the API message */
14828 M (PG_CREATE_INTERFACE, pg_create_interface);
14830 mp->interface_id = ntohl (if_id);
14839 api_pg_capture (vat_main_t * vam)
14841 unformat_input_t *input = vam->input;
14842 vl_api_pg_capture_t *mp;
14848 u8 pcap_file_set = 0;
14850 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14852 if (unformat (input, "if_id %d", &if_id))
14854 else if (unformat (input, "pcap %s", &pcap_file))
14856 else if (unformat (input, "count %d", &count))
14858 else if (unformat (input, "disable"))
14865 errmsg ("missing pg interface index\n");
14868 if (pcap_file_set > 0)
14870 if (vec_len (pcap_file) > 255)
14872 errmsg ("pcap file name is too long\n");
14877 u32 name_len = vec_len (pcap_file);
14878 /* Construct the API message */
14879 M (PG_CAPTURE, pg_capture);
14881 mp->interface_id = ntohl (if_id);
14882 mp->is_enabled = enable;
14883 mp->count = ntohl (count);
14884 mp->pcap_name_length = ntohl (name_len);
14885 if (pcap_file_set != 0)
14887 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
14889 vec_free (pcap_file);
14898 api_pg_enable_disable (vat_main_t * vam)
14900 unformat_input_t *input = vam->input;
14901 vl_api_pg_enable_disable_t *mp;
14905 u8 stream_name_set = 0;
14906 u8 *stream_name = 0;
14907 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14909 if (unformat (input, "stream %s", &stream_name))
14910 stream_name_set = 1;
14911 else if (unformat (input, "disable"))
14917 if (stream_name_set > 0)
14919 if (vec_len (stream_name) > 255)
14921 errmsg ("stream name too long\n");
14926 u32 name_len = vec_len (stream_name);
14927 /* Construct the API message */
14928 M (PG_ENABLE_DISABLE, pg_enable_disable);
14930 mp->is_enabled = enable;
14931 if (stream_name_set != 0)
14933 mp->stream_name_length = ntohl (name_len);
14934 clib_memcpy (mp->stream_name, stream_name, name_len);
14936 vec_free (stream_name);
14945 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
14947 unformat_input_t *input = vam->input;
14948 vl_api_ip_source_and_port_range_check_add_del_t *mp;
14951 u16 *low_ports = 0;
14952 u16 *high_ports = 0;
14955 ip4_address_t ip4_addr;
14956 ip6_address_t ip6_addr;
14964 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14966 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
14972 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
14977 else if (unformat (input, "vrf %d", &vrf_id))
14979 else if (unformat (input, "del"))
14981 else if (unformat (input, "port %d", &tmp))
14983 if (tmp == 0 || tmp > 65535)
14985 errmsg ("port %d out of range", tmp);
14989 this_hi = this_low + 1;
14990 vec_add1 (low_ports, this_low);
14991 vec_add1 (high_ports, this_hi);
14993 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
14995 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
14997 errmsg ("incorrect range parameters\n");
15001 /* Note: in debug CLI +1 is added to high before
15002 passing to real fn that does "the work"
15003 (ip_source_and_port_range_check_add_del).
15004 This fn is a wrapper around the binary API fn a
15005 control plane will call, which expects this increment
15006 to have occurred. Hence letting the binary API control
15007 plane fn do the increment for consistency between VAT
15008 and other control planes.
15011 vec_add1 (low_ports, this_low);
15012 vec_add1 (high_ports, this_hi);
15018 if (prefix_set == 0)
15020 errmsg ("<address>/<mask> not specified\n");
15026 errmsg ("VRF ID required, not specified\n");
15033 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
15037 if (vec_len (low_ports) == 0)
15039 errmsg ("At least one port or port range required\n");
15043 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,
15044 ip_source_and_port_range_check_add_del);
15046 mp->is_add = is_add;
15051 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
15056 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
15059 mp->mask_length = length;
15060 mp->number_of_ranges = vec_len (low_ports);
15062 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
15063 vec_free (low_ports);
15065 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
15066 vec_free (high_ports);
15068 mp->vrf_id = ntohl (vrf_id);
15077 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
15079 unformat_input_t *input = vam->input;
15080 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
15082 u32 sw_if_index = ~0;
15084 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
15085 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
15088 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15090 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
15092 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15094 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
15096 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
15098 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
15100 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
15102 else if (unformat (input, "del"))
15108 if (sw_if_index == ~0)
15110 errmsg ("Interface required but not specified\n");
15116 errmsg ("VRF ID required but not specified\n");
15120 if (tcp_out_vrf_id == 0
15121 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
15124 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
15128 /* Construct the API message */
15129 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,
15130 ip_source_and_port_range_check_interface_add_del);
15132 mp->sw_if_index = ntohl (sw_if_index);
15133 mp->is_add = is_add;
15134 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
15135 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
15136 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
15137 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
15142 /* Wait for a reply... */
15147 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
15149 unformat_input_t *i = vam->input;
15150 vl_api_ipsec_gre_add_del_tunnel_t *mp;
15152 u32 local_sa_id = 0;
15153 u32 remote_sa_id = 0;
15154 ip4_address_t src_address;
15155 ip4_address_t dst_address;
15158 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15160 if (unformat (i, "local_sa %d", &local_sa_id))
15162 else if (unformat (i, "remote_sa %d", &remote_sa_id))
15164 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
15166 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
15168 else if (unformat (i, "del"))
15172 clib_warning ("parse error '%U'", format_unformat_error, i);
15177 M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel);
15179 mp->local_sa_id = ntohl (local_sa_id);
15180 mp->remote_sa_id = ntohl (remote_sa_id);
15181 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
15182 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
15183 mp->is_add = is_add;
15191 static void vl_api_ipsec_gre_tunnel_details_t_handler
15192 (vl_api_ipsec_gre_tunnel_details_t * mp)
15194 vat_main_t *vam = &vat_main;
15196 fformat (vam->ofp, "%11d%15U%15U%14d%14d\n",
15197 ntohl (mp->sw_if_index),
15198 format_ip4_address, &mp->src_address,
15199 format_ip4_address, &mp->dst_address,
15200 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
15203 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
15204 (vl_api_ipsec_gre_tunnel_details_t * mp)
15206 vat_main_t *vam = &vat_main;
15207 vat_json_node_t *node = NULL;
15208 struct in_addr ip4;
15210 if (VAT_JSON_ARRAY != vam->json_tree.type)
15212 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15213 vat_json_init_array (&vam->json_tree);
15215 node = vat_json_array_add (&vam->json_tree);
15217 vat_json_init_object (node);
15218 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15219 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
15220 vat_json_object_add_ip4 (node, "src_address", ip4);
15221 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
15222 vat_json_object_add_ip4 (node, "dst_address", ip4);
15223 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
15224 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
15228 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
15230 unformat_input_t *i = vam->input;
15231 vl_api_ipsec_gre_tunnel_dump_t *mp;
15234 u8 sw_if_index_set = 0;
15236 /* Parse args required to build the message */
15237 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15239 if (unformat (i, "sw_if_index %d", &sw_if_index))
15240 sw_if_index_set = 1;
15245 if (sw_if_index_set == 0)
15250 if (!vam->json_output)
15252 fformat (vam->ofp, "%11s%15s%15s%14s%14s\n",
15253 "sw_if_index", "src_address", "dst_address",
15254 "local_sa_id", "remote_sa_id");
15257 /* Get list of gre-tunnel interfaces */
15258 M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump);
15260 mp->sw_if_index = htonl (sw_if_index);
15264 /* Use a control ping for synchronization */
15266 vl_api_control_ping_t *mp;
15267 M (CONTROL_PING, control_ping);
15274 api_delete_subif (vat_main_t * vam)
15276 unformat_input_t *i = vam->input;
15277 vl_api_delete_subif_t *mp;
15279 u32 sw_if_index = ~0;
15281 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15283 if (unformat (i, "sw_if_index %d", &sw_if_index))
15289 if (sw_if_index == ~0)
15291 errmsg ("missing sw_if_index\n");
15295 /* Construct the API message */
15296 M (DELETE_SUBIF, delete_subif);
15297 mp->sw_if_index = ntohl (sw_if_index);
15304 q_or_quit (vat_main_t * vam)
15306 longjmp (vam->jump_buf, 1);
15307 return 0; /* not so much */
15311 q (vat_main_t * vam)
15313 return q_or_quit (vam);
15317 quit (vat_main_t * vam)
15319 return q_or_quit (vam);
15323 comment (vat_main_t * vam)
15329 cmd_cmp (void *a1, void *a2)
15334 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
15338 help (vat_main_t * vam)
15343 unformat_input_t *i = vam->input;
15346 if (unformat (i, "%s", &name))
15350 vec_add1 (name, 0);
15352 hs = hash_get_mem (vam->help_by_name, name);
15354 fformat (vam->ofp, "usage: %s %s\n", name, hs[0]);
15356 fformat (vam->ofp, "No such msg / command '%s'\n", name);
15361 fformat (vam->ofp, "Help is available for the following:\n");
15364 hash_foreach_pair (p, vam->function_by_name,
15366 vec_add1 (cmds, (u8 *)(p->key));
15370 vec_sort_with_function (cmds, cmd_cmp);
15372 for (j = 0; j < vec_len (cmds); j++)
15373 fformat (vam->ofp, "%s\n", cmds[j]);
15380 set (vat_main_t * vam)
15382 u8 *name = 0, *value = 0;
15383 unformat_input_t *i = vam->input;
15385 if (unformat (i, "%s", &name))
15387 /* The input buffer is a vector, not a string. */
15388 value = vec_dup (i->buffer);
15389 vec_delete (value, i->index, 0);
15390 /* Almost certainly has a trailing newline */
15391 if (value[vec_len (value) - 1] == '\n')
15392 value[vec_len (value) - 1] = 0;
15393 /* Make sure it's a proper string, one way or the other */
15394 vec_add1 (value, 0);
15395 (void) clib_macro_set_value (&vam->macro_main,
15396 (char *) name, (char *) value);
15399 errmsg ("usage: set <name> <value>\n");
15407 unset (vat_main_t * vam)
15411 if (unformat (vam->input, "%s", &name))
15412 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
15413 errmsg ("unset: %s wasn't set\n", name);
15426 macro_sort_cmp (void *a1, void *a2)
15428 macro_sort_t *s1 = a1;
15429 macro_sort_t *s2 = a2;
15431 return strcmp ((char *) (s1->name), (char *) (s2->name));
15435 dump_macro_table (vat_main_t * vam)
15437 macro_sort_t *sort_me = 0, *sm;
15442 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
15444 vec_add2 (sort_me, sm, 1);
15445 sm->name = (u8 *)(p->key);
15446 sm->value = (u8 *) (p->value[0]);
15450 vec_sort_with_function (sort_me, macro_sort_cmp);
15452 if (vec_len (sort_me))
15453 fformat (vam->ofp, "%-15s%s\n", "Name", "Value");
15455 fformat (vam->ofp, "The macro table is empty...\n");
15457 for (i = 0; i < vec_len (sort_me); i++)
15458 fformat (vam->ofp, "%-15s%s\n", sort_me[i].name, sort_me[i].value);
15463 dump_node_table (vat_main_t * vam)
15466 vlib_node_t *node, *next_node;
15468 if (vec_len (vam->graph_nodes) == 0)
15470 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
15474 for (i = 0; i < vec_len (vam->graph_nodes); i++)
15476 node = vam->graph_nodes[i];
15477 fformat (vam->ofp, "[%d] %s\n", i, node->name);
15478 for (j = 0; j < vec_len (node->next_nodes); j++)
15480 if (node->next_nodes[j] != ~0)
15482 next_node = vam->graph_nodes[node->next_nodes[j]];
15483 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
15491 search_node_table (vat_main_t * vam)
15493 unformat_input_t *line_input = vam->input;
15496 vlib_node_t *node, *next_node;
15499 if (vam->graph_node_index_by_name == 0)
15501 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
15505 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15507 if (unformat (line_input, "%s", &node_to_find))
15509 vec_add1 (node_to_find, 0);
15510 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
15513 fformat (vam->ofp, "%s not found...\n", node_to_find);
15516 node = vam->graph_nodes[p[0]];
15517 fformat (vam->ofp, "[%d] %s\n", p[0], node->name);
15518 for (j = 0; j < vec_len (node->next_nodes); j++)
15520 if (node->next_nodes[j] != ~0)
15522 next_node = vam->graph_nodes[node->next_nodes[j]];
15523 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
15530 clib_warning ("parse error '%U'", format_unformat_error,
15536 vec_free (node_to_find);
15545 script (vat_main_t * vam)
15548 char *save_current_file;
15549 unformat_input_t save_input;
15550 jmp_buf save_jump_buf;
15551 u32 save_line_number;
15553 FILE *new_fp, *save_ifp;
15555 if (unformat (vam->input, "%s", &s))
15557 new_fp = fopen ((char *) s, "r");
15560 errmsg ("Couldn't open script file %s\n", s);
15567 errmsg ("Missing script name\n");
15571 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
15572 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
15573 save_ifp = vam->ifp;
15574 save_line_number = vam->input_line_number;
15575 save_current_file = (char *) vam->current_file;
15577 vam->input_line_number = 0;
15579 vam->current_file = s;
15582 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
15583 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
15584 vam->ifp = save_ifp;
15585 vam->input_line_number = save_line_number;
15586 vam->current_file = (u8 *) save_current_file;
15593 echo (vat_main_t * vam)
15595 fformat (vam->ofp, "%v", vam->input->buffer);
15599 /* List of API message constructors, CLI names map to api_xxx */
15600 #define foreach_vpe_api_msg \
15601 _(create_loopback,"[mac <mac-addr>]") \
15602 _(sw_interface_dump,"") \
15603 _(sw_interface_set_flags, \
15604 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
15605 _(sw_interface_add_del_address, \
15606 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
15607 _(sw_interface_set_table, \
15608 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
15609 _(sw_interface_set_vpath, \
15610 "<intfc> | sw_if_index <id> enable | disable") \
15611 _(sw_interface_set_l2_xconnect, \
15612 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
15613 "enable | disable") \
15614 _(sw_interface_set_l2_bridge, \
15615 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
15616 "[shg <split-horizon-group>] [bvi]\n" \
15617 "enable | disable") \
15618 _(bridge_domain_add_del, \
15619 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n")\
15620 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
15622 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
15624 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
15626 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
15628 "tapname <name> mac <mac-addr> | random-mac") \
15630 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
15632 "<vpp-if-name> | sw_if_index <id>") \
15633 _(sw_interface_tap_dump, "") \
15634 _(ip_add_del_route, \
15635 "<addr>/<mask> via <addr> [vrf <n>]\n" \
15636 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
15637 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
15638 "[multipath] [count <n>]") \
15639 _(proxy_arp_add_del, \
15640 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
15641 _(proxy_arp_intfc_enable_disable, \
15642 "<intfc> | sw_if_index <id> enable | disable") \
15643 _(mpls_add_del_encap, \
15644 "label <n> dst <ip4-addr> [vrf <n>] [del]") \
15645 _(mpls_add_del_decap, \
15646 "label <n> [rx_vrf_id <n>] [tx_vrf_id] [s-bit-clear][del]") \
15647 _(mpls_gre_add_del_tunnel, \
15648 "inner_vrf_id <n> outer_vrf_id <n> src <ip4-address> dst <ip4-address>\n" \
15649 "adj <ip4-address>/<mask-width> [del]") \
15650 _(sw_interface_set_unnumbered, \
15651 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
15652 _(ip_neighbor_add_del, \
15653 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
15654 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
15655 _(reset_vrf, "vrf <id> [ipv6]") \
15656 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
15657 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
15658 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
15659 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
15660 "[outer_vlan_id_any][inner_vlan_id_any]") \
15661 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
15662 _(reset_fib, "vrf <n> [ipv6]") \
15663 _(dhcp_proxy_config, \
15664 "svr <v46-address> src <v46-address>\n" \
15665 "insert-cid <n> [del]") \
15666 _(dhcp_proxy_config_2, \
15667 "svr <v46-address> src <v46-address>\n" \
15668 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
15669 _(dhcp_proxy_set_vss, \
15670 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
15671 _(dhcp_client_config, \
15672 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
15673 _(set_ip_flow_hash, \
15674 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
15675 _(sw_interface_ip6_enable_disable, \
15676 "<intfc> | sw_if_index <id> enable | disable") \
15677 _(sw_interface_ip6_set_link_local_address, \
15678 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
15679 _(sw_interface_ip6nd_ra_prefix, \
15680 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
15681 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
15682 "[nolink] [isno]") \
15683 _(sw_interface_ip6nd_ra_config, \
15684 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
15685 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
15686 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
15687 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
15688 _(l2_patch_add_del, \
15689 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
15690 "enable | disable") \
15691 _(mpls_ethernet_add_del_tunnel, \
15692 "tx <intfc> | tx_sw_if_index <n> dst <mac-addr>\n" \
15693 "adj <ip4-addr>/<mw> dst <mac-addr> [del]") \
15694 _(mpls_ethernet_add_del_tunnel_2, \
15695 "inner_vrf_id <n> outer_vrf_id <n> next-hop <ip4-addr>\n" \
15696 "resolve-attempts <n> resolve-if-needed 0 | 1 [del]") \
15697 _(sr_tunnel_add_del, \
15698 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
15699 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
15700 "[policy <policy_name>]") \
15701 _(sr_policy_add_del, \
15702 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
15703 _(sr_multicast_map_add_del, \
15704 "address [ip6 multicast address] sr-policy [policy name] [del]") \
15705 _(classify_add_del_table, \
15706 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
15707 "[del] mask <mask-value>\n" \
15708 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>") \
15709 _(classify_add_del_session, \
15710 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
15711 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
15712 " [l3 [ip4|ip6]]") \
15713 _(classify_set_interface_ip_table, \
15714 "<intfc> | sw_if_index <nn> table <nn>") \
15715 _(classify_set_interface_l2_tables, \
15716 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
15717 " [other-table <nn>]") \
15718 _(get_node_index, "node <node-name") \
15719 _(add_node_next, "node <node-name> next <next-node-name>") \
15720 _(l2tpv3_create_tunnel, \
15721 "client_address <ip6-addr> our_address <ip6-addr>\n" \
15722 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n"\
15723 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
15724 _(l2tpv3_set_tunnel_cookies, \
15725 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
15726 "[new_remote_cookie <nn>]\n") \
15727 _(l2tpv3_interface_enable_disable, \
15728 "<intfc> | sw_if_index <nn> enable | disable") \
15729 _(l2tpv3_set_lookup_key, \
15730 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
15731 _(sw_if_l2tpv3_tunnel_dump, "") \
15732 _(vxlan_add_del_tunnel, \
15733 "src <ip-addr> dst <ip-addr> vni <vni> [encap-vrf-id <nn>]\n" \
15734 " [decap-next l2|ip4|ip6] [del]") \
15735 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
15736 _(gre_add_del_tunnel, \
15737 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [del]\n") \
15738 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
15739 _(l2_fib_clear_table, "") \
15740 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
15741 _(l2_interface_vlan_tag_rewrite, \
15742 "<intfc> | sw_if_index <nn> \n" \
15743 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
15744 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
15745 _(create_vhost_user_if, \
15746 "socket <filename> [server] [renumber <dev_instance>] " \
15747 "[mac <mac_address>]") \
15748 _(modify_vhost_user_if, \
15749 "<intfc> | sw_if_index <nn> socket <filename>\n" \
15750 "[server] [renumber <dev_instance>]") \
15751 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
15752 _(sw_interface_vhost_user_dump, "") \
15753 _(show_version, "") \
15754 _(vxlan_gpe_add_del_tunnel, \
15755 "local <addr> remote <addr> vni <nn>\n" \
15756 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
15757 "[next-ethernet] [next-nsh]\n") \
15758 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
15759 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
15760 _(interface_name_renumber, \
15761 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
15762 _(input_acl_set_interface, \
15763 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
15764 " [l2-table <nn>] [del]") \
15765 _(want_ip4_arp_events, "address <ip4-address> [del]") \
15766 _(want_ip6_nd_events, "address <ip6-address> [del]") \
15767 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
15768 _(ip_dump, "ipv4 | ipv6") \
15769 _(ipsec_spd_add_del, "spd_id <n> [del]") \
15770 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
15772 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
15773 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
15774 " integ_alg <alg> integ_key <hex>") \
15775 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
15776 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
15777 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
15778 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" )\
15779 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
15780 _(ikev2_profile_add_del, "name <profile_name> [del]") \
15781 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
15782 "(auth_data 0x<data> | auth_data <data>)") \
15783 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
15784 "(id_data 0x<data> | id_data <data>) (local|remote)") \
15785 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
15786 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
15787 "(local|remote)") \
15788 _(ikev2_set_local_key, "file <absolute_file_path>") \
15789 _(delete_loopback,"sw_if_index <nn>") \
15790 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
15791 _(map_add_domain, \
15792 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
15793 "ip6-src <ip6addr> " \
15794 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
15795 _(map_del_domain, "index <n>") \
15796 _(map_add_del_rule, \
15797 "index <n> psid <n> dst <ip6addr> [del]") \
15798 _(map_domain_dump, "") \
15799 _(map_rule_dump, "index <map-domain>") \
15800 _(want_interface_events, "enable|disable") \
15801 _(want_stats,"enable|disable") \
15802 _(get_first_msg_id, "client <name>") \
15803 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
15804 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
15805 "fib-id <nn> [ip4][ip6][default]") \
15806 _(get_node_graph, " ") \
15807 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
15808 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
15809 _(ioam_disable, "") \
15810 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
15811 " sw_if_index <sw_if_index> p <priority> " \
15812 "w <weight>] [del]") \
15813 _(lisp_add_del_locator, "locator-set <locator_name> " \
15814 "iface <intf> | sw_if_index <sw_if_index> " \
15815 "p <priority> w <weight> [del]") \
15816 _(lisp_add_del_local_eid,"vni <vni> eid " \
15817 "<ipv4|ipv6>/<prefix> | <L2 address> " \
15818 "locator-set <locator_name> [del]") \
15819 _(lisp_gpe_add_del_fwd_entry, "rmt_eid <eid> [lcl_eid <eid>] vni <vni>" \
15820 "dp_table <table> loc-pair <lcl_loc> <rmt_loc> ... [del]") \
15821 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
15822 _(lisp_gpe_enable_disable, "enable|disable") \
15823 _(lisp_enable_disable, "enable|disable") \
15824 _(lisp_gpe_add_del_iface, "up|down") \
15825 _(lisp_add_del_remote_mapping, "add|del vni <vni> deid <dest-eid> " \
15826 "rloc <locator> p <prio> " \
15827 "w <weight> [rloc <loc> ... ] " \
15828 "action <action> [del-all]") \
15829 _(lisp_add_del_adjacency, "add|del vni <vni> deid <dest-eid> seid " \
15830 "<src-eid> rloc <locator> p <prio> w <weight>"\
15831 "[rloc <loc> ... ] action <action>") \
15832 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
15833 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
15834 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
15835 _(lisp_locator_set_dump, "[locator-set-index <ls-index> | " \
15836 "locator-set <loc-set-name>] [local | remote]")\
15837 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
15838 "[local] | [remote]") \
15839 _(lisp_eid_table_vni_dump, "") \
15840 _(lisp_eid_table_map_dump, "l2|l3") \
15841 _(lisp_gpe_tunnel_dump, "") \
15842 _(lisp_map_resolver_dump, "") \
15843 _(show_lisp_status, "") \
15844 _(lisp_get_map_request_itr_rlocs, "") \
15845 _(show_lisp_pitr, "") \
15846 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
15847 _(af_packet_delete, "name <host interface name>") \
15848 _(policer_add_del, "name <policer name> <params> [del]") \
15849 _(policer_dump, "[name <policer name>]") \
15850 _(policer_classify_set_interface, \
15851 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
15852 " [l2-table <nn>] [del]") \
15853 _(policer_classify_dump, "type [ip4|ip6|l2]") \
15854 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
15855 "[master|slave]") \
15856 _(netmap_delete, "name <interface name>") \
15857 _(mpls_gre_tunnel_dump, "tunnel_index <tunnel-id>") \
15858 _(mpls_eth_tunnel_dump, "tunnel_index <tunnel-id>") \
15859 _(mpls_fib_encap_dump, "") \
15860 _(mpls_fib_decap_dump, "") \
15861 _(classify_table_ids, "") \
15862 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
15863 _(classify_table_info, "table_id <nn>") \
15864 _(classify_session_dump, "table_id <nn>") \
15865 _(ipfix_enable, "collector_address <ip4> [collector_port <nn>] " \
15866 "src_address <ip4> [fib_id <nn>] [path_mtu <nn>] " \
15867 "[template_interval <nn>]") \
15868 _(ipfix_dump, "") \
15869 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
15870 _(pg_create_interface, "if_id <nn>") \
15871 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
15872 _(pg_enable_disable, "[stream <id>] disable") \
15873 _(ip_source_and_port_range_check_add_del, \
15874 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
15875 _(ip_source_and_port_range_check_interface_add_del, \
15876 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
15877 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
15878 _(ipsec_gre_add_del_tunnel, \
15879 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
15880 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
15881 _(delete_subif,"sub_sw_if_index <nn> sub_if_id <nn>")
15883 /* List of command functions, CLI names map directly to functions */
15884 #define foreach_cli_function \
15885 _(comment, "usage: comment <ignore-rest-of-line>") \
15886 _(dump_interface_table, "usage: dump_interface_table") \
15887 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
15888 _(dump_ipv4_table, "usage: dump_ipv4_table") \
15889 _(dump_ipv6_table, "usage: dump_ipv6_table") \
15890 _(dump_stats_table, "usage: dump_stats_table") \
15891 _(dump_macro_table, "usage: dump_macro_table ") \
15892 _(dump_node_table, "usage: dump_node_table") \
15893 _(echo, "usage: echo <message>") \
15894 _(exec, "usage: exec <vpe-debug-CLI-command>") \
15895 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
15896 _(help, "usage: help") \
15897 _(q, "usage: quit") \
15898 _(quit, "usage: quit") \
15899 _(search_node_table, "usage: search_node_table <name>...") \
15900 _(set, "usage: set <variable-name> <value>") \
15901 _(script, "usage: script <file-name>") \
15902 _(unset, "usage: unset <variable-name>")
15905 static void vl_api_##n##_t_handler_uni \
15906 (vl_api_##n##_t * mp) \
15908 vat_main_t * vam = &vat_main; \
15909 if (vam->json_output) { \
15910 vl_api_##n##_t_handler_json(mp); \
15912 vl_api_##n##_t_handler(mp); \
15915 foreach_vpe_api_reply_msg;
15919 vat_api_hookup (vat_main_t * vam)
15922 vl_msg_api_set_handlers(VL_API_##N, #n, \
15923 vl_api_##n##_t_handler_uni, \
15925 vl_api_##n##_t_endian, \
15926 vl_api_##n##_t_print, \
15927 sizeof(vl_api_##n##_t), 1);
15928 foreach_vpe_api_reply_msg;
15931 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
15933 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
15935 vam->function_by_name = hash_create_string (0, sizeof (uword));
15937 vam->help_by_name = hash_create_string (0, sizeof (uword));
15939 /* API messages we can send */
15940 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
15941 foreach_vpe_api_msg;
15945 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
15946 foreach_vpe_api_msg;
15949 /* CLI functions */
15950 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
15951 foreach_cli_function;
15955 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
15956 foreach_cli_function;
15960 #undef vl_api_version
15961 #define vl_api_version(n,v) static u32 vpe_api_version = v;
15962 #include <vpp-api/vpe.api.h>
15963 #undef vl_api_version
15966 vl_client_add_api_signatures (vl_api_memclnt_create_t * mp)
15969 * Send the main API signature in slot 0. This bit of code must
15970 * match the checks in ../vpe/api/api.c: vl_msg_api_version_check().
15972 mp->api_versions[0] = clib_host_to_net_u32 (vpe_api_version);
15976 * fd.io coding-style-patch-verification: ON
15979 * eval: (c-set-style "gnu")