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;
896 static void vl_api_classify_add_del_table_reply_t_handler
897 (vl_api_classify_add_del_table_reply_t * mp)
899 vat_main_t *vam = &vat_main;
900 i32 retval = ntohl (mp->retval);
903 vam->async_errors += (retval < 0);
907 vam->retval = retval;
909 ((mp->new_table_index != 0xFFFFFFFF) ||
910 (mp->skip_n_vectors != 0xFFFFFFFF) ||
911 (mp->match_n_vectors != 0xFFFFFFFF)))
913 * Note: this is just barely thread-safe, depends on
914 * the main thread spinning waiting for an answer...
916 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d\n",
917 ntohl (mp->new_table_index),
918 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
919 vam->result_ready = 1;
923 static void vl_api_classify_add_del_table_reply_t_handler_json
924 (vl_api_classify_add_del_table_reply_t * mp)
926 vat_main_t *vam = &vat_main;
927 vat_json_node_t node;
929 vat_json_init_object (&node);
930 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
931 vat_json_object_add_uint (&node, "new_table_index",
932 ntohl (mp->new_table_index));
933 vat_json_object_add_uint (&node, "skip_n_vectors",
934 ntohl (mp->skip_n_vectors));
935 vat_json_object_add_uint (&node, "match_n_vectors",
936 ntohl (mp->match_n_vectors));
938 vat_json_print (vam->ofp, &node);
939 vat_json_free (&node);
941 vam->retval = ntohl (mp->retval);
942 vam->result_ready = 1;
945 static void vl_api_get_node_index_reply_t_handler
946 (vl_api_get_node_index_reply_t * mp)
948 vat_main_t *vam = &vat_main;
949 i32 retval = ntohl (mp->retval);
952 vam->async_errors += (retval < 0);
956 vam->retval = retval;
958 errmsg ("node index %d\n", ntohl (mp->node_index));
959 vam->result_ready = 1;
963 static void vl_api_get_node_index_reply_t_handler_json
964 (vl_api_get_node_index_reply_t * mp)
966 vat_main_t *vam = &vat_main;
967 vat_json_node_t node;
969 vat_json_init_object (&node);
970 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
971 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
973 vat_json_print (vam->ofp, &node);
974 vat_json_free (&node);
976 vam->retval = ntohl (mp->retval);
977 vam->result_ready = 1;
980 static void vl_api_get_next_index_reply_t_handler
981 (vl_api_get_next_index_reply_t * mp)
983 vat_main_t *vam = &vat_main;
984 i32 retval = ntohl (mp->retval);
987 vam->async_errors += (retval < 0);
991 vam->retval = retval;
993 errmsg ("next node index %d\n", ntohl (mp->next_index));
994 vam->result_ready = 1;
998 static void vl_api_get_next_index_reply_t_handler_json
999 (vl_api_get_next_index_reply_t * mp)
1001 vat_main_t *vam = &vat_main;
1002 vat_json_node_t node;
1004 vat_json_init_object (&node);
1005 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1006 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1008 vat_json_print (vam->ofp, &node);
1009 vat_json_free (&node);
1011 vam->retval = ntohl (mp->retval);
1012 vam->result_ready = 1;
1015 static void vl_api_add_node_next_reply_t_handler
1016 (vl_api_add_node_next_reply_t * mp)
1018 vat_main_t *vam = &vat_main;
1019 i32 retval = ntohl (mp->retval);
1020 if (vam->async_mode)
1022 vam->async_errors += (retval < 0);
1026 vam->retval = retval;
1028 errmsg ("next index %d\n", ntohl (mp->next_index));
1029 vam->result_ready = 1;
1033 static void vl_api_add_node_next_reply_t_handler_json
1034 (vl_api_add_node_next_reply_t * mp)
1036 vat_main_t *vam = &vat_main;
1037 vat_json_node_t node;
1039 vat_json_init_object (&node);
1040 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1041 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1043 vat_json_print (vam->ofp, &node);
1044 vat_json_free (&node);
1046 vam->retval = ntohl (mp->retval);
1047 vam->result_ready = 1;
1050 static void vl_api_mpls_gre_add_del_tunnel_reply_t_handler
1051 (vl_api_mpls_gre_add_del_tunnel_reply_t * mp)
1053 vat_main_t *vam = &vat_main;
1054 i32 retval = ntohl (mp->retval);
1055 u32 sw_if_index = ntohl (mp->tunnel_sw_if_index);
1057 if (retval >= 0 && sw_if_index != (u32) ~ 0)
1059 errmsg ("tunnel_sw_if_index %d\n", sw_if_index);
1061 vam->retval = retval;
1062 vam->result_ready = 1;
1065 static void vl_api_mpls_gre_add_del_tunnel_reply_t_handler_json
1066 (vl_api_mpls_gre_add_del_tunnel_reply_t * mp)
1068 vat_main_t *vam = &vat_main;
1069 vat_json_node_t node;
1071 vat_json_init_object (&node);
1072 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1073 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1074 ntohl (mp->tunnel_sw_if_index));
1076 vat_json_print (vam->ofp, &node);
1077 vat_json_free (&node);
1079 vam->retval = ntohl (mp->retval);
1080 vam->result_ready = 1;
1084 static void vl_api_show_version_reply_t_handler
1085 (vl_api_show_version_reply_t * mp)
1087 vat_main_t *vam = &vat_main;
1088 i32 retval = ntohl (mp->retval);
1092 errmsg (" program: %s\n", mp->program);
1093 errmsg (" version: %s\n", mp->version);
1094 errmsg (" build date: %s\n", mp->build_date);
1095 errmsg ("build directory: %s\n", mp->build_directory);
1097 vam->retval = retval;
1098 vam->result_ready = 1;
1101 static void vl_api_show_version_reply_t_handler_json
1102 (vl_api_show_version_reply_t * mp)
1104 vat_main_t *vam = &vat_main;
1105 vat_json_node_t node;
1107 vat_json_init_object (&node);
1108 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1109 vat_json_object_add_string_copy (&node, "program", mp->program);
1110 vat_json_object_add_string_copy (&node, "version", mp->version);
1111 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1112 vat_json_object_add_string_copy (&node, "build_directory",
1113 mp->build_directory);
1115 vat_json_print (vam->ofp, &node);
1116 vat_json_free (&node);
1118 vam->retval = ntohl (mp->retval);
1119 vam->result_ready = 1;
1123 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1125 vat_main_t *vam = &vat_main;
1126 errmsg ("arp event: address %U new mac %U sw_if_index %d\n",
1127 format_ip4_address, &mp->address,
1128 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1132 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1134 /* JSON output not supported */
1138 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1140 vat_main_t *vam = &vat_main;
1141 errmsg ("ip6 nd event: address %U new mac %U sw_if_index %d\n",
1142 format_ip6_address, mp->address,
1143 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1147 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1149 /* JSON output not supported */
1153 * Special-case: build the bridge domain table, maintain
1154 * the next bd id vbl.
1156 static void vl_api_bridge_domain_details_t_handler
1157 (vl_api_bridge_domain_details_t * mp)
1159 vat_main_t *vam = &vat_main;
1160 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1162 fformat (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s\n",
1163 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1165 fformat (vam->ofp, "%3d %3d %3d %3d %3d %3d\n",
1166 ntohl (mp->bd_id), mp->learn, mp->forward,
1167 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1170 fformat (vam->ofp, "\n\n%s %s %s\n", "sw_if_index", "SHG",
1174 static void vl_api_bridge_domain_details_t_handler_json
1175 (vl_api_bridge_domain_details_t * mp)
1177 vat_main_t *vam = &vat_main;
1178 vat_json_node_t *node, *array = NULL;
1180 if (VAT_JSON_ARRAY != vam->json_tree.type)
1182 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1183 vat_json_init_array (&vam->json_tree);
1185 node = vat_json_array_add (&vam->json_tree);
1187 vat_json_init_object (node);
1188 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1189 vat_json_object_add_uint (node, "flood", mp->flood);
1190 vat_json_object_add_uint (node, "forward", mp->forward);
1191 vat_json_object_add_uint (node, "learn", mp->learn);
1192 vat_json_object_add_uint (node, "bvi_sw_if_index",
1193 ntohl (mp->bvi_sw_if_index));
1194 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1195 array = vat_json_object_add (node, "sw_if");
1196 vat_json_init_array (array);
1200 * Special-case: build the bridge domain sw if table.
1202 static void vl_api_bridge_domain_sw_if_details_t_handler
1203 (vl_api_bridge_domain_sw_if_details_t * mp)
1205 vat_main_t *vam = &vat_main;
1210 sw_if_index = ntohl (mp->sw_if_index);
1212 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1214 if ((u32) p->value[0] == sw_if_index)
1216 sw_if_name = (u8 *)(p->key);
1222 fformat (vam->ofp, "%7d %3d %s", sw_if_index,
1223 mp->shg, sw_if_name ? (char *) sw_if_name :
1224 "sw_if_index not found!");
1227 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1228 (vl_api_bridge_domain_sw_if_details_t * mp)
1230 vat_main_t *vam = &vat_main;
1231 vat_json_node_t *node = NULL;
1232 uword last_index = 0;
1234 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1235 ASSERT (vec_len (vam->json_tree.array) >= 1);
1236 last_index = vec_len (vam->json_tree.array) - 1;
1237 node = &vam->json_tree.array[last_index];
1238 node = vat_json_object_get_element (node, "sw_if");
1239 ASSERT (NULL != node);
1240 node = vat_json_array_add (node);
1242 vat_json_init_object (node);
1243 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1244 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1245 vat_json_object_add_uint (node, "shg", mp->shg);
1248 static void vl_api_control_ping_reply_t_handler
1249 (vl_api_control_ping_reply_t * mp)
1251 vat_main_t *vam = &vat_main;
1252 i32 retval = ntohl (mp->retval);
1253 if (vam->async_mode)
1255 vam->async_errors += (retval < 0);
1259 vam->retval = retval;
1260 vam->result_ready = 1;
1264 static void vl_api_control_ping_reply_t_handler_json
1265 (vl_api_control_ping_reply_t * mp)
1267 vat_main_t *vam = &vat_main;
1268 i32 retval = ntohl (mp->retval);
1270 if (VAT_JSON_NONE != vam->json_tree.type)
1272 vat_json_print (vam->ofp, &vam->json_tree);
1273 vat_json_free (&vam->json_tree);
1274 vam->json_tree.type = VAT_JSON_NONE;
1279 vat_json_init_array (&vam->json_tree);
1280 vat_json_print (vam->ofp, &vam->json_tree);
1281 vam->json_tree.type = VAT_JSON_NONE;
1284 vam->retval = retval;
1285 vam->result_ready = 1;
1288 static void vl_api_noprint_control_ping_reply_t_handler
1289 (vl_api_noprint_control_ping_reply_t * mp)
1291 vat_main_t *vam = &vat_main;
1292 i32 retval = ntohl (mp->retval);
1293 if (vam->async_mode)
1295 vam->async_errors += (retval < 0);
1299 vam->retval = retval;
1300 vam->result_ready = 1;
1304 static void vl_api_noprint_control_ping_reply_t_handler_json
1305 (vl_api_noprint_control_ping_reply_t * mp)
1307 vat_main_t *vam = &vat_main;
1308 i32 retval = ntohl (mp->retval);
1310 if (vam->noprint_msg)
1312 vam->retval = retval;
1313 vam->result_ready = 1;
1317 if (VAT_JSON_NONE != vam->json_tree.type)
1319 vat_json_print (vam->ofp, &vam->json_tree);
1320 vat_json_free (&vam->json_tree);
1321 vam->json_tree.type = VAT_JSON_NONE;
1326 vat_json_init_array (&vam->json_tree);
1327 vat_json_print (vam->ofp, &vam->json_tree);
1328 vam->json_tree.type = VAT_JSON_NONE;
1331 vam->retval = retval;
1332 vam->result_ready = 1;
1336 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1338 vat_main_t *vam = &vat_main;
1339 i32 retval = ntohl (mp->retval);
1340 if (vam->async_mode)
1342 vam->async_errors += (retval < 0);
1346 vam->retval = retval;
1347 vam->result_ready = 1;
1351 static void vl_api_l2_flags_reply_t_handler_json
1352 (vl_api_l2_flags_reply_t * mp)
1354 vat_main_t *vam = &vat_main;
1355 vat_json_node_t node;
1357 vat_json_init_object (&node);
1358 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1359 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1360 ntohl (mp->resulting_feature_bitmap));
1362 vat_json_print (vam->ofp, &node);
1363 vat_json_free (&node);
1365 vam->retval = ntohl (mp->retval);
1366 vam->result_ready = 1;
1369 static void vl_api_bridge_flags_reply_t_handler
1370 (vl_api_bridge_flags_reply_t * mp)
1372 vat_main_t *vam = &vat_main;
1373 i32 retval = ntohl (mp->retval);
1374 if (vam->async_mode)
1376 vam->async_errors += (retval < 0);
1380 vam->retval = retval;
1381 vam->result_ready = 1;
1385 static void vl_api_bridge_flags_reply_t_handler_json
1386 (vl_api_bridge_flags_reply_t * mp)
1388 vat_main_t *vam = &vat_main;
1389 vat_json_node_t node;
1391 vat_json_init_object (&node);
1392 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1393 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1394 ntohl (mp->resulting_feature_bitmap));
1396 vat_json_print (vam->ofp, &node);
1397 vat_json_free (&node);
1399 vam->retval = ntohl (mp->retval);
1400 vam->result_ready = 1;
1403 static void vl_api_tap_connect_reply_t_handler
1404 (vl_api_tap_connect_reply_t * mp)
1406 vat_main_t *vam = &vat_main;
1407 i32 retval = ntohl (mp->retval);
1408 if (vam->async_mode)
1410 vam->async_errors += (retval < 0);
1414 vam->retval = retval;
1415 vam->sw_if_index = ntohl (mp->sw_if_index);
1416 vam->result_ready = 1;
1421 static void vl_api_tap_connect_reply_t_handler_json
1422 (vl_api_tap_connect_reply_t * mp)
1424 vat_main_t *vam = &vat_main;
1425 vat_json_node_t node;
1427 vat_json_init_object (&node);
1428 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1429 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1431 vat_json_print (vam->ofp, &node);
1432 vat_json_free (&node);
1434 vam->retval = ntohl (mp->retval);
1435 vam->result_ready = 1;
1440 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1442 vat_main_t *vam = &vat_main;
1443 i32 retval = ntohl (mp->retval);
1444 if (vam->async_mode)
1446 vam->async_errors += (retval < 0);
1450 vam->retval = retval;
1451 vam->sw_if_index = ntohl (mp->sw_if_index);
1452 vam->result_ready = 1;
1456 static void vl_api_tap_modify_reply_t_handler_json
1457 (vl_api_tap_modify_reply_t * mp)
1459 vat_main_t *vam = &vat_main;
1460 vat_json_node_t node;
1462 vat_json_init_object (&node);
1463 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1464 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1466 vat_json_print (vam->ofp, &node);
1467 vat_json_free (&node);
1469 vam->retval = ntohl (mp->retval);
1470 vam->result_ready = 1;
1474 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1476 vat_main_t *vam = &vat_main;
1477 i32 retval = ntohl (mp->retval);
1478 if (vam->async_mode)
1480 vam->async_errors += (retval < 0);
1484 vam->retval = retval;
1485 vam->result_ready = 1;
1489 static void vl_api_tap_delete_reply_t_handler_json
1490 (vl_api_tap_delete_reply_t * mp)
1492 vat_main_t *vam = &vat_main;
1493 vat_json_node_t node;
1495 vat_json_init_object (&node);
1496 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1498 vat_json_print (vam->ofp, &node);
1499 vat_json_free (&node);
1501 vam->retval = ntohl (mp->retval);
1502 vam->result_ready = 1;
1505 static void vl_api_mpls_ethernet_add_del_tunnel_reply_t_handler
1506 (vl_api_mpls_ethernet_add_del_tunnel_reply_t * mp)
1508 vat_main_t *vam = &vat_main;
1509 i32 retval = ntohl (mp->retval);
1510 if (vam->async_mode)
1512 vam->async_errors += (retval < 0);
1516 vam->retval = retval;
1517 vam->result_ready = 1;
1521 static void vl_api_mpls_ethernet_add_del_tunnel_reply_t_handler_json
1522 (vl_api_mpls_ethernet_add_del_tunnel_reply_t * mp)
1524 vat_main_t *vam = &vat_main;
1525 vat_json_node_t node;
1527 vat_json_init_object (&node);
1528 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1529 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1530 ntohl (mp->tunnel_sw_if_index));
1532 vat_json_print (vam->ofp, &node);
1533 vat_json_free (&node);
1535 vam->retval = ntohl (mp->retval);
1536 vam->result_ready = 1;
1539 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1540 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1542 vat_main_t *vam = &vat_main;
1543 i32 retval = ntohl (mp->retval);
1544 if (vam->async_mode)
1546 vam->async_errors += (retval < 0);
1550 vam->retval = retval;
1551 vam->sw_if_index = ntohl (mp->sw_if_index);
1552 vam->result_ready = 1;
1556 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1557 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1559 vat_main_t *vam = &vat_main;
1560 vat_json_node_t node;
1562 vat_json_init_object (&node);
1563 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1564 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1566 vat_json_print (vam->ofp, &node);
1567 vat_json_free (&node);
1569 vam->retval = ntohl (mp->retval);
1570 vam->result_ready = 1;
1574 static void vl_api_lisp_add_del_locator_set_reply_t_handler
1575 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1577 vat_main_t *vam = &vat_main;
1578 i32 retval = ntohl (mp->retval);
1579 if (vam->async_mode)
1581 vam->async_errors += (retval < 0);
1585 vam->retval = retval;
1586 vam->result_ready = 1;
1590 static void vl_api_lisp_add_del_locator_set_reply_t_handler_json
1591 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1593 vat_main_t *vam = &vat_main;
1594 vat_json_node_t node;
1596 vat_json_init_object (&node);
1597 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1598 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1600 vat_json_print (vam->ofp, &node);
1601 vat_json_free (&node);
1603 vam->retval = ntohl (mp->retval);
1604 vam->result_ready = 1;
1607 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1608 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1610 vat_main_t *vam = &vat_main;
1611 i32 retval = ntohl (mp->retval);
1612 if (vam->async_mode)
1614 vam->async_errors += (retval < 0);
1618 vam->retval = retval;
1619 vam->sw_if_index = ntohl (mp->sw_if_index);
1620 vam->result_ready = 1;
1624 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1625 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1627 vat_main_t *vam = &vat_main;
1628 vat_json_node_t node;
1630 vat_json_init_object (&node);
1631 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1632 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1634 vat_json_print (vam->ofp, &node);
1635 vat_json_free (&node);
1637 vam->retval = ntohl (mp->retval);
1638 vam->result_ready = 1;
1641 static void vl_api_gre_add_del_tunnel_reply_t_handler
1642 (vl_api_gre_add_del_tunnel_reply_t * mp)
1644 vat_main_t *vam = &vat_main;
1645 i32 retval = ntohl (mp->retval);
1646 if (vam->async_mode)
1648 vam->async_errors += (retval < 0);
1652 vam->retval = retval;
1653 vam->sw_if_index = ntohl (mp->sw_if_index);
1654 vam->result_ready = 1;
1658 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1659 (vl_api_gre_add_del_tunnel_reply_t * mp)
1661 vat_main_t *vam = &vat_main;
1662 vat_json_node_t node;
1664 vat_json_init_object (&node);
1665 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1666 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1668 vat_json_print (vam->ofp, &node);
1669 vat_json_free (&node);
1671 vam->retval = ntohl (mp->retval);
1672 vam->result_ready = 1;
1675 static void vl_api_create_vhost_user_if_reply_t_handler
1676 (vl_api_create_vhost_user_if_reply_t * mp)
1678 vat_main_t *vam = &vat_main;
1679 i32 retval = ntohl (mp->retval);
1680 if (vam->async_mode)
1682 vam->async_errors += (retval < 0);
1686 vam->retval = retval;
1687 vam->sw_if_index = ntohl (mp->sw_if_index);
1688 vam->result_ready = 1;
1692 static void vl_api_create_vhost_user_if_reply_t_handler_json
1693 (vl_api_create_vhost_user_if_reply_t * mp)
1695 vat_main_t *vam = &vat_main;
1696 vat_json_node_t node;
1698 vat_json_init_object (&node);
1699 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1700 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1702 vat_json_print (vam->ofp, &node);
1703 vat_json_free (&node);
1705 vam->retval = ntohl (mp->retval);
1706 vam->result_ready = 1;
1709 static void vl_api_ip_address_details_t_handler
1710 (vl_api_ip_address_details_t * mp)
1712 vat_main_t *vam = &vat_main;
1713 static ip_address_details_t empty_ip_address_details = { {0} };
1714 ip_address_details_t *address = NULL;
1715 ip_details_t *current_ip_details = NULL;
1716 ip_details_t *details = NULL;
1718 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1720 if (!details || vam->current_sw_if_index >= vec_len (details)
1721 || !details[vam->current_sw_if_index].present)
1723 errmsg ("ip address details arrived but not stored\n");
1724 errmsg ("ip_dump should be called first\n");
1728 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1730 #define addresses (current_ip_details->addr)
1732 vec_validate_init_empty (addresses, vec_len (addresses),
1733 empty_ip_address_details);
1735 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1737 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1738 address->prefix_length = mp->prefix_length;
1742 static void vl_api_ip_address_details_t_handler_json
1743 (vl_api_ip_address_details_t * mp)
1745 vat_main_t *vam = &vat_main;
1746 vat_json_node_t *node = NULL;
1747 struct in6_addr ip6;
1750 if (VAT_JSON_ARRAY != vam->json_tree.type)
1752 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1753 vat_json_init_array (&vam->json_tree);
1755 node = vat_json_array_add (&vam->json_tree);
1757 vat_json_init_object (node);
1760 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1761 vat_json_object_add_ip6 (node, "ip", ip6);
1765 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1766 vat_json_object_add_ip4 (node, "ip", ip4);
1768 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1772 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1774 vat_main_t *vam = &vat_main;
1775 static ip_details_t empty_ip_details = { 0 };
1776 ip_details_t *ip = NULL;
1777 u32 sw_if_index = ~0;
1779 sw_if_index = ntohl (mp->sw_if_index);
1781 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1782 sw_if_index, empty_ip_details);
1784 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1791 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1793 vat_main_t *vam = &vat_main;
1795 if (VAT_JSON_ARRAY != vam->json_tree.type)
1797 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1798 vat_json_init_array (&vam->json_tree);
1800 vat_json_array_add_uint (&vam->json_tree,
1801 clib_net_to_host_u32 (mp->sw_if_index));
1804 static void vl_api_map_domain_details_t_handler_json
1805 (vl_api_map_domain_details_t * mp)
1807 vat_json_node_t *node = NULL;
1808 vat_main_t *vam = &vat_main;
1809 struct in6_addr ip6;
1812 if (VAT_JSON_ARRAY != vam->json_tree.type)
1814 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1815 vat_json_init_array (&vam->json_tree);
1818 node = vat_json_array_add (&vam->json_tree);
1819 vat_json_init_object (node);
1821 vat_json_object_add_uint (node, "domain_index",
1822 clib_net_to_host_u32 (mp->domain_index));
1823 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1824 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1825 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1826 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1827 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1828 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1829 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1830 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1831 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1832 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1833 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1834 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1835 vat_json_object_add_uint (node, "flags", mp->flags);
1836 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1837 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1840 static void vl_api_map_domain_details_t_handler
1841 (vl_api_map_domain_details_t * mp)
1843 vat_main_t *vam = &vat_main;
1845 if (mp->is_translation)
1848 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u\n",
1849 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1850 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1851 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1852 clib_net_to_host_u32 (mp->domain_index));
1857 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u\n",
1858 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1859 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1860 format_ip6_address, mp->ip6_src,
1861 clib_net_to_host_u32 (mp->domain_index));
1863 fformat (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s\n",
1864 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1865 mp->is_translation ? "map-t" : "");
1868 static void vl_api_map_rule_details_t_handler_json
1869 (vl_api_map_rule_details_t * mp)
1871 struct in6_addr ip6;
1872 vat_json_node_t *node = NULL;
1873 vat_main_t *vam = &vat_main;
1875 if (VAT_JSON_ARRAY != vam->json_tree.type)
1877 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1878 vat_json_init_array (&vam->json_tree);
1881 node = vat_json_array_add (&vam->json_tree);
1882 vat_json_init_object (node);
1884 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1885 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1886 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1890 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1892 vat_main_t *vam = &vat_main;
1893 fformat (vam->ofp, " %d (psid) %U (ip6-dst)\n",
1894 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1898 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1900 vat_main_t *vam = &vat_main;
1901 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1902 "router_addr %U host_mac %U\n",
1903 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1904 format_ip4_address, &mp->host_address,
1905 format_ip4_address, &mp->router_address,
1906 format_ethernet_address, mp->host_mac);
1909 static void vl_api_dhcp_compl_event_t_handler_json
1910 (vl_api_dhcp_compl_event_t * mp)
1912 /* JSON output not supported */
1916 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1919 vat_main_t *vam = &vat_main;
1920 static u64 default_counter = 0;
1922 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
1924 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
1925 sw_if_index, default_counter);
1926 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
1930 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1931 interface_counter_t counter)
1933 vat_main_t *vam = &vat_main;
1934 static interface_counter_t default_counter = { 0, };
1936 vec_validate_init_empty (vam->combined_interface_counters,
1937 vnet_counter_type, NULL);
1938 vec_validate_init_empty (vam->combined_interface_counters
1939 [vnet_counter_type], sw_if_index, default_counter);
1940 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
1943 static void vl_api_vnet_interface_counters_t_handler
1944 (vl_api_vnet_interface_counters_t * mp)
1949 static void vl_api_vnet_interface_counters_t_handler_json
1950 (vl_api_vnet_interface_counters_t * mp)
1952 interface_counter_t counter;
1957 u32 first_sw_if_index;
1960 count = ntohl (mp->count);
1961 first_sw_if_index = ntohl (mp->first_sw_if_index);
1963 if (!mp->is_combined)
1965 v_packets = (u64 *) & mp->data;
1966 for (i = 0; i < count; i++)
1969 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
1970 set_simple_interface_counter (mp->vnet_counter_type,
1971 first_sw_if_index + i, packets);
1977 v = (vlib_counter_t *) & mp->data;
1978 for (i = 0; i < count; i++)
1981 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
1983 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
1984 set_combined_interface_counter (mp->vnet_counter_type,
1985 first_sw_if_index + i, counter);
1992 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
1994 vat_main_t *vam = &vat_main;
1997 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
1999 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2008 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2010 vat_main_t *vam = &vat_main;
2013 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2015 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2023 static void vl_api_vnet_ip4_fib_counters_t_handler
2024 (vl_api_vnet_ip4_fib_counters_t * mp)
2029 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2030 (vl_api_vnet_ip4_fib_counters_t * mp)
2032 vat_main_t *vam = &vat_main;
2033 vl_api_ip4_fib_counter_t *v;
2034 ip4_fib_counter_t *counter;
2041 vrf_id = ntohl (mp->vrf_id);
2042 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2043 if (~0 == vrf_index)
2045 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2046 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2047 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2048 vec_validate (vam->ip4_fib_counters, vrf_index);
2049 vam->ip4_fib_counters[vrf_index] = NULL;
2052 vec_free (vam->ip4_fib_counters[vrf_index]);
2053 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2054 count = ntohl (mp->count);
2055 for (i = 0; i < count; i++)
2057 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2058 counter = &vam->ip4_fib_counters[vrf_index][i];
2059 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2060 counter->address = ip4;
2061 counter->address_length = v->address_length;
2062 counter->packets = clib_net_to_host_u64 (v->packets);
2063 counter->bytes = clib_net_to_host_u64 (v->bytes);
2068 static void vl_api_vnet_ip6_fib_counters_t_handler
2069 (vl_api_vnet_ip6_fib_counters_t * mp)
2074 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2075 (vl_api_vnet_ip6_fib_counters_t * mp)
2077 vat_main_t *vam = &vat_main;
2078 vl_api_ip6_fib_counter_t *v;
2079 ip6_fib_counter_t *counter;
2080 struct in6_addr ip6;
2086 vrf_id = ntohl (mp->vrf_id);
2087 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2088 if (~0 == vrf_index)
2090 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2091 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2092 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2093 vec_validate (vam->ip6_fib_counters, vrf_index);
2094 vam->ip6_fib_counters[vrf_index] = NULL;
2097 vec_free (vam->ip6_fib_counters[vrf_index]);
2098 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2099 count = ntohl (mp->count);
2100 for (i = 0; i < count; i++)
2102 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2103 counter = &vam->ip6_fib_counters[vrf_index][i];
2104 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2105 counter->address = ip6;
2106 counter->address_length = v->address_length;
2107 counter->packets = clib_net_to_host_u64 (v->packets);
2108 counter->bytes = clib_net_to_host_u64 (v->bytes);
2113 static void vl_api_get_first_msg_id_reply_t_handler
2114 (vl_api_get_first_msg_id_reply_t * mp)
2116 vat_main_t *vam = &vat_main;
2117 i32 retval = ntohl (mp->retval);
2119 if (vam->async_mode)
2121 vam->async_errors += (retval < 0);
2125 vam->retval = retval;
2126 vam->result_ready = 1;
2130 errmsg ("first message id %d\n", ntohs (mp->first_msg_id));
2134 static void vl_api_get_first_msg_id_reply_t_handler_json
2135 (vl_api_get_first_msg_id_reply_t * mp)
2137 vat_main_t *vam = &vat_main;
2138 vat_json_node_t node;
2140 vat_json_init_object (&node);
2141 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2142 vat_json_object_add_uint (&node, "first_msg_id",
2143 (uint) ntohs (mp->first_msg_id));
2145 vat_json_print (vam->ofp, &node);
2146 vat_json_free (&node);
2148 vam->retval = ntohl (mp->retval);
2149 vam->result_ready = 1;
2152 static void vl_api_get_node_graph_reply_t_handler
2153 (vl_api_get_node_graph_reply_t * mp)
2155 vat_main_t *vam = &vat_main;
2156 api_main_t *am = &api_main;
2157 i32 retval = ntohl (mp->retval);
2158 u8 *pvt_copy, *reply;
2163 if (vam->async_mode)
2165 vam->async_errors += (retval < 0);
2169 vam->retval = retval;
2170 vam->result_ready = 1;
2173 /* "Should never happen..." */
2177 reply = (u8 *) (mp->reply_in_shmem);
2178 pvt_copy = vec_dup (reply);
2180 /* Toss the shared-memory original... */
2181 pthread_mutex_lock (&am->vlib_rp->mutex);
2182 oldheap = svm_push_data_heap (am->vlib_rp);
2186 svm_pop_heap (oldheap);
2187 pthread_mutex_unlock (&am->vlib_rp->mutex);
2189 if (vam->graph_nodes)
2191 hash_free (vam->graph_node_index_by_name);
2193 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2195 node = vam->graph_nodes[i];
2196 vec_free (node->name);
2197 vec_free (node->next_nodes);
2200 vec_free (vam->graph_nodes);
2203 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2204 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2205 vec_free (pvt_copy);
2207 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2209 node = vam->graph_nodes[i];
2210 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2214 static void vl_api_get_node_graph_reply_t_handler_json
2215 (vl_api_get_node_graph_reply_t * mp)
2217 vat_main_t *vam = &vat_main;
2218 api_main_t *am = &api_main;
2220 vat_json_node_t node;
2223 /* $$$$ make this real? */
2224 vat_json_init_object (&node);
2225 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2226 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2228 reply = (u8 *) (mp->reply_in_shmem);
2230 /* Toss the shared-memory original... */
2231 pthread_mutex_lock (&am->vlib_rp->mutex);
2232 oldheap = svm_push_data_heap (am->vlib_rp);
2236 svm_pop_heap (oldheap);
2237 pthread_mutex_unlock (&am->vlib_rp->mutex);
2239 vat_json_print (vam->ofp, &node);
2240 vat_json_free (&node);
2242 vam->retval = ntohl (mp->retval);
2243 vam->result_ready = 1;
2247 vl_api_lisp_locator_details_t_handler (vl_api_lisp_locator_details_t * mp)
2249 vat_main_t *vam = &vat_main;
2253 memset (&loc, 0, sizeof (loc));
2254 if (vam->noprint_msg)
2256 loc.local = mp->local;
2257 loc.priority = mp->priority;
2258 loc.weight = mp->weight;
2261 loc.sw_if_index = ntohl (mp->sw_if_index);
2265 loc.is_ipv6 = mp->is_ipv6;
2266 clib_memcpy (loc.ip_address, mp->ip_address,
2267 sizeof (loc.ip_address));
2269 vec_add1 (vam->locator_msg, loc);
2275 tmp_str = format (tmp_str, "%=16d%=16d%=16d\n",
2276 ntohl (mp->sw_if_index),
2277 mp->priority, mp->weight);
2281 tmp_str = format (tmp_str, "%=16U%=16d%=16d\n",
2282 mp->is_ipv6 ? format_ip6_address :
2284 mp->ip_address, mp->priority, mp->weight);
2287 fformat (vam->ofp, "%s", tmp_str);
2294 vl_api_lisp_locator_details_t_handler_json (vl_api_lisp_locator_details_t *
2297 vat_main_t *vam = &vat_main;
2298 vat_json_node_t *node = NULL;
2300 struct in6_addr ip6;
2303 memset (&loc, 0, sizeof (loc));
2304 if (vam->noprint_msg)
2306 loc.local = mp->local;
2307 loc.priority = mp->priority;
2308 loc.weight = mp->weight;
2311 loc.sw_if_index = ntohl (mp->sw_if_index);
2315 loc.is_ipv6 = mp->is_ipv6;
2316 clib_memcpy (loc.ip_address, mp->ip_address,
2317 sizeof (loc.ip_address));
2319 vec_add1 (vam->locator_msg, loc);
2323 if (VAT_JSON_ARRAY != vam->json_tree.type)
2325 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2326 vat_json_init_array (&vam->json_tree);
2328 node = vat_json_array_add (&vam->json_tree);
2330 vat_json_init_object (node);
2334 vat_json_object_add_uint (node, "locator_index",
2335 ntohl (mp->sw_if_index));
2341 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2342 vat_json_object_add_ip6 (node, "locator", ip6);
2346 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2347 vat_json_object_add_ip4 (node, "locator", ip4);
2350 vat_json_object_add_uint (node, "priority", mp->priority);
2351 vat_json_object_add_uint (node, "weight", mp->weight);
2355 vl_api_lisp_locator_set_details_t_handler (vl_api_lisp_locator_set_details_t *
2358 vat_main_t *vam = &vat_main;
2359 locator_set_msg_t ls;
2361 ls.locator_set_index = ntohl (mp->locator_set_index);
2362 ls.locator_set_name = format (0, "%s", mp->locator_set_name);
2363 vec_add1 (vam->locator_set_msg, ls);
2367 vl_api_lisp_locator_set_details_t_handler_json
2368 (vl_api_lisp_locator_set_details_t * mp)
2370 vat_main_t *vam = &vat_main;
2371 locator_set_msg_t ls;
2373 ls.locator_set_index = ntohl (mp->locator_set_index);
2374 ls.locator_set_name = format (0, "%s", mp->locator_set_name);
2375 vec_add1 (vam->locator_set_msg, ls);
2379 add_lisp_eid_table_entry (vat_main_t * vam,
2380 vl_api_lisp_eid_table_details_t * mp)
2382 eid_table_t eid_table;
2384 memset (&eid_table, 0, sizeof (eid_table));
2385 eid_table.is_local = mp->is_local;
2386 eid_table.locator_set_index = clib_net_to_host_u32 (mp->locator_set_index);
2387 eid_table.eid_type = mp->eid_type;
2388 eid_table.vni = clib_net_to_host_u32 (mp->vni);
2389 eid_table.eid_prefix_len = mp->eid_prefix_len;
2390 eid_table.ttl = clib_net_to_host_u32 (mp->ttl);
2391 eid_table.action = mp->action;
2392 eid_table.authoritative = mp->authoritative;
2393 clib_memcpy (eid_table.eid, mp->eid, sizeof (eid_table.eid));
2394 vec_add1 (vam->eid_tables, eid_table);
2398 vl_api_lisp_eid_table_details_t_handler (vl_api_lisp_eid_table_details_t * mp)
2400 vat_main_t *vam = &vat_main;
2401 add_lisp_eid_table_entry (vam, mp);
2405 vl_api_lisp_eid_table_details_t_handler_json (vl_api_lisp_eid_table_details_t
2408 vat_main_t *vam = &vat_main;
2409 add_lisp_eid_table_entry (vam, mp);
2413 vl_api_lisp_eid_table_map_details_t_handler
2414 (vl_api_lisp_eid_table_map_details_t * mp)
2416 vat_main_t *vam = &vat_main;
2418 u8 *line = format (0, "%=10d%=10d",
2419 clib_net_to_host_u32 (mp->vni),
2420 clib_net_to_host_u32 (mp->dp_table));
2421 fformat (vam->ofp, "%v\n", line);
2426 vl_api_lisp_eid_table_map_details_t_handler_json
2427 (vl_api_lisp_eid_table_map_details_t * mp)
2429 vat_main_t *vam = &vat_main;
2430 vat_json_node_t *node = NULL;
2432 if (VAT_JSON_ARRAY != vam->json_tree.type)
2434 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2435 vat_json_init_array (&vam->json_tree);
2437 node = vat_json_array_add (&vam->json_tree);
2438 vat_json_init_object (node);
2439 vat_json_object_add_uint (node, "dp_table",
2440 clib_net_to_host_u32 (mp->dp_table));
2441 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2445 vl_api_lisp_eid_table_vni_details_t_handler
2446 (vl_api_lisp_eid_table_vni_details_t * mp)
2448 vat_main_t *vam = &vat_main;
2450 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2451 fformat (vam->ofp, "%v\n", line);
2456 vl_api_lisp_eid_table_vni_details_t_handler_json
2457 (vl_api_lisp_eid_table_vni_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, "vni", clib_net_to_host_u32 (mp->vni));
2473 format_decap_next (u8 * s, va_list * args)
2475 u32 next_index = va_arg (*args, u32);
2479 case LISP_GPE_INPUT_NEXT_DROP:
2480 return format (s, "drop");
2481 case LISP_GPE_INPUT_NEXT_IP4_INPUT:
2482 return format (s, "ip4");
2483 case LISP_GPE_INPUT_NEXT_IP6_INPUT:
2484 return format (s, "ip6");
2486 return format (s, "unknown %d", next_index);
2492 vl_api_lisp_gpe_tunnel_details_t_handler (vl_api_lisp_gpe_tunnel_details_t *
2495 vat_main_t *vam = &vat_main;
2497 u8 *flag_str = NULL;
2499 iid_str = format (0, "%d (0x%x)", ntohl (mp->iid), ntohl (mp->iid));
2501 #define _(n,v) if (mp->flags & v) flag_str = format (flag_str, "%s-bit ", #n);
2502 foreach_lisp_gpe_flag_bit;
2505 fformat (vam->ofp, "%=20d%=30U%=16U%=16d%=16d%=16U"
2506 "%=16d%=16d%=16sd=16d%=16s%=16s\n",
2508 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2510 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2512 ntohl (mp->encap_fib_id),
2513 ntohl (mp->decap_fib_id),
2514 format_decap_next, ntohl (mp->dcap_next),
2516 flag_str, mp->next_protocol, mp->ver_res, mp->res, iid_str);
2522 vl_api_lisp_gpe_tunnel_details_t_handler_json
2523 (vl_api_lisp_gpe_tunnel_details_t * mp)
2525 vat_main_t *vam = &vat_main;
2526 vat_json_node_t *node = NULL;
2527 struct in6_addr ip6;
2531 next_decap_str = format (0, "%U", format_decap_next, htonl (mp->dcap_next));
2533 if (VAT_JSON_ARRAY != vam->json_tree.type)
2535 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2536 vat_json_init_array (&vam->json_tree);
2538 node = vat_json_array_add (&vam->json_tree);
2540 vat_json_init_object (node);
2541 vat_json_object_add_uint (node, "tunel", mp->tunnels);
2544 clib_memcpy (&ip6, mp->source_ip, sizeof (ip6));
2545 vat_json_object_add_ip6 (node, "source address", ip6);
2546 clib_memcpy (&ip6, mp->destination_ip, sizeof (ip6));
2547 vat_json_object_add_ip6 (node, "destination address", ip6);
2551 clib_memcpy (&ip4, mp->source_ip, sizeof (ip4));
2552 vat_json_object_add_ip4 (node, "source address", ip4);
2553 clib_memcpy (&ip4, mp->destination_ip, sizeof (ip4));
2554 vat_json_object_add_ip4 (node, "destination address", ip4);
2556 vat_json_object_add_uint (node, "fib encap", ntohl (mp->encap_fib_id));
2557 vat_json_object_add_uint (node, "fib decap", ntohl (mp->decap_fib_id));
2558 vat_json_object_add_string_copy (node, "decap next", next_decap_str);
2559 vat_json_object_add_uint (node, "lisp version", mp->ver_res >> 6);
2560 vat_json_object_add_uint (node, "flags", mp->flags);
2561 vat_json_object_add_uint (node, "next protocol", mp->next_protocol);
2562 vat_json_object_add_uint (node, "ver_res", mp->ver_res);
2563 vat_json_object_add_uint (node, "res", mp->res);
2564 vat_json_object_add_uint (node, "iid", ntohl (mp->iid));
2566 vec_free (next_decap_str);
2570 vl_api_lisp_map_resolver_details_t_handler (vl_api_lisp_map_resolver_details_t
2573 vat_main_t *vam = &vat_main;
2575 fformat (vam->ofp, "%=20U\n",
2576 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2581 vl_api_lisp_map_resolver_details_t_handler_json
2582 (vl_api_lisp_map_resolver_details_t * mp)
2584 vat_main_t *vam = &vat_main;
2585 vat_json_node_t *node = NULL;
2586 struct in6_addr ip6;
2589 if (VAT_JSON_ARRAY != vam->json_tree.type)
2591 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2592 vat_json_init_array (&vam->json_tree);
2594 node = vat_json_array_add (&vam->json_tree);
2596 vat_json_init_object (node);
2599 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2600 vat_json_object_add_ip6 (node, "map resolver", ip6);
2604 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2605 vat_json_object_add_ip4 (node, "map resolver", ip4);
2610 vl_api_show_lisp_status_reply_t_handler
2611 (vl_api_show_lisp_status_reply_t * mp)
2613 vat_main_t *vam = &vat_main;
2614 i32 retval = ntohl (mp->retval);
2618 fformat (vam->ofp, "feature: %s\ngpe: %s\n",
2619 mp->feature_status ? "enabled" : "disabled",
2620 mp->gpe_status ? "enabled" : "disabled");
2623 vam->retval = retval;
2624 vam->result_ready = 1;
2628 vl_api_show_lisp_status_reply_t_handler_json
2629 (vl_api_show_lisp_status_reply_t * mp)
2631 vat_main_t *vam = &vat_main;
2632 vat_json_node_t node;
2633 u8 *gpe_status = NULL;
2634 u8 *feature_status = NULL;
2636 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
2637 feature_status = format (0, "%s",
2638 mp->feature_status ? "enabled" : "disabled");
2639 vec_add1 (gpe_status, 0);
2640 vec_add1 (feature_status, 0);
2642 vat_json_init_object (&node);
2643 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
2644 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
2646 vec_free (gpe_status);
2647 vec_free (feature_status);
2649 vat_json_print (vam->ofp, &node);
2650 vat_json_free (&node);
2652 vam->retval = ntohl (mp->retval);
2653 vam->result_ready = 1;
2657 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler
2658 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2660 vat_main_t *vam = &vat_main;
2661 i32 retval = ntohl (mp->retval);
2665 fformat (vam->ofp, "%=20s\n", mp->locator_set_name);
2668 vam->retval = retval;
2669 vam->result_ready = 1;
2673 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler_json
2674 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2676 vat_main_t *vam = &vat_main;
2677 vat_json_node_t *node = NULL;
2679 if (VAT_JSON_ARRAY != vam->json_tree.type)
2681 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2682 vat_json_init_array (&vam->json_tree);
2684 node = vat_json_array_add (&vam->json_tree);
2686 vat_json_init_object (node);
2687 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
2689 vat_json_print (vam->ofp, node);
2690 vat_json_free (node);
2692 vam->retval = ntohl (mp->retval);
2693 vam->result_ready = 1;
2697 vl_api_show_lisp_pitr_reply_t_handler (vl_api_show_lisp_pitr_reply_t * mp)
2699 vat_main_t *vam = &vat_main;
2700 i32 retval = ntohl (mp->retval);
2704 fformat (vam->ofp, "%-20s%-16s\n",
2705 mp->status ? "enabled" : "disabled",
2706 mp->status ? (char *) mp->locator_set_name : "");
2709 vam->retval = retval;
2710 vam->result_ready = 1;
2714 vl_api_show_lisp_pitr_reply_t_handler_json (vl_api_show_lisp_pitr_reply_t *
2717 vat_main_t *vam = &vat_main;
2718 vat_json_node_t node;
2721 status = format (0, "%s", mp->status ? "enabled" : "disabled");
2722 vec_add1 (status, 0);
2724 vat_json_init_object (&node);
2725 vat_json_object_add_string_copy (&node, "status", status);
2728 vat_json_object_add_string_copy (&node, "locator_set",
2729 mp->locator_set_name);
2734 vat_json_print (vam->ofp, &node);
2735 vat_json_free (&node);
2737 vam->retval = ntohl (mp->retval);
2738 vam->result_ready = 1;
2742 format_policer_type (u8 * s, va_list * va)
2744 u32 i = va_arg (*va, u32);
2746 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
2747 s = format (s, "1r2c");
2748 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
2749 s = format (s, "1r3c");
2750 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
2751 s = format (s, "2r3c-2698");
2752 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
2753 s = format (s, "2r3c-4115");
2754 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
2755 s = format (s, "2r3c-mef5cf1");
2757 s = format (s, "ILLEGAL");
2762 format_policer_rate_type (u8 * s, va_list * va)
2764 u32 i = va_arg (*va, u32);
2766 if (i == SSE2_QOS_RATE_KBPS)
2767 s = format (s, "kbps");
2768 else if (i == SSE2_QOS_RATE_PPS)
2769 s = format (s, "pps");
2771 s = format (s, "ILLEGAL");
2776 format_policer_round_type (u8 * s, va_list * va)
2778 u32 i = va_arg (*va, u32);
2780 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
2781 s = format (s, "closest");
2782 else if (i == SSE2_QOS_ROUND_TO_UP)
2783 s = format (s, "up");
2784 else if (i == SSE2_QOS_ROUND_TO_DOWN)
2785 s = format (s, "down");
2787 s = format (s, "ILLEGAL");
2792 format_policer_action_type (u8 * s, va_list * va)
2794 u32 i = va_arg (*va, u32);
2796 if (i == SSE2_QOS_ACTION_DROP)
2797 s = format (s, "drop");
2798 else if (i == SSE2_QOS_ACTION_TRANSMIT)
2799 s = format (s, "transmit");
2800 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2801 s = format (s, "mark-and-transmit");
2803 s = format (s, "ILLEGAL");
2808 format_dscp (u8 * s, va_list * va)
2810 u32 i = va_arg (*va, u32);
2815 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
2819 return format (s, "ILLEGAL");
2821 s = format (s, "%s", t);
2826 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
2828 vat_main_t *vam = &vat_main;
2829 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
2831 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2832 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
2834 conform_dscp_str = format (0, "");
2836 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2837 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
2839 exceed_dscp_str = format (0, "");
2841 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2842 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
2844 violate_dscp_str = format (0, "");
2846 fformat (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
2847 "rate type %U, round type %U, %s rate, %s color-aware, "
2848 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
2849 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
2850 "conform action %U%s, exceed action %U%s, violate action %U%s\n",
2852 format_policer_type, mp->type,
2855 clib_net_to_host_u64 (mp->cb),
2856 clib_net_to_host_u64 (mp->eb),
2857 format_policer_rate_type, mp->rate_type,
2858 format_policer_round_type, mp->round_type,
2859 mp->single_rate ? "single" : "dual",
2860 mp->color_aware ? "is" : "not",
2861 ntohl (mp->cir_tokens_per_period),
2862 ntohl (mp->pir_tokens_per_period),
2864 ntohl (mp->current_limit),
2865 ntohl (mp->current_bucket),
2866 ntohl (mp->extended_limit),
2867 ntohl (mp->extended_bucket),
2868 clib_net_to_host_u64 (mp->last_update_time),
2869 format_policer_action_type, mp->conform_action_type,
2871 format_policer_action_type, mp->exceed_action_type,
2873 format_policer_action_type, mp->violate_action_type,
2876 vec_free (conform_dscp_str);
2877 vec_free (exceed_dscp_str);
2878 vec_free (violate_dscp_str);
2881 static void vl_api_policer_details_t_handler_json
2882 (vl_api_policer_details_t * mp)
2884 vat_main_t *vam = &vat_main;
2885 vat_json_node_t *node;
2886 u8 *rate_type_str, *round_type_str, *type_str;
2887 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
2889 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
2891 format (0, "%U", format_policer_round_type, mp->round_type);
2892 type_str = format (0, "%U", format_policer_type, mp->type);
2893 conform_action_str = format (0, "%U", format_policer_action_type,
2894 mp->conform_action_type);
2895 exceed_action_str = format (0, "%U", format_policer_action_type,
2896 mp->exceed_action_type);
2897 violate_action_str = format (0, "%U", format_policer_action_type,
2898 mp->violate_action_type);
2900 if (VAT_JSON_ARRAY != vam->json_tree.type)
2902 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2903 vat_json_init_array (&vam->json_tree);
2905 node = vat_json_array_add (&vam->json_tree);
2907 vat_json_init_object (node);
2908 vat_json_object_add_string_copy (node, "name", mp->name);
2909 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
2910 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
2911 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
2912 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
2913 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
2914 vat_json_object_add_string_copy (node, "round_type", round_type_str);
2915 vat_json_object_add_string_copy (node, "type", type_str);
2916 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
2917 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
2918 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
2919 vat_json_object_add_uint (node, "cir_tokens_per_period",
2920 ntohl (mp->cir_tokens_per_period));
2921 vat_json_object_add_uint (node, "eir_tokens_per_period",
2922 ntohl (mp->pir_tokens_per_period));
2923 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
2924 vat_json_object_add_uint (node, "current_bucket",
2925 ntohl (mp->current_bucket));
2926 vat_json_object_add_uint (node, "extended_limit",
2927 ntohl (mp->extended_limit));
2928 vat_json_object_add_uint (node, "extended_bucket",
2929 ntohl (mp->extended_bucket));
2930 vat_json_object_add_uint (node, "last_update_time",
2931 ntohl (mp->last_update_time));
2932 vat_json_object_add_string_copy (node, "conform_action",
2933 conform_action_str);
2934 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2936 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
2937 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
2938 vec_free (dscp_str);
2940 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
2941 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2943 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
2944 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
2945 vec_free (dscp_str);
2947 vat_json_object_add_string_copy (node, "violate_action",
2948 violate_action_str);
2949 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2951 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
2952 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
2953 vec_free (dscp_str);
2956 vec_free (rate_type_str);
2957 vec_free (round_type_str);
2958 vec_free (type_str);
2959 vec_free (conform_action_str);
2960 vec_free (exceed_action_str);
2961 vec_free (violate_action_str);
2965 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
2968 vat_main_t *vam = &vat_main;
2969 int i, count = ntohl (mp->count);
2972 fformat (vam->ofp, "classify table ids (%d) : ", count);
2973 for (i = 0; i < count; i++)
2975 fformat (vam->ofp, "%d", ntohl (mp->ids[i]));
2976 fformat (vam->ofp, (i < count - 1) ? "," : "\n");
2978 vam->retval = ntohl (mp->retval);
2979 vam->result_ready = 1;
2983 vl_api_classify_table_ids_reply_t_handler_json
2984 (vl_api_classify_table_ids_reply_t * mp)
2986 vat_main_t *vam = &vat_main;
2987 int i, count = ntohl (mp->count);
2991 vat_json_node_t node;
2993 vat_json_init_object (&node);
2994 for (i = 0; i < count; i++)
2996 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
2998 vat_json_print (vam->ofp, &node);
2999 vat_json_free (&node);
3001 vam->retval = ntohl (mp->retval);
3002 vam->result_ready = 1;
3006 vl_api_classify_table_by_interface_reply_t_handler
3007 (vl_api_classify_table_by_interface_reply_t * mp)
3009 vat_main_t *vam = &vat_main;
3012 table_id = ntohl (mp->l2_table_id);
3014 fformat (vam->ofp, "l2 table id : %d\n", table_id);
3016 fformat (vam->ofp, "l2 table id : No input ACL tables configured\n");
3017 table_id = ntohl (mp->ip4_table_id);
3019 fformat (vam->ofp, "ip4 table id : %d\n", table_id);
3021 fformat (vam->ofp, "ip4 table id : No input ACL tables configured\n");
3022 table_id = ntohl (mp->ip6_table_id);
3024 fformat (vam->ofp, "ip6 table id : %d\n", table_id);
3026 fformat (vam->ofp, "ip6 table id : No input ACL tables configured\n");
3027 vam->retval = ntohl (mp->retval);
3028 vam->result_ready = 1;
3032 vl_api_classify_table_by_interface_reply_t_handler_json
3033 (vl_api_classify_table_by_interface_reply_t * mp)
3035 vat_main_t *vam = &vat_main;
3036 vat_json_node_t node;
3038 vat_json_init_object (&node);
3040 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3041 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3042 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3044 vat_json_print (vam->ofp, &node);
3045 vat_json_free (&node);
3047 vam->retval = ntohl (mp->retval);
3048 vam->result_ready = 1;
3051 static void vl_api_policer_add_del_reply_t_handler
3052 (vl_api_policer_add_del_reply_t * mp)
3054 vat_main_t *vam = &vat_main;
3055 i32 retval = ntohl (mp->retval);
3056 if (vam->async_mode)
3058 vam->async_errors += (retval < 0);
3062 vam->retval = retval;
3063 vam->result_ready = 1;
3064 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3066 * Note: this is just barely thread-safe, depends on
3067 * the main thread spinning waiting for an answer...
3069 errmsg ("policer index %d\n", ntohl (mp->policer_index));
3073 static void vl_api_policer_add_del_reply_t_handler_json
3074 (vl_api_policer_add_del_reply_t * mp)
3076 vat_main_t *vam = &vat_main;
3077 vat_json_node_t node;
3079 vat_json_init_object (&node);
3080 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3081 vat_json_object_add_uint (&node, "policer_index",
3082 ntohl (mp->policer_index));
3084 vat_json_print (vam->ofp, &node);
3085 vat_json_free (&node);
3087 vam->retval = ntohl (mp->retval);
3088 vam->result_ready = 1;
3091 /* Format hex dump. */
3093 format_hex_bytes (u8 * s, va_list * va)
3095 u8 *bytes = va_arg (*va, u8 *);
3096 int n_bytes = va_arg (*va, int);
3099 /* Print short or long form depending on byte count. */
3100 uword short_form = n_bytes <= 32;
3101 uword indent = format_get_indent (s);
3106 for (i = 0; i < n_bytes; i++)
3108 if (!short_form && (i % 32) == 0)
3109 s = format (s, "%08x: ", i);
3110 s = format (s, "%02x", bytes[i]);
3111 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3112 s = format (s, "\n%U", format_white_space, indent);
3119 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3122 vat_main_t *vam = &vat_main;
3123 i32 retval = ntohl (mp->retval);
3126 fformat (vam->ofp, "classify table info :\n");
3127 fformat (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d\n",
3128 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3129 ntohl (mp->miss_next_index));
3130 fformat (vam->ofp, "nbuckets: %d skip: %d match: %d\n",
3131 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3132 ntohl (mp->match_n_vectors));
3133 fformat (vam->ofp, "mask: %U\n", format_hex_bytes, mp->mask,
3134 ntohl (mp->mask_length));
3136 vam->retval = retval;
3137 vam->result_ready = 1;
3141 vl_api_classify_table_info_reply_t_handler_json
3142 (vl_api_classify_table_info_reply_t * mp)
3144 vat_main_t *vam = &vat_main;
3145 vat_json_node_t node;
3147 i32 retval = ntohl (mp->retval);
3150 vat_json_init_object (&node);
3152 vat_json_object_add_int (&node, "sessions",
3153 ntohl (mp->active_sessions));
3154 vat_json_object_add_int (&node, "nexttbl",
3155 ntohl (mp->next_table_index));
3156 vat_json_object_add_int (&node, "nextnode",
3157 ntohl (mp->miss_next_index));
3158 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3159 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3160 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3161 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3162 ntohl (mp->mask_length), 0);
3163 vat_json_object_add_string_copy (&node, "mask", s);
3165 vat_json_print (vam->ofp, &node);
3166 vat_json_free (&node);
3168 vam->retval = ntohl (mp->retval);
3169 vam->result_ready = 1;
3173 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3176 vat_main_t *vam = &vat_main;
3178 fformat (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3179 ntohl (mp->hit_next_index), ntohl (mp->advance),
3180 ntohl (mp->opaque_index));
3181 fformat (vam->ofp, "mask: %U\n", format_hex_bytes, mp->match,
3182 ntohl (mp->match_length));
3186 vl_api_classify_session_details_t_handler_json
3187 (vl_api_classify_session_details_t * mp)
3189 vat_main_t *vam = &vat_main;
3190 vat_json_node_t *node = NULL;
3192 if (VAT_JSON_ARRAY != vam->json_tree.type)
3194 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3195 vat_json_init_array (&vam->json_tree);
3197 node = vat_json_array_add (&vam->json_tree);
3199 vat_json_init_object (node);
3200 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3201 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3202 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3204 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3206 vat_json_object_add_string_copy (node, "match", s);
3209 static void vl_api_pg_create_interface_reply_t_handler
3210 (vl_api_pg_create_interface_reply_t * mp)
3212 vat_main_t *vam = &vat_main;
3214 vam->retval = ntohl (mp->retval);
3215 vam->result_ready = 1;
3218 static void vl_api_pg_create_interface_reply_t_handler_json
3219 (vl_api_pg_create_interface_reply_t * mp)
3221 vat_main_t *vam = &vat_main;
3222 vat_json_node_t node;
3224 i32 retval = ntohl (mp->retval);
3227 vat_json_init_object (&node);
3229 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3231 vat_json_print (vam->ofp, &node);
3232 vat_json_free (&node);
3234 vam->retval = ntohl (mp->retval);
3235 vam->result_ready = 1;
3238 static void vl_api_policer_classify_details_t_handler
3239 (vl_api_policer_classify_details_t * mp)
3241 vat_main_t *vam = &vat_main;
3243 fformat (vam->ofp, "%10d%20d\n", ntohl (mp->sw_if_index),
3244 ntohl (mp->table_index));
3247 static void vl_api_policer_classify_details_t_handler_json
3248 (vl_api_policer_classify_details_t * mp)
3250 vat_main_t *vam = &vat_main;
3251 vat_json_node_t *node;
3253 if (VAT_JSON_ARRAY != vam->json_tree.type)
3255 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3256 vat_json_init_array (&vam->json_tree);
3258 node = vat_json_array_add (&vam->json_tree);
3260 vat_json_init_object (node);
3261 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3262 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3265 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3266 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3268 vat_main_t *vam = &vat_main;
3269 i32 retval = ntohl (mp->retval);
3270 if (vam->async_mode)
3272 vam->async_errors += (retval < 0);
3276 vam->retval = retval;
3277 vam->sw_if_index = ntohl (mp->sw_if_index);
3278 vam->result_ready = 1;
3282 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3283 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3285 vat_main_t *vam = &vat_main;
3286 vat_json_node_t node;
3288 vat_json_init_object (&node);
3289 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3290 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3292 vat_json_print (vam->ofp, &node);
3293 vat_json_free (&node);
3295 vam->retval = ntohl (mp->retval);
3296 vam->result_ready = 1;
3299 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3300 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3301 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3302 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3305 * Generate boilerplate reply handlers, which
3306 * dig the return value out of the xxx_reply_t API message,
3307 * stick it into vam->retval, and set vam->result_ready
3309 * Could also do this by pointing N message decode slots at
3310 * a single function, but that could break in subtle ways.
3313 #define foreach_standard_reply_retval_handler \
3314 _(sw_interface_set_flags_reply) \
3315 _(sw_interface_add_del_address_reply) \
3316 _(sw_interface_set_table_reply) \
3317 _(sw_interface_set_vpath_reply) \
3318 _(sw_interface_set_l2_bridge_reply) \
3319 _(bridge_domain_add_del_reply) \
3320 _(sw_interface_set_l2_xconnect_reply) \
3321 _(l2fib_add_del_reply) \
3322 _(ip_add_del_route_reply) \
3323 _(proxy_arp_add_del_reply) \
3324 _(proxy_arp_intfc_enable_disable_reply) \
3325 _(mpls_add_del_encap_reply) \
3326 _(mpls_add_del_decap_reply) \
3327 _(mpls_ethernet_add_del_tunnel_2_reply) \
3328 _(sw_interface_set_unnumbered_reply) \
3329 _(ip_neighbor_add_del_reply) \
3330 _(reset_vrf_reply) \
3331 _(oam_add_del_reply) \
3332 _(reset_fib_reply) \
3333 _(dhcp_proxy_config_reply) \
3334 _(dhcp_proxy_config_2_reply) \
3335 _(dhcp_proxy_set_vss_reply) \
3336 _(dhcp_client_config_reply) \
3337 _(set_ip_flow_hash_reply) \
3338 _(sw_interface_ip6_enable_disable_reply) \
3339 _(sw_interface_ip6_set_link_local_address_reply) \
3340 _(sw_interface_ip6nd_ra_prefix_reply) \
3341 _(sw_interface_ip6nd_ra_config_reply) \
3342 _(set_arp_neighbor_limit_reply) \
3343 _(l2_patch_add_del_reply) \
3344 _(sr_tunnel_add_del_reply) \
3345 _(sr_policy_add_del_reply) \
3346 _(sr_multicast_map_add_del_reply) \
3347 _(classify_add_del_session_reply) \
3348 _(classify_set_interface_ip_table_reply) \
3349 _(classify_set_interface_l2_tables_reply) \
3350 _(l2tpv3_set_tunnel_cookies_reply) \
3351 _(l2tpv3_interface_enable_disable_reply) \
3352 _(l2tpv3_set_lookup_key_reply) \
3353 _(l2_fib_clear_table_reply) \
3354 _(l2_interface_efp_filter_reply) \
3355 _(l2_interface_vlan_tag_rewrite_reply) \
3356 _(modify_vhost_user_if_reply) \
3357 _(delete_vhost_user_if_reply) \
3358 _(want_ip4_arp_events_reply) \
3359 _(want_ip6_nd_events_reply) \
3360 _(input_acl_set_interface_reply) \
3361 _(ipsec_spd_add_del_reply) \
3362 _(ipsec_interface_add_del_spd_reply) \
3363 _(ipsec_spd_add_del_entry_reply) \
3364 _(ipsec_sad_add_del_entry_reply) \
3365 _(ipsec_sa_set_key_reply) \
3366 _(ikev2_profile_add_del_reply) \
3367 _(ikev2_profile_set_auth_reply) \
3368 _(ikev2_profile_set_id_reply) \
3369 _(ikev2_profile_set_ts_reply) \
3370 _(ikev2_set_local_key_reply) \
3371 _(delete_loopback_reply) \
3372 _(bd_ip_mac_add_del_reply) \
3373 _(map_del_domain_reply) \
3374 _(map_add_del_rule_reply) \
3375 _(want_interface_events_reply) \
3376 _(want_stats_reply) \
3377 _(cop_interface_enable_disable_reply) \
3378 _(cop_whitelist_enable_disable_reply) \
3379 _(sw_interface_clear_stats_reply) \
3380 _(trace_profile_add_reply) \
3381 _(trace_profile_apply_reply) \
3382 _(trace_profile_del_reply) \
3383 _(lisp_add_del_locator_reply) \
3384 _(lisp_add_del_local_eid_reply) \
3385 _(lisp_add_del_remote_mapping_reply) \
3386 _(lisp_add_del_adjacency_reply) \
3387 _(lisp_gpe_add_del_fwd_entry_reply) \
3388 _(lisp_add_del_map_resolver_reply) \
3389 _(lisp_gpe_enable_disable_reply) \
3390 _(lisp_gpe_add_del_iface_reply) \
3391 _(lisp_enable_disable_reply) \
3392 _(lisp_pitr_set_locator_set_reply) \
3393 _(lisp_add_del_map_request_itr_rlocs_reply) \
3394 _(lisp_eid_table_add_del_map_reply) \
3395 _(vxlan_gpe_add_del_tunnel_reply) \
3396 _(af_packet_delete_reply) \
3397 _(policer_classify_set_interface_reply) \
3398 _(netmap_create_reply) \
3399 _(netmap_delete_reply) \
3400 _(ipfix_enable_reply) \
3401 _(pg_capture_reply) \
3402 _(pg_enable_disable_reply) \
3403 _(ip_source_and_port_range_check_add_del_reply) \
3404 _(ip_source_and_port_range_check_interface_add_del_reply)\
3405 _(delete_subif_reply)
3408 static void vl_api_##n##_t_handler \
3409 (vl_api_##n##_t * mp) \
3411 vat_main_t * vam = &vat_main; \
3412 i32 retval = ntohl(mp->retval); \
3413 if (vam->async_mode) { \
3414 vam->async_errors += (retval < 0); \
3416 vam->retval = retval; \
3417 vam->result_ready = 1; \
3420 foreach_standard_reply_retval_handler;
3424 static void vl_api_##n##_t_handler_json \
3425 (vl_api_##n##_t * mp) \
3427 vat_main_t * vam = &vat_main; \
3428 vat_json_node_t node; \
3429 vat_json_init_object(&node); \
3430 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3431 vat_json_print(vam->ofp, &node); \
3432 vam->retval = ntohl(mp->retval); \
3433 vam->result_ready = 1; \
3435 foreach_standard_reply_retval_handler;
3439 * Table of message reply handlers, must include boilerplate handlers
3443 #define foreach_vpe_api_reply_msg \
3444 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3445 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3446 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
3447 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3448 _(CONTROL_PING_REPLY, control_ping_reply) \
3449 _(NOPRINT_CONTROL_PING_REPLY, noprint_control_ping_reply) \
3450 _(CLI_REPLY, cli_reply) \
3451 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
3452 sw_interface_add_del_address_reply) \
3453 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
3454 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
3455 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
3456 sw_interface_set_l2_xconnect_reply) \
3457 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
3458 sw_interface_set_l2_bridge_reply) \
3459 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
3460 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
3461 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
3462 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
3463 _(L2_FLAGS_REPLY, l2_flags_reply) \
3464 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
3465 _(TAP_CONNECT_REPLY, tap_connect_reply) \
3466 _(TAP_MODIFY_REPLY, tap_modify_reply) \
3467 _(TAP_DELETE_REPLY, tap_delete_reply) \
3468 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
3469 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
3470 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
3471 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
3472 proxy_arp_intfc_enable_disable_reply) \
3473 _(MPLS_ADD_DEL_ENCAP_REPLY, mpls_add_del_encap_reply) \
3474 _(MPLS_ADD_DEL_DECAP_REPLY, mpls_add_del_decap_reply) \
3475 _(MPLS_GRE_ADD_DEL_TUNNEL_REPLY, mpls_gre_add_del_tunnel_reply) \
3476 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_REPLY, \
3477 mpls_ethernet_add_del_tunnel_reply) \
3478 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_2_REPLY, \
3479 mpls_ethernet_add_del_tunnel_2_reply) \
3480 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
3481 sw_interface_set_unnumbered_reply) \
3482 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
3483 _(RESET_VRF_REPLY, reset_vrf_reply) \
3484 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
3485 _(CREATE_SUBIF_REPLY, create_subif_reply) \
3486 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
3487 _(RESET_FIB_REPLY, reset_fib_reply) \
3488 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
3489 _(DHCP_PROXY_CONFIG_2_REPLY, dhcp_proxy_config_2_reply) \
3490 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
3491 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
3492 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
3493 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
3494 sw_interface_ip6_enable_disable_reply) \
3495 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
3496 sw_interface_ip6_set_link_local_address_reply) \
3497 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
3498 sw_interface_ip6nd_ra_prefix_reply) \
3499 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
3500 sw_interface_ip6nd_ra_config_reply) \
3501 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
3502 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
3503 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
3504 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
3505 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
3506 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
3507 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
3508 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
3509 classify_set_interface_ip_table_reply) \
3510 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
3511 classify_set_interface_l2_tables_reply) \
3512 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
3513 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
3514 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
3515 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
3516 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
3517 l2tpv3_interface_enable_disable_reply) \
3518 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
3519 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
3520 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
3521 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
3522 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
3523 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
3524 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
3525 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
3526 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
3527 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
3528 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
3529 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
3530 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
3531 _(SHOW_VERSION_REPLY, show_version_reply) \
3532 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
3533 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
3534 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
3535 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
3536 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
3537 _(IP4_ARP_EVENT, ip4_arp_event) \
3538 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
3539 _(IP6_ND_EVENT, ip6_nd_event) \
3540 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
3541 _(IP_ADDRESS_DETAILS, ip_address_details) \
3542 _(IP_DETAILS, ip_details) \
3543 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
3544 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
3545 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
3546 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
3547 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
3548 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
3549 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
3550 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
3551 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
3552 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
3553 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
3554 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
3555 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
3556 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
3557 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
3558 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
3559 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
3560 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
3561 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
3562 _(MAP_DOMAIN_DETAILS, map_domain_details) \
3563 _(MAP_RULE_DETAILS, map_rule_details) \
3564 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
3565 _(WANT_STATS_REPLY, want_stats_reply) \
3566 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
3567 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
3568 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
3569 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
3570 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
3571 _(TRACE_PROFILE_ADD_REPLY, trace_profile_add_reply) \
3572 _(TRACE_PROFILE_APPLY_REPLY, trace_profile_apply_reply) \
3573 _(TRACE_PROFILE_DEL_REPLY, trace_profile_del_reply) \
3574 _(LISP_ADD_DEL_LOCATOR_SET_REPLY, lisp_add_del_locator_set_reply) \
3575 _(LISP_ADD_DEL_LOCATOR_REPLY, lisp_add_del_locator_reply) \
3576 _(LISP_ADD_DEL_LOCAL_EID_REPLY, lisp_add_del_local_eid_reply) \
3577 _(LISP_ADD_DEL_REMOTE_MAPPING_REPLY, lisp_add_del_remote_mapping_reply) \
3578 _(LISP_ADD_DEL_ADJACENCY_REPLY, lisp_add_del_adjacency_reply) \
3579 _(LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY, lisp_gpe_add_del_fwd_entry_reply) \
3580 _(LISP_ADD_DEL_MAP_RESOLVER_REPLY, lisp_add_del_map_resolver_reply) \
3581 _(LISP_GPE_ENABLE_DISABLE_REPLY, lisp_gpe_enable_disable_reply) \
3582 _(LISP_ENABLE_DISABLE_REPLY, lisp_enable_disable_reply) \
3583 _(LISP_PITR_SET_LOCATOR_SET_REPLY, lisp_pitr_set_locator_set_reply) \
3584 _(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \
3585 _(LISP_GPE_ADD_DEL_IFACE_REPLY, lisp_gpe_add_del_iface_reply) \
3586 _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \
3587 _(LISP_LOCATOR_DETAILS, lisp_locator_details) \
3588 _(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \
3589 _(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \
3590 _(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \
3591 _(LISP_GPE_TUNNEL_DETAILS, lisp_gpe_tunnel_details) \
3592 _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
3593 _(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
3594 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
3595 lisp_add_del_map_request_itr_rlocs_reply) \
3596 _(LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
3597 lisp_get_map_request_itr_rlocs_reply) \
3598 _(SHOW_LISP_PITR_REPLY, show_lisp_pitr_reply) \
3599 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
3600 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
3601 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
3602 _(POLICER_DETAILS, policer_details) \
3603 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
3604 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
3605 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
3606 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
3607 _(MPLS_GRE_TUNNEL_DETAILS, mpls_gre_tunnel_details) \
3608 _(MPLS_ETH_TUNNEL_DETAILS, mpls_eth_tunnel_details) \
3609 _(MPLS_FIB_ENCAP_DETAILS, mpls_fib_encap_details) \
3610 _(MPLS_FIB_DECAP_DETAILS, mpls_fib_decap_details) \
3611 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
3612 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
3613 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
3614 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
3615 _(IPFIX_ENABLE_REPLY, ipfix_enable_reply) \
3616 _(IPFIX_DETAILS, ipfix_details) \
3617 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
3618 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
3619 _(PG_CAPTURE_REPLY, pg_capture_reply) \
3620 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
3621 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
3622 ip_source_and_port_range_check_add_del_reply) \
3623 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
3624 ip_source_and_port_range_check_interface_add_del_reply) \
3625 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
3626 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
3627 _(DELETE_SUBIF_REPLY, delete_subif_reply)
3629 /* M: construct, but don't yet send a message */
3633 vam->result_ready = 0; \
3634 mp = vl_msg_api_alloc(sizeof(*mp)); \
3635 memset (mp, 0, sizeof (*mp)); \
3636 mp->_vl_msg_id = ntohs (VL_API_##T); \
3637 mp->client_index = vam->my_client_index; \
3642 vam->result_ready = 0; \
3643 mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
3644 memset (mp, 0, sizeof (*mp)); \
3645 mp->_vl_msg_id = ntohs (VL_API_##T); \
3646 mp->client_index = vam->my_client_index; \
3650 /* S: send a message */
3651 #define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
3653 /* W: wait for results, with timeout */
3656 timeout = vat_time_now (vam) + 1.0; \
3658 while (vat_time_now (vam) < timeout) { \
3659 if (vam->result_ready == 1) { \
3660 return (vam->retval); \
3666 /* W2: wait for results, with timeout */
3669 timeout = vat_time_now (vam) + 1.0; \
3671 while (vat_time_now (vam) < timeout) { \
3672 if (vam->result_ready == 1) { \
3674 return (vam->retval); \
3680 /* W_L: wait for results, with timeout */
3683 timeout = vat_time_now (vam) + 1.0; \
3685 while (vat_time_now (vam) < timeout) { \
3686 if (vam->result_ready == 1) { \
3688 return (vam->retval); \
3691 vam->noprint_msg = 0; \
3702 #define STR_VTR_OP_CASE(op) \
3703 case L2_VTR_ ## op: \
3707 str_vtr_op (u32 vtr_op)
3711 STR_VTR_OP_CASE (DISABLED);
3712 STR_VTR_OP_CASE (PUSH_1);
3713 STR_VTR_OP_CASE (PUSH_2);
3714 STR_VTR_OP_CASE (POP_1);
3715 STR_VTR_OP_CASE (POP_2);
3716 STR_VTR_OP_CASE (TRANSLATE_1_1);
3717 STR_VTR_OP_CASE (TRANSLATE_1_2);
3718 STR_VTR_OP_CASE (TRANSLATE_2_1);
3719 STR_VTR_OP_CASE (TRANSLATE_2_2);
3726 dump_sub_interface_table (vat_main_t * vam)
3728 const sw_interface_subif_t *sub = NULL;
3730 if (vam->json_output)
3733 ("JSON output supported only for VPE API calls and dump_stats_table");
3738 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s\n",
3739 "Interface", "sw_if_index",
3740 "sub id", "dot1ad", "tags", "outer id",
3741 "inner id", "exact", "default", "outer any", "inner any");
3743 vec_foreach (sub, vam->sw_if_subif_table)
3746 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d\n",
3747 sub->interface_name,
3749 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
3750 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
3751 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
3752 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
3753 if (sub->vtr_op != L2_VTR_DISABLED)
3756 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
3757 "tag1: %d tag2: %d ]\n",
3758 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
3759 sub->vtr_tag1, sub->vtr_tag2);
3767 name_sort_cmp (void *a1, void *a2)
3769 name_sort_t *n1 = a1;
3770 name_sort_t *n2 = a2;
3772 return strcmp ((char *) n1->name, (char *) n2->name);
3776 dump_interface_table (vat_main_t * vam)
3779 name_sort_t *nses = 0, *ns;
3781 if (vam->json_output)
3784 ("JSON output supported only for VPE API calls and dump_stats_table");
3789 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
3791 vec_add2 (nses, ns, 1);
3792 ns->name = (u8 *)(p->key);
3793 ns->value = (u32) p->value[0];
3797 vec_sort_with_function (nses, name_sort_cmp);
3799 fformat (vam->ofp, "%-25s%-15s\n", "Interface", "sw_if_index");
3800 vec_foreach (ns, nses)
3802 fformat (vam->ofp, "%-25s%-15d\n", ns->name, ns->value);
3809 dump_ip_table (vat_main_t * vam, int is_ipv6)
3811 const ip_details_t *det = NULL;
3812 const ip_address_details_t *address = NULL;
3815 fformat (vam->ofp, "%-12s\n", "sw_if_index");
3817 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
3824 fformat (vam->ofp, "%-12d\n", i);
3826 " %-30s%-13s\n", "Address", "Prefix length");
3831 vec_foreach (address, det->addr)
3835 is_ipv6 ? format_ip6_address : format_ip4_address,
3836 address->ip, address->prefix_length);
3844 dump_ipv4_table (vat_main_t * vam)
3846 if (vam->json_output)
3849 ("JSON output supported only for VPE API calls and dump_stats_table");
3853 return dump_ip_table (vam, 0);
3857 dump_ipv6_table (vat_main_t * vam)
3859 if (vam->json_output)
3862 ("JSON output supported only for VPE API calls and dump_stats_table");
3866 return dump_ip_table (vam, 1);
3870 counter_type_to_str (u8 counter_type, u8 is_combined)
3874 switch (counter_type)
3876 case VNET_INTERFACE_COUNTER_DROP:
3878 case VNET_INTERFACE_COUNTER_PUNT:
3880 case VNET_INTERFACE_COUNTER_IP4:
3882 case VNET_INTERFACE_COUNTER_IP6:
3884 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
3886 case VNET_INTERFACE_COUNTER_RX_MISS:
3888 case VNET_INTERFACE_COUNTER_RX_ERROR:
3890 case VNET_INTERFACE_COUNTER_TX_ERROR:
3893 return "INVALID-COUNTER-TYPE";
3898 switch (counter_type)
3900 case VNET_INTERFACE_COUNTER_RX:
3902 case VNET_INTERFACE_COUNTER_TX:
3905 return "INVALID-COUNTER-TYPE";
3911 dump_stats_table (vat_main_t * vam)
3913 vat_json_node_t node;
3914 vat_json_node_t *msg_array;
3915 vat_json_node_t *msg;
3916 vat_json_node_t *counter_array;
3917 vat_json_node_t *counter;
3918 interface_counter_t c;
3920 ip4_fib_counter_t *c4;
3921 ip6_fib_counter_t *c6;
3924 if (!vam->json_output)
3926 clib_warning ("dump_stats_table supported only in JSON format");
3930 vat_json_init_object (&node);
3932 /* interface counters */
3933 msg_array = vat_json_object_add (&node, "interface_counters");
3934 vat_json_init_array (msg_array);
3935 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
3937 msg = vat_json_array_add (msg_array);
3938 vat_json_init_object (msg);
3939 vat_json_object_add_string_copy (msg, "vnet_counter_type",
3940 (u8 *) counter_type_to_str (i, 0));
3941 vat_json_object_add_int (msg, "is_combined", 0);
3942 counter_array = vat_json_object_add (msg, "data");
3943 vat_json_init_array (counter_array);
3944 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
3946 packets = vam->simple_interface_counters[i][j];
3947 vat_json_array_add_uint (counter_array, packets);
3950 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
3952 msg = vat_json_array_add (msg_array);
3953 vat_json_init_object (msg);
3954 vat_json_object_add_string_copy (msg, "vnet_counter_type",
3955 (u8 *) counter_type_to_str (i, 1));
3956 vat_json_object_add_int (msg, "is_combined", 1);
3957 counter_array = vat_json_object_add (msg, "data");
3958 vat_json_init_array (counter_array);
3959 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
3961 c = vam->combined_interface_counters[i][j];
3962 counter = vat_json_array_add (counter_array);
3963 vat_json_init_object (counter);
3964 vat_json_object_add_uint (counter, "packets", c.packets);
3965 vat_json_object_add_uint (counter, "bytes", c.bytes);
3969 /* ip4 fib counters */
3970 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
3971 vat_json_init_array (msg_array);
3972 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
3974 msg = vat_json_array_add (msg_array);
3975 vat_json_init_object (msg);
3976 vat_json_object_add_uint (msg, "vrf_id",
3977 vam->ip4_fib_counters_vrf_id_by_index[i]);
3978 counter_array = vat_json_object_add (msg, "c");
3979 vat_json_init_array (counter_array);
3980 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
3982 counter = vat_json_array_add (counter_array);
3983 vat_json_init_object (counter);
3984 c4 = &vam->ip4_fib_counters[i][j];
3985 vat_json_object_add_ip4 (counter, "address", c4->address);
3986 vat_json_object_add_uint (counter, "address_length",
3987 c4->address_length);
3988 vat_json_object_add_uint (counter, "packets", c4->packets);
3989 vat_json_object_add_uint (counter, "bytes", c4->bytes);
3993 /* ip6 fib counters */
3994 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
3995 vat_json_init_array (msg_array);
3996 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
3998 msg = vat_json_array_add (msg_array);
3999 vat_json_init_object (msg);
4000 vat_json_object_add_uint (msg, "vrf_id",
4001 vam->ip6_fib_counters_vrf_id_by_index[i]);
4002 counter_array = vat_json_object_add (msg, "c");
4003 vat_json_init_array (counter_array);
4004 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4006 counter = vat_json_array_add (counter_array);
4007 vat_json_init_object (counter);
4008 c6 = &vam->ip6_fib_counters[i][j];
4009 vat_json_object_add_ip6 (counter, "address", c6->address);
4010 vat_json_object_add_uint (counter, "address_length",
4011 c6->address_length);
4012 vat_json_object_add_uint (counter, "packets", c6->packets);
4013 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4017 vat_json_print (vam->ofp, &node);
4018 vat_json_free (&node);
4024 exec (vat_main_t * vam)
4026 api_main_t *am = &api_main;
4027 vl_api_cli_request_t *mp;
4031 unformat_input_t *i = vam->input;
4033 if (vec_len (i->buffer) == 0)
4036 if (vam->exec_mode == 0 && unformat (i, "mode"))
4041 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4048 M (CLI_REQUEST, cli_request);
4051 * Copy cmd into shared memory.
4052 * In order for the CLI command to work, it
4053 * must be a vector ending in \n, not a C-string ending
4056 pthread_mutex_lock (&am->vlib_rp->mutex);
4057 oldheap = svm_push_data_heap (am->vlib_rp);
4059 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4060 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4062 svm_pop_heap (oldheap);
4063 pthread_mutex_unlock (&am->vlib_rp->mutex);
4065 mp->cmd_in_shmem = (u64) cmd;
4067 timeout = vat_time_now (vam) + 10.0;
4069 while (vat_time_now (vam) < timeout)
4071 if (vam->result_ready == 1)
4074 if (vam->shmem_result != NULL)
4075 fformat (vam->ofp, "%s", vam->shmem_result);
4076 pthread_mutex_lock (&am->vlib_rp->mutex);
4077 oldheap = svm_push_data_heap (am->vlib_rp);
4079 free_me = (u8 *) vam->shmem_result;
4082 svm_pop_heap (oldheap);
4083 pthread_mutex_unlock (&am->vlib_rp->mutex);
4091 api_create_loopback (vat_main_t * vam)
4093 unformat_input_t *i = vam->input;
4094 vl_api_create_loopback_t *mp;
4099 memset (mac_address, 0, sizeof (mac_address));
4101 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4103 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4109 /* Construct the API message */
4110 M (CREATE_LOOPBACK, create_loopback);
4112 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4119 api_delete_loopback (vat_main_t * vam)
4121 unformat_input_t *i = vam->input;
4122 vl_api_delete_loopback_t *mp;
4124 u32 sw_if_index = ~0;
4126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4128 if (unformat (i, "sw_if_index %d", &sw_if_index))
4134 if (sw_if_index == ~0)
4136 errmsg ("missing sw_if_index\n");
4140 /* Construct the API message */
4141 M (DELETE_LOOPBACK, delete_loopback);
4142 mp->sw_if_index = ntohl (sw_if_index);
4149 api_want_stats (vat_main_t * vam)
4151 unformat_input_t *i = vam->input;
4152 vl_api_want_stats_t *mp;
4156 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4158 if (unformat (i, "enable"))
4160 else if (unformat (i, "disable"))
4168 errmsg ("missing enable|disable\n");
4172 M (WANT_STATS, want_stats);
4173 mp->enable_disable = enable;
4180 api_want_interface_events (vat_main_t * vam)
4182 unformat_input_t *i = vam->input;
4183 vl_api_want_interface_events_t *mp;
4187 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4189 if (unformat (i, "enable"))
4191 else if (unformat (i, "disable"))
4199 errmsg ("missing enable|disable\n");
4203 M (WANT_INTERFACE_EVENTS, want_interface_events);
4204 mp->enable_disable = enable;
4206 vam->interface_event_display = enable;
4213 /* Note: non-static, called once to set up the initial intfc table */
4215 api_sw_interface_dump (vat_main_t * vam)
4217 vl_api_sw_interface_dump_t *mp;
4220 name_sort_t *nses = 0, *ns;
4221 sw_interface_subif_t *sub = NULL;
4223 /* Toss the old name table */
4225 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4227 vec_add2 (nses, ns, 1);
4228 ns->name = (u8 *)(p->key);
4229 ns->value = (u32) p->value[0];
4233 hash_free (vam->sw_if_index_by_interface_name);
4235 vec_foreach (ns, nses) vec_free (ns->name);
4239 vec_foreach (sub, vam->sw_if_subif_table)
4241 vec_free (sub->interface_name);
4243 vec_free (vam->sw_if_subif_table);
4245 /* recreate the interface name hash table */
4246 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4248 /* Get list of ethernets */
4249 M (SW_INTERFACE_DUMP, sw_interface_dump);
4250 mp->name_filter_valid = 1;
4251 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4254 /* and local / loopback interfaces */
4255 M (SW_INTERFACE_DUMP, sw_interface_dump);
4256 mp->name_filter_valid = 1;
4257 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4261 /* and vxlan-gpe tunnel interfaces */
4262 M (SW_INTERFACE_DUMP, sw_interface_dump);
4263 mp->name_filter_valid = 1;
4264 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4265 sizeof (mp->name_filter) - 1);
4268 /* and vxlan tunnel interfaces */
4269 M (SW_INTERFACE_DUMP, sw_interface_dump);
4270 mp->name_filter_valid = 1;
4271 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4274 /* and host (af_packet) interfaces */
4275 M (SW_INTERFACE_DUMP, sw_interface_dump);
4276 mp->name_filter_valid = 1;
4277 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4280 /* and l2tpv3 tunnel interfaces */
4281 M (SW_INTERFACE_DUMP, sw_interface_dump);
4282 mp->name_filter_valid = 1;
4283 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4284 sizeof (mp->name_filter) - 1);
4287 /* and GRE tunnel interfaces */
4288 M (SW_INTERFACE_DUMP, sw_interface_dump);
4289 mp->name_filter_valid = 1;
4290 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4293 /* Use a control ping for synchronization */
4295 vl_api_control_ping_t *mp;
4296 M (CONTROL_PING, control_ping);
4303 api_sw_interface_set_flags (vat_main_t * vam)
4305 unformat_input_t *i = vam->input;
4306 vl_api_sw_interface_set_flags_t *mp;
4309 u8 sw_if_index_set = 0;
4310 u8 admin_up = 0, link_up = 0;
4312 /* Parse args required to build the message */
4313 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4315 if (unformat (i, "admin-up"))
4317 else if (unformat (i, "admin-down"))
4319 else if (unformat (i, "link-up"))
4321 else if (unformat (i, "link-down"))
4323 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4324 sw_if_index_set = 1;
4325 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4326 sw_if_index_set = 1;
4331 if (sw_if_index_set == 0)
4333 errmsg ("missing interface name or sw_if_index\n");
4337 /* Construct the API message */
4338 M (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags);
4339 mp->sw_if_index = ntohl (sw_if_index);
4340 mp->admin_up_down = admin_up;
4341 mp->link_up_down = link_up;
4346 /* Wait for a reply, return the good/bad news... */
4351 api_sw_interface_clear_stats (vat_main_t * vam)
4353 unformat_input_t *i = vam->input;
4354 vl_api_sw_interface_clear_stats_t *mp;
4357 u8 sw_if_index_set = 0;
4359 /* Parse args required to build the message */
4360 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4362 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4363 sw_if_index_set = 1;
4364 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4365 sw_if_index_set = 1;
4370 /* Construct the API message */
4371 M (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats);
4373 if (sw_if_index_set == 1)
4374 mp->sw_if_index = ntohl (sw_if_index);
4376 mp->sw_if_index = ~0;
4381 /* Wait for a reply, return the good/bad news... */
4386 api_sw_interface_add_del_address (vat_main_t * vam)
4388 unformat_input_t *i = vam->input;
4389 vl_api_sw_interface_add_del_address_t *mp;
4392 u8 sw_if_index_set = 0;
4393 u8 is_add = 1, del_all = 0;
4394 u32 address_length = 0;
4395 u8 v4_address_set = 0;
4396 u8 v6_address_set = 0;
4397 ip4_address_t v4address;
4398 ip6_address_t v6address;
4400 /* Parse args required to build the message */
4401 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4403 if (unformat (i, "del-all"))
4405 else if (unformat (i, "del"))
4407 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4408 sw_if_index_set = 1;
4409 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4410 sw_if_index_set = 1;
4411 else if (unformat (i, "%U/%d",
4412 unformat_ip4_address, &v4address, &address_length))
4414 else if (unformat (i, "%U/%d",
4415 unformat_ip6_address, &v6address, &address_length))
4421 if (sw_if_index_set == 0)
4423 errmsg ("missing interface name or sw_if_index\n");
4426 if (v4_address_set && v6_address_set)
4428 errmsg ("both v4 and v6 addresses set\n");
4431 if (!v4_address_set && !v6_address_set && !del_all)
4433 errmsg ("no addresses set\n");
4437 /* Construct the API message */
4438 M (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address);
4440 mp->sw_if_index = ntohl (sw_if_index);
4441 mp->is_add = is_add;
4442 mp->del_all = del_all;
4446 clib_memcpy (mp->address, &v6address, sizeof (v6address));
4450 clib_memcpy (mp->address, &v4address, sizeof (v4address));
4452 mp->address_length = address_length;
4457 /* Wait for a reply, return good/bad news */
4462 api_sw_interface_set_table (vat_main_t * vam)
4464 unformat_input_t *i = vam->input;
4465 vl_api_sw_interface_set_table_t *mp;
4467 u32 sw_if_index, vrf_id = 0;
4468 u8 sw_if_index_set = 0;
4471 /* Parse args required to build the message */
4472 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4474 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4475 sw_if_index_set = 1;
4476 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4477 sw_if_index_set = 1;
4478 else if (unformat (i, "vrf %d", &vrf_id))
4480 else if (unformat (i, "ipv6"))
4486 if (sw_if_index_set == 0)
4488 errmsg ("missing interface name or sw_if_index\n");
4492 /* Construct the API message */
4493 M (SW_INTERFACE_SET_TABLE, sw_interface_set_table);
4495 mp->sw_if_index = ntohl (sw_if_index);
4496 mp->is_ipv6 = is_ipv6;
4497 mp->vrf_id = ntohl (vrf_id);
4502 /* Wait for a reply... */
4507 api_sw_interface_set_vpath (vat_main_t * vam)
4509 unformat_input_t *i = vam->input;
4510 vl_api_sw_interface_set_vpath_t *mp;
4512 u32 sw_if_index = 0;
4513 u8 sw_if_index_set = 0;
4516 /* Parse args required to build the message */
4517 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4519 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4520 sw_if_index_set = 1;
4521 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4522 sw_if_index_set = 1;
4523 else if (unformat (i, "enable"))
4525 else if (unformat (i, "disable"))
4531 if (sw_if_index_set == 0)
4533 errmsg ("missing interface name or sw_if_index\n");
4537 /* Construct the API message */
4538 M (SW_INTERFACE_SET_VPATH, sw_interface_set_vpath);
4540 mp->sw_if_index = ntohl (sw_if_index);
4541 mp->enable = is_enable;
4546 /* Wait for a reply... */
4551 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
4553 unformat_input_t *i = vam->input;
4554 vl_api_sw_interface_set_l2_xconnect_t *mp;
4557 u8 rx_sw_if_index_set = 0;
4559 u8 tx_sw_if_index_set = 0;
4562 /* Parse args required to build the message */
4563 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4565 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
4566 rx_sw_if_index_set = 1;
4567 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
4568 tx_sw_if_index_set = 1;
4569 else if (unformat (i, "rx"))
4571 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4573 if (unformat (i, "%U", unformat_sw_if_index, vam,
4575 rx_sw_if_index_set = 1;
4580 else if (unformat (i, "tx"))
4582 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4584 if (unformat (i, "%U", unformat_sw_if_index, vam,
4586 tx_sw_if_index_set = 1;
4591 else if (unformat (i, "enable"))
4593 else if (unformat (i, "disable"))
4599 if (rx_sw_if_index_set == 0)
4601 errmsg ("missing rx interface name or rx_sw_if_index\n");
4605 if (enable && (tx_sw_if_index_set == 0))
4607 errmsg ("missing tx interface name or tx_sw_if_index\n");
4611 M (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect);
4613 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
4614 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
4615 mp->enable = enable;
4624 api_sw_interface_set_l2_bridge (vat_main_t * vam)
4626 unformat_input_t *i = vam->input;
4627 vl_api_sw_interface_set_l2_bridge_t *mp;
4630 u8 rx_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, "sw_if_index %d", &rx_sw_if_index))
4641 rx_sw_if_index_set = 1;
4642 else if (unformat (i, "bd_id %d", &bd_id))
4644 else if (unformat (i, "%U", unformat_sw_if_index, vam, &rx_sw_if_index))
4645 rx_sw_if_index_set = 1;
4646 else if (unformat (i, "shg %d", &shg))
4648 else if (unformat (i, "bvi"))
4650 else if (unformat (i, "enable"))
4652 else if (unformat (i, "disable"))
4658 if (rx_sw_if_index_set == 0)
4660 errmsg ("missing rx interface name or sw_if_index\n");
4664 if (enable && (bd_id_set == 0))
4666 errmsg ("missing bridge domain\n");
4670 M (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge);
4672 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
4673 mp->bd_id = ntohl (bd_id);
4676 mp->enable = enable;
4685 api_bridge_domain_dump (vat_main_t * vam)
4687 unformat_input_t *i = vam->input;
4688 vl_api_bridge_domain_dump_t *mp;
4692 /* Parse args required to build the message */
4693 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4695 if (unformat (i, "bd_id %d", &bd_id))
4701 M (BRIDGE_DOMAIN_DUMP, bridge_domain_dump);
4702 mp->bd_id = ntohl (bd_id);
4705 /* Use a control ping for synchronization */
4707 vl_api_control_ping_t *mp;
4708 M (CONTROL_PING, control_ping);
4718 api_bridge_domain_add_del (vat_main_t * vam)
4720 unformat_input_t *i = vam->input;
4721 vl_api_bridge_domain_add_del_t *mp;
4725 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
4727 /* Parse args required to build the message */
4728 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4730 if (unformat (i, "bd_id %d", &bd_id))
4732 else if (unformat (i, "flood %d", &flood))
4734 else if (unformat (i, "uu-flood %d", &uu_flood))
4736 else if (unformat (i, "forward %d", &forward))
4738 else if (unformat (i, "learn %d", &learn))
4740 else if (unformat (i, "arp-term %d", &arp_term))
4742 else if (unformat (i, "del"))
4745 flood = uu_flood = forward = learn = 0;
4753 errmsg ("missing bridge domain\n");
4757 M (BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del);
4759 mp->bd_id = ntohl (bd_id);
4761 mp->uu_flood = uu_flood;
4762 mp->forward = forward;
4764 mp->arp_term = arp_term;
4765 mp->is_add = is_add;
4774 api_l2fib_add_del (vat_main_t * vam)
4776 unformat_input_t *i = vam->input;
4777 vl_api_l2fib_add_del_t *mp;
4784 u8 sw_if_index_set = 0;
4793 /* Parse args required to build the message */
4794 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4796 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
4798 else if (unformat (i, "bd_id %d", &bd_id))
4800 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4801 sw_if_index_set = 1;
4802 else if (unformat (i, "sw_if"))
4804 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4806 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4807 sw_if_index_set = 1;
4812 else if (unformat (i, "static"))
4814 else if (unformat (i, "filter"))
4819 else if (unformat (i, "bvi"))
4824 else if (unformat (i, "del"))
4826 else if (unformat (i, "count %d", &count))
4834 errmsg ("missing mac address\n");
4840 errmsg ("missing bridge domain\n");
4844 if (is_add && (sw_if_index_set == 0))
4846 errmsg ("missing interface name or sw_if_index\n");
4852 /* Turn on async mode */
4853 vam->async_mode = 1;
4854 vam->async_errors = 0;
4855 before = vat_time_now (vam);
4858 for (j = 0; j < count; j++)
4860 M (L2FIB_ADD_DEL, l2fib_add_del);
4863 mp->bd_id = ntohl (bd_id);
4864 mp->is_add = is_add;
4868 mp->sw_if_index = ntohl (sw_if_index);
4869 mp->static_mac = static_mac;
4870 mp->filter_mac = filter_mac;
4871 mp->bvi_mac = bvi_mac;
4873 increment_mac_address (&mac);
4880 vl_api_control_ping_t *mp;
4883 /* Shut off async mode */
4884 vam->async_mode = 0;
4886 M (CONTROL_PING, control_ping);
4889 timeout = vat_time_now (vam) + 1.0;
4890 while (vat_time_now (vam) < timeout)
4891 if (vam->result_ready == 1)
4896 if (vam->retval == -99)
4897 errmsg ("timeout\n");
4899 if (vam->async_errors > 0)
4901 errmsg ("%d asynchronous errors\n", vam->async_errors);
4904 vam->async_errors = 0;
4905 after = vat_time_now (vam);
4907 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
4908 count, after - before, count / (after - before));
4912 /* Wait for a reply... */
4915 /* Return the good/bad news */
4916 return (vam->retval);
4920 api_l2_flags (vat_main_t * vam)
4922 unformat_input_t *i = vam->input;
4923 vl_api_l2_flags_t *mp;
4926 u32 feature_bitmap = 0;
4927 u8 sw_if_index_set = 0;
4929 /* Parse args required to build the message */
4930 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4932 if (unformat (i, "sw_if_index %d", &sw_if_index))
4933 sw_if_index_set = 1;
4934 else if (unformat (i, "sw_if"))
4936 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4938 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4939 sw_if_index_set = 1;
4944 else if (unformat (i, "learn"))
4945 feature_bitmap |= L2INPUT_FEAT_LEARN;
4946 else if (unformat (i, "forward"))
4947 feature_bitmap |= L2INPUT_FEAT_FWD;
4948 else if (unformat (i, "flood"))
4949 feature_bitmap |= L2INPUT_FEAT_FLOOD;
4950 else if (unformat (i, "uu-flood"))
4951 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
4956 if (sw_if_index_set == 0)
4958 errmsg ("missing interface name or sw_if_index\n");
4962 M (L2_FLAGS, l2_flags);
4964 mp->sw_if_index = ntohl (sw_if_index);
4965 mp->feature_bitmap = ntohl (feature_bitmap);
4974 api_bridge_flags (vat_main_t * vam)
4976 unformat_input_t *i = vam->input;
4977 vl_api_bridge_flags_t *mp;
4984 /* Parse args required to build the message */
4985 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4987 if (unformat (i, "bd_id %d", &bd_id))
4989 else if (unformat (i, "learn"))
4991 else if (unformat (i, "forward"))
4993 else if (unformat (i, "flood"))
4995 else if (unformat (i, "uu-flood"))
4996 flags |= L2_UU_FLOOD;
4997 else if (unformat (i, "arp-term"))
4998 flags |= L2_ARP_TERM;
4999 else if (unformat (i, "off"))
5001 else if (unformat (i, "disable"))
5009 errmsg ("missing bridge domain\n");
5013 M (BRIDGE_FLAGS, bridge_flags);
5015 mp->bd_id = ntohl (bd_id);
5016 mp->feature_bitmap = ntohl (flags);
5017 mp->is_set = is_set;
5026 api_bd_ip_mac_add_del (vat_main_t * vam)
5028 unformat_input_t *i = vam->input;
5029 vl_api_bd_ip_mac_add_del_t *mp;
5037 ip4_address_t v4addr;
5038 ip6_address_t v6addr;
5042 /* Parse args required to build the message */
5043 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5045 if (unformat (i, "bd_id %d", &bd_id))
5049 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5053 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5058 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5062 else if (unformat (i, "del"))
5070 errmsg ("missing bridge domain\n");
5073 else if (ip_set == 0)
5075 errmsg ("missing IP address\n");
5078 else if (mac_set == 0)
5080 errmsg ("missing MAC address\n");
5084 M (BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del);
5086 mp->bd_id = ntohl (bd_id);
5087 mp->is_ipv6 = is_ipv6;
5088 mp->is_add = is_add;
5090 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5092 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5093 clib_memcpy (mp->mac_address, macaddr, 6);
5101 api_tap_connect (vat_main_t * vam)
5103 unformat_input_t *i = vam->input;
5104 vl_api_tap_connect_t *mp;
5111 memset (mac_address, 0, sizeof (mac_address));
5113 /* Parse args required to build the message */
5114 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5116 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5120 else if (unformat (i, "random-mac"))
5122 else if (unformat (i, "tapname %s", &tap_name))
5130 errmsg ("missing tap name\n");
5133 if (vec_len (tap_name) > 63)
5135 errmsg ("tap name too long\n");
5137 vec_add1 (tap_name, 0);
5139 /* Construct the API message */
5140 M (TAP_CONNECT, tap_connect);
5142 mp->use_random_mac = random_mac;
5143 clib_memcpy (mp->mac_address, mac_address, 6);
5144 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5145 vec_free (tap_name);
5150 /* Wait for a reply... */
5155 api_tap_modify (vat_main_t * vam)
5157 unformat_input_t *i = vam->input;
5158 vl_api_tap_modify_t *mp;
5164 u32 sw_if_index = ~0;
5165 u8 sw_if_index_set = 0;
5167 memset (mac_address, 0, sizeof (mac_address));
5169 /* Parse args required to build the message */
5170 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5172 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5173 sw_if_index_set = 1;
5174 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5175 sw_if_index_set = 1;
5176 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5180 else if (unformat (i, "random-mac"))
5182 else if (unformat (i, "tapname %s", &tap_name))
5188 if (sw_if_index_set == 0)
5190 errmsg ("missing vpp interface name");
5195 errmsg ("missing tap name\n");
5198 if (vec_len (tap_name) > 63)
5200 errmsg ("tap name too long\n");
5202 vec_add1 (tap_name, 0);
5204 /* Construct the API message */
5205 M (TAP_MODIFY, tap_modify);
5207 mp->use_random_mac = random_mac;
5208 mp->sw_if_index = ntohl (sw_if_index);
5209 clib_memcpy (mp->mac_address, mac_address, 6);
5210 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5211 vec_free (tap_name);
5216 /* Wait for a reply... */
5221 api_tap_delete (vat_main_t * vam)
5223 unformat_input_t *i = vam->input;
5224 vl_api_tap_delete_t *mp;
5226 u32 sw_if_index = ~0;
5227 u8 sw_if_index_set = 0;
5229 /* Parse args required to build the message */
5230 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5232 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5233 sw_if_index_set = 1;
5234 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5235 sw_if_index_set = 1;
5240 if (sw_if_index_set == 0)
5242 errmsg ("missing vpp interface name");
5246 /* Construct the API message */
5247 M (TAP_DELETE, tap_delete);
5249 mp->sw_if_index = ntohl (sw_if_index);
5254 /* Wait for a reply... */
5259 api_ip_add_del_route (vat_main_t * vam)
5261 unformat_input_t *i = vam->input;
5262 vl_api_ip_add_del_route_t *mp;
5264 u32 sw_if_index = ~0, vrf_id = 0;
5265 u8 sw_if_index_set = 0;
5267 u8 is_local = 0, is_drop = 0;
5268 u8 create_vrf_if_needed = 0;
5270 u8 next_hop_weight = 1;
5272 u8 is_multipath = 0;
5274 u8 address_length_set = 0;
5275 u32 lookup_in_vrf = 0;
5276 u32 resolve_attempts = 0;
5277 u32 dst_address_length = 0;
5278 u8 next_hop_set = 0;
5279 ip4_address_t v4_dst_address, v4_next_hop_address;
5280 ip6_address_t v6_dst_address, v6_next_hop_address;
5284 u32 random_add_del = 0;
5285 u32 *random_vector = 0;
5287 u32 random_seed = 0xdeaddabe;
5288 u32 classify_table_index = ~0;
5291 /* Parse args required to build the message */
5292 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5294 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5295 sw_if_index_set = 1;
5296 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5297 sw_if_index_set = 1;
5298 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
5303 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
5308 else if (unformat (i, "/%d", &dst_address_length))
5310 address_length_set = 1;
5313 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
5314 &v4_next_hop_address))
5318 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
5319 &v6_next_hop_address))
5323 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
5325 else if (unformat (i, "weight %d", &next_hop_weight))
5327 else if (unformat (i, "drop"))
5331 else if (unformat (i, "local"))
5335 else if (unformat (i, "classify %d", &classify_table_index))
5339 else if (unformat (i, "del"))
5341 else if (unformat (i, "add"))
5343 else if (unformat (i, "not-last"))
5345 else if (unformat (i, "multipath"))
5347 else if (unformat (i, "vrf %d", &vrf_id))
5349 else if (unformat (i, "create-vrf"))
5350 create_vrf_if_needed = 1;
5351 else if (unformat (i, "count %d", &count))
5353 else if (unformat (i, "lookup-in-vrf %d", &lookup_in_vrf))
5355 else if (unformat (i, "random"))
5357 else if (unformat (i, "seed %d", &random_seed))
5361 clib_warning ("parse error '%U'", format_unformat_error, i);
5366 if (resolve_attempts > 0 && sw_if_index_set == 0)
5368 errmsg ("ARP resolution needs explicit interface or sw_if_index\n");
5372 if (!next_hop_set && !is_drop && !is_local && !is_classify)
5374 errmsg ("next hop / local / drop / classify not set\n");
5378 if (address_set == 0)
5380 errmsg ("missing addresses\n");
5384 if (address_length_set == 0)
5386 errmsg ("missing address length\n");
5390 /* Generate a pile of unique, random routes */
5393 u32 this_random_address;
5394 random_hash = hash_create (count, sizeof (uword));
5396 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
5397 for (j = 0; j <= count; j++)
5401 this_random_address = random_u32 (&random_seed);
5402 this_random_address =
5403 clib_host_to_net_u32 (this_random_address);
5405 while (hash_get (random_hash, this_random_address));
5406 vec_add1 (random_vector, this_random_address);
5407 hash_set (random_hash, this_random_address, 1);
5409 hash_free (random_hash);
5410 v4_dst_address.as_u32 = random_vector[0];
5415 /* Turn on async mode */
5416 vam->async_mode = 1;
5417 vam->async_errors = 0;
5418 before = vat_time_now (vam);
5421 for (j = 0; j < count; j++)
5423 /* Construct the API message */
5424 M (IP_ADD_DEL_ROUTE, ip_add_del_route);
5426 mp->next_hop_sw_if_index = ntohl (sw_if_index);
5427 mp->vrf_id = ntohl (vrf_id);
5428 if (resolve_attempts > 0)
5430 mp->resolve_attempts = ntohl (resolve_attempts);
5431 mp->resolve_if_needed = 1;
5433 mp->create_vrf_if_needed = create_vrf_if_needed;
5435 mp->is_add = is_add;
5436 mp->is_drop = is_drop;
5437 mp->is_ipv6 = is_ipv6;
5438 mp->is_local = is_local;
5439 mp->is_classify = is_classify;
5440 mp->is_multipath = is_multipath;
5441 mp->not_last = not_last;
5442 mp->next_hop_weight = next_hop_weight;
5443 mp->dst_address_length = dst_address_length;
5444 mp->lookup_in_vrf = ntohl (lookup_in_vrf);
5445 mp->classify_table_index = ntohl (classify_table_index);
5449 clib_memcpy (mp->dst_address, &v6_dst_address,
5450 sizeof (v6_dst_address));
5452 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
5453 sizeof (v6_next_hop_address));
5454 increment_v6_address (&v6_dst_address);
5458 clib_memcpy (mp->dst_address, &v4_dst_address,
5459 sizeof (v4_dst_address));
5461 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
5462 sizeof (v4_next_hop_address));
5464 v4_dst_address.as_u32 = random_vector[j + 1];
5466 increment_v4_address (&v4_dst_address);
5472 /* When testing multiple add/del ops, use a control-ping to sync */
5475 vl_api_control_ping_t *mp;
5478 /* Shut off async mode */
5479 vam->async_mode = 0;
5481 M (CONTROL_PING, control_ping);
5484 timeout = vat_time_now (vam) + 1.0;
5485 while (vat_time_now (vam) < timeout)
5486 if (vam->result_ready == 1)
5491 if (vam->retval == -99)
5492 errmsg ("timeout\n");
5494 if (vam->async_errors > 0)
5496 errmsg ("%d asynchronous errors\n", vam->async_errors);
5499 vam->async_errors = 0;
5500 after = vat_time_now (vam);
5502 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
5503 count, after - before, count / (after - before));
5507 /* Wait for a reply... */
5511 /* Return the good/bad news */
5512 return (vam->retval);
5516 api_proxy_arp_add_del (vat_main_t * vam)
5518 unformat_input_t *i = vam->input;
5519 vl_api_proxy_arp_add_del_t *mp;
5523 ip4_address_t lo, hi;
5526 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5528 if (unformat (i, "vrf %d", &vrf_id))
5530 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
5531 unformat_ip4_address, &hi))
5533 else if (unformat (i, "del"))
5537 clib_warning ("parse error '%U'", format_unformat_error, i);
5544 errmsg ("address range not set\n");
5548 M (PROXY_ARP_ADD_DEL, proxy_arp_add_del);
5550 mp->vrf_id = ntohl (vrf_id);
5551 mp->is_add = is_add;
5552 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
5553 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
5562 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
5564 unformat_input_t *i = vam->input;
5565 vl_api_proxy_arp_intfc_enable_disable_t *mp;
5569 u8 sw_if_index_set = 0;
5571 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5573 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5574 sw_if_index_set = 1;
5575 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5576 sw_if_index_set = 1;
5577 else if (unformat (i, "enable"))
5579 else if (unformat (i, "disable"))
5583 clib_warning ("parse error '%U'", format_unformat_error, i);
5588 if (sw_if_index_set == 0)
5590 errmsg ("missing interface name or sw_if_index\n");
5594 M (PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable);
5596 mp->sw_if_index = ntohl (sw_if_index);
5597 mp->enable_disable = enable;
5606 api_mpls_add_del_decap (vat_main_t * vam)
5608 unformat_input_t *i = vam->input;
5609 vl_api_mpls_add_del_decap_t *mp;
5618 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5620 if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
5622 else if (unformat (i, "tx_vrf_id %d", &tx_vrf_id))
5624 else if (unformat (i, "label %d", &label))
5626 else if (unformat (i, "next-index %d", &next_index))
5628 else if (unformat (i, "del"))
5630 else if (unformat (i, "s-bit-clear"))
5634 clib_warning ("parse error '%U'", format_unformat_error, i);
5639 M (MPLS_ADD_DEL_DECAP, mpls_add_del_decap);
5641 mp->rx_vrf_id = ntohl (rx_vrf_id);
5642 mp->tx_vrf_id = ntohl (tx_vrf_id);
5643 mp->label = ntohl (label);
5644 mp->next_index = ntohl (next_index);
5646 mp->is_add = is_add;
5655 api_mpls_add_del_encap (vat_main_t * vam)
5657 unformat_input_t *i = vam->input;
5658 vl_api_mpls_add_del_encap_t *mp;
5663 ip4_address_t dst_address;
5666 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5668 if (unformat (i, "vrf %d", &vrf_id))
5670 else if (unformat (i, "label %d", &label))
5671 vec_add1 (labels, ntohl (label));
5672 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
5674 else if (unformat (i, "del"))
5678 clib_warning ("parse error '%U'", format_unformat_error, i);
5683 if (vec_len (labels) == 0)
5685 errmsg ("missing encap label stack\n");
5689 M2 (MPLS_ADD_DEL_ENCAP, mpls_add_del_encap,
5690 sizeof (u32) * vec_len (labels));
5692 mp->vrf_id = ntohl (vrf_id);
5693 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
5694 mp->is_add = is_add;
5695 mp->nlabels = vec_len (labels);
5696 clib_memcpy (mp->labels, labels, sizeof (u32) * mp->nlabels);
5707 api_mpls_gre_add_del_tunnel (vat_main_t * vam)
5709 unformat_input_t *i = vam->input;
5710 vl_api_mpls_gre_add_del_tunnel_t *mp;
5712 u32 inner_vrf_id = 0;
5713 u32 outer_vrf_id = 0;
5714 ip4_address_t src_address;
5715 ip4_address_t dst_address;
5716 ip4_address_t intfc_address;
5718 u8 intfc_address_length = 0;
5722 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5724 if (unformat (i, "inner_vrf_id %d", &inner_vrf_id))
5726 else if (unformat (i, "outer_vrf_id %d", &outer_vrf_id))
5728 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
5730 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
5732 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
5733 &intfc_address, &tmp))
5734 intfc_address_length = tmp;
5735 else if (unformat (i, "l2-only"))
5737 else if (unformat (i, "del"))
5741 clib_warning ("parse error '%U'", format_unformat_error, i);
5746 M (MPLS_GRE_ADD_DEL_TUNNEL, mpls_gre_add_del_tunnel);
5748 mp->inner_vrf_id = ntohl (inner_vrf_id);
5749 mp->outer_vrf_id = ntohl (outer_vrf_id);
5750 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
5751 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
5752 clib_memcpy (mp->intfc_address, &intfc_address, sizeof (intfc_address));
5753 mp->intfc_address_length = intfc_address_length;
5754 mp->l2_only = l2_only;
5755 mp->is_add = is_add;
5764 api_mpls_ethernet_add_del_tunnel (vat_main_t * vam)
5766 unformat_input_t *i = vam->input;
5767 vl_api_mpls_ethernet_add_del_tunnel_t *mp;
5769 u32 inner_vrf_id = 0;
5770 ip4_address_t intfc_address;
5771 u8 dst_mac_address[6];
5774 u8 intfc_address_length = 0;
5778 int tx_sw_if_index_set = 0;
5780 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5782 if (unformat (i, "vrf %d", &inner_vrf_id))
5784 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
5785 &intfc_address, &tmp))
5786 intfc_address_length = tmp;
5787 else if (unformat (i, "%U", unformat_sw_if_index, vam, &tx_sw_if_index))
5788 tx_sw_if_index_set = 1;
5789 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5790 tx_sw_if_index_set = 1;
5791 else if (unformat (i, "dst %U", unformat_ethernet_address,
5794 else if (unformat (i, "l2-only"))
5796 else if (unformat (i, "del"))
5800 clib_warning ("parse error '%U'", format_unformat_error, i);
5807 errmsg ("dst (mac address) not set\n");
5810 if (!tx_sw_if_index_set)
5812 errmsg ("tx-intfc not set\n");
5816 M (MPLS_ETHERNET_ADD_DEL_TUNNEL, mpls_ethernet_add_del_tunnel);
5818 mp->vrf_id = ntohl (inner_vrf_id);
5819 clib_memcpy (mp->adj_address, &intfc_address, sizeof (intfc_address));
5820 mp->adj_address_length = intfc_address_length;
5821 clib_memcpy (mp->dst_mac_address, dst_mac_address,
5822 sizeof (dst_mac_address));
5823 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5824 mp->l2_only = l2_only;
5825 mp->is_add = is_add;
5834 api_mpls_ethernet_add_del_tunnel_2 (vat_main_t * vam)
5836 unformat_input_t *i = vam->input;
5837 vl_api_mpls_ethernet_add_del_tunnel_2_t *mp;
5839 u32 inner_vrf_id = 0;
5840 u32 outer_vrf_id = 0;
5841 ip4_address_t adj_address;
5842 int adj_address_set = 0;
5843 ip4_address_t next_hop_address;
5844 int next_hop_address_set = 0;
5846 u8 adj_address_length = 0;
5849 u32 resolve_attempts = 5;
5850 u8 resolve_if_needed = 1;
5852 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5854 if (unformat (i, "inner_vrf_id %d", &inner_vrf_id))
5856 else if (unformat (i, "outer_vrf_id %d", &outer_vrf_id))
5858 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
5859 &adj_address, &tmp))
5861 adj_address_length = tmp;
5862 adj_address_set = 1;
5864 else if (unformat (i, "next-hop %U", unformat_ip4_address,
5866 next_hop_address_set = 1;
5867 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
5869 else if (unformat (i, "resolve-if-needed %d", &tmp))
5870 resolve_if_needed = tmp;
5871 else if (unformat (i, "l2-only"))
5873 else if (unformat (i, "del"))
5877 clib_warning ("parse error '%U'", format_unformat_error, i);
5882 if (!adj_address_set)
5884 errmsg ("adjacency address/mask not set\n");
5887 if (!next_hop_address_set)
5889 errmsg ("ip4 next hop address (in outer fib) not set\n");
5893 M (MPLS_ETHERNET_ADD_DEL_TUNNEL_2, mpls_ethernet_add_del_tunnel_2);
5895 mp->inner_vrf_id = ntohl (inner_vrf_id);
5896 mp->outer_vrf_id = ntohl (outer_vrf_id);
5897 mp->resolve_attempts = ntohl (resolve_attempts);
5898 mp->resolve_if_needed = resolve_if_needed;
5899 mp->is_add = is_add;
5900 mp->l2_only = l2_only;
5901 clib_memcpy (mp->adj_address, &adj_address, sizeof (adj_address));
5902 mp->adj_address_length = adj_address_length;
5903 clib_memcpy (mp->next_hop_ip4_address_in_outer_vrf, &next_hop_address,
5904 sizeof (next_hop_address));
5913 api_sw_interface_set_unnumbered (vat_main_t * vam)
5915 unformat_input_t *i = vam->input;
5916 vl_api_sw_interface_set_unnumbered_t *mp;
5919 u32 unnum_sw_index = ~0;
5921 u8 sw_if_index_set = 0;
5923 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5925 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5926 sw_if_index_set = 1;
5927 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5928 sw_if_index_set = 1;
5929 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
5931 else if (unformat (i, "del"))
5935 clib_warning ("parse error '%U'", format_unformat_error, i);
5940 if (sw_if_index_set == 0)
5942 errmsg ("missing interface name or sw_if_index\n");
5946 M (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered);
5948 mp->sw_if_index = ntohl (sw_if_index);
5949 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
5950 mp->is_add = is_add;
5959 api_ip_neighbor_add_del (vat_main_t * vam)
5961 unformat_input_t *i = vam->input;
5962 vl_api_ip_neighbor_add_del_t *mp;
5965 u8 sw_if_index_set = 0;
5971 u8 v4_address_set = 0;
5972 u8 v6_address_set = 0;
5973 ip4_address_t v4address;
5974 ip6_address_t v6address;
5976 memset (mac_address, 0, sizeof (mac_address));
5978 /* Parse args required to build the message */
5979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5981 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5985 else if (unformat (i, "del"))
5987 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5988 sw_if_index_set = 1;
5989 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5990 sw_if_index_set = 1;
5991 else if (unformat (i, "is_static"))
5993 else if (unformat (i, "vrf %d", &vrf_id))
5995 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
5997 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
6001 clib_warning ("parse error '%U'", format_unformat_error, i);
6006 if (sw_if_index_set == 0)
6008 errmsg ("missing interface name or sw_if_index\n");
6011 if (v4_address_set && v6_address_set)
6013 errmsg ("both v4 and v6 addresses set\n");
6016 if (!v4_address_set && !v6_address_set)
6018 errmsg ("no address set\n");
6022 /* Construct the API message */
6023 M (IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del);
6025 mp->sw_if_index = ntohl (sw_if_index);
6026 mp->is_add = is_add;
6027 mp->vrf_id = ntohl (vrf_id);
6028 mp->is_static = is_static;
6030 clib_memcpy (mp->mac_address, mac_address, 6);
6034 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
6038 /* mp->is_ipv6 = 0; via memset in M macro above */
6039 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
6045 /* Wait for a reply, return good/bad news */
6053 api_reset_vrf (vat_main_t * vam)
6055 unformat_input_t *i = vam->input;
6056 vl_api_reset_vrf_t *mp;
6062 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6064 if (unformat (i, "vrf %d", &vrf_id))
6066 else if (unformat (i, "ipv6"))
6070 clib_warning ("parse error '%U'", format_unformat_error, i);
6075 if (vrf_id_set == 0)
6077 errmsg ("missing vrf id\n");
6081 M (RESET_VRF, reset_vrf);
6083 mp->vrf_id = ntohl (vrf_id);
6084 mp->is_ipv6 = is_ipv6;
6093 api_create_vlan_subif (vat_main_t * vam)
6095 unformat_input_t *i = vam->input;
6096 vl_api_create_vlan_subif_t *mp;
6099 u8 sw_if_index_set = 0;
6103 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6105 if (unformat (i, "sw_if_index %d", &sw_if_index))
6106 sw_if_index_set = 1;
6107 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6108 sw_if_index_set = 1;
6109 else if (unformat (i, "vlan %d", &vlan_id))
6113 clib_warning ("parse error '%U'", format_unformat_error, i);
6118 if (sw_if_index_set == 0)
6120 errmsg ("missing interface name or sw_if_index\n");
6124 if (vlan_id_set == 0)
6126 errmsg ("missing vlan_id\n");
6129 M (CREATE_VLAN_SUBIF, create_vlan_subif);
6131 mp->sw_if_index = ntohl (sw_if_index);
6132 mp->vlan_id = ntohl (vlan_id);
6140 #define foreach_create_subif_bit \
6147 _(outer_vlan_id_any) \
6148 _(inner_vlan_id_any)
6151 api_create_subif (vat_main_t * vam)
6153 unformat_input_t *i = vam->input;
6154 vl_api_create_subif_t *mp;
6157 u8 sw_if_index_set = 0;
6164 u32 exact_match = 0;
6165 u32 default_sub = 0;
6166 u32 outer_vlan_id_any = 0;
6167 u32 inner_vlan_id_any = 0;
6169 u16 outer_vlan_id = 0;
6170 u16 inner_vlan_id = 0;
6172 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6174 if (unformat (i, "sw_if_index %d", &sw_if_index))
6175 sw_if_index_set = 1;
6176 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6177 sw_if_index_set = 1;
6178 else if (unformat (i, "sub_id %d", &sub_id))
6180 else if (unformat (i, "outer_vlan_id %d", &tmp))
6181 outer_vlan_id = tmp;
6182 else if (unformat (i, "inner_vlan_id %d", &tmp))
6183 inner_vlan_id = tmp;
6185 #define _(a) else if (unformat (i, #a)) a = 1 ;
6186 foreach_create_subif_bit
6190 clib_warning ("parse error '%U'", format_unformat_error, i);
6195 if (sw_if_index_set == 0)
6197 errmsg ("missing interface name or sw_if_index\n");
6201 if (sub_id_set == 0)
6203 errmsg ("missing sub_id\n");
6206 M (CREATE_SUBIF, create_subif);
6208 mp->sw_if_index = ntohl (sw_if_index);
6209 mp->sub_id = ntohl (sub_id);
6211 #define _(a) mp->a = a;
6212 foreach_create_subif_bit;
6215 mp->outer_vlan_id = ntohs (outer_vlan_id);
6216 mp->inner_vlan_id = ntohs (inner_vlan_id);
6225 api_oam_add_del (vat_main_t * vam)
6227 unformat_input_t *i = vam->input;
6228 vl_api_oam_add_del_t *mp;
6232 ip4_address_t src, dst;
6236 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6238 if (unformat (i, "vrf %d", &vrf_id))
6240 else if (unformat (i, "src %U", unformat_ip4_address, &src))
6242 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
6244 else if (unformat (i, "del"))
6248 clib_warning ("parse error '%U'", format_unformat_error, i);
6255 errmsg ("missing src addr\n");
6261 errmsg ("missing dst addr\n");
6265 M (OAM_ADD_DEL, oam_add_del);
6267 mp->vrf_id = ntohl (vrf_id);
6268 mp->is_add = is_add;
6269 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
6270 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
6279 api_reset_fib (vat_main_t * vam)
6281 unformat_input_t *i = vam->input;
6282 vl_api_reset_fib_t *mp;
6288 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6290 if (unformat (i, "vrf %d", &vrf_id))
6292 else if (unformat (i, "ipv6"))
6296 clib_warning ("parse error '%U'", format_unformat_error, i);
6301 if (vrf_id_set == 0)
6303 errmsg ("missing vrf id\n");
6307 M (RESET_FIB, reset_fib);
6309 mp->vrf_id = ntohl (vrf_id);
6310 mp->is_ipv6 = is_ipv6;
6319 api_dhcp_proxy_config (vat_main_t * vam)
6321 unformat_input_t *i = vam->input;
6322 vl_api_dhcp_proxy_config_t *mp;
6327 u8 v4_address_set = 0;
6328 u8 v6_address_set = 0;
6329 ip4_address_t v4address;
6330 ip6_address_t v6address;
6331 u8 v4_src_address_set = 0;
6332 u8 v6_src_address_set = 0;
6333 ip4_address_t v4srcaddress;
6334 ip6_address_t v6srcaddress;
6336 /* Parse args required to build the message */
6337 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6339 if (unformat (i, "del"))
6341 else if (unformat (i, "vrf %d", &vrf_id))
6343 else if (unformat (i, "insert-cid %d", &insert_cid))
6345 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
6347 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
6349 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
6350 v4_src_address_set = 1;
6351 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
6352 v6_src_address_set = 1;
6357 if (v4_address_set && v6_address_set)
6359 errmsg ("both v4 and v6 server addresses set\n");
6362 if (!v4_address_set && !v6_address_set)
6364 errmsg ("no server addresses set\n");
6368 if (v4_src_address_set && v6_src_address_set)
6370 errmsg ("both v4 and v6 src addresses set\n");
6373 if (!v4_src_address_set && !v6_src_address_set)
6375 errmsg ("no src addresses set\n");
6379 if (!(v4_src_address_set && v4_address_set) &&
6380 !(v6_src_address_set && v6_address_set))
6382 errmsg ("no matching server and src addresses set\n");
6386 /* Construct the API message */
6387 M (DHCP_PROXY_CONFIG, dhcp_proxy_config);
6389 mp->insert_circuit_id = insert_cid;
6390 mp->is_add = is_add;
6391 mp->vrf_id = ntohl (vrf_id);
6395 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
6396 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
6400 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
6401 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
6407 /* Wait for a reply, return good/bad news */
6414 api_dhcp_proxy_config_2 (vat_main_t * vam)
6416 unformat_input_t *i = vam->input;
6417 vl_api_dhcp_proxy_config_2_t *mp;
6420 u32 server_vrf_id = 0;
6423 u8 v4_address_set = 0;
6424 u8 v6_address_set = 0;
6425 ip4_address_t v4address;
6426 ip6_address_t v6address;
6427 u8 v4_src_address_set = 0;
6428 u8 v6_src_address_set = 0;
6429 ip4_address_t v4srcaddress;
6430 ip6_address_t v6srcaddress;
6432 /* Parse args required to build the message */
6433 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6435 if (unformat (i, "del"))
6437 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
6439 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
6441 else if (unformat (i, "insert-cid %d", &insert_cid))
6443 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
6445 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
6447 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
6448 v4_src_address_set = 1;
6449 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
6450 v6_src_address_set = 1;
6455 if (v4_address_set && v6_address_set)
6457 errmsg ("both v4 and v6 server addresses set\n");
6460 if (!v4_address_set && !v6_address_set)
6462 errmsg ("no server addresses set\n");
6466 if (v4_src_address_set && v6_src_address_set)
6468 errmsg ("both v4 and v6 src addresses set\n");
6471 if (!v4_src_address_set && !v6_src_address_set)
6473 errmsg ("no src addresses set\n");
6477 if (!(v4_src_address_set && v4_address_set) &&
6478 !(v6_src_address_set && v6_address_set))
6480 errmsg ("no matching server and src addresses set\n");
6484 /* Construct the API message */
6485 M (DHCP_PROXY_CONFIG_2, dhcp_proxy_config_2);
6487 mp->insert_circuit_id = insert_cid;
6488 mp->is_add = is_add;
6489 mp->rx_vrf_id = ntohl (rx_vrf_id);
6490 mp->server_vrf_id = ntohl (server_vrf_id);
6494 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
6495 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
6499 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
6500 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
6506 /* Wait for a reply, return good/bad news */
6513 api_dhcp_proxy_set_vss (vat_main_t * vam)
6515 unformat_input_t *i = vam->input;
6516 vl_api_dhcp_proxy_set_vss_t *mp;
6527 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6529 if (unformat (i, "tbl_id %d", &tbl_id))
6531 if (unformat (i, "fib_id %d", &fib_id))
6533 if (unformat (i, "oui %d", &oui))
6535 else if (unformat (i, "ipv6"))
6537 else if (unformat (i, "del"))
6541 clib_warning ("parse error '%U'", format_unformat_error, i);
6546 if (tbl_id_set == 0)
6548 errmsg ("missing tbl id\n");
6552 if (fib_id_set == 0)
6554 errmsg ("missing fib id\n");
6559 errmsg ("missing oui\n");
6563 M (DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss);
6564 mp->tbl_id = ntohl (tbl_id);
6565 mp->fib_id = ntohl (fib_id);
6566 mp->oui = ntohl (oui);
6567 mp->is_ipv6 = is_ipv6;
6568 mp->is_add = is_add;
6577 api_dhcp_client_config (vat_main_t * vam)
6579 unformat_input_t *i = vam->input;
6580 vl_api_dhcp_client_config_t *mp;
6583 u8 sw_if_index_set = 0;
6586 u8 disable_event = 0;
6588 /* Parse args required to build the message */
6589 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6591 if (unformat (i, "del"))
6593 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6594 sw_if_index_set = 1;
6595 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6596 sw_if_index_set = 1;
6597 else if (unformat (i, "hostname %s", &hostname))
6599 else if (unformat (i, "disable_event"))
6605 if (sw_if_index_set == 0)
6607 errmsg ("missing interface name or sw_if_index\n");
6611 if (vec_len (hostname) > 63)
6613 errmsg ("hostname too long\n");
6615 vec_add1 (hostname, 0);
6617 /* Construct the API message */
6618 M (DHCP_CLIENT_CONFIG, dhcp_client_config);
6620 mp->sw_if_index = ntohl (sw_if_index);
6621 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
6622 vec_free (hostname);
6623 mp->is_add = is_add;
6624 mp->want_dhcp_event = disable_event ? 0 : 1;
6625 mp->pid = getpid ();
6630 /* Wait for a reply, return good/bad news */
6637 api_set_ip_flow_hash (vat_main_t * vam)
6639 unformat_input_t *i = vam->input;
6640 vl_api_set_ip_flow_hash_t *mp;
6652 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6654 if (unformat (i, "vrf %d", &vrf_id))
6656 else if (unformat (i, "ipv6"))
6658 else if (unformat (i, "src"))
6660 else if (unformat (i, "dst"))
6662 else if (unformat (i, "sport"))
6664 else if (unformat (i, "dport"))
6666 else if (unformat (i, "proto"))
6668 else if (unformat (i, "reverse"))
6673 clib_warning ("parse error '%U'", format_unformat_error, i);
6678 if (vrf_id_set == 0)
6680 errmsg ("missing vrf id\n");
6684 M (SET_IP_FLOW_HASH, set_ip_flow_hash);
6690 mp->reverse = reverse;
6691 mp->vrf_id = ntohl (vrf_id);
6692 mp->is_ipv6 = is_ipv6;
6701 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
6703 unformat_input_t *i = vam->input;
6704 vl_api_sw_interface_ip6_enable_disable_t *mp;
6707 u8 sw_if_index_set = 0;
6710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6712 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6713 sw_if_index_set = 1;
6714 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6715 sw_if_index_set = 1;
6716 else if (unformat (i, "enable"))
6718 else if (unformat (i, "disable"))
6722 clib_warning ("parse error '%U'", format_unformat_error, i);
6727 if (sw_if_index_set == 0)
6729 errmsg ("missing interface name or sw_if_index\n");
6733 M (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable);
6735 mp->sw_if_index = ntohl (sw_if_index);
6736 mp->enable = enable;
6745 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
6747 unformat_input_t *i = vam->input;
6748 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
6751 u8 sw_if_index_set = 0;
6752 u32 address_length = 0;
6753 u8 v6_address_set = 0;
6754 ip6_address_t v6address;
6756 /* Parse args required to build the message */
6757 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6759 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6760 sw_if_index_set = 1;
6761 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6762 sw_if_index_set = 1;
6763 else if (unformat (i, "%U/%d",
6764 unformat_ip6_address, &v6address, &address_length))
6770 if (sw_if_index_set == 0)
6772 errmsg ("missing interface name or sw_if_index\n");
6775 if (!v6_address_set)
6777 errmsg ("no address set\n");
6781 /* Construct the API message */
6782 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,
6783 sw_interface_ip6_set_link_local_address);
6785 mp->sw_if_index = ntohl (sw_if_index);
6786 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6787 mp->address_length = address_length;
6792 /* Wait for a reply, return good/bad news */
6801 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
6803 unformat_input_t *i = vam->input;
6804 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
6807 u8 sw_if_index_set = 0;
6808 u32 address_length = 0;
6809 u8 v6_address_set = 0;
6810 ip6_address_t v6address;
6812 u8 no_advertise = 0;
6814 u8 no_autoconfig = 0;
6817 u32 val_lifetime = 0;
6818 u32 pref_lifetime = 0;
6820 /* Parse args required to build the message */
6821 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6823 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6824 sw_if_index_set = 1;
6825 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6826 sw_if_index_set = 1;
6827 else if (unformat (i, "%U/%d",
6828 unformat_ip6_address, &v6address, &address_length))
6830 else if (unformat (i, "val_life %d", &val_lifetime))
6832 else if (unformat (i, "pref_life %d", &pref_lifetime))
6834 else if (unformat (i, "def"))
6836 else if (unformat (i, "noadv"))
6838 else if (unformat (i, "offl"))
6840 else if (unformat (i, "noauto"))
6842 else if (unformat (i, "nolink"))
6844 else if (unformat (i, "isno"))
6848 clib_warning ("parse error '%U'", format_unformat_error, i);
6853 if (sw_if_index_set == 0)
6855 errmsg ("missing interface name or sw_if_index\n");
6858 if (!v6_address_set)
6860 errmsg ("no address set\n");
6864 /* Construct the API message */
6865 M (SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix);
6867 mp->sw_if_index = ntohl (sw_if_index);
6868 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6869 mp->address_length = address_length;
6870 mp->use_default = use_default;
6871 mp->no_advertise = no_advertise;
6872 mp->off_link = off_link;
6873 mp->no_autoconfig = no_autoconfig;
6874 mp->no_onlink = no_onlink;
6876 mp->val_lifetime = ntohl (val_lifetime);
6877 mp->pref_lifetime = ntohl (pref_lifetime);
6882 /* Wait for a reply, return good/bad news */
6890 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
6892 unformat_input_t *i = vam->input;
6893 vl_api_sw_interface_ip6nd_ra_config_t *mp;
6896 u8 sw_if_index_set = 0;
6901 u8 send_unicast = 0;
6904 u8 default_router = 0;
6905 u32 max_interval = 0;
6906 u32 min_interval = 0;
6908 u32 initial_count = 0;
6909 u32 initial_interval = 0;
6912 /* Parse args required to build the message */
6913 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6915 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6916 sw_if_index_set = 1;
6917 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6918 sw_if_index_set = 1;
6919 else if (unformat (i, "maxint %d", &max_interval))
6921 else if (unformat (i, "minint %d", &min_interval))
6923 else if (unformat (i, "life %d", &lifetime))
6925 else if (unformat (i, "count %d", &initial_count))
6927 else if (unformat (i, "interval %d", &initial_interval))
6929 else if (unformat (i, "suppress") || unformat (i, "surpress"))
6931 else if (unformat (i, "managed"))
6933 else if (unformat (i, "other"))
6935 else if (unformat (i, "ll"))
6937 else if (unformat (i, "send"))
6939 else if (unformat (i, "cease"))
6941 else if (unformat (i, "isno"))
6943 else if (unformat (i, "def"))
6947 clib_warning ("parse error '%U'", format_unformat_error, i);
6952 if (sw_if_index_set == 0)
6954 errmsg ("missing interface name or sw_if_index\n");
6958 /* Construct the API message */
6959 M (SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config);
6961 mp->sw_if_index = ntohl (sw_if_index);
6962 mp->max_interval = ntohl (max_interval);
6963 mp->min_interval = ntohl (min_interval);
6964 mp->lifetime = ntohl (lifetime);
6965 mp->initial_count = ntohl (initial_count);
6966 mp->initial_interval = ntohl (initial_interval);
6967 mp->suppress = suppress;
6968 mp->managed = managed;
6970 mp->ll_option = ll_option;
6971 mp->send_unicast = send_unicast;
6974 mp->default_router = default_router;
6979 /* Wait for a reply, return good/bad news */
6987 api_set_arp_neighbor_limit (vat_main_t * vam)
6989 unformat_input_t *i = vam->input;
6990 vl_api_set_arp_neighbor_limit_t *mp;
6996 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6998 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
7000 else if (unformat (i, "ipv6"))
7004 clib_warning ("parse error '%U'", format_unformat_error, i);
7011 errmsg ("missing limit value\n");
7015 M (SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit);
7017 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
7018 mp->is_ipv6 = is_ipv6;
7027 api_l2_patch_add_del (vat_main_t * vam)
7029 unformat_input_t *i = vam->input;
7030 vl_api_l2_patch_add_del_t *mp;
7033 u8 rx_sw_if_index_set = 0;
7035 u8 tx_sw_if_index_set = 0;
7038 /* Parse args required to build the message */
7039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7041 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7042 rx_sw_if_index_set = 1;
7043 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7044 tx_sw_if_index_set = 1;
7045 else if (unformat (i, "rx"))
7047 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7049 if (unformat (i, "%U", unformat_sw_if_index, vam,
7051 rx_sw_if_index_set = 1;
7056 else if (unformat (i, "tx"))
7058 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7060 if (unformat (i, "%U", unformat_sw_if_index, vam,
7062 tx_sw_if_index_set = 1;
7067 else if (unformat (i, "del"))
7073 if (rx_sw_if_index_set == 0)
7075 errmsg ("missing rx interface name or rx_sw_if_index\n");
7079 if (tx_sw_if_index_set == 0)
7081 errmsg ("missing tx interface name or tx_sw_if_index\n");
7085 M (L2_PATCH_ADD_DEL, l2_patch_add_del);
7087 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7088 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7089 mp->is_add = is_add;
7098 api_trace_profile_add (vat_main_t * vam)
7100 unformat_input_t *input = vam->input;
7101 vl_api_trace_profile_add_t *mp;
7104 u32 trace_option_elts = 0;
7105 u32 trace_type = 0, node_id = 0, app_data = 0, trace_tsp = 2;
7106 int has_pow_option = 0;
7107 int has_ppc_option = 0;
7109 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7111 if (unformat (input, "id %d trace-type 0x%x trace-elts %d "
7112 "trace-tsp %d node-id 0x%x app-data 0x%x",
7113 &id, &trace_type, &trace_option_elts, &trace_tsp,
7114 &node_id, &app_data))
7116 else if (unformat (input, "pow"))
7118 else if (unformat (input, "ppc encap"))
7119 has_ppc_option = PPC_ENCAP;
7120 else if (unformat (input, "ppc decap"))
7121 has_ppc_option = PPC_DECAP;
7122 else if (unformat (input, "ppc none"))
7123 has_ppc_option = PPC_NONE;
7127 M (TRACE_PROFILE_ADD, trace_profile_add);
7128 mp->id = htons (id);
7129 mp->trace_type = trace_type;
7130 mp->trace_num_elt = trace_option_elts;
7131 mp->trace_ppc = has_ppc_option;
7132 mp->trace_app_data = htonl (app_data);
7133 mp->pow_enable = has_pow_option;
7134 mp->trace_tsp = trace_tsp;
7135 mp->node_id = htonl (node_id);
7145 api_trace_profile_apply (vat_main_t * vam)
7147 unformat_input_t *input = vam->input;
7148 vl_api_trace_profile_apply_t *mp;
7151 u32 mask_width = ~0;
7158 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7160 if (unformat (input, "%U/%d", unformat_ip6_address, &addr, &mask_width))
7162 else if (unformat (input, "id %d", &id))
7164 else if (unformat (input, "vrf-id %d", &vrf_id))
7166 else if (unformat (input, "add"))
7168 else if (unformat (input, "pop"))
7170 else if (unformat (input, "none"))
7176 if ((is_add + is_pop + is_none) != 1)
7178 errmsg ("One of (add, pop, none) required");
7181 if (mask_width == ~0)
7183 errmsg ("<address>/<mask-width> required");
7186 M (TRACE_PROFILE_APPLY, trace_profile_apply);
7187 clib_memcpy (mp->dest_ipv6, &addr, sizeof (mp->dest_ipv6));
7188 mp->id = htons (id);
7189 mp->prefix_length = htonl (mask_width);
7190 mp->vrf_id = htonl (vrf_id);
7192 mp->trace_op = IOAM_HBYH_ADD;
7194 mp->trace_op = IOAM_HBYH_POP;
7196 mp->trace_op = IOAM_HBYH_MOD;
7210 api_trace_profile_del (vat_main_t * vam)
7212 vl_api_trace_profile_del_t *mp;
7215 M (TRACE_PROFILE_DEL, trace_profile_del);
7222 api_sr_tunnel_add_del (vat_main_t * vam)
7224 unformat_input_t *i = vam->input;
7225 vl_api_sr_tunnel_add_del_t *mp;
7229 ip6_address_t src_address;
7230 int src_address_set = 0;
7231 ip6_address_t dst_address;
7233 int dst_address_set = 0;
7235 u32 rx_table_id = 0;
7236 u32 tx_table_id = 0;
7237 ip6_address_t *segments = 0;
7238 ip6_address_t *this_seg;
7239 ip6_address_t *tags = 0;
7240 ip6_address_t *this_tag;
7241 ip6_address_t next_address, tag;
7243 u8 *policy_name = 0;
7245 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7247 if (unformat (i, "del"))
7249 else if (unformat (i, "name %s", &name))
7251 else if (unformat (i, "policy %s", &policy_name))
7253 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
7255 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
7257 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
7258 src_address_set = 1;
7259 else if (unformat (i, "dst %U/%d",
7260 unformat_ip6_address, &dst_address, &dst_mask_width))
7261 dst_address_set = 1;
7262 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
7264 vec_add2 (segments, this_seg, 1);
7265 clib_memcpy (this_seg->as_u8, next_address.as_u8,
7266 sizeof (*this_seg));
7268 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
7270 vec_add2 (tags, this_tag, 1);
7271 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
7273 else if (unformat (i, "clean"))
7274 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
7275 else if (unformat (i, "protected"))
7276 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
7277 else if (unformat (i, "InPE %d", &pl_index))
7279 if (pl_index <= 0 || pl_index > 4)
7281 pl_index_range_error:
7282 errmsg ("pl index %d out of range\n", pl_index);
7286 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
7288 else if (unformat (i, "EgPE %d", &pl_index))
7290 if (pl_index <= 0 || pl_index > 4)
7291 goto pl_index_range_error;
7293 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
7295 else if (unformat (i, "OrgSrc %d", &pl_index))
7297 if (pl_index <= 0 || pl_index > 4)
7298 goto pl_index_range_error;
7300 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
7306 if (!src_address_set)
7308 errmsg ("src address required\n");
7312 if (!dst_address_set)
7314 errmsg ("dst address required\n");
7320 errmsg ("at least one sr segment required\n");
7324 M2 (SR_TUNNEL_ADD_DEL, sr_tunnel_add_del,
7325 vec_len (segments) * sizeof (ip6_address_t)
7326 + vec_len (tags) * sizeof (ip6_address_t));
7328 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
7329 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
7330 mp->dst_mask_width = dst_mask_width;
7331 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
7332 mp->n_segments = vec_len (segments);
7333 mp->n_tags = vec_len (tags);
7334 mp->is_add = is_del == 0;
7335 clib_memcpy (mp->segs_and_tags, segments,
7336 vec_len (segments) * sizeof (ip6_address_t));
7337 clib_memcpy (mp->segs_and_tags +
7338 vec_len (segments) * sizeof (ip6_address_t), tags,
7339 vec_len (tags) * sizeof (ip6_address_t));
7341 mp->outer_vrf_id = ntohl (rx_table_id);
7342 mp->inner_vrf_id = ntohl (tx_table_id);
7343 memcpy (mp->name, name, vec_len (name));
7344 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
7346 vec_free (segments);
7355 api_sr_policy_add_del (vat_main_t * vam)
7357 unformat_input_t *input = vam->input;
7358 vl_api_sr_policy_add_del_t *mp;
7362 u8 *tunnel_name = 0;
7363 u8 **tunnel_names = 0;
7368 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
7369 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
7371 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7373 if (unformat (input, "del"))
7375 else if (unformat (input, "name %s", &name))
7377 else if (unformat (input, "tunnel %s", &tunnel_name))
7381 vec_add1 (tunnel_names, tunnel_name);
7383 - length = #bytes to store in serial vector
7384 - +1 = byte to store that length
7386 tunnel_names_length += (vec_len (tunnel_name) + 1);
7397 errmsg ("policy name required\n");
7401 if ((!tunnel_set) && (!is_del))
7403 errmsg ("tunnel name required\n");
7407 M2 (SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length);
7411 mp->is_add = !is_del;
7413 memcpy (mp->name, name, vec_len (name));
7414 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
7415 u8 *serial_orig = 0;
7416 vec_validate (serial_orig, tunnel_names_length);
7417 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
7418 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
7420 for (j = 0; j < vec_len (tunnel_names); j++)
7422 tun_name_len = vec_len (tunnel_names[j]);
7423 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
7424 serial_orig += 1; // Move along one byte to store the actual tunnel name
7425 memcpy (serial_orig, tunnel_names[j], tun_name_len);
7426 serial_orig += tun_name_len; // Advance past the copy
7428 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
7430 vec_free (tunnel_names);
7431 vec_free (tunnel_name);
7439 api_sr_multicast_map_add_del (vat_main_t * vam)
7441 unformat_input_t *input = vam->input;
7442 vl_api_sr_multicast_map_add_del_t *mp;
7445 ip6_address_t multicast_address;
7446 u8 *policy_name = 0;
7447 int multicast_address_set = 0;
7449 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7451 if (unformat (input, "del"))
7455 (input, "address %U", unformat_ip6_address, &multicast_address))
7456 multicast_address_set = 1;
7457 else if (unformat (input, "sr-policy %s", &policy_name))
7463 if (!is_del && !policy_name)
7465 errmsg ("sr-policy name required\n");
7470 if (!multicast_address_set)
7472 errmsg ("address required\n");
7476 M (SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del);
7478 mp->is_add = !is_del;
7479 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
7480 clib_memcpy (mp->multicast_address, &multicast_address,
7481 sizeof (mp->multicast_address));
7484 vec_free (policy_name);
7492 #define foreach_ip4_proto_field \
7503 unformat_ip4_mask (unformat_input_t * input, va_list * args)
7505 u8 **maskp = va_arg (*args, u8 **);
7507 u8 found_something = 0;
7510 #define _(a) u8 a=0;
7511 foreach_ip4_proto_field;
7517 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7519 if (unformat (input, "version"))
7521 else if (unformat (input, "hdr_length"))
7523 else if (unformat (input, "src"))
7525 else if (unformat (input, "dst"))
7527 else if (unformat (input, "proto"))
7530 #define _(a) else if (unformat (input, #a)) a=1;
7531 foreach_ip4_proto_field
7537 #define _(a) found_something += a;
7538 foreach_ip4_proto_field;
7541 if (found_something == 0)
7544 vec_validate (mask, sizeof (*ip) - 1);
7546 ip = (ip4_header_t *) mask;
7548 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
7549 foreach_ip4_proto_field;
7552 ip->ip_version_and_header_length = 0;
7555 ip->ip_version_and_header_length |= 0xF0;
7558 ip->ip_version_and_header_length |= 0x0F;
7564 #define foreach_ip6_proto_field \
7572 unformat_ip6_mask (unformat_input_t * input, va_list * args)
7574 u8 **maskp = va_arg (*args, u8 **);
7576 u8 found_something = 0;
7578 u32 ip_version_traffic_class_and_flow_label;
7580 #define _(a) u8 a=0;
7581 foreach_ip6_proto_field;
7584 u8 traffic_class = 0;
7587 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7589 if (unformat (input, "version"))
7591 else if (unformat (input, "traffic-class"))
7593 else if (unformat (input, "flow-label"))
7595 else if (unformat (input, "src"))
7597 else if (unformat (input, "dst"))
7599 else if (unformat (input, "proto"))
7602 #define _(a) else if (unformat (input, #a)) a=1;
7603 foreach_ip6_proto_field
7609 #define _(a) found_something += a;
7610 foreach_ip6_proto_field;
7613 if (found_something == 0)
7616 vec_validate (mask, sizeof (*ip) - 1);
7618 ip = (ip6_header_t *) mask;
7620 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
7621 foreach_ip6_proto_field;
7624 ip_version_traffic_class_and_flow_label = 0;
7627 ip_version_traffic_class_and_flow_label |= 0xF0000000;
7630 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
7633 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
7635 ip->ip_version_traffic_class_and_flow_label =
7636 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
7643 unformat_l3_mask (unformat_input_t * input, va_list * args)
7645 u8 **maskp = va_arg (*args, u8 **);
7647 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7649 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
7651 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
7660 unformat_l2_mask (unformat_input_t * input, va_list * args)
7662 u8 **maskp = va_arg (*args, u8 **);
7677 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7679 if (unformat (input, "src"))
7681 else if (unformat (input, "dst"))
7683 else if (unformat (input, "proto"))
7685 else if (unformat (input, "tag1"))
7687 else if (unformat (input, "tag2"))
7689 else if (unformat (input, "ignore-tag1"))
7691 else if (unformat (input, "ignore-tag2"))
7693 else if (unformat (input, "cos1"))
7695 else if (unformat (input, "cos2"))
7697 else if (unformat (input, "dot1q"))
7699 else if (unformat (input, "dot1ad"))
7704 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
7705 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
7708 if (tag1 || ignore_tag1 || cos1 || dot1q)
7710 if (tag2 || ignore_tag2 || cos2 || dot1ad)
7713 vec_validate (mask, len - 1);
7716 memset (mask, 0xff, 6);
7719 memset (mask + 6, 0xff, 6);
7723 /* inner vlan tag */
7732 mask[21] = mask[20] = 0xff;
7753 mask[16] = mask[17] = 0xff;
7763 mask[12] = mask[13] = 0xff;
7770 unformat_classify_mask (unformat_input_t * input, va_list * args)
7772 u8 **maskp = va_arg (*args, u8 **);
7773 u32 *skipp = va_arg (*args, u32 *);
7774 u32 *matchp = va_arg (*args, u32 *);
7781 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7783 if (unformat (input, "hex %U", unformat_hex_string, &mask))
7785 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
7787 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
7793 if (mask || l2 || l3)
7797 /* "With a free Ethernet header in every package" */
7799 vec_validate (l2, 13);
7803 vec_append (mask, l3);
7808 /* Scan forward looking for the first significant mask octet */
7809 for (i = 0; i < vec_len (mask); i++)
7813 /* compute (skip, match) params */
7814 *skipp = i / sizeof (u32x4);
7815 vec_delete (mask, *skipp * sizeof (u32x4), 0);
7817 /* Pad mask to an even multiple of the vector size */
7818 while (vec_len (mask) % sizeof (u32x4))
7821 match = vec_len (mask) / sizeof (u32x4);
7823 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
7825 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
7826 if (*tmp || *(tmp + 1))
7831 clib_warning ("BUG: match 0");
7833 _vec_len (mask) = match * sizeof (u32x4);
7844 #define foreach_l2_next \
7846 _(ethernet, ETHERNET_INPUT) \
7851 unformat_l2_next_index (unformat_input_t * input, va_list * args)
7853 u32 *miss_next_indexp = va_arg (*args, u32 *);
7858 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
7862 if (unformat (input, "%d", &tmp))
7871 *miss_next_indexp = next_index;
7875 #define foreach_ip_next \
7882 unformat_ip_next_index (unformat_input_t * input, va_list * args)
7884 u32 *miss_next_indexp = va_arg (*args, u32 *);
7889 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
7893 if (unformat (input, "%d", &tmp))
7902 *miss_next_indexp = next_index;
7906 #define foreach_acl_next \
7910 unformat_acl_next_index (unformat_input_t * input, va_list * args)
7912 u32 *miss_next_indexp = va_arg (*args, u32 *);
7917 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
7921 if (unformat (input, "permit"))
7926 else if (unformat (input, "%d", &tmp))
7935 *miss_next_indexp = next_index;
7940 unformat_policer_precolor (unformat_input_t * input, va_list * args)
7942 u32 *r = va_arg (*args, u32 *);
7944 if (unformat (input, "conform-color"))
7945 *r = POLICE_CONFORM;
7946 else if (unformat (input, "exceed-color"))
7955 api_classify_add_del_table (vat_main_t * vam)
7957 unformat_input_t *i = vam->input;
7958 vl_api_classify_add_del_table_t *mp;
7964 u32 table_index = ~0;
7965 u32 next_table_index = ~0;
7966 u32 miss_next_index = ~0;
7967 u32 memory_size = 32 << 20;
7971 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7973 if (unformat (i, "del"))
7975 else if (unformat (i, "buckets %d", &nbuckets))
7977 else if (unformat (i, "memory_size %d", &memory_size))
7979 else if (unformat (i, "skip %d", &skip))
7981 else if (unformat (i, "match %d", &match))
7983 else if (unformat (i, "table %d", &table_index))
7985 else if (unformat (i, "mask %U", unformat_classify_mask,
7986 &mask, &skip, &match))
7988 else if (unformat (i, "next-table %d", &next_table_index))
7990 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
7993 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
7996 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
8003 if (is_add && mask == 0)
8005 errmsg ("Mask required\n");
8009 if (is_add && skip == ~0)
8011 errmsg ("skip count required\n");
8015 if (is_add && match == ~0)
8017 errmsg ("match count required\n");
8021 if (!is_add && table_index == ~0)
8023 errmsg ("table index required for delete\n");
8027 M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask));
8029 mp->is_add = is_add;
8030 mp->table_index = ntohl (table_index);
8031 mp->nbuckets = ntohl (nbuckets);
8032 mp->memory_size = ntohl (memory_size);
8033 mp->skip_n_vectors = ntohl (skip);
8034 mp->match_n_vectors = ntohl (match);
8035 mp->next_table_index = ntohl (next_table_index);
8036 mp->miss_next_index = ntohl (miss_next_index);
8037 clib_memcpy (mp->mask, mask, vec_len (mask));
8047 unformat_ip4_match (unformat_input_t * input, va_list * args)
8049 u8 **matchp = va_arg (*args, u8 **);
8056 int src = 0, dst = 0;
8057 ip4_address_t src_val, dst_val;
8064 int fragment_id = 0;
8065 u32 fragment_id_val;
8071 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8073 if (unformat (input, "version %d", &version_val))
8075 else if (unformat (input, "hdr_length %d", &hdr_length_val))
8077 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
8079 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
8081 else if (unformat (input, "proto %d", &proto_val))
8083 else if (unformat (input, "tos %d", &tos_val))
8085 else if (unformat (input, "length %d", &length_val))
8087 else if (unformat (input, "fragment_id %d", &fragment_id_val))
8089 else if (unformat (input, "ttl %d", &ttl_val))
8091 else if (unformat (input, "checksum %d", &checksum_val))
8097 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
8098 + ttl + checksum == 0)
8102 * Aligned because we use the real comparison functions
8104 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
8106 ip = (ip4_header_t *) match;
8108 /* These are realistically matched in practice */
8110 ip->src_address.as_u32 = src_val.as_u32;
8113 ip->dst_address.as_u32 = dst_val.as_u32;
8116 ip->protocol = proto_val;
8119 /* These are not, but they're included for completeness */
8121 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
8124 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
8130 ip->length = length_val;
8136 ip->checksum = checksum_val;
8143 unformat_ip6_match (unformat_input_t * input, va_list * args)
8145 u8 **matchp = va_arg (*args, u8 **);
8150 u8 traffic_class = 0;
8151 u32 traffic_class_val = 0;
8154 int src = 0, dst = 0;
8155 ip6_address_t src_val, dst_val;
8158 int payload_length = 0;
8159 u32 payload_length_val;
8162 u32 ip_version_traffic_class_and_flow_label;
8164 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8166 if (unformat (input, "version %d", &version_val))
8168 else if (unformat (input, "traffic_class %d", &traffic_class_val))
8170 else if (unformat (input, "flow_label %d", &flow_label_val))
8172 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
8174 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
8176 else if (unformat (input, "proto %d", &proto_val))
8178 else if (unformat (input, "payload_length %d", &payload_length_val))
8180 else if (unformat (input, "hop_limit %d", &hop_limit_val))
8186 if (version + traffic_class + flow_label + src + dst + proto +
8187 payload_length + hop_limit == 0)
8191 * Aligned because we use the real comparison functions
8193 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
8195 ip = (ip6_header_t *) match;
8198 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
8201 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
8204 ip->protocol = proto_val;
8206 ip_version_traffic_class_and_flow_label = 0;
8209 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
8212 ip_version_traffic_class_and_flow_label |=
8213 (traffic_class_val & 0xFF) << 20;
8216 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
8218 ip->ip_version_traffic_class_and_flow_label =
8219 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8222 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
8225 ip->hop_limit = hop_limit_val;
8232 unformat_l3_match (unformat_input_t * input, va_list * args)
8234 u8 **matchp = va_arg (*args, u8 **);
8236 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8238 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
8240 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
8249 unformat_vlan_tag (unformat_input_t * input, va_list * args)
8251 u8 *tagp = va_arg (*args, u8 *);
8254 if (unformat (input, "%d", &tag))
8256 tagp[0] = (tag >> 8) & 0x0F;
8257 tagp[1] = tag & 0xFF;
8265 unformat_l2_match (unformat_input_t * input, va_list * args)
8267 u8 **matchp = va_arg (*args, u8 **);
8287 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8289 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
8292 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
8294 else if (unformat (input, "proto %U",
8295 unformat_ethernet_type_host_byte_order, &proto_val))
8297 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
8299 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
8301 else if (unformat (input, "ignore-tag1"))
8303 else if (unformat (input, "ignore-tag2"))
8305 else if (unformat (input, "cos1 %d", &cos1_val))
8307 else if (unformat (input, "cos2 %d", &cos2_val))
8312 if ((src + dst + proto + tag1 + tag2 +
8313 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8316 if (tag1 || ignore_tag1 || cos1)
8318 if (tag2 || ignore_tag2 || cos2)
8321 vec_validate_aligned (match, len - 1, sizeof (u32x4));
8324 clib_memcpy (match, dst_val, 6);
8327 clib_memcpy (match + 6, src_val, 6);
8331 /* inner vlan tag */
8332 match[19] = tag2_val[1];
8333 match[18] = tag2_val[0];
8335 match[18] |= (cos2_val & 0x7) << 5;
8338 match[21] = proto_val & 0xff;
8339 match[20] = proto_val >> 8;
8343 match[15] = tag1_val[1];
8344 match[14] = tag1_val[0];
8347 match[14] |= (cos1_val & 0x7) << 5;
8353 match[15] = tag1_val[1];
8354 match[14] = tag1_val[0];
8357 match[17] = proto_val & 0xff;
8358 match[16] = proto_val >> 8;
8361 match[14] |= (cos1_val & 0x7) << 5;
8367 match[18] |= (cos2_val & 0x7) << 5;
8369 match[14] |= (cos1_val & 0x7) << 5;
8372 match[13] = proto_val & 0xff;
8373 match[12] = proto_val >> 8;
8382 unformat_classify_match (unformat_input_t * input, va_list * args)
8384 u8 **matchp = va_arg (*args, u8 **);
8385 u32 skip_n_vectors = va_arg (*args, u32);
8386 u32 match_n_vectors = va_arg (*args, u32);
8392 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8394 if (unformat (input, "hex %U", unformat_hex_string, &match))
8396 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
8398 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
8404 if (match || l2 || l3)
8408 /* "Win a free Ethernet header in every packet" */
8410 vec_validate_aligned (l2, 13, sizeof (u32x4));
8414 vec_append_aligned (match, l3, sizeof (u32x4));
8419 /* Make sure the vector is big enough even if key is all 0's */
8420 vec_validate_aligned
8421 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
8424 /* Set size, include skipped vectors */
8425 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
8436 api_classify_add_del_session (vat_main_t * vam)
8438 unformat_input_t *i = vam->input;
8439 vl_api_classify_add_del_session_t *mp;
8441 u32 table_index = ~0;
8442 u32 hit_next_index = ~0;
8443 u32 opaque_index = ~0;
8447 u32 skip_n_vectors = 0;
8448 u32 match_n_vectors = 0;
8451 * Warning: you have to supply skip_n and match_n
8452 * because the API client cant simply look at the classify
8456 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8458 if (unformat (i, "del"))
8460 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
8463 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
8466 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
8469 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
8471 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
8473 else if (unformat (i, "opaque-index %d", &opaque_index))
8475 else if (unformat (i, "skip_n %d", &skip_n_vectors))
8477 else if (unformat (i, "match_n %d", &match_n_vectors))
8479 else if (unformat (i, "match %U", unformat_classify_match,
8480 &match, skip_n_vectors, match_n_vectors))
8482 else if (unformat (i, "advance %d", &advance))
8484 else if (unformat (i, "table-index %d", &table_index))
8490 if (table_index == ~0)
8492 errmsg ("Table index required\n");
8496 if (is_add && match == 0)
8498 errmsg ("Match value required\n");
8502 M2 (CLASSIFY_ADD_DEL_SESSION, classify_add_del_session, vec_len (match));
8504 mp->is_add = is_add;
8505 mp->table_index = ntohl (table_index);
8506 mp->hit_next_index = ntohl (hit_next_index);
8507 mp->opaque_index = ntohl (opaque_index);
8508 mp->advance = ntohl (advance);
8509 clib_memcpy (mp->match, match, vec_len (match));
8518 api_classify_set_interface_ip_table (vat_main_t * vam)
8520 unformat_input_t *i = vam->input;
8521 vl_api_classify_set_interface_ip_table_t *mp;
8524 int sw_if_index_set;
8525 u32 table_index = ~0;
8528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8530 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8531 sw_if_index_set = 1;
8532 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8533 sw_if_index_set = 1;
8534 else if (unformat (i, "table %d", &table_index))
8538 clib_warning ("parse error '%U'", format_unformat_error, i);
8543 if (sw_if_index_set == 0)
8545 errmsg ("missing interface name or sw_if_index\n");
8550 M (CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table);
8552 mp->sw_if_index = ntohl (sw_if_index);
8553 mp->table_index = ntohl (table_index);
8554 mp->is_ipv6 = is_ipv6;
8563 api_classify_set_interface_l2_tables (vat_main_t * vam)
8565 unformat_input_t *i = vam->input;
8566 vl_api_classify_set_interface_l2_tables_t *mp;
8569 int sw_if_index_set;
8570 u32 ip4_table_index = ~0;
8571 u32 ip6_table_index = ~0;
8572 u32 other_table_index = ~0;
8575 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8577 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8578 sw_if_index_set = 1;
8579 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8580 sw_if_index_set = 1;
8581 else if (unformat (i, "ip4-table %d", &ip4_table_index))
8583 else if (unformat (i, "ip6-table %d", &ip6_table_index))
8585 else if (unformat (i, "other-table %d", &other_table_index))
8587 else if (unformat (i, "is-input %d", &is_input))
8591 clib_warning ("parse error '%U'", format_unformat_error, i);
8596 if (sw_if_index_set == 0)
8598 errmsg ("missing interface name or sw_if_index\n");
8603 M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables);
8605 mp->sw_if_index = ntohl (sw_if_index);
8606 mp->ip4_table_index = ntohl (ip4_table_index);
8607 mp->ip6_table_index = ntohl (ip6_table_index);
8608 mp->other_table_index = ntohl (other_table_index);
8609 mp->is_input = (u8) is_input;
8618 api_ipfix_enable (vat_main_t * vam)
8620 unformat_input_t *i = vam->input;
8621 vl_api_ipfix_enable_t *mp;
8622 ip4_address_t collector_address;
8623 u8 collector_address_set = 0;
8624 u32 collector_port = ~0;
8625 ip4_address_t src_address;
8626 u8 src_address_set = 0;
8629 u32 template_interval = ~0;
8632 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8634 if (unformat (i, "collector_address %U", unformat_ip4_address,
8635 &collector_address))
8636 collector_address_set = 1;
8637 else if (unformat (i, "collector_port %d", &collector_port))
8639 else if (unformat (i, "src_address %U", unformat_ip4_address,
8641 src_address_set = 1;
8642 else if (unformat (i, "vrf_id %d", &vrf_id))
8644 else if (unformat (i, "path_mtu %d", &path_mtu))
8646 else if (unformat (i, "template_interval %d", &template_interval))
8652 if (collector_address_set == 0)
8654 errmsg ("collector_address required\n");
8658 if (src_address_set == 0)
8660 errmsg ("src_address required\n");
8664 M (IPFIX_ENABLE, ipfix_enable);
8666 memcpy (mp->collector_address, collector_address.data,
8667 sizeof (collector_address.data));
8668 mp->collector_port = htons ((u16) collector_port);
8669 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
8670 mp->vrf_id = htonl (vrf_id);
8671 mp->path_mtu = htonl (path_mtu);
8672 mp->template_interval = htonl (template_interval);
8680 api_get_node_index (vat_main_t * vam)
8682 unformat_input_t *i = vam->input;
8683 vl_api_get_node_index_t *mp;
8687 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8689 if (unformat (i, "node %s", &name))
8696 errmsg ("node name required\n");
8699 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
8701 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
8705 M (GET_NODE_INDEX, get_node_index);
8706 clib_memcpy (mp->node_name, name, vec_len (name));
8716 api_get_next_index (vat_main_t * vam)
8718 unformat_input_t *i = vam->input;
8719 vl_api_get_next_index_t *mp;
8721 u8 *node_name = 0, *next_node_name = 0;
8723 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8725 if (unformat (i, "node-name %s", &node_name))
8727 else if (unformat (i, "next-node-name %s", &next_node_name))
8733 errmsg ("node name required\n");
8736 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
8738 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
8742 if (next_node_name == 0)
8744 errmsg ("next node name required\n");
8747 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
8749 errmsg ("next node name too long, max %d\n", ARRAY_LEN (mp->next_name));
8753 M (GET_NEXT_INDEX, get_next_index);
8754 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
8755 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
8756 vec_free (node_name);
8757 vec_free (next_node_name);
8766 api_add_node_next (vat_main_t * vam)
8768 unformat_input_t *i = vam->input;
8769 vl_api_add_node_next_t *mp;
8774 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8776 if (unformat (i, "node %s", &name))
8778 else if (unformat (i, "next %s", &next))
8785 errmsg ("node name required\n");
8788 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
8790 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
8795 errmsg ("next node required\n");
8798 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
8800 errmsg ("next name too long, max %d\n", ARRAY_LEN (mp->next_name));
8804 M (ADD_NODE_NEXT, add_node_next);
8805 clib_memcpy (mp->node_name, name, vec_len (name));
8806 clib_memcpy (mp->next_name, next, vec_len (next));
8817 api_l2tpv3_create_tunnel (vat_main_t * vam)
8819 unformat_input_t *i = vam->input;
8820 ip6_address_t client_address, our_address;
8821 int client_address_set = 0;
8822 int our_address_set = 0;
8823 u32 local_session_id = 0;
8824 u32 remote_session_id = 0;
8825 u64 local_cookie = 0;
8826 u64 remote_cookie = 0;
8827 u8 l2_sublayer_present = 0;
8828 vl_api_l2tpv3_create_tunnel_t *mp;
8831 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8833 if (unformat (i, "client_address %U", unformat_ip6_address,
8835 client_address_set = 1;
8836 else if (unformat (i, "our_address %U", unformat_ip6_address,
8838 our_address_set = 1;
8839 else if (unformat (i, "local_session_id %d", &local_session_id))
8841 else if (unformat (i, "remote_session_id %d", &remote_session_id))
8843 else if (unformat (i, "local_cookie %lld", &local_cookie))
8845 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
8847 else if (unformat (i, "l2-sublayer-present"))
8848 l2_sublayer_present = 1;
8853 if (client_address_set == 0)
8855 errmsg ("client_address required\n");
8859 if (our_address_set == 0)
8861 errmsg ("our_address required\n");
8865 M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel);
8867 clib_memcpy (mp->client_address, client_address.as_u8,
8868 sizeof (mp->client_address));
8870 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
8872 mp->local_session_id = ntohl (local_session_id);
8873 mp->remote_session_id = ntohl (remote_session_id);
8874 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
8875 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
8876 mp->l2_sublayer_present = l2_sublayer_present;
8886 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
8888 unformat_input_t *i = vam->input;
8890 u8 sw_if_index_set = 0;
8891 u64 new_local_cookie = 0;
8892 u64 new_remote_cookie = 0;
8893 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
8896 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8898 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8899 sw_if_index_set = 1;
8900 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8901 sw_if_index_set = 1;
8902 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
8904 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
8910 if (sw_if_index_set == 0)
8912 errmsg ("missing interface name or sw_if_index\n");
8916 M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies);
8918 mp->sw_if_index = ntohl (sw_if_index);
8919 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
8920 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
8929 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
8931 unformat_input_t *i = vam->input;
8932 vl_api_l2tpv3_interface_enable_disable_t *mp;
8935 u8 sw_if_index_set = 0;
8936 u8 enable_disable = 1;
8938 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8940 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8941 sw_if_index_set = 1;
8942 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8943 sw_if_index_set = 1;
8944 else if (unformat (i, "enable"))
8946 else if (unformat (i, "disable"))
8952 if (sw_if_index_set == 0)
8954 errmsg ("missing interface name or sw_if_index\n");
8958 M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable);
8960 mp->sw_if_index = ntohl (sw_if_index);
8961 mp->enable_disable = enable_disable;
8970 api_l2tpv3_set_lookup_key (vat_main_t * vam)
8972 unformat_input_t *i = vam->input;
8973 vl_api_l2tpv3_set_lookup_key_t *mp;
8977 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8979 if (unformat (i, "lookup_v6_src"))
8980 key = L2T_LOOKUP_SRC_ADDRESS;
8981 else if (unformat (i, "lookup_v6_dst"))
8982 key = L2T_LOOKUP_DST_ADDRESS;
8983 else if (unformat (i, "lookup_session_id"))
8984 key = L2T_LOOKUP_SESSION_ID;
8989 if (key == (u8) ~ 0)
8991 errmsg ("l2tp session lookup key unset\n");
8995 M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key);
9005 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
9006 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
9008 vat_main_t *vam = &vat_main;
9010 fformat (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)\n",
9011 format_ip6_address, mp->our_address,
9012 format_ip6_address, mp->client_address,
9013 clib_net_to_host_u32 (mp->sw_if_index));
9016 " local cookies %016llx %016llx remote cookie %016llx\n",
9017 clib_net_to_host_u64 (mp->local_cookie[0]),
9018 clib_net_to_host_u64 (mp->local_cookie[1]),
9019 clib_net_to_host_u64 (mp->remote_cookie));
9021 fformat (vam->ofp, " local session-id %d remote session-id %d\n",
9022 clib_net_to_host_u32 (mp->local_session_id),
9023 clib_net_to_host_u32 (mp->remote_session_id));
9025 fformat (vam->ofp, " l2 specific sublayer %s\n\n",
9026 mp->l2_sublayer_present ? "preset" : "absent");
9030 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
9031 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
9033 vat_main_t *vam = &vat_main;
9034 vat_json_node_t *node = NULL;
9035 struct in6_addr addr;
9037 if (VAT_JSON_ARRAY != vam->json_tree.type)
9039 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9040 vat_json_init_array (&vam->json_tree);
9042 node = vat_json_array_add (&vam->json_tree);
9044 vat_json_init_object (node);
9046 clib_memcpy (&addr, mp->our_address, sizeof (addr));
9047 vat_json_object_add_ip6 (node, "our_address", addr);
9048 clib_memcpy (&addr, mp->client_address, sizeof (addr));
9049 vat_json_object_add_ip6 (node, "client_address", addr);
9051 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
9052 vat_json_init_array (lc);
9053 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
9054 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
9055 vat_json_object_add_uint (node, "remote_cookie",
9056 clib_net_to_host_u64 (mp->remote_cookie));
9058 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
9059 vat_json_object_add_uint (node, "local_session_id",
9060 clib_net_to_host_u32 (mp->local_session_id));
9061 vat_json_object_add_uint (node, "remote_session_id",
9062 clib_net_to_host_u32 (mp->remote_session_id));
9063 vat_json_object_add_string_copy (node, "l2_sublayer",
9064 mp->l2_sublayer_present ? (u8 *) "present"
9069 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
9071 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
9074 /* Get list of l2tpv3-tunnel interfaces */
9075 M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump);
9078 /* Use a control ping for synchronization */
9080 vl_api_control_ping_t *mp;
9081 M (CONTROL_PING, control_ping);
9088 static void vl_api_sw_interface_tap_details_t_handler
9089 (vl_api_sw_interface_tap_details_t * mp)
9091 vat_main_t *vam = &vat_main;
9093 fformat (vam->ofp, "%-16s %d\n",
9094 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
9097 static void vl_api_sw_interface_tap_details_t_handler_json
9098 (vl_api_sw_interface_tap_details_t * mp)
9100 vat_main_t *vam = &vat_main;
9101 vat_json_node_t *node = NULL;
9103 if (VAT_JSON_ARRAY != vam->json_tree.type)
9105 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9106 vat_json_init_array (&vam->json_tree);
9108 node = vat_json_array_add (&vam->json_tree);
9110 vat_json_init_object (node);
9111 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9112 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
9116 api_sw_interface_tap_dump (vat_main_t * vam)
9118 vl_api_sw_interface_tap_dump_t *mp;
9121 fformat (vam->ofp, "\n%-16s %s\n", "dev_name", "sw_if_index");
9122 /* Get list of tap interfaces */
9123 M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump);
9126 /* Use a control ping for synchronization */
9128 vl_api_control_ping_t *mp;
9129 M (CONTROL_PING, control_ping);
9135 static uword unformat_vxlan_decap_next
9136 (unformat_input_t * input, va_list * args)
9138 u32 *result = va_arg (*args, u32 *);
9141 if (unformat (input, "drop"))
9142 *result = VXLAN_INPUT_NEXT_DROP;
9143 else if (unformat (input, "ip4"))
9144 *result = VXLAN_INPUT_NEXT_IP4_INPUT;
9145 else if (unformat (input, "ip6"))
9146 *result = VXLAN_INPUT_NEXT_IP6_INPUT;
9147 else if (unformat (input, "l2"))
9148 *result = VXLAN_INPUT_NEXT_L2_INPUT;
9149 else if (unformat (input, "%d", &tmp))
9157 api_vxlan_add_del_tunnel (vat_main_t * vam)
9159 unformat_input_t *line_input = vam->input;
9160 vl_api_vxlan_add_del_tunnel_t *mp;
9162 ip4_address_t src4, dst4;
9163 ip6_address_t src6, dst6;
9165 u8 ipv4_set = 0, ipv6_set = 0;
9168 u32 encap_vrf_id = 0;
9169 u32 decap_next_index = ~0;
9172 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9174 if (unformat (line_input, "del"))
9176 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
9181 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
9186 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
9191 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
9196 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
9198 else if (unformat (line_input, "decap-next %U",
9199 unformat_vxlan_decap_next, &decap_next_index))
9201 else if (unformat (line_input, "vni %d", &vni))
9205 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
9212 errmsg ("tunnel src address not specified\n");
9217 errmsg ("tunnel dst address not specified\n");
9221 if (ipv4_set && ipv6_set)
9223 errmsg ("both IPv4 and IPv6 addresses specified");
9227 if ((vni == 0) || (vni >> 24))
9229 errmsg ("vni not specified or out of range\n");
9233 M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel);
9237 clib_memcpy (&mp->src_address, &src6, sizeof (src6));
9238 clib_memcpy (&mp->dst_address, &dst6, sizeof (dst6));
9242 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
9243 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
9245 mp->encap_vrf_id = ntohl (encap_vrf_id);
9246 mp->decap_next_index = ntohl (decap_next_index);
9247 mp->vni = ntohl (vni);
9248 mp->is_add = is_add;
9249 mp->is_ipv6 = ipv6_set;
9257 static void vl_api_vxlan_tunnel_details_t_handler
9258 (vl_api_vxlan_tunnel_details_t * mp)
9260 vat_main_t *vam = &vat_main;
9262 fformat (vam->ofp, "%11d%24U%24U%14d%18d%13d\n",
9263 ntohl (mp->sw_if_index),
9264 format_ip46_address, &(mp->src_address[0]),
9266 format_ip46_address, &(mp->dst_address[0]),
9268 ntohl (mp->encap_vrf_id),
9269 ntohl (mp->decap_next_index), ntohl (mp->vni));
9272 static void vl_api_vxlan_tunnel_details_t_handler_json
9273 (vl_api_vxlan_tunnel_details_t * mp)
9275 vat_main_t *vam = &vat_main;
9276 vat_json_node_t *node = NULL;
9278 struct in6_addr ip6;
9280 if (VAT_JSON_ARRAY != vam->json_tree.type)
9282 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9283 vat_json_init_array (&vam->json_tree);
9285 node = vat_json_array_add (&vam->json_tree);
9287 vat_json_init_object (node);
9288 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9291 clib_memcpy (&ip6, &(mp->src_address[0]), sizeof (ip6));
9292 vat_json_object_add_ip6 (node, "src_address", ip6);
9293 clib_memcpy (&ip6, &(mp->dst_address[0]), sizeof (ip6));
9294 vat_json_object_add_ip6 (node, "dst_address", ip6);
9298 clib_memcpy (&ip4, &(mp->src_address[0]), sizeof (ip4));
9299 vat_json_object_add_ip4 (node, "src_address", ip4);
9300 clib_memcpy (&ip4, &(mp->dst_address[0]), sizeof (ip4));
9301 vat_json_object_add_ip4 (node, "dst_address", ip4);
9303 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
9304 vat_json_object_add_uint (node, "decap_next_index",
9305 ntohl (mp->decap_next_index));
9306 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
9307 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
9311 api_vxlan_tunnel_dump (vat_main_t * vam)
9313 unformat_input_t *i = vam->input;
9314 vl_api_vxlan_tunnel_dump_t *mp;
9317 u8 sw_if_index_set = 0;
9319 /* Parse args required to build the message */
9320 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9322 if (unformat (i, "sw_if_index %d", &sw_if_index))
9323 sw_if_index_set = 1;
9328 if (sw_if_index_set == 0)
9333 if (!vam->json_output)
9335 fformat (vam->ofp, "%11s%24s%24s%14s%18s%13s\n",
9336 "sw_if_index", "src_address", "dst_address",
9337 "encap_vrf_id", "decap_next_index", "vni");
9340 /* Get list of vxlan-tunnel interfaces */
9341 M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
9343 mp->sw_if_index = htonl (sw_if_index);
9347 /* Use a control ping for synchronization */
9349 vl_api_control_ping_t *mp;
9350 M (CONTROL_PING, control_ping);
9357 api_gre_add_del_tunnel (vat_main_t * vam)
9359 unformat_input_t *line_input = vam->input;
9360 vl_api_gre_add_del_tunnel_t *mp;
9362 ip4_address_t src4, dst4;
9366 u32 outer_fib_id = 0;
9368 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9370 if (unformat (line_input, "del"))
9372 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
9374 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
9376 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
9380 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
9387 errmsg ("tunnel src address not specified\n");
9392 errmsg ("tunnel dst address not specified\n");
9397 M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel);
9399 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
9400 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
9401 mp->outer_fib_id = ntohl (outer_fib_id);
9402 mp->is_add = is_add;
9410 static void vl_api_gre_tunnel_details_t_handler
9411 (vl_api_gre_tunnel_details_t * mp)
9413 vat_main_t *vam = &vat_main;
9415 fformat (vam->ofp, "%11d%15U%15U%14d\n",
9416 ntohl (mp->sw_if_index),
9417 format_ip4_address, &mp->src_address,
9418 format_ip4_address, &mp->dst_address, ntohl (mp->outer_fib_id));
9421 static void vl_api_gre_tunnel_details_t_handler_json
9422 (vl_api_gre_tunnel_details_t * mp)
9424 vat_main_t *vam = &vat_main;
9425 vat_json_node_t *node = NULL;
9428 if (VAT_JSON_ARRAY != vam->json_tree.type)
9430 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9431 vat_json_init_array (&vam->json_tree);
9433 node = vat_json_array_add (&vam->json_tree);
9435 vat_json_init_object (node);
9436 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9437 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
9438 vat_json_object_add_ip4 (node, "src_address", ip4);
9439 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
9440 vat_json_object_add_ip4 (node, "dst_address", ip4);
9441 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
9445 api_gre_tunnel_dump (vat_main_t * vam)
9447 unformat_input_t *i = vam->input;
9448 vl_api_gre_tunnel_dump_t *mp;
9451 u8 sw_if_index_set = 0;
9453 /* Parse args required to build the message */
9454 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9456 if (unformat (i, "sw_if_index %d", &sw_if_index))
9457 sw_if_index_set = 1;
9462 if (sw_if_index_set == 0)
9467 if (!vam->json_output)
9469 fformat (vam->ofp, "%11s%15s%15s%14s\n",
9470 "sw_if_index", "src_address", "dst_address", "outer_fib_id");
9473 /* Get list of gre-tunnel interfaces */
9474 M (GRE_TUNNEL_DUMP, gre_tunnel_dump);
9476 mp->sw_if_index = htonl (sw_if_index);
9480 /* Use a control ping for synchronization */
9482 vl_api_control_ping_t *mp;
9483 M (CONTROL_PING, control_ping);
9490 api_l2_fib_clear_table (vat_main_t * vam)
9492 // unformat_input_t * i = vam->input;
9493 vl_api_l2_fib_clear_table_t *mp;
9496 M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table);
9505 api_l2_interface_efp_filter (vat_main_t * vam)
9507 unformat_input_t *i = vam->input;
9508 vl_api_l2_interface_efp_filter_t *mp;
9512 u8 sw_if_index_set = 0;
9514 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9516 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9517 sw_if_index_set = 1;
9518 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9519 sw_if_index_set = 1;
9520 else if (unformat (i, "enable"))
9522 else if (unformat (i, "disable"))
9526 clib_warning ("parse error '%U'", format_unformat_error, i);
9531 if (sw_if_index_set == 0)
9533 errmsg ("missing sw_if_index\n");
9537 M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter);
9539 mp->sw_if_index = ntohl (sw_if_index);
9540 mp->enable_disable = enable;
9548 #define foreach_vtr_op \
9549 _("disable", L2_VTR_DISABLED) \
9550 _("push-1", L2_VTR_PUSH_1) \
9551 _("push-2", L2_VTR_PUSH_2) \
9552 _("pop-1", L2_VTR_POP_1) \
9553 _("pop-2", L2_VTR_POP_2) \
9554 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
9555 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
9556 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
9557 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
9560 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
9562 unformat_input_t *i = vam->input;
9563 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
9566 u8 sw_if_index_set = 0;
9573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9575 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9576 sw_if_index_set = 1;
9577 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9578 sw_if_index_set = 1;
9579 else if (unformat (i, "vtr_op %d", &vtr_op))
9581 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
9584 else if (unformat (i, "push_dot1q %d", &push_dot1q))
9586 else if (unformat (i, "tag1 %d", &tag1))
9588 else if (unformat (i, "tag2 %d", &tag2))
9592 clib_warning ("parse error '%U'", format_unformat_error, i);
9597 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
9599 errmsg ("missing vtr operation or sw_if_index\n");
9603 M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)
9604 mp->sw_if_index = ntohl (sw_if_index);
9605 mp->vtr_op = ntohl (vtr_op);
9606 mp->push_dot1q = ntohl (push_dot1q);
9607 mp->tag1 = ntohl (tag1);
9608 mp->tag2 = ntohl (tag2);
9617 api_create_vhost_user_if (vat_main_t * vam)
9619 unformat_input_t *i = vam->input;
9620 vl_api_create_vhost_user_if_t *mp;
9624 u8 file_name_set = 0;
9625 u32 custom_dev_instance = ~0;
9627 u8 use_custom_mac = 0;
9629 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9631 if (unformat (i, "socket %s", &file_name))
9635 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
9637 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
9639 else if (unformat (i, "server"))
9645 if (file_name_set == 0)
9647 errmsg ("missing socket file name\n");
9651 if (vec_len (file_name) > 255)
9653 errmsg ("socket file name too long\n");
9656 vec_add1 (file_name, 0);
9658 M (CREATE_VHOST_USER_IF, create_vhost_user_if);
9660 mp->is_server = is_server;
9661 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
9662 vec_free (file_name);
9663 if (custom_dev_instance != ~0)
9666 mp->custom_dev_instance = ntohl (custom_dev_instance);
9668 mp->use_custom_mac = use_custom_mac;
9669 clib_memcpy (mp->mac_address, hwaddr, 6);
9678 api_modify_vhost_user_if (vat_main_t * vam)
9680 unformat_input_t *i = vam->input;
9681 vl_api_modify_vhost_user_if_t *mp;
9685 u8 file_name_set = 0;
9686 u32 custom_dev_instance = ~0;
9687 u8 sw_if_index_set = 0;
9688 u32 sw_if_index = (u32) ~ 0;
9690 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9692 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9693 sw_if_index_set = 1;
9694 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9695 sw_if_index_set = 1;
9696 else if (unformat (i, "socket %s", &file_name))
9700 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
9702 else if (unformat (i, "server"))
9708 if (sw_if_index_set == 0)
9710 errmsg ("missing sw_if_index or interface name\n");
9714 if (file_name_set == 0)
9716 errmsg ("missing socket file name\n");
9720 if (vec_len (file_name) > 255)
9722 errmsg ("socket file name too long\n");
9725 vec_add1 (file_name, 0);
9727 M (MODIFY_VHOST_USER_IF, modify_vhost_user_if);
9729 mp->sw_if_index = ntohl (sw_if_index);
9730 mp->is_server = is_server;
9731 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
9732 vec_free (file_name);
9733 if (custom_dev_instance != ~0)
9736 mp->custom_dev_instance = ntohl (custom_dev_instance);
9746 api_delete_vhost_user_if (vat_main_t * vam)
9748 unformat_input_t *i = vam->input;
9749 vl_api_delete_vhost_user_if_t *mp;
9751 u32 sw_if_index = ~0;
9752 u8 sw_if_index_set = 0;
9754 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9756 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9757 sw_if_index_set = 1;
9758 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9759 sw_if_index_set = 1;
9764 if (sw_if_index_set == 0)
9766 errmsg ("missing sw_if_index or interface name\n");
9771 M (DELETE_VHOST_USER_IF, delete_vhost_user_if);
9773 mp->sw_if_index = ntohl (sw_if_index);
9781 static void vl_api_sw_interface_vhost_user_details_t_handler
9782 (vl_api_sw_interface_vhost_user_details_t * mp)
9784 vat_main_t *vam = &vat_main;
9786 fformat (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s\n",
9787 (char *) mp->interface_name,
9788 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
9789 clib_net_to_host_u64 (mp->features), mp->is_server,
9790 ntohl (mp->num_regions), (char *) mp->sock_filename);
9791 fformat (vam->ofp, " Status: '%s'\n", strerror (ntohl (mp->sock_errno)));
9794 static void vl_api_sw_interface_vhost_user_details_t_handler_json
9795 (vl_api_sw_interface_vhost_user_details_t * mp)
9797 vat_main_t *vam = &vat_main;
9798 vat_json_node_t *node = NULL;
9800 if (VAT_JSON_ARRAY != vam->json_tree.type)
9802 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9803 vat_json_init_array (&vam->json_tree);
9805 node = vat_json_array_add (&vam->json_tree);
9807 vat_json_init_object (node);
9808 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9809 vat_json_object_add_string_copy (node, "interface_name",
9810 mp->interface_name);
9811 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
9812 ntohl (mp->virtio_net_hdr_sz));
9813 vat_json_object_add_uint (node, "features",
9814 clib_net_to_host_u64 (mp->features));
9815 vat_json_object_add_uint (node, "is_server", mp->is_server);
9816 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
9817 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
9818 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
9822 api_sw_interface_vhost_user_dump (vat_main_t * vam)
9824 vl_api_sw_interface_vhost_user_dump_t *mp;
9827 "Interface name idx hdr_sz features server regions filename\n");
9829 /* Get list of vhost-user interfaces */
9830 M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump);
9833 /* Use a control ping for synchronization */
9835 vl_api_control_ping_t *mp;
9836 M (CONTROL_PING, control_ping);
9843 api_show_version (vat_main_t * vam)
9845 vl_api_show_version_t *mp;
9848 M (SHOW_VERSION, show_version);
9858 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
9860 unformat_input_t *line_input = vam->input;
9861 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
9863 ip4_address_t local4, remote4;
9864 ip6_address_t local6, remote6;
9866 u8 ipv4_set = 0, ipv6_set = 0;
9869 u32 encap_vrf_id = 0;
9870 u32 decap_vrf_id = 0;
9875 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9877 if (unformat (line_input, "del"))
9879 else if (unformat (line_input, "local %U",
9880 unformat_ip4_address, &local4))
9885 else if (unformat (line_input, "remote %U",
9886 unformat_ip4_address, &remote4))
9891 else if (unformat (line_input, "local %U",
9892 unformat_ip6_address, &local6))
9897 else if (unformat (line_input, "remote %U",
9898 unformat_ip6_address, &remote6))
9903 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
9905 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
9907 else if (unformat (line_input, "vni %d", &vni))
9909 else if (unformat (line_input, "next-ip4"))
9911 else if (unformat (line_input, "next-ip6"))
9913 else if (unformat (line_input, "next-ethernet"))
9915 else if (unformat (line_input, "next-nsh"))
9919 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
9926 errmsg ("tunnel local address not specified\n");
9929 if (remote_set == 0)
9931 errmsg ("tunnel remote address not specified\n");
9934 if (ipv4_set && ipv6_set)
9936 errmsg ("both IPv4 and IPv6 addresses specified");
9942 errmsg ("vni not specified\n");
9946 M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel);
9951 clib_memcpy (&mp->local, &local6, sizeof (local6));
9952 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
9956 clib_memcpy (&mp->local, &local4, sizeof (local4));
9957 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
9960 mp->encap_vrf_id = ntohl (encap_vrf_id);
9961 mp->decap_vrf_id = ntohl (decap_vrf_id);
9962 mp->protocol = ntohl (protocol);
9963 mp->vni = ntohl (vni);
9964 mp->is_add = is_add;
9965 mp->is_ipv6 = ipv6_set;
9973 static void vl_api_vxlan_gpe_tunnel_details_t_handler
9974 (vl_api_vxlan_gpe_tunnel_details_t * mp)
9976 vat_main_t *vam = &vat_main;
9978 fformat (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d\n",
9979 ntohl (mp->sw_if_index),
9980 format_ip46_address, &(mp->local[0]),
9981 format_ip46_address, &(mp->remote[0]),
9983 ntohl (mp->protocol),
9984 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
9987 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
9988 (vl_api_vxlan_gpe_tunnel_details_t * mp)
9990 vat_main_t *vam = &vat_main;
9991 vat_json_node_t *node = NULL;
9993 struct in6_addr ip6;
9995 if (VAT_JSON_ARRAY != vam->json_tree.type)
9997 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9998 vat_json_init_array (&vam->json_tree);
10000 node = vat_json_array_add (&vam->json_tree);
10002 vat_json_init_object (node);
10003 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10006 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
10007 vat_json_object_add_ip6 (node, "local", ip6);
10008 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
10009 vat_json_object_add_ip6 (node, "remote", ip6);
10013 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
10014 vat_json_object_add_ip4 (node, "local", ip4);
10015 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
10016 vat_json_object_add_ip4 (node, "remote", ip4);
10018 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10019 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
10020 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10021 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
10022 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10026 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
10028 unformat_input_t *i = vam->input;
10029 vl_api_vxlan_gpe_tunnel_dump_t *mp;
10032 u8 sw_if_index_set = 0;
10034 /* Parse args required to build the message */
10035 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10037 if (unformat (i, "sw_if_index %d", &sw_if_index))
10038 sw_if_index_set = 1;
10043 if (sw_if_index_set == 0)
10048 if (!vam->json_output)
10050 fformat (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s\n",
10051 "sw_if_index", "local", "remote", "vni",
10052 "protocol", "encap_vrf_id", "decap_vrf_id");
10055 /* Get list of vxlan-tunnel interfaces */
10056 M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump);
10058 mp->sw_if_index = htonl (sw_if_index);
10062 /* Use a control ping for synchronization */
10064 vl_api_control_ping_t *mp;
10065 M (CONTROL_PING, control_ping);
10072 format_l2_fib_mac_address (u8 * s, va_list * args)
10074 u8 *a = va_arg (*args, u8 *);
10076 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
10077 a[2], a[3], a[4], a[5], a[6], a[7]);
10080 static void vl_api_l2_fib_table_entry_t_handler
10081 (vl_api_l2_fib_table_entry_t * mp)
10083 vat_main_t *vam = &vat_main;
10085 fformat (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
10087 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
10088 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
10092 static void vl_api_l2_fib_table_entry_t_handler_json
10093 (vl_api_l2_fib_table_entry_t * mp)
10095 vat_main_t *vam = &vat_main;
10096 vat_json_node_t *node = NULL;
10098 if (VAT_JSON_ARRAY != vam->json_tree.type)
10100 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10101 vat_json_init_array (&vam->json_tree);
10103 node = vat_json_array_add (&vam->json_tree);
10105 vat_json_init_object (node);
10106 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
10107 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
10108 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10109 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
10110 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
10111 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
10115 api_l2_fib_table_dump (vat_main_t * vam)
10117 unformat_input_t *i = vam->input;
10118 vl_api_l2_fib_table_dump_t *mp;
10123 /* Parse args required to build the message */
10124 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10126 if (unformat (i, "bd_id %d", &bd_id))
10132 if (bd_id_set == 0)
10134 errmsg ("missing bridge domain\n");
10139 "BD-ID Mac Address sw-ndx Static Filter BVI\n");
10141 /* Get list of l2 fib entries */
10142 M (L2_FIB_TABLE_DUMP, l2_fib_table_dump);
10144 mp->bd_id = ntohl (bd_id);
10147 /* Use a control ping for synchronization */
10149 vl_api_control_ping_t *mp;
10150 M (CONTROL_PING, control_ping);
10158 api_interface_name_renumber (vat_main_t * vam)
10160 unformat_input_t *line_input = vam->input;
10161 vl_api_interface_name_renumber_t *mp;
10162 u32 sw_if_index = ~0;
10164 u32 new_show_dev_instance = ~0;
10166 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10168 if (unformat (line_input, "%U", unformat_sw_if_index, vam,
10171 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
10173 else if (unformat (line_input, "new_show_dev_instance %d",
10174 &new_show_dev_instance))
10180 if (sw_if_index == ~0)
10182 errmsg ("missing interface name or sw_if_index\n");
10186 if (new_show_dev_instance == ~0)
10188 errmsg ("missing new_show_dev_instance\n");
10192 M (INTERFACE_NAME_RENUMBER, interface_name_renumber);
10194 mp->sw_if_index = ntohl (sw_if_index);
10195 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
10202 api_want_ip4_arp_events (vat_main_t * vam)
10204 unformat_input_t *line_input = vam->input;
10205 vl_api_want_ip4_arp_events_t *mp;
10207 ip4_address_t address;
10208 int address_set = 0;
10209 u32 enable_disable = 1;
10211 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10213 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
10215 else if (unformat (line_input, "del"))
10216 enable_disable = 0;
10221 if (address_set == 0)
10223 errmsg ("missing addresses\n");
10227 M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events);
10228 mp->enable_disable = enable_disable;
10229 mp->pid = getpid ();
10230 mp->address = address.as_u32;
10237 api_want_ip6_nd_events (vat_main_t * vam)
10239 unformat_input_t *line_input = vam->input;
10240 vl_api_want_ip6_nd_events_t *mp;
10242 ip6_address_t address;
10243 int address_set = 0;
10244 u32 enable_disable = 1;
10246 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10248 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
10250 else if (unformat (line_input, "del"))
10251 enable_disable = 0;
10256 if (address_set == 0)
10258 errmsg ("missing addresses\n");
10262 M (WANT_IP6_ND_EVENTS, want_ip6_nd_events);
10263 mp->enable_disable = enable_disable;
10264 mp->pid = getpid ();
10265 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
10272 api_input_acl_set_interface (vat_main_t * vam)
10274 unformat_input_t *i = vam->input;
10275 vl_api_input_acl_set_interface_t *mp;
10278 int sw_if_index_set;
10279 u32 ip4_table_index = ~0;
10280 u32 ip6_table_index = ~0;
10281 u32 l2_table_index = ~0;
10284 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10286 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10287 sw_if_index_set = 1;
10288 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10289 sw_if_index_set = 1;
10290 else if (unformat (i, "del"))
10292 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10294 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10296 else if (unformat (i, "l2-table %d", &l2_table_index))
10300 clib_warning ("parse error '%U'", format_unformat_error, i);
10305 if (sw_if_index_set == 0)
10307 errmsg ("missing interface name or sw_if_index\n");
10311 M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface);
10313 mp->sw_if_index = ntohl (sw_if_index);
10314 mp->ip4_table_index = ntohl (ip4_table_index);
10315 mp->ip6_table_index = ntohl (ip6_table_index);
10316 mp->l2_table_index = ntohl (l2_table_index);
10317 mp->is_add = is_add;
10326 api_ip_address_dump (vat_main_t * vam)
10328 unformat_input_t *i = vam->input;
10329 vl_api_ip_address_dump_t *mp;
10330 u32 sw_if_index = ~0;
10331 u8 sw_if_index_set = 0;
10336 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10338 if (unformat (i, "sw_if_index %d", &sw_if_index))
10339 sw_if_index_set = 1;
10340 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10341 sw_if_index_set = 1;
10342 else if (unformat (i, "ipv4"))
10344 else if (unformat (i, "ipv6"))
10350 if (ipv4_set && ipv6_set)
10352 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
10356 if ((!ipv4_set) && (!ipv6_set))
10358 errmsg ("no ipv4 nor ipv6 flag set\n");
10362 if (sw_if_index_set == 0)
10364 errmsg ("missing interface name or sw_if_index\n");
10368 vam->current_sw_if_index = sw_if_index;
10369 vam->is_ipv6 = ipv6_set;
10371 M (IP_ADDRESS_DUMP, ip_address_dump);
10372 mp->sw_if_index = ntohl (sw_if_index);
10373 mp->is_ipv6 = ipv6_set;
10376 /* Use a control ping for synchronization */
10378 vl_api_control_ping_t *mp;
10379 M (CONTROL_PING, control_ping);
10386 api_ip_dump (vat_main_t * vam)
10388 vl_api_ip_dump_t *mp;
10389 unformat_input_t *in = vam->input;
10396 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
10398 if (unformat (in, "ipv4"))
10400 else if (unformat (in, "ipv6"))
10406 if (ipv4_set && ipv6_set)
10408 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
10412 if ((!ipv4_set) && (!ipv6_set))
10414 errmsg ("no ipv4 nor ipv6 flag set\n");
10418 is_ipv6 = ipv6_set;
10419 vam->is_ipv6 = is_ipv6;
10421 /* free old data */
10422 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
10424 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
10426 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
10428 M (IP_DUMP, ip_dump);
10429 mp->is_ipv6 = ipv6_set;
10432 /* Use a control ping for synchronization */
10434 vl_api_control_ping_t *mp;
10435 M (CONTROL_PING, control_ping);
10442 api_ipsec_spd_add_del (vat_main_t * vam)
10445 unformat_input_t *i = vam->input;
10446 vl_api_ipsec_spd_add_del_t *mp;
10451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10453 if (unformat (i, "spd_id %d", &spd_id))
10455 else if (unformat (i, "del"))
10459 clib_warning ("parse error '%U'", format_unformat_error, i);
10465 errmsg ("spd_id must be set\n");
10469 M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del);
10471 mp->spd_id = ntohl (spd_id);
10472 mp->is_add = is_add;
10479 clib_warning ("unsupported (no dpdk)");
10485 api_ipsec_interface_add_del_spd (vat_main_t * vam)
10488 unformat_input_t *i = vam->input;
10489 vl_api_ipsec_interface_add_del_spd_t *mp;
10492 u8 sw_if_index_set = 0;
10493 u32 spd_id = (u32) ~ 0;
10496 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10498 if (unformat (i, "del"))
10500 else if (unformat (i, "spd_id %d", &spd_id))
10502 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10503 sw_if_index_set = 1;
10504 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10505 sw_if_index_set = 1;
10508 clib_warning ("parse error '%U'", format_unformat_error, i);
10514 if (spd_id == (u32) ~ 0)
10516 errmsg ("spd_id must be set\n");
10520 if (sw_if_index_set == 0)
10522 errmsg ("missing interface name or sw_if_index\n");
10526 M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd);
10528 mp->spd_id = ntohl (spd_id);
10529 mp->sw_if_index = ntohl (sw_if_index);
10530 mp->is_add = is_add;
10537 clib_warning ("unsupported (no dpdk)");
10543 api_ipsec_spd_add_del_entry (vat_main_t * vam)
10546 unformat_input_t *i = vam->input;
10547 vl_api_ipsec_spd_add_del_entry_t *mp;
10549 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
10550 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
10552 u32 rport_start = 0, rport_stop = (u32) ~ 0;
10553 u32 lport_start = 0, lport_stop = (u32) ~ 0;
10554 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
10555 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
10557 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
10558 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
10559 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
10560 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
10561 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
10562 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
10564 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10566 if (unformat (i, "del"))
10568 if (unformat (i, "outbound"))
10570 if (unformat (i, "inbound"))
10572 else if (unformat (i, "spd_id %d", &spd_id))
10574 else if (unformat (i, "sa_id %d", &sa_id))
10576 else if (unformat (i, "priority %d", &priority))
10578 else if (unformat (i, "protocol %d", &protocol))
10580 else if (unformat (i, "lport_start %d", &lport_start))
10582 else if (unformat (i, "lport_stop %d", &lport_stop))
10584 else if (unformat (i, "rport_start %d", &rport_start))
10586 else if (unformat (i, "rport_stop %d", &rport_stop))
10590 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
10596 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
10603 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
10609 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
10616 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
10622 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
10629 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
10635 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
10641 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
10643 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
10645 clib_warning ("unsupported action: 'resolve'");
10651 clib_warning ("parse error '%U'", format_unformat_error, i);
10657 M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry);
10659 mp->spd_id = ntohl (spd_id);
10660 mp->priority = ntohl (priority);
10661 mp->is_outbound = is_outbound;
10663 mp->is_ipv6 = is_ipv6;
10664 if (is_ipv6 || is_ip_any)
10666 clib_memcpy (mp->remote_address_start, &raddr6_start,
10667 sizeof (ip6_address_t));
10668 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
10669 sizeof (ip6_address_t));
10670 clib_memcpy (mp->local_address_start, &laddr6_start,
10671 sizeof (ip6_address_t));
10672 clib_memcpy (mp->local_address_stop, &laddr6_stop,
10673 sizeof (ip6_address_t));
10677 clib_memcpy (mp->remote_address_start, &raddr4_start,
10678 sizeof (ip4_address_t));
10679 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
10680 sizeof (ip4_address_t));
10681 clib_memcpy (mp->local_address_start, &laddr4_start,
10682 sizeof (ip4_address_t));
10683 clib_memcpy (mp->local_address_stop, &laddr4_stop,
10684 sizeof (ip4_address_t));
10686 mp->protocol = (u8) protocol;
10687 mp->local_port_start = ntohs ((u16) lport_start);
10688 mp->local_port_stop = ntohs ((u16) lport_stop);
10689 mp->remote_port_start = ntohs ((u16) rport_start);
10690 mp->remote_port_stop = ntohs ((u16) rport_stop);
10691 mp->policy = (u8) policy;
10692 mp->sa_id = ntohl (sa_id);
10693 mp->is_add = is_add;
10694 mp->is_ip_any = is_ip_any;
10700 clib_warning ("unsupported (no dpdk)");
10706 api_ipsec_sad_add_del_entry (vat_main_t * vam)
10709 unformat_input_t *i = vam->input;
10710 vl_api_ipsec_sad_add_del_entry_t *mp;
10712 u32 sad_id = 0, spi = 0;
10713 u8 *ck = 0, *ik = 0;
10716 u8 protocol = IPSEC_PROTOCOL_AH;
10717 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
10718 u32 crypto_alg = 0, integ_alg = 0;
10719 ip4_address_t tun_src4;
10720 ip4_address_t tun_dst4;
10721 ip6_address_t tun_src6;
10722 ip6_address_t tun_dst6;
10724 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10726 if (unformat (i, "del"))
10728 else if (unformat (i, "sad_id %d", &sad_id))
10730 else if (unformat (i, "spi %d", &spi))
10732 else if (unformat (i, "esp"))
10733 protocol = IPSEC_PROTOCOL_ESP;
10734 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
10737 is_tunnel_ipv6 = 0;
10739 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
10742 is_tunnel_ipv6 = 0;
10744 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
10747 is_tunnel_ipv6 = 1;
10749 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
10752 is_tunnel_ipv6 = 1;
10756 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
10758 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
10759 crypto_alg > IPSEC_INTEG_ALG_SHA_512_256)
10761 clib_warning ("unsupported crypto-alg: '%U'",
10762 format_ipsec_crypto_alg, crypto_alg);
10766 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
10770 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
10772 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
10773 integ_alg > IPSEC_INTEG_ALG_SHA_512_256)
10775 clib_warning ("unsupported integ-alg: '%U'",
10776 format_ipsec_integ_alg, integ_alg);
10780 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
10784 clib_warning ("parse error '%U'", format_unformat_error, i);
10790 M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
10792 mp->sad_id = ntohl (sad_id);
10793 mp->is_add = is_add;
10794 mp->protocol = protocol;
10795 mp->spi = ntohl (spi);
10796 mp->is_tunnel = is_tunnel;
10797 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
10798 mp->crypto_algorithm = crypto_alg;
10799 mp->integrity_algorithm = integ_alg;
10800 mp->crypto_key_length = vec_len (ck);
10801 mp->integrity_key_length = vec_len (ik);
10803 if (mp->crypto_key_length > sizeof (mp->crypto_key))
10804 mp->crypto_key_length = sizeof (mp->crypto_key);
10806 if (mp->integrity_key_length > sizeof (mp->integrity_key))
10807 mp->integrity_key_length = sizeof (mp->integrity_key);
10810 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
10812 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
10816 if (is_tunnel_ipv6)
10818 clib_memcpy (mp->tunnel_src_address, &tun_src6,
10819 sizeof (ip6_address_t));
10820 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
10821 sizeof (ip6_address_t));
10825 clib_memcpy (mp->tunnel_src_address, &tun_src4,
10826 sizeof (ip4_address_t));
10827 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
10828 sizeof (ip4_address_t));
10837 clib_warning ("unsupported (no dpdk)");
10843 api_ipsec_sa_set_key (vat_main_t * vam)
10846 unformat_input_t *i = vam->input;
10847 vl_api_ipsec_sa_set_key_t *mp;
10850 u8 *ck = 0, *ik = 0;
10852 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10854 if (unformat (i, "sa_id %d", &sa_id))
10856 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
10858 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
10862 clib_warning ("parse error '%U'", format_unformat_error, i);
10867 M (IPSEC_SA_SET_KEY, ipsec_set_sa_key);
10869 mp->sa_id = ntohl (sa_id);
10870 mp->crypto_key_length = vec_len (ck);
10871 mp->integrity_key_length = vec_len (ik);
10873 if (mp->crypto_key_length > sizeof (mp->crypto_key))
10874 mp->crypto_key_length = sizeof (mp->crypto_key);
10876 if (mp->integrity_key_length > sizeof (mp->integrity_key))
10877 mp->integrity_key_length = sizeof (mp->integrity_key);
10880 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
10882 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
10889 clib_warning ("unsupported (no dpdk)");
10895 api_ikev2_profile_add_del (vat_main_t * vam)
10898 unformat_input_t *i = vam->input;
10899 vl_api_ikev2_profile_add_del_t *mp;
10904 const char *valid_chars = "a-zA-Z0-9_";
10906 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10908 if (unformat (i, "del"))
10910 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
10911 vec_add1 (name, 0);
10914 errmsg ("parse error '%U'", format_unformat_error, i);
10919 if (!vec_len (name))
10921 errmsg ("profile name must be specified");
10925 if (vec_len (name) > 64)
10927 errmsg ("profile name too long");
10931 M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del);
10933 clib_memcpy (mp->name, name, vec_len (name));
10934 mp->is_add = is_add;
10942 clib_warning ("unsupported (no dpdk)");
10948 api_ikev2_profile_set_auth (vat_main_t * vam)
10951 unformat_input_t *i = vam->input;
10952 vl_api_ikev2_profile_set_auth_t *mp;
10956 u32 auth_method = 0;
10959 const char *valid_chars = "a-zA-Z0-9_";
10961 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10963 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
10964 vec_add1 (name, 0);
10965 else if (unformat (i, "auth_method %U",
10966 unformat_ikev2_auth_method, &auth_method))
10968 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
10970 else if (unformat (i, "auth_data %v", &data))
10974 errmsg ("parse error '%U'", format_unformat_error, i);
10979 if (!vec_len (name))
10981 errmsg ("profile name must be specified");
10985 if (vec_len (name) > 64)
10987 errmsg ("profile name too long");
10991 if (!vec_len (data))
10993 errmsg ("auth_data must be specified");
10999 errmsg ("auth_method must be specified");
11003 M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth);
11005 mp->is_hex = is_hex;
11006 mp->auth_method = (u8) auth_method;
11007 mp->data_len = vec_len (data);
11008 clib_memcpy (mp->name, name, vec_len (name));
11009 clib_memcpy (mp->data, data, vec_len (data));
11018 clib_warning ("unsupported (no dpdk)");
11024 api_ikev2_profile_set_id (vat_main_t * vam)
11027 unformat_input_t *i = vam->input;
11028 vl_api_ikev2_profile_set_id_t *mp;
11036 const char *valid_chars = "a-zA-Z0-9_";
11038 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11040 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11041 vec_add1 (name, 0);
11042 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
11044 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
11046 data = vec_new (u8, 4);
11047 clib_memcpy (data, ip4.as_u8, 4);
11049 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
11051 else if (unformat (i, "id_data %v", &data))
11053 else if (unformat (i, "local"))
11055 else if (unformat (i, "remote"))
11059 errmsg ("parse error '%U'", format_unformat_error, i);
11064 if (!vec_len (name))
11066 errmsg ("profile name must be specified");
11070 if (vec_len (name) > 64)
11072 errmsg ("profile name too long");
11076 if (!vec_len (data))
11078 errmsg ("id_data must be specified");
11084 errmsg ("id_type must be specified");
11088 M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id);
11090 mp->is_local = is_local;
11091 mp->id_type = (u8) id_type;
11092 mp->data_len = vec_len (data);
11093 clib_memcpy (mp->name, name, vec_len (name));
11094 clib_memcpy (mp->data, data, vec_len (data));
11103 clib_warning ("unsupported (no dpdk)");
11109 api_ikev2_profile_set_ts (vat_main_t * vam)
11112 unformat_input_t *i = vam->input;
11113 vl_api_ikev2_profile_set_ts_t *mp;
11117 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
11118 ip4_address_t start_addr, end_addr;
11120 const char *valid_chars = "a-zA-Z0-9_";
11122 start_addr.as_u32 = 0;
11123 end_addr.as_u32 = (u32) ~ 0;
11125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11127 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11128 vec_add1 (name, 0);
11129 else if (unformat (i, "protocol %d", &proto))
11131 else if (unformat (i, "start_port %d", &start_port))
11133 else if (unformat (i, "end_port %d", &end_port))
11136 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
11138 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
11140 else if (unformat (i, "local"))
11142 else if (unformat (i, "remote"))
11146 errmsg ("parse error '%U'", format_unformat_error, i);
11151 if (!vec_len (name))
11153 errmsg ("profile name must be specified");
11157 if (vec_len (name) > 64)
11159 errmsg ("profile name too long");
11163 M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts);
11165 mp->is_local = is_local;
11166 mp->proto = (u8) proto;
11167 mp->start_port = (u16) start_port;
11168 mp->end_port = (u16) end_port;
11169 mp->start_addr = start_addr.as_u32;
11170 mp->end_addr = end_addr.as_u32;
11171 clib_memcpy (mp->name, name, vec_len (name));
11179 clib_warning ("unsupported (no dpdk)");
11185 api_ikev2_set_local_key (vat_main_t * vam)
11188 unformat_input_t *i = vam->input;
11189 vl_api_ikev2_set_local_key_t *mp;
11193 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11195 if (unformat (i, "file %v", &file))
11196 vec_add1 (file, 0);
11199 errmsg ("parse error '%U'", format_unformat_error, i);
11204 if (!vec_len (file))
11206 errmsg ("RSA key file must be specified");
11210 if (vec_len (file) > 256)
11212 errmsg ("file name too long");
11216 M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key);
11218 clib_memcpy (mp->key_file, file, vec_len (file));
11226 clib_warning ("unsupported (no dpdk)");
11235 api_map_add_domain (vat_main_t * vam)
11237 unformat_input_t *i = vam->input;
11238 vl_api_map_add_domain_t *mp;
11241 ip4_address_t ip4_prefix;
11242 ip6_address_t ip6_prefix;
11243 ip6_address_t ip6_src;
11244 u32 num_m_args = 0;
11245 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
11246 0, psid_length = 0;
11247 u8 is_translation = 0;
11249 u32 ip6_src_len = 128;
11251 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11253 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
11254 &ip4_prefix, &ip4_prefix_len))
11256 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
11257 &ip6_prefix, &ip6_prefix_len))
11261 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
11264 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
11266 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
11268 else if (unformat (i, "psid-offset %d", &psid_offset))
11270 else if (unformat (i, "psid-len %d", &psid_length))
11272 else if (unformat (i, "mtu %d", &mtu))
11274 else if (unformat (i, "map-t"))
11275 is_translation = 1;
11278 clib_warning ("parse error '%U'", format_unformat_error, i);
11283 if (num_m_args < 3)
11285 errmsg ("mandatory argument(s) missing\n");
11289 /* Construct the API message */
11290 M (MAP_ADD_DOMAIN, map_add_domain);
11292 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
11293 mp->ip4_prefix_len = ip4_prefix_len;
11295 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
11296 mp->ip6_prefix_len = ip6_prefix_len;
11298 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
11299 mp->ip6_src_prefix_len = ip6_src_len;
11301 mp->ea_bits_len = ea_bits_len;
11302 mp->psid_offset = psid_offset;
11303 mp->psid_length = psid_length;
11304 mp->is_translation = is_translation;
11305 mp->mtu = htons (mtu);
11310 /* Wait for a reply, return good/bad news */
11315 api_map_del_domain (vat_main_t * vam)
11317 unformat_input_t *i = vam->input;
11318 vl_api_map_del_domain_t *mp;
11321 u32 num_m_args = 0;
11324 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11326 if (unformat (i, "index %d", &index))
11330 clib_warning ("parse error '%U'", format_unformat_error, i);
11335 if (num_m_args != 1)
11337 errmsg ("mandatory argument(s) missing\n");
11341 /* Construct the API message */
11342 M (MAP_DEL_DOMAIN, map_del_domain);
11344 mp->index = ntohl (index);
11349 /* Wait for a reply, return good/bad news */
11354 api_map_add_del_rule (vat_main_t * vam)
11356 unformat_input_t *i = vam->input;
11357 vl_api_map_add_del_rule_t *mp;
11360 ip6_address_t ip6_dst;
11361 u32 num_m_args = 0, index, psid = 0;
11363 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11365 if (unformat (i, "index %d", &index))
11367 else if (unformat (i, "psid %d", &psid))
11369 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
11371 else if (unformat (i, "del"))
11377 clib_warning ("parse error '%U'", format_unformat_error, i);
11382 /* Construct the API message */
11383 M (MAP_ADD_DEL_RULE, map_add_del_rule);
11385 mp->index = ntohl (index);
11386 mp->is_add = is_add;
11387 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
11388 mp->psid = ntohs (psid);
11393 /* Wait for a reply, return good/bad news */
11398 api_map_domain_dump (vat_main_t * vam)
11400 vl_api_map_domain_dump_t *mp;
11403 /* Construct the API message */
11404 M (MAP_DOMAIN_DUMP, map_domain_dump);
11409 /* Use a control ping for synchronization */
11411 vl_api_control_ping_t *mp;
11412 M (CONTROL_PING, control_ping);
11419 api_map_rule_dump (vat_main_t * vam)
11421 unformat_input_t *i = vam->input;
11422 vl_api_map_rule_dump_t *mp;
11424 u32 domain_index = ~0;
11426 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11428 if (unformat (i, "index %u", &domain_index))
11434 if (domain_index == ~0)
11436 clib_warning ("parse error: domain index expected");
11440 /* Construct the API message */
11441 M (MAP_RULE_DUMP, map_rule_dump);
11443 mp->domain_index = htonl (domain_index);
11448 /* Use a control ping for synchronization */
11450 vl_api_control_ping_t *mp;
11451 M (CONTROL_PING, control_ping);
11457 static void vl_api_map_add_domain_reply_t_handler
11458 (vl_api_map_add_domain_reply_t * mp)
11460 vat_main_t *vam = &vat_main;
11461 i32 retval = ntohl (mp->retval);
11463 if (vam->async_mode)
11465 vam->async_errors += (retval < 0);
11469 vam->retval = retval;
11470 vam->result_ready = 1;
11474 static void vl_api_map_add_domain_reply_t_handler_json
11475 (vl_api_map_add_domain_reply_t * mp)
11477 vat_main_t *vam = &vat_main;
11478 vat_json_node_t node;
11480 vat_json_init_object (&node);
11481 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
11482 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
11484 vat_json_print (vam->ofp, &node);
11485 vat_json_free (&node);
11487 vam->retval = ntohl (mp->retval);
11488 vam->result_ready = 1;
11492 api_get_first_msg_id (vat_main_t * vam)
11494 vl_api_get_first_msg_id_t *mp;
11496 unformat_input_t *i = vam->input;
11500 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11502 if (unformat (i, "client %s", &name))
11510 errmsg ("missing client name\n");
11513 vec_add1 (name, 0);
11515 if (vec_len (name) > 63)
11517 errmsg ("client name too long\n");
11521 M (GET_FIRST_MSG_ID, get_first_msg_id);
11522 clib_memcpy (mp->name, name, vec_len (name));
11530 api_cop_interface_enable_disable (vat_main_t * vam)
11532 unformat_input_t *line_input = vam->input;
11533 vl_api_cop_interface_enable_disable_t *mp;
11535 u32 sw_if_index = ~0;
11536 u8 enable_disable = 1;
11538 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11540 if (unformat (line_input, "disable"))
11541 enable_disable = 0;
11542 if (unformat (line_input, "enable"))
11543 enable_disable = 1;
11544 else if (unformat (line_input, "%U", unformat_sw_if_index,
11545 vam, &sw_if_index))
11547 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11553 if (sw_if_index == ~0)
11555 errmsg ("missing interface name or sw_if_index\n");
11559 /* Construct the API message */
11560 M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable);
11561 mp->sw_if_index = ntohl (sw_if_index);
11562 mp->enable_disable = enable_disable;
11566 /* Wait for the reply */
11571 api_cop_whitelist_enable_disable (vat_main_t * vam)
11573 unformat_input_t *line_input = vam->input;
11574 vl_api_cop_whitelist_enable_disable_t *mp;
11576 u32 sw_if_index = ~0;
11577 u8 ip4 = 0, ip6 = 0, default_cop = 0;
11580 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11582 if (unformat (line_input, "ip4"))
11584 else if (unformat (line_input, "ip6"))
11586 else if (unformat (line_input, "default"))
11588 else if (unformat (line_input, "%U", unformat_sw_if_index,
11589 vam, &sw_if_index))
11591 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11593 else if (unformat (line_input, "fib-id %d", &fib_id))
11599 if (sw_if_index == ~0)
11601 errmsg ("missing interface name or sw_if_index\n");
11605 /* Construct the API message */
11606 M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable);
11607 mp->sw_if_index = ntohl (sw_if_index);
11608 mp->fib_id = ntohl (fib_id);
11611 mp->default_cop = default_cop;
11615 /* Wait for the reply */
11620 api_get_node_graph (vat_main_t * vam)
11622 vl_api_get_node_graph_t *mp;
11625 M (GET_NODE_GRAPH, get_node_graph);
11629 /* Wait for the reply */
11634 /** Used for parsing LISP eids */
11635 typedef CLIB_PACKED(struct{
11636 u8 addr[16]; /**< eid address */
11637 u32 len; /**< prefix length if IP */
11638 u8 type; /**< type of eid */
11643 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
11645 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
11647 memset (a, 0, sizeof (a[0]));
11649 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
11651 a->type = 0; /* ipv4 type */
11653 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
11655 a->type = 1; /* ipv6 type */
11657 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
11659 a->type = 2; /* mac type */
11666 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
11675 lisp_eid_size_vat (u8 type)
11690 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
11692 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
11696 /** Used for transferring locators via VPP API */
11697 typedef CLIB_PACKED(struct
11699 u32 sw_if_index; /**< locator sw_if_index */
11700 u8 priority; /**< locator priority */
11701 u8 weight; /**< locator weight */
11706 api_lisp_add_del_locator_set (vat_main_t * vam)
11708 unformat_input_t *input = vam->input;
11709 vl_api_lisp_add_del_locator_set_t *mp;
11712 u8 *locator_set_name = NULL;
11713 u8 locator_set_name_set = 0;
11714 ls_locator_t locator, *locators = 0;
11715 u32 sw_if_index, priority, weight;
11717 /* Parse args required to build the message */
11718 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11720 if (unformat (input, "del"))
11724 else if (unformat (input, "locator-set %s", &locator_set_name))
11726 locator_set_name_set = 1;
11728 else if (unformat (input, "sw_if_index %u p %u w %u",
11729 &sw_if_index, &priority, &weight))
11731 locator.sw_if_index = htonl (sw_if_index);
11732 locator.priority = priority;
11733 locator.weight = weight;
11734 vec_add1 (locators, locator);
11736 else if (unformat (input, "iface %U p %u w %u", unformat_sw_if_index,
11737 vam, &sw_if_index, &priority, &weight))
11739 locator.sw_if_index = htonl (sw_if_index);
11740 locator.priority = priority;
11741 locator.weight = weight;
11742 vec_add1 (locators, locator);
11748 if (locator_set_name_set == 0)
11750 errmsg ("missing locator-set name");
11751 vec_free (locators);
11755 if (vec_len (locator_set_name) > 64)
11757 errmsg ("locator-set name too long\n");
11758 vec_free (locator_set_name);
11759 vec_free (locators);
11762 vec_add1 (locator_set_name, 0);
11764 /* Construct the API message */
11765 M (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set);
11767 mp->is_add = is_add;
11768 clib_memcpy (mp->locator_set_name, locator_set_name,
11769 vec_len (locator_set_name));
11770 vec_free (locator_set_name);
11772 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
11774 clib_memcpy (mp->locators, locators,
11775 (sizeof (ls_locator_t) * vec_len (locators)));
11776 vec_free (locators);
11781 /* Wait for a reply... */
11789 api_lisp_add_del_locator (vat_main_t * vam)
11791 unformat_input_t *input = vam->input;
11792 vl_api_lisp_add_del_locator_t *mp;
11794 u32 tmp_if_index = ~0;
11795 u32 sw_if_index = ~0;
11796 u8 sw_if_index_set = 0;
11797 u8 sw_if_index_if_name_set = 0;
11799 u8 priority_set = 0;
11803 u8 *locator_set_name = NULL;
11804 u8 locator_set_name_set = 0;
11806 /* Parse args required to build the message */
11807 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11809 if (unformat (input, "del"))
11813 else if (unformat (input, "locator-set %s", &locator_set_name))
11815 locator_set_name_set = 1;
11817 else if (unformat (input, "iface %U", unformat_sw_if_index, vam,
11820 sw_if_index_if_name_set = 1;
11821 sw_if_index = tmp_if_index;
11823 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
11825 sw_if_index_set = 1;
11826 sw_if_index = tmp_if_index;
11828 else if (unformat (input, "p %d", &priority))
11832 else if (unformat (input, "w %d", &weight))
11840 if (locator_set_name_set == 0)
11842 errmsg ("missing locator-set name");
11846 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
11848 errmsg ("missing sw_if_index");
11849 vec_free (locator_set_name);
11853 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
11855 errmsg ("cannot use both params interface name and sw_if_index");
11856 vec_free (locator_set_name);
11860 if (priority_set == 0)
11862 errmsg ("missing locator-set priority\n");
11863 vec_free (locator_set_name);
11867 if (weight_set == 0)
11869 errmsg ("missing locator-set weight\n");
11870 vec_free (locator_set_name);
11874 if (vec_len (locator_set_name) > 64)
11876 errmsg ("locator-set name too long\n");
11877 vec_free (locator_set_name);
11880 vec_add1 (locator_set_name, 0);
11882 /* Construct the API message */
11883 M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
11885 mp->is_add = is_add;
11886 mp->sw_if_index = ntohl (sw_if_index);
11887 mp->priority = priority;
11888 mp->weight = weight;
11889 clib_memcpy (mp->locator_set_name, locator_set_name,
11890 vec_len (locator_set_name));
11891 vec_free (locator_set_name);
11896 /* Wait for a reply... */
11904 api_lisp_add_del_local_eid (vat_main_t * vam)
11906 unformat_input_t *input = vam->input;
11907 vl_api_lisp_add_del_local_eid_t *mp;
11911 lisp_eid_vat_t _eid, *eid = &_eid;
11912 u8 *locator_set_name = 0;
11913 u8 locator_set_name_set = 0;
11916 /* Parse args required to build the message */
11917 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11919 if (unformat (input, "del"))
11923 else if (unformat (input, "vni %d", &vni))
11927 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
11931 else if (unformat (input, "locator-set %s", &locator_set_name))
11933 locator_set_name_set = 1;
11939 if (locator_set_name_set == 0)
11941 errmsg ("missing locator-set name\n");
11947 errmsg ("EID address not set!");
11948 vec_free (locator_set_name);
11952 if (vec_len (locator_set_name) > 64)
11954 errmsg ("locator-set name too long\n");
11955 vec_free (locator_set_name);
11958 vec_add1 (locator_set_name, 0);
11960 /* Construct the API message */
11961 M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
11963 mp->is_add = is_add;
11964 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
11965 mp->eid_type = eid->type;
11966 mp->prefix_len = eid->len;
11967 mp->vni = clib_host_to_net_u32 (vni);
11968 clib_memcpy (mp->locator_set_name, locator_set_name,
11969 vec_len (locator_set_name));
11971 vec_free (locator_set_name);
11976 /* Wait for a reply... */
11984 /** Used for transferring locators via VPP API */
11985 typedef CLIB_PACKED(struct
11987 u8 is_ip4; /**< is locator an IPv4 address? */
11988 u8 priority; /**< locator priority */
11989 u8 weight; /**< locator weight */
11990 u8 addr[16]; /**< IPv4/IPv6 address */
11995 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
11997 unformat_input_t *input = vam->input;
11998 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
12001 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
12002 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
12003 u8 rmt_eid_set = 0, lcl_eid_set = 0;
12004 u32 action = ~0, p, w;
12005 ip4_address_t rmt_rloc4, lcl_rloc4;
12006 ip6_address_t rmt_rloc6, lcl_rloc6;
12007 rloc_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
12009 memset (&rloc, 0, sizeof (rloc));
12011 /* Parse args required to build the message */
12012 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12014 if (unformat (input, "del"))
12018 else if (unformat (input, "rmt_eid %U", unformat_lisp_eid_vat, rmt_eid))
12022 else if (unformat (input, "lcl_eid %U", unformat_lisp_eid_vat, lcl_eid))
12026 else if (unformat (input, "p %d w %d", &p, &w))
12030 errmsg ("No RLOC configured for setting priority/weight!");
12033 curr_rloc->priority = p;
12034 curr_rloc->weight = w;
12036 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
12037 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
12041 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
12042 rloc.priority = rloc.weight = 0;
12043 vec_add1 (lcl_locs, rloc);
12045 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
12046 vec_add1 (rmt_locs, rloc);
12047 /* priority and weight saved in rmt loc */
12048 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
12050 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
12051 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
12054 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
12055 rloc.priority = rloc.weight = 0;
12056 vec_add1 (lcl_locs, rloc);
12058 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
12059 vec_add1 (rmt_locs, rloc);
12060 /* priority and weight saved in rmt loc */
12061 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
12063 else if (unformat (input, "action %d", &action))
12069 clib_warning ("parse error '%U'", format_unformat_error, input);
12076 errmsg ("remote eid addresses not set\n");
12080 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
12082 errmsg ("eid types don't match\n");
12086 if (0 == rmt_locs && (u32) ~ 0 == action)
12088 errmsg ("action not set for negative mapping\n");
12092 /* Construct the API message */
12093 M (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry);
12095 mp->is_add = is_add;
12096 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
12097 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
12098 mp->eid_type = rmt_eid->type;
12099 mp->rmt_len = rmt_eid->len;
12100 mp->lcl_len = lcl_eid->len;
12101 mp->action = action;
12103 if (0 != rmt_locs && 0 != lcl_locs)
12105 mp->loc_num = vec_len (rmt_locs);
12106 clib_memcpy (mp->lcl_locs, lcl_locs,
12107 (sizeof (rloc_t) * vec_len (lcl_locs)));
12108 clib_memcpy (mp->rmt_locs, rmt_locs,
12109 (sizeof (rloc_t) * vec_len (rmt_locs)));
12111 vec_free (lcl_locs);
12112 vec_free (rmt_locs);
12117 /* Wait for a reply... */
12125 api_lisp_add_del_map_resolver (vat_main_t * vam)
12127 unformat_input_t *input = vam->input;
12128 vl_api_lisp_add_del_map_resolver_t *mp;
12133 ip4_address_t ipv4;
12134 ip6_address_t ipv6;
12136 /* Parse args required to build the message */
12137 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12139 if (unformat (input, "del"))
12143 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
12147 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
12155 if (ipv4_set && ipv6_set)
12157 errmsg ("both eid v4 and v6 addresses set\n");
12161 if (!ipv4_set && !ipv6_set)
12163 errmsg ("eid addresses not set\n");
12167 /* Construct the API message */
12168 M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
12170 mp->is_add = is_add;
12174 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
12179 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
12185 /* Wait for a reply... */
12193 api_lisp_gpe_enable_disable (vat_main_t * vam)
12195 unformat_input_t *input = vam->input;
12196 vl_api_lisp_gpe_enable_disable_t *mp;
12201 /* Parse args required to build the message */
12202 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12204 if (unformat (input, "enable"))
12209 else if (unformat (input, "disable"))
12220 errmsg ("Value not set\n");
12224 /* Construct the API message */
12225 M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
12232 /* Wait for a reply... */
12240 api_lisp_enable_disable (vat_main_t * vam)
12242 unformat_input_t *input = vam->input;
12243 vl_api_lisp_enable_disable_t *mp;
12248 /* Parse args required to build the message */
12249 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12251 if (unformat (input, "enable"))
12256 else if (unformat (input, "disable"))
12266 errmsg ("Value not set\n");
12270 /* Construct the API message */
12271 M (LISP_ENABLE_DISABLE, lisp_enable_disable);
12278 /* Wait for a reply... */
12286 * Enable/disable LISP proxy ITR.
12288 * @param vam vpp API test context
12289 * @return return code
12292 api_lisp_pitr_set_locator_set (vat_main_t * vam)
12295 u8 ls_name_set = 0;
12296 unformat_input_t *input = vam->input;
12297 vl_api_lisp_pitr_set_locator_set_t *mp;
12301 /* Parse args required to build the message */
12302 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12304 if (unformat (input, "del"))
12306 else if (unformat (input, "locator-set %s", &ls_name))
12310 errmsg ("parse error '%U'", format_unformat_error, input);
12317 errmsg ("locator-set name not set!");
12321 M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set);
12323 mp->is_add = is_add;
12324 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
12325 vec_free (ls_name);
12330 /* wait for reply */
12338 api_show_lisp_pitr (vat_main_t * vam)
12340 vl_api_show_lisp_pitr_t *mp;
12343 if (!vam->json_output)
12345 fformat (vam->ofp, "%=20s\n", "lisp status:");
12348 M (SHOW_LISP_PITR, show_lisp_pitr);
12352 /* Wait for a reply... */
12360 * Add/delete mapping between vni and vrf
12363 api_lisp_eid_table_add_del_map (vat_main_t * vam)
12366 unformat_input_t *input = vam->input;
12367 vl_api_lisp_eid_table_add_del_map_t *mp;
12368 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
12369 u32 vni, vrf, bd_index;
12371 /* Parse args required to build the message */
12372 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12374 if (unformat (input, "del"))
12376 else if (unformat (input, "vrf %d", &vrf))
12378 else if (unformat (input, "bd_index %d", &bd_index))
12380 else if (unformat (input, "vni %d", &vni))
12386 if (!vni_set || (!vrf_set && !bd_index_set))
12388 errmsg ("missing arguments!");
12392 if (vrf_set && bd_index_set)
12394 errmsg ("error: both vrf and bd entered!");
12398 M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
12400 mp->is_add = is_add;
12401 mp->vni = htonl (vni);
12402 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
12403 mp->is_l2 = bd_index_set;
12408 /* wait for reply */
12416 * Add/del remote mapping to/from LISP control plane
12418 * @param vam vpp API test context
12419 * @return return code
12422 api_lisp_add_del_remote_mapping (vat_main_t * vam)
12424 unformat_input_t *input = vam->input;
12425 vl_api_lisp_add_del_remote_mapping_t *mp;
12428 //TODO: seid need remove
12429 lisp_eid_vat_t _eid, *eid = &_eid;
12430 lisp_eid_vat_t _seid, *seid = &_seid;
12431 u8 is_add = 1, del_all = 0, eid_set = 0;
12432 u32 action = ~0, p, w;
12433 ip4_address_t rloc4;
12434 ip6_address_t rloc6;
12435 rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
12437 memset (&rloc, 0, sizeof (rloc));
12439 /* Parse args required to build the message */
12440 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12442 if (unformat (input, "del-all"))
12446 else if (unformat (input, "del"))
12450 else if (unformat (input, "add"))
12454 else if (unformat (input, "deid %U", unformat_lisp_eid_vat, eid))
12458 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, &seid))
12460 //TODO: Need remove, but first must be remove from CSIT test
12462 else if (unformat (input, "vni %d", &vni))
12466 else if (unformat (input, "p %d w %d", &p, &w))
12470 errmsg ("No RLOC configured for setting priority/weight!");
12473 curr_rloc->priority = p;
12474 curr_rloc->weight = w;
12476 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
12479 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
12480 vec_add1 (rlocs, rloc);
12481 curr_rloc = &rlocs[vec_len (rlocs) - 1];
12483 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
12486 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
12487 vec_add1 (rlocs, rloc);
12488 curr_rloc = &rlocs[vec_len (rlocs) - 1];
12490 else if (unformat (input, "action %d", &action))
12496 clib_warning ("parse error '%U'", format_unformat_error, input);
12503 errmsg ("missing params!");
12507 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
12509 errmsg ("no action set for negative map-reply!");
12513 M (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping);
12514 mp->is_add = is_add;
12515 mp->vni = htonl (vni);
12516 mp->action = (u8) action;
12517 mp->eid_len = eid->len;
12518 mp->del_all = del_all;
12519 mp->eid_type = eid->type;
12520 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
12522 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
12523 clib_memcpy (mp->rlocs, rlocs, (sizeof (rloc_t) * vec_len (rlocs)));
12529 /* Wait for a reply... */
12537 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
12538 * forwarding entries in data-plane accordingly.
12540 * @param vam vpp API test context
12541 * @return return code
12544 api_lisp_add_del_adjacency (vat_main_t * vam)
12546 unformat_input_t *input = vam->input;
12547 vl_api_lisp_add_del_adjacency_t *mp;
12550 ip4_address_t seid4, deid4;
12551 ip6_address_t seid6, deid6;
12552 u8 deid_mac[6] = { 0 };
12553 u8 seid_mac[6] = { 0 };
12554 u8 deid_type, seid_type;
12555 u32 seid_len = 0, deid_len = 0, len;
12558 seid_type = deid_type = (u8) ~ 0;
12560 /* Parse args required to build the message */
12561 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12563 if (unformat (input, "del"))
12567 else if (unformat (input, "add"))
12571 else if (unformat (input, "deid %U/%d", unformat_ip4_address,
12574 deid_type = 0; /* ipv4 */
12577 else if (unformat (input, "deid %U/%d", unformat_ip6_address,
12580 deid_type = 1; /* ipv6 */
12583 else if (unformat (input, "deid %U", unformat_ethernet_address,
12586 deid_type = 2; /* mac */
12588 else if (unformat (input, "seid %U/%d", unformat_ip4_address,
12591 seid_type = 0; /* ipv4 */
12594 else if (unformat (input, "seid %U/%d", unformat_ip6_address,
12597 seid_type = 1; /* ipv6 */
12600 else if (unformat (input, "seid %U", unformat_ethernet_address,
12603 seid_type = 2; /* mac */
12605 else if (unformat (input, "vni %d", &vni))
12611 errmsg ("parse error '%U'", format_unformat_error, input);
12616 if ((u8) ~ 0 == deid_type)
12618 errmsg ("missing params!");
12622 if (seid_type != deid_type)
12624 errmsg ("source and destination EIDs are of different types!");
12628 M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency);
12629 mp->is_add = is_add;
12630 mp->vni = htonl (vni);
12631 mp->seid_len = seid_len;
12632 mp->deid_len = deid_len;
12633 mp->eid_type = deid_type;
12635 switch (mp->eid_type)
12638 clib_memcpy (mp->seid, &seid4, sizeof (seid4));
12639 clib_memcpy (mp->deid, &deid4, sizeof (deid4));
12642 clib_memcpy (mp->seid, &seid6, sizeof (seid6));
12643 clib_memcpy (mp->deid, &deid6, sizeof (deid6));
12646 clib_memcpy (mp->seid, seid_mac, 6);
12647 clib_memcpy (mp->deid, deid_mac, 6);
12650 errmsg ("unknown EID type %d!", mp->eid_type);
12657 /* Wait for a reply... */
12665 api_lisp_gpe_add_del_iface (vat_main_t * vam)
12667 unformat_input_t *input = vam->input;
12668 vl_api_lisp_gpe_add_del_iface_t *mp;
12670 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
12671 u32 dp_table = 0, vni = 0;
12673 /* Parse args required to build the message */
12674 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12676 if (unformat (input, "up"))
12681 else if (unformat (input, "down"))
12686 else if (unformat (input, "table_id %d", &dp_table))
12690 else if (unformat (input, "bd_id %d", &dp_table))
12695 else if (unformat (input, "vni %d", &vni))
12703 if (action_set == 0)
12705 errmsg ("Action not set\n");
12708 if (dp_table_set == 0 || vni_set == 0)
12710 errmsg ("vni and dp_table must be set\n");
12714 /* Construct the API message */
12715 M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
12717 mp->is_add = is_add;
12718 mp->dp_table = dp_table;
12725 /* Wait for a reply... */
12733 * Add/del map request itr rlocs from LISP control plane and updates
12735 * @param vam vpp API test context
12736 * @return return code
12739 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
12741 unformat_input_t *input = vam->input;
12742 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
12744 u8 *locator_set_name = 0;
12745 u8 locator_set_name_set = 0;
12748 /* Parse args required to build the message */
12749 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12751 if (unformat (input, "del"))
12755 else if (unformat (input, "%_%v%_", &locator_set_name))
12757 locator_set_name_set = 1;
12761 clib_warning ("parse error '%U'", format_unformat_error, input);
12766 if (is_add && !locator_set_name_set)
12768 errmsg ("itr-rloc is not set!");
12772 if (is_add && vec_len (locator_set_name) > 64)
12774 errmsg ("itr-rloc locator-set name too long\n");
12775 vec_free (locator_set_name);
12779 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs);
12780 mp->is_add = is_add;
12783 clib_memcpy (mp->locator_set_name, locator_set_name,
12784 vec_len (locator_set_name));
12788 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
12790 vec_free (locator_set_name);
12795 /* Wait for a reply... */
12803 lisp_locator_dump_send_msg (vat_main_t * vam, u32 locator_set_index,
12806 vl_api_lisp_locator_dump_t *mp;
12809 M (LISP_LOCATOR_DUMP, lisp_locator_dump);
12811 mp->locator_set_index = htonl (locator_set_index);
12812 mp->filter = filter;
12817 /* Use a control ping for synchronization */
12819 vl_api_noprint_control_ping_t *mp;
12820 M (NOPRINT_CONTROL_PING, noprint_control_ping);
12823 /* Wait for a reply... */
12828 clean_locator_set_message (vat_main_t * vam)
12830 locator_set_msg_t *ls = 0;
12832 vec_foreach (ls, vam->locator_set_msg)
12834 vec_free (ls->locator_set_name);
12837 vec_free (vam->locator_set_msg);
12841 print_locator_in_locator_set (vat_main_t * vam, u8 filter)
12843 locator_set_msg_t *ls;
12844 locator_msg_t *loc;
12846 int i = 0, ret = 0;
12848 vec_foreach (ls, vam->locator_set_msg)
12850 ret = lisp_locator_dump_send_msg (vam, ls->locator_set_index, filter);
12853 vec_free (vam->locator_msg);
12854 clean_locator_set_message (vam);
12858 tmp_str = format (0, "%=20s%=16d%s", ls->locator_set_name,
12859 ls->locator_set_index,
12860 vec_len (vam->locator_msg) ? "" : "\n");
12862 vec_foreach (loc, vam->locator_msg)
12866 tmp_str = format (tmp_str, "%=37s", " ");
12870 tmp_str = format (tmp_str, "%=16d%=16d%=16d\n",
12871 loc->sw_if_index, loc->priority, loc->weight);
12875 tmp_str = format (tmp_str, "%=16U%=16d%=16d\n",
12876 loc->is_ipv6 ? format_ip6_address :
12877 format_ip4_address,
12878 loc->ip_address, loc->priority, loc->weight);
12883 fformat (vam->ofp, "%s", tmp_str);
12884 vec_free (tmp_str);
12885 vec_free (vam->locator_msg);
12888 clean_locator_set_message (vam);
12894 json_locator_in_locator_set (vat_main_t * vam, u8 filter)
12896 locator_set_msg_t *ls;
12897 locator_msg_t *loc;
12898 vat_json_node_t *node = NULL;
12899 vat_json_node_t *locator_array;
12900 vat_json_node_t *locator;
12901 struct in6_addr ip6;
12902 struct in_addr ip4;
12905 if (!vec_len (vam->locator_set_msg))
12907 /* just print [] */
12908 vat_json_init_array (&vam->json_tree);
12909 vat_json_print (vam->ofp, &vam->json_tree);
12910 vam->json_tree.type = VAT_JSON_NONE;
12914 if (VAT_JSON_ARRAY != vam->json_tree.type)
12916 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12917 vat_json_init_array (&vam->json_tree);
12920 vec_foreach (ls, vam->locator_set_msg)
12922 ret = lisp_locator_dump_send_msg (vam, ls->locator_set_index, filter);
12925 vec_free (ls->locator_set_name);
12926 vec_free (vam->locator_msg);
12927 vec_free (vam->locator_set_msg);
12928 vat_json_free (&vam->json_tree);
12929 vam->json_tree.type = VAT_JSON_NONE;
12933 node = vat_json_array_add (&vam->json_tree);
12934 vat_json_init_object (node);
12936 vat_json_object_add_uint (node, "locator-set-index",
12937 ls->locator_set_index);
12938 vat_json_object_add_string_copy (node, "locator-set",
12939 ls->locator_set_name);
12940 locator_array = vat_json_object_add_list (node, "locator");
12941 vec_foreach (loc, vam->locator_msg)
12943 locator = vat_json_array_add (locator_array);
12944 vat_json_init_object (locator);
12947 vat_json_object_add_uint (locator, "locator-index",
12954 clib_memcpy (&ip6, loc->ip_address, sizeof (ip6));
12955 vat_json_object_add_ip6 (locator, "locator", ip6);
12959 clib_memcpy (&ip4, loc->ip_address, sizeof (ip4));
12960 vat_json_object_add_ip4 (locator, "locator", ip4);
12963 vat_json_object_add_uint (locator, "priority", loc->priority);
12964 vat_json_object_add_uint (locator, "weight", loc->weight);
12967 vec_free (ls->locator_set_name);
12968 vec_free (vam->locator_msg);
12971 vat_json_print (vam->ofp, &vam->json_tree);
12972 vat_json_free (&vam->json_tree);
12973 vam->json_tree.type = VAT_JSON_NONE;
12975 vec_free (vam->locator_set_msg);
12981 get_locator_set_index_from_msg (vat_main_t * vam, u8 * locator_set,
12982 u32 * locator_set_index)
12984 locator_set_msg_t *ls;
12987 *locator_set_index = ~0;
12989 if (!vec_len (vam->locator_set_msg))
12994 vec_foreach (ls, vam->locator_set_msg)
12996 if (!strcmp ((char *) locator_set, (char *) ls->locator_set_name))
12998 *locator_set_index = ls->locator_set_index;
12999 vec_free (vam->locator_set_msg);
13004 vec_free (vam->locator_set_msg);
13010 get_locator_set_index (vat_main_t * vam, u8 * locator_set,
13011 u32 * locator_set_index)
13013 vl_api_lisp_locator_set_dump_t *mp;
13016 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
13020 /* Use a control ping for synchronization */
13022 vl_api_noprint_control_ping_t *mp;
13023 M (NOPRINT_CONTROL_PING, noprint_control_ping);
13027 vam->noprint_msg = 1;
13028 /* Wait for a reply... */
13032 get_locator_set_index_from_msg (vam, locator_set, locator_set_index);
13033 vam->noprint_msg = 0;
13042 lisp_locator_dump (vat_main_t * vam, u32 locator_set_index, u8 * locator_set,
13049 if (!vam->json_output)
13051 fformat (vam->ofp, "%=20s%=16s%=16s\n",
13052 "locator", "priority", "weight");
13057 ret = get_locator_set_index (vam, locator_set, &locator_set_index);
13060 if (!ret && ~0 == locator_set_index)
13065 ret = lisp_locator_dump_send_msg (vam, locator_set_index, filter);
13071 lisp_locator_set_dump (vat_main_t * vam, u8 filter)
13073 vl_api_lisp_locator_set_dump_t *mp;
13076 if (!vam->json_output)
13078 fformat (vam->ofp, "%=20s%=16s%=16s%=16s%=16s\n",
13079 "locator-set", "locator-set-index", "locator", "priority",
13083 vam->noprint_msg = 1;
13085 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
13087 mp->filter = filter;
13092 /* Use a control ping for synchronization */
13094 vl_api_noprint_control_ping_t *mp;
13095 M (NOPRINT_CONTROL_PING, noprint_control_ping);
13099 /* Wait for a reply... */
13103 if (vam->noprint_msg)
13105 if (!vam->json_output)
13107 print_locator_in_locator_set(vam, filter);
13111 json_locator_in_locator_set(vam, filter);
13114 vam->noprint_msg = 0;
13123 api_lisp_locator_set_dump (vat_main_t * vam)
13125 unformat_input_t *input = vam->input;
13126 vam->noprint_msg = 0;
13127 u32 locator_set_index = ~0;
13128 u8 locator_set_index_set = 0;
13129 u8 *locator_set = 0;
13130 u8 locator_set_set = 0;
13134 /* Parse args required to build the message */
13135 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13137 if (unformat (input, "locator-set-index %u", &locator_set_index))
13139 locator_set_index_set = 1;
13141 else if (unformat (input, "locator-set %s", &locator_set))
13143 locator_set_set = 1;
13145 else if (unformat (input, "local"))
13149 else if (unformat (input, "remote"))
13159 if (locator_set_index_set && locator_set_set)
13161 errmsg ("use only input parameter!\n");
13165 if (locator_set_index_set || locator_set_set)
13167 ret = lisp_locator_dump (vam, locator_set_index, locator_set, filter);
13171 ret = lisp_locator_set_dump (vam, filter);
13174 vec_free (locator_set);
13180 api_lisp_eid_table_map_dump (vat_main_t * vam)
13184 unformat_input_t *input = vam->input;
13185 vl_api_lisp_eid_table_map_dump_t *mp;
13188 /* Parse args required to build the message */
13189 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13191 if (unformat (input, "l2"))
13196 else if (unformat (input, "l3"))
13203 errmsg ("parse error '%U'", format_unformat_error, input);
13210 errmsg ("expected one of 'l2' or 'l3' parameter!\n");
13214 if (!vam->json_output)
13216 fformat (vam->ofp, "%=10s%=10s\n", "VNI", is_l2 ? "BD" : "VRF");
13219 M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump);
13225 /* Use a control ping for synchronization */
13227 vl_api_control_ping_t *mp;
13228 M (CONTROL_PING, control_ping);
13231 /* Wait for a reply... */
13239 api_lisp_eid_table_vni_dump (vat_main_t * vam)
13241 vl_api_lisp_eid_table_vni_dump_t *mp;
13244 if (!vam->json_output)
13246 fformat (vam->ofp, "VNI\n");
13249 M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
13254 /* Use a control ping for synchronization */
13256 vl_api_control_ping_t *mp;
13257 M (CONTROL_PING, control_ping);
13260 /* Wait for a reply... */
13268 get_locator_set (vat_main_t * vam)
13270 vl_api_lisp_locator_set_dump_t *mp;
13273 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
13277 /* Use a control ping for synchronization */
13279 vl_api_noprint_control_ping_t *mp;
13280 M (NOPRINT_CONTROL_PING, noprint_control_ping);
13284 /* Wait for a reply... */
13292 format_eid_for_eid_table (vat_main_t * vam, u8 * str, eid_table_t * eid_table,
13295 u8 *(*format_eid) (u8 *, va_list *) = 0;
13297 ASSERT (vam != NULL);
13298 ASSERT (eid_table != NULL);
13305 switch (eid_table->eid_type)
13309 format_eid = (eid_table->eid_type ? format_ip6_address :
13310 format_ip4_address);
13311 str = format (0, "[%d] %U/%d", eid_table->vni,
13312 format_eid, eid_table->eid, eid_table->eid_prefix_len);
13315 str = format (0, "[%d] %U", eid_table->vni,
13316 format_ethernet_address, eid_table->eid);
13319 errmsg ("unknown EID type %d!", eid_table->eid_type);
13331 format_locator_set_for_eid_table (vat_main_t * vam, u8 * str,
13332 eid_table_t * eid_table)
13334 locator_set_msg_t *ls = 0;
13336 ASSERT (vam != NULL);
13337 ASSERT (eid_table != NULL);
13339 if (eid_table->is_local)
13341 vec_foreach (ls, vam->locator_set_msg)
13343 if (ls->locator_set_index == eid_table->locator_set_index)
13345 str = format (0, "local(%s)", ls->locator_set_name);
13350 str = format (0, "local(N/A)");
13354 str = format (0, "remote");
13361 format_locator_for_eid_table (vat_main_t * vam, u8 * str,
13362 eid_table_t * eid_table)
13364 locator_msg_t *loc = 0;
13365 int first_line = 1;
13367 ASSERT (vam != NULL);
13368 ASSERT (eid_table != NULL);
13370 if (~0 == eid_table->locator_set_index)
13372 return format (0, "action: %d\n", eid_table->action);
13375 vec_foreach (loc, vam->locator_msg)
13381 str = format (str, "%-55s%-d\n", " ", loc->sw_if_index);
13385 str = format (str, "%=55s%-U\n", " ",
13386 loc->is_ipv6 ? format_ip6_address :
13387 format_ip4_address, loc->ip_address);
13395 str = format (str, "%-30d%-20u%-u\n", loc->sw_if_index,
13396 eid_table->ttl, eid_table->authoritative);
13400 str = format (str, "%-30U%-20u%-u\n",
13401 loc->is_ipv6 ? format_ip6_address :
13402 format_ip4_address,
13403 loc->ip_address, eid_table->ttl,
13404 eid_table->authoritative);
13413 print_lisp_eid_table_dump (vat_main_t * vam)
13415 eid_table_t *eid_table = 0;
13416 u8 *tmp_str = 0, *tmp_str2 = 0;
13419 ASSERT (vam != NULL);
13421 ret = get_locator_set (vam);
13424 vec_free (vam->eid_tables);
13428 fformat (vam->ofp, "%-35s%-20s%-30s%-20s%-s\n", "EID", "type", "locators",
13429 "ttl", "authoritative");
13431 vec_foreach (eid_table, vam->eid_tables)
13433 if (~0 != eid_table->locator_set_index)
13435 ret = lisp_locator_dump_send_msg (vam, eid_table->locator_set_index,
13439 vec_free (vam->locator_msg);
13440 clean_locator_set_message (vam);
13441 vec_free (vam->eid_tables);
13446 tmp_str2 = format_eid_for_eid_table (vam, tmp_str2, eid_table, &ret);
13449 vec_free (vam->locator_msg);
13450 clean_locator_set_message (vam);
13451 vec_free (vam->eid_tables);
13455 tmp_str = format (0, "%-35s", tmp_str2);
13456 vec_free (tmp_str2);
13458 tmp_str2 = format_locator_set_for_eid_table (vam, tmp_str2, eid_table);
13459 tmp_str = format (tmp_str, "%-20s", tmp_str2);
13460 vec_free (tmp_str2);
13462 tmp_str2 = format_locator_for_eid_table (vam, tmp_str2, eid_table);
13463 tmp_str = format (tmp_str, "%-s", tmp_str2);
13464 vec_free (tmp_str2);
13466 fformat (vam->ofp, "%s", tmp_str);
13467 vec_free (tmp_str);
13468 vec_free (vam->locator_msg);
13471 clean_locator_set_message (vam);
13472 vec_free (vam->eid_tables);
13478 json_locator_set_for_eid_table (vat_main_t * vam, vat_json_node_t * node,
13479 eid_table_t * eid_table)
13481 locator_set_msg_t *ls = 0;
13484 ASSERT (vam != NULL);
13485 ASSERT (node != NULL);
13486 ASSERT (eid_table != NULL);
13488 if (eid_table->is_local)
13490 vec_foreach (ls, vam->locator_set_msg)
13492 if (ls->locator_set_index == eid_table->locator_set_index)
13494 vat_json_object_add_string_copy (node, "locator-set",
13495 ls->locator_set_name);
13500 s = format (0, "N/A");
13502 vat_json_object_add_string_copy (node, "locator-set", s);
13507 s = format (0, "remote");
13509 vat_json_object_add_string_copy (node, "locator-set", s);
13515 json_eid_for_eid_table (vat_main_t * vam, vat_json_node_t * node,
13516 eid_table_t * eid_table)
13519 struct in6_addr ip6;
13520 struct in_addr ip4;
13522 ASSERT (vam != NULL);
13523 ASSERT (node != NULL);
13524 ASSERT (eid_table != NULL);
13526 switch (eid_table->eid_type)
13529 clib_memcpy (&ip4, eid_table->eid, sizeof (ip4));
13530 vat_json_object_add_ip4 (node, "eid", ip4);
13531 vat_json_object_add_uint (node, "eid-prefix-len",
13532 eid_table->eid_prefix_len);
13535 clib_memcpy (&ip6, eid_table->eid, sizeof (ip6));
13536 vat_json_object_add_ip6 (node, "eid", ip6);
13537 vat_json_object_add_uint (node, "eid-prefix-len",
13538 eid_table->eid_prefix_len);
13541 s = format (0, "%U", format_ethernet_address, eid_table->eid);
13543 vat_json_object_add_string_copy (node, "eid", s);
13547 errmsg ("unknown EID type %d!", eid_table->eid_type);
13555 json_locator_for_eid_table (vat_main_t * vam, vat_json_node_t * node,
13556 eid_table_t * eid_table)
13558 locator_msg_t *loc = 0;
13559 vat_json_node_t *locator_array = 0;
13560 vat_json_node_t *locator = 0;
13561 struct in6_addr ip6;
13562 struct in_addr ip4;
13564 ASSERT (vam != NULL);
13565 ASSERT (node != NULL);
13566 ASSERT (eid_table != NULL);
13568 locator_array = vat_json_object_add_list (node, "locator");
13569 vec_foreach (loc, vam->locator_msg)
13571 locator = vat_json_array_add (locator_array);
13572 vat_json_init_object (locator);
13575 vat_json_object_add_uint (locator, "locator-index", loc->sw_if_index);
13581 clib_memcpy (&ip6, loc->ip_address, sizeof (ip6));
13582 vat_json_object_add_ip6 (locator, "locator", ip6);
13586 clib_memcpy (&ip4, loc->ip_address, sizeof (ip4));
13587 vat_json_object_add_ip4 (locator, "locator", ip4);
13594 json_lisp_eid_table_dump (vat_main_t * vam)
13596 eid_table_t *eid_table;
13597 vat_json_node_t *node = 0;
13600 ASSERT (vam != NULL);
13602 ret = get_locator_set (vam);
13605 vec_free (vam->eid_tables);
13609 if (!vec_len (vam->eid_tables))
13611 /* just print [] */
13612 vat_json_init_array (&vam->json_tree);
13613 vat_json_print (vam->ofp, &vam->json_tree);
13614 vam->json_tree.type = VAT_JSON_NONE;
13618 if (VAT_JSON_ARRAY != vam->json_tree.type)
13620 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13621 vat_json_init_array (&vam->json_tree);
13624 vec_foreach (eid_table, vam->eid_tables)
13626 ret = lisp_locator_dump_send_msg (vam, eid_table->locator_set_index, 0);
13629 vec_free (vam->locator_msg);
13630 vec_free (vam->eid_tables);
13631 clean_locator_set_message (vam);
13632 vat_json_free (&vam->json_tree);
13633 vam->json_tree.type = VAT_JSON_NONE;
13637 node = vat_json_array_add (&vam->json_tree);
13638 vat_json_init_object (node);
13640 vat_json_object_add_uint (node, "vni", eid_table->vni);
13642 json_locator_set_for_eid_table (vam, node, eid_table);
13643 ret = json_eid_for_eid_table (vam, node, eid_table);
13646 vec_free (vam->locator_msg);
13647 vec_free (vam->eid_tables);
13648 clean_locator_set_message (vam);
13649 vat_json_free (&vam->json_tree);
13650 vam->json_tree.type = VAT_JSON_NONE;
13654 json_locator_for_eid_table (vam, node, eid_table);
13656 vat_json_object_add_uint (node, "ttl", eid_table->ttl);
13657 vat_json_object_add_uint (node, "authoritative",
13658 eid_table->authoritative);
13660 vec_free (vam->locator_msg);
13663 vat_json_print (vam->ofp, &vam->json_tree);
13664 vat_json_free (&vam->json_tree);
13665 vam->json_tree.type = VAT_JSON_NONE;
13667 clean_locator_set_message (vam);
13668 vec_free (vam->eid_tables);
13674 api_lisp_eid_table_dump (vat_main_t * vam)
13676 unformat_input_t *i = vam->input;
13677 vl_api_lisp_eid_table_dump_t *mp;
13679 struct in_addr ip4;
13680 struct in6_addr ip6;
13682 u8 eid_type = ~0, eid_set = 0;
13683 u32 prefix_length = ~0, t, vni = 0;
13686 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13688 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
13694 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
13700 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
13705 else if (unformat (i, "vni %d", &t))
13709 else if (unformat (i, "local"))
13713 else if (unformat (i, "remote"))
13719 errmsg ("parse error '%U'", format_unformat_error, i);
13724 M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump);
13726 mp->filter = filter;
13730 mp->vni = htonl (vni);
13731 mp->eid_type = eid_type;
13735 mp->prefix_length = prefix_length;
13736 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
13739 mp->prefix_length = prefix_length;
13740 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
13743 clib_memcpy (mp->eid, mac, sizeof (mac));
13746 errmsg ("unknown EID type %d!", eid_type);
13751 vam->noprint_msg = 1;
13756 /* Use a control ping for synchronization */
13758 vl_api_noprint_control_ping_t *mp;
13759 M (NOPRINT_CONTROL_PING, noprint_control_ping);
13763 /* Wait for a reply... */
13767 if (vam->noprint_msg)
13769 if (!vam->json_output)
13771 vam->retval = print_lisp_eid_table_dump(vam);
13775 vam->retval = json_lisp_eid_table_dump(vam);
13778 vam->noprint_msg = 0;
13787 api_lisp_gpe_tunnel_dump (vat_main_t * vam)
13789 vl_api_lisp_gpe_tunnel_dump_t *mp;
13792 if (!vam->json_output)
13794 fformat (vam->ofp, "%=20s%=30s%=16s%=16s%=16s%=16s"
13795 "%=16s%=16s%=16s%=16s%=16s\n",
13796 "Tunel", "Source", "Destination", "Fib encap", "Fib decap",
13797 "Decap next", "Lisp version", "Flags", "Next protocol",
13798 "ver_res", "res", "iid");
13801 M (LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump);
13805 /* Use a control ping for synchronization */
13807 vl_api_control_ping_t *mp;
13808 M (CONTROL_PING, control_ping);
13811 /* Wait for a reply... */
13819 api_lisp_map_resolver_dump (vat_main_t * vam)
13821 vl_api_lisp_map_resolver_dump_t *mp;
13824 if (!vam->json_output)
13826 fformat (vam->ofp, "%=20s\n", "Map resolver");
13829 M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
13833 /* Use a control ping for synchronization */
13835 vl_api_control_ping_t *mp;
13836 M (CONTROL_PING, control_ping);
13839 /* Wait for a reply... */
13847 api_show_lisp_status (vat_main_t * vam)
13849 vl_api_show_lisp_status_t *mp;
13852 if (!vam->json_output)
13854 fformat (vam->ofp, "%-20s%-16s\n", "lisp status", "locator-set");
13857 M (SHOW_LISP_STATUS, show_lisp_status);
13860 /* Wait for a reply... */
13868 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
13870 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
13873 if (!vam->json_output)
13875 fformat (vam->ofp, "%=20s\n", "itr-rlocs:");
13878 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
13881 /* Wait for a reply... */
13889 api_af_packet_create (vat_main_t * vam)
13891 unformat_input_t *i = vam->input;
13892 vl_api_af_packet_create_t *mp;
13894 u8 *host_if_name = 0;
13896 u8 random_hw_addr = 1;
13898 memset (hw_addr, 0, sizeof (hw_addr));
13900 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13902 if (unformat (i, "name %s", &host_if_name))
13903 vec_add1 (host_if_name, 0);
13904 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
13905 random_hw_addr = 0;
13910 if (!vec_len (host_if_name))
13912 errmsg ("host-interface name must be specified");
13916 if (vec_len (host_if_name) > 64)
13918 errmsg ("host-interface name too long");
13922 M (AF_PACKET_CREATE, af_packet_create);
13924 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
13925 clib_memcpy (mp->hw_addr, hw_addr, 6);
13926 mp->use_random_hw_addr = random_hw_addr;
13927 vec_free (host_if_name);
13930 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
13936 api_af_packet_delete (vat_main_t * vam)
13938 unformat_input_t *i = vam->input;
13939 vl_api_af_packet_delete_t *mp;
13941 u8 *host_if_name = 0;
13943 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13945 if (unformat (i, "name %s", &host_if_name))
13946 vec_add1 (host_if_name, 0);
13951 if (!vec_len (host_if_name))
13953 errmsg ("host-interface name must be specified");
13957 if (vec_len (host_if_name) > 64)
13959 errmsg ("host-interface name too long");
13963 M (AF_PACKET_DELETE, af_packet_delete);
13965 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
13966 vec_free (host_if_name);
13975 api_policer_add_del (vat_main_t * vam)
13977 unformat_input_t *i = vam->input;
13978 vl_api_policer_add_del_t *mp;
13989 u8 color_aware = 0;
13990 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
13992 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
13993 conform_action.dscp = 0;
13994 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
13995 exceed_action.dscp = 0;
13996 violate_action.action_type = SSE2_QOS_ACTION_DROP;
13997 violate_action.dscp = 0;
13999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14001 if (unformat (i, "del"))
14003 else if (unformat (i, "name %s", &name))
14004 vec_add1 (name, 0);
14005 else if (unformat (i, "cir %u", &cir))
14007 else if (unformat (i, "eir %u", &eir))
14009 else if (unformat (i, "cb %u", &cb))
14011 else if (unformat (i, "eb %u", &eb))
14013 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
14016 else if (unformat (i, "round_type %U", unformat_policer_round_type,
14019 else if (unformat (i, "type %U", unformat_policer_type, &type))
14021 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
14024 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
14027 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
14030 else if (unformat (i, "color-aware"))
14036 if (!vec_len (name))
14038 errmsg ("policer name must be specified");
14042 if (vec_len (name) > 64)
14044 errmsg ("policer name too long");
14048 M (POLICER_ADD_DEL, policer_add_del);
14050 clib_memcpy (mp->name, name, vec_len (name));
14052 mp->is_add = is_add;
14057 mp->rate_type = rate_type;
14058 mp->round_type = round_type;
14060 mp->conform_action_type = conform_action.action_type;
14061 mp->conform_dscp = conform_action.dscp;
14062 mp->exceed_action_type = exceed_action.action_type;
14063 mp->exceed_dscp = exceed_action.dscp;
14064 mp->violate_action_type = violate_action.action_type;
14065 mp->violate_dscp = violate_action.dscp;
14066 mp->color_aware = color_aware;
14075 api_policer_dump (vat_main_t * vam)
14077 unformat_input_t *i = vam->input;
14078 vl_api_policer_dump_t *mp;
14080 u8 *match_name = 0;
14081 u8 match_name_valid = 0;
14083 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14085 if (unformat (i, "name %s", &match_name))
14087 vec_add1 (match_name, 0);
14088 match_name_valid = 1;
14094 M (POLICER_DUMP, policer_dump);
14095 mp->match_name_valid = match_name_valid;
14096 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
14097 vec_free (match_name);
14101 /* Use a control ping for synchronization */
14103 vl_api_control_ping_t *mp;
14104 M (CONTROL_PING, control_ping);
14107 /* Wait for a reply... */
14115 api_policer_classify_set_interface (vat_main_t * vam)
14117 unformat_input_t *i = vam->input;
14118 vl_api_policer_classify_set_interface_t *mp;
14121 int sw_if_index_set;
14122 u32 ip4_table_index = ~0;
14123 u32 ip6_table_index = ~0;
14124 u32 l2_table_index = ~0;
14127 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14129 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
14130 sw_if_index_set = 1;
14131 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14132 sw_if_index_set = 1;
14133 else if (unformat (i, "del"))
14135 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14137 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14139 else if (unformat (i, "l2-table %d", &l2_table_index))
14143 clib_warning ("parse error '%U'", format_unformat_error, i);
14148 if (sw_if_index_set == 0)
14150 errmsg ("missing interface name or sw_if_index\n");
14154 M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface);
14156 mp->sw_if_index = ntohl (sw_if_index);
14157 mp->ip4_table_index = ntohl (ip4_table_index);
14158 mp->ip6_table_index = ntohl (ip6_table_index);
14159 mp->l2_table_index = ntohl (l2_table_index);
14160 mp->is_add = is_add;
14169 api_policer_classify_dump (vat_main_t * vam)
14171 unformat_input_t *i = vam->input;
14172 vl_api_policer_classify_dump_t *mp;
14174 u8 type = POLICER_CLASSIFY_N_TABLES;
14176 if (unformat (i, "type %U", unformat_classify_table_type, &type))
14180 errmsg ("classify table type must be specified\n");
14184 if (!vam->json_output)
14186 fformat (vam->ofp, "%10s%20s\n", "Intfc idx", "Classify table");
14189 M (POLICER_CLASSIFY_DUMP, policer_classify_dump);
14194 /* Use a control ping for synchronization */
14196 vl_api_control_ping_t *mp;
14197 M (CONTROL_PING, control_ping);
14200 /* Wait for a reply... */
14208 api_netmap_create (vat_main_t * vam)
14210 unformat_input_t *i = vam->input;
14211 vl_api_netmap_create_t *mp;
14215 u8 random_hw_addr = 1;
14219 memset (hw_addr, 0, sizeof (hw_addr));
14221 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14223 if (unformat (i, "name %s", &if_name))
14224 vec_add1 (if_name, 0);
14225 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14226 random_hw_addr = 0;
14227 else if (unformat (i, "pipe"))
14229 else if (unformat (i, "master"))
14231 else if (unformat (i, "slave"))
14237 if (!vec_len (if_name))
14239 errmsg ("interface name must be specified");
14243 if (vec_len (if_name) > 64)
14245 errmsg ("interface name too long");
14249 M (NETMAP_CREATE, netmap_create);
14251 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
14252 clib_memcpy (mp->hw_addr, hw_addr, 6);
14253 mp->use_random_hw_addr = random_hw_addr;
14254 mp->is_pipe = is_pipe;
14255 mp->is_master = is_master;
14256 vec_free (if_name);
14265 api_netmap_delete (vat_main_t * vam)
14267 unformat_input_t *i = vam->input;
14268 vl_api_netmap_delete_t *mp;
14272 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14274 if (unformat (i, "name %s", &if_name))
14275 vec_add1 (if_name, 0);
14280 if (!vec_len (if_name))
14282 errmsg ("interface name must be specified");
14286 if (vec_len (if_name) > 64)
14288 errmsg ("interface name too long");
14292 M (NETMAP_DELETE, netmap_delete);
14294 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
14295 vec_free (if_name);
14303 static void vl_api_mpls_gre_tunnel_details_t_handler
14304 (vl_api_mpls_gre_tunnel_details_t * mp)
14306 vat_main_t *vam = &vat_main;
14308 i32 len = ntohl (mp->nlabels);
14310 if (mp->l2_only == 0)
14312 fformat (vam->ofp, "[%d]: src %U, dst %U, adj %U/%d, labels ",
14313 ntohl (mp->tunnel_index),
14314 format_ip4_address, &mp->tunnel_src,
14315 format_ip4_address, &mp->tunnel_dst,
14316 format_ip4_address, &mp->intfc_address,
14317 ntohl (mp->mask_width));
14318 for (i = 0; i < len; i++)
14320 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14322 fformat (vam->ofp, "\n");
14323 fformat (vam->ofp, " inner fib index %d, outer fib index %d\n",
14324 ntohl (mp->inner_fib_index), ntohl (mp->outer_fib_index));
14328 fformat (vam->ofp, "[%d]: src %U, dst %U, key %U, labels ",
14329 ntohl (mp->tunnel_index),
14330 format_ip4_address, &mp->tunnel_src,
14331 format_ip4_address, &mp->tunnel_dst,
14332 format_ip4_address, &mp->intfc_address);
14333 for (i = 0; i < len; i++)
14335 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14337 fformat (vam->ofp, "\n");
14338 fformat (vam->ofp, " l2 interface %d, outer fib index %d\n",
14339 ntohl (mp->hw_if_index), ntohl (mp->outer_fib_index));
14343 static void vl_api_mpls_gre_tunnel_details_t_handler_json
14344 (vl_api_mpls_gre_tunnel_details_t * mp)
14346 vat_main_t *vam = &vat_main;
14347 vat_json_node_t *node = NULL;
14348 struct in_addr ip4;
14350 i32 len = ntohl (mp->nlabels);
14352 if (VAT_JSON_ARRAY != vam->json_tree.type)
14354 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14355 vat_json_init_array (&vam->json_tree);
14357 node = vat_json_array_add (&vam->json_tree);
14359 vat_json_init_object (node);
14360 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
14361 clib_memcpy (&ip4, &(mp->intfc_address), sizeof (ip4));
14362 vat_json_object_add_ip4 (node, "intfc_address", ip4);
14363 vat_json_object_add_uint (node, "inner_fib_index",
14364 ntohl (mp->inner_fib_index));
14365 vat_json_object_add_uint (node, "mask_width", ntohl (mp->mask_width));
14366 vat_json_object_add_uint (node, "encap_index", ntohl (mp->encap_index));
14367 vat_json_object_add_uint (node, "hw_if_index", ntohl (mp->hw_if_index));
14368 vat_json_object_add_uint (node, "l2_only", ntohl (mp->l2_only));
14369 clib_memcpy (&ip4, &(mp->tunnel_src), sizeof (ip4));
14370 vat_json_object_add_ip4 (node, "tunnel_src", ip4);
14371 clib_memcpy (&ip4, &(mp->tunnel_dst), sizeof (ip4));
14372 vat_json_object_add_ip4 (node, "tunnel_dst", ip4);
14373 vat_json_object_add_uint (node, "outer_fib_index",
14374 ntohl (mp->outer_fib_index));
14375 vat_json_object_add_uint (node, "label_count", len);
14376 for (i = 0; i < len; i++)
14378 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14383 api_mpls_gre_tunnel_dump (vat_main_t * vam)
14385 vl_api_mpls_gre_tunnel_dump_t *mp;
14389 /* Parse args required to build the message */
14390 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
14392 if (!unformat (vam->input, "tunnel_index %d", &index))
14399 fformat (vam->ofp, " tunnel_index %d\n", index);
14401 M (MPLS_GRE_TUNNEL_DUMP, mpls_gre_tunnel_dump);
14402 mp->tunnel_index = htonl (index);
14405 /* Use a control ping for synchronization */
14407 vl_api_control_ping_t *mp;
14408 M (CONTROL_PING, control_ping);
14414 static void vl_api_mpls_eth_tunnel_details_t_handler
14415 (vl_api_mpls_eth_tunnel_details_t * mp)
14417 vat_main_t *vam = &vat_main;
14419 i32 len = ntohl (mp->nlabels);
14421 fformat (vam->ofp, "[%d]: dst %U, adj %U/%d, labels ",
14422 ntohl (mp->tunnel_index),
14423 format_ethernet_address, &mp->tunnel_dst_mac,
14424 format_ip4_address, &mp->intfc_address, ntohl (mp->mask_width));
14425 for (i = 0; i < len; i++)
14427 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14429 fformat (vam->ofp, "\n");
14430 fformat (vam->ofp, " tx on %d, rx fib index %d\n",
14431 ntohl (mp->tx_sw_if_index), ntohl (mp->inner_fib_index));
14434 static void vl_api_mpls_eth_tunnel_details_t_handler_json
14435 (vl_api_mpls_eth_tunnel_details_t * mp)
14437 vat_main_t *vam = &vat_main;
14438 vat_json_node_t *node = NULL;
14439 struct in_addr ip4;
14441 i32 len = ntohl (mp->nlabels);
14443 if (VAT_JSON_ARRAY != vam->json_tree.type)
14445 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14446 vat_json_init_array (&vam->json_tree);
14448 node = vat_json_array_add (&vam->json_tree);
14450 vat_json_init_object (node);
14451 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
14452 clib_memcpy (&ip4, &(mp->intfc_address), sizeof (ip4));
14453 vat_json_object_add_ip4 (node, "intfc_address", ip4);
14454 vat_json_object_add_uint (node, "inner_fib_index",
14455 ntohl (mp->inner_fib_index));
14456 vat_json_object_add_uint (node, "mask_width", ntohl (mp->mask_width));
14457 vat_json_object_add_uint (node, "encap_index", ntohl (mp->encap_index));
14458 vat_json_object_add_uint (node, "hw_if_index", ntohl (mp->hw_if_index));
14459 vat_json_object_add_uint (node, "l2_only", ntohl (mp->l2_only));
14460 vat_json_object_add_string_copy (node, "tunnel_dst_mac",
14461 format (0, "%U", format_ethernet_address,
14462 &mp->tunnel_dst_mac));
14463 vat_json_object_add_uint (node, "tx_sw_if_index",
14464 ntohl (mp->tx_sw_if_index));
14465 vat_json_object_add_uint (node, "label_count", len);
14466 for (i = 0; i < len; i++)
14468 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14473 api_mpls_eth_tunnel_dump (vat_main_t * vam)
14475 vl_api_mpls_eth_tunnel_dump_t *mp;
14479 /* Parse args required to build the message */
14480 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
14482 if (!unformat (vam->input, "tunnel_index %d", &index))
14489 fformat (vam->ofp, " tunnel_index %d\n", index);
14491 M (MPLS_ETH_TUNNEL_DUMP, mpls_eth_tunnel_dump);
14492 mp->tunnel_index = htonl (index);
14495 /* Use a control ping for synchronization */
14497 vl_api_control_ping_t *mp;
14498 M (CONTROL_PING, control_ping);
14504 static void vl_api_mpls_fib_encap_details_t_handler
14505 (vl_api_mpls_fib_encap_details_t * mp)
14507 vat_main_t *vam = &vat_main;
14509 i32 len = ntohl (mp->nlabels);
14511 fformat (vam->ofp, "table %d, dest %U, label ",
14512 ntohl (mp->fib_index), format_ip4_address, &mp->dest, len);
14513 for (i = 0; i < len; i++)
14515 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14517 fformat (vam->ofp, "\n");
14520 static void vl_api_mpls_fib_encap_details_t_handler_json
14521 (vl_api_mpls_fib_encap_details_t * mp)
14523 vat_main_t *vam = &vat_main;
14524 vat_json_node_t *node = NULL;
14526 i32 len = ntohl (mp->nlabels);
14527 struct in_addr ip4;
14529 if (VAT_JSON_ARRAY != vam->json_tree.type)
14531 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14532 vat_json_init_array (&vam->json_tree);
14534 node = vat_json_array_add (&vam->json_tree);
14536 vat_json_init_object (node);
14537 vat_json_object_add_uint (node, "table", ntohl (mp->fib_index));
14538 vat_json_object_add_uint (node, "entry_index", ntohl (mp->entry_index));
14539 clib_memcpy (&ip4, &(mp->dest), sizeof (ip4));
14540 vat_json_object_add_ip4 (node, "dest", ip4);
14541 vat_json_object_add_uint (node, "s_bit", ntohl (mp->s_bit));
14542 vat_json_object_add_uint (node, "label_count", len);
14543 for (i = 0; i < len; i++)
14545 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14550 api_mpls_fib_encap_dump (vat_main_t * vam)
14552 vl_api_mpls_fib_encap_dump_t *mp;
14555 M (MPLS_FIB_ENCAP_DUMP, mpls_fib_encap_dump);
14558 /* Use a control ping for synchronization */
14560 vl_api_control_ping_t *mp;
14561 M (CONTROL_PING, control_ping);
14567 static void vl_api_mpls_fib_decap_details_t_handler
14568 (vl_api_mpls_fib_decap_details_t * mp)
14570 vat_main_t *vam = &vat_main;
14573 "RX table %d, TX table/intfc %u, swif_tag '%s', label %u, s_bit %u\n",
14574 ntohl (mp->rx_table_id), ntohl (mp->tx_table_id), mp->swif_tag,
14575 ntohl (mp->label), ntohl (mp->s_bit));
14578 static void vl_api_mpls_fib_decap_details_t_handler_json
14579 (vl_api_mpls_fib_decap_details_t * mp)
14581 vat_main_t *vam = &vat_main;
14582 vat_json_node_t *node = NULL;
14583 struct in_addr ip4;
14585 if (VAT_JSON_ARRAY != vam->json_tree.type)
14587 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14588 vat_json_init_array (&vam->json_tree);
14590 node = vat_json_array_add (&vam->json_tree);
14592 vat_json_init_object (node);
14593 vat_json_object_add_uint (node, "table", ntohl (mp->fib_index));
14594 vat_json_object_add_uint (node, "entry_index", ntohl (mp->entry_index));
14595 clib_memcpy (&ip4, &(mp->dest), sizeof (ip4));
14596 vat_json_object_add_ip4 (node, "dest", ip4);
14597 vat_json_object_add_uint (node, "s_bit", ntohl (mp->s_bit));
14598 vat_json_object_add_uint (node, "label", ntohl (mp->label));
14599 vat_json_object_add_uint (node, "rx_table_id", ntohl (mp->rx_table_id));
14600 vat_json_object_add_uint (node, "tx_table_id", ntohl (mp->tx_table_id));
14601 vat_json_object_add_string_copy (node, "swif_tag", mp->swif_tag);
14605 api_mpls_fib_decap_dump (vat_main_t * vam)
14607 vl_api_mpls_fib_decap_dump_t *mp;
14610 M (MPLS_FIB_DECAP_DUMP, mpls_fib_decap_dump);
14613 /* Use a control ping for synchronization */
14615 vl_api_control_ping_t *mp;
14616 M (CONTROL_PING, control_ping);
14623 api_classify_table_ids (vat_main_t * vam)
14625 vl_api_classify_table_ids_t *mp;
14628 /* Construct the API message */
14629 M (CLASSIFY_TABLE_IDS, classify_table_ids);
14639 api_classify_table_by_interface (vat_main_t * vam)
14641 unformat_input_t *input = vam->input;
14642 vl_api_classify_table_by_interface_t *mp;
14645 u32 sw_if_index = ~0;
14646 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14648 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
14650 else if (unformat (input, "sw_if_index %d", &sw_if_index))
14655 if (sw_if_index == ~0)
14657 errmsg ("missing interface name or sw_if_index\n");
14661 /* Construct the API message */
14662 M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
14664 mp->sw_if_index = ntohl (sw_if_index);
14673 api_classify_table_info (vat_main_t * vam)
14675 unformat_input_t *input = vam->input;
14676 vl_api_classify_table_info_t *mp;
14680 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14682 if (unformat (input, "table_id %d", &table_id))
14687 if (table_id == ~0)
14689 errmsg ("missing table id\n");
14693 /* Construct the API message */
14694 M (CLASSIFY_TABLE_INFO, classify_table_info);
14696 mp->table_id = ntohl (table_id);
14705 api_classify_session_dump (vat_main_t * vam)
14707 unformat_input_t *input = vam->input;
14708 vl_api_classify_session_dump_t *mp;
14712 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14714 if (unformat (input, "table_id %d", &table_id))
14719 if (table_id == ~0)
14721 errmsg ("missing table id\n");
14725 /* Construct the API message */
14726 M (CLASSIFY_SESSION_DUMP, classify_session_dump);
14728 mp->table_id = ntohl (table_id);
14731 /* Use a control ping for synchronization */
14733 vl_api_control_ping_t *mp;
14734 M (CONTROL_PING, control_ping);
14743 vl_api_ipfix_details_t_handler (vl_api_ipfix_details_t * mp)
14745 vat_main_t *vam = &vat_main;
14747 fformat (vam->ofp, "collector_address %U, collector_port %d, "
14748 "src_address %U, fib_index %u, path_mtu %u, "
14749 "template_interval %u\n",
14750 format_ip4_address, mp->collector_address,
14751 ntohs (mp->collector_port),
14752 format_ip4_address, mp->src_address,
14753 ntohl (mp->fib_index),
14754 ntohl (mp->path_mtu), ntohl (mp->template_interval));
14757 vam->result_ready = 1;
14761 vl_api_ipfix_details_t_handler_json (vl_api_ipfix_details_t * mp)
14763 vat_main_t *vam = &vat_main;
14764 vat_json_node_t node;
14765 struct in_addr collector_address;
14766 struct in_addr src_address;
14768 vat_json_init_object (&node);
14769 clib_memcpy (&collector_address, &mp->collector_address,
14770 sizeof (collector_address));
14771 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
14772 vat_json_object_add_uint (&node, "collector_port",
14773 ntohs (mp->collector_port));
14774 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
14775 vat_json_object_add_ip4 (&node, "src_address", src_address);
14776 vat_json_object_add_uint (&node, "fib_index", ntohl (mp->fib_index));
14777 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
14778 vat_json_object_add_uint (&node, "template_interval",
14779 ntohl (mp->template_interval));
14781 vat_json_print (vam->ofp, &node);
14782 vat_json_free (&node);
14784 vam->result_ready = 1;
14788 api_ipfix_dump (vat_main_t * vam)
14790 vl_api_ipfix_dump_t *mp;
14793 /* Construct the API message */
14794 M (IPFIX_DUMP, ipfix_dump);
14804 api_pg_create_interface (vat_main_t * vam)
14806 unformat_input_t *input = vam->input;
14807 vl_api_pg_create_interface_t *mp;
14811 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14813 if (unformat (input, "if_id %d", &if_id))
14820 errmsg ("missing pg interface index\n");
14824 /* Construct the API message */
14825 M (PG_CREATE_INTERFACE, pg_create_interface);
14827 mp->interface_id = ntohl (if_id);
14836 api_pg_capture (vat_main_t * vam)
14838 unformat_input_t *input = vam->input;
14839 vl_api_pg_capture_t *mp;
14845 u8 pcap_file_set = 0;
14847 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14849 if (unformat (input, "if_id %d", &if_id))
14851 else if (unformat (input, "pcap %s", &pcap_file))
14853 else if (unformat (input, "count %d", &count))
14855 else if (unformat (input, "disable"))
14862 errmsg ("missing pg interface index\n");
14865 if (pcap_file_set > 0)
14867 if (vec_len (pcap_file) > 255)
14869 errmsg ("pcap file name is too long\n");
14874 u32 name_len = vec_len (pcap_file);
14875 /* Construct the API message */
14876 M (PG_CAPTURE, pg_capture);
14878 mp->interface_id = ntohl (if_id);
14879 mp->is_enabled = enable;
14880 mp->count = ntohl (count);
14881 mp->pcap_name_length = ntohl (name_len);
14882 if (pcap_file_set != 0)
14884 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
14886 vec_free (pcap_file);
14895 api_pg_enable_disable (vat_main_t * vam)
14897 unformat_input_t *input = vam->input;
14898 vl_api_pg_enable_disable_t *mp;
14902 u8 stream_name_set = 0;
14903 u8 *stream_name = 0;
14904 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14906 if (unformat (input, "stream %s", &stream_name))
14907 stream_name_set = 1;
14908 else if (unformat (input, "disable"))
14914 if (stream_name_set > 0)
14916 if (vec_len (stream_name) > 255)
14918 errmsg ("stream name too long\n");
14923 u32 name_len = vec_len (stream_name);
14924 /* Construct the API message */
14925 M (PG_ENABLE_DISABLE, pg_enable_disable);
14927 mp->is_enabled = enable;
14928 if (stream_name_set != 0)
14930 mp->stream_name_length = ntohl (name_len);
14931 clib_memcpy (mp->stream_name, stream_name, name_len);
14933 vec_free (stream_name);
14942 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
14944 unformat_input_t *input = vam->input;
14945 vl_api_ip_source_and_port_range_check_add_del_t *mp;
14948 u16 *low_ports = 0;
14949 u16 *high_ports = 0;
14952 ip4_address_t ip4_addr;
14953 ip6_address_t ip6_addr;
14961 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14963 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
14969 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
14974 else if (unformat (input, "vrf %d", &vrf_id))
14976 else if (unformat (input, "del"))
14978 else if (unformat (input, "port %d", &tmp))
14980 if (tmp == 0 || tmp > 65535)
14982 errmsg ("port %d out of range", tmp);
14986 this_hi = this_low + 1;
14987 vec_add1 (low_ports, this_low);
14988 vec_add1 (high_ports, this_hi);
14990 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
14992 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
14994 errmsg ("incorrect range parameters\n");
14998 /* Note: in debug CLI +1 is added to high before
14999 passing to real fn that does "the work"
15000 (ip_source_and_port_range_check_add_del).
15001 This fn is a wrapper around the binary API fn a
15002 control plane will call, which expects this increment
15003 to have occurred. Hence letting the binary API control
15004 plane fn do the increment for consistency between VAT
15005 and other control planes.
15008 vec_add1 (low_ports, this_low);
15009 vec_add1 (high_ports, this_hi);
15015 if (prefix_set == 0)
15017 errmsg ("<address>/<mask> not specified\n");
15023 errmsg ("VRF ID required, not specified\n");
15030 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
15034 if (vec_len (low_ports) == 0)
15036 errmsg ("At least one port or port range required\n");
15040 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,
15041 ip_source_and_port_range_check_add_del);
15043 mp->is_add = is_add;
15048 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
15053 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
15056 mp->mask_length = length;
15057 mp->number_of_ranges = vec_len (low_ports);
15059 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
15060 vec_free (low_ports);
15062 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
15063 vec_free (high_ports);
15065 mp->vrf_id = ntohl (vrf_id);
15074 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
15076 unformat_input_t *input = vam->input;
15077 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
15079 u32 sw_if_index = ~0;
15081 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
15082 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
15085 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15087 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
15089 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15091 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
15093 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
15095 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
15097 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
15099 else if (unformat (input, "del"))
15105 if (sw_if_index == ~0)
15107 errmsg ("Interface required but not specified\n");
15113 errmsg ("VRF ID required but not specified\n");
15117 if (tcp_out_vrf_id == 0
15118 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
15121 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
15125 /* Construct the API message */
15126 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,
15127 ip_source_and_port_range_check_interface_add_del);
15129 mp->sw_if_index = ntohl (sw_if_index);
15130 mp->is_add = is_add;
15131 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
15132 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
15133 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
15134 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
15139 /* Wait for a reply... */
15144 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
15146 unformat_input_t *i = vam->input;
15147 vl_api_ipsec_gre_add_del_tunnel_t *mp;
15149 u32 local_sa_id = 0;
15150 u32 remote_sa_id = 0;
15151 ip4_address_t src_address;
15152 ip4_address_t dst_address;
15155 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15157 if (unformat (i, "local_sa %d", &local_sa_id))
15159 else if (unformat (i, "remote_sa %d", &remote_sa_id))
15161 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
15163 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
15165 else if (unformat (i, "del"))
15169 clib_warning ("parse error '%U'", format_unformat_error, i);
15174 M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel);
15176 mp->local_sa_id = ntohl (local_sa_id);
15177 mp->remote_sa_id = ntohl (remote_sa_id);
15178 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
15179 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
15180 mp->is_add = is_add;
15188 static void vl_api_ipsec_gre_tunnel_details_t_handler
15189 (vl_api_ipsec_gre_tunnel_details_t * mp)
15191 vat_main_t *vam = &vat_main;
15193 fformat (vam->ofp, "%11d%15U%15U%14d%14d\n",
15194 ntohl (mp->sw_if_index),
15195 format_ip4_address, &mp->src_address,
15196 format_ip4_address, &mp->dst_address,
15197 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
15200 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
15201 (vl_api_ipsec_gre_tunnel_details_t * mp)
15203 vat_main_t *vam = &vat_main;
15204 vat_json_node_t *node = NULL;
15205 struct in_addr ip4;
15207 if (VAT_JSON_ARRAY != vam->json_tree.type)
15209 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15210 vat_json_init_array (&vam->json_tree);
15212 node = vat_json_array_add (&vam->json_tree);
15214 vat_json_init_object (node);
15215 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15216 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
15217 vat_json_object_add_ip4 (node, "src_address", ip4);
15218 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
15219 vat_json_object_add_ip4 (node, "dst_address", ip4);
15220 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
15221 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
15225 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
15227 unformat_input_t *i = vam->input;
15228 vl_api_ipsec_gre_tunnel_dump_t *mp;
15231 u8 sw_if_index_set = 0;
15233 /* Parse args required to build the message */
15234 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15236 if (unformat (i, "sw_if_index %d", &sw_if_index))
15237 sw_if_index_set = 1;
15242 if (sw_if_index_set == 0)
15247 if (!vam->json_output)
15249 fformat (vam->ofp, "%11s%15s%15s%14s%14s\n",
15250 "sw_if_index", "src_address", "dst_address",
15251 "local_sa_id", "remote_sa_id");
15254 /* Get list of gre-tunnel interfaces */
15255 M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump);
15257 mp->sw_if_index = htonl (sw_if_index);
15261 /* Use a control ping for synchronization */
15263 vl_api_control_ping_t *mp;
15264 M (CONTROL_PING, control_ping);
15271 api_delete_subif (vat_main_t * vam)
15273 unformat_input_t *i = vam->input;
15274 vl_api_delete_subif_t *mp;
15276 u32 sw_if_index = ~0;
15278 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15280 if (unformat (i, "sw_if_index %d", &sw_if_index))
15286 if (sw_if_index == ~0)
15288 errmsg ("missing sw_if_index\n");
15292 /* Construct the API message */
15293 M (DELETE_SUBIF, delete_subif);
15294 mp->sw_if_index = ntohl (sw_if_index);
15301 q_or_quit (vat_main_t * vam)
15303 longjmp (vam->jump_buf, 1);
15304 return 0; /* not so much */
15308 q (vat_main_t * vam)
15310 return q_or_quit (vam);
15314 quit (vat_main_t * vam)
15316 return q_or_quit (vam);
15320 comment (vat_main_t * vam)
15326 cmd_cmp (void *a1, void *a2)
15331 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
15335 help (vat_main_t * vam)
15340 unformat_input_t *i = vam->input;
15343 if (unformat (i, "%s", &name))
15347 vec_add1 (name, 0);
15349 hs = hash_get_mem (vam->help_by_name, name);
15351 fformat (vam->ofp, "usage: %s %s\n", name, hs[0]);
15353 fformat (vam->ofp, "No such msg / command '%s'\n", name);
15358 fformat (vam->ofp, "Help is available for the following:\n");
15361 hash_foreach_pair (p, vam->function_by_name,
15363 vec_add1 (cmds, (u8 *)(p->key));
15367 vec_sort_with_function (cmds, cmd_cmp);
15369 for (j = 0; j < vec_len (cmds); j++)
15370 fformat (vam->ofp, "%s\n", cmds[j]);
15377 set (vat_main_t * vam)
15379 u8 *name = 0, *value = 0;
15380 unformat_input_t *i = vam->input;
15382 if (unformat (i, "%s", &name))
15384 /* The input buffer is a vector, not a string. */
15385 value = vec_dup (i->buffer);
15386 vec_delete (value, i->index, 0);
15387 /* Almost certainly has a trailing newline */
15388 if (value[vec_len (value) - 1] == '\n')
15389 value[vec_len (value) - 1] = 0;
15390 /* Make sure it's a proper string, one way or the other */
15391 vec_add1 (value, 0);
15392 (void) clib_macro_set_value (&vam->macro_main,
15393 (char *) name, (char *) value);
15396 errmsg ("usage: set <name> <value>\n");
15404 unset (vat_main_t * vam)
15408 if (unformat (vam->input, "%s", &name))
15409 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
15410 errmsg ("unset: %s wasn't set\n", name);
15423 macro_sort_cmp (void *a1, void *a2)
15425 macro_sort_t *s1 = a1;
15426 macro_sort_t *s2 = a2;
15428 return strcmp ((char *) (s1->name), (char *) (s2->name));
15432 dump_macro_table (vat_main_t * vam)
15434 macro_sort_t *sort_me = 0, *sm;
15439 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
15441 vec_add2 (sort_me, sm, 1);
15442 sm->name = (u8 *)(p->key);
15443 sm->value = (u8 *) (p->value[0]);
15447 vec_sort_with_function (sort_me, macro_sort_cmp);
15449 if (vec_len (sort_me))
15450 fformat (vam->ofp, "%-15s%s\n", "Name", "Value");
15452 fformat (vam->ofp, "The macro table is empty...\n");
15454 for (i = 0; i < vec_len (sort_me); i++)
15455 fformat (vam->ofp, "%-15s%s\n", sort_me[i].name, sort_me[i].value);
15460 dump_node_table (vat_main_t * vam)
15463 vlib_node_t *node, *next_node;
15465 if (vec_len (vam->graph_nodes) == 0)
15467 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
15471 for (i = 0; i < vec_len (vam->graph_nodes); i++)
15473 node = vam->graph_nodes[i];
15474 fformat (vam->ofp, "[%d] %s\n", i, node->name);
15475 for (j = 0; j < vec_len (node->next_nodes); j++)
15477 if (node->next_nodes[j] != ~0)
15479 next_node = vam->graph_nodes[node->next_nodes[j]];
15480 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
15488 search_node_table (vat_main_t * vam)
15490 unformat_input_t *line_input = vam->input;
15493 vlib_node_t *node, *next_node;
15496 if (vam->graph_node_index_by_name == 0)
15498 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
15502 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15504 if (unformat (line_input, "%s", &node_to_find))
15506 vec_add1 (node_to_find, 0);
15507 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
15510 fformat (vam->ofp, "%s not found...\n", node_to_find);
15513 node = vam->graph_nodes[p[0]];
15514 fformat (vam->ofp, "[%d] %s\n", p[0], node->name);
15515 for (j = 0; j < vec_len (node->next_nodes); j++)
15517 if (node->next_nodes[j] != ~0)
15519 next_node = vam->graph_nodes[node->next_nodes[j]];
15520 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
15527 clib_warning ("parse error '%U'", format_unformat_error,
15533 vec_free (node_to_find);
15542 script (vat_main_t * vam)
15545 char *save_current_file;
15546 unformat_input_t save_input;
15547 jmp_buf save_jump_buf;
15548 u32 save_line_number;
15550 FILE *new_fp, *save_ifp;
15552 if (unformat (vam->input, "%s", &s))
15554 new_fp = fopen ((char *) s, "r");
15557 errmsg ("Couldn't open script file %s\n", s);
15564 errmsg ("Missing script name\n");
15568 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
15569 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
15570 save_ifp = vam->ifp;
15571 save_line_number = vam->input_line_number;
15572 save_current_file = (char *) vam->current_file;
15574 vam->input_line_number = 0;
15576 vam->current_file = s;
15579 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
15580 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
15581 vam->ifp = save_ifp;
15582 vam->input_line_number = save_line_number;
15583 vam->current_file = (u8 *) save_current_file;
15590 echo (vat_main_t * vam)
15592 fformat (vam->ofp, "%v", vam->input->buffer);
15596 /* List of API message constructors, CLI names map to api_xxx */
15597 #define foreach_vpe_api_msg \
15598 _(create_loopback,"[mac <mac-addr>]") \
15599 _(sw_interface_dump,"") \
15600 _(sw_interface_set_flags, \
15601 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
15602 _(sw_interface_add_del_address, \
15603 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
15604 _(sw_interface_set_table, \
15605 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
15606 _(sw_interface_set_vpath, \
15607 "<intfc> | sw_if_index <id> enable | disable") \
15608 _(sw_interface_set_l2_xconnect, \
15609 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
15610 "enable | disable") \
15611 _(sw_interface_set_l2_bridge, \
15612 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
15613 "[shg <split-horizon-group>] [bvi]\n" \
15614 "enable | disable") \
15615 _(bridge_domain_add_del, \
15616 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n")\
15617 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
15619 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
15621 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
15623 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
15625 "tapname <name> mac <mac-addr> | random-mac") \
15627 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
15629 "<vpp-if-name> | sw_if_index <id>") \
15630 _(sw_interface_tap_dump, "") \
15631 _(ip_add_del_route, \
15632 "<addr>/<mask> via <addr> [vrf <n>]\n" \
15633 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
15634 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
15635 "[multipath] [count <n>]") \
15636 _(proxy_arp_add_del, \
15637 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
15638 _(proxy_arp_intfc_enable_disable, \
15639 "<intfc> | sw_if_index <id> enable | disable") \
15640 _(mpls_add_del_encap, \
15641 "label <n> dst <ip4-addr> [vrf <n>] [del]") \
15642 _(mpls_add_del_decap, \
15643 "label <n> [rx_vrf_id <n>] [tx_vrf_id] [s-bit-clear][del]") \
15644 _(mpls_gre_add_del_tunnel, \
15645 "inner_vrf_id <n> outer_vrf_id <n> src <ip4-address> dst <ip4-address>\n" \
15646 "adj <ip4-address>/<mask-width> [del]") \
15647 _(sw_interface_set_unnumbered, \
15648 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
15649 _(ip_neighbor_add_del, \
15650 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
15651 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
15652 _(reset_vrf, "vrf <id> [ipv6]") \
15653 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
15654 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
15655 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
15656 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
15657 "[outer_vlan_id_any][inner_vlan_id_any]") \
15658 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
15659 _(reset_fib, "vrf <n> [ipv6]") \
15660 _(dhcp_proxy_config, \
15661 "svr <v46-address> src <v46-address>\n" \
15662 "insert-cid <n> [del]") \
15663 _(dhcp_proxy_config_2, \
15664 "svr <v46-address> src <v46-address>\n" \
15665 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
15666 _(dhcp_proxy_set_vss, \
15667 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
15668 _(dhcp_client_config, \
15669 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
15670 _(set_ip_flow_hash, \
15671 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
15672 _(sw_interface_ip6_enable_disable, \
15673 "<intfc> | sw_if_index <id> enable | disable") \
15674 _(sw_interface_ip6_set_link_local_address, \
15675 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
15676 _(sw_interface_ip6nd_ra_prefix, \
15677 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
15678 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
15679 "[nolink] [isno]") \
15680 _(sw_interface_ip6nd_ra_config, \
15681 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
15682 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
15683 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
15684 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
15685 _(l2_patch_add_del, \
15686 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
15687 "enable | disable") \
15688 _(mpls_ethernet_add_del_tunnel, \
15689 "tx <intfc> | tx_sw_if_index <n> dst <mac-addr>\n" \
15690 "adj <ip4-addr>/<mw> dst <mac-addr> [del]") \
15691 _(mpls_ethernet_add_del_tunnel_2, \
15692 "inner_vrf_id <n> outer_vrf_id <n> next-hop <ip4-addr>\n" \
15693 "resolve-attempts <n> resolve-if-needed 0 | 1 [del]") \
15694 _(sr_tunnel_add_del, \
15695 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
15696 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
15697 "[policy <policy_name>]") \
15698 _(sr_policy_add_del, \
15699 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
15700 _(sr_multicast_map_add_del, \
15701 "address [ip6 multicast address] sr-policy [policy name] [del]") \
15702 _(classify_add_del_table, \
15703 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
15704 "[del] mask <mask-value>\n" \
15705 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>") \
15706 _(classify_add_del_session, \
15707 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
15708 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
15709 " [l3 [ip4|ip6]]") \
15710 _(classify_set_interface_ip_table, \
15711 "<intfc> | sw_if_index <nn> table <nn>") \
15712 _(classify_set_interface_l2_tables, \
15713 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
15714 " [other-table <nn>]") \
15715 _(get_node_index, "node <node-name") \
15716 _(add_node_next, "node <node-name> next <next-node-name>") \
15717 _(l2tpv3_create_tunnel, \
15718 "client_address <ip6-addr> our_address <ip6-addr>\n" \
15719 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n"\
15720 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
15721 _(l2tpv3_set_tunnel_cookies, \
15722 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
15723 "[new_remote_cookie <nn>]\n") \
15724 _(l2tpv3_interface_enable_disable, \
15725 "<intfc> | sw_if_index <nn> enable | disable") \
15726 _(l2tpv3_set_lookup_key, \
15727 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
15728 _(sw_if_l2tpv3_tunnel_dump, "") \
15729 _(vxlan_add_del_tunnel, \
15730 "src <ip-addr> dst <ip-addr> vni <vni> [encap-vrf-id <nn>]\n" \
15731 " [decap-next l2|ip4|ip6] [del]") \
15732 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
15733 _(gre_add_del_tunnel, \
15734 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [del]\n") \
15735 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
15736 _(l2_fib_clear_table, "") \
15737 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
15738 _(l2_interface_vlan_tag_rewrite, \
15739 "<intfc> | sw_if_index <nn> \n" \
15740 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
15741 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
15742 _(create_vhost_user_if, \
15743 "socket <filename> [server] [renumber <dev_instance>] " \
15744 "[mac <mac_address>]") \
15745 _(modify_vhost_user_if, \
15746 "<intfc> | sw_if_index <nn> socket <filename>\n" \
15747 "[server] [renumber <dev_instance>]") \
15748 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
15749 _(sw_interface_vhost_user_dump, "") \
15750 _(show_version, "") \
15751 _(vxlan_gpe_add_del_tunnel, \
15752 "local <addr> remote <addr> vni <nn>\n" \
15753 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
15754 "[next-ethernet] [next-nsh]\n") \
15755 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
15756 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
15757 _(interface_name_renumber, \
15758 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
15759 _(input_acl_set_interface, \
15760 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
15761 " [l2-table <nn>] [del]") \
15762 _(want_ip4_arp_events, "address <ip4-address> [del]") \
15763 _(want_ip6_nd_events, "address <ip6-address> [del]") \
15764 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
15765 _(ip_dump, "ipv4 | ipv6") \
15766 _(ipsec_spd_add_del, "spd_id <n> [del]") \
15767 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
15769 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
15770 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
15771 " integ_alg <alg> integ_key <hex>") \
15772 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
15773 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
15774 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
15775 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" )\
15776 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
15777 _(ikev2_profile_add_del, "name <profile_name> [del]") \
15778 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
15779 "(auth_data 0x<data> | auth_data <data>)") \
15780 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
15781 "(id_data 0x<data> | id_data <data>) (local|remote)") \
15782 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
15783 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
15784 "(local|remote)") \
15785 _(ikev2_set_local_key, "file <absolute_file_path>") \
15786 _(delete_loopback,"sw_if_index <nn>") \
15787 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
15788 _(map_add_domain, \
15789 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
15790 "ip6-src <ip6addr> " \
15791 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
15792 _(map_del_domain, "index <n>") \
15793 _(map_add_del_rule, \
15794 "index <n> psid <n> dst <ip6addr> [del]") \
15795 _(map_domain_dump, "") \
15796 _(map_rule_dump, "index <map-domain>") \
15797 _(want_interface_events, "enable|disable") \
15798 _(want_stats,"enable|disable") \
15799 _(get_first_msg_id, "client <name>") \
15800 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
15801 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
15802 "fib-id <nn> [ip4][ip6][default]") \
15803 _(get_node_graph, " ") \
15804 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
15805 _(trace_profile_add, "id <nn> trace-type <0x1f|0x3|0x9|0x11|0x19> " \
15806 "trace-elts <nn> trace-tsp <0|1|2|3> node-id <node id in hex> " \
15807 "app-data <app_data in hex> [pow] [ppc <encap|decap>]") \
15808 _(trace_profile_apply, "id <nn> <ip6-address>/<width>" \
15809 " vrf_id <nn> add | pop | none") \
15810 _(trace_profile_del, "") \
15811 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
15812 " sw_if_index <sw_if_index> p <priority> " \
15813 "w <weight>] [del]") \
15814 _(lisp_add_del_locator, "locator-set <locator_name> " \
15815 "iface <intf> | sw_if_index <sw_if_index> " \
15816 "p <priority> w <weight> [del]") \
15817 _(lisp_add_del_local_eid,"vni <vni> eid " \
15818 "<ipv4|ipv6>/<prefix> | <L2 address> " \
15819 "locator-set <locator_name> [del]") \
15820 _(lisp_gpe_add_del_fwd_entry, "rmt_eid <eid> [lcl_eid <eid>] vni <vni>" \
15821 "dp_table <table> loc-pair <lcl_loc> <rmt_loc> ... [del]") \
15822 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
15823 _(lisp_gpe_enable_disable, "enable|disable") \
15824 _(lisp_enable_disable, "enable|disable") \
15825 _(lisp_gpe_add_del_iface, "up|down") \
15826 _(lisp_add_del_remote_mapping, "add|del vni <vni> deid <dest-eid> " \
15827 "rloc <locator> p <prio> " \
15828 "w <weight> [rloc <loc> ... ] " \
15829 "action <action> [del-all]") \
15830 _(lisp_add_del_adjacency, "add|del vni <vni> deid <dest-eid> seid " \
15831 "<src-eid> rloc <locator> p <prio> w <weight>"\
15832 "[rloc <loc> ... ] action <action>") \
15833 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
15834 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
15835 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
15836 _(lisp_locator_set_dump, "[locator-set-index <ls-index> | " \
15837 "locator-set <loc-set-name>] [local | remote]")\
15838 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
15839 "[local] | [remote]") \
15840 _(lisp_eid_table_vni_dump, "") \
15841 _(lisp_eid_table_map_dump, "l2|l3") \
15842 _(lisp_gpe_tunnel_dump, "") \
15843 _(lisp_map_resolver_dump, "") \
15844 _(show_lisp_status, "") \
15845 _(lisp_get_map_request_itr_rlocs, "") \
15846 _(show_lisp_pitr, "") \
15847 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
15848 _(af_packet_delete, "name <host interface name>") \
15849 _(policer_add_del, "name <policer name> <params> [del]") \
15850 _(policer_dump, "[name <policer name>]") \
15851 _(policer_classify_set_interface, \
15852 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
15853 " [l2-table <nn>] [del]") \
15854 _(policer_classify_dump, "type [ip4|ip6|l2]") \
15855 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
15856 "[master|slave]") \
15857 _(netmap_delete, "name <interface name>") \
15858 _(mpls_gre_tunnel_dump, "tunnel_index <tunnel-id>") \
15859 _(mpls_eth_tunnel_dump, "tunnel_index <tunnel-id>") \
15860 _(mpls_fib_encap_dump, "") \
15861 _(mpls_fib_decap_dump, "") \
15862 _(classify_table_ids, "") \
15863 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
15864 _(classify_table_info, "table_id <nn>") \
15865 _(classify_session_dump, "table_id <nn>") \
15866 _(ipfix_enable, "collector_address <ip4> [collector_port <nn>] " \
15867 "src_address <ip4> [fib_id <nn>] [path_mtu <nn>] " \
15868 "[template_interval <nn>]") \
15869 _(ipfix_dump, "") \
15870 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
15871 _(pg_create_interface, "if_id <nn>") \
15872 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
15873 _(pg_enable_disable, "[stream <id>] disable") \
15874 _(ip_source_and_port_range_check_add_del, \
15875 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
15876 _(ip_source_and_port_range_check_interface_add_del, \
15877 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
15878 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
15879 _(ipsec_gre_add_del_tunnel, \
15880 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
15881 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
15882 _(delete_subif,"sub_sw_if_index <nn> sub_if_id <nn>")
15884 /* List of command functions, CLI names map directly to functions */
15885 #define foreach_cli_function \
15886 _(comment, "usage: comment <ignore-rest-of-line>") \
15887 _(dump_interface_table, "usage: dump_interface_table") \
15888 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
15889 _(dump_ipv4_table, "usage: dump_ipv4_table") \
15890 _(dump_ipv6_table, "usage: dump_ipv6_table") \
15891 _(dump_stats_table, "usage: dump_stats_table") \
15892 _(dump_macro_table, "usage: dump_macro_table ") \
15893 _(dump_node_table, "usage: dump_node_table") \
15894 _(echo, "usage: echo <message>") \
15895 _(exec, "usage: exec <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")