2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 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/classify/flow_classify.h>
39 #include <vnet/mpls/mpls.h>
41 #include <vnet/ipsec/ipsec.h>
42 #include <vnet/ipsec/ikev2.h>
46 #include <vnet/map/map.h>
47 #include <vnet/cop/cop.h>
48 #include <vnet/ip/ip6_hop_by_hop.h>
49 #include <vnet/ip/ip_source_and_port_range_check.h>
50 #include <vnet/policer/xlate.h>
51 #include <vnet/policer/policer.h>
52 #include <vnet/policer/police.h>
54 #include "vat/json_format.h"
58 #define vl_typedefs /* define message structures */
59 #include <vpp-api/vpe_all_api_h.h>
62 /* declare message handlers for each api */
64 #define vl_endianfun /* define message structures */
65 #include <vpp-api/vpe_all_api_h.h>
68 /* instantiate all the print functions we know about */
69 #define vl_print(handle, ...)
71 #include <vpp-api/vpe_all_api_h.h>
75 unformat_sw_if_index (unformat_input_t * input, va_list * args)
77 vat_main_t *vam = va_arg (*args, vat_main_t *);
78 u32 *result = va_arg (*args, u32 *);
82 if (!unformat (input, "%s", &if_name))
85 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
92 /* Parse an IP4 address %d.%d.%d.%d. */
94 unformat_ip4_address (unformat_input_t * input, va_list * args)
96 u8 *result = va_arg (*args, u8 *);
99 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
102 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
115 unformat_ethernet_address (unformat_input_t * input, va_list * args)
117 u8 *result = va_arg (*args, u8 *);
120 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
121 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
125 for (i = 0; i < 6; i++)
126 if (a[i] >= (1 << 8))
129 for (i = 0; i < 6; i++)
135 /* Returns ethernet type as an int in host byte order. */
137 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
140 u16 *result = va_arg (*args, u16 *);
144 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
146 if (type >= (1 << 16))
154 /* Parse an IP6 address. */
156 unformat_ip6_address (unformat_input_t * input, va_list * args)
158 ip6_address_t *result = va_arg (*args, ip6_address_t *);
160 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
161 uword c, n_colon, double_colon_index;
163 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
164 double_colon_index = ARRAY_LEN (hex_quads);
165 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
168 if (c >= '0' && c <= '9')
170 else if (c >= 'a' && c <= 'f')
171 hex_digit = c + 10 - 'a';
172 else if (c >= 'A' && c <= 'F')
173 hex_digit = c + 10 - 'A';
174 else if (c == ':' && n_colon < 2)
178 unformat_put_input (input);
182 /* Too many hex quads. */
183 if (n_hex_quads >= ARRAY_LEN (hex_quads))
188 hex_quad = (hex_quad << 4) | hex_digit;
190 /* Hex quad must fit in 16 bits. */
191 if (n_hex_digits >= 4)
198 /* Save position of :: */
201 /* More than one :: ? */
202 if (double_colon_index < ARRAY_LEN (hex_quads))
204 double_colon_index = n_hex_quads;
207 if (n_colon > 0 && n_hex_digits > 0)
209 hex_quads[n_hex_quads++] = hex_quad;
215 if (n_hex_digits > 0)
216 hex_quads[n_hex_quads++] = hex_quad;
221 /* Expand :: to appropriate number of zero hex quads. */
222 if (double_colon_index < ARRAY_LEN (hex_quads))
224 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
226 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
227 hex_quads[n_zero + i] = hex_quads[i];
229 for (i = 0; i < n_zero; i++)
230 hex_quads[double_colon_index + i] = 0;
232 n_hex_quads = ARRAY_LEN (hex_quads);
235 /* Too few hex quads given. */
236 if (n_hex_quads < ARRAY_LEN (hex_quads))
239 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
240 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
247 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
250 u32 *r = va_arg (*args, u32 *);
253 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
254 foreach_ipsec_policy_action
265 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
268 u32 *r = va_arg (*args, u32 *);
271 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
272 foreach_ipsec_crypto_alg
283 format_ipsec_crypto_alg (u8 * s, va_list * args)
286 u32 i = va_arg (*args, u32);
291 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
292 foreach_ipsec_crypto_alg
295 return format (s, "unknown");
297 return format (s, "%s", t);
299 return format (s, "Unimplemented");
304 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
307 u32 *r = va_arg (*args, u32 *);
310 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
311 foreach_ipsec_integ_alg
322 format_ipsec_integ_alg (u8 * s, va_list * args)
325 u32 i = va_arg (*args, u32);
330 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
331 foreach_ipsec_integ_alg
334 return format (s, "unknown");
336 return format (s, "%s", t);
338 return format (s, "Unsupported");
343 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
346 u32 *r = va_arg (*args, u32 *);
349 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
350 foreach_ikev2_auth_method
361 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
364 u32 *r = va_arg (*args, u32 *);
367 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
368 foreach_ikev2_id_type
379 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
381 u8 *r = va_arg (*args, u8 *);
383 if (unformat (input, "kbps"))
384 *r = SSE2_QOS_RATE_KBPS;
385 else if (unformat (input, "pps"))
386 *r = SSE2_QOS_RATE_PPS;
393 unformat_policer_round_type (unformat_input_t * input, va_list * args)
395 u8 *r = va_arg (*args, u8 *);
397 if (unformat (input, "closest"))
398 *r = SSE2_QOS_ROUND_TO_CLOSEST;
399 else if (unformat (input, "up"))
400 *r = SSE2_QOS_ROUND_TO_UP;
401 else if (unformat (input, "down"))
402 *r = SSE2_QOS_ROUND_TO_DOWN;
409 unformat_policer_type (unformat_input_t * input, va_list * args)
411 u8 *r = va_arg (*args, u8 *);
413 if (unformat (input, "1r2c"))
414 *r = SSE2_QOS_POLICER_TYPE_1R2C;
415 else if (unformat (input, "1r3c"))
416 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
417 else if (unformat (input, "2r3c-2698"))
418 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
419 else if (unformat (input, "2r3c-4115"))
420 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
421 else if (unformat (input, "2r3c-mef5cf1"))
422 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
429 unformat_dscp (unformat_input_t * input, va_list * va)
431 u8 *r = va_arg (*va, u8 *);
434 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
443 unformat_policer_action_type (unformat_input_t * input, va_list * va)
445 sse2_qos_pol_action_params_st *a
446 = va_arg (*va, sse2_qos_pol_action_params_st *);
448 if (unformat (input, "drop"))
449 a->action_type = SSE2_QOS_ACTION_DROP;
450 else if (unformat (input, "transmit"))
451 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
452 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
453 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
460 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
462 u32 *r = va_arg (*va, u32 *);
465 if (unformat (input, "ip4"))
466 tid = POLICER_CLASSIFY_TABLE_IP4;
467 else if (unformat (input, "ip6"))
468 tid = POLICER_CLASSIFY_TABLE_IP6;
469 else if (unformat (input, "l2"))
470 tid = POLICER_CLASSIFY_TABLE_L2;
479 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
481 u32 *r = va_arg (*va, u32 *);
484 if (unformat (input, "ip4"))
485 tid = FLOW_CLASSIFY_TABLE_IP4;
486 else if (unformat (input, "ip6"))
487 tid = FLOW_CLASSIFY_TABLE_IP6;
496 format_ip4_address (u8 * s, va_list * args)
498 u8 *a = va_arg (*args, u8 *);
499 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
503 format_ip6_address (u8 * s, va_list * args)
505 ip6_address_t *a = va_arg (*args, ip6_address_t *);
506 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
508 i_max_n_zero = ARRAY_LEN (a->as_u16);
510 i_first_zero = i_max_n_zero;
512 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
514 u32 is_zero = a->as_u16[i] == 0;
515 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
521 if ((!is_zero && n_zeros > max_n_zeros)
522 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
524 i_max_n_zero = i_first_zero;
525 max_n_zeros = n_zeros;
526 i_first_zero = ARRAY_LEN (a->as_u16);
531 last_double_colon = 0;
532 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
534 if (i == i_max_n_zero && max_n_zeros > 1)
536 s = format (s, "::");
537 i += max_n_zeros - 1;
538 last_double_colon = 1;
542 s = format (s, "%s%x",
543 (last_double_colon || i == 0) ? "" : ":",
544 clib_net_to_host_u16 (a->as_u16[i]));
545 last_double_colon = 0;
552 /* Format an IP46 address. */
554 format_ip46_address (u8 * s, va_list * args)
556 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
557 ip46_type_t type = va_arg (*args, ip46_type_t);
563 is_ip4 = ip46_address_is_ip4 (ip46);
574 format (s, "%U", format_ip4_address, &ip46->ip4) :
575 format (s, "%U", format_ip6_address, &ip46->ip6);
579 format_ethernet_address (u8 * s, va_list * args)
581 u8 *a = va_arg (*args, u8 *);
583 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
584 a[0], a[1], a[2], a[3], a[4], a[5]);
588 increment_v4_address (ip4_address_t * a)
592 v = ntohl (a->as_u32) + 1;
593 a->as_u32 = ntohl (v);
597 increment_v6_address (ip6_address_t * a)
601 v0 = clib_net_to_host_u64 (a->as_u64[0]);
602 v1 = clib_net_to_host_u64 (a->as_u64[1]);
607 a->as_u64[0] = clib_net_to_host_u64 (v0);
608 a->as_u64[1] = clib_net_to_host_u64 (v1);
612 increment_mac_address (u64 * mac)
616 tmp = clib_net_to_host_u64 (tmp);
617 tmp += 1 << 16; /* skip unused (least significant) octets */
618 tmp = clib_host_to_net_u64 (tmp);
622 static void vl_api_create_loopback_reply_t_handler
623 (vl_api_create_loopback_reply_t * mp)
625 vat_main_t *vam = &vat_main;
626 i32 retval = ntohl (mp->retval);
628 vam->retval = retval;
629 vam->regenerate_interface_table = 1;
630 vam->sw_if_index = ntohl (mp->sw_if_index);
631 vam->result_ready = 1;
634 static void vl_api_create_loopback_reply_t_handler_json
635 (vl_api_create_loopback_reply_t * mp)
637 vat_main_t *vam = &vat_main;
638 vat_json_node_t node;
640 vat_json_init_object (&node);
641 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
642 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
644 vat_json_print (vam->ofp, &node);
645 vat_json_free (&node);
646 vam->retval = ntohl (mp->retval);
647 vam->result_ready = 1;
650 static void vl_api_af_packet_create_reply_t_handler
651 (vl_api_af_packet_create_reply_t * mp)
653 vat_main_t *vam = &vat_main;
654 i32 retval = ntohl (mp->retval);
656 vam->retval = retval;
657 vam->regenerate_interface_table = 1;
658 vam->sw_if_index = ntohl (mp->sw_if_index);
659 vam->result_ready = 1;
662 static void vl_api_af_packet_create_reply_t_handler_json
663 (vl_api_af_packet_create_reply_t * mp)
665 vat_main_t *vam = &vat_main;
666 vat_json_node_t node;
668 vat_json_init_object (&node);
669 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
670 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
672 vat_json_print (vam->ofp, &node);
673 vat_json_free (&node);
675 vam->retval = ntohl (mp->retval);
676 vam->result_ready = 1;
679 static void vl_api_create_vlan_subif_reply_t_handler
680 (vl_api_create_vlan_subif_reply_t * mp)
682 vat_main_t *vam = &vat_main;
683 i32 retval = ntohl (mp->retval);
685 vam->retval = retval;
686 vam->regenerate_interface_table = 1;
687 vam->sw_if_index = ntohl (mp->sw_if_index);
688 vam->result_ready = 1;
691 static void vl_api_create_vlan_subif_reply_t_handler_json
692 (vl_api_create_vlan_subif_reply_t * mp)
694 vat_main_t *vam = &vat_main;
695 vat_json_node_t node;
697 vat_json_init_object (&node);
698 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
699 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
701 vat_json_print (vam->ofp, &node);
702 vat_json_free (&node);
704 vam->retval = ntohl (mp->retval);
705 vam->result_ready = 1;
708 static void vl_api_create_subif_reply_t_handler
709 (vl_api_create_subif_reply_t * mp)
711 vat_main_t *vam = &vat_main;
712 i32 retval = ntohl (mp->retval);
714 vam->retval = retval;
715 vam->regenerate_interface_table = 1;
716 vam->sw_if_index = ntohl (mp->sw_if_index);
717 vam->result_ready = 1;
720 static void vl_api_create_subif_reply_t_handler_json
721 (vl_api_create_subif_reply_t * mp)
723 vat_main_t *vam = &vat_main;
724 vat_json_node_t node;
726 vat_json_init_object (&node);
727 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
728 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
730 vat_json_print (vam->ofp, &node);
731 vat_json_free (&node);
733 vam->retval = ntohl (mp->retval);
734 vam->result_ready = 1;
737 static void vl_api_interface_name_renumber_reply_t_handler
738 (vl_api_interface_name_renumber_reply_t * mp)
740 vat_main_t *vam = &vat_main;
741 i32 retval = ntohl (mp->retval);
743 vam->retval = retval;
744 vam->regenerate_interface_table = 1;
745 vam->result_ready = 1;
748 static void vl_api_interface_name_renumber_reply_t_handler_json
749 (vl_api_interface_name_renumber_reply_t * mp)
751 vat_main_t *vam = &vat_main;
752 vat_json_node_t node;
754 vat_json_init_object (&node);
755 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
757 vat_json_print (vam->ofp, &node);
758 vat_json_free (&node);
760 vam->retval = ntohl (mp->retval);
761 vam->result_ready = 1;
765 * Special-case: build the interface table, maintain
766 * the next loopback sw_if_index vbl.
768 static void vl_api_sw_interface_details_t_handler
769 (vl_api_sw_interface_details_t * mp)
771 vat_main_t *vam = &vat_main;
772 u8 *s = format (0, "%s%c", mp->interface_name, 0);
774 hash_set_mem (vam->sw_if_index_by_interface_name, s,
775 ntohl (mp->sw_if_index));
777 /* In sub interface case, fill the sub interface table entry */
778 if (mp->sw_if_index != mp->sup_sw_if_index)
780 sw_interface_subif_t *sub = NULL;
782 vec_add2 (vam->sw_if_subif_table, sub, 1);
784 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
785 strncpy ((char *) sub->interface_name, (char *) s,
786 vec_len (sub->interface_name));
787 sub->sw_if_index = ntohl (mp->sw_if_index);
788 sub->sub_id = ntohl (mp->sub_id);
790 sub->sub_dot1ad = mp->sub_dot1ad;
791 sub->sub_number_of_tags = mp->sub_number_of_tags;
792 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
793 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
794 sub->sub_exact_match = mp->sub_exact_match;
795 sub->sub_default = mp->sub_default;
796 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
797 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
799 /* vlan tag rewrite */
800 sub->vtr_op = ntohl (mp->vtr_op);
801 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
802 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
803 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
807 static void vl_api_sw_interface_details_t_handler_json
808 (vl_api_sw_interface_details_t * mp)
810 vat_main_t *vam = &vat_main;
811 vat_json_node_t *node = NULL;
813 if (VAT_JSON_ARRAY != vam->json_tree.type)
815 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
816 vat_json_init_array (&vam->json_tree);
818 node = vat_json_array_add (&vam->json_tree);
820 vat_json_init_object (node);
821 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
822 vat_json_object_add_uint (node, "sup_sw_if_index",
823 ntohl (mp->sup_sw_if_index));
824 vat_json_object_add_uint (node, "l2_address_length",
825 ntohl (mp->l2_address_length));
826 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
827 sizeof (mp->l2_address));
828 vat_json_object_add_string_copy (node, "interface_name",
830 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
831 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
832 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
833 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
834 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
835 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
836 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
837 vat_json_object_add_uint (node, "sub_number_of_tags",
838 mp->sub_number_of_tags);
839 vat_json_object_add_uint (node, "sub_outer_vlan_id",
840 ntohs (mp->sub_outer_vlan_id));
841 vat_json_object_add_uint (node, "sub_inner_vlan_id",
842 ntohs (mp->sub_inner_vlan_id));
843 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
844 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
845 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
846 mp->sub_outer_vlan_id_any);
847 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
848 mp->sub_inner_vlan_id_any);
849 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
850 vat_json_object_add_uint (node, "vtr_push_dot1q",
851 ntohl (mp->vtr_push_dot1q));
852 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
853 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
856 static void vl_api_sw_interface_set_flags_t_handler
857 (vl_api_sw_interface_set_flags_t * mp)
859 vat_main_t *vam = &vat_main;
860 if (vam->interface_event_display)
861 errmsg ("interface flags: sw_if_index %d %s %s\n",
862 ntohl (mp->sw_if_index),
863 mp->admin_up_down ? "admin-up" : "admin-down",
864 mp->link_up_down ? "link-up" : "link-down");
867 static void vl_api_sw_interface_set_flags_t_handler_json
868 (vl_api_sw_interface_set_flags_t * mp)
870 /* JSON output not supported */
874 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
876 vat_main_t *vam = &vat_main;
877 i32 retval = ntohl (mp->retval);
879 vam->retval = retval;
880 vam->shmem_result = (u8 *) mp->reply_in_shmem;
881 vam->result_ready = 1;
885 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
887 vat_main_t *vam = &vat_main;
888 vat_json_node_t node;
889 api_main_t *am = &api_main;
893 vat_json_init_object (&node);
894 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
895 vat_json_object_add_uint (&node, "reply_in_shmem",
896 ntohl (mp->reply_in_shmem));
897 /* Toss the shared-memory original... */
898 pthread_mutex_lock (&am->vlib_rp->mutex);
899 oldheap = svm_push_data_heap (am->vlib_rp);
901 reply = (u8 *) (mp->reply_in_shmem);
904 svm_pop_heap (oldheap);
905 pthread_mutex_unlock (&am->vlib_rp->mutex);
907 vat_json_print (vam->ofp, &node);
908 vat_json_free (&node);
910 vam->retval = ntohl (mp->retval);
911 vam->result_ready = 1;
915 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
917 vat_main_t *vam = &vat_main;
918 i32 retval = ntohl (mp->retval);
920 vam->retval = retval;
921 vam->cmd_reply = mp->reply;
922 vam->result_ready = 1;
926 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
928 vat_main_t *vam = &vat_main;
929 vat_json_node_t node;
931 vat_json_init_object (&node);
932 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
933 vat_json_object_add_string_copy (&node, "reply", mp->reply);
935 vat_json_print (vam->ofp, &node);
936 vat_json_free (&node);
938 vam->retval = ntohl (mp->retval);
939 vam->result_ready = 1;
942 static void vl_api_classify_add_del_table_reply_t_handler
943 (vl_api_classify_add_del_table_reply_t * mp)
945 vat_main_t *vam = &vat_main;
946 i32 retval = ntohl (mp->retval);
949 vam->async_errors += (retval < 0);
953 vam->retval = retval;
955 ((mp->new_table_index != 0xFFFFFFFF) ||
956 (mp->skip_n_vectors != 0xFFFFFFFF) ||
957 (mp->match_n_vectors != 0xFFFFFFFF)))
959 * Note: this is just barely thread-safe, depends on
960 * the main thread spinning waiting for an answer...
962 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d\n",
963 ntohl (mp->new_table_index),
964 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
965 vam->result_ready = 1;
969 static void vl_api_classify_add_del_table_reply_t_handler_json
970 (vl_api_classify_add_del_table_reply_t * mp)
972 vat_main_t *vam = &vat_main;
973 vat_json_node_t node;
975 vat_json_init_object (&node);
976 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
977 vat_json_object_add_uint (&node, "new_table_index",
978 ntohl (mp->new_table_index));
979 vat_json_object_add_uint (&node, "skip_n_vectors",
980 ntohl (mp->skip_n_vectors));
981 vat_json_object_add_uint (&node, "match_n_vectors",
982 ntohl (mp->match_n_vectors));
984 vat_json_print (vam->ofp, &node);
985 vat_json_free (&node);
987 vam->retval = ntohl (mp->retval);
988 vam->result_ready = 1;
991 static void vl_api_get_node_index_reply_t_handler
992 (vl_api_get_node_index_reply_t * mp)
994 vat_main_t *vam = &vat_main;
995 i32 retval = ntohl (mp->retval);
998 vam->async_errors += (retval < 0);
1002 vam->retval = retval;
1004 errmsg ("node index %d\n", ntohl (mp->node_index));
1005 vam->result_ready = 1;
1009 static void vl_api_get_node_index_reply_t_handler_json
1010 (vl_api_get_node_index_reply_t * mp)
1012 vat_main_t *vam = &vat_main;
1013 vat_json_node_t node;
1015 vat_json_init_object (&node);
1016 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1017 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1019 vat_json_print (vam->ofp, &node);
1020 vat_json_free (&node);
1022 vam->retval = ntohl (mp->retval);
1023 vam->result_ready = 1;
1026 static void vl_api_get_next_index_reply_t_handler
1027 (vl_api_get_next_index_reply_t * mp)
1029 vat_main_t *vam = &vat_main;
1030 i32 retval = ntohl (mp->retval);
1031 if (vam->async_mode)
1033 vam->async_errors += (retval < 0);
1037 vam->retval = retval;
1039 errmsg ("next node index %d\n", ntohl (mp->next_index));
1040 vam->result_ready = 1;
1044 static void vl_api_get_next_index_reply_t_handler_json
1045 (vl_api_get_next_index_reply_t * mp)
1047 vat_main_t *vam = &vat_main;
1048 vat_json_node_t node;
1050 vat_json_init_object (&node);
1051 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1052 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1054 vat_json_print (vam->ofp, &node);
1055 vat_json_free (&node);
1057 vam->retval = ntohl (mp->retval);
1058 vam->result_ready = 1;
1061 static void vl_api_add_node_next_reply_t_handler
1062 (vl_api_add_node_next_reply_t * mp)
1064 vat_main_t *vam = &vat_main;
1065 i32 retval = ntohl (mp->retval);
1066 if (vam->async_mode)
1068 vam->async_errors += (retval < 0);
1072 vam->retval = retval;
1074 errmsg ("next index %d\n", ntohl (mp->next_index));
1075 vam->result_ready = 1;
1079 static void vl_api_add_node_next_reply_t_handler_json
1080 (vl_api_add_node_next_reply_t * mp)
1082 vat_main_t *vam = &vat_main;
1083 vat_json_node_t node;
1085 vat_json_init_object (&node);
1086 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1087 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1089 vat_json_print (vam->ofp, &node);
1090 vat_json_free (&node);
1092 vam->retval = ntohl (mp->retval);
1093 vam->result_ready = 1;
1096 static void vl_api_mpls_gre_add_del_tunnel_reply_t_handler
1097 (vl_api_mpls_gre_add_del_tunnel_reply_t * mp)
1099 vat_main_t *vam = &vat_main;
1100 i32 retval = ntohl (mp->retval);
1101 u32 sw_if_index = ntohl (mp->tunnel_sw_if_index);
1103 if (retval >= 0 && sw_if_index != (u32) ~ 0)
1105 errmsg ("tunnel_sw_if_index %d\n", sw_if_index);
1107 vam->retval = retval;
1108 vam->result_ready = 1;
1111 static void vl_api_mpls_gre_add_del_tunnel_reply_t_handler_json
1112 (vl_api_mpls_gre_add_del_tunnel_reply_t * mp)
1114 vat_main_t *vam = &vat_main;
1115 vat_json_node_t node;
1117 vat_json_init_object (&node);
1118 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1119 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1120 ntohl (mp->tunnel_sw_if_index));
1122 vat_json_print (vam->ofp, &node);
1123 vat_json_free (&node);
1125 vam->retval = ntohl (mp->retval);
1126 vam->result_ready = 1;
1130 static void vl_api_show_version_reply_t_handler
1131 (vl_api_show_version_reply_t * mp)
1133 vat_main_t *vam = &vat_main;
1134 i32 retval = ntohl (mp->retval);
1138 errmsg (" program: %s\n", mp->program);
1139 errmsg (" version: %s\n", mp->version);
1140 errmsg (" build date: %s\n", mp->build_date);
1141 errmsg ("build directory: %s\n", mp->build_directory);
1143 vam->retval = retval;
1144 vam->result_ready = 1;
1147 static void vl_api_show_version_reply_t_handler_json
1148 (vl_api_show_version_reply_t * mp)
1150 vat_main_t *vam = &vat_main;
1151 vat_json_node_t node;
1153 vat_json_init_object (&node);
1154 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1155 vat_json_object_add_string_copy (&node, "program", mp->program);
1156 vat_json_object_add_string_copy (&node, "version", mp->version);
1157 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1158 vat_json_object_add_string_copy (&node, "build_directory",
1159 mp->build_directory);
1161 vat_json_print (vam->ofp, &node);
1162 vat_json_free (&node);
1164 vam->retval = ntohl (mp->retval);
1165 vam->result_ready = 1;
1169 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1171 vat_main_t *vam = &vat_main;
1172 errmsg ("arp %s event: address %U new mac %U sw_if_index %d\n",
1173 mp->mac_ip ? "mac/ip binding" : "address resolution",
1174 format_ip4_address, &mp->address,
1175 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1179 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1181 /* JSON output not supported */
1185 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1187 vat_main_t *vam = &vat_main;
1188 errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d\n",
1189 mp->mac_ip ? "mac/ip binding" : "address resolution",
1190 format_ip6_address, mp->address,
1191 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1195 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1197 /* JSON output not supported */
1201 * Special-case: build the bridge domain table, maintain
1202 * the next bd id vbl.
1204 static void vl_api_bridge_domain_details_t_handler
1205 (vl_api_bridge_domain_details_t * mp)
1207 vat_main_t *vam = &vat_main;
1208 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1210 fformat (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s\n",
1211 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1213 fformat (vam->ofp, "%3d %3d %3d %3d %3d %3d\n",
1214 ntohl (mp->bd_id), mp->learn, mp->forward,
1215 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1218 fformat (vam->ofp, "\n\n%s %s %s\n", "sw_if_index", "SHG",
1222 static void vl_api_bridge_domain_details_t_handler_json
1223 (vl_api_bridge_domain_details_t * mp)
1225 vat_main_t *vam = &vat_main;
1226 vat_json_node_t *node, *array = NULL;
1228 if (VAT_JSON_ARRAY != vam->json_tree.type)
1230 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1231 vat_json_init_array (&vam->json_tree);
1233 node = vat_json_array_add (&vam->json_tree);
1235 vat_json_init_object (node);
1236 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1237 vat_json_object_add_uint (node, "flood", mp->flood);
1238 vat_json_object_add_uint (node, "forward", mp->forward);
1239 vat_json_object_add_uint (node, "learn", mp->learn);
1240 vat_json_object_add_uint (node, "bvi_sw_if_index",
1241 ntohl (mp->bvi_sw_if_index));
1242 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1243 array = vat_json_object_add (node, "sw_if");
1244 vat_json_init_array (array);
1248 * Special-case: build the bridge domain sw if table.
1250 static void vl_api_bridge_domain_sw_if_details_t_handler
1251 (vl_api_bridge_domain_sw_if_details_t * mp)
1253 vat_main_t *vam = &vat_main;
1258 sw_if_index = ntohl (mp->sw_if_index);
1260 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1262 if ((u32) p->value[0] == sw_if_index)
1264 sw_if_name = (u8 *)(p->key);
1270 fformat (vam->ofp, "%7d %3d %s", sw_if_index,
1271 mp->shg, sw_if_name ? (char *) sw_if_name :
1272 "sw_if_index not found!");
1275 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1276 (vl_api_bridge_domain_sw_if_details_t * mp)
1278 vat_main_t *vam = &vat_main;
1279 vat_json_node_t *node = NULL;
1280 uword last_index = 0;
1282 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1283 ASSERT (vec_len (vam->json_tree.array) >= 1);
1284 last_index = vec_len (vam->json_tree.array) - 1;
1285 node = &vam->json_tree.array[last_index];
1286 node = vat_json_object_get_element (node, "sw_if");
1287 ASSERT (NULL != node);
1288 node = vat_json_array_add (node);
1290 vat_json_init_object (node);
1291 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1292 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1293 vat_json_object_add_uint (node, "shg", mp->shg);
1296 static void vl_api_control_ping_reply_t_handler
1297 (vl_api_control_ping_reply_t * mp)
1299 vat_main_t *vam = &vat_main;
1300 i32 retval = ntohl (mp->retval);
1301 if (vam->async_mode)
1303 vam->async_errors += (retval < 0);
1307 vam->retval = retval;
1308 vam->result_ready = 1;
1312 static void vl_api_control_ping_reply_t_handler_json
1313 (vl_api_control_ping_reply_t * mp)
1315 vat_main_t *vam = &vat_main;
1316 i32 retval = ntohl (mp->retval);
1318 if (VAT_JSON_NONE != vam->json_tree.type)
1320 vat_json_print (vam->ofp, &vam->json_tree);
1321 vat_json_free (&vam->json_tree);
1322 vam->json_tree.type = VAT_JSON_NONE;
1327 vat_json_init_array (&vam->json_tree);
1328 vat_json_print (vam->ofp, &vam->json_tree);
1329 vam->json_tree.type = VAT_JSON_NONE;
1332 vam->retval = retval;
1333 vam->result_ready = 1;
1337 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1339 vat_main_t *vam = &vat_main;
1340 i32 retval = ntohl (mp->retval);
1341 if (vam->async_mode)
1343 vam->async_errors += (retval < 0);
1347 vam->retval = retval;
1348 vam->result_ready = 1;
1352 static void vl_api_l2_flags_reply_t_handler_json
1353 (vl_api_l2_flags_reply_t * mp)
1355 vat_main_t *vam = &vat_main;
1356 vat_json_node_t node;
1358 vat_json_init_object (&node);
1359 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1360 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1361 ntohl (mp->resulting_feature_bitmap));
1363 vat_json_print (vam->ofp, &node);
1364 vat_json_free (&node);
1366 vam->retval = ntohl (mp->retval);
1367 vam->result_ready = 1;
1370 static void vl_api_bridge_flags_reply_t_handler
1371 (vl_api_bridge_flags_reply_t * mp)
1373 vat_main_t *vam = &vat_main;
1374 i32 retval = ntohl (mp->retval);
1375 if (vam->async_mode)
1377 vam->async_errors += (retval < 0);
1381 vam->retval = retval;
1382 vam->result_ready = 1;
1386 static void vl_api_bridge_flags_reply_t_handler_json
1387 (vl_api_bridge_flags_reply_t * mp)
1389 vat_main_t *vam = &vat_main;
1390 vat_json_node_t node;
1392 vat_json_init_object (&node);
1393 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1394 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1395 ntohl (mp->resulting_feature_bitmap));
1397 vat_json_print (vam->ofp, &node);
1398 vat_json_free (&node);
1400 vam->retval = ntohl (mp->retval);
1401 vam->result_ready = 1;
1404 static void vl_api_tap_connect_reply_t_handler
1405 (vl_api_tap_connect_reply_t * mp)
1407 vat_main_t *vam = &vat_main;
1408 i32 retval = ntohl (mp->retval);
1409 if (vam->async_mode)
1411 vam->async_errors += (retval < 0);
1415 vam->retval = retval;
1416 vam->sw_if_index = ntohl (mp->sw_if_index);
1417 vam->result_ready = 1;
1422 static void vl_api_tap_connect_reply_t_handler_json
1423 (vl_api_tap_connect_reply_t * mp)
1425 vat_main_t *vam = &vat_main;
1426 vat_json_node_t node;
1428 vat_json_init_object (&node);
1429 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1430 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1432 vat_json_print (vam->ofp, &node);
1433 vat_json_free (&node);
1435 vam->retval = ntohl (mp->retval);
1436 vam->result_ready = 1;
1441 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1443 vat_main_t *vam = &vat_main;
1444 i32 retval = ntohl (mp->retval);
1445 if (vam->async_mode)
1447 vam->async_errors += (retval < 0);
1451 vam->retval = retval;
1452 vam->sw_if_index = ntohl (mp->sw_if_index);
1453 vam->result_ready = 1;
1457 static void vl_api_tap_modify_reply_t_handler_json
1458 (vl_api_tap_modify_reply_t * mp)
1460 vat_main_t *vam = &vat_main;
1461 vat_json_node_t node;
1463 vat_json_init_object (&node);
1464 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1465 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1467 vat_json_print (vam->ofp, &node);
1468 vat_json_free (&node);
1470 vam->retval = ntohl (mp->retval);
1471 vam->result_ready = 1;
1475 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1477 vat_main_t *vam = &vat_main;
1478 i32 retval = ntohl (mp->retval);
1479 if (vam->async_mode)
1481 vam->async_errors += (retval < 0);
1485 vam->retval = retval;
1486 vam->result_ready = 1;
1490 static void vl_api_tap_delete_reply_t_handler_json
1491 (vl_api_tap_delete_reply_t * mp)
1493 vat_main_t *vam = &vat_main;
1494 vat_json_node_t node;
1496 vat_json_init_object (&node);
1497 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1499 vat_json_print (vam->ofp, &node);
1500 vat_json_free (&node);
1502 vam->retval = ntohl (mp->retval);
1503 vam->result_ready = 1;
1506 static void vl_api_mpls_ethernet_add_del_tunnel_reply_t_handler
1507 (vl_api_mpls_ethernet_add_del_tunnel_reply_t * mp)
1509 vat_main_t *vam = &vat_main;
1510 i32 retval = ntohl (mp->retval);
1511 if (vam->async_mode)
1513 vam->async_errors += (retval < 0);
1517 vam->retval = retval;
1518 vam->result_ready = 1;
1522 static void vl_api_mpls_ethernet_add_del_tunnel_reply_t_handler_json
1523 (vl_api_mpls_ethernet_add_del_tunnel_reply_t * mp)
1525 vat_main_t *vam = &vat_main;
1526 vat_json_node_t node;
1528 vat_json_init_object (&node);
1529 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1530 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1531 ntohl (mp->tunnel_sw_if_index));
1533 vat_json_print (vam->ofp, &node);
1534 vat_json_free (&node);
1536 vam->retval = ntohl (mp->retval);
1537 vam->result_ready = 1;
1540 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1541 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1543 vat_main_t *vam = &vat_main;
1544 i32 retval = ntohl (mp->retval);
1545 if (vam->async_mode)
1547 vam->async_errors += (retval < 0);
1551 vam->retval = retval;
1552 vam->sw_if_index = ntohl (mp->sw_if_index);
1553 vam->result_ready = 1;
1557 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1558 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1560 vat_main_t *vam = &vat_main;
1561 vat_json_node_t node;
1563 vat_json_init_object (&node);
1564 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1565 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1567 vat_json_print (vam->ofp, &node);
1568 vat_json_free (&node);
1570 vam->retval = ntohl (mp->retval);
1571 vam->result_ready = 1;
1575 static void vl_api_lisp_add_del_locator_set_reply_t_handler
1576 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1578 vat_main_t *vam = &vat_main;
1579 i32 retval = ntohl (mp->retval);
1580 if (vam->async_mode)
1582 vam->async_errors += (retval < 0);
1586 vam->retval = retval;
1587 vam->result_ready = 1;
1591 static void vl_api_lisp_add_del_locator_set_reply_t_handler_json
1592 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1594 vat_main_t *vam = &vat_main;
1595 vat_json_node_t node;
1597 vat_json_init_object (&node);
1598 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1599 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1601 vat_json_print (vam->ofp, &node);
1602 vat_json_free (&node);
1604 vam->retval = ntohl (mp->retval);
1605 vam->result_ready = 1;
1608 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1609 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1611 vat_main_t *vam = &vat_main;
1612 i32 retval = ntohl (mp->retval);
1613 if (vam->async_mode)
1615 vam->async_errors += (retval < 0);
1619 vam->retval = retval;
1620 vam->sw_if_index = ntohl (mp->sw_if_index);
1621 vam->result_ready = 1;
1625 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1626 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1628 vat_main_t *vam = &vat_main;
1629 vat_json_node_t node;
1631 vat_json_init_object (&node);
1632 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1633 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1635 vat_json_print (vam->ofp, &node);
1636 vat_json_free (&node);
1638 vam->retval = ntohl (mp->retval);
1639 vam->result_ready = 1;
1642 static void vl_api_gre_add_del_tunnel_reply_t_handler
1643 (vl_api_gre_add_del_tunnel_reply_t * mp)
1645 vat_main_t *vam = &vat_main;
1646 i32 retval = ntohl (mp->retval);
1647 if (vam->async_mode)
1649 vam->async_errors += (retval < 0);
1653 vam->retval = retval;
1654 vam->sw_if_index = ntohl (mp->sw_if_index);
1655 vam->result_ready = 1;
1659 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1660 (vl_api_gre_add_del_tunnel_reply_t * mp)
1662 vat_main_t *vam = &vat_main;
1663 vat_json_node_t node;
1665 vat_json_init_object (&node);
1666 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1667 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1669 vat_json_print (vam->ofp, &node);
1670 vat_json_free (&node);
1672 vam->retval = ntohl (mp->retval);
1673 vam->result_ready = 1;
1676 static void vl_api_create_vhost_user_if_reply_t_handler
1677 (vl_api_create_vhost_user_if_reply_t * mp)
1679 vat_main_t *vam = &vat_main;
1680 i32 retval = ntohl (mp->retval);
1681 if (vam->async_mode)
1683 vam->async_errors += (retval < 0);
1687 vam->retval = retval;
1688 vam->sw_if_index = ntohl (mp->sw_if_index);
1689 vam->result_ready = 1;
1693 static void vl_api_create_vhost_user_if_reply_t_handler_json
1694 (vl_api_create_vhost_user_if_reply_t * mp)
1696 vat_main_t *vam = &vat_main;
1697 vat_json_node_t node;
1699 vat_json_init_object (&node);
1700 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1701 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1703 vat_json_print (vam->ofp, &node);
1704 vat_json_free (&node);
1706 vam->retval = ntohl (mp->retval);
1707 vam->result_ready = 1;
1710 static void vl_api_ip_address_details_t_handler
1711 (vl_api_ip_address_details_t * mp)
1713 vat_main_t *vam = &vat_main;
1714 static ip_address_details_t empty_ip_address_details = { {0} };
1715 ip_address_details_t *address = NULL;
1716 ip_details_t *current_ip_details = NULL;
1717 ip_details_t *details = NULL;
1719 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1721 if (!details || vam->current_sw_if_index >= vec_len (details)
1722 || !details[vam->current_sw_if_index].present)
1724 errmsg ("ip address details arrived but not stored\n");
1725 errmsg ("ip_dump should be called first\n");
1729 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1731 #define addresses (current_ip_details->addr)
1733 vec_validate_init_empty (addresses, vec_len (addresses),
1734 empty_ip_address_details);
1736 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1738 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1739 address->prefix_length = mp->prefix_length;
1743 static void vl_api_ip_address_details_t_handler_json
1744 (vl_api_ip_address_details_t * mp)
1746 vat_main_t *vam = &vat_main;
1747 vat_json_node_t *node = NULL;
1748 struct in6_addr ip6;
1751 if (VAT_JSON_ARRAY != vam->json_tree.type)
1753 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1754 vat_json_init_array (&vam->json_tree);
1756 node = vat_json_array_add (&vam->json_tree);
1758 vat_json_init_object (node);
1761 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1762 vat_json_object_add_ip6 (node, "ip", ip6);
1766 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1767 vat_json_object_add_ip4 (node, "ip", ip4);
1769 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1773 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1775 vat_main_t *vam = &vat_main;
1776 static ip_details_t empty_ip_details = { 0 };
1777 ip_details_t *ip = NULL;
1778 u32 sw_if_index = ~0;
1780 sw_if_index = ntohl (mp->sw_if_index);
1782 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1783 sw_if_index, empty_ip_details);
1785 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1792 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1794 vat_main_t *vam = &vat_main;
1796 if (VAT_JSON_ARRAY != vam->json_tree.type)
1798 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1799 vat_json_init_array (&vam->json_tree);
1801 vat_json_array_add_uint (&vam->json_tree,
1802 clib_net_to_host_u32 (mp->sw_if_index));
1805 static void vl_api_map_domain_details_t_handler_json
1806 (vl_api_map_domain_details_t * mp)
1808 vat_json_node_t *node = NULL;
1809 vat_main_t *vam = &vat_main;
1810 struct in6_addr ip6;
1813 if (VAT_JSON_ARRAY != vam->json_tree.type)
1815 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1816 vat_json_init_array (&vam->json_tree);
1819 node = vat_json_array_add (&vam->json_tree);
1820 vat_json_init_object (node);
1822 vat_json_object_add_uint (node, "domain_index",
1823 clib_net_to_host_u32 (mp->domain_index));
1824 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1825 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1826 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1827 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1828 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1829 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1830 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1831 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1832 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1833 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1834 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1835 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1836 vat_json_object_add_uint (node, "flags", mp->flags);
1837 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1838 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1841 static void vl_api_map_domain_details_t_handler
1842 (vl_api_map_domain_details_t * mp)
1844 vat_main_t *vam = &vat_main;
1846 if (mp->is_translation)
1849 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u\n",
1850 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1851 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1852 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1853 clib_net_to_host_u32 (mp->domain_index));
1858 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u\n",
1859 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1860 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1861 format_ip6_address, mp->ip6_src,
1862 clib_net_to_host_u32 (mp->domain_index));
1864 fformat (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s\n",
1865 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1866 mp->is_translation ? "map-t" : "");
1869 static void vl_api_map_rule_details_t_handler_json
1870 (vl_api_map_rule_details_t * mp)
1872 struct in6_addr ip6;
1873 vat_json_node_t *node = NULL;
1874 vat_main_t *vam = &vat_main;
1876 if (VAT_JSON_ARRAY != vam->json_tree.type)
1878 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1879 vat_json_init_array (&vam->json_tree);
1882 node = vat_json_array_add (&vam->json_tree);
1883 vat_json_init_object (node);
1885 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1886 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1887 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1891 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1893 vat_main_t *vam = &vat_main;
1894 fformat (vam->ofp, " %d (psid) %U (ip6-dst)\n",
1895 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1899 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1901 vat_main_t *vam = &vat_main;
1902 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1903 "router_addr %U host_mac %U\n",
1904 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1905 format_ip4_address, &mp->host_address,
1906 format_ip4_address, &mp->router_address,
1907 format_ethernet_address, mp->host_mac);
1910 static void vl_api_dhcp_compl_event_t_handler_json
1911 (vl_api_dhcp_compl_event_t * mp)
1913 /* JSON output not supported */
1917 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1920 vat_main_t *vam = &vat_main;
1921 static u64 default_counter = 0;
1923 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
1925 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
1926 sw_if_index, default_counter);
1927 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
1931 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1932 interface_counter_t counter)
1934 vat_main_t *vam = &vat_main;
1935 static interface_counter_t default_counter = { 0, };
1937 vec_validate_init_empty (vam->combined_interface_counters,
1938 vnet_counter_type, NULL);
1939 vec_validate_init_empty (vam->combined_interface_counters
1940 [vnet_counter_type], sw_if_index, default_counter);
1941 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
1944 static void vl_api_vnet_interface_counters_t_handler
1945 (vl_api_vnet_interface_counters_t * mp)
1950 static void vl_api_vnet_interface_counters_t_handler_json
1951 (vl_api_vnet_interface_counters_t * mp)
1953 interface_counter_t counter;
1958 u32 first_sw_if_index;
1961 count = ntohl (mp->count);
1962 first_sw_if_index = ntohl (mp->first_sw_if_index);
1964 if (!mp->is_combined)
1966 v_packets = (u64 *) & mp->data;
1967 for (i = 0; i < count; i++)
1970 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
1971 set_simple_interface_counter (mp->vnet_counter_type,
1972 first_sw_if_index + i, packets);
1978 v = (vlib_counter_t *) & mp->data;
1979 for (i = 0; i < count; i++)
1982 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
1984 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
1985 set_combined_interface_counter (mp->vnet_counter_type,
1986 first_sw_if_index + i, counter);
1993 ip4_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->ip4_fib_counters_vrf_id_by_index); i++)
2000 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2009 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2011 vat_main_t *vam = &vat_main;
2014 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2016 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2024 static void vl_api_vnet_ip4_fib_counters_t_handler
2025 (vl_api_vnet_ip4_fib_counters_t * mp)
2030 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2031 (vl_api_vnet_ip4_fib_counters_t * mp)
2033 vat_main_t *vam = &vat_main;
2034 vl_api_ip4_fib_counter_t *v;
2035 ip4_fib_counter_t *counter;
2042 vrf_id = ntohl (mp->vrf_id);
2043 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2044 if (~0 == vrf_index)
2046 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2047 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2048 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2049 vec_validate (vam->ip4_fib_counters, vrf_index);
2050 vam->ip4_fib_counters[vrf_index] = NULL;
2053 vec_free (vam->ip4_fib_counters[vrf_index]);
2054 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2055 count = ntohl (mp->count);
2056 for (i = 0; i < count; i++)
2058 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2059 counter = &vam->ip4_fib_counters[vrf_index][i];
2060 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2061 counter->address = ip4;
2062 counter->address_length = v->address_length;
2063 counter->packets = clib_net_to_host_u64 (v->packets);
2064 counter->bytes = clib_net_to_host_u64 (v->bytes);
2069 static void vl_api_vnet_ip6_fib_counters_t_handler
2070 (vl_api_vnet_ip6_fib_counters_t * mp)
2075 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2076 (vl_api_vnet_ip6_fib_counters_t * mp)
2078 vat_main_t *vam = &vat_main;
2079 vl_api_ip6_fib_counter_t *v;
2080 ip6_fib_counter_t *counter;
2081 struct in6_addr ip6;
2087 vrf_id = ntohl (mp->vrf_id);
2088 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2089 if (~0 == vrf_index)
2091 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2092 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2093 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2094 vec_validate (vam->ip6_fib_counters, vrf_index);
2095 vam->ip6_fib_counters[vrf_index] = NULL;
2098 vec_free (vam->ip6_fib_counters[vrf_index]);
2099 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2100 count = ntohl (mp->count);
2101 for (i = 0; i < count; i++)
2103 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2104 counter = &vam->ip6_fib_counters[vrf_index][i];
2105 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2106 counter->address = ip6;
2107 counter->address_length = v->address_length;
2108 counter->packets = clib_net_to_host_u64 (v->packets);
2109 counter->bytes = clib_net_to_host_u64 (v->bytes);
2114 static void vl_api_get_first_msg_id_reply_t_handler
2115 (vl_api_get_first_msg_id_reply_t * mp)
2117 vat_main_t *vam = &vat_main;
2118 i32 retval = ntohl (mp->retval);
2120 if (vam->async_mode)
2122 vam->async_errors += (retval < 0);
2126 vam->retval = retval;
2127 vam->result_ready = 1;
2131 errmsg ("first message id %d\n", ntohs (mp->first_msg_id));
2135 static void vl_api_get_first_msg_id_reply_t_handler_json
2136 (vl_api_get_first_msg_id_reply_t * mp)
2138 vat_main_t *vam = &vat_main;
2139 vat_json_node_t node;
2141 vat_json_init_object (&node);
2142 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2143 vat_json_object_add_uint (&node, "first_msg_id",
2144 (uint) ntohs (mp->first_msg_id));
2146 vat_json_print (vam->ofp, &node);
2147 vat_json_free (&node);
2149 vam->retval = ntohl (mp->retval);
2150 vam->result_ready = 1;
2153 static void vl_api_get_node_graph_reply_t_handler
2154 (vl_api_get_node_graph_reply_t * mp)
2156 vat_main_t *vam = &vat_main;
2157 api_main_t *am = &api_main;
2158 i32 retval = ntohl (mp->retval);
2159 u8 *pvt_copy, *reply;
2164 if (vam->async_mode)
2166 vam->async_errors += (retval < 0);
2170 vam->retval = retval;
2171 vam->result_ready = 1;
2174 /* "Should never happen..." */
2178 reply = (u8 *) (mp->reply_in_shmem);
2179 pvt_copy = vec_dup (reply);
2181 /* Toss the shared-memory original... */
2182 pthread_mutex_lock (&am->vlib_rp->mutex);
2183 oldheap = svm_push_data_heap (am->vlib_rp);
2187 svm_pop_heap (oldheap);
2188 pthread_mutex_unlock (&am->vlib_rp->mutex);
2190 if (vam->graph_nodes)
2192 hash_free (vam->graph_node_index_by_name);
2194 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2196 node = vam->graph_nodes[i];
2197 vec_free (node->name);
2198 vec_free (node->next_nodes);
2201 vec_free (vam->graph_nodes);
2204 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2205 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2206 vec_free (pvt_copy);
2208 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2210 node = vam->graph_nodes[i];
2211 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2215 static void vl_api_get_node_graph_reply_t_handler_json
2216 (vl_api_get_node_graph_reply_t * mp)
2218 vat_main_t *vam = &vat_main;
2219 api_main_t *am = &api_main;
2221 vat_json_node_t node;
2224 /* $$$$ make this real? */
2225 vat_json_init_object (&node);
2226 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2227 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2229 reply = (u8 *) (mp->reply_in_shmem);
2231 /* Toss the shared-memory original... */
2232 pthread_mutex_lock (&am->vlib_rp->mutex);
2233 oldheap = svm_push_data_heap (am->vlib_rp);
2237 svm_pop_heap (oldheap);
2238 pthread_mutex_unlock (&am->vlib_rp->mutex);
2240 vat_json_print (vam->ofp, &node);
2241 vat_json_free (&node);
2243 vam->retval = ntohl (mp->retval);
2244 vam->result_ready = 1;
2248 vl_api_lisp_locator_details_t_handler (vl_api_lisp_locator_details_t * mp)
2250 vat_main_t *vam = &vat_main;
2255 s = format (s, "%=16d%=16d%=16d\n",
2256 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2260 s = format (s, "%=16U%=16d%=16d\n",
2261 mp->is_ipv6 ? format_ip6_address :
2263 mp->ip_address, mp->priority, mp->weight);
2266 fformat (vam->ofp, "%v", s);
2271 vl_api_lisp_locator_details_t_handler_json (vl_api_lisp_locator_details_t *
2274 vat_main_t *vam = &vat_main;
2275 vat_json_node_t *node = NULL;
2276 struct in6_addr ip6;
2279 if (VAT_JSON_ARRAY != vam->json_tree.type)
2281 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2282 vat_json_init_array (&vam->json_tree);
2284 node = vat_json_array_add (&vam->json_tree);
2285 vat_json_init_object (node);
2287 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2288 vat_json_object_add_uint (node, "priority", mp->priority);
2289 vat_json_object_add_uint (node, "weight", mp->weight);
2292 vat_json_object_add_uint (node, "sw_if_index",
2293 clib_net_to_host_u32 (mp->sw_if_index));
2298 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2299 vat_json_object_add_ip6 (node, "address", ip6);
2303 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2304 vat_json_object_add_ip4 (node, "address", ip4);
2310 vl_api_lisp_locator_set_details_t_handler (vl_api_lisp_locator_set_details_t *
2313 vat_main_t *vam = &vat_main;
2316 ls_name = format (0, "%s", mp->ls_name);
2318 fformat (vam->ofp, "%=10d%=15v\n", clib_net_to_host_u32 (mp->ls_index),
2324 vl_api_lisp_locator_set_details_t_handler_json
2325 (vl_api_lisp_locator_set_details_t * mp)
2327 vat_main_t *vam = &vat_main;
2328 vat_json_node_t *node = 0;
2331 ls_name = format (0, "%s", mp->ls_name);
2332 vec_add1 (ls_name, 0);
2334 if (VAT_JSON_ARRAY != vam->json_tree.type)
2336 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2337 vat_json_init_array (&vam->json_tree);
2339 node = vat_json_array_add (&vam->json_tree);
2341 vat_json_init_object (node);
2342 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2343 vat_json_object_add_uint (node, "ls_index",
2344 clib_net_to_host_u32 (mp->ls_index));
2349 format_lisp_flat_eid (u8 * s, va_list * args)
2351 u32 type = va_arg (*args, u32);
2352 u8 *eid = va_arg (*args, u8 *);
2353 u32 eid_len = va_arg (*args, u32);
2358 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2360 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2362 return format (s, "%U", format_ethernet_address, eid);
2368 format_lisp_eid_vat (u8 * s, va_list * args)
2370 u32 type = va_arg (*args, u32);
2371 u8 *eid = va_arg (*args, u8 *);
2372 u32 eid_len = va_arg (*args, u32);
2373 u8 *seid = va_arg (*args, u8 *);
2374 u32 seid_len = va_arg (*args, u32);
2375 u32 is_src_dst = va_arg (*args, u32);
2378 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2380 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2386 vl_api_lisp_eid_table_details_t_handler (vl_api_lisp_eid_table_details_t * mp)
2388 vat_main_t *vam = &vat_main;
2389 u8 *s = 0, *eid = 0;
2391 if (~0 == mp->locator_set_index)
2392 s = format (0, "action: %d", mp->action);
2394 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2396 eid = format (0, "%U", format_lisp_eid_vat,
2400 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2403 fformat (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-d\n",
2404 clib_net_to_host_u32 (mp->vni),
2406 mp->is_local ? "local" : "remote",
2407 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative);
2413 vl_api_lisp_eid_table_details_t_handler_json (vl_api_lisp_eid_table_details_t
2416 vat_main_t *vam = &vat_main;
2417 vat_json_node_t *node = 0;
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);
2427 vat_json_init_object (node);
2428 if (~0 == mp->locator_set_index)
2429 vat_json_object_add_uint (node, "action", mp->action);
2431 vat_json_object_add_uint (node, "locator_set_index",
2432 clib_net_to_host_u32 (mp->locator_set_index));
2434 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2435 eid = format (0, "%U", format_lisp_eid_vat,
2439 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2441 vat_json_object_add_string_copy (node, "eid", eid);
2442 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2443 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2444 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2449 vl_api_lisp_eid_table_map_details_t_handler
2450 (vl_api_lisp_eid_table_map_details_t * mp)
2452 vat_main_t *vam = &vat_main;
2454 u8 *line = format (0, "%=10d%=10d",
2455 clib_net_to_host_u32 (mp->vni),
2456 clib_net_to_host_u32 (mp->dp_table));
2457 fformat (vam->ofp, "%v\n", line);
2462 vl_api_lisp_eid_table_map_details_t_handler_json
2463 (vl_api_lisp_eid_table_map_details_t * mp)
2465 vat_main_t *vam = &vat_main;
2466 vat_json_node_t *node = NULL;
2468 if (VAT_JSON_ARRAY != vam->json_tree.type)
2470 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2471 vat_json_init_array (&vam->json_tree);
2473 node = vat_json_array_add (&vam->json_tree);
2474 vat_json_init_object (node);
2475 vat_json_object_add_uint (node, "dp_table",
2476 clib_net_to_host_u32 (mp->dp_table));
2477 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2481 vl_api_lisp_eid_table_vni_details_t_handler
2482 (vl_api_lisp_eid_table_vni_details_t * mp)
2484 vat_main_t *vam = &vat_main;
2486 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2487 fformat (vam->ofp, "%v\n", line);
2492 vl_api_lisp_eid_table_vni_details_t_handler_json
2493 (vl_api_lisp_eid_table_vni_details_t * mp)
2495 vat_main_t *vam = &vat_main;
2496 vat_json_node_t *node = NULL;
2498 if (VAT_JSON_ARRAY != vam->json_tree.type)
2500 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2501 vat_json_init_array (&vam->json_tree);
2503 node = vat_json_array_add (&vam->json_tree);
2504 vat_json_init_object (node);
2505 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2509 format_decap_next (u8 * s, va_list * args)
2511 u32 next_index = va_arg (*args, u32);
2515 case LISP_GPE_INPUT_NEXT_DROP:
2516 return format (s, "drop");
2517 case LISP_GPE_INPUT_NEXT_IP4_INPUT:
2518 return format (s, "ip4");
2519 case LISP_GPE_INPUT_NEXT_IP6_INPUT:
2520 return format (s, "ip6");
2522 return format (s, "unknown %d", next_index);
2528 vl_api_lisp_gpe_tunnel_details_t_handler (vl_api_lisp_gpe_tunnel_details_t *
2531 vat_main_t *vam = &vat_main;
2533 u8 *flag_str = NULL;
2535 iid_str = format (0, "%d (0x%x)", ntohl (mp->iid), ntohl (mp->iid));
2537 #define _(n,v) if (mp->flags & v) flag_str = format (flag_str, "%s-bit ", #n);
2538 foreach_lisp_gpe_flag_bit;
2541 fformat (vam->ofp, "%=20d%=30U%=16U%=16d%=16d%=16U"
2542 "%=16d%=16d%=16sd=16d%=16s%=16s\n",
2544 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2546 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2548 ntohl (mp->encap_fib_id),
2549 ntohl (mp->decap_fib_id),
2550 format_decap_next, ntohl (mp->dcap_next),
2552 flag_str, mp->next_protocol, mp->ver_res, mp->res, iid_str);
2558 vl_api_lisp_gpe_tunnel_details_t_handler_json
2559 (vl_api_lisp_gpe_tunnel_details_t * mp)
2561 vat_main_t *vam = &vat_main;
2562 vat_json_node_t *node = NULL;
2563 struct in6_addr ip6;
2567 next_decap_str = format (0, "%U", format_decap_next, htonl (mp->dcap_next));
2569 if (VAT_JSON_ARRAY != vam->json_tree.type)
2571 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2572 vat_json_init_array (&vam->json_tree);
2574 node = vat_json_array_add (&vam->json_tree);
2576 vat_json_init_object (node);
2577 vat_json_object_add_uint (node, "tunel", mp->tunnels);
2580 clib_memcpy (&ip6, mp->source_ip, sizeof (ip6));
2581 vat_json_object_add_ip6 (node, "source address", ip6);
2582 clib_memcpy (&ip6, mp->destination_ip, sizeof (ip6));
2583 vat_json_object_add_ip6 (node, "destination address", ip6);
2587 clib_memcpy (&ip4, mp->source_ip, sizeof (ip4));
2588 vat_json_object_add_ip4 (node, "source address", ip4);
2589 clib_memcpy (&ip4, mp->destination_ip, sizeof (ip4));
2590 vat_json_object_add_ip4 (node, "destination address", ip4);
2592 vat_json_object_add_uint (node, "fib encap", ntohl (mp->encap_fib_id));
2593 vat_json_object_add_uint (node, "fib decap", ntohl (mp->decap_fib_id));
2594 vat_json_object_add_string_copy (node, "decap next", next_decap_str);
2595 vat_json_object_add_uint (node, "lisp version", mp->ver_res >> 6);
2596 vat_json_object_add_uint (node, "flags", mp->flags);
2597 vat_json_object_add_uint (node, "next protocol", mp->next_protocol);
2598 vat_json_object_add_uint (node, "ver_res", mp->ver_res);
2599 vat_json_object_add_uint (node, "res", mp->res);
2600 vat_json_object_add_uint (node, "iid", ntohl (mp->iid));
2602 vec_free (next_decap_str);
2606 vl_api_lisp_adjacencies_get_reply_t_handler
2607 (vl_api_lisp_adjacencies_get_reply_t * mp)
2609 vat_main_t *vam = &vat_main;
2611 int retval = clib_net_to_host_u32 (mp->retval);
2612 vl_api_lisp_adjacency_t *a;
2617 n = clib_net_to_host_u32 (mp->count);
2619 for (i = 0; i < n; i++)
2621 a = &mp->adjacencies[i];
2622 fformat (vam->ofp, "%U %40U\n",
2623 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
2624 format_lisp_flat_eid, a->eid_type, a->reid,
2625 a->reid_prefix_len);
2629 vam->retval = retval;
2630 vam->result_ready = 1;
2634 vl_api_lisp_adjacencies_get_reply_t_handler_json
2635 (vl_api_lisp_adjacencies_get_reply_t * mp)
2638 vat_main_t *vam = &vat_main;
2639 vat_json_node_t *e = 0, root;
2641 int retval = clib_net_to_host_u32 (mp->retval);
2642 vl_api_lisp_adjacency_t *a;
2647 n = clib_net_to_host_u32 (mp->count);
2648 vat_json_init_array (&root);
2650 for (i = 0; i < n; i++)
2652 e = vat_json_array_add (&root);
2653 a = &mp->adjacencies[i];
2655 vat_json_init_object (e);
2656 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
2657 a->leid_prefix_len);
2659 vat_json_object_add_string_copy (e, "leid", s);
2662 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
2663 a->reid_prefix_len);
2665 vat_json_object_add_string_copy (e, "reid", s);
2669 vat_json_print (vam->ofp, &root);
2670 vat_json_free (&root);
2673 vam->retval = retval;
2674 vam->result_ready = 1;
2678 vl_api_lisp_map_resolver_details_t_handler (vl_api_lisp_map_resolver_details_t
2681 vat_main_t *vam = &vat_main;
2683 fformat (vam->ofp, "%=20U\n",
2684 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2689 vl_api_lisp_map_resolver_details_t_handler_json
2690 (vl_api_lisp_map_resolver_details_t * mp)
2692 vat_main_t *vam = &vat_main;
2693 vat_json_node_t *node = NULL;
2694 struct in6_addr ip6;
2697 if (VAT_JSON_ARRAY != vam->json_tree.type)
2699 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2700 vat_json_init_array (&vam->json_tree);
2702 node = vat_json_array_add (&vam->json_tree);
2704 vat_json_init_object (node);
2707 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2708 vat_json_object_add_ip6 (node, "map resolver", ip6);
2712 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2713 vat_json_object_add_ip4 (node, "map resolver", ip4);
2718 vl_api_show_lisp_status_reply_t_handler
2719 (vl_api_show_lisp_status_reply_t * mp)
2721 vat_main_t *vam = &vat_main;
2722 i32 retval = ntohl (mp->retval);
2726 fformat (vam->ofp, "feature: %s\ngpe: %s\n",
2727 mp->feature_status ? "enabled" : "disabled",
2728 mp->gpe_status ? "enabled" : "disabled");
2731 vam->retval = retval;
2732 vam->result_ready = 1;
2736 vl_api_show_lisp_status_reply_t_handler_json
2737 (vl_api_show_lisp_status_reply_t * mp)
2739 vat_main_t *vam = &vat_main;
2740 vat_json_node_t node;
2741 u8 *gpe_status = NULL;
2742 u8 *feature_status = NULL;
2744 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
2745 feature_status = format (0, "%s",
2746 mp->feature_status ? "enabled" : "disabled");
2747 vec_add1 (gpe_status, 0);
2748 vec_add1 (feature_status, 0);
2750 vat_json_init_object (&node);
2751 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
2752 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
2754 vec_free (gpe_status);
2755 vec_free (feature_status);
2757 vat_json_print (vam->ofp, &node);
2758 vat_json_free (&node);
2760 vam->retval = ntohl (mp->retval);
2761 vam->result_ready = 1;
2765 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler
2766 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2768 vat_main_t *vam = &vat_main;
2769 i32 retval = ntohl (mp->retval);
2773 fformat (vam->ofp, "%=20s\n", mp->locator_set_name);
2776 vam->retval = retval;
2777 vam->result_ready = 1;
2781 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler_json
2782 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2784 vat_main_t *vam = &vat_main;
2785 vat_json_node_t *node = NULL;
2787 if (VAT_JSON_ARRAY != vam->json_tree.type)
2789 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2790 vat_json_init_array (&vam->json_tree);
2792 node = vat_json_array_add (&vam->json_tree);
2794 vat_json_init_object (node);
2795 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
2797 vat_json_print (vam->ofp, node);
2798 vat_json_free (node);
2800 vam->retval = ntohl (mp->retval);
2801 vam->result_ready = 1;
2805 format_lisp_map_request_mode (u8 * s, va_list * args)
2807 u32 mode = va_arg (*args, u32);
2812 return format (0, "dst-only");
2814 return format (0, "src-dst");
2820 vl_api_show_lisp_map_request_mode_reply_t_handler
2821 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2823 vat_main_t *vam = &vat_main;
2824 i32 retval = ntohl (mp->retval);
2828 u32 mode = mp->mode;
2829 fformat (vam->ofp, "map_request_mode: %U\n",
2830 format_lisp_map_request_mode, mode);
2833 vam->retval = retval;
2834 vam->result_ready = 1;
2838 vl_api_show_lisp_map_request_mode_reply_t_handler_json
2839 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2841 vat_main_t *vam = &vat_main;
2842 vat_json_node_t node;
2847 s = format (0, "%U", format_lisp_map_request_mode, mode);
2850 vat_json_init_object (&node);
2851 vat_json_object_add_string_copy (&node, "map_request_mode", s);
2852 vat_json_print (vam->ofp, &node);
2853 vat_json_free (&node);
2856 vam->retval = ntohl (mp->retval);
2857 vam->result_ready = 1;
2861 vl_api_show_lisp_pitr_reply_t_handler (vl_api_show_lisp_pitr_reply_t * mp)
2863 vat_main_t *vam = &vat_main;
2864 i32 retval = ntohl (mp->retval);
2868 fformat (vam->ofp, "%-20s%-16s\n",
2869 mp->status ? "enabled" : "disabled",
2870 mp->status ? (char *) mp->locator_set_name : "");
2873 vam->retval = retval;
2874 vam->result_ready = 1;
2878 vl_api_show_lisp_pitr_reply_t_handler_json (vl_api_show_lisp_pitr_reply_t *
2881 vat_main_t *vam = &vat_main;
2882 vat_json_node_t node;
2885 status = format (0, "%s", mp->status ? "enabled" : "disabled");
2886 vec_add1 (status, 0);
2888 vat_json_init_object (&node);
2889 vat_json_object_add_string_copy (&node, "status", status);
2892 vat_json_object_add_string_copy (&node, "locator_set",
2893 mp->locator_set_name);
2898 vat_json_print (vam->ofp, &node);
2899 vat_json_free (&node);
2901 vam->retval = ntohl (mp->retval);
2902 vam->result_ready = 1;
2906 format_policer_type (u8 * s, va_list * va)
2908 u32 i = va_arg (*va, u32);
2910 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
2911 s = format (s, "1r2c");
2912 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
2913 s = format (s, "1r3c");
2914 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
2915 s = format (s, "2r3c-2698");
2916 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
2917 s = format (s, "2r3c-4115");
2918 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
2919 s = format (s, "2r3c-mef5cf1");
2921 s = format (s, "ILLEGAL");
2926 format_policer_rate_type (u8 * s, va_list * va)
2928 u32 i = va_arg (*va, u32);
2930 if (i == SSE2_QOS_RATE_KBPS)
2931 s = format (s, "kbps");
2932 else if (i == SSE2_QOS_RATE_PPS)
2933 s = format (s, "pps");
2935 s = format (s, "ILLEGAL");
2940 format_policer_round_type (u8 * s, va_list * va)
2942 u32 i = va_arg (*va, u32);
2944 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
2945 s = format (s, "closest");
2946 else if (i == SSE2_QOS_ROUND_TO_UP)
2947 s = format (s, "up");
2948 else if (i == SSE2_QOS_ROUND_TO_DOWN)
2949 s = format (s, "down");
2951 s = format (s, "ILLEGAL");
2956 format_policer_action_type (u8 * s, va_list * va)
2958 u32 i = va_arg (*va, u32);
2960 if (i == SSE2_QOS_ACTION_DROP)
2961 s = format (s, "drop");
2962 else if (i == SSE2_QOS_ACTION_TRANSMIT)
2963 s = format (s, "transmit");
2964 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2965 s = format (s, "mark-and-transmit");
2967 s = format (s, "ILLEGAL");
2972 format_dscp (u8 * s, va_list * va)
2974 u32 i = va_arg (*va, u32);
2979 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
2983 return format (s, "ILLEGAL");
2985 s = format (s, "%s", t);
2990 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
2992 vat_main_t *vam = &vat_main;
2993 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
2995 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2996 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
2998 conform_dscp_str = format (0, "");
3000 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3001 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3003 exceed_dscp_str = format (0, "");
3005 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3006 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3008 violate_dscp_str = format (0, "");
3010 fformat (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3011 "rate type %U, round type %U, %s rate, %s color-aware, "
3012 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3013 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3014 "conform action %U%s, exceed action %U%s, violate action %U%s\n",
3016 format_policer_type, mp->type,
3019 clib_net_to_host_u64 (mp->cb),
3020 clib_net_to_host_u64 (mp->eb),
3021 format_policer_rate_type, mp->rate_type,
3022 format_policer_round_type, mp->round_type,
3023 mp->single_rate ? "single" : "dual",
3024 mp->color_aware ? "is" : "not",
3025 ntohl (mp->cir_tokens_per_period),
3026 ntohl (mp->pir_tokens_per_period),
3028 ntohl (mp->current_limit),
3029 ntohl (mp->current_bucket),
3030 ntohl (mp->extended_limit),
3031 ntohl (mp->extended_bucket),
3032 clib_net_to_host_u64 (mp->last_update_time),
3033 format_policer_action_type, mp->conform_action_type,
3035 format_policer_action_type, mp->exceed_action_type,
3037 format_policer_action_type, mp->violate_action_type,
3040 vec_free (conform_dscp_str);
3041 vec_free (exceed_dscp_str);
3042 vec_free (violate_dscp_str);
3045 static void vl_api_policer_details_t_handler_json
3046 (vl_api_policer_details_t * mp)
3048 vat_main_t *vam = &vat_main;
3049 vat_json_node_t *node;
3050 u8 *rate_type_str, *round_type_str, *type_str;
3051 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3053 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3055 format (0, "%U", format_policer_round_type, mp->round_type);
3056 type_str = format (0, "%U", format_policer_type, mp->type);
3057 conform_action_str = format (0, "%U", format_policer_action_type,
3058 mp->conform_action_type);
3059 exceed_action_str = format (0, "%U", format_policer_action_type,
3060 mp->exceed_action_type);
3061 violate_action_str = format (0, "%U", format_policer_action_type,
3062 mp->violate_action_type);
3064 if (VAT_JSON_ARRAY != vam->json_tree.type)
3066 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3067 vat_json_init_array (&vam->json_tree);
3069 node = vat_json_array_add (&vam->json_tree);
3071 vat_json_init_object (node);
3072 vat_json_object_add_string_copy (node, "name", mp->name);
3073 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3074 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3075 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3076 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3077 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3078 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3079 vat_json_object_add_string_copy (node, "type", type_str);
3080 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3081 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3082 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3083 vat_json_object_add_uint (node, "cir_tokens_per_period",
3084 ntohl (mp->cir_tokens_per_period));
3085 vat_json_object_add_uint (node, "eir_tokens_per_period",
3086 ntohl (mp->pir_tokens_per_period));
3087 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3088 vat_json_object_add_uint (node, "current_bucket",
3089 ntohl (mp->current_bucket));
3090 vat_json_object_add_uint (node, "extended_limit",
3091 ntohl (mp->extended_limit));
3092 vat_json_object_add_uint (node, "extended_bucket",
3093 ntohl (mp->extended_bucket));
3094 vat_json_object_add_uint (node, "last_update_time",
3095 ntohl (mp->last_update_time));
3096 vat_json_object_add_string_copy (node, "conform_action",
3097 conform_action_str);
3098 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3100 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3101 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3102 vec_free (dscp_str);
3104 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3105 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3107 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3108 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3109 vec_free (dscp_str);
3111 vat_json_object_add_string_copy (node, "violate_action",
3112 violate_action_str);
3113 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3115 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3116 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3117 vec_free (dscp_str);
3120 vec_free (rate_type_str);
3121 vec_free (round_type_str);
3122 vec_free (type_str);
3123 vec_free (conform_action_str);
3124 vec_free (exceed_action_str);
3125 vec_free (violate_action_str);
3129 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3132 vat_main_t *vam = &vat_main;
3133 int i, count = ntohl (mp->count);
3136 fformat (vam->ofp, "classify table ids (%d) : ", count);
3137 for (i = 0; i < count; i++)
3139 fformat (vam->ofp, "%d", ntohl (mp->ids[i]));
3140 fformat (vam->ofp, (i < count - 1) ? "," : "\n");
3142 vam->retval = ntohl (mp->retval);
3143 vam->result_ready = 1;
3147 vl_api_classify_table_ids_reply_t_handler_json
3148 (vl_api_classify_table_ids_reply_t * mp)
3150 vat_main_t *vam = &vat_main;
3151 int i, count = ntohl (mp->count);
3155 vat_json_node_t node;
3157 vat_json_init_object (&node);
3158 for (i = 0; i < count; i++)
3160 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3162 vat_json_print (vam->ofp, &node);
3163 vat_json_free (&node);
3165 vam->retval = ntohl (mp->retval);
3166 vam->result_ready = 1;
3170 vl_api_classify_table_by_interface_reply_t_handler
3171 (vl_api_classify_table_by_interface_reply_t * mp)
3173 vat_main_t *vam = &vat_main;
3176 table_id = ntohl (mp->l2_table_id);
3178 fformat (vam->ofp, "l2 table id : %d\n", table_id);
3180 fformat (vam->ofp, "l2 table id : No input ACL tables configured\n");
3181 table_id = ntohl (mp->ip4_table_id);
3183 fformat (vam->ofp, "ip4 table id : %d\n", table_id);
3185 fformat (vam->ofp, "ip4 table id : No input ACL tables configured\n");
3186 table_id = ntohl (mp->ip6_table_id);
3188 fformat (vam->ofp, "ip6 table id : %d\n", table_id);
3190 fformat (vam->ofp, "ip6 table id : No input ACL tables configured\n");
3191 vam->retval = ntohl (mp->retval);
3192 vam->result_ready = 1;
3196 vl_api_classify_table_by_interface_reply_t_handler_json
3197 (vl_api_classify_table_by_interface_reply_t * mp)
3199 vat_main_t *vam = &vat_main;
3200 vat_json_node_t node;
3202 vat_json_init_object (&node);
3204 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3205 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3206 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3208 vat_json_print (vam->ofp, &node);
3209 vat_json_free (&node);
3211 vam->retval = ntohl (mp->retval);
3212 vam->result_ready = 1;
3215 static void vl_api_policer_add_del_reply_t_handler
3216 (vl_api_policer_add_del_reply_t * mp)
3218 vat_main_t *vam = &vat_main;
3219 i32 retval = ntohl (mp->retval);
3220 if (vam->async_mode)
3222 vam->async_errors += (retval < 0);
3226 vam->retval = retval;
3227 vam->result_ready = 1;
3228 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3230 * Note: this is just barely thread-safe, depends on
3231 * the main thread spinning waiting for an answer...
3233 errmsg ("policer index %d\n", ntohl (mp->policer_index));
3237 static void vl_api_policer_add_del_reply_t_handler_json
3238 (vl_api_policer_add_del_reply_t * mp)
3240 vat_main_t *vam = &vat_main;
3241 vat_json_node_t node;
3243 vat_json_init_object (&node);
3244 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3245 vat_json_object_add_uint (&node, "policer_index",
3246 ntohl (mp->policer_index));
3248 vat_json_print (vam->ofp, &node);
3249 vat_json_free (&node);
3251 vam->retval = ntohl (mp->retval);
3252 vam->result_ready = 1;
3255 /* Format hex dump. */
3257 format_hex_bytes (u8 * s, va_list * va)
3259 u8 *bytes = va_arg (*va, u8 *);
3260 int n_bytes = va_arg (*va, int);
3263 /* Print short or long form depending on byte count. */
3264 uword short_form = n_bytes <= 32;
3265 uword indent = format_get_indent (s);
3270 for (i = 0; i < n_bytes; i++)
3272 if (!short_form && (i % 32) == 0)
3273 s = format (s, "%08x: ", i);
3274 s = format (s, "%02x", bytes[i]);
3275 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3276 s = format (s, "\n%U", format_white_space, indent);
3283 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3286 vat_main_t *vam = &vat_main;
3287 i32 retval = ntohl (mp->retval);
3290 fformat (vam->ofp, "classify table info :\n");
3291 fformat (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d\n",
3292 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3293 ntohl (mp->miss_next_index));
3294 fformat (vam->ofp, "nbuckets: %d skip: %d match: %d\n",
3295 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3296 ntohl (mp->match_n_vectors));
3297 fformat (vam->ofp, "mask: %U\n", format_hex_bytes, mp->mask,
3298 ntohl (mp->mask_length));
3300 vam->retval = retval;
3301 vam->result_ready = 1;
3305 vl_api_classify_table_info_reply_t_handler_json
3306 (vl_api_classify_table_info_reply_t * mp)
3308 vat_main_t *vam = &vat_main;
3309 vat_json_node_t node;
3311 i32 retval = ntohl (mp->retval);
3314 vat_json_init_object (&node);
3316 vat_json_object_add_int (&node, "sessions",
3317 ntohl (mp->active_sessions));
3318 vat_json_object_add_int (&node, "nexttbl",
3319 ntohl (mp->next_table_index));
3320 vat_json_object_add_int (&node, "nextnode",
3321 ntohl (mp->miss_next_index));
3322 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3323 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3324 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3325 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3326 ntohl (mp->mask_length), 0);
3327 vat_json_object_add_string_copy (&node, "mask", s);
3329 vat_json_print (vam->ofp, &node);
3330 vat_json_free (&node);
3332 vam->retval = ntohl (mp->retval);
3333 vam->result_ready = 1;
3337 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3340 vat_main_t *vam = &vat_main;
3342 fformat (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3343 ntohl (mp->hit_next_index), ntohl (mp->advance),
3344 ntohl (mp->opaque_index));
3345 fformat (vam->ofp, "mask: %U\n", format_hex_bytes, mp->match,
3346 ntohl (mp->match_length));
3350 vl_api_classify_session_details_t_handler_json
3351 (vl_api_classify_session_details_t * mp)
3353 vat_main_t *vam = &vat_main;
3354 vat_json_node_t *node = NULL;
3356 if (VAT_JSON_ARRAY != vam->json_tree.type)
3358 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3359 vat_json_init_array (&vam->json_tree);
3361 node = vat_json_array_add (&vam->json_tree);
3363 vat_json_init_object (node);
3364 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3365 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3366 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3368 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3370 vat_json_object_add_string_copy (node, "match", s);
3373 static void vl_api_pg_create_interface_reply_t_handler
3374 (vl_api_pg_create_interface_reply_t * mp)
3376 vat_main_t *vam = &vat_main;
3378 vam->retval = ntohl (mp->retval);
3379 vam->result_ready = 1;
3382 static void vl_api_pg_create_interface_reply_t_handler_json
3383 (vl_api_pg_create_interface_reply_t * mp)
3385 vat_main_t *vam = &vat_main;
3386 vat_json_node_t node;
3388 i32 retval = ntohl (mp->retval);
3391 vat_json_init_object (&node);
3393 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3395 vat_json_print (vam->ofp, &node);
3396 vat_json_free (&node);
3398 vam->retval = ntohl (mp->retval);
3399 vam->result_ready = 1;
3402 static void vl_api_policer_classify_details_t_handler
3403 (vl_api_policer_classify_details_t * mp)
3405 vat_main_t *vam = &vat_main;
3407 fformat (vam->ofp, "%10d%20d\n", ntohl (mp->sw_if_index),
3408 ntohl (mp->table_index));
3411 static void vl_api_policer_classify_details_t_handler_json
3412 (vl_api_policer_classify_details_t * mp)
3414 vat_main_t *vam = &vat_main;
3415 vat_json_node_t *node;
3417 if (VAT_JSON_ARRAY != vam->json_tree.type)
3419 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3420 vat_json_init_array (&vam->json_tree);
3422 node = vat_json_array_add (&vam->json_tree);
3424 vat_json_init_object (node);
3425 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3426 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3429 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3430 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3432 vat_main_t *vam = &vat_main;
3433 i32 retval = ntohl (mp->retval);
3434 if (vam->async_mode)
3436 vam->async_errors += (retval < 0);
3440 vam->retval = retval;
3441 vam->sw_if_index = ntohl (mp->sw_if_index);
3442 vam->result_ready = 1;
3446 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3447 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3449 vat_main_t *vam = &vat_main;
3450 vat_json_node_t node;
3452 vat_json_init_object (&node);
3453 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3454 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3456 vat_json_print (vam->ofp, &node);
3457 vat_json_free (&node);
3459 vam->retval = ntohl (mp->retval);
3460 vam->result_ready = 1;
3463 static void vl_api_flow_classify_details_t_handler
3464 (vl_api_flow_classify_details_t * mp)
3466 vat_main_t *vam = &vat_main;
3468 fformat (vam->ofp, "%10d%20d\n", ntohl (mp->sw_if_index),
3469 ntohl (mp->table_index));
3472 static void vl_api_flow_classify_details_t_handler_json
3473 (vl_api_flow_classify_details_t * mp)
3475 vat_main_t *vam = &vat_main;
3476 vat_json_node_t *node;
3478 if (VAT_JSON_ARRAY != vam->json_tree.type)
3480 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3481 vat_json_init_array (&vam->json_tree);
3483 node = vat_json_array_add (&vam->json_tree);
3485 vat_json_init_object (node);
3486 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3487 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3492 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3493 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3494 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3495 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3496 #define vl_api_lisp_adjacencies_get_reply_t_endian vl_noop_handler
3497 #define vl_api_lisp_adjacencies_get_reply_t_print vl_noop_handler
3500 * Generate boilerplate reply handlers, which
3501 * dig the return value out of the xxx_reply_t API message,
3502 * stick it into vam->retval, and set vam->result_ready
3504 * Could also do this by pointing N message decode slots at
3505 * a single function, but that could break in subtle ways.
3508 #define foreach_standard_reply_retval_handler \
3509 _(sw_interface_set_flags_reply) \
3510 _(sw_interface_add_del_address_reply) \
3511 _(sw_interface_set_table_reply) \
3512 _(sw_interface_set_vpath_reply) \
3513 _(sw_interface_set_l2_bridge_reply) \
3514 _(sw_interface_set_dpdk_hqos_pipe_reply) \
3515 _(sw_interface_set_dpdk_hqos_subport_reply) \
3516 _(sw_interface_set_dpdk_hqos_tctbl_reply) \
3517 _(bridge_domain_add_del_reply) \
3518 _(sw_interface_set_l2_xconnect_reply) \
3519 _(l2fib_add_del_reply) \
3520 _(ip_add_del_route_reply) \
3521 _(proxy_arp_add_del_reply) \
3522 _(proxy_arp_intfc_enable_disable_reply) \
3523 _(mpls_add_del_encap_reply) \
3524 _(mpls_add_del_decap_reply) \
3525 _(mpls_ethernet_add_del_tunnel_2_reply) \
3526 _(sw_interface_set_unnumbered_reply) \
3527 _(ip_neighbor_add_del_reply) \
3528 _(reset_vrf_reply) \
3529 _(oam_add_del_reply) \
3530 _(reset_fib_reply) \
3531 _(dhcp_proxy_config_reply) \
3532 _(dhcp_proxy_config_2_reply) \
3533 _(dhcp_proxy_set_vss_reply) \
3534 _(dhcp_client_config_reply) \
3535 _(set_ip_flow_hash_reply) \
3536 _(sw_interface_ip6_enable_disable_reply) \
3537 _(sw_interface_ip6_set_link_local_address_reply) \
3538 _(sw_interface_ip6nd_ra_prefix_reply) \
3539 _(sw_interface_ip6nd_ra_config_reply) \
3540 _(set_arp_neighbor_limit_reply) \
3541 _(l2_patch_add_del_reply) \
3542 _(sr_tunnel_add_del_reply) \
3543 _(sr_policy_add_del_reply) \
3544 _(sr_multicast_map_add_del_reply) \
3545 _(classify_add_del_session_reply) \
3546 _(classify_set_interface_ip_table_reply) \
3547 _(classify_set_interface_l2_tables_reply) \
3548 _(l2tpv3_set_tunnel_cookies_reply) \
3549 _(l2tpv3_interface_enable_disable_reply) \
3550 _(l2tpv3_set_lookup_key_reply) \
3551 _(l2_fib_clear_table_reply) \
3552 _(l2_interface_efp_filter_reply) \
3553 _(l2_interface_vlan_tag_rewrite_reply) \
3554 _(modify_vhost_user_if_reply) \
3555 _(delete_vhost_user_if_reply) \
3556 _(want_ip4_arp_events_reply) \
3557 _(want_ip6_nd_events_reply) \
3558 _(input_acl_set_interface_reply) \
3559 _(ipsec_spd_add_del_reply) \
3560 _(ipsec_interface_add_del_spd_reply) \
3561 _(ipsec_spd_add_del_entry_reply) \
3562 _(ipsec_sad_add_del_entry_reply) \
3563 _(ipsec_sa_set_key_reply) \
3564 _(ikev2_profile_add_del_reply) \
3565 _(ikev2_profile_set_auth_reply) \
3566 _(ikev2_profile_set_id_reply) \
3567 _(ikev2_profile_set_ts_reply) \
3568 _(ikev2_set_local_key_reply) \
3569 _(delete_loopback_reply) \
3570 _(bd_ip_mac_add_del_reply) \
3571 _(map_del_domain_reply) \
3572 _(map_add_del_rule_reply) \
3573 _(want_interface_events_reply) \
3574 _(want_stats_reply) \
3575 _(cop_interface_enable_disable_reply) \
3576 _(cop_whitelist_enable_disable_reply) \
3577 _(sw_interface_clear_stats_reply) \
3578 _(ioam_enable_reply) \
3579 _(ioam_disable_reply) \
3580 _(lisp_add_del_locator_reply) \
3581 _(lisp_add_del_local_eid_reply) \
3582 _(lisp_add_del_remote_mapping_reply) \
3583 _(lisp_add_del_adjacency_reply) \
3584 _(lisp_gpe_add_del_fwd_entry_reply) \
3585 _(lisp_add_del_map_resolver_reply) \
3586 _(lisp_gpe_enable_disable_reply) \
3587 _(lisp_gpe_add_del_iface_reply) \
3588 _(lisp_enable_disable_reply) \
3589 _(lisp_pitr_set_locator_set_reply) \
3590 _(lisp_map_request_mode_reply) \
3591 _(lisp_add_del_map_request_itr_rlocs_reply) \
3592 _(lisp_eid_table_add_del_map_reply) \
3593 _(vxlan_gpe_add_del_tunnel_reply) \
3594 _(af_packet_delete_reply) \
3595 _(policer_classify_set_interface_reply) \
3596 _(netmap_create_reply) \
3597 _(netmap_delete_reply) \
3598 _(set_ipfix_exporter_reply) \
3599 _(set_ipfix_classify_stream_reply) \
3600 _(ipfix_classify_table_add_del_reply) \
3601 _(flow_classify_set_interface_reply) \
3602 _(pg_capture_reply) \
3603 _(pg_enable_disable_reply) \
3604 _(ip_source_and_port_range_check_add_del_reply) \
3605 _(ip_source_and_port_range_check_interface_add_del_reply)\
3606 _(delete_subif_reply) \
3607 _(l2_interface_pbb_tag_rewrite_reply) \
3611 static void vl_api_##n##_t_handler \
3612 (vl_api_##n##_t * mp) \
3614 vat_main_t * vam = &vat_main; \
3615 i32 retval = ntohl(mp->retval); \
3616 if (vam->async_mode) { \
3617 vam->async_errors += (retval < 0); \
3619 vam->retval = retval; \
3620 vam->result_ready = 1; \
3623 foreach_standard_reply_retval_handler;
3627 static void vl_api_##n##_t_handler_json \
3628 (vl_api_##n##_t * mp) \
3630 vat_main_t * vam = &vat_main; \
3631 vat_json_node_t node; \
3632 vat_json_init_object(&node); \
3633 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3634 vat_json_print(vam->ofp, &node); \
3635 vam->retval = ntohl(mp->retval); \
3636 vam->result_ready = 1; \
3638 foreach_standard_reply_retval_handler;
3642 * Table of message reply handlers, must include boilerplate handlers
3646 #define foreach_vpe_api_reply_msg \
3647 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3648 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3649 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
3650 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3651 _(CONTROL_PING_REPLY, control_ping_reply) \
3652 _(CLI_REPLY, cli_reply) \
3653 _(CLI_INBAND_REPLY, cli_inband_reply) \
3654 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
3655 sw_interface_add_del_address_reply) \
3656 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
3657 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
3658 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
3659 sw_interface_set_l2_xconnect_reply) \
3660 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
3661 sw_interface_set_l2_bridge_reply) \
3662 _(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
3663 sw_interface_set_dpdk_hqos_pipe_reply) \
3664 _(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
3665 sw_interface_set_dpdk_hqos_subport_reply) \
3666 _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
3667 sw_interface_set_dpdk_hqos_tctbl_reply) \
3668 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
3669 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
3670 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
3671 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
3672 _(L2_FLAGS_REPLY, l2_flags_reply) \
3673 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
3674 _(TAP_CONNECT_REPLY, tap_connect_reply) \
3675 _(TAP_MODIFY_REPLY, tap_modify_reply) \
3676 _(TAP_DELETE_REPLY, tap_delete_reply) \
3677 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
3678 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
3679 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
3680 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
3681 proxy_arp_intfc_enable_disable_reply) \
3682 _(MPLS_ADD_DEL_ENCAP_REPLY, mpls_add_del_encap_reply) \
3683 _(MPLS_ADD_DEL_DECAP_REPLY, mpls_add_del_decap_reply) \
3684 _(MPLS_GRE_ADD_DEL_TUNNEL_REPLY, mpls_gre_add_del_tunnel_reply) \
3685 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_REPLY, \
3686 mpls_ethernet_add_del_tunnel_reply) \
3687 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_2_REPLY, \
3688 mpls_ethernet_add_del_tunnel_2_reply) \
3689 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
3690 sw_interface_set_unnumbered_reply) \
3691 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
3692 _(RESET_VRF_REPLY, reset_vrf_reply) \
3693 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
3694 _(CREATE_SUBIF_REPLY, create_subif_reply) \
3695 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
3696 _(RESET_FIB_REPLY, reset_fib_reply) \
3697 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
3698 _(DHCP_PROXY_CONFIG_2_REPLY, dhcp_proxy_config_2_reply) \
3699 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
3700 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
3701 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
3702 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
3703 sw_interface_ip6_enable_disable_reply) \
3704 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
3705 sw_interface_ip6_set_link_local_address_reply) \
3706 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
3707 sw_interface_ip6nd_ra_prefix_reply) \
3708 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
3709 sw_interface_ip6nd_ra_config_reply) \
3710 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
3711 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
3712 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
3713 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
3714 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
3715 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
3716 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
3717 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
3718 classify_set_interface_ip_table_reply) \
3719 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
3720 classify_set_interface_l2_tables_reply) \
3721 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
3722 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
3723 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
3724 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
3725 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
3726 l2tpv3_interface_enable_disable_reply) \
3727 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
3728 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
3729 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
3730 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
3731 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
3732 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
3733 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
3734 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
3735 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
3736 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
3737 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
3738 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
3739 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
3740 _(SHOW_VERSION_REPLY, show_version_reply) \
3741 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
3742 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
3743 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
3744 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
3745 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
3746 _(IP4_ARP_EVENT, ip4_arp_event) \
3747 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
3748 _(IP6_ND_EVENT, ip6_nd_event) \
3749 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
3750 _(IP_ADDRESS_DETAILS, ip_address_details) \
3751 _(IP_DETAILS, ip_details) \
3752 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
3753 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
3754 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
3755 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
3756 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
3757 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
3758 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
3759 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
3760 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
3761 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
3762 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
3763 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
3764 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
3765 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
3766 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
3767 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
3768 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
3769 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
3770 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
3771 _(MAP_DOMAIN_DETAILS, map_domain_details) \
3772 _(MAP_RULE_DETAILS, map_rule_details) \
3773 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
3774 _(WANT_STATS_REPLY, want_stats_reply) \
3775 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
3776 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
3777 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
3778 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
3779 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
3780 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
3781 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
3782 _(LISP_ADD_DEL_LOCATOR_SET_REPLY, lisp_add_del_locator_set_reply) \
3783 _(LISP_ADD_DEL_LOCATOR_REPLY, lisp_add_del_locator_reply) \
3784 _(LISP_ADD_DEL_LOCAL_EID_REPLY, lisp_add_del_local_eid_reply) \
3785 _(LISP_ADD_DEL_REMOTE_MAPPING_REPLY, lisp_add_del_remote_mapping_reply) \
3786 _(LISP_ADD_DEL_ADJACENCY_REPLY, lisp_add_del_adjacency_reply) \
3787 _(LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY, lisp_gpe_add_del_fwd_entry_reply) \
3788 _(LISP_ADD_DEL_MAP_RESOLVER_REPLY, lisp_add_del_map_resolver_reply) \
3789 _(LISP_GPE_ENABLE_DISABLE_REPLY, lisp_gpe_enable_disable_reply) \
3790 _(LISP_ENABLE_DISABLE_REPLY, lisp_enable_disable_reply) \
3791 _(LISP_PITR_SET_LOCATOR_SET_REPLY, lisp_pitr_set_locator_set_reply) \
3792 _(LISP_MAP_REQUEST_MODE_REPLY, lisp_map_request_mode_reply) \
3793 _(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \
3794 _(LISP_GPE_ADD_DEL_IFACE_REPLY, lisp_gpe_add_del_iface_reply) \
3795 _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \
3796 _(LISP_LOCATOR_DETAILS, lisp_locator_details) \
3797 _(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \
3798 _(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \
3799 _(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \
3800 _(LISP_GPE_TUNNEL_DETAILS, lisp_gpe_tunnel_details) \
3801 _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
3802 _(LISP_ADJACENCIES_GET_REPLY, lisp_adjacencies_get_reply) \
3803 _(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
3804 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
3805 lisp_add_del_map_request_itr_rlocs_reply) \
3806 _(LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
3807 lisp_get_map_request_itr_rlocs_reply) \
3808 _(SHOW_LISP_PITR_REPLY, show_lisp_pitr_reply) \
3809 _(SHOW_LISP_MAP_REQUEST_MODE_REPLY, show_lisp_map_request_mode_reply) \
3810 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
3811 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
3812 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
3813 _(POLICER_DETAILS, policer_details) \
3814 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
3815 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
3816 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
3817 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
3818 _(MPLS_GRE_TUNNEL_DETAILS, mpls_gre_tunnel_details) \
3819 _(MPLS_ETH_TUNNEL_DETAILS, mpls_eth_tunnel_details) \
3820 _(MPLS_FIB_ENCAP_DETAILS, mpls_fib_encap_details) \
3821 _(MPLS_FIB_DECAP_DETAILS, mpls_fib_decap_details) \
3822 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
3823 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
3824 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
3825 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
3826 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
3827 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
3828 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
3829 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
3830 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
3831 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
3832 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
3833 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
3834 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
3835 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
3836 _(PG_CAPTURE_REPLY, pg_capture_reply) \
3837 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
3838 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
3839 ip_source_and_port_range_check_add_del_reply) \
3840 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
3841 ip_source_and_port_range_check_interface_add_del_reply) \
3842 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
3843 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
3844 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
3845 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
3846 _(PUNT_REPLY, punt_reply)
3848 /* M: construct, but don't yet send a message */
3852 vam->result_ready = 0; \
3853 mp = vl_msg_api_alloc(sizeof(*mp)); \
3854 memset (mp, 0, sizeof (*mp)); \
3855 mp->_vl_msg_id = ntohs (VL_API_##T); \
3856 mp->client_index = vam->my_client_index; \
3861 vam->result_ready = 0; \
3862 mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
3863 memset (mp, 0, sizeof (*mp)); \
3864 mp->_vl_msg_id = ntohs (VL_API_##T); \
3865 mp->client_index = vam->my_client_index; \
3869 /* S: send a message */
3870 #define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
3872 /* W: wait for results, with timeout */
3875 timeout = vat_time_now (vam) + 1.0; \
3877 while (vat_time_now (vam) < timeout) { \
3878 if (vam->result_ready == 1) { \
3879 return (vam->retval); \
3885 /* W2: wait for results, with timeout */
3888 timeout = vat_time_now (vam) + 1.0; \
3890 while (vat_time_now (vam) < timeout) { \
3891 if (vam->result_ready == 1) { \
3893 return (vam->retval); \
3906 #define STR_VTR_OP_CASE(op) \
3907 case L2_VTR_ ## op: \
3911 str_vtr_op (u32 vtr_op)
3915 STR_VTR_OP_CASE (DISABLED);
3916 STR_VTR_OP_CASE (PUSH_1);
3917 STR_VTR_OP_CASE (PUSH_2);
3918 STR_VTR_OP_CASE (POP_1);
3919 STR_VTR_OP_CASE (POP_2);
3920 STR_VTR_OP_CASE (TRANSLATE_1_1);
3921 STR_VTR_OP_CASE (TRANSLATE_1_2);
3922 STR_VTR_OP_CASE (TRANSLATE_2_1);
3923 STR_VTR_OP_CASE (TRANSLATE_2_2);
3930 dump_sub_interface_table (vat_main_t * vam)
3932 const sw_interface_subif_t *sub = NULL;
3934 if (vam->json_output)
3937 ("JSON output supported only for VPE API calls and dump_stats_table");
3942 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s\n",
3943 "Interface", "sw_if_index",
3944 "sub id", "dot1ad", "tags", "outer id",
3945 "inner id", "exact", "default", "outer any", "inner any");
3947 vec_foreach (sub, vam->sw_if_subif_table)
3950 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d\n",
3951 sub->interface_name,
3953 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
3954 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
3955 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
3956 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
3957 if (sub->vtr_op != L2_VTR_DISABLED)
3960 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
3961 "tag1: %d tag2: %d ]\n",
3962 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
3963 sub->vtr_tag1, sub->vtr_tag2);
3971 name_sort_cmp (void *a1, void *a2)
3973 name_sort_t *n1 = a1;
3974 name_sort_t *n2 = a2;
3976 return strcmp ((char *) n1->name, (char *) n2->name);
3980 dump_interface_table (vat_main_t * vam)
3983 name_sort_t *nses = 0, *ns;
3985 if (vam->json_output)
3988 ("JSON output supported only for VPE API calls and dump_stats_table");
3993 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
3995 vec_add2 (nses, ns, 1);
3996 ns->name = (u8 *)(p->key);
3997 ns->value = (u32) p->value[0];
4001 vec_sort_with_function (nses, name_sort_cmp);
4003 fformat (vam->ofp, "%-25s%-15s\n", "Interface", "sw_if_index");
4004 vec_foreach (ns, nses)
4006 fformat (vam->ofp, "%-25s%-15d\n", ns->name, ns->value);
4013 dump_ip_table (vat_main_t * vam, int is_ipv6)
4015 const ip_details_t *det = NULL;
4016 const ip_address_details_t *address = NULL;
4019 fformat (vam->ofp, "%-12s\n", "sw_if_index");
4021 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4028 fformat (vam->ofp, "%-12d\n", i);
4030 " %-30s%-13s\n", "Address", "Prefix length");
4035 vec_foreach (address, det->addr)
4039 is_ipv6 ? format_ip6_address : format_ip4_address,
4040 address->ip, address->prefix_length);
4048 dump_ipv4_table (vat_main_t * vam)
4050 if (vam->json_output)
4053 ("JSON output supported only for VPE API calls and dump_stats_table");
4057 return dump_ip_table (vam, 0);
4061 dump_ipv6_table (vat_main_t * vam)
4063 if (vam->json_output)
4066 ("JSON output supported only for VPE API calls and dump_stats_table");
4070 return dump_ip_table (vam, 1);
4074 counter_type_to_str (u8 counter_type, u8 is_combined)
4078 switch (counter_type)
4080 case VNET_INTERFACE_COUNTER_DROP:
4082 case VNET_INTERFACE_COUNTER_PUNT:
4084 case VNET_INTERFACE_COUNTER_IP4:
4086 case VNET_INTERFACE_COUNTER_IP6:
4088 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4090 case VNET_INTERFACE_COUNTER_RX_MISS:
4092 case VNET_INTERFACE_COUNTER_RX_ERROR:
4094 case VNET_INTERFACE_COUNTER_TX_ERROR:
4097 return "INVALID-COUNTER-TYPE";
4102 switch (counter_type)
4104 case VNET_INTERFACE_COUNTER_RX:
4106 case VNET_INTERFACE_COUNTER_TX:
4109 return "INVALID-COUNTER-TYPE";
4115 dump_stats_table (vat_main_t * vam)
4117 vat_json_node_t node;
4118 vat_json_node_t *msg_array;
4119 vat_json_node_t *msg;
4120 vat_json_node_t *counter_array;
4121 vat_json_node_t *counter;
4122 interface_counter_t c;
4124 ip4_fib_counter_t *c4;
4125 ip6_fib_counter_t *c6;
4128 if (!vam->json_output)
4130 clib_warning ("dump_stats_table supported only in JSON format");
4134 vat_json_init_object (&node);
4136 /* interface counters */
4137 msg_array = vat_json_object_add (&node, "interface_counters");
4138 vat_json_init_array (msg_array);
4139 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4141 msg = vat_json_array_add (msg_array);
4142 vat_json_init_object (msg);
4143 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4144 (u8 *) counter_type_to_str (i, 0));
4145 vat_json_object_add_int (msg, "is_combined", 0);
4146 counter_array = vat_json_object_add (msg, "data");
4147 vat_json_init_array (counter_array);
4148 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4150 packets = vam->simple_interface_counters[i][j];
4151 vat_json_array_add_uint (counter_array, packets);
4154 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4156 msg = vat_json_array_add (msg_array);
4157 vat_json_init_object (msg);
4158 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4159 (u8 *) counter_type_to_str (i, 1));
4160 vat_json_object_add_int (msg, "is_combined", 1);
4161 counter_array = vat_json_object_add (msg, "data");
4162 vat_json_init_array (counter_array);
4163 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4165 c = vam->combined_interface_counters[i][j];
4166 counter = vat_json_array_add (counter_array);
4167 vat_json_init_object (counter);
4168 vat_json_object_add_uint (counter, "packets", c.packets);
4169 vat_json_object_add_uint (counter, "bytes", c.bytes);
4173 /* ip4 fib counters */
4174 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4175 vat_json_init_array (msg_array);
4176 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4178 msg = vat_json_array_add (msg_array);
4179 vat_json_init_object (msg);
4180 vat_json_object_add_uint (msg, "vrf_id",
4181 vam->ip4_fib_counters_vrf_id_by_index[i]);
4182 counter_array = vat_json_object_add (msg, "c");
4183 vat_json_init_array (counter_array);
4184 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4186 counter = vat_json_array_add (counter_array);
4187 vat_json_init_object (counter);
4188 c4 = &vam->ip4_fib_counters[i][j];
4189 vat_json_object_add_ip4 (counter, "address", c4->address);
4190 vat_json_object_add_uint (counter, "address_length",
4191 c4->address_length);
4192 vat_json_object_add_uint (counter, "packets", c4->packets);
4193 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4197 /* ip6 fib counters */
4198 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4199 vat_json_init_array (msg_array);
4200 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4202 msg = vat_json_array_add (msg_array);
4203 vat_json_init_object (msg);
4204 vat_json_object_add_uint (msg, "vrf_id",
4205 vam->ip6_fib_counters_vrf_id_by_index[i]);
4206 counter_array = vat_json_object_add (msg, "c");
4207 vat_json_init_array (counter_array);
4208 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4210 counter = vat_json_array_add (counter_array);
4211 vat_json_init_object (counter);
4212 c6 = &vam->ip6_fib_counters[i][j];
4213 vat_json_object_add_ip6 (counter, "address", c6->address);
4214 vat_json_object_add_uint (counter, "address_length",
4215 c6->address_length);
4216 vat_json_object_add_uint (counter, "packets", c6->packets);
4217 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4221 vat_json_print (vam->ofp, &node);
4222 vat_json_free (&node);
4228 exec (vat_main_t * vam)
4230 api_main_t *am = &api_main;
4231 vl_api_cli_request_t *mp;
4235 unformat_input_t *i = vam->input;
4237 if (vec_len (i->buffer) == 0)
4240 if (vam->exec_mode == 0 && unformat (i, "mode"))
4245 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4252 M (CLI_REQUEST, cli_request);
4255 * Copy cmd into shared memory.
4256 * In order for the CLI command to work, it
4257 * must be a vector ending in \n, not a C-string ending
4260 pthread_mutex_lock (&am->vlib_rp->mutex);
4261 oldheap = svm_push_data_heap (am->vlib_rp);
4263 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4264 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4266 svm_pop_heap (oldheap);
4267 pthread_mutex_unlock (&am->vlib_rp->mutex);
4269 mp->cmd_in_shmem = (u64) cmd;
4271 timeout = vat_time_now (vam) + 10.0;
4273 while (vat_time_now (vam) < timeout)
4275 if (vam->result_ready == 1)
4278 if (vam->shmem_result != NULL)
4279 fformat (vam->ofp, "%s", vam->shmem_result);
4280 pthread_mutex_lock (&am->vlib_rp->mutex);
4281 oldheap = svm_push_data_heap (am->vlib_rp);
4283 free_me = (u8 *) vam->shmem_result;
4286 svm_pop_heap (oldheap);
4287 pthread_mutex_unlock (&am->vlib_rp->mutex);
4295 * Future replacement of exec() that passes CLI buffers directly in
4296 * the API messages instead of an additional shared memory area.
4299 exec_inband (vat_main_t * vam)
4301 vl_api_cli_inband_t *mp;
4303 unformat_input_t *i = vam->input;
4305 if (vec_len (i->buffer) == 0)
4308 if (vam->exec_mode == 0 && unformat (i, "mode"))
4313 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4320 * In order for the CLI command to work, it
4321 * must be a vector ending in \n, not a C-string ending
4324 u32 len = vec_len (vam->input->buffer);
4325 M2 (CLI_INBAND, cli_inband, len);
4326 clib_memcpy (mp->cmd, vam->input->buffer, len);
4327 mp->length = htonl (len);
4330 W2 (fformat (vam->ofp, "%s", vam->cmd_reply));
4334 api_create_loopback (vat_main_t * vam)
4336 unformat_input_t *i = vam->input;
4337 vl_api_create_loopback_t *mp;
4342 memset (mac_address, 0, sizeof (mac_address));
4344 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4346 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4352 /* Construct the API message */
4353 M (CREATE_LOOPBACK, create_loopback);
4355 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4362 api_delete_loopback (vat_main_t * vam)
4364 unformat_input_t *i = vam->input;
4365 vl_api_delete_loopback_t *mp;
4367 u32 sw_if_index = ~0;
4369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4371 if (unformat (i, "sw_if_index %d", &sw_if_index))
4377 if (sw_if_index == ~0)
4379 errmsg ("missing sw_if_index\n");
4383 /* Construct the API message */
4384 M (DELETE_LOOPBACK, delete_loopback);
4385 mp->sw_if_index = ntohl (sw_if_index);
4392 api_want_stats (vat_main_t * vam)
4394 unformat_input_t *i = vam->input;
4395 vl_api_want_stats_t *mp;
4399 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4401 if (unformat (i, "enable"))
4403 else if (unformat (i, "disable"))
4411 errmsg ("missing enable|disable\n");
4415 M (WANT_STATS, want_stats);
4416 mp->enable_disable = enable;
4423 api_want_interface_events (vat_main_t * vam)
4425 unformat_input_t *i = vam->input;
4426 vl_api_want_interface_events_t *mp;
4430 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4432 if (unformat (i, "enable"))
4434 else if (unformat (i, "disable"))
4442 errmsg ("missing enable|disable\n");
4446 M (WANT_INTERFACE_EVENTS, want_interface_events);
4447 mp->enable_disable = enable;
4449 vam->interface_event_display = enable;
4456 /* Note: non-static, called once to set up the initial intfc table */
4458 api_sw_interface_dump (vat_main_t * vam)
4460 vl_api_sw_interface_dump_t *mp;
4463 name_sort_t *nses = 0, *ns;
4464 sw_interface_subif_t *sub = NULL;
4466 /* Toss the old name table */
4468 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4470 vec_add2 (nses, ns, 1);
4471 ns->name = (u8 *)(p->key);
4472 ns->value = (u32) p->value[0];
4476 hash_free (vam->sw_if_index_by_interface_name);
4478 vec_foreach (ns, nses) vec_free (ns->name);
4482 vec_foreach (sub, vam->sw_if_subif_table)
4484 vec_free (sub->interface_name);
4486 vec_free (vam->sw_if_subif_table);
4488 /* recreate the interface name hash table */
4489 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4491 /* Get list of ethernets */
4492 M (SW_INTERFACE_DUMP, sw_interface_dump);
4493 mp->name_filter_valid = 1;
4494 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4497 /* and local / loopback interfaces */
4498 M (SW_INTERFACE_DUMP, sw_interface_dump);
4499 mp->name_filter_valid = 1;
4500 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4503 /* and packet-generator interfaces */
4504 M (SW_INTERFACE_DUMP, sw_interface_dump);
4505 mp->name_filter_valid = 1;
4506 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4509 /* and vxlan-gpe tunnel interfaces */
4510 M (SW_INTERFACE_DUMP, sw_interface_dump);
4511 mp->name_filter_valid = 1;
4512 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4513 sizeof (mp->name_filter) - 1);
4516 /* and vxlan tunnel interfaces */
4517 M (SW_INTERFACE_DUMP, sw_interface_dump);
4518 mp->name_filter_valid = 1;
4519 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4522 /* and host (af_packet) interfaces */
4523 M (SW_INTERFACE_DUMP, sw_interface_dump);
4524 mp->name_filter_valid = 1;
4525 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4528 /* and l2tpv3 tunnel interfaces */
4529 M (SW_INTERFACE_DUMP, sw_interface_dump);
4530 mp->name_filter_valid = 1;
4531 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4532 sizeof (mp->name_filter) - 1);
4535 /* and GRE tunnel interfaces */
4536 M (SW_INTERFACE_DUMP, sw_interface_dump);
4537 mp->name_filter_valid = 1;
4538 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4541 /* and LISP-GPE interfaces */
4542 M (SW_INTERFACE_DUMP, sw_interface_dump);
4543 mp->name_filter_valid = 1;
4544 strncpy ((char *) mp->name_filter, "lisp_gpe",
4545 sizeof (mp->name_filter) - 1);
4548 /* and IPSEC tunnel interfaces */
4549 M (SW_INTERFACE_DUMP, sw_interface_dump);
4550 mp->name_filter_valid = 1;
4551 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4554 /* Use a control ping for synchronization */
4556 vl_api_control_ping_t *mp;
4557 M (CONTROL_PING, control_ping);
4564 api_sw_interface_set_flags (vat_main_t * vam)
4566 unformat_input_t *i = vam->input;
4567 vl_api_sw_interface_set_flags_t *mp;
4570 u8 sw_if_index_set = 0;
4571 u8 admin_up = 0, link_up = 0;
4573 /* Parse args required to build the message */
4574 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4576 if (unformat (i, "admin-up"))
4578 else if (unformat (i, "admin-down"))
4580 else if (unformat (i, "link-up"))
4582 else if (unformat (i, "link-down"))
4584 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4585 sw_if_index_set = 1;
4586 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4587 sw_if_index_set = 1;
4592 if (sw_if_index_set == 0)
4594 errmsg ("missing interface name or sw_if_index\n");
4598 /* Construct the API message */
4599 M (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags);
4600 mp->sw_if_index = ntohl (sw_if_index);
4601 mp->admin_up_down = admin_up;
4602 mp->link_up_down = link_up;
4607 /* Wait for a reply, return the good/bad news... */
4612 api_sw_interface_clear_stats (vat_main_t * vam)
4614 unformat_input_t *i = vam->input;
4615 vl_api_sw_interface_clear_stats_t *mp;
4618 u8 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, "%U", unformat_sw_if_index, vam, &sw_if_index))
4624 sw_if_index_set = 1;
4625 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4626 sw_if_index_set = 1;
4631 /* Construct the API message */
4632 M (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats);
4634 if (sw_if_index_set == 1)
4635 mp->sw_if_index = ntohl (sw_if_index);
4637 mp->sw_if_index = ~0;
4642 /* Wait for a reply, return the good/bad news... */
4647 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
4649 unformat_input_t *i = vam->input;
4650 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
4653 u8 sw_if_index_set = 0;
4661 /* Parse args required to build the message */
4662 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4664 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4665 sw_if_index_set = 1;
4666 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4667 sw_if_index_set = 1;
4668 else if (unformat (i, "subport %u", &subport))
4670 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4671 sw_if_index_set = 1;
4672 else if (unformat (i, "pipe %u", &pipe))
4674 else if (unformat (i, "profile %u", &profile))
4680 if (sw_if_index_set == 0)
4682 errmsg ("missing interface name or sw_if_index\n");
4686 if (subport_set == 0)
4688 errmsg ("missing subport \n");
4694 errmsg ("missing pipe\n");
4698 if (profile_set == 0)
4700 errmsg ("missing profile\n");
4704 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe);
4706 mp->sw_if_index = ntohl (sw_if_index);
4707 mp->subport = ntohl (subport);
4708 mp->pipe = ntohl (pipe);
4709 mp->profile = ntohl (profile);
4719 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
4721 unformat_input_t *i = vam->input;
4722 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
4725 u8 sw_if_index_set = 0;
4728 u32 tb_rate = 1250000000; /* 10GbE */
4729 u32 tb_size = 1000000;
4730 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
4733 /* Parse args required to build the message */
4734 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4736 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4737 sw_if_index_set = 1;
4738 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4739 sw_if_index_set = 1;
4740 else if (unformat (i, "subport %u", &subport))
4742 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4743 sw_if_index_set = 1;
4744 else if (unformat (i, "rate %u", &tb_rate))
4748 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
4750 tc_rate[tc_id] = tb_rate;
4752 else if (unformat (i, "bktsize %u", &tb_size))
4754 else if (unformat (i, "tc0 %u", &tc_rate[0]))
4756 else if (unformat (i, "tc1 %u", &tc_rate[1]))
4758 else if (unformat (i, "tc2 %u", &tc_rate[2]))
4760 else if (unformat (i, "tc3 %u", &tc_rate[3]))
4762 else if (unformat (i, "period %u", &tc_period))
4768 if (sw_if_index_set == 0)
4770 errmsg ("missing interface name or sw_if_index\n");
4774 if (subport_set == 0)
4776 errmsg ("missing subport \n");
4780 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport);
4782 mp->sw_if_index = ntohl (sw_if_index);
4783 mp->subport = ntohl (subport);
4784 mp->tb_rate = ntohl (tb_rate);
4785 mp->tb_size = ntohl (tb_size);
4786 mp->tc_rate[0] = ntohl (tc_rate[0]);
4787 mp->tc_rate[1] = ntohl (tc_rate[1]);
4788 mp->tc_rate[2] = ntohl (tc_rate[2]);
4789 mp->tc_rate[3] = ntohl (tc_rate[3]);
4790 mp->tc_period = ntohl (tc_period);
4799 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
4801 unformat_input_t *i = vam->input;
4802 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
4805 u8 sw_if_index_set = 0;
4809 u32 entry, tc, queue;
4811 /* Parse args required to build the message */
4812 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4814 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4815 sw_if_index_set = 1;
4816 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4817 sw_if_index_set = 1;
4818 else if (unformat (i, "entry %d", &entry))
4820 else if (unformat (i, "tc %d", &tc))
4822 else if (unformat (i, "queue %d", &queue))
4828 if (sw_if_index_set == 0)
4830 errmsg ("missing interface name or sw_if_index\n");
4836 errmsg ("missing entry \n");
4842 errmsg ("missing traffic class \n");
4848 errmsg ("missing queue \n");
4852 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl);
4854 mp->sw_if_index = ntohl (sw_if_index);
4855 mp->entry = ntohl (entry);
4856 mp->tc = ntohl (tc);
4857 mp->queue = ntohl (queue);
4866 api_sw_interface_add_del_address (vat_main_t * vam)
4868 unformat_input_t *i = vam->input;
4869 vl_api_sw_interface_add_del_address_t *mp;
4872 u8 sw_if_index_set = 0;
4873 u8 is_add = 1, del_all = 0;
4874 u32 address_length = 0;
4875 u8 v4_address_set = 0;
4876 u8 v6_address_set = 0;
4877 ip4_address_t v4address;
4878 ip6_address_t v6address;
4880 /* Parse args required to build the message */
4881 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4883 if (unformat (i, "del-all"))
4885 else if (unformat (i, "del"))
4887 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4888 sw_if_index_set = 1;
4889 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4890 sw_if_index_set = 1;
4891 else if (unformat (i, "%U/%d",
4892 unformat_ip4_address, &v4address, &address_length))
4894 else if (unformat (i, "%U/%d",
4895 unformat_ip6_address, &v6address, &address_length))
4901 if (sw_if_index_set == 0)
4903 errmsg ("missing interface name or sw_if_index\n");
4906 if (v4_address_set && v6_address_set)
4908 errmsg ("both v4 and v6 addresses set\n");
4911 if (!v4_address_set && !v6_address_set && !del_all)
4913 errmsg ("no addresses set\n");
4917 /* Construct the API message */
4918 M (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address);
4920 mp->sw_if_index = ntohl (sw_if_index);
4921 mp->is_add = is_add;
4922 mp->del_all = del_all;
4926 clib_memcpy (mp->address, &v6address, sizeof (v6address));
4930 clib_memcpy (mp->address, &v4address, sizeof (v4address));
4932 mp->address_length = address_length;
4937 /* Wait for a reply, return good/bad news */
4942 api_sw_interface_set_table (vat_main_t * vam)
4944 unformat_input_t *i = vam->input;
4945 vl_api_sw_interface_set_table_t *mp;
4947 u32 sw_if_index, vrf_id = 0;
4948 u8 sw_if_index_set = 0;
4951 /* Parse args required to build the message */
4952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4954 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4955 sw_if_index_set = 1;
4956 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4957 sw_if_index_set = 1;
4958 else if (unformat (i, "vrf %d", &vrf_id))
4960 else if (unformat (i, "ipv6"))
4966 if (sw_if_index_set == 0)
4968 errmsg ("missing interface name or sw_if_index\n");
4972 /* Construct the API message */
4973 M (SW_INTERFACE_SET_TABLE, sw_interface_set_table);
4975 mp->sw_if_index = ntohl (sw_if_index);
4976 mp->is_ipv6 = is_ipv6;
4977 mp->vrf_id = ntohl (vrf_id);
4982 /* Wait for a reply... */
4987 api_sw_interface_set_vpath (vat_main_t * vam)
4989 unformat_input_t *i = vam->input;
4990 vl_api_sw_interface_set_vpath_t *mp;
4992 u32 sw_if_index = 0;
4993 u8 sw_if_index_set = 0;
4996 /* Parse args required to build the message */
4997 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4999 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5000 sw_if_index_set = 1;
5001 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5002 sw_if_index_set = 1;
5003 else if (unformat (i, "enable"))
5005 else if (unformat (i, "disable"))
5011 if (sw_if_index_set == 0)
5013 errmsg ("missing interface name or sw_if_index\n");
5017 /* Construct the API message */
5018 M (SW_INTERFACE_SET_VPATH, sw_interface_set_vpath);
5020 mp->sw_if_index = ntohl (sw_if_index);
5021 mp->enable = is_enable;
5026 /* Wait for a reply... */
5031 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5033 unformat_input_t *i = vam->input;
5034 vl_api_sw_interface_set_l2_xconnect_t *mp;
5037 u8 rx_sw_if_index_set = 0;
5039 u8 tx_sw_if_index_set = 0;
5042 /* Parse args required to build the message */
5043 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5045 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5046 rx_sw_if_index_set = 1;
5047 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5048 tx_sw_if_index_set = 1;
5049 else if (unformat (i, "rx"))
5051 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5053 if (unformat (i, "%U", unformat_sw_if_index, vam,
5055 rx_sw_if_index_set = 1;
5060 else if (unformat (i, "tx"))
5062 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5064 if (unformat (i, "%U", unformat_sw_if_index, vam,
5066 tx_sw_if_index_set = 1;
5071 else if (unformat (i, "enable"))
5073 else if (unformat (i, "disable"))
5079 if (rx_sw_if_index_set == 0)
5081 errmsg ("missing rx interface name or rx_sw_if_index\n");
5085 if (enable && (tx_sw_if_index_set == 0))
5087 errmsg ("missing tx interface name or tx_sw_if_index\n");
5091 M (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect);
5093 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5094 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5095 mp->enable = enable;
5104 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5106 unformat_input_t *i = vam->input;
5107 vl_api_sw_interface_set_l2_bridge_t *mp;
5110 u8 rx_sw_if_index_set = 0;
5117 /* Parse args required to build the message */
5118 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5120 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5121 rx_sw_if_index_set = 1;
5122 else if (unformat (i, "bd_id %d", &bd_id))
5124 else if (unformat (i, "%U", unformat_sw_if_index, vam, &rx_sw_if_index))
5125 rx_sw_if_index_set = 1;
5126 else if (unformat (i, "shg %d", &shg))
5128 else if (unformat (i, "bvi"))
5130 else if (unformat (i, "enable"))
5132 else if (unformat (i, "disable"))
5138 if (rx_sw_if_index_set == 0)
5140 errmsg ("missing rx interface name or sw_if_index\n");
5144 if (enable && (bd_id_set == 0))
5146 errmsg ("missing bridge domain\n");
5150 M (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge);
5152 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5153 mp->bd_id = ntohl (bd_id);
5156 mp->enable = enable;
5165 api_bridge_domain_dump (vat_main_t * vam)
5167 unformat_input_t *i = vam->input;
5168 vl_api_bridge_domain_dump_t *mp;
5172 /* Parse args required to build the message */
5173 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5175 if (unformat (i, "bd_id %d", &bd_id))
5181 M (BRIDGE_DOMAIN_DUMP, bridge_domain_dump);
5182 mp->bd_id = ntohl (bd_id);
5185 /* Use a control ping for synchronization */
5187 vl_api_control_ping_t *mp;
5188 M (CONTROL_PING, control_ping);
5198 api_bridge_domain_add_del (vat_main_t * vam)
5200 unformat_input_t *i = vam->input;
5201 vl_api_bridge_domain_add_del_t *mp;
5205 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5207 /* Parse args required to build the message */
5208 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5210 if (unformat (i, "bd_id %d", &bd_id))
5212 else if (unformat (i, "flood %d", &flood))
5214 else if (unformat (i, "uu-flood %d", &uu_flood))
5216 else if (unformat (i, "forward %d", &forward))
5218 else if (unformat (i, "learn %d", &learn))
5220 else if (unformat (i, "arp-term %d", &arp_term))
5222 else if (unformat (i, "del"))
5225 flood = uu_flood = forward = learn = 0;
5233 errmsg ("missing bridge domain\n");
5237 M (BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del);
5239 mp->bd_id = ntohl (bd_id);
5241 mp->uu_flood = uu_flood;
5242 mp->forward = forward;
5244 mp->arp_term = arp_term;
5245 mp->is_add = is_add;
5254 api_l2fib_add_del (vat_main_t * vam)
5256 unformat_input_t *i = vam->input;
5257 vl_api_l2fib_add_del_t *mp;
5264 u8 sw_if_index_set = 0;
5273 /* Parse args required to build the message */
5274 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5276 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5278 else if (unformat (i, "bd_id %d", &bd_id))
5280 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5281 sw_if_index_set = 1;
5282 else if (unformat (i, "sw_if"))
5284 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5286 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5287 sw_if_index_set = 1;
5292 else if (unformat (i, "static"))
5294 else if (unformat (i, "filter"))
5299 else if (unformat (i, "bvi"))
5304 else if (unformat (i, "del"))
5306 else if (unformat (i, "count %d", &count))
5314 errmsg ("missing mac address\n");
5320 errmsg ("missing bridge domain\n");
5324 if (is_add && (sw_if_index_set == 0))
5326 errmsg ("missing interface name or sw_if_index\n");
5332 /* Turn on async mode */
5333 vam->async_mode = 1;
5334 vam->async_errors = 0;
5335 before = vat_time_now (vam);
5338 for (j = 0; j < count; j++)
5340 M (L2FIB_ADD_DEL, l2fib_add_del);
5343 mp->bd_id = ntohl (bd_id);
5344 mp->is_add = is_add;
5348 mp->sw_if_index = ntohl (sw_if_index);
5349 mp->static_mac = static_mac;
5350 mp->filter_mac = filter_mac;
5351 mp->bvi_mac = bvi_mac;
5353 increment_mac_address (&mac);
5360 vl_api_control_ping_t *mp;
5363 /* Shut off async mode */
5364 vam->async_mode = 0;
5366 M (CONTROL_PING, control_ping);
5369 timeout = vat_time_now (vam) + 1.0;
5370 while (vat_time_now (vam) < timeout)
5371 if (vam->result_ready == 1)
5376 if (vam->retval == -99)
5377 errmsg ("timeout\n");
5379 if (vam->async_errors > 0)
5381 errmsg ("%d asynchronous errors\n", vam->async_errors);
5384 vam->async_errors = 0;
5385 after = vat_time_now (vam);
5387 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
5388 count, after - before, count / (after - before));
5392 /* Wait for a reply... */
5395 /* Return the good/bad news */
5396 return (vam->retval);
5400 api_l2_flags (vat_main_t * vam)
5402 unformat_input_t *i = vam->input;
5403 vl_api_l2_flags_t *mp;
5406 u32 feature_bitmap = 0;
5407 u8 sw_if_index_set = 0;
5409 /* Parse args required to build the message */
5410 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5412 if (unformat (i, "sw_if_index %d", &sw_if_index))
5413 sw_if_index_set = 1;
5414 else if (unformat (i, "sw_if"))
5416 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5418 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5419 sw_if_index_set = 1;
5424 else if (unformat (i, "learn"))
5425 feature_bitmap |= L2INPUT_FEAT_LEARN;
5426 else if (unformat (i, "forward"))
5427 feature_bitmap |= L2INPUT_FEAT_FWD;
5428 else if (unformat (i, "flood"))
5429 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5430 else if (unformat (i, "uu-flood"))
5431 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5436 if (sw_if_index_set == 0)
5438 errmsg ("missing interface name or sw_if_index\n");
5442 M (L2_FLAGS, l2_flags);
5444 mp->sw_if_index = ntohl (sw_if_index);
5445 mp->feature_bitmap = ntohl (feature_bitmap);
5454 api_bridge_flags (vat_main_t * vam)
5456 unformat_input_t *i = vam->input;
5457 vl_api_bridge_flags_t *mp;
5464 /* Parse args required to build the message */
5465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5467 if (unformat (i, "bd_id %d", &bd_id))
5469 else if (unformat (i, "learn"))
5471 else if (unformat (i, "forward"))
5473 else if (unformat (i, "flood"))
5475 else if (unformat (i, "uu-flood"))
5476 flags |= L2_UU_FLOOD;
5477 else if (unformat (i, "arp-term"))
5478 flags |= L2_ARP_TERM;
5479 else if (unformat (i, "off"))
5481 else if (unformat (i, "disable"))
5489 errmsg ("missing bridge domain\n");
5493 M (BRIDGE_FLAGS, bridge_flags);
5495 mp->bd_id = ntohl (bd_id);
5496 mp->feature_bitmap = ntohl (flags);
5497 mp->is_set = is_set;
5506 api_bd_ip_mac_add_del (vat_main_t * vam)
5508 unformat_input_t *i = vam->input;
5509 vl_api_bd_ip_mac_add_del_t *mp;
5517 ip4_address_t v4addr;
5518 ip6_address_t v6addr;
5522 /* Parse args required to build the message */
5523 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5525 if (unformat (i, "bd_id %d", &bd_id))
5529 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5533 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5538 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5542 else if (unformat (i, "del"))
5550 errmsg ("missing bridge domain\n");
5553 else if (ip_set == 0)
5555 errmsg ("missing IP address\n");
5558 else if (mac_set == 0)
5560 errmsg ("missing MAC address\n");
5564 M (BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del);
5566 mp->bd_id = ntohl (bd_id);
5567 mp->is_ipv6 = is_ipv6;
5568 mp->is_add = is_add;
5570 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5572 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5573 clib_memcpy (mp->mac_address, macaddr, 6);
5581 api_tap_connect (vat_main_t * vam)
5583 unformat_input_t *i = vam->input;
5584 vl_api_tap_connect_t *mp;
5591 memset (mac_address, 0, sizeof (mac_address));
5593 /* Parse args required to build the message */
5594 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5596 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5600 else if (unformat (i, "random-mac"))
5602 else if (unformat (i, "tapname %s", &tap_name))
5610 errmsg ("missing tap name\n");
5613 if (vec_len (tap_name) > 63)
5615 errmsg ("tap name too long\n");
5617 vec_add1 (tap_name, 0);
5619 /* Construct the API message */
5620 M (TAP_CONNECT, tap_connect);
5622 mp->use_random_mac = random_mac;
5623 clib_memcpy (mp->mac_address, mac_address, 6);
5624 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5625 vec_free (tap_name);
5630 /* Wait for a reply... */
5635 api_tap_modify (vat_main_t * vam)
5637 unformat_input_t *i = vam->input;
5638 vl_api_tap_modify_t *mp;
5644 u32 sw_if_index = ~0;
5645 u8 sw_if_index_set = 0;
5647 memset (mac_address, 0, sizeof (mac_address));
5649 /* Parse args required to build the message */
5650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5652 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5653 sw_if_index_set = 1;
5654 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5655 sw_if_index_set = 1;
5656 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5660 else if (unformat (i, "random-mac"))
5662 else if (unformat (i, "tapname %s", &tap_name))
5668 if (sw_if_index_set == 0)
5670 errmsg ("missing vpp interface name");
5675 errmsg ("missing tap name\n");
5678 if (vec_len (tap_name) > 63)
5680 errmsg ("tap name too long\n");
5682 vec_add1 (tap_name, 0);
5684 /* Construct the API message */
5685 M (TAP_MODIFY, tap_modify);
5687 mp->use_random_mac = random_mac;
5688 mp->sw_if_index = ntohl (sw_if_index);
5689 clib_memcpy (mp->mac_address, mac_address, 6);
5690 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5691 vec_free (tap_name);
5696 /* Wait for a reply... */
5701 api_tap_delete (vat_main_t * vam)
5703 unformat_input_t *i = vam->input;
5704 vl_api_tap_delete_t *mp;
5706 u32 sw_if_index = ~0;
5707 u8 sw_if_index_set = 0;
5709 /* Parse args required to build the message */
5710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5712 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5713 sw_if_index_set = 1;
5714 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5715 sw_if_index_set = 1;
5720 if (sw_if_index_set == 0)
5722 errmsg ("missing vpp interface name");
5726 /* Construct the API message */
5727 M (TAP_DELETE, tap_delete);
5729 mp->sw_if_index = ntohl (sw_if_index);
5734 /* Wait for a reply... */
5739 api_ip_add_del_route (vat_main_t * vam)
5741 unformat_input_t *i = vam->input;
5742 vl_api_ip_add_del_route_t *mp;
5744 u32 sw_if_index = ~0, vrf_id = 0;
5745 u8 sw_if_index_set = 0;
5747 u8 is_local = 0, is_drop = 0;
5748 u8 create_vrf_if_needed = 0;
5750 u8 next_hop_weight = 1;
5752 u8 is_multipath = 0;
5754 u8 address_length_set = 0;
5755 u32 lookup_in_vrf = 0;
5756 u32 resolve_attempts = 0;
5757 u32 dst_address_length = 0;
5758 u8 next_hop_set = 0;
5759 ip4_address_t v4_dst_address, v4_next_hop_address;
5760 ip6_address_t v6_dst_address, v6_next_hop_address;
5764 u32 random_add_del = 0;
5765 u32 *random_vector = 0;
5767 u32 random_seed = 0xdeaddabe;
5768 u32 classify_table_index = ~0;
5770 u8 resolve_host = 0, resolve_attached = 0;
5772 /* Parse args required to build the message */
5773 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5775 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5776 sw_if_index_set = 1;
5777 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5778 sw_if_index_set = 1;
5779 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
5784 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
5789 else if (unformat (i, "/%d", &dst_address_length))
5791 address_length_set = 1;
5794 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
5795 &v4_next_hop_address))
5799 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
5800 &v6_next_hop_address))
5804 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
5806 else if (unformat (i, "weight %d", &next_hop_weight))
5808 else if (unformat (i, "drop"))
5812 else if (unformat (i, "local"))
5816 else if (unformat (i, "classify %d", &classify_table_index))
5820 else if (unformat (i, "del"))
5822 else if (unformat (i, "add"))
5824 else if (unformat (i, "not-last"))
5826 else if (unformat (i, "resolve-via-host"))
5828 else if (unformat (i, "resolve-via-attached"))
5829 resolve_attached = 1;
5830 else if (unformat (i, "multipath"))
5832 else if (unformat (i, "vrf %d", &vrf_id))
5834 else if (unformat (i, "create-vrf"))
5835 create_vrf_if_needed = 1;
5836 else if (unformat (i, "count %d", &count))
5838 else if (unformat (i, "lookup-in-vrf %d", &lookup_in_vrf))
5840 else if (unformat (i, "random"))
5842 else if (unformat (i, "seed %d", &random_seed))
5846 clib_warning ("parse error '%U'", format_unformat_error, i);
5851 if (resolve_attempts > 0 && sw_if_index_set == 0)
5853 errmsg ("ARP resolution needs explicit interface or sw_if_index\n");
5857 if (!next_hop_set && !is_drop && !is_local && !is_classify)
5859 errmsg ("next hop / local / drop / classify not set\n");
5863 if (address_set == 0)
5865 errmsg ("missing addresses\n");
5869 if (address_length_set == 0)
5871 errmsg ("missing address length\n");
5875 /* Generate a pile of unique, random routes */
5878 u32 this_random_address;
5879 random_hash = hash_create (count, sizeof (uword));
5881 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
5882 for (j = 0; j <= count; j++)
5886 this_random_address = random_u32 (&random_seed);
5887 this_random_address =
5888 clib_host_to_net_u32 (this_random_address);
5890 while (hash_get (random_hash, this_random_address));
5891 vec_add1 (random_vector, this_random_address);
5892 hash_set (random_hash, this_random_address, 1);
5894 hash_free (random_hash);
5895 v4_dst_address.as_u32 = random_vector[0];
5900 /* Turn on async mode */
5901 vam->async_mode = 1;
5902 vam->async_errors = 0;
5903 before = vat_time_now (vam);
5906 for (j = 0; j < count; j++)
5908 /* Construct the API message */
5909 M (IP_ADD_DEL_ROUTE, ip_add_del_route);
5911 mp->next_hop_sw_if_index = ntohl (sw_if_index);
5912 mp->vrf_id = ntohl (vrf_id);
5913 if (resolve_attempts > 0)
5915 mp->resolve_attempts = ntohl (resolve_attempts);
5916 mp->resolve_if_needed = 1;
5918 mp->create_vrf_if_needed = create_vrf_if_needed;
5920 mp->is_add = is_add;
5921 mp->is_drop = is_drop;
5922 mp->is_ipv6 = is_ipv6;
5923 mp->is_local = is_local;
5924 mp->is_classify = is_classify;
5925 mp->is_multipath = is_multipath;
5926 mp->is_resolve_host = resolve_host;
5927 mp->is_resolve_attached = resolve_attached;
5928 mp->not_last = not_last;
5929 mp->next_hop_weight = next_hop_weight;
5930 mp->dst_address_length = dst_address_length;
5931 mp->lookup_in_vrf = ntohl (lookup_in_vrf);
5932 mp->classify_table_index = ntohl (classify_table_index);
5936 clib_memcpy (mp->dst_address, &v6_dst_address,
5937 sizeof (v6_dst_address));
5939 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
5940 sizeof (v6_next_hop_address));
5941 increment_v6_address (&v6_dst_address);
5945 clib_memcpy (mp->dst_address, &v4_dst_address,
5946 sizeof (v4_dst_address));
5948 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
5949 sizeof (v4_next_hop_address));
5951 v4_dst_address.as_u32 = random_vector[j + 1];
5953 increment_v4_address (&v4_dst_address);
5957 /* If we receive SIGTERM, stop now... */
5962 /* When testing multiple add/del ops, use a control-ping to sync */
5965 vl_api_control_ping_t *mp;
5968 /* Shut off async mode */
5969 vam->async_mode = 0;
5971 M (CONTROL_PING, control_ping);
5974 timeout = vat_time_now (vam) + 1.0;
5975 while (vat_time_now (vam) < timeout)
5976 if (vam->result_ready == 1)
5981 if (vam->retval == -99)
5982 errmsg ("timeout\n");
5984 if (vam->async_errors > 0)
5986 errmsg ("%d asynchronous errors\n", vam->async_errors);
5989 vam->async_errors = 0;
5990 after = vat_time_now (vam);
5992 /* slim chance, but we might have eaten SIGTERM on the first iteration */
5996 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
5997 count, after - before, count / (after - before));
6001 /* Wait for a reply... */
6005 /* Return the good/bad news */
6006 return (vam->retval);
6010 api_proxy_arp_add_del (vat_main_t * vam)
6012 unformat_input_t *i = vam->input;
6013 vl_api_proxy_arp_add_del_t *mp;
6017 ip4_address_t lo, hi;
6020 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6022 if (unformat (i, "vrf %d", &vrf_id))
6024 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
6025 unformat_ip4_address, &hi))
6027 else if (unformat (i, "del"))
6031 clib_warning ("parse error '%U'", format_unformat_error, i);
6038 errmsg ("address range not set\n");
6042 M (PROXY_ARP_ADD_DEL, proxy_arp_add_del);
6044 mp->vrf_id = ntohl (vrf_id);
6045 mp->is_add = is_add;
6046 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
6047 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
6056 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
6058 unformat_input_t *i = vam->input;
6059 vl_api_proxy_arp_intfc_enable_disable_t *mp;
6063 u8 sw_if_index_set = 0;
6065 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6067 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6068 sw_if_index_set = 1;
6069 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6070 sw_if_index_set = 1;
6071 else if (unformat (i, "enable"))
6073 else if (unformat (i, "disable"))
6077 clib_warning ("parse error '%U'", format_unformat_error, i);
6082 if (sw_if_index_set == 0)
6084 errmsg ("missing interface name or sw_if_index\n");
6088 M (PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable);
6090 mp->sw_if_index = ntohl (sw_if_index);
6091 mp->enable_disable = enable;
6100 api_mpls_add_del_decap (vat_main_t * vam)
6102 unformat_input_t *i = vam->input;
6103 vl_api_mpls_add_del_decap_t *mp;
6112 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6114 if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
6116 else if (unformat (i, "tx_vrf_id %d", &tx_vrf_id))
6118 else if (unformat (i, "label %d", &label))
6120 else if (unformat (i, "next-index %d", &next_index))
6122 else if (unformat (i, "del"))
6124 else if (unformat (i, "s-bit-clear"))
6128 clib_warning ("parse error '%U'", format_unformat_error, i);
6133 M (MPLS_ADD_DEL_DECAP, mpls_add_del_decap);
6135 mp->rx_vrf_id = ntohl (rx_vrf_id);
6136 mp->tx_vrf_id = ntohl (tx_vrf_id);
6137 mp->label = ntohl (label);
6138 mp->next_index = ntohl (next_index);
6140 mp->is_add = is_add;
6149 api_mpls_add_del_encap (vat_main_t * vam)
6151 unformat_input_t *i = vam->input;
6152 vl_api_mpls_add_del_encap_t *mp;
6157 ip4_address_t dst_address;
6160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6162 if (unformat (i, "vrf %d", &vrf_id))
6164 else if (unformat (i, "label %d", &label))
6165 vec_add1 (labels, ntohl (label));
6166 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
6168 else if (unformat (i, "del"))
6172 clib_warning ("parse error '%U'", format_unformat_error, i);
6177 if (vec_len (labels) == 0)
6179 errmsg ("missing encap label stack\n");
6183 M2 (MPLS_ADD_DEL_ENCAP, mpls_add_del_encap,
6184 sizeof (u32) * vec_len (labels));
6186 mp->vrf_id = ntohl (vrf_id);
6187 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
6188 mp->is_add = is_add;
6189 mp->nlabels = vec_len (labels);
6190 clib_memcpy (mp->labels, labels, sizeof (u32) * mp->nlabels);
6201 api_mpls_gre_add_del_tunnel (vat_main_t * vam)
6203 unformat_input_t *i = vam->input;
6204 vl_api_mpls_gre_add_del_tunnel_t *mp;
6206 u32 inner_vrf_id = 0;
6207 u32 outer_vrf_id = 0;
6208 ip4_address_t src_address;
6209 ip4_address_t dst_address;
6210 ip4_address_t intfc_address;
6212 u8 intfc_address_length = 0;
6216 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6218 if (unformat (i, "inner_vrf_id %d", &inner_vrf_id))
6220 else if (unformat (i, "outer_vrf_id %d", &outer_vrf_id))
6222 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
6224 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
6226 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
6227 &intfc_address, &tmp))
6228 intfc_address_length = tmp;
6229 else if (unformat (i, "l2-only"))
6231 else if (unformat (i, "del"))
6235 clib_warning ("parse error '%U'", format_unformat_error, i);
6240 M (MPLS_GRE_ADD_DEL_TUNNEL, mpls_gre_add_del_tunnel);
6242 mp->inner_vrf_id = ntohl (inner_vrf_id);
6243 mp->outer_vrf_id = ntohl (outer_vrf_id);
6244 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
6245 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
6246 clib_memcpy (mp->intfc_address, &intfc_address, sizeof (intfc_address));
6247 mp->intfc_address_length = intfc_address_length;
6248 mp->l2_only = l2_only;
6249 mp->is_add = is_add;
6258 api_mpls_ethernet_add_del_tunnel (vat_main_t * vam)
6260 unformat_input_t *i = vam->input;
6261 vl_api_mpls_ethernet_add_del_tunnel_t *mp;
6263 u32 inner_vrf_id = 0;
6264 ip4_address_t intfc_address;
6265 u8 dst_mac_address[6];
6268 u8 intfc_address_length = 0;
6272 int tx_sw_if_index_set = 0;
6274 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6276 if (unformat (i, "vrf %d", &inner_vrf_id))
6278 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
6279 &intfc_address, &tmp))
6280 intfc_address_length = tmp;
6281 else if (unformat (i, "%U", unformat_sw_if_index, vam, &tx_sw_if_index))
6282 tx_sw_if_index_set = 1;
6283 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6284 tx_sw_if_index_set = 1;
6285 else if (unformat (i, "dst %U", unformat_ethernet_address,
6288 else if (unformat (i, "l2-only"))
6290 else if (unformat (i, "del"))
6294 clib_warning ("parse error '%U'", format_unformat_error, i);
6301 errmsg ("dst (mac address) not set\n");
6304 if (!tx_sw_if_index_set)
6306 errmsg ("tx-intfc not set\n");
6310 M (MPLS_ETHERNET_ADD_DEL_TUNNEL, mpls_ethernet_add_del_tunnel);
6312 mp->vrf_id = ntohl (inner_vrf_id);
6313 clib_memcpy (mp->adj_address, &intfc_address, sizeof (intfc_address));
6314 mp->adj_address_length = intfc_address_length;
6315 clib_memcpy (mp->dst_mac_address, dst_mac_address,
6316 sizeof (dst_mac_address));
6317 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6318 mp->l2_only = l2_only;
6319 mp->is_add = is_add;
6328 api_mpls_ethernet_add_del_tunnel_2 (vat_main_t * vam)
6330 unformat_input_t *i = vam->input;
6331 vl_api_mpls_ethernet_add_del_tunnel_2_t *mp;
6333 u32 inner_vrf_id = 0;
6334 u32 outer_vrf_id = 0;
6335 ip4_address_t adj_address;
6336 int adj_address_set = 0;
6337 ip4_address_t next_hop_address;
6338 int next_hop_address_set = 0;
6340 u8 adj_address_length = 0;
6343 u32 resolve_attempts = 5;
6344 u8 resolve_if_needed = 1;
6346 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6348 if (unformat (i, "inner_vrf_id %d", &inner_vrf_id))
6350 else if (unformat (i, "outer_vrf_id %d", &outer_vrf_id))
6352 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
6353 &adj_address, &tmp))
6355 adj_address_length = tmp;
6356 adj_address_set = 1;
6358 else if (unformat (i, "next-hop %U", unformat_ip4_address,
6360 next_hop_address_set = 1;
6361 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6363 else if (unformat (i, "resolve-if-needed %d", &tmp))
6364 resolve_if_needed = tmp;
6365 else if (unformat (i, "l2-only"))
6367 else if (unformat (i, "del"))
6371 clib_warning ("parse error '%U'", format_unformat_error, i);
6376 if (!adj_address_set)
6378 errmsg ("adjacency address/mask not set\n");
6381 if (!next_hop_address_set)
6383 errmsg ("ip4 next hop address (in outer fib) not set\n");
6387 M (MPLS_ETHERNET_ADD_DEL_TUNNEL_2, mpls_ethernet_add_del_tunnel_2);
6389 mp->inner_vrf_id = ntohl (inner_vrf_id);
6390 mp->outer_vrf_id = ntohl (outer_vrf_id);
6391 mp->resolve_attempts = ntohl (resolve_attempts);
6392 mp->resolve_if_needed = resolve_if_needed;
6393 mp->is_add = is_add;
6394 mp->l2_only = l2_only;
6395 clib_memcpy (mp->adj_address, &adj_address, sizeof (adj_address));
6396 mp->adj_address_length = adj_address_length;
6397 clib_memcpy (mp->next_hop_ip4_address_in_outer_vrf, &next_hop_address,
6398 sizeof (next_hop_address));
6407 api_sw_interface_set_unnumbered (vat_main_t * vam)
6409 unformat_input_t *i = vam->input;
6410 vl_api_sw_interface_set_unnumbered_t *mp;
6413 u32 unnum_sw_index = ~0;
6415 u8 sw_if_index_set = 0;
6417 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6419 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6420 sw_if_index_set = 1;
6421 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6422 sw_if_index_set = 1;
6423 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
6425 else if (unformat (i, "del"))
6429 clib_warning ("parse error '%U'", format_unformat_error, i);
6434 if (sw_if_index_set == 0)
6436 errmsg ("missing interface name or sw_if_index\n");
6440 M (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered);
6442 mp->sw_if_index = ntohl (sw_if_index);
6443 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
6444 mp->is_add = is_add;
6453 api_ip_neighbor_add_del (vat_main_t * vam)
6455 unformat_input_t *i = vam->input;
6456 vl_api_ip_neighbor_add_del_t *mp;
6459 u8 sw_if_index_set = 0;
6465 u8 v4_address_set = 0;
6466 u8 v6_address_set = 0;
6467 ip4_address_t v4address;
6468 ip6_address_t v6address;
6470 memset (mac_address, 0, sizeof (mac_address));
6472 /* Parse args required to build the message */
6473 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6475 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6479 else if (unformat (i, "del"))
6481 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6482 sw_if_index_set = 1;
6483 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6484 sw_if_index_set = 1;
6485 else if (unformat (i, "is_static"))
6487 else if (unformat (i, "vrf %d", &vrf_id))
6489 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
6491 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
6495 clib_warning ("parse error '%U'", format_unformat_error, i);
6500 if (sw_if_index_set == 0)
6502 errmsg ("missing interface name or sw_if_index\n");
6505 if (v4_address_set && v6_address_set)
6507 errmsg ("both v4 and v6 addresses set\n");
6510 if (!v4_address_set && !v6_address_set)
6512 errmsg ("no address set\n");
6516 /* Construct the API message */
6517 M (IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del);
6519 mp->sw_if_index = ntohl (sw_if_index);
6520 mp->is_add = is_add;
6521 mp->vrf_id = ntohl (vrf_id);
6522 mp->is_static = is_static;
6524 clib_memcpy (mp->mac_address, mac_address, 6);
6528 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
6532 /* mp->is_ipv6 = 0; via memset in M macro above */
6533 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
6539 /* Wait for a reply, return good/bad news */
6547 api_reset_vrf (vat_main_t * vam)
6549 unformat_input_t *i = vam->input;
6550 vl_api_reset_vrf_t *mp;
6556 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6558 if (unformat (i, "vrf %d", &vrf_id))
6560 else if (unformat (i, "ipv6"))
6564 clib_warning ("parse error '%U'", format_unformat_error, i);
6569 if (vrf_id_set == 0)
6571 errmsg ("missing vrf id\n");
6575 M (RESET_VRF, reset_vrf);
6577 mp->vrf_id = ntohl (vrf_id);
6578 mp->is_ipv6 = is_ipv6;
6587 api_create_vlan_subif (vat_main_t * vam)
6589 unformat_input_t *i = vam->input;
6590 vl_api_create_vlan_subif_t *mp;
6593 u8 sw_if_index_set = 0;
6597 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6599 if (unformat (i, "sw_if_index %d", &sw_if_index))
6600 sw_if_index_set = 1;
6601 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6602 sw_if_index_set = 1;
6603 else if (unformat (i, "vlan %d", &vlan_id))
6607 clib_warning ("parse error '%U'", format_unformat_error, i);
6612 if (sw_if_index_set == 0)
6614 errmsg ("missing interface name or sw_if_index\n");
6618 if (vlan_id_set == 0)
6620 errmsg ("missing vlan_id\n");
6623 M (CREATE_VLAN_SUBIF, create_vlan_subif);
6625 mp->sw_if_index = ntohl (sw_if_index);
6626 mp->vlan_id = ntohl (vlan_id);
6634 #define foreach_create_subif_bit \
6641 _(outer_vlan_id_any) \
6642 _(inner_vlan_id_any)
6645 api_create_subif (vat_main_t * vam)
6647 unformat_input_t *i = vam->input;
6648 vl_api_create_subif_t *mp;
6651 u8 sw_if_index_set = 0;
6658 u32 exact_match = 0;
6659 u32 default_sub = 0;
6660 u32 outer_vlan_id_any = 0;
6661 u32 inner_vlan_id_any = 0;
6663 u16 outer_vlan_id = 0;
6664 u16 inner_vlan_id = 0;
6666 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6668 if (unformat (i, "sw_if_index %d", &sw_if_index))
6669 sw_if_index_set = 1;
6670 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6671 sw_if_index_set = 1;
6672 else if (unformat (i, "sub_id %d", &sub_id))
6674 else if (unformat (i, "outer_vlan_id %d", &tmp))
6675 outer_vlan_id = tmp;
6676 else if (unformat (i, "inner_vlan_id %d", &tmp))
6677 inner_vlan_id = tmp;
6679 #define _(a) else if (unformat (i, #a)) a = 1 ;
6680 foreach_create_subif_bit
6684 clib_warning ("parse error '%U'", format_unformat_error, i);
6689 if (sw_if_index_set == 0)
6691 errmsg ("missing interface name or sw_if_index\n");
6695 if (sub_id_set == 0)
6697 errmsg ("missing sub_id\n");
6700 M (CREATE_SUBIF, create_subif);
6702 mp->sw_if_index = ntohl (sw_if_index);
6703 mp->sub_id = ntohl (sub_id);
6705 #define _(a) mp->a = a;
6706 foreach_create_subif_bit;
6709 mp->outer_vlan_id = ntohs (outer_vlan_id);
6710 mp->inner_vlan_id = ntohs (inner_vlan_id);
6719 api_oam_add_del (vat_main_t * vam)
6721 unformat_input_t *i = vam->input;
6722 vl_api_oam_add_del_t *mp;
6726 ip4_address_t src, dst;
6730 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6732 if (unformat (i, "vrf %d", &vrf_id))
6734 else if (unformat (i, "src %U", unformat_ip4_address, &src))
6736 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
6738 else if (unformat (i, "del"))
6742 clib_warning ("parse error '%U'", format_unformat_error, i);
6749 errmsg ("missing src addr\n");
6755 errmsg ("missing dst addr\n");
6759 M (OAM_ADD_DEL, oam_add_del);
6761 mp->vrf_id = ntohl (vrf_id);
6762 mp->is_add = is_add;
6763 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
6764 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
6773 api_reset_fib (vat_main_t * vam)
6775 unformat_input_t *i = vam->input;
6776 vl_api_reset_fib_t *mp;
6782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6784 if (unformat (i, "vrf %d", &vrf_id))
6786 else if (unformat (i, "ipv6"))
6790 clib_warning ("parse error '%U'", format_unformat_error, i);
6795 if (vrf_id_set == 0)
6797 errmsg ("missing vrf id\n");
6801 M (RESET_FIB, reset_fib);
6803 mp->vrf_id = ntohl (vrf_id);
6804 mp->is_ipv6 = is_ipv6;
6813 api_dhcp_proxy_config (vat_main_t * vam)
6815 unformat_input_t *i = vam->input;
6816 vl_api_dhcp_proxy_config_t *mp;
6821 u8 v4_address_set = 0;
6822 u8 v6_address_set = 0;
6823 ip4_address_t v4address;
6824 ip6_address_t v6address;
6825 u8 v4_src_address_set = 0;
6826 u8 v6_src_address_set = 0;
6827 ip4_address_t v4srcaddress;
6828 ip6_address_t v6srcaddress;
6830 /* Parse args required to build the message */
6831 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6833 if (unformat (i, "del"))
6835 else if (unformat (i, "vrf %d", &vrf_id))
6837 else if (unformat (i, "insert-cid %d", &insert_cid))
6839 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
6841 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
6843 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
6844 v4_src_address_set = 1;
6845 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
6846 v6_src_address_set = 1;
6851 if (v4_address_set && v6_address_set)
6853 errmsg ("both v4 and v6 server addresses set\n");
6856 if (!v4_address_set && !v6_address_set)
6858 errmsg ("no server addresses set\n");
6862 if (v4_src_address_set && v6_src_address_set)
6864 errmsg ("both v4 and v6 src addresses set\n");
6867 if (!v4_src_address_set && !v6_src_address_set)
6869 errmsg ("no src addresses set\n");
6873 if (!(v4_src_address_set && v4_address_set) &&
6874 !(v6_src_address_set && v6_address_set))
6876 errmsg ("no matching server and src addresses set\n");
6880 /* Construct the API message */
6881 M (DHCP_PROXY_CONFIG, dhcp_proxy_config);
6883 mp->insert_circuit_id = insert_cid;
6884 mp->is_add = is_add;
6885 mp->vrf_id = ntohl (vrf_id);
6889 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
6890 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
6894 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
6895 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
6901 /* Wait for a reply, return good/bad news */
6908 api_dhcp_proxy_config_2 (vat_main_t * vam)
6910 unformat_input_t *i = vam->input;
6911 vl_api_dhcp_proxy_config_2_t *mp;
6914 u32 server_vrf_id = 0;
6917 u8 v4_address_set = 0;
6918 u8 v6_address_set = 0;
6919 ip4_address_t v4address;
6920 ip6_address_t v6address;
6921 u8 v4_src_address_set = 0;
6922 u8 v6_src_address_set = 0;
6923 ip4_address_t v4srcaddress;
6924 ip6_address_t v6srcaddress;
6926 /* Parse args required to build the message */
6927 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6929 if (unformat (i, "del"))
6931 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
6933 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
6935 else if (unformat (i, "insert-cid %d", &insert_cid))
6937 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
6939 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
6941 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
6942 v4_src_address_set = 1;
6943 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
6944 v6_src_address_set = 1;
6949 if (v4_address_set && v6_address_set)
6951 errmsg ("both v4 and v6 server addresses set\n");
6954 if (!v4_address_set && !v6_address_set)
6956 errmsg ("no server addresses set\n");
6960 if (v4_src_address_set && v6_src_address_set)
6962 errmsg ("both v4 and v6 src addresses set\n");
6965 if (!v4_src_address_set && !v6_src_address_set)
6967 errmsg ("no src addresses set\n");
6971 if (!(v4_src_address_set && v4_address_set) &&
6972 !(v6_src_address_set && v6_address_set))
6974 errmsg ("no matching server and src addresses set\n");
6978 /* Construct the API message */
6979 M (DHCP_PROXY_CONFIG_2, dhcp_proxy_config_2);
6981 mp->insert_circuit_id = insert_cid;
6982 mp->is_add = is_add;
6983 mp->rx_vrf_id = ntohl (rx_vrf_id);
6984 mp->server_vrf_id = ntohl (server_vrf_id);
6988 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
6989 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
6993 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
6994 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7000 /* Wait for a reply, return good/bad news */
7007 api_dhcp_proxy_set_vss (vat_main_t * vam)
7009 unformat_input_t *i = vam->input;
7010 vl_api_dhcp_proxy_set_vss_t *mp;
7021 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7023 if (unformat (i, "tbl_id %d", &tbl_id))
7025 if (unformat (i, "fib_id %d", &fib_id))
7027 if (unformat (i, "oui %d", &oui))
7029 else if (unformat (i, "ipv6"))
7031 else if (unformat (i, "del"))
7035 clib_warning ("parse error '%U'", format_unformat_error, i);
7040 if (tbl_id_set == 0)
7042 errmsg ("missing tbl id\n");
7046 if (fib_id_set == 0)
7048 errmsg ("missing fib id\n");
7053 errmsg ("missing oui\n");
7057 M (DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss);
7058 mp->tbl_id = ntohl (tbl_id);
7059 mp->fib_id = ntohl (fib_id);
7060 mp->oui = ntohl (oui);
7061 mp->is_ipv6 = is_ipv6;
7062 mp->is_add = is_add;
7071 api_dhcp_client_config (vat_main_t * vam)
7073 unformat_input_t *i = vam->input;
7074 vl_api_dhcp_client_config_t *mp;
7077 u8 sw_if_index_set = 0;
7080 u8 disable_event = 0;
7082 /* Parse args required to build the message */
7083 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7085 if (unformat (i, "del"))
7087 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7088 sw_if_index_set = 1;
7089 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7090 sw_if_index_set = 1;
7091 else if (unformat (i, "hostname %s", &hostname))
7093 else if (unformat (i, "disable_event"))
7099 if (sw_if_index_set == 0)
7101 errmsg ("missing interface name or sw_if_index\n");
7105 if (vec_len (hostname) > 63)
7107 errmsg ("hostname too long\n");
7109 vec_add1 (hostname, 0);
7111 /* Construct the API message */
7112 M (DHCP_CLIENT_CONFIG, dhcp_client_config);
7114 mp->sw_if_index = ntohl (sw_if_index);
7115 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7116 vec_free (hostname);
7117 mp->is_add = is_add;
7118 mp->want_dhcp_event = disable_event ? 0 : 1;
7119 mp->pid = getpid ();
7124 /* Wait for a reply, return good/bad news */
7131 api_set_ip_flow_hash (vat_main_t * vam)
7133 unformat_input_t *i = vam->input;
7134 vl_api_set_ip_flow_hash_t *mp;
7146 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7148 if (unformat (i, "vrf %d", &vrf_id))
7150 else if (unformat (i, "ipv6"))
7152 else if (unformat (i, "src"))
7154 else if (unformat (i, "dst"))
7156 else if (unformat (i, "sport"))
7158 else if (unformat (i, "dport"))
7160 else if (unformat (i, "proto"))
7162 else if (unformat (i, "reverse"))
7167 clib_warning ("parse error '%U'", format_unformat_error, i);
7172 if (vrf_id_set == 0)
7174 errmsg ("missing vrf id\n");
7178 M (SET_IP_FLOW_HASH, set_ip_flow_hash);
7184 mp->reverse = reverse;
7185 mp->vrf_id = ntohl (vrf_id);
7186 mp->is_ipv6 = is_ipv6;
7195 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7197 unformat_input_t *i = vam->input;
7198 vl_api_sw_interface_ip6_enable_disable_t *mp;
7201 u8 sw_if_index_set = 0;
7204 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7206 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7207 sw_if_index_set = 1;
7208 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7209 sw_if_index_set = 1;
7210 else if (unformat (i, "enable"))
7212 else if (unformat (i, "disable"))
7216 clib_warning ("parse error '%U'", format_unformat_error, i);
7221 if (sw_if_index_set == 0)
7223 errmsg ("missing interface name or sw_if_index\n");
7227 M (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable);
7229 mp->sw_if_index = ntohl (sw_if_index);
7230 mp->enable = enable;
7239 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7241 unformat_input_t *i = vam->input;
7242 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7245 u8 sw_if_index_set = 0;
7246 u32 address_length = 0;
7247 u8 v6_address_set = 0;
7248 ip6_address_t v6address;
7250 /* Parse args required to build the message */
7251 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7253 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7254 sw_if_index_set = 1;
7255 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7256 sw_if_index_set = 1;
7257 else if (unformat (i, "%U/%d",
7258 unformat_ip6_address, &v6address, &address_length))
7264 if (sw_if_index_set == 0)
7266 errmsg ("missing interface name or sw_if_index\n");
7269 if (!v6_address_set)
7271 errmsg ("no address set\n");
7275 /* Construct the API message */
7276 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,
7277 sw_interface_ip6_set_link_local_address);
7279 mp->sw_if_index = ntohl (sw_if_index);
7280 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7281 mp->address_length = address_length;
7286 /* Wait for a reply, return good/bad news */
7295 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
7297 unformat_input_t *i = vam->input;
7298 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
7301 u8 sw_if_index_set = 0;
7302 u32 address_length = 0;
7303 u8 v6_address_set = 0;
7304 ip6_address_t v6address;
7306 u8 no_advertise = 0;
7308 u8 no_autoconfig = 0;
7311 u32 val_lifetime = 0;
7312 u32 pref_lifetime = 0;
7314 /* Parse args required to build the message */
7315 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7317 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7318 sw_if_index_set = 1;
7319 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7320 sw_if_index_set = 1;
7321 else if (unformat (i, "%U/%d",
7322 unformat_ip6_address, &v6address, &address_length))
7324 else if (unformat (i, "val_life %d", &val_lifetime))
7326 else if (unformat (i, "pref_life %d", &pref_lifetime))
7328 else if (unformat (i, "def"))
7330 else if (unformat (i, "noadv"))
7332 else if (unformat (i, "offl"))
7334 else if (unformat (i, "noauto"))
7336 else if (unformat (i, "nolink"))
7338 else if (unformat (i, "isno"))
7342 clib_warning ("parse error '%U'", format_unformat_error, i);
7347 if (sw_if_index_set == 0)
7349 errmsg ("missing interface name or sw_if_index\n");
7352 if (!v6_address_set)
7354 errmsg ("no address set\n");
7358 /* Construct the API message */
7359 M (SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix);
7361 mp->sw_if_index = ntohl (sw_if_index);
7362 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7363 mp->address_length = address_length;
7364 mp->use_default = use_default;
7365 mp->no_advertise = no_advertise;
7366 mp->off_link = off_link;
7367 mp->no_autoconfig = no_autoconfig;
7368 mp->no_onlink = no_onlink;
7370 mp->val_lifetime = ntohl (val_lifetime);
7371 mp->pref_lifetime = ntohl (pref_lifetime);
7376 /* Wait for a reply, return good/bad news */
7384 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
7386 unformat_input_t *i = vam->input;
7387 vl_api_sw_interface_ip6nd_ra_config_t *mp;
7390 u8 sw_if_index_set = 0;
7395 u8 send_unicast = 0;
7398 u8 default_router = 0;
7399 u32 max_interval = 0;
7400 u32 min_interval = 0;
7402 u32 initial_count = 0;
7403 u32 initial_interval = 0;
7406 /* Parse args required to build the message */
7407 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7409 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7410 sw_if_index_set = 1;
7411 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7412 sw_if_index_set = 1;
7413 else if (unformat (i, "maxint %d", &max_interval))
7415 else if (unformat (i, "minint %d", &min_interval))
7417 else if (unformat (i, "life %d", &lifetime))
7419 else if (unformat (i, "count %d", &initial_count))
7421 else if (unformat (i, "interval %d", &initial_interval))
7423 else if (unformat (i, "suppress") || unformat (i, "surpress"))
7425 else if (unformat (i, "managed"))
7427 else if (unformat (i, "other"))
7429 else if (unformat (i, "ll"))
7431 else if (unformat (i, "send"))
7433 else if (unformat (i, "cease"))
7435 else if (unformat (i, "isno"))
7437 else if (unformat (i, "def"))
7441 clib_warning ("parse error '%U'", format_unformat_error, i);
7446 if (sw_if_index_set == 0)
7448 errmsg ("missing interface name or sw_if_index\n");
7452 /* Construct the API message */
7453 M (SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config);
7455 mp->sw_if_index = ntohl (sw_if_index);
7456 mp->max_interval = ntohl (max_interval);
7457 mp->min_interval = ntohl (min_interval);
7458 mp->lifetime = ntohl (lifetime);
7459 mp->initial_count = ntohl (initial_count);
7460 mp->initial_interval = ntohl (initial_interval);
7461 mp->suppress = suppress;
7462 mp->managed = managed;
7464 mp->ll_option = ll_option;
7465 mp->send_unicast = send_unicast;
7468 mp->default_router = default_router;
7473 /* Wait for a reply, return good/bad news */
7481 api_set_arp_neighbor_limit (vat_main_t * vam)
7483 unformat_input_t *i = vam->input;
7484 vl_api_set_arp_neighbor_limit_t *mp;
7490 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7492 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
7494 else if (unformat (i, "ipv6"))
7498 clib_warning ("parse error '%U'", format_unformat_error, i);
7505 errmsg ("missing limit value\n");
7509 M (SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit);
7511 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
7512 mp->is_ipv6 = is_ipv6;
7521 api_l2_patch_add_del (vat_main_t * vam)
7523 unformat_input_t *i = vam->input;
7524 vl_api_l2_patch_add_del_t *mp;
7527 u8 rx_sw_if_index_set = 0;
7529 u8 tx_sw_if_index_set = 0;
7532 /* Parse args required to build the message */
7533 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7535 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7536 rx_sw_if_index_set = 1;
7537 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7538 tx_sw_if_index_set = 1;
7539 else if (unformat (i, "rx"))
7541 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7543 if (unformat (i, "%U", unformat_sw_if_index, vam,
7545 rx_sw_if_index_set = 1;
7550 else if (unformat (i, "tx"))
7552 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7554 if (unformat (i, "%U", unformat_sw_if_index, vam,
7556 tx_sw_if_index_set = 1;
7561 else if (unformat (i, "del"))
7567 if (rx_sw_if_index_set == 0)
7569 errmsg ("missing rx interface name or rx_sw_if_index\n");
7573 if (tx_sw_if_index_set == 0)
7575 errmsg ("missing tx interface name or tx_sw_if_index\n");
7579 M (L2_PATCH_ADD_DEL, l2_patch_add_del);
7581 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7582 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7583 mp->is_add = is_add;
7592 api_ioam_enable (vat_main_t * vam)
7594 unformat_input_t *input = vam->input;
7595 vl_api_ioam_enable_t *mp;
7598 int has_trace_option = 0;
7599 int has_pow_option = 0;
7600 int has_ppc_option = 0;
7602 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7604 if (unformat (input, "trace"))
7605 has_trace_option = 1;
7606 else if (unformat (input, "pow"))
7608 else if (unformat (input, "ppc encap"))
7609 has_ppc_option = PPC_ENCAP;
7610 else if (unformat (input, "ppc decap"))
7611 has_ppc_option = PPC_DECAP;
7612 else if (unformat (input, "ppc none"))
7613 has_ppc_option = PPC_NONE;
7617 M (IOAM_ENABLE, ioam_enable);
7618 mp->id = htons (id);
7619 mp->trace_ppc = has_ppc_option;
7620 mp->pow_enable = has_pow_option;
7621 mp->trace_enable = has_trace_option;
7632 api_ioam_disable (vat_main_t * vam)
7634 vl_api_ioam_disable_t *mp;
7637 M (IOAM_DISABLE, ioam_disable);
7644 api_sr_tunnel_add_del (vat_main_t * vam)
7646 unformat_input_t *i = vam->input;
7647 vl_api_sr_tunnel_add_del_t *mp;
7651 ip6_address_t src_address;
7652 int src_address_set = 0;
7653 ip6_address_t dst_address;
7655 int dst_address_set = 0;
7657 u32 rx_table_id = 0;
7658 u32 tx_table_id = 0;
7659 ip6_address_t *segments = 0;
7660 ip6_address_t *this_seg;
7661 ip6_address_t *tags = 0;
7662 ip6_address_t *this_tag;
7663 ip6_address_t next_address, tag;
7665 u8 *policy_name = 0;
7667 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7669 if (unformat (i, "del"))
7671 else if (unformat (i, "name %s", &name))
7673 else if (unformat (i, "policy %s", &policy_name))
7675 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
7677 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
7679 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
7680 src_address_set = 1;
7681 else if (unformat (i, "dst %U/%d",
7682 unformat_ip6_address, &dst_address, &dst_mask_width))
7683 dst_address_set = 1;
7684 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
7686 vec_add2 (segments, this_seg, 1);
7687 clib_memcpy (this_seg->as_u8, next_address.as_u8,
7688 sizeof (*this_seg));
7690 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
7692 vec_add2 (tags, this_tag, 1);
7693 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
7695 else if (unformat (i, "clean"))
7696 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
7697 else if (unformat (i, "protected"))
7698 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
7699 else if (unformat (i, "InPE %d", &pl_index))
7701 if (pl_index <= 0 || pl_index > 4)
7703 pl_index_range_error:
7704 errmsg ("pl index %d out of range\n", pl_index);
7708 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
7710 else if (unformat (i, "EgPE %d", &pl_index))
7712 if (pl_index <= 0 || pl_index > 4)
7713 goto pl_index_range_error;
7715 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
7717 else if (unformat (i, "OrgSrc %d", &pl_index))
7719 if (pl_index <= 0 || pl_index > 4)
7720 goto pl_index_range_error;
7722 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
7728 if (!src_address_set)
7730 errmsg ("src address required\n");
7734 if (!dst_address_set)
7736 errmsg ("dst address required\n");
7742 errmsg ("at least one sr segment required\n");
7746 M2 (SR_TUNNEL_ADD_DEL, sr_tunnel_add_del,
7747 vec_len (segments) * sizeof (ip6_address_t)
7748 + vec_len (tags) * sizeof (ip6_address_t));
7750 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
7751 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
7752 mp->dst_mask_width = dst_mask_width;
7753 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
7754 mp->n_segments = vec_len (segments);
7755 mp->n_tags = vec_len (tags);
7756 mp->is_add = is_del == 0;
7757 clib_memcpy (mp->segs_and_tags, segments,
7758 vec_len (segments) * sizeof (ip6_address_t));
7759 clib_memcpy (mp->segs_and_tags +
7760 vec_len (segments) * sizeof (ip6_address_t), tags,
7761 vec_len (tags) * sizeof (ip6_address_t));
7763 mp->outer_vrf_id = ntohl (rx_table_id);
7764 mp->inner_vrf_id = ntohl (tx_table_id);
7765 memcpy (mp->name, name, vec_len (name));
7766 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
7768 vec_free (segments);
7777 api_sr_policy_add_del (vat_main_t * vam)
7779 unformat_input_t *input = vam->input;
7780 vl_api_sr_policy_add_del_t *mp;
7784 u8 *tunnel_name = 0;
7785 u8 **tunnel_names = 0;
7790 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
7791 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
7793 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7795 if (unformat (input, "del"))
7797 else if (unformat (input, "name %s", &name))
7799 else if (unformat (input, "tunnel %s", &tunnel_name))
7803 vec_add1 (tunnel_names, tunnel_name);
7805 - length = #bytes to store in serial vector
7806 - +1 = byte to store that length
7808 tunnel_names_length += (vec_len (tunnel_name) + 1);
7819 errmsg ("policy name required\n");
7823 if ((!tunnel_set) && (!is_del))
7825 errmsg ("tunnel name required\n");
7829 M2 (SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length);
7833 mp->is_add = !is_del;
7835 memcpy (mp->name, name, vec_len (name));
7836 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
7837 u8 *serial_orig = 0;
7838 vec_validate (serial_orig, tunnel_names_length);
7839 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
7840 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
7842 for (j = 0; j < vec_len (tunnel_names); j++)
7844 tun_name_len = vec_len (tunnel_names[j]);
7845 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
7846 serial_orig += 1; // Move along one byte to store the actual tunnel name
7847 memcpy (serial_orig, tunnel_names[j], tun_name_len);
7848 serial_orig += tun_name_len; // Advance past the copy
7850 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
7852 vec_free (tunnel_names);
7853 vec_free (tunnel_name);
7861 api_sr_multicast_map_add_del (vat_main_t * vam)
7863 unformat_input_t *input = vam->input;
7864 vl_api_sr_multicast_map_add_del_t *mp;
7867 ip6_address_t multicast_address;
7868 u8 *policy_name = 0;
7869 int multicast_address_set = 0;
7871 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7873 if (unformat (input, "del"))
7877 (input, "address %U", unformat_ip6_address, &multicast_address))
7878 multicast_address_set = 1;
7879 else if (unformat (input, "sr-policy %s", &policy_name))
7885 if (!is_del && !policy_name)
7887 errmsg ("sr-policy name required\n");
7892 if (!multicast_address_set)
7894 errmsg ("address required\n");
7898 M (SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del);
7900 mp->is_add = !is_del;
7901 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
7902 clib_memcpy (mp->multicast_address, &multicast_address,
7903 sizeof (mp->multicast_address));
7906 vec_free (policy_name);
7914 #define foreach_tcp_proto_field \
7918 #define foreach_udp_proto_field \
7922 #define foreach_ip4_proto_field \
7933 unformat_tcp_mask (unformat_input_t * input, va_list * args)
7935 u8 **maskp = va_arg (*args, u8 **);
7937 u8 found_something = 0;
7940 #define _(a) u8 a=0;
7941 foreach_tcp_proto_field;
7944 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7947 #define _(a) else if (unformat (input, #a)) a=1;
7948 foreach_tcp_proto_field
7954 #define _(a) found_something += a;
7955 foreach_tcp_proto_field;
7958 if (found_something == 0)
7961 vec_validate (mask, sizeof (*tcp) - 1);
7963 tcp = (tcp_header_t *) mask;
7965 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
7966 foreach_tcp_proto_field;
7974 unformat_udp_mask (unformat_input_t * input, va_list * args)
7976 u8 **maskp = va_arg (*args, u8 **);
7978 u8 found_something = 0;
7981 #define _(a) u8 a=0;
7982 foreach_udp_proto_field;
7985 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7988 #define _(a) else if (unformat (input, #a)) a=1;
7989 foreach_udp_proto_field
7995 #define _(a) found_something += a;
7996 foreach_udp_proto_field;
7999 if (found_something == 0)
8002 vec_validate (mask, sizeof (*udp) - 1);
8004 udp = (udp_header_t *) mask;
8006 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8007 foreach_udp_proto_field;
8016 u16 src_port, dst_port;
8020 unformat_l4_mask (unformat_input_t * input, va_list * args)
8022 u8 **maskp = va_arg (*args, u8 **);
8023 u16 src_port = 0, dst_port = 0;
8024 tcpudp_header_t *tcpudp;
8026 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8028 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8030 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8032 else if (unformat (input, "src_port"))
8034 else if (unformat (input, "dst_port"))
8040 if (!src_port && !dst_port)
8044 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8046 tcpudp = (tcpudp_header_t *) mask;
8047 tcpudp->src_port = src_port;
8048 tcpudp->dst_port = dst_port;
8056 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8058 u8 **maskp = va_arg (*args, u8 **);
8060 u8 found_something = 0;
8063 #define _(a) u8 a=0;
8064 foreach_ip4_proto_field;
8070 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8072 if (unformat (input, "version"))
8074 else if (unformat (input, "hdr_length"))
8076 else if (unformat (input, "src"))
8078 else if (unformat (input, "dst"))
8080 else if (unformat (input, "proto"))
8083 #define _(a) else if (unformat (input, #a)) a=1;
8084 foreach_ip4_proto_field
8090 #define _(a) found_something += a;
8091 foreach_ip4_proto_field;
8094 if (found_something == 0)
8097 vec_validate (mask, sizeof (*ip) - 1);
8099 ip = (ip4_header_t *) mask;
8101 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8102 foreach_ip4_proto_field;
8105 ip->ip_version_and_header_length = 0;
8108 ip->ip_version_and_header_length |= 0xF0;
8111 ip->ip_version_and_header_length |= 0x0F;
8117 #define foreach_ip6_proto_field \
8125 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8127 u8 **maskp = va_arg (*args, u8 **);
8129 u8 found_something = 0;
8131 u32 ip_version_traffic_class_and_flow_label;
8133 #define _(a) u8 a=0;
8134 foreach_ip6_proto_field;
8137 u8 traffic_class = 0;
8140 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8142 if (unformat (input, "version"))
8144 else if (unformat (input, "traffic-class"))
8146 else if (unformat (input, "flow-label"))
8148 else if (unformat (input, "src"))
8150 else if (unformat (input, "dst"))
8152 else if (unformat (input, "proto"))
8155 #define _(a) else if (unformat (input, #a)) a=1;
8156 foreach_ip6_proto_field
8162 #define _(a) found_something += a;
8163 foreach_ip6_proto_field;
8166 if (found_something == 0)
8169 vec_validate (mask, sizeof (*ip) - 1);
8171 ip = (ip6_header_t *) mask;
8173 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8174 foreach_ip6_proto_field;
8177 ip_version_traffic_class_and_flow_label = 0;
8180 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8183 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8186 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8188 ip->ip_version_traffic_class_and_flow_label =
8189 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8196 unformat_l3_mask (unformat_input_t * input, va_list * args)
8198 u8 **maskp = va_arg (*args, u8 **);
8200 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8202 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8204 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8213 unformat_l2_mask (unformat_input_t * input, va_list * args)
8215 u8 **maskp = va_arg (*args, u8 **);
8230 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8232 if (unformat (input, "src"))
8234 else if (unformat (input, "dst"))
8236 else if (unformat (input, "proto"))
8238 else if (unformat (input, "tag1"))
8240 else if (unformat (input, "tag2"))
8242 else if (unformat (input, "ignore-tag1"))
8244 else if (unformat (input, "ignore-tag2"))
8246 else if (unformat (input, "cos1"))
8248 else if (unformat (input, "cos2"))
8250 else if (unformat (input, "dot1q"))
8252 else if (unformat (input, "dot1ad"))
8257 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8258 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8261 if (tag1 || ignore_tag1 || cos1 || dot1q)
8263 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8266 vec_validate (mask, len - 1);
8269 memset (mask, 0xff, 6);
8272 memset (mask + 6, 0xff, 6);
8276 /* inner vlan tag */
8285 mask[21] = mask[20] = 0xff;
8306 mask[16] = mask[17] = 0xff;
8316 mask[12] = mask[13] = 0xff;
8323 unformat_classify_mask (unformat_input_t * input, va_list * args)
8325 u8 **maskp = va_arg (*args, u8 **);
8326 u32 *skipp = va_arg (*args, u32 *);
8327 u32 *matchp = va_arg (*args, u32 *);
8335 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8337 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8339 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8341 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8343 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
8357 if (mask || l2 || l3 || l4)
8361 /* "With a free Ethernet header in every package" */
8363 vec_validate (l2, 13);
8367 vec_append (mask, l3);
8372 vec_append (mask, l4);
8377 /* Scan forward looking for the first significant mask octet */
8378 for (i = 0; i < vec_len (mask); i++)
8382 /* compute (skip, match) params */
8383 *skipp = i / sizeof (u32x4);
8384 vec_delete (mask, *skipp * sizeof (u32x4), 0);
8386 /* Pad mask to an even multiple of the vector size */
8387 while (vec_len (mask) % sizeof (u32x4))
8390 match = vec_len (mask) / sizeof (u32x4);
8392 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
8394 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
8395 if (*tmp || *(tmp + 1))
8400 clib_warning ("BUG: match 0");
8402 _vec_len (mask) = match * sizeof (u32x4);
8413 #define foreach_l2_next \
8415 _(ethernet, ETHERNET_INPUT) \
8420 unformat_l2_next_index (unformat_input_t * input, va_list * args)
8422 u32 *miss_next_indexp = va_arg (*args, u32 *);
8427 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
8431 if (unformat (input, "%d", &tmp))
8440 *miss_next_indexp = next_index;
8444 #define foreach_ip_next \
8450 unformat_ip_next_index (unformat_input_t * input, va_list * args)
8452 u32 *miss_next_indexp = va_arg (*args, u32 *);
8457 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
8461 if (unformat (input, "%d", &tmp))
8470 *miss_next_indexp = next_index;
8474 #define foreach_acl_next \
8478 unformat_acl_next_index (unformat_input_t * input, va_list * args)
8480 u32 *miss_next_indexp = va_arg (*args, u32 *);
8485 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
8489 if (unformat (input, "permit"))
8494 else if (unformat (input, "%d", &tmp))
8503 *miss_next_indexp = next_index;
8508 unformat_policer_precolor (unformat_input_t * input, va_list * args)
8510 u32 *r = va_arg (*args, u32 *);
8512 if (unformat (input, "conform-color"))
8513 *r = POLICE_CONFORM;
8514 else if (unformat (input, "exceed-color"))
8523 api_classify_add_del_table (vat_main_t * vam)
8525 unformat_input_t *i = vam->input;
8526 vl_api_classify_add_del_table_t *mp;
8532 u32 table_index = ~0;
8533 u32 next_table_index = ~0;
8534 u32 miss_next_index = ~0;
8535 u32 memory_size = 32 << 20;
8539 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8541 if (unformat (i, "del"))
8543 else if (unformat (i, "buckets %d", &nbuckets))
8545 else if (unformat (i, "memory_size %d", &memory_size))
8547 else if (unformat (i, "skip %d", &skip))
8549 else if (unformat (i, "match %d", &match))
8551 else if (unformat (i, "table %d", &table_index))
8553 else if (unformat (i, "mask %U", unformat_classify_mask,
8554 &mask, &skip, &match))
8556 else if (unformat (i, "next-table %d", &next_table_index))
8558 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
8561 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
8564 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
8571 if (is_add && mask == 0)
8573 errmsg ("Mask required\n");
8577 if (is_add && skip == ~0)
8579 errmsg ("skip count required\n");
8583 if (is_add && match == ~0)
8585 errmsg ("match count required\n");
8589 if (!is_add && table_index == ~0)
8591 errmsg ("table index required for delete\n");
8595 M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask));
8597 mp->is_add = is_add;
8598 mp->table_index = ntohl (table_index);
8599 mp->nbuckets = ntohl (nbuckets);
8600 mp->memory_size = ntohl (memory_size);
8601 mp->skip_n_vectors = ntohl (skip);
8602 mp->match_n_vectors = ntohl (match);
8603 mp->next_table_index = ntohl (next_table_index);
8604 mp->miss_next_index = ntohl (miss_next_index);
8605 clib_memcpy (mp->mask, mask, vec_len (mask));
8615 unformat_l4_match (unformat_input_t * input, va_list * args)
8617 u8 **matchp = va_arg (*args, u8 **);
8619 u8 *proto_header = 0;
8625 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8627 if (unformat (input, "src_port %d", &src_port))
8629 else if (unformat (input, "dst_port %d", &dst_port))
8635 h.src_port = clib_host_to_net_u16 (src_port);
8636 h.dst_port = clib_host_to_net_u16 (dst_port);
8637 vec_validate (proto_header, sizeof (h) - 1);
8638 memcpy (proto_header, &h, sizeof (h));
8640 *matchp = proto_header;
8646 unformat_ip4_match (unformat_input_t * input, va_list * args)
8648 u8 **matchp = va_arg (*args, u8 **);
8655 int src = 0, dst = 0;
8656 ip4_address_t src_val, dst_val;
8663 int fragment_id = 0;
8664 u32 fragment_id_val;
8670 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8672 if (unformat (input, "version %d", &version_val))
8674 else if (unformat (input, "hdr_length %d", &hdr_length_val))
8676 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
8678 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
8680 else if (unformat (input, "proto %d", &proto_val))
8682 else if (unformat (input, "tos %d", &tos_val))
8684 else if (unformat (input, "length %d", &length_val))
8686 else if (unformat (input, "fragment_id %d", &fragment_id_val))
8688 else if (unformat (input, "ttl %d", &ttl_val))
8690 else if (unformat (input, "checksum %d", &checksum_val))
8696 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
8697 + ttl + checksum == 0)
8701 * Aligned because we use the real comparison functions
8703 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
8705 ip = (ip4_header_t *) match;
8707 /* These are realistically matched in practice */
8709 ip->src_address.as_u32 = src_val.as_u32;
8712 ip->dst_address.as_u32 = dst_val.as_u32;
8715 ip->protocol = proto_val;
8718 /* These are not, but they're included for completeness */
8720 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
8723 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
8729 ip->length = clib_host_to_net_u16 (length_val);
8735 ip->checksum = clib_host_to_net_u16 (checksum_val);
8742 unformat_ip6_match (unformat_input_t * input, va_list * args)
8744 u8 **matchp = va_arg (*args, u8 **);
8749 u8 traffic_class = 0;
8750 u32 traffic_class_val = 0;
8753 int src = 0, dst = 0;
8754 ip6_address_t src_val, dst_val;
8757 int payload_length = 0;
8758 u32 payload_length_val;
8761 u32 ip_version_traffic_class_and_flow_label;
8763 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8765 if (unformat (input, "version %d", &version_val))
8767 else if (unformat (input, "traffic_class %d", &traffic_class_val))
8769 else if (unformat (input, "flow_label %d", &flow_label_val))
8771 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
8773 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
8775 else if (unformat (input, "proto %d", &proto_val))
8777 else if (unformat (input, "payload_length %d", &payload_length_val))
8779 else if (unformat (input, "hop_limit %d", &hop_limit_val))
8785 if (version + traffic_class + flow_label + src + dst + proto +
8786 payload_length + hop_limit == 0)
8790 * Aligned because we use the real comparison functions
8792 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
8794 ip = (ip6_header_t *) match;
8797 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
8800 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
8803 ip->protocol = proto_val;
8805 ip_version_traffic_class_and_flow_label = 0;
8808 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
8811 ip_version_traffic_class_and_flow_label |=
8812 (traffic_class_val & 0xFF) << 20;
8815 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
8817 ip->ip_version_traffic_class_and_flow_label =
8818 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8821 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
8824 ip->hop_limit = hop_limit_val;
8831 unformat_l3_match (unformat_input_t * input, va_list * args)
8833 u8 **matchp = va_arg (*args, u8 **);
8835 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8837 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
8839 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
8848 unformat_vlan_tag (unformat_input_t * input, va_list * args)
8850 u8 *tagp = va_arg (*args, u8 *);
8853 if (unformat (input, "%d", &tag))
8855 tagp[0] = (tag >> 8) & 0x0F;
8856 tagp[1] = tag & 0xFF;
8864 unformat_l2_match (unformat_input_t * input, va_list * args)
8866 u8 **matchp = va_arg (*args, u8 **);
8886 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8888 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
8891 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
8893 else if (unformat (input, "proto %U",
8894 unformat_ethernet_type_host_byte_order, &proto_val))
8896 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
8898 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
8900 else if (unformat (input, "ignore-tag1"))
8902 else if (unformat (input, "ignore-tag2"))
8904 else if (unformat (input, "cos1 %d", &cos1_val))
8906 else if (unformat (input, "cos2 %d", &cos2_val))
8911 if ((src + dst + proto + tag1 + tag2 +
8912 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8915 if (tag1 || ignore_tag1 || cos1)
8917 if (tag2 || ignore_tag2 || cos2)
8920 vec_validate_aligned (match, len - 1, sizeof (u32x4));
8923 clib_memcpy (match, dst_val, 6);
8926 clib_memcpy (match + 6, src_val, 6);
8930 /* inner vlan tag */
8931 match[19] = tag2_val[1];
8932 match[18] = tag2_val[0];
8934 match[18] |= (cos2_val & 0x7) << 5;
8937 match[21] = proto_val & 0xff;
8938 match[20] = proto_val >> 8;
8942 match[15] = tag1_val[1];
8943 match[14] = tag1_val[0];
8946 match[14] |= (cos1_val & 0x7) << 5;
8952 match[15] = tag1_val[1];
8953 match[14] = tag1_val[0];
8956 match[17] = proto_val & 0xff;
8957 match[16] = proto_val >> 8;
8960 match[14] |= (cos1_val & 0x7) << 5;
8966 match[18] |= (cos2_val & 0x7) << 5;
8968 match[14] |= (cos1_val & 0x7) << 5;
8971 match[13] = proto_val & 0xff;
8972 match[12] = proto_val >> 8;
8981 unformat_classify_match (unformat_input_t * input, va_list * args)
8983 u8 **matchp = va_arg (*args, u8 **);
8984 u32 skip_n_vectors = va_arg (*args, u32);
8985 u32 match_n_vectors = va_arg (*args, u32);
8992 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8994 if (unformat (input, "hex %U", unformat_hex_string, &match))
8996 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
8998 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9000 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9014 if (match || l2 || l3 || l4)
9018 /* "Win a free Ethernet header in every packet" */
9020 vec_validate_aligned (l2, 13, sizeof (u32x4));
9024 vec_append_aligned (match, l3, sizeof (u32x4));
9029 vec_append_aligned (match, l4, sizeof (u32x4));
9034 /* Make sure the vector is big enough even if key is all 0's */
9035 vec_validate_aligned
9036 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9039 /* Set size, include skipped vectors */
9040 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9051 api_classify_add_del_session (vat_main_t * vam)
9053 unformat_input_t *i = vam->input;
9054 vl_api_classify_add_del_session_t *mp;
9056 u32 table_index = ~0;
9057 u32 hit_next_index = ~0;
9058 u32 opaque_index = ~0;
9062 u32 skip_n_vectors = 0;
9063 u32 match_n_vectors = 0;
9066 * Warning: you have to supply skip_n and match_n
9067 * because the API client cant simply look at the classify
9071 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9073 if (unformat (i, "del"))
9075 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
9078 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9081 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
9084 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9086 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9088 else if (unformat (i, "opaque-index %d", &opaque_index))
9090 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9092 else if (unformat (i, "match_n %d", &match_n_vectors))
9094 else if (unformat (i, "match %U", unformat_classify_match,
9095 &match, skip_n_vectors, match_n_vectors))
9097 else if (unformat (i, "advance %d", &advance))
9099 else if (unformat (i, "table-index %d", &table_index))
9105 if (table_index == ~0)
9107 errmsg ("Table index required\n");
9111 if (is_add && match == 0)
9113 errmsg ("Match value required\n");
9117 M2 (CLASSIFY_ADD_DEL_SESSION, classify_add_del_session, vec_len (match));
9119 mp->is_add = is_add;
9120 mp->table_index = ntohl (table_index);
9121 mp->hit_next_index = ntohl (hit_next_index);
9122 mp->opaque_index = ntohl (opaque_index);
9123 mp->advance = ntohl (advance);
9124 clib_memcpy (mp->match, match, vec_len (match));
9133 api_classify_set_interface_ip_table (vat_main_t * vam)
9135 unformat_input_t *i = vam->input;
9136 vl_api_classify_set_interface_ip_table_t *mp;
9139 int sw_if_index_set;
9140 u32 table_index = ~0;
9143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9145 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9146 sw_if_index_set = 1;
9147 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9148 sw_if_index_set = 1;
9149 else if (unformat (i, "table %d", &table_index))
9153 clib_warning ("parse error '%U'", format_unformat_error, i);
9158 if (sw_if_index_set == 0)
9160 errmsg ("missing interface name or sw_if_index\n");
9165 M (CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table);
9167 mp->sw_if_index = ntohl (sw_if_index);
9168 mp->table_index = ntohl (table_index);
9169 mp->is_ipv6 = is_ipv6;
9178 api_classify_set_interface_l2_tables (vat_main_t * vam)
9180 unformat_input_t *i = vam->input;
9181 vl_api_classify_set_interface_l2_tables_t *mp;
9184 int sw_if_index_set;
9185 u32 ip4_table_index = ~0;
9186 u32 ip6_table_index = ~0;
9187 u32 other_table_index = ~0;
9190 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9192 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9193 sw_if_index_set = 1;
9194 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9195 sw_if_index_set = 1;
9196 else if (unformat (i, "ip4-table %d", &ip4_table_index))
9198 else if (unformat (i, "ip6-table %d", &ip6_table_index))
9200 else if (unformat (i, "other-table %d", &other_table_index))
9202 else if (unformat (i, "is-input %d", &is_input))
9206 clib_warning ("parse error '%U'", format_unformat_error, i);
9211 if (sw_if_index_set == 0)
9213 errmsg ("missing interface name or sw_if_index\n");
9218 M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables);
9220 mp->sw_if_index = ntohl (sw_if_index);
9221 mp->ip4_table_index = ntohl (ip4_table_index);
9222 mp->ip6_table_index = ntohl (ip6_table_index);
9223 mp->other_table_index = ntohl (other_table_index);
9224 mp->is_input = (u8) is_input;
9233 api_set_ipfix_exporter (vat_main_t * vam)
9235 unformat_input_t *i = vam->input;
9236 vl_api_set_ipfix_exporter_t *mp;
9237 ip4_address_t collector_address;
9238 u8 collector_address_set = 0;
9239 u32 collector_port = ~0;
9240 ip4_address_t src_address;
9241 u8 src_address_set = 0;
9244 u32 template_interval = ~0;
9245 u8 udp_checksum = 0;
9248 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9250 if (unformat (i, "collector_address %U", unformat_ip4_address,
9251 &collector_address))
9252 collector_address_set = 1;
9253 else if (unformat (i, "collector_port %d", &collector_port))
9255 else if (unformat (i, "src_address %U", unformat_ip4_address,
9257 src_address_set = 1;
9258 else if (unformat (i, "vrf_id %d", &vrf_id))
9260 else if (unformat (i, "path_mtu %d", &path_mtu))
9262 else if (unformat (i, "template_interval %d", &template_interval))
9264 else if (unformat (i, "udp_checksum"))
9270 if (collector_address_set == 0)
9272 errmsg ("collector_address required\n");
9276 if (src_address_set == 0)
9278 errmsg ("src_address required\n");
9282 M (SET_IPFIX_EXPORTER, set_ipfix_exporter);
9284 memcpy (mp->collector_address, collector_address.data,
9285 sizeof (collector_address.data));
9286 mp->collector_port = htons ((u16) collector_port);
9287 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
9288 mp->vrf_id = htonl (vrf_id);
9289 mp->path_mtu = htonl (path_mtu);
9290 mp->template_interval = htonl (template_interval);
9291 mp->udp_checksum = udp_checksum;
9299 api_set_ipfix_classify_stream (vat_main_t * vam)
9301 unformat_input_t *i = vam->input;
9302 vl_api_set_ipfix_classify_stream_t *mp;
9304 u32 src_port = UDP_DST_PORT_ipfix;
9307 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9309 if (unformat (i, "domain %d", &domain_id))
9311 else if (unformat (i, "src_port %d", &src_port))
9315 errmsg ("unknown input `%U'", format_unformat_error, i);
9320 M (SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream);
9322 mp->domain_id = htonl (domain_id);
9323 mp->src_port = htons ((u16) src_port);
9331 api_ipfix_classify_table_add_del (vat_main_t * vam)
9333 unformat_input_t *i = vam->input;
9334 vl_api_ipfix_classify_table_add_del_t *mp;
9336 u32 classify_table_index = ~0;
9338 u8 transport_protocol = 255;
9341 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9343 if (unformat (i, "add"))
9345 else if (unformat (i, "del"))
9347 else if (unformat (i, "table %d", &classify_table_index))
9349 else if (unformat (i, "ip4"))
9351 else if (unformat (i, "ip6"))
9353 else if (unformat (i, "tcp"))
9354 transport_protocol = 6;
9355 else if (unformat (i, "udp"))
9356 transport_protocol = 17;
9359 errmsg ("unknown input `%U'", format_unformat_error, i);
9366 errmsg ("expecting: add|del");
9369 if (classify_table_index == ~0)
9371 errmsg ("classifier table not specified");
9374 if (ip_version == 0)
9376 errmsg ("IP version not specified");
9380 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del);
9382 mp->is_add = is_add;
9383 mp->table_id = htonl (classify_table_index);
9384 mp->ip_version = ip_version;
9385 mp->transport_protocol = transport_protocol;
9393 api_get_node_index (vat_main_t * vam)
9395 unformat_input_t *i = vam->input;
9396 vl_api_get_node_index_t *mp;
9400 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9402 if (unformat (i, "node %s", &name))
9409 errmsg ("node name required\n");
9412 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9414 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9418 M (GET_NODE_INDEX, get_node_index);
9419 clib_memcpy (mp->node_name, name, vec_len (name));
9429 api_get_next_index (vat_main_t * vam)
9431 unformat_input_t *i = vam->input;
9432 vl_api_get_next_index_t *mp;
9434 u8 *node_name = 0, *next_node_name = 0;
9436 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9438 if (unformat (i, "node-name %s", &node_name))
9440 else if (unformat (i, "next-node-name %s", &next_node_name))
9446 errmsg ("node name required\n");
9449 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
9451 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9455 if (next_node_name == 0)
9457 errmsg ("next node name required\n");
9460 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
9462 errmsg ("next node name too long, max %d\n", ARRAY_LEN (mp->next_name));
9466 M (GET_NEXT_INDEX, get_next_index);
9467 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
9468 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
9469 vec_free (node_name);
9470 vec_free (next_node_name);
9479 api_add_node_next (vat_main_t * vam)
9481 unformat_input_t *i = vam->input;
9482 vl_api_add_node_next_t *mp;
9487 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9489 if (unformat (i, "node %s", &name))
9491 else if (unformat (i, "next %s", &next))
9498 errmsg ("node name required\n");
9501 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9503 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9508 errmsg ("next node required\n");
9511 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
9513 errmsg ("next name too long, max %d\n", ARRAY_LEN (mp->next_name));
9517 M (ADD_NODE_NEXT, add_node_next);
9518 clib_memcpy (mp->node_name, name, vec_len (name));
9519 clib_memcpy (mp->next_name, next, vec_len (next));
9530 api_l2tpv3_create_tunnel (vat_main_t * vam)
9532 unformat_input_t *i = vam->input;
9533 ip6_address_t client_address, our_address;
9534 int client_address_set = 0;
9535 int our_address_set = 0;
9536 u32 local_session_id = 0;
9537 u32 remote_session_id = 0;
9538 u64 local_cookie = 0;
9539 u64 remote_cookie = 0;
9540 u8 l2_sublayer_present = 0;
9541 vl_api_l2tpv3_create_tunnel_t *mp;
9544 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9546 if (unformat (i, "client_address %U", unformat_ip6_address,
9548 client_address_set = 1;
9549 else if (unformat (i, "our_address %U", unformat_ip6_address,
9551 our_address_set = 1;
9552 else if (unformat (i, "local_session_id %d", &local_session_id))
9554 else if (unformat (i, "remote_session_id %d", &remote_session_id))
9556 else if (unformat (i, "local_cookie %lld", &local_cookie))
9558 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
9560 else if (unformat (i, "l2-sublayer-present"))
9561 l2_sublayer_present = 1;
9566 if (client_address_set == 0)
9568 errmsg ("client_address required\n");
9572 if (our_address_set == 0)
9574 errmsg ("our_address required\n");
9578 M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel);
9580 clib_memcpy (mp->client_address, client_address.as_u8,
9581 sizeof (mp->client_address));
9583 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
9585 mp->local_session_id = ntohl (local_session_id);
9586 mp->remote_session_id = ntohl (remote_session_id);
9587 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
9588 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
9589 mp->l2_sublayer_present = l2_sublayer_present;
9599 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
9601 unformat_input_t *i = vam->input;
9603 u8 sw_if_index_set = 0;
9604 u64 new_local_cookie = 0;
9605 u64 new_remote_cookie = 0;
9606 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
9609 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9611 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9612 sw_if_index_set = 1;
9613 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9614 sw_if_index_set = 1;
9615 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
9617 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
9623 if (sw_if_index_set == 0)
9625 errmsg ("missing interface name or sw_if_index\n");
9629 M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies);
9631 mp->sw_if_index = ntohl (sw_if_index);
9632 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
9633 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
9642 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
9644 unformat_input_t *i = vam->input;
9645 vl_api_l2tpv3_interface_enable_disable_t *mp;
9648 u8 sw_if_index_set = 0;
9649 u8 enable_disable = 1;
9651 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9653 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9654 sw_if_index_set = 1;
9655 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9656 sw_if_index_set = 1;
9657 else if (unformat (i, "enable"))
9659 else if (unformat (i, "disable"))
9665 if (sw_if_index_set == 0)
9667 errmsg ("missing interface name or sw_if_index\n");
9671 M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable);
9673 mp->sw_if_index = ntohl (sw_if_index);
9674 mp->enable_disable = enable_disable;
9683 api_l2tpv3_set_lookup_key (vat_main_t * vam)
9685 unformat_input_t *i = vam->input;
9686 vl_api_l2tpv3_set_lookup_key_t *mp;
9690 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9692 if (unformat (i, "lookup_v6_src"))
9693 key = L2T_LOOKUP_SRC_ADDRESS;
9694 else if (unformat (i, "lookup_v6_dst"))
9695 key = L2T_LOOKUP_DST_ADDRESS;
9696 else if (unformat (i, "lookup_session_id"))
9697 key = L2T_LOOKUP_SESSION_ID;
9702 if (key == (u8) ~ 0)
9704 errmsg ("l2tp session lookup key unset\n");
9708 M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key);
9718 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
9719 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
9721 vat_main_t *vam = &vat_main;
9723 fformat (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)\n",
9724 format_ip6_address, mp->our_address,
9725 format_ip6_address, mp->client_address,
9726 clib_net_to_host_u32 (mp->sw_if_index));
9729 " local cookies %016llx %016llx remote cookie %016llx\n",
9730 clib_net_to_host_u64 (mp->local_cookie[0]),
9731 clib_net_to_host_u64 (mp->local_cookie[1]),
9732 clib_net_to_host_u64 (mp->remote_cookie));
9734 fformat (vam->ofp, " local session-id %d remote session-id %d\n",
9735 clib_net_to_host_u32 (mp->local_session_id),
9736 clib_net_to_host_u32 (mp->remote_session_id));
9738 fformat (vam->ofp, " l2 specific sublayer %s\n\n",
9739 mp->l2_sublayer_present ? "preset" : "absent");
9743 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
9744 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
9746 vat_main_t *vam = &vat_main;
9747 vat_json_node_t *node = NULL;
9748 struct in6_addr addr;
9750 if (VAT_JSON_ARRAY != vam->json_tree.type)
9752 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9753 vat_json_init_array (&vam->json_tree);
9755 node = vat_json_array_add (&vam->json_tree);
9757 vat_json_init_object (node);
9759 clib_memcpy (&addr, mp->our_address, sizeof (addr));
9760 vat_json_object_add_ip6 (node, "our_address", addr);
9761 clib_memcpy (&addr, mp->client_address, sizeof (addr));
9762 vat_json_object_add_ip6 (node, "client_address", addr);
9764 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
9765 vat_json_init_array (lc);
9766 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
9767 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
9768 vat_json_object_add_uint (node, "remote_cookie",
9769 clib_net_to_host_u64 (mp->remote_cookie));
9771 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
9772 vat_json_object_add_uint (node, "local_session_id",
9773 clib_net_to_host_u32 (mp->local_session_id));
9774 vat_json_object_add_uint (node, "remote_session_id",
9775 clib_net_to_host_u32 (mp->remote_session_id));
9776 vat_json_object_add_string_copy (node, "l2_sublayer",
9777 mp->l2_sublayer_present ? (u8 *) "present"
9782 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
9784 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
9787 /* Get list of l2tpv3-tunnel interfaces */
9788 M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump);
9791 /* Use a control ping for synchronization */
9793 vl_api_control_ping_t *mp;
9794 M (CONTROL_PING, control_ping);
9801 static void vl_api_sw_interface_tap_details_t_handler
9802 (vl_api_sw_interface_tap_details_t * mp)
9804 vat_main_t *vam = &vat_main;
9806 fformat (vam->ofp, "%-16s %d\n",
9807 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
9810 static void vl_api_sw_interface_tap_details_t_handler_json
9811 (vl_api_sw_interface_tap_details_t * mp)
9813 vat_main_t *vam = &vat_main;
9814 vat_json_node_t *node = NULL;
9816 if (VAT_JSON_ARRAY != vam->json_tree.type)
9818 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9819 vat_json_init_array (&vam->json_tree);
9821 node = vat_json_array_add (&vam->json_tree);
9823 vat_json_init_object (node);
9824 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9825 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
9829 api_sw_interface_tap_dump (vat_main_t * vam)
9831 vl_api_sw_interface_tap_dump_t *mp;
9834 fformat (vam->ofp, "\n%-16s %s\n", "dev_name", "sw_if_index");
9835 /* Get list of tap interfaces */
9836 M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump);
9839 /* Use a control ping for synchronization */
9841 vl_api_control_ping_t *mp;
9842 M (CONTROL_PING, control_ping);
9848 static uword unformat_vxlan_decap_next
9849 (unformat_input_t * input, va_list * args)
9851 u32 *result = va_arg (*args, u32 *);
9854 if (unformat (input, "drop"))
9855 *result = VXLAN_INPUT_NEXT_DROP;
9856 else if (unformat (input, "ip4"))
9857 *result = VXLAN_INPUT_NEXT_IP4_INPUT;
9858 else if (unformat (input, "ip6"))
9859 *result = VXLAN_INPUT_NEXT_IP6_INPUT;
9860 else if (unformat (input, "l2"))
9861 *result = VXLAN_INPUT_NEXT_L2_INPUT;
9862 else if (unformat (input, "%d", &tmp))
9870 api_vxlan_add_del_tunnel (vat_main_t * vam)
9872 unformat_input_t *line_input = vam->input;
9873 vl_api_vxlan_add_del_tunnel_t *mp;
9875 ip4_address_t src4, dst4;
9876 ip6_address_t src6, dst6;
9878 u8 ipv4_set = 0, ipv6_set = 0;
9881 u32 encap_vrf_id = 0;
9882 u32 decap_next_index = ~0;
9885 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9887 if (unformat (line_input, "del"))
9889 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
9894 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
9899 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
9904 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
9909 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
9911 else if (unformat (line_input, "decap-next %U",
9912 unformat_vxlan_decap_next, &decap_next_index))
9914 else if (unformat (line_input, "vni %d", &vni))
9918 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
9925 errmsg ("tunnel src address not specified\n");
9930 errmsg ("tunnel dst address not specified\n");
9934 if (ipv4_set && ipv6_set)
9936 errmsg ("both IPv4 and IPv6 addresses specified");
9940 if ((vni == 0) || (vni >> 24))
9942 errmsg ("vni not specified or out of range\n");
9946 M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel);
9950 clib_memcpy (&mp->src_address, &src6, sizeof (src6));
9951 clib_memcpy (&mp->dst_address, &dst6, sizeof (dst6));
9955 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
9956 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
9958 mp->encap_vrf_id = ntohl (encap_vrf_id);
9959 mp->decap_next_index = ntohl (decap_next_index);
9960 mp->vni = ntohl (vni);
9961 mp->is_add = is_add;
9962 mp->is_ipv6 = ipv6_set;
9970 static void vl_api_vxlan_tunnel_details_t_handler
9971 (vl_api_vxlan_tunnel_details_t * mp)
9973 vat_main_t *vam = &vat_main;
9975 fformat (vam->ofp, "%11d%24U%24U%14d%18d%13d\n",
9976 ntohl (mp->sw_if_index),
9977 format_ip46_address, &(mp->src_address[0]),
9979 format_ip46_address, &(mp->dst_address[0]),
9981 ntohl (mp->encap_vrf_id),
9982 ntohl (mp->decap_next_index), ntohl (mp->vni));
9985 static void vl_api_vxlan_tunnel_details_t_handler_json
9986 (vl_api_vxlan_tunnel_details_t * mp)
9988 vat_main_t *vam = &vat_main;
9989 vat_json_node_t *node = NULL;
9991 struct in6_addr ip6;
9993 if (VAT_JSON_ARRAY != vam->json_tree.type)
9995 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9996 vat_json_init_array (&vam->json_tree);
9998 node = vat_json_array_add (&vam->json_tree);
10000 vat_json_init_object (node);
10001 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10004 clib_memcpy (&ip6, &(mp->src_address[0]), sizeof (ip6));
10005 vat_json_object_add_ip6 (node, "src_address", ip6);
10006 clib_memcpy (&ip6, &(mp->dst_address[0]), sizeof (ip6));
10007 vat_json_object_add_ip6 (node, "dst_address", ip6);
10011 clib_memcpy (&ip4, &(mp->src_address[0]), sizeof (ip4));
10012 vat_json_object_add_ip4 (node, "src_address", ip4);
10013 clib_memcpy (&ip4, &(mp->dst_address[0]), sizeof (ip4));
10014 vat_json_object_add_ip4 (node, "dst_address", ip4);
10016 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10017 vat_json_object_add_uint (node, "decap_next_index",
10018 ntohl (mp->decap_next_index));
10019 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10020 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10024 api_vxlan_tunnel_dump (vat_main_t * vam)
10026 unformat_input_t *i = vam->input;
10027 vl_api_vxlan_tunnel_dump_t *mp;
10030 u8 sw_if_index_set = 0;
10032 /* Parse args required to build the message */
10033 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10035 if (unformat (i, "sw_if_index %d", &sw_if_index))
10036 sw_if_index_set = 1;
10041 if (sw_if_index_set == 0)
10046 if (!vam->json_output)
10048 fformat (vam->ofp, "%11s%24s%24s%14s%18s%13s\n",
10049 "sw_if_index", "src_address", "dst_address",
10050 "encap_vrf_id", "decap_next_index", "vni");
10053 /* Get list of vxlan-tunnel interfaces */
10054 M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
10056 mp->sw_if_index = htonl (sw_if_index);
10060 /* Use a control ping for synchronization */
10062 vl_api_control_ping_t *mp;
10063 M (CONTROL_PING, control_ping);
10070 api_gre_add_del_tunnel (vat_main_t * vam)
10072 unformat_input_t *line_input = vam->input;
10073 vl_api_gre_add_del_tunnel_t *mp;
10075 ip4_address_t src4, dst4;
10080 u32 outer_fib_id = 0;
10082 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10084 if (unformat (line_input, "del"))
10086 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10088 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10090 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10092 else if (unformat (line_input, "teb"))
10096 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
10103 errmsg ("tunnel src address not specified\n");
10108 errmsg ("tunnel dst address not specified\n");
10113 M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel);
10115 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10116 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10117 mp->outer_fib_id = ntohl (outer_fib_id);
10118 mp->is_add = is_add;
10127 static void vl_api_gre_tunnel_details_t_handler
10128 (vl_api_gre_tunnel_details_t * mp)
10130 vat_main_t *vam = &vat_main;
10132 fformat (vam->ofp, "%11d%15U%15U%6d%14d\n",
10133 ntohl (mp->sw_if_index),
10134 format_ip4_address, &mp->src_address,
10135 format_ip4_address, &mp->dst_address,
10136 mp->teb, ntohl (mp->outer_fib_id));
10139 static void vl_api_gre_tunnel_details_t_handler_json
10140 (vl_api_gre_tunnel_details_t * mp)
10142 vat_main_t *vam = &vat_main;
10143 vat_json_node_t *node = NULL;
10144 struct in_addr ip4;
10146 if (VAT_JSON_ARRAY != vam->json_tree.type)
10148 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10149 vat_json_init_array (&vam->json_tree);
10151 node = vat_json_array_add (&vam->json_tree);
10153 vat_json_init_object (node);
10154 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10155 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10156 vat_json_object_add_ip4 (node, "src_address", ip4);
10157 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10158 vat_json_object_add_ip4 (node, "dst_address", ip4);
10159 vat_json_object_add_uint (node, "teb", mp->teb);
10160 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10164 api_gre_tunnel_dump (vat_main_t * vam)
10166 unformat_input_t *i = vam->input;
10167 vl_api_gre_tunnel_dump_t *mp;
10170 u8 sw_if_index_set = 0;
10172 /* Parse args required to build the message */
10173 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10175 if (unformat (i, "sw_if_index %d", &sw_if_index))
10176 sw_if_index_set = 1;
10181 if (sw_if_index_set == 0)
10186 if (!vam->json_output)
10188 fformat (vam->ofp, "%11s%15s%15s%6s%14s\n",
10189 "sw_if_index", "src_address", "dst_address", "teb",
10193 /* Get list of gre-tunnel interfaces */
10194 M (GRE_TUNNEL_DUMP, gre_tunnel_dump);
10196 mp->sw_if_index = htonl (sw_if_index);
10200 /* Use a control ping for synchronization */
10202 vl_api_control_ping_t *mp;
10203 M (CONTROL_PING, control_ping);
10210 api_l2_fib_clear_table (vat_main_t * vam)
10212 // unformat_input_t * i = vam->input;
10213 vl_api_l2_fib_clear_table_t *mp;
10216 M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table);
10225 api_l2_interface_efp_filter (vat_main_t * vam)
10227 unformat_input_t *i = vam->input;
10228 vl_api_l2_interface_efp_filter_t *mp;
10232 u8 sw_if_index_set = 0;
10234 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10236 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10237 sw_if_index_set = 1;
10238 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10239 sw_if_index_set = 1;
10240 else if (unformat (i, "enable"))
10242 else if (unformat (i, "disable"))
10246 clib_warning ("parse error '%U'", format_unformat_error, i);
10251 if (sw_if_index_set == 0)
10253 errmsg ("missing sw_if_index\n");
10257 M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter);
10259 mp->sw_if_index = ntohl (sw_if_index);
10260 mp->enable_disable = enable;
10268 #define foreach_vtr_op \
10269 _("disable", L2_VTR_DISABLED) \
10270 _("push-1", L2_VTR_PUSH_1) \
10271 _("push-2", L2_VTR_PUSH_2) \
10272 _("pop-1", L2_VTR_POP_1) \
10273 _("pop-2", L2_VTR_POP_2) \
10274 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10275 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10276 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10277 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10280 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10282 unformat_input_t *i = vam->input;
10283 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
10286 u8 sw_if_index_set = 0;
10289 u32 push_dot1q = 1;
10293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10295 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10296 sw_if_index_set = 1;
10297 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10298 sw_if_index_set = 1;
10299 else if (unformat (i, "vtr_op %d", &vtr_op))
10301 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
10304 else if (unformat (i, "push_dot1q %d", &push_dot1q))
10306 else if (unformat (i, "tag1 %d", &tag1))
10308 else if (unformat (i, "tag2 %d", &tag2))
10312 clib_warning ("parse error '%U'", format_unformat_error, i);
10317 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
10319 errmsg ("missing vtr operation or sw_if_index\n");
10323 M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)
10324 mp->sw_if_index = ntohl (sw_if_index);
10325 mp->vtr_op = ntohl (vtr_op);
10326 mp->push_dot1q = ntohl (push_dot1q);
10327 mp->tag1 = ntohl (tag1);
10328 mp->tag2 = ntohl (tag2);
10337 api_create_vhost_user_if (vat_main_t * vam)
10339 unformat_input_t *i = vam->input;
10340 vl_api_create_vhost_user_if_t *mp;
10344 u8 file_name_set = 0;
10345 u32 custom_dev_instance = ~0;
10347 u8 use_custom_mac = 0;
10349 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10351 if (unformat (i, "socket %s", &file_name))
10355 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10357 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
10358 use_custom_mac = 1;
10359 else if (unformat (i, "server"))
10365 if (file_name_set == 0)
10367 errmsg ("missing socket file name\n");
10371 if (vec_len (file_name) > 255)
10373 errmsg ("socket file name too long\n");
10376 vec_add1 (file_name, 0);
10378 M (CREATE_VHOST_USER_IF, create_vhost_user_if);
10380 mp->is_server = is_server;
10381 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10382 vec_free (file_name);
10383 if (custom_dev_instance != ~0)
10386 mp->custom_dev_instance = ntohl (custom_dev_instance);
10388 mp->use_custom_mac = use_custom_mac;
10389 clib_memcpy (mp->mac_address, hwaddr, 6);
10398 api_modify_vhost_user_if (vat_main_t * vam)
10400 unformat_input_t *i = vam->input;
10401 vl_api_modify_vhost_user_if_t *mp;
10405 u8 file_name_set = 0;
10406 u32 custom_dev_instance = ~0;
10407 u8 sw_if_index_set = 0;
10408 u32 sw_if_index = (u32) ~ 0;
10410 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10412 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10413 sw_if_index_set = 1;
10414 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10415 sw_if_index_set = 1;
10416 else if (unformat (i, "socket %s", &file_name))
10420 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10422 else if (unformat (i, "server"))
10428 if (sw_if_index_set == 0)
10430 errmsg ("missing sw_if_index or interface name\n");
10434 if (file_name_set == 0)
10436 errmsg ("missing socket file name\n");
10440 if (vec_len (file_name) > 255)
10442 errmsg ("socket file name too long\n");
10445 vec_add1 (file_name, 0);
10447 M (MODIFY_VHOST_USER_IF, modify_vhost_user_if);
10449 mp->sw_if_index = ntohl (sw_if_index);
10450 mp->is_server = is_server;
10451 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10452 vec_free (file_name);
10453 if (custom_dev_instance != ~0)
10456 mp->custom_dev_instance = ntohl (custom_dev_instance);
10466 api_delete_vhost_user_if (vat_main_t * vam)
10468 unformat_input_t *i = vam->input;
10469 vl_api_delete_vhost_user_if_t *mp;
10471 u32 sw_if_index = ~0;
10472 u8 sw_if_index_set = 0;
10474 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10476 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10477 sw_if_index_set = 1;
10478 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10479 sw_if_index_set = 1;
10484 if (sw_if_index_set == 0)
10486 errmsg ("missing sw_if_index or interface name\n");
10491 M (DELETE_VHOST_USER_IF, delete_vhost_user_if);
10493 mp->sw_if_index = ntohl (sw_if_index);
10501 static void vl_api_sw_interface_vhost_user_details_t_handler
10502 (vl_api_sw_interface_vhost_user_details_t * mp)
10504 vat_main_t *vam = &vat_main;
10506 fformat (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s\n",
10507 (char *) mp->interface_name,
10508 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
10509 clib_net_to_host_u64 (mp->features), mp->is_server,
10510 ntohl (mp->num_regions), (char *) mp->sock_filename);
10511 fformat (vam->ofp, " Status: '%s'\n", strerror (ntohl (mp->sock_errno)));
10514 static void vl_api_sw_interface_vhost_user_details_t_handler_json
10515 (vl_api_sw_interface_vhost_user_details_t * mp)
10517 vat_main_t *vam = &vat_main;
10518 vat_json_node_t *node = NULL;
10520 if (VAT_JSON_ARRAY != vam->json_tree.type)
10522 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10523 vat_json_init_array (&vam->json_tree);
10525 node = vat_json_array_add (&vam->json_tree);
10527 vat_json_init_object (node);
10528 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10529 vat_json_object_add_string_copy (node, "interface_name",
10530 mp->interface_name);
10531 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
10532 ntohl (mp->virtio_net_hdr_sz));
10533 vat_json_object_add_uint (node, "features",
10534 clib_net_to_host_u64 (mp->features));
10535 vat_json_object_add_uint (node, "is_server", mp->is_server);
10536 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
10537 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
10538 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
10542 api_sw_interface_vhost_user_dump (vat_main_t * vam)
10544 vl_api_sw_interface_vhost_user_dump_t *mp;
10547 "Interface name idx hdr_sz features server regions filename\n");
10549 /* Get list of vhost-user interfaces */
10550 M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump);
10553 /* Use a control ping for synchronization */
10555 vl_api_control_ping_t *mp;
10556 M (CONTROL_PING, control_ping);
10563 api_show_version (vat_main_t * vam)
10565 vl_api_show_version_t *mp;
10568 M (SHOW_VERSION, show_version);
10578 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
10580 unformat_input_t *line_input = vam->input;
10581 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
10583 ip4_address_t local4, remote4;
10584 ip6_address_t local6, remote6;
10586 u8 ipv4_set = 0, ipv6_set = 0;
10589 u32 encap_vrf_id = 0;
10590 u32 decap_vrf_id = 0;
10595 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10597 if (unformat (line_input, "del"))
10599 else if (unformat (line_input, "local %U",
10600 unformat_ip4_address, &local4))
10605 else if (unformat (line_input, "remote %U",
10606 unformat_ip4_address, &remote4))
10611 else if (unformat (line_input, "local %U",
10612 unformat_ip6_address, &local6))
10617 else if (unformat (line_input, "remote %U",
10618 unformat_ip6_address, &remote6))
10623 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10625 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
10627 else if (unformat (line_input, "vni %d", &vni))
10629 else if (unformat (line_input, "next-ip4"))
10631 else if (unformat (line_input, "next-ip6"))
10633 else if (unformat (line_input, "next-ethernet"))
10635 else if (unformat (line_input, "next-nsh"))
10639 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
10644 if (local_set == 0)
10646 errmsg ("tunnel local address not specified\n");
10649 if (remote_set == 0)
10651 errmsg ("tunnel remote address not specified\n");
10654 if (ipv4_set && ipv6_set)
10656 errmsg ("both IPv4 and IPv6 addresses specified");
10662 errmsg ("vni not specified\n");
10666 M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel);
10671 clib_memcpy (&mp->local, &local6, sizeof (local6));
10672 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
10676 clib_memcpy (&mp->local, &local4, sizeof (local4));
10677 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
10680 mp->encap_vrf_id = ntohl (encap_vrf_id);
10681 mp->decap_vrf_id = ntohl (decap_vrf_id);
10682 mp->protocol = ntohl (protocol);
10683 mp->vni = ntohl (vni);
10684 mp->is_add = is_add;
10685 mp->is_ipv6 = ipv6_set;
10693 static void vl_api_vxlan_gpe_tunnel_details_t_handler
10694 (vl_api_vxlan_gpe_tunnel_details_t * mp)
10696 vat_main_t *vam = &vat_main;
10698 fformat (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d\n",
10699 ntohl (mp->sw_if_index),
10700 format_ip46_address, &(mp->local[0]),
10701 format_ip46_address, &(mp->remote[0]),
10703 ntohl (mp->protocol),
10704 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
10707 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
10708 (vl_api_vxlan_gpe_tunnel_details_t * mp)
10710 vat_main_t *vam = &vat_main;
10711 vat_json_node_t *node = NULL;
10712 struct in_addr ip4;
10713 struct in6_addr ip6;
10715 if (VAT_JSON_ARRAY != vam->json_tree.type)
10717 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10718 vat_json_init_array (&vam->json_tree);
10720 node = vat_json_array_add (&vam->json_tree);
10722 vat_json_init_object (node);
10723 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10726 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
10727 vat_json_object_add_ip6 (node, "local", ip6);
10728 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
10729 vat_json_object_add_ip6 (node, "remote", ip6);
10733 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
10734 vat_json_object_add_ip4 (node, "local", ip4);
10735 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
10736 vat_json_object_add_ip4 (node, "remote", ip4);
10738 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10739 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
10740 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10741 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
10742 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10746 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
10748 unformat_input_t *i = vam->input;
10749 vl_api_vxlan_gpe_tunnel_dump_t *mp;
10752 u8 sw_if_index_set = 0;
10754 /* Parse args required to build the message */
10755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10757 if (unformat (i, "sw_if_index %d", &sw_if_index))
10758 sw_if_index_set = 1;
10763 if (sw_if_index_set == 0)
10768 if (!vam->json_output)
10770 fformat (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s\n",
10771 "sw_if_index", "local", "remote", "vni",
10772 "protocol", "encap_vrf_id", "decap_vrf_id");
10775 /* Get list of vxlan-tunnel interfaces */
10776 M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump);
10778 mp->sw_if_index = htonl (sw_if_index);
10782 /* Use a control ping for synchronization */
10784 vl_api_control_ping_t *mp;
10785 M (CONTROL_PING, control_ping);
10792 format_l2_fib_mac_address (u8 * s, va_list * args)
10794 u8 *a = va_arg (*args, u8 *);
10796 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
10797 a[2], a[3], a[4], a[5], a[6], a[7]);
10800 static void vl_api_l2_fib_table_entry_t_handler
10801 (vl_api_l2_fib_table_entry_t * mp)
10803 vat_main_t *vam = &vat_main;
10805 fformat (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
10807 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
10808 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
10812 static void vl_api_l2_fib_table_entry_t_handler_json
10813 (vl_api_l2_fib_table_entry_t * mp)
10815 vat_main_t *vam = &vat_main;
10816 vat_json_node_t *node = NULL;
10818 if (VAT_JSON_ARRAY != vam->json_tree.type)
10820 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10821 vat_json_init_array (&vam->json_tree);
10823 node = vat_json_array_add (&vam->json_tree);
10825 vat_json_init_object (node);
10826 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
10827 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
10828 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10829 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
10830 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
10831 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
10835 api_l2_fib_table_dump (vat_main_t * vam)
10837 unformat_input_t *i = vam->input;
10838 vl_api_l2_fib_table_dump_t *mp;
10843 /* Parse args required to build the message */
10844 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10846 if (unformat (i, "bd_id %d", &bd_id))
10852 if (bd_id_set == 0)
10854 errmsg ("missing bridge domain\n");
10859 "BD-ID Mac Address sw-ndx Static Filter BVI\n");
10861 /* Get list of l2 fib entries */
10862 M (L2_FIB_TABLE_DUMP, l2_fib_table_dump);
10864 mp->bd_id = ntohl (bd_id);
10867 /* Use a control ping for synchronization */
10869 vl_api_control_ping_t *mp;
10870 M (CONTROL_PING, control_ping);
10878 api_interface_name_renumber (vat_main_t * vam)
10880 unformat_input_t *line_input = vam->input;
10881 vl_api_interface_name_renumber_t *mp;
10882 u32 sw_if_index = ~0;
10884 u32 new_show_dev_instance = ~0;
10886 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10888 if (unformat (line_input, "%U", unformat_sw_if_index, vam,
10891 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
10893 else if (unformat (line_input, "new_show_dev_instance %d",
10894 &new_show_dev_instance))
10900 if (sw_if_index == ~0)
10902 errmsg ("missing interface name or sw_if_index\n");
10906 if (new_show_dev_instance == ~0)
10908 errmsg ("missing new_show_dev_instance\n");
10912 M (INTERFACE_NAME_RENUMBER, interface_name_renumber);
10914 mp->sw_if_index = ntohl (sw_if_index);
10915 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
10922 api_want_ip4_arp_events (vat_main_t * vam)
10924 unformat_input_t *line_input = vam->input;
10925 vl_api_want_ip4_arp_events_t *mp;
10927 ip4_address_t address;
10928 int address_set = 0;
10929 u32 enable_disable = 1;
10931 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10933 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
10935 else if (unformat (line_input, "del"))
10936 enable_disable = 0;
10941 if (address_set == 0)
10943 errmsg ("missing addresses\n");
10947 M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events);
10948 mp->enable_disable = enable_disable;
10949 mp->pid = getpid ();
10950 mp->address = address.as_u32;
10957 api_want_ip6_nd_events (vat_main_t * vam)
10959 unformat_input_t *line_input = vam->input;
10960 vl_api_want_ip6_nd_events_t *mp;
10962 ip6_address_t address;
10963 int address_set = 0;
10964 u32 enable_disable = 1;
10966 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10968 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
10970 else if (unformat (line_input, "del"))
10971 enable_disable = 0;
10976 if (address_set == 0)
10978 errmsg ("missing addresses\n");
10982 M (WANT_IP6_ND_EVENTS, want_ip6_nd_events);
10983 mp->enable_disable = enable_disable;
10984 mp->pid = getpid ();
10985 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
10992 api_input_acl_set_interface (vat_main_t * vam)
10994 unformat_input_t *i = vam->input;
10995 vl_api_input_acl_set_interface_t *mp;
10998 int sw_if_index_set;
10999 u32 ip4_table_index = ~0;
11000 u32 ip6_table_index = ~0;
11001 u32 l2_table_index = ~0;
11004 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11006 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
11007 sw_if_index_set = 1;
11008 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11009 sw_if_index_set = 1;
11010 else if (unformat (i, "del"))
11012 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11014 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11016 else if (unformat (i, "l2-table %d", &l2_table_index))
11020 clib_warning ("parse error '%U'", format_unformat_error, i);
11025 if (sw_if_index_set == 0)
11027 errmsg ("missing interface name or sw_if_index\n");
11031 M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface);
11033 mp->sw_if_index = ntohl (sw_if_index);
11034 mp->ip4_table_index = ntohl (ip4_table_index);
11035 mp->ip6_table_index = ntohl (ip6_table_index);
11036 mp->l2_table_index = ntohl (l2_table_index);
11037 mp->is_add = is_add;
11046 api_ip_address_dump (vat_main_t * vam)
11048 unformat_input_t *i = vam->input;
11049 vl_api_ip_address_dump_t *mp;
11050 u32 sw_if_index = ~0;
11051 u8 sw_if_index_set = 0;
11056 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11058 if (unformat (i, "sw_if_index %d", &sw_if_index))
11059 sw_if_index_set = 1;
11060 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
11061 sw_if_index_set = 1;
11062 else if (unformat (i, "ipv4"))
11064 else if (unformat (i, "ipv6"))
11070 if (ipv4_set && ipv6_set)
11072 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
11076 if ((!ipv4_set) && (!ipv6_set))
11078 errmsg ("no ipv4 nor ipv6 flag set\n");
11082 if (sw_if_index_set == 0)
11084 errmsg ("missing interface name or sw_if_index\n");
11088 vam->current_sw_if_index = sw_if_index;
11089 vam->is_ipv6 = ipv6_set;
11091 M (IP_ADDRESS_DUMP, ip_address_dump);
11092 mp->sw_if_index = ntohl (sw_if_index);
11093 mp->is_ipv6 = ipv6_set;
11096 /* Use a control ping for synchronization */
11098 vl_api_control_ping_t *mp;
11099 M (CONTROL_PING, control_ping);
11106 api_ip_dump (vat_main_t * vam)
11108 vl_api_ip_dump_t *mp;
11109 unformat_input_t *in = vam->input;
11116 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11118 if (unformat (in, "ipv4"))
11120 else if (unformat (in, "ipv6"))
11126 if (ipv4_set && ipv6_set)
11128 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
11132 if ((!ipv4_set) && (!ipv6_set))
11134 errmsg ("no ipv4 nor ipv6 flag set\n");
11138 is_ipv6 = ipv6_set;
11139 vam->is_ipv6 = is_ipv6;
11141 /* free old data */
11142 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11144 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11146 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11148 M (IP_DUMP, ip_dump);
11149 mp->is_ipv6 = ipv6_set;
11152 /* Use a control ping for synchronization */
11154 vl_api_control_ping_t *mp;
11155 M (CONTROL_PING, control_ping);
11162 api_ipsec_spd_add_del (vat_main_t * vam)
11165 unformat_input_t *i = vam->input;
11166 vl_api_ipsec_spd_add_del_t *mp;
11171 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11173 if (unformat (i, "spd_id %d", &spd_id))
11175 else if (unformat (i, "del"))
11179 clib_warning ("parse error '%U'", format_unformat_error, i);
11185 errmsg ("spd_id must be set\n");
11189 M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del);
11191 mp->spd_id = ntohl (spd_id);
11192 mp->is_add = is_add;
11199 clib_warning ("unsupported (no dpdk)");
11205 api_ipsec_interface_add_del_spd (vat_main_t * vam)
11208 unformat_input_t *i = vam->input;
11209 vl_api_ipsec_interface_add_del_spd_t *mp;
11212 u8 sw_if_index_set = 0;
11213 u32 spd_id = (u32) ~ 0;
11216 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11218 if (unformat (i, "del"))
11220 else if (unformat (i, "spd_id %d", &spd_id))
11222 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
11223 sw_if_index_set = 1;
11224 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11225 sw_if_index_set = 1;
11228 clib_warning ("parse error '%U'", format_unformat_error, i);
11234 if (spd_id == (u32) ~ 0)
11236 errmsg ("spd_id must be set\n");
11240 if (sw_if_index_set == 0)
11242 errmsg ("missing interface name or sw_if_index\n");
11246 M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd);
11248 mp->spd_id = ntohl (spd_id);
11249 mp->sw_if_index = ntohl (sw_if_index);
11250 mp->is_add = is_add;
11257 clib_warning ("unsupported (no dpdk)");
11263 api_ipsec_spd_add_del_entry (vat_main_t * vam)
11266 unformat_input_t *i = vam->input;
11267 vl_api_ipsec_spd_add_del_entry_t *mp;
11269 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11270 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11272 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11273 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11274 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11275 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11277 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11278 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11279 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11280 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11281 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11282 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11284 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11286 if (unformat (i, "del"))
11288 if (unformat (i, "outbound"))
11290 if (unformat (i, "inbound"))
11292 else if (unformat (i, "spd_id %d", &spd_id))
11294 else if (unformat (i, "sa_id %d", &sa_id))
11296 else if (unformat (i, "priority %d", &priority))
11298 else if (unformat (i, "protocol %d", &protocol))
11300 else if (unformat (i, "lport_start %d", &lport_start))
11302 else if (unformat (i, "lport_stop %d", &lport_stop))
11304 else if (unformat (i, "rport_start %d", &rport_start))
11306 else if (unformat (i, "rport_stop %d", &rport_stop))
11310 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
11316 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
11323 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
11329 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
11336 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
11342 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
11349 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
11355 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
11361 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
11363 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
11365 clib_warning ("unsupported action: 'resolve'");
11371 clib_warning ("parse error '%U'", format_unformat_error, i);
11377 M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry);
11379 mp->spd_id = ntohl (spd_id);
11380 mp->priority = ntohl (priority);
11381 mp->is_outbound = is_outbound;
11383 mp->is_ipv6 = is_ipv6;
11384 if (is_ipv6 || is_ip_any)
11386 clib_memcpy (mp->remote_address_start, &raddr6_start,
11387 sizeof (ip6_address_t));
11388 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
11389 sizeof (ip6_address_t));
11390 clib_memcpy (mp->local_address_start, &laddr6_start,
11391 sizeof (ip6_address_t));
11392 clib_memcpy (mp->local_address_stop, &laddr6_stop,
11393 sizeof (ip6_address_t));
11397 clib_memcpy (mp->remote_address_start, &raddr4_start,
11398 sizeof (ip4_address_t));
11399 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
11400 sizeof (ip4_address_t));
11401 clib_memcpy (mp->local_address_start, &laddr4_start,
11402 sizeof (ip4_address_t));
11403 clib_memcpy (mp->local_address_stop, &laddr4_stop,
11404 sizeof (ip4_address_t));
11406 mp->protocol = (u8) protocol;
11407 mp->local_port_start = ntohs ((u16) lport_start);
11408 mp->local_port_stop = ntohs ((u16) lport_stop);
11409 mp->remote_port_start = ntohs ((u16) rport_start);
11410 mp->remote_port_stop = ntohs ((u16) rport_stop);
11411 mp->policy = (u8) policy;
11412 mp->sa_id = ntohl (sa_id);
11413 mp->is_add = is_add;
11414 mp->is_ip_any = is_ip_any;
11420 clib_warning ("unsupported (no dpdk)");
11426 api_ipsec_sad_add_del_entry (vat_main_t * vam)
11429 unformat_input_t *i = vam->input;
11430 vl_api_ipsec_sad_add_del_entry_t *mp;
11432 u32 sad_id = 0, spi = 0;
11433 u8 *ck = 0, *ik = 0;
11436 u8 protocol = IPSEC_PROTOCOL_AH;
11437 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
11438 u32 crypto_alg = 0, integ_alg = 0;
11439 ip4_address_t tun_src4;
11440 ip4_address_t tun_dst4;
11441 ip6_address_t tun_src6;
11442 ip6_address_t tun_dst6;
11444 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11446 if (unformat (i, "del"))
11448 else if (unformat (i, "sad_id %d", &sad_id))
11450 else if (unformat (i, "spi %d", &spi))
11452 else if (unformat (i, "esp"))
11453 protocol = IPSEC_PROTOCOL_ESP;
11454 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
11457 is_tunnel_ipv6 = 0;
11459 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
11462 is_tunnel_ipv6 = 0;
11464 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
11467 is_tunnel_ipv6 = 1;
11469 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
11472 is_tunnel_ipv6 = 1;
11476 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
11478 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
11479 crypto_alg > IPSEC_INTEG_ALG_SHA_512_256)
11481 clib_warning ("unsupported crypto-alg: '%U'",
11482 format_ipsec_crypto_alg, crypto_alg);
11486 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11490 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
11492 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
11493 integ_alg > IPSEC_INTEG_ALG_SHA_512_256)
11495 clib_warning ("unsupported integ-alg: '%U'",
11496 format_ipsec_integ_alg, integ_alg);
11500 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
11504 clib_warning ("parse error '%U'", format_unformat_error, i);
11510 M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
11512 mp->sad_id = ntohl (sad_id);
11513 mp->is_add = is_add;
11514 mp->protocol = protocol;
11515 mp->spi = ntohl (spi);
11516 mp->is_tunnel = is_tunnel;
11517 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
11518 mp->crypto_algorithm = crypto_alg;
11519 mp->integrity_algorithm = integ_alg;
11520 mp->crypto_key_length = vec_len (ck);
11521 mp->integrity_key_length = vec_len (ik);
11523 if (mp->crypto_key_length > sizeof (mp->crypto_key))
11524 mp->crypto_key_length = sizeof (mp->crypto_key);
11526 if (mp->integrity_key_length > sizeof (mp->integrity_key))
11527 mp->integrity_key_length = sizeof (mp->integrity_key);
11530 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
11532 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
11536 if (is_tunnel_ipv6)
11538 clib_memcpy (mp->tunnel_src_address, &tun_src6,
11539 sizeof (ip6_address_t));
11540 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
11541 sizeof (ip6_address_t));
11545 clib_memcpy (mp->tunnel_src_address, &tun_src4,
11546 sizeof (ip4_address_t));
11547 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
11548 sizeof (ip4_address_t));
11557 clib_warning ("unsupported (no dpdk)");
11563 api_ipsec_sa_set_key (vat_main_t * vam)
11566 unformat_input_t *i = vam->input;
11567 vl_api_ipsec_sa_set_key_t *mp;
11570 u8 *ck = 0, *ik = 0;
11572 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11574 if (unformat (i, "sa_id %d", &sa_id))
11576 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11578 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
11582 clib_warning ("parse error '%U'", format_unformat_error, i);
11587 M (IPSEC_SA_SET_KEY, ipsec_set_sa_key);
11589 mp->sa_id = ntohl (sa_id);
11590 mp->crypto_key_length = vec_len (ck);
11591 mp->integrity_key_length = vec_len (ik);
11593 if (mp->crypto_key_length > sizeof (mp->crypto_key))
11594 mp->crypto_key_length = sizeof (mp->crypto_key);
11596 if (mp->integrity_key_length > sizeof (mp->integrity_key))
11597 mp->integrity_key_length = sizeof (mp->integrity_key);
11600 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
11602 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
11609 clib_warning ("unsupported (no dpdk)");
11615 api_ikev2_profile_add_del (vat_main_t * vam)
11618 unformat_input_t *i = vam->input;
11619 vl_api_ikev2_profile_add_del_t *mp;
11624 const char *valid_chars = "a-zA-Z0-9_";
11626 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11628 if (unformat (i, "del"))
11630 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11631 vec_add1 (name, 0);
11634 errmsg ("parse error '%U'", format_unformat_error, i);
11639 if (!vec_len (name))
11641 errmsg ("profile name must be specified");
11645 if (vec_len (name) > 64)
11647 errmsg ("profile name too long");
11651 M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del);
11653 clib_memcpy (mp->name, name, vec_len (name));
11654 mp->is_add = is_add;
11662 clib_warning ("unsupported (no dpdk)");
11668 api_ikev2_profile_set_auth (vat_main_t * vam)
11671 unformat_input_t *i = vam->input;
11672 vl_api_ikev2_profile_set_auth_t *mp;
11676 u32 auth_method = 0;
11679 const char *valid_chars = "a-zA-Z0-9_";
11681 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11683 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11684 vec_add1 (name, 0);
11685 else if (unformat (i, "auth_method %U",
11686 unformat_ikev2_auth_method, &auth_method))
11688 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
11690 else if (unformat (i, "auth_data %v", &data))
11694 errmsg ("parse error '%U'", format_unformat_error, i);
11699 if (!vec_len (name))
11701 errmsg ("profile name must be specified");
11705 if (vec_len (name) > 64)
11707 errmsg ("profile name too long");
11711 if (!vec_len (data))
11713 errmsg ("auth_data must be specified");
11719 errmsg ("auth_method must be specified");
11723 M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth);
11725 mp->is_hex = is_hex;
11726 mp->auth_method = (u8) auth_method;
11727 mp->data_len = vec_len (data);
11728 clib_memcpy (mp->name, name, vec_len (name));
11729 clib_memcpy (mp->data, data, vec_len (data));
11738 clib_warning ("unsupported (no dpdk)");
11744 api_ikev2_profile_set_id (vat_main_t * vam)
11747 unformat_input_t *i = vam->input;
11748 vl_api_ikev2_profile_set_id_t *mp;
11756 const char *valid_chars = "a-zA-Z0-9_";
11758 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11760 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11761 vec_add1 (name, 0);
11762 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
11764 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
11766 data = vec_new (u8, 4);
11767 clib_memcpy (data, ip4.as_u8, 4);
11769 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
11771 else if (unformat (i, "id_data %v", &data))
11773 else if (unformat (i, "local"))
11775 else if (unformat (i, "remote"))
11779 errmsg ("parse error '%U'", format_unformat_error, i);
11784 if (!vec_len (name))
11786 errmsg ("profile name must be specified");
11790 if (vec_len (name) > 64)
11792 errmsg ("profile name too long");
11796 if (!vec_len (data))
11798 errmsg ("id_data must be specified");
11804 errmsg ("id_type must be specified");
11808 M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id);
11810 mp->is_local = is_local;
11811 mp->id_type = (u8) id_type;
11812 mp->data_len = vec_len (data);
11813 clib_memcpy (mp->name, name, vec_len (name));
11814 clib_memcpy (mp->data, data, vec_len (data));
11823 clib_warning ("unsupported (no dpdk)");
11829 api_ikev2_profile_set_ts (vat_main_t * vam)
11832 unformat_input_t *i = vam->input;
11833 vl_api_ikev2_profile_set_ts_t *mp;
11837 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
11838 ip4_address_t start_addr, end_addr;
11840 const char *valid_chars = "a-zA-Z0-9_";
11842 start_addr.as_u32 = 0;
11843 end_addr.as_u32 = (u32) ~ 0;
11845 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11847 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11848 vec_add1 (name, 0);
11849 else if (unformat (i, "protocol %d", &proto))
11851 else if (unformat (i, "start_port %d", &start_port))
11853 else if (unformat (i, "end_port %d", &end_port))
11856 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
11858 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
11860 else if (unformat (i, "local"))
11862 else if (unformat (i, "remote"))
11866 errmsg ("parse error '%U'", format_unformat_error, i);
11871 if (!vec_len (name))
11873 errmsg ("profile name must be specified");
11877 if (vec_len (name) > 64)
11879 errmsg ("profile name too long");
11883 M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts);
11885 mp->is_local = is_local;
11886 mp->proto = (u8) proto;
11887 mp->start_port = (u16) start_port;
11888 mp->end_port = (u16) end_port;
11889 mp->start_addr = start_addr.as_u32;
11890 mp->end_addr = end_addr.as_u32;
11891 clib_memcpy (mp->name, name, vec_len (name));
11899 clib_warning ("unsupported (no dpdk)");
11905 api_ikev2_set_local_key (vat_main_t * vam)
11908 unformat_input_t *i = vam->input;
11909 vl_api_ikev2_set_local_key_t *mp;
11913 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11915 if (unformat (i, "file %v", &file))
11916 vec_add1 (file, 0);
11919 errmsg ("parse error '%U'", format_unformat_error, i);
11924 if (!vec_len (file))
11926 errmsg ("RSA key file must be specified");
11930 if (vec_len (file) > 256)
11932 errmsg ("file name too long");
11936 M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key);
11938 clib_memcpy (mp->key_file, file, vec_len (file));
11946 clib_warning ("unsupported (no dpdk)");
11955 api_map_add_domain (vat_main_t * vam)
11957 unformat_input_t *i = vam->input;
11958 vl_api_map_add_domain_t *mp;
11961 ip4_address_t ip4_prefix;
11962 ip6_address_t ip6_prefix;
11963 ip6_address_t ip6_src;
11964 u32 num_m_args = 0;
11965 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
11966 0, psid_length = 0;
11967 u8 is_translation = 0;
11969 u32 ip6_src_len = 128;
11971 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11973 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
11974 &ip4_prefix, &ip4_prefix_len))
11976 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
11977 &ip6_prefix, &ip6_prefix_len))
11981 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
11984 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
11986 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
11988 else if (unformat (i, "psid-offset %d", &psid_offset))
11990 else if (unformat (i, "psid-len %d", &psid_length))
11992 else if (unformat (i, "mtu %d", &mtu))
11994 else if (unformat (i, "map-t"))
11995 is_translation = 1;
11998 clib_warning ("parse error '%U'", format_unformat_error, i);
12003 if (num_m_args < 3)
12005 errmsg ("mandatory argument(s) missing\n");
12009 /* Construct the API message */
12010 M (MAP_ADD_DOMAIN, map_add_domain);
12012 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12013 mp->ip4_prefix_len = ip4_prefix_len;
12015 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12016 mp->ip6_prefix_len = ip6_prefix_len;
12018 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12019 mp->ip6_src_prefix_len = ip6_src_len;
12021 mp->ea_bits_len = ea_bits_len;
12022 mp->psid_offset = psid_offset;
12023 mp->psid_length = psid_length;
12024 mp->is_translation = is_translation;
12025 mp->mtu = htons (mtu);
12030 /* Wait for a reply, return good/bad news */
12035 api_map_del_domain (vat_main_t * vam)
12037 unformat_input_t *i = vam->input;
12038 vl_api_map_del_domain_t *mp;
12041 u32 num_m_args = 0;
12044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12046 if (unformat (i, "index %d", &index))
12050 clib_warning ("parse error '%U'", format_unformat_error, i);
12055 if (num_m_args != 1)
12057 errmsg ("mandatory argument(s) missing\n");
12061 /* Construct the API message */
12062 M (MAP_DEL_DOMAIN, map_del_domain);
12064 mp->index = ntohl (index);
12069 /* Wait for a reply, return good/bad news */
12074 api_map_add_del_rule (vat_main_t * vam)
12076 unformat_input_t *i = vam->input;
12077 vl_api_map_add_del_rule_t *mp;
12080 ip6_address_t ip6_dst;
12081 u32 num_m_args = 0, index, psid = 0;
12083 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12085 if (unformat (i, "index %d", &index))
12087 else if (unformat (i, "psid %d", &psid))
12089 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
12091 else if (unformat (i, "del"))
12097 clib_warning ("parse error '%U'", format_unformat_error, i);
12102 /* Construct the API message */
12103 M (MAP_ADD_DEL_RULE, map_add_del_rule);
12105 mp->index = ntohl (index);
12106 mp->is_add = is_add;
12107 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
12108 mp->psid = ntohs (psid);
12113 /* Wait for a reply, return good/bad news */
12118 api_map_domain_dump (vat_main_t * vam)
12120 vl_api_map_domain_dump_t *mp;
12123 /* Construct the API message */
12124 M (MAP_DOMAIN_DUMP, map_domain_dump);
12129 /* Use a control ping for synchronization */
12131 vl_api_control_ping_t *mp;
12132 M (CONTROL_PING, control_ping);
12139 api_map_rule_dump (vat_main_t * vam)
12141 unformat_input_t *i = vam->input;
12142 vl_api_map_rule_dump_t *mp;
12144 u32 domain_index = ~0;
12146 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12148 if (unformat (i, "index %u", &domain_index))
12154 if (domain_index == ~0)
12156 clib_warning ("parse error: domain index expected");
12160 /* Construct the API message */
12161 M (MAP_RULE_DUMP, map_rule_dump);
12163 mp->domain_index = htonl (domain_index);
12168 /* Use a control ping for synchronization */
12170 vl_api_control_ping_t *mp;
12171 M (CONTROL_PING, control_ping);
12177 static void vl_api_map_add_domain_reply_t_handler
12178 (vl_api_map_add_domain_reply_t * mp)
12180 vat_main_t *vam = &vat_main;
12181 i32 retval = ntohl (mp->retval);
12183 if (vam->async_mode)
12185 vam->async_errors += (retval < 0);
12189 vam->retval = retval;
12190 vam->result_ready = 1;
12194 static void vl_api_map_add_domain_reply_t_handler_json
12195 (vl_api_map_add_domain_reply_t * mp)
12197 vat_main_t *vam = &vat_main;
12198 vat_json_node_t node;
12200 vat_json_init_object (&node);
12201 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
12202 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
12204 vat_json_print (vam->ofp, &node);
12205 vat_json_free (&node);
12207 vam->retval = ntohl (mp->retval);
12208 vam->result_ready = 1;
12212 api_get_first_msg_id (vat_main_t * vam)
12214 vl_api_get_first_msg_id_t *mp;
12216 unformat_input_t *i = vam->input;
12220 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12222 if (unformat (i, "client %s", &name))
12230 errmsg ("missing client name\n");
12233 vec_add1 (name, 0);
12235 if (vec_len (name) > 63)
12237 errmsg ("client name too long\n");
12241 M (GET_FIRST_MSG_ID, get_first_msg_id);
12242 clib_memcpy (mp->name, name, vec_len (name));
12250 api_cop_interface_enable_disable (vat_main_t * vam)
12252 unformat_input_t *line_input = vam->input;
12253 vl_api_cop_interface_enable_disable_t *mp;
12255 u32 sw_if_index = ~0;
12256 u8 enable_disable = 1;
12258 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12260 if (unformat (line_input, "disable"))
12261 enable_disable = 0;
12262 if (unformat (line_input, "enable"))
12263 enable_disable = 1;
12264 else if (unformat (line_input, "%U", unformat_sw_if_index,
12265 vam, &sw_if_index))
12267 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12273 if (sw_if_index == ~0)
12275 errmsg ("missing interface name or sw_if_index\n");
12279 /* Construct the API message */
12280 M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable);
12281 mp->sw_if_index = ntohl (sw_if_index);
12282 mp->enable_disable = enable_disable;
12286 /* Wait for the reply */
12291 api_cop_whitelist_enable_disable (vat_main_t * vam)
12293 unformat_input_t *line_input = vam->input;
12294 vl_api_cop_whitelist_enable_disable_t *mp;
12296 u32 sw_if_index = ~0;
12297 u8 ip4 = 0, ip6 = 0, default_cop = 0;
12300 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12302 if (unformat (line_input, "ip4"))
12304 else if (unformat (line_input, "ip6"))
12306 else if (unformat (line_input, "default"))
12308 else if (unformat (line_input, "%U", unformat_sw_if_index,
12309 vam, &sw_if_index))
12311 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12313 else if (unformat (line_input, "fib-id %d", &fib_id))
12319 if (sw_if_index == ~0)
12321 errmsg ("missing interface name or sw_if_index\n");
12325 /* Construct the API message */
12326 M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable);
12327 mp->sw_if_index = ntohl (sw_if_index);
12328 mp->fib_id = ntohl (fib_id);
12331 mp->default_cop = default_cop;
12335 /* Wait for the reply */
12340 api_get_node_graph (vat_main_t * vam)
12342 vl_api_get_node_graph_t *mp;
12345 M (GET_NODE_GRAPH, get_node_graph);
12349 /* Wait for the reply */
12354 /** Used for parsing LISP eids */
12355 typedef CLIB_PACKED(struct{
12356 u8 addr[16]; /**< eid address */
12357 u32 len; /**< prefix length if IP */
12358 u8 type; /**< type of eid */
12363 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
12365 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
12367 memset (a, 0, sizeof (a[0]));
12369 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
12371 a->type = 0; /* ipv4 type */
12373 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
12375 a->type = 1; /* ipv6 type */
12377 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
12379 a->type = 2; /* mac type */
12386 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
12395 lisp_eid_size_vat (u8 type)
12410 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
12412 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
12416 /** Used for transferring locators via VPP API */
12417 typedef CLIB_PACKED(struct
12419 u32 sw_if_index; /**< locator sw_if_index */
12420 u8 priority; /**< locator priority */
12421 u8 weight; /**< locator weight */
12426 api_lisp_add_del_locator_set (vat_main_t * vam)
12428 unformat_input_t *input = vam->input;
12429 vl_api_lisp_add_del_locator_set_t *mp;
12432 u8 *locator_set_name = NULL;
12433 u8 locator_set_name_set = 0;
12434 ls_locator_t locator, *locators = 0;
12435 u32 sw_if_index, priority, weight;
12438 /* Parse args required to build the message */
12439 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12441 if (unformat (input, "del"))
12445 else if (unformat (input, "locator-set %s", &locator_set_name))
12447 locator_set_name_set = 1;
12449 else if (unformat (input, "sw_if_index %u p %u w %u",
12450 &sw_if_index, &priority, &weight))
12452 locator.sw_if_index = htonl (sw_if_index);
12453 locator.priority = priority;
12454 locator.weight = weight;
12455 vec_add1 (locators, locator);
12457 else if (unformat (input, "iface %U p %u w %u", unformat_sw_if_index,
12458 vam, &sw_if_index, &priority, &weight))
12460 locator.sw_if_index = htonl (sw_if_index);
12461 locator.priority = priority;
12462 locator.weight = weight;
12463 vec_add1 (locators, locator);
12469 if (locator_set_name_set == 0)
12471 errmsg ("missing locator-set name");
12472 vec_free (locators);
12476 if (vec_len (locator_set_name) > 64)
12478 errmsg ("locator-set name too long\n");
12479 vec_free (locator_set_name);
12480 vec_free (locators);
12483 vec_add1 (locator_set_name, 0);
12485 data_len = sizeof (ls_locator_t) * vec_len (locators);
12487 /* Construct the API message */
12488 M2 (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set, data_len);
12490 mp->is_add = is_add;
12491 clib_memcpy (mp->locator_set_name, locator_set_name,
12492 vec_len (locator_set_name));
12493 vec_free (locator_set_name);
12495 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
12497 clib_memcpy (mp->locators, locators, data_len);
12498 vec_free (locators);
12503 /* Wait for a reply... */
12511 api_lisp_add_del_locator (vat_main_t * vam)
12513 unformat_input_t *input = vam->input;
12514 vl_api_lisp_add_del_locator_t *mp;
12516 u32 tmp_if_index = ~0;
12517 u32 sw_if_index = ~0;
12518 u8 sw_if_index_set = 0;
12519 u8 sw_if_index_if_name_set = 0;
12521 u8 priority_set = 0;
12525 u8 *locator_set_name = NULL;
12526 u8 locator_set_name_set = 0;
12528 /* Parse args required to build the message */
12529 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12531 if (unformat (input, "del"))
12535 else if (unformat (input, "locator-set %s", &locator_set_name))
12537 locator_set_name_set = 1;
12539 else if (unformat (input, "iface %U", unformat_sw_if_index, vam,
12542 sw_if_index_if_name_set = 1;
12543 sw_if_index = tmp_if_index;
12545 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
12547 sw_if_index_set = 1;
12548 sw_if_index = tmp_if_index;
12550 else if (unformat (input, "p %d", &priority))
12554 else if (unformat (input, "w %d", &weight))
12562 if (locator_set_name_set == 0)
12564 errmsg ("missing locator-set name");
12568 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
12570 errmsg ("missing sw_if_index");
12571 vec_free (locator_set_name);
12575 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
12577 errmsg ("cannot use both params interface name and sw_if_index");
12578 vec_free (locator_set_name);
12582 if (priority_set == 0)
12584 errmsg ("missing locator-set priority\n");
12585 vec_free (locator_set_name);
12589 if (weight_set == 0)
12591 errmsg ("missing locator-set weight\n");
12592 vec_free (locator_set_name);
12596 if (vec_len (locator_set_name) > 64)
12598 errmsg ("locator-set name too long\n");
12599 vec_free (locator_set_name);
12602 vec_add1 (locator_set_name, 0);
12604 /* Construct the API message */
12605 M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
12607 mp->is_add = is_add;
12608 mp->sw_if_index = ntohl (sw_if_index);
12609 mp->priority = priority;
12610 mp->weight = weight;
12611 clib_memcpy (mp->locator_set_name, locator_set_name,
12612 vec_len (locator_set_name));
12613 vec_free (locator_set_name);
12618 /* Wait for a reply... */
12626 api_lisp_add_del_local_eid (vat_main_t * vam)
12628 unformat_input_t *input = vam->input;
12629 vl_api_lisp_add_del_local_eid_t *mp;
12633 lisp_eid_vat_t _eid, *eid = &_eid;
12634 u8 *locator_set_name = 0;
12635 u8 locator_set_name_set = 0;
12638 /* Parse args required to build the message */
12639 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12641 if (unformat (input, "del"))
12645 else if (unformat (input, "vni %d", &vni))
12649 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
12653 else if (unformat (input, "locator-set %s", &locator_set_name))
12655 locator_set_name_set = 1;
12661 if (locator_set_name_set == 0)
12663 errmsg ("missing locator-set name\n");
12669 errmsg ("EID address not set!");
12670 vec_free (locator_set_name);
12674 if (vec_len (locator_set_name) > 64)
12676 errmsg ("locator-set name too long\n");
12677 vec_free (locator_set_name);
12680 vec_add1 (locator_set_name, 0);
12682 /* Construct the API message */
12683 M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
12685 mp->is_add = is_add;
12686 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
12687 mp->eid_type = eid->type;
12688 mp->prefix_len = eid->len;
12689 mp->vni = clib_host_to_net_u32 (vni);
12690 clib_memcpy (mp->locator_set_name, locator_set_name,
12691 vec_len (locator_set_name));
12693 vec_free (locator_set_name);
12698 /* Wait for a reply... */
12706 /** Used for transferring locators via VPP API */
12707 typedef CLIB_PACKED(struct
12709 u8 is_ip4; /**< is locator an IPv4 address? */
12710 u8 priority; /**< locator priority */
12711 u8 weight; /**< locator weight */
12712 u8 addr[16]; /**< IPv4/IPv6 address */
12717 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
12719 unformat_input_t *input = vam->input;
12720 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
12723 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
12724 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
12725 u8 rmt_eid_set = 0, lcl_eid_set = 0;
12726 u32 action = ~0, p, w;
12727 ip4_address_t rmt_rloc4, lcl_rloc4;
12728 ip6_address_t rmt_rloc6, lcl_rloc6;
12729 rloc_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
12731 memset (&rloc, 0, sizeof (rloc));
12733 /* Parse args required to build the message */
12734 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12736 if (unformat (input, "del"))
12740 else if (unformat (input, "rmt_eid %U", unformat_lisp_eid_vat, rmt_eid))
12744 else if (unformat (input, "lcl_eid %U", unformat_lisp_eid_vat, lcl_eid))
12748 else if (unformat (input, "p %d w %d", &p, &w))
12752 errmsg ("No RLOC configured for setting priority/weight!");
12755 curr_rloc->priority = p;
12756 curr_rloc->weight = w;
12758 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
12759 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
12763 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
12764 rloc.priority = rloc.weight = 0;
12765 vec_add1 (lcl_locs, rloc);
12767 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
12768 vec_add1 (rmt_locs, rloc);
12769 /* priority and weight saved in rmt loc */
12770 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
12772 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
12773 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
12776 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
12777 rloc.priority = rloc.weight = 0;
12778 vec_add1 (lcl_locs, rloc);
12780 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
12781 vec_add1 (rmt_locs, rloc);
12782 /* priority and weight saved in rmt loc */
12783 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
12785 else if (unformat (input, "action %d", &action))
12791 clib_warning ("parse error '%U'", format_unformat_error, input);
12798 errmsg ("remote eid addresses not set\n");
12802 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
12804 errmsg ("eid types don't match\n");
12808 if (0 == rmt_locs && (u32) ~ 0 == action)
12810 errmsg ("action not set for negative mapping\n");
12814 /* Construct the API message */
12815 M (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry);
12817 mp->is_add = is_add;
12818 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
12819 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
12820 mp->eid_type = rmt_eid->type;
12821 mp->rmt_len = rmt_eid->len;
12822 mp->lcl_len = lcl_eid->len;
12823 mp->action = action;
12825 if (0 != rmt_locs && 0 != lcl_locs)
12827 mp->loc_num = vec_len (rmt_locs);
12828 clib_memcpy (mp->lcl_locs, lcl_locs,
12829 (sizeof (rloc_t) * vec_len (lcl_locs)));
12830 clib_memcpy (mp->rmt_locs, rmt_locs,
12831 (sizeof (rloc_t) * vec_len (rmt_locs)));
12833 vec_free (lcl_locs);
12834 vec_free (rmt_locs);
12839 /* Wait for a reply... */
12847 api_lisp_add_del_map_resolver (vat_main_t * vam)
12849 unformat_input_t *input = vam->input;
12850 vl_api_lisp_add_del_map_resolver_t *mp;
12855 ip4_address_t ipv4;
12856 ip6_address_t ipv6;
12858 /* Parse args required to build the message */
12859 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12861 if (unformat (input, "del"))
12865 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
12869 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
12877 if (ipv4_set && ipv6_set)
12879 errmsg ("both eid v4 and v6 addresses set\n");
12883 if (!ipv4_set && !ipv6_set)
12885 errmsg ("eid addresses not set\n");
12889 /* Construct the API message */
12890 M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
12892 mp->is_add = is_add;
12896 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
12901 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
12907 /* Wait for a reply... */
12915 api_lisp_gpe_enable_disable (vat_main_t * vam)
12917 unformat_input_t *input = vam->input;
12918 vl_api_lisp_gpe_enable_disable_t *mp;
12923 /* Parse args required to build the message */
12924 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12926 if (unformat (input, "enable"))
12931 else if (unformat (input, "disable"))
12942 errmsg ("Value not set\n");
12946 /* Construct the API message */
12947 M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
12954 /* Wait for a reply... */
12962 api_lisp_enable_disable (vat_main_t * vam)
12964 unformat_input_t *input = vam->input;
12965 vl_api_lisp_enable_disable_t *mp;
12970 /* Parse args required to build the message */
12971 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12973 if (unformat (input, "enable"))
12978 else if (unformat (input, "disable"))
12988 errmsg ("Value not set\n");
12992 /* Construct the API message */
12993 M (LISP_ENABLE_DISABLE, lisp_enable_disable);
13000 /* Wait for a reply... */
13008 api_show_lisp_map_request_mode (vat_main_t * vam)
13011 vl_api_show_lisp_map_request_mode_t *mp;
13013 M (SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode);
13018 /* wait for reply */
13025 api_lisp_map_request_mode (vat_main_t * vam)
13028 unformat_input_t *input = vam->input;
13029 vl_api_lisp_map_request_mode_t *mp;
13032 /* Parse args required to build the message */
13033 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13035 if (unformat (input, "dst-only"))
13037 else if (unformat (input, "src-dst"))
13041 errmsg ("parse error '%U'", format_unformat_error, input);
13046 M (LISP_MAP_REQUEST_MODE, lisp_map_request_mode);
13053 /* wait for reply */
13061 * Enable/disable LISP proxy ITR.
13063 * @param vam vpp API test context
13064 * @return return code
13067 api_lisp_pitr_set_locator_set (vat_main_t * vam)
13070 u8 ls_name_set = 0;
13071 unformat_input_t *input = vam->input;
13072 vl_api_lisp_pitr_set_locator_set_t *mp;
13076 /* Parse args required to build the message */
13077 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13079 if (unformat (input, "del"))
13081 else if (unformat (input, "locator-set %s", &ls_name))
13085 errmsg ("parse error '%U'", format_unformat_error, input);
13092 errmsg ("locator-set name not set!");
13096 M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set);
13098 mp->is_add = is_add;
13099 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
13100 vec_free (ls_name);
13105 /* wait for reply */
13113 api_show_lisp_pitr (vat_main_t * vam)
13115 vl_api_show_lisp_pitr_t *mp;
13118 if (!vam->json_output)
13120 fformat (vam->ofp, "%=20s\n", "lisp status:");
13123 M (SHOW_LISP_PITR, show_lisp_pitr);
13127 /* Wait for a reply... */
13135 * Add/delete mapping between vni and vrf
13138 api_lisp_eid_table_add_del_map (vat_main_t * vam)
13141 unformat_input_t *input = vam->input;
13142 vl_api_lisp_eid_table_add_del_map_t *mp;
13143 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
13144 u32 vni, vrf, bd_index;
13146 /* Parse args required to build the message */
13147 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13149 if (unformat (input, "del"))
13151 else if (unformat (input, "vrf %d", &vrf))
13153 else if (unformat (input, "bd_index %d", &bd_index))
13155 else if (unformat (input, "vni %d", &vni))
13161 if (!vni_set || (!vrf_set && !bd_index_set))
13163 errmsg ("missing arguments!");
13167 if (vrf_set && bd_index_set)
13169 errmsg ("error: both vrf and bd entered!");
13173 M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
13175 mp->is_add = is_add;
13176 mp->vni = htonl (vni);
13177 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
13178 mp->is_l2 = bd_index_set;
13183 /* wait for reply */
13191 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
13193 u32 *action = va_arg (*args, u32 *);
13196 if (unformat (input, "%s", &s))
13198 if (!strcmp ((char *) s, "no-action"))
13200 else if (!strcmp ((char *) s, "natively-forward"))
13202 else if (!strcmp ((char *) s, "send-map-request"))
13204 else if (!strcmp ((char *) s, "drop"))
13208 clib_warning ("invalid action: '%s'", s);
13220 * Add/del remote mapping to/from LISP control plane
13222 * @param vam vpp API test context
13223 * @return return code
13226 api_lisp_add_del_remote_mapping (vat_main_t * vam)
13228 unformat_input_t *input = vam->input;
13229 vl_api_lisp_add_del_remote_mapping_t *mp;
13232 lisp_eid_vat_t _eid, *eid = &_eid;
13233 lisp_eid_vat_t _seid, *seid = &_seid;
13234 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
13235 u32 action = ~0, p, w, data_len;
13236 ip4_address_t rloc4;
13237 ip6_address_t rloc6;
13238 rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
13240 memset (&rloc, 0, sizeof (rloc));
13242 /* Parse args required to build the message */
13243 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13245 if (unformat (input, "del-all"))
13249 else if (unformat (input, "del"))
13253 else if (unformat (input, "add"))
13257 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13261 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
13265 else if (unformat (input, "vni %d", &vni))
13269 else if (unformat (input, "p %d w %d", &p, &w))
13273 errmsg ("No RLOC configured for setting priority/weight!");
13276 curr_rloc->priority = p;
13277 curr_rloc->weight = w;
13279 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
13282 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
13283 vec_add1 (rlocs, rloc);
13284 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13286 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
13289 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
13290 vec_add1 (rlocs, rloc);
13291 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13293 else if (unformat (input, "action %U",
13294 unformat_negative_mapping_action, &action))
13300 clib_warning ("parse error '%U'", format_unformat_error, input);
13307 errmsg ("missing params!");
13311 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
13313 errmsg ("no action set for negative map-reply!");
13317 data_len = vec_len (rlocs) * sizeof (rloc_t);
13319 M2 (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping, data_len);
13320 mp->is_add = is_add;
13321 mp->vni = htonl (vni);
13322 mp->action = (u8) action;
13323 mp->is_src_dst = seid_set;
13324 mp->eid_len = eid->len;
13325 mp->seid_len = seid->len;
13326 mp->del_all = del_all;
13327 mp->eid_type = eid->type;
13328 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13329 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
13331 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
13332 clib_memcpy (mp->rlocs, rlocs, data_len);
13338 /* Wait for a reply... */
13346 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
13347 * forwarding entries in data-plane accordingly.
13349 * @param vam vpp API test context
13350 * @return return code
13353 api_lisp_add_del_adjacency (vat_main_t * vam)
13355 unformat_input_t *input = vam->input;
13356 vl_api_lisp_add_del_adjacency_t *mp;
13359 ip4_address_t leid4, reid4;
13360 ip6_address_t leid6, reid6;
13361 u8 reid_mac[6] = { 0 };
13362 u8 leid_mac[6] = { 0 };
13363 u8 reid_type, leid_type;
13364 u32 leid_len = 0, reid_len = 0, len;
13367 leid_type = reid_type = (u8) ~ 0;
13369 /* Parse args required to build the message */
13370 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13372 if (unformat (input, "del"))
13376 else if (unformat (input, "add"))
13380 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
13383 reid_type = 0; /* ipv4 */
13386 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
13389 reid_type = 1; /* ipv6 */
13392 else if (unformat (input, "reid %U", unformat_ethernet_address,
13395 reid_type = 2; /* mac */
13397 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
13400 leid_type = 0; /* ipv4 */
13403 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
13406 leid_type = 1; /* ipv6 */
13409 else if (unformat (input, "leid %U", unformat_ethernet_address,
13412 leid_type = 2; /* mac */
13414 else if (unformat (input, "vni %d", &vni))
13420 errmsg ("parse error '%U'", format_unformat_error, input);
13425 if ((u8) ~ 0 == reid_type)
13427 errmsg ("missing params!");
13431 if (leid_type != reid_type)
13433 errmsg ("remote and local EIDs are of different types!");
13437 M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency);
13438 mp->is_add = is_add;
13439 mp->vni = htonl (vni);
13440 mp->leid_len = leid_len;
13441 mp->reid_len = reid_len;
13442 mp->eid_type = reid_type;
13444 switch (mp->eid_type)
13447 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
13448 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
13451 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
13452 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
13455 clib_memcpy (mp->leid, leid_mac, 6);
13456 clib_memcpy (mp->reid, reid_mac, 6);
13459 errmsg ("unknown EID type %d!", mp->eid_type);
13466 /* Wait for a reply... */
13474 api_lisp_gpe_add_del_iface (vat_main_t * vam)
13476 unformat_input_t *input = vam->input;
13477 vl_api_lisp_gpe_add_del_iface_t *mp;
13479 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
13480 u32 dp_table = 0, vni = 0;
13482 /* Parse args required to build the message */
13483 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13485 if (unformat (input, "up"))
13490 else if (unformat (input, "down"))
13495 else if (unformat (input, "table_id %d", &dp_table))
13499 else if (unformat (input, "bd_id %d", &dp_table))
13504 else if (unformat (input, "vni %d", &vni))
13512 if (action_set == 0)
13514 errmsg ("Action not set\n");
13517 if (dp_table_set == 0 || vni_set == 0)
13519 errmsg ("vni and dp_table must be set\n");
13523 /* Construct the API message */
13524 M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
13526 mp->is_add = is_add;
13527 mp->dp_table = dp_table;
13534 /* Wait for a reply... */
13542 * Add/del map request itr rlocs from LISP control plane and updates
13544 * @param vam vpp API test context
13545 * @return return code
13548 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
13550 unformat_input_t *input = vam->input;
13551 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
13553 u8 *locator_set_name = 0;
13554 u8 locator_set_name_set = 0;
13557 /* Parse args required to build the message */
13558 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13560 if (unformat (input, "del"))
13564 else if (unformat (input, "%_%v%_", &locator_set_name))
13566 locator_set_name_set = 1;
13570 clib_warning ("parse error '%U'", format_unformat_error, input);
13575 if (is_add && !locator_set_name_set)
13577 errmsg ("itr-rloc is not set!");
13581 if (is_add && vec_len (locator_set_name) > 64)
13583 errmsg ("itr-rloc locator-set name too long\n");
13584 vec_free (locator_set_name);
13588 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs);
13589 mp->is_add = is_add;
13592 clib_memcpy (mp->locator_set_name, locator_set_name,
13593 vec_len (locator_set_name));
13597 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
13599 vec_free (locator_set_name);
13604 /* Wait for a reply... */
13612 api_lisp_locator_dump (vat_main_t * vam)
13614 unformat_input_t *input = vam->input;
13615 vl_api_lisp_locator_dump_t *mp;
13617 u8 is_index_set = 0, is_name_set = 0;
13621 /* Parse args required to build the message */
13622 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13624 if (unformat (input, "ls_name %_%v%_", &ls_name))
13628 else if (unformat (input, "ls_index %d", &ls_index))
13634 errmsg ("parse error '%U'", format_unformat_error, input);
13639 if (!is_index_set && !is_name_set)
13641 errmsg ("error: expected one of index or name!\n");
13645 if (is_index_set && is_name_set)
13647 errmsg ("error: only one param expected!\n");
13651 if (vec_len (ls_name) > 62)
13653 errmsg ("error: locator set name too long!");
13657 if (!vam->json_output)
13659 fformat (vam->ofp, "%=16s%=16s%=16s\n", "locator", "priority",
13663 M (LISP_LOCATOR_DUMP, lisp_locator_dump);
13664 mp->is_index_set = is_index_set;
13667 mp->ls_index = clib_host_to_net_u32 (ls_index);
13670 vec_add1 (ls_name, 0);
13671 strncpy ((char *) mp->ls_name, (char *) ls_name,
13672 sizeof (mp->ls_name) - 1);
13678 /* Use a control ping for synchronization */
13680 vl_api_control_ping_t *mp;
13681 M (CONTROL_PING, control_ping);
13684 /* Wait for a reply... */
13692 api_lisp_locator_set_dump (vat_main_t * vam)
13694 vl_api_lisp_locator_set_dump_t *mp;
13695 unformat_input_t *input = vam->input;
13699 /* Parse args required to build the message */
13700 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13702 if (unformat (input, "local"))
13706 else if (unformat (input, "remote"))
13712 errmsg ("parse error '%U'", format_unformat_error, input);
13717 if (!vam->json_output)
13719 fformat (vam->ofp, "%=10s%=15s\n", "ls_index", "ls_name");
13722 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
13724 mp->filter = filter;
13729 /* Use a control ping for synchronization */
13731 vl_api_control_ping_t *mp;
13732 M (CONTROL_PING, control_ping);
13735 /* Wait for a reply... */
13743 api_lisp_eid_table_map_dump (vat_main_t * vam)
13747 unformat_input_t *input = vam->input;
13748 vl_api_lisp_eid_table_map_dump_t *mp;
13751 /* Parse args required to build the message */
13752 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13754 if (unformat (input, "l2"))
13759 else if (unformat (input, "l3"))
13766 errmsg ("parse error '%U'", format_unformat_error, input);
13773 errmsg ("expected one of 'l2' or 'l3' parameter!\n");
13777 if (!vam->json_output)
13779 fformat (vam->ofp, "%=10s%=10s\n", "VNI", is_l2 ? "BD" : "VRF");
13782 M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump);
13788 /* Use a control ping for synchronization */
13790 vl_api_control_ping_t *mp;
13791 M (CONTROL_PING, control_ping);
13794 /* Wait for a reply... */
13802 api_lisp_eid_table_vni_dump (vat_main_t * vam)
13804 vl_api_lisp_eid_table_vni_dump_t *mp;
13807 if (!vam->json_output)
13809 fformat (vam->ofp, "VNI\n");
13812 M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
13817 /* Use a control ping for synchronization */
13819 vl_api_control_ping_t *mp;
13820 M (CONTROL_PING, control_ping);
13823 /* Wait for a reply... */
13831 api_lisp_eid_table_dump (vat_main_t * vam)
13833 unformat_input_t *i = vam->input;
13834 vl_api_lisp_eid_table_dump_t *mp;
13836 struct in_addr ip4;
13837 struct in6_addr ip6;
13839 u8 eid_type = ~0, eid_set = 0;
13840 u32 prefix_length = ~0, t, vni = 0;
13843 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13845 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
13851 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
13857 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
13862 else if (unformat (i, "vni %d", &t))
13866 else if (unformat (i, "local"))
13870 else if (unformat (i, "remote"))
13876 errmsg ("parse error '%U'", format_unformat_error, i);
13881 if (!vam->json_output)
13883 fformat (vam->ofp, "%-35s%-20s%-30s%-20s%-s\n", "EID", "type",
13884 "ls_index", "ttl", "authoritative");
13887 M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump);
13889 mp->filter = filter;
13893 mp->vni = htonl (vni);
13894 mp->eid_type = eid_type;
13898 mp->prefix_length = prefix_length;
13899 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
13902 mp->prefix_length = prefix_length;
13903 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
13906 clib_memcpy (mp->eid, mac, sizeof (mac));
13909 errmsg ("unknown EID type %d!", eid_type);
13917 /* Use a control ping for synchronization */
13919 vl_api_control_ping_t *mp;
13920 M (CONTROL_PING, control_ping);
13924 /* Wait for a reply... */
13932 api_lisp_gpe_tunnel_dump (vat_main_t * vam)
13934 vl_api_lisp_gpe_tunnel_dump_t *mp;
13937 if (!vam->json_output)
13939 fformat (vam->ofp, "%=20s%=30s%=16s%=16s%=16s%=16s"
13940 "%=16s%=16s%=16s%=16s%=16s\n",
13941 "Tunel", "Source", "Destination", "Fib encap", "Fib decap",
13942 "Decap next", "Lisp version", "Flags", "Next protocol",
13943 "ver_res", "res", "iid");
13946 M (LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump);
13950 /* Use a control ping for synchronization */
13952 vl_api_control_ping_t *mp;
13953 M (CONTROL_PING, control_ping);
13956 /* Wait for a reply... */
13964 api_lisp_adjacencies_get (vat_main_t * vam)
13966 unformat_input_t *i = vam->input;
13967 vl_api_lisp_adjacencies_get_t *mp;
13972 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13974 if (unformat (i, "vni %d", &vni))
13980 errmsg ("parse error '%U'\n", format_unformat_error, i);
13987 errmsg ("vni not set!\n");
13991 if (!vam->json_output)
13993 fformat (vam->ofp, "%s %40s\n", "leid", "reid");
13996 M (LISP_ADJACENCIES_GET, lisp_adjacencies_get);
13997 mp->vni = clib_host_to_net_u32 (vni);
14002 /* Wait for a reply... */
14010 api_lisp_map_resolver_dump (vat_main_t * vam)
14012 vl_api_lisp_map_resolver_dump_t *mp;
14015 if (!vam->json_output)
14017 fformat (vam->ofp, "%=20s\n", "Map resolver");
14020 M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
14024 /* Use a control ping for synchronization */
14026 vl_api_control_ping_t *mp;
14027 M (CONTROL_PING, control_ping);
14030 /* Wait for a reply... */
14038 api_show_lisp_status (vat_main_t * vam)
14040 vl_api_show_lisp_status_t *mp;
14043 if (!vam->json_output)
14045 fformat (vam->ofp, "%-20s%-16s\n", "lisp status", "locator-set");
14048 M (SHOW_LISP_STATUS, show_lisp_status);
14051 /* Wait for a reply... */
14059 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
14061 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
14064 if (!vam->json_output)
14066 fformat (vam->ofp, "%=20s\n", "itr-rlocs:");
14069 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
14072 /* Wait for a reply... */
14080 api_af_packet_create (vat_main_t * vam)
14082 unformat_input_t *i = vam->input;
14083 vl_api_af_packet_create_t *mp;
14085 u8 *host_if_name = 0;
14087 u8 random_hw_addr = 1;
14089 memset (hw_addr, 0, sizeof (hw_addr));
14091 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14093 if (unformat (i, "name %s", &host_if_name))
14094 vec_add1 (host_if_name, 0);
14095 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14096 random_hw_addr = 0;
14101 if (!vec_len (host_if_name))
14103 errmsg ("host-interface name must be specified");
14107 if (vec_len (host_if_name) > 64)
14109 errmsg ("host-interface name too long");
14113 M (AF_PACKET_CREATE, af_packet_create);
14115 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14116 clib_memcpy (mp->hw_addr, hw_addr, 6);
14117 mp->use_random_hw_addr = random_hw_addr;
14118 vec_free (host_if_name);
14121 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
14127 api_af_packet_delete (vat_main_t * vam)
14129 unformat_input_t *i = vam->input;
14130 vl_api_af_packet_delete_t *mp;
14132 u8 *host_if_name = 0;
14134 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14136 if (unformat (i, "name %s", &host_if_name))
14137 vec_add1 (host_if_name, 0);
14142 if (!vec_len (host_if_name))
14144 errmsg ("host-interface name must be specified");
14148 if (vec_len (host_if_name) > 64)
14150 errmsg ("host-interface name too long");
14154 M (AF_PACKET_DELETE, af_packet_delete);
14156 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14157 vec_free (host_if_name);
14166 api_policer_add_del (vat_main_t * vam)
14168 unformat_input_t *i = vam->input;
14169 vl_api_policer_add_del_t *mp;
14180 u8 color_aware = 0;
14181 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
14183 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
14184 conform_action.dscp = 0;
14185 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
14186 exceed_action.dscp = 0;
14187 violate_action.action_type = SSE2_QOS_ACTION_DROP;
14188 violate_action.dscp = 0;
14190 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14192 if (unformat (i, "del"))
14194 else if (unformat (i, "name %s", &name))
14195 vec_add1 (name, 0);
14196 else if (unformat (i, "cir %u", &cir))
14198 else if (unformat (i, "eir %u", &eir))
14200 else if (unformat (i, "cb %u", &cb))
14202 else if (unformat (i, "eb %u", &eb))
14204 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
14207 else if (unformat (i, "round_type %U", unformat_policer_round_type,
14210 else if (unformat (i, "type %U", unformat_policer_type, &type))
14212 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
14215 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
14218 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
14221 else if (unformat (i, "color-aware"))
14227 if (!vec_len (name))
14229 errmsg ("policer name must be specified");
14233 if (vec_len (name) > 64)
14235 errmsg ("policer name too long");
14239 M (POLICER_ADD_DEL, policer_add_del);
14241 clib_memcpy (mp->name, name, vec_len (name));
14243 mp->is_add = is_add;
14248 mp->rate_type = rate_type;
14249 mp->round_type = round_type;
14251 mp->conform_action_type = conform_action.action_type;
14252 mp->conform_dscp = conform_action.dscp;
14253 mp->exceed_action_type = exceed_action.action_type;
14254 mp->exceed_dscp = exceed_action.dscp;
14255 mp->violate_action_type = violate_action.action_type;
14256 mp->violate_dscp = violate_action.dscp;
14257 mp->color_aware = color_aware;
14266 api_policer_dump (vat_main_t * vam)
14268 unformat_input_t *i = vam->input;
14269 vl_api_policer_dump_t *mp;
14271 u8 *match_name = 0;
14272 u8 match_name_valid = 0;
14274 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14276 if (unformat (i, "name %s", &match_name))
14278 vec_add1 (match_name, 0);
14279 match_name_valid = 1;
14285 M (POLICER_DUMP, policer_dump);
14286 mp->match_name_valid = match_name_valid;
14287 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
14288 vec_free (match_name);
14292 /* Use a control ping for synchronization */
14294 vl_api_control_ping_t *mp;
14295 M (CONTROL_PING, control_ping);
14298 /* Wait for a reply... */
14306 api_policer_classify_set_interface (vat_main_t * vam)
14308 unformat_input_t *i = vam->input;
14309 vl_api_policer_classify_set_interface_t *mp;
14312 int sw_if_index_set;
14313 u32 ip4_table_index = ~0;
14314 u32 ip6_table_index = ~0;
14315 u32 l2_table_index = ~0;
14318 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14320 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
14321 sw_if_index_set = 1;
14322 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14323 sw_if_index_set = 1;
14324 else if (unformat (i, "del"))
14326 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14328 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14330 else if (unformat (i, "l2-table %d", &l2_table_index))
14334 clib_warning ("parse error '%U'", format_unformat_error, i);
14339 if (sw_if_index_set == 0)
14341 errmsg ("missing interface name or sw_if_index\n");
14345 M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface);
14347 mp->sw_if_index = ntohl (sw_if_index);
14348 mp->ip4_table_index = ntohl (ip4_table_index);
14349 mp->ip6_table_index = ntohl (ip6_table_index);
14350 mp->l2_table_index = ntohl (l2_table_index);
14351 mp->is_add = is_add;
14360 api_policer_classify_dump (vat_main_t * vam)
14362 unformat_input_t *i = vam->input;
14363 vl_api_policer_classify_dump_t *mp;
14365 u8 type = POLICER_CLASSIFY_N_TABLES;
14367 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
14371 errmsg ("classify table type must be specified\n");
14375 if (!vam->json_output)
14377 fformat (vam->ofp, "%10s%20s\n", "Intfc idx", "Classify table");
14380 M (POLICER_CLASSIFY_DUMP, policer_classify_dump);
14385 /* Use a control ping for synchronization */
14387 vl_api_control_ping_t *mp;
14388 M (CONTROL_PING, control_ping);
14391 /* Wait for a reply... */
14399 api_netmap_create (vat_main_t * vam)
14401 unformat_input_t *i = vam->input;
14402 vl_api_netmap_create_t *mp;
14406 u8 random_hw_addr = 1;
14410 memset (hw_addr, 0, sizeof (hw_addr));
14412 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14414 if (unformat (i, "name %s", &if_name))
14415 vec_add1 (if_name, 0);
14416 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14417 random_hw_addr = 0;
14418 else if (unformat (i, "pipe"))
14420 else if (unformat (i, "master"))
14422 else if (unformat (i, "slave"))
14428 if (!vec_len (if_name))
14430 errmsg ("interface name must be specified");
14434 if (vec_len (if_name) > 64)
14436 errmsg ("interface name too long");
14440 M (NETMAP_CREATE, netmap_create);
14442 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
14443 clib_memcpy (mp->hw_addr, hw_addr, 6);
14444 mp->use_random_hw_addr = random_hw_addr;
14445 mp->is_pipe = is_pipe;
14446 mp->is_master = is_master;
14447 vec_free (if_name);
14456 api_netmap_delete (vat_main_t * vam)
14458 unformat_input_t *i = vam->input;
14459 vl_api_netmap_delete_t *mp;
14463 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14465 if (unformat (i, "name %s", &if_name))
14466 vec_add1 (if_name, 0);
14471 if (!vec_len (if_name))
14473 errmsg ("interface name must be specified");
14477 if (vec_len (if_name) > 64)
14479 errmsg ("interface name too long");
14483 M (NETMAP_DELETE, netmap_delete);
14485 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
14486 vec_free (if_name);
14494 static void vl_api_mpls_gre_tunnel_details_t_handler
14495 (vl_api_mpls_gre_tunnel_details_t * mp)
14497 vat_main_t *vam = &vat_main;
14499 i32 len = ntohl (mp->nlabels);
14501 if (mp->l2_only == 0)
14503 fformat (vam->ofp, "[%d]: src %U, dst %U, adj %U/%d, labels ",
14504 ntohl (mp->tunnel_index),
14505 format_ip4_address, &mp->tunnel_src,
14506 format_ip4_address, &mp->tunnel_dst,
14507 format_ip4_address, &mp->intfc_address,
14508 ntohl (mp->mask_width));
14509 for (i = 0; i < len; i++)
14511 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14513 fformat (vam->ofp, "\n");
14514 fformat (vam->ofp, " inner fib index %d, outer fib index %d\n",
14515 ntohl (mp->inner_fib_index), ntohl (mp->outer_fib_index));
14519 fformat (vam->ofp, "[%d]: src %U, dst %U, key %U, labels ",
14520 ntohl (mp->tunnel_index),
14521 format_ip4_address, &mp->tunnel_src,
14522 format_ip4_address, &mp->tunnel_dst,
14523 format_ip4_address, &mp->intfc_address);
14524 for (i = 0; i < len; i++)
14526 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14528 fformat (vam->ofp, "\n");
14529 fformat (vam->ofp, " l2 interface %d, outer fib index %d\n",
14530 ntohl (mp->hw_if_index), ntohl (mp->outer_fib_index));
14534 static void vl_api_mpls_gre_tunnel_details_t_handler_json
14535 (vl_api_mpls_gre_tunnel_details_t * mp)
14537 vat_main_t *vam = &vat_main;
14538 vat_json_node_t *node = NULL;
14539 struct in_addr ip4;
14541 i32 len = ntohl (mp->nlabels);
14543 if (VAT_JSON_ARRAY != vam->json_tree.type)
14545 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14546 vat_json_init_array (&vam->json_tree);
14548 node = vat_json_array_add (&vam->json_tree);
14550 vat_json_init_object (node);
14551 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
14552 clib_memcpy (&ip4, &(mp->intfc_address), sizeof (ip4));
14553 vat_json_object_add_ip4 (node, "intfc_address", ip4);
14554 vat_json_object_add_uint (node, "inner_fib_index",
14555 ntohl (mp->inner_fib_index));
14556 vat_json_object_add_uint (node, "mask_width", ntohl (mp->mask_width));
14557 vat_json_object_add_uint (node, "encap_index", ntohl (mp->encap_index));
14558 vat_json_object_add_uint (node, "hw_if_index", ntohl (mp->hw_if_index));
14559 vat_json_object_add_uint (node, "l2_only", ntohl (mp->l2_only));
14560 clib_memcpy (&ip4, &(mp->tunnel_src), sizeof (ip4));
14561 vat_json_object_add_ip4 (node, "tunnel_src", ip4);
14562 clib_memcpy (&ip4, &(mp->tunnel_dst), sizeof (ip4));
14563 vat_json_object_add_ip4 (node, "tunnel_dst", ip4);
14564 vat_json_object_add_uint (node, "outer_fib_index",
14565 ntohl (mp->outer_fib_index));
14566 vat_json_object_add_uint (node, "label_count", len);
14567 for (i = 0; i < len; i++)
14569 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14574 api_mpls_gre_tunnel_dump (vat_main_t * vam)
14576 vl_api_mpls_gre_tunnel_dump_t *mp;
14580 /* Parse args required to build the message */
14581 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
14583 if (!unformat (vam->input, "tunnel_index %d", &index))
14590 fformat (vam->ofp, " tunnel_index %d\n", index);
14592 M (MPLS_GRE_TUNNEL_DUMP, mpls_gre_tunnel_dump);
14593 mp->tunnel_index = htonl (index);
14596 /* Use a control ping for synchronization */
14598 vl_api_control_ping_t *mp;
14599 M (CONTROL_PING, control_ping);
14605 static void vl_api_mpls_eth_tunnel_details_t_handler
14606 (vl_api_mpls_eth_tunnel_details_t * mp)
14608 vat_main_t *vam = &vat_main;
14610 i32 len = ntohl (mp->nlabels);
14612 fformat (vam->ofp, "[%d]: dst %U, adj %U/%d, labels ",
14613 ntohl (mp->tunnel_index),
14614 format_ethernet_address, &mp->tunnel_dst_mac,
14615 format_ip4_address, &mp->intfc_address, ntohl (mp->mask_width));
14616 for (i = 0; i < len; i++)
14618 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14620 fformat (vam->ofp, "\n");
14621 fformat (vam->ofp, " tx on %d, rx fib index %d\n",
14622 ntohl (mp->tx_sw_if_index), ntohl (mp->inner_fib_index));
14625 static void vl_api_mpls_eth_tunnel_details_t_handler_json
14626 (vl_api_mpls_eth_tunnel_details_t * mp)
14628 vat_main_t *vam = &vat_main;
14629 vat_json_node_t *node = NULL;
14630 struct in_addr ip4;
14632 i32 len = ntohl (mp->nlabels);
14634 if (VAT_JSON_ARRAY != vam->json_tree.type)
14636 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14637 vat_json_init_array (&vam->json_tree);
14639 node = vat_json_array_add (&vam->json_tree);
14641 vat_json_init_object (node);
14642 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
14643 clib_memcpy (&ip4, &(mp->intfc_address), sizeof (ip4));
14644 vat_json_object_add_ip4 (node, "intfc_address", ip4);
14645 vat_json_object_add_uint (node, "inner_fib_index",
14646 ntohl (mp->inner_fib_index));
14647 vat_json_object_add_uint (node, "mask_width", ntohl (mp->mask_width));
14648 vat_json_object_add_uint (node, "encap_index", ntohl (mp->encap_index));
14649 vat_json_object_add_uint (node, "hw_if_index", ntohl (mp->hw_if_index));
14650 vat_json_object_add_uint (node, "l2_only", ntohl (mp->l2_only));
14651 vat_json_object_add_string_copy (node, "tunnel_dst_mac",
14652 format (0, "%U", format_ethernet_address,
14653 &mp->tunnel_dst_mac));
14654 vat_json_object_add_uint (node, "tx_sw_if_index",
14655 ntohl (mp->tx_sw_if_index));
14656 vat_json_object_add_uint (node, "label_count", len);
14657 for (i = 0; i < len; i++)
14659 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14664 api_mpls_eth_tunnel_dump (vat_main_t * vam)
14666 vl_api_mpls_eth_tunnel_dump_t *mp;
14670 /* Parse args required to build the message */
14671 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
14673 if (!unformat (vam->input, "tunnel_index %d", &index))
14680 fformat (vam->ofp, " tunnel_index %d\n", index);
14682 M (MPLS_ETH_TUNNEL_DUMP, mpls_eth_tunnel_dump);
14683 mp->tunnel_index = htonl (index);
14686 /* Use a control ping for synchronization */
14688 vl_api_control_ping_t *mp;
14689 M (CONTROL_PING, control_ping);
14695 static void vl_api_mpls_fib_encap_details_t_handler
14696 (vl_api_mpls_fib_encap_details_t * mp)
14698 vat_main_t *vam = &vat_main;
14700 i32 len = ntohl (mp->nlabels);
14702 fformat (vam->ofp, "table %d, dest %U, label ",
14703 ntohl (mp->fib_index), format_ip4_address, &mp->dest, len);
14704 for (i = 0; i < len; i++)
14706 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14708 fformat (vam->ofp, "\n");
14711 static void vl_api_mpls_fib_encap_details_t_handler_json
14712 (vl_api_mpls_fib_encap_details_t * mp)
14714 vat_main_t *vam = &vat_main;
14715 vat_json_node_t *node = NULL;
14717 i32 len = ntohl (mp->nlabels);
14718 struct in_addr ip4;
14720 if (VAT_JSON_ARRAY != vam->json_tree.type)
14722 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14723 vat_json_init_array (&vam->json_tree);
14725 node = vat_json_array_add (&vam->json_tree);
14727 vat_json_init_object (node);
14728 vat_json_object_add_uint (node, "table", ntohl (mp->fib_index));
14729 vat_json_object_add_uint (node, "entry_index", ntohl (mp->entry_index));
14730 clib_memcpy (&ip4, &(mp->dest), sizeof (ip4));
14731 vat_json_object_add_ip4 (node, "dest", ip4);
14732 vat_json_object_add_uint (node, "s_bit", ntohl (mp->s_bit));
14733 vat_json_object_add_uint (node, "label_count", len);
14734 for (i = 0; i < len; i++)
14736 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14741 api_mpls_fib_encap_dump (vat_main_t * vam)
14743 vl_api_mpls_fib_encap_dump_t *mp;
14746 M (MPLS_FIB_ENCAP_DUMP, mpls_fib_encap_dump);
14749 /* Use a control ping for synchronization */
14751 vl_api_control_ping_t *mp;
14752 M (CONTROL_PING, control_ping);
14758 static void vl_api_mpls_fib_decap_details_t_handler
14759 (vl_api_mpls_fib_decap_details_t * mp)
14761 vat_main_t *vam = &vat_main;
14764 "RX table %d, TX table/intfc %u, swif_tag '%s', label %u, s_bit %u\n",
14765 ntohl (mp->rx_table_id), ntohl (mp->tx_table_id), mp->swif_tag,
14766 ntohl (mp->label), ntohl (mp->s_bit));
14769 static void vl_api_mpls_fib_decap_details_t_handler_json
14770 (vl_api_mpls_fib_decap_details_t * mp)
14772 vat_main_t *vam = &vat_main;
14773 vat_json_node_t *node = NULL;
14774 struct in_addr ip4;
14776 if (VAT_JSON_ARRAY != vam->json_tree.type)
14778 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14779 vat_json_init_array (&vam->json_tree);
14781 node = vat_json_array_add (&vam->json_tree);
14783 vat_json_init_object (node);
14784 vat_json_object_add_uint (node, "table", ntohl (mp->fib_index));
14785 vat_json_object_add_uint (node, "entry_index", ntohl (mp->entry_index));
14786 clib_memcpy (&ip4, &(mp->dest), sizeof (ip4));
14787 vat_json_object_add_ip4 (node, "dest", ip4);
14788 vat_json_object_add_uint (node, "s_bit", ntohl (mp->s_bit));
14789 vat_json_object_add_uint (node, "label", ntohl (mp->label));
14790 vat_json_object_add_uint (node, "rx_table_id", ntohl (mp->rx_table_id));
14791 vat_json_object_add_uint (node, "tx_table_id", ntohl (mp->tx_table_id));
14792 vat_json_object_add_string_copy (node, "swif_tag", mp->swif_tag);
14796 api_mpls_fib_decap_dump (vat_main_t * vam)
14798 vl_api_mpls_fib_decap_dump_t *mp;
14801 M (MPLS_FIB_DECAP_DUMP, mpls_fib_decap_dump);
14804 /* Use a control ping for synchronization */
14806 vl_api_control_ping_t *mp;
14807 M (CONTROL_PING, control_ping);
14814 api_classify_table_ids (vat_main_t * vam)
14816 vl_api_classify_table_ids_t *mp;
14819 /* Construct the API message */
14820 M (CLASSIFY_TABLE_IDS, classify_table_ids);
14830 api_classify_table_by_interface (vat_main_t * vam)
14832 unformat_input_t *input = vam->input;
14833 vl_api_classify_table_by_interface_t *mp;
14836 u32 sw_if_index = ~0;
14837 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14839 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
14841 else if (unformat (input, "sw_if_index %d", &sw_if_index))
14846 if (sw_if_index == ~0)
14848 errmsg ("missing interface name or sw_if_index\n");
14852 /* Construct the API message */
14853 M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
14855 mp->sw_if_index = ntohl (sw_if_index);
14864 api_classify_table_info (vat_main_t * vam)
14866 unformat_input_t *input = vam->input;
14867 vl_api_classify_table_info_t *mp;
14871 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14873 if (unformat (input, "table_id %d", &table_id))
14878 if (table_id == ~0)
14880 errmsg ("missing table id\n");
14884 /* Construct the API message */
14885 M (CLASSIFY_TABLE_INFO, classify_table_info);
14887 mp->table_id = ntohl (table_id);
14896 api_classify_session_dump (vat_main_t * vam)
14898 unformat_input_t *input = vam->input;
14899 vl_api_classify_session_dump_t *mp;
14903 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14905 if (unformat (input, "table_id %d", &table_id))
14910 if (table_id == ~0)
14912 errmsg ("missing table id\n");
14916 /* Construct the API message */
14917 M (CLASSIFY_SESSION_DUMP, classify_session_dump);
14919 mp->table_id = ntohl (table_id);
14922 /* Use a control ping for synchronization */
14924 vl_api_control_ping_t *mp;
14925 M (CONTROL_PING, control_ping);
14934 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
14936 vat_main_t *vam = &vat_main;
14938 fformat (vam->ofp, "collector_address %U, collector_port %d, "
14939 "src_address %U, vrf_id %d, path_mtu %u, "
14940 "template_interval %u, udp_checksum %d\n",
14941 format_ip4_address, mp->collector_address,
14942 ntohs (mp->collector_port),
14943 format_ip4_address, mp->src_address,
14944 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
14945 ntohl (mp->template_interval), mp->udp_checksum);
14948 vam->result_ready = 1;
14952 vl_api_ipfix_exporter_details_t_handler_json
14953 (vl_api_ipfix_exporter_details_t * mp)
14955 vat_main_t *vam = &vat_main;
14956 vat_json_node_t node;
14957 struct in_addr collector_address;
14958 struct in_addr src_address;
14960 vat_json_init_object (&node);
14961 clib_memcpy (&collector_address, &mp->collector_address,
14962 sizeof (collector_address));
14963 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
14964 vat_json_object_add_uint (&node, "collector_port",
14965 ntohs (mp->collector_port));
14966 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
14967 vat_json_object_add_ip4 (&node, "src_address", src_address);
14968 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
14969 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
14970 vat_json_object_add_uint (&node, "template_interval",
14971 ntohl (mp->template_interval));
14972 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
14974 vat_json_print (vam->ofp, &node);
14975 vat_json_free (&node);
14977 vam->result_ready = 1;
14981 api_ipfix_exporter_dump (vat_main_t * vam)
14983 vl_api_ipfix_exporter_dump_t *mp;
14986 /* Construct the API message */
14987 M (IPFIX_EXPORTER_DUMP, ipfix_exporter_dump);
14997 api_ipfix_classify_stream_dump (vat_main_t * vam)
14999 vl_api_ipfix_classify_stream_dump_t *mp;
15002 /* Construct the API message */
15003 M (IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump);
15013 vl_api_ipfix_classify_stream_details_t_handler
15014 (vl_api_ipfix_classify_stream_details_t * mp)
15016 vat_main_t *vam = &vat_main;
15017 fformat (vam->ofp, "domain_id %d, src_port %d\n",
15018 ntohl (mp->domain_id), ntohs (mp->src_port));
15020 vam->result_ready = 1;
15024 vl_api_ipfix_classify_stream_details_t_handler_json
15025 (vl_api_ipfix_classify_stream_details_t * mp)
15027 vat_main_t *vam = &vat_main;
15028 vat_json_node_t node;
15030 vat_json_init_object (&node);
15031 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
15032 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
15034 vat_json_print (vam->ofp, &node);
15035 vat_json_free (&node);
15037 vam->result_ready = 1;
15041 api_ipfix_classify_table_dump (vat_main_t * vam)
15043 vl_api_ipfix_classify_table_dump_t *mp;
15046 if (!vam->json_output)
15048 fformat (vam->ofp, "%15s%15s%20s\n", "table_id", "ip_version",
15049 "transport_protocol");
15052 /* Construct the API message */
15053 M (IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump);
15058 /* Use a control ping for synchronization */
15060 vl_api_control_ping_t *mp;
15061 M (CONTROL_PING, control_ping);
15068 vl_api_ipfix_classify_table_details_t_handler
15069 (vl_api_ipfix_classify_table_details_t * mp)
15071 vat_main_t *vam = &vat_main;
15072 fformat (vam->ofp, "%15d%15d%20d\n", ntohl (mp->table_id), mp->ip_version,
15073 mp->transport_protocol);
15077 vl_api_ipfix_classify_table_details_t_handler_json
15078 (vl_api_ipfix_classify_table_details_t * mp)
15080 vat_json_node_t *node = NULL;
15081 vat_main_t *vam = &vat_main;
15083 if (VAT_JSON_ARRAY != vam->json_tree.type)
15085 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15086 vat_json_init_array (&vam->json_tree);
15089 node = vat_json_array_add (&vam->json_tree);
15090 vat_json_init_object (node);
15092 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
15093 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
15094 vat_json_object_add_uint (node, "transport_protocol",
15095 mp->transport_protocol);
15099 api_pg_create_interface (vat_main_t * vam)
15101 unformat_input_t *input = vam->input;
15102 vl_api_pg_create_interface_t *mp;
15106 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15108 if (unformat (input, "if_id %d", &if_id))
15115 errmsg ("missing pg interface index\n");
15119 /* Construct the API message */
15120 M (PG_CREATE_INTERFACE, pg_create_interface);
15122 mp->interface_id = ntohl (if_id);
15131 api_pg_capture (vat_main_t * vam)
15133 unformat_input_t *input = vam->input;
15134 vl_api_pg_capture_t *mp;
15140 u8 pcap_file_set = 0;
15142 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15144 if (unformat (input, "if_id %d", &if_id))
15146 else if (unformat (input, "pcap %s", &pcap_file))
15148 else if (unformat (input, "count %d", &count))
15150 else if (unformat (input, "disable"))
15157 errmsg ("missing pg interface index\n");
15160 if (pcap_file_set > 0)
15162 if (vec_len (pcap_file) > 255)
15164 errmsg ("pcap file name is too long\n");
15169 u32 name_len = vec_len (pcap_file);
15170 /* Construct the API message */
15171 M (PG_CAPTURE, pg_capture);
15173 mp->interface_id = ntohl (if_id);
15174 mp->is_enabled = enable;
15175 mp->count = ntohl (count);
15176 mp->pcap_name_length = ntohl (name_len);
15177 if (pcap_file_set != 0)
15179 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
15181 vec_free (pcap_file);
15190 api_pg_enable_disable (vat_main_t * vam)
15192 unformat_input_t *input = vam->input;
15193 vl_api_pg_enable_disable_t *mp;
15197 u8 stream_name_set = 0;
15198 u8 *stream_name = 0;
15199 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15201 if (unformat (input, "stream %s", &stream_name))
15202 stream_name_set = 1;
15203 else if (unformat (input, "disable"))
15209 if (stream_name_set > 0)
15211 if (vec_len (stream_name) > 255)
15213 errmsg ("stream name too long\n");
15218 u32 name_len = vec_len (stream_name);
15219 /* Construct the API message */
15220 M (PG_ENABLE_DISABLE, pg_enable_disable);
15222 mp->is_enabled = enable;
15223 if (stream_name_set != 0)
15225 mp->stream_name_length = ntohl (name_len);
15226 clib_memcpy (mp->stream_name, stream_name, name_len);
15228 vec_free (stream_name);
15237 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
15239 unformat_input_t *input = vam->input;
15240 vl_api_ip_source_and_port_range_check_add_del_t *mp;
15243 u16 *low_ports = 0;
15244 u16 *high_ports = 0;
15247 ip4_address_t ip4_addr;
15248 ip6_address_t ip6_addr;
15256 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15258 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
15264 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
15269 else if (unformat (input, "vrf %d", &vrf_id))
15271 else if (unformat (input, "del"))
15273 else if (unformat (input, "port %d", &tmp))
15275 if (tmp == 0 || tmp > 65535)
15277 errmsg ("port %d out of range", tmp);
15281 this_hi = this_low + 1;
15282 vec_add1 (low_ports, this_low);
15283 vec_add1 (high_ports, this_hi);
15285 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
15287 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
15289 errmsg ("incorrect range parameters\n");
15293 /* Note: in debug CLI +1 is added to high before
15294 passing to real fn that does "the work"
15295 (ip_source_and_port_range_check_add_del).
15296 This fn is a wrapper around the binary API fn a
15297 control plane will call, which expects this increment
15298 to have occurred. Hence letting the binary API control
15299 plane fn do the increment for consistency between VAT
15300 and other control planes.
15303 vec_add1 (low_ports, this_low);
15304 vec_add1 (high_ports, this_hi);
15310 if (prefix_set == 0)
15312 errmsg ("<address>/<mask> not specified\n");
15318 errmsg ("VRF ID required, not specified\n");
15325 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
15329 if (vec_len (low_ports) == 0)
15331 errmsg ("At least one port or port range required\n");
15335 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,
15336 ip_source_and_port_range_check_add_del);
15338 mp->is_add = is_add;
15343 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
15348 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
15351 mp->mask_length = length;
15352 mp->number_of_ranges = vec_len (low_ports);
15354 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
15355 vec_free (low_ports);
15357 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
15358 vec_free (high_ports);
15360 mp->vrf_id = ntohl (vrf_id);
15369 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
15371 unformat_input_t *input = vam->input;
15372 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
15374 u32 sw_if_index = ~0;
15376 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
15377 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
15380 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15382 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
15384 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15386 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
15388 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
15390 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
15392 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
15394 else if (unformat (input, "del"))
15400 if (sw_if_index == ~0)
15402 errmsg ("Interface required but not specified\n");
15408 errmsg ("VRF ID required but not specified\n");
15412 if (tcp_out_vrf_id == 0
15413 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
15416 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
15420 /* Construct the API message */
15421 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,
15422 ip_source_and_port_range_check_interface_add_del);
15424 mp->sw_if_index = ntohl (sw_if_index);
15425 mp->is_add = is_add;
15426 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
15427 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
15428 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
15429 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
15434 /* Wait for a reply... */
15439 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
15441 unformat_input_t *i = vam->input;
15442 vl_api_ipsec_gre_add_del_tunnel_t *mp;
15444 u32 local_sa_id = 0;
15445 u32 remote_sa_id = 0;
15446 ip4_address_t src_address;
15447 ip4_address_t dst_address;
15450 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15452 if (unformat (i, "local_sa %d", &local_sa_id))
15454 else if (unformat (i, "remote_sa %d", &remote_sa_id))
15456 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
15458 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
15460 else if (unformat (i, "del"))
15464 clib_warning ("parse error '%U'", format_unformat_error, i);
15469 M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel);
15471 mp->local_sa_id = ntohl (local_sa_id);
15472 mp->remote_sa_id = ntohl (remote_sa_id);
15473 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
15474 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
15475 mp->is_add = is_add;
15484 api_punt (vat_main_t * vam)
15486 unformat_input_t *i = vam->input;
15494 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15496 if (unformat (i, "ip %d", &ipv))
15498 else if (unformat (i, "protocol %d", &protocol))
15500 else if (unformat (i, "port %d", &port))
15502 else if (unformat (i, "del"))
15506 clib_warning ("parse error '%U'", format_unformat_error, i);
15513 mp->is_add = (u8) is_add;
15514 mp->ipv = (u8) ipv;
15515 mp->l4_protocol = (u8) protocol;
15516 mp->l4_port = htons ((u16) port);
15524 static void vl_api_ipsec_gre_tunnel_details_t_handler
15525 (vl_api_ipsec_gre_tunnel_details_t * mp)
15527 vat_main_t *vam = &vat_main;
15529 fformat (vam->ofp, "%11d%15U%15U%14d%14d\n",
15530 ntohl (mp->sw_if_index),
15531 format_ip4_address, &mp->src_address,
15532 format_ip4_address, &mp->dst_address,
15533 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
15536 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
15537 (vl_api_ipsec_gre_tunnel_details_t * mp)
15539 vat_main_t *vam = &vat_main;
15540 vat_json_node_t *node = NULL;
15541 struct in_addr ip4;
15543 if (VAT_JSON_ARRAY != vam->json_tree.type)
15545 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15546 vat_json_init_array (&vam->json_tree);
15548 node = vat_json_array_add (&vam->json_tree);
15550 vat_json_init_object (node);
15551 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15552 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
15553 vat_json_object_add_ip4 (node, "src_address", ip4);
15554 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
15555 vat_json_object_add_ip4 (node, "dst_address", ip4);
15556 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
15557 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
15561 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
15563 unformat_input_t *i = vam->input;
15564 vl_api_ipsec_gre_tunnel_dump_t *mp;
15567 u8 sw_if_index_set = 0;
15569 /* Parse args required to build the message */
15570 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15572 if (unformat (i, "sw_if_index %d", &sw_if_index))
15573 sw_if_index_set = 1;
15578 if (sw_if_index_set == 0)
15583 if (!vam->json_output)
15585 fformat (vam->ofp, "%11s%15s%15s%14s%14s\n",
15586 "sw_if_index", "src_address", "dst_address",
15587 "local_sa_id", "remote_sa_id");
15590 /* Get list of gre-tunnel interfaces */
15591 M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump);
15593 mp->sw_if_index = htonl (sw_if_index);
15597 /* Use a control ping for synchronization */
15599 vl_api_control_ping_t *mp;
15600 M (CONTROL_PING, control_ping);
15607 api_delete_subif (vat_main_t * vam)
15609 unformat_input_t *i = vam->input;
15610 vl_api_delete_subif_t *mp;
15612 u32 sw_if_index = ~0;
15614 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15616 if (unformat (i, "sw_if_index %d", &sw_if_index))
15622 if (sw_if_index == ~0)
15624 errmsg ("missing sw_if_index\n");
15628 /* Construct the API message */
15629 M (DELETE_SUBIF, delete_subif);
15630 mp->sw_if_index = ntohl (sw_if_index);
15636 #define foreach_pbb_vtr_op \
15637 _("disable", L2_VTR_DISABLED) \
15638 _("pop", L2_VTR_POP_2) \
15639 _("push", L2_VTR_PUSH_2)
15642 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
15644 unformat_input_t *i = vam->input;
15645 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
15647 u32 sw_if_index = ~0, vtr_op = ~0;
15648 u16 outer_tag = ~0;
15649 u8 dmac[6], smac[6];
15650 u8 dmac_set = 0, smac_set = 0;
15655 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15657 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
15659 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15661 else if (unformat (i, "vtr_op %d", &vtr_op))
15663 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
15666 else if (unformat (i, "translate_pbb_stag"))
15668 if (unformat (i, "%d", &tmp))
15670 vtr_op = L2_VTR_TRANSLATE_2_1;
15676 ("translate_pbb_stag operation requires outer tag definition\n");
15680 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
15682 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
15684 else if (unformat (i, "sid %d", &sid))
15686 else if (unformat (i, "vlanid %d", &tmp))
15690 clib_warning ("parse error '%U'", format_unformat_error, i);
15695 if ((sw_if_index == ~0) || (vtr_op == ~0))
15697 errmsg ("missing sw_if_index or vtr operation\n");
15700 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
15701 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
15704 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid\n");
15708 M (L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite);
15709 mp->sw_if_index = ntohl (sw_if_index);
15710 mp->vtr_op = ntohl (vtr_op);
15711 mp->outer_tag = ntohs (outer_tag);
15712 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
15713 clib_memcpy (mp->b_smac, smac, sizeof (smac));
15714 mp->b_vlanid = ntohs (vlanid);
15715 mp->i_sid = ntohl (sid);
15724 api_flow_classify_set_interface (vat_main_t * vam)
15726 unformat_input_t *i = vam->input;
15727 vl_api_flow_classify_set_interface_t *mp;
15730 int sw_if_index_set;
15731 u32 ip4_table_index = ~0;
15732 u32 ip6_table_index = ~0;
15735 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15737 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
15738 sw_if_index_set = 1;
15739 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15740 sw_if_index_set = 1;
15741 else if (unformat (i, "del"))
15743 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15745 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15749 clib_warning ("parse error '%U'", format_unformat_error, i);
15754 if (sw_if_index_set == 0)
15756 errmsg ("missing interface name or sw_if_index\n");
15760 M (FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface);
15762 mp->sw_if_index = ntohl (sw_if_index);
15763 mp->ip4_table_index = ntohl (ip4_table_index);
15764 mp->ip6_table_index = ntohl (ip6_table_index);
15765 mp->is_add = is_add;
15774 api_flow_classify_dump (vat_main_t * vam)
15776 unformat_input_t *i = vam->input;
15777 vl_api_flow_classify_dump_t *mp;
15779 u8 type = FLOW_CLASSIFY_N_TABLES;
15781 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
15785 errmsg ("classify table type must be specified\n");
15789 if (!vam->json_output)
15791 fformat (vam->ofp, "%10s%20s\n", "Intfc idx", "Classify table");
15794 M (FLOW_CLASSIFY_DUMP, flow_classify_dump);
15799 /* Use a control ping for synchronization */
15801 vl_api_control_ping_t *mp;
15802 M (CONTROL_PING, control_ping);
15805 /* Wait for a reply... */
15813 q_or_quit (vat_main_t * vam)
15815 longjmp (vam->jump_buf, 1);
15816 return 0; /* not so much */
15820 q (vat_main_t * vam)
15822 return q_or_quit (vam);
15826 quit (vat_main_t * vam)
15828 return q_or_quit (vam);
15832 comment (vat_main_t * vam)
15838 cmd_cmp (void *a1, void *a2)
15843 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
15847 help (vat_main_t * vam)
15852 unformat_input_t *i = vam->input;
15855 if (unformat (i, "%s", &name))
15859 vec_add1 (name, 0);
15861 hs = hash_get_mem (vam->help_by_name, name);
15863 fformat (vam->ofp, "usage: %s %s\n", name, hs[0]);
15865 fformat (vam->ofp, "No such msg / command '%s'\n", name);
15870 fformat (vam->ofp, "Help is available for the following:\n");
15873 hash_foreach_pair (p, vam->function_by_name,
15875 vec_add1 (cmds, (u8 *)(p->key));
15879 vec_sort_with_function (cmds, cmd_cmp);
15881 for (j = 0; j < vec_len (cmds); j++)
15882 fformat (vam->ofp, "%s\n", cmds[j]);
15889 set (vat_main_t * vam)
15891 u8 *name = 0, *value = 0;
15892 unformat_input_t *i = vam->input;
15894 if (unformat (i, "%s", &name))
15896 /* The input buffer is a vector, not a string. */
15897 value = vec_dup (i->buffer);
15898 vec_delete (value, i->index, 0);
15899 /* Almost certainly has a trailing newline */
15900 if (value[vec_len (value) - 1] == '\n')
15901 value[vec_len (value) - 1] = 0;
15902 /* Make sure it's a proper string, one way or the other */
15903 vec_add1 (value, 0);
15904 (void) clib_macro_set_value (&vam->macro_main,
15905 (char *) name, (char *) value);
15908 errmsg ("usage: set <name> <value>\n");
15916 unset (vat_main_t * vam)
15920 if (unformat (vam->input, "%s", &name))
15921 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
15922 errmsg ("unset: %s wasn't set\n", name);
15935 macro_sort_cmp (void *a1, void *a2)
15937 macro_sort_t *s1 = a1;
15938 macro_sort_t *s2 = a2;
15940 return strcmp ((char *) (s1->name), (char *) (s2->name));
15944 dump_macro_table (vat_main_t * vam)
15946 macro_sort_t *sort_me = 0, *sm;
15951 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
15953 vec_add2 (sort_me, sm, 1);
15954 sm->name = (u8 *)(p->key);
15955 sm->value = (u8 *) (p->value[0]);
15959 vec_sort_with_function (sort_me, macro_sort_cmp);
15961 if (vec_len (sort_me))
15962 fformat (vam->ofp, "%-15s%s\n", "Name", "Value");
15964 fformat (vam->ofp, "The macro table is empty...\n");
15966 for (i = 0; i < vec_len (sort_me); i++)
15967 fformat (vam->ofp, "%-15s%s\n", sort_me[i].name, sort_me[i].value);
15972 dump_node_table (vat_main_t * vam)
15975 vlib_node_t *node, *next_node;
15977 if (vec_len (vam->graph_nodes) == 0)
15979 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
15983 for (i = 0; i < vec_len (vam->graph_nodes); i++)
15985 node = vam->graph_nodes[i];
15986 fformat (vam->ofp, "[%d] %s\n", i, node->name);
15987 for (j = 0; j < vec_len (node->next_nodes); j++)
15989 if (node->next_nodes[j] != ~0)
15991 next_node = vam->graph_nodes[node->next_nodes[j]];
15992 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
16000 search_node_table (vat_main_t * vam)
16002 unformat_input_t *line_input = vam->input;
16005 vlib_node_t *node, *next_node;
16008 if (vam->graph_node_index_by_name == 0)
16010 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
16014 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16016 if (unformat (line_input, "%s", &node_to_find))
16018 vec_add1 (node_to_find, 0);
16019 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
16022 fformat (vam->ofp, "%s not found...\n", node_to_find);
16025 node = vam->graph_nodes[p[0]];
16026 fformat (vam->ofp, "[%d] %s\n", p[0], node->name);
16027 for (j = 0; j < vec_len (node->next_nodes); j++)
16029 if (node->next_nodes[j] != ~0)
16031 next_node = vam->graph_nodes[node->next_nodes[j]];
16032 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
16039 clib_warning ("parse error '%U'", format_unformat_error,
16045 vec_free (node_to_find);
16054 script (vat_main_t * vam)
16057 char *save_current_file;
16058 unformat_input_t save_input;
16059 jmp_buf save_jump_buf;
16060 u32 save_line_number;
16062 FILE *new_fp, *save_ifp;
16064 if (unformat (vam->input, "%s", &s))
16066 new_fp = fopen ((char *) s, "r");
16069 errmsg ("Couldn't open script file %s\n", s);
16076 errmsg ("Missing script name\n");
16080 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
16081 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
16082 save_ifp = vam->ifp;
16083 save_line_number = vam->input_line_number;
16084 save_current_file = (char *) vam->current_file;
16086 vam->input_line_number = 0;
16088 vam->current_file = s;
16091 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
16092 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
16093 vam->ifp = save_ifp;
16094 vam->input_line_number = save_line_number;
16095 vam->current_file = (u8 *) save_current_file;
16102 echo (vat_main_t * vam)
16104 fformat (vam->ofp, "%v", vam->input->buffer);
16108 /* List of API message constructors, CLI names map to api_xxx */
16109 #define foreach_vpe_api_msg \
16110 _(create_loopback,"[mac <mac-addr>]") \
16111 _(sw_interface_dump,"") \
16112 _(sw_interface_set_flags, \
16113 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
16114 _(sw_interface_add_del_address, \
16115 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
16116 _(sw_interface_set_table, \
16117 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
16118 _(sw_interface_set_vpath, \
16119 "<intfc> | sw_if_index <id> enable | disable") \
16120 _(sw_interface_set_l2_xconnect, \
16121 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
16122 "enable | disable") \
16123 _(sw_interface_set_l2_bridge, \
16124 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
16125 "[shg <split-horizon-group>] [bvi]\n" \
16126 "enable | disable") \
16127 _(sw_interface_set_dpdk_hqos_pipe, \
16128 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
16129 "profile <profile-id>\n") \
16130 _(sw_interface_set_dpdk_hqos_subport, \
16131 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
16132 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
16133 _(sw_interface_set_dpdk_hqos_tctbl, \
16134 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n") \
16135 _(bridge_domain_add_del, \
16136 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n")\
16137 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
16139 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
16141 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
16143 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
16145 "tapname <name> mac <mac-addr> | random-mac") \
16147 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
16149 "<vpp-if-name> | sw_if_index <id>") \
16150 _(sw_interface_tap_dump, "") \
16151 _(ip_add_del_route, \
16152 "<addr>/<mask> via <addr> [vrf <n>]\n" \
16153 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
16154 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
16155 "[multipath] [count <n>]") \
16156 _(proxy_arp_add_del, \
16157 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
16158 _(proxy_arp_intfc_enable_disable, \
16159 "<intfc> | sw_if_index <id> enable | disable") \
16160 _(mpls_add_del_encap, \
16161 "label <n> dst <ip4-addr> [vrf <n>] [del]") \
16162 _(mpls_add_del_decap, \
16163 "label <n> [rx_vrf_id <n>] [tx_vrf_id] [s-bit-clear][del]") \
16164 _(mpls_gre_add_del_tunnel, \
16165 "inner_vrf_id <n> outer_vrf_id <n> src <ip4-address> dst <ip4-address>\n" \
16166 "adj <ip4-address>/<mask-width> [del]") \
16167 _(sw_interface_set_unnumbered, \
16168 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
16169 _(ip_neighbor_add_del, \
16170 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
16171 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
16172 _(reset_vrf, "vrf <id> [ipv6]") \
16173 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
16174 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
16175 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
16176 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
16177 "[outer_vlan_id_any][inner_vlan_id_any]") \
16178 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
16179 _(reset_fib, "vrf <n> [ipv6]") \
16180 _(dhcp_proxy_config, \
16181 "svr <v46-address> src <v46-address>\n" \
16182 "insert-cid <n> [del]") \
16183 _(dhcp_proxy_config_2, \
16184 "svr <v46-address> src <v46-address>\n" \
16185 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
16186 _(dhcp_proxy_set_vss, \
16187 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
16188 _(dhcp_client_config, \
16189 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
16190 _(set_ip_flow_hash, \
16191 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
16192 _(sw_interface_ip6_enable_disable, \
16193 "<intfc> | sw_if_index <id> enable | disable") \
16194 _(sw_interface_ip6_set_link_local_address, \
16195 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
16196 _(sw_interface_ip6nd_ra_prefix, \
16197 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
16198 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
16199 "[nolink] [isno]") \
16200 _(sw_interface_ip6nd_ra_config, \
16201 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
16202 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
16203 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
16204 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
16205 _(l2_patch_add_del, \
16206 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
16207 "enable | disable") \
16208 _(mpls_ethernet_add_del_tunnel, \
16209 "tx <intfc> | tx_sw_if_index <n> dst <mac-addr>\n" \
16210 "adj <ip4-addr>/<mw> dst <mac-addr> [del]") \
16211 _(mpls_ethernet_add_del_tunnel_2, \
16212 "inner_vrf_id <n> outer_vrf_id <n> next-hop <ip4-addr>\n" \
16213 "resolve-attempts <n> resolve-if-needed 0 | 1 [del]") \
16214 _(sr_tunnel_add_del, \
16215 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
16216 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
16217 "[policy <policy_name>]") \
16218 _(sr_policy_add_del, \
16219 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
16220 _(sr_multicast_map_add_del, \
16221 "address [ip6 multicast address] sr-policy [policy name] [del]") \
16222 _(classify_add_del_table, \
16223 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
16224 "[del] mask <mask-value>\n" \
16225 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>") \
16226 _(classify_add_del_session, \
16227 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
16228 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
16229 " [l3 [ip4|ip6]]") \
16230 _(classify_set_interface_ip_table, \
16231 "<intfc> | sw_if_index <nn> table <nn>") \
16232 _(classify_set_interface_l2_tables, \
16233 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
16234 " [other-table <nn>]") \
16235 _(get_node_index, "node <node-name") \
16236 _(add_node_next, "node <node-name> next <next-node-name>") \
16237 _(l2tpv3_create_tunnel, \
16238 "client_address <ip6-addr> our_address <ip6-addr>\n" \
16239 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n"\
16240 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
16241 _(l2tpv3_set_tunnel_cookies, \
16242 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
16243 "[new_remote_cookie <nn>]\n") \
16244 _(l2tpv3_interface_enable_disable, \
16245 "<intfc> | sw_if_index <nn> enable | disable") \
16246 _(l2tpv3_set_lookup_key, \
16247 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
16248 _(sw_if_l2tpv3_tunnel_dump, "") \
16249 _(vxlan_add_del_tunnel, \
16250 "src <ip-addr> dst <ip-addr> vni <vni> [encap-vrf-id <nn>]\n" \
16251 " [decap-next l2|ip4|ip6] [del]") \
16252 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
16253 _(gre_add_del_tunnel, \
16254 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
16255 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
16256 _(l2_fib_clear_table, "") \
16257 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
16258 _(l2_interface_vlan_tag_rewrite, \
16259 "<intfc> | sw_if_index <nn> \n" \
16260 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
16261 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
16262 _(create_vhost_user_if, \
16263 "socket <filename> [server] [renumber <dev_instance>] " \
16264 "[mac <mac_address>]") \
16265 _(modify_vhost_user_if, \
16266 "<intfc> | sw_if_index <nn> socket <filename>\n" \
16267 "[server] [renumber <dev_instance>]") \
16268 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
16269 _(sw_interface_vhost_user_dump, "") \
16270 _(show_version, "") \
16271 _(vxlan_gpe_add_del_tunnel, \
16272 "local <addr> remote <addr> vni <nn>\n" \
16273 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
16274 "[next-ethernet] [next-nsh]\n") \
16275 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
16276 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
16277 _(interface_name_renumber, \
16278 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
16279 _(input_acl_set_interface, \
16280 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
16281 " [l2-table <nn>] [del]") \
16282 _(want_ip4_arp_events, "address <ip4-address> [del]") \
16283 _(want_ip6_nd_events, "address <ip6-address> [del]") \
16284 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
16285 _(ip_dump, "ipv4 | ipv6") \
16286 _(ipsec_spd_add_del, "spd_id <n> [del]") \
16287 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
16289 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
16290 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
16291 " integ_alg <alg> integ_key <hex>") \
16292 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
16293 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
16294 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
16295 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" )\
16296 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
16297 _(ikev2_profile_add_del, "name <profile_name> [del]") \
16298 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
16299 "(auth_data 0x<data> | auth_data <data>)") \
16300 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
16301 "(id_data 0x<data> | id_data <data>) (local|remote)") \
16302 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
16303 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
16304 "(local|remote)") \
16305 _(ikev2_set_local_key, "file <absolute_file_path>") \
16306 _(delete_loopback,"sw_if_index <nn>") \
16307 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
16308 _(map_add_domain, \
16309 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
16310 "ip6-src <ip6addr> " \
16311 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
16312 _(map_del_domain, "index <n>") \
16313 _(map_add_del_rule, \
16314 "index <n> psid <n> dst <ip6addr> [del]") \
16315 _(map_domain_dump, "") \
16316 _(map_rule_dump, "index <map-domain>") \
16317 _(want_interface_events, "enable|disable") \
16318 _(want_stats,"enable|disable") \
16319 _(get_first_msg_id, "client <name>") \
16320 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
16321 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
16322 "fib-id <nn> [ip4][ip6][default]") \
16323 _(get_node_graph, " ") \
16324 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
16325 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
16326 _(ioam_disable, "") \
16327 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
16328 " sw_if_index <sw_if_index> p <priority> " \
16329 "w <weight>] [del]") \
16330 _(lisp_add_del_locator, "locator-set <locator_name> " \
16331 "iface <intf> | sw_if_index <sw_if_index> " \
16332 "p <priority> w <weight> [del]") \
16333 _(lisp_add_del_local_eid,"vni <vni> eid " \
16334 "<ipv4|ipv6>/<prefix> | <L2 address> " \
16335 "locator-set <locator_name> [del]") \
16336 _(lisp_gpe_add_del_fwd_entry, "rmt_eid <eid> [lcl_eid <eid>] vni <vni>" \
16337 "dp_table <table> loc-pair <lcl_loc> <rmt_loc> ... [del]") \
16338 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
16339 _(lisp_gpe_enable_disable, "enable|disable") \
16340 _(lisp_enable_disable, "enable|disable") \
16341 _(lisp_gpe_add_del_iface, "up|down") \
16342 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
16344 "rloc <locator> p <prio> " \
16345 "w <weight> [rloc <loc> ... ] " \
16346 "action <action> [del-all]") \
16347 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
16349 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
16350 _(lisp_map_request_mode, "src-dst|dst-only") \
16351 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
16352 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
16353 _(lisp_locator_set_dump, "[local | remote]") \
16354 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
16355 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
16356 "[local] | [remote]") \
16357 _(lisp_eid_table_vni_dump, "") \
16358 _(lisp_eid_table_map_dump, "l2|l3") \
16359 _(lisp_gpe_tunnel_dump, "") \
16360 _(lisp_map_resolver_dump, "") \
16361 _(lisp_adjacencies_get, "vni <vni>") \
16362 _(show_lisp_status, "") \
16363 _(lisp_get_map_request_itr_rlocs, "") \
16364 _(show_lisp_pitr, "") \
16365 _(show_lisp_map_request_mode, "") \
16366 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
16367 _(af_packet_delete, "name <host interface name>") \
16368 _(policer_add_del, "name <policer name> <params> [del]") \
16369 _(policer_dump, "[name <policer name>]") \
16370 _(policer_classify_set_interface, \
16371 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
16372 " [l2-table <nn>] [del]") \
16373 _(policer_classify_dump, "type [ip4|ip6|l2]") \
16374 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
16375 "[master|slave]") \
16376 _(netmap_delete, "name <interface name>") \
16377 _(mpls_gre_tunnel_dump, "tunnel_index <tunnel-id>") \
16378 _(mpls_eth_tunnel_dump, "tunnel_index <tunnel-id>") \
16379 _(mpls_fib_encap_dump, "") \
16380 _(mpls_fib_decap_dump, "") \
16381 _(classify_table_ids, "") \
16382 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
16383 _(classify_table_info, "table_id <nn>") \
16384 _(classify_session_dump, "table_id <nn>") \
16385 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
16386 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
16387 "[template_interval <nn>] [udp_checksum]") \
16388 _(ipfix_exporter_dump, "") \
16389 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
16390 _(ipfix_classify_stream_dump, "") \
16391 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]")\
16392 _(ipfix_classify_table_dump, "") \
16393 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
16394 _(pg_create_interface, "if_id <nn>") \
16395 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
16396 _(pg_enable_disable, "[stream <id>] disable") \
16397 _(ip_source_and_port_range_check_add_del, \
16398 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
16399 _(ip_source_and_port_range_check_interface_add_del, \
16400 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
16401 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
16402 _(ipsec_gre_add_del_tunnel, \
16403 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
16404 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
16405 _(delete_subif,"sub_sw_if_index <nn> sub_if_id <nn>") \
16406 _(l2_interface_pbb_tag_rewrite, \
16407 "<intfc> | sw_if_index <nn> \n" \
16408 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
16409 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
16410 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
16411 _(flow_classify_set_interface, \
16412 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
16413 _(flow_classify_dump, "type [ip4|ip6]")
16415 /* List of command functions, CLI names map directly to functions */
16416 #define foreach_cli_function \
16417 _(comment, "usage: comment <ignore-rest-of-line>") \
16418 _(dump_interface_table, "usage: dump_interface_table") \
16419 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
16420 _(dump_ipv4_table, "usage: dump_ipv4_table") \
16421 _(dump_ipv6_table, "usage: dump_ipv6_table") \
16422 _(dump_stats_table, "usage: dump_stats_table") \
16423 _(dump_macro_table, "usage: dump_macro_table ") \
16424 _(dump_node_table, "usage: dump_node_table") \
16425 _(echo, "usage: echo <message>") \
16426 _(exec, "usage: exec <vpe-debug-CLI-command>") \
16427 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
16428 _(help, "usage: help") \
16429 _(q, "usage: quit") \
16430 _(quit, "usage: quit") \
16431 _(search_node_table, "usage: search_node_table <name>...") \
16432 _(set, "usage: set <variable-name> <value>") \
16433 _(script, "usage: script <file-name>") \
16434 _(unset, "usage: unset <variable-name>")
16437 static void vl_api_##n##_t_handler_uni \
16438 (vl_api_##n##_t * mp) \
16440 vat_main_t * vam = &vat_main; \
16441 if (vam->json_output) { \
16442 vl_api_##n##_t_handler_json(mp); \
16444 vl_api_##n##_t_handler(mp); \
16447 foreach_vpe_api_reply_msg;
16451 vat_api_hookup (vat_main_t * vam)
16454 vl_msg_api_set_handlers(VL_API_##N, #n, \
16455 vl_api_##n##_t_handler_uni, \
16457 vl_api_##n##_t_endian, \
16458 vl_api_##n##_t_print, \
16459 sizeof(vl_api_##n##_t), 1);
16460 foreach_vpe_api_reply_msg;
16463 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
16465 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
16467 vam->function_by_name = hash_create_string (0, sizeof (uword));
16469 vam->help_by_name = hash_create_string (0, sizeof (uword));
16471 /* API messages we can send */
16472 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
16473 foreach_vpe_api_msg;
16477 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
16478 foreach_vpe_api_msg;
16481 /* CLI functions */
16482 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
16483 foreach_cli_function;
16487 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
16488 foreach_cli_function;
16492 #undef vl_api_version
16493 #define vl_api_version(n,v) static u32 vpe_api_version = v;
16494 #include <vpp-api/vpe.api.h>
16495 #undef vl_api_version
16498 vl_client_add_api_signatures (vl_api_memclnt_create_t * mp)
16501 * Send the main API signature in slot 0. This bit of code must
16502 * match the checks in ../vpe/api/api.c: vl_msg_api_version_check().
16504 mp->api_versions[0] = clib_host_to_net_u32 (vpe_api_version);
16508 * fd.io coding-style-patch-verification: ON
16511 * eval: (c-set-style "gnu")