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_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;
8574 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8576 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8577 sw_if_index_set = 1;
8578 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8579 sw_if_index_set = 1;
8580 else if (unformat (i, "ip4-table %d", &ip4_table_index))
8582 else if (unformat (i, "ip6-table %d", &ip6_table_index))
8584 else if (unformat (i, "other-table %d", &other_table_index))
8588 clib_warning ("parse error '%U'", format_unformat_error, i);
8593 if (sw_if_index_set == 0)
8595 errmsg ("missing interface name or sw_if_index\n");
8600 M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables);
8602 mp->sw_if_index = ntohl (sw_if_index);
8603 mp->ip4_table_index = ntohl (ip4_table_index);
8604 mp->ip6_table_index = ntohl (ip6_table_index);
8605 mp->other_table_index = ntohl (other_table_index);
8615 api_ipfix_enable (vat_main_t * vam)
8617 unformat_input_t *i = vam->input;
8618 vl_api_ipfix_enable_t *mp;
8619 ip4_address_t collector_address;
8620 u8 collector_address_set = 0;
8621 u32 collector_port = ~0;
8622 ip4_address_t src_address;
8623 u8 src_address_set = 0;
8626 u32 template_interval = ~0;
8629 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8631 if (unformat (i, "collector_address %U", unformat_ip4_address,
8632 &collector_address))
8633 collector_address_set = 1;
8634 else if (unformat (i, "collector_port %d", &collector_port))
8636 else if (unformat (i, "src_address %U", unformat_ip4_address,
8638 src_address_set = 1;
8639 else if (unformat (i, "vrf_id %d", &vrf_id))
8641 else if (unformat (i, "path_mtu %d", &path_mtu))
8643 else if (unformat (i, "template_interval %d", &template_interval))
8649 if (collector_address_set == 0)
8651 errmsg ("collector_address required\n");
8655 if (src_address_set == 0)
8657 errmsg ("src_address required\n");
8661 M (IPFIX_ENABLE, ipfix_enable);
8663 memcpy (mp->collector_address, collector_address.data,
8664 sizeof (collector_address.data));
8665 mp->collector_port = htons ((u16) collector_port);
8666 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
8667 mp->vrf_id = htonl (vrf_id);
8668 mp->path_mtu = htonl (path_mtu);
8669 mp->template_interval = htonl (template_interval);
8677 api_get_node_index (vat_main_t * vam)
8679 unformat_input_t *i = vam->input;
8680 vl_api_get_node_index_t *mp;
8684 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8686 if (unformat (i, "node %s", &name))
8693 errmsg ("node name required\n");
8696 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
8698 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
8702 M (GET_NODE_INDEX, get_node_index);
8703 clib_memcpy (mp->node_name, name, vec_len (name));
8713 api_get_next_index (vat_main_t * vam)
8715 unformat_input_t *i = vam->input;
8716 vl_api_get_next_index_t *mp;
8718 u8 *node_name = 0, *next_node_name = 0;
8720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8722 if (unformat (i, "node-name %s", &node_name))
8724 else if (unformat (i, "next-node-name %s", &next_node_name))
8730 errmsg ("node name required\n");
8733 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
8735 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
8739 if (next_node_name == 0)
8741 errmsg ("next node name required\n");
8744 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
8746 errmsg ("next node name too long, max %d\n", ARRAY_LEN (mp->next_name));
8750 M (GET_NEXT_INDEX, get_next_index);
8751 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
8752 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
8753 vec_free (node_name);
8754 vec_free (next_node_name);
8763 api_add_node_next (vat_main_t * vam)
8765 unformat_input_t *i = vam->input;
8766 vl_api_add_node_next_t *mp;
8771 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8773 if (unformat (i, "node %s", &name))
8775 else if (unformat (i, "next %s", &next))
8782 errmsg ("node name required\n");
8785 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
8787 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
8792 errmsg ("next node required\n");
8795 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
8797 errmsg ("next name too long, max %d\n", ARRAY_LEN (mp->next_name));
8801 M (ADD_NODE_NEXT, add_node_next);
8802 clib_memcpy (mp->node_name, name, vec_len (name));
8803 clib_memcpy (mp->next_name, next, vec_len (next));
8814 api_l2tpv3_create_tunnel (vat_main_t * vam)
8816 unformat_input_t *i = vam->input;
8817 ip6_address_t client_address, our_address;
8818 int client_address_set = 0;
8819 int our_address_set = 0;
8820 u32 local_session_id = 0;
8821 u32 remote_session_id = 0;
8822 u64 local_cookie = 0;
8823 u64 remote_cookie = 0;
8824 u8 l2_sublayer_present = 0;
8825 vl_api_l2tpv3_create_tunnel_t *mp;
8828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8830 if (unformat (i, "client_address %U", unformat_ip6_address,
8832 client_address_set = 1;
8833 else if (unformat (i, "our_address %U", unformat_ip6_address,
8835 our_address_set = 1;
8836 else if (unformat (i, "local_session_id %d", &local_session_id))
8838 else if (unformat (i, "remote_session_id %d", &remote_session_id))
8840 else if (unformat (i, "local_cookie %lld", &local_cookie))
8842 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
8844 else if (unformat (i, "l2-sublayer-present"))
8845 l2_sublayer_present = 1;
8850 if (client_address_set == 0)
8852 errmsg ("client_address required\n");
8856 if (our_address_set == 0)
8858 errmsg ("our_address required\n");
8862 M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel);
8864 clib_memcpy (mp->client_address, client_address.as_u8,
8865 sizeof (mp->client_address));
8867 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
8869 mp->local_session_id = ntohl (local_session_id);
8870 mp->remote_session_id = ntohl (remote_session_id);
8871 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
8872 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
8873 mp->l2_sublayer_present = l2_sublayer_present;
8883 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
8885 unformat_input_t *i = vam->input;
8887 u8 sw_if_index_set = 0;
8888 u64 new_local_cookie = 0;
8889 u64 new_remote_cookie = 0;
8890 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
8893 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8895 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8896 sw_if_index_set = 1;
8897 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8898 sw_if_index_set = 1;
8899 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
8901 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
8907 if (sw_if_index_set == 0)
8909 errmsg ("missing interface name or sw_if_index\n");
8913 M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies);
8915 mp->sw_if_index = ntohl (sw_if_index);
8916 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
8917 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
8926 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
8928 unformat_input_t *i = vam->input;
8929 vl_api_l2tpv3_interface_enable_disable_t *mp;
8932 u8 sw_if_index_set = 0;
8933 u8 enable_disable = 1;
8935 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8937 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8938 sw_if_index_set = 1;
8939 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8940 sw_if_index_set = 1;
8941 else if (unformat (i, "enable"))
8943 else if (unformat (i, "disable"))
8949 if (sw_if_index_set == 0)
8951 errmsg ("missing interface name or sw_if_index\n");
8955 M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable);
8957 mp->sw_if_index = ntohl (sw_if_index);
8958 mp->enable_disable = enable_disable;
8967 api_l2tpv3_set_lookup_key (vat_main_t * vam)
8969 unformat_input_t *i = vam->input;
8970 vl_api_l2tpv3_set_lookup_key_t *mp;
8974 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8976 if (unformat (i, "lookup_v6_src"))
8977 key = L2T_LOOKUP_SRC_ADDRESS;
8978 else if (unformat (i, "lookup_v6_dst"))
8979 key = L2T_LOOKUP_DST_ADDRESS;
8980 else if (unformat (i, "lookup_session_id"))
8981 key = L2T_LOOKUP_SESSION_ID;
8986 if (key == (u8) ~ 0)
8988 errmsg ("l2tp session lookup key unset\n");
8992 M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key);
9002 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
9003 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
9005 vat_main_t *vam = &vat_main;
9007 fformat (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)\n",
9008 format_ip6_address, mp->our_address,
9009 format_ip6_address, mp->client_address,
9010 clib_net_to_host_u32 (mp->sw_if_index));
9013 " local cookies %016llx %016llx remote cookie %016llx\n",
9014 clib_net_to_host_u64 (mp->local_cookie[0]),
9015 clib_net_to_host_u64 (mp->local_cookie[1]),
9016 clib_net_to_host_u64 (mp->remote_cookie));
9018 fformat (vam->ofp, " local session-id %d remote session-id %d\n",
9019 clib_net_to_host_u32 (mp->local_session_id),
9020 clib_net_to_host_u32 (mp->remote_session_id));
9022 fformat (vam->ofp, " l2 specific sublayer %s\n\n",
9023 mp->l2_sublayer_present ? "preset" : "absent");
9027 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
9028 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
9030 vat_main_t *vam = &vat_main;
9031 vat_json_node_t *node = NULL;
9032 struct in6_addr addr;
9034 if (VAT_JSON_ARRAY != vam->json_tree.type)
9036 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9037 vat_json_init_array (&vam->json_tree);
9039 node = vat_json_array_add (&vam->json_tree);
9041 vat_json_init_object (node);
9043 clib_memcpy (&addr, mp->our_address, sizeof (addr));
9044 vat_json_object_add_ip6 (node, "our_address", addr);
9045 clib_memcpy (&addr, mp->client_address, sizeof (addr));
9046 vat_json_object_add_ip6 (node, "client_address", addr);
9048 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
9049 vat_json_init_array (lc);
9050 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
9051 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
9052 vat_json_object_add_uint (node, "remote_cookie",
9053 clib_net_to_host_u64 (mp->remote_cookie));
9055 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
9056 vat_json_object_add_uint (node, "local_session_id",
9057 clib_net_to_host_u32 (mp->local_session_id));
9058 vat_json_object_add_uint (node, "remote_session_id",
9059 clib_net_to_host_u32 (mp->remote_session_id));
9060 vat_json_object_add_string_copy (node, "l2_sublayer",
9061 mp->l2_sublayer_present ? (u8 *) "present"
9066 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
9068 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
9071 /* Get list of l2tpv3-tunnel interfaces */
9072 M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump);
9075 /* Use a control ping for synchronization */
9077 vl_api_control_ping_t *mp;
9078 M (CONTROL_PING, control_ping);
9085 static void vl_api_sw_interface_tap_details_t_handler
9086 (vl_api_sw_interface_tap_details_t * mp)
9088 vat_main_t *vam = &vat_main;
9090 fformat (vam->ofp, "%-16s %d\n",
9091 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
9094 static void vl_api_sw_interface_tap_details_t_handler_json
9095 (vl_api_sw_interface_tap_details_t * mp)
9097 vat_main_t *vam = &vat_main;
9098 vat_json_node_t *node = NULL;
9100 if (VAT_JSON_ARRAY != vam->json_tree.type)
9102 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9103 vat_json_init_array (&vam->json_tree);
9105 node = vat_json_array_add (&vam->json_tree);
9107 vat_json_init_object (node);
9108 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9109 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
9113 api_sw_interface_tap_dump (vat_main_t * vam)
9115 vl_api_sw_interface_tap_dump_t *mp;
9118 fformat (vam->ofp, "\n%-16s %s\n", "dev_name", "sw_if_index");
9119 /* Get list of tap interfaces */
9120 M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump);
9123 /* Use a control ping for synchronization */
9125 vl_api_control_ping_t *mp;
9126 M (CONTROL_PING, control_ping);
9132 static uword unformat_vxlan_decap_next
9133 (unformat_input_t * input, va_list * args)
9135 u32 *result = va_arg (*args, u32 *);
9138 if (unformat (input, "drop"))
9139 *result = VXLAN_INPUT_NEXT_DROP;
9140 else if (unformat (input, "ip4"))
9141 *result = VXLAN_INPUT_NEXT_IP4_INPUT;
9142 else if (unformat (input, "ip6"))
9143 *result = VXLAN_INPUT_NEXT_IP6_INPUT;
9144 else if (unformat (input, "l2"))
9145 *result = VXLAN_INPUT_NEXT_L2_INPUT;
9146 else if (unformat (input, "%d", &tmp))
9154 api_vxlan_add_del_tunnel (vat_main_t * vam)
9156 unformat_input_t *line_input = vam->input;
9157 vl_api_vxlan_add_del_tunnel_t *mp;
9159 ip4_address_t src4, dst4;
9160 ip6_address_t src6, dst6;
9162 u8 ipv4_set = 0, ipv6_set = 0;
9165 u32 encap_vrf_id = 0;
9166 u32 decap_next_index = ~0;
9169 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9171 if (unformat (line_input, "del"))
9173 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
9178 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
9183 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
9188 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
9193 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
9195 else if (unformat (line_input, "decap-next %U",
9196 unformat_vxlan_decap_next, &decap_next_index))
9198 else if (unformat (line_input, "vni %d", &vni))
9202 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
9209 errmsg ("tunnel src address not specified\n");
9214 errmsg ("tunnel dst address not specified\n");
9218 if (ipv4_set && ipv6_set)
9220 errmsg ("both IPv4 and IPv6 addresses specified");
9224 if ((vni == 0) || (vni >> 24))
9226 errmsg ("vni not specified or out of range\n");
9230 M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel);
9234 clib_memcpy (&mp->src_address, &src6, sizeof (src6));
9235 clib_memcpy (&mp->dst_address, &dst6, sizeof (dst6));
9239 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
9240 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
9242 mp->encap_vrf_id = ntohl (encap_vrf_id);
9243 mp->decap_next_index = ntohl (decap_next_index);
9244 mp->vni = ntohl (vni);
9245 mp->is_add = is_add;
9246 mp->is_ipv6 = ipv6_set;
9254 static void vl_api_vxlan_tunnel_details_t_handler
9255 (vl_api_vxlan_tunnel_details_t * mp)
9257 vat_main_t *vam = &vat_main;
9259 fformat (vam->ofp, "%11d%24U%24U%14d%18d%13d\n",
9260 ntohl (mp->sw_if_index),
9261 format_ip46_address, &(mp->src_address[0]),
9263 format_ip46_address, &(mp->dst_address[0]),
9265 ntohl (mp->encap_vrf_id),
9266 ntohl (mp->decap_next_index), ntohl (mp->vni));
9269 static void vl_api_vxlan_tunnel_details_t_handler_json
9270 (vl_api_vxlan_tunnel_details_t * mp)
9272 vat_main_t *vam = &vat_main;
9273 vat_json_node_t *node = NULL;
9275 struct in6_addr ip6;
9277 if (VAT_JSON_ARRAY != vam->json_tree.type)
9279 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9280 vat_json_init_array (&vam->json_tree);
9282 node = vat_json_array_add (&vam->json_tree);
9284 vat_json_init_object (node);
9285 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9288 clib_memcpy (&ip6, &(mp->src_address[0]), sizeof (ip6));
9289 vat_json_object_add_ip6 (node, "src_address", ip6);
9290 clib_memcpy (&ip6, &(mp->dst_address[0]), sizeof (ip6));
9291 vat_json_object_add_ip6 (node, "dst_address", ip6);
9295 clib_memcpy (&ip4, &(mp->src_address[0]), sizeof (ip4));
9296 vat_json_object_add_ip4 (node, "src_address", ip4);
9297 clib_memcpy (&ip4, &(mp->dst_address[0]), sizeof (ip4));
9298 vat_json_object_add_ip4 (node, "dst_address", ip4);
9300 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
9301 vat_json_object_add_uint (node, "decap_next_index",
9302 ntohl (mp->decap_next_index));
9303 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
9304 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
9308 api_vxlan_tunnel_dump (vat_main_t * vam)
9310 unformat_input_t *i = vam->input;
9311 vl_api_vxlan_tunnel_dump_t *mp;
9314 u8 sw_if_index_set = 0;
9316 /* Parse args required to build the message */
9317 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9319 if (unformat (i, "sw_if_index %d", &sw_if_index))
9320 sw_if_index_set = 1;
9325 if (sw_if_index_set == 0)
9330 if (!vam->json_output)
9332 fformat (vam->ofp, "%11s%24s%24s%14s%18s%13s\n",
9333 "sw_if_index", "src_address", "dst_address",
9334 "encap_vrf_id", "decap_next_index", "vni");
9337 /* Get list of vxlan-tunnel interfaces */
9338 M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
9340 mp->sw_if_index = htonl (sw_if_index);
9344 /* Use a control ping for synchronization */
9346 vl_api_control_ping_t *mp;
9347 M (CONTROL_PING, control_ping);
9354 api_gre_add_del_tunnel (vat_main_t * vam)
9356 unformat_input_t *line_input = vam->input;
9357 vl_api_gre_add_del_tunnel_t *mp;
9359 ip4_address_t src4, dst4;
9363 u32 outer_fib_id = 0;
9365 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9367 if (unformat (line_input, "del"))
9369 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
9371 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
9373 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
9377 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
9384 errmsg ("tunnel src address not specified\n");
9389 errmsg ("tunnel dst address not specified\n");
9394 M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel);
9396 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
9397 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
9398 mp->outer_fib_id = ntohl (outer_fib_id);
9399 mp->is_add = is_add;
9407 static void vl_api_gre_tunnel_details_t_handler
9408 (vl_api_gre_tunnel_details_t * mp)
9410 vat_main_t *vam = &vat_main;
9412 fformat (vam->ofp, "%11d%15U%15U%14d\n",
9413 ntohl (mp->sw_if_index),
9414 format_ip4_address, &mp->src_address,
9415 format_ip4_address, &mp->dst_address, ntohl (mp->outer_fib_id));
9418 static void vl_api_gre_tunnel_details_t_handler_json
9419 (vl_api_gre_tunnel_details_t * mp)
9421 vat_main_t *vam = &vat_main;
9422 vat_json_node_t *node = NULL;
9425 if (VAT_JSON_ARRAY != vam->json_tree.type)
9427 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9428 vat_json_init_array (&vam->json_tree);
9430 node = vat_json_array_add (&vam->json_tree);
9432 vat_json_init_object (node);
9433 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9434 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
9435 vat_json_object_add_ip4 (node, "src_address", ip4);
9436 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
9437 vat_json_object_add_ip4 (node, "dst_address", ip4);
9438 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
9442 api_gre_tunnel_dump (vat_main_t * vam)
9444 unformat_input_t *i = vam->input;
9445 vl_api_gre_tunnel_dump_t *mp;
9448 u8 sw_if_index_set = 0;
9450 /* Parse args required to build the message */
9451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9453 if (unformat (i, "sw_if_index %d", &sw_if_index))
9454 sw_if_index_set = 1;
9459 if (sw_if_index_set == 0)
9464 if (!vam->json_output)
9466 fformat (vam->ofp, "%11s%15s%15s%14s\n",
9467 "sw_if_index", "src_address", "dst_address", "outer_fib_id");
9470 /* Get list of gre-tunnel interfaces */
9471 M (GRE_TUNNEL_DUMP, gre_tunnel_dump);
9473 mp->sw_if_index = htonl (sw_if_index);
9477 /* Use a control ping for synchronization */
9479 vl_api_control_ping_t *mp;
9480 M (CONTROL_PING, control_ping);
9487 api_l2_fib_clear_table (vat_main_t * vam)
9489 // unformat_input_t * i = vam->input;
9490 vl_api_l2_fib_clear_table_t *mp;
9493 M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table);
9502 api_l2_interface_efp_filter (vat_main_t * vam)
9504 unformat_input_t *i = vam->input;
9505 vl_api_l2_interface_efp_filter_t *mp;
9509 u8 sw_if_index_set = 0;
9511 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9513 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9514 sw_if_index_set = 1;
9515 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9516 sw_if_index_set = 1;
9517 else if (unformat (i, "enable"))
9519 else if (unformat (i, "disable"))
9523 clib_warning ("parse error '%U'", format_unformat_error, i);
9528 if (sw_if_index_set == 0)
9530 errmsg ("missing sw_if_index\n");
9534 M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter);
9536 mp->sw_if_index = ntohl (sw_if_index);
9537 mp->enable_disable = enable;
9545 #define foreach_vtr_op \
9546 _("disable", L2_VTR_DISABLED) \
9547 _("push-1", L2_VTR_PUSH_1) \
9548 _("push-2", L2_VTR_PUSH_2) \
9549 _("pop-1", L2_VTR_POP_1) \
9550 _("pop-2", L2_VTR_POP_2) \
9551 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
9552 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
9553 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
9554 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
9557 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
9559 unformat_input_t *i = vam->input;
9560 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
9563 u8 sw_if_index_set = 0;
9570 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9572 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9573 sw_if_index_set = 1;
9574 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9575 sw_if_index_set = 1;
9576 else if (unformat (i, "vtr_op %d", &vtr_op))
9578 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
9581 else if (unformat (i, "push_dot1q %d", &push_dot1q))
9583 else if (unformat (i, "tag1 %d", &tag1))
9585 else if (unformat (i, "tag2 %d", &tag2))
9589 clib_warning ("parse error '%U'", format_unformat_error, i);
9594 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
9596 errmsg ("missing vtr operation or sw_if_index\n");
9600 M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)
9601 mp->sw_if_index = ntohl (sw_if_index);
9602 mp->vtr_op = ntohl (vtr_op);
9603 mp->push_dot1q = ntohl (push_dot1q);
9604 mp->tag1 = ntohl (tag1);
9605 mp->tag2 = ntohl (tag2);
9614 api_create_vhost_user_if (vat_main_t * vam)
9616 unformat_input_t *i = vam->input;
9617 vl_api_create_vhost_user_if_t *mp;
9621 u8 file_name_set = 0;
9622 u32 custom_dev_instance = ~0;
9624 u8 use_custom_mac = 0;
9626 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9628 if (unformat (i, "socket %s", &file_name))
9632 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
9634 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
9636 else if (unformat (i, "server"))
9642 if (file_name_set == 0)
9644 errmsg ("missing socket file name\n");
9648 if (vec_len (file_name) > 255)
9650 errmsg ("socket file name too long\n");
9653 vec_add1 (file_name, 0);
9655 M (CREATE_VHOST_USER_IF, create_vhost_user_if);
9657 mp->is_server = is_server;
9658 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
9659 vec_free (file_name);
9660 if (custom_dev_instance != ~0)
9663 mp->custom_dev_instance = ntohl (custom_dev_instance);
9665 mp->use_custom_mac = use_custom_mac;
9666 clib_memcpy (mp->mac_address, hwaddr, 6);
9675 api_modify_vhost_user_if (vat_main_t * vam)
9677 unformat_input_t *i = vam->input;
9678 vl_api_modify_vhost_user_if_t *mp;
9682 u8 file_name_set = 0;
9683 u32 custom_dev_instance = ~0;
9684 u8 sw_if_index_set = 0;
9685 u32 sw_if_index = (u32) ~ 0;
9687 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9689 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9690 sw_if_index_set = 1;
9691 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9692 sw_if_index_set = 1;
9693 else if (unformat (i, "socket %s", &file_name))
9697 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
9699 else if (unformat (i, "server"))
9705 if (sw_if_index_set == 0)
9707 errmsg ("missing sw_if_index or interface name\n");
9711 if (file_name_set == 0)
9713 errmsg ("missing socket file name\n");
9717 if (vec_len (file_name) > 255)
9719 errmsg ("socket file name too long\n");
9722 vec_add1 (file_name, 0);
9724 M (MODIFY_VHOST_USER_IF, modify_vhost_user_if);
9726 mp->sw_if_index = ntohl (sw_if_index);
9727 mp->is_server = is_server;
9728 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
9729 vec_free (file_name);
9730 if (custom_dev_instance != ~0)
9733 mp->custom_dev_instance = ntohl (custom_dev_instance);
9743 api_delete_vhost_user_if (vat_main_t * vam)
9745 unformat_input_t *i = vam->input;
9746 vl_api_delete_vhost_user_if_t *mp;
9748 u32 sw_if_index = ~0;
9749 u8 sw_if_index_set = 0;
9751 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9753 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9754 sw_if_index_set = 1;
9755 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9756 sw_if_index_set = 1;
9761 if (sw_if_index_set == 0)
9763 errmsg ("missing sw_if_index or interface name\n");
9768 M (DELETE_VHOST_USER_IF, delete_vhost_user_if);
9770 mp->sw_if_index = ntohl (sw_if_index);
9778 static void vl_api_sw_interface_vhost_user_details_t_handler
9779 (vl_api_sw_interface_vhost_user_details_t * mp)
9781 vat_main_t *vam = &vat_main;
9783 fformat (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s\n",
9784 (char *) mp->interface_name,
9785 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
9786 clib_net_to_host_u64 (mp->features), mp->is_server,
9787 ntohl (mp->num_regions), (char *) mp->sock_filename);
9788 fformat (vam->ofp, " Status: '%s'\n", strerror (ntohl (mp->sock_errno)));
9791 static void vl_api_sw_interface_vhost_user_details_t_handler_json
9792 (vl_api_sw_interface_vhost_user_details_t * mp)
9794 vat_main_t *vam = &vat_main;
9795 vat_json_node_t *node = NULL;
9797 if (VAT_JSON_ARRAY != vam->json_tree.type)
9799 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9800 vat_json_init_array (&vam->json_tree);
9802 node = vat_json_array_add (&vam->json_tree);
9804 vat_json_init_object (node);
9805 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9806 vat_json_object_add_string_copy (node, "interface_name",
9807 mp->interface_name);
9808 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
9809 ntohl (mp->virtio_net_hdr_sz));
9810 vat_json_object_add_uint (node, "features",
9811 clib_net_to_host_u64 (mp->features));
9812 vat_json_object_add_uint (node, "is_server", mp->is_server);
9813 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
9814 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
9815 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
9819 api_sw_interface_vhost_user_dump (vat_main_t * vam)
9821 vl_api_sw_interface_vhost_user_dump_t *mp;
9824 "Interface name idx hdr_sz features server regions filename\n");
9826 /* Get list of vhost-user interfaces */
9827 M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump);
9830 /* Use a control ping for synchronization */
9832 vl_api_control_ping_t *mp;
9833 M (CONTROL_PING, control_ping);
9840 api_show_version (vat_main_t * vam)
9842 vl_api_show_version_t *mp;
9845 M (SHOW_VERSION, show_version);
9855 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
9857 unformat_input_t *line_input = vam->input;
9858 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
9860 ip4_address_t local4, remote4;
9861 ip6_address_t local6, remote6;
9863 u8 ipv4_set = 0, ipv6_set = 0;
9866 u32 encap_vrf_id = 0;
9867 u32 decap_vrf_id = 0;
9872 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9874 if (unformat (line_input, "del"))
9876 else if (unformat (line_input, "local %U",
9877 unformat_ip4_address, &local4))
9882 else if (unformat (line_input, "remote %U",
9883 unformat_ip4_address, &remote4))
9888 else if (unformat (line_input, "local %U",
9889 unformat_ip6_address, &local6))
9894 else if (unformat (line_input, "remote %U",
9895 unformat_ip6_address, &remote6))
9900 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
9902 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
9904 else if (unformat (line_input, "vni %d", &vni))
9906 else if (unformat (line_input, "next-ip4"))
9908 else if (unformat (line_input, "next-ip6"))
9910 else if (unformat (line_input, "next-ethernet"))
9912 else if (unformat (line_input, "next-nsh"))
9916 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
9923 errmsg ("tunnel local address not specified\n");
9926 if (remote_set == 0)
9928 errmsg ("tunnel remote address not specified\n");
9931 if (ipv4_set && ipv6_set)
9933 errmsg ("both IPv4 and IPv6 addresses specified");
9939 errmsg ("vni not specified\n");
9943 M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel);
9948 clib_memcpy (&mp->local, &local6, sizeof (local6));
9949 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
9953 clib_memcpy (&mp->local, &local4, sizeof (local4));
9954 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
9957 mp->encap_vrf_id = ntohl (encap_vrf_id);
9958 mp->decap_vrf_id = ntohl (decap_vrf_id);
9959 mp->protocol = ntohl (protocol);
9960 mp->vni = ntohl (vni);
9961 mp->is_add = is_add;
9962 mp->is_ipv6 = ipv6_set;
9970 static void vl_api_vxlan_gpe_tunnel_details_t_handler
9971 (vl_api_vxlan_gpe_tunnel_details_t * mp)
9973 vat_main_t *vam = &vat_main;
9975 fformat (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d\n",
9976 ntohl (mp->sw_if_index),
9977 format_ip46_address, &(mp->local[0]),
9978 format_ip46_address, &(mp->remote[0]),
9980 ntohl (mp->protocol),
9981 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
9984 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
9985 (vl_api_vxlan_gpe_tunnel_details_t * mp)
9987 vat_main_t *vam = &vat_main;
9988 vat_json_node_t *node = NULL;
9990 struct in6_addr ip6;
9992 if (VAT_JSON_ARRAY != vam->json_tree.type)
9994 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9995 vat_json_init_array (&vam->json_tree);
9997 node = vat_json_array_add (&vam->json_tree);
9999 vat_json_init_object (node);
10000 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10003 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
10004 vat_json_object_add_ip6 (node, "local", ip6);
10005 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
10006 vat_json_object_add_ip6 (node, "remote", ip6);
10010 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
10011 vat_json_object_add_ip4 (node, "local", ip4);
10012 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
10013 vat_json_object_add_ip4 (node, "remote", ip4);
10015 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10016 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
10017 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10018 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
10019 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10023 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
10025 unformat_input_t *i = vam->input;
10026 vl_api_vxlan_gpe_tunnel_dump_t *mp;
10029 u8 sw_if_index_set = 0;
10031 /* Parse args required to build the message */
10032 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10034 if (unformat (i, "sw_if_index %d", &sw_if_index))
10035 sw_if_index_set = 1;
10040 if (sw_if_index_set == 0)
10045 if (!vam->json_output)
10047 fformat (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s\n",
10048 "sw_if_index", "local", "remote", "vni",
10049 "protocol", "encap_vrf_id", "decap_vrf_id");
10052 /* Get list of vxlan-tunnel interfaces */
10053 M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump);
10055 mp->sw_if_index = htonl (sw_if_index);
10059 /* Use a control ping for synchronization */
10061 vl_api_control_ping_t *mp;
10062 M (CONTROL_PING, control_ping);
10069 format_l2_fib_mac_address (u8 * s, va_list * args)
10071 u8 *a = va_arg (*args, u8 *);
10073 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
10074 a[2], a[3], a[4], a[5], a[6], a[7]);
10077 static void vl_api_l2_fib_table_entry_t_handler
10078 (vl_api_l2_fib_table_entry_t * mp)
10080 vat_main_t *vam = &vat_main;
10082 fformat (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
10084 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
10085 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
10089 static void vl_api_l2_fib_table_entry_t_handler_json
10090 (vl_api_l2_fib_table_entry_t * mp)
10092 vat_main_t *vam = &vat_main;
10093 vat_json_node_t *node = NULL;
10095 if (VAT_JSON_ARRAY != vam->json_tree.type)
10097 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10098 vat_json_init_array (&vam->json_tree);
10100 node = vat_json_array_add (&vam->json_tree);
10102 vat_json_init_object (node);
10103 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
10104 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
10105 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10106 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
10107 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
10108 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
10112 api_l2_fib_table_dump (vat_main_t * vam)
10114 unformat_input_t *i = vam->input;
10115 vl_api_l2_fib_table_dump_t *mp;
10120 /* Parse args required to build the message */
10121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10123 if (unformat (i, "bd_id %d", &bd_id))
10129 if (bd_id_set == 0)
10131 errmsg ("missing bridge domain\n");
10136 "BD-ID Mac Address sw-ndx Static Filter BVI\n");
10138 /* Get list of l2 fib entries */
10139 M (L2_FIB_TABLE_DUMP, l2_fib_table_dump);
10141 mp->bd_id = ntohl (bd_id);
10144 /* Use a control ping for synchronization */
10146 vl_api_control_ping_t *mp;
10147 M (CONTROL_PING, control_ping);
10155 api_interface_name_renumber (vat_main_t * vam)
10157 unformat_input_t *line_input = vam->input;
10158 vl_api_interface_name_renumber_t *mp;
10159 u32 sw_if_index = ~0;
10161 u32 new_show_dev_instance = ~0;
10163 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10165 if (unformat (line_input, "%U", unformat_sw_if_index, vam,
10168 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
10170 else if (unformat (line_input, "new_show_dev_instance %d",
10171 &new_show_dev_instance))
10177 if (sw_if_index == ~0)
10179 errmsg ("missing interface name or sw_if_index\n");
10183 if (new_show_dev_instance == ~0)
10185 errmsg ("missing new_show_dev_instance\n");
10189 M (INTERFACE_NAME_RENUMBER, interface_name_renumber);
10191 mp->sw_if_index = ntohl (sw_if_index);
10192 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
10199 api_want_ip4_arp_events (vat_main_t * vam)
10201 unformat_input_t *line_input = vam->input;
10202 vl_api_want_ip4_arp_events_t *mp;
10204 ip4_address_t address;
10205 int address_set = 0;
10206 u32 enable_disable = 1;
10208 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10210 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
10212 else if (unformat (line_input, "del"))
10213 enable_disable = 0;
10218 if (address_set == 0)
10220 errmsg ("missing addresses\n");
10224 M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events);
10225 mp->enable_disable = enable_disable;
10226 mp->pid = getpid ();
10227 mp->address = address.as_u32;
10234 api_want_ip6_nd_events (vat_main_t * vam)
10236 unformat_input_t *line_input = vam->input;
10237 vl_api_want_ip6_nd_events_t *mp;
10239 ip6_address_t address;
10240 int address_set = 0;
10241 u32 enable_disable = 1;
10243 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10245 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
10247 else if (unformat (line_input, "del"))
10248 enable_disable = 0;
10253 if (address_set == 0)
10255 errmsg ("missing addresses\n");
10259 M (WANT_IP6_ND_EVENTS, want_ip6_nd_events);
10260 mp->enable_disable = enable_disable;
10261 mp->pid = getpid ();
10262 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
10269 api_input_acl_set_interface (vat_main_t * vam)
10271 unformat_input_t *i = vam->input;
10272 vl_api_input_acl_set_interface_t *mp;
10275 int sw_if_index_set;
10276 u32 ip4_table_index = ~0;
10277 u32 ip6_table_index = ~0;
10278 u32 l2_table_index = ~0;
10281 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10283 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10284 sw_if_index_set = 1;
10285 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10286 sw_if_index_set = 1;
10287 else if (unformat (i, "del"))
10289 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10291 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10293 else if (unformat (i, "l2-table %d", &l2_table_index))
10297 clib_warning ("parse error '%U'", format_unformat_error, i);
10302 if (sw_if_index_set == 0)
10304 errmsg ("missing interface name or sw_if_index\n");
10308 M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface);
10310 mp->sw_if_index = ntohl (sw_if_index);
10311 mp->ip4_table_index = ntohl (ip4_table_index);
10312 mp->ip6_table_index = ntohl (ip6_table_index);
10313 mp->l2_table_index = ntohl (l2_table_index);
10314 mp->is_add = is_add;
10323 api_ip_address_dump (vat_main_t * vam)
10325 unformat_input_t *i = vam->input;
10326 vl_api_ip_address_dump_t *mp;
10327 u32 sw_if_index = ~0;
10328 u8 sw_if_index_set = 0;
10333 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10335 if (unformat (i, "sw_if_index %d", &sw_if_index))
10336 sw_if_index_set = 1;
10337 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10338 sw_if_index_set = 1;
10339 else if (unformat (i, "ipv4"))
10341 else if (unformat (i, "ipv6"))
10347 if (ipv4_set && ipv6_set)
10349 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
10353 if ((!ipv4_set) && (!ipv6_set))
10355 errmsg ("no ipv4 nor ipv6 flag set\n");
10359 if (sw_if_index_set == 0)
10361 errmsg ("missing interface name or sw_if_index\n");
10365 vam->current_sw_if_index = sw_if_index;
10366 vam->is_ipv6 = ipv6_set;
10368 M (IP_ADDRESS_DUMP, ip_address_dump);
10369 mp->sw_if_index = ntohl (sw_if_index);
10370 mp->is_ipv6 = ipv6_set;
10373 /* Use a control ping for synchronization */
10375 vl_api_control_ping_t *mp;
10376 M (CONTROL_PING, control_ping);
10383 api_ip_dump (vat_main_t * vam)
10385 vl_api_ip_dump_t *mp;
10386 unformat_input_t *in = vam->input;
10393 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
10395 if (unformat (in, "ipv4"))
10397 else if (unformat (in, "ipv6"))
10403 if (ipv4_set && ipv6_set)
10405 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
10409 if ((!ipv4_set) && (!ipv6_set))
10411 errmsg ("no ipv4 nor ipv6 flag set\n");
10415 is_ipv6 = ipv6_set;
10416 vam->is_ipv6 = is_ipv6;
10418 /* free old data */
10419 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
10421 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
10423 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
10425 M (IP_DUMP, ip_dump);
10426 mp->is_ipv6 = ipv6_set;
10429 /* Use a control ping for synchronization */
10431 vl_api_control_ping_t *mp;
10432 M (CONTROL_PING, control_ping);
10439 api_ipsec_spd_add_del (vat_main_t * vam)
10442 unformat_input_t *i = vam->input;
10443 vl_api_ipsec_spd_add_del_t *mp;
10448 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10450 if (unformat (i, "spd_id %d", &spd_id))
10452 else if (unformat (i, "del"))
10456 clib_warning ("parse error '%U'", format_unformat_error, i);
10462 errmsg ("spd_id must be set\n");
10466 M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del);
10468 mp->spd_id = ntohl (spd_id);
10469 mp->is_add = is_add;
10476 clib_warning ("unsupported (no dpdk)");
10482 api_ipsec_interface_add_del_spd (vat_main_t * vam)
10485 unformat_input_t *i = vam->input;
10486 vl_api_ipsec_interface_add_del_spd_t *mp;
10489 u8 sw_if_index_set = 0;
10490 u32 spd_id = (u32) ~ 0;
10493 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10495 if (unformat (i, "del"))
10497 else if (unformat (i, "spd_id %d", &spd_id))
10499 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10500 sw_if_index_set = 1;
10501 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10502 sw_if_index_set = 1;
10505 clib_warning ("parse error '%U'", format_unformat_error, i);
10511 if (spd_id == (u32) ~ 0)
10513 errmsg ("spd_id must be set\n");
10517 if (sw_if_index_set == 0)
10519 errmsg ("missing interface name or sw_if_index\n");
10523 M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd);
10525 mp->spd_id = ntohl (spd_id);
10526 mp->sw_if_index = ntohl (sw_if_index);
10527 mp->is_add = is_add;
10534 clib_warning ("unsupported (no dpdk)");
10540 api_ipsec_spd_add_del_entry (vat_main_t * vam)
10543 unformat_input_t *i = vam->input;
10544 vl_api_ipsec_spd_add_del_entry_t *mp;
10546 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
10547 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
10549 u32 rport_start = 0, rport_stop = (u32) ~ 0;
10550 u32 lport_start = 0, lport_stop = (u32) ~ 0;
10551 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
10552 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
10554 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
10555 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
10556 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
10557 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
10558 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
10559 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
10561 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10563 if (unformat (i, "del"))
10565 if (unformat (i, "outbound"))
10567 if (unformat (i, "inbound"))
10569 else if (unformat (i, "spd_id %d", &spd_id))
10571 else if (unformat (i, "sa_id %d", &sa_id))
10573 else if (unformat (i, "priority %d", &priority))
10575 else if (unformat (i, "protocol %d", &protocol))
10577 else if (unformat (i, "lport_start %d", &lport_start))
10579 else if (unformat (i, "lport_stop %d", &lport_stop))
10581 else if (unformat (i, "rport_start %d", &rport_start))
10583 else if (unformat (i, "rport_stop %d", &rport_stop))
10587 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
10593 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
10600 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
10606 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
10613 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
10619 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
10626 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
10632 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
10638 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
10640 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
10642 clib_warning ("unsupported action: 'resolve'");
10648 clib_warning ("parse error '%U'", format_unformat_error, i);
10654 M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry);
10656 mp->spd_id = ntohl (spd_id);
10657 mp->priority = ntohl (priority);
10658 mp->is_outbound = is_outbound;
10660 mp->is_ipv6 = is_ipv6;
10661 if (is_ipv6 || is_ip_any)
10663 clib_memcpy (mp->remote_address_start, &raddr6_start,
10664 sizeof (ip6_address_t));
10665 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
10666 sizeof (ip6_address_t));
10667 clib_memcpy (mp->local_address_start, &laddr6_start,
10668 sizeof (ip6_address_t));
10669 clib_memcpy (mp->local_address_stop, &laddr6_stop,
10670 sizeof (ip6_address_t));
10674 clib_memcpy (mp->remote_address_start, &raddr4_start,
10675 sizeof (ip4_address_t));
10676 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
10677 sizeof (ip4_address_t));
10678 clib_memcpy (mp->local_address_start, &laddr4_start,
10679 sizeof (ip4_address_t));
10680 clib_memcpy (mp->local_address_stop, &laddr4_stop,
10681 sizeof (ip4_address_t));
10683 mp->protocol = (u8) protocol;
10684 mp->local_port_start = ntohs ((u16) lport_start);
10685 mp->local_port_stop = ntohs ((u16) lport_stop);
10686 mp->remote_port_start = ntohs ((u16) rport_start);
10687 mp->remote_port_stop = ntohs ((u16) rport_stop);
10688 mp->policy = (u8) policy;
10689 mp->sa_id = ntohl (sa_id);
10690 mp->is_add = is_add;
10691 mp->is_ip_any = is_ip_any;
10697 clib_warning ("unsupported (no dpdk)");
10703 api_ipsec_sad_add_del_entry (vat_main_t * vam)
10706 unformat_input_t *i = vam->input;
10707 vl_api_ipsec_sad_add_del_entry_t *mp;
10709 u32 sad_id = 0, spi = 0;
10710 u8 *ck = 0, *ik = 0;
10713 u8 protocol = IPSEC_PROTOCOL_AH;
10714 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
10715 u32 crypto_alg = 0, integ_alg = 0;
10716 ip4_address_t tun_src4;
10717 ip4_address_t tun_dst4;
10718 ip6_address_t tun_src6;
10719 ip6_address_t tun_dst6;
10721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10723 if (unformat (i, "del"))
10725 else if (unformat (i, "sad_id %d", &sad_id))
10727 else if (unformat (i, "spi %d", &spi))
10729 else if (unformat (i, "esp"))
10730 protocol = IPSEC_PROTOCOL_ESP;
10731 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
10734 is_tunnel_ipv6 = 0;
10736 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
10739 is_tunnel_ipv6 = 0;
10741 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
10744 is_tunnel_ipv6 = 1;
10746 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
10749 is_tunnel_ipv6 = 1;
10753 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
10755 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
10756 crypto_alg > IPSEC_INTEG_ALG_SHA_512_256)
10758 clib_warning ("unsupported crypto-alg: '%U'",
10759 format_ipsec_crypto_alg, crypto_alg);
10763 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
10767 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
10769 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
10770 integ_alg > IPSEC_INTEG_ALG_SHA_512_256)
10772 clib_warning ("unsupported integ-alg: '%U'",
10773 format_ipsec_integ_alg, integ_alg);
10777 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
10781 clib_warning ("parse error '%U'", format_unformat_error, i);
10787 M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
10789 mp->sad_id = ntohl (sad_id);
10790 mp->is_add = is_add;
10791 mp->protocol = protocol;
10792 mp->spi = ntohl (spi);
10793 mp->is_tunnel = is_tunnel;
10794 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
10795 mp->crypto_algorithm = crypto_alg;
10796 mp->integrity_algorithm = integ_alg;
10797 mp->crypto_key_length = vec_len (ck);
10798 mp->integrity_key_length = vec_len (ik);
10800 if (mp->crypto_key_length > sizeof (mp->crypto_key))
10801 mp->crypto_key_length = sizeof (mp->crypto_key);
10803 if (mp->integrity_key_length > sizeof (mp->integrity_key))
10804 mp->integrity_key_length = sizeof (mp->integrity_key);
10807 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
10809 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
10813 if (is_tunnel_ipv6)
10815 clib_memcpy (mp->tunnel_src_address, &tun_src6,
10816 sizeof (ip6_address_t));
10817 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
10818 sizeof (ip6_address_t));
10822 clib_memcpy (mp->tunnel_src_address, &tun_src4,
10823 sizeof (ip4_address_t));
10824 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
10825 sizeof (ip4_address_t));
10834 clib_warning ("unsupported (no dpdk)");
10840 api_ipsec_sa_set_key (vat_main_t * vam)
10843 unformat_input_t *i = vam->input;
10844 vl_api_ipsec_sa_set_key_t *mp;
10847 u8 *ck = 0, *ik = 0;
10849 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10851 if (unformat (i, "sa_id %d", &sa_id))
10853 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
10855 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
10859 clib_warning ("parse error '%U'", format_unformat_error, i);
10864 M (IPSEC_SA_SET_KEY, ipsec_set_sa_key);
10866 mp->sa_id = ntohl (sa_id);
10867 mp->crypto_key_length = vec_len (ck);
10868 mp->integrity_key_length = vec_len (ik);
10870 if (mp->crypto_key_length > sizeof (mp->crypto_key))
10871 mp->crypto_key_length = sizeof (mp->crypto_key);
10873 if (mp->integrity_key_length > sizeof (mp->integrity_key))
10874 mp->integrity_key_length = sizeof (mp->integrity_key);
10877 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
10879 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
10886 clib_warning ("unsupported (no dpdk)");
10892 api_ikev2_profile_add_del (vat_main_t * vam)
10895 unformat_input_t *i = vam->input;
10896 vl_api_ikev2_profile_add_del_t *mp;
10901 const char *valid_chars = "a-zA-Z0-9_";
10903 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10905 if (unformat (i, "del"))
10907 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
10908 vec_add1 (name, 0);
10911 errmsg ("parse error '%U'", format_unformat_error, i);
10916 if (!vec_len (name))
10918 errmsg ("profile name must be specified");
10922 if (vec_len (name) > 64)
10924 errmsg ("profile name too long");
10928 M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del);
10930 clib_memcpy (mp->name, name, vec_len (name));
10931 mp->is_add = is_add;
10939 clib_warning ("unsupported (no dpdk)");
10945 api_ikev2_profile_set_auth (vat_main_t * vam)
10948 unformat_input_t *i = vam->input;
10949 vl_api_ikev2_profile_set_auth_t *mp;
10953 u32 auth_method = 0;
10956 const char *valid_chars = "a-zA-Z0-9_";
10958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10960 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
10961 vec_add1 (name, 0);
10962 else if (unformat (i, "auth_method %U",
10963 unformat_ikev2_auth_method, &auth_method))
10965 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
10967 else if (unformat (i, "auth_data %v", &data))
10971 errmsg ("parse error '%U'", format_unformat_error, i);
10976 if (!vec_len (name))
10978 errmsg ("profile name must be specified");
10982 if (vec_len (name) > 64)
10984 errmsg ("profile name too long");
10988 if (!vec_len (data))
10990 errmsg ("auth_data must be specified");
10996 errmsg ("auth_method must be specified");
11000 M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth);
11002 mp->is_hex = is_hex;
11003 mp->auth_method = (u8) auth_method;
11004 mp->data_len = vec_len (data);
11005 clib_memcpy (mp->name, name, vec_len (name));
11006 clib_memcpy (mp->data, data, vec_len (data));
11015 clib_warning ("unsupported (no dpdk)");
11021 api_ikev2_profile_set_id (vat_main_t * vam)
11024 unformat_input_t *i = vam->input;
11025 vl_api_ikev2_profile_set_id_t *mp;
11033 const char *valid_chars = "a-zA-Z0-9_";
11035 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11037 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11038 vec_add1 (name, 0);
11039 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
11041 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
11043 data = vec_new (u8, 4);
11044 clib_memcpy (data, ip4.as_u8, 4);
11046 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
11048 else if (unformat (i, "id_data %v", &data))
11050 else if (unformat (i, "local"))
11052 else if (unformat (i, "remote"))
11056 errmsg ("parse error '%U'", format_unformat_error, i);
11061 if (!vec_len (name))
11063 errmsg ("profile name must be specified");
11067 if (vec_len (name) > 64)
11069 errmsg ("profile name too long");
11073 if (!vec_len (data))
11075 errmsg ("id_data must be specified");
11081 errmsg ("id_type must be specified");
11085 M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id);
11087 mp->is_local = is_local;
11088 mp->id_type = (u8) id_type;
11089 mp->data_len = vec_len (data);
11090 clib_memcpy (mp->name, name, vec_len (name));
11091 clib_memcpy (mp->data, data, vec_len (data));
11100 clib_warning ("unsupported (no dpdk)");
11106 api_ikev2_profile_set_ts (vat_main_t * vam)
11109 unformat_input_t *i = vam->input;
11110 vl_api_ikev2_profile_set_ts_t *mp;
11114 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
11115 ip4_address_t start_addr, end_addr;
11117 const char *valid_chars = "a-zA-Z0-9_";
11119 start_addr.as_u32 = 0;
11120 end_addr.as_u32 = (u32) ~ 0;
11122 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11124 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11125 vec_add1 (name, 0);
11126 else if (unformat (i, "protocol %d", &proto))
11128 else if (unformat (i, "start_port %d", &start_port))
11130 else if (unformat (i, "end_port %d", &end_port))
11133 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
11135 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
11137 else if (unformat (i, "local"))
11139 else if (unformat (i, "remote"))
11143 errmsg ("parse error '%U'", format_unformat_error, i);
11148 if (!vec_len (name))
11150 errmsg ("profile name must be specified");
11154 if (vec_len (name) > 64)
11156 errmsg ("profile name too long");
11160 M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts);
11162 mp->is_local = is_local;
11163 mp->proto = (u8) proto;
11164 mp->start_port = (u16) start_port;
11165 mp->end_port = (u16) end_port;
11166 mp->start_addr = start_addr.as_u32;
11167 mp->end_addr = end_addr.as_u32;
11168 clib_memcpy (mp->name, name, vec_len (name));
11176 clib_warning ("unsupported (no dpdk)");
11182 api_ikev2_set_local_key (vat_main_t * vam)
11185 unformat_input_t *i = vam->input;
11186 vl_api_ikev2_set_local_key_t *mp;
11190 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11192 if (unformat (i, "file %v", &file))
11193 vec_add1 (file, 0);
11196 errmsg ("parse error '%U'", format_unformat_error, i);
11201 if (!vec_len (file))
11203 errmsg ("RSA key file must be specified");
11207 if (vec_len (file) > 256)
11209 errmsg ("file name too long");
11213 M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key);
11215 clib_memcpy (mp->key_file, file, vec_len (file));
11223 clib_warning ("unsupported (no dpdk)");
11232 api_map_add_domain (vat_main_t * vam)
11234 unformat_input_t *i = vam->input;
11235 vl_api_map_add_domain_t *mp;
11238 ip4_address_t ip4_prefix;
11239 ip6_address_t ip6_prefix;
11240 ip6_address_t ip6_src;
11241 u32 num_m_args = 0;
11242 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
11243 0, psid_length = 0;
11244 u8 is_translation = 0;
11246 u32 ip6_src_len = 128;
11248 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11250 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
11251 &ip4_prefix, &ip4_prefix_len))
11253 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
11254 &ip6_prefix, &ip6_prefix_len))
11258 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
11261 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
11263 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
11265 else if (unformat (i, "psid-offset %d", &psid_offset))
11267 else if (unformat (i, "psid-len %d", &psid_length))
11269 else if (unformat (i, "mtu %d", &mtu))
11271 else if (unformat (i, "map-t"))
11272 is_translation = 1;
11275 clib_warning ("parse error '%U'", format_unformat_error, i);
11280 if (num_m_args < 3)
11282 errmsg ("mandatory argument(s) missing\n");
11286 /* Construct the API message */
11287 M (MAP_ADD_DOMAIN, map_add_domain);
11289 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
11290 mp->ip4_prefix_len = ip4_prefix_len;
11292 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
11293 mp->ip6_prefix_len = ip6_prefix_len;
11295 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
11296 mp->ip6_src_prefix_len = ip6_src_len;
11298 mp->ea_bits_len = ea_bits_len;
11299 mp->psid_offset = psid_offset;
11300 mp->psid_length = psid_length;
11301 mp->is_translation = is_translation;
11302 mp->mtu = htons (mtu);
11307 /* Wait for a reply, return good/bad news */
11312 api_map_del_domain (vat_main_t * vam)
11314 unformat_input_t *i = vam->input;
11315 vl_api_map_del_domain_t *mp;
11318 u32 num_m_args = 0;
11321 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11323 if (unformat (i, "index %d", &index))
11327 clib_warning ("parse error '%U'", format_unformat_error, i);
11332 if (num_m_args != 1)
11334 errmsg ("mandatory argument(s) missing\n");
11338 /* Construct the API message */
11339 M (MAP_DEL_DOMAIN, map_del_domain);
11341 mp->index = ntohl (index);
11346 /* Wait for a reply, return good/bad news */
11351 api_map_add_del_rule (vat_main_t * vam)
11353 unformat_input_t *i = vam->input;
11354 vl_api_map_add_del_rule_t *mp;
11357 ip6_address_t ip6_dst;
11358 u32 num_m_args = 0, index, psid = 0;
11360 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11362 if (unformat (i, "index %d", &index))
11364 else if (unformat (i, "psid %d", &psid))
11366 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
11368 else if (unformat (i, "del"))
11374 clib_warning ("parse error '%U'", format_unformat_error, i);
11379 /* Construct the API message */
11380 M (MAP_ADD_DEL_RULE, map_add_del_rule);
11382 mp->index = ntohl (index);
11383 mp->is_add = is_add;
11384 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
11385 mp->psid = ntohs (psid);
11390 /* Wait for a reply, return good/bad news */
11395 api_map_domain_dump (vat_main_t * vam)
11397 vl_api_map_domain_dump_t *mp;
11400 /* Construct the API message */
11401 M (MAP_DOMAIN_DUMP, map_domain_dump);
11406 /* Use a control ping for synchronization */
11408 vl_api_control_ping_t *mp;
11409 M (CONTROL_PING, control_ping);
11416 api_map_rule_dump (vat_main_t * vam)
11418 unformat_input_t *i = vam->input;
11419 vl_api_map_rule_dump_t *mp;
11421 u32 domain_index = ~0;
11423 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11425 if (unformat (i, "index %u", &domain_index))
11431 if (domain_index == ~0)
11433 clib_warning ("parse error: domain index expected");
11437 /* Construct the API message */
11438 M (MAP_RULE_DUMP, map_rule_dump);
11440 mp->domain_index = htonl (domain_index);
11445 /* Use a control ping for synchronization */
11447 vl_api_control_ping_t *mp;
11448 M (CONTROL_PING, control_ping);
11454 static void vl_api_map_add_domain_reply_t_handler
11455 (vl_api_map_add_domain_reply_t * mp)
11457 vat_main_t *vam = &vat_main;
11458 i32 retval = ntohl (mp->retval);
11460 if (vam->async_mode)
11462 vam->async_errors += (retval < 0);
11466 vam->retval = retval;
11467 vam->result_ready = 1;
11471 static void vl_api_map_add_domain_reply_t_handler_json
11472 (vl_api_map_add_domain_reply_t * mp)
11474 vat_main_t *vam = &vat_main;
11475 vat_json_node_t node;
11477 vat_json_init_object (&node);
11478 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
11479 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
11481 vat_json_print (vam->ofp, &node);
11482 vat_json_free (&node);
11484 vam->retval = ntohl (mp->retval);
11485 vam->result_ready = 1;
11489 api_get_first_msg_id (vat_main_t * vam)
11491 vl_api_get_first_msg_id_t *mp;
11493 unformat_input_t *i = vam->input;
11497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11499 if (unformat (i, "client %s", &name))
11507 errmsg ("missing client name\n");
11510 vec_add1 (name, 0);
11512 if (vec_len (name) > 63)
11514 errmsg ("client name too long\n");
11518 M (GET_FIRST_MSG_ID, get_first_msg_id);
11519 clib_memcpy (mp->name, name, vec_len (name));
11527 api_cop_interface_enable_disable (vat_main_t * vam)
11529 unformat_input_t *line_input = vam->input;
11530 vl_api_cop_interface_enable_disable_t *mp;
11532 u32 sw_if_index = ~0;
11533 u8 enable_disable = 1;
11535 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11537 if (unformat (line_input, "disable"))
11538 enable_disable = 0;
11539 if (unformat (line_input, "enable"))
11540 enable_disable = 1;
11541 else if (unformat (line_input, "%U", unformat_sw_if_index,
11542 vam, &sw_if_index))
11544 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11550 if (sw_if_index == ~0)
11552 errmsg ("missing interface name or sw_if_index\n");
11556 /* Construct the API message */
11557 M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable);
11558 mp->sw_if_index = ntohl (sw_if_index);
11559 mp->enable_disable = enable_disable;
11563 /* Wait for the reply */
11568 api_cop_whitelist_enable_disable (vat_main_t * vam)
11570 unformat_input_t *line_input = vam->input;
11571 vl_api_cop_whitelist_enable_disable_t *mp;
11573 u32 sw_if_index = ~0;
11574 u8 ip4 = 0, ip6 = 0, default_cop = 0;
11577 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11579 if (unformat (line_input, "ip4"))
11581 else if (unformat (line_input, "ip6"))
11583 else if (unformat (line_input, "default"))
11585 else if (unformat (line_input, "%U", unformat_sw_if_index,
11586 vam, &sw_if_index))
11588 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11590 else if (unformat (line_input, "fib-id %d", &fib_id))
11596 if (sw_if_index == ~0)
11598 errmsg ("missing interface name or sw_if_index\n");
11602 /* Construct the API message */
11603 M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable);
11604 mp->sw_if_index = ntohl (sw_if_index);
11605 mp->fib_id = ntohl (fib_id);
11608 mp->default_cop = default_cop;
11612 /* Wait for the reply */
11617 api_get_node_graph (vat_main_t * vam)
11619 vl_api_get_node_graph_t *mp;
11622 M (GET_NODE_GRAPH, get_node_graph);
11626 /* Wait for the reply */
11631 /** Used for parsing LISP eids */
11632 typedef CLIB_PACKED(struct{
11633 u8 addr[16]; /**< eid address */
11634 u32 len; /**< prefix length if IP */
11635 u8 type; /**< type of eid */
11640 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
11642 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
11644 memset (a, 0, sizeof (a[0]));
11646 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
11648 a->type = 0; /* ipv4 type */
11650 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
11652 a->type = 1; /* ipv6 type */
11654 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
11656 a->type = 2; /* mac type */
11663 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
11672 lisp_eid_size_vat (u8 type)
11687 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
11689 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
11693 /** Used for transferring locators via VPP API */
11694 typedef CLIB_PACKED(struct
11696 u32 sw_if_index; /**< locator sw_if_index */
11697 u8 priority; /**< locator priority */
11698 u8 weight; /**< locator weight */
11703 api_lisp_add_del_locator_set (vat_main_t * vam)
11705 unformat_input_t *input = vam->input;
11706 vl_api_lisp_add_del_locator_set_t *mp;
11709 u8 *locator_set_name = NULL;
11710 u8 locator_set_name_set = 0;
11711 ls_locator_t locator, *locators = 0;
11712 u32 sw_if_index, priority, weight;
11714 /* Parse args required to build the message */
11715 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11717 if (unformat (input, "del"))
11721 else if (unformat (input, "locator-set %s", &locator_set_name))
11723 locator_set_name_set = 1;
11725 else if (unformat (input, "sw_if_index %u p %u w %u",
11726 &sw_if_index, &priority, &weight))
11728 locator.sw_if_index = htonl (sw_if_index);
11729 locator.priority = priority;
11730 locator.weight = weight;
11731 vec_add1 (locators, locator);
11733 else if (unformat (input, "iface %U p %u w %u", unformat_sw_if_index,
11734 vam, &sw_if_index, &priority, &weight))
11736 locator.sw_if_index = htonl (sw_if_index);
11737 locator.priority = priority;
11738 locator.weight = weight;
11739 vec_add1 (locators, locator);
11745 if (locator_set_name_set == 0)
11747 errmsg ("missing locator-set name");
11748 vec_free (locators);
11752 if (vec_len (locator_set_name) > 64)
11754 errmsg ("locator-set name too long\n");
11755 vec_free (locator_set_name);
11756 vec_free (locators);
11759 vec_add1 (locator_set_name, 0);
11761 /* Construct the API message */
11762 M (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set);
11764 mp->is_add = is_add;
11765 clib_memcpy (mp->locator_set_name, locator_set_name,
11766 vec_len (locator_set_name));
11767 vec_free (locator_set_name);
11769 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
11771 clib_memcpy (mp->locators, locators,
11772 (sizeof (ls_locator_t) * vec_len (locators)));
11773 vec_free (locators);
11778 /* Wait for a reply... */
11786 api_lisp_add_del_locator (vat_main_t * vam)
11788 unformat_input_t *input = vam->input;
11789 vl_api_lisp_add_del_locator_t *mp;
11791 u32 tmp_if_index = ~0;
11792 u32 sw_if_index = ~0;
11793 u8 sw_if_index_set = 0;
11794 u8 sw_if_index_if_name_set = 0;
11796 u8 priority_set = 0;
11800 u8 *locator_set_name = NULL;
11801 u8 locator_set_name_set = 0;
11803 /* Parse args required to build the message */
11804 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11806 if (unformat (input, "del"))
11810 else if (unformat (input, "locator-set %s", &locator_set_name))
11812 locator_set_name_set = 1;
11814 else if (unformat (input, "iface %U", unformat_sw_if_index, vam,
11817 sw_if_index_if_name_set = 1;
11818 sw_if_index = tmp_if_index;
11820 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
11822 sw_if_index_set = 1;
11823 sw_if_index = tmp_if_index;
11825 else if (unformat (input, "p %d", &priority))
11829 else if (unformat (input, "w %d", &weight))
11837 if (locator_set_name_set == 0)
11839 errmsg ("missing locator-set name");
11843 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
11845 errmsg ("missing sw_if_index");
11846 vec_free (locator_set_name);
11850 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
11852 errmsg ("cannot use both params interface name and sw_if_index");
11853 vec_free (locator_set_name);
11857 if (priority_set == 0)
11859 errmsg ("missing locator-set priority\n");
11860 vec_free (locator_set_name);
11864 if (weight_set == 0)
11866 errmsg ("missing locator-set weight\n");
11867 vec_free (locator_set_name);
11871 if (vec_len (locator_set_name) > 64)
11873 errmsg ("locator-set name too long\n");
11874 vec_free (locator_set_name);
11877 vec_add1 (locator_set_name, 0);
11879 /* Construct the API message */
11880 M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
11882 mp->is_add = is_add;
11883 mp->sw_if_index = ntohl (sw_if_index);
11884 mp->priority = priority;
11885 mp->weight = weight;
11886 clib_memcpy (mp->locator_set_name, locator_set_name,
11887 vec_len (locator_set_name));
11888 vec_free (locator_set_name);
11893 /* Wait for a reply... */
11901 api_lisp_add_del_local_eid (vat_main_t * vam)
11903 unformat_input_t *input = vam->input;
11904 vl_api_lisp_add_del_local_eid_t *mp;
11908 lisp_eid_vat_t _eid, *eid = &_eid;
11909 u8 *locator_set_name = 0;
11910 u8 locator_set_name_set = 0;
11913 /* Parse args required to build the message */
11914 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11916 if (unformat (input, "del"))
11920 else if (unformat (input, "vni %d", &vni))
11924 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
11928 else if (unformat (input, "locator-set %s", &locator_set_name))
11930 locator_set_name_set = 1;
11936 if (locator_set_name_set == 0)
11938 errmsg ("missing locator-set name\n");
11944 errmsg ("EID address not set!");
11945 vec_free (locator_set_name);
11949 if (vec_len (locator_set_name) > 64)
11951 errmsg ("locator-set name too long\n");
11952 vec_free (locator_set_name);
11955 vec_add1 (locator_set_name, 0);
11957 /* Construct the API message */
11958 M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
11960 mp->is_add = is_add;
11961 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
11962 mp->eid_type = eid->type;
11963 mp->prefix_len = eid->len;
11964 mp->vni = clib_host_to_net_u32 (vni);
11965 clib_memcpy (mp->locator_set_name, locator_set_name,
11966 vec_len (locator_set_name));
11968 vec_free (locator_set_name);
11973 /* Wait for a reply... */
11981 /** Used for transferring locators via VPP API */
11982 typedef CLIB_PACKED(struct
11984 u8 is_ip4; /**< is locator an IPv4 address? */
11985 u8 priority; /**< locator priority */
11986 u8 weight; /**< locator weight */
11987 u8 addr[16]; /**< IPv4/IPv6 address */
11992 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
11994 unformat_input_t *input = vam->input;
11995 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
11998 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
11999 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
12000 u8 rmt_eid_set = 0, lcl_eid_set = 0;
12001 u32 action = ~0, p, w;
12002 ip4_address_t rmt_rloc4, lcl_rloc4;
12003 ip6_address_t rmt_rloc6, lcl_rloc6;
12004 rloc_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
12006 memset (&rloc, 0, sizeof (rloc));
12008 /* Parse args required to build the message */
12009 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12011 if (unformat (input, "del"))
12015 else if (unformat (input, "rmt_eid %U", unformat_lisp_eid_vat, rmt_eid))
12019 else if (unformat (input, "lcl_eid %U", unformat_lisp_eid_vat, lcl_eid))
12023 else if (unformat (input, "p %d w %d", &p, &w))
12027 errmsg ("No RLOC configured for setting priority/weight!");
12030 curr_rloc->priority = p;
12031 curr_rloc->weight = w;
12033 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
12034 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
12038 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
12039 rloc.priority = rloc.weight = 0;
12040 vec_add1 (lcl_locs, rloc);
12042 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
12043 vec_add1 (rmt_locs, rloc);
12044 /* priority and weight saved in rmt loc */
12045 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
12047 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
12048 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
12051 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
12052 rloc.priority = rloc.weight = 0;
12053 vec_add1 (lcl_locs, rloc);
12055 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
12056 vec_add1 (rmt_locs, rloc);
12057 /* priority and weight saved in rmt loc */
12058 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
12060 else if (unformat (input, "action %d", &action))
12066 clib_warning ("parse error '%U'", format_unformat_error, input);
12073 errmsg ("remote eid addresses not set\n");
12077 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
12079 errmsg ("eid types don't match\n");
12083 if (0 == rmt_locs && (u32) ~ 0 == action)
12085 errmsg ("action not set for negative mapping\n");
12089 /* Construct the API message */
12090 M (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry);
12092 mp->is_add = is_add;
12093 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
12094 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
12095 mp->eid_type = rmt_eid->type;
12096 mp->rmt_len = rmt_eid->len;
12097 mp->lcl_len = lcl_eid->len;
12098 mp->action = action;
12100 if (0 != rmt_locs && 0 != lcl_locs)
12102 mp->loc_num = vec_len (rmt_locs);
12103 clib_memcpy (mp->lcl_locs, lcl_locs,
12104 (sizeof (rloc_t) * vec_len (lcl_locs)));
12105 clib_memcpy (mp->rmt_locs, rmt_locs,
12106 (sizeof (rloc_t) * vec_len (rmt_locs)));
12108 vec_free (lcl_locs);
12109 vec_free (rmt_locs);
12114 /* Wait for a reply... */
12122 api_lisp_add_del_map_resolver (vat_main_t * vam)
12124 unformat_input_t *input = vam->input;
12125 vl_api_lisp_add_del_map_resolver_t *mp;
12130 ip4_address_t ipv4;
12131 ip6_address_t ipv6;
12133 /* Parse args required to build the message */
12134 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12136 if (unformat (input, "del"))
12140 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
12144 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
12152 if (ipv4_set && ipv6_set)
12154 errmsg ("both eid v4 and v6 addresses set\n");
12158 if (!ipv4_set && !ipv6_set)
12160 errmsg ("eid addresses not set\n");
12164 /* Construct the API message */
12165 M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
12167 mp->is_add = is_add;
12171 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
12176 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
12182 /* Wait for a reply... */
12190 api_lisp_gpe_enable_disable (vat_main_t * vam)
12192 unformat_input_t *input = vam->input;
12193 vl_api_lisp_gpe_enable_disable_t *mp;
12198 /* Parse args required to build the message */
12199 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12201 if (unformat (input, "enable"))
12206 else if (unformat (input, "disable"))
12217 errmsg ("Value not set\n");
12221 /* Construct the API message */
12222 M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
12229 /* Wait for a reply... */
12237 api_lisp_enable_disable (vat_main_t * vam)
12239 unformat_input_t *input = vam->input;
12240 vl_api_lisp_enable_disable_t *mp;
12245 /* Parse args required to build the message */
12246 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12248 if (unformat (input, "enable"))
12253 else if (unformat (input, "disable"))
12263 errmsg ("Value not set\n");
12267 /* Construct the API message */
12268 M (LISP_ENABLE_DISABLE, lisp_enable_disable);
12275 /* Wait for a reply... */
12283 * Enable/disable LISP proxy ITR.
12285 * @param vam vpp API test context
12286 * @return return code
12289 api_lisp_pitr_set_locator_set (vat_main_t * vam)
12292 u8 ls_name_set = 0;
12293 unformat_input_t *input = vam->input;
12294 vl_api_lisp_pitr_set_locator_set_t *mp;
12298 /* Parse args required to build the message */
12299 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12301 if (unformat (input, "del"))
12303 else if (unformat (input, "locator-set %s", &ls_name))
12307 errmsg ("parse error '%U'", format_unformat_error, input);
12314 errmsg ("locator-set name not set!");
12318 M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set);
12320 mp->is_add = is_add;
12321 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
12322 vec_free (ls_name);
12327 /* wait for reply */
12335 api_show_lisp_pitr (vat_main_t * vam)
12337 vl_api_show_lisp_pitr_t *mp;
12340 if (!vam->json_output)
12342 fformat (vam->ofp, "%=20s\n", "lisp status:");
12345 M (SHOW_LISP_PITR, show_lisp_pitr);
12349 /* Wait for a reply... */
12357 * Add/delete mapping between vni and vrf
12360 api_lisp_eid_table_add_del_map (vat_main_t * vam)
12363 unformat_input_t *input = vam->input;
12364 vl_api_lisp_eid_table_add_del_map_t *mp;
12365 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
12366 u32 vni, vrf, bd_index;
12368 /* Parse args required to build the message */
12369 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12371 if (unformat (input, "del"))
12373 else if (unformat (input, "vrf %d", &vrf))
12375 else if (unformat (input, "bd_index %d", &bd_index))
12377 else if (unformat (input, "vni %d", &vni))
12383 if (!vni_set || (!vrf_set && !bd_index_set))
12385 errmsg ("missing arguments!");
12389 if (vrf_set && bd_index_set)
12391 errmsg ("error: both vrf and bd entered!");
12395 M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
12397 mp->is_add = is_add;
12398 mp->vni = htonl (vni);
12399 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
12400 mp->is_l2 = bd_index_set;
12405 /* wait for reply */
12413 * Add/del remote mapping to/from LISP control plane
12415 * @param vam vpp API test context
12416 * @return return code
12419 api_lisp_add_del_remote_mapping (vat_main_t * vam)
12421 unformat_input_t *input = vam->input;
12422 vl_api_lisp_add_del_remote_mapping_t *mp;
12425 //TODO: seid need remove
12426 lisp_eid_vat_t _eid, *eid = &_eid;
12427 lisp_eid_vat_t _seid, *seid = &_seid;
12428 u8 is_add = 1, del_all = 0, eid_set = 0;
12429 u32 action = ~0, p, w;
12430 ip4_address_t rloc4;
12431 ip6_address_t rloc6;
12432 rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
12434 memset (&rloc, 0, sizeof (rloc));
12436 /* Parse args required to build the message */
12437 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12439 if (unformat (input, "del-all"))
12443 else if (unformat (input, "del"))
12447 else if (unformat (input, "add"))
12451 else if (unformat (input, "deid %U", unformat_lisp_eid_vat, eid))
12455 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, &seid))
12457 //TODO: Need remove, but first must be remove from CSIT test
12459 else if (unformat (input, "vni %d", &vni))
12463 else if (unformat (input, "p %d w %d", &p, &w))
12467 errmsg ("No RLOC configured for setting priority/weight!");
12470 curr_rloc->priority = p;
12471 curr_rloc->weight = w;
12473 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
12476 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
12477 vec_add1 (rlocs, rloc);
12478 curr_rloc = &rlocs[vec_len (rlocs) - 1];
12480 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
12483 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
12484 vec_add1 (rlocs, rloc);
12485 curr_rloc = &rlocs[vec_len (rlocs) - 1];
12487 else if (unformat (input, "action %d", &action))
12493 clib_warning ("parse error '%U'", format_unformat_error, input);
12500 errmsg ("missing params!");
12504 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
12506 errmsg ("no action set for negative map-reply!");
12510 M (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping);
12511 mp->is_add = is_add;
12512 mp->vni = htonl (vni);
12513 mp->action = (u8) action;
12514 mp->eid_len = eid->len;
12515 mp->del_all = del_all;
12516 mp->eid_type = eid->type;
12517 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
12519 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
12520 clib_memcpy (mp->rlocs, rlocs, (sizeof (rloc_t) * vec_len (rlocs)));
12526 /* Wait for a reply... */
12534 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
12535 * forwarding entries in data-plane accordingly.
12537 * @param vam vpp API test context
12538 * @return return code
12541 api_lisp_add_del_adjacency (vat_main_t * vam)
12543 unformat_input_t *input = vam->input;
12544 vl_api_lisp_add_del_adjacency_t *mp;
12547 ip4_address_t seid4, deid4;
12548 ip6_address_t seid6, deid6;
12549 u8 deid_mac[6] = { 0 };
12550 u8 seid_mac[6] = { 0 };
12551 u8 deid_type, seid_type;
12552 u32 seid_len = 0, deid_len = 0, len;
12555 seid_type = deid_type = (u8) ~ 0;
12557 /* Parse args required to build the message */
12558 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12560 if (unformat (input, "del"))
12564 else if (unformat (input, "add"))
12568 else if (unformat (input, "deid %U/%d", unformat_ip4_address,
12571 deid_type = 0; /* ipv4 */
12574 else if (unformat (input, "deid %U/%d", unformat_ip6_address,
12577 deid_type = 1; /* ipv6 */
12580 else if (unformat (input, "deid %U", unformat_ethernet_address,
12583 deid_type = 2; /* mac */
12585 else if (unformat (input, "seid %U/%d", unformat_ip4_address,
12588 seid_type = 0; /* ipv4 */
12591 else if (unformat (input, "seid %U/%d", unformat_ip6_address,
12594 seid_type = 1; /* ipv6 */
12597 else if (unformat (input, "seid %U", unformat_ethernet_address,
12600 seid_type = 2; /* mac */
12602 else if (unformat (input, "vni %d", &vni))
12608 errmsg ("parse error '%U'", format_unformat_error, input);
12613 if ((u8) ~ 0 == deid_type)
12615 errmsg ("missing params!");
12619 if (seid_type != deid_type)
12621 errmsg ("source and destination EIDs are of different types!");
12625 M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency);
12626 mp->is_add = is_add;
12627 mp->vni = htonl (vni);
12628 mp->seid_len = seid_len;
12629 mp->deid_len = deid_len;
12630 mp->eid_type = deid_type;
12632 switch (mp->eid_type)
12635 clib_memcpy (mp->seid, &seid4, sizeof (seid4));
12636 clib_memcpy (mp->deid, &deid4, sizeof (deid4));
12639 clib_memcpy (mp->seid, &seid6, sizeof (seid6));
12640 clib_memcpy (mp->deid, &deid6, sizeof (deid6));
12643 clib_memcpy (mp->seid, seid_mac, 6);
12644 clib_memcpy (mp->deid, deid_mac, 6);
12647 errmsg ("unknown EID type %d!", mp->eid_type);
12654 /* Wait for a reply... */
12662 api_lisp_gpe_add_del_iface (vat_main_t * vam)
12664 unformat_input_t *input = vam->input;
12665 vl_api_lisp_gpe_add_del_iface_t *mp;
12667 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
12668 u32 dp_table = 0, vni = 0;
12670 /* Parse args required to build the message */
12671 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12673 if (unformat (input, "up"))
12678 else if (unformat (input, "down"))
12683 else if (unformat (input, "table_id %d", &dp_table))
12687 else if (unformat (input, "bd_id %d", &dp_table))
12692 else if (unformat (input, "vni %d", &vni))
12700 if (action_set == 0)
12702 errmsg ("Action not set\n");
12705 if (dp_table_set == 0 || vni_set == 0)
12707 errmsg ("vni and dp_table must be set\n");
12711 /* Construct the API message */
12712 M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
12714 mp->is_add = is_add;
12715 mp->dp_table = dp_table;
12722 /* Wait for a reply... */
12730 * Add/del map request itr rlocs from LISP control plane and updates
12732 * @param vam vpp API test context
12733 * @return return code
12736 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
12738 unformat_input_t *input = vam->input;
12739 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
12741 u8 *locator_set_name = 0;
12742 u8 locator_set_name_set = 0;
12745 /* Parse args required to build the message */
12746 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12748 if (unformat (input, "del"))
12752 else if (unformat (input, "%_%v%_", &locator_set_name))
12754 locator_set_name_set = 1;
12758 clib_warning ("parse error '%U'", format_unformat_error, input);
12763 if (is_add && !locator_set_name_set)
12765 errmsg ("itr-rloc is not set!");
12769 if (is_add && vec_len (locator_set_name) > 64)
12771 errmsg ("itr-rloc locator-set name too long\n");
12772 vec_free (locator_set_name);
12776 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs);
12777 mp->is_add = is_add;
12780 clib_memcpy (mp->locator_set_name, locator_set_name,
12781 vec_len (locator_set_name));
12785 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
12787 vec_free (locator_set_name);
12792 /* Wait for a reply... */
12800 lisp_locator_dump_send_msg (vat_main_t * vam, u32 locator_set_index,
12803 vl_api_lisp_locator_dump_t *mp;
12806 M (LISP_LOCATOR_DUMP, lisp_locator_dump);
12808 mp->locator_set_index = htonl (locator_set_index);
12809 mp->filter = filter;
12814 /* Use a control ping for synchronization */
12816 vl_api_noprint_control_ping_t *mp;
12817 M (NOPRINT_CONTROL_PING, noprint_control_ping);
12820 /* Wait for a reply... */
12825 clean_locator_set_message (vat_main_t * vam)
12827 locator_set_msg_t *ls = 0;
12829 vec_foreach (ls, vam->locator_set_msg)
12831 vec_free (ls->locator_set_name);
12834 vec_free (vam->locator_set_msg);
12838 print_locator_in_locator_set (vat_main_t * vam, u8 filter)
12840 locator_set_msg_t *ls;
12841 locator_msg_t *loc;
12843 int i = 0, ret = 0;
12845 vec_foreach (ls, vam->locator_set_msg)
12847 ret = lisp_locator_dump_send_msg (vam, ls->locator_set_index, filter);
12850 vec_free (vam->locator_msg);
12851 clean_locator_set_message (vam);
12855 tmp_str = format (0, "%=20s%=16d%s", ls->locator_set_name,
12856 ls->locator_set_index,
12857 vec_len (vam->locator_msg) ? "" : "\n");
12859 vec_foreach (loc, vam->locator_msg)
12863 tmp_str = format (tmp_str, "%=37s", " ");
12867 tmp_str = format (tmp_str, "%=16d%=16d%=16d\n",
12868 loc->sw_if_index, loc->priority, loc->weight);
12872 tmp_str = format (tmp_str, "%=16U%=16d%=16d\n",
12873 loc->is_ipv6 ? format_ip6_address :
12874 format_ip4_address,
12875 loc->ip_address, loc->priority, loc->weight);
12880 fformat (vam->ofp, "%s", tmp_str);
12881 vec_free (tmp_str);
12882 vec_free (vam->locator_msg);
12885 clean_locator_set_message (vam);
12891 json_locator_in_locator_set (vat_main_t * vam, u8 filter)
12893 locator_set_msg_t *ls;
12894 locator_msg_t *loc;
12895 vat_json_node_t *node = NULL;
12896 vat_json_node_t *locator_array;
12897 vat_json_node_t *locator;
12898 struct in6_addr ip6;
12899 struct in_addr ip4;
12902 if (!vec_len (vam->locator_set_msg))
12904 /* just print [] */
12905 vat_json_init_array (&vam->json_tree);
12906 vat_json_print (vam->ofp, &vam->json_tree);
12907 vam->json_tree.type = VAT_JSON_NONE;
12911 if (VAT_JSON_ARRAY != vam->json_tree.type)
12913 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12914 vat_json_init_array (&vam->json_tree);
12917 vec_foreach (ls, vam->locator_set_msg)
12919 ret = lisp_locator_dump_send_msg (vam, ls->locator_set_index, filter);
12922 vec_free (ls->locator_set_name);
12923 vec_free (vam->locator_msg);
12924 vec_free (vam->locator_set_msg);
12925 vat_json_free (&vam->json_tree);
12926 vam->json_tree.type = VAT_JSON_NONE;
12930 node = vat_json_array_add (&vam->json_tree);
12931 vat_json_init_object (node);
12933 vat_json_object_add_uint (node, "locator-set-index",
12934 ls->locator_set_index);
12935 vat_json_object_add_string_copy (node, "locator-set",
12936 ls->locator_set_name);
12937 locator_array = vat_json_object_add_list (node, "locator");
12938 vec_foreach (loc, vam->locator_msg)
12940 locator = vat_json_array_add (locator_array);
12941 vat_json_init_object (locator);
12944 vat_json_object_add_uint (locator, "locator-index",
12951 clib_memcpy (&ip6, loc->ip_address, sizeof (ip6));
12952 vat_json_object_add_ip6 (locator, "locator", ip6);
12956 clib_memcpy (&ip4, loc->ip_address, sizeof (ip4));
12957 vat_json_object_add_ip4 (locator, "locator", ip4);
12960 vat_json_object_add_uint (locator, "priority", loc->priority);
12961 vat_json_object_add_uint (locator, "weight", loc->weight);
12964 vec_free (ls->locator_set_name);
12965 vec_free (vam->locator_msg);
12968 vat_json_print (vam->ofp, &vam->json_tree);
12969 vat_json_free (&vam->json_tree);
12970 vam->json_tree.type = VAT_JSON_NONE;
12972 vec_free (vam->locator_set_msg);
12978 get_locator_set_index_from_msg (vat_main_t * vam, u8 * locator_set,
12979 u32 * locator_set_index)
12981 locator_set_msg_t *ls;
12984 *locator_set_index = ~0;
12986 if (!vec_len (vam->locator_set_msg))
12991 vec_foreach (ls, vam->locator_set_msg)
12993 if (!strcmp ((char *) locator_set, (char *) ls->locator_set_name))
12995 *locator_set_index = ls->locator_set_index;
12996 vec_free (vam->locator_set_msg);
13001 vec_free (vam->locator_set_msg);
13007 get_locator_set_index (vat_main_t * vam, u8 * locator_set,
13008 u32 * locator_set_index)
13010 vl_api_lisp_locator_set_dump_t *mp;
13013 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
13017 /* Use a control ping for synchronization */
13019 vl_api_noprint_control_ping_t *mp;
13020 M (NOPRINT_CONTROL_PING, noprint_control_ping);
13024 vam->noprint_msg = 1;
13025 /* Wait for a reply... */
13029 get_locator_set_index_from_msg (vam, locator_set, locator_set_index);
13030 vam->noprint_msg = 0;
13039 lisp_locator_dump (vat_main_t * vam, u32 locator_set_index, u8 * locator_set,
13046 if (!vam->json_output)
13048 fformat (vam->ofp, "%=20s%=16s%=16s\n",
13049 "locator", "priority", "weight");
13054 ret = get_locator_set_index (vam, locator_set, &locator_set_index);
13057 if (!ret && ~0 == locator_set_index)
13062 ret = lisp_locator_dump_send_msg (vam, locator_set_index, filter);
13068 lisp_locator_set_dump (vat_main_t * vam, u8 filter)
13070 vl_api_lisp_locator_set_dump_t *mp;
13073 if (!vam->json_output)
13075 fformat (vam->ofp, "%=20s%=16s%=16s%=16s%=16s\n",
13076 "locator-set", "locator-set-index", "locator", "priority",
13080 vam->noprint_msg = 1;
13082 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
13084 mp->filter = filter;
13089 /* Use a control ping for synchronization */
13091 vl_api_noprint_control_ping_t *mp;
13092 M (NOPRINT_CONTROL_PING, noprint_control_ping);
13096 /* Wait for a reply... */
13100 if (vam->noprint_msg)
13102 if (!vam->json_output)
13104 print_locator_in_locator_set(vam, filter);
13108 json_locator_in_locator_set(vam, filter);
13111 vam->noprint_msg = 0;
13120 api_lisp_locator_set_dump (vat_main_t * vam)
13122 unformat_input_t *input = vam->input;
13123 vam->noprint_msg = 0;
13124 u32 locator_set_index = ~0;
13125 u8 locator_set_index_set = 0;
13126 u8 *locator_set = 0;
13127 u8 locator_set_set = 0;
13131 /* Parse args required to build the message */
13132 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13134 if (unformat (input, "locator-set-index %u", &locator_set_index))
13136 locator_set_index_set = 1;
13138 else if (unformat (input, "locator-set %s", &locator_set))
13140 locator_set_set = 1;
13142 else if (unformat (input, "local"))
13146 else if (unformat (input, "remote"))
13156 if (locator_set_index_set && locator_set_set)
13158 errmsg ("use only input parameter!\n");
13162 if (locator_set_index_set || locator_set_set)
13164 ret = lisp_locator_dump (vam, locator_set_index, locator_set, filter);
13168 ret = lisp_locator_set_dump (vam, filter);
13171 vec_free (locator_set);
13177 api_lisp_eid_table_map_dump (vat_main_t * vam)
13181 unformat_input_t *input = vam->input;
13182 vl_api_lisp_eid_table_map_dump_t *mp;
13185 /* Parse args required to build the message */
13186 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13188 if (unformat (input, "l2"))
13193 else if (unformat (input, "l3"))
13200 errmsg ("parse error '%U'", format_unformat_error, input);
13207 errmsg ("expected one of 'l2' or 'l3' parameter!\n");
13211 if (!vam->json_output)
13213 fformat (vam->ofp, "%=10s%=10s\n", "VNI", is_l2 ? "BD" : "VRF");
13216 M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump);
13222 /* Use a control ping for synchronization */
13224 vl_api_control_ping_t *mp;
13225 M (CONTROL_PING, control_ping);
13228 /* Wait for a reply... */
13236 api_lisp_eid_table_vni_dump (vat_main_t * vam)
13238 vl_api_lisp_eid_table_vni_dump_t *mp;
13241 if (!vam->json_output)
13243 fformat (vam->ofp, "VNI\n");
13246 M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
13251 /* Use a control ping for synchronization */
13253 vl_api_control_ping_t *mp;
13254 M (CONTROL_PING, control_ping);
13257 /* Wait for a reply... */
13265 get_locator_set (vat_main_t * vam)
13267 vl_api_lisp_locator_set_dump_t *mp;
13270 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
13274 /* Use a control ping for synchronization */
13276 vl_api_noprint_control_ping_t *mp;
13277 M (NOPRINT_CONTROL_PING, noprint_control_ping);
13281 /* Wait for a reply... */
13289 format_eid_for_eid_table (vat_main_t * vam, u8 * str, eid_table_t * eid_table,
13292 u8 *(*format_eid) (u8 *, va_list *) = 0;
13294 ASSERT (vam != NULL);
13295 ASSERT (eid_table != NULL);
13302 switch (eid_table->eid_type)
13306 format_eid = (eid_table->eid_type ? format_ip6_address :
13307 format_ip4_address);
13308 str = format (0, "[%d] %U/%d", eid_table->vni,
13309 format_eid, eid_table->eid, eid_table->eid_prefix_len);
13312 str = format (0, "[%d] %U", eid_table->vni,
13313 format_ethernet_address, eid_table->eid);
13316 errmsg ("unknown EID type %d!", eid_table->eid_type);
13328 format_locator_set_for_eid_table (vat_main_t * vam, u8 * str,
13329 eid_table_t * eid_table)
13331 locator_set_msg_t *ls = 0;
13333 ASSERT (vam != NULL);
13334 ASSERT (eid_table != NULL);
13336 if (eid_table->is_local)
13338 vec_foreach (ls, vam->locator_set_msg)
13340 if (ls->locator_set_index == eid_table->locator_set_index)
13342 str = format (0, "local(%s)", ls->locator_set_name);
13347 str = format (0, "local(N/A)");
13351 str = format (0, "remote");
13358 format_locator_for_eid_table (vat_main_t * vam, u8 * str,
13359 eid_table_t * eid_table)
13361 locator_msg_t *loc = 0;
13362 int first_line = 1;
13364 ASSERT (vam != NULL);
13365 ASSERT (eid_table != NULL);
13367 if (~0 == eid_table->locator_set_index)
13369 return format (0, "action: %d\n", eid_table->action);
13372 vec_foreach (loc, vam->locator_msg)
13378 str = format (str, "%-55s%-d\n", " ", loc->sw_if_index);
13382 str = format (str, "%=55s%-U\n", " ",
13383 loc->is_ipv6 ? format_ip6_address :
13384 format_ip4_address, loc->ip_address);
13392 str = format (str, "%-30d%-20u%-u\n", loc->sw_if_index,
13393 eid_table->ttl, eid_table->authoritative);
13397 str = format (str, "%-30U%-20u%-u\n",
13398 loc->is_ipv6 ? format_ip6_address :
13399 format_ip4_address,
13400 loc->ip_address, eid_table->ttl,
13401 eid_table->authoritative);
13410 print_lisp_eid_table_dump (vat_main_t * vam)
13412 eid_table_t *eid_table = 0;
13413 u8 *tmp_str = 0, *tmp_str2 = 0;
13416 ASSERT (vam != NULL);
13418 ret = get_locator_set (vam);
13421 vec_free (vam->eid_tables);
13425 fformat (vam->ofp, "%-35s%-20s%-30s%-20s%-s\n", "EID", "type", "locators",
13426 "ttl", "authoritative");
13428 vec_foreach (eid_table, vam->eid_tables)
13430 if (~0 != eid_table->locator_set_index)
13432 ret = lisp_locator_dump_send_msg (vam, eid_table->locator_set_index,
13436 vec_free (vam->locator_msg);
13437 clean_locator_set_message (vam);
13438 vec_free (vam->eid_tables);
13443 tmp_str2 = format_eid_for_eid_table (vam, tmp_str2, eid_table, &ret);
13446 vec_free (vam->locator_msg);
13447 clean_locator_set_message (vam);
13448 vec_free (vam->eid_tables);
13452 tmp_str = format (0, "%-35s", tmp_str2);
13453 vec_free (tmp_str2);
13455 tmp_str2 = format_locator_set_for_eid_table (vam, tmp_str2, eid_table);
13456 tmp_str = format (tmp_str, "%-20s", tmp_str2);
13457 vec_free (tmp_str2);
13459 tmp_str2 = format_locator_for_eid_table (vam, tmp_str2, eid_table);
13460 tmp_str = format (tmp_str, "%-s", tmp_str2);
13461 vec_free (tmp_str2);
13463 fformat (vam->ofp, "%s", tmp_str);
13464 vec_free (tmp_str);
13465 vec_free (vam->locator_msg);
13468 clean_locator_set_message (vam);
13469 vec_free (vam->eid_tables);
13475 json_locator_set_for_eid_table (vat_main_t * vam, vat_json_node_t * node,
13476 eid_table_t * eid_table)
13478 locator_set_msg_t *ls = 0;
13481 ASSERT (vam != NULL);
13482 ASSERT (node != NULL);
13483 ASSERT (eid_table != NULL);
13485 if (eid_table->is_local)
13487 vec_foreach (ls, vam->locator_set_msg)
13489 if (ls->locator_set_index == eid_table->locator_set_index)
13491 vat_json_object_add_string_copy (node, "locator-set",
13492 ls->locator_set_name);
13497 s = format (0, "N/A");
13499 vat_json_object_add_string_copy (node, "locator-set", s);
13504 s = format (0, "remote");
13506 vat_json_object_add_string_copy (node, "locator-set", s);
13512 json_eid_for_eid_table (vat_main_t * vam, vat_json_node_t * node,
13513 eid_table_t * eid_table)
13516 struct in6_addr ip6;
13517 struct in_addr ip4;
13519 ASSERT (vam != NULL);
13520 ASSERT (node != NULL);
13521 ASSERT (eid_table != NULL);
13523 switch (eid_table->eid_type)
13526 clib_memcpy (&ip4, eid_table->eid, sizeof (ip4));
13527 vat_json_object_add_ip4 (node, "eid", ip4);
13528 vat_json_object_add_uint (node, "eid-prefix-len",
13529 eid_table->eid_prefix_len);
13532 clib_memcpy (&ip6, eid_table->eid, sizeof (ip6));
13533 vat_json_object_add_ip6 (node, "eid", ip6);
13534 vat_json_object_add_uint (node, "eid-prefix-len",
13535 eid_table->eid_prefix_len);
13538 s = format (0, "%U", format_ethernet_address, eid_table->eid);
13540 vat_json_object_add_string_copy (node, "eid", s);
13544 errmsg ("unknown EID type %d!", eid_table->eid_type);
13552 json_locator_for_eid_table (vat_main_t * vam, vat_json_node_t * node,
13553 eid_table_t * eid_table)
13555 locator_msg_t *loc = 0;
13556 vat_json_node_t *locator_array = 0;
13557 vat_json_node_t *locator = 0;
13558 struct in6_addr ip6;
13559 struct in_addr ip4;
13561 ASSERT (vam != NULL);
13562 ASSERT (node != NULL);
13563 ASSERT (eid_table != NULL);
13565 locator_array = vat_json_object_add_list (node, "locator");
13566 vec_foreach (loc, vam->locator_msg)
13568 locator = vat_json_array_add (locator_array);
13569 vat_json_init_object (locator);
13572 vat_json_object_add_uint (locator, "locator-index", loc->sw_if_index);
13578 clib_memcpy (&ip6, loc->ip_address, sizeof (ip6));
13579 vat_json_object_add_ip6 (locator, "locator", ip6);
13583 clib_memcpy (&ip4, loc->ip_address, sizeof (ip4));
13584 vat_json_object_add_ip4 (locator, "locator", ip4);
13591 json_lisp_eid_table_dump (vat_main_t * vam)
13593 eid_table_t *eid_table;
13594 vat_json_node_t *node = 0;
13597 ASSERT (vam != NULL);
13599 ret = get_locator_set (vam);
13602 vec_free (vam->eid_tables);
13606 if (!vec_len (vam->eid_tables))
13608 /* just print [] */
13609 vat_json_init_array (&vam->json_tree);
13610 vat_json_print (vam->ofp, &vam->json_tree);
13611 vam->json_tree.type = VAT_JSON_NONE;
13615 if (VAT_JSON_ARRAY != vam->json_tree.type)
13617 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13618 vat_json_init_array (&vam->json_tree);
13621 vec_foreach (eid_table, vam->eid_tables)
13623 ret = lisp_locator_dump_send_msg (vam, eid_table->locator_set_index, 0);
13626 vec_free (vam->locator_msg);
13627 vec_free (vam->eid_tables);
13628 clean_locator_set_message (vam);
13629 vat_json_free (&vam->json_tree);
13630 vam->json_tree.type = VAT_JSON_NONE;
13634 node = vat_json_array_add (&vam->json_tree);
13635 vat_json_init_object (node);
13637 vat_json_object_add_uint (node, "vni", eid_table->vni);
13639 json_locator_set_for_eid_table (vam, node, eid_table);
13640 ret = json_eid_for_eid_table (vam, node, eid_table);
13643 vec_free (vam->locator_msg);
13644 vec_free (vam->eid_tables);
13645 clean_locator_set_message (vam);
13646 vat_json_free (&vam->json_tree);
13647 vam->json_tree.type = VAT_JSON_NONE;
13651 json_locator_for_eid_table (vam, node, eid_table);
13653 vat_json_object_add_uint (node, "ttl", eid_table->ttl);
13654 vat_json_object_add_uint (node, "authoritative",
13655 eid_table->authoritative);
13657 vec_free (vam->locator_msg);
13660 vat_json_print (vam->ofp, &vam->json_tree);
13661 vat_json_free (&vam->json_tree);
13662 vam->json_tree.type = VAT_JSON_NONE;
13664 clean_locator_set_message (vam);
13665 vec_free (vam->eid_tables);
13671 api_lisp_eid_table_dump (vat_main_t * vam)
13673 unformat_input_t *i = vam->input;
13674 vl_api_lisp_eid_table_dump_t *mp;
13676 struct in_addr ip4;
13677 struct in6_addr ip6;
13679 u8 eid_type = ~0, eid_set = 0;
13680 u32 prefix_length = ~0, t, vni = 0;
13683 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13685 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
13691 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
13697 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
13702 else if (unformat (i, "vni %d", &t))
13706 else if (unformat (i, "local"))
13710 else if (unformat (i, "remote"))
13716 errmsg ("parse error '%U'", format_unformat_error, i);
13721 M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump);
13723 mp->filter = filter;
13727 mp->vni = htonl (vni);
13728 mp->eid_type = eid_type;
13732 mp->prefix_length = prefix_length;
13733 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
13736 mp->prefix_length = prefix_length;
13737 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
13740 clib_memcpy (mp->eid, mac, sizeof (mac));
13743 errmsg ("unknown EID type %d!", eid_type);
13748 vam->noprint_msg = 1;
13753 /* Use a control ping for synchronization */
13755 vl_api_noprint_control_ping_t *mp;
13756 M (NOPRINT_CONTROL_PING, noprint_control_ping);
13760 /* Wait for a reply... */
13764 if (vam->noprint_msg)
13766 if (!vam->json_output)
13768 vam->retval = print_lisp_eid_table_dump(vam);
13772 vam->retval = json_lisp_eid_table_dump(vam);
13775 vam->noprint_msg = 0;
13784 api_lisp_gpe_tunnel_dump (vat_main_t * vam)
13786 vl_api_lisp_gpe_tunnel_dump_t *mp;
13789 if (!vam->json_output)
13791 fformat (vam->ofp, "%=20s%=30s%=16s%=16s%=16s%=16s"
13792 "%=16s%=16s%=16s%=16s%=16s\n",
13793 "Tunel", "Source", "Destination", "Fib encap", "Fib decap",
13794 "Decap next", "Lisp version", "Flags", "Next protocol",
13795 "ver_res", "res", "iid");
13798 M (LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump);
13802 /* Use a control ping for synchronization */
13804 vl_api_control_ping_t *mp;
13805 M (CONTROL_PING, control_ping);
13808 /* Wait for a reply... */
13816 api_lisp_map_resolver_dump (vat_main_t * vam)
13818 vl_api_lisp_map_resolver_dump_t *mp;
13821 if (!vam->json_output)
13823 fformat (vam->ofp, "%=20s\n", "Map resolver");
13826 M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
13830 /* Use a control ping for synchronization */
13832 vl_api_control_ping_t *mp;
13833 M (CONTROL_PING, control_ping);
13836 /* Wait for a reply... */
13844 api_show_lisp_status (vat_main_t * vam)
13846 vl_api_show_lisp_status_t *mp;
13849 if (!vam->json_output)
13851 fformat (vam->ofp, "%-20s%-16s\n", "lisp status", "locator-set");
13854 M (SHOW_LISP_STATUS, show_lisp_status);
13857 /* Wait for a reply... */
13865 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
13867 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
13870 if (!vam->json_output)
13872 fformat (vam->ofp, "%=20s\n", "itr-rlocs:");
13875 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
13878 /* Wait for a reply... */
13886 api_af_packet_create (vat_main_t * vam)
13888 unformat_input_t *i = vam->input;
13889 vl_api_af_packet_create_t *mp;
13891 u8 *host_if_name = 0;
13893 u8 random_hw_addr = 1;
13895 memset (hw_addr, 0, sizeof (hw_addr));
13897 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13899 if (unformat (i, "name %s", &host_if_name))
13900 vec_add1 (host_if_name, 0);
13901 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
13902 random_hw_addr = 0;
13907 if (!vec_len (host_if_name))
13909 errmsg ("host-interface name must be specified");
13913 if (vec_len (host_if_name) > 64)
13915 errmsg ("host-interface name too long");
13919 M (AF_PACKET_CREATE, af_packet_create);
13921 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
13922 clib_memcpy (mp->hw_addr, hw_addr, 6);
13923 mp->use_random_hw_addr = random_hw_addr;
13924 vec_free (host_if_name);
13927 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
13933 api_af_packet_delete (vat_main_t * vam)
13935 unformat_input_t *i = vam->input;
13936 vl_api_af_packet_delete_t *mp;
13938 u8 *host_if_name = 0;
13940 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13942 if (unformat (i, "name %s", &host_if_name))
13943 vec_add1 (host_if_name, 0);
13948 if (!vec_len (host_if_name))
13950 errmsg ("host-interface name must be specified");
13954 if (vec_len (host_if_name) > 64)
13956 errmsg ("host-interface name too long");
13960 M (AF_PACKET_DELETE, af_packet_delete);
13962 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
13963 vec_free (host_if_name);
13972 api_policer_add_del (vat_main_t * vam)
13974 unformat_input_t *i = vam->input;
13975 vl_api_policer_add_del_t *mp;
13986 u8 color_aware = 0;
13987 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
13989 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
13990 conform_action.dscp = 0;
13991 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
13992 exceed_action.dscp = 0;
13993 violate_action.action_type = SSE2_QOS_ACTION_DROP;
13994 violate_action.dscp = 0;
13996 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13998 if (unformat (i, "del"))
14000 else if (unformat (i, "name %s", &name))
14001 vec_add1 (name, 0);
14002 else if (unformat (i, "cir %u", &cir))
14004 else if (unformat (i, "eir %u", &eir))
14006 else if (unformat (i, "cb %u", &cb))
14008 else if (unformat (i, "eb %u", &eb))
14010 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
14013 else if (unformat (i, "round_type %U", unformat_policer_round_type,
14016 else if (unformat (i, "type %U", unformat_policer_type, &type))
14018 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
14021 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
14024 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
14027 else if (unformat (i, "color-aware"))
14033 if (!vec_len (name))
14035 errmsg ("policer name must be specified");
14039 if (vec_len (name) > 64)
14041 errmsg ("policer name too long");
14045 M (POLICER_ADD_DEL, policer_add_del);
14047 clib_memcpy (mp->name, name, vec_len (name));
14049 mp->is_add = is_add;
14054 mp->rate_type = rate_type;
14055 mp->round_type = round_type;
14057 mp->conform_action_type = conform_action.action_type;
14058 mp->conform_dscp = conform_action.dscp;
14059 mp->exceed_action_type = exceed_action.action_type;
14060 mp->exceed_dscp = exceed_action.dscp;
14061 mp->violate_action_type = violate_action.action_type;
14062 mp->violate_dscp = violate_action.dscp;
14063 mp->color_aware = color_aware;
14072 api_policer_dump (vat_main_t * vam)
14074 unformat_input_t *i = vam->input;
14075 vl_api_policer_dump_t *mp;
14077 u8 *match_name = 0;
14078 u8 match_name_valid = 0;
14080 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14082 if (unformat (i, "name %s", &match_name))
14084 vec_add1 (match_name, 0);
14085 match_name_valid = 1;
14091 M (POLICER_DUMP, policer_dump);
14092 mp->match_name_valid = match_name_valid;
14093 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
14094 vec_free (match_name);
14098 /* Use a control ping for synchronization */
14100 vl_api_control_ping_t *mp;
14101 M (CONTROL_PING, control_ping);
14104 /* Wait for a reply... */
14112 api_policer_classify_set_interface (vat_main_t * vam)
14114 unformat_input_t *i = vam->input;
14115 vl_api_policer_classify_set_interface_t *mp;
14118 int sw_if_index_set;
14119 u32 ip4_table_index = ~0;
14120 u32 ip6_table_index = ~0;
14121 u32 l2_table_index = ~0;
14124 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14126 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
14127 sw_if_index_set = 1;
14128 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14129 sw_if_index_set = 1;
14130 else if (unformat (i, "del"))
14132 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14134 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14136 else if (unformat (i, "l2-table %d", &l2_table_index))
14140 clib_warning ("parse error '%U'", format_unformat_error, i);
14145 if (sw_if_index_set == 0)
14147 errmsg ("missing interface name or sw_if_index\n");
14151 M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface);
14153 mp->sw_if_index = ntohl (sw_if_index);
14154 mp->ip4_table_index = ntohl (ip4_table_index);
14155 mp->ip6_table_index = ntohl (ip6_table_index);
14156 mp->l2_table_index = ntohl (l2_table_index);
14157 mp->is_add = is_add;
14166 api_policer_classify_dump (vat_main_t * vam)
14168 unformat_input_t *i = vam->input;
14169 vl_api_policer_classify_dump_t *mp;
14171 u8 type = POLICER_CLASSIFY_N_TABLES;
14173 if (unformat (i, "type %U", unformat_classify_table_type, &type))
14177 errmsg ("classify table type must be specified\n");
14181 if (!vam->json_output)
14183 fformat (vam->ofp, "%10s%20s\n", "Intfc idx", "Classify table");
14186 M (POLICER_CLASSIFY_DUMP, policer_classify_dump);
14191 /* Use a control ping for synchronization */
14193 vl_api_control_ping_t *mp;
14194 M (CONTROL_PING, control_ping);
14197 /* Wait for a reply... */
14205 api_netmap_create (vat_main_t * vam)
14207 unformat_input_t *i = vam->input;
14208 vl_api_netmap_create_t *mp;
14212 u8 random_hw_addr = 1;
14216 memset (hw_addr, 0, sizeof (hw_addr));
14218 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14220 if (unformat (i, "name %s", &if_name))
14221 vec_add1 (if_name, 0);
14222 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14223 random_hw_addr = 0;
14224 else if (unformat (i, "pipe"))
14226 else if (unformat (i, "master"))
14228 else if (unformat (i, "slave"))
14234 if (!vec_len (if_name))
14236 errmsg ("interface name must be specified");
14240 if (vec_len (if_name) > 64)
14242 errmsg ("interface name too long");
14246 M (NETMAP_CREATE, netmap_create);
14248 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
14249 clib_memcpy (mp->hw_addr, hw_addr, 6);
14250 mp->use_random_hw_addr = random_hw_addr;
14251 mp->is_pipe = is_pipe;
14252 mp->is_master = is_master;
14253 vec_free (if_name);
14262 api_netmap_delete (vat_main_t * vam)
14264 unformat_input_t *i = vam->input;
14265 vl_api_netmap_delete_t *mp;
14269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14271 if (unformat (i, "name %s", &if_name))
14272 vec_add1 (if_name, 0);
14277 if (!vec_len (if_name))
14279 errmsg ("interface name must be specified");
14283 if (vec_len (if_name) > 64)
14285 errmsg ("interface name too long");
14289 M (NETMAP_DELETE, netmap_delete);
14291 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
14292 vec_free (if_name);
14300 static void vl_api_mpls_gre_tunnel_details_t_handler
14301 (vl_api_mpls_gre_tunnel_details_t * mp)
14303 vat_main_t *vam = &vat_main;
14305 i32 len = ntohl (mp->nlabels);
14307 if (mp->l2_only == 0)
14309 fformat (vam->ofp, "[%d]: src %U, dst %U, adj %U/%d, labels ",
14310 ntohl (mp->tunnel_index),
14311 format_ip4_address, &mp->tunnel_src,
14312 format_ip4_address, &mp->tunnel_dst,
14313 format_ip4_address, &mp->intfc_address,
14314 ntohl (mp->mask_width));
14315 for (i = 0; i < len; i++)
14317 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14319 fformat (vam->ofp, "\n");
14320 fformat (vam->ofp, " inner fib index %d, outer fib index %d\n",
14321 ntohl (mp->inner_fib_index), ntohl (mp->outer_fib_index));
14325 fformat (vam->ofp, "[%d]: src %U, dst %U, key %U, labels ",
14326 ntohl (mp->tunnel_index),
14327 format_ip4_address, &mp->tunnel_src,
14328 format_ip4_address, &mp->tunnel_dst,
14329 format_ip4_address, &mp->intfc_address);
14330 for (i = 0; i < len; i++)
14332 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14334 fformat (vam->ofp, "\n");
14335 fformat (vam->ofp, " l2 interface %d, outer fib index %d\n",
14336 ntohl (mp->hw_if_index), ntohl (mp->outer_fib_index));
14340 static void vl_api_mpls_gre_tunnel_details_t_handler_json
14341 (vl_api_mpls_gre_tunnel_details_t * mp)
14343 vat_main_t *vam = &vat_main;
14344 vat_json_node_t *node = NULL;
14345 struct in_addr ip4;
14347 i32 len = ntohl (mp->nlabels);
14349 if (VAT_JSON_ARRAY != vam->json_tree.type)
14351 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14352 vat_json_init_array (&vam->json_tree);
14354 node = vat_json_array_add (&vam->json_tree);
14356 vat_json_init_object (node);
14357 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
14358 clib_memcpy (&ip4, &(mp->intfc_address), sizeof (ip4));
14359 vat_json_object_add_ip4 (node, "intfc_address", ip4);
14360 vat_json_object_add_uint (node, "inner_fib_index",
14361 ntohl (mp->inner_fib_index));
14362 vat_json_object_add_uint (node, "mask_width", ntohl (mp->mask_width));
14363 vat_json_object_add_uint (node, "encap_index", ntohl (mp->encap_index));
14364 vat_json_object_add_uint (node, "hw_if_index", ntohl (mp->hw_if_index));
14365 vat_json_object_add_uint (node, "l2_only", ntohl (mp->l2_only));
14366 clib_memcpy (&ip4, &(mp->tunnel_src), sizeof (ip4));
14367 vat_json_object_add_ip4 (node, "tunnel_src", ip4);
14368 clib_memcpy (&ip4, &(mp->tunnel_dst), sizeof (ip4));
14369 vat_json_object_add_ip4 (node, "tunnel_dst", ip4);
14370 vat_json_object_add_uint (node, "outer_fib_index",
14371 ntohl (mp->outer_fib_index));
14372 vat_json_object_add_uint (node, "label_count", len);
14373 for (i = 0; i < len; i++)
14375 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14380 api_mpls_gre_tunnel_dump (vat_main_t * vam)
14382 vl_api_mpls_gre_tunnel_dump_t *mp;
14386 /* Parse args required to build the message */
14387 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
14389 if (!unformat (vam->input, "tunnel_index %d", &index))
14396 fformat (vam->ofp, " tunnel_index %d\n", index);
14398 M (MPLS_GRE_TUNNEL_DUMP, mpls_gre_tunnel_dump);
14399 mp->tunnel_index = htonl (index);
14402 /* Use a control ping for synchronization */
14404 vl_api_control_ping_t *mp;
14405 M (CONTROL_PING, control_ping);
14411 static void vl_api_mpls_eth_tunnel_details_t_handler
14412 (vl_api_mpls_eth_tunnel_details_t * mp)
14414 vat_main_t *vam = &vat_main;
14416 i32 len = ntohl (mp->nlabels);
14418 fformat (vam->ofp, "[%d]: dst %U, adj %U/%d, labels ",
14419 ntohl (mp->tunnel_index),
14420 format_ethernet_address, &mp->tunnel_dst_mac,
14421 format_ip4_address, &mp->intfc_address, ntohl (mp->mask_width));
14422 for (i = 0; i < len; i++)
14424 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14426 fformat (vam->ofp, "\n");
14427 fformat (vam->ofp, " tx on %d, rx fib index %d\n",
14428 ntohl (mp->tx_sw_if_index), ntohl (mp->inner_fib_index));
14431 static void vl_api_mpls_eth_tunnel_details_t_handler_json
14432 (vl_api_mpls_eth_tunnel_details_t * mp)
14434 vat_main_t *vam = &vat_main;
14435 vat_json_node_t *node = NULL;
14436 struct in_addr ip4;
14438 i32 len = ntohl (mp->nlabels);
14440 if (VAT_JSON_ARRAY != vam->json_tree.type)
14442 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14443 vat_json_init_array (&vam->json_tree);
14445 node = vat_json_array_add (&vam->json_tree);
14447 vat_json_init_object (node);
14448 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
14449 clib_memcpy (&ip4, &(mp->intfc_address), sizeof (ip4));
14450 vat_json_object_add_ip4 (node, "intfc_address", ip4);
14451 vat_json_object_add_uint (node, "inner_fib_index",
14452 ntohl (mp->inner_fib_index));
14453 vat_json_object_add_uint (node, "mask_width", ntohl (mp->mask_width));
14454 vat_json_object_add_uint (node, "encap_index", ntohl (mp->encap_index));
14455 vat_json_object_add_uint (node, "hw_if_index", ntohl (mp->hw_if_index));
14456 vat_json_object_add_uint (node, "l2_only", ntohl (mp->l2_only));
14457 vat_json_object_add_string_copy (node, "tunnel_dst_mac",
14458 format (0, "%U", format_ethernet_address,
14459 &mp->tunnel_dst_mac));
14460 vat_json_object_add_uint (node, "tx_sw_if_index",
14461 ntohl (mp->tx_sw_if_index));
14462 vat_json_object_add_uint (node, "label_count", len);
14463 for (i = 0; i < len; i++)
14465 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14470 api_mpls_eth_tunnel_dump (vat_main_t * vam)
14472 vl_api_mpls_eth_tunnel_dump_t *mp;
14476 /* Parse args required to build the message */
14477 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
14479 if (!unformat (vam->input, "tunnel_index %d", &index))
14486 fformat (vam->ofp, " tunnel_index %d\n", index);
14488 M (MPLS_ETH_TUNNEL_DUMP, mpls_eth_tunnel_dump);
14489 mp->tunnel_index = htonl (index);
14492 /* Use a control ping for synchronization */
14494 vl_api_control_ping_t *mp;
14495 M (CONTROL_PING, control_ping);
14501 static void vl_api_mpls_fib_encap_details_t_handler
14502 (vl_api_mpls_fib_encap_details_t * mp)
14504 vat_main_t *vam = &vat_main;
14506 i32 len = ntohl (mp->nlabels);
14508 fformat (vam->ofp, "table %d, dest %U, label ",
14509 ntohl (mp->fib_index), format_ip4_address, &mp->dest, len);
14510 for (i = 0; i < len; i++)
14512 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14514 fformat (vam->ofp, "\n");
14517 static void vl_api_mpls_fib_encap_details_t_handler_json
14518 (vl_api_mpls_fib_encap_details_t * mp)
14520 vat_main_t *vam = &vat_main;
14521 vat_json_node_t *node = NULL;
14523 i32 len = ntohl (mp->nlabels);
14524 struct in_addr ip4;
14526 if (VAT_JSON_ARRAY != vam->json_tree.type)
14528 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14529 vat_json_init_array (&vam->json_tree);
14531 node = vat_json_array_add (&vam->json_tree);
14533 vat_json_init_object (node);
14534 vat_json_object_add_uint (node, "table", ntohl (mp->fib_index));
14535 vat_json_object_add_uint (node, "entry_index", ntohl (mp->entry_index));
14536 clib_memcpy (&ip4, &(mp->dest), sizeof (ip4));
14537 vat_json_object_add_ip4 (node, "dest", ip4);
14538 vat_json_object_add_uint (node, "s_bit", ntohl (mp->s_bit));
14539 vat_json_object_add_uint (node, "label_count", len);
14540 for (i = 0; i < len; i++)
14542 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14547 api_mpls_fib_encap_dump (vat_main_t * vam)
14549 vl_api_mpls_fib_encap_dump_t *mp;
14552 M (MPLS_FIB_ENCAP_DUMP, mpls_fib_encap_dump);
14555 /* Use a control ping for synchronization */
14557 vl_api_control_ping_t *mp;
14558 M (CONTROL_PING, control_ping);
14564 static void vl_api_mpls_fib_decap_details_t_handler
14565 (vl_api_mpls_fib_decap_details_t * mp)
14567 vat_main_t *vam = &vat_main;
14570 "RX table %d, TX table/intfc %u, swif_tag '%s', label %u, s_bit %u\n",
14571 ntohl (mp->rx_table_id), ntohl (mp->tx_table_id), mp->swif_tag,
14572 ntohl (mp->label), ntohl (mp->s_bit));
14575 static void vl_api_mpls_fib_decap_details_t_handler_json
14576 (vl_api_mpls_fib_decap_details_t * mp)
14578 vat_main_t *vam = &vat_main;
14579 vat_json_node_t *node = NULL;
14580 struct in_addr ip4;
14582 if (VAT_JSON_ARRAY != vam->json_tree.type)
14584 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14585 vat_json_init_array (&vam->json_tree);
14587 node = vat_json_array_add (&vam->json_tree);
14589 vat_json_init_object (node);
14590 vat_json_object_add_uint (node, "table", ntohl (mp->fib_index));
14591 vat_json_object_add_uint (node, "entry_index", ntohl (mp->entry_index));
14592 clib_memcpy (&ip4, &(mp->dest), sizeof (ip4));
14593 vat_json_object_add_ip4 (node, "dest", ip4);
14594 vat_json_object_add_uint (node, "s_bit", ntohl (mp->s_bit));
14595 vat_json_object_add_uint (node, "label", ntohl (mp->label));
14596 vat_json_object_add_uint (node, "rx_table_id", ntohl (mp->rx_table_id));
14597 vat_json_object_add_uint (node, "tx_table_id", ntohl (mp->tx_table_id));
14598 vat_json_object_add_string_copy (node, "swif_tag", mp->swif_tag);
14602 api_mpls_fib_decap_dump (vat_main_t * vam)
14604 vl_api_mpls_fib_decap_dump_t *mp;
14607 M (MPLS_FIB_DECAP_DUMP, mpls_fib_decap_dump);
14610 /* Use a control ping for synchronization */
14612 vl_api_control_ping_t *mp;
14613 M (CONTROL_PING, control_ping);
14620 api_classify_table_ids (vat_main_t * vam)
14622 vl_api_classify_table_ids_t *mp;
14625 /* Construct the API message */
14626 M (CLASSIFY_TABLE_IDS, classify_table_ids);
14636 api_classify_table_by_interface (vat_main_t * vam)
14638 unformat_input_t *input = vam->input;
14639 vl_api_classify_table_by_interface_t *mp;
14642 u32 sw_if_index = ~0;
14643 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14645 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
14647 else if (unformat (input, "sw_if_index %d", &sw_if_index))
14652 if (sw_if_index == ~0)
14654 errmsg ("missing interface name or sw_if_index\n");
14658 /* Construct the API message */
14659 M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
14661 mp->sw_if_index = ntohl (sw_if_index);
14670 api_classify_table_info (vat_main_t * vam)
14672 unformat_input_t *input = vam->input;
14673 vl_api_classify_table_info_t *mp;
14677 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14679 if (unformat (input, "table_id %d", &table_id))
14684 if (table_id == ~0)
14686 errmsg ("missing table id\n");
14690 /* Construct the API message */
14691 M (CLASSIFY_TABLE_INFO, classify_table_info);
14693 mp->table_id = ntohl (table_id);
14702 api_classify_session_dump (vat_main_t * vam)
14704 unformat_input_t *input = vam->input;
14705 vl_api_classify_session_dump_t *mp;
14709 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14711 if (unformat (input, "table_id %d", &table_id))
14716 if (table_id == ~0)
14718 errmsg ("missing table id\n");
14722 /* Construct the API message */
14723 M (CLASSIFY_SESSION_DUMP, classify_session_dump);
14725 mp->table_id = ntohl (table_id);
14728 /* Use a control ping for synchronization */
14730 vl_api_control_ping_t *mp;
14731 M (CONTROL_PING, control_ping);
14740 vl_api_ipfix_details_t_handler (vl_api_ipfix_details_t * mp)
14742 vat_main_t *vam = &vat_main;
14744 fformat (vam->ofp, "collector_address %U, collector_port %d, "
14745 "src_address %U, fib_index %u, path_mtu %u, "
14746 "template_interval %u\n",
14747 format_ip4_address, mp->collector_address,
14748 ntohs (mp->collector_port),
14749 format_ip4_address, mp->src_address,
14750 ntohl (mp->fib_index),
14751 ntohl (mp->path_mtu), ntohl (mp->template_interval));
14754 vam->result_ready = 1;
14758 vl_api_ipfix_details_t_handler_json (vl_api_ipfix_details_t * mp)
14760 vat_main_t *vam = &vat_main;
14761 vat_json_node_t node;
14762 struct in_addr collector_address;
14763 struct in_addr src_address;
14765 vat_json_init_object (&node);
14766 clib_memcpy (&collector_address, &mp->collector_address,
14767 sizeof (collector_address));
14768 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
14769 vat_json_object_add_uint (&node, "collector_port",
14770 ntohs (mp->collector_port));
14771 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
14772 vat_json_object_add_ip4 (&node, "src_address", src_address);
14773 vat_json_object_add_uint (&node, "fib_index", ntohl (mp->fib_index));
14774 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
14775 vat_json_object_add_uint (&node, "template_interval",
14776 ntohl (mp->template_interval));
14778 vat_json_print (vam->ofp, &node);
14779 vat_json_free (&node);
14781 vam->result_ready = 1;
14785 api_ipfix_dump (vat_main_t * vam)
14787 vl_api_ipfix_dump_t *mp;
14790 /* Construct the API message */
14791 M (IPFIX_DUMP, ipfix_dump);
14801 api_pg_create_interface (vat_main_t * vam)
14803 unformat_input_t *input = vam->input;
14804 vl_api_pg_create_interface_t *mp;
14808 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14810 if (unformat (input, "if_id %d", &if_id))
14817 errmsg ("missing pg interface index\n");
14821 /* Construct the API message */
14822 M (PG_CREATE_INTERFACE, pg_create_interface);
14824 mp->interface_id = ntohl (if_id);
14833 api_pg_capture (vat_main_t * vam)
14835 unformat_input_t *input = vam->input;
14836 vl_api_pg_capture_t *mp;
14842 u8 pcap_file_set = 0;
14844 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14846 if (unformat (input, "if_id %d", &if_id))
14848 else if (unformat (input, "pcap %s", &pcap_file))
14850 else if (unformat (input, "count %d", &count))
14852 else if (unformat (input, "disable"))
14859 errmsg ("missing pg interface index\n");
14862 if (pcap_file_set > 0)
14864 if (vec_len (pcap_file) > 255)
14866 errmsg ("pcap file name is too long\n");
14871 u32 name_len = vec_len (pcap_file);
14872 /* Construct the API message */
14873 M (PG_CAPTURE, pg_capture);
14875 mp->interface_id = ntohl (if_id);
14876 mp->is_enabled = enable;
14877 mp->count = ntohl (count);
14878 mp->pcap_name_length = ntohl (name_len);
14879 if (pcap_file_set != 0)
14881 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
14883 vec_free (pcap_file);
14892 api_pg_enable_disable (vat_main_t * vam)
14894 unformat_input_t *input = vam->input;
14895 vl_api_pg_enable_disable_t *mp;
14899 u8 stream_name_set = 0;
14900 u8 *stream_name = 0;
14901 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14903 if (unformat (input, "stream %s", &stream_name))
14904 stream_name_set = 1;
14905 else if (unformat (input, "disable"))
14911 if (stream_name_set > 0)
14913 if (vec_len (stream_name) > 255)
14915 errmsg ("stream name too long\n");
14920 u32 name_len = vec_len (stream_name);
14921 /* Construct the API message */
14922 M (PG_ENABLE_DISABLE, pg_enable_disable);
14924 mp->is_enabled = enable;
14925 if (stream_name_set != 0)
14927 mp->stream_name_length = ntohl (name_len);
14928 clib_memcpy (mp->stream_name, stream_name, name_len);
14930 vec_free (stream_name);
14939 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
14941 unformat_input_t *input = vam->input;
14942 vl_api_ip_source_and_port_range_check_add_del_t *mp;
14945 u16 *low_ports = 0;
14946 u16 *high_ports = 0;
14949 ip4_address_t ip4_addr;
14950 ip6_address_t ip6_addr;
14958 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14960 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
14966 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
14971 else if (unformat (input, "vrf %d", &vrf_id))
14973 else if (unformat (input, "del"))
14975 else if (unformat (input, "port %d", &tmp))
14977 if (tmp == 0 || tmp > 65535)
14979 errmsg ("port %d out of range", tmp);
14983 this_hi = this_low + 1;
14984 vec_add1 (low_ports, this_low);
14985 vec_add1 (high_ports, this_hi);
14987 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
14989 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
14991 errmsg ("incorrect range parameters\n");
14995 /* Note: in debug CLI +1 is added to high before
14996 passing to real fn that does "the work"
14997 (ip_source_and_port_range_check_add_del).
14998 This fn is a wrapper around the binary API fn a
14999 control plane will call, which expects this increment
15000 to have occurred. Hence letting the binary API control
15001 plane fn do the increment for consistency between VAT
15002 and other control planes.
15005 vec_add1 (low_ports, this_low);
15006 vec_add1 (high_ports, this_hi);
15012 if (prefix_set == 0)
15014 errmsg ("<address>/<mask> not specified\n");
15020 errmsg ("VRF ID required, not specified\n");
15027 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
15031 if (vec_len (low_ports) == 0)
15033 errmsg ("At least one port or port range required\n");
15037 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,
15038 ip_source_and_port_range_check_add_del);
15040 mp->is_add = is_add;
15045 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
15050 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
15053 mp->mask_length = length;
15054 mp->number_of_ranges = vec_len (low_ports);
15056 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
15057 vec_free (low_ports);
15059 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
15060 vec_free (high_ports);
15062 mp->vrf_id = ntohl (vrf_id);
15071 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
15073 unformat_input_t *input = vam->input;
15074 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
15076 u32 sw_if_index = ~0;
15078 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
15079 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
15082 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15084 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
15086 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15088 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
15090 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
15092 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
15094 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
15096 else if (unformat (input, "del"))
15102 if (sw_if_index == ~0)
15104 errmsg ("Interface required but not specified\n");
15110 errmsg ("VRF ID required but not specified\n");
15114 if (tcp_out_vrf_id == 0
15115 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
15118 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
15122 /* Construct the API message */
15123 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,
15124 ip_source_and_port_range_check_interface_add_del);
15126 mp->sw_if_index = ntohl (sw_if_index);
15127 mp->is_add = is_add;
15128 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
15129 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
15130 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
15131 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
15136 /* Wait for a reply... */
15141 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
15143 unformat_input_t *i = vam->input;
15144 vl_api_ipsec_gre_add_del_tunnel_t *mp;
15146 u32 local_sa_id = 0;
15147 u32 remote_sa_id = 0;
15148 ip4_address_t src_address;
15149 ip4_address_t dst_address;
15152 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15154 if (unformat (i, "local_sa %d", &local_sa_id))
15156 else if (unformat (i, "remote_sa %d", &remote_sa_id))
15158 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
15160 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
15162 else if (unformat (i, "del"))
15166 clib_warning ("parse error '%U'", format_unformat_error, i);
15171 M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel);
15173 mp->local_sa_id = ntohl (local_sa_id);
15174 mp->remote_sa_id = ntohl (remote_sa_id);
15175 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
15176 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
15177 mp->is_add = is_add;
15185 static void vl_api_ipsec_gre_tunnel_details_t_handler
15186 (vl_api_ipsec_gre_tunnel_details_t * mp)
15188 vat_main_t *vam = &vat_main;
15190 fformat (vam->ofp, "%11d%15U%15U%14d%14d\n",
15191 ntohl (mp->sw_if_index),
15192 format_ip4_address, &mp->src_address,
15193 format_ip4_address, &mp->dst_address,
15194 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
15197 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
15198 (vl_api_ipsec_gre_tunnel_details_t * mp)
15200 vat_main_t *vam = &vat_main;
15201 vat_json_node_t *node = NULL;
15202 struct in_addr ip4;
15204 if (VAT_JSON_ARRAY != vam->json_tree.type)
15206 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15207 vat_json_init_array (&vam->json_tree);
15209 node = vat_json_array_add (&vam->json_tree);
15211 vat_json_init_object (node);
15212 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15213 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
15214 vat_json_object_add_ip4 (node, "src_address", ip4);
15215 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
15216 vat_json_object_add_ip4 (node, "dst_address", ip4);
15217 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
15218 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
15222 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
15224 unformat_input_t *i = vam->input;
15225 vl_api_ipsec_gre_tunnel_dump_t *mp;
15228 u8 sw_if_index_set = 0;
15230 /* Parse args required to build the message */
15231 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15233 if (unformat (i, "sw_if_index %d", &sw_if_index))
15234 sw_if_index_set = 1;
15239 if (sw_if_index_set == 0)
15244 if (!vam->json_output)
15246 fformat (vam->ofp, "%11s%15s%15s%14s%14s\n",
15247 "sw_if_index", "src_address", "dst_address",
15248 "local_sa_id", "remote_sa_id");
15251 /* Get list of gre-tunnel interfaces */
15252 M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump);
15254 mp->sw_if_index = htonl (sw_if_index);
15258 /* Use a control ping for synchronization */
15260 vl_api_control_ping_t *mp;
15261 M (CONTROL_PING, control_ping);
15268 api_delete_subif (vat_main_t * vam)
15270 unformat_input_t *i = vam->input;
15271 vl_api_delete_subif_t *mp;
15273 u32 sw_if_index = ~0;
15275 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15277 if (unformat (i, "sw_if_index %d", &sw_if_index))
15283 if (sw_if_index == ~0)
15285 errmsg ("missing sw_if_index\n");
15289 /* Construct the API message */
15290 M (DELETE_SUBIF, delete_subif);
15291 mp->sw_if_index = ntohl (sw_if_index);
15298 q_or_quit (vat_main_t * vam)
15300 longjmp (vam->jump_buf, 1);
15301 return 0; /* not so much */
15305 q (vat_main_t * vam)
15307 return q_or_quit (vam);
15311 quit (vat_main_t * vam)
15313 return q_or_quit (vam);
15317 comment (vat_main_t * vam)
15323 cmd_cmp (void *a1, void *a2)
15328 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
15332 help (vat_main_t * vam)
15337 unformat_input_t *i = vam->input;
15340 if (unformat (i, "%s", &name))
15344 vec_add1 (name, 0);
15346 hs = hash_get_mem (vam->help_by_name, name);
15348 fformat (vam->ofp, "usage: %s %s\n", name, hs[0]);
15350 fformat (vam->ofp, "No such msg / command '%s'\n", name);
15355 fformat (vam->ofp, "Help is available for the following:\n");
15358 hash_foreach_pair (p, vam->function_by_name,
15360 vec_add1 (cmds, (u8 *)(p->key));
15364 vec_sort_with_function (cmds, cmd_cmp);
15366 for (j = 0; j < vec_len (cmds); j++)
15367 fformat (vam->ofp, "%s\n", cmds[j]);
15374 set (vat_main_t * vam)
15376 u8 *name = 0, *value = 0;
15377 unformat_input_t *i = vam->input;
15379 if (unformat (i, "%s", &name))
15381 /* The input buffer is a vector, not a string. */
15382 value = vec_dup (i->buffer);
15383 vec_delete (value, i->index, 0);
15384 /* Almost certainly has a trailing newline */
15385 if (value[vec_len (value) - 1] == '\n')
15386 value[vec_len (value) - 1] = 0;
15387 /* Make sure it's a proper string, one way or the other */
15388 vec_add1 (value, 0);
15389 (void) clib_macro_set_value (&vam->macro_main,
15390 (char *) name, (char *) value);
15393 errmsg ("usage: set <name> <value>\n");
15401 unset (vat_main_t * vam)
15405 if (unformat (vam->input, "%s", &name))
15406 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
15407 errmsg ("unset: %s wasn't set\n", name);
15420 macro_sort_cmp (void *a1, void *a2)
15422 macro_sort_t *s1 = a1;
15423 macro_sort_t *s2 = a2;
15425 return strcmp ((char *) (s1->name), (char *) (s2->name));
15429 dump_macro_table (vat_main_t * vam)
15431 macro_sort_t *sort_me = 0, *sm;
15436 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
15438 vec_add2 (sort_me, sm, 1);
15439 sm->name = (u8 *)(p->key);
15440 sm->value = (u8 *) (p->value[0]);
15444 vec_sort_with_function (sort_me, macro_sort_cmp);
15446 if (vec_len (sort_me))
15447 fformat (vam->ofp, "%-15s%s\n", "Name", "Value");
15449 fformat (vam->ofp, "The macro table is empty...\n");
15451 for (i = 0; i < vec_len (sort_me); i++)
15452 fformat (vam->ofp, "%-15s%s\n", sort_me[i].name, sort_me[i].value);
15457 dump_node_table (vat_main_t * vam)
15460 vlib_node_t *node, *next_node;
15462 if (vec_len (vam->graph_nodes) == 0)
15464 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
15468 for (i = 0; i < vec_len (vam->graph_nodes); i++)
15470 node = vam->graph_nodes[i];
15471 fformat (vam->ofp, "[%d] %s\n", i, node->name);
15472 for (j = 0; j < vec_len (node->next_nodes); j++)
15474 if (node->next_nodes[j] != ~0)
15476 next_node = vam->graph_nodes[node->next_nodes[j]];
15477 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
15485 search_node_table (vat_main_t * vam)
15487 unformat_input_t *line_input = vam->input;
15490 vlib_node_t *node, *next_node;
15493 if (vam->graph_node_index_by_name == 0)
15495 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
15499 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15501 if (unformat (line_input, "%s", &node_to_find))
15503 vec_add1 (node_to_find, 0);
15504 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
15507 fformat (vam->ofp, "%s not found...\n", node_to_find);
15510 node = vam->graph_nodes[p[0]];
15511 fformat (vam->ofp, "[%d] %s\n", p[0], node->name);
15512 for (j = 0; j < vec_len (node->next_nodes); j++)
15514 if (node->next_nodes[j] != ~0)
15516 next_node = vam->graph_nodes[node->next_nodes[j]];
15517 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
15524 clib_warning ("parse error '%U'", format_unformat_error,
15530 vec_free (node_to_find);
15539 script (vat_main_t * vam)
15542 char *save_current_file;
15543 unformat_input_t save_input;
15544 jmp_buf save_jump_buf;
15545 u32 save_line_number;
15547 FILE *new_fp, *save_ifp;
15549 if (unformat (vam->input, "%s", &s))
15551 new_fp = fopen ((char *) s, "r");
15554 errmsg ("Couldn't open script file %s\n", s);
15561 errmsg ("Missing script name\n");
15565 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
15566 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
15567 save_ifp = vam->ifp;
15568 save_line_number = vam->input_line_number;
15569 save_current_file = (char *) vam->current_file;
15571 vam->input_line_number = 0;
15573 vam->current_file = s;
15576 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
15577 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
15578 vam->ifp = save_ifp;
15579 vam->input_line_number = save_line_number;
15580 vam->current_file = (u8 *) save_current_file;
15587 echo (vat_main_t * vam)
15589 fformat (vam->ofp, "%v", vam->input->buffer);
15593 /* List of API message constructors, CLI names map to api_xxx */
15594 #define foreach_vpe_api_msg \
15595 _(create_loopback,"[mac <mac-addr>]") \
15596 _(sw_interface_dump,"") \
15597 _(sw_interface_set_flags, \
15598 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
15599 _(sw_interface_add_del_address, \
15600 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
15601 _(sw_interface_set_table, \
15602 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
15603 _(sw_interface_set_vpath, \
15604 "<intfc> | sw_if_index <id> enable | disable") \
15605 _(sw_interface_set_l2_xconnect, \
15606 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
15607 "enable | disable") \
15608 _(sw_interface_set_l2_bridge, \
15609 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
15610 "[shg <split-horizon-group>] [bvi]\n" \
15611 "enable | disable") \
15612 _(bridge_domain_add_del, \
15613 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n")\
15614 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
15616 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
15618 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
15620 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
15622 "tapname <name> mac <mac-addr> | random-mac") \
15624 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
15626 "<vpp-if-name> | sw_if_index <id>") \
15627 _(sw_interface_tap_dump, "") \
15628 _(ip_add_del_route, \
15629 "<addr>/<mask> via <addr> [vrf <n>]\n" \
15630 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
15631 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
15632 "[multipath] [count <n>]") \
15633 _(proxy_arp_add_del, \
15634 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
15635 _(proxy_arp_intfc_enable_disable, \
15636 "<intfc> | sw_if_index <id> enable | disable") \
15637 _(mpls_add_del_encap, \
15638 "label <n> dst <ip4-addr> [vrf <n>] [del]") \
15639 _(mpls_add_del_decap, \
15640 "label <n> [rx_vrf_id <n>] [tx_vrf_id] [s-bit-clear][del]") \
15641 _(mpls_gre_add_del_tunnel, \
15642 "inner_vrf_id <n> outer_vrf_id <n> src <ip4-address> dst <ip4-address>\n" \
15643 "adj <ip4-address>/<mask-width> [del]") \
15644 _(sw_interface_set_unnumbered, \
15645 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
15646 _(ip_neighbor_add_del, \
15647 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
15648 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
15649 _(reset_vrf, "vrf <id> [ipv6]") \
15650 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
15651 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
15652 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
15653 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
15654 "[outer_vlan_id_any][inner_vlan_id_any]") \
15655 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
15656 _(reset_fib, "vrf <n> [ipv6]") \
15657 _(dhcp_proxy_config, \
15658 "svr <v46-address> src <v46-address>\n" \
15659 "insert-cid <n> [del]") \
15660 _(dhcp_proxy_config_2, \
15661 "svr <v46-address> src <v46-address>\n" \
15662 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
15663 _(dhcp_proxy_set_vss, \
15664 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
15665 _(dhcp_client_config, \
15666 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
15667 _(set_ip_flow_hash, \
15668 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
15669 _(sw_interface_ip6_enable_disable, \
15670 "<intfc> | sw_if_index <id> enable | disable") \
15671 _(sw_interface_ip6_set_link_local_address, \
15672 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
15673 _(sw_interface_ip6nd_ra_prefix, \
15674 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
15675 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
15676 "[nolink] [isno]") \
15677 _(sw_interface_ip6nd_ra_config, \
15678 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
15679 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
15680 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
15681 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
15682 _(l2_patch_add_del, \
15683 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
15684 "enable | disable") \
15685 _(mpls_ethernet_add_del_tunnel, \
15686 "tx <intfc> | tx_sw_if_index <n> dst <mac-addr>\n" \
15687 "adj <ip4-addr>/<mw> dst <mac-addr> [del]") \
15688 _(mpls_ethernet_add_del_tunnel_2, \
15689 "inner_vrf_id <n> outer_vrf_id <n> next-hop <ip4-addr>\n" \
15690 "resolve-attempts <n> resolve-if-needed 0 | 1 [del]") \
15691 _(sr_tunnel_add_del, \
15692 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
15693 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
15694 "[policy <policy_name>]") \
15695 _(sr_policy_add_del, \
15696 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
15697 _(sr_multicast_map_add_del, \
15698 "address [ip6 multicast address] sr-policy [policy name] [del]") \
15699 _(classify_add_del_table, \
15700 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
15701 "[del] mask <mask-value>\n" \
15702 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>") \
15703 _(classify_add_del_session, \
15704 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
15705 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
15706 " [l3 [ip4|ip6]]") \
15707 _(classify_set_interface_ip_table, \
15708 "<intfc> | sw_if_index <nn> table <nn>") \
15709 _(classify_set_interface_l2_tables, \
15710 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
15711 " [other-table <nn>]") \
15712 _(get_node_index, "node <node-name") \
15713 _(add_node_next, "node <node-name> next <next-node-name>") \
15714 _(l2tpv3_create_tunnel, \
15715 "client_address <ip6-addr> our_address <ip6-addr>\n" \
15716 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n"\
15717 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
15718 _(l2tpv3_set_tunnel_cookies, \
15719 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
15720 "[new_remote_cookie <nn>]\n") \
15721 _(l2tpv3_interface_enable_disable, \
15722 "<intfc> | sw_if_index <nn> enable | disable") \
15723 _(l2tpv3_set_lookup_key, \
15724 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
15725 _(sw_if_l2tpv3_tunnel_dump, "") \
15726 _(vxlan_add_del_tunnel, \
15727 "src <ip-addr> dst <ip-addr> vni <vni> [encap-vrf-id <nn>]\n" \
15728 " [decap-next l2|ip4|ip6] [del]") \
15729 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
15730 _(gre_add_del_tunnel, \
15731 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [del]\n") \
15732 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
15733 _(l2_fib_clear_table, "") \
15734 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
15735 _(l2_interface_vlan_tag_rewrite, \
15736 "<intfc> | sw_if_index <nn> \n" \
15737 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
15738 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
15739 _(create_vhost_user_if, \
15740 "socket <filename> [server] [renumber <dev_instance>] " \
15741 "[mac <mac_address>]") \
15742 _(modify_vhost_user_if, \
15743 "<intfc> | sw_if_index <nn> socket <filename>\n" \
15744 "[server] [renumber <dev_instance>]") \
15745 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
15746 _(sw_interface_vhost_user_dump, "") \
15747 _(show_version, "") \
15748 _(vxlan_gpe_add_del_tunnel, \
15749 "local <addr> remote <addr> vni <nn>\n" \
15750 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
15751 "[next-ethernet] [next-nsh]\n") \
15752 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
15753 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
15754 _(interface_name_renumber, \
15755 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
15756 _(input_acl_set_interface, \
15757 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
15758 " [l2-table <nn>] [del]") \
15759 _(want_ip4_arp_events, "address <ip4-address> [del]") \
15760 _(want_ip6_nd_events, "address <ip6-address> [del]") \
15761 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
15762 _(ip_dump, "ipv4 | ipv6") \
15763 _(ipsec_spd_add_del, "spd_id <n> [del]") \
15764 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
15766 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
15767 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
15768 " integ_alg <alg> integ_key <hex>") \
15769 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
15770 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
15771 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
15772 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" )\
15773 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
15774 _(ikev2_profile_add_del, "name <profile_name> [del]") \
15775 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
15776 "(auth_data 0x<data> | auth_data <data>)") \
15777 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
15778 "(id_data 0x<data> | id_data <data>) (local|remote)") \
15779 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
15780 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
15781 "(local|remote)") \
15782 _(ikev2_set_local_key, "file <absolute_file_path>") \
15783 _(delete_loopback,"sw_if_index <nn>") \
15784 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
15785 _(map_add_domain, \
15786 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
15787 "ip6-src <ip6addr> " \
15788 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
15789 _(map_del_domain, "index <n>") \
15790 _(map_add_del_rule, \
15791 "index <n> psid <n> dst <ip6addr> [del]") \
15792 _(map_domain_dump, "") \
15793 _(map_rule_dump, "index <map-domain>") \
15794 _(want_interface_events, "enable|disable") \
15795 _(want_stats,"enable|disable") \
15796 _(get_first_msg_id, "client <name>") \
15797 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
15798 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
15799 "fib-id <nn> [ip4][ip6][default]") \
15800 _(get_node_graph, " ") \
15801 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
15802 _(trace_profile_add, "id <nn> trace-type <0x1f|0x3|0x9|0x11|0x19> " \
15803 "trace-elts <nn> trace-tsp <0|1|2|3> node-id <node id in hex> " \
15804 "app-data <app_data in hex> [pow] [ppc <encap|decap>]") \
15805 _(trace_profile_apply, "id <nn> <ip6-address>/<width>" \
15806 " vrf_id <nn> add | pop | none") \
15807 _(trace_profile_del, "") \
15808 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
15809 " sw_if_index <sw_if_index> p <priority> " \
15810 "w <weight>] [del]") \
15811 _(lisp_add_del_locator, "locator-set <locator_name> " \
15812 "iface <intf> | sw_if_index <sw_if_index> " \
15813 "p <priority> w <weight> [del]") \
15814 _(lisp_add_del_local_eid,"vni <vni> eid " \
15815 "<ipv4|ipv6>/<prefix> | <L2 address> " \
15816 "locator-set <locator_name> [del]") \
15817 _(lisp_gpe_add_del_fwd_entry, "rmt_eid <eid> [lcl_eid <eid>] vni <vni>" \
15818 "dp_table <table> loc-pair <lcl_loc> <rmt_loc> ... [del]") \
15819 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
15820 _(lisp_gpe_enable_disable, "enable|disable") \
15821 _(lisp_enable_disable, "enable|disable") \
15822 _(lisp_gpe_add_del_iface, "up|down") \
15823 _(lisp_add_del_remote_mapping, "add|del vni <vni> deid <dest-eid> " \
15824 "rloc <locator> p <prio> " \
15825 "w <weight> [rloc <loc> ... ] " \
15826 "action <action> [del-all]") \
15827 _(lisp_add_del_adjacency, "add|del vni <vni> deid <dest-eid> seid " \
15828 "<src-eid> rloc <locator> p <prio> w <weight>"\
15829 "[rloc <loc> ... ] action <action>") \
15830 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
15831 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
15832 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
15833 _(lisp_locator_set_dump, "[locator-set-index <ls-index> | " \
15834 "locator-set <loc-set-name>] [local | remote]")\
15835 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
15836 "[local] | [remote]") \
15837 _(lisp_eid_table_vni_dump, "") \
15838 _(lisp_eid_table_map_dump, "l2|l3") \
15839 _(lisp_gpe_tunnel_dump, "") \
15840 _(lisp_map_resolver_dump, "") \
15841 _(show_lisp_status, "") \
15842 _(lisp_get_map_request_itr_rlocs, "") \
15843 _(show_lisp_pitr, "") \
15844 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
15845 _(af_packet_delete, "name <host interface name>") \
15846 _(policer_add_del, "name <policer name> <params> [del]") \
15847 _(policer_dump, "[name <policer name>]") \
15848 _(policer_classify_set_interface, \
15849 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
15850 " [l2-table <nn>] [del]") \
15851 _(policer_classify_dump, "type [ip4|ip6|l2]") \
15852 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
15853 "[master|slave]") \
15854 _(netmap_delete, "name <interface name>") \
15855 _(mpls_gre_tunnel_dump, "tunnel_index <tunnel-id>") \
15856 _(mpls_eth_tunnel_dump, "tunnel_index <tunnel-id>") \
15857 _(mpls_fib_encap_dump, "") \
15858 _(mpls_fib_decap_dump, "") \
15859 _(classify_table_ids, "") \
15860 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
15861 _(classify_table_info, "table_id <nn>") \
15862 _(classify_session_dump, "table_id <nn>") \
15863 _(ipfix_enable, "collector_address <ip4> [collector_port <nn>] " \
15864 "src_address <ip4> [fib_id <nn>] [path_mtu <nn>] " \
15865 "[template_interval <nn>]") \
15866 _(ipfix_dump, "") \
15867 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
15868 _(pg_create_interface, "if_id <nn>") \
15869 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
15870 _(pg_enable_disable, "[stream <id>] disable") \
15871 _(ip_source_and_port_range_check_add_del, \
15872 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
15873 _(ip_source_and_port_range_check_interface_add_del, \
15874 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
15875 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
15876 _(ipsec_gre_add_del_tunnel, \
15877 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
15878 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
15879 _(delete_subif,"sub_sw_if_index <nn> sub_if_id <nn>")
15881 /* List of command functions, CLI names map directly to functions */
15882 #define foreach_cli_function \
15883 _(comment, "usage: comment <ignore-rest-of-line>") \
15884 _(dump_interface_table, "usage: dump_interface_table") \
15885 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
15886 _(dump_ipv4_table, "usage: dump_ipv4_table") \
15887 _(dump_ipv6_table, "usage: dump_ipv6_table") \
15888 _(dump_stats_table, "usage: dump_stats_table") \
15889 _(dump_macro_table, "usage: dump_macro_table ") \
15890 _(dump_node_table, "usage: dump_node_table") \
15891 _(echo, "usage: echo <message>") \
15892 _(exec, "usage: exec <vpe-debug-CLI-command>") \
15893 _(help, "usage: help") \
15894 _(q, "usage: quit") \
15895 _(quit, "usage: quit") \
15896 _(search_node_table, "usage: search_node_table <name>...") \
15897 _(set, "usage: set <variable-name> <value>") \
15898 _(script, "usage: script <file-name>") \
15899 _(unset, "usage: unset <variable-name>")
15902 static void vl_api_##n##_t_handler_uni \
15903 (vl_api_##n##_t * mp) \
15905 vat_main_t * vam = &vat_main; \
15906 if (vam->json_output) { \
15907 vl_api_##n##_t_handler_json(mp); \
15909 vl_api_##n##_t_handler(mp); \
15912 foreach_vpe_api_reply_msg;
15916 vat_api_hookup (vat_main_t * vam)
15919 vl_msg_api_set_handlers(VL_API_##N, #n, \
15920 vl_api_##n##_t_handler_uni, \
15922 vl_api_##n##_t_endian, \
15923 vl_api_##n##_t_print, \
15924 sizeof(vl_api_##n##_t), 1);
15925 foreach_vpe_api_reply_msg;
15928 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
15930 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
15932 vam->function_by_name = hash_create_string (0, sizeof (uword));
15934 vam->help_by_name = hash_create_string (0, sizeof (uword));
15936 /* API messages we can send */
15937 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
15938 foreach_vpe_api_msg;
15942 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
15943 foreach_vpe_api_msg;
15946 /* CLI functions */
15947 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
15948 foreach_cli_function;
15952 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
15953 foreach_cli_function;
15957 #undef vl_api_version
15958 #define vl_api_version(n,v) static u32 vpe_api_version = v;
15959 #include <vpp-api/vpe.api.h>
15960 #undef vl_api_version
15963 vl_client_add_api_signatures (vl_api_memclnt_create_t * mp)
15966 * Send the main API signature in slot 0. This bit of code must
15967 * match the checks in ../vpe/api/api.c: vl_msg_api_version_check().
15969 mp->api_versions[0] = clib_host_to_net_u32 (vpe_api_version);
15973 * fd.io coding-style-patch-verification: ON
15976 * eval: (c-set-style "gnu")