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 * Special-case: build the bridge domain table, maintain
1139 * the next bd id vbl.
1141 static void vl_api_bridge_domain_details_t_handler
1142 (vl_api_bridge_domain_details_t * mp)
1144 vat_main_t *vam = &vat_main;
1145 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1147 fformat (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s\n",
1148 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1150 fformat (vam->ofp, "%3d %3d %3d %3d %3d %3d\n",
1151 ntohl (mp->bd_id), mp->learn, mp->forward,
1152 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1155 fformat (vam->ofp, "\n\n%s %s %s\n", "sw_if_index", "SHG",
1159 static void vl_api_bridge_domain_details_t_handler_json
1160 (vl_api_bridge_domain_details_t * mp)
1162 vat_main_t *vam = &vat_main;
1163 vat_json_node_t *node, *array = NULL;
1165 if (VAT_JSON_ARRAY != vam->json_tree.type)
1167 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1168 vat_json_init_array (&vam->json_tree);
1170 node = vat_json_array_add (&vam->json_tree);
1172 vat_json_init_object (node);
1173 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1174 vat_json_object_add_uint (node, "flood", mp->flood);
1175 vat_json_object_add_uint (node, "forward", mp->forward);
1176 vat_json_object_add_uint (node, "learn", mp->learn);
1177 vat_json_object_add_uint (node, "bvi_sw_if_index",
1178 ntohl (mp->bvi_sw_if_index));
1179 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1180 array = vat_json_object_add (node, "sw_if");
1181 vat_json_init_array (array);
1185 * Special-case: build the bridge domain sw if table.
1187 static void vl_api_bridge_domain_sw_if_details_t_handler
1188 (vl_api_bridge_domain_sw_if_details_t * mp)
1190 vat_main_t *vam = &vat_main;
1195 sw_if_index = ntohl (mp->sw_if_index);
1197 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1199 if ((u32) p->value[0] == sw_if_index)
1201 sw_if_name = (u8 *)(p->key);
1207 fformat (vam->ofp, "%7d %3d %s", sw_if_index,
1208 mp->shg, sw_if_name ? (char *) sw_if_name :
1209 "sw_if_index not found!");
1212 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1213 (vl_api_bridge_domain_sw_if_details_t * mp)
1215 vat_main_t *vam = &vat_main;
1216 vat_json_node_t *node = NULL;
1217 uword last_index = 0;
1219 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1220 ASSERT (vec_len (vam->json_tree.array) >= 1);
1221 last_index = vec_len (vam->json_tree.array) - 1;
1222 node = &vam->json_tree.array[last_index];
1223 node = vat_json_object_get_element (node, "sw_if");
1224 ASSERT (NULL != node);
1225 node = vat_json_array_add (node);
1227 vat_json_init_object (node);
1228 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1229 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1230 vat_json_object_add_uint (node, "shg", mp->shg);
1233 static void vl_api_control_ping_reply_t_handler
1234 (vl_api_control_ping_reply_t * mp)
1236 vat_main_t *vam = &vat_main;
1237 i32 retval = ntohl (mp->retval);
1238 if (vam->async_mode)
1240 vam->async_errors += (retval < 0);
1244 vam->retval = retval;
1245 vam->result_ready = 1;
1249 static void vl_api_control_ping_reply_t_handler_json
1250 (vl_api_control_ping_reply_t * mp)
1252 vat_main_t *vam = &vat_main;
1253 i32 retval = ntohl (mp->retval);
1255 if (VAT_JSON_NONE != vam->json_tree.type)
1257 vat_json_print (vam->ofp, &vam->json_tree);
1258 vat_json_free (&vam->json_tree);
1259 vam->json_tree.type = VAT_JSON_NONE;
1264 vat_json_init_array (&vam->json_tree);
1265 vat_json_print (vam->ofp, &vam->json_tree);
1266 vam->json_tree.type = VAT_JSON_NONE;
1269 vam->retval = retval;
1270 vam->result_ready = 1;
1273 static void vl_api_noprint_control_ping_reply_t_handler
1274 (vl_api_noprint_control_ping_reply_t * mp)
1276 vat_main_t *vam = &vat_main;
1277 i32 retval = ntohl (mp->retval);
1278 if (vam->async_mode)
1280 vam->async_errors += (retval < 0);
1284 vam->retval = retval;
1285 vam->result_ready = 1;
1289 static void vl_api_noprint_control_ping_reply_t_handler_json
1290 (vl_api_noprint_control_ping_reply_t * mp)
1292 vat_main_t *vam = &vat_main;
1293 i32 retval = ntohl (mp->retval);
1295 if (vam->noprint_msg)
1297 vam->retval = retval;
1298 vam->result_ready = 1;
1302 if (VAT_JSON_NONE != vam->json_tree.type)
1304 vat_json_print (vam->ofp, &vam->json_tree);
1305 vat_json_free (&vam->json_tree);
1306 vam->json_tree.type = VAT_JSON_NONE;
1311 vat_json_init_array (&vam->json_tree);
1312 vat_json_print (vam->ofp, &vam->json_tree);
1313 vam->json_tree.type = VAT_JSON_NONE;
1316 vam->retval = retval;
1317 vam->result_ready = 1;
1321 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1323 vat_main_t *vam = &vat_main;
1324 i32 retval = ntohl (mp->retval);
1325 if (vam->async_mode)
1327 vam->async_errors += (retval < 0);
1331 vam->retval = retval;
1332 vam->result_ready = 1;
1336 static void vl_api_l2_flags_reply_t_handler_json
1337 (vl_api_l2_flags_reply_t * mp)
1339 vat_main_t *vam = &vat_main;
1340 vat_json_node_t node;
1342 vat_json_init_object (&node);
1343 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1344 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1345 ntohl (mp->resulting_feature_bitmap));
1347 vat_json_print (vam->ofp, &node);
1348 vat_json_free (&node);
1350 vam->retval = ntohl (mp->retval);
1351 vam->result_ready = 1;
1354 static void vl_api_bridge_flags_reply_t_handler
1355 (vl_api_bridge_flags_reply_t * mp)
1357 vat_main_t *vam = &vat_main;
1358 i32 retval = ntohl (mp->retval);
1359 if (vam->async_mode)
1361 vam->async_errors += (retval < 0);
1365 vam->retval = retval;
1366 vam->result_ready = 1;
1370 static void vl_api_bridge_flags_reply_t_handler_json
1371 (vl_api_bridge_flags_reply_t * mp)
1373 vat_main_t *vam = &vat_main;
1374 vat_json_node_t node;
1376 vat_json_init_object (&node);
1377 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1378 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1379 ntohl (mp->resulting_feature_bitmap));
1381 vat_json_print (vam->ofp, &node);
1382 vat_json_free (&node);
1384 vam->retval = ntohl (mp->retval);
1385 vam->result_ready = 1;
1388 static void vl_api_tap_connect_reply_t_handler
1389 (vl_api_tap_connect_reply_t * mp)
1391 vat_main_t *vam = &vat_main;
1392 i32 retval = ntohl (mp->retval);
1393 if (vam->async_mode)
1395 vam->async_errors += (retval < 0);
1399 vam->retval = retval;
1400 vam->sw_if_index = ntohl (mp->sw_if_index);
1401 vam->result_ready = 1;
1406 static void vl_api_tap_connect_reply_t_handler_json
1407 (vl_api_tap_connect_reply_t * mp)
1409 vat_main_t *vam = &vat_main;
1410 vat_json_node_t node;
1412 vat_json_init_object (&node);
1413 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1414 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1416 vat_json_print (vam->ofp, &node);
1417 vat_json_free (&node);
1419 vam->retval = ntohl (mp->retval);
1420 vam->result_ready = 1;
1425 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1427 vat_main_t *vam = &vat_main;
1428 i32 retval = ntohl (mp->retval);
1429 if (vam->async_mode)
1431 vam->async_errors += (retval < 0);
1435 vam->retval = retval;
1436 vam->sw_if_index = ntohl (mp->sw_if_index);
1437 vam->result_ready = 1;
1441 static void vl_api_tap_modify_reply_t_handler_json
1442 (vl_api_tap_modify_reply_t * mp)
1444 vat_main_t *vam = &vat_main;
1445 vat_json_node_t node;
1447 vat_json_init_object (&node);
1448 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1449 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1451 vat_json_print (vam->ofp, &node);
1452 vat_json_free (&node);
1454 vam->retval = ntohl (mp->retval);
1455 vam->result_ready = 1;
1459 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1461 vat_main_t *vam = &vat_main;
1462 i32 retval = ntohl (mp->retval);
1463 if (vam->async_mode)
1465 vam->async_errors += (retval < 0);
1469 vam->retval = retval;
1470 vam->result_ready = 1;
1474 static void vl_api_tap_delete_reply_t_handler_json
1475 (vl_api_tap_delete_reply_t * mp)
1477 vat_main_t *vam = &vat_main;
1478 vat_json_node_t node;
1480 vat_json_init_object (&node);
1481 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1483 vat_json_print (vam->ofp, &node);
1484 vat_json_free (&node);
1486 vam->retval = ntohl (mp->retval);
1487 vam->result_ready = 1;
1490 static void vl_api_mpls_ethernet_add_del_tunnel_reply_t_handler
1491 (vl_api_mpls_ethernet_add_del_tunnel_reply_t * mp)
1493 vat_main_t *vam = &vat_main;
1494 i32 retval = ntohl (mp->retval);
1495 if (vam->async_mode)
1497 vam->async_errors += (retval < 0);
1501 vam->retval = retval;
1502 vam->result_ready = 1;
1506 static void vl_api_mpls_ethernet_add_del_tunnel_reply_t_handler_json
1507 (vl_api_mpls_ethernet_add_del_tunnel_reply_t * mp)
1509 vat_main_t *vam = &vat_main;
1510 vat_json_node_t node;
1512 vat_json_init_object (&node);
1513 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1514 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1515 ntohl (mp->tunnel_sw_if_index));
1517 vat_json_print (vam->ofp, &node);
1518 vat_json_free (&node);
1520 vam->retval = ntohl (mp->retval);
1521 vam->result_ready = 1;
1524 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1525 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1527 vat_main_t *vam = &vat_main;
1528 i32 retval = ntohl (mp->retval);
1529 if (vam->async_mode)
1531 vam->async_errors += (retval < 0);
1535 vam->retval = retval;
1536 vam->sw_if_index = ntohl (mp->sw_if_index);
1537 vam->result_ready = 1;
1541 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1542 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1544 vat_main_t *vam = &vat_main;
1545 vat_json_node_t node;
1547 vat_json_init_object (&node);
1548 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1549 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1551 vat_json_print (vam->ofp, &node);
1552 vat_json_free (&node);
1554 vam->retval = ntohl (mp->retval);
1555 vam->result_ready = 1;
1559 static void vl_api_lisp_add_del_locator_set_reply_t_handler
1560 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1562 vat_main_t *vam = &vat_main;
1563 i32 retval = ntohl (mp->retval);
1564 if (vam->async_mode)
1566 vam->async_errors += (retval < 0);
1570 vam->retval = retval;
1571 vam->result_ready = 1;
1575 static void vl_api_lisp_add_del_locator_set_reply_t_handler_json
1576 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1578 vat_main_t *vam = &vat_main;
1579 vat_json_node_t node;
1581 vat_json_init_object (&node);
1582 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1583 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1585 vat_json_print (vam->ofp, &node);
1586 vat_json_free (&node);
1588 vam->retval = ntohl (mp->retval);
1589 vam->result_ready = 1;
1592 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1593 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1595 vat_main_t *vam = &vat_main;
1596 i32 retval = ntohl (mp->retval);
1597 if (vam->async_mode)
1599 vam->async_errors += (retval < 0);
1603 vam->retval = retval;
1604 vam->sw_if_index = ntohl (mp->sw_if_index);
1605 vam->result_ready = 1;
1609 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1610 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1612 vat_main_t *vam = &vat_main;
1613 vat_json_node_t node;
1615 vat_json_init_object (&node);
1616 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1617 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1619 vat_json_print (vam->ofp, &node);
1620 vat_json_free (&node);
1622 vam->retval = ntohl (mp->retval);
1623 vam->result_ready = 1;
1626 static void vl_api_gre_add_del_tunnel_reply_t_handler
1627 (vl_api_gre_add_del_tunnel_reply_t * mp)
1629 vat_main_t *vam = &vat_main;
1630 i32 retval = ntohl (mp->retval);
1631 if (vam->async_mode)
1633 vam->async_errors += (retval < 0);
1637 vam->retval = retval;
1638 vam->sw_if_index = ntohl (mp->sw_if_index);
1639 vam->result_ready = 1;
1643 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1644 (vl_api_gre_add_del_tunnel_reply_t * mp)
1646 vat_main_t *vam = &vat_main;
1647 vat_json_node_t node;
1649 vat_json_init_object (&node);
1650 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1651 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1653 vat_json_print (vam->ofp, &node);
1654 vat_json_free (&node);
1656 vam->retval = ntohl (mp->retval);
1657 vam->result_ready = 1;
1660 static void vl_api_create_vhost_user_if_reply_t_handler
1661 (vl_api_create_vhost_user_if_reply_t * mp)
1663 vat_main_t *vam = &vat_main;
1664 i32 retval = ntohl (mp->retval);
1665 if (vam->async_mode)
1667 vam->async_errors += (retval < 0);
1671 vam->retval = retval;
1672 vam->sw_if_index = ntohl (mp->sw_if_index);
1673 vam->result_ready = 1;
1677 static void vl_api_create_vhost_user_if_reply_t_handler_json
1678 (vl_api_create_vhost_user_if_reply_t * mp)
1680 vat_main_t *vam = &vat_main;
1681 vat_json_node_t node;
1683 vat_json_init_object (&node);
1684 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1685 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1687 vat_json_print (vam->ofp, &node);
1688 vat_json_free (&node);
1690 vam->retval = ntohl (mp->retval);
1691 vam->result_ready = 1;
1694 static void vl_api_ip_address_details_t_handler
1695 (vl_api_ip_address_details_t * mp)
1697 vat_main_t *vam = &vat_main;
1698 static ip_address_details_t empty_ip_address_details = { {0} };
1699 ip_address_details_t *address = NULL;
1700 ip_details_t *current_ip_details = NULL;
1701 ip_details_t *details = NULL;
1703 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1705 if (!details || vam->current_sw_if_index >= vec_len (details)
1706 || !details[vam->current_sw_if_index].present)
1708 errmsg ("ip address details arrived but not stored\n");
1709 errmsg ("ip_dump should be called first\n");
1713 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1715 #define addresses (current_ip_details->addr)
1717 vec_validate_init_empty (addresses, vec_len (addresses),
1718 empty_ip_address_details);
1720 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1722 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1723 address->prefix_length = mp->prefix_length;
1727 static void vl_api_ip_address_details_t_handler_json
1728 (vl_api_ip_address_details_t * mp)
1730 vat_main_t *vam = &vat_main;
1731 vat_json_node_t *node = NULL;
1732 struct in6_addr ip6;
1735 if (VAT_JSON_ARRAY != vam->json_tree.type)
1737 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1738 vat_json_init_array (&vam->json_tree);
1740 node = vat_json_array_add (&vam->json_tree);
1742 vat_json_init_object (node);
1745 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1746 vat_json_object_add_ip6 (node, "ip", ip6);
1750 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1751 vat_json_object_add_ip4 (node, "ip", ip4);
1753 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1757 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1759 vat_main_t *vam = &vat_main;
1760 static ip_details_t empty_ip_details = { 0 };
1761 ip_details_t *ip = NULL;
1762 u32 sw_if_index = ~0;
1764 sw_if_index = ntohl (mp->sw_if_index);
1766 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1767 sw_if_index, empty_ip_details);
1769 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1776 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1778 vat_main_t *vam = &vat_main;
1780 if (VAT_JSON_ARRAY != vam->json_tree.type)
1782 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1783 vat_json_init_array (&vam->json_tree);
1785 vat_json_array_add_uint (&vam->json_tree,
1786 clib_net_to_host_u32 (mp->sw_if_index));
1789 static void vl_api_map_domain_details_t_handler_json
1790 (vl_api_map_domain_details_t * mp)
1792 vat_json_node_t *node = NULL;
1793 vat_main_t *vam = &vat_main;
1794 struct in6_addr ip6;
1797 if (VAT_JSON_ARRAY != vam->json_tree.type)
1799 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1800 vat_json_init_array (&vam->json_tree);
1803 node = vat_json_array_add (&vam->json_tree);
1804 vat_json_init_object (node);
1806 vat_json_object_add_uint (node, "domain_index",
1807 clib_net_to_host_u32 (mp->domain_index));
1808 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1809 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1810 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1811 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1812 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1813 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1814 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1815 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1816 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1817 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1818 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1819 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1820 vat_json_object_add_uint (node, "flags", mp->flags);
1821 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1822 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1825 static void vl_api_map_domain_details_t_handler
1826 (vl_api_map_domain_details_t * mp)
1828 vat_main_t *vam = &vat_main;
1830 if (mp->is_translation)
1833 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u\n",
1834 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1835 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1836 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1837 clib_net_to_host_u32 (mp->domain_index));
1842 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u\n",
1843 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1844 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1845 format_ip6_address, mp->ip6_src,
1846 clib_net_to_host_u32 (mp->domain_index));
1848 fformat (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s\n",
1849 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1850 mp->is_translation ? "map-t" : "");
1853 static void vl_api_map_rule_details_t_handler_json
1854 (vl_api_map_rule_details_t * mp)
1856 struct in6_addr ip6;
1857 vat_json_node_t *node = NULL;
1858 vat_main_t *vam = &vat_main;
1860 if (VAT_JSON_ARRAY != vam->json_tree.type)
1862 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1863 vat_json_init_array (&vam->json_tree);
1866 node = vat_json_array_add (&vam->json_tree);
1867 vat_json_init_object (node);
1869 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1870 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1871 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1875 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1877 vat_main_t *vam = &vat_main;
1878 fformat (vam->ofp, " %d (psid) %U (ip6-dst)\n",
1879 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1883 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1885 vat_main_t *vam = &vat_main;
1886 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1887 "router_addr %U host_mac %U\n",
1888 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1889 format_ip4_address, &mp->host_address,
1890 format_ip4_address, &mp->router_address,
1891 format_ethernet_address, mp->host_mac);
1894 static void vl_api_dhcp_compl_event_t_handler_json
1895 (vl_api_dhcp_compl_event_t * mp)
1897 /* JSON output not supported */
1901 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1904 vat_main_t *vam = &vat_main;
1905 static u64 default_counter = 0;
1907 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
1909 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
1910 sw_if_index, default_counter);
1911 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
1915 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1916 interface_counter_t counter)
1918 vat_main_t *vam = &vat_main;
1919 static interface_counter_t default_counter = { 0, };
1921 vec_validate_init_empty (vam->combined_interface_counters,
1922 vnet_counter_type, NULL);
1923 vec_validate_init_empty (vam->combined_interface_counters
1924 [vnet_counter_type], sw_if_index, default_counter);
1925 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
1928 static void vl_api_vnet_interface_counters_t_handler
1929 (vl_api_vnet_interface_counters_t * mp)
1934 static void vl_api_vnet_interface_counters_t_handler_json
1935 (vl_api_vnet_interface_counters_t * mp)
1937 interface_counter_t counter;
1942 u32 first_sw_if_index;
1945 count = ntohl (mp->count);
1946 first_sw_if_index = ntohl (mp->first_sw_if_index);
1948 if (!mp->is_combined)
1950 v_packets = (u64 *) & mp->data;
1951 for (i = 0; i < count; i++)
1954 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
1955 set_simple_interface_counter (mp->vnet_counter_type,
1956 first_sw_if_index + i, packets);
1962 v = (vlib_counter_t *) & mp->data;
1963 for (i = 0; i < count; i++)
1966 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
1968 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
1969 set_combined_interface_counter (mp->vnet_counter_type,
1970 first_sw_if_index + i, counter);
1977 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
1979 vat_main_t *vam = &vat_main;
1982 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
1984 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
1993 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
1995 vat_main_t *vam = &vat_main;
1998 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2000 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2008 static void vl_api_vnet_ip4_fib_counters_t_handler
2009 (vl_api_vnet_ip4_fib_counters_t * mp)
2014 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2015 (vl_api_vnet_ip4_fib_counters_t * mp)
2017 vat_main_t *vam = &vat_main;
2018 vl_api_ip4_fib_counter_t *v;
2019 ip4_fib_counter_t *counter;
2026 vrf_id = ntohl (mp->vrf_id);
2027 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2028 if (~0 == vrf_index)
2030 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2031 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2032 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2033 vec_validate (vam->ip4_fib_counters, vrf_index);
2034 vam->ip4_fib_counters[vrf_index] = NULL;
2037 vec_free (vam->ip4_fib_counters[vrf_index]);
2038 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2039 count = ntohl (mp->count);
2040 for (i = 0; i < count; i++)
2042 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2043 counter = &vam->ip4_fib_counters[vrf_index][i];
2044 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2045 counter->address = ip4;
2046 counter->address_length = v->address_length;
2047 counter->packets = clib_net_to_host_u64 (v->packets);
2048 counter->bytes = clib_net_to_host_u64 (v->bytes);
2053 static void vl_api_vnet_ip6_fib_counters_t_handler
2054 (vl_api_vnet_ip6_fib_counters_t * mp)
2059 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2060 (vl_api_vnet_ip6_fib_counters_t * mp)
2062 vat_main_t *vam = &vat_main;
2063 vl_api_ip6_fib_counter_t *v;
2064 ip6_fib_counter_t *counter;
2065 struct in6_addr ip6;
2071 vrf_id = ntohl (mp->vrf_id);
2072 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2073 if (~0 == vrf_index)
2075 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2076 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2077 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2078 vec_validate (vam->ip6_fib_counters, vrf_index);
2079 vam->ip6_fib_counters[vrf_index] = NULL;
2082 vec_free (vam->ip6_fib_counters[vrf_index]);
2083 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2084 count = ntohl (mp->count);
2085 for (i = 0; i < count; i++)
2087 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2088 counter = &vam->ip6_fib_counters[vrf_index][i];
2089 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2090 counter->address = ip6;
2091 counter->address_length = v->address_length;
2092 counter->packets = clib_net_to_host_u64 (v->packets);
2093 counter->bytes = clib_net_to_host_u64 (v->bytes);
2098 static void vl_api_get_first_msg_id_reply_t_handler
2099 (vl_api_get_first_msg_id_reply_t * mp)
2101 vat_main_t *vam = &vat_main;
2102 i32 retval = ntohl (mp->retval);
2104 if (vam->async_mode)
2106 vam->async_errors += (retval < 0);
2110 vam->retval = retval;
2111 vam->result_ready = 1;
2115 errmsg ("first message id %d\n", ntohs (mp->first_msg_id));
2119 static void vl_api_get_first_msg_id_reply_t_handler_json
2120 (vl_api_get_first_msg_id_reply_t * mp)
2122 vat_main_t *vam = &vat_main;
2123 vat_json_node_t node;
2125 vat_json_init_object (&node);
2126 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2127 vat_json_object_add_uint (&node, "first_msg_id",
2128 (uint) ntohs (mp->first_msg_id));
2130 vat_json_print (vam->ofp, &node);
2131 vat_json_free (&node);
2133 vam->retval = ntohl (mp->retval);
2134 vam->result_ready = 1;
2137 static void vl_api_get_node_graph_reply_t_handler
2138 (vl_api_get_node_graph_reply_t * mp)
2140 vat_main_t *vam = &vat_main;
2141 api_main_t *am = &api_main;
2142 i32 retval = ntohl (mp->retval);
2143 u8 *pvt_copy, *reply;
2148 if (vam->async_mode)
2150 vam->async_errors += (retval < 0);
2154 vam->retval = retval;
2155 vam->result_ready = 1;
2158 /* "Should never happen..." */
2162 reply = (u8 *) (mp->reply_in_shmem);
2163 pvt_copy = vec_dup (reply);
2165 /* Toss the shared-memory original... */
2166 pthread_mutex_lock (&am->vlib_rp->mutex);
2167 oldheap = svm_push_data_heap (am->vlib_rp);
2171 svm_pop_heap (oldheap);
2172 pthread_mutex_unlock (&am->vlib_rp->mutex);
2174 if (vam->graph_nodes)
2176 hash_free (vam->graph_node_index_by_name);
2178 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2180 node = vam->graph_nodes[i];
2181 vec_free (node->name);
2182 vec_free (node->next_nodes);
2185 vec_free (vam->graph_nodes);
2188 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2189 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2190 vec_free (pvt_copy);
2192 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2194 node = vam->graph_nodes[i];
2195 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2199 static void vl_api_get_node_graph_reply_t_handler_json
2200 (vl_api_get_node_graph_reply_t * mp)
2202 vat_main_t *vam = &vat_main;
2203 api_main_t *am = &api_main;
2205 vat_json_node_t node;
2208 /* $$$$ make this real? */
2209 vat_json_init_object (&node);
2210 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2211 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2213 reply = (u8 *) (mp->reply_in_shmem);
2215 /* Toss the shared-memory original... */
2216 pthread_mutex_lock (&am->vlib_rp->mutex);
2217 oldheap = svm_push_data_heap (am->vlib_rp);
2221 svm_pop_heap (oldheap);
2222 pthread_mutex_unlock (&am->vlib_rp->mutex);
2224 vat_json_print (vam->ofp, &node);
2225 vat_json_free (&node);
2227 vam->retval = ntohl (mp->retval);
2228 vam->result_ready = 1;
2232 vl_api_lisp_locator_details_t_handler (vl_api_lisp_locator_details_t * mp)
2234 vat_main_t *vam = &vat_main;
2238 memset (&loc, 0, sizeof (loc));
2239 if (vam->noprint_msg)
2241 loc.local = mp->local;
2242 loc.priority = mp->priority;
2243 loc.weight = mp->weight;
2246 loc.sw_if_index = ntohl (mp->sw_if_index);
2250 loc.is_ipv6 = mp->is_ipv6;
2251 clib_memcpy (loc.ip_address, mp->ip_address,
2252 sizeof (loc.ip_address));
2254 vec_add1 (vam->locator_msg, loc);
2260 tmp_str = format (tmp_str, "%=16d%=16d%=16d\n",
2261 ntohl (mp->sw_if_index),
2262 mp->priority, mp->weight);
2266 tmp_str = format (tmp_str, "%=16U%=16d%=16d\n",
2267 mp->is_ipv6 ? format_ip6_address :
2269 mp->ip_address, mp->priority, mp->weight);
2272 fformat (vam->ofp, "%s", tmp_str);
2279 vl_api_lisp_locator_details_t_handler_json (vl_api_lisp_locator_details_t *
2282 vat_main_t *vam = &vat_main;
2283 vat_json_node_t *node = NULL;
2285 struct in6_addr ip6;
2288 memset (&loc, 0, sizeof (loc));
2289 if (vam->noprint_msg)
2291 loc.local = mp->local;
2292 loc.priority = mp->priority;
2293 loc.weight = mp->weight;
2296 loc.sw_if_index = ntohl (mp->sw_if_index);
2300 loc.is_ipv6 = mp->is_ipv6;
2301 clib_memcpy (loc.ip_address, mp->ip_address,
2302 sizeof (loc.ip_address));
2304 vec_add1 (vam->locator_msg, loc);
2308 if (VAT_JSON_ARRAY != vam->json_tree.type)
2310 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2311 vat_json_init_array (&vam->json_tree);
2313 node = vat_json_array_add (&vam->json_tree);
2315 vat_json_init_object (node);
2319 vat_json_object_add_uint (node, "locator_index",
2320 ntohl (mp->sw_if_index));
2326 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2327 vat_json_object_add_ip6 (node, "locator", ip6);
2331 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2332 vat_json_object_add_ip4 (node, "locator", ip4);
2335 vat_json_object_add_uint (node, "priority", mp->priority);
2336 vat_json_object_add_uint (node, "weight", mp->weight);
2340 vl_api_lisp_locator_set_details_t_handler (vl_api_lisp_locator_set_details_t *
2343 vat_main_t *vam = &vat_main;
2344 locator_set_msg_t ls;
2346 ls.locator_set_index = ntohl (mp->locator_set_index);
2347 ls.locator_set_name = format (0, "%s", mp->locator_set_name);
2348 vec_add1 (vam->locator_set_msg, ls);
2352 vl_api_lisp_locator_set_details_t_handler_json
2353 (vl_api_lisp_locator_set_details_t * mp)
2355 vat_main_t *vam = &vat_main;
2356 locator_set_msg_t ls;
2358 ls.locator_set_index = ntohl (mp->locator_set_index);
2359 ls.locator_set_name = format (0, "%s", mp->locator_set_name);
2360 vec_add1 (vam->locator_set_msg, ls);
2364 vl_api_lisp_eid_table_details_t_handler (vl_api_lisp_eid_table_details_t * mp)
2366 vat_main_t *vam = &vat_main;
2367 eid_table_t eid_table;
2369 memset (&eid_table, 0, sizeof (eid_table));
2370 eid_table.is_local = mp->is_local;
2371 eid_table.locator_set_index = mp->locator_set_index;
2372 eid_table.eid_type = mp->eid_type;
2373 eid_table.vni = mp->vni;
2374 eid_table.eid_prefix_len = mp->eid_prefix_len;
2375 eid_table.ttl = mp->ttl;
2376 eid_table.authoritative = mp->authoritative;
2377 clib_memcpy (eid_table.eid, mp->eid, sizeof (eid_table.eid));
2378 vec_add1 (vam->eid_tables, eid_table);
2382 vl_api_lisp_eid_table_details_t_handler_json (vl_api_lisp_eid_table_details_t
2385 vat_main_t *vam = &vat_main;
2386 eid_table_t eid_table;
2388 memset (&eid_table, 0, sizeof (eid_table));
2389 eid_table.is_local = mp->is_local;
2390 eid_table.locator_set_index = mp->locator_set_index;
2391 eid_table.eid_type = mp->eid_type;
2392 eid_table.vni = mp->vni;
2393 eid_table.eid_prefix_len = mp->eid_prefix_len;
2394 eid_table.ttl = mp->ttl;
2395 eid_table.authoritative = mp->authoritative;
2396 clib_memcpy (eid_table.eid, mp->eid, sizeof (eid_table.eid));
2397 vec_add1 (vam->eid_tables, eid_table);
2401 vl_api_lisp_eid_table_map_details_t_handler
2402 (vl_api_lisp_eid_table_map_details_t * mp)
2404 vat_main_t *vam = &vat_main;
2406 u8 *line = format (0, "%=10d%=10d",
2407 clib_net_to_host_u32 (mp->vni),
2408 clib_net_to_host_u32 (mp->dp_table));
2409 fformat (vam->ofp, "%v\n", line);
2414 vl_api_lisp_eid_table_map_details_t_handler_json
2415 (vl_api_lisp_eid_table_map_details_t * mp)
2417 vat_main_t *vam = &vat_main;
2418 vat_json_node_t *node = NULL;
2420 if (VAT_JSON_ARRAY != vam->json_tree.type)
2422 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2423 vat_json_init_array (&vam->json_tree);
2425 node = vat_json_array_add (&vam->json_tree);
2426 vat_json_init_object (node);
2427 vat_json_object_add_uint (node, "dp_table",
2428 clib_net_to_host_u32 (mp->dp_table));
2429 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2433 vl_api_lisp_eid_table_vni_details_t_handler
2434 (vl_api_lisp_eid_table_vni_details_t * mp)
2436 vat_main_t *vam = &vat_main;
2438 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2439 fformat (vam->ofp, "%v\n", line);
2444 vl_api_lisp_eid_table_vni_details_t_handler_json
2445 (vl_api_lisp_eid_table_vni_details_t * mp)
2447 vat_main_t *vam = &vat_main;
2448 vat_json_node_t *node = NULL;
2450 if (VAT_JSON_ARRAY != vam->json_tree.type)
2452 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2453 vat_json_init_array (&vam->json_tree);
2455 node = vat_json_array_add (&vam->json_tree);
2456 vat_json_init_object (node);
2457 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2461 format_decap_next (u8 * s, va_list * args)
2463 u32 next_index = va_arg (*args, u32);
2467 case LISP_GPE_INPUT_NEXT_DROP:
2468 return format (s, "drop");
2469 case LISP_GPE_INPUT_NEXT_IP4_INPUT:
2470 return format (s, "ip4");
2471 case LISP_GPE_INPUT_NEXT_IP6_INPUT:
2472 return format (s, "ip6");
2474 return format (s, "unknown %d", next_index);
2480 vl_api_lisp_gpe_tunnel_details_t_handler (vl_api_lisp_gpe_tunnel_details_t *
2483 vat_main_t *vam = &vat_main;
2485 u8 *flag_str = NULL;
2487 iid_str = format (0, "%d (0x%x)", ntohl (mp->iid), ntohl (mp->iid));
2489 #define _(n,v) if (mp->flags & v) flag_str = format (flag_str, "%s-bit ", #n);
2490 foreach_lisp_gpe_flag_bit;
2493 fformat (vam->ofp, "%=20d%=30U%=16U%=16d%=16d%=16U"
2494 "%=16d%=16d%=16sd=16d%=16s%=16s\n",
2496 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2498 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2500 ntohl (mp->encap_fib_id),
2501 ntohl (mp->decap_fib_id),
2502 format_decap_next, ntohl (mp->dcap_next),
2504 flag_str, mp->next_protocol, mp->ver_res, mp->res, iid_str);
2510 vl_api_lisp_gpe_tunnel_details_t_handler_json
2511 (vl_api_lisp_gpe_tunnel_details_t * mp)
2513 vat_main_t *vam = &vat_main;
2514 vat_json_node_t *node = NULL;
2515 struct in6_addr ip6;
2519 next_decap_str = format (0, "%U", format_decap_next, htonl (mp->dcap_next));
2521 if (VAT_JSON_ARRAY != vam->json_tree.type)
2523 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2524 vat_json_init_array (&vam->json_tree);
2526 node = vat_json_array_add (&vam->json_tree);
2528 vat_json_init_object (node);
2529 vat_json_object_add_uint (node, "tunel", mp->tunnels);
2532 clib_memcpy (&ip6, mp->source_ip, sizeof (ip6));
2533 vat_json_object_add_ip6 (node, "source address", ip6);
2534 clib_memcpy (&ip6, mp->destination_ip, sizeof (ip6));
2535 vat_json_object_add_ip6 (node, "destination address", ip6);
2539 clib_memcpy (&ip4, mp->source_ip, sizeof (ip4));
2540 vat_json_object_add_ip4 (node, "source address", ip4);
2541 clib_memcpy (&ip4, mp->destination_ip, sizeof (ip4));
2542 vat_json_object_add_ip4 (node, "destination address", ip4);
2544 vat_json_object_add_uint (node, "fib encap", ntohl (mp->encap_fib_id));
2545 vat_json_object_add_uint (node, "fib decap", ntohl (mp->decap_fib_id));
2546 vat_json_object_add_string_copy (node, "decap next", next_decap_str);
2547 vat_json_object_add_uint (node, "lisp version", mp->ver_res >> 6);
2548 vat_json_object_add_uint (node, "flags", mp->flags);
2549 vat_json_object_add_uint (node, "next protocol", mp->next_protocol);
2550 vat_json_object_add_uint (node, "ver_res", mp->ver_res);
2551 vat_json_object_add_uint (node, "res", mp->res);
2552 vat_json_object_add_uint (node, "iid", ntohl (mp->iid));
2554 vec_free (next_decap_str);
2558 vl_api_lisp_map_resolver_details_t_handler (vl_api_lisp_map_resolver_details_t
2561 vat_main_t *vam = &vat_main;
2563 fformat (vam->ofp, "%=20U\n",
2564 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2569 vl_api_lisp_map_resolver_details_t_handler_json
2570 (vl_api_lisp_map_resolver_details_t * mp)
2572 vat_main_t *vam = &vat_main;
2573 vat_json_node_t *node = NULL;
2574 struct in6_addr ip6;
2577 if (VAT_JSON_ARRAY != vam->json_tree.type)
2579 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2580 vat_json_init_array (&vam->json_tree);
2582 node = vat_json_array_add (&vam->json_tree);
2584 vat_json_init_object (node);
2587 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2588 vat_json_object_add_ip6 (node, "map resolver", ip6);
2592 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2593 vat_json_object_add_ip4 (node, "map resolver", ip4);
2598 vl_api_show_lisp_status_reply_t_handler
2599 (vl_api_show_lisp_status_reply_t * mp)
2601 vat_main_t *vam = &vat_main;
2602 i32 retval = ntohl (mp->retval);
2606 fformat (vam->ofp, "feature: %s\ngpe: %s\n",
2607 mp->feature_status ? "enabled" : "disabled",
2608 mp->gpe_status ? "enabled" : "disabled");
2611 vam->retval = retval;
2612 vam->result_ready = 1;
2616 vl_api_show_lisp_status_reply_t_handler_json
2617 (vl_api_show_lisp_status_reply_t * mp)
2619 vat_main_t *vam = &vat_main;
2620 vat_json_node_t node;
2621 u8 *gpe_status = NULL;
2622 u8 *feature_status = NULL;
2624 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
2625 feature_status = format (0, "%s",
2626 mp->feature_status ? "enabled" : "disabled");
2627 vec_add1 (gpe_status, 0);
2628 vec_add1 (feature_status, 0);
2630 vat_json_init_object (&node);
2631 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
2632 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
2634 vec_free (gpe_status);
2635 vec_free (feature_status);
2637 vat_json_print (vam->ofp, &node);
2638 vat_json_free (&node);
2640 vam->retval = ntohl (mp->retval);
2641 vam->result_ready = 1;
2645 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler
2646 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2648 vat_main_t *vam = &vat_main;
2649 i32 retval = ntohl (mp->retval);
2653 fformat (vam->ofp, "%=20s\n", mp->locator_set_name);
2656 vam->retval = retval;
2657 vam->result_ready = 1;
2661 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler_json
2662 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2664 vat_main_t *vam = &vat_main;
2665 vat_json_node_t *node = NULL;
2667 if (VAT_JSON_ARRAY != vam->json_tree.type)
2669 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2670 vat_json_init_array (&vam->json_tree);
2672 node = vat_json_array_add (&vam->json_tree);
2674 vat_json_init_object (node);
2675 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
2677 vat_json_print (vam->ofp, node);
2678 vat_json_free (node);
2680 vam->retval = ntohl (mp->retval);
2681 vam->result_ready = 1;
2685 vl_api_show_lisp_pitr_reply_t_handler (vl_api_show_lisp_pitr_reply_t * mp)
2687 vat_main_t *vam = &vat_main;
2688 i32 retval = ntohl (mp->retval);
2692 fformat (vam->ofp, "%-20s%-16s\n",
2693 mp->status ? "enabled" : "disabled",
2694 mp->status ? (char *) mp->locator_set_name : "");
2697 vam->retval = retval;
2698 vam->result_ready = 1;
2702 vl_api_show_lisp_pitr_reply_t_handler_json (vl_api_show_lisp_pitr_reply_t *
2705 vat_main_t *vam = &vat_main;
2706 vat_json_node_t node;
2709 status = format (0, "%s", mp->status ? "enabled" : "disabled");
2710 vec_add1 (status, 0);
2712 vat_json_init_object (&node);
2713 vat_json_object_add_string_copy (&node, "status", status);
2716 vat_json_object_add_string_copy (&node, "locator_set",
2717 mp->locator_set_name);
2722 vat_json_print (vam->ofp, &node);
2723 vat_json_free (&node);
2725 vam->retval = ntohl (mp->retval);
2726 vam->result_ready = 1;
2730 format_policer_type (u8 * s, va_list * va)
2732 u32 i = va_arg (*va, u32);
2734 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
2735 s = format (s, "1r2c");
2736 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
2737 s = format (s, "1r3c");
2738 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
2739 s = format (s, "2r3c-2698");
2740 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
2741 s = format (s, "2r3c-4115");
2742 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
2743 s = format (s, "2r3c-mef5cf1");
2745 s = format (s, "ILLEGAL");
2750 format_policer_rate_type (u8 * s, va_list * va)
2752 u32 i = va_arg (*va, u32);
2754 if (i == SSE2_QOS_RATE_KBPS)
2755 s = format (s, "kbps");
2756 else if (i == SSE2_QOS_RATE_PPS)
2757 s = format (s, "pps");
2759 s = format (s, "ILLEGAL");
2764 format_policer_round_type (u8 * s, va_list * va)
2766 u32 i = va_arg (*va, u32);
2768 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
2769 s = format (s, "closest");
2770 else if (i == SSE2_QOS_ROUND_TO_UP)
2771 s = format (s, "up");
2772 else if (i == SSE2_QOS_ROUND_TO_DOWN)
2773 s = format (s, "down");
2775 s = format (s, "ILLEGAL");
2780 format_policer_action_type (u8 * s, va_list * va)
2782 u32 i = va_arg (*va, u32);
2784 if (i == SSE2_QOS_ACTION_DROP)
2785 s = format (s, "drop");
2786 else if (i == SSE2_QOS_ACTION_TRANSMIT)
2787 s = format (s, "transmit");
2788 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2789 s = format (s, "mark-and-transmit");
2791 s = format (s, "ILLEGAL");
2796 format_dscp (u8 * s, va_list * va)
2798 u32 i = va_arg (*va, u32);
2803 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
2807 return format (s, "ILLEGAL");
2809 s = format (s, "%s", t);
2814 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
2816 vat_main_t *vam = &vat_main;
2817 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
2819 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2820 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
2822 conform_dscp_str = format (0, "");
2824 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2825 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
2827 exceed_dscp_str = format (0, "");
2829 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2830 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
2832 violate_dscp_str = format (0, "");
2834 fformat (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
2835 "rate type %U, round type %U, %s rate, %s color-aware, "
2836 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
2837 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
2838 "conform action %U%s, exceed action %U%s, violate action %U%s\n",
2840 format_policer_type, mp->type,
2843 clib_net_to_host_u64 (mp->cb),
2844 clib_net_to_host_u64 (mp->eb),
2845 format_policer_rate_type, mp->rate_type,
2846 format_policer_round_type, mp->round_type,
2847 mp->single_rate ? "single" : "dual",
2848 mp->color_aware ? "is" : "not",
2849 ntohl (mp->cir_tokens_per_period),
2850 ntohl (mp->pir_tokens_per_period),
2852 ntohl (mp->current_limit),
2853 ntohl (mp->current_bucket),
2854 ntohl (mp->extended_limit),
2855 ntohl (mp->extended_bucket),
2856 clib_net_to_host_u64 (mp->last_update_time),
2857 format_policer_action_type, mp->conform_action_type,
2859 format_policer_action_type, mp->exceed_action_type,
2861 format_policer_action_type, mp->violate_action_type,
2864 vec_free (conform_dscp_str);
2865 vec_free (exceed_dscp_str);
2866 vec_free (violate_dscp_str);
2869 static void vl_api_policer_details_t_handler_json
2870 (vl_api_policer_details_t * mp)
2872 vat_main_t *vam = &vat_main;
2873 vat_json_node_t *node;
2874 u8 *rate_type_str, *round_type_str, *type_str;
2875 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
2877 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
2879 format (0, "%U", format_policer_round_type, mp->round_type);
2880 type_str = format (0, "%U", format_policer_type, mp->type);
2881 conform_action_str = format (0, "%U", format_policer_action_type,
2882 mp->conform_action_type);
2883 exceed_action_str = format (0, "%U", format_policer_action_type,
2884 mp->exceed_action_type);
2885 violate_action_str = format (0, "%U", format_policer_action_type,
2886 mp->violate_action_type);
2888 if (VAT_JSON_ARRAY != vam->json_tree.type)
2890 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2891 vat_json_init_array (&vam->json_tree);
2893 node = vat_json_array_add (&vam->json_tree);
2895 vat_json_init_object (node);
2896 vat_json_object_add_string_copy (node, "name", mp->name);
2897 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
2898 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
2899 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
2900 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
2901 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
2902 vat_json_object_add_string_copy (node, "round_type", round_type_str);
2903 vat_json_object_add_string_copy (node, "type", type_str);
2904 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
2905 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
2906 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
2907 vat_json_object_add_uint (node, "cir_tokens_per_period",
2908 ntohl (mp->cir_tokens_per_period));
2909 vat_json_object_add_uint (node, "eir_tokens_per_period",
2910 ntohl (mp->pir_tokens_per_period));
2911 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
2912 vat_json_object_add_uint (node, "current_bucket",
2913 ntohl (mp->current_bucket));
2914 vat_json_object_add_uint (node, "extended_limit",
2915 ntohl (mp->extended_limit));
2916 vat_json_object_add_uint (node, "extended_bucket",
2917 ntohl (mp->extended_bucket));
2918 vat_json_object_add_uint (node, "last_update_time",
2919 ntohl (mp->last_update_time));
2920 vat_json_object_add_string_copy (node, "conform_action",
2921 conform_action_str);
2922 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2924 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
2925 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
2926 vec_free (dscp_str);
2928 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
2929 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2931 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
2932 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
2933 vec_free (dscp_str);
2935 vat_json_object_add_string_copy (node, "violate_action",
2936 violate_action_str);
2937 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2939 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
2940 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
2941 vec_free (dscp_str);
2944 vec_free (rate_type_str);
2945 vec_free (round_type_str);
2946 vec_free (type_str);
2947 vec_free (conform_action_str);
2948 vec_free (exceed_action_str);
2949 vec_free (violate_action_str);
2953 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
2956 vat_main_t *vam = &vat_main;
2957 int i, count = ntohl (mp->count);
2960 fformat (vam->ofp, "classify table ids (%d) : ", count);
2961 for (i = 0; i < count; i++)
2963 fformat (vam->ofp, "%d", ntohl (mp->ids[i]));
2964 fformat (vam->ofp, (i < count - 1) ? "," : "\n");
2966 vam->retval = ntohl (mp->retval);
2967 vam->result_ready = 1;
2971 vl_api_classify_table_ids_reply_t_handler_json
2972 (vl_api_classify_table_ids_reply_t * mp)
2974 vat_main_t *vam = &vat_main;
2975 int i, count = ntohl (mp->count);
2979 vat_json_node_t node;
2981 vat_json_init_object (&node);
2982 for (i = 0; i < count; i++)
2984 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
2986 vat_json_print (vam->ofp, &node);
2987 vat_json_free (&node);
2989 vam->retval = ntohl (mp->retval);
2990 vam->result_ready = 1;
2994 vl_api_classify_table_by_interface_reply_t_handler
2995 (vl_api_classify_table_by_interface_reply_t * mp)
2997 vat_main_t *vam = &vat_main;
3000 table_id = ntohl (mp->l2_table_id);
3002 fformat (vam->ofp, "l2 table id : %d\n", table_id);
3004 fformat (vam->ofp, "l2 table id : No input ACL tables configured\n");
3005 table_id = ntohl (mp->ip4_table_id);
3007 fformat (vam->ofp, "ip4 table id : %d\n", table_id);
3009 fformat (vam->ofp, "ip4 table id : No input ACL tables configured\n");
3010 table_id = ntohl (mp->ip6_table_id);
3012 fformat (vam->ofp, "ip6 table id : %d\n", table_id);
3014 fformat (vam->ofp, "ip6 table id : No input ACL tables configured\n");
3015 vam->retval = ntohl (mp->retval);
3016 vam->result_ready = 1;
3020 vl_api_classify_table_by_interface_reply_t_handler_json
3021 (vl_api_classify_table_by_interface_reply_t * mp)
3023 vat_main_t *vam = &vat_main;
3024 vat_json_node_t node;
3026 vat_json_init_object (&node);
3028 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3029 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3030 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3032 vat_json_print (vam->ofp, &node);
3033 vat_json_free (&node);
3035 vam->retval = ntohl (mp->retval);
3036 vam->result_ready = 1;
3039 static void vl_api_policer_add_del_reply_t_handler
3040 (vl_api_policer_add_del_reply_t * mp)
3042 vat_main_t *vam = &vat_main;
3043 i32 retval = ntohl (mp->retval);
3044 if (vam->async_mode)
3046 vam->async_errors += (retval < 0);
3050 vam->retval = retval;
3051 vam->result_ready = 1;
3052 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3054 * Note: this is just barely thread-safe, depends on
3055 * the main thread spinning waiting for an answer...
3057 errmsg ("policer index %d\n", ntohl (mp->policer_index));
3061 static void vl_api_policer_add_del_reply_t_handler_json
3062 (vl_api_policer_add_del_reply_t * mp)
3064 vat_main_t *vam = &vat_main;
3065 vat_json_node_t node;
3067 vat_json_init_object (&node);
3068 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3069 vat_json_object_add_uint (&node, "policer_index",
3070 ntohl (mp->policer_index));
3072 vat_json_print (vam->ofp, &node);
3073 vat_json_free (&node);
3075 vam->retval = ntohl (mp->retval);
3076 vam->result_ready = 1;
3079 /* Format hex dump. */
3081 format_hex_bytes (u8 * s, va_list * va)
3083 u8 *bytes = va_arg (*va, u8 *);
3084 int n_bytes = va_arg (*va, int);
3087 /* Print short or long form depending on byte count. */
3088 uword short_form = n_bytes <= 32;
3089 uword indent = format_get_indent (s);
3094 for (i = 0; i < n_bytes; i++)
3096 if (!short_form && (i % 32) == 0)
3097 s = format (s, "%08x: ", i);
3098 s = format (s, "%02x", bytes[i]);
3099 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3100 s = format (s, "\n%U", format_white_space, indent);
3107 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3110 vat_main_t *vam = &vat_main;
3111 i32 retval = ntohl (mp->retval);
3114 fformat (vam->ofp, "classify table info :\n");
3115 fformat (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d\n",
3116 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3117 ntohl (mp->miss_next_index));
3118 fformat (vam->ofp, "nbuckets: %d skip: %d match: %d\n",
3119 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3120 ntohl (mp->match_n_vectors));
3121 fformat (vam->ofp, "mask: %U\n", format_hex_bytes, mp->mask,
3122 ntohl (mp->mask_length));
3124 vam->retval = retval;
3125 vam->result_ready = 1;
3129 vl_api_classify_table_info_reply_t_handler_json
3130 (vl_api_classify_table_info_reply_t * mp)
3132 vat_main_t *vam = &vat_main;
3133 vat_json_node_t node;
3135 i32 retval = ntohl (mp->retval);
3138 vat_json_init_object (&node);
3140 vat_json_object_add_int (&node, "sessions",
3141 ntohl (mp->active_sessions));
3142 vat_json_object_add_int (&node, "nexttbl",
3143 ntohl (mp->next_table_index));
3144 vat_json_object_add_int (&node, "nextnode",
3145 ntohl (mp->miss_next_index));
3146 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3147 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3148 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3149 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3150 ntohl (mp->mask_length), 0);
3151 vat_json_object_add_string_copy (&node, "mask", s);
3153 vat_json_print (vam->ofp, &node);
3154 vat_json_free (&node);
3156 vam->retval = ntohl (mp->retval);
3157 vam->result_ready = 1;
3161 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3164 vat_main_t *vam = &vat_main;
3166 fformat (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3167 ntohl (mp->hit_next_index), ntohl (mp->advance),
3168 ntohl (mp->opaque_index));
3169 fformat (vam->ofp, "mask: %U\n", format_hex_bytes, mp->match,
3170 ntohl (mp->match_length));
3174 vl_api_classify_session_details_t_handler_json
3175 (vl_api_classify_session_details_t * mp)
3177 vat_main_t *vam = &vat_main;
3178 vat_json_node_t *node = NULL;
3180 if (VAT_JSON_ARRAY != vam->json_tree.type)
3182 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3183 vat_json_init_array (&vam->json_tree);
3185 node = vat_json_array_add (&vam->json_tree);
3187 vat_json_init_object (node);
3188 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3189 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3190 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3192 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3194 vat_json_object_add_string_copy (node, "match", s);
3197 static void vl_api_pg_create_interface_reply_t_handler
3198 (vl_api_pg_create_interface_reply_t * mp)
3200 vat_main_t *vam = &vat_main;
3202 vam->retval = ntohl (mp->retval);
3203 vam->result_ready = 1;
3206 static void vl_api_pg_create_interface_reply_t_handler_json
3207 (vl_api_pg_create_interface_reply_t * mp)
3209 vat_main_t *vam = &vat_main;
3210 vat_json_node_t node;
3212 i32 retval = ntohl (mp->retval);
3215 vat_json_init_object (&node);
3217 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3219 vat_json_print (vam->ofp, &node);
3220 vat_json_free (&node);
3222 vam->retval = ntohl (mp->retval);
3223 vam->result_ready = 1;
3226 static void vl_api_policer_classify_details_t_handler
3227 (vl_api_policer_classify_details_t * mp)
3229 vat_main_t *vam = &vat_main;
3231 fformat (vam->ofp, "%10d%20d\n", ntohl (mp->sw_if_index),
3232 ntohl (mp->table_index));
3235 static void vl_api_policer_classify_details_t_handler_json
3236 (vl_api_policer_classify_details_t * mp)
3238 vat_main_t *vam = &vat_main;
3239 vat_json_node_t *node;
3241 if (VAT_JSON_ARRAY != vam->json_tree.type)
3243 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3244 vat_json_init_array (&vam->json_tree);
3246 node = vat_json_array_add (&vam->json_tree);
3248 vat_json_init_object (node);
3249 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3250 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3253 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3254 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3256 vat_main_t *vam = &vat_main;
3257 i32 retval = ntohl (mp->retval);
3258 if (vam->async_mode)
3260 vam->async_errors += (retval < 0);
3264 vam->retval = retval;
3265 vam->sw_if_index = ntohl (mp->sw_if_index);
3266 vam->result_ready = 1;
3270 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3271 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3273 vat_main_t *vam = &vat_main;
3274 vat_json_node_t node;
3276 vat_json_init_object (&node);
3277 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3278 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3280 vat_json_print (vam->ofp, &node);
3281 vat_json_free (&node);
3283 vam->retval = ntohl (mp->retval);
3284 vam->result_ready = 1;
3287 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3288 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3289 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3290 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3293 * Generate boilerplate reply handlers, which
3294 * dig the return value out of the xxx_reply_t API message,
3295 * stick it into vam->retval, and set vam->result_ready
3297 * Could also do this by pointing N message decode slots at
3298 * a single function, but that could break in subtle ways.
3301 #define foreach_standard_reply_retval_handler \
3302 _(sw_interface_set_flags_reply) \
3303 _(sw_interface_add_del_address_reply) \
3304 _(sw_interface_set_table_reply) \
3305 _(sw_interface_set_vpath_reply) \
3306 _(sw_interface_set_l2_bridge_reply) \
3307 _(bridge_domain_add_del_reply) \
3308 _(sw_interface_set_l2_xconnect_reply) \
3309 _(l2fib_add_del_reply) \
3310 _(ip_add_del_route_reply) \
3311 _(proxy_arp_add_del_reply) \
3312 _(proxy_arp_intfc_enable_disable_reply) \
3313 _(mpls_add_del_encap_reply) \
3314 _(mpls_add_del_decap_reply) \
3315 _(mpls_ethernet_add_del_tunnel_2_reply) \
3316 _(sw_interface_set_unnumbered_reply) \
3317 _(ip_neighbor_add_del_reply) \
3318 _(reset_vrf_reply) \
3319 _(oam_add_del_reply) \
3320 _(reset_fib_reply) \
3321 _(dhcp_proxy_config_reply) \
3322 _(dhcp_proxy_config_2_reply) \
3323 _(dhcp_proxy_set_vss_reply) \
3324 _(dhcp_client_config_reply) \
3325 _(set_ip_flow_hash_reply) \
3326 _(sw_interface_ip6_enable_disable_reply) \
3327 _(sw_interface_ip6_set_link_local_address_reply) \
3328 _(sw_interface_ip6nd_ra_prefix_reply) \
3329 _(sw_interface_ip6nd_ra_config_reply) \
3330 _(set_arp_neighbor_limit_reply) \
3331 _(l2_patch_add_del_reply) \
3332 _(sr_tunnel_add_del_reply) \
3333 _(sr_policy_add_del_reply) \
3334 _(sr_multicast_map_add_del_reply) \
3335 _(classify_add_del_session_reply) \
3336 _(classify_set_interface_ip_table_reply) \
3337 _(classify_set_interface_l2_tables_reply) \
3338 _(l2tpv3_set_tunnel_cookies_reply) \
3339 _(l2tpv3_interface_enable_disable_reply) \
3340 _(l2tpv3_set_lookup_key_reply) \
3341 _(l2_fib_clear_table_reply) \
3342 _(l2_interface_efp_filter_reply) \
3343 _(l2_interface_vlan_tag_rewrite_reply) \
3344 _(modify_vhost_user_if_reply) \
3345 _(delete_vhost_user_if_reply) \
3346 _(want_ip4_arp_events_reply) \
3347 _(input_acl_set_interface_reply) \
3348 _(ipsec_spd_add_del_reply) \
3349 _(ipsec_interface_add_del_spd_reply) \
3350 _(ipsec_spd_add_del_entry_reply) \
3351 _(ipsec_sad_add_del_entry_reply) \
3352 _(ipsec_sa_set_key_reply) \
3353 _(ikev2_profile_add_del_reply) \
3354 _(ikev2_profile_set_auth_reply) \
3355 _(ikev2_profile_set_id_reply) \
3356 _(ikev2_profile_set_ts_reply) \
3357 _(ikev2_set_local_key_reply) \
3358 _(delete_loopback_reply) \
3359 _(bd_ip_mac_add_del_reply) \
3360 _(map_del_domain_reply) \
3361 _(map_add_del_rule_reply) \
3362 _(want_interface_events_reply) \
3363 _(want_stats_reply) \
3364 _(cop_interface_enable_disable_reply) \
3365 _(cop_whitelist_enable_disable_reply) \
3366 _(sw_interface_clear_stats_reply) \
3367 _(trace_profile_add_reply) \
3368 _(trace_profile_apply_reply) \
3369 _(trace_profile_del_reply) \
3370 _(lisp_add_del_locator_reply) \
3371 _(lisp_add_del_local_eid_reply) \
3372 _(lisp_add_del_remote_mapping_reply) \
3373 _(lisp_add_del_adjacency_reply) \
3374 _(lisp_gpe_add_del_fwd_entry_reply) \
3375 _(lisp_add_del_map_resolver_reply) \
3376 _(lisp_gpe_enable_disable_reply) \
3377 _(lisp_gpe_add_del_iface_reply) \
3378 _(lisp_enable_disable_reply) \
3379 _(lisp_pitr_set_locator_set_reply) \
3380 _(lisp_add_del_map_request_itr_rlocs_reply) \
3381 _(lisp_eid_table_add_del_map_reply) \
3382 _(vxlan_gpe_add_del_tunnel_reply) \
3383 _(af_packet_delete_reply) \
3384 _(policer_classify_set_interface_reply) \
3385 _(netmap_create_reply) \
3386 _(netmap_delete_reply) \
3387 _(ipfix_enable_reply) \
3388 _(pg_capture_reply) \
3389 _(pg_enable_disable_reply) \
3390 _(ip_source_and_port_range_check_add_del_reply) \
3391 _(ip_source_and_port_range_check_interface_add_del_reply)
3394 static void vl_api_##n##_t_handler \
3395 (vl_api_##n##_t * mp) \
3397 vat_main_t * vam = &vat_main; \
3398 i32 retval = ntohl(mp->retval); \
3399 if (vam->async_mode) { \
3400 vam->async_errors += (retval < 0); \
3402 vam->retval = retval; \
3403 vam->result_ready = 1; \
3406 foreach_standard_reply_retval_handler;
3410 static void vl_api_##n##_t_handler_json \
3411 (vl_api_##n##_t * mp) \
3413 vat_main_t * vam = &vat_main; \
3414 vat_json_node_t node; \
3415 vat_json_init_object(&node); \
3416 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3417 vat_json_print(vam->ofp, &node); \
3418 vam->retval = ntohl(mp->retval); \
3419 vam->result_ready = 1; \
3421 foreach_standard_reply_retval_handler;
3425 * Table of message reply handlers, must include boilerplate handlers
3429 #define foreach_vpe_api_reply_msg \
3430 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3431 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3432 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
3433 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3434 _(CONTROL_PING_REPLY, control_ping_reply) \
3435 _(NOPRINT_CONTROL_PING_REPLY, noprint_control_ping_reply) \
3436 _(CLI_REPLY, cli_reply) \
3437 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
3438 sw_interface_add_del_address_reply) \
3439 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
3440 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
3441 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
3442 sw_interface_set_l2_xconnect_reply) \
3443 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
3444 sw_interface_set_l2_bridge_reply) \
3445 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
3446 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
3447 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
3448 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
3449 _(L2_FLAGS_REPLY, l2_flags_reply) \
3450 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
3451 _(TAP_CONNECT_REPLY, tap_connect_reply) \
3452 _(TAP_MODIFY_REPLY, tap_modify_reply) \
3453 _(TAP_DELETE_REPLY, tap_delete_reply) \
3454 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
3455 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
3456 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
3457 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
3458 proxy_arp_intfc_enable_disable_reply) \
3459 _(MPLS_ADD_DEL_ENCAP_REPLY, mpls_add_del_encap_reply) \
3460 _(MPLS_ADD_DEL_DECAP_REPLY, mpls_add_del_decap_reply) \
3461 _(MPLS_GRE_ADD_DEL_TUNNEL_REPLY, mpls_gre_add_del_tunnel_reply) \
3462 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_REPLY, \
3463 mpls_ethernet_add_del_tunnel_reply) \
3464 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_2_REPLY, \
3465 mpls_ethernet_add_del_tunnel_2_reply) \
3466 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
3467 sw_interface_set_unnumbered_reply) \
3468 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
3469 _(RESET_VRF_REPLY, reset_vrf_reply) \
3470 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
3471 _(CREATE_SUBIF_REPLY, create_subif_reply) \
3472 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
3473 _(RESET_FIB_REPLY, reset_fib_reply) \
3474 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
3475 _(DHCP_PROXY_CONFIG_2_REPLY, dhcp_proxy_config_2_reply) \
3476 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
3477 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
3478 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
3479 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
3480 sw_interface_ip6_enable_disable_reply) \
3481 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
3482 sw_interface_ip6_set_link_local_address_reply) \
3483 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
3484 sw_interface_ip6nd_ra_prefix_reply) \
3485 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
3486 sw_interface_ip6nd_ra_config_reply) \
3487 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
3488 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
3489 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
3490 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
3491 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
3492 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
3493 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
3494 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
3495 classify_set_interface_ip_table_reply) \
3496 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
3497 classify_set_interface_l2_tables_reply) \
3498 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
3499 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
3500 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
3501 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
3502 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
3503 l2tpv3_interface_enable_disable_reply) \
3504 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
3505 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
3506 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
3507 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
3508 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
3509 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
3510 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
3511 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
3512 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
3513 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
3514 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
3515 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
3516 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
3517 _(SHOW_VERSION_REPLY, show_version_reply) \
3518 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
3519 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
3520 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
3521 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
3522 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
3523 _(IP4_ARP_EVENT, ip4_arp_event) \
3524 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
3525 _(IP_ADDRESS_DETAILS, ip_address_details) \
3526 _(IP_DETAILS, ip_details) \
3527 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
3528 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
3529 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
3530 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
3531 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
3532 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
3533 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
3534 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
3535 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
3536 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
3537 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
3538 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
3539 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
3540 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
3541 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
3542 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
3543 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
3544 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
3545 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
3546 _(MAP_DOMAIN_DETAILS, map_domain_details) \
3547 _(MAP_RULE_DETAILS, map_rule_details) \
3548 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
3549 _(WANT_STATS_REPLY, want_stats_reply) \
3550 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
3551 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
3552 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
3553 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
3554 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
3555 _(TRACE_PROFILE_ADD_REPLY, trace_profile_add_reply) \
3556 _(TRACE_PROFILE_APPLY_REPLY, trace_profile_apply_reply) \
3557 _(TRACE_PROFILE_DEL_REPLY, trace_profile_del_reply) \
3558 _(LISP_ADD_DEL_LOCATOR_SET_REPLY, lisp_add_del_locator_set_reply) \
3559 _(LISP_ADD_DEL_LOCATOR_REPLY, lisp_add_del_locator_reply) \
3560 _(LISP_ADD_DEL_LOCAL_EID_REPLY, lisp_add_del_local_eid_reply) \
3561 _(LISP_ADD_DEL_REMOTE_MAPPING_REPLY, lisp_add_del_remote_mapping_reply) \
3562 _(LISP_ADD_DEL_ADJACENCY_REPLY, lisp_add_del_adjacency_reply) \
3563 _(LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY, lisp_gpe_add_del_fwd_entry_reply) \
3564 _(LISP_ADD_DEL_MAP_RESOLVER_REPLY, lisp_add_del_map_resolver_reply) \
3565 _(LISP_GPE_ENABLE_DISABLE_REPLY, lisp_gpe_enable_disable_reply) \
3566 _(LISP_ENABLE_DISABLE_REPLY, lisp_enable_disable_reply) \
3567 _(LISP_PITR_SET_LOCATOR_SET_REPLY, lisp_pitr_set_locator_set_reply) \
3568 _(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \
3569 _(LISP_GPE_ADD_DEL_IFACE_REPLY, lisp_gpe_add_del_iface_reply) \
3570 _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \
3571 _(LISP_LOCATOR_DETAILS, lisp_locator_details) \
3572 _(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \
3573 _(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \
3574 _(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \
3575 _(LISP_GPE_TUNNEL_DETAILS, lisp_gpe_tunnel_details) \
3576 _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
3577 _(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
3578 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
3579 lisp_add_del_map_request_itr_rlocs_reply) \
3580 _(LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
3581 lisp_get_map_request_itr_rlocs_reply) \
3582 _(SHOW_LISP_PITR_REPLY, show_lisp_pitr_reply) \
3583 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
3584 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
3585 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
3586 _(POLICER_DETAILS, policer_details) \
3587 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
3588 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
3589 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
3590 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
3591 _(MPLS_GRE_TUNNEL_DETAILS, mpls_gre_tunnel_details) \
3592 _(MPLS_ETH_TUNNEL_DETAILS, mpls_eth_tunnel_details) \
3593 _(MPLS_FIB_ENCAP_DETAILS, mpls_fib_encap_details) \
3594 _(MPLS_FIB_DECAP_DETAILS, mpls_fib_decap_details) \
3595 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
3596 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
3597 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
3598 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
3599 _(IPFIX_ENABLE_REPLY, ipfix_enable_reply) \
3600 _(IPFIX_DETAILS, ipfix_details) \
3601 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
3602 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
3603 _(PG_CAPTURE_REPLY, pg_capture_reply) \
3604 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
3605 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
3606 ip_source_and_port_range_check_add_del_reply) \
3607 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
3608 ip_source_and_port_range_check_interface_add_del_reply) \
3609 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
3610 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details)
3612 /* M: construct, but don't yet send a message */
3616 vam->result_ready = 0; \
3617 mp = vl_msg_api_alloc(sizeof(*mp)); \
3618 memset (mp, 0, sizeof (*mp)); \
3619 mp->_vl_msg_id = ntohs (VL_API_##T); \
3620 mp->client_index = vam->my_client_index; \
3625 vam->result_ready = 0; \
3626 mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
3627 memset (mp, 0, sizeof (*mp)); \
3628 mp->_vl_msg_id = ntohs (VL_API_##T); \
3629 mp->client_index = vam->my_client_index; \
3633 /* S: send a message */
3634 #define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
3636 /* W: wait for results, with timeout */
3639 timeout = vat_time_now (vam) + 1.0; \
3641 while (vat_time_now (vam) < timeout) { \
3642 if (vam->result_ready == 1) { \
3643 return (vam->retval); \
3649 /* W2: wait for results, with timeout */
3652 timeout = vat_time_now (vam) + 1.0; \
3654 while (vat_time_now (vam) < timeout) { \
3655 if (vam->result_ready == 1) { \
3657 return (vam->retval); \
3663 /* W_L: wait for results, with timeout */
3666 timeout = vat_time_now (vam) + 1.0; \
3668 while (vat_time_now (vam) < timeout) { \
3669 if (vam->result_ready == 1) { \
3671 return (vam->retval); \
3674 vam->noprint_msg = 0; \
3685 #define STR_VTR_OP_CASE(op) \
3686 case L2_VTR_ ## op: \
3690 str_vtr_op (u32 vtr_op)
3694 STR_VTR_OP_CASE (DISABLED);
3695 STR_VTR_OP_CASE (PUSH_1);
3696 STR_VTR_OP_CASE (PUSH_2);
3697 STR_VTR_OP_CASE (POP_1);
3698 STR_VTR_OP_CASE (POP_2);
3699 STR_VTR_OP_CASE (TRANSLATE_1_1);
3700 STR_VTR_OP_CASE (TRANSLATE_1_2);
3701 STR_VTR_OP_CASE (TRANSLATE_2_1);
3702 STR_VTR_OP_CASE (TRANSLATE_2_2);
3709 dump_sub_interface_table (vat_main_t * vam)
3711 const sw_interface_subif_t *sub = NULL;
3713 if (vam->json_output)
3716 ("JSON output supported only for VPE API calls and dump_stats_table");
3721 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s\n",
3722 "Interface", "sw_if_index",
3723 "sub id", "dot1ad", "tags", "outer id",
3724 "inner id", "exact", "default", "outer any", "inner any");
3726 vec_foreach (sub, vam->sw_if_subif_table)
3729 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d\n",
3730 sub->interface_name,
3732 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
3733 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
3734 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
3735 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
3736 if (sub->vtr_op != L2_VTR_DISABLED)
3739 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
3740 "tag1: %d tag2: %d ]\n",
3741 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
3742 sub->vtr_tag1, sub->vtr_tag2);
3750 name_sort_cmp (void *a1, void *a2)
3752 name_sort_t *n1 = a1;
3753 name_sort_t *n2 = a2;
3755 return strcmp ((char *) n1->name, (char *) n2->name);
3759 dump_interface_table (vat_main_t * vam)
3762 name_sort_t *nses = 0, *ns;
3764 if (vam->json_output)
3767 ("JSON output supported only for VPE API calls and dump_stats_table");
3772 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
3774 vec_add2 (nses, ns, 1);
3775 ns->name = (u8 *)(p->key);
3776 ns->value = (u32) p->value[0];
3780 vec_sort_with_function (nses, name_sort_cmp);
3782 fformat (vam->ofp, "%-25s%-15s\n", "Interface", "sw_if_index");
3783 vec_foreach (ns, nses)
3785 fformat (vam->ofp, "%-25s%-15d\n", ns->name, ns->value);
3792 dump_ip_table (vat_main_t * vam, int is_ipv6)
3794 const ip_details_t *det = NULL;
3795 const ip_address_details_t *address = NULL;
3798 fformat (vam->ofp, "%-12s\n", "sw_if_index");
3800 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
3807 fformat (vam->ofp, "%-12d\n", i);
3809 " %-30s%-13s\n", "Address", "Prefix length");
3814 vec_foreach (address, det->addr)
3818 is_ipv6 ? format_ip6_address : format_ip4_address,
3819 address->ip, address->prefix_length);
3827 dump_ipv4_table (vat_main_t * vam)
3829 if (vam->json_output)
3832 ("JSON output supported only for VPE API calls and dump_stats_table");
3836 return dump_ip_table (vam, 0);
3840 dump_ipv6_table (vat_main_t * vam)
3842 if (vam->json_output)
3845 ("JSON output supported only for VPE API calls and dump_stats_table");
3849 return dump_ip_table (vam, 1);
3853 counter_type_to_str (u8 counter_type, u8 is_combined)
3857 switch (counter_type)
3859 case VNET_INTERFACE_COUNTER_DROP:
3861 case VNET_INTERFACE_COUNTER_PUNT:
3863 case VNET_INTERFACE_COUNTER_IP4:
3865 case VNET_INTERFACE_COUNTER_IP6:
3867 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
3869 case VNET_INTERFACE_COUNTER_RX_MISS:
3871 case VNET_INTERFACE_COUNTER_RX_ERROR:
3873 case VNET_INTERFACE_COUNTER_TX_ERROR:
3876 return "INVALID-COUNTER-TYPE";
3881 switch (counter_type)
3883 case VNET_INTERFACE_COUNTER_RX:
3885 case VNET_INTERFACE_COUNTER_TX:
3888 return "INVALID-COUNTER-TYPE";
3894 dump_stats_table (vat_main_t * vam)
3896 vat_json_node_t node;
3897 vat_json_node_t *msg_array;
3898 vat_json_node_t *msg;
3899 vat_json_node_t *counter_array;
3900 vat_json_node_t *counter;
3901 interface_counter_t c;
3903 ip4_fib_counter_t *c4;
3904 ip6_fib_counter_t *c6;
3907 if (!vam->json_output)
3909 clib_warning ("dump_stats_table supported only in JSON format");
3913 vat_json_init_object (&node);
3915 /* interface counters */
3916 msg_array = vat_json_object_add (&node, "interface_counters");
3917 vat_json_init_array (msg_array);
3918 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
3920 msg = vat_json_array_add (msg_array);
3921 vat_json_init_object (msg);
3922 vat_json_object_add_string_copy (msg, "vnet_counter_type",
3923 (u8 *) counter_type_to_str (i, 0));
3924 vat_json_object_add_int (msg, "is_combined", 0);
3925 counter_array = vat_json_object_add (msg, "data");
3926 vat_json_init_array (counter_array);
3927 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
3929 packets = vam->simple_interface_counters[i][j];
3930 vat_json_array_add_uint (counter_array, packets);
3933 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
3935 msg = vat_json_array_add (msg_array);
3936 vat_json_init_object (msg);
3937 vat_json_object_add_string_copy (msg, "vnet_counter_type",
3938 (u8 *) counter_type_to_str (i, 1));
3939 vat_json_object_add_int (msg, "is_combined", 1);
3940 counter_array = vat_json_object_add (msg, "data");
3941 vat_json_init_array (counter_array);
3942 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
3944 c = vam->combined_interface_counters[i][j];
3945 counter = vat_json_array_add (counter_array);
3946 vat_json_init_object (counter);
3947 vat_json_object_add_uint (counter, "packets", c.packets);
3948 vat_json_object_add_uint (counter, "bytes", c.bytes);
3952 /* ip4 fib counters */
3953 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
3954 vat_json_init_array (msg_array);
3955 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
3957 msg = vat_json_array_add (msg_array);
3958 vat_json_init_object (msg);
3959 vat_json_object_add_uint (msg, "vrf_id",
3960 vam->ip4_fib_counters_vrf_id_by_index[i]);
3961 counter_array = vat_json_object_add (msg, "c");
3962 vat_json_init_array (counter_array);
3963 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
3965 counter = vat_json_array_add (counter_array);
3966 vat_json_init_object (counter);
3967 c4 = &vam->ip4_fib_counters[i][j];
3968 vat_json_object_add_ip4 (counter, "address", c4->address);
3969 vat_json_object_add_uint (counter, "address_length",
3970 c4->address_length);
3971 vat_json_object_add_uint (counter, "packets", c4->packets);
3972 vat_json_object_add_uint (counter, "bytes", c4->bytes);
3976 /* ip6 fib counters */
3977 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
3978 vat_json_init_array (msg_array);
3979 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
3981 msg = vat_json_array_add (msg_array);
3982 vat_json_init_object (msg);
3983 vat_json_object_add_uint (msg, "vrf_id",
3984 vam->ip6_fib_counters_vrf_id_by_index[i]);
3985 counter_array = vat_json_object_add (msg, "c");
3986 vat_json_init_array (counter_array);
3987 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
3989 counter = vat_json_array_add (counter_array);
3990 vat_json_init_object (counter);
3991 c6 = &vam->ip6_fib_counters[i][j];
3992 vat_json_object_add_ip6 (counter, "address", c6->address);
3993 vat_json_object_add_uint (counter, "address_length",
3994 c6->address_length);
3995 vat_json_object_add_uint (counter, "packets", c6->packets);
3996 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4000 vat_json_print (vam->ofp, &node);
4001 vat_json_free (&node);
4007 exec (vat_main_t * vam)
4009 api_main_t *am = &api_main;
4010 vl_api_cli_request_t *mp;
4014 unformat_input_t *i = vam->input;
4016 if (vec_len (i->buffer) == 0)
4019 if (vam->exec_mode == 0 && unformat (i, "mode"))
4024 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4031 M (CLI_REQUEST, cli_request);
4034 * Copy cmd into shared memory.
4035 * In order for the CLI command to work, it
4036 * must be a vector ending in \n, not a C-string ending
4039 pthread_mutex_lock (&am->vlib_rp->mutex);
4040 oldheap = svm_push_data_heap (am->vlib_rp);
4042 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4043 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4045 svm_pop_heap (oldheap);
4046 pthread_mutex_unlock (&am->vlib_rp->mutex);
4048 mp->cmd_in_shmem = (u64) cmd;
4050 timeout = vat_time_now (vam) + 10.0;
4052 while (vat_time_now (vam) < timeout)
4054 if (vam->result_ready == 1)
4057 if (vam->shmem_result != NULL)
4058 fformat (vam->ofp, "%s", vam->shmem_result);
4059 pthread_mutex_lock (&am->vlib_rp->mutex);
4060 oldheap = svm_push_data_heap (am->vlib_rp);
4062 free_me = (u8 *) vam->shmem_result;
4065 svm_pop_heap (oldheap);
4066 pthread_mutex_unlock (&am->vlib_rp->mutex);
4074 api_create_loopback (vat_main_t * vam)
4076 unformat_input_t *i = vam->input;
4077 vl_api_create_loopback_t *mp;
4082 memset (mac_address, 0, sizeof (mac_address));
4084 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4086 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4092 /* Construct the API message */
4093 M (CREATE_LOOPBACK, create_loopback);
4095 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4102 api_delete_loopback (vat_main_t * vam)
4104 unformat_input_t *i = vam->input;
4105 vl_api_delete_loopback_t *mp;
4107 u32 sw_if_index = ~0;
4109 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4111 if (unformat (i, "sw_if_index %d", &sw_if_index))
4117 if (sw_if_index == ~0)
4119 errmsg ("missing sw_if_index\n");
4123 /* Construct the API message */
4124 M (DELETE_LOOPBACK, delete_loopback);
4125 mp->sw_if_index = ntohl (sw_if_index);
4132 api_want_stats (vat_main_t * vam)
4134 unformat_input_t *i = vam->input;
4135 vl_api_want_stats_t *mp;
4139 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4141 if (unformat (i, "enable"))
4143 else if (unformat (i, "disable"))
4151 errmsg ("missing enable|disable\n");
4155 M (WANT_STATS, want_stats);
4156 mp->enable_disable = enable;
4163 api_want_interface_events (vat_main_t * vam)
4165 unformat_input_t *i = vam->input;
4166 vl_api_want_interface_events_t *mp;
4170 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4172 if (unformat (i, "enable"))
4174 else if (unformat (i, "disable"))
4182 errmsg ("missing enable|disable\n");
4186 M (WANT_INTERFACE_EVENTS, want_interface_events);
4187 mp->enable_disable = enable;
4189 vam->interface_event_display = enable;
4196 /* Note: non-static, called once to set up the initial intfc table */
4198 api_sw_interface_dump (vat_main_t * vam)
4200 vl_api_sw_interface_dump_t *mp;
4203 name_sort_t *nses = 0, *ns;
4204 sw_interface_subif_t *sub = NULL;
4206 /* Toss the old name table */
4208 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4210 vec_add2 (nses, ns, 1);
4211 ns->name = (u8 *)(p->key);
4212 ns->value = (u32) p->value[0];
4216 hash_free (vam->sw_if_index_by_interface_name);
4218 vec_foreach (ns, nses) vec_free (ns->name);
4222 vec_foreach (sub, vam->sw_if_subif_table)
4224 vec_free (sub->interface_name);
4226 vec_free (vam->sw_if_subif_table);
4228 /* recreate the interface name hash table */
4229 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4231 /* Get list of ethernets */
4232 M (SW_INTERFACE_DUMP, sw_interface_dump);
4233 mp->name_filter_valid = 1;
4234 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4237 /* and local / loopback interfaces */
4238 M (SW_INTERFACE_DUMP, sw_interface_dump);
4239 mp->name_filter_valid = 1;
4240 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4244 /* and vxlan-gpe tunnel interfaces */
4245 M (SW_INTERFACE_DUMP, sw_interface_dump);
4246 mp->name_filter_valid = 1;
4247 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4248 sizeof (mp->name_filter) - 1);
4251 /* and vxlan tunnel interfaces */
4252 M (SW_INTERFACE_DUMP, sw_interface_dump);
4253 mp->name_filter_valid = 1;
4254 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4257 /* and host (af_packet) interfaces */
4258 M (SW_INTERFACE_DUMP, sw_interface_dump);
4259 mp->name_filter_valid = 1;
4260 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4263 /* and l2tpv3 tunnel interfaces */
4264 M (SW_INTERFACE_DUMP, sw_interface_dump);
4265 mp->name_filter_valid = 1;
4266 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4267 sizeof (mp->name_filter) - 1);
4270 /* and GRE tunnel interfaces */
4271 M (SW_INTERFACE_DUMP, sw_interface_dump);
4272 mp->name_filter_valid = 1;
4273 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4276 /* Use a control ping for synchronization */
4278 vl_api_control_ping_t *mp;
4279 M (CONTROL_PING, control_ping);
4286 api_sw_interface_set_flags (vat_main_t * vam)
4288 unformat_input_t *i = vam->input;
4289 vl_api_sw_interface_set_flags_t *mp;
4292 u8 sw_if_index_set = 0;
4293 u8 admin_up = 0, link_up = 0;
4295 /* Parse args required to build the message */
4296 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4298 if (unformat (i, "admin-up"))
4300 else if (unformat (i, "admin-down"))
4302 else if (unformat (i, "link-up"))
4304 else if (unformat (i, "link-down"))
4306 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4307 sw_if_index_set = 1;
4308 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4309 sw_if_index_set = 1;
4314 if (sw_if_index_set == 0)
4316 errmsg ("missing interface name or sw_if_index\n");
4320 /* Construct the API message */
4321 M (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags);
4322 mp->sw_if_index = ntohl (sw_if_index);
4323 mp->admin_up_down = admin_up;
4324 mp->link_up_down = link_up;
4329 /* Wait for a reply, return the good/bad news... */
4334 api_sw_interface_clear_stats (vat_main_t * vam)
4336 unformat_input_t *i = vam->input;
4337 vl_api_sw_interface_clear_stats_t *mp;
4340 u8 sw_if_index_set = 0;
4342 /* Parse args required to build the message */
4343 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4345 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4346 sw_if_index_set = 1;
4347 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4348 sw_if_index_set = 1;
4353 /* Construct the API message */
4354 M (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats);
4356 if (sw_if_index_set == 1)
4357 mp->sw_if_index = ntohl (sw_if_index);
4359 mp->sw_if_index = ~0;
4364 /* Wait for a reply, return the good/bad news... */
4369 api_sw_interface_add_del_address (vat_main_t * vam)
4371 unformat_input_t *i = vam->input;
4372 vl_api_sw_interface_add_del_address_t *mp;
4375 u8 sw_if_index_set = 0;
4376 u8 is_add = 1, del_all = 0;
4377 u32 address_length = 0;
4378 u8 v4_address_set = 0;
4379 u8 v6_address_set = 0;
4380 ip4_address_t v4address;
4381 ip6_address_t v6address;
4383 /* Parse args required to build the message */
4384 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4386 if (unformat (i, "del-all"))
4388 else if (unformat (i, "del"))
4390 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4391 sw_if_index_set = 1;
4392 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4393 sw_if_index_set = 1;
4394 else if (unformat (i, "%U/%d",
4395 unformat_ip4_address, &v4address, &address_length))
4397 else if (unformat (i, "%U/%d",
4398 unformat_ip6_address, &v6address, &address_length))
4404 if (sw_if_index_set == 0)
4406 errmsg ("missing interface name or sw_if_index\n");
4409 if (v4_address_set && v6_address_set)
4411 errmsg ("both v4 and v6 addresses set\n");
4414 if (!v4_address_set && !v6_address_set && !del_all)
4416 errmsg ("no addresses set\n");
4420 /* Construct the API message */
4421 M (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address);
4423 mp->sw_if_index = ntohl (sw_if_index);
4424 mp->is_add = is_add;
4425 mp->del_all = del_all;
4429 clib_memcpy (mp->address, &v6address, sizeof (v6address));
4433 clib_memcpy (mp->address, &v4address, sizeof (v4address));
4435 mp->address_length = address_length;
4440 /* Wait for a reply, return good/bad news */
4445 api_sw_interface_set_table (vat_main_t * vam)
4447 unformat_input_t *i = vam->input;
4448 vl_api_sw_interface_set_table_t *mp;
4450 u32 sw_if_index, vrf_id = 0;
4451 u8 sw_if_index_set = 0;
4454 /* Parse args required to build the message */
4455 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4457 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4458 sw_if_index_set = 1;
4459 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4460 sw_if_index_set = 1;
4461 else if (unformat (i, "vrf %d", &vrf_id))
4463 else if (unformat (i, "ipv6"))
4469 if (sw_if_index_set == 0)
4471 errmsg ("missing interface name or sw_if_index\n");
4475 /* Construct the API message */
4476 M (SW_INTERFACE_SET_TABLE, sw_interface_set_table);
4478 mp->sw_if_index = ntohl (sw_if_index);
4479 mp->is_ipv6 = is_ipv6;
4480 mp->vrf_id = ntohl (vrf_id);
4485 /* Wait for a reply... */
4490 api_sw_interface_set_vpath (vat_main_t * vam)
4492 unformat_input_t *i = vam->input;
4493 vl_api_sw_interface_set_vpath_t *mp;
4495 u32 sw_if_index = 0;
4496 u8 sw_if_index_set = 0;
4499 /* Parse args required to build the message */
4500 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4502 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4503 sw_if_index_set = 1;
4504 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4505 sw_if_index_set = 1;
4506 else if (unformat (i, "enable"))
4508 else if (unformat (i, "disable"))
4514 if (sw_if_index_set == 0)
4516 errmsg ("missing interface name or sw_if_index\n");
4520 /* Construct the API message */
4521 M (SW_INTERFACE_SET_VPATH, sw_interface_set_vpath);
4523 mp->sw_if_index = ntohl (sw_if_index);
4524 mp->enable = is_enable;
4529 /* Wait for a reply... */
4534 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
4536 unformat_input_t *i = vam->input;
4537 vl_api_sw_interface_set_l2_xconnect_t *mp;
4540 u8 rx_sw_if_index_set = 0;
4542 u8 tx_sw_if_index_set = 0;
4545 /* Parse args required to build the message */
4546 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4548 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
4549 rx_sw_if_index_set = 1;
4550 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
4551 tx_sw_if_index_set = 1;
4552 else if (unformat (i, "rx"))
4554 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4556 if (unformat (i, "%U", unformat_sw_if_index, vam,
4558 rx_sw_if_index_set = 1;
4563 else if (unformat (i, "tx"))
4565 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4567 if (unformat (i, "%U", unformat_sw_if_index, vam,
4569 tx_sw_if_index_set = 1;
4574 else if (unformat (i, "enable"))
4576 else if (unformat (i, "disable"))
4582 if (rx_sw_if_index_set == 0)
4584 errmsg ("missing rx interface name or rx_sw_if_index\n");
4588 if (enable && (tx_sw_if_index_set == 0))
4590 errmsg ("missing tx interface name or tx_sw_if_index\n");
4594 M (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect);
4596 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
4597 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
4598 mp->enable = enable;
4607 api_sw_interface_set_l2_bridge (vat_main_t * vam)
4609 unformat_input_t *i = vam->input;
4610 vl_api_sw_interface_set_l2_bridge_t *mp;
4613 u8 rx_sw_if_index_set = 0;
4620 /* Parse args required to build the message */
4621 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4623 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
4624 rx_sw_if_index_set = 1;
4625 else if (unformat (i, "bd_id %d", &bd_id))
4627 else if (unformat (i, "%U", unformat_sw_if_index, vam, &rx_sw_if_index))
4628 rx_sw_if_index_set = 1;
4629 else if (unformat (i, "shg %d", &shg))
4631 else if (unformat (i, "bvi"))
4633 else if (unformat (i, "enable"))
4635 else if (unformat (i, "disable"))
4641 if (rx_sw_if_index_set == 0)
4643 errmsg ("missing rx interface name or sw_if_index\n");
4647 if (enable && (bd_id_set == 0))
4649 errmsg ("missing bridge domain\n");
4653 M (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge);
4655 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
4656 mp->bd_id = ntohl (bd_id);
4659 mp->enable = enable;
4668 api_bridge_domain_dump (vat_main_t * vam)
4670 unformat_input_t *i = vam->input;
4671 vl_api_bridge_domain_dump_t *mp;
4675 /* Parse args required to build the message */
4676 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4678 if (unformat (i, "bd_id %d", &bd_id))
4684 M (BRIDGE_DOMAIN_DUMP, bridge_domain_dump);
4685 mp->bd_id = ntohl (bd_id);
4688 /* Use a control ping for synchronization */
4690 vl_api_control_ping_t *mp;
4691 M (CONTROL_PING, control_ping);
4701 api_bridge_domain_add_del (vat_main_t * vam)
4703 unformat_input_t *i = vam->input;
4704 vl_api_bridge_domain_add_del_t *mp;
4708 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
4710 /* Parse args required to build the message */
4711 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4713 if (unformat (i, "bd_id %d", &bd_id))
4715 else if (unformat (i, "flood %d", &flood))
4717 else if (unformat (i, "uu-flood %d", &uu_flood))
4719 else if (unformat (i, "forward %d", &forward))
4721 else if (unformat (i, "learn %d", &learn))
4723 else if (unformat (i, "arp-term %d", &arp_term))
4725 else if (unformat (i, "del"))
4728 flood = uu_flood = forward = learn = 0;
4736 errmsg ("missing bridge domain\n");
4740 M (BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del);
4742 mp->bd_id = ntohl (bd_id);
4744 mp->uu_flood = uu_flood;
4745 mp->forward = forward;
4747 mp->arp_term = arp_term;
4748 mp->is_add = is_add;
4757 api_l2fib_add_del (vat_main_t * vam)
4759 unformat_input_t *i = vam->input;
4760 vl_api_l2fib_add_del_t *mp;
4767 u8 sw_if_index_set = 0;
4776 /* Parse args required to build the message */
4777 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4779 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
4781 else if (unformat (i, "bd_id %d", &bd_id))
4783 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4784 sw_if_index_set = 1;
4785 else if (unformat (i, "sw_if"))
4787 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4789 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4790 sw_if_index_set = 1;
4795 else if (unformat (i, "static"))
4797 else if (unformat (i, "filter"))
4802 else if (unformat (i, "bvi"))
4807 else if (unformat (i, "del"))
4809 else if (unformat (i, "count %d", &count))
4817 errmsg ("missing mac address\n");
4823 errmsg ("missing bridge domain\n");
4827 if (is_add && (sw_if_index_set == 0))
4829 errmsg ("missing interface name or sw_if_index\n");
4835 /* Turn on async mode */
4836 vam->async_mode = 1;
4837 vam->async_errors = 0;
4838 before = vat_time_now (vam);
4841 for (j = 0; j < count; j++)
4843 M (L2FIB_ADD_DEL, l2fib_add_del);
4846 mp->bd_id = ntohl (bd_id);
4847 mp->is_add = is_add;
4851 mp->sw_if_index = ntohl (sw_if_index);
4852 mp->static_mac = static_mac;
4853 mp->filter_mac = filter_mac;
4854 mp->bvi_mac = bvi_mac;
4856 increment_mac_address (&mac);
4863 vl_api_control_ping_t *mp;
4866 /* Shut off async mode */
4867 vam->async_mode = 0;
4869 M (CONTROL_PING, control_ping);
4872 timeout = vat_time_now (vam) + 1.0;
4873 while (vat_time_now (vam) < timeout)
4874 if (vam->result_ready == 1)
4879 if (vam->retval == -99)
4880 errmsg ("timeout\n");
4882 if (vam->async_errors > 0)
4884 errmsg ("%d asynchronous errors\n", vam->async_errors);
4887 vam->async_errors = 0;
4888 after = vat_time_now (vam);
4890 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
4891 count, after - before, count / (after - before));
4895 /* Wait for a reply... */
4898 /* Return the good/bad news */
4899 return (vam->retval);
4903 api_l2_flags (vat_main_t * vam)
4905 unformat_input_t *i = vam->input;
4906 vl_api_l2_flags_t *mp;
4909 u32 feature_bitmap = 0;
4910 u8 sw_if_index_set = 0;
4912 /* Parse args required to build the message */
4913 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4915 if (unformat (i, "sw_if_index %d", &sw_if_index))
4916 sw_if_index_set = 1;
4917 else if (unformat (i, "sw_if"))
4919 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4921 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4922 sw_if_index_set = 1;
4927 else if (unformat (i, "learn"))
4928 feature_bitmap |= L2INPUT_FEAT_LEARN;
4929 else if (unformat (i, "forward"))
4930 feature_bitmap |= L2INPUT_FEAT_FWD;
4931 else if (unformat (i, "flood"))
4932 feature_bitmap |= L2INPUT_FEAT_FLOOD;
4933 else if (unformat (i, "uu-flood"))
4934 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
4939 if (sw_if_index_set == 0)
4941 errmsg ("missing interface name or sw_if_index\n");
4945 M (L2_FLAGS, l2_flags);
4947 mp->sw_if_index = ntohl (sw_if_index);
4948 mp->feature_bitmap = ntohl (feature_bitmap);
4957 api_bridge_flags (vat_main_t * vam)
4959 unformat_input_t *i = vam->input;
4960 vl_api_bridge_flags_t *mp;
4967 /* Parse args required to build the message */
4968 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4970 if (unformat (i, "bd_id %d", &bd_id))
4972 else if (unformat (i, "learn"))
4974 else if (unformat (i, "forward"))
4976 else if (unformat (i, "flood"))
4978 else if (unformat (i, "uu-flood"))
4979 flags |= L2_UU_FLOOD;
4980 else if (unformat (i, "arp-term"))
4981 flags |= L2_ARP_TERM;
4982 else if (unformat (i, "off"))
4984 else if (unformat (i, "disable"))
4992 errmsg ("missing bridge domain\n");
4996 M (BRIDGE_FLAGS, bridge_flags);
4998 mp->bd_id = ntohl (bd_id);
4999 mp->feature_bitmap = ntohl (flags);
5000 mp->is_set = is_set;
5009 api_bd_ip_mac_add_del (vat_main_t * vam)
5011 unformat_input_t *i = vam->input;
5012 vl_api_bd_ip_mac_add_del_t *mp;
5020 ip4_address_t v4addr;
5021 ip6_address_t v6addr;
5025 /* Parse args required to build the message */
5026 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5028 if (unformat (i, "bd_id %d", &bd_id))
5032 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5036 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5041 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5045 else if (unformat (i, "del"))
5053 errmsg ("missing bridge domain\n");
5056 else if (ip_set == 0)
5058 errmsg ("missing IP address\n");
5061 else if (mac_set == 0)
5063 errmsg ("missing MAC address\n");
5067 M (BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del);
5069 mp->bd_id = ntohl (bd_id);
5070 mp->is_ipv6 = is_ipv6;
5071 mp->is_add = is_add;
5073 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5075 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5076 clib_memcpy (mp->mac_address, macaddr, 6);
5084 api_tap_connect (vat_main_t * vam)
5086 unformat_input_t *i = vam->input;
5087 vl_api_tap_connect_t *mp;
5094 memset (mac_address, 0, sizeof (mac_address));
5096 /* Parse args required to build the message */
5097 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5099 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5103 else if (unformat (i, "random-mac"))
5105 else if (unformat (i, "tapname %s", &tap_name))
5113 errmsg ("missing tap name\n");
5116 if (vec_len (tap_name) > 63)
5118 errmsg ("tap name too long\n");
5120 vec_add1 (tap_name, 0);
5122 /* Construct the API message */
5123 M (TAP_CONNECT, tap_connect);
5125 mp->use_random_mac = random_mac;
5126 clib_memcpy (mp->mac_address, mac_address, 6);
5127 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5128 vec_free (tap_name);
5133 /* Wait for a reply... */
5138 api_tap_modify (vat_main_t * vam)
5140 unformat_input_t *i = vam->input;
5141 vl_api_tap_modify_t *mp;
5147 u32 sw_if_index = ~0;
5148 u8 sw_if_index_set = 0;
5150 memset (mac_address, 0, sizeof (mac_address));
5152 /* Parse args required to build the message */
5153 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5155 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5156 sw_if_index_set = 1;
5157 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5158 sw_if_index_set = 1;
5159 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5163 else if (unformat (i, "random-mac"))
5165 else if (unformat (i, "tapname %s", &tap_name))
5171 if (sw_if_index_set == 0)
5173 errmsg ("missing vpp interface name");
5178 errmsg ("missing tap name\n");
5181 if (vec_len (tap_name) > 63)
5183 errmsg ("tap name too long\n");
5185 vec_add1 (tap_name, 0);
5187 /* Construct the API message */
5188 M (TAP_MODIFY, tap_modify);
5190 mp->use_random_mac = random_mac;
5191 mp->sw_if_index = ntohl (sw_if_index);
5192 clib_memcpy (mp->mac_address, mac_address, 6);
5193 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5194 vec_free (tap_name);
5199 /* Wait for a reply... */
5204 api_tap_delete (vat_main_t * vam)
5206 unformat_input_t *i = vam->input;
5207 vl_api_tap_delete_t *mp;
5209 u32 sw_if_index = ~0;
5210 u8 sw_if_index_set = 0;
5212 /* Parse args required to build the message */
5213 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5215 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5216 sw_if_index_set = 1;
5217 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5218 sw_if_index_set = 1;
5223 if (sw_if_index_set == 0)
5225 errmsg ("missing vpp interface name");
5229 /* Construct the API message */
5230 M (TAP_DELETE, tap_delete);
5232 mp->sw_if_index = ntohl (sw_if_index);
5237 /* Wait for a reply... */
5242 api_ip_add_del_route (vat_main_t * vam)
5244 unformat_input_t *i = vam->input;
5245 vl_api_ip_add_del_route_t *mp;
5247 u32 sw_if_index = ~0, vrf_id = 0;
5248 u8 sw_if_index_set = 0;
5250 u8 is_local = 0, is_drop = 0;
5251 u8 create_vrf_if_needed = 0;
5253 u8 next_hop_weight = 1;
5255 u8 is_multipath = 0;
5257 u8 address_length_set = 0;
5258 u32 lookup_in_vrf = 0;
5259 u32 resolve_attempts = 0;
5260 u32 dst_address_length = 0;
5261 u8 next_hop_set = 0;
5262 ip4_address_t v4_dst_address, v4_next_hop_address;
5263 ip6_address_t v6_dst_address, v6_next_hop_address;
5267 u32 random_add_del = 0;
5268 u32 *random_vector = 0;
5270 u32 random_seed = 0xdeaddabe;
5271 u32 classify_table_index = ~0;
5274 /* Parse args required to build the message */
5275 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5277 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5278 sw_if_index_set = 1;
5279 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5280 sw_if_index_set = 1;
5281 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
5286 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
5291 else if (unformat (i, "/%d", &dst_address_length))
5293 address_length_set = 1;
5296 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
5297 &v4_next_hop_address))
5301 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
5302 &v6_next_hop_address))
5306 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
5308 else if (unformat (i, "weight %d", &next_hop_weight))
5310 else if (unformat (i, "drop"))
5314 else if (unformat (i, "local"))
5318 else if (unformat (i, "classify %d", &classify_table_index))
5322 else if (unformat (i, "del"))
5324 else if (unformat (i, "add"))
5326 else if (unformat (i, "not-last"))
5328 else if (unformat (i, "multipath"))
5330 else if (unformat (i, "vrf %d", &vrf_id))
5332 else if (unformat (i, "create-vrf"))
5333 create_vrf_if_needed = 1;
5334 else if (unformat (i, "count %d", &count))
5336 else if (unformat (i, "lookup-in-vrf %d", &lookup_in_vrf))
5338 else if (unformat (i, "random"))
5340 else if (unformat (i, "seed %d", &random_seed))
5344 clib_warning ("parse error '%U'", format_unformat_error, i);
5349 if (resolve_attempts > 0 && sw_if_index_set == 0)
5351 errmsg ("ARP resolution needs explicit interface or sw_if_index\n");
5355 if (!next_hop_set && !is_drop && !is_local && !is_classify)
5357 errmsg ("next hop / local / drop / classify not set\n");
5361 if (address_set == 0)
5363 errmsg ("missing addresses\n");
5367 if (address_length_set == 0)
5369 errmsg ("missing address length\n");
5373 /* Generate a pile of unique, random routes */
5376 u32 this_random_address;
5377 random_hash = hash_create (count, sizeof (uword));
5379 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
5380 for (j = 0; j <= count; j++)
5384 this_random_address = random_u32 (&random_seed);
5385 this_random_address =
5386 clib_host_to_net_u32 (this_random_address);
5388 while (hash_get (random_hash, this_random_address));
5389 vec_add1 (random_vector, this_random_address);
5390 hash_set (random_hash, this_random_address, 1);
5392 hash_free (random_hash);
5393 v4_dst_address.as_u32 = random_vector[0];
5398 /* Turn on async mode */
5399 vam->async_mode = 1;
5400 vam->async_errors = 0;
5401 before = vat_time_now (vam);
5404 for (j = 0; j < count; j++)
5406 /* Construct the API message */
5407 M (IP_ADD_DEL_ROUTE, ip_add_del_route);
5409 mp->next_hop_sw_if_index = ntohl (sw_if_index);
5410 mp->vrf_id = ntohl (vrf_id);
5411 if (resolve_attempts > 0)
5413 mp->resolve_attempts = ntohl (resolve_attempts);
5414 mp->resolve_if_needed = 1;
5416 mp->create_vrf_if_needed = create_vrf_if_needed;
5418 mp->is_add = is_add;
5419 mp->is_drop = is_drop;
5420 mp->is_ipv6 = is_ipv6;
5421 mp->is_local = is_local;
5422 mp->is_classify = is_classify;
5423 mp->is_multipath = is_multipath;
5424 mp->not_last = not_last;
5425 mp->next_hop_weight = next_hop_weight;
5426 mp->dst_address_length = dst_address_length;
5427 mp->lookup_in_vrf = ntohl (lookup_in_vrf);
5428 mp->classify_table_index = ntohl (classify_table_index);
5432 clib_memcpy (mp->dst_address, &v6_dst_address,
5433 sizeof (v6_dst_address));
5435 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
5436 sizeof (v6_next_hop_address));
5437 increment_v6_address (&v6_dst_address);
5441 clib_memcpy (mp->dst_address, &v4_dst_address,
5442 sizeof (v4_dst_address));
5444 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
5445 sizeof (v4_next_hop_address));
5447 v4_dst_address.as_u32 = random_vector[j + 1];
5449 increment_v4_address (&v4_dst_address);
5455 /* When testing multiple add/del ops, use a control-ping to sync */
5458 vl_api_control_ping_t *mp;
5461 /* Shut off async mode */
5462 vam->async_mode = 0;
5464 M (CONTROL_PING, control_ping);
5467 timeout = vat_time_now (vam) + 1.0;
5468 while (vat_time_now (vam) < timeout)
5469 if (vam->result_ready == 1)
5474 if (vam->retval == -99)
5475 errmsg ("timeout\n");
5477 if (vam->async_errors > 0)
5479 errmsg ("%d asynchronous errors\n", vam->async_errors);
5482 vam->async_errors = 0;
5483 after = vat_time_now (vam);
5485 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
5486 count, after - before, count / (after - before));
5490 /* Wait for a reply... */
5494 /* Return the good/bad news */
5495 return (vam->retval);
5499 api_proxy_arp_add_del (vat_main_t * vam)
5501 unformat_input_t *i = vam->input;
5502 vl_api_proxy_arp_add_del_t *mp;
5506 ip4_address_t lo, hi;
5509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5511 if (unformat (i, "vrf %d", &vrf_id))
5513 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
5514 unformat_ip4_address, &hi))
5516 else if (unformat (i, "del"))
5520 clib_warning ("parse error '%U'", format_unformat_error, i);
5527 errmsg ("address range not set\n");
5531 M (PROXY_ARP_ADD_DEL, proxy_arp_add_del);
5533 mp->vrf_id = ntohl (vrf_id);
5534 mp->is_add = is_add;
5535 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
5536 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
5545 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
5547 unformat_input_t *i = vam->input;
5548 vl_api_proxy_arp_intfc_enable_disable_t *mp;
5552 u8 sw_if_index_set = 0;
5554 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5556 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5557 sw_if_index_set = 1;
5558 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5559 sw_if_index_set = 1;
5560 else if (unformat (i, "enable"))
5562 else if (unformat (i, "disable"))
5566 clib_warning ("parse error '%U'", format_unformat_error, i);
5571 if (sw_if_index_set == 0)
5573 errmsg ("missing interface name or sw_if_index\n");
5577 M (PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable);
5579 mp->sw_if_index = ntohl (sw_if_index);
5580 mp->enable_disable = enable;
5589 api_mpls_add_del_decap (vat_main_t * vam)
5591 unformat_input_t *i = vam->input;
5592 vl_api_mpls_add_del_decap_t *mp;
5601 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5603 if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
5605 else if (unformat (i, "tx_vrf_id %d", &tx_vrf_id))
5607 else if (unformat (i, "label %d", &label))
5609 else if (unformat (i, "next-index %d", &next_index))
5611 else if (unformat (i, "del"))
5613 else if (unformat (i, "s-bit-clear"))
5617 clib_warning ("parse error '%U'", format_unformat_error, i);
5622 M (MPLS_ADD_DEL_DECAP, mpls_add_del_decap);
5624 mp->rx_vrf_id = ntohl (rx_vrf_id);
5625 mp->tx_vrf_id = ntohl (tx_vrf_id);
5626 mp->label = ntohl (label);
5627 mp->next_index = ntohl (next_index);
5629 mp->is_add = is_add;
5638 api_mpls_add_del_encap (vat_main_t * vam)
5640 unformat_input_t *i = vam->input;
5641 vl_api_mpls_add_del_encap_t *mp;
5646 ip4_address_t dst_address;
5649 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5651 if (unformat (i, "vrf %d", &vrf_id))
5653 else if (unformat (i, "label %d", &label))
5654 vec_add1 (labels, ntohl (label));
5655 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
5657 else if (unformat (i, "del"))
5661 clib_warning ("parse error '%U'", format_unformat_error, i);
5666 if (vec_len (labels) == 0)
5668 errmsg ("missing encap label stack\n");
5672 M2 (MPLS_ADD_DEL_ENCAP, mpls_add_del_encap,
5673 sizeof (u32) * vec_len (labels));
5675 mp->vrf_id = ntohl (vrf_id);
5676 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
5677 mp->is_add = is_add;
5678 mp->nlabels = vec_len (labels);
5679 clib_memcpy (mp->labels, labels, sizeof (u32) * mp->nlabels);
5690 api_mpls_gre_add_del_tunnel (vat_main_t * vam)
5692 unformat_input_t *i = vam->input;
5693 vl_api_mpls_gre_add_del_tunnel_t *mp;
5695 u32 inner_vrf_id = 0;
5696 u32 outer_vrf_id = 0;
5697 ip4_address_t src_address;
5698 ip4_address_t dst_address;
5699 ip4_address_t intfc_address;
5701 u8 intfc_address_length = 0;
5705 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5707 if (unformat (i, "inner_vrf_id %d", &inner_vrf_id))
5709 else if (unformat (i, "outer_vrf_id %d", &outer_vrf_id))
5711 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
5713 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
5715 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
5716 &intfc_address, &tmp))
5717 intfc_address_length = tmp;
5718 else if (unformat (i, "l2-only"))
5720 else if (unformat (i, "del"))
5724 clib_warning ("parse error '%U'", format_unformat_error, i);
5729 M (MPLS_GRE_ADD_DEL_TUNNEL, mpls_gre_add_del_tunnel);
5731 mp->inner_vrf_id = ntohl (inner_vrf_id);
5732 mp->outer_vrf_id = ntohl (outer_vrf_id);
5733 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
5734 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
5735 clib_memcpy (mp->intfc_address, &intfc_address, sizeof (intfc_address));
5736 mp->intfc_address_length = intfc_address_length;
5737 mp->l2_only = l2_only;
5738 mp->is_add = is_add;
5747 api_mpls_ethernet_add_del_tunnel (vat_main_t * vam)
5749 unformat_input_t *i = vam->input;
5750 vl_api_mpls_ethernet_add_del_tunnel_t *mp;
5752 u32 inner_vrf_id = 0;
5753 ip4_address_t intfc_address;
5754 u8 dst_mac_address[6];
5757 u8 intfc_address_length = 0;
5761 int tx_sw_if_index_set = 0;
5763 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5765 if (unformat (i, "vrf %d", &inner_vrf_id))
5767 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
5768 &intfc_address, &tmp))
5769 intfc_address_length = tmp;
5770 else if (unformat (i, "%U", unformat_sw_if_index, vam, &tx_sw_if_index))
5771 tx_sw_if_index_set = 1;
5772 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5773 tx_sw_if_index_set = 1;
5774 else if (unformat (i, "dst %U", unformat_ethernet_address,
5777 else if (unformat (i, "l2-only"))
5779 else if (unformat (i, "del"))
5783 clib_warning ("parse error '%U'", format_unformat_error, i);
5790 errmsg ("dst (mac address) not set\n");
5793 if (!tx_sw_if_index_set)
5795 errmsg ("tx-intfc not set\n");
5799 M (MPLS_ETHERNET_ADD_DEL_TUNNEL, mpls_ethernet_add_del_tunnel);
5801 mp->vrf_id = ntohl (inner_vrf_id);
5802 clib_memcpy (mp->adj_address, &intfc_address, sizeof (intfc_address));
5803 mp->adj_address_length = intfc_address_length;
5804 clib_memcpy (mp->dst_mac_address, dst_mac_address,
5805 sizeof (dst_mac_address));
5806 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5807 mp->l2_only = l2_only;
5808 mp->is_add = is_add;
5817 api_mpls_ethernet_add_del_tunnel_2 (vat_main_t * vam)
5819 unformat_input_t *i = vam->input;
5820 vl_api_mpls_ethernet_add_del_tunnel_2_t *mp;
5822 u32 inner_vrf_id = 0;
5823 u32 outer_vrf_id = 0;
5824 ip4_address_t adj_address;
5825 int adj_address_set = 0;
5826 ip4_address_t next_hop_address;
5827 int next_hop_address_set = 0;
5829 u8 adj_address_length = 0;
5832 u32 resolve_attempts = 5;
5833 u8 resolve_if_needed = 1;
5835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5837 if (unformat (i, "inner_vrf_id %d", &inner_vrf_id))
5839 else if (unformat (i, "outer_vrf_id %d", &outer_vrf_id))
5841 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
5842 &adj_address, &tmp))
5844 adj_address_length = tmp;
5845 adj_address_set = 1;
5847 else if (unformat (i, "next-hop %U", unformat_ip4_address,
5849 next_hop_address_set = 1;
5850 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
5852 else if (unformat (i, "resolve-if-needed %d", &tmp))
5853 resolve_if_needed = tmp;
5854 else if (unformat (i, "l2-only"))
5856 else if (unformat (i, "del"))
5860 clib_warning ("parse error '%U'", format_unformat_error, i);
5865 if (!adj_address_set)
5867 errmsg ("adjacency address/mask not set\n");
5870 if (!next_hop_address_set)
5872 errmsg ("ip4 next hop address (in outer fib) not set\n");
5876 M (MPLS_ETHERNET_ADD_DEL_TUNNEL_2, mpls_ethernet_add_del_tunnel_2);
5878 mp->inner_vrf_id = ntohl (inner_vrf_id);
5879 mp->outer_vrf_id = ntohl (outer_vrf_id);
5880 mp->resolve_attempts = ntohl (resolve_attempts);
5881 mp->resolve_if_needed = resolve_if_needed;
5882 mp->is_add = is_add;
5883 mp->l2_only = l2_only;
5884 clib_memcpy (mp->adj_address, &adj_address, sizeof (adj_address));
5885 mp->adj_address_length = adj_address_length;
5886 clib_memcpy (mp->next_hop_ip4_address_in_outer_vrf, &next_hop_address,
5887 sizeof (next_hop_address));
5896 api_sw_interface_set_unnumbered (vat_main_t * vam)
5898 unformat_input_t *i = vam->input;
5899 vl_api_sw_interface_set_unnumbered_t *mp;
5902 u32 unnum_sw_index = ~0;
5904 u8 sw_if_index_set = 0;
5906 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5908 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5909 sw_if_index_set = 1;
5910 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5911 sw_if_index_set = 1;
5912 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
5914 else if (unformat (i, "del"))
5918 clib_warning ("parse error '%U'", format_unformat_error, i);
5923 if (sw_if_index_set == 0)
5925 errmsg ("missing interface name or sw_if_index\n");
5929 M (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered);
5931 mp->sw_if_index = ntohl (sw_if_index);
5932 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
5933 mp->is_add = is_add;
5942 api_ip_neighbor_add_del (vat_main_t * vam)
5944 unformat_input_t *i = vam->input;
5945 vl_api_ip_neighbor_add_del_t *mp;
5948 u8 sw_if_index_set = 0;
5954 u8 v4_address_set = 0;
5955 u8 v6_address_set = 0;
5956 ip4_address_t v4address;
5957 ip6_address_t v6address;
5959 memset (mac_address, 0, sizeof (mac_address));
5961 /* Parse args required to build the message */
5962 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5964 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5968 else if (unformat (i, "del"))
5970 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5971 sw_if_index_set = 1;
5972 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5973 sw_if_index_set = 1;
5974 else if (unformat (i, "is_static"))
5976 else if (unformat (i, "vrf %d", &vrf_id))
5978 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
5980 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
5984 clib_warning ("parse error '%U'", format_unformat_error, i);
5989 if (sw_if_index_set == 0)
5991 errmsg ("missing interface name or sw_if_index\n");
5994 if (v4_address_set && v6_address_set)
5996 errmsg ("both v4 and v6 addresses set\n");
5999 if (!v4_address_set && !v6_address_set)
6001 errmsg ("no address set\n");
6005 /* Construct the API message */
6006 M (IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del);
6008 mp->sw_if_index = ntohl (sw_if_index);
6009 mp->is_add = is_add;
6010 mp->vrf_id = ntohl (vrf_id);
6011 mp->is_static = is_static;
6013 clib_memcpy (mp->mac_address, mac_address, 6);
6017 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
6021 /* mp->is_ipv6 = 0; via memset in M macro above */
6022 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
6028 /* Wait for a reply, return good/bad news */
6036 api_reset_vrf (vat_main_t * vam)
6038 unformat_input_t *i = vam->input;
6039 vl_api_reset_vrf_t *mp;
6045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6047 if (unformat (i, "vrf %d", &vrf_id))
6049 else if (unformat (i, "ipv6"))
6053 clib_warning ("parse error '%U'", format_unformat_error, i);
6058 if (vrf_id_set == 0)
6060 errmsg ("missing vrf id\n");
6064 M (RESET_VRF, reset_vrf);
6066 mp->vrf_id = ntohl (vrf_id);
6067 mp->is_ipv6 = is_ipv6;
6076 api_create_vlan_subif (vat_main_t * vam)
6078 unformat_input_t *i = vam->input;
6079 vl_api_create_vlan_subif_t *mp;
6082 u8 sw_if_index_set = 0;
6086 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6088 if (unformat (i, "sw_if_index %d", &sw_if_index))
6089 sw_if_index_set = 1;
6090 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6091 sw_if_index_set = 1;
6092 else if (unformat (i, "vlan %d", &vlan_id))
6096 clib_warning ("parse error '%U'", format_unformat_error, i);
6101 if (sw_if_index_set == 0)
6103 errmsg ("missing interface name or sw_if_index\n");
6107 if (vlan_id_set == 0)
6109 errmsg ("missing vlan_id\n");
6112 M (CREATE_VLAN_SUBIF, create_vlan_subif);
6114 mp->sw_if_index = ntohl (sw_if_index);
6115 mp->vlan_id = ntohl (vlan_id);
6123 #define foreach_create_subif_bit \
6130 _(outer_vlan_id_any) \
6131 _(inner_vlan_id_any)
6134 api_create_subif (vat_main_t * vam)
6136 unformat_input_t *i = vam->input;
6137 vl_api_create_subif_t *mp;
6140 u8 sw_if_index_set = 0;
6147 u32 exact_match = 0;
6148 u32 default_sub = 0;
6149 u32 outer_vlan_id_any = 0;
6150 u32 inner_vlan_id_any = 0;
6152 u16 outer_vlan_id = 0;
6153 u16 inner_vlan_id = 0;
6155 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6157 if (unformat (i, "sw_if_index %d", &sw_if_index))
6158 sw_if_index_set = 1;
6159 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6160 sw_if_index_set = 1;
6161 else if (unformat (i, "sub_id %d", &sub_id))
6163 else if (unformat (i, "outer_vlan_id %d", &tmp))
6164 outer_vlan_id = tmp;
6165 else if (unformat (i, "inner_vlan_id %d", &tmp))
6166 inner_vlan_id = tmp;
6168 #define _(a) else if (unformat (i, #a)) a = 1 ;
6169 foreach_create_subif_bit
6173 clib_warning ("parse error '%U'", format_unformat_error, i);
6178 if (sw_if_index_set == 0)
6180 errmsg ("missing interface name or sw_if_index\n");
6184 if (sub_id_set == 0)
6186 errmsg ("missing sub_id\n");
6189 M (CREATE_SUBIF, create_subif);
6191 mp->sw_if_index = ntohl (sw_if_index);
6192 mp->sub_id = ntohl (sub_id);
6194 #define _(a) mp->a = a;
6195 foreach_create_subif_bit;
6198 mp->outer_vlan_id = ntohs (outer_vlan_id);
6199 mp->inner_vlan_id = ntohs (inner_vlan_id);
6208 api_oam_add_del (vat_main_t * vam)
6210 unformat_input_t *i = vam->input;
6211 vl_api_oam_add_del_t *mp;
6215 ip4_address_t src, dst;
6219 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6221 if (unformat (i, "vrf %d", &vrf_id))
6223 else if (unformat (i, "src %U", unformat_ip4_address, &src))
6225 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
6227 else if (unformat (i, "del"))
6231 clib_warning ("parse error '%U'", format_unformat_error, i);
6238 errmsg ("missing src addr\n");
6244 errmsg ("missing dst addr\n");
6248 M (OAM_ADD_DEL, oam_add_del);
6250 mp->vrf_id = ntohl (vrf_id);
6251 mp->is_add = is_add;
6252 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
6253 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
6262 api_reset_fib (vat_main_t * vam)
6264 unformat_input_t *i = vam->input;
6265 vl_api_reset_fib_t *mp;
6271 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6273 if (unformat (i, "vrf %d", &vrf_id))
6275 else if (unformat (i, "ipv6"))
6279 clib_warning ("parse error '%U'", format_unformat_error, i);
6284 if (vrf_id_set == 0)
6286 errmsg ("missing vrf id\n");
6290 M (RESET_FIB, reset_fib);
6292 mp->vrf_id = ntohl (vrf_id);
6293 mp->is_ipv6 = is_ipv6;
6302 api_dhcp_proxy_config (vat_main_t * vam)
6304 unformat_input_t *i = vam->input;
6305 vl_api_dhcp_proxy_config_t *mp;
6310 u8 v4_address_set = 0;
6311 u8 v6_address_set = 0;
6312 ip4_address_t v4address;
6313 ip6_address_t v6address;
6314 u8 v4_src_address_set = 0;
6315 u8 v6_src_address_set = 0;
6316 ip4_address_t v4srcaddress;
6317 ip6_address_t v6srcaddress;
6319 /* Parse args required to build the message */
6320 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6322 if (unformat (i, "del"))
6324 else if (unformat (i, "vrf %d", &vrf_id))
6326 else if (unformat (i, "insert-cid %d", &insert_cid))
6328 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
6330 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
6332 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
6333 v4_src_address_set = 1;
6334 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
6335 v6_src_address_set = 1;
6340 if (v4_address_set && v6_address_set)
6342 errmsg ("both v4 and v6 server addresses set\n");
6345 if (!v4_address_set && !v6_address_set)
6347 errmsg ("no server addresses set\n");
6351 if (v4_src_address_set && v6_src_address_set)
6353 errmsg ("both v4 and v6 src addresses set\n");
6356 if (!v4_src_address_set && !v6_src_address_set)
6358 errmsg ("no src addresses set\n");
6362 if (!(v4_src_address_set && v4_address_set) &&
6363 !(v6_src_address_set && v6_address_set))
6365 errmsg ("no matching server and src addresses set\n");
6369 /* Construct the API message */
6370 M (DHCP_PROXY_CONFIG, dhcp_proxy_config);
6372 mp->insert_circuit_id = insert_cid;
6373 mp->is_add = is_add;
6374 mp->vrf_id = ntohl (vrf_id);
6378 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
6379 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
6383 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
6384 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
6390 /* Wait for a reply, return good/bad news */
6397 api_dhcp_proxy_config_2 (vat_main_t * vam)
6399 unformat_input_t *i = vam->input;
6400 vl_api_dhcp_proxy_config_2_t *mp;
6403 u32 server_vrf_id = 0;
6406 u8 v4_address_set = 0;
6407 u8 v6_address_set = 0;
6408 ip4_address_t v4address;
6409 ip6_address_t v6address;
6410 u8 v4_src_address_set = 0;
6411 u8 v6_src_address_set = 0;
6412 ip4_address_t v4srcaddress;
6413 ip6_address_t v6srcaddress;
6415 /* Parse args required to build the message */
6416 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6418 if (unformat (i, "del"))
6420 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
6422 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
6424 else if (unformat (i, "insert-cid %d", &insert_cid))
6426 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
6428 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
6430 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
6431 v4_src_address_set = 1;
6432 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
6433 v6_src_address_set = 1;
6438 if (v4_address_set && v6_address_set)
6440 errmsg ("both v4 and v6 server addresses set\n");
6443 if (!v4_address_set && !v6_address_set)
6445 errmsg ("no server addresses set\n");
6449 if (v4_src_address_set && v6_src_address_set)
6451 errmsg ("both v4 and v6 src addresses set\n");
6454 if (!v4_src_address_set && !v6_src_address_set)
6456 errmsg ("no src addresses set\n");
6460 if (!(v4_src_address_set && v4_address_set) &&
6461 !(v6_src_address_set && v6_address_set))
6463 errmsg ("no matching server and src addresses set\n");
6467 /* Construct the API message */
6468 M (DHCP_PROXY_CONFIG_2, dhcp_proxy_config_2);
6470 mp->insert_circuit_id = insert_cid;
6471 mp->is_add = is_add;
6472 mp->rx_vrf_id = ntohl (rx_vrf_id);
6473 mp->server_vrf_id = ntohl (server_vrf_id);
6477 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
6478 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
6482 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
6483 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
6489 /* Wait for a reply, return good/bad news */
6496 api_dhcp_proxy_set_vss (vat_main_t * vam)
6498 unformat_input_t *i = vam->input;
6499 vl_api_dhcp_proxy_set_vss_t *mp;
6510 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6512 if (unformat (i, "tbl_id %d", &tbl_id))
6514 if (unformat (i, "fib_id %d", &fib_id))
6516 if (unformat (i, "oui %d", &oui))
6518 else if (unformat (i, "ipv6"))
6520 else if (unformat (i, "del"))
6524 clib_warning ("parse error '%U'", format_unformat_error, i);
6529 if (tbl_id_set == 0)
6531 errmsg ("missing tbl id\n");
6535 if (fib_id_set == 0)
6537 errmsg ("missing fib id\n");
6542 errmsg ("missing oui\n");
6546 M (DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss);
6547 mp->tbl_id = ntohl (tbl_id);
6548 mp->fib_id = ntohl (fib_id);
6549 mp->oui = ntohl (oui);
6550 mp->is_ipv6 = is_ipv6;
6551 mp->is_add = is_add;
6560 api_dhcp_client_config (vat_main_t * vam)
6562 unformat_input_t *i = vam->input;
6563 vl_api_dhcp_client_config_t *mp;
6566 u8 sw_if_index_set = 0;
6569 u8 disable_event = 0;
6571 /* Parse args required to build the message */
6572 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6574 if (unformat (i, "del"))
6576 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6577 sw_if_index_set = 1;
6578 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6579 sw_if_index_set = 1;
6580 else if (unformat (i, "hostname %s", &hostname))
6582 else if (unformat (i, "disable_event"))
6588 if (sw_if_index_set == 0)
6590 errmsg ("missing interface name or sw_if_index\n");
6594 if (vec_len (hostname) > 63)
6596 errmsg ("hostname too long\n");
6598 vec_add1 (hostname, 0);
6600 /* Construct the API message */
6601 M (DHCP_CLIENT_CONFIG, dhcp_client_config);
6603 mp->sw_if_index = ntohl (sw_if_index);
6604 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
6605 vec_free (hostname);
6606 mp->is_add = is_add;
6607 mp->want_dhcp_event = disable_event ? 0 : 1;
6608 mp->pid = getpid ();
6613 /* Wait for a reply, return good/bad news */
6620 api_set_ip_flow_hash (vat_main_t * vam)
6622 unformat_input_t *i = vam->input;
6623 vl_api_set_ip_flow_hash_t *mp;
6635 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6637 if (unformat (i, "vrf %d", &vrf_id))
6639 else if (unformat (i, "ipv6"))
6641 else if (unformat (i, "src"))
6643 else if (unformat (i, "dst"))
6645 else if (unformat (i, "sport"))
6647 else if (unformat (i, "dport"))
6649 else if (unformat (i, "proto"))
6651 else if (unformat (i, "reverse"))
6656 clib_warning ("parse error '%U'", format_unformat_error, i);
6661 if (vrf_id_set == 0)
6663 errmsg ("missing vrf id\n");
6667 M (SET_IP_FLOW_HASH, set_ip_flow_hash);
6673 mp->reverse = reverse;
6674 mp->vrf_id = ntohl (vrf_id);
6675 mp->is_ipv6 = is_ipv6;
6684 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
6686 unformat_input_t *i = vam->input;
6687 vl_api_sw_interface_ip6_enable_disable_t *mp;
6690 u8 sw_if_index_set = 0;
6693 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6695 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6696 sw_if_index_set = 1;
6697 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6698 sw_if_index_set = 1;
6699 else if (unformat (i, "enable"))
6701 else if (unformat (i, "disable"))
6705 clib_warning ("parse error '%U'", format_unformat_error, i);
6710 if (sw_if_index_set == 0)
6712 errmsg ("missing interface name or sw_if_index\n");
6716 M (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable);
6718 mp->sw_if_index = ntohl (sw_if_index);
6719 mp->enable = enable;
6728 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
6730 unformat_input_t *i = vam->input;
6731 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
6734 u8 sw_if_index_set = 0;
6735 u32 address_length = 0;
6736 u8 v6_address_set = 0;
6737 ip6_address_t v6address;
6739 /* Parse args required to build the message */
6740 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6742 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6743 sw_if_index_set = 1;
6744 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6745 sw_if_index_set = 1;
6746 else if (unformat (i, "%U/%d",
6747 unformat_ip6_address, &v6address, &address_length))
6753 if (sw_if_index_set == 0)
6755 errmsg ("missing interface name or sw_if_index\n");
6758 if (!v6_address_set)
6760 errmsg ("no address set\n");
6764 /* Construct the API message */
6765 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,
6766 sw_interface_ip6_set_link_local_address);
6768 mp->sw_if_index = ntohl (sw_if_index);
6769 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6770 mp->address_length = address_length;
6775 /* Wait for a reply, return good/bad news */
6784 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
6786 unformat_input_t *i = vam->input;
6787 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
6790 u8 sw_if_index_set = 0;
6791 u32 address_length = 0;
6792 u8 v6_address_set = 0;
6793 ip6_address_t v6address;
6795 u8 no_advertise = 0;
6797 u8 no_autoconfig = 0;
6800 u32 val_lifetime = 0;
6801 u32 pref_lifetime = 0;
6803 /* Parse args required to build the message */
6804 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6806 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6807 sw_if_index_set = 1;
6808 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6809 sw_if_index_set = 1;
6810 else if (unformat (i, "%U/%d",
6811 unformat_ip6_address, &v6address, &address_length))
6813 else if (unformat (i, "val_life %d", &val_lifetime))
6815 else if (unformat (i, "pref_life %d", &pref_lifetime))
6817 else if (unformat (i, "def"))
6819 else if (unformat (i, "noadv"))
6821 else if (unformat (i, "offl"))
6823 else if (unformat (i, "noauto"))
6825 else if (unformat (i, "nolink"))
6827 else if (unformat (i, "isno"))
6831 clib_warning ("parse error '%U'", format_unformat_error, i);
6836 if (sw_if_index_set == 0)
6838 errmsg ("missing interface name or sw_if_index\n");
6841 if (!v6_address_set)
6843 errmsg ("no address set\n");
6847 /* Construct the API message */
6848 M (SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix);
6850 mp->sw_if_index = ntohl (sw_if_index);
6851 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6852 mp->address_length = address_length;
6853 mp->use_default = use_default;
6854 mp->no_advertise = no_advertise;
6855 mp->off_link = off_link;
6856 mp->no_autoconfig = no_autoconfig;
6857 mp->no_onlink = no_onlink;
6859 mp->val_lifetime = ntohl (val_lifetime);
6860 mp->pref_lifetime = ntohl (pref_lifetime);
6865 /* Wait for a reply, return good/bad news */
6873 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
6875 unformat_input_t *i = vam->input;
6876 vl_api_sw_interface_ip6nd_ra_config_t *mp;
6879 u8 sw_if_index_set = 0;
6884 u8 send_unicast = 0;
6887 u8 default_router = 0;
6888 u32 max_interval = 0;
6889 u32 min_interval = 0;
6891 u32 initial_count = 0;
6892 u32 initial_interval = 0;
6895 /* Parse args required to build the message */
6896 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6898 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6899 sw_if_index_set = 1;
6900 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6901 sw_if_index_set = 1;
6902 else if (unformat (i, "maxint %d", &max_interval))
6904 else if (unformat (i, "minint %d", &min_interval))
6906 else if (unformat (i, "life %d", &lifetime))
6908 else if (unformat (i, "count %d", &initial_count))
6910 else if (unformat (i, "interval %d", &initial_interval))
6912 else if (unformat (i, "suppress") || unformat (i, "surpress"))
6914 else if (unformat (i, "managed"))
6916 else if (unformat (i, "other"))
6918 else if (unformat (i, "ll"))
6920 else if (unformat (i, "send"))
6922 else if (unformat (i, "cease"))
6924 else if (unformat (i, "isno"))
6926 else if (unformat (i, "def"))
6930 clib_warning ("parse error '%U'", format_unformat_error, i);
6935 if (sw_if_index_set == 0)
6937 errmsg ("missing interface name or sw_if_index\n");
6941 /* Construct the API message */
6942 M (SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config);
6944 mp->sw_if_index = ntohl (sw_if_index);
6945 mp->max_interval = ntohl (max_interval);
6946 mp->min_interval = ntohl (min_interval);
6947 mp->lifetime = ntohl (lifetime);
6948 mp->initial_count = ntohl (initial_count);
6949 mp->initial_interval = ntohl (initial_interval);
6950 mp->suppress = suppress;
6951 mp->managed = managed;
6953 mp->ll_option = ll_option;
6954 mp->send_unicast = send_unicast;
6957 mp->default_router = default_router;
6962 /* Wait for a reply, return good/bad news */
6970 api_set_arp_neighbor_limit (vat_main_t * vam)
6972 unformat_input_t *i = vam->input;
6973 vl_api_set_arp_neighbor_limit_t *mp;
6979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6981 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
6983 else if (unformat (i, "ipv6"))
6987 clib_warning ("parse error '%U'", format_unformat_error, i);
6994 errmsg ("missing limit value\n");
6998 M (SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit);
7000 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
7001 mp->is_ipv6 = is_ipv6;
7010 api_l2_patch_add_del (vat_main_t * vam)
7012 unformat_input_t *i = vam->input;
7013 vl_api_l2_patch_add_del_t *mp;
7016 u8 rx_sw_if_index_set = 0;
7018 u8 tx_sw_if_index_set = 0;
7021 /* Parse args required to build the message */
7022 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7024 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7025 rx_sw_if_index_set = 1;
7026 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7027 tx_sw_if_index_set = 1;
7028 else if (unformat (i, "rx"))
7030 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7032 if (unformat (i, "%U", unformat_sw_if_index, vam,
7034 rx_sw_if_index_set = 1;
7039 else if (unformat (i, "tx"))
7041 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7043 if (unformat (i, "%U", unformat_sw_if_index, vam,
7045 tx_sw_if_index_set = 1;
7050 else if (unformat (i, "del"))
7056 if (rx_sw_if_index_set == 0)
7058 errmsg ("missing rx interface name or rx_sw_if_index\n");
7062 if (tx_sw_if_index_set == 0)
7064 errmsg ("missing tx interface name or tx_sw_if_index\n");
7068 M (L2_PATCH_ADD_DEL, l2_patch_add_del);
7070 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7071 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7072 mp->is_add = is_add;
7081 api_trace_profile_add (vat_main_t * vam)
7083 unformat_input_t *input = vam->input;
7084 vl_api_trace_profile_add_t *mp;
7087 u32 trace_option_elts = 0;
7088 u32 trace_type = 0, node_id = 0, app_data = 0, trace_tsp = 2;
7089 int has_pow_option = 0;
7090 int has_ppc_option = 0;
7092 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7094 if (unformat (input, "id %d trace-type 0x%x trace-elts %d "
7095 "trace-tsp %d node-id 0x%x app-data 0x%x",
7096 &id, &trace_type, &trace_option_elts, &trace_tsp,
7097 &node_id, &app_data))
7099 else if (unformat (input, "pow"))
7101 else if (unformat (input, "ppc encap"))
7102 has_ppc_option = PPC_ENCAP;
7103 else if (unformat (input, "ppc decap"))
7104 has_ppc_option = PPC_DECAP;
7105 else if (unformat (input, "ppc none"))
7106 has_ppc_option = PPC_NONE;
7110 M (TRACE_PROFILE_ADD, trace_profile_add);
7111 mp->id = htons (id);
7112 mp->trace_type = trace_type;
7113 mp->trace_num_elt = trace_option_elts;
7114 mp->trace_ppc = has_ppc_option;
7115 mp->trace_app_data = htonl (app_data);
7116 mp->pow_enable = has_pow_option;
7117 mp->trace_tsp = trace_tsp;
7118 mp->node_id = htonl (node_id);
7128 api_trace_profile_apply (vat_main_t * vam)
7130 unformat_input_t *input = vam->input;
7131 vl_api_trace_profile_apply_t *mp;
7134 u32 mask_width = ~0;
7141 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7143 if (unformat (input, "%U/%d", unformat_ip6_address, &addr, &mask_width))
7145 else if (unformat (input, "id %d", &id))
7147 else if (unformat (input, "vrf-id %d", &vrf_id))
7149 else if (unformat (input, "add"))
7151 else if (unformat (input, "pop"))
7153 else if (unformat (input, "none"))
7159 if ((is_add + is_pop + is_none) != 1)
7161 errmsg ("One of (add, pop, none) required");
7164 if (mask_width == ~0)
7166 errmsg ("<address>/<mask-width> required");
7169 M (TRACE_PROFILE_APPLY, trace_profile_apply);
7170 clib_memcpy (mp->dest_ipv6, &addr, sizeof (mp->dest_ipv6));
7171 mp->id = htons (id);
7172 mp->prefix_length = htonl (mask_width);
7173 mp->vrf_id = htonl (vrf_id);
7175 mp->trace_op = IOAM_HBYH_ADD;
7177 mp->trace_op = IOAM_HBYH_POP;
7179 mp->trace_op = IOAM_HBYH_MOD;
7193 api_trace_profile_del (vat_main_t * vam)
7195 vl_api_trace_profile_del_t *mp;
7198 M (TRACE_PROFILE_DEL, trace_profile_del);
7205 api_sr_tunnel_add_del (vat_main_t * vam)
7207 unformat_input_t *i = vam->input;
7208 vl_api_sr_tunnel_add_del_t *mp;
7212 ip6_address_t src_address;
7213 int src_address_set = 0;
7214 ip6_address_t dst_address;
7216 int dst_address_set = 0;
7218 u32 rx_table_id = 0;
7219 u32 tx_table_id = 0;
7220 ip6_address_t *segments = 0;
7221 ip6_address_t *this_seg;
7222 ip6_address_t *tags = 0;
7223 ip6_address_t *this_tag;
7224 ip6_address_t next_address, tag;
7226 u8 *policy_name = 0;
7228 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7230 if (unformat (i, "del"))
7232 else if (unformat (i, "name %s", &name))
7234 else if (unformat (i, "policy %s", &policy_name))
7236 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
7238 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
7240 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
7241 src_address_set = 1;
7242 else if (unformat (i, "dst %U/%d",
7243 unformat_ip6_address, &dst_address, &dst_mask_width))
7244 dst_address_set = 1;
7245 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
7247 vec_add2 (segments, this_seg, 1);
7248 clib_memcpy (this_seg->as_u8, next_address.as_u8,
7249 sizeof (*this_seg));
7251 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
7253 vec_add2 (tags, this_tag, 1);
7254 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
7256 else if (unformat (i, "clean"))
7257 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
7258 else if (unformat (i, "protected"))
7259 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
7260 else if (unformat (i, "InPE %d", &pl_index))
7262 if (pl_index <= 0 || pl_index > 4)
7264 pl_index_range_error:
7265 errmsg ("pl index %d out of range\n", pl_index);
7269 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
7271 else if (unformat (i, "EgPE %d", &pl_index))
7273 if (pl_index <= 0 || pl_index > 4)
7274 goto pl_index_range_error;
7276 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
7278 else if (unformat (i, "OrgSrc %d", &pl_index))
7280 if (pl_index <= 0 || pl_index > 4)
7281 goto pl_index_range_error;
7283 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
7289 if (!src_address_set)
7291 errmsg ("src address required\n");
7295 if (!dst_address_set)
7297 errmsg ("dst address required\n");
7303 errmsg ("at least one sr segment required\n");
7307 M2 (SR_TUNNEL_ADD_DEL, sr_tunnel_add_del,
7308 vec_len (segments) * sizeof (ip6_address_t)
7309 + vec_len (tags) * sizeof (ip6_address_t));
7311 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
7312 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
7313 mp->dst_mask_width = dst_mask_width;
7314 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
7315 mp->n_segments = vec_len (segments);
7316 mp->n_tags = vec_len (tags);
7317 mp->is_add = is_del == 0;
7318 clib_memcpy (mp->segs_and_tags, segments,
7319 vec_len (segments) * sizeof (ip6_address_t));
7320 clib_memcpy (mp->segs_and_tags +
7321 vec_len (segments) * sizeof (ip6_address_t), tags,
7322 vec_len (tags) * sizeof (ip6_address_t));
7324 mp->outer_vrf_id = ntohl (rx_table_id);
7325 mp->inner_vrf_id = ntohl (tx_table_id);
7326 memcpy (mp->name, name, vec_len (name));
7327 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
7329 vec_free (segments);
7338 api_sr_policy_add_del (vat_main_t * vam)
7340 unformat_input_t *input = vam->input;
7341 vl_api_sr_policy_add_del_t *mp;
7345 u8 *tunnel_name = 0;
7346 u8 **tunnel_names = 0;
7351 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
7352 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
7354 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7356 if (unformat (input, "del"))
7358 else if (unformat (input, "name %s", &name))
7360 else if (unformat (input, "tunnel %s", &tunnel_name))
7364 vec_add1 (tunnel_names, tunnel_name);
7366 - length = #bytes to store in serial vector
7367 - +1 = byte to store that length
7369 tunnel_names_length += (vec_len (tunnel_name) + 1);
7380 errmsg ("policy name required\n");
7384 if ((!tunnel_set) && (!is_del))
7386 errmsg ("tunnel name required\n");
7390 M2 (SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length);
7394 mp->is_add = !is_del;
7396 memcpy (mp->name, name, vec_len (name));
7397 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
7398 u8 *serial_orig = 0;
7399 vec_validate (serial_orig, tunnel_names_length);
7400 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
7401 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
7403 for (j = 0; j < vec_len (tunnel_names); j++)
7405 tun_name_len = vec_len (tunnel_names[j]);
7406 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
7407 serial_orig += 1; // Move along one byte to store the actual tunnel name
7408 memcpy (serial_orig, tunnel_names[j], tun_name_len);
7409 serial_orig += tun_name_len; // Advance past the copy
7411 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
7413 vec_free (tunnel_names);
7414 vec_free (tunnel_name);
7422 api_sr_multicast_map_add_del (vat_main_t * vam)
7424 unformat_input_t *input = vam->input;
7425 vl_api_sr_multicast_map_add_del_t *mp;
7428 ip6_address_t multicast_address;
7429 u8 *policy_name = 0;
7430 int multicast_address_set = 0;
7432 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7434 if (unformat (input, "del"))
7438 (input, "address %U", unformat_ip6_address, &multicast_address))
7439 multicast_address_set = 1;
7440 else if (unformat (input, "sr-policy %s", &policy_name))
7446 if (!is_del && !policy_name)
7448 errmsg ("sr-policy name required\n");
7453 if (!multicast_address_set)
7455 errmsg ("address required\n");
7459 M (SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del);
7461 mp->is_add = !is_del;
7462 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
7463 clib_memcpy (mp->multicast_address, &multicast_address,
7464 sizeof (mp->multicast_address));
7467 vec_free (policy_name);
7475 #define foreach_ip4_proto_field \
7486 unformat_ip4_mask (unformat_input_t * input, va_list * args)
7488 u8 **maskp = va_arg (*args, u8 **);
7490 u8 found_something = 0;
7493 #define _(a) u8 a=0;
7494 foreach_ip4_proto_field;
7500 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7502 if (unformat (input, "version"))
7504 else if (unformat (input, "hdr_length"))
7506 else if (unformat (input, "src"))
7508 else if (unformat (input, "dst"))
7510 else if (unformat (input, "proto"))
7513 #define _(a) else if (unformat (input, #a)) a=1;
7514 foreach_ip4_proto_field
7520 #define _(a) found_something += a;
7521 foreach_ip4_proto_field;
7524 if (found_something == 0)
7527 vec_validate (mask, sizeof (*ip) - 1);
7529 ip = (ip4_header_t *) mask;
7531 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
7532 foreach_ip4_proto_field;
7535 ip->ip_version_and_header_length = 0;
7538 ip->ip_version_and_header_length |= 0xF0;
7541 ip->ip_version_and_header_length |= 0x0F;
7547 #define foreach_ip6_proto_field \
7555 unformat_ip6_mask (unformat_input_t * input, va_list * args)
7557 u8 **maskp = va_arg (*args, u8 **);
7559 u8 found_something = 0;
7561 u32 ip_version_traffic_class_and_flow_label;
7563 #define _(a) u8 a=0;
7564 foreach_ip6_proto_field;
7567 u8 traffic_class = 0;
7570 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7572 if (unformat (input, "version"))
7574 else if (unformat (input, "traffic-class"))
7576 else if (unformat (input, "flow-label"))
7578 else if (unformat (input, "src"))
7580 else if (unformat (input, "dst"))
7582 else if (unformat (input, "proto"))
7585 #define _(a) else if (unformat (input, #a)) a=1;
7586 foreach_ip6_proto_field
7592 #define _(a) found_something += a;
7593 foreach_ip6_proto_field;
7596 if (found_something == 0)
7599 vec_validate (mask, sizeof (*ip) - 1);
7601 ip = (ip6_header_t *) mask;
7603 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
7604 foreach_ip6_proto_field;
7607 ip_version_traffic_class_and_flow_label = 0;
7610 ip_version_traffic_class_and_flow_label |= 0xF0000000;
7613 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
7616 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
7618 ip->ip_version_traffic_class_and_flow_label =
7619 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
7626 unformat_l3_mask (unformat_input_t * input, va_list * args)
7628 u8 **maskp = va_arg (*args, u8 **);
7630 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7632 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
7634 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
7643 unformat_l2_mask (unformat_input_t * input, va_list * args)
7645 u8 **maskp = va_arg (*args, u8 **);
7660 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7662 if (unformat (input, "src"))
7664 else if (unformat (input, "dst"))
7666 else if (unformat (input, "proto"))
7668 else if (unformat (input, "tag1"))
7670 else if (unformat (input, "tag2"))
7672 else if (unformat (input, "ignore-tag1"))
7674 else if (unformat (input, "ignore-tag2"))
7676 else if (unformat (input, "cos1"))
7678 else if (unformat (input, "cos2"))
7680 else if (unformat (input, "dot1q"))
7682 else if (unformat (input, "dot1ad"))
7687 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
7688 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
7691 if (tag1 || ignore_tag1 || cos1 || dot1q)
7693 if (tag2 || ignore_tag2 || cos2 || dot1ad)
7696 vec_validate (mask, len - 1);
7699 memset (mask, 0xff, 6);
7702 memset (mask + 6, 0xff, 6);
7706 /* inner vlan tag */
7715 mask[21] = mask[20] = 0xff;
7736 mask[16] = mask[17] = 0xff;
7746 mask[12] = mask[13] = 0xff;
7753 unformat_classify_mask (unformat_input_t * input, va_list * args)
7755 u8 **maskp = va_arg (*args, u8 **);
7756 u32 *skipp = va_arg (*args, u32 *);
7757 u32 *matchp = va_arg (*args, u32 *);
7764 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7766 if (unformat (input, "hex %U", unformat_hex_string, &mask))
7768 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
7770 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
7776 if (mask || l2 || l3)
7780 /* "With a free Ethernet header in every package" */
7782 vec_validate (l2, 13);
7786 vec_append (mask, l3);
7791 /* Scan forward looking for the first significant mask octet */
7792 for (i = 0; i < vec_len (mask); i++)
7796 /* compute (skip, match) params */
7797 *skipp = i / sizeof (u32x4);
7798 vec_delete (mask, *skipp * sizeof (u32x4), 0);
7800 /* Pad mask to an even multiple of the vector size */
7801 while (vec_len (mask) % sizeof (u32x4))
7804 match = vec_len (mask) / sizeof (u32x4);
7806 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
7808 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
7809 if (*tmp || *(tmp + 1))
7814 clib_warning ("BUG: match 0");
7816 _vec_len (mask) = match * sizeof (u32x4);
7827 #define foreach_l2_next \
7829 _(ethernet, ETHERNET_INPUT) \
7834 unformat_l2_next_index (unformat_input_t * input, va_list * args)
7836 u32 *miss_next_indexp = va_arg (*args, u32 *);
7841 if (unformat (input, #n)) { next_index = L2_CLASSIFY_NEXT_##N; goto out;}
7845 if (unformat (input, "%d", &tmp))
7854 *miss_next_indexp = next_index;
7858 #define foreach_ip_next \
7865 unformat_ip_next_index (unformat_input_t * input, va_list * args)
7867 u32 *miss_next_indexp = va_arg (*args, u32 *);
7872 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
7876 if (unformat (input, "%d", &tmp))
7885 *miss_next_indexp = next_index;
7889 #define foreach_acl_next \
7893 unformat_acl_next_index (unformat_input_t * input, va_list * args)
7895 u32 *miss_next_indexp = va_arg (*args, u32 *);
7900 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
7904 if (unformat (input, "permit"))
7909 else if (unformat (input, "%d", &tmp))
7918 *miss_next_indexp = next_index;
7923 unformat_policer_precolor (unformat_input_t * input, va_list * args)
7925 u32 *r = va_arg (*args, u32 *);
7927 if (unformat (input, "conform-color"))
7928 *r = POLICE_CONFORM;
7929 else if (unformat (input, "exceed-color"))
7938 api_classify_add_del_table (vat_main_t * vam)
7940 unformat_input_t *i = vam->input;
7941 vl_api_classify_add_del_table_t *mp;
7947 u32 table_index = ~0;
7948 u32 next_table_index = ~0;
7949 u32 miss_next_index = ~0;
7950 u32 memory_size = 32 << 20;
7954 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7956 if (unformat (i, "del"))
7958 else if (unformat (i, "buckets %d", &nbuckets))
7960 else if (unformat (i, "memory_size %d", &memory_size))
7962 else if (unformat (i, "skip %d", &skip))
7964 else if (unformat (i, "match %d", &match))
7966 else if (unformat (i, "table %d", &table_index))
7968 else if (unformat (i, "mask %U", unformat_classify_mask,
7969 &mask, &skip, &match))
7971 else if (unformat (i, "next-table %d", &next_table_index))
7973 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
7976 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
7979 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
7986 if (is_add && mask == 0)
7988 errmsg ("Mask required\n");
7992 if (is_add && skip == ~0)
7994 errmsg ("skip count required\n");
7998 if (is_add && match == ~0)
8000 errmsg ("match count required\n");
8004 if (!is_add && table_index == ~0)
8006 errmsg ("table index required for delete\n");
8010 M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask));
8012 mp->is_add = is_add;
8013 mp->table_index = ntohl (table_index);
8014 mp->nbuckets = ntohl (nbuckets);
8015 mp->memory_size = ntohl (memory_size);
8016 mp->skip_n_vectors = ntohl (skip);
8017 mp->match_n_vectors = ntohl (match);
8018 mp->next_table_index = ntohl (next_table_index);
8019 mp->miss_next_index = ntohl (miss_next_index);
8020 clib_memcpy (mp->mask, mask, vec_len (mask));
8030 unformat_ip4_match (unformat_input_t * input, va_list * args)
8032 u8 **matchp = va_arg (*args, u8 **);
8039 int src = 0, dst = 0;
8040 ip4_address_t src_val, dst_val;
8047 int fragment_id = 0;
8048 u32 fragment_id_val;
8054 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8056 if (unformat (input, "version %d", &version_val))
8058 else if (unformat (input, "hdr_length %d", &hdr_length_val))
8060 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
8062 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
8064 else if (unformat (input, "proto %d", &proto_val))
8066 else if (unformat (input, "tos %d", &tos_val))
8068 else if (unformat (input, "length %d", &length_val))
8070 else if (unformat (input, "fragment_id %d", &fragment_id_val))
8072 else if (unformat (input, "ttl %d", &ttl_val))
8074 else if (unformat (input, "checksum %d", &checksum_val))
8080 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
8081 + ttl + checksum == 0)
8085 * Aligned because we use the real comparison functions
8087 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
8089 ip = (ip4_header_t *) match;
8091 /* These are realistically matched in practice */
8093 ip->src_address.as_u32 = src_val.as_u32;
8096 ip->dst_address.as_u32 = dst_val.as_u32;
8099 ip->protocol = proto_val;
8102 /* These are not, but they're included for completeness */
8104 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
8107 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
8113 ip->length = length_val;
8119 ip->checksum = checksum_val;
8126 unformat_ip6_match (unformat_input_t * input, va_list * args)
8128 u8 **matchp = va_arg (*args, u8 **);
8133 u8 traffic_class = 0;
8134 u32 traffic_class_val = 0;
8137 int src = 0, dst = 0;
8138 ip6_address_t src_val, dst_val;
8141 int payload_length = 0;
8142 u32 payload_length_val;
8145 u32 ip_version_traffic_class_and_flow_label;
8147 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8149 if (unformat (input, "version %d", &version_val))
8151 else if (unformat (input, "traffic_class %d", &traffic_class_val))
8153 else if (unformat (input, "flow_label %d", &flow_label_val))
8155 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
8157 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
8159 else if (unformat (input, "proto %d", &proto_val))
8161 else if (unformat (input, "payload_length %d", &payload_length_val))
8163 else if (unformat (input, "hop_limit %d", &hop_limit_val))
8169 if (version + traffic_class + flow_label + src + dst + proto +
8170 payload_length + hop_limit == 0)
8174 * Aligned because we use the real comparison functions
8176 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
8178 ip = (ip6_header_t *) match;
8181 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
8184 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
8187 ip->protocol = proto_val;
8189 ip_version_traffic_class_and_flow_label = 0;
8192 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
8195 ip_version_traffic_class_and_flow_label |=
8196 (traffic_class_val & 0xFF) << 20;
8199 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
8201 ip->ip_version_traffic_class_and_flow_label =
8202 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8205 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
8208 ip->hop_limit = hop_limit_val;
8215 unformat_l3_match (unformat_input_t * input, va_list * args)
8217 u8 **matchp = va_arg (*args, u8 **);
8219 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8221 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
8223 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
8232 unformat_vlan_tag (unformat_input_t * input, va_list * args)
8234 u8 *tagp = va_arg (*args, u8 *);
8237 if (unformat (input, "%d", &tag))
8239 tagp[0] = (tag >> 8) & 0x0F;
8240 tagp[1] = tag & 0xFF;
8248 unformat_l2_match (unformat_input_t * input, va_list * args)
8250 u8 **matchp = va_arg (*args, u8 **);
8270 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8272 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
8275 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
8277 else if (unformat (input, "proto %U",
8278 unformat_ethernet_type_host_byte_order, &proto_val))
8280 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
8282 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
8284 else if (unformat (input, "ignore-tag1"))
8286 else if (unformat (input, "ignore-tag2"))
8288 else if (unformat (input, "cos1 %d", &cos1_val))
8290 else if (unformat (input, "cos2 %d", &cos2_val))
8295 if ((src + dst + proto + tag1 + tag2 +
8296 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8299 if (tag1 || ignore_tag1 || cos1)
8301 if (tag2 || ignore_tag2 || cos2)
8304 vec_validate_aligned (match, len - 1, sizeof (u32x4));
8307 clib_memcpy (match, dst_val, 6);
8310 clib_memcpy (match + 6, src_val, 6);
8314 /* inner vlan tag */
8315 match[19] = tag2_val[1];
8316 match[18] = tag2_val[0];
8318 match[18] |= (cos2_val & 0x7) << 5;
8321 match[21] = proto_val & 0xff;
8322 match[20] = proto_val >> 8;
8326 match[15] = tag1_val[1];
8327 match[14] = tag1_val[0];
8330 match[14] |= (cos1_val & 0x7) << 5;
8336 match[15] = tag1_val[1];
8337 match[14] = tag1_val[0];
8340 match[17] = proto_val & 0xff;
8341 match[16] = proto_val >> 8;
8344 match[14] |= (cos1_val & 0x7) << 5;
8350 match[18] |= (cos2_val & 0x7) << 5;
8352 match[14] |= (cos1_val & 0x7) << 5;
8355 match[13] = proto_val & 0xff;
8356 match[12] = proto_val >> 8;
8365 unformat_classify_match (unformat_input_t * input, va_list * args)
8367 u8 **matchp = va_arg (*args, u8 **);
8368 u32 skip_n_vectors = va_arg (*args, u32);
8369 u32 match_n_vectors = va_arg (*args, u32);
8375 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8377 if (unformat (input, "hex %U", unformat_hex_string, &match))
8379 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
8381 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
8387 if (match || l2 || l3)
8391 /* "Win a free Ethernet header in every packet" */
8393 vec_validate_aligned (l2, 13, sizeof (u32x4));
8397 vec_append_aligned (match, l3, sizeof (u32x4));
8402 /* Make sure the vector is big enough even if key is all 0's */
8403 vec_validate_aligned
8404 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
8407 /* Set size, include skipped vectors */
8408 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
8419 api_classify_add_del_session (vat_main_t * vam)
8421 unformat_input_t *i = vam->input;
8422 vl_api_classify_add_del_session_t *mp;
8424 u32 table_index = ~0;
8425 u32 hit_next_index = ~0;
8426 u32 opaque_index = ~0;
8430 u32 skip_n_vectors = 0;
8431 u32 match_n_vectors = 0;
8434 * Warning: you have to supply skip_n and match_n
8435 * because the API client cant simply look at the classify
8439 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8441 if (unformat (i, "del"))
8443 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
8446 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
8449 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
8452 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
8454 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
8456 else if (unformat (i, "opaque-index %d", &opaque_index))
8458 else if (unformat (i, "skip_n %d", &skip_n_vectors))
8460 else if (unformat (i, "match_n %d", &match_n_vectors))
8462 else if (unformat (i, "match %U", unformat_classify_match,
8463 &match, skip_n_vectors, match_n_vectors))
8465 else if (unformat (i, "advance %d", &advance))
8467 else if (unformat (i, "table-index %d", &table_index))
8473 if (table_index == ~0)
8475 errmsg ("Table index required\n");
8479 if (is_add && match == 0)
8481 errmsg ("Match value required\n");
8485 M2 (CLASSIFY_ADD_DEL_SESSION, classify_add_del_session, vec_len (match));
8487 mp->is_add = is_add;
8488 mp->table_index = ntohl (table_index);
8489 mp->hit_next_index = ntohl (hit_next_index);
8490 mp->opaque_index = ntohl (opaque_index);
8491 mp->advance = ntohl (advance);
8492 clib_memcpy (mp->match, match, vec_len (match));
8501 api_classify_set_interface_ip_table (vat_main_t * vam)
8503 unformat_input_t *i = vam->input;
8504 vl_api_classify_set_interface_ip_table_t *mp;
8507 int sw_if_index_set;
8508 u32 table_index = ~0;
8511 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8513 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8514 sw_if_index_set = 1;
8515 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8516 sw_if_index_set = 1;
8517 else if (unformat (i, "table %d", &table_index))
8521 clib_warning ("parse error '%U'", format_unformat_error, i);
8526 if (sw_if_index_set == 0)
8528 errmsg ("missing interface name or sw_if_index\n");
8533 M (CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table);
8535 mp->sw_if_index = ntohl (sw_if_index);
8536 mp->table_index = ntohl (table_index);
8537 mp->is_ipv6 = is_ipv6;
8546 api_classify_set_interface_l2_tables (vat_main_t * vam)
8548 unformat_input_t *i = vam->input;
8549 vl_api_classify_set_interface_l2_tables_t *mp;
8552 int sw_if_index_set;
8553 u32 ip4_table_index = ~0;
8554 u32 ip6_table_index = ~0;
8555 u32 other_table_index = ~0;
8557 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8559 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8560 sw_if_index_set = 1;
8561 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8562 sw_if_index_set = 1;
8563 else if (unformat (i, "ip4-table %d", &ip4_table_index))
8565 else if (unformat (i, "ip6-table %d", &ip6_table_index))
8567 else if (unformat (i, "other-table %d", &other_table_index))
8571 clib_warning ("parse error '%U'", format_unformat_error, i);
8576 if (sw_if_index_set == 0)
8578 errmsg ("missing interface name or sw_if_index\n");
8583 M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables);
8585 mp->sw_if_index = ntohl (sw_if_index);
8586 mp->ip4_table_index = ntohl (ip4_table_index);
8587 mp->ip6_table_index = ntohl (ip6_table_index);
8588 mp->other_table_index = ntohl (other_table_index);
8598 api_ipfix_enable (vat_main_t * vam)
8600 unformat_input_t *i = vam->input;
8601 vl_api_ipfix_enable_t *mp;
8602 ip4_address_t collector_address;
8603 u8 collector_address_set = 0;
8604 u32 collector_port = ~0;
8605 ip4_address_t src_address;
8606 u8 src_address_set = 0;
8609 u32 template_interval = ~0;
8612 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8614 if (unformat (i, "collector_address %U", unformat_ip4_address,
8615 &collector_address))
8616 collector_address_set = 1;
8617 else if (unformat (i, "collector_port %d", &collector_port))
8619 else if (unformat (i, "src_address %U", unformat_ip4_address,
8621 src_address_set = 1;
8622 else if (unformat (i, "vrf_id %d", &vrf_id))
8624 else if (unformat (i, "path_mtu %d", &path_mtu))
8626 else if (unformat (i, "template_interval %d", &template_interval))
8632 if (collector_address_set == 0)
8634 errmsg ("collector_address required\n");
8638 if (src_address_set == 0)
8640 errmsg ("src_address required\n");
8644 M (IPFIX_ENABLE, ipfix_enable);
8646 memcpy (mp->collector_address, collector_address.data,
8647 sizeof (collector_address.data));
8648 mp->collector_port = htons ((u16) collector_port);
8649 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
8650 mp->vrf_id = htonl (vrf_id);
8651 mp->path_mtu = htonl (path_mtu);
8652 mp->template_interval = htonl (template_interval);
8660 api_get_node_index (vat_main_t * vam)
8662 unformat_input_t *i = vam->input;
8663 vl_api_get_node_index_t *mp;
8667 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8669 if (unformat (i, "node %s", &name))
8676 errmsg ("node name required\n");
8679 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
8681 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
8685 M (GET_NODE_INDEX, get_node_index);
8686 clib_memcpy (mp->node_name, name, vec_len (name));
8696 api_get_next_index (vat_main_t * vam)
8698 unformat_input_t *i = vam->input;
8699 vl_api_get_next_index_t *mp;
8701 u8 *node_name = 0, *next_node_name = 0;
8703 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8705 if (unformat (i, "node-name %s", &node_name))
8707 else if (unformat (i, "next-node-name %s", &next_node_name))
8713 errmsg ("node name required\n");
8716 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
8718 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
8722 if (next_node_name == 0)
8724 errmsg ("next node name required\n");
8727 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
8729 errmsg ("next node name too long, max %d\n", ARRAY_LEN (mp->next_name));
8733 M (GET_NEXT_INDEX, get_next_index);
8734 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
8735 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
8736 vec_free (node_name);
8737 vec_free (next_node_name);
8746 api_add_node_next (vat_main_t * vam)
8748 unformat_input_t *i = vam->input;
8749 vl_api_add_node_next_t *mp;
8754 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8756 if (unformat (i, "node %s", &name))
8758 else if (unformat (i, "next %s", &next))
8765 errmsg ("node name required\n");
8768 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
8770 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
8775 errmsg ("next node required\n");
8778 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
8780 errmsg ("next name too long, max %d\n", ARRAY_LEN (mp->next_name));
8784 M (ADD_NODE_NEXT, add_node_next);
8785 clib_memcpy (mp->node_name, name, vec_len (name));
8786 clib_memcpy (mp->next_name, next, vec_len (next));
8797 api_l2tpv3_create_tunnel (vat_main_t * vam)
8799 unformat_input_t *i = vam->input;
8800 ip6_address_t client_address, our_address;
8801 int client_address_set = 0;
8802 int our_address_set = 0;
8803 u32 local_session_id = 0;
8804 u32 remote_session_id = 0;
8805 u64 local_cookie = 0;
8806 u64 remote_cookie = 0;
8807 u8 l2_sublayer_present = 0;
8808 vl_api_l2tpv3_create_tunnel_t *mp;
8811 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8813 if (unformat (i, "client_address %U", unformat_ip6_address,
8815 client_address_set = 1;
8816 else if (unformat (i, "our_address %U", unformat_ip6_address,
8818 our_address_set = 1;
8819 else if (unformat (i, "local_session_id %d", &local_session_id))
8821 else if (unformat (i, "remote_session_id %d", &remote_session_id))
8823 else if (unformat (i, "local_cookie %lld", &local_cookie))
8825 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
8827 else if (unformat (i, "l2-sublayer-present"))
8828 l2_sublayer_present = 1;
8833 if (client_address_set == 0)
8835 errmsg ("client_address required\n");
8839 if (our_address_set == 0)
8841 errmsg ("our_address required\n");
8845 M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel);
8847 clib_memcpy (mp->client_address, client_address.as_u8,
8848 sizeof (mp->client_address));
8850 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
8852 mp->local_session_id = ntohl (local_session_id);
8853 mp->remote_session_id = ntohl (remote_session_id);
8854 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
8855 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
8856 mp->l2_sublayer_present = l2_sublayer_present;
8866 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
8868 unformat_input_t *i = vam->input;
8870 u8 sw_if_index_set = 0;
8871 u64 new_local_cookie = 0;
8872 u64 new_remote_cookie = 0;
8873 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
8876 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8878 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8879 sw_if_index_set = 1;
8880 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8881 sw_if_index_set = 1;
8882 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
8884 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
8890 if (sw_if_index_set == 0)
8892 errmsg ("missing interface name or sw_if_index\n");
8896 M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies);
8898 mp->sw_if_index = ntohl (sw_if_index);
8899 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
8900 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
8909 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
8911 unformat_input_t *i = vam->input;
8912 vl_api_l2tpv3_interface_enable_disable_t *mp;
8915 u8 sw_if_index_set = 0;
8916 u8 enable_disable = 1;
8918 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8920 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8921 sw_if_index_set = 1;
8922 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8923 sw_if_index_set = 1;
8924 else if (unformat (i, "enable"))
8926 else if (unformat (i, "disable"))
8932 if (sw_if_index_set == 0)
8934 errmsg ("missing interface name or sw_if_index\n");
8938 M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable);
8940 mp->sw_if_index = ntohl (sw_if_index);
8941 mp->enable_disable = enable_disable;
8950 api_l2tpv3_set_lookup_key (vat_main_t * vam)
8952 unformat_input_t *i = vam->input;
8953 vl_api_l2tpv3_set_lookup_key_t *mp;
8957 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8959 if (unformat (i, "lookup_v6_src"))
8960 key = L2T_LOOKUP_SRC_ADDRESS;
8961 else if (unformat (i, "lookup_v6_dst"))
8962 key = L2T_LOOKUP_DST_ADDRESS;
8963 else if (unformat (i, "lookup_session_id"))
8964 key = L2T_LOOKUP_SESSION_ID;
8969 if (key == (u8) ~ 0)
8971 errmsg ("l2tp session lookup key unset\n");
8975 M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key);
8985 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
8986 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
8988 vat_main_t *vam = &vat_main;
8990 fformat (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)\n",
8991 format_ip6_address, mp->our_address,
8992 format_ip6_address, mp->client_address,
8993 clib_net_to_host_u32 (mp->sw_if_index));
8996 " local cookies %016llx %016llx remote cookie %016llx\n",
8997 clib_net_to_host_u64 (mp->local_cookie[0]),
8998 clib_net_to_host_u64 (mp->local_cookie[1]),
8999 clib_net_to_host_u64 (mp->remote_cookie));
9001 fformat (vam->ofp, " local session-id %d remote session-id %d\n",
9002 clib_net_to_host_u32 (mp->local_session_id),
9003 clib_net_to_host_u32 (mp->remote_session_id));
9005 fformat (vam->ofp, " l2 specific sublayer %s\n\n",
9006 mp->l2_sublayer_present ? "preset" : "absent");
9010 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
9011 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
9013 vat_main_t *vam = &vat_main;
9014 vat_json_node_t *node = NULL;
9015 struct in6_addr addr;
9017 if (VAT_JSON_ARRAY != vam->json_tree.type)
9019 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9020 vat_json_init_array (&vam->json_tree);
9022 node = vat_json_array_add (&vam->json_tree);
9024 vat_json_init_object (node);
9026 clib_memcpy (&addr, mp->our_address, sizeof (addr));
9027 vat_json_object_add_ip6 (node, "our_address", addr);
9028 clib_memcpy (&addr, mp->client_address, sizeof (addr));
9029 vat_json_object_add_ip6 (node, "client_address", addr);
9031 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
9032 vat_json_init_array (lc);
9033 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
9034 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
9035 vat_json_object_add_uint (node, "remote_cookie",
9036 clib_net_to_host_u64 (mp->remote_cookie));
9038 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
9039 vat_json_object_add_uint (node, "local_session_id",
9040 clib_net_to_host_u32 (mp->local_session_id));
9041 vat_json_object_add_uint (node, "remote_session_id",
9042 clib_net_to_host_u32 (mp->remote_session_id));
9043 vat_json_object_add_string_copy (node, "l2_sublayer",
9044 mp->l2_sublayer_present ? (u8 *) "present"
9049 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
9051 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
9054 /* Get list of l2tpv3-tunnel interfaces */
9055 M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump);
9058 /* Use a control ping for synchronization */
9060 vl_api_control_ping_t *mp;
9061 M (CONTROL_PING, control_ping);
9068 static void vl_api_sw_interface_tap_details_t_handler
9069 (vl_api_sw_interface_tap_details_t * mp)
9071 vat_main_t *vam = &vat_main;
9073 fformat (vam->ofp, "%-16s %d\n",
9074 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
9077 static void vl_api_sw_interface_tap_details_t_handler_json
9078 (vl_api_sw_interface_tap_details_t * mp)
9080 vat_main_t *vam = &vat_main;
9081 vat_json_node_t *node = NULL;
9083 if (VAT_JSON_ARRAY != vam->json_tree.type)
9085 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9086 vat_json_init_array (&vam->json_tree);
9088 node = vat_json_array_add (&vam->json_tree);
9090 vat_json_init_object (node);
9091 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9092 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
9096 api_sw_interface_tap_dump (vat_main_t * vam)
9098 vl_api_sw_interface_tap_dump_t *mp;
9101 fformat (vam->ofp, "\n%-16s %s\n", "dev_name", "sw_if_index");
9102 /* Get list of tap interfaces */
9103 M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump);
9106 /* Use a control ping for synchronization */
9108 vl_api_control_ping_t *mp;
9109 M (CONTROL_PING, control_ping);
9115 static uword unformat_vxlan_decap_next
9116 (unformat_input_t * input, va_list * args)
9118 u32 *result = va_arg (*args, u32 *);
9121 if (unformat (input, "drop"))
9122 *result = VXLAN_INPUT_NEXT_DROP;
9123 else if (unformat (input, "ip4"))
9124 *result = VXLAN_INPUT_NEXT_IP4_INPUT;
9125 else if (unformat (input, "ip6"))
9126 *result = VXLAN_INPUT_NEXT_IP6_INPUT;
9127 else if (unformat (input, "l2"))
9128 *result = VXLAN_INPUT_NEXT_L2_INPUT;
9129 else if (unformat (input, "%d", &tmp))
9137 api_vxlan_add_del_tunnel (vat_main_t * vam)
9139 unformat_input_t *line_input = vam->input;
9140 vl_api_vxlan_add_del_tunnel_t *mp;
9142 ip4_address_t src4, dst4;
9143 ip6_address_t src6, dst6;
9145 u8 ipv4_set = 0, ipv6_set = 0;
9148 u32 encap_vrf_id = 0;
9149 u32 decap_next_index = ~0;
9152 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9154 if (unformat (line_input, "del"))
9156 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
9161 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
9166 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
9171 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
9176 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
9178 else if (unformat (line_input, "decap-next %U",
9179 unformat_vxlan_decap_next, &decap_next_index))
9181 else if (unformat (line_input, "vni %d", &vni))
9185 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
9192 errmsg ("tunnel src address not specified\n");
9197 errmsg ("tunnel dst address not specified\n");
9201 if (ipv4_set && ipv6_set)
9203 errmsg ("both IPv4 and IPv6 addresses specified");
9207 if ((vni == 0) || (vni >> 24))
9209 errmsg ("vni not specified or out of range\n");
9213 M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel);
9217 clib_memcpy (&mp->src_address, &src6, sizeof (src6));
9218 clib_memcpy (&mp->dst_address, &dst6, sizeof (dst6));
9222 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
9223 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
9225 mp->encap_vrf_id = ntohl (encap_vrf_id);
9226 mp->decap_next_index = ntohl (decap_next_index);
9227 mp->vni = ntohl (vni);
9228 mp->is_add = is_add;
9229 mp->is_ipv6 = ipv6_set;
9237 static void vl_api_vxlan_tunnel_details_t_handler
9238 (vl_api_vxlan_tunnel_details_t * mp)
9240 vat_main_t *vam = &vat_main;
9242 fformat (vam->ofp, "%11d%24U%24U%14d%18d%13d\n",
9243 ntohl (mp->sw_if_index),
9244 format_ip46_address, &(mp->src_address[0]),
9246 format_ip46_address, &(mp->dst_address[0]),
9248 ntohl (mp->encap_vrf_id),
9249 ntohl (mp->decap_next_index), ntohl (mp->vni));
9252 static void vl_api_vxlan_tunnel_details_t_handler_json
9253 (vl_api_vxlan_tunnel_details_t * mp)
9255 vat_main_t *vam = &vat_main;
9256 vat_json_node_t *node = NULL;
9258 struct in6_addr ip6;
9260 if (VAT_JSON_ARRAY != vam->json_tree.type)
9262 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9263 vat_json_init_array (&vam->json_tree);
9265 node = vat_json_array_add (&vam->json_tree);
9267 vat_json_init_object (node);
9268 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9271 clib_memcpy (&ip6, &(mp->src_address[0]), sizeof (ip6));
9272 vat_json_object_add_ip6 (node, "src_address", ip6);
9273 clib_memcpy (&ip6, &(mp->dst_address[0]), sizeof (ip6));
9274 vat_json_object_add_ip6 (node, "dst_address", ip6);
9278 clib_memcpy (&ip4, &(mp->src_address[0]), sizeof (ip4));
9279 vat_json_object_add_ip4 (node, "src_address", ip4);
9280 clib_memcpy (&ip4, &(mp->dst_address[0]), sizeof (ip4));
9281 vat_json_object_add_ip4 (node, "dst_address", ip4);
9283 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
9284 vat_json_object_add_uint (node, "decap_next_index",
9285 ntohl (mp->decap_next_index));
9286 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
9287 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
9291 api_vxlan_tunnel_dump (vat_main_t * vam)
9293 unformat_input_t *i = vam->input;
9294 vl_api_vxlan_tunnel_dump_t *mp;
9297 u8 sw_if_index_set = 0;
9299 /* Parse args required to build the message */
9300 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9302 if (unformat (i, "sw_if_index %d", &sw_if_index))
9303 sw_if_index_set = 1;
9308 if (sw_if_index_set == 0)
9313 if (!vam->json_output)
9315 fformat (vam->ofp, "%11s%24s%24s%14s%18s%13s\n",
9316 "sw_if_index", "src_address", "dst_address",
9317 "encap_vrf_id", "decap_next_index", "vni");
9320 /* Get list of vxlan-tunnel interfaces */
9321 M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
9323 mp->sw_if_index = htonl (sw_if_index);
9327 /* Use a control ping for synchronization */
9329 vl_api_control_ping_t *mp;
9330 M (CONTROL_PING, control_ping);
9337 api_gre_add_del_tunnel (vat_main_t * vam)
9339 unformat_input_t *line_input = vam->input;
9340 vl_api_gre_add_del_tunnel_t *mp;
9342 ip4_address_t src4, dst4;
9346 u32 outer_fib_id = 0;
9348 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9350 if (unformat (line_input, "del"))
9352 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
9354 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
9356 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
9360 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
9367 errmsg ("tunnel src address not specified\n");
9372 errmsg ("tunnel dst address not specified\n");
9377 M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel);
9379 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
9380 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
9381 mp->outer_fib_id = ntohl (outer_fib_id);
9382 mp->is_add = is_add;
9390 static void vl_api_gre_tunnel_details_t_handler
9391 (vl_api_gre_tunnel_details_t * mp)
9393 vat_main_t *vam = &vat_main;
9395 fformat (vam->ofp, "%11d%15U%15U%14d\n",
9396 ntohl (mp->sw_if_index),
9397 format_ip4_address, &mp->src_address,
9398 format_ip4_address, &mp->dst_address, ntohl (mp->outer_fib_id));
9401 static void vl_api_gre_tunnel_details_t_handler_json
9402 (vl_api_gre_tunnel_details_t * mp)
9404 vat_main_t *vam = &vat_main;
9405 vat_json_node_t *node = NULL;
9408 if (VAT_JSON_ARRAY != vam->json_tree.type)
9410 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9411 vat_json_init_array (&vam->json_tree);
9413 node = vat_json_array_add (&vam->json_tree);
9415 vat_json_init_object (node);
9416 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9417 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
9418 vat_json_object_add_ip4 (node, "src_address", ip4);
9419 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
9420 vat_json_object_add_ip4 (node, "dst_address", ip4);
9421 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
9425 api_gre_tunnel_dump (vat_main_t * vam)
9427 unformat_input_t *i = vam->input;
9428 vl_api_gre_tunnel_dump_t *mp;
9431 u8 sw_if_index_set = 0;
9433 /* Parse args required to build the message */
9434 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9436 if (unformat (i, "sw_if_index %d", &sw_if_index))
9437 sw_if_index_set = 1;
9442 if (sw_if_index_set == 0)
9447 if (!vam->json_output)
9449 fformat (vam->ofp, "%11s%15s%15s%14s\n",
9450 "sw_if_index", "src_address", "dst_address", "outer_fib_id");
9453 /* Get list of gre-tunnel interfaces */
9454 M (GRE_TUNNEL_DUMP, gre_tunnel_dump);
9456 mp->sw_if_index = htonl (sw_if_index);
9460 /* Use a control ping for synchronization */
9462 vl_api_control_ping_t *mp;
9463 M (CONTROL_PING, control_ping);
9470 api_l2_fib_clear_table (vat_main_t * vam)
9472 // unformat_input_t * i = vam->input;
9473 vl_api_l2_fib_clear_table_t *mp;
9476 M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table);
9485 api_l2_interface_efp_filter (vat_main_t * vam)
9487 unformat_input_t *i = vam->input;
9488 vl_api_l2_interface_efp_filter_t *mp;
9492 u8 sw_if_index_set = 0;
9494 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9496 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9497 sw_if_index_set = 1;
9498 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9499 sw_if_index_set = 1;
9500 else if (unformat (i, "enable"))
9502 else if (unformat (i, "disable"))
9506 clib_warning ("parse error '%U'", format_unformat_error, i);
9511 if (sw_if_index_set == 0)
9513 errmsg ("missing sw_if_index\n");
9517 M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter);
9519 mp->sw_if_index = ntohl (sw_if_index);
9520 mp->enable_disable = enable;
9528 #define foreach_vtr_op \
9529 _("disable", L2_VTR_DISABLED) \
9530 _("push-1", L2_VTR_PUSH_1) \
9531 _("push-2", L2_VTR_PUSH_2) \
9532 _("pop-1", L2_VTR_POP_1) \
9533 _("pop-2", L2_VTR_POP_2) \
9534 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
9535 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
9536 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
9537 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
9540 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
9542 unformat_input_t *i = vam->input;
9543 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
9546 u8 sw_if_index_set = 0;
9553 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9555 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9556 sw_if_index_set = 1;
9557 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9558 sw_if_index_set = 1;
9559 else if (unformat (i, "vtr_op %d", &vtr_op))
9561 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
9564 else if (unformat (i, "push_dot1q %d", &push_dot1q))
9566 else if (unformat (i, "tag1 %d", &tag1))
9568 else if (unformat (i, "tag2 %d", &tag2))
9572 clib_warning ("parse error '%U'", format_unformat_error, i);
9577 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
9579 errmsg ("missing vtr operation or sw_if_index\n");
9583 M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)
9584 mp->sw_if_index = ntohl (sw_if_index);
9585 mp->vtr_op = ntohl (vtr_op);
9586 mp->push_dot1q = ntohl (push_dot1q);
9587 mp->tag1 = ntohl (tag1);
9588 mp->tag2 = ntohl (tag2);
9597 api_create_vhost_user_if (vat_main_t * vam)
9599 unformat_input_t *i = vam->input;
9600 vl_api_create_vhost_user_if_t *mp;
9604 u8 file_name_set = 0;
9605 u32 custom_dev_instance = ~0;
9607 u8 use_custom_mac = 0;
9609 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9611 if (unformat (i, "socket %s", &file_name))
9615 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
9617 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
9619 else if (unformat (i, "server"))
9625 if (file_name_set == 0)
9627 errmsg ("missing socket file name\n");
9631 if (vec_len (file_name) > 255)
9633 errmsg ("socket file name too long\n");
9636 vec_add1 (file_name, 0);
9638 M (CREATE_VHOST_USER_IF, create_vhost_user_if);
9640 mp->is_server = is_server;
9641 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
9642 vec_free (file_name);
9643 if (custom_dev_instance != ~0)
9646 mp->custom_dev_instance = ntohl (custom_dev_instance);
9648 mp->use_custom_mac = use_custom_mac;
9649 clib_memcpy (mp->mac_address, hwaddr, 6);
9658 api_modify_vhost_user_if (vat_main_t * vam)
9660 unformat_input_t *i = vam->input;
9661 vl_api_modify_vhost_user_if_t *mp;
9665 u8 file_name_set = 0;
9666 u32 custom_dev_instance = ~0;
9667 u8 sw_if_index_set = 0;
9668 u32 sw_if_index = (u32) ~ 0;
9670 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9672 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9673 sw_if_index_set = 1;
9674 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9675 sw_if_index_set = 1;
9676 else if (unformat (i, "socket %s", &file_name))
9680 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
9682 else if (unformat (i, "server"))
9688 if (sw_if_index_set == 0)
9690 errmsg ("missing sw_if_index or interface name\n");
9694 if (file_name_set == 0)
9696 errmsg ("missing socket file name\n");
9700 if (vec_len (file_name) > 255)
9702 errmsg ("socket file name too long\n");
9705 vec_add1 (file_name, 0);
9707 M (MODIFY_VHOST_USER_IF, modify_vhost_user_if);
9709 mp->sw_if_index = ntohl (sw_if_index);
9710 mp->is_server = is_server;
9711 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
9712 vec_free (file_name);
9713 if (custom_dev_instance != ~0)
9716 mp->custom_dev_instance = ntohl (custom_dev_instance);
9726 api_delete_vhost_user_if (vat_main_t * vam)
9728 unformat_input_t *i = vam->input;
9729 vl_api_delete_vhost_user_if_t *mp;
9731 u32 sw_if_index = ~0;
9732 u8 sw_if_index_set = 0;
9734 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9736 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9737 sw_if_index_set = 1;
9738 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9739 sw_if_index_set = 1;
9744 if (sw_if_index_set == 0)
9746 errmsg ("missing sw_if_index or interface name\n");
9751 M (DELETE_VHOST_USER_IF, delete_vhost_user_if);
9753 mp->sw_if_index = ntohl (sw_if_index);
9761 static void vl_api_sw_interface_vhost_user_details_t_handler
9762 (vl_api_sw_interface_vhost_user_details_t * mp)
9764 vat_main_t *vam = &vat_main;
9766 fformat (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s\n",
9767 (char *) mp->interface_name,
9768 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
9769 clib_net_to_host_u64 (mp->features), mp->is_server,
9770 ntohl (mp->num_regions), (char *) mp->sock_filename);
9771 fformat (vam->ofp, " Status: '%s'\n", strerror (ntohl (mp->sock_errno)));
9774 static void vl_api_sw_interface_vhost_user_details_t_handler_json
9775 (vl_api_sw_interface_vhost_user_details_t * mp)
9777 vat_main_t *vam = &vat_main;
9778 vat_json_node_t *node = NULL;
9780 if (VAT_JSON_ARRAY != vam->json_tree.type)
9782 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9783 vat_json_init_array (&vam->json_tree);
9785 node = vat_json_array_add (&vam->json_tree);
9787 vat_json_init_object (node);
9788 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9789 vat_json_object_add_string_copy (node, "interface_name",
9790 mp->interface_name);
9791 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
9792 ntohl (mp->virtio_net_hdr_sz));
9793 vat_json_object_add_uint (node, "features",
9794 clib_net_to_host_u64 (mp->features));
9795 vat_json_object_add_uint (node, "is_server", mp->is_server);
9796 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
9797 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
9798 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
9802 api_sw_interface_vhost_user_dump (vat_main_t * vam)
9804 vl_api_sw_interface_vhost_user_dump_t *mp;
9807 "Interface name idx hdr_sz features server regions filename\n");
9809 /* Get list of vhost-user interfaces */
9810 M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump);
9813 /* Use a control ping for synchronization */
9815 vl_api_control_ping_t *mp;
9816 M (CONTROL_PING, control_ping);
9823 api_show_version (vat_main_t * vam)
9825 vl_api_show_version_t *mp;
9828 M (SHOW_VERSION, show_version);
9838 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
9840 unformat_input_t *line_input = vam->input;
9841 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
9843 ip4_address_t local4, remote4;
9844 ip6_address_t local6, remote6;
9846 u8 ipv4_set = 0, ipv6_set = 0;
9849 u32 encap_vrf_id = 0;
9850 u32 decap_vrf_id = 0;
9855 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9857 if (unformat (line_input, "del"))
9859 else if (unformat (line_input, "local %U",
9860 unformat_ip4_address, &local4))
9865 else if (unformat (line_input, "remote %U",
9866 unformat_ip4_address, &remote4))
9871 else if (unformat (line_input, "local %U",
9872 unformat_ip6_address, &local6))
9877 else if (unformat (line_input, "remote %U",
9878 unformat_ip6_address, &remote6))
9883 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
9885 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
9887 else if (unformat (line_input, "vni %d", &vni))
9889 else if (unformat (line_input, "next-ip4"))
9891 else if (unformat (line_input, "next-ip6"))
9893 else if (unformat (line_input, "next-ethernet"))
9895 else if (unformat (line_input, "next-nsh"))
9899 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
9906 errmsg ("tunnel local address not specified\n");
9909 if (remote_set == 0)
9911 errmsg ("tunnel remote address not specified\n");
9914 if (ipv4_set && ipv6_set)
9916 errmsg ("both IPv4 and IPv6 addresses specified");
9922 errmsg ("vni not specified\n");
9926 M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel);
9931 clib_memcpy (&mp->local, &local6, sizeof (local6));
9932 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
9936 clib_memcpy (&mp->local, &local4, sizeof (local4));
9937 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
9940 mp->encap_vrf_id = ntohl (encap_vrf_id);
9941 mp->decap_vrf_id = ntohl (decap_vrf_id);
9942 mp->protocol = ntohl (protocol);
9943 mp->vni = ntohl (vni);
9944 mp->is_add = is_add;
9945 mp->is_ipv6 = ipv6_set;
9953 static void vl_api_vxlan_gpe_tunnel_details_t_handler
9954 (vl_api_vxlan_gpe_tunnel_details_t * mp)
9956 vat_main_t *vam = &vat_main;
9958 fformat (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d\n",
9959 ntohl (mp->sw_if_index),
9960 format_ip46_address, &(mp->local[0]),
9961 format_ip46_address, &(mp->remote[0]),
9963 ntohl (mp->protocol),
9964 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
9967 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
9968 (vl_api_vxlan_gpe_tunnel_details_t * mp)
9970 vat_main_t *vam = &vat_main;
9971 vat_json_node_t *node = NULL;
9973 struct in6_addr ip6;
9975 if (VAT_JSON_ARRAY != vam->json_tree.type)
9977 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9978 vat_json_init_array (&vam->json_tree);
9980 node = vat_json_array_add (&vam->json_tree);
9982 vat_json_init_object (node);
9983 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9986 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
9987 vat_json_object_add_ip6 (node, "local", ip6);
9988 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
9989 vat_json_object_add_ip6 (node, "remote", ip6);
9993 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
9994 vat_json_object_add_ip4 (node, "local", ip4);
9995 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
9996 vat_json_object_add_ip4 (node, "remote", ip4);
9998 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
9999 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
10000 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10001 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
10002 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10006 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
10008 unformat_input_t *i = vam->input;
10009 vl_api_vxlan_gpe_tunnel_dump_t *mp;
10012 u8 sw_if_index_set = 0;
10014 /* Parse args required to build the message */
10015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10017 if (unformat (i, "sw_if_index %d", &sw_if_index))
10018 sw_if_index_set = 1;
10023 if (sw_if_index_set == 0)
10028 if (!vam->json_output)
10030 fformat (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s\n",
10031 "sw_if_index", "local", "remote", "vni",
10032 "protocol", "encap_vrf_id", "decap_vrf_id");
10035 /* Get list of vxlan-tunnel interfaces */
10036 M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump);
10038 mp->sw_if_index = htonl (sw_if_index);
10042 /* Use a control ping for synchronization */
10044 vl_api_control_ping_t *mp;
10045 M (CONTROL_PING, control_ping);
10052 format_l2_fib_mac_address (u8 * s, va_list * args)
10054 u8 *a = va_arg (*args, u8 *);
10056 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
10057 a[2], a[3], a[4], a[5], a[6], a[7]);
10060 static void vl_api_l2_fib_table_entry_t_handler
10061 (vl_api_l2_fib_table_entry_t * mp)
10063 vat_main_t *vam = &vat_main;
10065 fformat (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
10067 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
10068 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
10072 static void vl_api_l2_fib_table_entry_t_handler_json
10073 (vl_api_l2_fib_table_entry_t * mp)
10075 vat_main_t *vam = &vat_main;
10076 vat_json_node_t *node = NULL;
10078 if (VAT_JSON_ARRAY != vam->json_tree.type)
10080 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10081 vat_json_init_array (&vam->json_tree);
10083 node = vat_json_array_add (&vam->json_tree);
10085 vat_json_init_object (node);
10086 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
10087 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
10088 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10089 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
10090 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
10091 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
10095 api_l2_fib_table_dump (vat_main_t * vam)
10097 unformat_input_t *i = vam->input;
10098 vl_api_l2_fib_table_dump_t *mp;
10103 /* Parse args required to build the message */
10104 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10106 if (unformat (i, "bd_id %d", &bd_id))
10112 if (bd_id_set == 0)
10114 errmsg ("missing bridge domain\n");
10119 "BD-ID Mac Address sw-ndx Static Filter BVI\n");
10121 /* Get list of l2 fib entries */
10122 M (L2_FIB_TABLE_DUMP, l2_fib_table_dump);
10124 mp->bd_id = ntohl (bd_id);
10127 /* Use a control ping for synchronization */
10129 vl_api_control_ping_t *mp;
10130 M (CONTROL_PING, control_ping);
10138 api_interface_name_renumber (vat_main_t * vam)
10140 unformat_input_t *line_input = vam->input;
10141 vl_api_interface_name_renumber_t *mp;
10142 u32 sw_if_index = ~0;
10144 u32 new_show_dev_instance = ~0;
10146 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10148 if (unformat (line_input, "%U", unformat_sw_if_index, vam,
10151 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
10153 else if (unformat (line_input, "new_show_dev_instance %d",
10154 &new_show_dev_instance))
10160 if (sw_if_index == ~0)
10162 errmsg ("missing interface name or sw_if_index\n");
10166 if (new_show_dev_instance == ~0)
10168 errmsg ("missing new_show_dev_instance\n");
10172 M (INTERFACE_NAME_RENUMBER, interface_name_renumber);
10174 mp->sw_if_index = ntohl (sw_if_index);
10175 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
10182 api_want_ip4_arp_events (vat_main_t * vam)
10184 unformat_input_t *line_input = vam->input;
10185 vl_api_want_ip4_arp_events_t *mp;
10187 ip4_address_t address;
10188 int address_set = 0;
10189 u32 enable_disable = 1;
10191 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10193 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
10195 else if (unformat (line_input, "del"))
10196 enable_disable = 0;
10201 if (address_set == 0)
10203 errmsg ("missing addresses\n");
10207 M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events);
10208 mp->enable_disable = enable_disable;
10209 mp->pid = getpid ();
10210 mp->address = address.as_u32;
10217 api_input_acl_set_interface (vat_main_t * vam)
10219 unformat_input_t *i = vam->input;
10220 vl_api_input_acl_set_interface_t *mp;
10223 int sw_if_index_set;
10224 u32 ip4_table_index = ~0;
10225 u32 ip6_table_index = ~0;
10226 u32 l2_table_index = ~0;
10229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10231 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10232 sw_if_index_set = 1;
10233 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10234 sw_if_index_set = 1;
10235 else if (unformat (i, "del"))
10237 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10239 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10241 else if (unformat (i, "l2-table %d", &l2_table_index))
10245 clib_warning ("parse error '%U'", format_unformat_error, i);
10250 if (sw_if_index_set == 0)
10252 errmsg ("missing interface name or sw_if_index\n");
10256 M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface);
10258 mp->sw_if_index = ntohl (sw_if_index);
10259 mp->ip4_table_index = ntohl (ip4_table_index);
10260 mp->ip6_table_index = ntohl (ip6_table_index);
10261 mp->l2_table_index = ntohl (l2_table_index);
10262 mp->is_add = is_add;
10271 api_ip_address_dump (vat_main_t * vam)
10273 unformat_input_t *i = vam->input;
10274 vl_api_ip_address_dump_t *mp;
10275 u32 sw_if_index = ~0;
10276 u8 sw_if_index_set = 0;
10281 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10283 if (unformat (i, "sw_if_index %d", &sw_if_index))
10284 sw_if_index_set = 1;
10285 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10286 sw_if_index_set = 1;
10287 else if (unformat (i, "ipv4"))
10289 else if (unformat (i, "ipv6"))
10295 if (ipv4_set && ipv6_set)
10297 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
10301 if ((!ipv4_set) && (!ipv6_set))
10303 errmsg ("no ipv4 nor ipv6 flag set\n");
10307 if (sw_if_index_set == 0)
10309 errmsg ("missing interface name or sw_if_index\n");
10313 vam->current_sw_if_index = sw_if_index;
10314 vam->is_ipv6 = ipv6_set;
10316 M (IP_ADDRESS_DUMP, ip_address_dump);
10317 mp->sw_if_index = ntohl (sw_if_index);
10318 mp->is_ipv6 = ipv6_set;
10321 /* Use a control ping for synchronization */
10323 vl_api_control_ping_t *mp;
10324 M (CONTROL_PING, control_ping);
10331 api_ip_dump (vat_main_t * vam)
10333 vl_api_ip_dump_t *mp;
10334 unformat_input_t *in = vam->input;
10341 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
10343 if (unformat (in, "ipv4"))
10345 else if (unformat (in, "ipv6"))
10351 if (ipv4_set && ipv6_set)
10353 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
10357 if ((!ipv4_set) && (!ipv6_set))
10359 errmsg ("no ipv4 nor ipv6 flag set\n");
10363 is_ipv6 = ipv6_set;
10364 vam->is_ipv6 = is_ipv6;
10366 /* free old data */
10367 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
10369 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
10371 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
10373 M (IP_DUMP, ip_dump);
10374 mp->is_ipv6 = ipv6_set;
10377 /* Use a control ping for synchronization */
10379 vl_api_control_ping_t *mp;
10380 M (CONTROL_PING, control_ping);
10387 api_ipsec_spd_add_del (vat_main_t * vam)
10390 unformat_input_t *i = vam->input;
10391 vl_api_ipsec_spd_add_del_t *mp;
10396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10398 if (unformat (i, "spd_id %d", &spd_id))
10400 else if (unformat (i, "del"))
10404 clib_warning ("parse error '%U'", format_unformat_error, i);
10410 errmsg ("spd_id must be set\n");
10414 M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del);
10416 mp->spd_id = ntohl (spd_id);
10417 mp->is_add = is_add;
10424 clib_warning ("unsupported (no dpdk)");
10430 api_ipsec_interface_add_del_spd (vat_main_t * vam)
10433 unformat_input_t *i = vam->input;
10434 vl_api_ipsec_interface_add_del_spd_t *mp;
10437 u8 sw_if_index_set = 0;
10438 u32 spd_id = (u32) ~ 0;
10441 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10443 if (unformat (i, "del"))
10445 else if (unformat (i, "spd_id %d", &spd_id))
10447 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10448 sw_if_index_set = 1;
10449 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10450 sw_if_index_set = 1;
10453 clib_warning ("parse error '%U'", format_unformat_error, i);
10459 if (spd_id == (u32) ~ 0)
10461 errmsg ("spd_id must be set\n");
10465 if (sw_if_index_set == 0)
10467 errmsg ("missing interface name or sw_if_index\n");
10471 M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd);
10473 mp->spd_id = ntohl (spd_id);
10474 mp->sw_if_index = ntohl (sw_if_index);
10475 mp->is_add = is_add;
10482 clib_warning ("unsupported (no dpdk)");
10488 api_ipsec_spd_add_del_entry (vat_main_t * vam)
10491 unformat_input_t *i = vam->input;
10492 vl_api_ipsec_spd_add_del_entry_t *mp;
10494 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
10495 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
10497 u32 rport_start = 0, rport_stop = (u32) ~ 0;
10498 u32 lport_start = 0, lport_stop = (u32) ~ 0;
10499 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
10500 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
10502 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
10503 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
10504 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
10505 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
10506 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
10507 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
10509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10511 if (unformat (i, "del"))
10513 if (unformat (i, "outbound"))
10515 if (unformat (i, "inbound"))
10517 else if (unformat (i, "spd_id %d", &spd_id))
10519 else if (unformat (i, "sa_id %d", &sa_id))
10521 else if (unformat (i, "priority %d", &priority))
10523 else if (unformat (i, "protocol %d", &protocol))
10525 else if (unformat (i, "lport_start %d", &lport_start))
10527 else if (unformat (i, "lport_stop %d", &lport_stop))
10529 else if (unformat (i, "rport_start %d", &rport_start))
10531 else if (unformat (i, "rport_stop %d", &rport_stop))
10535 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
10541 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
10548 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
10554 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
10561 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
10567 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
10574 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
10580 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
10586 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
10588 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
10590 clib_warning ("unsupported action: 'resolve'");
10596 clib_warning ("parse error '%U'", format_unformat_error, i);
10602 M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry);
10604 mp->spd_id = ntohl (spd_id);
10605 mp->priority = ntohl (priority);
10606 mp->is_outbound = is_outbound;
10608 mp->is_ipv6 = is_ipv6;
10609 if (is_ipv6 || is_ip_any)
10611 clib_memcpy (mp->remote_address_start, &raddr6_start,
10612 sizeof (ip6_address_t));
10613 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
10614 sizeof (ip6_address_t));
10615 clib_memcpy (mp->local_address_start, &laddr6_start,
10616 sizeof (ip6_address_t));
10617 clib_memcpy (mp->local_address_stop, &laddr6_stop,
10618 sizeof (ip6_address_t));
10622 clib_memcpy (mp->remote_address_start, &raddr4_start,
10623 sizeof (ip4_address_t));
10624 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
10625 sizeof (ip4_address_t));
10626 clib_memcpy (mp->local_address_start, &laddr4_start,
10627 sizeof (ip4_address_t));
10628 clib_memcpy (mp->local_address_stop, &laddr4_stop,
10629 sizeof (ip4_address_t));
10631 mp->protocol = (u8) protocol;
10632 mp->local_port_start = ntohs ((u16) lport_start);
10633 mp->local_port_stop = ntohs ((u16) lport_stop);
10634 mp->remote_port_start = ntohs ((u16) rport_start);
10635 mp->remote_port_stop = ntohs ((u16) rport_stop);
10636 mp->policy = (u8) policy;
10637 mp->sa_id = ntohl (sa_id);
10638 mp->is_add = is_add;
10639 mp->is_ip_any = is_ip_any;
10645 clib_warning ("unsupported (no dpdk)");
10651 api_ipsec_sad_add_del_entry (vat_main_t * vam)
10654 unformat_input_t *i = vam->input;
10655 vl_api_ipsec_sad_add_del_entry_t *mp;
10657 u32 sad_id = 0, spi = 0;
10658 u8 *ck = 0, *ik = 0;
10661 u8 protocol = IPSEC_PROTOCOL_AH;
10662 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
10663 u32 crypto_alg = 0, integ_alg = 0;
10664 ip4_address_t tun_src4;
10665 ip4_address_t tun_dst4;
10666 ip6_address_t tun_src6;
10667 ip6_address_t tun_dst6;
10669 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10671 if (unformat (i, "del"))
10673 else if (unformat (i, "sad_id %d", &sad_id))
10675 else if (unformat (i, "spi %d", &spi))
10677 else if (unformat (i, "esp"))
10678 protocol = IPSEC_PROTOCOL_ESP;
10679 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
10682 is_tunnel_ipv6 = 0;
10684 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
10687 is_tunnel_ipv6 = 0;
10689 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
10692 is_tunnel_ipv6 = 1;
10694 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
10697 is_tunnel_ipv6 = 1;
10701 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
10703 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
10704 crypto_alg > IPSEC_INTEG_ALG_SHA_512_256)
10706 clib_warning ("unsupported crypto-alg: '%U'",
10707 format_ipsec_crypto_alg, crypto_alg);
10711 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
10715 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
10717 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
10718 integ_alg > IPSEC_INTEG_ALG_SHA_512_256)
10720 clib_warning ("unsupported integ-alg: '%U'",
10721 format_ipsec_integ_alg, integ_alg);
10725 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
10729 clib_warning ("parse error '%U'", format_unformat_error, i);
10735 M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
10737 mp->sad_id = ntohl (sad_id);
10738 mp->is_add = is_add;
10739 mp->protocol = protocol;
10740 mp->spi = ntohl (spi);
10741 mp->is_tunnel = is_tunnel;
10742 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
10743 mp->crypto_algorithm = crypto_alg;
10744 mp->integrity_algorithm = integ_alg;
10745 mp->crypto_key_length = vec_len (ck);
10746 mp->integrity_key_length = vec_len (ik);
10748 if (mp->crypto_key_length > sizeof (mp->crypto_key))
10749 mp->crypto_key_length = sizeof (mp->crypto_key);
10751 if (mp->integrity_key_length > sizeof (mp->integrity_key))
10752 mp->integrity_key_length = sizeof (mp->integrity_key);
10755 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
10757 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
10761 if (is_tunnel_ipv6)
10763 clib_memcpy (mp->tunnel_src_address, &tun_src6,
10764 sizeof (ip6_address_t));
10765 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
10766 sizeof (ip6_address_t));
10770 clib_memcpy (mp->tunnel_src_address, &tun_src4,
10771 sizeof (ip4_address_t));
10772 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
10773 sizeof (ip4_address_t));
10782 clib_warning ("unsupported (no dpdk)");
10788 api_ipsec_sa_set_key (vat_main_t * vam)
10791 unformat_input_t *i = vam->input;
10792 vl_api_ipsec_sa_set_key_t *mp;
10795 u8 *ck = 0, *ik = 0;
10797 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10799 if (unformat (i, "sa_id %d", &sa_id))
10801 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
10803 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
10807 clib_warning ("parse error '%U'", format_unformat_error, i);
10812 M (IPSEC_SA_SET_KEY, ipsec_set_sa_key);
10814 mp->sa_id = ntohl (sa_id);
10815 mp->crypto_key_length = vec_len (ck);
10816 mp->integrity_key_length = vec_len (ik);
10818 if (mp->crypto_key_length > sizeof (mp->crypto_key))
10819 mp->crypto_key_length = sizeof (mp->crypto_key);
10821 if (mp->integrity_key_length > sizeof (mp->integrity_key))
10822 mp->integrity_key_length = sizeof (mp->integrity_key);
10825 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
10827 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
10834 clib_warning ("unsupported (no dpdk)");
10840 api_ikev2_profile_add_del (vat_main_t * vam)
10843 unformat_input_t *i = vam->input;
10844 vl_api_ikev2_profile_add_del_t *mp;
10849 const char *valid_chars = "a-zA-Z0-9_";
10851 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10853 if (unformat (i, "del"))
10855 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
10856 vec_add1 (name, 0);
10859 errmsg ("parse error '%U'", format_unformat_error, i);
10864 if (!vec_len (name))
10866 errmsg ("profile name must be specified");
10870 if (vec_len (name) > 64)
10872 errmsg ("profile name too long");
10876 M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del);
10878 clib_memcpy (mp->name, name, vec_len (name));
10879 mp->is_add = is_add;
10887 clib_warning ("unsupported (no dpdk)");
10893 api_ikev2_profile_set_auth (vat_main_t * vam)
10896 unformat_input_t *i = vam->input;
10897 vl_api_ikev2_profile_set_auth_t *mp;
10901 u32 auth_method = 0;
10904 const char *valid_chars = "a-zA-Z0-9_";
10906 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10908 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
10909 vec_add1 (name, 0);
10910 else if (unformat (i, "auth_method %U",
10911 unformat_ikev2_auth_method, &auth_method))
10913 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
10915 else if (unformat (i, "auth_data %v", &data))
10919 errmsg ("parse error '%U'", format_unformat_error, i);
10924 if (!vec_len (name))
10926 errmsg ("profile name must be specified");
10930 if (vec_len (name) > 64)
10932 errmsg ("profile name too long");
10936 if (!vec_len (data))
10938 errmsg ("auth_data must be specified");
10944 errmsg ("auth_method must be specified");
10948 M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth);
10950 mp->is_hex = is_hex;
10951 mp->auth_method = (u8) auth_method;
10952 mp->data_len = vec_len (data);
10953 clib_memcpy (mp->name, name, vec_len (name));
10954 clib_memcpy (mp->data, data, vec_len (data));
10963 clib_warning ("unsupported (no dpdk)");
10969 api_ikev2_profile_set_id (vat_main_t * vam)
10972 unformat_input_t *i = vam->input;
10973 vl_api_ikev2_profile_set_id_t *mp;
10981 const char *valid_chars = "a-zA-Z0-9_";
10983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10985 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
10986 vec_add1 (name, 0);
10987 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
10989 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
10991 data = vec_new (u8, 4);
10992 clib_memcpy (data, ip4.as_u8, 4);
10994 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
10996 else if (unformat (i, "id_data %v", &data))
10998 else if (unformat (i, "local"))
11000 else if (unformat (i, "remote"))
11004 errmsg ("parse error '%U'", format_unformat_error, i);
11009 if (!vec_len (name))
11011 errmsg ("profile name must be specified");
11015 if (vec_len (name) > 64)
11017 errmsg ("profile name too long");
11021 if (!vec_len (data))
11023 errmsg ("id_data must be specified");
11029 errmsg ("id_type must be specified");
11033 M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id);
11035 mp->is_local = is_local;
11036 mp->id_type = (u8) id_type;
11037 mp->data_len = vec_len (data);
11038 clib_memcpy (mp->name, name, vec_len (name));
11039 clib_memcpy (mp->data, data, vec_len (data));
11048 clib_warning ("unsupported (no dpdk)");
11054 api_ikev2_profile_set_ts (vat_main_t * vam)
11057 unformat_input_t *i = vam->input;
11058 vl_api_ikev2_profile_set_ts_t *mp;
11062 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
11063 ip4_address_t start_addr, end_addr;
11065 const char *valid_chars = "a-zA-Z0-9_";
11067 start_addr.as_u32 = 0;
11068 end_addr.as_u32 = (u32) ~ 0;
11070 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11072 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11073 vec_add1 (name, 0);
11074 else if (unformat (i, "protocol %d", &proto))
11076 else if (unformat (i, "start_port %d", &start_port))
11078 else if (unformat (i, "end_port %d", &end_port))
11081 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
11083 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
11085 else if (unformat (i, "local"))
11087 else if (unformat (i, "remote"))
11091 errmsg ("parse error '%U'", format_unformat_error, i);
11096 if (!vec_len (name))
11098 errmsg ("profile name must be specified");
11102 if (vec_len (name) > 64)
11104 errmsg ("profile name too long");
11108 M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts);
11110 mp->is_local = is_local;
11111 mp->proto = (u8) proto;
11112 mp->start_port = (u16) start_port;
11113 mp->end_port = (u16) end_port;
11114 mp->start_addr = start_addr.as_u32;
11115 mp->end_addr = end_addr.as_u32;
11116 clib_memcpy (mp->name, name, vec_len (name));
11124 clib_warning ("unsupported (no dpdk)");
11130 api_ikev2_set_local_key (vat_main_t * vam)
11133 unformat_input_t *i = vam->input;
11134 vl_api_ikev2_set_local_key_t *mp;
11138 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11140 if (unformat (i, "file %v", &file))
11141 vec_add1 (file, 0);
11144 errmsg ("parse error '%U'", format_unformat_error, i);
11149 if (!vec_len (file))
11151 errmsg ("RSA key file must be specified");
11155 if (vec_len (file) > 256)
11157 errmsg ("file name too long");
11161 M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key);
11163 clib_memcpy (mp->key_file, file, vec_len (file));
11171 clib_warning ("unsupported (no dpdk)");
11180 api_map_add_domain (vat_main_t * vam)
11182 unformat_input_t *i = vam->input;
11183 vl_api_map_add_domain_t *mp;
11186 ip4_address_t ip4_prefix;
11187 ip6_address_t ip6_prefix;
11188 ip6_address_t ip6_src;
11189 u32 num_m_args = 0;
11190 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
11191 0, psid_length = 0;
11192 u8 is_translation = 0;
11194 u32 ip6_src_len = 128;
11196 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11198 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
11199 &ip4_prefix, &ip4_prefix_len))
11201 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
11202 &ip6_prefix, &ip6_prefix_len))
11206 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
11209 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
11211 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
11213 else if (unformat (i, "psid-offset %d", &psid_offset))
11215 else if (unformat (i, "psid-len %d", &psid_length))
11217 else if (unformat (i, "mtu %d", &mtu))
11219 else if (unformat (i, "map-t"))
11220 is_translation = 1;
11223 clib_warning ("parse error '%U'", format_unformat_error, i);
11228 if (num_m_args < 3)
11230 errmsg ("mandatory argument(s) missing\n");
11234 /* Construct the API message */
11235 M (MAP_ADD_DOMAIN, map_add_domain);
11237 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
11238 mp->ip4_prefix_len = ip4_prefix_len;
11240 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
11241 mp->ip6_prefix_len = ip6_prefix_len;
11243 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
11244 mp->ip6_src_prefix_len = ip6_src_len;
11246 mp->ea_bits_len = ea_bits_len;
11247 mp->psid_offset = psid_offset;
11248 mp->psid_length = psid_length;
11249 mp->is_translation = is_translation;
11250 mp->mtu = htons (mtu);
11255 /* Wait for a reply, return good/bad news */
11260 api_map_del_domain (vat_main_t * vam)
11262 unformat_input_t *i = vam->input;
11263 vl_api_map_del_domain_t *mp;
11266 u32 num_m_args = 0;
11269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11271 if (unformat (i, "index %d", &index))
11275 clib_warning ("parse error '%U'", format_unformat_error, i);
11280 if (num_m_args != 1)
11282 errmsg ("mandatory argument(s) missing\n");
11286 /* Construct the API message */
11287 M (MAP_DEL_DOMAIN, map_del_domain);
11289 mp->index = ntohl (index);
11294 /* Wait for a reply, return good/bad news */
11299 api_map_add_del_rule (vat_main_t * vam)
11301 unformat_input_t *i = vam->input;
11302 vl_api_map_add_del_rule_t *mp;
11305 ip6_address_t ip6_dst;
11306 u32 num_m_args = 0, index, psid = 0;
11308 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11310 if (unformat (i, "index %d", &index))
11312 else if (unformat (i, "psid %d", &psid))
11314 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
11316 else if (unformat (i, "del"))
11322 clib_warning ("parse error '%U'", format_unformat_error, i);
11327 /* Construct the API message */
11328 M (MAP_ADD_DEL_RULE, map_add_del_rule);
11330 mp->index = ntohl (index);
11331 mp->is_add = is_add;
11332 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
11333 mp->psid = ntohs (psid);
11338 /* Wait for a reply, return good/bad news */
11343 api_map_domain_dump (vat_main_t * vam)
11345 vl_api_map_domain_dump_t *mp;
11348 /* Construct the API message */
11349 M (MAP_DOMAIN_DUMP, map_domain_dump);
11354 /* Use a control ping for synchronization */
11356 vl_api_control_ping_t *mp;
11357 M (CONTROL_PING, control_ping);
11364 api_map_rule_dump (vat_main_t * vam)
11366 unformat_input_t *i = vam->input;
11367 vl_api_map_rule_dump_t *mp;
11369 u32 domain_index = ~0;
11371 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11373 if (unformat (i, "index %u", &domain_index))
11379 if (domain_index == ~0)
11381 clib_warning ("parse error: domain index expected");
11385 /* Construct the API message */
11386 M (MAP_RULE_DUMP, map_rule_dump);
11388 mp->domain_index = htonl (domain_index);
11393 /* Use a control ping for synchronization */
11395 vl_api_control_ping_t *mp;
11396 M (CONTROL_PING, control_ping);
11402 static void vl_api_map_add_domain_reply_t_handler
11403 (vl_api_map_add_domain_reply_t * mp)
11405 vat_main_t *vam = &vat_main;
11406 i32 retval = ntohl (mp->retval);
11408 if (vam->async_mode)
11410 vam->async_errors += (retval < 0);
11414 vam->retval = retval;
11415 vam->result_ready = 1;
11419 static void vl_api_map_add_domain_reply_t_handler_json
11420 (vl_api_map_add_domain_reply_t * mp)
11422 vat_main_t *vam = &vat_main;
11423 vat_json_node_t node;
11425 vat_json_init_object (&node);
11426 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
11427 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
11429 vat_json_print (vam->ofp, &node);
11430 vat_json_free (&node);
11432 vam->retval = ntohl (mp->retval);
11433 vam->result_ready = 1;
11437 api_get_first_msg_id (vat_main_t * vam)
11439 vl_api_get_first_msg_id_t *mp;
11441 unformat_input_t *i = vam->input;
11445 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11447 if (unformat (i, "client %s", &name))
11455 errmsg ("missing client name\n");
11458 vec_add1 (name, 0);
11460 if (vec_len (name) > 63)
11462 errmsg ("client name too long\n");
11466 M (GET_FIRST_MSG_ID, get_first_msg_id);
11467 clib_memcpy (mp->name, name, vec_len (name));
11475 api_cop_interface_enable_disable (vat_main_t * vam)
11477 unformat_input_t *line_input = vam->input;
11478 vl_api_cop_interface_enable_disable_t *mp;
11480 u32 sw_if_index = ~0;
11481 u8 enable_disable = 1;
11483 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11485 if (unformat (line_input, "disable"))
11486 enable_disable = 0;
11487 if (unformat (line_input, "enable"))
11488 enable_disable = 1;
11489 else if (unformat (line_input, "%U", unformat_sw_if_index,
11490 vam, &sw_if_index))
11492 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11498 if (sw_if_index == ~0)
11500 errmsg ("missing interface name or sw_if_index\n");
11504 /* Construct the API message */
11505 M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable);
11506 mp->sw_if_index = ntohl (sw_if_index);
11507 mp->enable_disable = enable_disable;
11511 /* Wait for the reply */
11516 api_cop_whitelist_enable_disable (vat_main_t * vam)
11518 unformat_input_t *line_input = vam->input;
11519 vl_api_cop_whitelist_enable_disable_t *mp;
11521 u32 sw_if_index = ~0;
11522 u8 ip4 = 0, ip6 = 0, default_cop = 0;
11525 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11527 if (unformat (line_input, "ip4"))
11529 else if (unformat (line_input, "ip6"))
11531 else if (unformat (line_input, "default"))
11533 else if (unformat (line_input, "%U", unformat_sw_if_index,
11534 vam, &sw_if_index))
11536 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11538 else if (unformat (line_input, "fib-id %d", &fib_id))
11544 if (sw_if_index == ~0)
11546 errmsg ("missing interface name or sw_if_index\n");
11550 /* Construct the API message */
11551 M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable);
11552 mp->sw_if_index = ntohl (sw_if_index);
11553 mp->fib_id = ntohl (fib_id);
11556 mp->default_cop = default_cop;
11560 /* Wait for the reply */
11565 api_get_node_graph (vat_main_t * vam)
11567 vl_api_get_node_graph_t *mp;
11570 M (GET_NODE_GRAPH, get_node_graph);
11574 /* Wait for the reply */
11579 /** Used for parsing LISP eids */
11580 typedef CLIB_PACKED(struct{
11581 u8 addr[16]; /**< eid address */
11582 u32 len; /**< prefix length if IP */
11583 u8 type; /**< type of eid */
11588 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
11590 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
11592 memset (a, 0, sizeof (a[0]));
11594 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
11596 a->type = 0; /* ipv4 type */
11598 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
11600 a->type = 1; /* ipv6 type */
11602 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
11604 a->type = 2; /* mac type */
11611 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
11620 lisp_eid_size_vat (u8 type)
11635 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
11637 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
11641 /** Used for transferring locators via VPP API */
11642 typedef CLIB_PACKED(struct
11644 u32 sw_if_index; /**< locator sw_if_index */
11645 u8 priority; /**< locator priority */
11646 u8 weight; /**< locator weight */
11651 api_lisp_add_del_locator_set (vat_main_t * vam)
11653 unformat_input_t *input = vam->input;
11654 vl_api_lisp_add_del_locator_set_t *mp;
11657 u8 *locator_set_name = NULL;
11658 u8 locator_set_name_set = 0;
11659 ls_locator_t locator, *locators = 0;
11660 u32 sw_if_index, priority, weight;
11662 /* Parse args required to build the message */
11663 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11665 if (unformat (input, "del"))
11669 else if (unformat (input, "locator-set %s", &locator_set_name))
11671 locator_set_name_set = 1;
11673 else if (unformat (input, "sw_if_index %u p %u w %u",
11674 &sw_if_index, &priority, &weight))
11676 locator.sw_if_index = htonl (sw_if_index);
11677 locator.priority = priority;
11678 locator.weight = weight;
11679 vec_add1 (locators, locator);
11681 else if (unformat (input, "iface %U p %u w %u", unformat_sw_if_index,
11682 vam, &sw_if_index, &priority, &weight))
11684 locator.sw_if_index = htonl (sw_if_index);
11685 locator.priority = priority;
11686 locator.weight = weight;
11687 vec_add1 (locators, locator);
11693 if (locator_set_name_set == 0)
11695 errmsg ("missing locator-set name");
11696 vec_free (locators);
11700 if (vec_len (locator_set_name) > 64)
11702 errmsg ("locator-set name too long\n");
11703 vec_free (locator_set_name);
11704 vec_free (locators);
11707 vec_add1 (locator_set_name, 0);
11709 /* Construct the API message */
11710 M (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set);
11712 mp->is_add = is_add;
11713 clib_memcpy (mp->locator_set_name, locator_set_name,
11714 vec_len (locator_set_name));
11715 vec_free (locator_set_name);
11717 mp->locator_num = vec_len (locators);
11719 clib_memcpy (mp->locators, locators,
11720 (sizeof (ls_locator_t) * vec_len (locators)));
11721 vec_free (locators);
11726 /* Wait for a reply... */
11734 api_lisp_add_del_locator (vat_main_t * vam)
11736 unformat_input_t *input = vam->input;
11737 vl_api_lisp_add_del_locator_t *mp;
11739 u32 tmp_if_index = ~0;
11740 u32 sw_if_index = ~0;
11741 u8 sw_if_index_set = 0;
11742 u8 sw_if_index_if_name_set = 0;
11744 u8 priority_set = 0;
11748 u8 *locator_set_name = NULL;
11749 u8 locator_set_name_set = 0;
11751 /* Parse args required to build the message */
11752 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11754 if (unformat (input, "del"))
11758 else if (unformat (input, "locator-set %s", &locator_set_name))
11760 locator_set_name_set = 1;
11762 else if (unformat (input, "iface %U", unformat_sw_if_index, vam,
11765 sw_if_index_if_name_set = 1;
11766 sw_if_index = tmp_if_index;
11768 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
11770 sw_if_index_set = 1;
11771 sw_if_index = tmp_if_index;
11773 else if (unformat (input, "p %d", &priority))
11777 else if (unformat (input, "w %d", &weight))
11785 if (locator_set_name_set == 0)
11787 errmsg ("missing locator-set name");
11791 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
11793 errmsg ("missing sw_if_index");
11794 vec_free (locator_set_name);
11798 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
11800 errmsg ("cannot use both params interface name and sw_if_index");
11801 vec_free (locator_set_name);
11805 if (priority_set == 0)
11807 errmsg ("missing locator-set priority\n");
11808 vec_free (locator_set_name);
11812 if (weight_set == 0)
11814 errmsg ("missing locator-set weight\n");
11815 vec_free (locator_set_name);
11819 if (vec_len (locator_set_name) > 64)
11821 errmsg ("locator-set name too long\n");
11822 vec_free (locator_set_name);
11825 vec_add1 (locator_set_name, 0);
11827 /* Construct the API message */
11828 M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
11830 mp->is_add = is_add;
11831 mp->sw_if_index = ntohl (sw_if_index);
11832 mp->priority = priority;
11833 mp->weight = weight;
11834 clib_memcpy (mp->locator_set_name, locator_set_name,
11835 vec_len (locator_set_name));
11836 vec_free (locator_set_name);
11841 /* Wait for a reply... */
11849 api_lisp_add_del_local_eid (vat_main_t * vam)
11851 unformat_input_t *input = vam->input;
11852 vl_api_lisp_add_del_local_eid_t *mp;
11856 lisp_eid_vat_t _eid, *eid = &_eid;
11857 u8 *locator_set_name = 0;
11858 u8 locator_set_name_set = 0;
11861 /* Parse args required to build the message */
11862 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11864 if (unformat (input, "del"))
11868 else if (unformat (input, "vni %d", &vni))
11872 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
11876 else if (unformat (input, "locator-set %s", &locator_set_name))
11878 locator_set_name_set = 1;
11884 if (locator_set_name_set == 0)
11886 errmsg ("missing locator-set name\n");
11892 errmsg ("EID address not set!");
11893 vec_free (locator_set_name);
11897 if (vec_len (locator_set_name) > 64)
11899 errmsg ("locator-set name too long\n");
11900 vec_free (locator_set_name);
11903 vec_add1 (locator_set_name, 0);
11905 /* Construct the API message */
11906 M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
11908 mp->is_add = is_add;
11909 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
11910 mp->eid_type = eid->type;
11911 mp->prefix_len = eid->len;
11912 mp->vni = clib_host_to_net_u32 (vni);
11913 clib_memcpy (mp->locator_set_name, locator_set_name,
11914 vec_len (locator_set_name));
11916 vec_free (locator_set_name);
11921 /* Wait for a reply... */
11929 /** Used for transferring locators via VPP API */
11930 typedef CLIB_PACKED(struct
11932 u8 is_ip4; /**< is locator an IPv4 address? */
11933 u8 priority; /**< locator priority */
11934 u8 weight; /**< locator weight */
11935 u8 addr[16]; /**< IPv4/IPv6 address */
11940 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
11942 unformat_input_t *input = vam->input;
11943 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
11946 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
11947 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
11948 u8 rmt_eid_set = 0, lcl_eid_set = 0;
11949 u32 action = ~0, p, w;
11950 ip4_address_t rmt_rloc4, lcl_rloc4;
11951 ip6_address_t rmt_rloc6, lcl_rloc6;
11952 rloc_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
11954 memset (&rloc, 0, sizeof (rloc));
11956 /* Parse args required to build the message */
11957 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11959 if (unformat (input, "del"))
11963 else if (unformat (input, "rmt_eid %U", unformat_lisp_eid_vat, rmt_eid))
11967 else if (unformat (input, "lcl_eid %U", unformat_lisp_eid_vat, lcl_eid))
11971 else if (unformat (input, "p %d w %d", &p, &w))
11975 errmsg ("No RLOC configured for setting priority/weight!");
11978 curr_rloc->priority = p;
11979 curr_rloc->weight = w;
11981 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
11982 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
11986 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
11987 rloc.priority = rloc.weight = 0;
11988 vec_add1 (lcl_locs, rloc);
11990 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
11991 vec_add1 (rmt_locs, rloc);
11992 /* priority and weight saved in rmt loc */
11993 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
11995 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
11996 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
11999 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
12000 rloc.priority = rloc.weight = 0;
12001 vec_add1 (lcl_locs, rloc);
12003 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
12004 vec_add1 (rmt_locs, rloc);
12005 /* priority and weight saved in rmt loc */
12006 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
12008 else if (unformat (input, "action %d", &action))
12014 clib_warning ("parse error '%U'", format_unformat_error, input);
12021 errmsg ("remote eid addresses not set\n");
12025 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
12027 errmsg ("eid types don't match\n");
12031 if (0 == rmt_locs && (u32) ~ 0 == action)
12033 errmsg ("action not set for negative mapping\n");
12037 /* Construct the API message */
12038 M (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry);
12040 mp->is_add = is_add;
12041 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
12042 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
12043 mp->eid_type = rmt_eid->type;
12044 mp->rmt_len = rmt_eid->len;
12045 mp->lcl_len = lcl_eid->len;
12046 mp->action = action;
12048 if (0 != rmt_locs && 0 != lcl_locs)
12050 mp->loc_num = vec_len (rmt_locs);
12051 clib_memcpy (mp->lcl_locs, lcl_locs,
12052 (sizeof (rloc_t) * vec_len (lcl_locs)));
12053 clib_memcpy (mp->rmt_locs, rmt_locs,
12054 (sizeof (rloc_t) * vec_len (rmt_locs)));
12056 vec_free (lcl_locs);
12057 vec_free (rmt_locs);
12062 /* Wait for a reply... */
12070 api_lisp_add_del_map_resolver (vat_main_t * vam)
12072 unformat_input_t *input = vam->input;
12073 vl_api_lisp_add_del_map_resolver_t *mp;
12078 ip4_address_t ipv4;
12079 ip6_address_t ipv6;
12081 /* Parse args required to build the message */
12082 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12084 if (unformat (input, "del"))
12088 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
12092 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
12100 if (ipv4_set && ipv6_set)
12102 errmsg ("both eid v4 and v6 addresses set\n");
12106 if (!ipv4_set && !ipv6_set)
12108 errmsg ("eid addresses not set\n");
12112 /* Construct the API message */
12113 M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
12115 mp->is_add = is_add;
12119 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
12124 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
12130 /* Wait for a reply... */
12138 api_lisp_gpe_enable_disable (vat_main_t * vam)
12140 unformat_input_t *input = vam->input;
12141 vl_api_lisp_gpe_enable_disable_t *mp;
12146 /* Parse args required to build the message */
12147 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12149 if (unformat (input, "enable"))
12154 else if (unformat (input, "disable"))
12165 errmsg ("Value not set\n");
12169 /* Construct the API message */
12170 M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
12177 /* Wait for a reply... */
12185 api_lisp_enable_disable (vat_main_t * vam)
12187 unformat_input_t *input = vam->input;
12188 vl_api_lisp_enable_disable_t *mp;
12193 /* Parse args required to build the message */
12194 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12196 if (unformat (input, "enable"))
12201 else if (unformat (input, "disable"))
12211 errmsg ("Value not set\n");
12215 /* Construct the API message */
12216 M (LISP_ENABLE_DISABLE, lisp_enable_disable);
12223 /* Wait for a reply... */
12231 * Enable/disable LISP proxy ITR.
12233 * @param vam vpp API test context
12234 * @return return code
12237 api_lisp_pitr_set_locator_set (vat_main_t * vam)
12240 u8 ls_name_set = 0;
12241 unformat_input_t *input = vam->input;
12242 vl_api_lisp_pitr_set_locator_set_t *mp;
12246 /* Parse args required to build the message */
12247 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12249 if (unformat (input, "del"))
12251 else if (unformat (input, "locator-set %s", &ls_name))
12255 errmsg ("parse error '%U'", format_unformat_error, input);
12262 errmsg ("locator-set name not set!");
12266 M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set);
12268 mp->is_add = is_add;
12269 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
12270 vec_free (ls_name);
12275 /* wait for reply */
12283 api_show_lisp_pitr (vat_main_t * vam)
12285 vl_api_show_lisp_pitr_t *mp;
12288 if (!vam->json_output)
12290 fformat (vam->ofp, "%=20s\n", "lisp status:");
12293 M (SHOW_LISP_PITR, show_lisp_pitr);
12297 /* Wait for a reply... */
12305 * Add/delete mapping between vni and vrf
12308 api_lisp_eid_table_add_del_map (vat_main_t * vam)
12311 unformat_input_t *input = vam->input;
12312 vl_api_lisp_eid_table_add_del_map_t *mp;
12313 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
12314 u32 vni, vrf, bd_index;
12316 /* Parse args required to build the message */
12317 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12319 if (unformat (input, "del"))
12321 else if (unformat (input, "vrf %d", &vrf))
12323 else if (unformat (input, "bd_index %d", &bd_index))
12325 else if (unformat (input, "vni %d", &vni))
12331 if (!vni_set || (!vrf_set && !bd_index_set))
12333 errmsg ("missing arguments!");
12337 M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
12339 mp->is_add = is_add;
12340 mp->vni = htonl (vni);
12341 mp->dp_table = htonl (vrf);
12342 mp->is_l2 = bd_index_set;
12347 /* wait for reply */
12355 * Add/del remote mapping to/from LISP control plane
12357 * @param vam vpp API test context
12358 * @return return code
12361 api_lisp_add_del_remote_mapping (vat_main_t * vam)
12363 unformat_input_t *input = vam->input;
12364 vl_api_lisp_add_del_remote_mapping_t *mp;
12367 //TODO: seid need remove
12368 lisp_eid_vat_t _eid, *eid = &_eid;
12369 lisp_eid_vat_t _seid, *seid = &_seid;
12370 u8 is_add = 1, del_all = 0, eid_set = 0;
12371 u32 action = ~0, p, w;
12372 ip4_address_t rloc4;
12373 ip6_address_t rloc6;
12374 rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
12376 memset (&rloc, 0, sizeof (rloc));
12378 /* Parse args required to build the message */
12379 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12381 if (unformat (input, "del-all"))
12385 else if (unformat (input, "del"))
12389 else if (unformat (input, "add"))
12393 else if (unformat (input, "deid %U", unformat_lisp_eid_vat, eid))
12397 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, &seid))
12399 //TODO: Need remove, but first must be remove from CSIT test
12401 else if (unformat (input, "vni %d", &vni))
12405 else if (unformat (input, "p %d w %d", &p, &w))
12409 errmsg ("No RLOC configured for setting priority/weight!");
12412 curr_rloc->priority = p;
12413 curr_rloc->weight = w;
12415 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
12418 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
12419 vec_add1 (rlocs, rloc);
12420 curr_rloc = &rlocs[vec_len (rlocs) - 1];
12422 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
12425 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
12426 vec_add1 (rlocs, rloc);
12427 curr_rloc = &rlocs[vec_len (rlocs) - 1];
12429 else if (unformat (input, "action %d", &action))
12435 clib_warning ("parse error '%U'", format_unformat_error, input);
12442 errmsg ("missing params!");
12446 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
12448 errmsg ("no action set for negative map-reply!");
12452 M (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping);
12453 mp->is_add = is_add;
12454 mp->vni = htonl (vni);
12455 mp->action = (u8) action;
12456 mp->eid_len = eid->len;
12457 mp->del_all = del_all;
12458 mp->eid_type = eid->type;
12459 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
12461 mp->rloc_num = vec_len (rlocs);
12462 clib_memcpy (mp->rlocs, rlocs, (sizeof (rloc_t) * vec_len (rlocs)));
12468 /* Wait for a reply... */
12476 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
12477 * forwarding entries in data-plane accordingly.
12479 * @param vam vpp API test context
12480 * @return return code
12483 api_lisp_add_del_adjacency (vat_main_t * vam)
12485 unformat_input_t *input = vam->input;
12486 vl_api_lisp_add_del_adjacency_t *mp;
12489 ip4_address_t seid4, deid4;
12490 ip6_address_t seid6, deid6;
12491 u8 deid_mac[6] = { 0 };
12492 u8 seid_mac[6] = { 0 };
12493 u8 deid_type, seid_type;
12494 u32 seid_len = 0, deid_len = 0, len;
12497 seid_type = deid_type = (u8) ~ 0;
12499 /* Parse args required to build the message */
12500 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12502 if (unformat (input, "del"))
12506 else if (unformat (input, "add"))
12510 else if (unformat (input, "deid %U/%d", unformat_ip4_address,
12513 deid_type = 0; /* ipv4 */
12516 else if (unformat (input, "deid %U/%d", unformat_ip6_address,
12519 deid_type = 1; /* ipv6 */
12522 else if (unformat (input, "deid %U", unformat_ethernet_address,
12525 deid_type = 2; /* mac */
12527 else if (unformat (input, "seid %U/%d", unformat_ip4_address,
12530 seid_type = 0; /* ipv4 */
12533 else if (unformat (input, "seid %U/%d", unformat_ip6_address,
12536 seid_type = 1; /* ipv6 */
12539 else if (unformat (input, "seid %U", unformat_ethernet_address,
12542 seid_type = 2; /* mac */
12544 else if (unformat (input, "vni %d", &vni))
12550 errmsg ("parse error '%U'", format_unformat_error, input);
12555 if ((u8) ~ 0 == deid_type)
12557 errmsg ("missing params!");
12561 if (seid_type != deid_type)
12563 errmsg ("source and destination EIDs are of different types!");
12567 M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency);
12568 mp->is_add = is_add;
12569 mp->vni = htonl (vni);
12570 mp->seid_len = seid_len;
12571 mp->deid_len = deid_len;
12572 mp->eid_type = deid_type;
12574 switch (mp->eid_type)
12577 clib_memcpy (mp->seid, &seid4, sizeof (seid4));
12578 clib_memcpy (mp->deid, &deid4, sizeof (deid4));
12581 clib_memcpy (mp->seid, &seid6, sizeof (seid6));
12582 clib_memcpy (mp->deid, &deid6, sizeof (deid6));
12585 clib_memcpy (mp->seid, seid_mac, 6);
12586 clib_memcpy (mp->deid, deid_mac, 6);
12589 errmsg ("unknown EID type %d!", mp->eid_type);
12596 /* Wait for a reply... */
12604 api_lisp_gpe_add_del_iface (vat_main_t * vam)
12606 unformat_input_t *input = vam->input;
12607 vl_api_lisp_gpe_add_del_iface_t *mp;
12609 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
12610 u32 dp_table = 0, vni = 0;
12612 /* Parse args required to build the message */
12613 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12615 if (unformat (input, "up"))
12620 else if (unformat (input, "down"))
12625 else if (unformat (input, "table_id %d", &dp_table))
12629 else if (unformat (input, "bd_id %d", &dp_table))
12634 else if (unformat (input, "vni %d", &vni))
12642 if (action_set == 0)
12644 errmsg ("Action not set\n");
12647 if (dp_table_set == 0 || vni_set == 0)
12649 errmsg ("vni and dp_table must be set\n");
12653 /* Construct the API message */
12654 M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
12656 mp->is_add = is_add;
12657 mp->dp_table = dp_table;
12664 /* Wait for a reply... */
12672 * Add/del map request itr rlocs from LISP control plane and updates
12674 * @param vam vpp API test context
12675 * @return return code
12678 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
12680 unformat_input_t *input = vam->input;
12681 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
12683 u8 *locator_set_name = 0;
12684 u8 locator_set_name_set = 0;
12687 /* Parse args required to build the message */
12688 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12690 if (unformat (input, "del"))
12694 else if (unformat (input, "%_%v%_", &locator_set_name))
12696 locator_set_name_set = 1;
12700 clib_warning ("parse error '%U'", format_unformat_error, input);
12705 if (is_add && !locator_set_name_set)
12707 errmsg ("itr-rloc is not set!");
12711 if (is_add && vec_len (locator_set_name) > 64)
12713 errmsg ("itr-rloc locator-set name too long\n");
12714 vec_free (locator_set_name);
12718 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs);
12719 mp->is_add = is_add;
12722 clib_memcpy (mp->locator_set_name, locator_set_name,
12723 vec_len (locator_set_name));
12727 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
12729 vec_free (locator_set_name);
12734 /* Wait for a reply... */
12742 lisp_locator_dump_send_msg (vat_main_t * vam, u32 locator_set_index,
12745 vl_api_lisp_locator_dump_t *mp;
12748 M (LISP_LOCATOR_DUMP, lisp_locator_dump);
12750 mp->locator_set_index = htonl (locator_set_index);
12751 mp->filter = filter;
12756 /* Use a control ping for synchronization */
12758 vl_api_noprint_control_ping_t *mp;
12759 M (NOPRINT_CONTROL_PING, noprint_control_ping);
12762 /* Wait for a reply... */
12767 clean_locator_set_message (vat_main_t * vam)
12769 locator_set_msg_t *ls = 0;
12771 vec_foreach (ls, vam->locator_set_msg)
12773 vec_free (ls->locator_set_name);
12776 vec_free (vam->locator_set_msg);
12780 print_locator_in_locator_set (vat_main_t * vam, u8 filter)
12782 locator_set_msg_t *ls;
12783 locator_msg_t *loc;
12785 int i = 0, ret = 0;
12787 vec_foreach (ls, vam->locator_set_msg)
12789 ret = lisp_locator_dump_send_msg (vam, ls->locator_set_index, filter);
12792 vec_free (vam->locator_msg);
12793 clean_locator_set_message (vam);
12797 tmp_str = format (0, "%=20s%=16d%s", ls->locator_set_name,
12798 ls->locator_set_index,
12799 vec_len (vam->locator_msg) ? "" : "\n");
12801 vec_foreach (loc, vam->locator_msg)
12805 tmp_str = format (tmp_str, "%=37s", " ");
12809 tmp_str = format (tmp_str, "%=16d%=16d%=16d\n",
12810 loc->sw_if_index, loc->priority, loc->weight);
12814 tmp_str = format (tmp_str, "%=16U%=16d%=16d\n",
12815 loc->is_ipv6 ? format_ip6_address :
12816 format_ip4_address,
12817 loc->ip_address, loc->priority, loc->weight);
12822 fformat (vam->ofp, "%s", tmp_str);
12823 vec_free (tmp_str);
12824 vec_free (vam->locator_msg);
12827 clean_locator_set_message (vam);
12833 json_locator_in_locator_set (vat_main_t * vam, u8 filter)
12835 locator_set_msg_t *ls;
12836 locator_msg_t *loc;
12837 vat_json_node_t *node = NULL;
12838 vat_json_node_t *locator_array;
12839 vat_json_node_t *locator;
12840 struct in6_addr ip6;
12841 struct in_addr ip4;
12844 if (!vec_len (vam->locator_set_msg))
12846 /* just print [] */
12847 vat_json_init_array (&vam->json_tree);
12848 vat_json_print (vam->ofp, &vam->json_tree);
12849 vam->json_tree.type = VAT_JSON_NONE;
12853 if (VAT_JSON_ARRAY != vam->json_tree.type)
12855 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12856 vat_json_init_array (&vam->json_tree);
12859 vec_foreach (ls, vam->locator_set_msg)
12861 ret = lisp_locator_dump_send_msg (vam, ls->locator_set_index, filter);
12864 vec_free (ls->locator_set_name);
12865 vec_free (vam->locator_msg);
12866 vec_free (vam->locator_set_msg);
12867 vat_json_free (&vam->json_tree);
12868 vam->json_tree.type = VAT_JSON_NONE;
12872 node = vat_json_array_add (&vam->json_tree);
12873 vat_json_init_object (node);
12875 vat_json_object_add_uint (node, "locator-set-index",
12876 ls->locator_set_index);
12877 vat_json_object_add_string_copy (node, "locator-set",
12878 ls->locator_set_name);
12879 locator_array = vat_json_object_add_list (node, "locator");
12880 vec_foreach (loc, vam->locator_msg)
12882 locator = vat_json_array_add (locator_array);
12883 vat_json_init_object (locator);
12886 vat_json_object_add_uint (locator, "locator-index",
12893 clib_memcpy (&ip6, loc->ip_address, sizeof (ip6));
12894 vat_json_object_add_ip6 (locator, "locator", ip6);
12898 clib_memcpy (&ip4, loc->ip_address, sizeof (ip4));
12899 vat_json_object_add_ip4 (locator, "locator", ip4);
12902 vat_json_object_add_uint (locator, "priority", loc->priority);
12903 vat_json_object_add_uint (locator, "weight", loc->weight);
12906 vec_free (ls->locator_set_name);
12907 vec_free (vam->locator_msg);
12910 vat_json_print (vam->ofp, &vam->json_tree);
12911 vat_json_free (&vam->json_tree);
12912 vam->json_tree.type = VAT_JSON_NONE;
12914 vec_free (vam->locator_set_msg);
12920 get_locator_set_index_from_msg (vat_main_t * vam, u8 * locator_set,
12921 u32 * locator_set_index)
12923 locator_set_msg_t *ls;
12926 *locator_set_index = ~0;
12928 if (!vec_len (vam->locator_set_msg))
12933 vec_foreach (ls, vam->locator_set_msg)
12935 if (!strcmp ((char *) locator_set, (char *) ls->locator_set_name))
12937 *locator_set_index = ls->locator_set_index;
12938 vec_free (vam->locator_set_msg);
12943 vec_free (vam->locator_set_msg);
12949 get_locator_set_index (vat_main_t * vam, u8 * locator_set,
12950 u32 * locator_set_index)
12952 vl_api_lisp_locator_set_dump_t *mp;
12955 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
12959 /* Use a control ping for synchronization */
12961 vl_api_noprint_control_ping_t *mp;
12962 M (NOPRINT_CONTROL_PING, noprint_control_ping);
12966 vam->noprint_msg = 1;
12967 /* Wait for a reply... */
12971 get_locator_set_index_from_msg (vam, locator_set, locator_set_index);
12972 vam->noprint_msg = 0;
12981 lisp_locator_dump (vat_main_t * vam, u32 locator_set_index, u8 * locator_set,
12988 if (!vam->json_output)
12990 fformat (vam->ofp, "%=20s%=16s%=16s\n",
12991 "locator", "priority", "weight");
12996 ret = get_locator_set_index (vam, locator_set, &locator_set_index);
12999 if (!ret && ~0 == locator_set_index)
13004 ret = lisp_locator_dump_send_msg (vam, locator_set_index, filter);
13010 lisp_locator_set_dump (vat_main_t * vam, u8 filter)
13012 vl_api_lisp_locator_set_dump_t *mp;
13015 if (!vam->json_output)
13017 fformat (vam->ofp, "%=20s%=16s%=16s%=16s%=16s\n",
13018 "locator-set", "locator-set-index", "locator", "priority",
13022 vam->noprint_msg = 1;
13024 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
13026 mp->filter = filter;
13031 /* Use a control ping for synchronization */
13033 vl_api_noprint_control_ping_t *mp;
13034 M (NOPRINT_CONTROL_PING, noprint_control_ping);
13038 /* Wait for a reply... */
13042 if (vam->noprint_msg)
13044 if (!vam->json_output)
13046 print_locator_in_locator_set(vam, filter);
13050 json_locator_in_locator_set(vam, filter);
13053 vam->noprint_msg = 0;
13062 api_lisp_locator_set_dump (vat_main_t * vam)
13064 unformat_input_t *input = vam->input;
13065 vam->noprint_msg = 0;
13066 u32 locator_set_index = ~0;
13067 u8 locator_set_index_set = 0;
13068 u8 *locator_set = 0;
13069 u8 locator_set_set = 0;
13073 /* Parse args required to build the message */
13074 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13076 if (unformat (input, "locator-set-index %u", &locator_set_index))
13078 locator_set_index_set = 1;
13080 else if (unformat (input, "locator-set %s", &locator_set))
13082 locator_set_set = 1;
13084 else if (unformat (input, "local"))
13088 else if (unformat (input, "remote"))
13098 if (locator_set_index_set && locator_set_set)
13100 errmsg ("use only input parameter!\n");
13104 if (locator_set_index_set || locator_set_set)
13106 ret = lisp_locator_dump (vam, locator_set_index, locator_set, filter);
13110 ret = lisp_locator_set_dump (vam, filter);
13113 vec_free (locator_set);
13119 api_lisp_eid_table_map_dump (vat_main_t * vam)
13123 unformat_input_t *input = vam->input;
13124 vl_api_lisp_eid_table_map_dump_t *mp;
13127 /* Parse args required to build the message */
13128 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13130 if (unformat (input, "l2"))
13135 else if (unformat (input, "l3"))
13142 errmsg ("parse error '%U'", format_unformat_error, input);
13149 errmsg ("expected one of 'l2' or 'l3' parameter!\n");
13153 if (!vam->json_output)
13155 fformat (vam->ofp, "%=10s%=10s\n", "VNI", is_l2 ? "BD" : "VRF");
13158 M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump);
13164 /* Use a control ping for synchronization */
13166 vl_api_control_ping_t *mp;
13167 M (CONTROL_PING, control_ping);
13170 /* Wait for a reply... */
13178 api_lisp_eid_table_vni_dump (vat_main_t * vam)
13180 vl_api_lisp_eid_table_vni_dump_t *mp;
13183 if (!vam->json_output)
13185 fformat (vam->ofp, "VNI\n");
13188 M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
13193 /* Use a control ping for synchronization */
13195 vl_api_control_ping_t *mp;
13196 M (CONTROL_PING, control_ping);
13199 /* Wait for a reply... */
13207 get_locator_set (vat_main_t * vam)
13209 vl_api_lisp_locator_set_dump_t *mp;
13212 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
13216 /* Use a control ping for synchronization */
13218 vl_api_noprint_control_ping_t *mp;
13219 M (NOPRINT_CONTROL_PING, noprint_control_ping);
13223 /* Wait for a reply... */
13231 format_eid_for_eid_table (vat_main_t * vam, u8 * str, eid_table_t * eid_table,
13234 u8 *(*format_eid) (u8 *, va_list *) = 0;
13236 ASSERT (vam != NULL);
13237 ASSERT (eid_table != NULL);
13244 switch (eid_table->eid_type)
13248 format_eid = (eid_table->eid_type ? format_ip6_address :
13249 format_ip4_address);
13250 str = format (0, "[%d] %U/%d",
13251 clib_net_to_host_u32 (eid_table->vni),
13252 format_eid, eid_table->eid, eid_table->eid_prefix_len);
13255 str = format (0, "[%d] %U",
13256 clib_net_to_host_u32 (eid_table->vni),
13257 format_ethernet_address, eid_table->eid);
13260 errmsg ("unknown EID type %d!", eid_table->eid_type);
13272 format_locator_set_for_eid_table (vat_main_t * vam, u8 * str,
13273 eid_table_t * eid_table)
13275 locator_set_msg_t *ls = 0;
13277 ASSERT (vam != NULL);
13278 ASSERT (eid_table != NULL);
13280 if (eid_table->is_local)
13282 vec_foreach (ls, vam->locator_set_msg)
13284 if (ls->locator_set_index == eid_table->locator_set_index)
13286 str = format (0, "local(%s)", ls->locator_set_name);
13291 str = format (0, "local(N/A)");
13295 str = format (0, "remote");
13302 format_locator_for_eid_table (vat_main_t * vam, u8 * str,
13303 eid_table_t * eid_table)
13305 locator_msg_t *loc = 0;
13306 int first_line = 1;
13308 ASSERT (vam != NULL);
13309 ASSERT (eid_table != NULL);
13311 vec_foreach (loc, vam->locator_msg)
13317 str = format (str, "%-55s%-d\n", " ", loc->sw_if_index);
13321 str = format (str, "%=55s%-U\n", " ",
13322 loc->is_ipv6 ? format_ip6_address :
13323 format_ip4_address, loc->ip_address);
13331 str = format (str, "%-30d%-20u%-u\n", loc->sw_if_index,
13332 eid_table->ttl, eid_table->authoritative);
13336 str = format (str, "%-30U%-20u%-u\n",
13337 loc->is_ipv6 ? format_ip6_address :
13338 format_ip4_address,
13339 loc->ip_address, eid_table->ttl,
13340 eid_table->authoritative);
13349 print_lisp_eid_table_dump (vat_main_t * vam)
13351 eid_table_t *eid_table = 0;
13352 u8 *tmp_str = 0, *tmp_str2 = 0;
13355 ASSERT (vam != NULL);
13357 ret = get_locator_set (vam);
13360 vec_free (vam->eid_tables);
13364 fformat (vam->ofp, "%-35s%-20s%-30s%-20s%-s\n", "EID", "type", "locators",
13365 "ttl", "authoritative");
13367 vec_foreach (eid_table, vam->eid_tables)
13369 ret = lisp_locator_dump_send_msg (vam, eid_table->locator_set_index, 0);
13372 vec_free (vam->locator_msg);
13373 clean_locator_set_message (vam);
13374 vec_free (vam->eid_tables);
13378 tmp_str2 = format_eid_for_eid_table (vam, tmp_str2, eid_table, &ret);
13381 vec_free (vam->locator_msg);
13382 clean_locator_set_message (vam);
13383 vec_free (vam->eid_tables);
13387 tmp_str = format (0, "%-35s", tmp_str2);
13388 vec_free (tmp_str2);
13390 tmp_str2 = format_locator_set_for_eid_table (vam, tmp_str2, eid_table);
13391 tmp_str = format (tmp_str, "%-20s", tmp_str2);
13392 vec_free (tmp_str2);
13394 tmp_str2 = format_locator_for_eid_table (vam, tmp_str2, eid_table);
13395 tmp_str = format (tmp_str, "%-s", tmp_str2);
13396 vec_free (tmp_str2);
13398 fformat (vam->ofp, "%s", tmp_str);
13399 vec_free (tmp_str);
13400 vec_free (vam->locator_msg);
13403 clean_locator_set_message (vam);
13404 vec_free (vam->eid_tables);
13410 json_locator_set_for_eid_table (vat_main_t * vam, vat_json_node_t * node,
13411 eid_table_t * eid_table)
13413 locator_set_msg_t *ls = 0;
13416 ASSERT (vam != NULL);
13417 ASSERT (node != NULL);
13418 ASSERT (eid_table != NULL);
13420 if (eid_table->is_local)
13422 vec_foreach (ls, vam->locator_set_msg)
13424 if (ls->locator_set_index == eid_table->locator_set_index)
13426 vat_json_object_add_string_copy (node, "locator-set",
13427 ls->locator_set_name);
13432 s = format (0, "N/A");
13434 vat_json_object_add_string_copy (node, "locator-set", s);
13439 s = format (0, "remote");
13441 vat_json_object_add_string_copy (node, "locator-set", s);
13447 json_eid_for_eid_table (vat_main_t * vam, vat_json_node_t * node,
13448 eid_table_t * eid_table)
13451 struct in6_addr ip6;
13452 struct in_addr ip4;
13454 ASSERT (vam != NULL);
13455 ASSERT (node != NULL);
13456 ASSERT (eid_table != NULL);
13458 switch (eid_table->eid_type)
13461 clib_memcpy (&ip4, eid_table->eid, sizeof (ip4));
13462 vat_json_object_add_ip4 (node, "eid", ip4);
13463 vat_json_object_add_uint (node, "eid-prefix-len",
13464 eid_table->eid_prefix_len);
13467 clib_memcpy (&ip6, eid_table->eid, sizeof (ip6));
13468 vat_json_object_add_ip6 (node, "eid", ip6);
13469 vat_json_object_add_uint (node, "eid-prefix-len",
13470 eid_table->eid_prefix_len);
13473 s = format (0, "%U", format_ethernet_address, eid_table->eid);
13475 vat_json_object_add_string_copy (node, "eid", s);
13479 errmsg ("unknown EID type %d!", eid_table->eid_type);
13487 json_locator_for_eid_table (vat_main_t * vam, vat_json_node_t * node,
13488 eid_table_t * eid_table)
13490 locator_msg_t *loc = 0;
13491 vat_json_node_t *locator_array = 0;
13492 vat_json_node_t *locator = 0;
13493 struct in6_addr ip6;
13494 struct in_addr ip4;
13496 ASSERT (vam != NULL);
13497 ASSERT (node != NULL);
13498 ASSERT (eid_table != NULL);
13500 locator_array = vat_json_object_add_list (node, "locator");
13501 vec_foreach (loc, vam->locator_msg)
13503 locator = vat_json_array_add (locator_array);
13504 vat_json_init_object (locator);
13507 vat_json_object_add_uint (locator, "locator-index", loc->sw_if_index);
13513 clib_memcpy (&ip6, loc->ip_address, sizeof (ip6));
13514 vat_json_object_add_ip6 (locator, "locator", ip6);
13518 clib_memcpy (&ip4, loc->ip_address, sizeof (ip4));
13519 vat_json_object_add_ip4 (locator, "locator", ip4);
13526 json_lisp_eid_table_dump (vat_main_t * vam)
13528 eid_table_t *eid_table;
13529 vat_json_node_t *node = 0;
13532 ASSERT (vam != NULL);
13534 ret = get_locator_set (vam);
13537 vec_free (vam->eid_tables);
13541 if (!vec_len (vam->eid_tables))
13543 /* just print [] */
13544 vat_json_init_array (&vam->json_tree);
13545 vat_json_print (vam->ofp, &vam->json_tree);
13546 vam->json_tree.type = VAT_JSON_NONE;
13550 if (VAT_JSON_ARRAY != vam->json_tree.type)
13552 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13553 vat_json_init_array (&vam->json_tree);
13556 vec_foreach (eid_table, vam->eid_tables)
13558 ret = lisp_locator_dump_send_msg (vam, eid_table->locator_set_index, 0);
13561 vec_free (vam->locator_msg);
13562 vec_free (vam->eid_tables);
13563 clean_locator_set_message (vam);
13564 vat_json_free (&vam->json_tree);
13565 vam->json_tree.type = VAT_JSON_NONE;
13569 node = vat_json_array_add (&vam->json_tree);
13570 vat_json_init_object (node);
13572 vat_json_object_add_uint (node, "vni", eid_table->vni);
13574 json_locator_set_for_eid_table (vam, node, eid_table);
13575 ret = json_eid_for_eid_table (vam, node, eid_table);
13578 vec_free (vam->locator_msg);
13579 vec_free (vam->eid_tables);
13580 clean_locator_set_message (vam);
13581 vat_json_free (&vam->json_tree);
13582 vam->json_tree.type = VAT_JSON_NONE;
13586 json_locator_for_eid_table (vam, node, eid_table);
13588 vat_json_object_add_uint (node, "ttl", eid_table->ttl);
13589 vat_json_object_add_uint (node, "authoritative",
13590 eid_table->authoritative);
13592 vec_free (vam->locator_msg);
13595 vat_json_print (vam->ofp, &vam->json_tree);
13596 vat_json_free (&vam->json_tree);
13597 vam->json_tree.type = VAT_JSON_NONE;
13599 clean_locator_set_message (vam);
13600 vec_free (vam->eid_tables);
13606 api_lisp_eid_table_dump (vat_main_t * vam)
13608 unformat_input_t *i = vam->input;
13609 vl_api_lisp_eid_table_dump_t *mp;
13611 struct in_addr ip4;
13612 struct in6_addr ip6;
13614 u8 eid_type = ~0, eid_set = 0;
13615 u32 prefix_length = ~0, t, vni = 0;
13618 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13620 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
13626 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
13632 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
13637 else if (unformat (i, "vni %d", &t))
13641 else if (unformat (i, "local"))
13645 else if (unformat (i, "remote"))
13651 errmsg ("parse error '%U'", format_unformat_error, i);
13656 M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump);
13658 mp->filter = filter;
13662 mp->vni = htonl (vni);
13663 mp->eid_type = eid_type;
13667 mp->prefix_length = prefix_length;
13668 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
13671 mp->prefix_length = prefix_length;
13672 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
13675 clib_memcpy (mp->eid, mac, sizeof (mac));
13678 errmsg ("unknown EID type %d!", eid_type);
13683 vam->noprint_msg = 1;
13688 /* Use a control ping for synchronization */
13690 vl_api_noprint_control_ping_t *mp;
13691 M (NOPRINT_CONTROL_PING, noprint_control_ping);
13695 /* Wait for a reply... */
13699 if (vam->noprint_msg)
13701 if (!vam->json_output)
13703 vam->retval = print_lisp_eid_table_dump(vam);
13707 vam->retval = json_lisp_eid_table_dump(vam);
13710 vam->noprint_msg = 0;
13719 api_lisp_gpe_tunnel_dump (vat_main_t * vam)
13721 vl_api_lisp_gpe_tunnel_dump_t *mp;
13724 if (!vam->json_output)
13726 fformat (vam->ofp, "%=20s%=30s%=16s%=16s%=16s%=16s"
13727 "%=16s%=16s%=16s%=16s%=16s\n",
13728 "Tunel", "Source", "Destination", "Fib encap", "Fib decap",
13729 "Decap next", "Lisp version", "Flags", "Next protocol",
13730 "ver_res", "res", "iid");
13733 M (LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump);
13737 /* Use a control ping for synchronization */
13739 vl_api_control_ping_t *mp;
13740 M (CONTROL_PING, control_ping);
13743 /* Wait for a reply... */
13751 api_lisp_map_resolver_dump (vat_main_t * vam)
13753 vl_api_lisp_map_resolver_dump_t *mp;
13756 if (!vam->json_output)
13758 fformat (vam->ofp, "%=20s\n", "Map resolver");
13761 M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
13765 /* Use a control ping for synchronization */
13767 vl_api_control_ping_t *mp;
13768 M (CONTROL_PING, control_ping);
13771 /* Wait for a reply... */
13779 api_show_lisp_status (vat_main_t * vam)
13781 vl_api_show_lisp_status_t *mp;
13784 if (!vam->json_output)
13786 fformat (vam->ofp, "%-20s%-16s\n", "lisp status", "locator-set");
13789 M (SHOW_LISP_STATUS, show_lisp_status);
13792 /* Wait for a reply... */
13800 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
13802 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
13805 if (!vam->json_output)
13807 fformat (vam->ofp, "%=20s\n", "itr-rlocs:");
13810 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
13813 /* Wait for a reply... */
13821 api_af_packet_create (vat_main_t * vam)
13823 unformat_input_t *i = vam->input;
13824 vl_api_af_packet_create_t *mp;
13826 u8 *host_if_name = 0;
13828 u8 random_hw_addr = 1;
13830 memset (hw_addr, 0, sizeof (hw_addr));
13832 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13834 if (unformat (i, "name %s", &host_if_name))
13835 vec_add1 (host_if_name, 0);
13836 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
13837 random_hw_addr = 0;
13842 if (!vec_len (host_if_name))
13844 errmsg ("host-interface name must be specified");
13848 if (vec_len (host_if_name) > 64)
13850 errmsg ("host-interface name too long");
13854 M (AF_PACKET_CREATE, af_packet_create);
13856 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
13857 clib_memcpy (mp->hw_addr, hw_addr, 6);
13858 mp->use_random_hw_addr = random_hw_addr;
13859 vec_free (host_if_name);
13862 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
13868 api_af_packet_delete (vat_main_t * vam)
13870 unformat_input_t *i = vam->input;
13871 vl_api_af_packet_delete_t *mp;
13873 u8 *host_if_name = 0;
13875 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13877 if (unformat (i, "name %s", &host_if_name))
13878 vec_add1 (host_if_name, 0);
13883 if (!vec_len (host_if_name))
13885 errmsg ("host-interface name must be specified");
13889 if (vec_len (host_if_name) > 64)
13891 errmsg ("host-interface name too long");
13895 M (AF_PACKET_DELETE, af_packet_delete);
13897 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
13898 vec_free (host_if_name);
13907 api_policer_add_del (vat_main_t * vam)
13909 unformat_input_t *i = vam->input;
13910 vl_api_policer_add_del_t *mp;
13921 u8 color_aware = 0;
13922 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
13924 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
13925 conform_action.dscp = 0;
13926 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
13927 exceed_action.dscp = 0;
13928 violate_action.action_type = SSE2_QOS_ACTION_DROP;
13929 violate_action.dscp = 0;
13931 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13933 if (unformat (i, "del"))
13935 else if (unformat (i, "name %s", &name))
13936 vec_add1 (name, 0);
13937 else if (unformat (i, "cir %u", &cir))
13939 else if (unformat (i, "eir %u", &eir))
13941 else if (unformat (i, "cb %u", &cb))
13943 else if (unformat (i, "eb %u", &eb))
13945 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
13948 else if (unformat (i, "round_type %U", unformat_policer_round_type,
13951 else if (unformat (i, "type %U", unformat_policer_type, &type))
13953 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
13956 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
13959 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
13962 else if (unformat (i, "color-aware"))
13968 if (!vec_len (name))
13970 errmsg ("policer name must be specified");
13974 if (vec_len (name) > 64)
13976 errmsg ("policer name too long");
13980 M (POLICER_ADD_DEL, policer_add_del);
13982 clib_memcpy (mp->name, name, vec_len (name));
13984 mp->is_add = is_add;
13989 mp->rate_type = rate_type;
13990 mp->round_type = round_type;
13992 mp->conform_action_type = conform_action.action_type;
13993 mp->conform_dscp = conform_action.dscp;
13994 mp->exceed_action_type = exceed_action.action_type;
13995 mp->exceed_dscp = exceed_action.dscp;
13996 mp->violate_action_type = violate_action.action_type;
13997 mp->violate_dscp = violate_action.dscp;
13998 mp->color_aware = color_aware;
14007 api_policer_dump (vat_main_t * vam)
14009 unformat_input_t *i = vam->input;
14010 vl_api_policer_dump_t *mp;
14012 u8 *match_name = 0;
14013 u8 match_name_valid = 0;
14015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14017 if (unformat (i, "name %s", &match_name))
14019 vec_add1 (match_name, 0);
14020 match_name_valid = 1;
14026 M (POLICER_DUMP, policer_dump);
14027 mp->match_name_valid = match_name_valid;
14028 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
14029 vec_free (match_name);
14033 /* Use a control ping for synchronization */
14035 vl_api_control_ping_t *mp;
14036 M (CONTROL_PING, control_ping);
14039 /* Wait for a reply... */
14047 api_policer_classify_set_interface (vat_main_t * vam)
14049 unformat_input_t *i = vam->input;
14050 vl_api_policer_classify_set_interface_t *mp;
14053 int sw_if_index_set;
14054 u32 ip4_table_index = ~0;
14055 u32 ip6_table_index = ~0;
14056 u32 l2_table_index = ~0;
14059 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14061 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
14062 sw_if_index_set = 1;
14063 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14064 sw_if_index_set = 1;
14065 else if (unformat (i, "del"))
14067 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14069 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14071 else if (unformat (i, "l2-table %d", &l2_table_index))
14075 clib_warning ("parse error '%U'", format_unformat_error, i);
14080 if (sw_if_index_set == 0)
14082 errmsg ("missing interface name or sw_if_index\n");
14086 M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface);
14088 mp->sw_if_index = ntohl (sw_if_index);
14089 mp->ip4_table_index = ntohl (ip4_table_index);
14090 mp->ip6_table_index = ntohl (ip6_table_index);
14091 mp->l2_table_index = ntohl (l2_table_index);
14092 mp->is_add = is_add;
14101 api_policer_classify_dump (vat_main_t * vam)
14103 unformat_input_t *i = vam->input;
14104 vl_api_policer_classify_dump_t *mp;
14106 u8 type = POLICER_CLASSIFY_N_TABLES;
14108 if (unformat (i, "type %U", unformat_classify_table_type, &type))
14112 errmsg ("classify table type must be specified\n");
14116 if (!vam->json_output)
14118 fformat (vam->ofp, "%10s%20s\n", "Intfc idx", "Classify table");
14121 M (POLICER_CLASSIFY_DUMP, policer_classify_dump);
14126 /* Use a control ping for synchronization */
14128 vl_api_control_ping_t *mp;
14129 M (CONTROL_PING, control_ping);
14132 /* Wait for a reply... */
14140 api_netmap_create (vat_main_t * vam)
14142 unformat_input_t *i = vam->input;
14143 vl_api_netmap_create_t *mp;
14147 u8 random_hw_addr = 1;
14151 memset (hw_addr, 0, sizeof (hw_addr));
14153 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14155 if (unformat (i, "name %s", &if_name))
14156 vec_add1 (if_name, 0);
14157 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14158 random_hw_addr = 0;
14159 else if (unformat (i, "pipe"))
14161 else if (unformat (i, "master"))
14163 else if (unformat (i, "slave"))
14169 if (!vec_len (if_name))
14171 errmsg ("interface name must be specified");
14175 if (vec_len (if_name) > 64)
14177 errmsg ("interface name too long");
14181 M (NETMAP_CREATE, netmap_create);
14183 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
14184 clib_memcpy (mp->hw_addr, hw_addr, 6);
14185 mp->use_random_hw_addr = random_hw_addr;
14186 mp->is_pipe = is_pipe;
14187 mp->is_master = is_master;
14188 vec_free (if_name);
14197 api_netmap_delete (vat_main_t * vam)
14199 unformat_input_t *i = vam->input;
14200 vl_api_netmap_delete_t *mp;
14204 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14206 if (unformat (i, "name %s", &if_name))
14207 vec_add1 (if_name, 0);
14212 if (!vec_len (if_name))
14214 errmsg ("interface name must be specified");
14218 if (vec_len (if_name) > 64)
14220 errmsg ("interface name too long");
14224 M (NETMAP_DELETE, netmap_delete);
14226 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
14227 vec_free (if_name);
14235 static void vl_api_mpls_gre_tunnel_details_t_handler
14236 (vl_api_mpls_gre_tunnel_details_t * mp)
14238 vat_main_t *vam = &vat_main;
14240 i32 len = ntohl (mp->nlabels);
14242 if (mp->l2_only == 0)
14244 fformat (vam->ofp, "[%d]: src %U, dst %U, adj %U/%d, labels ",
14245 ntohl (mp->tunnel_index),
14246 format_ip4_address, &mp->tunnel_src,
14247 format_ip4_address, &mp->tunnel_dst,
14248 format_ip4_address, &mp->intfc_address,
14249 ntohl (mp->mask_width));
14250 for (i = 0; i < len; i++)
14252 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14254 fformat (vam->ofp, "\n");
14255 fformat (vam->ofp, " inner fib index %d, outer fib index %d\n",
14256 ntohl (mp->inner_fib_index), ntohl (mp->outer_fib_index));
14260 fformat (vam->ofp, "[%d]: src %U, dst %U, key %U, labels ",
14261 ntohl (mp->tunnel_index),
14262 format_ip4_address, &mp->tunnel_src,
14263 format_ip4_address, &mp->tunnel_dst,
14264 format_ip4_address, &mp->intfc_address);
14265 for (i = 0; i < len; i++)
14267 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14269 fformat (vam->ofp, "\n");
14270 fformat (vam->ofp, " l2 interface %d, outer fib index %d\n",
14271 ntohl (mp->hw_if_index), ntohl (mp->outer_fib_index));
14275 static void vl_api_mpls_gre_tunnel_details_t_handler_json
14276 (vl_api_mpls_gre_tunnel_details_t * mp)
14278 vat_main_t *vam = &vat_main;
14279 vat_json_node_t *node = NULL;
14280 struct in_addr ip4;
14282 i32 len = ntohl (mp->nlabels);
14284 if (VAT_JSON_ARRAY != vam->json_tree.type)
14286 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14287 vat_json_init_array (&vam->json_tree);
14289 node = vat_json_array_add (&vam->json_tree);
14291 vat_json_init_object (node);
14292 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
14293 clib_memcpy (&ip4, &(mp->intfc_address), sizeof (ip4));
14294 vat_json_object_add_ip4 (node, "intfc_address", ip4);
14295 vat_json_object_add_uint (node, "inner_fib_index",
14296 ntohl (mp->inner_fib_index));
14297 vat_json_object_add_uint (node, "mask_width", ntohl (mp->mask_width));
14298 vat_json_object_add_uint (node, "encap_index", ntohl (mp->encap_index));
14299 vat_json_object_add_uint (node, "hw_if_index", ntohl (mp->hw_if_index));
14300 vat_json_object_add_uint (node, "l2_only", ntohl (mp->l2_only));
14301 clib_memcpy (&ip4, &(mp->tunnel_src), sizeof (ip4));
14302 vat_json_object_add_ip4 (node, "tunnel_src", ip4);
14303 clib_memcpy (&ip4, &(mp->tunnel_dst), sizeof (ip4));
14304 vat_json_object_add_ip4 (node, "tunnel_dst", ip4);
14305 vat_json_object_add_uint (node, "outer_fib_index",
14306 ntohl (mp->outer_fib_index));
14307 vat_json_object_add_uint (node, "label_count", len);
14308 for (i = 0; i < len; i++)
14310 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14315 api_mpls_gre_tunnel_dump (vat_main_t * vam)
14317 vl_api_mpls_gre_tunnel_dump_t *mp;
14321 /* Parse args required to build the message */
14322 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
14324 if (!unformat (vam->input, "tunnel_index %d", &index))
14331 fformat (vam->ofp, " tunnel_index %d\n", index);
14333 M (MPLS_GRE_TUNNEL_DUMP, mpls_gre_tunnel_dump);
14334 mp->tunnel_index = htonl (index);
14337 /* Use a control ping for synchronization */
14339 vl_api_control_ping_t *mp;
14340 M (CONTROL_PING, control_ping);
14346 static void vl_api_mpls_eth_tunnel_details_t_handler
14347 (vl_api_mpls_eth_tunnel_details_t * mp)
14349 vat_main_t *vam = &vat_main;
14351 i32 len = ntohl (mp->nlabels);
14353 fformat (vam->ofp, "[%d]: dst %U, adj %U/%d, labels ",
14354 ntohl (mp->tunnel_index),
14355 format_ethernet_address, &mp->tunnel_dst_mac,
14356 format_ip4_address, &mp->intfc_address, ntohl (mp->mask_width));
14357 for (i = 0; i < len; i++)
14359 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14361 fformat (vam->ofp, "\n");
14362 fformat (vam->ofp, " tx on %d, rx fib index %d\n",
14363 ntohl (mp->tx_sw_if_index), ntohl (mp->inner_fib_index));
14366 static void vl_api_mpls_eth_tunnel_details_t_handler_json
14367 (vl_api_mpls_eth_tunnel_details_t * mp)
14369 vat_main_t *vam = &vat_main;
14370 vat_json_node_t *node = NULL;
14371 struct in_addr ip4;
14373 i32 len = ntohl (mp->nlabels);
14375 if (VAT_JSON_ARRAY != vam->json_tree.type)
14377 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14378 vat_json_init_array (&vam->json_tree);
14380 node = vat_json_array_add (&vam->json_tree);
14382 vat_json_init_object (node);
14383 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
14384 clib_memcpy (&ip4, &(mp->intfc_address), sizeof (ip4));
14385 vat_json_object_add_ip4 (node, "intfc_address", ip4);
14386 vat_json_object_add_uint (node, "inner_fib_index",
14387 ntohl (mp->inner_fib_index));
14388 vat_json_object_add_uint (node, "mask_width", ntohl (mp->mask_width));
14389 vat_json_object_add_uint (node, "encap_index", ntohl (mp->encap_index));
14390 vat_json_object_add_uint (node, "hw_if_index", ntohl (mp->hw_if_index));
14391 vat_json_object_add_uint (node, "l2_only", ntohl (mp->l2_only));
14392 vat_json_object_add_string_copy (node, "tunnel_dst_mac",
14393 format (0, "%U", format_ethernet_address,
14394 &mp->tunnel_dst_mac));
14395 vat_json_object_add_uint (node, "tx_sw_if_index",
14396 ntohl (mp->tx_sw_if_index));
14397 vat_json_object_add_uint (node, "label_count", len);
14398 for (i = 0; i < len; i++)
14400 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14405 api_mpls_eth_tunnel_dump (vat_main_t * vam)
14407 vl_api_mpls_eth_tunnel_dump_t *mp;
14411 /* Parse args required to build the message */
14412 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
14414 if (!unformat (vam->input, "tunnel_index %d", &index))
14421 fformat (vam->ofp, " tunnel_index %d\n", index);
14423 M (MPLS_ETH_TUNNEL_DUMP, mpls_eth_tunnel_dump);
14424 mp->tunnel_index = htonl (index);
14427 /* Use a control ping for synchronization */
14429 vl_api_control_ping_t *mp;
14430 M (CONTROL_PING, control_ping);
14436 static void vl_api_mpls_fib_encap_details_t_handler
14437 (vl_api_mpls_fib_encap_details_t * mp)
14439 vat_main_t *vam = &vat_main;
14441 i32 len = ntohl (mp->nlabels);
14443 fformat (vam->ofp, "table %d, dest %U, label ",
14444 ntohl (mp->fib_index), format_ip4_address, &mp->dest, len);
14445 for (i = 0; i < len; i++)
14447 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14449 fformat (vam->ofp, "\n");
14452 static void vl_api_mpls_fib_encap_details_t_handler_json
14453 (vl_api_mpls_fib_encap_details_t * mp)
14455 vat_main_t *vam = &vat_main;
14456 vat_json_node_t *node = NULL;
14458 i32 len = ntohl (mp->nlabels);
14459 struct in_addr ip4;
14461 if (VAT_JSON_ARRAY != vam->json_tree.type)
14463 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14464 vat_json_init_array (&vam->json_tree);
14466 node = vat_json_array_add (&vam->json_tree);
14468 vat_json_init_object (node);
14469 vat_json_object_add_uint (node, "table", ntohl (mp->fib_index));
14470 vat_json_object_add_uint (node, "entry_index", ntohl (mp->entry_index));
14471 clib_memcpy (&ip4, &(mp->dest), sizeof (ip4));
14472 vat_json_object_add_ip4 (node, "dest", ip4);
14473 vat_json_object_add_uint (node, "s_bit", ntohl (mp->s_bit));
14474 vat_json_object_add_uint (node, "label_count", len);
14475 for (i = 0; i < len; i++)
14477 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14482 api_mpls_fib_encap_dump (vat_main_t * vam)
14484 vl_api_mpls_fib_encap_dump_t *mp;
14487 M (MPLS_FIB_ENCAP_DUMP, mpls_fib_encap_dump);
14490 /* Use a control ping for synchronization */
14492 vl_api_control_ping_t *mp;
14493 M (CONTROL_PING, control_ping);
14499 static void vl_api_mpls_fib_decap_details_t_handler
14500 (vl_api_mpls_fib_decap_details_t * mp)
14502 vat_main_t *vam = &vat_main;
14505 "RX table %d, TX table/intfc %u, swif_tag '%s', label %u, s_bit %u\n",
14506 ntohl (mp->rx_table_id), ntohl (mp->tx_table_id), mp->swif_tag,
14507 ntohl (mp->label), ntohl (mp->s_bit));
14510 static void vl_api_mpls_fib_decap_details_t_handler_json
14511 (vl_api_mpls_fib_decap_details_t * mp)
14513 vat_main_t *vam = &vat_main;
14514 vat_json_node_t *node = NULL;
14515 struct in_addr ip4;
14517 if (VAT_JSON_ARRAY != vam->json_tree.type)
14519 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14520 vat_json_init_array (&vam->json_tree);
14522 node = vat_json_array_add (&vam->json_tree);
14524 vat_json_init_object (node);
14525 vat_json_object_add_uint (node, "table", ntohl (mp->fib_index));
14526 vat_json_object_add_uint (node, "entry_index", ntohl (mp->entry_index));
14527 clib_memcpy (&ip4, &(mp->dest), sizeof (ip4));
14528 vat_json_object_add_ip4 (node, "dest", ip4);
14529 vat_json_object_add_uint (node, "s_bit", ntohl (mp->s_bit));
14530 vat_json_object_add_uint (node, "label", ntohl (mp->label));
14531 vat_json_object_add_uint (node, "rx_table_id", ntohl (mp->rx_table_id));
14532 vat_json_object_add_uint (node, "tx_table_id", ntohl (mp->tx_table_id));
14533 vat_json_object_add_string_copy (node, "swif_tag", mp->swif_tag);
14537 api_mpls_fib_decap_dump (vat_main_t * vam)
14539 vl_api_mpls_fib_decap_dump_t *mp;
14542 M (MPLS_FIB_DECAP_DUMP, mpls_fib_decap_dump);
14545 /* Use a control ping for synchronization */
14547 vl_api_control_ping_t *mp;
14548 M (CONTROL_PING, control_ping);
14555 api_classify_table_ids (vat_main_t * vam)
14557 vl_api_classify_table_ids_t *mp;
14560 /* Construct the API message */
14561 M (CLASSIFY_TABLE_IDS, classify_table_ids);
14571 api_classify_table_by_interface (vat_main_t * vam)
14573 unformat_input_t *input = vam->input;
14574 vl_api_classify_table_by_interface_t *mp;
14577 u32 sw_if_index = ~0;
14578 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14580 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
14582 else if (unformat (input, "sw_if_index %d", &sw_if_index))
14587 if (sw_if_index == ~0)
14589 errmsg ("missing interface name or sw_if_index\n");
14593 /* Construct the API message */
14594 M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
14596 mp->sw_if_index = ntohl (sw_if_index);
14605 api_classify_table_info (vat_main_t * vam)
14607 unformat_input_t *input = vam->input;
14608 vl_api_classify_table_info_t *mp;
14612 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14614 if (unformat (input, "table_id %d", &table_id))
14619 if (table_id == ~0)
14621 errmsg ("missing table id\n");
14625 /* Construct the API message */
14626 M (CLASSIFY_TABLE_INFO, classify_table_info);
14628 mp->table_id = ntohl (table_id);
14637 api_classify_session_dump (vat_main_t * vam)
14639 unformat_input_t *input = vam->input;
14640 vl_api_classify_session_dump_t *mp;
14644 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14646 if (unformat (input, "table_id %d", &table_id))
14651 if (table_id == ~0)
14653 errmsg ("missing table id\n");
14657 /* Construct the API message */
14658 M (CLASSIFY_SESSION_DUMP, classify_session_dump);
14660 mp->table_id = ntohl (table_id);
14663 /* Use a control ping for synchronization */
14665 vl_api_control_ping_t *mp;
14666 M (CONTROL_PING, control_ping);
14675 vl_api_ipfix_details_t_handler (vl_api_ipfix_details_t * mp)
14677 vat_main_t *vam = &vat_main;
14679 fformat (vam->ofp, "collector_address %U, collector_port %d, "
14680 "src_address %U, fib_index %u, path_mtu %u, "
14681 "template_interval %u\n",
14682 format_ip4_address, mp->collector_address,
14683 ntohs (mp->collector_port),
14684 format_ip4_address, mp->src_address,
14685 ntohl (mp->fib_index),
14686 ntohl (mp->path_mtu), ntohl (mp->template_interval));
14689 vam->result_ready = 1;
14693 vl_api_ipfix_details_t_handler_json (vl_api_ipfix_details_t * mp)
14695 vat_main_t *vam = &vat_main;
14696 vat_json_node_t node;
14697 struct in_addr collector_address;
14698 struct in_addr src_address;
14700 vat_json_init_object (&node);
14701 clib_memcpy (&collector_address, &mp->collector_address,
14702 sizeof (collector_address));
14703 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
14704 vat_json_object_add_uint (&node, "collector_port",
14705 ntohs (mp->collector_port));
14706 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
14707 vat_json_object_add_ip4 (&node, "src_address", src_address);
14708 vat_json_object_add_uint (&node, "fib_index", ntohl (mp->fib_index));
14709 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
14710 vat_json_object_add_uint (&node, "template_interval",
14711 ntohl (mp->template_interval));
14713 vat_json_print (vam->ofp, &node);
14714 vat_json_free (&node);
14716 vam->result_ready = 1;
14720 api_ipfix_dump (vat_main_t * vam)
14722 vl_api_ipfix_dump_t *mp;
14725 /* Construct the API message */
14726 M (IPFIX_DUMP, ipfix_dump);
14736 api_pg_create_interface (vat_main_t * vam)
14738 unformat_input_t *input = vam->input;
14739 vl_api_pg_create_interface_t *mp;
14743 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14745 if (unformat (input, "if_id %d", &if_id))
14752 errmsg ("missing pg interface index\n");
14756 /* Construct the API message */
14757 M (PG_CREATE_INTERFACE, pg_create_interface);
14759 mp->interface_id = ntohl (if_id);
14768 api_pg_capture (vat_main_t * vam)
14770 unformat_input_t *input = vam->input;
14771 vl_api_pg_capture_t *mp;
14777 u8 pcap_file_set = 0;
14779 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14781 if (unformat (input, "if_id %d", &if_id))
14783 else if (unformat (input, "pcap %s", &pcap_file))
14785 else if (unformat (input, "count %d", &count))
14787 else if (unformat (input, "disable"))
14794 errmsg ("missing pg interface index\n");
14797 if (pcap_file_set > 0)
14799 if (vec_len (pcap_file) > 255)
14801 errmsg ("pcap file name is too long\n");
14806 u32 name_len = vec_len (pcap_file);
14807 /* Construct the API message */
14808 M (PG_CAPTURE, pg_capture);
14810 mp->interface_id = ntohl (if_id);
14811 mp->is_enabled = enable;
14812 mp->count = ntohl (count);
14813 mp->pcap_name_length = ntohl (name_len);
14814 if (pcap_file_set != 0)
14816 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
14818 vec_free (pcap_file);
14827 api_pg_enable_disable (vat_main_t * vam)
14829 unformat_input_t *input = vam->input;
14830 vl_api_pg_enable_disable_t *mp;
14834 u8 stream_name_set = 0;
14835 u8 *stream_name = 0;
14836 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14838 if (unformat (input, "stream %s", &stream_name))
14839 stream_name_set = 1;
14840 else if (unformat (input, "disable"))
14846 if (stream_name_set > 0)
14848 if (vec_len (stream_name) > 255)
14850 errmsg ("stream name too long\n");
14855 u32 name_len = vec_len (stream_name);
14856 /* Construct the API message */
14857 M (PG_ENABLE_DISABLE, pg_enable_disable);
14859 mp->is_enabled = enable;
14860 if (stream_name_set != 0)
14862 mp->stream_name_length = ntohl (name_len);
14863 clib_memcpy (mp->stream_name, stream_name, name_len);
14865 vec_free (stream_name);
14874 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
14876 unformat_input_t *input = vam->input;
14877 vl_api_ip_source_and_port_range_check_add_del_t *mp;
14880 u16 *low_ports = 0;
14881 u16 *high_ports = 0;
14884 ip4_address_t ip4_addr;
14885 ip6_address_t ip6_addr;
14893 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14895 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
14901 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
14906 else if (unformat (input, "vrf %d", &vrf_id))
14908 else if (unformat (input, "del"))
14910 else if (unformat (input, "port %d", &tmp))
14912 if (tmp == 0 || tmp > 65535)
14914 errmsg ("port %d out of range", tmp);
14918 this_hi = this_low + 1;
14919 vec_add1 (low_ports, this_low);
14920 vec_add1 (high_ports, this_hi);
14922 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
14924 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
14926 errmsg ("incorrect range parameters\n");
14930 /* Note: in debug CLI +1 is added to high before
14931 passing to real fn that does "the work"
14932 (ip_source_and_port_range_check_add_del).
14933 This fn is a wrapper around the binary API fn a
14934 control plane will call, which expects this increment
14935 to have occurred. Hence letting the binary API control
14936 plane fn do the increment for consistency between VAT
14937 and other control planes.
14940 vec_add1 (low_ports, this_low);
14941 vec_add1 (high_ports, this_hi);
14947 if (prefix_set == 0)
14949 errmsg ("<address>/<mask> not specified\n");
14955 errmsg ("VRF ID required, not specified\n");
14962 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
14966 if (vec_len (low_ports) == 0)
14968 errmsg ("At least one port or port range required\n");
14972 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,
14973 ip_source_and_port_range_check_add_del);
14975 mp->is_add = is_add;
14980 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
14985 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
14988 mp->mask_length = length;
14989 mp->number_of_ranges = vec_len (low_ports);
14991 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
14992 vec_free (low_ports);
14994 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
14995 vec_free (high_ports);
14997 mp->vrf_id = ntohl (vrf_id);
15006 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
15008 unformat_input_t *input = vam->input;
15009 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
15011 u32 sw_if_index = ~0;
15013 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
15014 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
15017 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15019 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
15021 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15023 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
15025 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
15027 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
15029 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
15031 else if (unformat (input, "del"))
15037 if (sw_if_index == ~0)
15039 errmsg ("Interface required but not specified\n");
15045 errmsg ("VRF ID required but not specified\n");
15049 if (tcp_out_vrf_id == 0
15050 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
15053 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
15057 /* Construct the API message */
15058 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,
15059 ip_source_and_port_range_check_interface_add_del);
15061 mp->sw_if_index = ntohl (sw_if_index);
15062 mp->is_add = is_add;
15063 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
15064 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
15065 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
15066 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
15071 /* Wait for a reply... */
15076 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
15078 unformat_input_t *i = vam->input;
15079 vl_api_ipsec_gre_add_del_tunnel_t *mp;
15081 u32 local_sa_id = 0;
15082 u32 remote_sa_id = 0;
15083 ip4_address_t src_address;
15084 ip4_address_t dst_address;
15087 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15089 if (unformat (i, "local_sa %d", &local_sa_id))
15091 else if (unformat (i, "remote_sa %d", &remote_sa_id))
15093 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
15095 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
15097 else if (unformat (i, "del"))
15101 clib_warning ("parse error '%U'", format_unformat_error, i);
15106 M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel);
15108 mp->local_sa_id = ntohl (local_sa_id);
15109 mp->remote_sa_id = ntohl (remote_sa_id);
15110 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
15111 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
15112 mp->is_add = is_add;
15120 static void vl_api_ipsec_gre_tunnel_details_t_handler
15121 (vl_api_ipsec_gre_tunnel_details_t * mp)
15123 vat_main_t *vam = &vat_main;
15125 fformat (vam->ofp, "%11d%15U%15U%14d%14d\n",
15126 ntohl (mp->sw_if_index),
15127 format_ip4_address, &mp->src_address,
15128 format_ip4_address, &mp->dst_address,
15129 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
15132 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
15133 (vl_api_ipsec_gre_tunnel_details_t * mp)
15135 vat_main_t *vam = &vat_main;
15136 vat_json_node_t *node = NULL;
15137 struct in_addr ip4;
15139 if (VAT_JSON_ARRAY != vam->json_tree.type)
15141 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15142 vat_json_init_array (&vam->json_tree);
15144 node = vat_json_array_add (&vam->json_tree);
15146 vat_json_init_object (node);
15147 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15148 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
15149 vat_json_object_add_ip4 (node, "src_address", ip4);
15150 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
15151 vat_json_object_add_ip4 (node, "dst_address", ip4);
15152 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
15153 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
15157 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
15159 unformat_input_t *i = vam->input;
15160 vl_api_ipsec_gre_tunnel_dump_t *mp;
15163 u8 sw_if_index_set = 0;
15165 /* Parse args required to build the message */
15166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15168 if (unformat (i, "sw_if_index %d", &sw_if_index))
15169 sw_if_index_set = 1;
15174 if (sw_if_index_set == 0)
15179 if (!vam->json_output)
15181 fformat (vam->ofp, "%11s%15s%15s%14s%14s\n",
15182 "sw_if_index", "src_address", "dst_address",
15183 "local_sa_id", "remote_sa_id");
15186 /* Get list of gre-tunnel interfaces */
15187 M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump);
15189 mp->sw_if_index = htonl (sw_if_index);
15193 /* Use a control ping for synchronization */
15195 vl_api_control_ping_t *mp;
15196 M (CONTROL_PING, control_ping);
15203 q_or_quit (vat_main_t * vam)
15205 longjmp (vam->jump_buf, 1);
15206 return 0; /* not so much */
15210 q (vat_main_t * vam)
15212 return q_or_quit (vam);
15216 quit (vat_main_t * vam)
15218 return q_or_quit (vam);
15222 comment (vat_main_t * vam)
15228 cmd_cmp (void *a1, void *a2)
15233 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
15237 help (vat_main_t * vam)
15242 unformat_input_t *i = vam->input;
15245 if (unformat (i, "%s", &name))
15249 vec_add1 (name, 0);
15251 hs = hash_get_mem (vam->help_by_name, name);
15253 fformat (vam->ofp, "usage: %s %s\n", name, hs[0]);
15255 fformat (vam->ofp, "No such msg / command '%s'\n", name);
15260 fformat (vam->ofp, "Help is available for the following:\n");
15263 hash_foreach_pair (p, vam->function_by_name,
15265 vec_add1 (cmds, (u8 *)(p->key));
15269 vec_sort_with_function (cmds, cmd_cmp);
15271 for (j = 0; j < vec_len (cmds); j++)
15272 fformat (vam->ofp, "%s\n", cmds[j]);
15279 set (vat_main_t * vam)
15281 u8 *name = 0, *value = 0;
15282 unformat_input_t *i = vam->input;
15284 if (unformat (i, "%s", &name))
15286 /* The input buffer is a vector, not a string. */
15287 value = vec_dup (i->buffer);
15288 vec_delete (value, i->index, 0);
15289 /* Almost certainly has a trailing newline */
15290 if (value[vec_len (value) - 1] == '\n')
15291 value[vec_len (value) - 1] = 0;
15292 /* Make sure it's a proper string, one way or the other */
15293 vec_add1 (value, 0);
15294 (void) clib_macro_set_value (&vam->macro_main,
15295 (char *) name, (char *) value);
15298 errmsg ("usage: set <name> <value>\n");
15306 unset (vat_main_t * vam)
15310 if (unformat (vam->input, "%s", &name))
15311 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
15312 errmsg ("unset: %s wasn't set\n", name);
15325 macro_sort_cmp (void *a1, void *a2)
15327 macro_sort_t *s1 = a1;
15328 macro_sort_t *s2 = a2;
15330 return strcmp ((char *) (s1->name), (char *) (s2->name));
15334 dump_macro_table (vat_main_t * vam)
15336 macro_sort_t *sort_me = 0, *sm;
15341 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
15343 vec_add2 (sort_me, sm, 1);
15344 sm->name = (u8 *)(p->key);
15345 sm->value = (u8 *) (p->value[0]);
15349 vec_sort_with_function (sort_me, macro_sort_cmp);
15351 if (vec_len (sort_me))
15352 fformat (vam->ofp, "%-15s%s\n", "Name", "Value");
15354 fformat (vam->ofp, "The macro table is empty...\n");
15356 for (i = 0; i < vec_len (sort_me); i++)
15357 fformat (vam->ofp, "%-15s%s\n", sort_me[i].name, sort_me[i].value);
15362 dump_node_table (vat_main_t * vam)
15365 vlib_node_t *node, *next_node;
15367 if (vec_len (vam->graph_nodes) == 0)
15369 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
15373 for (i = 0; i < vec_len (vam->graph_nodes); i++)
15375 node = vam->graph_nodes[i];
15376 fformat (vam->ofp, "[%d] %s\n", i, node->name);
15377 for (j = 0; j < vec_len (node->next_nodes); j++)
15379 if (node->next_nodes[j] != ~0)
15381 next_node = vam->graph_nodes[node->next_nodes[j]];
15382 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
15390 search_node_table (vat_main_t * vam)
15392 unformat_input_t *line_input = vam->input;
15395 vlib_node_t *node, *next_node;
15398 if (vam->graph_node_index_by_name == 0)
15400 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
15404 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15406 if (unformat (line_input, "%s", &node_to_find))
15408 vec_add1 (node_to_find, 0);
15409 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
15412 fformat (vam->ofp, "%s not found...\n", node_to_find);
15415 node = vam->graph_nodes[p[0]];
15416 fformat (vam->ofp, "[%d] %s\n", p[0], node->name);
15417 for (j = 0; j < vec_len (node->next_nodes); j++)
15419 if (node->next_nodes[j] != ~0)
15421 next_node = vam->graph_nodes[node->next_nodes[j]];
15422 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
15429 clib_warning ("parse error '%U'", format_unformat_error,
15435 vec_free (node_to_find);
15444 script (vat_main_t * vam)
15447 char *save_current_file;
15448 unformat_input_t save_input;
15449 jmp_buf save_jump_buf;
15450 u32 save_line_number;
15452 FILE *new_fp, *save_ifp;
15454 if (unformat (vam->input, "%s", &s))
15456 new_fp = fopen ((char *) s, "r");
15459 errmsg ("Couldn't open script file %s\n", s);
15466 errmsg ("Missing script name\n");
15470 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
15471 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
15472 save_ifp = vam->ifp;
15473 save_line_number = vam->input_line_number;
15474 save_current_file = (char *) vam->current_file;
15476 vam->input_line_number = 0;
15478 vam->current_file = s;
15481 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
15482 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
15483 vam->ifp = save_ifp;
15484 vam->input_line_number = save_line_number;
15485 vam->current_file = (u8 *) save_current_file;
15492 echo (vat_main_t * vam)
15494 fformat (vam->ofp, "%v", vam->input->buffer);
15498 /* List of API message constructors, CLI names map to api_xxx */
15499 #define foreach_vpe_api_msg \
15500 _(create_loopback,"[mac <mac-addr>]") \
15501 _(sw_interface_dump,"") \
15502 _(sw_interface_set_flags, \
15503 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
15504 _(sw_interface_add_del_address, \
15505 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
15506 _(sw_interface_set_table, \
15507 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
15508 _(sw_interface_set_vpath, \
15509 "<intfc> | sw_if_index <id> enable | disable") \
15510 _(sw_interface_set_l2_xconnect, \
15511 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
15512 "enable | disable") \
15513 _(sw_interface_set_l2_bridge, \
15514 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
15515 "[shg <split-horizon-group>] [bvi]\n" \
15516 "enable | disable") \
15517 _(bridge_domain_add_del, \
15518 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n")\
15519 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
15521 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
15523 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
15525 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
15527 "tapname <name> mac <mac-addr> | random-mac") \
15529 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
15531 "<vpp-if-name> | sw_if_index <id>") \
15532 _(sw_interface_tap_dump, "") \
15533 _(ip_add_del_route, \
15534 "<addr>/<mask> via <addr> [vrf <n>]\n" \
15535 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
15536 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
15537 "[multipath] [count <n>]") \
15538 _(proxy_arp_add_del, \
15539 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
15540 _(proxy_arp_intfc_enable_disable, \
15541 "<intfc> | sw_if_index <id> enable | disable") \
15542 _(mpls_add_del_encap, \
15543 "label <n> dst <ip4-addr> [vrf <n>] [del]") \
15544 _(mpls_add_del_decap, \
15545 "label <n> [rx_vrf_id <n>] [tx_vrf_id] [s-bit-clear][del]") \
15546 _(mpls_gre_add_del_tunnel, \
15547 "inner_vrf_id <n> outer_vrf_id <n> src <ip4-address> dst <ip4-address>\n" \
15548 "adj <ip4-address>/<mask-width> [del]") \
15549 _(sw_interface_set_unnumbered, \
15550 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
15551 _(ip_neighbor_add_del, \
15552 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
15553 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
15554 _(reset_vrf, "vrf <id> [ipv6]") \
15555 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
15556 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
15557 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
15558 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
15559 "[outer_vlan_id_any][inner_vlan_id_any]") \
15560 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
15561 _(reset_fib, "vrf <n> [ipv6]") \
15562 _(dhcp_proxy_config, \
15563 "svr <v46-address> src <v46-address>\n" \
15564 "insert-cid <n> [del]") \
15565 _(dhcp_proxy_config_2, \
15566 "svr <v46-address> src <v46-address>\n" \
15567 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
15568 _(dhcp_proxy_set_vss, \
15569 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
15570 _(dhcp_client_config, \
15571 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
15572 _(set_ip_flow_hash, \
15573 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
15574 _(sw_interface_ip6_enable_disable, \
15575 "<intfc> | sw_if_index <id> enable | disable") \
15576 _(sw_interface_ip6_set_link_local_address, \
15577 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
15578 _(sw_interface_ip6nd_ra_prefix, \
15579 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
15580 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
15581 "[nolink] [isno]") \
15582 _(sw_interface_ip6nd_ra_config, \
15583 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
15584 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
15585 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
15586 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
15587 _(l2_patch_add_del, \
15588 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
15589 "enable | disable") \
15590 _(mpls_ethernet_add_del_tunnel, \
15591 "tx <intfc> | tx_sw_if_index <n> dst <mac-addr>\n" \
15592 "adj <ip4-addr>/<mw> dst <mac-addr> [del]") \
15593 _(mpls_ethernet_add_del_tunnel_2, \
15594 "inner_vrf_id <n> outer_vrf_id <n> next-hop <ip4-addr>\n" \
15595 "resolve-attempts <n> resolve-if-needed 0 | 1 [del]") \
15596 _(sr_tunnel_add_del, \
15597 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
15598 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
15599 "[policy <policy_name>]") \
15600 _(sr_policy_add_del, \
15601 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
15602 _(sr_multicast_map_add_del, \
15603 "address [ip6 multicast address] sr-policy [policy name] [del]") \
15604 _(classify_add_del_table, \
15605 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
15606 "[del] mask <mask-value>\n" \
15607 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>") \
15608 _(classify_add_del_session, \
15609 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
15610 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
15611 " [l3 [ip4|ip6]]") \
15612 _(classify_set_interface_ip_table, \
15613 "<intfc> | sw_if_index <nn> table <nn>") \
15614 _(classify_set_interface_l2_tables, \
15615 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
15616 " [other-table <nn>]") \
15617 _(get_node_index, "node <node-name") \
15618 _(add_node_next, "node <node-name> next <next-node-name>") \
15619 _(l2tpv3_create_tunnel, \
15620 "client_address <ip6-addr> our_address <ip6-addr>\n" \
15621 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n"\
15622 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
15623 _(l2tpv3_set_tunnel_cookies, \
15624 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
15625 "[new_remote_cookie <nn>]\n") \
15626 _(l2tpv3_interface_enable_disable, \
15627 "<intfc> | sw_if_index <nn> enable | disable") \
15628 _(l2tpv3_set_lookup_key, \
15629 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
15630 _(sw_if_l2tpv3_tunnel_dump, "") \
15631 _(vxlan_add_del_tunnel, \
15632 "src <ip-addr> dst <ip-addr> vni <vni> [encap-vrf-id <nn>]\n" \
15633 " [decap-next l2|ip4|ip6] [del]") \
15634 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
15635 _(gre_add_del_tunnel, \
15636 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [del]\n") \
15637 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
15638 _(l2_fib_clear_table, "") \
15639 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
15640 _(l2_interface_vlan_tag_rewrite, \
15641 "<intfc> | sw_if_index <nn> \n" \
15642 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
15643 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
15644 _(create_vhost_user_if, \
15645 "socket <filename> [server] [renumber <dev_instance>] " \
15646 "[mac <mac_address>]") \
15647 _(modify_vhost_user_if, \
15648 "<intfc> | sw_if_index <nn> socket <filename>\n" \
15649 "[server] [renumber <dev_instance>]") \
15650 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
15651 _(sw_interface_vhost_user_dump, "") \
15652 _(show_version, "") \
15653 _(vxlan_gpe_add_del_tunnel, \
15654 "local <addr> remote <addr> vni <nn>\n" \
15655 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
15656 "[next-ethernet] [next-nsh]\n") \
15657 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
15658 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
15659 _(interface_name_renumber, \
15660 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
15661 _(input_acl_set_interface, \
15662 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
15663 " [l2-table <nn>] [del]") \
15664 _(want_ip4_arp_events, "address <ip4-address> [del]") \
15665 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
15666 _(ip_dump, "ipv4 | ipv6") \
15667 _(ipsec_spd_add_del, "spd_id <n> [del]") \
15668 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
15670 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
15671 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
15672 " integ_alg <alg> integ_key <hex>") \
15673 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
15674 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
15675 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
15676 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" )\
15677 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
15678 _(ikev2_profile_add_del, "name <profile_name> [del]") \
15679 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
15680 "(auth_data 0x<data> | auth_data <data>)") \
15681 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
15682 "(id_data 0x<data> | id_data <data>) (local|remote)") \
15683 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
15684 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
15685 "(local|remote)") \
15686 _(ikev2_set_local_key, "file <absolute_file_path>") \
15687 _(delete_loopback,"sw_if_index <nn>") \
15688 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
15689 _(map_add_domain, \
15690 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
15691 "ip6-src <ip6addr> " \
15692 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
15693 _(map_del_domain, "index <n>") \
15694 _(map_add_del_rule, \
15695 "index <n> psid <n> dst <ip6addr> [del]") \
15696 _(map_domain_dump, "") \
15697 _(map_rule_dump, "index <map-domain>") \
15698 _(want_interface_events, "enable|disable") \
15699 _(want_stats,"enable|disable") \
15700 _(get_first_msg_id, "client <name>") \
15701 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
15702 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
15703 "fib-id <nn> [ip4][ip6][default]") \
15704 _(get_node_graph, " ") \
15705 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
15706 _(trace_profile_add, "id <nn> trace-type <0x1f|0x3|0x9|0x11|0x19> " \
15707 "trace-elts <nn> trace-tsp <0|1|2|3> node-id <node id in hex> " \
15708 "app-data <app_data in hex> [pow] [ppc <encap|decap>]") \
15709 _(trace_profile_apply, "id <nn> <ip6-address>/<width>" \
15710 " vrf_id <nn> add | pop | none") \
15711 _(trace_profile_del, "") \
15712 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
15713 " sw_if_index <sw_if_index> p <priority> " \
15714 "w <weight>] [del]") \
15715 _(lisp_add_del_locator, "locator-set <locator_name> " \
15716 "iface <intf> | sw_if_index <sw_if_index> " \
15717 "p <priority> w <weight> [del]") \
15718 _(lisp_add_del_local_eid,"vni <vni> eid " \
15719 "<ipv4|ipv6>/<prefix> | <L2 address> " \
15720 "locator-set <locator_name> [del]") \
15721 _(lisp_gpe_add_del_fwd_entry, "rmt_eid <eid> [lcl_eid <eid>] vni <vni>" \
15722 "dp_table <table> loc-pair <lcl_loc> <rmt_loc> ... [del]") \
15723 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
15724 _(lisp_gpe_enable_disable, "enable|disable") \
15725 _(lisp_enable_disable, "enable|disable") \
15726 _(lisp_gpe_add_del_iface, "up|down") \
15727 _(lisp_add_del_remote_mapping, "add|del vni <vni> deid <dest-eid> " \
15728 "rloc <locator> p <prio> " \
15729 "w <weight> [rloc <loc> ... ] " \
15730 "action <action> [del-all]") \
15731 _(lisp_add_del_adjacency, "add|del vni <vni> deid <dest-eid> seid " \
15732 "<src-eid> rloc <locator> p <prio> w <weight>"\
15733 "[rloc <loc> ... ] action <action>") \
15734 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
15735 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
15736 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
15737 _(lisp_locator_set_dump, "[locator-set-index <ls-index> | " \
15738 "locator-set <loc-set-name>] [local | remote]")\
15739 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
15740 "[local] | [remote]") \
15741 _(lisp_eid_table_vni_dump, "") \
15742 _(lisp_eid_table_map_dump, "l2|l3") \
15743 _(lisp_gpe_tunnel_dump, "") \
15744 _(lisp_map_resolver_dump, "") \
15745 _(show_lisp_status, "") \
15746 _(lisp_get_map_request_itr_rlocs, "") \
15747 _(show_lisp_pitr, "") \
15748 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
15749 _(af_packet_delete, "name <host interface name>") \
15750 _(policer_add_del, "name <policer name> <params> [del]") \
15751 _(policer_dump, "[name <policer name>]") \
15752 _(policer_classify_set_interface, \
15753 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
15754 " [l2-table <nn>] [del]") \
15755 _(policer_classify_dump, "type [ip4|ip6|l2]") \
15756 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
15757 "[master|slave]") \
15758 _(netmap_delete, "name <interface name>") \
15759 _(mpls_gre_tunnel_dump, "tunnel_index <tunnel-id>") \
15760 _(mpls_eth_tunnel_dump, "tunnel_index <tunnel-id>") \
15761 _(mpls_fib_encap_dump, "") \
15762 _(mpls_fib_decap_dump, "") \
15763 _(classify_table_ids, "") \
15764 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
15765 _(classify_table_info, "table_id <nn>") \
15766 _(classify_session_dump, "table_id <nn>") \
15767 _(ipfix_enable, "collector_address <ip4> [collector_port <nn>] " \
15768 "src_address <ip4> [fib_id <nn>] [path_mtu <nn>] " \
15769 "[template_interval <nn>]") \
15770 _(ipfix_dump, "") \
15771 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
15772 _(pg_create_interface, "if_id <nn>") \
15773 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
15774 _(pg_enable_disable, "[stream <id>] disable") \
15775 _(ip_source_and_port_range_check_add_del, \
15776 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
15777 _(ip_source_and_port_range_check_interface_add_del, \
15778 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
15779 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
15780 _(ipsec_gre_add_del_tunnel, \
15781 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
15782 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]")
15784 /* List of command functions, CLI names map directly to functions */
15785 #define foreach_cli_function \
15786 _(comment, "usage: comment <ignore-rest-of-line>") \
15787 _(dump_interface_table, "usage: dump_interface_table") \
15788 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
15789 _(dump_ipv4_table, "usage: dump_ipv4_table") \
15790 _(dump_ipv6_table, "usage: dump_ipv6_table") \
15791 _(dump_stats_table, "usage: dump_stats_table") \
15792 _(dump_macro_table, "usage: dump_macro_table ") \
15793 _(dump_node_table, "usage: dump_node_table") \
15794 _(echo, "usage: echo <message>") \
15795 _(exec, "usage: exec <vpe-debug-CLI-command>") \
15796 _(help, "usage: help") \
15797 _(q, "usage: quit") \
15798 _(quit, "usage: quit") \
15799 _(search_node_table, "usage: search_node_table <name>...") \
15800 _(set, "usage: set <variable-name> <value>") \
15801 _(script, "usage: script <file-name>") \
15802 _(unset, "usage: unset <variable-name>")
15805 static void vl_api_##n##_t_handler_uni \
15806 (vl_api_##n##_t * mp) \
15808 vat_main_t * vam = &vat_main; \
15809 if (vam->json_output) { \
15810 vl_api_##n##_t_handler_json(mp); \
15812 vl_api_##n##_t_handler(mp); \
15815 foreach_vpe_api_reply_msg;
15819 vat_api_hookup (vat_main_t * vam)
15822 vl_msg_api_set_handlers(VL_API_##N, #n, \
15823 vl_api_##n##_t_handler_uni, \
15825 vl_api_##n##_t_endian, \
15826 vl_api_##n##_t_print, \
15827 sizeof(vl_api_##n##_t), 1);
15828 foreach_vpe_api_reply_msg;
15831 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
15833 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
15835 vam->function_by_name = hash_create_string (0, sizeof (uword));
15837 vam->help_by_name = hash_create_string (0, sizeof (uword));
15839 /* API messages we can send */
15840 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
15841 foreach_vpe_api_msg;
15845 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
15846 foreach_vpe_api_msg;
15849 /* CLI functions */
15850 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
15851 foreach_cli_function;
15855 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
15856 foreach_cli_function;
15860 #undef vl_api_version
15861 #define vl_api_version(n,v) static u32 vpe_api_version = v;
15862 #include <vpp-api/vpe.api.h>
15863 #undef vl_api_version
15866 vl_client_add_api_signatures (vl_api_memclnt_create_t * mp)
15869 * Send the main API signature in slot 0. This bit of code must
15870 * match the checks in ../vpe/api/api.c: vl_msg_api_version_check().
15872 mp->api_versions[0] = clib_host_to_net_u32 (vpe_api_version);
15876 * fd.io coding-style-patch-verification: ON
15879 * eval: (c-set-style "gnu")