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_map_resolver_details_t_handler (vl_api_lisp_map_resolver_details_t
2609 vat_main_t *vam = &vat_main;
2611 fformat (vam->ofp, "%=20U\n",
2612 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2617 vl_api_lisp_map_resolver_details_t_handler_json
2618 (vl_api_lisp_map_resolver_details_t * mp)
2620 vat_main_t *vam = &vat_main;
2621 vat_json_node_t *node = NULL;
2622 struct in6_addr ip6;
2625 if (VAT_JSON_ARRAY != vam->json_tree.type)
2627 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2628 vat_json_init_array (&vam->json_tree);
2630 node = vat_json_array_add (&vam->json_tree);
2632 vat_json_init_object (node);
2635 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2636 vat_json_object_add_ip6 (node, "map resolver", ip6);
2640 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2641 vat_json_object_add_ip4 (node, "map resolver", ip4);
2646 vl_api_show_lisp_status_reply_t_handler
2647 (vl_api_show_lisp_status_reply_t * mp)
2649 vat_main_t *vam = &vat_main;
2650 i32 retval = ntohl (mp->retval);
2654 fformat (vam->ofp, "feature: %s\ngpe: %s\n",
2655 mp->feature_status ? "enabled" : "disabled",
2656 mp->gpe_status ? "enabled" : "disabled");
2659 vam->retval = retval;
2660 vam->result_ready = 1;
2664 vl_api_show_lisp_status_reply_t_handler_json
2665 (vl_api_show_lisp_status_reply_t * mp)
2667 vat_main_t *vam = &vat_main;
2668 vat_json_node_t node;
2669 u8 *gpe_status = NULL;
2670 u8 *feature_status = NULL;
2672 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
2673 feature_status = format (0, "%s",
2674 mp->feature_status ? "enabled" : "disabled");
2675 vec_add1 (gpe_status, 0);
2676 vec_add1 (feature_status, 0);
2678 vat_json_init_object (&node);
2679 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
2680 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
2682 vec_free (gpe_status);
2683 vec_free (feature_status);
2685 vat_json_print (vam->ofp, &node);
2686 vat_json_free (&node);
2688 vam->retval = ntohl (mp->retval);
2689 vam->result_ready = 1;
2693 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler
2694 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2696 vat_main_t *vam = &vat_main;
2697 i32 retval = ntohl (mp->retval);
2701 fformat (vam->ofp, "%=20s\n", mp->locator_set_name);
2704 vam->retval = retval;
2705 vam->result_ready = 1;
2709 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler_json
2710 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2712 vat_main_t *vam = &vat_main;
2713 vat_json_node_t *node = NULL;
2715 if (VAT_JSON_ARRAY != vam->json_tree.type)
2717 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2718 vat_json_init_array (&vam->json_tree);
2720 node = vat_json_array_add (&vam->json_tree);
2722 vat_json_init_object (node);
2723 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
2725 vat_json_print (vam->ofp, node);
2726 vat_json_free (node);
2728 vam->retval = ntohl (mp->retval);
2729 vam->result_ready = 1;
2733 format_lisp_map_request_mode (u8 * s, va_list * args)
2735 u32 mode = va_arg (*args, u32);
2740 return format (0, "dst-only");
2742 return format (0, "src-dst");
2748 vl_api_show_lisp_map_request_mode_reply_t_handler
2749 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2751 vat_main_t *vam = &vat_main;
2752 i32 retval = ntohl (mp->retval);
2756 u32 mode = mp->mode;
2757 fformat (vam->ofp, "map_request_mode: %U\n",
2758 format_lisp_map_request_mode, mode);
2761 vam->retval = retval;
2762 vam->result_ready = 1;
2766 vl_api_show_lisp_map_request_mode_reply_t_handler_json
2767 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2769 vat_main_t *vam = &vat_main;
2770 vat_json_node_t node;
2775 s = format (0, "%U", format_lisp_map_request_mode, mode);
2778 vat_json_init_object (&node);
2779 vat_json_object_add_string_copy (&node, "map_request_mode", s);
2780 vat_json_print (vam->ofp, &node);
2781 vat_json_free (&node);
2784 vam->retval = ntohl (mp->retval);
2785 vam->result_ready = 1;
2789 vl_api_show_lisp_pitr_reply_t_handler (vl_api_show_lisp_pitr_reply_t * mp)
2791 vat_main_t *vam = &vat_main;
2792 i32 retval = ntohl (mp->retval);
2796 fformat (vam->ofp, "%-20s%-16s\n",
2797 mp->status ? "enabled" : "disabled",
2798 mp->status ? (char *) mp->locator_set_name : "");
2801 vam->retval = retval;
2802 vam->result_ready = 1;
2806 vl_api_show_lisp_pitr_reply_t_handler_json (vl_api_show_lisp_pitr_reply_t *
2809 vat_main_t *vam = &vat_main;
2810 vat_json_node_t node;
2813 status = format (0, "%s", mp->status ? "enabled" : "disabled");
2814 vec_add1 (status, 0);
2816 vat_json_init_object (&node);
2817 vat_json_object_add_string_copy (&node, "status", status);
2820 vat_json_object_add_string_copy (&node, "locator_set",
2821 mp->locator_set_name);
2826 vat_json_print (vam->ofp, &node);
2827 vat_json_free (&node);
2829 vam->retval = ntohl (mp->retval);
2830 vam->result_ready = 1;
2834 format_policer_type (u8 * s, va_list * va)
2836 u32 i = va_arg (*va, u32);
2838 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
2839 s = format (s, "1r2c");
2840 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
2841 s = format (s, "1r3c");
2842 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
2843 s = format (s, "2r3c-2698");
2844 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
2845 s = format (s, "2r3c-4115");
2846 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
2847 s = format (s, "2r3c-mef5cf1");
2849 s = format (s, "ILLEGAL");
2854 format_policer_rate_type (u8 * s, va_list * va)
2856 u32 i = va_arg (*va, u32);
2858 if (i == SSE2_QOS_RATE_KBPS)
2859 s = format (s, "kbps");
2860 else if (i == SSE2_QOS_RATE_PPS)
2861 s = format (s, "pps");
2863 s = format (s, "ILLEGAL");
2868 format_policer_round_type (u8 * s, va_list * va)
2870 u32 i = va_arg (*va, u32);
2872 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
2873 s = format (s, "closest");
2874 else if (i == SSE2_QOS_ROUND_TO_UP)
2875 s = format (s, "up");
2876 else if (i == SSE2_QOS_ROUND_TO_DOWN)
2877 s = format (s, "down");
2879 s = format (s, "ILLEGAL");
2884 format_policer_action_type (u8 * s, va_list * va)
2886 u32 i = va_arg (*va, u32);
2888 if (i == SSE2_QOS_ACTION_DROP)
2889 s = format (s, "drop");
2890 else if (i == SSE2_QOS_ACTION_TRANSMIT)
2891 s = format (s, "transmit");
2892 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2893 s = format (s, "mark-and-transmit");
2895 s = format (s, "ILLEGAL");
2900 format_dscp (u8 * s, va_list * va)
2902 u32 i = va_arg (*va, u32);
2907 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
2911 return format (s, "ILLEGAL");
2913 s = format (s, "%s", t);
2918 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
2920 vat_main_t *vam = &vat_main;
2921 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
2923 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2924 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
2926 conform_dscp_str = format (0, "");
2928 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2929 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
2931 exceed_dscp_str = format (0, "");
2933 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2934 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
2936 violate_dscp_str = format (0, "");
2938 fformat (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
2939 "rate type %U, round type %U, %s rate, %s color-aware, "
2940 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
2941 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
2942 "conform action %U%s, exceed action %U%s, violate action %U%s\n",
2944 format_policer_type, mp->type,
2947 clib_net_to_host_u64 (mp->cb),
2948 clib_net_to_host_u64 (mp->eb),
2949 format_policer_rate_type, mp->rate_type,
2950 format_policer_round_type, mp->round_type,
2951 mp->single_rate ? "single" : "dual",
2952 mp->color_aware ? "is" : "not",
2953 ntohl (mp->cir_tokens_per_period),
2954 ntohl (mp->pir_tokens_per_period),
2956 ntohl (mp->current_limit),
2957 ntohl (mp->current_bucket),
2958 ntohl (mp->extended_limit),
2959 ntohl (mp->extended_bucket),
2960 clib_net_to_host_u64 (mp->last_update_time),
2961 format_policer_action_type, mp->conform_action_type,
2963 format_policer_action_type, mp->exceed_action_type,
2965 format_policer_action_type, mp->violate_action_type,
2968 vec_free (conform_dscp_str);
2969 vec_free (exceed_dscp_str);
2970 vec_free (violate_dscp_str);
2973 static void vl_api_policer_details_t_handler_json
2974 (vl_api_policer_details_t * mp)
2976 vat_main_t *vam = &vat_main;
2977 vat_json_node_t *node;
2978 u8 *rate_type_str, *round_type_str, *type_str;
2979 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
2981 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
2983 format (0, "%U", format_policer_round_type, mp->round_type);
2984 type_str = format (0, "%U", format_policer_type, mp->type);
2985 conform_action_str = format (0, "%U", format_policer_action_type,
2986 mp->conform_action_type);
2987 exceed_action_str = format (0, "%U", format_policer_action_type,
2988 mp->exceed_action_type);
2989 violate_action_str = format (0, "%U", format_policer_action_type,
2990 mp->violate_action_type);
2992 if (VAT_JSON_ARRAY != vam->json_tree.type)
2994 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2995 vat_json_init_array (&vam->json_tree);
2997 node = vat_json_array_add (&vam->json_tree);
2999 vat_json_init_object (node);
3000 vat_json_object_add_string_copy (node, "name", mp->name);
3001 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3002 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3003 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3004 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3005 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3006 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3007 vat_json_object_add_string_copy (node, "type", type_str);
3008 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3009 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3010 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3011 vat_json_object_add_uint (node, "cir_tokens_per_period",
3012 ntohl (mp->cir_tokens_per_period));
3013 vat_json_object_add_uint (node, "eir_tokens_per_period",
3014 ntohl (mp->pir_tokens_per_period));
3015 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3016 vat_json_object_add_uint (node, "current_bucket",
3017 ntohl (mp->current_bucket));
3018 vat_json_object_add_uint (node, "extended_limit",
3019 ntohl (mp->extended_limit));
3020 vat_json_object_add_uint (node, "extended_bucket",
3021 ntohl (mp->extended_bucket));
3022 vat_json_object_add_uint (node, "last_update_time",
3023 ntohl (mp->last_update_time));
3024 vat_json_object_add_string_copy (node, "conform_action",
3025 conform_action_str);
3026 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3028 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3029 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3030 vec_free (dscp_str);
3032 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3033 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3035 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3036 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3037 vec_free (dscp_str);
3039 vat_json_object_add_string_copy (node, "violate_action",
3040 violate_action_str);
3041 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3043 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3044 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3045 vec_free (dscp_str);
3048 vec_free (rate_type_str);
3049 vec_free (round_type_str);
3050 vec_free (type_str);
3051 vec_free (conform_action_str);
3052 vec_free (exceed_action_str);
3053 vec_free (violate_action_str);
3057 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3060 vat_main_t *vam = &vat_main;
3061 int i, count = ntohl (mp->count);
3064 fformat (vam->ofp, "classify table ids (%d) : ", count);
3065 for (i = 0; i < count; i++)
3067 fformat (vam->ofp, "%d", ntohl (mp->ids[i]));
3068 fformat (vam->ofp, (i < count - 1) ? "," : "\n");
3070 vam->retval = ntohl (mp->retval);
3071 vam->result_ready = 1;
3075 vl_api_classify_table_ids_reply_t_handler_json
3076 (vl_api_classify_table_ids_reply_t * mp)
3078 vat_main_t *vam = &vat_main;
3079 int i, count = ntohl (mp->count);
3083 vat_json_node_t node;
3085 vat_json_init_object (&node);
3086 for (i = 0; i < count; i++)
3088 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3090 vat_json_print (vam->ofp, &node);
3091 vat_json_free (&node);
3093 vam->retval = ntohl (mp->retval);
3094 vam->result_ready = 1;
3098 vl_api_classify_table_by_interface_reply_t_handler
3099 (vl_api_classify_table_by_interface_reply_t * mp)
3101 vat_main_t *vam = &vat_main;
3104 table_id = ntohl (mp->l2_table_id);
3106 fformat (vam->ofp, "l2 table id : %d\n", table_id);
3108 fformat (vam->ofp, "l2 table id : No input ACL tables configured\n");
3109 table_id = ntohl (mp->ip4_table_id);
3111 fformat (vam->ofp, "ip4 table id : %d\n", table_id);
3113 fformat (vam->ofp, "ip4 table id : No input ACL tables configured\n");
3114 table_id = ntohl (mp->ip6_table_id);
3116 fformat (vam->ofp, "ip6 table id : %d\n", table_id);
3118 fformat (vam->ofp, "ip6 table id : No input ACL tables configured\n");
3119 vam->retval = ntohl (mp->retval);
3120 vam->result_ready = 1;
3124 vl_api_classify_table_by_interface_reply_t_handler_json
3125 (vl_api_classify_table_by_interface_reply_t * mp)
3127 vat_main_t *vam = &vat_main;
3128 vat_json_node_t node;
3130 vat_json_init_object (&node);
3132 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3133 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3134 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3136 vat_json_print (vam->ofp, &node);
3137 vat_json_free (&node);
3139 vam->retval = ntohl (mp->retval);
3140 vam->result_ready = 1;
3143 static void vl_api_policer_add_del_reply_t_handler
3144 (vl_api_policer_add_del_reply_t * mp)
3146 vat_main_t *vam = &vat_main;
3147 i32 retval = ntohl (mp->retval);
3148 if (vam->async_mode)
3150 vam->async_errors += (retval < 0);
3154 vam->retval = retval;
3155 vam->result_ready = 1;
3156 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3158 * Note: this is just barely thread-safe, depends on
3159 * the main thread spinning waiting for an answer...
3161 errmsg ("policer index %d\n", ntohl (mp->policer_index));
3165 static void vl_api_policer_add_del_reply_t_handler_json
3166 (vl_api_policer_add_del_reply_t * mp)
3168 vat_main_t *vam = &vat_main;
3169 vat_json_node_t node;
3171 vat_json_init_object (&node);
3172 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3173 vat_json_object_add_uint (&node, "policer_index",
3174 ntohl (mp->policer_index));
3176 vat_json_print (vam->ofp, &node);
3177 vat_json_free (&node);
3179 vam->retval = ntohl (mp->retval);
3180 vam->result_ready = 1;
3183 /* Format hex dump. */
3185 format_hex_bytes (u8 * s, va_list * va)
3187 u8 *bytes = va_arg (*va, u8 *);
3188 int n_bytes = va_arg (*va, int);
3191 /* Print short or long form depending on byte count. */
3192 uword short_form = n_bytes <= 32;
3193 uword indent = format_get_indent (s);
3198 for (i = 0; i < n_bytes; i++)
3200 if (!short_form && (i % 32) == 0)
3201 s = format (s, "%08x: ", i);
3202 s = format (s, "%02x", bytes[i]);
3203 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3204 s = format (s, "\n%U", format_white_space, indent);
3211 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3214 vat_main_t *vam = &vat_main;
3215 i32 retval = ntohl (mp->retval);
3218 fformat (vam->ofp, "classify table info :\n");
3219 fformat (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d\n",
3220 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3221 ntohl (mp->miss_next_index));
3222 fformat (vam->ofp, "nbuckets: %d skip: %d match: %d\n",
3223 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3224 ntohl (mp->match_n_vectors));
3225 fformat (vam->ofp, "mask: %U\n", format_hex_bytes, mp->mask,
3226 ntohl (mp->mask_length));
3228 vam->retval = retval;
3229 vam->result_ready = 1;
3233 vl_api_classify_table_info_reply_t_handler_json
3234 (vl_api_classify_table_info_reply_t * mp)
3236 vat_main_t *vam = &vat_main;
3237 vat_json_node_t node;
3239 i32 retval = ntohl (mp->retval);
3242 vat_json_init_object (&node);
3244 vat_json_object_add_int (&node, "sessions",
3245 ntohl (mp->active_sessions));
3246 vat_json_object_add_int (&node, "nexttbl",
3247 ntohl (mp->next_table_index));
3248 vat_json_object_add_int (&node, "nextnode",
3249 ntohl (mp->miss_next_index));
3250 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3251 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3252 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3253 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3254 ntohl (mp->mask_length), 0);
3255 vat_json_object_add_string_copy (&node, "mask", s);
3257 vat_json_print (vam->ofp, &node);
3258 vat_json_free (&node);
3260 vam->retval = ntohl (mp->retval);
3261 vam->result_ready = 1;
3265 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3268 vat_main_t *vam = &vat_main;
3270 fformat (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3271 ntohl (mp->hit_next_index), ntohl (mp->advance),
3272 ntohl (mp->opaque_index));
3273 fformat (vam->ofp, "mask: %U\n", format_hex_bytes, mp->match,
3274 ntohl (mp->match_length));
3278 vl_api_classify_session_details_t_handler_json
3279 (vl_api_classify_session_details_t * mp)
3281 vat_main_t *vam = &vat_main;
3282 vat_json_node_t *node = NULL;
3284 if (VAT_JSON_ARRAY != vam->json_tree.type)
3286 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3287 vat_json_init_array (&vam->json_tree);
3289 node = vat_json_array_add (&vam->json_tree);
3291 vat_json_init_object (node);
3292 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3293 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3294 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3296 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3298 vat_json_object_add_string_copy (node, "match", s);
3301 static void vl_api_pg_create_interface_reply_t_handler
3302 (vl_api_pg_create_interface_reply_t * mp)
3304 vat_main_t *vam = &vat_main;
3306 vam->retval = ntohl (mp->retval);
3307 vam->result_ready = 1;
3310 static void vl_api_pg_create_interface_reply_t_handler_json
3311 (vl_api_pg_create_interface_reply_t * mp)
3313 vat_main_t *vam = &vat_main;
3314 vat_json_node_t node;
3316 i32 retval = ntohl (mp->retval);
3319 vat_json_init_object (&node);
3321 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3323 vat_json_print (vam->ofp, &node);
3324 vat_json_free (&node);
3326 vam->retval = ntohl (mp->retval);
3327 vam->result_ready = 1;
3330 static void vl_api_policer_classify_details_t_handler
3331 (vl_api_policer_classify_details_t * mp)
3333 vat_main_t *vam = &vat_main;
3335 fformat (vam->ofp, "%10d%20d\n", ntohl (mp->sw_if_index),
3336 ntohl (mp->table_index));
3339 static void vl_api_policer_classify_details_t_handler_json
3340 (vl_api_policer_classify_details_t * mp)
3342 vat_main_t *vam = &vat_main;
3343 vat_json_node_t *node;
3345 if (VAT_JSON_ARRAY != vam->json_tree.type)
3347 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3348 vat_json_init_array (&vam->json_tree);
3350 node = vat_json_array_add (&vam->json_tree);
3352 vat_json_init_object (node);
3353 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3354 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3357 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3358 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3360 vat_main_t *vam = &vat_main;
3361 i32 retval = ntohl (mp->retval);
3362 if (vam->async_mode)
3364 vam->async_errors += (retval < 0);
3368 vam->retval = retval;
3369 vam->sw_if_index = ntohl (mp->sw_if_index);
3370 vam->result_ready = 1;
3374 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3375 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3377 vat_main_t *vam = &vat_main;
3378 vat_json_node_t node;
3380 vat_json_init_object (&node);
3381 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3382 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3384 vat_json_print (vam->ofp, &node);
3385 vat_json_free (&node);
3387 vam->retval = ntohl (mp->retval);
3388 vam->result_ready = 1;
3391 static void vl_api_flow_classify_details_t_handler
3392 (vl_api_flow_classify_details_t * mp)
3394 vat_main_t *vam = &vat_main;
3396 fformat (vam->ofp, "%10d%20d\n", ntohl (mp->sw_if_index),
3397 ntohl (mp->table_index));
3400 static void vl_api_flow_classify_details_t_handler_json
3401 (vl_api_flow_classify_details_t * mp)
3403 vat_main_t *vam = &vat_main;
3404 vat_json_node_t *node;
3406 if (VAT_JSON_ARRAY != vam->json_tree.type)
3408 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3409 vat_json_init_array (&vam->json_tree);
3411 node = vat_json_array_add (&vam->json_tree);
3413 vat_json_init_object (node);
3414 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3415 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3420 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3421 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3422 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3423 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3426 * Generate boilerplate reply handlers, which
3427 * dig the return value out of the xxx_reply_t API message,
3428 * stick it into vam->retval, and set vam->result_ready
3430 * Could also do this by pointing N message decode slots at
3431 * a single function, but that could break in subtle ways.
3434 #define foreach_standard_reply_retval_handler \
3435 _(sw_interface_set_flags_reply) \
3436 _(sw_interface_add_del_address_reply) \
3437 _(sw_interface_set_table_reply) \
3438 _(sw_interface_set_vpath_reply) \
3439 _(sw_interface_set_l2_bridge_reply) \
3440 _(sw_interface_set_dpdk_hqos_pipe_reply) \
3441 _(sw_interface_set_dpdk_hqos_subport_reply) \
3442 _(sw_interface_set_dpdk_hqos_tctbl_reply) \
3443 _(bridge_domain_add_del_reply) \
3444 _(sw_interface_set_l2_xconnect_reply) \
3445 _(l2fib_add_del_reply) \
3446 _(ip_add_del_route_reply) \
3447 _(proxy_arp_add_del_reply) \
3448 _(proxy_arp_intfc_enable_disable_reply) \
3449 _(mpls_add_del_encap_reply) \
3450 _(mpls_add_del_decap_reply) \
3451 _(mpls_ethernet_add_del_tunnel_2_reply) \
3452 _(sw_interface_set_unnumbered_reply) \
3453 _(ip_neighbor_add_del_reply) \
3454 _(reset_vrf_reply) \
3455 _(oam_add_del_reply) \
3456 _(reset_fib_reply) \
3457 _(dhcp_proxy_config_reply) \
3458 _(dhcp_proxy_config_2_reply) \
3459 _(dhcp_proxy_set_vss_reply) \
3460 _(dhcp_client_config_reply) \
3461 _(set_ip_flow_hash_reply) \
3462 _(sw_interface_ip6_enable_disable_reply) \
3463 _(sw_interface_ip6_set_link_local_address_reply) \
3464 _(sw_interface_ip6nd_ra_prefix_reply) \
3465 _(sw_interface_ip6nd_ra_config_reply) \
3466 _(set_arp_neighbor_limit_reply) \
3467 _(l2_patch_add_del_reply) \
3468 _(sr_tunnel_add_del_reply) \
3469 _(sr_policy_add_del_reply) \
3470 _(sr_multicast_map_add_del_reply) \
3471 _(classify_add_del_session_reply) \
3472 _(classify_set_interface_ip_table_reply) \
3473 _(classify_set_interface_l2_tables_reply) \
3474 _(l2tpv3_set_tunnel_cookies_reply) \
3475 _(l2tpv3_interface_enable_disable_reply) \
3476 _(l2tpv3_set_lookup_key_reply) \
3477 _(l2_fib_clear_table_reply) \
3478 _(l2_interface_efp_filter_reply) \
3479 _(l2_interface_vlan_tag_rewrite_reply) \
3480 _(modify_vhost_user_if_reply) \
3481 _(delete_vhost_user_if_reply) \
3482 _(want_ip4_arp_events_reply) \
3483 _(want_ip6_nd_events_reply) \
3484 _(input_acl_set_interface_reply) \
3485 _(ipsec_spd_add_del_reply) \
3486 _(ipsec_interface_add_del_spd_reply) \
3487 _(ipsec_spd_add_del_entry_reply) \
3488 _(ipsec_sad_add_del_entry_reply) \
3489 _(ipsec_sa_set_key_reply) \
3490 _(ikev2_profile_add_del_reply) \
3491 _(ikev2_profile_set_auth_reply) \
3492 _(ikev2_profile_set_id_reply) \
3493 _(ikev2_profile_set_ts_reply) \
3494 _(ikev2_set_local_key_reply) \
3495 _(delete_loopback_reply) \
3496 _(bd_ip_mac_add_del_reply) \
3497 _(map_del_domain_reply) \
3498 _(map_add_del_rule_reply) \
3499 _(want_interface_events_reply) \
3500 _(want_stats_reply) \
3501 _(cop_interface_enable_disable_reply) \
3502 _(cop_whitelist_enable_disable_reply) \
3503 _(sw_interface_clear_stats_reply) \
3504 _(ioam_enable_reply) \
3505 _(ioam_disable_reply) \
3506 _(lisp_add_del_locator_reply) \
3507 _(lisp_add_del_local_eid_reply) \
3508 _(lisp_add_del_remote_mapping_reply) \
3509 _(lisp_add_del_adjacency_reply) \
3510 _(lisp_gpe_add_del_fwd_entry_reply) \
3511 _(lisp_add_del_map_resolver_reply) \
3512 _(lisp_gpe_enable_disable_reply) \
3513 _(lisp_gpe_add_del_iface_reply) \
3514 _(lisp_enable_disable_reply) \
3515 _(lisp_pitr_set_locator_set_reply) \
3516 _(lisp_map_request_mode_reply) \
3517 _(lisp_add_del_map_request_itr_rlocs_reply) \
3518 _(lisp_eid_table_add_del_map_reply) \
3519 _(vxlan_gpe_add_del_tunnel_reply) \
3520 _(af_packet_delete_reply) \
3521 _(policer_classify_set_interface_reply) \
3522 _(netmap_create_reply) \
3523 _(netmap_delete_reply) \
3524 _(set_ipfix_exporter_reply) \
3525 _(set_ipfix_classify_stream_reply) \
3526 _(ipfix_classify_table_add_del_reply) \
3527 _(flow_classify_set_interface_reply) \
3528 _(pg_capture_reply) \
3529 _(pg_enable_disable_reply) \
3530 _(ip_source_and_port_range_check_add_del_reply) \
3531 _(ip_source_and_port_range_check_interface_add_del_reply)\
3532 _(delete_subif_reply) \
3533 _(l2_interface_pbb_tag_rewrite_reply) \
3537 static void vl_api_##n##_t_handler \
3538 (vl_api_##n##_t * mp) \
3540 vat_main_t * vam = &vat_main; \
3541 i32 retval = ntohl(mp->retval); \
3542 if (vam->async_mode) { \
3543 vam->async_errors += (retval < 0); \
3545 vam->retval = retval; \
3546 vam->result_ready = 1; \
3549 foreach_standard_reply_retval_handler;
3553 static void vl_api_##n##_t_handler_json \
3554 (vl_api_##n##_t * mp) \
3556 vat_main_t * vam = &vat_main; \
3557 vat_json_node_t node; \
3558 vat_json_init_object(&node); \
3559 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3560 vat_json_print(vam->ofp, &node); \
3561 vam->retval = ntohl(mp->retval); \
3562 vam->result_ready = 1; \
3564 foreach_standard_reply_retval_handler;
3568 * Table of message reply handlers, must include boilerplate handlers
3572 #define foreach_vpe_api_reply_msg \
3573 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3574 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3575 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
3576 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3577 _(CONTROL_PING_REPLY, control_ping_reply) \
3578 _(CLI_REPLY, cli_reply) \
3579 _(CLI_INBAND_REPLY, cli_inband_reply) \
3580 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
3581 sw_interface_add_del_address_reply) \
3582 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
3583 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
3584 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
3585 sw_interface_set_l2_xconnect_reply) \
3586 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
3587 sw_interface_set_l2_bridge_reply) \
3588 _(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
3589 sw_interface_set_dpdk_hqos_pipe_reply) \
3590 _(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
3591 sw_interface_set_dpdk_hqos_subport_reply) \
3592 _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
3593 sw_interface_set_dpdk_hqos_tctbl_reply) \
3594 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
3595 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
3596 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
3597 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
3598 _(L2_FLAGS_REPLY, l2_flags_reply) \
3599 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
3600 _(TAP_CONNECT_REPLY, tap_connect_reply) \
3601 _(TAP_MODIFY_REPLY, tap_modify_reply) \
3602 _(TAP_DELETE_REPLY, tap_delete_reply) \
3603 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
3604 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
3605 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
3606 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
3607 proxy_arp_intfc_enable_disable_reply) \
3608 _(MPLS_ADD_DEL_ENCAP_REPLY, mpls_add_del_encap_reply) \
3609 _(MPLS_ADD_DEL_DECAP_REPLY, mpls_add_del_decap_reply) \
3610 _(MPLS_GRE_ADD_DEL_TUNNEL_REPLY, mpls_gre_add_del_tunnel_reply) \
3611 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_REPLY, \
3612 mpls_ethernet_add_del_tunnel_reply) \
3613 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_2_REPLY, \
3614 mpls_ethernet_add_del_tunnel_2_reply) \
3615 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
3616 sw_interface_set_unnumbered_reply) \
3617 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
3618 _(RESET_VRF_REPLY, reset_vrf_reply) \
3619 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
3620 _(CREATE_SUBIF_REPLY, create_subif_reply) \
3621 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
3622 _(RESET_FIB_REPLY, reset_fib_reply) \
3623 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
3624 _(DHCP_PROXY_CONFIG_2_REPLY, dhcp_proxy_config_2_reply) \
3625 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
3626 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
3627 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
3628 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
3629 sw_interface_ip6_enable_disable_reply) \
3630 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
3631 sw_interface_ip6_set_link_local_address_reply) \
3632 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
3633 sw_interface_ip6nd_ra_prefix_reply) \
3634 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
3635 sw_interface_ip6nd_ra_config_reply) \
3636 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
3637 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
3638 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
3639 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
3640 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
3641 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
3642 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
3643 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
3644 classify_set_interface_ip_table_reply) \
3645 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
3646 classify_set_interface_l2_tables_reply) \
3647 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
3648 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
3649 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
3650 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
3651 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
3652 l2tpv3_interface_enable_disable_reply) \
3653 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
3654 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
3655 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
3656 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
3657 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
3658 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
3659 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
3660 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
3661 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
3662 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
3663 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
3664 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
3665 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
3666 _(SHOW_VERSION_REPLY, show_version_reply) \
3667 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
3668 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
3669 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
3670 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
3671 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
3672 _(IP4_ARP_EVENT, ip4_arp_event) \
3673 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
3674 _(IP6_ND_EVENT, ip6_nd_event) \
3675 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
3676 _(IP_ADDRESS_DETAILS, ip_address_details) \
3677 _(IP_DETAILS, ip_details) \
3678 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
3679 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
3680 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
3681 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
3682 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
3683 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
3684 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
3685 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
3686 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
3687 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
3688 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
3689 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
3690 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
3691 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
3692 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
3693 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
3694 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
3695 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
3696 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
3697 _(MAP_DOMAIN_DETAILS, map_domain_details) \
3698 _(MAP_RULE_DETAILS, map_rule_details) \
3699 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
3700 _(WANT_STATS_REPLY, want_stats_reply) \
3701 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
3702 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
3703 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
3704 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
3705 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
3706 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
3707 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
3708 _(LISP_ADD_DEL_LOCATOR_SET_REPLY, lisp_add_del_locator_set_reply) \
3709 _(LISP_ADD_DEL_LOCATOR_REPLY, lisp_add_del_locator_reply) \
3710 _(LISP_ADD_DEL_LOCAL_EID_REPLY, lisp_add_del_local_eid_reply) \
3711 _(LISP_ADD_DEL_REMOTE_MAPPING_REPLY, lisp_add_del_remote_mapping_reply) \
3712 _(LISP_ADD_DEL_ADJACENCY_REPLY, lisp_add_del_adjacency_reply) \
3713 _(LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY, lisp_gpe_add_del_fwd_entry_reply) \
3714 _(LISP_ADD_DEL_MAP_RESOLVER_REPLY, lisp_add_del_map_resolver_reply) \
3715 _(LISP_GPE_ENABLE_DISABLE_REPLY, lisp_gpe_enable_disable_reply) \
3716 _(LISP_ENABLE_DISABLE_REPLY, lisp_enable_disable_reply) \
3717 _(LISP_PITR_SET_LOCATOR_SET_REPLY, lisp_pitr_set_locator_set_reply) \
3718 _(LISP_MAP_REQUEST_MODE_REPLY, lisp_map_request_mode_reply) \
3719 _(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \
3720 _(LISP_GPE_ADD_DEL_IFACE_REPLY, lisp_gpe_add_del_iface_reply) \
3721 _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \
3722 _(LISP_LOCATOR_DETAILS, lisp_locator_details) \
3723 _(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \
3724 _(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \
3725 _(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \
3726 _(LISP_GPE_TUNNEL_DETAILS, lisp_gpe_tunnel_details) \
3727 _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
3728 _(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
3729 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
3730 lisp_add_del_map_request_itr_rlocs_reply) \
3731 _(LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
3732 lisp_get_map_request_itr_rlocs_reply) \
3733 _(SHOW_LISP_PITR_REPLY, show_lisp_pitr_reply) \
3734 _(SHOW_LISP_MAP_REQUEST_MODE_REPLY, show_lisp_map_request_mode_reply) \
3735 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
3736 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
3737 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
3738 _(POLICER_DETAILS, policer_details) \
3739 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
3740 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
3741 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
3742 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
3743 _(MPLS_GRE_TUNNEL_DETAILS, mpls_gre_tunnel_details) \
3744 _(MPLS_ETH_TUNNEL_DETAILS, mpls_eth_tunnel_details) \
3745 _(MPLS_FIB_ENCAP_DETAILS, mpls_fib_encap_details) \
3746 _(MPLS_FIB_DECAP_DETAILS, mpls_fib_decap_details) \
3747 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
3748 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
3749 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
3750 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
3751 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
3752 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
3753 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
3754 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
3755 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
3756 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
3757 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
3758 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
3759 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
3760 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
3761 _(PG_CAPTURE_REPLY, pg_capture_reply) \
3762 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
3763 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
3764 ip_source_and_port_range_check_add_del_reply) \
3765 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
3766 ip_source_and_port_range_check_interface_add_del_reply) \
3767 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
3768 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
3769 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
3770 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
3771 _(PUNT_REPLY, punt_reply)
3773 /* M: construct, but don't yet send a message */
3777 vam->result_ready = 0; \
3778 mp = vl_msg_api_alloc(sizeof(*mp)); \
3779 memset (mp, 0, sizeof (*mp)); \
3780 mp->_vl_msg_id = ntohs (VL_API_##T); \
3781 mp->client_index = vam->my_client_index; \
3786 vam->result_ready = 0; \
3787 mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
3788 memset (mp, 0, sizeof (*mp)); \
3789 mp->_vl_msg_id = ntohs (VL_API_##T); \
3790 mp->client_index = vam->my_client_index; \
3794 /* S: send a message */
3795 #define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
3797 /* W: wait for results, with timeout */
3800 timeout = vat_time_now (vam) + 1.0; \
3802 while (vat_time_now (vam) < timeout) { \
3803 if (vam->result_ready == 1) { \
3804 return (vam->retval); \
3810 /* W2: wait for results, with timeout */
3813 timeout = vat_time_now (vam) + 1.0; \
3815 while (vat_time_now (vam) < timeout) { \
3816 if (vam->result_ready == 1) { \
3818 return (vam->retval); \
3831 #define STR_VTR_OP_CASE(op) \
3832 case L2_VTR_ ## op: \
3836 str_vtr_op (u32 vtr_op)
3840 STR_VTR_OP_CASE (DISABLED);
3841 STR_VTR_OP_CASE (PUSH_1);
3842 STR_VTR_OP_CASE (PUSH_2);
3843 STR_VTR_OP_CASE (POP_1);
3844 STR_VTR_OP_CASE (POP_2);
3845 STR_VTR_OP_CASE (TRANSLATE_1_1);
3846 STR_VTR_OP_CASE (TRANSLATE_1_2);
3847 STR_VTR_OP_CASE (TRANSLATE_2_1);
3848 STR_VTR_OP_CASE (TRANSLATE_2_2);
3855 dump_sub_interface_table (vat_main_t * vam)
3857 const sw_interface_subif_t *sub = NULL;
3859 if (vam->json_output)
3862 ("JSON output supported only for VPE API calls and dump_stats_table");
3867 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s\n",
3868 "Interface", "sw_if_index",
3869 "sub id", "dot1ad", "tags", "outer id",
3870 "inner id", "exact", "default", "outer any", "inner any");
3872 vec_foreach (sub, vam->sw_if_subif_table)
3875 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d\n",
3876 sub->interface_name,
3878 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
3879 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
3880 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
3881 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
3882 if (sub->vtr_op != L2_VTR_DISABLED)
3885 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
3886 "tag1: %d tag2: %d ]\n",
3887 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
3888 sub->vtr_tag1, sub->vtr_tag2);
3896 name_sort_cmp (void *a1, void *a2)
3898 name_sort_t *n1 = a1;
3899 name_sort_t *n2 = a2;
3901 return strcmp ((char *) n1->name, (char *) n2->name);
3905 dump_interface_table (vat_main_t * vam)
3908 name_sort_t *nses = 0, *ns;
3910 if (vam->json_output)
3913 ("JSON output supported only for VPE API calls and dump_stats_table");
3918 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
3920 vec_add2 (nses, ns, 1);
3921 ns->name = (u8 *)(p->key);
3922 ns->value = (u32) p->value[0];
3926 vec_sort_with_function (nses, name_sort_cmp);
3928 fformat (vam->ofp, "%-25s%-15s\n", "Interface", "sw_if_index");
3929 vec_foreach (ns, nses)
3931 fformat (vam->ofp, "%-25s%-15d\n", ns->name, ns->value);
3938 dump_ip_table (vat_main_t * vam, int is_ipv6)
3940 const ip_details_t *det = NULL;
3941 const ip_address_details_t *address = NULL;
3944 fformat (vam->ofp, "%-12s\n", "sw_if_index");
3946 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
3953 fformat (vam->ofp, "%-12d\n", i);
3955 " %-30s%-13s\n", "Address", "Prefix length");
3960 vec_foreach (address, det->addr)
3964 is_ipv6 ? format_ip6_address : format_ip4_address,
3965 address->ip, address->prefix_length);
3973 dump_ipv4_table (vat_main_t * vam)
3975 if (vam->json_output)
3978 ("JSON output supported only for VPE API calls and dump_stats_table");
3982 return dump_ip_table (vam, 0);
3986 dump_ipv6_table (vat_main_t * vam)
3988 if (vam->json_output)
3991 ("JSON output supported only for VPE API calls and dump_stats_table");
3995 return dump_ip_table (vam, 1);
3999 counter_type_to_str (u8 counter_type, u8 is_combined)
4003 switch (counter_type)
4005 case VNET_INTERFACE_COUNTER_DROP:
4007 case VNET_INTERFACE_COUNTER_PUNT:
4009 case VNET_INTERFACE_COUNTER_IP4:
4011 case VNET_INTERFACE_COUNTER_IP6:
4013 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4015 case VNET_INTERFACE_COUNTER_RX_MISS:
4017 case VNET_INTERFACE_COUNTER_RX_ERROR:
4019 case VNET_INTERFACE_COUNTER_TX_ERROR:
4022 return "INVALID-COUNTER-TYPE";
4027 switch (counter_type)
4029 case VNET_INTERFACE_COUNTER_RX:
4031 case VNET_INTERFACE_COUNTER_TX:
4034 return "INVALID-COUNTER-TYPE";
4040 dump_stats_table (vat_main_t * vam)
4042 vat_json_node_t node;
4043 vat_json_node_t *msg_array;
4044 vat_json_node_t *msg;
4045 vat_json_node_t *counter_array;
4046 vat_json_node_t *counter;
4047 interface_counter_t c;
4049 ip4_fib_counter_t *c4;
4050 ip6_fib_counter_t *c6;
4053 if (!vam->json_output)
4055 clib_warning ("dump_stats_table supported only in JSON format");
4059 vat_json_init_object (&node);
4061 /* interface counters */
4062 msg_array = vat_json_object_add (&node, "interface_counters");
4063 vat_json_init_array (msg_array);
4064 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4066 msg = vat_json_array_add (msg_array);
4067 vat_json_init_object (msg);
4068 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4069 (u8 *) counter_type_to_str (i, 0));
4070 vat_json_object_add_int (msg, "is_combined", 0);
4071 counter_array = vat_json_object_add (msg, "data");
4072 vat_json_init_array (counter_array);
4073 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4075 packets = vam->simple_interface_counters[i][j];
4076 vat_json_array_add_uint (counter_array, packets);
4079 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4081 msg = vat_json_array_add (msg_array);
4082 vat_json_init_object (msg);
4083 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4084 (u8 *) counter_type_to_str (i, 1));
4085 vat_json_object_add_int (msg, "is_combined", 1);
4086 counter_array = vat_json_object_add (msg, "data");
4087 vat_json_init_array (counter_array);
4088 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4090 c = vam->combined_interface_counters[i][j];
4091 counter = vat_json_array_add (counter_array);
4092 vat_json_init_object (counter);
4093 vat_json_object_add_uint (counter, "packets", c.packets);
4094 vat_json_object_add_uint (counter, "bytes", c.bytes);
4098 /* ip4 fib counters */
4099 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4100 vat_json_init_array (msg_array);
4101 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4103 msg = vat_json_array_add (msg_array);
4104 vat_json_init_object (msg);
4105 vat_json_object_add_uint (msg, "vrf_id",
4106 vam->ip4_fib_counters_vrf_id_by_index[i]);
4107 counter_array = vat_json_object_add (msg, "c");
4108 vat_json_init_array (counter_array);
4109 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4111 counter = vat_json_array_add (counter_array);
4112 vat_json_init_object (counter);
4113 c4 = &vam->ip4_fib_counters[i][j];
4114 vat_json_object_add_ip4 (counter, "address", c4->address);
4115 vat_json_object_add_uint (counter, "address_length",
4116 c4->address_length);
4117 vat_json_object_add_uint (counter, "packets", c4->packets);
4118 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4122 /* ip6 fib counters */
4123 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4124 vat_json_init_array (msg_array);
4125 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4127 msg = vat_json_array_add (msg_array);
4128 vat_json_init_object (msg);
4129 vat_json_object_add_uint (msg, "vrf_id",
4130 vam->ip6_fib_counters_vrf_id_by_index[i]);
4131 counter_array = vat_json_object_add (msg, "c");
4132 vat_json_init_array (counter_array);
4133 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4135 counter = vat_json_array_add (counter_array);
4136 vat_json_init_object (counter);
4137 c6 = &vam->ip6_fib_counters[i][j];
4138 vat_json_object_add_ip6 (counter, "address", c6->address);
4139 vat_json_object_add_uint (counter, "address_length",
4140 c6->address_length);
4141 vat_json_object_add_uint (counter, "packets", c6->packets);
4142 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4146 vat_json_print (vam->ofp, &node);
4147 vat_json_free (&node);
4153 exec (vat_main_t * vam)
4155 api_main_t *am = &api_main;
4156 vl_api_cli_request_t *mp;
4160 unformat_input_t *i = vam->input;
4162 if (vec_len (i->buffer) == 0)
4165 if (vam->exec_mode == 0 && unformat (i, "mode"))
4170 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4177 M (CLI_REQUEST, cli_request);
4180 * Copy cmd into shared memory.
4181 * In order for the CLI command to work, it
4182 * must be a vector ending in \n, not a C-string ending
4185 pthread_mutex_lock (&am->vlib_rp->mutex);
4186 oldheap = svm_push_data_heap (am->vlib_rp);
4188 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4189 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4191 svm_pop_heap (oldheap);
4192 pthread_mutex_unlock (&am->vlib_rp->mutex);
4194 mp->cmd_in_shmem = (u64) cmd;
4196 timeout = vat_time_now (vam) + 10.0;
4198 while (vat_time_now (vam) < timeout)
4200 if (vam->result_ready == 1)
4203 if (vam->shmem_result != NULL)
4204 fformat (vam->ofp, "%s", vam->shmem_result);
4205 pthread_mutex_lock (&am->vlib_rp->mutex);
4206 oldheap = svm_push_data_heap (am->vlib_rp);
4208 free_me = (u8 *) vam->shmem_result;
4211 svm_pop_heap (oldheap);
4212 pthread_mutex_unlock (&am->vlib_rp->mutex);
4220 * Future replacement of exec() that passes CLI buffers directly in
4221 * the API messages instead of an additional shared memory area.
4224 exec_inband (vat_main_t * vam)
4226 vl_api_cli_inband_t *mp;
4228 unformat_input_t *i = vam->input;
4230 if (vec_len (i->buffer) == 0)
4233 if (vam->exec_mode == 0 && unformat (i, "mode"))
4238 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4245 * In order for the CLI command to work, it
4246 * must be a vector ending in \n, not a C-string ending
4249 u32 len = vec_len (vam->input->buffer);
4250 M2 (CLI_INBAND, cli_inband, len);
4251 clib_memcpy (mp->cmd, vam->input->buffer, len);
4252 mp->length = htonl (len);
4255 W2 (fformat (vam->ofp, "%s", vam->cmd_reply));
4259 api_create_loopback (vat_main_t * vam)
4261 unformat_input_t *i = vam->input;
4262 vl_api_create_loopback_t *mp;
4267 memset (mac_address, 0, sizeof (mac_address));
4269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4271 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4277 /* Construct the API message */
4278 M (CREATE_LOOPBACK, create_loopback);
4280 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4287 api_delete_loopback (vat_main_t * vam)
4289 unformat_input_t *i = vam->input;
4290 vl_api_delete_loopback_t *mp;
4292 u32 sw_if_index = ~0;
4294 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4296 if (unformat (i, "sw_if_index %d", &sw_if_index))
4302 if (sw_if_index == ~0)
4304 errmsg ("missing sw_if_index\n");
4308 /* Construct the API message */
4309 M (DELETE_LOOPBACK, delete_loopback);
4310 mp->sw_if_index = ntohl (sw_if_index);
4317 api_want_stats (vat_main_t * vam)
4319 unformat_input_t *i = vam->input;
4320 vl_api_want_stats_t *mp;
4324 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4326 if (unformat (i, "enable"))
4328 else if (unformat (i, "disable"))
4336 errmsg ("missing enable|disable\n");
4340 M (WANT_STATS, want_stats);
4341 mp->enable_disable = enable;
4348 api_want_interface_events (vat_main_t * vam)
4350 unformat_input_t *i = vam->input;
4351 vl_api_want_interface_events_t *mp;
4355 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4357 if (unformat (i, "enable"))
4359 else if (unformat (i, "disable"))
4367 errmsg ("missing enable|disable\n");
4371 M (WANT_INTERFACE_EVENTS, want_interface_events);
4372 mp->enable_disable = enable;
4374 vam->interface_event_display = enable;
4381 /* Note: non-static, called once to set up the initial intfc table */
4383 api_sw_interface_dump (vat_main_t * vam)
4385 vl_api_sw_interface_dump_t *mp;
4388 name_sort_t *nses = 0, *ns;
4389 sw_interface_subif_t *sub = NULL;
4391 /* Toss the old name table */
4393 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4395 vec_add2 (nses, ns, 1);
4396 ns->name = (u8 *)(p->key);
4397 ns->value = (u32) p->value[0];
4401 hash_free (vam->sw_if_index_by_interface_name);
4403 vec_foreach (ns, nses) vec_free (ns->name);
4407 vec_foreach (sub, vam->sw_if_subif_table)
4409 vec_free (sub->interface_name);
4411 vec_free (vam->sw_if_subif_table);
4413 /* recreate the interface name hash table */
4414 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4416 /* Get list of ethernets */
4417 M (SW_INTERFACE_DUMP, sw_interface_dump);
4418 mp->name_filter_valid = 1;
4419 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4422 /* and local / loopback interfaces */
4423 M (SW_INTERFACE_DUMP, sw_interface_dump);
4424 mp->name_filter_valid = 1;
4425 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4428 /* and packet-generator interfaces */
4429 M (SW_INTERFACE_DUMP, sw_interface_dump);
4430 mp->name_filter_valid = 1;
4431 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4434 /* and vxlan-gpe tunnel interfaces */
4435 M (SW_INTERFACE_DUMP, sw_interface_dump);
4436 mp->name_filter_valid = 1;
4437 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4438 sizeof (mp->name_filter) - 1);
4441 /* and vxlan tunnel interfaces */
4442 M (SW_INTERFACE_DUMP, sw_interface_dump);
4443 mp->name_filter_valid = 1;
4444 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4447 /* and host (af_packet) interfaces */
4448 M (SW_INTERFACE_DUMP, sw_interface_dump);
4449 mp->name_filter_valid = 1;
4450 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4453 /* and l2tpv3 tunnel interfaces */
4454 M (SW_INTERFACE_DUMP, sw_interface_dump);
4455 mp->name_filter_valid = 1;
4456 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4457 sizeof (mp->name_filter) - 1);
4460 /* and GRE tunnel interfaces */
4461 M (SW_INTERFACE_DUMP, sw_interface_dump);
4462 mp->name_filter_valid = 1;
4463 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4466 /* and LISP-GPE interfaces */
4467 M (SW_INTERFACE_DUMP, sw_interface_dump);
4468 mp->name_filter_valid = 1;
4469 strncpy ((char *) mp->name_filter, "lisp_gpe",
4470 sizeof (mp->name_filter) - 1);
4473 /* and IPSEC tunnel interfaces */
4474 M (SW_INTERFACE_DUMP, sw_interface_dump);
4475 mp->name_filter_valid = 1;
4476 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4479 /* Use a control ping for synchronization */
4481 vl_api_control_ping_t *mp;
4482 M (CONTROL_PING, control_ping);
4489 api_sw_interface_set_flags (vat_main_t * vam)
4491 unformat_input_t *i = vam->input;
4492 vl_api_sw_interface_set_flags_t *mp;
4495 u8 sw_if_index_set = 0;
4496 u8 admin_up = 0, link_up = 0;
4498 /* Parse args required to build the message */
4499 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4501 if (unformat (i, "admin-up"))
4503 else if (unformat (i, "admin-down"))
4505 else if (unformat (i, "link-up"))
4507 else if (unformat (i, "link-down"))
4509 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4510 sw_if_index_set = 1;
4511 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4512 sw_if_index_set = 1;
4517 if (sw_if_index_set == 0)
4519 errmsg ("missing interface name or sw_if_index\n");
4523 /* Construct the API message */
4524 M (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags);
4525 mp->sw_if_index = ntohl (sw_if_index);
4526 mp->admin_up_down = admin_up;
4527 mp->link_up_down = link_up;
4532 /* Wait for a reply, return the good/bad news... */
4537 api_sw_interface_clear_stats (vat_main_t * vam)
4539 unformat_input_t *i = vam->input;
4540 vl_api_sw_interface_clear_stats_t *mp;
4543 u8 sw_if_index_set = 0;
4545 /* Parse args required to build the message */
4546 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4548 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4549 sw_if_index_set = 1;
4550 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4551 sw_if_index_set = 1;
4556 /* Construct the API message */
4557 M (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats);
4559 if (sw_if_index_set == 1)
4560 mp->sw_if_index = ntohl (sw_if_index);
4562 mp->sw_if_index = ~0;
4567 /* Wait for a reply, return the good/bad news... */
4572 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
4574 unformat_input_t *i = vam->input;
4575 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
4578 u8 sw_if_index_set = 0;
4586 /* Parse args required to build the message */
4587 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4589 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4590 sw_if_index_set = 1;
4591 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4592 sw_if_index_set = 1;
4593 else if (unformat (i, "subport %u", &subport))
4595 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4596 sw_if_index_set = 1;
4597 else if (unformat (i, "pipe %u", &pipe))
4599 else if (unformat (i, "profile %u", &profile))
4605 if (sw_if_index_set == 0)
4607 errmsg ("missing interface name or sw_if_index\n");
4611 if (subport_set == 0)
4613 errmsg ("missing subport \n");
4619 errmsg ("missing pipe\n");
4623 if (profile_set == 0)
4625 errmsg ("missing profile\n");
4629 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe);
4631 mp->sw_if_index = ntohl (sw_if_index);
4632 mp->subport = ntohl (subport);
4633 mp->pipe = ntohl (pipe);
4634 mp->profile = ntohl (profile);
4644 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
4646 unformat_input_t *i = vam->input;
4647 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
4650 u8 sw_if_index_set = 0;
4653 u32 tb_rate = 1250000000; /* 10GbE */
4654 u32 tb_size = 1000000;
4655 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
4658 /* Parse args required to build the message */
4659 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4661 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4662 sw_if_index_set = 1;
4663 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4664 sw_if_index_set = 1;
4665 else if (unformat (i, "subport %u", &subport))
4667 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4668 sw_if_index_set = 1;
4669 else if (unformat (i, "rate %u", &tb_rate))
4673 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
4675 tc_rate[tc_id] = tb_rate;
4677 else if (unformat (i, "bktsize %u", &tb_size))
4679 else if (unformat (i, "tc0 %u", &tc_rate[0]))
4681 else if (unformat (i, "tc1 %u", &tc_rate[1]))
4683 else if (unformat (i, "tc2 %u", &tc_rate[2]))
4685 else if (unformat (i, "tc3 %u", &tc_rate[3]))
4687 else if (unformat (i, "period %u", &tc_period))
4693 if (sw_if_index_set == 0)
4695 errmsg ("missing interface name or sw_if_index\n");
4699 if (subport_set == 0)
4701 errmsg ("missing subport \n");
4705 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport);
4707 mp->sw_if_index = ntohl (sw_if_index);
4708 mp->subport = ntohl (subport);
4709 mp->tb_rate = ntohl (tb_rate);
4710 mp->tb_size = ntohl (tb_size);
4711 mp->tc_rate[0] = ntohl (tc_rate[0]);
4712 mp->tc_rate[1] = ntohl (tc_rate[1]);
4713 mp->tc_rate[2] = ntohl (tc_rate[2]);
4714 mp->tc_rate[3] = ntohl (tc_rate[3]);
4715 mp->tc_period = ntohl (tc_period);
4724 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
4726 unformat_input_t *i = vam->input;
4727 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
4730 u8 sw_if_index_set = 0;
4734 u32 entry, tc, queue;
4736 /* Parse args required to build the message */
4737 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4739 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4740 sw_if_index_set = 1;
4741 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4742 sw_if_index_set = 1;
4743 else if (unformat (i, "entry %d", &entry))
4745 else if (unformat (i, "tc %d", &tc))
4747 else if (unformat (i, "queue %d", &queue))
4753 if (sw_if_index_set == 0)
4755 errmsg ("missing interface name or sw_if_index\n");
4761 errmsg ("missing entry \n");
4767 errmsg ("missing traffic class \n");
4773 errmsg ("missing queue \n");
4777 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl);
4779 mp->sw_if_index = ntohl (sw_if_index);
4780 mp->entry = ntohl (entry);
4781 mp->tc = ntohl (tc);
4782 mp->queue = ntohl (queue);
4791 api_sw_interface_add_del_address (vat_main_t * vam)
4793 unformat_input_t *i = vam->input;
4794 vl_api_sw_interface_add_del_address_t *mp;
4797 u8 sw_if_index_set = 0;
4798 u8 is_add = 1, del_all = 0;
4799 u32 address_length = 0;
4800 u8 v4_address_set = 0;
4801 u8 v6_address_set = 0;
4802 ip4_address_t v4address;
4803 ip6_address_t v6address;
4805 /* Parse args required to build the message */
4806 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4808 if (unformat (i, "del-all"))
4810 else if (unformat (i, "del"))
4812 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4813 sw_if_index_set = 1;
4814 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4815 sw_if_index_set = 1;
4816 else if (unformat (i, "%U/%d",
4817 unformat_ip4_address, &v4address, &address_length))
4819 else if (unformat (i, "%U/%d",
4820 unformat_ip6_address, &v6address, &address_length))
4826 if (sw_if_index_set == 0)
4828 errmsg ("missing interface name or sw_if_index\n");
4831 if (v4_address_set && v6_address_set)
4833 errmsg ("both v4 and v6 addresses set\n");
4836 if (!v4_address_set && !v6_address_set && !del_all)
4838 errmsg ("no addresses set\n");
4842 /* Construct the API message */
4843 M (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address);
4845 mp->sw_if_index = ntohl (sw_if_index);
4846 mp->is_add = is_add;
4847 mp->del_all = del_all;
4851 clib_memcpy (mp->address, &v6address, sizeof (v6address));
4855 clib_memcpy (mp->address, &v4address, sizeof (v4address));
4857 mp->address_length = address_length;
4862 /* Wait for a reply, return good/bad news */
4867 api_sw_interface_set_table (vat_main_t * vam)
4869 unformat_input_t *i = vam->input;
4870 vl_api_sw_interface_set_table_t *mp;
4872 u32 sw_if_index, vrf_id = 0;
4873 u8 sw_if_index_set = 0;
4876 /* Parse args required to build the message */
4877 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4879 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4880 sw_if_index_set = 1;
4881 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4882 sw_if_index_set = 1;
4883 else if (unformat (i, "vrf %d", &vrf_id))
4885 else if (unformat (i, "ipv6"))
4891 if (sw_if_index_set == 0)
4893 errmsg ("missing interface name or sw_if_index\n");
4897 /* Construct the API message */
4898 M (SW_INTERFACE_SET_TABLE, sw_interface_set_table);
4900 mp->sw_if_index = ntohl (sw_if_index);
4901 mp->is_ipv6 = is_ipv6;
4902 mp->vrf_id = ntohl (vrf_id);
4907 /* Wait for a reply... */
4912 api_sw_interface_set_vpath (vat_main_t * vam)
4914 unformat_input_t *i = vam->input;
4915 vl_api_sw_interface_set_vpath_t *mp;
4917 u32 sw_if_index = 0;
4918 u8 sw_if_index_set = 0;
4921 /* Parse args required to build the message */
4922 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4924 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4925 sw_if_index_set = 1;
4926 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4927 sw_if_index_set = 1;
4928 else if (unformat (i, "enable"))
4930 else if (unformat (i, "disable"))
4936 if (sw_if_index_set == 0)
4938 errmsg ("missing interface name or sw_if_index\n");
4942 /* Construct the API message */
4943 M (SW_INTERFACE_SET_VPATH, sw_interface_set_vpath);
4945 mp->sw_if_index = ntohl (sw_if_index);
4946 mp->enable = is_enable;
4951 /* Wait for a reply... */
4956 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
4958 unformat_input_t *i = vam->input;
4959 vl_api_sw_interface_set_l2_xconnect_t *mp;
4962 u8 rx_sw_if_index_set = 0;
4964 u8 tx_sw_if_index_set = 0;
4967 /* Parse args required to build the message */
4968 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4970 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
4971 rx_sw_if_index_set = 1;
4972 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
4973 tx_sw_if_index_set = 1;
4974 else if (unformat (i, "rx"))
4976 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4978 if (unformat (i, "%U", unformat_sw_if_index, vam,
4980 rx_sw_if_index_set = 1;
4985 else if (unformat (i, "tx"))
4987 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4989 if (unformat (i, "%U", unformat_sw_if_index, vam,
4991 tx_sw_if_index_set = 1;
4996 else if (unformat (i, "enable"))
4998 else if (unformat (i, "disable"))
5004 if (rx_sw_if_index_set == 0)
5006 errmsg ("missing rx interface name or rx_sw_if_index\n");
5010 if (enable && (tx_sw_if_index_set == 0))
5012 errmsg ("missing tx interface name or tx_sw_if_index\n");
5016 M (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect);
5018 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5019 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5020 mp->enable = enable;
5029 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5031 unformat_input_t *i = vam->input;
5032 vl_api_sw_interface_set_l2_bridge_t *mp;
5035 u8 rx_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, "sw_if_index %d", &rx_sw_if_index))
5046 rx_sw_if_index_set = 1;
5047 else if (unformat (i, "bd_id %d", &bd_id))
5049 else if (unformat (i, "%U", unformat_sw_if_index, vam, &rx_sw_if_index))
5050 rx_sw_if_index_set = 1;
5051 else if (unformat (i, "shg %d", &shg))
5053 else if (unformat (i, "bvi"))
5055 else if (unformat (i, "enable"))
5057 else if (unformat (i, "disable"))
5063 if (rx_sw_if_index_set == 0)
5065 errmsg ("missing rx interface name or sw_if_index\n");
5069 if (enable && (bd_id_set == 0))
5071 errmsg ("missing bridge domain\n");
5075 M (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge);
5077 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5078 mp->bd_id = ntohl (bd_id);
5081 mp->enable = enable;
5090 api_bridge_domain_dump (vat_main_t * vam)
5092 unformat_input_t *i = vam->input;
5093 vl_api_bridge_domain_dump_t *mp;
5097 /* Parse args required to build the message */
5098 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5100 if (unformat (i, "bd_id %d", &bd_id))
5106 M (BRIDGE_DOMAIN_DUMP, bridge_domain_dump);
5107 mp->bd_id = ntohl (bd_id);
5110 /* Use a control ping for synchronization */
5112 vl_api_control_ping_t *mp;
5113 M (CONTROL_PING, control_ping);
5123 api_bridge_domain_add_del (vat_main_t * vam)
5125 unformat_input_t *i = vam->input;
5126 vl_api_bridge_domain_add_del_t *mp;
5130 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5132 /* Parse args required to build the message */
5133 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5135 if (unformat (i, "bd_id %d", &bd_id))
5137 else if (unformat (i, "flood %d", &flood))
5139 else if (unformat (i, "uu-flood %d", &uu_flood))
5141 else if (unformat (i, "forward %d", &forward))
5143 else if (unformat (i, "learn %d", &learn))
5145 else if (unformat (i, "arp-term %d", &arp_term))
5147 else if (unformat (i, "del"))
5150 flood = uu_flood = forward = learn = 0;
5158 errmsg ("missing bridge domain\n");
5162 M (BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del);
5164 mp->bd_id = ntohl (bd_id);
5166 mp->uu_flood = uu_flood;
5167 mp->forward = forward;
5169 mp->arp_term = arp_term;
5170 mp->is_add = is_add;
5179 api_l2fib_add_del (vat_main_t * vam)
5181 unformat_input_t *i = vam->input;
5182 vl_api_l2fib_add_del_t *mp;
5189 u8 sw_if_index_set = 0;
5198 /* Parse args required to build the message */
5199 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5201 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5203 else if (unformat (i, "bd_id %d", &bd_id))
5205 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5206 sw_if_index_set = 1;
5207 else if (unformat (i, "sw_if"))
5209 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5211 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5212 sw_if_index_set = 1;
5217 else if (unformat (i, "static"))
5219 else if (unformat (i, "filter"))
5224 else if (unformat (i, "bvi"))
5229 else if (unformat (i, "del"))
5231 else if (unformat (i, "count %d", &count))
5239 errmsg ("missing mac address\n");
5245 errmsg ("missing bridge domain\n");
5249 if (is_add && (sw_if_index_set == 0))
5251 errmsg ("missing interface name or sw_if_index\n");
5257 /* Turn on async mode */
5258 vam->async_mode = 1;
5259 vam->async_errors = 0;
5260 before = vat_time_now (vam);
5263 for (j = 0; j < count; j++)
5265 M (L2FIB_ADD_DEL, l2fib_add_del);
5268 mp->bd_id = ntohl (bd_id);
5269 mp->is_add = is_add;
5273 mp->sw_if_index = ntohl (sw_if_index);
5274 mp->static_mac = static_mac;
5275 mp->filter_mac = filter_mac;
5276 mp->bvi_mac = bvi_mac;
5278 increment_mac_address (&mac);
5285 vl_api_control_ping_t *mp;
5288 /* Shut off async mode */
5289 vam->async_mode = 0;
5291 M (CONTROL_PING, control_ping);
5294 timeout = vat_time_now (vam) + 1.0;
5295 while (vat_time_now (vam) < timeout)
5296 if (vam->result_ready == 1)
5301 if (vam->retval == -99)
5302 errmsg ("timeout\n");
5304 if (vam->async_errors > 0)
5306 errmsg ("%d asynchronous errors\n", vam->async_errors);
5309 vam->async_errors = 0;
5310 after = vat_time_now (vam);
5312 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
5313 count, after - before, count / (after - before));
5317 /* Wait for a reply... */
5320 /* Return the good/bad news */
5321 return (vam->retval);
5325 api_l2_flags (vat_main_t * vam)
5327 unformat_input_t *i = vam->input;
5328 vl_api_l2_flags_t *mp;
5331 u32 feature_bitmap = 0;
5332 u8 sw_if_index_set = 0;
5334 /* Parse args required to build the message */
5335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5337 if (unformat (i, "sw_if_index %d", &sw_if_index))
5338 sw_if_index_set = 1;
5339 else if (unformat (i, "sw_if"))
5341 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5343 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5344 sw_if_index_set = 1;
5349 else if (unformat (i, "learn"))
5350 feature_bitmap |= L2INPUT_FEAT_LEARN;
5351 else if (unformat (i, "forward"))
5352 feature_bitmap |= L2INPUT_FEAT_FWD;
5353 else if (unformat (i, "flood"))
5354 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5355 else if (unformat (i, "uu-flood"))
5356 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5361 if (sw_if_index_set == 0)
5363 errmsg ("missing interface name or sw_if_index\n");
5367 M (L2_FLAGS, l2_flags);
5369 mp->sw_if_index = ntohl (sw_if_index);
5370 mp->feature_bitmap = ntohl (feature_bitmap);
5379 api_bridge_flags (vat_main_t * vam)
5381 unformat_input_t *i = vam->input;
5382 vl_api_bridge_flags_t *mp;
5389 /* Parse args required to build the message */
5390 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5392 if (unformat (i, "bd_id %d", &bd_id))
5394 else if (unformat (i, "learn"))
5396 else if (unformat (i, "forward"))
5398 else if (unformat (i, "flood"))
5400 else if (unformat (i, "uu-flood"))
5401 flags |= L2_UU_FLOOD;
5402 else if (unformat (i, "arp-term"))
5403 flags |= L2_ARP_TERM;
5404 else if (unformat (i, "off"))
5406 else if (unformat (i, "disable"))
5414 errmsg ("missing bridge domain\n");
5418 M (BRIDGE_FLAGS, bridge_flags);
5420 mp->bd_id = ntohl (bd_id);
5421 mp->feature_bitmap = ntohl (flags);
5422 mp->is_set = is_set;
5431 api_bd_ip_mac_add_del (vat_main_t * vam)
5433 unformat_input_t *i = vam->input;
5434 vl_api_bd_ip_mac_add_del_t *mp;
5442 ip4_address_t v4addr;
5443 ip6_address_t v6addr;
5447 /* Parse args required to build the message */
5448 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5450 if (unformat (i, "bd_id %d", &bd_id))
5454 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5458 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5463 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5467 else if (unformat (i, "del"))
5475 errmsg ("missing bridge domain\n");
5478 else if (ip_set == 0)
5480 errmsg ("missing IP address\n");
5483 else if (mac_set == 0)
5485 errmsg ("missing MAC address\n");
5489 M (BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del);
5491 mp->bd_id = ntohl (bd_id);
5492 mp->is_ipv6 = is_ipv6;
5493 mp->is_add = is_add;
5495 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5497 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5498 clib_memcpy (mp->mac_address, macaddr, 6);
5506 api_tap_connect (vat_main_t * vam)
5508 unformat_input_t *i = vam->input;
5509 vl_api_tap_connect_t *mp;
5516 memset (mac_address, 0, sizeof (mac_address));
5518 /* Parse args required to build the message */
5519 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5521 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5525 else if (unformat (i, "random-mac"))
5527 else if (unformat (i, "tapname %s", &tap_name))
5535 errmsg ("missing tap name\n");
5538 if (vec_len (tap_name) > 63)
5540 errmsg ("tap name too long\n");
5542 vec_add1 (tap_name, 0);
5544 /* Construct the API message */
5545 M (TAP_CONNECT, tap_connect);
5547 mp->use_random_mac = random_mac;
5548 clib_memcpy (mp->mac_address, mac_address, 6);
5549 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5550 vec_free (tap_name);
5555 /* Wait for a reply... */
5560 api_tap_modify (vat_main_t * vam)
5562 unformat_input_t *i = vam->input;
5563 vl_api_tap_modify_t *mp;
5569 u32 sw_if_index = ~0;
5570 u8 sw_if_index_set = 0;
5572 memset (mac_address, 0, sizeof (mac_address));
5574 /* Parse args required to build the message */
5575 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5577 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5578 sw_if_index_set = 1;
5579 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5580 sw_if_index_set = 1;
5581 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5585 else if (unformat (i, "random-mac"))
5587 else if (unformat (i, "tapname %s", &tap_name))
5593 if (sw_if_index_set == 0)
5595 errmsg ("missing vpp interface name");
5600 errmsg ("missing tap name\n");
5603 if (vec_len (tap_name) > 63)
5605 errmsg ("tap name too long\n");
5607 vec_add1 (tap_name, 0);
5609 /* Construct the API message */
5610 M (TAP_MODIFY, tap_modify);
5612 mp->use_random_mac = random_mac;
5613 mp->sw_if_index = ntohl (sw_if_index);
5614 clib_memcpy (mp->mac_address, mac_address, 6);
5615 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5616 vec_free (tap_name);
5621 /* Wait for a reply... */
5626 api_tap_delete (vat_main_t * vam)
5628 unformat_input_t *i = vam->input;
5629 vl_api_tap_delete_t *mp;
5631 u32 sw_if_index = ~0;
5632 u8 sw_if_index_set = 0;
5634 /* Parse args required to build the message */
5635 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5637 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5638 sw_if_index_set = 1;
5639 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5640 sw_if_index_set = 1;
5645 if (sw_if_index_set == 0)
5647 errmsg ("missing vpp interface name");
5651 /* Construct the API message */
5652 M (TAP_DELETE, tap_delete);
5654 mp->sw_if_index = ntohl (sw_if_index);
5659 /* Wait for a reply... */
5664 api_ip_add_del_route (vat_main_t * vam)
5666 unformat_input_t *i = vam->input;
5667 vl_api_ip_add_del_route_t *mp;
5669 u32 sw_if_index = ~0, vrf_id = 0;
5670 u8 sw_if_index_set = 0;
5672 u8 is_local = 0, is_drop = 0;
5673 u8 create_vrf_if_needed = 0;
5675 u8 next_hop_weight = 1;
5677 u8 is_multipath = 0;
5679 u8 address_length_set = 0;
5680 u32 lookup_in_vrf = 0;
5681 u32 resolve_attempts = 0;
5682 u32 dst_address_length = 0;
5683 u8 next_hop_set = 0;
5684 ip4_address_t v4_dst_address, v4_next_hop_address;
5685 ip6_address_t v6_dst_address, v6_next_hop_address;
5689 u32 random_add_del = 0;
5690 u32 *random_vector = 0;
5692 u32 random_seed = 0xdeaddabe;
5693 u32 classify_table_index = ~0;
5695 u8 resolve_host = 0, resolve_attached = 0;
5697 /* Parse args required to build the message */
5698 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5700 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5701 sw_if_index_set = 1;
5702 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5703 sw_if_index_set = 1;
5704 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
5709 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
5714 else if (unformat (i, "/%d", &dst_address_length))
5716 address_length_set = 1;
5719 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
5720 &v4_next_hop_address))
5724 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
5725 &v6_next_hop_address))
5729 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
5731 else if (unformat (i, "weight %d", &next_hop_weight))
5733 else if (unformat (i, "drop"))
5737 else if (unformat (i, "local"))
5741 else if (unformat (i, "classify %d", &classify_table_index))
5745 else if (unformat (i, "del"))
5747 else if (unformat (i, "add"))
5749 else if (unformat (i, "not-last"))
5751 else if (unformat (i, "resolve-via-host"))
5753 else if (unformat (i, "resolve-via-attached"))
5754 resolve_attached = 1;
5755 else if (unformat (i, "multipath"))
5757 else if (unformat (i, "vrf %d", &vrf_id))
5759 else if (unformat (i, "create-vrf"))
5760 create_vrf_if_needed = 1;
5761 else if (unformat (i, "count %d", &count))
5763 else if (unformat (i, "lookup-in-vrf %d", &lookup_in_vrf))
5765 else if (unformat (i, "random"))
5767 else if (unformat (i, "seed %d", &random_seed))
5771 clib_warning ("parse error '%U'", format_unformat_error, i);
5776 if (resolve_attempts > 0 && sw_if_index_set == 0)
5778 errmsg ("ARP resolution needs explicit interface or sw_if_index\n");
5782 if (!next_hop_set && !is_drop && !is_local && !is_classify)
5784 errmsg ("next hop / local / drop / classify not set\n");
5788 if (address_set == 0)
5790 errmsg ("missing addresses\n");
5794 if (address_length_set == 0)
5796 errmsg ("missing address length\n");
5800 /* Generate a pile of unique, random routes */
5803 u32 this_random_address;
5804 random_hash = hash_create (count, sizeof (uword));
5806 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
5807 for (j = 0; j <= count; j++)
5811 this_random_address = random_u32 (&random_seed);
5812 this_random_address =
5813 clib_host_to_net_u32 (this_random_address);
5815 while (hash_get (random_hash, this_random_address));
5816 vec_add1 (random_vector, this_random_address);
5817 hash_set (random_hash, this_random_address, 1);
5819 hash_free (random_hash);
5820 v4_dst_address.as_u32 = random_vector[0];
5825 /* Turn on async mode */
5826 vam->async_mode = 1;
5827 vam->async_errors = 0;
5828 before = vat_time_now (vam);
5831 for (j = 0; j < count; j++)
5833 /* Construct the API message */
5834 M (IP_ADD_DEL_ROUTE, ip_add_del_route);
5836 mp->next_hop_sw_if_index = ntohl (sw_if_index);
5837 mp->vrf_id = ntohl (vrf_id);
5838 if (resolve_attempts > 0)
5840 mp->resolve_attempts = ntohl (resolve_attempts);
5841 mp->resolve_if_needed = 1;
5843 mp->create_vrf_if_needed = create_vrf_if_needed;
5845 mp->is_add = is_add;
5846 mp->is_drop = is_drop;
5847 mp->is_ipv6 = is_ipv6;
5848 mp->is_local = is_local;
5849 mp->is_classify = is_classify;
5850 mp->is_multipath = is_multipath;
5851 mp->is_resolve_host = resolve_host;
5852 mp->is_resolve_attached = resolve_attached;
5853 mp->not_last = not_last;
5854 mp->next_hop_weight = next_hop_weight;
5855 mp->dst_address_length = dst_address_length;
5856 mp->lookup_in_vrf = ntohl (lookup_in_vrf);
5857 mp->classify_table_index = ntohl (classify_table_index);
5861 clib_memcpy (mp->dst_address, &v6_dst_address,
5862 sizeof (v6_dst_address));
5864 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
5865 sizeof (v6_next_hop_address));
5866 increment_v6_address (&v6_dst_address);
5870 clib_memcpy (mp->dst_address, &v4_dst_address,
5871 sizeof (v4_dst_address));
5873 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
5874 sizeof (v4_next_hop_address));
5876 v4_dst_address.as_u32 = random_vector[j + 1];
5878 increment_v4_address (&v4_dst_address);
5882 /* If we receive SIGTERM, stop now... */
5887 /* When testing multiple add/del ops, use a control-ping to sync */
5890 vl_api_control_ping_t *mp;
5893 /* Shut off async mode */
5894 vam->async_mode = 0;
5896 M (CONTROL_PING, control_ping);
5899 timeout = vat_time_now (vam) + 1.0;
5900 while (vat_time_now (vam) < timeout)
5901 if (vam->result_ready == 1)
5906 if (vam->retval == -99)
5907 errmsg ("timeout\n");
5909 if (vam->async_errors > 0)
5911 errmsg ("%d asynchronous errors\n", vam->async_errors);
5914 vam->async_errors = 0;
5915 after = vat_time_now (vam);
5917 /* slim chance, but we might have eaten SIGTERM on the first iteration */
5921 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
5922 count, after - before, count / (after - before));
5926 /* Wait for a reply... */
5930 /* Return the good/bad news */
5931 return (vam->retval);
5935 api_proxy_arp_add_del (vat_main_t * vam)
5937 unformat_input_t *i = vam->input;
5938 vl_api_proxy_arp_add_del_t *mp;
5942 ip4_address_t lo, hi;
5945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5947 if (unformat (i, "vrf %d", &vrf_id))
5949 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
5950 unformat_ip4_address, &hi))
5952 else if (unformat (i, "del"))
5956 clib_warning ("parse error '%U'", format_unformat_error, i);
5963 errmsg ("address range not set\n");
5967 M (PROXY_ARP_ADD_DEL, proxy_arp_add_del);
5969 mp->vrf_id = ntohl (vrf_id);
5970 mp->is_add = is_add;
5971 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
5972 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
5981 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
5983 unformat_input_t *i = vam->input;
5984 vl_api_proxy_arp_intfc_enable_disable_t *mp;
5988 u8 sw_if_index_set = 0;
5990 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5992 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5993 sw_if_index_set = 1;
5994 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5995 sw_if_index_set = 1;
5996 else if (unformat (i, "enable"))
5998 else if (unformat (i, "disable"))
6002 clib_warning ("parse error '%U'", format_unformat_error, i);
6007 if (sw_if_index_set == 0)
6009 errmsg ("missing interface name or sw_if_index\n");
6013 M (PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable);
6015 mp->sw_if_index = ntohl (sw_if_index);
6016 mp->enable_disable = enable;
6025 api_mpls_add_del_decap (vat_main_t * vam)
6027 unformat_input_t *i = vam->input;
6028 vl_api_mpls_add_del_decap_t *mp;
6037 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6039 if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
6041 else if (unformat (i, "tx_vrf_id %d", &tx_vrf_id))
6043 else if (unformat (i, "label %d", &label))
6045 else if (unformat (i, "next-index %d", &next_index))
6047 else if (unformat (i, "del"))
6049 else if (unformat (i, "s-bit-clear"))
6053 clib_warning ("parse error '%U'", format_unformat_error, i);
6058 M (MPLS_ADD_DEL_DECAP, mpls_add_del_decap);
6060 mp->rx_vrf_id = ntohl (rx_vrf_id);
6061 mp->tx_vrf_id = ntohl (tx_vrf_id);
6062 mp->label = ntohl (label);
6063 mp->next_index = ntohl (next_index);
6065 mp->is_add = is_add;
6074 api_mpls_add_del_encap (vat_main_t * vam)
6076 unformat_input_t *i = vam->input;
6077 vl_api_mpls_add_del_encap_t *mp;
6082 ip4_address_t dst_address;
6085 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6087 if (unformat (i, "vrf %d", &vrf_id))
6089 else if (unformat (i, "label %d", &label))
6090 vec_add1 (labels, ntohl (label));
6091 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
6093 else if (unformat (i, "del"))
6097 clib_warning ("parse error '%U'", format_unformat_error, i);
6102 if (vec_len (labels) == 0)
6104 errmsg ("missing encap label stack\n");
6108 M2 (MPLS_ADD_DEL_ENCAP, mpls_add_del_encap,
6109 sizeof (u32) * vec_len (labels));
6111 mp->vrf_id = ntohl (vrf_id);
6112 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
6113 mp->is_add = is_add;
6114 mp->nlabels = vec_len (labels);
6115 clib_memcpy (mp->labels, labels, sizeof (u32) * mp->nlabels);
6126 api_mpls_gre_add_del_tunnel (vat_main_t * vam)
6128 unformat_input_t *i = vam->input;
6129 vl_api_mpls_gre_add_del_tunnel_t *mp;
6131 u32 inner_vrf_id = 0;
6132 u32 outer_vrf_id = 0;
6133 ip4_address_t src_address;
6134 ip4_address_t dst_address;
6135 ip4_address_t intfc_address;
6137 u8 intfc_address_length = 0;
6141 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6143 if (unformat (i, "inner_vrf_id %d", &inner_vrf_id))
6145 else if (unformat (i, "outer_vrf_id %d", &outer_vrf_id))
6147 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
6149 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
6151 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
6152 &intfc_address, &tmp))
6153 intfc_address_length = tmp;
6154 else if (unformat (i, "l2-only"))
6156 else if (unformat (i, "del"))
6160 clib_warning ("parse error '%U'", format_unformat_error, i);
6165 M (MPLS_GRE_ADD_DEL_TUNNEL, mpls_gre_add_del_tunnel);
6167 mp->inner_vrf_id = ntohl (inner_vrf_id);
6168 mp->outer_vrf_id = ntohl (outer_vrf_id);
6169 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
6170 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
6171 clib_memcpy (mp->intfc_address, &intfc_address, sizeof (intfc_address));
6172 mp->intfc_address_length = intfc_address_length;
6173 mp->l2_only = l2_only;
6174 mp->is_add = is_add;
6183 api_mpls_ethernet_add_del_tunnel (vat_main_t * vam)
6185 unformat_input_t *i = vam->input;
6186 vl_api_mpls_ethernet_add_del_tunnel_t *mp;
6188 u32 inner_vrf_id = 0;
6189 ip4_address_t intfc_address;
6190 u8 dst_mac_address[6];
6193 u8 intfc_address_length = 0;
6197 int tx_sw_if_index_set = 0;
6199 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6201 if (unformat (i, "vrf %d", &inner_vrf_id))
6203 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
6204 &intfc_address, &tmp))
6205 intfc_address_length = tmp;
6206 else if (unformat (i, "%U", unformat_sw_if_index, vam, &tx_sw_if_index))
6207 tx_sw_if_index_set = 1;
6208 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6209 tx_sw_if_index_set = 1;
6210 else if (unformat (i, "dst %U", unformat_ethernet_address,
6213 else if (unformat (i, "l2-only"))
6215 else if (unformat (i, "del"))
6219 clib_warning ("parse error '%U'", format_unformat_error, i);
6226 errmsg ("dst (mac address) not set\n");
6229 if (!tx_sw_if_index_set)
6231 errmsg ("tx-intfc not set\n");
6235 M (MPLS_ETHERNET_ADD_DEL_TUNNEL, mpls_ethernet_add_del_tunnel);
6237 mp->vrf_id = ntohl (inner_vrf_id);
6238 clib_memcpy (mp->adj_address, &intfc_address, sizeof (intfc_address));
6239 mp->adj_address_length = intfc_address_length;
6240 clib_memcpy (mp->dst_mac_address, dst_mac_address,
6241 sizeof (dst_mac_address));
6242 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6243 mp->l2_only = l2_only;
6244 mp->is_add = is_add;
6253 api_mpls_ethernet_add_del_tunnel_2 (vat_main_t * vam)
6255 unformat_input_t *i = vam->input;
6256 vl_api_mpls_ethernet_add_del_tunnel_2_t *mp;
6258 u32 inner_vrf_id = 0;
6259 u32 outer_vrf_id = 0;
6260 ip4_address_t adj_address;
6261 int adj_address_set = 0;
6262 ip4_address_t next_hop_address;
6263 int next_hop_address_set = 0;
6265 u8 adj_address_length = 0;
6268 u32 resolve_attempts = 5;
6269 u8 resolve_if_needed = 1;
6271 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6273 if (unformat (i, "inner_vrf_id %d", &inner_vrf_id))
6275 else if (unformat (i, "outer_vrf_id %d", &outer_vrf_id))
6277 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
6278 &adj_address, &tmp))
6280 adj_address_length = tmp;
6281 adj_address_set = 1;
6283 else if (unformat (i, "next-hop %U", unformat_ip4_address,
6285 next_hop_address_set = 1;
6286 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6288 else if (unformat (i, "resolve-if-needed %d", &tmp))
6289 resolve_if_needed = tmp;
6290 else if (unformat (i, "l2-only"))
6292 else if (unformat (i, "del"))
6296 clib_warning ("parse error '%U'", format_unformat_error, i);
6301 if (!adj_address_set)
6303 errmsg ("adjacency address/mask not set\n");
6306 if (!next_hop_address_set)
6308 errmsg ("ip4 next hop address (in outer fib) not set\n");
6312 M (MPLS_ETHERNET_ADD_DEL_TUNNEL_2, mpls_ethernet_add_del_tunnel_2);
6314 mp->inner_vrf_id = ntohl (inner_vrf_id);
6315 mp->outer_vrf_id = ntohl (outer_vrf_id);
6316 mp->resolve_attempts = ntohl (resolve_attempts);
6317 mp->resolve_if_needed = resolve_if_needed;
6318 mp->is_add = is_add;
6319 mp->l2_only = l2_only;
6320 clib_memcpy (mp->adj_address, &adj_address, sizeof (adj_address));
6321 mp->adj_address_length = adj_address_length;
6322 clib_memcpy (mp->next_hop_ip4_address_in_outer_vrf, &next_hop_address,
6323 sizeof (next_hop_address));
6332 api_sw_interface_set_unnumbered (vat_main_t * vam)
6334 unformat_input_t *i = vam->input;
6335 vl_api_sw_interface_set_unnumbered_t *mp;
6338 u32 unnum_sw_index = ~0;
6340 u8 sw_if_index_set = 0;
6342 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6344 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6345 sw_if_index_set = 1;
6346 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6347 sw_if_index_set = 1;
6348 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
6350 else if (unformat (i, "del"))
6354 clib_warning ("parse error '%U'", format_unformat_error, i);
6359 if (sw_if_index_set == 0)
6361 errmsg ("missing interface name or sw_if_index\n");
6365 M (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered);
6367 mp->sw_if_index = ntohl (sw_if_index);
6368 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
6369 mp->is_add = is_add;
6378 api_ip_neighbor_add_del (vat_main_t * vam)
6380 unformat_input_t *i = vam->input;
6381 vl_api_ip_neighbor_add_del_t *mp;
6384 u8 sw_if_index_set = 0;
6390 u8 v4_address_set = 0;
6391 u8 v6_address_set = 0;
6392 ip4_address_t v4address;
6393 ip6_address_t v6address;
6395 memset (mac_address, 0, sizeof (mac_address));
6397 /* Parse args required to build the message */
6398 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6400 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6404 else if (unformat (i, "del"))
6406 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6407 sw_if_index_set = 1;
6408 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6409 sw_if_index_set = 1;
6410 else if (unformat (i, "is_static"))
6412 else if (unformat (i, "vrf %d", &vrf_id))
6414 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
6416 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
6420 clib_warning ("parse error '%U'", format_unformat_error, i);
6425 if (sw_if_index_set == 0)
6427 errmsg ("missing interface name or sw_if_index\n");
6430 if (v4_address_set && v6_address_set)
6432 errmsg ("both v4 and v6 addresses set\n");
6435 if (!v4_address_set && !v6_address_set)
6437 errmsg ("no address set\n");
6441 /* Construct the API message */
6442 M (IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del);
6444 mp->sw_if_index = ntohl (sw_if_index);
6445 mp->is_add = is_add;
6446 mp->vrf_id = ntohl (vrf_id);
6447 mp->is_static = is_static;
6449 clib_memcpy (mp->mac_address, mac_address, 6);
6453 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
6457 /* mp->is_ipv6 = 0; via memset in M macro above */
6458 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
6464 /* Wait for a reply, return good/bad news */
6472 api_reset_vrf (vat_main_t * vam)
6474 unformat_input_t *i = vam->input;
6475 vl_api_reset_vrf_t *mp;
6481 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6483 if (unformat (i, "vrf %d", &vrf_id))
6485 else if (unformat (i, "ipv6"))
6489 clib_warning ("parse error '%U'", format_unformat_error, i);
6494 if (vrf_id_set == 0)
6496 errmsg ("missing vrf id\n");
6500 M (RESET_VRF, reset_vrf);
6502 mp->vrf_id = ntohl (vrf_id);
6503 mp->is_ipv6 = is_ipv6;
6512 api_create_vlan_subif (vat_main_t * vam)
6514 unformat_input_t *i = vam->input;
6515 vl_api_create_vlan_subif_t *mp;
6518 u8 sw_if_index_set = 0;
6522 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6524 if (unformat (i, "sw_if_index %d", &sw_if_index))
6525 sw_if_index_set = 1;
6526 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6527 sw_if_index_set = 1;
6528 else if (unformat (i, "vlan %d", &vlan_id))
6532 clib_warning ("parse error '%U'", format_unformat_error, i);
6537 if (sw_if_index_set == 0)
6539 errmsg ("missing interface name or sw_if_index\n");
6543 if (vlan_id_set == 0)
6545 errmsg ("missing vlan_id\n");
6548 M (CREATE_VLAN_SUBIF, create_vlan_subif);
6550 mp->sw_if_index = ntohl (sw_if_index);
6551 mp->vlan_id = ntohl (vlan_id);
6559 #define foreach_create_subif_bit \
6566 _(outer_vlan_id_any) \
6567 _(inner_vlan_id_any)
6570 api_create_subif (vat_main_t * vam)
6572 unformat_input_t *i = vam->input;
6573 vl_api_create_subif_t *mp;
6576 u8 sw_if_index_set = 0;
6583 u32 exact_match = 0;
6584 u32 default_sub = 0;
6585 u32 outer_vlan_id_any = 0;
6586 u32 inner_vlan_id_any = 0;
6588 u16 outer_vlan_id = 0;
6589 u16 inner_vlan_id = 0;
6591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6593 if (unformat (i, "sw_if_index %d", &sw_if_index))
6594 sw_if_index_set = 1;
6595 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6596 sw_if_index_set = 1;
6597 else if (unformat (i, "sub_id %d", &sub_id))
6599 else if (unformat (i, "outer_vlan_id %d", &tmp))
6600 outer_vlan_id = tmp;
6601 else if (unformat (i, "inner_vlan_id %d", &tmp))
6602 inner_vlan_id = tmp;
6604 #define _(a) else if (unformat (i, #a)) a = 1 ;
6605 foreach_create_subif_bit
6609 clib_warning ("parse error '%U'", format_unformat_error, i);
6614 if (sw_if_index_set == 0)
6616 errmsg ("missing interface name or sw_if_index\n");
6620 if (sub_id_set == 0)
6622 errmsg ("missing sub_id\n");
6625 M (CREATE_SUBIF, create_subif);
6627 mp->sw_if_index = ntohl (sw_if_index);
6628 mp->sub_id = ntohl (sub_id);
6630 #define _(a) mp->a = a;
6631 foreach_create_subif_bit;
6634 mp->outer_vlan_id = ntohs (outer_vlan_id);
6635 mp->inner_vlan_id = ntohs (inner_vlan_id);
6644 api_oam_add_del (vat_main_t * vam)
6646 unformat_input_t *i = vam->input;
6647 vl_api_oam_add_del_t *mp;
6651 ip4_address_t src, dst;
6655 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6657 if (unformat (i, "vrf %d", &vrf_id))
6659 else if (unformat (i, "src %U", unformat_ip4_address, &src))
6661 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
6663 else if (unformat (i, "del"))
6667 clib_warning ("parse error '%U'", format_unformat_error, i);
6674 errmsg ("missing src addr\n");
6680 errmsg ("missing dst addr\n");
6684 M (OAM_ADD_DEL, oam_add_del);
6686 mp->vrf_id = ntohl (vrf_id);
6687 mp->is_add = is_add;
6688 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
6689 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
6698 api_reset_fib (vat_main_t * vam)
6700 unformat_input_t *i = vam->input;
6701 vl_api_reset_fib_t *mp;
6707 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6709 if (unformat (i, "vrf %d", &vrf_id))
6711 else if (unformat (i, "ipv6"))
6715 clib_warning ("parse error '%U'", format_unformat_error, i);
6720 if (vrf_id_set == 0)
6722 errmsg ("missing vrf id\n");
6726 M (RESET_FIB, reset_fib);
6728 mp->vrf_id = ntohl (vrf_id);
6729 mp->is_ipv6 = is_ipv6;
6738 api_dhcp_proxy_config (vat_main_t * vam)
6740 unformat_input_t *i = vam->input;
6741 vl_api_dhcp_proxy_config_t *mp;
6746 u8 v4_address_set = 0;
6747 u8 v6_address_set = 0;
6748 ip4_address_t v4address;
6749 ip6_address_t v6address;
6750 u8 v4_src_address_set = 0;
6751 u8 v6_src_address_set = 0;
6752 ip4_address_t v4srcaddress;
6753 ip6_address_t v6srcaddress;
6755 /* Parse args required to build the message */
6756 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6758 if (unformat (i, "del"))
6760 else if (unformat (i, "vrf %d", &vrf_id))
6762 else if (unformat (i, "insert-cid %d", &insert_cid))
6764 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
6766 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
6768 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
6769 v4_src_address_set = 1;
6770 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
6771 v6_src_address_set = 1;
6776 if (v4_address_set && v6_address_set)
6778 errmsg ("both v4 and v6 server addresses set\n");
6781 if (!v4_address_set && !v6_address_set)
6783 errmsg ("no server addresses set\n");
6787 if (v4_src_address_set && v6_src_address_set)
6789 errmsg ("both v4 and v6 src addresses set\n");
6792 if (!v4_src_address_set && !v6_src_address_set)
6794 errmsg ("no src addresses set\n");
6798 if (!(v4_src_address_set && v4_address_set) &&
6799 !(v6_src_address_set && v6_address_set))
6801 errmsg ("no matching server and src addresses set\n");
6805 /* Construct the API message */
6806 M (DHCP_PROXY_CONFIG, dhcp_proxy_config);
6808 mp->insert_circuit_id = insert_cid;
6809 mp->is_add = is_add;
6810 mp->vrf_id = ntohl (vrf_id);
6814 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
6815 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
6819 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
6820 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
6826 /* Wait for a reply, return good/bad news */
6833 api_dhcp_proxy_config_2 (vat_main_t * vam)
6835 unformat_input_t *i = vam->input;
6836 vl_api_dhcp_proxy_config_2_t *mp;
6839 u32 server_vrf_id = 0;
6842 u8 v4_address_set = 0;
6843 u8 v6_address_set = 0;
6844 ip4_address_t v4address;
6845 ip6_address_t v6address;
6846 u8 v4_src_address_set = 0;
6847 u8 v6_src_address_set = 0;
6848 ip4_address_t v4srcaddress;
6849 ip6_address_t v6srcaddress;
6851 /* Parse args required to build the message */
6852 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6854 if (unformat (i, "del"))
6856 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
6858 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
6860 else if (unformat (i, "insert-cid %d", &insert_cid))
6862 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
6864 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
6866 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
6867 v4_src_address_set = 1;
6868 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
6869 v6_src_address_set = 1;
6874 if (v4_address_set && v6_address_set)
6876 errmsg ("both v4 and v6 server addresses set\n");
6879 if (!v4_address_set && !v6_address_set)
6881 errmsg ("no server addresses set\n");
6885 if (v4_src_address_set && v6_src_address_set)
6887 errmsg ("both v4 and v6 src addresses set\n");
6890 if (!v4_src_address_set && !v6_src_address_set)
6892 errmsg ("no src addresses set\n");
6896 if (!(v4_src_address_set && v4_address_set) &&
6897 !(v6_src_address_set && v6_address_set))
6899 errmsg ("no matching server and src addresses set\n");
6903 /* Construct the API message */
6904 M (DHCP_PROXY_CONFIG_2, dhcp_proxy_config_2);
6906 mp->insert_circuit_id = insert_cid;
6907 mp->is_add = is_add;
6908 mp->rx_vrf_id = ntohl (rx_vrf_id);
6909 mp->server_vrf_id = ntohl (server_vrf_id);
6913 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
6914 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
6918 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
6919 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
6925 /* Wait for a reply, return good/bad news */
6932 api_dhcp_proxy_set_vss (vat_main_t * vam)
6934 unformat_input_t *i = vam->input;
6935 vl_api_dhcp_proxy_set_vss_t *mp;
6946 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6948 if (unformat (i, "tbl_id %d", &tbl_id))
6950 if (unformat (i, "fib_id %d", &fib_id))
6952 if (unformat (i, "oui %d", &oui))
6954 else if (unformat (i, "ipv6"))
6956 else if (unformat (i, "del"))
6960 clib_warning ("parse error '%U'", format_unformat_error, i);
6965 if (tbl_id_set == 0)
6967 errmsg ("missing tbl id\n");
6971 if (fib_id_set == 0)
6973 errmsg ("missing fib id\n");
6978 errmsg ("missing oui\n");
6982 M (DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss);
6983 mp->tbl_id = ntohl (tbl_id);
6984 mp->fib_id = ntohl (fib_id);
6985 mp->oui = ntohl (oui);
6986 mp->is_ipv6 = is_ipv6;
6987 mp->is_add = is_add;
6996 api_dhcp_client_config (vat_main_t * vam)
6998 unformat_input_t *i = vam->input;
6999 vl_api_dhcp_client_config_t *mp;
7002 u8 sw_if_index_set = 0;
7005 u8 disable_event = 0;
7007 /* Parse args required to build the message */
7008 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7010 if (unformat (i, "del"))
7012 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7013 sw_if_index_set = 1;
7014 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7015 sw_if_index_set = 1;
7016 else if (unformat (i, "hostname %s", &hostname))
7018 else if (unformat (i, "disable_event"))
7024 if (sw_if_index_set == 0)
7026 errmsg ("missing interface name or sw_if_index\n");
7030 if (vec_len (hostname) > 63)
7032 errmsg ("hostname too long\n");
7034 vec_add1 (hostname, 0);
7036 /* Construct the API message */
7037 M (DHCP_CLIENT_CONFIG, dhcp_client_config);
7039 mp->sw_if_index = ntohl (sw_if_index);
7040 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7041 vec_free (hostname);
7042 mp->is_add = is_add;
7043 mp->want_dhcp_event = disable_event ? 0 : 1;
7044 mp->pid = getpid ();
7049 /* Wait for a reply, return good/bad news */
7056 api_set_ip_flow_hash (vat_main_t * vam)
7058 unformat_input_t *i = vam->input;
7059 vl_api_set_ip_flow_hash_t *mp;
7071 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7073 if (unformat (i, "vrf %d", &vrf_id))
7075 else if (unformat (i, "ipv6"))
7077 else if (unformat (i, "src"))
7079 else if (unformat (i, "dst"))
7081 else if (unformat (i, "sport"))
7083 else if (unformat (i, "dport"))
7085 else if (unformat (i, "proto"))
7087 else if (unformat (i, "reverse"))
7092 clib_warning ("parse error '%U'", format_unformat_error, i);
7097 if (vrf_id_set == 0)
7099 errmsg ("missing vrf id\n");
7103 M (SET_IP_FLOW_HASH, set_ip_flow_hash);
7109 mp->reverse = reverse;
7110 mp->vrf_id = ntohl (vrf_id);
7111 mp->is_ipv6 = is_ipv6;
7120 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7122 unformat_input_t *i = vam->input;
7123 vl_api_sw_interface_ip6_enable_disable_t *mp;
7126 u8 sw_if_index_set = 0;
7129 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7131 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7132 sw_if_index_set = 1;
7133 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7134 sw_if_index_set = 1;
7135 else if (unformat (i, "enable"))
7137 else if (unformat (i, "disable"))
7141 clib_warning ("parse error '%U'", format_unformat_error, i);
7146 if (sw_if_index_set == 0)
7148 errmsg ("missing interface name or sw_if_index\n");
7152 M (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable);
7154 mp->sw_if_index = ntohl (sw_if_index);
7155 mp->enable = enable;
7164 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7166 unformat_input_t *i = vam->input;
7167 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7170 u8 sw_if_index_set = 0;
7171 u32 address_length = 0;
7172 u8 v6_address_set = 0;
7173 ip6_address_t v6address;
7175 /* Parse args required to build the message */
7176 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7178 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7179 sw_if_index_set = 1;
7180 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7181 sw_if_index_set = 1;
7182 else if (unformat (i, "%U/%d",
7183 unformat_ip6_address, &v6address, &address_length))
7189 if (sw_if_index_set == 0)
7191 errmsg ("missing interface name or sw_if_index\n");
7194 if (!v6_address_set)
7196 errmsg ("no address set\n");
7200 /* Construct the API message */
7201 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,
7202 sw_interface_ip6_set_link_local_address);
7204 mp->sw_if_index = ntohl (sw_if_index);
7205 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7206 mp->address_length = address_length;
7211 /* Wait for a reply, return good/bad news */
7220 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
7222 unformat_input_t *i = vam->input;
7223 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
7226 u8 sw_if_index_set = 0;
7227 u32 address_length = 0;
7228 u8 v6_address_set = 0;
7229 ip6_address_t v6address;
7231 u8 no_advertise = 0;
7233 u8 no_autoconfig = 0;
7236 u32 val_lifetime = 0;
7237 u32 pref_lifetime = 0;
7239 /* Parse args required to build the message */
7240 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7242 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7243 sw_if_index_set = 1;
7244 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7245 sw_if_index_set = 1;
7246 else if (unformat (i, "%U/%d",
7247 unformat_ip6_address, &v6address, &address_length))
7249 else if (unformat (i, "val_life %d", &val_lifetime))
7251 else if (unformat (i, "pref_life %d", &pref_lifetime))
7253 else if (unformat (i, "def"))
7255 else if (unformat (i, "noadv"))
7257 else if (unformat (i, "offl"))
7259 else if (unformat (i, "noauto"))
7261 else if (unformat (i, "nolink"))
7263 else if (unformat (i, "isno"))
7267 clib_warning ("parse error '%U'", format_unformat_error, i);
7272 if (sw_if_index_set == 0)
7274 errmsg ("missing interface name or sw_if_index\n");
7277 if (!v6_address_set)
7279 errmsg ("no address set\n");
7283 /* Construct the API message */
7284 M (SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix);
7286 mp->sw_if_index = ntohl (sw_if_index);
7287 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7288 mp->address_length = address_length;
7289 mp->use_default = use_default;
7290 mp->no_advertise = no_advertise;
7291 mp->off_link = off_link;
7292 mp->no_autoconfig = no_autoconfig;
7293 mp->no_onlink = no_onlink;
7295 mp->val_lifetime = ntohl (val_lifetime);
7296 mp->pref_lifetime = ntohl (pref_lifetime);
7301 /* Wait for a reply, return good/bad news */
7309 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
7311 unformat_input_t *i = vam->input;
7312 vl_api_sw_interface_ip6nd_ra_config_t *mp;
7315 u8 sw_if_index_set = 0;
7320 u8 send_unicast = 0;
7323 u8 default_router = 0;
7324 u32 max_interval = 0;
7325 u32 min_interval = 0;
7327 u32 initial_count = 0;
7328 u32 initial_interval = 0;
7331 /* Parse args required to build the message */
7332 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7334 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7335 sw_if_index_set = 1;
7336 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7337 sw_if_index_set = 1;
7338 else if (unformat (i, "maxint %d", &max_interval))
7340 else if (unformat (i, "minint %d", &min_interval))
7342 else if (unformat (i, "life %d", &lifetime))
7344 else if (unformat (i, "count %d", &initial_count))
7346 else if (unformat (i, "interval %d", &initial_interval))
7348 else if (unformat (i, "suppress") || unformat (i, "surpress"))
7350 else if (unformat (i, "managed"))
7352 else if (unformat (i, "other"))
7354 else if (unformat (i, "ll"))
7356 else if (unformat (i, "send"))
7358 else if (unformat (i, "cease"))
7360 else if (unformat (i, "isno"))
7362 else if (unformat (i, "def"))
7366 clib_warning ("parse error '%U'", format_unformat_error, i);
7371 if (sw_if_index_set == 0)
7373 errmsg ("missing interface name or sw_if_index\n");
7377 /* Construct the API message */
7378 M (SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config);
7380 mp->sw_if_index = ntohl (sw_if_index);
7381 mp->max_interval = ntohl (max_interval);
7382 mp->min_interval = ntohl (min_interval);
7383 mp->lifetime = ntohl (lifetime);
7384 mp->initial_count = ntohl (initial_count);
7385 mp->initial_interval = ntohl (initial_interval);
7386 mp->suppress = suppress;
7387 mp->managed = managed;
7389 mp->ll_option = ll_option;
7390 mp->send_unicast = send_unicast;
7393 mp->default_router = default_router;
7398 /* Wait for a reply, return good/bad news */
7406 api_set_arp_neighbor_limit (vat_main_t * vam)
7408 unformat_input_t *i = vam->input;
7409 vl_api_set_arp_neighbor_limit_t *mp;
7415 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7417 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
7419 else if (unformat (i, "ipv6"))
7423 clib_warning ("parse error '%U'", format_unformat_error, i);
7430 errmsg ("missing limit value\n");
7434 M (SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit);
7436 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
7437 mp->is_ipv6 = is_ipv6;
7446 api_l2_patch_add_del (vat_main_t * vam)
7448 unformat_input_t *i = vam->input;
7449 vl_api_l2_patch_add_del_t *mp;
7452 u8 rx_sw_if_index_set = 0;
7454 u8 tx_sw_if_index_set = 0;
7457 /* Parse args required to build the message */
7458 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7460 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7461 rx_sw_if_index_set = 1;
7462 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7463 tx_sw_if_index_set = 1;
7464 else if (unformat (i, "rx"))
7466 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7468 if (unformat (i, "%U", unformat_sw_if_index, vam,
7470 rx_sw_if_index_set = 1;
7475 else if (unformat (i, "tx"))
7477 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7479 if (unformat (i, "%U", unformat_sw_if_index, vam,
7481 tx_sw_if_index_set = 1;
7486 else if (unformat (i, "del"))
7492 if (rx_sw_if_index_set == 0)
7494 errmsg ("missing rx interface name or rx_sw_if_index\n");
7498 if (tx_sw_if_index_set == 0)
7500 errmsg ("missing tx interface name or tx_sw_if_index\n");
7504 M (L2_PATCH_ADD_DEL, l2_patch_add_del);
7506 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7507 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7508 mp->is_add = is_add;
7517 api_ioam_enable (vat_main_t * vam)
7519 unformat_input_t *input = vam->input;
7520 vl_api_ioam_enable_t *mp;
7523 int has_trace_option = 0;
7524 int has_pow_option = 0;
7525 int has_ppc_option = 0;
7527 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7529 if (unformat (input, "trace"))
7530 has_trace_option = 1;
7531 else if (unformat (input, "pow"))
7533 else if (unformat (input, "ppc encap"))
7534 has_ppc_option = PPC_ENCAP;
7535 else if (unformat (input, "ppc decap"))
7536 has_ppc_option = PPC_DECAP;
7537 else if (unformat (input, "ppc none"))
7538 has_ppc_option = PPC_NONE;
7542 M (IOAM_ENABLE, ioam_enable);
7543 mp->id = htons (id);
7544 mp->trace_ppc = has_ppc_option;
7545 mp->pow_enable = has_pow_option;
7546 mp->trace_enable = has_trace_option;
7557 api_ioam_disable (vat_main_t * vam)
7559 vl_api_ioam_disable_t *mp;
7562 M (IOAM_DISABLE, ioam_disable);
7569 api_sr_tunnel_add_del (vat_main_t * vam)
7571 unformat_input_t *i = vam->input;
7572 vl_api_sr_tunnel_add_del_t *mp;
7576 ip6_address_t src_address;
7577 int src_address_set = 0;
7578 ip6_address_t dst_address;
7580 int dst_address_set = 0;
7582 u32 rx_table_id = 0;
7583 u32 tx_table_id = 0;
7584 ip6_address_t *segments = 0;
7585 ip6_address_t *this_seg;
7586 ip6_address_t *tags = 0;
7587 ip6_address_t *this_tag;
7588 ip6_address_t next_address, tag;
7590 u8 *policy_name = 0;
7592 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7594 if (unformat (i, "del"))
7596 else if (unformat (i, "name %s", &name))
7598 else if (unformat (i, "policy %s", &policy_name))
7600 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
7602 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
7604 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
7605 src_address_set = 1;
7606 else if (unformat (i, "dst %U/%d",
7607 unformat_ip6_address, &dst_address, &dst_mask_width))
7608 dst_address_set = 1;
7609 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
7611 vec_add2 (segments, this_seg, 1);
7612 clib_memcpy (this_seg->as_u8, next_address.as_u8,
7613 sizeof (*this_seg));
7615 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
7617 vec_add2 (tags, this_tag, 1);
7618 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
7620 else if (unformat (i, "clean"))
7621 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
7622 else if (unformat (i, "protected"))
7623 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
7624 else if (unformat (i, "InPE %d", &pl_index))
7626 if (pl_index <= 0 || pl_index > 4)
7628 pl_index_range_error:
7629 errmsg ("pl index %d out of range\n", pl_index);
7633 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
7635 else if (unformat (i, "EgPE %d", &pl_index))
7637 if (pl_index <= 0 || pl_index > 4)
7638 goto pl_index_range_error;
7640 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
7642 else if (unformat (i, "OrgSrc %d", &pl_index))
7644 if (pl_index <= 0 || pl_index > 4)
7645 goto pl_index_range_error;
7647 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
7653 if (!src_address_set)
7655 errmsg ("src address required\n");
7659 if (!dst_address_set)
7661 errmsg ("dst address required\n");
7667 errmsg ("at least one sr segment required\n");
7671 M2 (SR_TUNNEL_ADD_DEL, sr_tunnel_add_del,
7672 vec_len (segments) * sizeof (ip6_address_t)
7673 + vec_len (tags) * sizeof (ip6_address_t));
7675 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
7676 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
7677 mp->dst_mask_width = dst_mask_width;
7678 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
7679 mp->n_segments = vec_len (segments);
7680 mp->n_tags = vec_len (tags);
7681 mp->is_add = is_del == 0;
7682 clib_memcpy (mp->segs_and_tags, segments,
7683 vec_len (segments) * sizeof (ip6_address_t));
7684 clib_memcpy (mp->segs_and_tags +
7685 vec_len (segments) * sizeof (ip6_address_t), tags,
7686 vec_len (tags) * sizeof (ip6_address_t));
7688 mp->outer_vrf_id = ntohl (rx_table_id);
7689 mp->inner_vrf_id = ntohl (tx_table_id);
7690 memcpy (mp->name, name, vec_len (name));
7691 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
7693 vec_free (segments);
7702 api_sr_policy_add_del (vat_main_t * vam)
7704 unformat_input_t *input = vam->input;
7705 vl_api_sr_policy_add_del_t *mp;
7709 u8 *tunnel_name = 0;
7710 u8 **tunnel_names = 0;
7715 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
7716 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
7718 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7720 if (unformat (input, "del"))
7722 else if (unformat (input, "name %s", &name))
7724 else if (unformat (input, "tunnel %s", &tunnel_name))
7728 vec_add1 (tunnel_names, tunnel_name);
7730 - length = #bytes to store in serial vector
7731 - +1 = byte to store that length
7733 tunnel_names_length += (vec_len (tunnel_name) + 1);
7744 errmsg ("policy name required\n");
7748 if ((!tunnel_set) && (!is_del))
7750 errmsg ("tunnel name required\n");
7754 M2 (SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length);
7758 mp->is_add = !is_del;
7760 memcpy (mp->name, name, vec_len (name));
7761 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
7762 u8 *serial_orig = 0;
7763 vec_validate (serial_orig, tunnel_names_length);
7764 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
7765 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
7767 for (j = 0; j < vec_len (tunnel_names); j++)
7769 tun_name_len = vec_len (tunnel_names[j]);
7770 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
7771 serial_orig += 1; // Move along one byte to store the actual tunnel name
7772 memcpy (serial_orig, tunnel_names[j], tun_name_len);
7773 serial_orig += tun_name_len; // Advance past the copy
7775 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
7777 vec_free (tunnel_names);
7778 vec_free (tunnel_name);
7786 api_sr_multicast_map_add_del (vat_main_t * vam)
7788 unformat_input_t *input = vam->input;
7789 vl_api_sr_multicast_map_add_del_t *mp;
7792 ip6_address_t multicast_address;
7793 u8 *policy_name = 0;
7794 int multicast_address_set = 0;
7796 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7798 if (unformat (input, "del"))
7802 (input, "address %U", unformat_ip6_address, &multicast_address))
7803 multicast_address_set = 1;
7804 else if (unformat (input, "sr-policy %s", &policy_name))
7810 if (!is_del && !policy_name)
7812 errmsg ("sr-policy name required\n");
7817 if (!multicast_address_set)
7819 errmsg ("address required\n");
7823 M (SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del);
7825 mp->is_add = !is_del;
7826 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
7827 clib_memcpy (mp->multicast_address, &multicast_address,
7828 sizeof (mp->multicast_address));
7831 vec_free (policy_name);
7839 #define foreach_ip4_proto_field \
7850 unformat_ip4_mask (unformat_input_t * input, va_list * args)
7852 u8 **maskp = va_arg (*args, u8 **);
7854 u8 found_something = 0;
7857 #define _(a) u8 a=0;
7858 foreach_ip4_proto_field;
7864 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7866 if (unformat (input, "version"))
7868 else if (unformat (input, "hdr_length"))
7870 else if (unformat (input, "src"))
7872 else if (unformat (input, "dst"))
7874 else if (unformat (input, "proto"))
7877 #define _(a) else if (unformat (input, #a)) a=1;
7878 foreach_ip4_proto_field
7884 #define _(a) found_something += a;
7885 foreach_ip4_proto_field;
7888 if (found_something == 0)
7891 vec_validate (mask, sizeof (*ip) - 1);
7893 ip = (ip4_header_t *) mask;
7895 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
7896 foreach_ip4_proto_field;
7899 ip->ip_version_and_header_length = 0;
7902 ip->ip_version_and_header_length |= 0xF0;
7905 ip->ip_version_and_header_length |= 0x0F;
7911 #define foreach_ip6_proto_field \
7919 unformat_ip6_mask (unformat_input_t * input, va_list * args)
7921 u8 **maskp = va_arg (*args, u8 **);
7923 u8 found_something = 0;
7925 u32 ip_version_traffic_class_and_flow_label;
7927 #define _(a) u8 a=0;
7928 foreach_ip6_proto_field;
7931 u8 traffic_class = 0;
7934 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7936 if (unformat (input, "version"))
7938 else if (unformat (input, "traffic-class"))
7940 else if (unformat (input, "flow-label"))
7942 else if (unformat (input, "src"))
7944 else if (unformat (input, "dst"))
7946 else if (unformat (input, "proto"))
7949 #define _(a) else if (unformat (input, #a)) a=1;
7950 foreach_ip6_proto_field
7956 #define _(a) found_something += a;
7957 foreach_ip6_proto_field;
7960 if (found_something == 0)
7963 vec_validate (mask, sizeof (*ip) - 1);
7965 ip = (ip6_header_t *) mask;
7967 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
7968 foreach_ip6_proto_field;
7971 ip_version_traffic_class_and_flow_label = 0;
7974 ip_version_traffic_class_and_flow_label |= 0xF0000000;
7977 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
7980 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
7982 ip->ip_version_traffic_class_and_flow_label =
7983 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
7990 unformat_l3_mask (unformat_input_t * input, va_list * args)
7992 u8 **maskp = va_arg (*args, u8 **);
7994 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7996 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
7998 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8007 unformat_l2_mask (unformat_input_t * input, va_list * args)
8009 u8 **maskp = va_arg (*args, u8 **);
8024 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8026 if (unformat (input, "src"))
8028 else if (unformat (input, "dst"))
8030 else if (unformat (input, "proto"))
8032 else if (unformat (input, "tag1"))
8034 else if (unformat (input, "tag2"))
8036 else if (unformat (input, "ignore-tag1"))
8038 else if (unformat (input, "ignore-tag2"))
8040 else if (unformat (input, "cos1"))
8042 else if (unformat (input, "cos2"))
8044 else if (unformat (input, "dot1q"))
8046 else if (unformat (input, "dot1ad"))
8051 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8052 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8055 if (tag1 || ignore_tag1 || cos1 || dot1q)
8057 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8060 vec_validate (mask, len - 1);
8063 memset (mask, 0xff, 6);
8066 memset (mask + 6, 0xff, 6);
8070 /* inner vlan tag */
8079 mask[21] = mask[20] = 0xff;
8100 mask[16] = mask[17] = 0xff;
8110 mask[12] = mask[13] = 0xff;
8117 unformat_classify_mask (unformat_input_t * input, va_list * args)
8119 u8 **maskp = va_arg (*args, u8 **);
8120 u32 *skipp = va_arg (*args, u32 *);
8121 u32 *matchp = va_arg (*args, u32 *);
8128 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8130 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8132 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8134 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8140 if (mask || l2 || l3)
8144 /* "With a free Ethernet header in every package" */
8146 vec_validate (l2, 13);
8150 vec_append (mask, l3);
8155 /* Scan forward looking for the first significant mask octet */
8156 for (i = 0; i < vec_len (mask); i++)
8160 /* compute (skip, match) params */
8161 *skipp = i / sizeof (u32x4);
8162 vec_delete (mask, *skipp * sizeof (u32x4), 0);
8164 /* Pad mask to an even multiple of the vector size */
8165 while (vec_len (mask) % sizeof (u32x4))
8168 match = vec_len (mask) / sizeof (u32x4);
8170 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
8172 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
8173 if (*tmp || *(tmp + 1))
8178 clib_warning ("BUG: match 0");
8180 _vec_len (mask) = match * sizeof (u32x4);
8191 #define foreach_l2_next \
8193 _(ethernet, ETHERNET_INPUT) \
8198 unformat_l2_next_index (unformat_input_t * input, va_list * args)
8200 u32 *miss_next_indexp = va_arg (*args, u32 *);
8205 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
8209 if (unformat (input, "%d", &tmp))
8218 *miss_next_indexp = next_index;
8222 #define foreach_ip_next \
8228 unformat_ip_next_index (unformat_input_t * input, va_list * args)
8230 u32 *miss_next_indexp = va_arg (*args, u32 *);
8235 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
8239 if (unformat (input, "%d", &tmp))
8248 *miss_next_indexp = next_index;
8252 #define foreach_acl_next \
8256 unformat_acl_next_index (unformat_input_t * input, va_list * args)
8258 u32 *miss_next_indexp = va_arg (*args, u32 *);
8263 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
8267 if (unformat (input, "permit"))
8272 else if (unformat (input, "%d", &tmp))
8281 *miss_next_indexp = next_index;
8286 unformat_policer_precolor (unformat_input_t * input, va_list * args)
8288 u32 *r = va_arg (*args, u32 *);
8290 if (unformat (input, "conform-color"))
8291 *r = POLICE_CONFORM;
8292 else if (unformat (input, "exceed-color"))
8301 api_classify_add_del_table (vat_main_t * vam)
8303 unformat_input_t *i = vam->input;
8304 vl_api_classify_add_del_table_t *mp;
8310 u32 table_index = ~0;
8311 u32 next_table_index = ~0;
8312 u32 miss_next_index = ~0;
8313 u32 memory_size = 32 << 20;
8317 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8319 if (unformat (i, "del"))
8321 else if (unformat (i, "buckets %d", &nbuckets))
8323 else if (unformat (i, "memory_size %d", &memory_size))
8325 else if (unformat (i, "skip %d", &skip))
8327 else if (unformat (i, "match %d", &match))
8329 else if (unformat (i, "table %d", &table_index))
8331 else if (unformat (i, "mask %U", unformat_classify_mask,
8332 &mask, &skip, &match))
8334 else if (unformat (i, "next-table %d", &next_table_index))
8336 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
8339 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
8342 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
8349 if (is_add && mask == 0)
8351 errmsg ("Mask required\n");
8355 if (is_add && skip == ~0)
8357 errmsg ("skip count required\n");
8361 if (is_add && match == ~0)
8363 errmsg ("match count required\n");
8367 if (!is_add && table_index == ~0)
8369 errmsg ("table index required for delete\n");
8373 M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask));
8375 mp->is_add = is_add;
8376 mp->table_index = ntohl (table_index);
8377 mp->nbuckets = ntohl (nbuckets);
8378 mp->memory_size = ntohl (memory_size);
8379 mp->skip_n_vectors = ntohl (skip);
8380 mp->match_n_vectors = ntohl (match);
8381 mp->next_table_index = ntohl (next_table_index);
8382 mp->miss_next_index = ntohl (miss_next_index);
8383 clib_memcpy (mp->mask, mask, vec_len (mask));
8393 unformat_ip4_match (unformat_input_t * input, va_list * args)
8395 u8 **matchp = va_arg (*args, u8 **);
8402 int src = 0, dst = 0;
8403 ip4_address_t src_val, dst_val;
8410 int fragment_id = 0;
8411 u32 fragment_id_val;
8417 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8419 if (unformat (input, "version %d", &version_val))
8421 else if (unformat (input, "hdr_length %d", &hdr_length_val))
8423 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
8425 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
8427 else if (unformat (input, "proto %d", &proto_val))
8429 else if (unformat (input, "tos %d", &tos_val))
8431 else if (unformat (input, "length %d", &length_val))
8433 else if (unformat (input, "fragment_id %d", &fragment_id_val))
8435 else if (unformat (input, "ttl %d", &ttl_val))
8437 else if (unformat (input, "checksum %d", &checksum_val))
8443 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
8444 + ttl + checksum == 0)
8448 * Aligned because we use the real comparison functions
8450 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
8452 ip = (ip4_header_t *) match;
8454 /* These are realistically matched in practice */
8456 ip->src_address.as_u32 = src_val.as_u32;
8459 ip->dst_address.as_u32 = dst_val.as_u32;
8462 ip->protocol = proto_val;
8465 /* These are not, but they're included for completeness */
8467 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
8470 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
8476 ip->length = length_val;
8482 ip->checksum = checksum_val;
8489 unformat_ip6_match (unformat_input_t * input, va_list * args)
8491 u8 **matchp = va_arg (*args, u8 **);
8496 u8 traffic_class = 0;
8497 u32 traffic_class_val = 0;
8500 int src = 0, dst = 0;
8501 ip6_address_t src_val, dst_val;
8504 int payload_length = 0;
8505 u32 payload_length_val;
8508 u32 ip_version_traffic_class_and_flow_label;
8510 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8512 if (unformat (input, "version %d", &version_val))
8514 else if (unformat (input, "traffic_class %d", &traffic_class_val))
8516 else if (unformat (input, "flow_label %d", &flow_label_val))
8518 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
8520 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
8522 else if (unformat (input, "proto %d", &proto_val))
8524 else if (unformat (input, "payload_length %d", &payload_length_val))
8526 else if (unformat (input, "hop_limit %d", &hop_limit_val))
8532 if (version + traffic_class + flow_label + src + dst + proto +
8533 payload_length + hop_limit == 0)
8537 * Aligned because we use the real comparison functions
8539 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
8541 ip = (ip6_header_t *) match;
8544 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
8547 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
8550 ip->protocol = proto_val;
8552 ip_version_traffic_class_and_flow_label = 0;
8555 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
8558 ip_version_traffic_class_and_flow_label |=
8559 (traffic_class_val & 0xFF) << 20;
8562 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
8564 ip->ip_version_traffic_class_and_flow_label =
8565 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8568 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
8571 ip->hop_limit = hop_limit_val;
8578 unformat_l3_match (unformat_input_t * input, va_list * args)
8580 u8 **matchp = va_arg (*args, u8 **);
8582 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8584 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
8586 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
8595 unformat_vlan_tag (unformat_input_t * input, va_list * args)
8597 u8 *tagp = va_arg (*args, u8 *);
8600 if (unformat (input, "%d", &tag))
8602 tagp[0] = (tag >> 8) & 0x0F;
8603 tagp[1] = tag & 0xFF;
8611 unformat_l2_match (unformat_input_t * input, va_list * args)
8613 u8 **matchp = va_arg (*args, u8 **);
8633 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8635 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
8638 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
8640 else if (unformat (input, "proto %U",
8641 unformat_ethernet_type_host_byte_order, &proto_val))
8643 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
8645 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
8647 else if (unformat (input, "ignore-tag1"))
8649 else if (unformat (input, "ignore-tag2"))
8651 else if (unformat (input, "cos1 %d", &cos1_val))
8653 else if (unformat (input, "cos2 %d", &cos2_val))
8658 if ((src + dst + proto + tag1 + tag2 +
8659 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8662 if (tag1 || ignore_tag1 || cos1)
8664 if (tag2 || ignore_tag2 || cos2)
8667 vec_validate_aligned (match, len - 1, sizeof (u32x4));
8670 clib_memcpy (match, dst_val, 6);
8673 clib_memcpy (match + 6, src_val, 6);
8677 /* inner vlan tag */
8678 match[19] = tag2_val[1];
8679 match[18] = tag2_val[0];
8681 match[18] |= (cos2_val & 0x7) << 5;
8684 match[21] = proto_val & 0xff;
8685 match[20] = proto_val >> 8;
8689 match[15] = tag1_val[1];
8690 match[14] = tag1_val[0];
8693 match[14] |= (cos1_val & 0x7) << 5;
8699 match[15] = tag1_val[1];
8700 match[14] = tag1_val[0];
8703 match[17] = proto_val & 0xff;
8704 match[16] = proto_val >> 8;
8707 match[14] |= (cos1_val & 0x7) << 5;
8713 match[18] |= (cos2_val & 0x7) << 5;
8715 match[14] |= (cos1_val & 0x7) << 5;
8718 match[13] = proto_val & 0xff;
8719 match[12] = proto_val >> 8;
8728 unformat_classify_match (unformat_input_t * input, va_list * args)
8730 u8 **matchp = va_arg (*args, u8 **);
8731 u32 skip_n_vectors = va_arg (*args, u32);
8732 u32 match_n_vectors = va_arg (*args, u32);
8738 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8740 if (unformat (input, "hex %U", unformat_hex_string, &match))
8742 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
8744 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
8750 if (match || l2 || l3)
8754 /* "Win a free Ethernet header in every packet" */
8756 vec_validate_aligned (l2, 13, sizeof (u32x4));
8760 vec_append_aligned (match, l3, sizeof (u32x4));
8765 /* Make sure the vector is big enough even if key is all 0's */
8766 vec_validate_aligned
8767 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
8770 /* Set size, include skipped vectors */
8771 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
8782 api_classify_add_del_session (vat_main_t * vam)
8784 unformat_input_t *i = vam->input;
8785 vl_api_classify_add_del_session_t *mp;
8787 u32 table_index = ~0;
8788 u32 hit_next_index = ~0;
8789 u32 opaque_index = ~0;
8793 u32 skip_n_vectors = 0;
8794 u32 match_n_vectors = 0;
8797 * Warning: you have to supply skip_n and match_n
8798 * because the API client cant simply look at the classify
8802 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8804 if (unformat (i, "del"))
8806 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
8809 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
8812 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
8815 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
8817 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
8819 else if (unformat (i, "opaque-index %d", &opaque_index))
8821 else if (unformat (i, "skip_n %d", &skip_n_vectors))
8823 else if (unformat (i, "match_n %d", &match_n_vectors))
8825 else if (unformat (i, "match %U", unformat_classify_match,
8826 &match, skip_n_vectors, match_n_vectors))
8828 else if (unformat (i, "advance %d", &advance))
8830 else if (unformat (i, "table-index %d", &table_index))
8836 if (table_index == ~0)
8838 errmsg ("Table index required\n");
8842 if (is_add && match == 0)
8844 errmsg ("Match value required\n");
8848 M2 (CLASSIFY_ADD_DEL_SESSION, classify_add_del_session, vec_len (match));
8850 mp->is_add = is_add;
8851 mp->table_index = ntohl (table_index);
8852 mp->hit_next_index = ntohl (hit_next_index);
8853 mp->opaque_index = ntohl (opaque_index);
8854 mp->advance = ntohl (advance);
8855 clib_memcpy (mp->match, match, vec_len (match));
8864 api_classify_set_interface_ip_table (vat_main_t * vam)
8866 unformat_input_t *i = vam->input;
8867 vl_api_classify_set_interface_ip_table_t *mp;
8870 int sw_if_index_set;
8871 u32 table_index = ~0;
8874 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8876 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8877 sw_if_index_set = 1;
8878 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8879 sw_if_index_set = 1;
8880 else if (unformat (i, "table %d", &table_index))
8884 clib_warning ("parse error '%U'", format_unformat_error, i);
8889 if (sw_if_index_set == 0)
8891 errmsg ("missing interface name or sw_if_index\n");
8896 M (CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table);
8898 mp->sw_if_index = ntohl (sw_if_index);
8899 mp->table_index = ntohl (table_index);
8900 mp->is_ipv6 = is_ipv6;
8909 api_classify_set_interface_l2_tables (vat_main_t * vam)
8911 unformat_input_t *i = vam->input;
8912 vl_api_classify_set_interface_l2_tables_t *mp;
8915 int sw_if_index_set;
8916 u32 ip4_table_index = ~0;
8917 u32 ip6_table_index = ~0;
8918 u32 other_table_index = ~0;
8921 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8923 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
8924 sw_if_index_set = 1;
8925 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8926 sw_if_index_set = 1;
8927 else if (unformat (i, "ip4-table %d", &ip4_table_index))
8929 else if (unformat (i, "ip6-table %d", &ip6_table_index))
8931 else if (unformat (i, "other-table %d", &other_table_index))
8933 else if (unformat (i, "is-input %d", &is_input))
8937 clib_warning ("parse error '%U'", format_unformat_error, i);
8942 if (sw_if_index_set == 0)
8944 errmsg ("missing interface name or sw_if_index\n");
8949 M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables);
8951 mp->sw_if_index = ntohl (sw_if_index);
8952 mp->ip4_table_index = ntohl (ip4_table_index);
8953 mp->ip6_table_index = ntohl (ip6_table_index);
8954 mp->other_table_index = ntohl (other_table_index);
8955 mp->is_input = (u8) is_input;
8964 api_set_ipfix_exporter (vat_main_t * vam)
8966 unformat_input_t *i = vam->input;
8967 vl_api_set_ipfix_exporter_t *mp;
8968 ip4_address_t collector_address;
8969 u8 collector_address_set = 0;
8970 u32 collector_port = ~0;
8971 ip4_address_t src_address;
8972 u8 src_address_set = 0;
8975 u32 template_interval = ~0;
8976 u8 udp_checksum = 0;
8979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8981 if (unformat (i, "collector_address %U", unformat_ip4_address,
8982 &collector_address))
8983 collector_address_set = 1;
8984 else if (unformat (i, "collector_port %d", &collector_port))
8986 else if (unformat (i, "src_address %U", unformat_ip4_address,
8988 src_address_set = 1;
8989 else if (unformat (i, "vrf_id %d", &vrf_id))
8991 else if (unformat (i, "path_mtu %d", &path_mtu))
8993 else if (unformat (i, "template_interval %d", &template_interval))
8995 else if (unformat (i, "udp_checksum"))
9001 if (collector_address_set == 0)
9003 errmsg ("collector_address required\n");
9007 if (src_address_set == 0)
9009 errmsg ("src_address required\n");
9013 M (SET_IPFIX_EXPORTER, set_ipfix_exporter);
9015 memcpy (mp->collector_address, collector_address.data,
9016 sizeof (collector_address.data));
9017 mp->collector_port = htons ((u16) collector_port);
9018 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
9019 mp->vrf_id = htonl (vrf_id);
9020 mp->path_mtu = htonl (path_mtu);
9021 mp->template_interval = htonl (template_interval);
9022 mp->udp_checksum = udp_checksum;
9030 api_set_ipfix_classify_stream (vat_main_t * vam)
9032 unformat_input_t *i = vam->input;
9033 vl_api_set_ipfix_classify_stream_t *mp;
9035 u32 src_port = UDP_DST_PORT_ipfix;
9038 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9040 if (unformat (i, "domain %d", &domain_id))
9042 else if (unformat (i, "src_port %d", &src_port))
9046 errmsg ("unknown input `%U'", format_unformat_error, i);
9051 M (SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream);
9053 mp->domain_id = htonl (domain_id);
9054 mp->src_port = htons ((u16) src_port);
9062 api_ipfix_classify_table_add_del (vat_main_t * vam)
9064 unformat_input_t *i = vam->input;
9065 vl_api_ipfix_classify_table_add_del_t *mp;
9067 u32 classify_table_index = ~0;
9069 u8 transport_protocol = 255;
9072 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9074 if (unformat (i, "add"))
9076 else if (unformat (i, "del"))
9078 else if (unformat (i, "table %d", &classify_table_index))
9080 else if (unformat (i, "ip4"))
9082 else if (unformat (i, "ip6"))
9084 else if (unformat (i, "tcp"))
9085 transport_protocol = 6;
9086 else if (unformat (i, "udp"))
9087 transport_protocol = 17;
9090 errmsg ("unknown input `%U'", format_unformat_error, i);
9097 errmsg ("expecting: add|del");
9100 if (classify_table_index == ~0)
9102 errmsg ("classifier table not specified");
9105 if (ip_version == 0)
9107 errmsg ("IP version not specified");
9111 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del);
9113 mp->is_add = is_add;
9114 mp->table_id = htonl (classify_table_index);
9115 mp->ip_version = ip_version;
9116 mp->transport_protocol = transport_protocol;
9124 api_get_node_index (vat_main_t * vam)
9126 unformat_input_t *i = vam->input;
9127 vl_api_get_node_index_t *mp;
9131 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9133 if (unformat (i, "node %s", &name))
9140 errmsg ("node name required\n");
9143 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9145 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9149 M (GET_NODE_INDEX, get_node_index);
9150 clib_memcpy (mp->node_name, name, vec_len (name));
9160 api_get_next_index (vat_main_t * vam)
9162 unformat_input_t *i = vam->input;
9163 vl_api_get_next_index_t *mp;
9165 u8 *node_name = 0, *next_node_name = 0;
9167 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9169 if (unformat (i, "node-name %s", &node_name))
9171 else if (unformat (i, "next-node-name %s", &next_node_name))
9177 errmsg ("node name required\n");
9180 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
9182 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9186 if (next_node_name == 0)
9188 errmsg ("next node name required\n");
9191 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
9193 errmsg ("next node name too long, max %d\n", ARRAY_LEN (mp->next_name));
9197 M (GET_NEXT_INDEX, get_next_index);
9198 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
9199 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
9200 vec_free (node_name);
9201 vec_free (next_node_name);
9210 api_add_node_next (vat_main_t * vam)
9212 unformat_input_t *i = vam->input;
9213 vl_api_add_node_next_t *mp;
9218 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9220 if (unformat (i, "node %s", &name))
9222 else if (unformat (i, "next %s", &next))
9229 errmsg ("node name required\n");
9232 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9234 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9239 errmsg ("next node required\n");
9242 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
9244 errmsg ("next name too long, max %d\n", ARRAY_LEN (mp->next_name));
9248 M (ADD_NODE_NEXT, add_node_next);
9249 clib_memcpy (mp->node_name, name, vec_len (name));
9250 clib_memcpy (mp->next_name, next, vec_len (next));
9261 api_l2tpv3_create_tunnel (vat_main_t * vam)
9263 unformat_input_t *i = vam->input;
9264 ip6_address_t client_address, our_address;
9265 int client_address_set = 0;
9266 int our_address_set = 0;
9267 u32 local_session_id = 0;
9268 u32 remote_session_id = 0;
9269 u64 local_cookie = 0;
9270 u64 remote_cookie = 0;
9271 u8 l2_sublayer_present = 0;
9272 vl_api_l2tpv3_create_tunnel_t *mp;
9275 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9277 if (unformat (i, "client_address %U", unformat_ip6_address,
9279 client_address_set = 1;
9280 else if (unformat (i, "our_address %U", unformat_ip6_address,
9282 our_address_set = 1;
9283 else if (unformat (i, "local_session_id %d", &local_session_id))
9285 else if (unformat (i, "remote_session_id %d", &remote_session_id))
9287 else if (unformat (i, "local_cookie %lld", &local_cookie))
9289 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
9291 else if (unformat (i, "l2-sublayer-present"))
9292 l2_sublayer_present = 1;
9297 if (client_address_set == 0)
9299 errmsg ("client_address required\n");
9303 if (our_address_set == 0)
9305 errmsg ("our_address required\n");
9309 M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel);
9311 clib_memcpy (mp->client_address, client_address.as_u8,
9312 sizeof (mp->client_address));
9314 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
9316 mp->local_session_id = ntohl (local_session_id);
9317 mp->remote_session_id = ntohl (remote_session_id);
9318 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
9319 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
9320 mp->l2_sublayer_present = l2_sublayer_present;
9330 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
9332 unformat_input_t *i = vam->input;
9334 u8 sw_if_index_set = 0;
9335 u64 new_local_cookie = 0;
9336 u64 new_remote_cookie = 0;
9337 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
9340 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9342 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9343 sw_if_index_set = 1;
9344 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9345 sw_if_index_set = 1;
9346 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
9348 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
9354 if (sw_if_index_set == 0)
9356 errmsg ("missing interface name or sw_if_index\n");
9360 M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies);
9362 mp->sw_if_index = ntohl (sw_if_index);
9363 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
9364 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
9373 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
9375 unformat_input_t *i = vam->input;
9376 vl_api_l2tpv3_interface_enable_disable_t *mp;
9379 u8 sw_if_index_set = 0;
9380 u8 enable_disable = 1;
9382 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9384 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9385 sw_if_index_set = 1;
9386 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9387 sw_if_index_set = 1;
9388 else if (unformat (i, "enable"))
9390 else if (unformat (i, "disable"))
9396 if (sw_if_index_set == 0)
9398 errmsg ("missing interface name or sw_if_index\n");
9402 M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable);
9404 mp->sw_if_index = ntohl (sw_if_index);
9405 mp->enable_disable = enable_disable;
9414 api_l2tpv3_set_lookup_key (vat_main_t * vam)
9416 unformat_input_t *i = vam->input;
9417 vl_api_l2tpv3_set_lookup_key_t *mp;
9421 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9423 if (unformat (i, "lookup_v6_src"))
9424 key = L2T_LOOKUP_SRC_ADDRESS;
9425 else if (unformat (i, "lookup_v6_dst"))
9426 key = L2T_LOOKUP_DST_ADDRESS;
9427 else if (unformat (i, "lookup_session_id"))
9428 key = L2T_LOOKUP_SESSION_ID;
9433 if (key == (u8) ~ 0)
9435 errmsg ("l2tp session lookup key unset\n");
9439 M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key);
9449 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
9450 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
9452 vat_main_t *vam = &vat_main;
9454 fformat (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)\n",
9455 format_ip6_address, mp->our_address,
9456 format_ip6_address, mp->client_address,
9457 clib_net_to_host_u32 (mp->sw_if_index));
9460 " local cookies %016llx %016llx remote cookie %016llx\n",
9461 clib_net_to_host_u64 (mp->local_cookie[0]),
9462 clib_net_to_host_u64 (mp->local_cookie[1]),
9463 clib_net_to_host_u64 (mp->remote_cookie));
9465 fformat (vam->ofp, " local session-id %d remote session-id %d\n",
9466 clib_net_to_host_u32 (mp->local_session_id),
9467 clib_net_to_host_u32 (mp->remote_session_id));
9469 fformat (vam->ofp, " l2 specific sublayer %s\n\n",
9470 mp->l2_sublayer_present ? "preset" : "absent");
9474 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
9475 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
9477 vat_main_t *vam = &vat_main;
9478 vat_json_node_t *node = NULL;
9479 struct in6_addr addr;
9481 if (VAT_JSON_ARRAY != vam->json_tree.type)
9483 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9484 vat_json_init_array (&vam->json_tree);
9486 node = vat_json_array_add (&vam->json_tree);
9488 vat_json_init_object (node);
9490 clib_memcpy (&addr, mp->our_address, sizeof (addr));
9491 vat_json_object_add_ip6 (node, "our_address", addr);
9492 clib_memcpy (&addr, mp->client_address, sizeof (addr));
9493 vat_json_object_add_ip6 (node, "client_address", addr);
9495 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
9496 vat_json_init_array (lc);
9497 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
9498 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
9499 vat_json_object_add_uint (node, "remote_cookie",
9500 clib_net_to_host_u64 (mp->remote_cookie));
9502 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
9503 vat_json_object_add_uint (node, "local_session_id",
9504 clib_net_to_host_u32 (mp->local_session_id));
9505 vat_json_object_add_uint (node, "remote_session_id",
9506 clib_net_to_host_u32 (mp->remote_session_id));
9507 vat_json_object_add_string_copy (node, "l2_sublayer",
9508 mp->l2_sublayer_present ? (u8 *) "present"
9513 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
9515 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
9518 /* Get list of l2tpv3-tunnel interfaces */
9519 M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump);
9522 /* Use a control ping for synchronization */
9524 vl_api_control_ping_t *mp;
9525 M (CONTROL_PING, control_ping);
9532 static void vl_api_sw_interface_tap_details_t_handler
9533 (vl_api_sw_interface_tap_details_t * mp)
9535 vat_main_t *vam = &vat_main;
9537 fformat (vam->ofp, "%-16s %d\n",
9538 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
9541 static void vl_api_sw_interface_tap_details_t_handler_json
9542 (vl_api_sw_interface_tap_details_t * mp)
9544 vat_main_t *vam = &vat_main;
9545 vat_json_node_t *node = NULL;
9547 if (VAT_JSON_ARRAY != vam->json_tree.type)
9549 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9550 vat_json_init_array (&vam->json_tree);
9552 node = vat_json_array_add (&vam->json_tree);
9554 vat_json_init_object (node);
9555 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9556 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
9560 api_sw_interface_tap_dump (vat_main_t * vam)
9562 vl_api_sw_interface_tap_dump_t *mp;
9565 fformat (vam->ofp, "\n%-16s %s\n", "dev_name", "sw_if_index");
9566 /* Get list of tap interfaces */
9567 M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump);
9570 /* Use a control ping for synchronization */
9572 vl_api_control_ping_t *mp;
9573 M (CONTROL_PING, control_ping);
9579 static uword unformat_vxlan_decap_next
9580 (unformat_input_t * input, va_list * args)
9582 u32 *result = va_arg (*args, u32 *);
9585 if (unformat (input, "drop"))
9586 *result = VXLAN_INPUT_NEXT_DROP;
9587 else if (unformat (input, "ip4"))
9588 *result = VXLAN_INPUT_NEXT_IP4_INPUT;
9589 else if (unformat (input, "ip6"))
9590 *result = VXLAN_INPUT_NEXT_IP6_INPUT;
9591 else if (unformat (input, "l2"))
9592 *result = VXLAN_INPUT_NEXT_L2_INPUT;
9593 else if (unformat (input, "%d", &tmp))
9601 api_vxlan_add_del_tunnel (vat_main_t * vam)
9603 unformat_input_t *line_input = vam->input;
9604 vl_api_vxlan_add_del_tunnel_t *mp;
9606 ip4_address_t src4, dst4;
9607 ip6_address_t src6, dst6;
9609 u8 ipv4_set = 0, ipv6_set = 0;
9612 u32 encap_vrf_id = 0;
9613 u32 decap_next_index = ~0;
9616 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9618 if (unformat (line_input, "del"))
9620 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
9625 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
9630 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
9635 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
9640 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
9642 else if (unformat (line_input, "decap-next %U",
9643 unformat_vxlan_decap_next, &decap_next_index))
9645 else if (unformat (line_input, "vni %d", &vni))
9649 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
9656 errmsg ("tunnel src address not specified\n");
9661 errmsg ("tunnel dst address not specified\n");
9665 if (ipv4_set && ipv6_set)
9667 errmsg ("both IPv4 and IPv6 addresses specified");
9671 if ((vni == 0) || (vni >> 24))
9673 errmsg ("vni not specified or out of range\n");
9677 M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel);
9681 clib_memcpy (&mp->src_address, &src6, sizeof (src6));
9682 clib_memcpy (&mp->dst_address, &dst6, sizeof (dst6));
9686 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
9687 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
9689 mp->encap_vrf_id = ntohl (encap_vrf_id);
9690 mp->decap_next_index = ntohl (decap_next_index);
9691 mp->vni = ntohl (vni);
9692 mp->is_add = is_add;
9693 mp->is_ipv6 = ipv6_set;
9701 static void vl_api_vxlan_tunnel_details_t_handler
9702 (vl_api_vxlan_tunnel_details_t * mp)
9704 vat_main_t *vam = &vat_main;
9706 fformat (vam->ofp, "%11d%24U%24U%14d%18d%13d\n",
9707 ntohl (mp->sw_if_index),
9708 format_ip46_address, &(mp->src_address[0]),
9710 format_ip46_address, &(mp->dst_address[0]),
9712 ntohl (mp->encap_vrf_id),
9713 ntohl (mp->decap_next_index), ntohl (mp->vni));
9716 static void vl_api_vxlan_tunnel_details_t_handler_json
9717 (vl_api_vxlan_tunnel_details_t * mp)
9719 vat_main_t *vam = &vat_main;
9720 vat_json_node_t *node = NULL;
9722 struct in6_addr ip6;
9724 if (VAT_JSON_ARRAY != vam->json_tree.type)
9726 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9727 vat_json_init_array (&vam->json_tree);
9729 node = vat_json_array_add (&vam->json_tree);
9731 vat_json_init_object (node);
9732 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9735 clib_memcpy (&ip6, &(mp->src_address[0]), sizeof (ip6));
9736 vat_json_object_add_ip6 (node, "src_address", ip6);
9737 clib_memcpy (&ip6, &(mp->dst_address[0]), sizeof (ip6));
9738 vat_json_object_add_ip6 (node, "dst_address", ip6);
9742 clib_memcpy (&ip4, &(mp->src_address[0]), sizeof (ip4));
9743 vat_json_object_add_ip4 (node, "src_address", ip4);
9744 clib_memcpy (&ip4, &(mp->dst_address[0]), sizeof (ip4));
9745 vat_json_object_add_ip4 (node, "dst_address", ip4);
9747 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
9748 vat_json_object_add_uint (node, "decap_next_index",
9749 ntohl (mp->decap_next_index));
9750 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
9751 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
9755 api_vxlan_tunnel_dump (vat_main_t * vam)
9757 unformat_input_t *i = vam->input;
9758 vl_api_vxlan_tunnel_dump_t *mp;
9761 u8 sw_if_index_set = 0;
9763 /* Parse args required to build the message */
9764 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9766 if (unformat (i, "sw_if_index %d", &sw_if_index))
9767 sw_if_index_set = 1;
9772 if (sw_if_index_set == 0)
9777 if (!vam->json_output)
9779 fformat (vam->ofp, "%11s%24s%24s%14s%18s%13s\n",
9780 "sw_if_index", "src_address", "dst_address",
9781 "encap_vrf_id", "decap_next_index", "vni");
9784 /* Get list of vxlan-tunnel interfaces */
9785 M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
9787 mp->sw_if_index = htonl (sw_if_index);
9791 /* Use a control ping for synchronization */
9793 vl_api_control_ping_t *mp;
9794 M (CONTROL_PING, control_ping);
9801 api_gre_add_del_tunnel (vat_main_t * vam)
9803 unformat_input_t *line_input = vam->input;
9804 vl_api_gre_add_del_tunnel_t *mp;
9806 ip4_address_t src4, dst4;
9811 u32 outer_fib_id = 0;
9813 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9815 if (unformat (line_input, "del"))
9817 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
9819 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
9821 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
9823 else if (unformat (line_input, "teb"))
9827 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
9834 errmsg ("tunnel src address not specified\n");
9839 errmsg ("tunnel dst address not specified\n");
9844 M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel);
9846 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
9847 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
9848 mp->outer_fib_id = ntohl (outer_fib_id);
9849 mp->is_add = is_add;
9858 static void vl_api_gre_tunnel_details_t_handler
9859 (vl_api_gre_tunnel_details_t * mp)
9861 vat_main_t *vam = &vat_main;
9863 fformat (vam->ofp, "%11d%15U%15U%6d%14d\n",
9864 ntohl (mp->sw_if_index),
9865 format_ip4_address, &mp->src_address,
9866 format_ip4_address, &mp->dst_address,
9867 mp->teb, ntohl (mp->outer_fib_id));
9870 static void vl_api_gre_tunnel_details_t_handler_json
9871 (vl_api_gre_tunnel_details_t * mp)
9873 vat_main_t *vam = &vat_main;
9874 vat_json_node_t *node = NULL;
9877 if (VAT_JSON_ARRAY != vam->json_tree.type)
9879 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9880 vat_json_init_array (&vam->json_tree);
9882 node = vat_json_array_add (&vam->json_tree);
9884 vat_json_init_object (node);
9885 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9886 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
9887 vat_json_object_add_ip4 (node, "src_address", ip4);
9888 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
9889 vat_json_object_add_ip4 (node, "dst_address", ip4);
9890 vat_json_object_add_uint (node, "teb", mp->teb);
9891 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
9895 api_gre_tunnel_dump (vat_main_t * vam)
9897 unformat_input_t *i = vam->input;
9898 vl_api_gre_tunnel_dump_t *mp;
9901 u8 sw_if_index_set = 0;
9903 /* Parse args required to build the message */
9904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9906 if (unformat (i, "sw_if_index %d", &sw_if_index))
9907 sw_if_index_set = 1;
9912 if (sw_if_index_set == 0)
9917 if (!vam->json_output)
9919 fformat (vam->ofp, "%11s%15s%15s%6s%14s\n",
9920 "sw_if_index", "src_address", "dst_address", "teb",
9924 /* Get list of gre-tunnel interfaces */
9925 M (GRE_TUNNEL_DUMP, gre_tunnel_dump);
9927 mp->sw_if_index = htonl (sw_if_index);
9931 /* Use a control ping for synchronization */
9933 vl_api_control_ping_t *mp;
9934 M (CONTROL_PING, control_ping);
9941 api_l2_fib_clear_table (vat_main_t * vam)
9943 // unformat_input_t * i = vam->input;
9944 vl_api_l2_fib_clear_table_t *mp;
9947 M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table);
9956 api_l2_interface_efp_filter (vat_main_t * vam)
9958 unformat_input_t *i = vam->input;
9959 vl_api_l2_interface_efp_filter_t *mp;
9963 u8 sw_if_index_set = 0;
9965 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9967 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9968 sw_if_index_set = 1;
9969 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9970 sw_if_index_set = 1;
9971 else if (unformat (i, "enable"))
9973 else if (unformat (i, "disable"))
9977 clib_warning ("parse error '%U'", format_unformat_error, i);
9982 if (sw_if_index_set == 0)
9984 errmsg ("missing sw_if_index\n");
9988 M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter);
9990 mp->sw_if_index = ntohl (sw_if_index);
9991 mp->enable_disable = enable;
9999 #define foreach_vtr_op \
10000 _("disable", L2_VTR_DISABLED) \
10001 _("push-1", L2_VTR_PUSH_1) \
10002 _("push-2", L2_VTR_PUSH_2) \
10003 _("pop-1", L2_VTR_POP_1) \
10004 _("pop-2", L2_VTR_POP_2) \
10005 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10006 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10007 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10008 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10011 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10013 unformat_input_t *i = vam->input;
10014 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
10017 u8 sw_if_index_set = 0;
10020 u32 push_dot1q = 1;
10024 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10026 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10027 sw_if_index_set = 1;
10028 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10029 sw_if_index_set = 1;
10030 else if (unformat (i, "vtr_op %d", &vtr_op))
10032 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
10035 else if (unformat (i, "push_dot1q %d", &push_dot1q))
10037 else if (unformat (i, "tag1 %d", &tag1))
10039 else if (unformat (i, "tag2 %d", &tag2))
10043 clib_warning ("parse error '%U'", format_unformat_error, i);
10048 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
10050 errmsg ("missing vtr operation or sw_if_index\n");
10054 M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)
10055 mp->sw_if_index = ntohl (sw_if_index);
10056 mp->vtr_op = ntohl (vtr_op);
10057 mp->push_dot1q = ntohl (push_dot1q);
10058 mp->tag1 = ntohl (tag1);
10059 mp->tag2 = ntohl (tag2);
10068 api_create_vhost_user_if (vat_main_t * vam)
10070 unformat_input_t *i = vam->input;
10071 vl_api_create_vhost_user_if_t *mp;
10075 u8 file_name_set = 0;
10076 u32 custom_dev_instance = ~0;
10078 u8 use_custom_mac = 0;
10080 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10082 if (unformat (i, "socket %s", &file_name))
10086 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10088 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
10089 use_custom_mac = 1;
10090 else if (unformat (i, "server"))
10096 if (file_name_set == 0)
10098 errmsg ("missing socket file name\n");
10102 if (vec_len (file_name) > 255)
10104 errmsg ("socket file name too long\n");
10107 vec_add1 (file_name, 0);
10109 M (CREATE_VHOST_USER_IF, create_vhost_user_if);
10111 mp->is_server = is_server;
10112 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10113 vec_free (file_name);
10114 if (custom_dev_instance != ~0)
10117 mp->custom_dev_instance = ntohl (custom_dev_instance);
10119 mp->use_custom_mac = use_custom_mac;
10120 clib_memcpy (mp->mac_address, hwaddr, 6);
10129 api_modify_vhost_user_if (vat_main_t * vam)
10131 unformat_input_t *i = vam->input;
10132 vl_api_modify_vhost_user_if_t *mp;
10136 u8 file_name_set = 0;
10137 u32 custom_dev_instance = ~0;
10138 u8 sw_if_index_set = 0;
10139 u32 sw_if_index = (u32) ~ 0;
10141 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10143 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10144 sw_if_index_set = 1;
10145 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10146 sw_if_index_set = 1;
10147 else if (unformat (i, "socket %s", &file_name))
10151 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10153 else if (unformat (i, "server"))
10159 if (sw_if_index_set == 0)
10161 errmsg ("missing sw_if_index or interface name\n");
10165 if (file_name_set == 0)
10167 errmsg ("missing socket file name\n");
10171 if (vec_len (file_name) > 255)
10173 errmsg ("socket file name too long\n");
10176 vec_add1 (file_name, 0);
10178 M (MODIFY_VHOST_USER_IF, modify_vhost_user_if);
10180 mp->sw_if_index = ntohl (sw_if_index);
10181 mp->is_server = is_server;
10182 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10183 vec_free (file_name);
10184 if (custom_dev_instance != ~0)
10187 mp->custom_dev_instance = ntohl (custom_dev_instance);
10197 api_delete_vhost_user_if (vat_main_t * vam)
10199 unformat_input_t *i = vam->input;
10200 vl_api_delete_vhost_user_if_t *mp;
10202 u32 sw_if_index = ~0;
10203 u8 sw_if_index_set = 0;
10205 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10207 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10208 sw_if_index_set = 1;
10209 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10210 sw_if_index_set = 1;
10215 if (sw_if_index_set == 0)
10217 errmsg ("missing sw_if_index or interface name\n");
10222 M (DELETE_VHOST_USER_IF, delete_vhost_user_if);
10224 mp->sw_if_index = ntohl (sw_if_index);
10232 static void vl_api_sw_interface_vhost_user_details_t_handler
10233 (vl_api_sw_interface_vhost_user_details_t * mp)
10235 vat_main_t *vam = &vat_main;
10237 fformat (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s\n",
10238 (char *) mp->interface_name,
10239 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
10240 clib_net_to_host_u64 (mp->features), mp->is_server,
10241 ntohl (mp->num_regions), (char *) mp->sock_filename);
10242 fformat (vam->ofp, " Status: '%s'\n", strerror (ntohl (mp->sock_errno)));
10245 static void vl_api_sw_interface_vhost_user_details_t_handler_json
10246 (vl_api_sw_interface_vhost_user_details_t * mp)
10248 vat_main_t *vam = &vat_main;
10249 vat_json_node_t *node = NULL;
10251 if (VAT_JSON_ARRAY != vam->json_tree.type)
10253 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10254 vat_json_init_array (&vam->json_tree);
10256 node = vat_json_array_add (&vam->json_tree);
10258 vat_json_init_object (node);
10259 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10260 vat_json_object_add_string_copy (node, "interface_name",
10261 mp->interface_name);
10262 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
10263 ntohl (mp->virtio_net_hdr_sz));
10264 vat_json_object_add_uint (node, "features",
10265 clib_net_to_host_u64 (mp->features));
10266 vat_json_object_add_uint (node, "is_server", mp->is_server);
10267 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
10268 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
10269 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
10273 api_sw_interface_vhost_user_dump (vat_main_t * vam)
10275 vl_api_sw_interface_vhost_user_dump_t *mp;
10278 "Interface name idx hdr_sz features server regions filename\n");
10280 /* Get list of vhost-user interfaces */
10281 M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump);
10284 /* Use a control ping for synchronization */
10286 vl_api_control_ping_t *mp;
10287 M (CONTROL_PING, control_ping);
10294 api_show_version (vat_main_t * vam)
10296 vl_api_show_version_t *mp;
10299 M (SHOW_VERSION, show_version);
10309 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
10311 unformat_input_t *line_input = vam->input;
10312 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
10314 ip4_address_t local4, remote4;
10315 ip6_address_t local6, remote6;
10317 u8 ipv4_set = 0, ipv6_set = 0;
10320 u32 encap_vrf_id = 0;
10321 u32 decap_vrf_id = 0;
10326 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10328 if (unformat (line_input, "del"))
10330 else if (unformat (line_input, "local %U",
10331 unformat_ip4_address, &local4))
10336 else if (unformat (line_input, "remote %U",
10337 unformat_ip4_address, &remote4))
10342 else if (unformat (line_input, "local %U",
10343 unformat_ip6_address, &local6))
10348 else if (unformat (line_input, "remote %U",
10349 unformat_ip6_address, &remote6))
10354 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10356 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
10358 else if (unformat (line_input, "vni %d", &vni))
10360 else if (unformat (line_input, "next-ip4"))
10362 else if (unformat (line_input, "next-ip6"))
10364 else if (unformat (line_input, "next-ethernet"))
10366 else if (unformat (line_input, "next-nsh"))
10370 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
10375 if (local_set == 0)
10377 errmsg ("tunnel local address not specified\n");
10380 if (remote_set == 0)
10382 errmsg ("tunnel remote address not specified\n");
10385 if (ipv4_set && ipv6_set)
10387 errmsg ("both IPv4 and IPv6 addresses specified");
10393 errmsg ("vni not specified\n");
10397 M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel);
10402 clib_memcpy (&mp->local, &local6, sizeof (local6));
10403 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
10407 clib_memcpy (&mp->local, &local4, sizeof (local4));
10408 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
10411 mp->encap_vrf_id = ntohl (encap_vrf_id);
10412 mp->decap_vrf_id = ntohl (decap_vrf_id);
10413 mp->protocol = ntohl (protocol);
10414 mp->vni = ntohl (vni);
10415 mp->is_add = is_add;
10416 mp->is_ipv6 = ipv6_set;
10424 static void vl_api_vxlan_gpe_tunnel_details_t_handler
10425 (vl_api_vxlan_gpe_tunnel_details_t * mp)
10427 vat_main_t *vam = &vat_main;
10429 fformat (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d\n",
10430 ntohl (mp->sw_if_index),
10431 format_ip46_address, &(mp->local[0]),
10432 format_ip46_address, &(mp->remote[0]),
10434 ntohl (mp->protocol),
10435 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
10438 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
10439 (vl_api_vxlan_gpe_tunnel_details_t * mp)
10441 vat_main_t *vam = &vat_main;
10442 vat_json_node_t *node = NULL;
10443 struct in_addr ip4;
10444 struct in6_addr ip6;
10446 if (VAT_JSON_ARRAY != vam->json_tree.type)
10448 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10449 vat_json_init_array (&vam->json_tree);
10451 node = vat_json_array_add (&vam->json_tree);
10453 vat_json_init_object (node);
10454 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10457 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
10458 vat_json_object_add_ip6 (node, "local", ip6);
10459 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
10460 vat_json_object_add_ip6 (node, "remote", ip6);
10464 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
10465 vat_json_object_add_ip4 (node, "local", ip4);
10466 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
10467 vat_json_object_add_ip4 (node, "remote", ip4);
10469 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10470 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
10471 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10472 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
10473 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10477 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
10479 unformat_input_t *i = vam->input;
10480 vl_api_vxlan_gpe_tunnel_dump_t *mp;
10483 u8 sw_if_index_set = 0;
10485 /* Parse args required to build the message */
10486 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10488 if (unformat (i, "sw_if_index %d", &sw_if_index))
10489 sw_if_index_set = 1;
10494 if (sw_if_index_set == 0)
10499 if (!vam->json_output)
10501 fformat (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s\n",
10502 "sw_if_index", "local", "remote", "vni",
10503 "protocol", "encap_vrf_id", "decap_vrf_id");
10506 /* Get list of vxlan-tunnel interfaces */
10507 M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump);
10509 mp->sw_if_index = htonl (sw_if_index);
10513 /* Use a control ping for synchronization */
10515 vl_api_control_ping_t *mp;
10516 M (CONTROL_PING, control_ping);
10523 format_l2_fib_mac_address (u8 * s, va_list * args)
10525 u8 *a = va_arg (*args, u8 *);
10527 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
10528 a[2], a[3], a[4], a[5], a[6], a[7]);
10531 static void vl_api_l2_fib_table_entry_t_handler
10532 (vl_api_l2_fib_table_entry_t * mp)
10534 vat_main_t *vam = &vat_main;
10536 fformat (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
10538 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
10539 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
10543 static void vl_api_l2_fib_table_entry_t_handler_json
10544 (vl_api_l2_fib_table_entry_t * mp)
10546 vat_main_t *vam = &vat_main;
10547 vat_json_node_t *node = NULL;
10549 if (VAT_JSON_ARRAY != vam->json_tree.type)
10551 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10552 vat_json_init_array (&vam->json_tree);
10554 node = vat_json_array_add (&vam->json_tree);
10556 vat_json_init_object (node);
10557 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
10558 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
10559 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10560 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
10561 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
10562 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
10566 api_l2_fib_table_dump (vat_main_t * vam)
10568 unformat_input_t *i = vam->input;
10569 vl_api_l2_fib_table_dump_t *mp;
10574 /* Parse args required to build the message */
10575 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10577 if (unformat (i, "bd_id %d", &bd_id))
10583 if (bd_id_set == 0)
10585 errmsg ("missing bridge domain\n");
10590 "BD-ID Mac Address sw-ndx Static Filter BVI\n");
10592 /* Get list of l2 fib entries */
10593 M (L2_FIB_TABLE_DUMP, l2_fib_table_dump);
10595 mp->bd_id = ntohl (bd_id);
10598 /* Use a control ping for synchronization */
10600 vl_api_control_ping_t *mp;
10601 M (CONTROL_PING, control_ping);
10609 api_interface_name_renumber (vat_main_t * vam)
10611 unformat_input_t *line_input = vam->input;
10612 vl_api_interface_name_renumber_t *mp;
10613 u32 sw_if_index = ~0;
10615 u32 new_show_dev_instance = ~0;
10617 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10619 if (unformat (line_input, "%U", unformat_sw_if_index, vam,
10622 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
10624 else if (unformat (line_input, "new_show_dev_instance %d",
10625 &new_show_dev_instance))
10631 if (sw_if_index == ~0)
10633 errmsg ("missing interface name or sw_if_index\n");
10637 if (new_show_dev_instance == ~0)
10639 errmsg ("missing new_show_dev_instance\n");
10643 M (INTERFACE_NAME_RENUMBER, interface_name_renumber);
10645 mp->sw_if_index = ntohl (sw_if_index);
10646 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
10653 api_want_ip4_arp_events (vat_main_t * vam)
10655 unformat_input_t *line_input = vam->input;
10656 vl_api_want_ip4_arp_events_t *mp;
10658 ip4_address_t address;
10659 int address_set = 0;
10660 u32 enable_disable = 1;
10662 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10664 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
10666 else if (unformat (line_input, "del"))
10667 enable_disable = 0;
10672 if (address_set == 0)
10674 errmsg ("missing addresses\n");
10678 M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events);
10679 mp->enable_disable = enable_disable;
10680 mp->pid = getpid ();
10681 mp->address = address.as_u32;
10688 api_want_ip6_nd_events (vat_main_t * vam)
10690 unformat_input_t *line_input = vam->input;
10691 vl_api_want_ip6_nd_events_t *mp;
10693 ip6_address_t address;
10694 int address_set = 0;
10695 u32 enable_disable = 1;
10697 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10699 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
10701 else if (unformat (line_input, "del"))
10702 enable_disable = 0;
10707 if (address_set == 0)
10709 errmsg ("missing addresses\n");
10713 M (WANT_IP6_ND_EVENTS, want_ip6_nd_events);
10714 mp->enable_disable = enable_disable;
10715 mp->pid = getpid ();
10716 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
10723 api_input_acl_set_interface (vat_main_t * vam)
10725 unformat_input_t *i = vam->input;
10726 vl_api_input_acl_set_interface_t *mp;
10729 int sw_if_index_set;
10730 u32 ip4_table_index = ~0;
10731 u32 ip6_table_index = ~0;
10732 u32 l2_table_index = ~0;
10735 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10737 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10738 sw_if_index_set = 1;
10739 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10740 sw_if_index_set = 1;
10741 else if (unformat (i, "del"))
10743 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10745 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10747 else if (unformat (i, "l2-table %d", &l2_table_index))
10751 clib_warning ("parse error '%U'", format_unformat_error, i);
10756 if (sw_if_index_set == 0)
10758 errmsg ("missing interface name or sw_if_index\n");
10762 M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface);
10764 mp->sw_if_index = ntohl (sw_if_index);
10765 mp->ip4_table_index = ntohl (ip4_table_index);
10766 mp->ip6_table_index = ntohl (ip6_table_index);
10767 mp->l2_table_index = ntohl (l2_table_index);
10768 mp->is_add = is_add;
10777 api_ip_address_dump (vat_main_t * vam)
10779 unformat_input_t *i = vam->input;
10780 vl_api_ip_address_dump_t *mp;
10781 u32 sw_if_index = ~0;
10782 u8 sw_if_index_set = 0;
10787 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10789 if (unformat (i, "sw_if_index %d", &sw_if_index))
10790 sw_if_index_set = 1;
10791 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10792 sw_if_index_set = 1;
10793 else if (unformat (i, "ipv4"))
10795 else if (unformat (i, "ipv6"))
10801 if (ipv4_set && ipv6_set)
10803 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
10807 if ((!ipv4_set) && (!ipv6_set))
10809 errmsg ("no ipv4 nor ipv6 flag set\n");
10813 if (sw_if_index_set == 0)
10815 errmsg ("missing interface name or sw_if_index\n");
10819 vam->current_sw_if_index = sw_if_index;
10820 vam->is_ipv6 = ipv6_set;
10822 M (IP_ADDRESS_DUMP, ip_address_dump);
10823 mp->sw_if_index = ntohl (sw_if_index);
10824 mp->is_ipv6 = ipv6_set;
10827 /* Use a control ping for synchronization */
10829 vl_api_control_ping_t *mp;
10830 M (CONTROL_PING, control_ping);
10837 api_ip_dump (vat_main_t * vam)
10839 vl_api_ip_dump_t *mp;
10840 unformat_input_t *in = vam->input;
10847 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
10849 if (unformat (in, "ipv4"))
10851 else if (unformat (in, "ipv6"))
10857 if (ipv4_set && ipv6_set)
10859 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
10863 if ((!ipv4_set) && (!ipv6_set))
10865 errmsg ("no ipv4 nor ipv6 flag set\n");
10869 is_ipv6 = ipv6_set;
10870 vam->is_ipv6 = is_ipv6;
10872 /* free old data */
10873 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
10875 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
10877 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
10879 M (IP_DUMP, ip_dump);
10880 mp->is_ipv6 = ipv6_set;
10883 /* Use a control ping for synchronization */
10885 vl_api_control_ping_t *mp;
10886 M (CONTROL_PING, control_ping);
10893 api_ipsec_spd_add_del (vat_main_t * vam)
10896 unformat_input_t *i = vam->input;
10897 vl_api_ipsec_spd_add_del_t *mp;
10902 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10904 if (unformat (i, "spd_id %d", &spd_id))
10906 else if (unformat (i, "del"))
10910 clib_warning ("parse error '%U'", format_unformat_error, i);
10916 errmsg ("spd_id must be set\n");
10920 M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del);
10922 mp->spd_id = ntohl (spd_id);
10923 mp->is_add = is_add;
10930 clib_warning ("unsupported (no dpdk)");
10936 api_ipsec_interface_add_del_spd (vat_main_t * vam)
10939 unformat_input_t *i = vam->input;
10940 vl_api_ipsec_interface_add_del_spd_t *mp;
10943 u8 sw_if_index_set = 0;
10944 u32 spd_id = (u32) ~ 0;
10947 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10949 if (unformat (i, "del"))
10951 else if (unformat (i, "spd_id %d", &spd_id))
10953 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10954 sw_if_index_set = 1;
10955 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10956 sw_if_index_set = 1;
10959 clib_warning ("parse error '%U'", format_unformat_error, i);
10965 if (spd_id == (u32) ~ 0)
10967 errmsg ("spd_id must be set\n");
10971 if (sw_if_index_set == 0)
10973 errmsg ("missing interface name or sw_if_index\n");
10977 M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd);
10979 mp->spd_id = ntohl (spd_id);
10980 mp->sw_if_index = ntohl (sw_if_index);
10981 mp->is_add = is_add;
10988 clib_warning ("unsupported (no dpdk)");
10994 api_ipsec_spd_add_del_entry (vat_main_t * vam)
10997 unformat_input_t *i = vam->input;
10998 vl_api_ipsec_spd_add_del_entry_t *mp;
11000 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11001 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11003 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11004 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11005 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11006 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11008 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11009 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11010 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11011 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11012 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11013 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11017 if (unformat (i, "del"))
11019 if (unformat (i, "outbound"))
11021 if (unformat (i, "inbound"))
11023 else if (unformat (i, "spd_id %d", &spd_id))
11025 else if (unformat (i, "sa_id %d", &sa_id))
11027 else if (unformat (i, "priority %d", &priority))
11029 else if (unformat (i, "protocol %d", &protocol))
11031 else if (unformat (i, "lport_start %d", &lport_start))
11033 else if (unformat (i, "lport_stop %d", &lport_stop))
11035 else if (unformat (i, "rport_start %d", &rport_start))
11037 else if (unformat (i, "rport_stop %d", &rport_stop))
11041 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
11047 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
11054 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
11060 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
11067 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
11073 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
11080 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
11086 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
11092 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
11094 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
11096 clib_warning ("unsupported action: 'resolve'");
11102 clib_warning ("parse error '%U'", format_unformat_error, i);
11108 M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry);
11110 mp->spd_id = ntohl (spd_id);
11111 mp->priority = ntohl (priority);
11112 mp->is_outbound = is_outbound;
11114 mp->is_ipv6 = is_ipv6;
11115 if (is_ipv6 || is_ip_any)
11117 clib_memcpy (mp->remote_address_start, &raddr6_start,
11118 sizeof (ip6_address_t));
11119 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
11120 sizeof (ip6_address_t));
11121 clib_memcpy (mp->local_address_start, &laddr6_start,
11122 sizeof (ip6_address_t));
11123 clib_memcpy (mp->local_address_stop, &laddr6_stop,
11124 sizeof (ip6_address_t));
11128 clib_memcpy (mp->remote_address_start, &raddr4_start,
11129 sizeof (ip4_address_t));
11130 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
11131 sizeof (ip4_address_t));
11132 clib_memcpy (mp->local_address_start, &laddr4_start,
11133 sizeof (ip4_address_t));
11134 clib_memcpy (mp->local_address_stop, &laddr4_stop,
11135 sizeof (ip4_address_t));
11137 mp->protocol = (u8) protocol;
11138 mp->local_port_start = ntohs ((u16) lport_start);
11139 mp->local_port_stop = ntohs ((u16) lport_stop);
11140 mp->remote_port_start = ntohs ((u16) rport_start);
11141 mp->remote_port_stop = ntohs ((u16) rport_stop);
11142 mp->policy = (u8) policy;
11143 mp->sa_id = ntohl (sa_id);
11144 mp->is_add = is_add;
11145 mp->is_ip_any = is_ip_any;
11151 clib_warning ("unsupported (no dpdk)");
11157 api_ipsec_sad_add_del_entry (vat_main_t * vam)
11160 unformat_input_t *i = vam->input;
11161 vl_api_ipsec_sad_add_del_entry_t *mp;
11163 u32 sad_id = 0, spi = 0;
11164 u8 *ck = 0, *ik = 0;
11167 u8 protocol = IPSEC_PROTOCOL_AH;
11168 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
11169 u32 crypto_alg = 0, integ_alg = 0;
11170 ip4_address_t tun_src4;
11171 ip4_address_t tun_dst4;
11172 ip6_address_t tun_src6;
11173 ip6_address_t tun_dst6;
11175 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11177 if (unformat (i, "del"))
11179 else if (unformat (i, "sad_id %d", &sad_id))
11181 else if (unformat (i, "spi %d", &spi))
11183 else if (unformat (i, "esp"))
11184 protocol = IPSEC_PROTOCOL_ESP;
11185 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
11188 is_tunnel_ipv6 = 0;
11190 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
11193 is_tunnel_ipv6 = 0;
11195 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
11198 is_tunnel_ipv6 = 1;
11200 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
11203 is_tunnel_ipv6 = 1;
11207 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
11209 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
11210 crypto_alg > IPSEC_INTEG_ALG_SHA_512_256)
11212 clib_warning ("unsupported crypto-alg: '%U'",
11213 format_ipsec_crypto_alg, crypto_alg);
11217 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11221 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
11223 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
11224 integ_alg > IPSEC_INTEG_ALG_SHA_512_256)
11226 clib_warning ("unsupported integ-alg: '%U'",
11227 format_ipsec_integ_alg, integ_alg);
11231 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
11235 clib_warning ("parse error '%U'", format_unformat_error, i);
11241 M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
11243 mp->sad_id = ntohl (sad_id);
11244 mp->is_add = is_add;
11245 mp->protocol = protocol;
11246 mp->spi = ntohl (spi);
11247 mp->is_tunnel = is_tunnel;
11248 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
11249 mp->crypto_algorithm = crypto_alg;
11250 mp->integrity_algorithm = integ_alg;
11251 mp->crypto_key_length = vec_len (ck);
11252 mp->integrity_key_length = vec_len (ik);
11254 if (mp->crypto_key_length > sizeof (mp->crypto_key))
11255 mp->crypto_key_length = sizeof (mp->crypto_key);
11257 if (mp->integrity_key_length > sizeof (mp->integrity_key))
11258 mp->integrity_key_length = sizeof (mp->integrity_key);
11261 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
11263 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
11267 if (is_tunnel_ipv6)
11269 clib_memcpy (mp->tunnel_src_address, &tun_src6,
11270 sizeof (ip6_address_t));
11271 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
11272 sizeof (ip6_address_t));
11276 clib_memcpy (mp->tunnel_src_address, &tun_src4,
11277 sizeof (ip4_address_t));
11278 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
11279 sizeof (ip4_address_t));
11288 clib_warning ("unsupported (no dpdk)");
11294 api_ipsec_sa_set_key (vat_main_t * vam)
11297 unformat_input_t *i = vam->input;
11298 vl_api_ipsec_sa_set_key_t *mp;
11301 u8 *ck = 0, *ik = 0;
11303 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11305 if (unformat (i, "sa_id %d", &sa_id))
11307 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11309 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
11313 clib_warning ("parse error '%U'", format_unformat_error, i);
11318 M (IPSEC_SA_SET_KEY, ipsec_set_sa_key);
11320 mp->sa_id = ntohl (sa_id);
11321 mp->crypto_key_length = vec_len (ck);
11322 mp->integrity_key_length = vec_len (ik);
11324 if (mp->crypto_key_length > sizeof (mp->crypto_key))
11325 mp->crypto_key_length = sizeof (mp->crypto_key);
11327 if (mp->integrity_key_length > sizeof (mp->integrity_key))
11328 mp->integrity_key_length = sizeof (mp->integrity_key);
11331 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
11333 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
11340 clib_warning ("unsupported (no dpdk)");
11346 api_ikev2_profile_add_del (vat_main_t * vam)
11349 unformat_input_t *i = vam->input;
11350 vl_api_ikev2_profile_add_del_t *mp;
11355 const char *valid_chars = "a-zA-Z0-9_";
11357 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11359 if (unformat (i, "del"))
11361 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11362 vec_add1 (name, 0);
11365 errmsg ("parse error '%U'", format_unformat_error, i);
11370 if (!vec_len (name))
11372 errmsg ("profile name must be specified");
11376 if (vec_len (name) > 64)
11378 errmsg ("profile name too long");
11382 M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del);
11384 clib_memcpy (mp->name, name, vec_len (name));
11385 mp->is_add = is_add;
11393 clib_warning ("unsupported (no dpdk)");
11399 api_ikev2_profile_set_auth (vat_main_t * vam)
11402 unformat_input_t *i = vam->input;
11403 vl_api_ikev2_profile_set_auth_t *mp;
11407 u32 auth_method = 0;
11410 const char *valid_chars = "a-zA-Z0-9_";
11412 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11414 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11415 vec_add1 (name, 0);
11416 else if (unformat (i, "auth_method %U",
11417 unformat_ikev2_auth_method, &auth_method))
11419 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
11421 else if (unformat (i, "auth_data %v", &data))
11425 errmsg ("parse error '%U'", format_unformat_error, i);
11430 if (!vec_len (name))
11432 errmsg ("profile name must be specified");
11436 if (vec_len (name) > 64)
11438 errmsg ("profile name too long");
11442 if (!vec_len (data))
11444 errmsg ("auth_data must be specified");
11450 errmsg ("auth_method must be specified");
11454 M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth);
11456 mp->is_hex = is_hex;
11457 mp->auth_method = (u8) auth_method;
11458 mp->data_len = vec_len (data);
11459 clib_memcpy (mp->name, name, vec_len (name));
11460 clib_memcpy (mp->data, data, vec_len (data));
11469 clib_warning ("unsupported (no dpdk)");
11475 api_ikev2_profile_set_id (vat_main_t * vam)
11478 unformat_input_t *i = vam->input;
11479 vl_api_ikev2_profile_set_id_t *mp;
11487 const char *valid_chars = "a-zA-Z0-9_";
11489 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11491 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11492 vec_add1 (name, 0);
11493 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
11495 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
11497 data = vec_new (u8, 4);
11498 clib_memcpy (data, ip4.as_u8, 4);
11500 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
11502 else if (unformat (i, "id_data %v", &data))
11504 else if (unformat (i, "local"))
11506 else if (unformat (i, "remote"))
11510 errmsg ("parse error '%U'", format_unformat_error, i);
11515 if (!vec_len (name))
11517 errmsg ("profile name must be specified");
11521 if (vec_len (name) > 64)
11523 errmsg ("profile name too long");
11527 if (!vec_len (data))
11529 errmsg ("id_data must be specified");
11535 errmsg ("id_type must be specified");
11539 M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id);
11541 mp->is_local = is_local;
11542 mp->id_type = (u8) id_type;
11543 mp->data_len = vec_len (data);
11544 clib_memcpy (mp->name, name, vec_len (name));
11545 clib_memcpy (mp->data, data, vec_len (data));
11554 clib_warning ("unsupported (no dpdk)");
11560 api_ikev2_profile_set_ts (vat_main_t * vam)
11563 unformat_input_t *i = vam->input;
11564 vl_api_ikev2_profile_set_ts_t *mp;
11568 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
11569 ip4_address_t start_addr, end_addr;
11571 const char *valid_chars = "a-zA-Z0-9_";
11573 start_addr.as_u32 = 0;
11574 end_addr.as_u32 = (u32) ~ 0;
11576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11578 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11579 vec_add1 (name, 0);
11580 else if (unformat (i, "protocol %d", &proto))
11582 else if (unformat (i, "start_port %d", &start_port))
11584 else if (unformat (i, "end_port %d", &end_port))
11587 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
11589 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
11591 else if (unformat (i, "local"))
11593 else if (unformat (i, "remote"))
11597 errmsg ("parse error '%U'", format_unformat_error, i);
11602 if (!vec_len (name))
11604 errmsg ("profile name must be specified");
11608 if (vec_len (name) > 64)
11610 errmsg ("profile name too long");
11614 M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts);
11616 mp->is_local = is_local;
11617 mp->proto = (u8) proto;
11618 mp->start_port = (u16) start_port;
11619 mp->end_port = (u16) end_port;
11620 mp->start_addr = start_addr.as_u32;
11621 mp->end_addr = end_addr.as_u32;
11622 clib_memcpy (mp->name, name, vec_len (name));
11630 clib_warning ("unsupported (no dpdk)");
11636 api_ikev2_set_local_key (vat_main_t * vam)
11639 unformat_input_t *i = vam->input;
11640 vl_api_ikev2_set_local_key_t *mp;
11644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11646 if (unformat (i, "file %v", &file))
11647 vec_add1 (file, 0);
11650 errmsg ("parse error '%U'", format_unformat_error, i);
11655 if (!vec_len (file))
11657 errmsg ("RSA key file must be specified");
11661 if (vec_len (file) > 256)
11663 errmsg ("file name too long");
11667 M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key);
11669 clib_memcpy (mp->key_file, file, vec_len (file));
11677 clib_warning ("unsupported (no dpdk)");
11686 api_map_add_domain (vat_main_t * vam)
11688 unformat_input_t *i = vam->input;
11689 vl_api_map_add_domain_t *mp;
11692 ip4_address_t ip4_prefix;
11693 ip6_address_t ip6_prefix;
11694 ip6_address_t ip6_src;
11695 u32 num_m_args = 0;
11696 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
11697 0, psid_length = 0;
11698 u8 is_translation = 0;
11700 u32 ip6_src_len = 128;
11702 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11704 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
11705 &ip4_prefix, &ip4_prefix_len))
11707 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
11708 &ip6_prefix, &ip6_prefix_len))
11712 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
11715 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
11717 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
11719 else if (unformat (i, "psid-offset %d", &psid_offset))
11721 else if (unformat (i, "psid-len %d", &psid_length))
11723 else if (unformat (i, "mtu %d", &mtu))
11725 else if (unformat (i, "map-t"))
11726 is_translation = 1;
11729 clib_warning ("parse error '%U'", format_unformat_error, i);
11734 if (num_m_args < 3)
11736 errmsg ("mandatory argument(s) missing\n");
11740 /* Construct the API message */
11741 M (MAP_ADD_DOMAIN, map_add_domain);
11743 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
11744 mp->ip4_prefix_len = ip4_prefix_len;
11746 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
11747 mp->ip6_prefix_len = ip6_prefix_len;
11749 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
11750 mp->ip6_src_prefix_len = ip6_src_len;
11752 mp->ea_bits_len = ea_bits_len;
11753 mp->psid_offset = psid_offset;
11754 mp->psid_length = psid_length;
11755 mp->is_translation = is_translation;
11756 mp->mtu = htons (mtu);
11761 /* Wait for a reply, return good/bad news */
11766 api_map_del_domain (vat_main_t * vam)
11768 unformat_input_t *i = vam->input;
11769 vl_api_map_del_domain_t *mp;
11772 u32 num_m_args = 0;
11775 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11777 if (unformat (i, "index %d", &index))
11781 clib_warning ("parse error '%U'", format_unformat_error, i);
11786 if (num_m_args != 1)
11788 errmsg ("mandatory argument(s) missing\n");
11792 /* Construct the API message */
11793 M (MAP_DEL_DOMAIN, map_del_domain);
11795 mp->index = ntohl (index);
11800 /* Wait for a reply, return good/bad news */
11805 api_map_add_del_rule (vat_main_t * vam)
11807 unformat_input_t *i = vam->input;
11808 vl_api_map_add_del_rule_t *mp;
11811 ip6_address_t ip6_dst;
11812 u32 num_m_args = 0, index, psid = 0;
11814 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11816 if (unformat (i, "index %d", &index))
11818 else if (unformat (i, "psid %d", &psid))
11820 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
11822 else if (unformat (i, "del"))
11828 clib_warning ("parse error '%U'", format_unformat_error, i);
11833 /* Construct the API message */
11834 M (MAP_ADD_DEL_RULE, map_add_del_rule);
11836 mp->index = ntohl (index);
11837 mp->is_add = is_add;
11838 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
11839 mp->psid = ntohs (psid);
11844 /* Wait for a reply, return good/bad news */
11849 api_map_domain_dump (vat_main_t * vam)
11851 vl_api_map_domain_dump_t *mp;
11854 /* Construct the API message */
11855 M (MAP_DOMAIN_DUMP, map_domain_dump);
11860 /* Use a control ping for synchronization */
11862 vl_api_control_ping_t *mp;
11863 M (CONTROL_PING, control_ping);
11870 api_map_rule_dump (vat_main_t * vam)
11872 unformat_input_t *i = vam->input;
11873 vl_api_map_rule_dump_t *mp;
11875 u32 domain_index = ~0;
11877 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11879 if (unformat (i, "index %u", &domain_index))
11885 if (domain_index == ~0)
11887 clib_warning ("parse error: domain index expected");
11891 /* Construct the API message */
11892 M (MAP_RULE_DUMP, map_rule_dump);
11894 mp->domain_index = htonl (domain_index);
11899 /* Use a control ping for synchronization */
11901 vl_api_control_ping_t *mp;
11902 M (CONTROL_PING, control_ping);
11908 static void vl_api_map_add_domain_reply_t_handler
11909 (vl_api_map_add_domain_reply_t * mp)
11911 vat_main_t *vam = &vat_main;
11912 i32 retval = ntohl (mp->retval);
11914 if (vam->async_mode)
11916 vam->async_errors += (retval < 0);
11920 vam->retval = retval;
11921 vam->result_ready = 1;
11925 static void vl_api_map_add_domain_reply_t_handler_json
11926 (vl_api_map_add_domain_reply_t * mp)
11928 vat_main_t *vam = &vat_main;
11929 vat_json_node_t node;
11931 vat_json_init_object (&node);
11932 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
11933 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
11935 vat_json_print (vam->ofp, &node);
11936 vat_json_free (&node);
11938 vam->retval = ntohl (mp->retval);
11939 vam->result_ready = 1;
11943 api_get_first_msg_id (vat_main_t * vam)
11945 vl_api_get_first_msg_id_t *mp;
11947 unformat_input_t *i = vam->input;
11951 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11953 if (unformat (i, "client %s", &name))
11961 errmsg ("missing client name\n");
11964 vec_add1 (name, 0);
11966 if (vec_len (name) > 63)
11968 errmsg ("client name too long\n");
11972 M (GET_FIRST_MSG_ID, get_first_msg_id);
11973 clib_memcpy (mp->name, name, vec_len (name));
11981 api_cop_interface_enable_disable (vat_main_t * vam)
11983 unformat_input_t *line_input = vam->input;
11984 vl_api_cop_interface_enable_disable_t *mp;
11986 u32 sw_if_index = ~0;
11987 u8 enable_disable = 1;
11989 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11991 if (unformat (line_input, "disable"))
11992 enable_disable = 0;
11993 if (unformat (line_input, "enable"))
11994 enable_disable = 1;
11995 else if (unformat (line_input, "%U", unformat_sw_if_index,
11996 vam, &sw_if_index))
11998 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12004 if (sw_if_index == ~0)
12006 errmsg ("missing interface name or sw_if_index\n");
12010 /* Construct the API message */
12011 M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable);
12012 mp->sw_if_index = ntohl (sw_if_index);
12013 mp->enable_disable = enable_disable;
12017 /* Wait for the reply */
12022 api_cop_whitelist_enable_disable (vat_main_t * vam)
12024 unformat_input_t *line_input = vam->input;
12025 vl_api_cop_whitelist_enable_disable_t *mp;
12027 u32 sw_if_index = ~0;
12028 u8 ip4 = 0, ip6 = 0, default_cop = 0;
12031 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12033 if (unformat (line_input, "ip4"))
12035 else if (unformat (line_input, "ip6"))
12037 else if (unformat (line_input, "default"))
12039 else if (unformat (line_input, "%U", unformat_sw_if_index,
12040 vam, &sw_if_index))
12042 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12044 else if (unformat (line_input, "fib-id %d", &fib_id))
12050 if (sw_if_index == ~0)
12052 errmsg ("missing interface name or sw_if_index\n");
12056 /* Construct the API message */
12057 M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable);
12058 mp->sw_if_index = ntohl (sw_if_index);
12059 mp->fib_id = ntohl (fib_id);
12062 mp->default_cop = default_cop;
12066 /* Wait for the reply */
12071 api_get_node_graph (vat_main_t * vam)
12073 vl_api_get_node_graph_t *mp;
12076 M (GET_NODE_GRAPH, get_node_graph);
12080 /* Wait for the reply */
12085 /** Used for parsing LISP eids */
12086 typedef CLIB_PACKED(struct{
12087 u8 addr[16]; /**< eid address */
12088 u32 len; /**< prefix length if IP */
12089 u8 type; /**< type of eid */
12094 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
12096 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
12098 memset (a, 0, sizeof (a[0]));
12100 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
12102 a->type = 0; /* ipv4 type */
12104 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
12106 a->type = 1; /* ipv6 type */
12108 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
12110 a->type = 2; /* mac type */
12117 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
12126 lisp_eid_size_vat (u8 type)
12141 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
12143 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
12147 /** Used for transferring locators via VPP API */
12148 typedef CLIB_PACKED(struct
12150 u32 sw_if_index; /**< locator sw_if_index */
12151 u8 priority; /**< locator priority */
12152 u8 weight; /**< locator weight */
12157 api_lisp_add_del_locator_set (vat_main_t * vam)
12159 unformat_input_t *input = vam->input;
12160 vl_api_lisp_add_del_locator_set_t *mp;
12163 u8 *locator_set_name = NULL;
12164 u8 locator_set_name_set = 0;
12165 ls_locator_t locator, *locators = 0;
12166 u32 sw_if_index, priority, weight;
12169 /* Parse args required to build the message */
12170 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12172 if (unformat (input, "del"))
12176 else if (unformat (input, "locator-set %s", &locator_set_name))
12178 locator_set_name_set = 1;
12180 else if (unformat (input, "sw_if_index %u p %u w %u",
12181 &sw_if_index, &priority, &weight))
12183 locator.sw_if_index = htonl (sw_if_index);
12184 locator.priority = priority;
12185 locator.weight = weight;
12186 vec_add1 (locators, locator);
12188 else if (unformat (input, "iface %U p %u w %u", unformat_sw_if_index,
12189 vam, &sw_if_index, &priority, &weight))
12191 locator.sw_if_index = htonl (sw_if_index);
12192 locator.priority = priority;
12193 locator.weight = weight;
12194 vec_add1 (locators, locator);
12200 if (locator_set_name_set == 0)
12202 errmsg ("missing locator-set name");
12203 vec_free (locators);
12207 if (vec_len (locator_set_name) > 64)
12209 errmsg ("locator-set name too long\n");
12210 vec_free (locator_set_name);
12211 vec_free (locators);
12214 vec_add1 (locator_set_name, 0);
12216 data_len = sizeof (ls_locator_t) * vec_len (locators);
12218 /* Construct the API message */
12219 M2 (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set, data_len);
12221 mp->is_add = is_add;
12222 clib_memcpy (mp->locator_set_name, locator_set_name,
12223 vec_len (locator_set_name));
12224 vec_free (locator_set_name);
12226 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
12228 clib_memcpy (mp->locators, locators, data_len);
12229 vec_free (locators);
12234 /* Wait for a reply... */
12242 api_lisp_add_del_locator (vat_main_t * vam)
12244 unformat_input_t *input = vam->input;
12245 vl_api_lisp_add_del_locator_t *mp;
12247 u32 tmp_if_index = ~0;
12248 u32 sw_if_index = ~0;
12249 u8 sw_if_index_set = 0;
12250 u8 sw_if_index_if_name_set = 0;
12252 u8 priority_set = 0;
12256 u8 *locator_set_name = NULL;
12257 u8 locator_set_name_set = 0;
12259 /* Parse args required to build the message */
12260 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12262 if (unformat (input, "del"))
12266 else if (unformat (input, "locator-set %s", &locator_set_name))
12268 locator_set_name_set = 1;
12270 else if (unformat (input, "iface %U", unformat_sw_if_index, vam,
12273 sw_if_index_if_name_set = 1;
12274 sw_if_index = tmp_if_index;
12276 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
12278 sw_if_index_set = 1;
12279 sw_if_index = tmp_if_index;
12281 else if (unformat (input, "p %d", &priority))
12285 else if (unformat (input, "w %d", &weight))
12293 if (locator_set_name_set == 0)
12295 errmsg ("missing locator-set name");
12299 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
12301 errmsg ("missing sw_if_index");
12302 vec_free (locator_set_name);
12306 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
12308 errmsg ("cannot use both params interface name and sw_if_index");
12309 vec_free (locator_set_name);
12313 if (priority_set == 0)
12315 errmsg ("missing locator-set priority\n");
12316 vec_free (locator_set_name);
12320 if (weight_set == 0)
12322 errmsg ("missing locator-set weight\n");
12323 vec_free (locator_set_name);
12327 if (vec_len (locator_set_name) > 64)
12329 errmsg ("locator-set name too long\n");
12330 vec_free (locator_set_name);
12333 vec_add1 (locator_set_name, 0);
12335 /* Construct the API message */
12336 M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
12338 mp->is_add = is_add;
12339 mp->sw_if_index = ntohl (sw_if_index);
12340 mp->priority = priority;
12341 mp->weight = weight;
12342 clib_memcpy (mp->locator_set_name, locator_set_name,
12343 vec_len (locator_set_name));
12344 vec_free (locator_set_name);
12349 /* Wait for a reply... */
12357 api_lisp_add_del_local_eid (vat_main_t * vam)
12359 unformat_input_t *input = vam->input;
12360 vl_api_lisp_add_del_local_eid_t *mp;
12364 lisp_eid_vat_t _eid, *eid = &_eid;
12365 u8 *locator_set_name = 0;
12366 u8 locator_set_name_set = 0;
12369 /* Parse args required to build the message */
12370 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12372 if (unformat (input, "del"))
12376 else if (unformat (input, "vni %d", &vni))
12380 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
12384 else if (unformat (input, "locator-set %s", &locator_set_name))
12386 locator_set_name_set = 1;
12392 if (locator_set_name_set == 0)
12394 errmsg ("missing locator-set name\n");
12400 errmsg ("EID address not set!");
12401 vec_free (locator_set_name);
12405 if (vec_len (locator_set_name) > 64)
12407 errmsg ("locator-set name too long\n");
12408 vec_free (locator_set_name);
12411 vec_add1 (locator_set_name, 0);
12413 /* Construct the API message */
12414 M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
12416 mp->is_add = is_add;
12417 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
12418 mp->eid_type = eid->type;
12419 mp->prefix_len = eid->len;
12420 mp->vni = clib_host_to_net_u32 (vni);
12421 clib_memcpy (mp->locator_set_name, locator_set_name,
12422 vec_len (locator_set_name));
12424 vec_free (locator_set_name);
12429 /* Wait for a reply... */
12437 /** Used for transferring locators via VPP API */
12438 typedef CLIB_PACKED(struct
12440 u8 is_ip4; /**< is locator an IPv4 address? */
12441 u8 priority; /**< locator priority */
12442 u8 weight; /**< locator weight */
12443 u8 addr[16]; /**< IPv4/IPv6 address */
12448 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
12450 unformat_input_t *input = vam->input;
12451 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
12454 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
12455 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
12456 u8 rmt_eid_set = 0, lcl_eid_set = 0;
12457 u32 action = ~0, p, w;
12458 ip4_address_t rmt_rloc4, lcl_rloc4;
12459 ip6_address_t rmt_rloc6, lcl_rloc6;
12460 rloc_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
12462 memset (&rloc, 0, sizeof (rloc));
12464 /* Parse args required to build the message */
12465 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12467 if (unformat (input, "del"))
12471 else if (unformat (input, "rmt_eid %U", unformat_lisp_eid_vat, rmt_eid))
12475 else if (unformat (input, "lcl_eid %U", unformat_lisp_eid_vat, lcl_eid))
12479 else if (unformat (input, "p %d w %d", &p, &w))
12483 errmsg ("No RLOC configured for setting priority/weight!");
12486 curr_rloc->priority = p;
12487 curr_rloc->weight = w;
12489 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
12490 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
12494 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
12495 rloc.priority = rloc.weight = 0;
12496 vec_add1 (lcl_locs, rloc);
12498 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
12499 vec_add1 (rmt_locs, rloc);
12500 /* priority and weight saved in rmt loc */
12501 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
12503 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
12504 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
12507 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
12508 rloc.priority = rloc.weight = 0;
12509 vec_add1 (lcl_locs, rloc);
12511 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
12512 vec_add1 (rmt_locs, rloc);
12513 /* priority and weight saved in rmt loc */
12514 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
12516 else if (unformat (input, "action %d", &action))
12522 clib_warning ("parse error '%U'", format_unformat_error, input);
12529 errmsg ("remote eid addresses not set\n");
12533 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
12535 errmsg ("eid types don't match\n");
12539 if (0 == rmt_locs && (u32) ~ 0 == action)
12541 errmsg ("action not set for negative mapping\n");
12545 /* Construct the API message */
12546 M (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry);
12548 mp->is_add = is_add;
12549 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
12550 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
12551 mp->eid_type = rmt_eid->type;
12552 mp->rmt_len = rmt_eid->len;
12553 mp->lcl_len = lcl_eid->len;
12554 mp->action = action;
12556 if (0 != rmt_locs && 0 != lcl_locs)
12558 mp->loc_num = vec_len (rmt_locs);
12559 clib_memcpy (mp->lcl_locs, lcl_locs,
12560 (sizeof (rloc_t) * vec_len (lcl_locs)));
12561 clib_memcpy (mp->rmt_locs, rmt_locs,
12562 (sizeof (rloc_t) * vec_len (rmt_locs)));
12564 vec_free (lcl_locs);
12565 vec_free (rmt_locs);
12570 /* Wait for a reply... */
12578 api_lisp_add_del_map_resolver (vat_main_t * vam)
12580 unformat_input_t *input = vam->input;
12581 vl_api_lisp_add_del_map_resolver_t *mp;
12586 ip4_address_t ipv4;
12587 ip6_address_t ipv6;
12589 /* Parse args required to build the message */
12590 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12592 if (unformat (input, "del"))
12596 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
12600 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
12608 if (ipv4_set && ipv6_set)
12610 errmsg ("both eid v4 and v6 addresses set\n");
12614 if (!ipv4_set && !ipv6_set)
12616 errmsg ("eid addresses not set\n");
12620 /* Construct the API message */
12621 M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
12623 mp->is_add = is_add;
12627 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
12632 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
12638 /* Wait for a reply... */
12646 api_lisp_gpe_enable_disable (vat_main_t * vam)
12648 unformat_input_t *input = vam->input;
12649 vl_api_lisp_gpe_enable_disable_t *mp;
12654 /* Parse args required to build the message */
12655 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12657 if (unformat (input, "enable"))
12662 else if (unformat (input, "disable"))
12673 errmsg ("Value not set\n");
12677 /* Construct the API message */
12678 M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
12685 /* Wait for a reply... */
12693 api_lisp_enable_disable (vat_main_t * vam)
12695 unformat_input_t *input = vam->input;
12696 vl_api_lisp_enable_disable_t *mp;
12701 /* Parse args required to build the message */
12702 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12704 if (unformat (input, "enable"))
12709 else if (unformat (input, "disable"))
12719 errmsg ("Value not set\n");
12723 /* Construct the API message */
12724 M (LISP_ENABLE_DISABLE, lisp_enable_disable);
12731 /* Wait for a reply... */
12739 api_show_lisp_map_request_mode (vat_main_t * vam)
12742 vl_api_show_lisp_map_request_mode_t *mp;
12744 M (SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode);
12749 /* wait for reply */
12756 api_lisp_map_request_mode (vat_main_t * vam)
12759 unformat_input_t *input = vam->input;
12760 vl_api_lisp_map_request_mode_t *mp;
12763 /* Parse args required to build the message */
12764 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12766 if (unformat (input, "dst-only"))
12768 else if (unformat (input, "src-dst"))
12772 errmsg ("parse error '%U'", format_unformat_error, input);
12777 M (LISP_MAP_REQUEST_MODE, lisp_map_request_mode);
12784 /* wait for reply */
12792 * Enable/disable LISP proxy ITR.
12794 * @param vam vpp API test context
12795 * @return return code
12798 api_lisp_pitr_set_locator_set (vat_main_t * vam)
12801 u8 ls_name_set = 0;
12802 unformat_input_t *input = vam->input;
12803 vl_api_lisp_pitr_set_locator_set_t *mp;
12807 /* Parse args required to build the message */
12808 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12810 if (unformat (input, "del"))
12812 else if (unformat (input, "locator-set %s", &ls_name))
12816 errmsg ("parse error '%U'", format_unformat_error, input);
12823 errmsg ("locator-set name not set!");
12827 M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set);
12829 mp->is_add = is_add;
12830 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
12831 vec_free (ls_name);
12836 /* wait for reply */
12844 api_show_lisp_pitr (vat_main_t * vam)
12846 vl_api_show_lisp_pitr_t *mp;
12849 if (!vam->json_output)
12851 fformat (vam->ofp, "%=20s\n", "lisp status:");
12854 M (SHOW_LISP_PITR, show_lisp_pitr);
12858 /* Wait for a reply... */
12866 * Add/delete mapping between vni and vrf
12869 api_lisp_eid_table_add_del_map (vat_main_t * vam)
12872 unformat_input_t *input = vam->input;
12873 vl_api_lisp_eid_table_add_del_map_t *mp;
12874 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
12875 u32 vni, vrf, bd_index;
12877 /* Parse args required to build the message */
12878 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12880 if (unformat (input, "del"))
12882 else if (unformat (input, "vrf %d", &vrf))
12884 else if (unformat (input, "bd_index %d", &bd_index))
12886 else if (unformat (input, "vni %d", &vni))
12892 if (!vni_set || (!vrf_set && !bd_index_set))
12894 errmsg ("missing arguments!");
12898 if (vrf_set && bd_index_set)
12900 errmsg ("error: both vrf and bd entered!");
12904 M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
12906 mp->is_add = is_add;
12907 mp->vni = htonl (vni);
12908 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
12909 mp->is_l2 = bd_index_set;
12914 /* wait for reply */
12922 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
12924 u32 *action = va_arg (*args, u32 *);
12927 if (unformat (input, "%s", &s))
12929 if (!strcmp ((char *) s, "no-action"))
12931 else if (!strcmp ((char *) s, "natively-forward"))
12933 else if (!strcmp ((char *) s, "send-map-request"))
12935 else if (!strcmp ((char *) s, "drop"))
12939 clib_warning ("invalid action: '%s'", s);
12951 * Add/del remote mapping to/from LISP control plane
12953 * @param vam vpp API test context
12954 * @return return code
12957 api_lisp_add_del_remote_mapping (vat_main_t * vam)
12959 unformat_input_t *input = vam->input;
12960 vl_api_lisp_add_del_remote_mapping_t *mp;
12963 lisp_eid_vat_t _eid, *eid = &_eid;
12964 lisp_eid_vat_t _seid, *seid = &_seid;
12965 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
12966 u32 action = ~0, p, w, data_len;
12967 ip4_address_t rloc4;
12968 ip6_address_t rloc6;
12969 rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
12971 memset (&rloc, 0, sizeof (rloc));
12973 /* Parse args required to build the message */
12974 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12976 if (unformat (input, "del-all"))
12980 else if (unformat (input, "del"))
12984 else if (unformat (input, "add"))
12988 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
12992 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
12996 else if (unformat (input, "vni %d", &vni))
13000 else if (unformat (input, "p %d w %d", &p, &w))
13004 errmsg ("No RLOC configured for setting priority/weight!");
13007 curr_rloc->priority = p;
13008 curr_rloc->weight = w;
13010 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
13013 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
13014 vec_add1 (rlocs, rloc);
13015 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13017 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
13020 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
13021 vec_add1 (rlocs, rloc);
13022 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13024 else if (unformat (input, "action %U",
13025 unformat_negative_mapping_action, &action))
13031 clib_warning ("parse error '%U'", format_unformat_error, input);
13038 errmsg ("missing params!");
13042 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
13044 errmsg ("no action set for negative map-reply!");
13048 data_len = vec_len (rlocs) * sizeof (rloc_t);
13050 M2 (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping, data_len);
13051 mp->is_add = is_add;
13052 mp->vni = htonl (vni);
13053 mp->action = (u8) action;
13054 mp->is_src_dst = seid_set;
13055 mp->eid_len = eid->len;
13056 mp->seid_len = seid->len;
13057 mp->del_all = del_all;
13058 mp->eid_type = eid->type;
13059 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13060 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
13062 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
13063 clib_memcpy (mp->rlocs, rlocs, data_len);
13069 /* Wait for a reply... */
13077 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
13078 * forwarding entries in data-plane accordingly.
13080 * @param vam vpp API test context
13081 * @return return code
13084 api_lisp_add_del_adjacency (vat_main_t * vam)
13086 unformat_input_t *input = vam->input;
13087 vl_api_lisp_add_del_adjacency_t *mp;
13090 ip4_address_t leid4, reid4;
13091 ip6_address_t leid6, reid6;
13092 u8 reid_mac[6] = { 0 };
13093 u8 leid_mac[6] = { 0 };
13094 u8 reid_type, leid_type;
13095 u32 leid_len = 0, reid_len = 0, len;
13098 leid_type = reid_type = (u8) ~ 0;
13100 /* Parse args required to build the message */
13101 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13103 if (unformat (input, "del"))
13107 else if (unformat (input, "add"))
13111 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
13114 reid_type = 0; /* ipv4 */
13117 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
13120 reid_type = 1; /* ipv6 */
13123 else if (unformat (input, "reid %U", unformat_ethernet_address,
13126 reid_type = 2; /* mac */
13128 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
13131 leid_type = 0; /* ipv4 */
13134 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
13137 leid_type = 1; /* ipv6 */
13140 else if (unformat (input, "leid %U", unformat_ethernet_address,
13143 leid_type = 2; /* mac */
13145 else if (unformat (input, "vni %d", &vni))
13151 errmsg ("parse error '%U'", format_unformat_error, input);
13156 if ((u8) ~ 0 == reid_type)
13158 errmsg ("missing params!");
13162 if (leid_type != reid_type)
13164 errmsg ("remote and local EIDs are of different types!");
13168 M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency);
13169 mp->is_add = is_add;
13170 mp->vni = htonl (vni);
13171 mp->leid_len = leid_len;
13172 mp->reid_len = reid_len;
13173 mp->eid_type = reid_type;
13175 switch (mp->eid_type)
13178 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
13179 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
13182 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
13183 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
13186 clib_memcpy (mp->leid, leid_mac, 6);
13187 clib_memcpy (mp->reid, reid_mac, 6);
13190 errmsg ("unknown EID type %d!", mp->eid_type);
13197 /* Wait for a reply... */
13205 api_lisp_gpe_add_del_iface (vat_main_t * vam)
13207 unformat_input_t *input = vam->input;
13208 vl_api_lisp_gpe_add_del_iface_t *mp;
13210 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
13211 u32 dp_table = 0, vni = 0;
13213 /* Parse args required to build the message */
13214 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13216 if (unformat (input, "up"))
13221 else if (unformat (input, "down"))
13226 else if (unformat (input, "table_id %d", &dp_table))
13230 else if (unformat (input, "bd_id %d", &dp_table))
13235 else if (unformat (input, "vni %d", &vni))
13243 if (action_set == 0)
13245 errmsg ("Action not set\n");
13248 if (dp_table_set == 0 || vni_set == 0)
13250 errmsg ("vni and dp_table must be set\n");
13254 /* Construct the API message */
13255 M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
13257 mp->is_add = is_add;
13258 mp->dp_table = dp_table;
13265 /* Wait for a reply... */
13273 * Add/del map request itr rlocs from LISP control plane and updates
13275 * @param vam vpp API test context
13276 * @return return code
13279 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
13281 unformat_input_t *input = vam->input;
13282 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
13284 u8 *locator_set_name = 0;
13285 u8 locator_set_name_set = 0;
13288 /* Parse args required to build the message */
13289 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13291 if (unformat (input, "del"))
13295 else if (unformat (input, "%_%v%_", &locator_set_name))
13297 locator_set_name_set = 1;
13301 clib_warning ("parse error '%U'", format_unformat_error, input);
13306 if (is_add && !locator_set_name_set)
13308 errmsg ("itr-rloc is not set!");
13312 if (is_add && vec_len (locator_set_name) > 64)
13314 errmsg ("itr-rloc locator-set name too long\n");
13315 vec_free (locator_set_name);
13319 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs);
13320 mp->is_add = is_add;
13323 clib_memcpy (mp->locator_set_name, locator_set_name,
13324 vec_len (locator_set_name));
13328 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
13330 vec_free (locator_set_name);
13335 /* Wait for a reply... */
13343 api_lisp_locator_dump (vat_main_t * vam)
13345 unformat_input_t *input = vam->input;
13346 vl_api_lisp_locator_dump_t *mp;
13348 u8 is_index_set = 0, is_name_set = 0;
13352 /* Parse args required to build the message */
13353 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13355 if (unformat (input, "ls_name %_%v%_", &ls_name))
13359 else if (unformat (input, "ls_index %d", &ls_index))
13365 errmsg ("parse error '%U'", format_unformat_error, input);
13370 if (!is_index_set && !is_name_set)
13372 errmsg ("error: expected one of index or name!\n");
13376 if (is_index_set && is_name_set)
13378 errmsg ("error: only one param expected!\n");
13382 if (vec_len (ls_name) > 62)
13384 errmsg ("error: locator set name too long!");
13388 if (!vam->json_output)
13390 fformat (vam->ofp, "%=16s%=16s%=16s\n", "locator", "priority",
13394 M (LISP_LOCATOR_DUMP, lisp_locator_dump);
13395 mp->is_index_set = is_index_set;
13398 mp->ls_index = clib_host_to_net_u32 (ls_index);
13401 vec_add1 (ls_name, 0);
13402 strncpy ((char *) mp->ls_name, (char *) ls_name,
13403 sizeof (mp->ls_name) - 1);
13409 /* Use a control ping for synchronization */
13411 vl_api_control_ping_t *mp;
13412 M (CONTROL_PING, control_ping);
13415 /* Wait for a reply... */
13423 api_lisp_locator_set_dump (vat_main_t * vam)
13425 vl_api_lisp_locator_set_dump_t *mp;
13426 unformat_input_t *input = vam->input;
13430 /* Parse args required to build the message */
13431 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13433 if (unformat (input, "local"))
13437 else if (unformat (input, "remote"))
13443 errmsg ("parse error '%U'", format_unformat_error, input);
13448 if (!vam->json_output)
13450 fformat (vam->ofp, "%=10s%=15s\n", "ls_index", "ls_name");
13453 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
13455 mp->filter = filter;
13460 /* Use a control ping for synchronization */
13462 vl_api_control_ping_t *mp;
13463 M (CONTROL_PING, control_ping);
13466 /* Wait for a reply... */
13474 api_lisp_eid_table_map_dump (vat_main_t * vam)
13478 unformat_input_t *input = vam->input;
13479 vl_api_lisp_eid_table_map_dump_t *mp;
13482 /* Parse args required to build the message */
13483 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13485 if (unformat (input, "l2"))
13490 else if (unformat (input, "l3"))
13497 errmsg ("parse error '%U'", format_unformat_error, input);
13504 errmsg ("expected one of 'l2' or 'l3' parameter!\n");
13508 if (!vam->json_output)
13510 fformat (vam->ofp, "%=10s%=10s\n", "VNI", is_l2 ? "BD" : "VRF");
13513 M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump);
13519 /* Use a control ping for synchronization */
13521 vl_api_control_ping_t *mp;
13522 M (CONTROL_PING, control_ping);
13525 /* Wait for a reply... */
13533 api_lisp_eid_table_vni_dump (vat_main_t * vam)
13535 vl_api_lisp_eid_table_vni_dump_t *mp;
13538 if (!vam->json_output)
13540 fformat (vam->ofp, "VNI\n");
13543 M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
13548 /* Use a control ping for synchronization */
13550 vl_api_control_ping_t *mp;
13551 M (CONTROL_PING, control_ping);
13554 /* Wait for a reply... */
13562 api_lisp_eid_table_dump (vat_main_t * vam)
13564 unformat_input_t *i = vam->input;
13565 vl_api_lisp_eid_table_dump_t *mp;
13567 struct in_addr ip4;
13568 struct in6_addr ip6;
13570 u8 eid_type = ~0, eid_set = 0;
13571 u32 prefix_length = ~0, t, vni = 0;
13574 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13576 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
13582 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
13588 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
13593 else if (unformat (i, "vni %d", &t))
13597 else if (unformat (i, "local"))
13601 else if (unformat (i, "remote"))
13607 errmsg ("parse error '%U'", format_unformat_error, i);
13612 if (!vam->json_output)
13614 fformat (vam->ofp, "%-35s%-20s%-30s%-20s%-s\n", "EID", "type",
13615 "ls_index", "ttl", "authoritative");
13618 M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump);
13620 mp->filter = filter;
13624 mp->vni = htonl (vni);
13625 mp->eid_type = eid_type;
13629 mp->prefix_length = prefix_length;
13630 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
13633 mp->prefix_length = prefix_length;
13634 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
13637 clib_memcpy (mp->eid, mac, sizeof (mac));
13640 errmsg ("unknown EID type %d!", eid_type);
13648 /* Use a control ping for synchronization */
13650 vl_api_control_ping_t *mp;
13651 M (CONTROL_PING, control_ping);
13655 /* Wait for a reply... */
13663 api_lisp_gpe_tunnel_dump (vat_main_t * vam)
13665 vl_api_lisp_gpe_tunnel_dump_t *mp;
13668 if (!vam->json_output)
13670 fformat (vam->ofp, "%=20s%=30s%=16s%=16s%=16s%=16s"
13671 "%=16s%=16s%=16s%=16s%=16s\n",
13672 "Tunel", "Source", "Destination", "Fib encap", "Fib decap",
13673 "Decap next", "Lisp version", "Flags", "Next protocol",
13674 "ver_res", "res", "iid");
13677 M (LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump);
13681 /* Use a control ping for synchronization */
13683 vl_api_control_ping_t *mp;
13684 M (CONTROL_PING, control_ping);
13687 /* Wait for a reply... */
13695 api_lisp_map_resolver_dump (vat_main_t * vam)
13697 vl_api_lisp_map_resolver_dump_t *mp;
13700 if (!vam->json_output)
13702 fformat (vam->ofp, "%=20s\n", "Map resolver");
13705 M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
13709 /* Use a control ping for synchronization */
13711 vl_api_control_ping_t *mp;
13712 M (CONTROL_PING, control_ping);
13715 /* Wait for a reply... */
13723 api_show_lisp_status (vat_main_t * vam)
13725 vl_api_show_lisp_status_t *mp;
13728 if (!vam->json_output)
13730 fformat (vam->ofp, "%-20s%-16s\n", "lisp status", "locator-set");
13733 M (SHOW_LISP_STATUS, show_lisp_status);
13736 /* Wait for a reply... */
13744 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
13746 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
13749 if (!vam->json_output)
13751 fformat (vam->ofp, "%=20s\n", "itr-rlocs:");
13754 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
13757 /* Wait for a reply... */
13765 api_af_packet_create (vat_main_t * vam)
13767 unformat_input_t *i = vam->input;
13768 vl_api_af_packet_create_t *mp;
13770 u8 *host_if_name = 0;
13772 u8 random_hw_addr = 1;
13774 memset (hw_addr, 0, sizeof (hw_addr));
13776 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13778 if (unformat (i, "name %s", &host_if_name))
13779 vec_add1 (host_if_name, 0);
13780 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
13781 random_hw_addr = 0;
13786 if (!vec_len (host_if_name))
13788 errmsg ("host-interface name must be specified");
13792 if (vec_len (host_if_name) > 64)
13794 errmsg ("host-interface name too long");
13798 M (AF_PACKET_CREATE, af_packet_create);
13800 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
13801 clib_memcpy (mp->hw_addr, hw_addr, 6);
13802 mp->use_random_hw_addr = random_hw_addr;
13803 vec_free (host_if_name);
13806 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
13812 api_af_packet_delete (vat_main_t * vam)
13814 unformat_input_t *i = vam->input;
13815 vl_api_af_packet_delete_t *mp;
13817 u8 *host_if_name = 0;
13819 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13821 if (unformat (i, "name %s", &host_if_name))
13822 vec_add1 (host_if_name, 0);
13827 if (!vec_len (host_if_name))
13829 errmsg ("host-interface name must be specified");
13833 if (vec_len (host_if_name) > 64)
13835 errmsg ("host-interface name too long");
13839 M (AF_PACKET_DELETE, af_packet_delete);
13841 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
13842 vec_free (host_if_name);
13851 api_policer_add_del (vat_main_t * vam)
13853 unformat_input_t *i = vam->input;
13854 vl_api_policer_add_del_t *mp;
13865 u8 color_aware = 0;
13866 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
13868 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
13869 conform_action.dscp = 0;
13870 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
13871 exceed_action.dscp = 0;
13872 violate_action.action_type = SSE2_QOS_ACTION_DROP;
13873 violate_action.dscp = 0;
13875 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13877 if (unformat (i, "del"))
13879 else if (unformat (i, "name %s", &name))
13880 vec_add1 (name, 0);
13881 else if (unformat (i, "cir %u", &cir))
13883 else if (unformat (i, "eir %u", &eir))
13885 else if (unformat (i, "cb %u", &cb))
13887 else if (unformat (i, "eb %u", &eb))
13889 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
13892 else if (unformat (i, "round_type %U", unformat_policer_round_type,
13895 else if (unformat (i, "type %U", unformat_policer_type, &type))
13897 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
13900 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
13903 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
13906 else if (unformat (i, "color-aware"))
13912 if (!vec_len (name))
13914 errmsg ("policer name must be specified");
13918 if (vec_len (name) > 64)
13920 errmsg ("policer name too long");
13924 M (POLICER_ADD_DEL, policer_add_del);
13926 clib_memcpy (mp->name, name, vec_len (name));
13928 mp->is_add = is_add;
13933 mp->rate_type = rate_type;
13934 mp->round_type = round_type;
13936 mp->conform_action_type = conform_action.action_type;
13937 mp->conform_dscp = conform_action.dscp;
13938 mp->exceed_action_type = exceed_action.action_type;
13939 mp->exceed_dscp = exceed_action.dscp;
13940 mp->violate_action_type = violate_action.action_type;
13941 mp->violate_dscp = violate_action.dscp;
13942 mp->color_aware = color_aware;
13951 api_policer_dump (vat_main_t * vam)
13953 unformat_input_t *i = vam->input;
13954 vl_api_policer_dump_t *mp;
13956 u8 *match_name = 0;
13957 u8 match_name_valid = 0;
13959 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13961 if (unformat (i, "name %s", &match_name))
13963 vec_add1 (match_name, 0);
13964 match_name_valid = 1;
13970 M (POLICER_DUMP, policer_dump);
13971 mp->match_name_valid = match_name_valid;
13972 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
13973 vec_free (match_name);
13977 /* Use a control ping for synchronization */
13979 vl_api_control_ping_t *mp;
13980 M (CONTROL_PING, control_ping);
13983 /* Wait for a reply... */
13991 api_policer_classify_set_interface (vat_main_t * vam)
13993 unformat_input_t *i = vam->input;
13994 vl_api_policer_classify_set_interface_t *mp;
13997 int sw_if_index_set;
13998 u32 ip4_table_index = ~0;
13999 u32 ip6_table_index = ~0;
14000 u32 l2_table_index = ~0;
14003 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14005 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
14006 sw_if_index_set = 1;
14007 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14008 sw_if_index_set = 1;
14009 else if (unformat (i, "del"))
14011 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14013 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14015 else if (unformat (i, "l2-table %d", &l2_table_index))
14019 clib_warning ("parse error '%U'", format_unformat_error, i);
14024 if (sw_if_index_set == 0)
14026 errmsg ("missing interface name or sw_if_index\n");
14030 M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface);
14032 mp->sw_if_index = ntohl (sw_if_index);
14033 mp->ip4_table_index = ntohl (ip4_table_index);
14034 mp->ip6_table_index = ntohl (ip6_table_index);
14035 mp->l2_table_index = ntohl (l2_table_index);
14036 mp->is_add = is_add;
14045 api_policer_classify_dump (vat_main_t * vam)
14047 unformat_input_t *i = vam->input;
14048 vl_api_policer_classify_dump_t *mp;
14050 u8 type = POLICER_CLASSIFY_N_TABLES;
14052 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
14056 errmsg ("classify table type must be specified\n");
14060 if (!vam->json_output)
14062 fformat (vam->ofp, "%10s%20s\n", "Intfc idx", "Classify table");
14065 M (POLICER_CLASSIFY_DUMP, policer_classify_dump);
14070 /* Use a control ping for synchronization */
14072 vl_api_control_ping_t *mp;
14073 M (CONTROL_PING, control_ping);
14076 /* Wait for a reply... */
14084 api_netmap_create (vat_main_t * vam)
14086 unformat_input_t *i = vam->input;
14087 vl_api_netmap_create_t *mp;
14091 u8 random_hw_addr = 1;
14095 memset (hw_addr, 0, sizeof (hw_addr));
14097 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14099 if (unformat (i, "name %s", &if_name))
14100 vec_add1 (if_name, 0);
14101 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14102 random_hw_addr = 0;
14103 else if (unformat (i, "pipe"))
14105 else if (unformat (i, "master"))
14107 else if (unformat (i, "slave"))
14113 if (!vec_len (if_name))
14115 errmsg ("interface name must be specified");
14119 if (vec_len (if_name) > 64)
14121 errmsg ("interface name too long");
14125 M (NETMAP_CREATE, netmap_create);
14127 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
14128 clib_memcpy (mp->hw_addr, hw_addr, 6);
14129 mp->use_random_hw_addr = random_hw_addr;
14130 mp->is_pipe = is_pipe;
14131 mp->is_master = is_master;
14132 vec_free (if_name);
14141 api_netmap_delete (vat_main_t * vam)
14143 unformat_input_t *i = vam->input;
14144 vl_api_netmap_delete_t *mp;
14148 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14150 if (unformat (i, "name %s", &if_name))
14151 vec_add1 (if_name, 0);
14156 if (!vec_len (if_name))
14158 errmsg ("interface name must be specified");
14162 if (vec_len (if_name) > 64)
14164 errmsg ("interface name too long");
14168 M (NETMAP_DELETE, netmap_delete);
14170 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
14171 vec_free (if_name);
14179 static void vl_api_mpls_gre_tunnel_details_t_handler
14180 (vl_api_mpls_gre_tunnel_details_t * mp)
14182 vat_main_t *vam = &vat_main;
14184 i32 len = ntohl (mp->nlabels);
14186 if (mp->l2_only == 0)
14188 fformat (vam->ofp, "[%d]: src %U, dst %U, adj %U/%d, labels ",
14189 ntohl (mp->tunnel_index),
14190 format_ip4_address, &mp->tunnel_src,
14191 format_ip4_address, &mp->tunnel_dst,
14192 format_ip4_address, &mp->intfc_address,
14193 ntohl (mp->mask_width));
14194 for (i = 0; i < len; i++)
14196 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14198 fformat (vam->ofp, "\n");
14199 fformat (vam->ofp, " inner fib index %d, outer fib index %d\n",
14200 ntohl (mp->inner_fib_index), ntohl (mp->outer_fib_index));
14204 fformat (vam->ofp, "[%d]: src %U, dst %U, key %U, labels ",
14205 ntohl (mp->tunnel_index),
14206 format_ip4_address, &mp->tunnel_src,
14207 format_ip4_address, &mp->tunnel_dst,
14208 format_ip4_address, &mp->intfc_address);
14209 for (i = 0; i < len; i++)
14211 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14213 fformat (vam->ofp, "\n");
14214 fformat (vam->ofp, " l2 interface %d, outer fib index %d\n",
14215 ntohl (mp->hw_if_index), ntohl (mp->outer_fib_index));
14219 static void vl_api_mpls_gre_tunnel_details_t_handler_json
14220 (vl_api_mpls_gre_tunnel_details_t * mp)
14222 vat_main_t *vam = &vat_main;
14223 vat_json_node_t *node = NULL;
14224 struct in_addr ip4;
14226 i32 len = ntohl (mp->nlabels);
14228 if (VAT_JSON_ARRAY != vam->json_tree.type)
14230 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14231 vat_json_init_array (&vam->json_tree);
14233 node = vat_json_array_add (&vam->json_tree);
14235 vat_json_init_object (node);
14236 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
14237 clib_memcpy (&ip4, &(mp->intfc_address), sizeof (ip4));
14238 vat_json_object_add_ip4 (node, "intfc_address", ip4);
14239 vat_json_object_add_uint (node, "inner_fib_index",
14240 ntohl (mp->inner_fib_index));
14241 vat_json_object_add_uint (node, "mask_width", ntohl (mp->mask_width));
14242 vat_json_object_add_uint (node, "encap_index", ntohl (mp->encap_index));
14243 vat_json_object_add_uint (node, "hw_if_index", ntohl (mp->hw_if_index));
14244 vat_json_object_add_uint (node, "l2_only", ntohl (mp->l2_only));
14245 clib_memcpy (&ip4, &(mp->tunnel_src), sizeof (ip4));
14246 vat_json_object_add_ip4 (node, "tunnel_src", ip4);
14247 clib_memcpy (&ip4, &(mp->tunnel_dst), sizeof (ip4));
14248 vat_json_object_add_ip4 (node, "tunnel_dst", ip4);
14249 vat_json_object_add_uint (node, "outer_fib_index",
14250 ntohl (mp->outer_fib_index));
14251 vat_json_object_add_uint (node, "label_count", len);
14252 for (i = 0; i < len; i++)
14254 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14259 api_mpls_gre_tunnel_dump (vat_main_t * vam)
14261 vl_api_mpls_gre_tunnel_dump_t *mp;
14265 /* Parse args required to build the message */
14266 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
14268 if (!unformat (vam->input, "tunnel_index %d", &index))
14275 fformat (vam->ofp, " tunnel_index %d\n", index);
14277 M (MPLS_GRE_TUNNEL_DUMP, mpls_gre_tunnel_dump);
14278 mp->tunnel_index = htonl (index);
14281 /* Use a control ping for synchronization */
14283 vl_api_control_ping_t *mp;
14284 M (CONTROL_PING, control_ping);
14290 static void vl_api_mpls_eth_tunnel_details_t_handler
14291 (vl_api_mpls_eth_tunnel_details_t * mp)
14293 vat_main_t *vam = &vat_main;
14295 i32 len = ntohl (mp->nlabels);
14297 fformat (vam->ofp, "[%d]: dst %U, adj %U/%d, labels ",
14298 ntohl (mp->tunnel_index),
14299 format_ethernet_address, &mp->tunnel_dst_mac,
14300 format_ip4_address, &mp->intfc_address, ntohl (mp->mask_width));
14301 for (i = 0; i < len; i++)
14303 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14305 fformat (vam->ofp, "\n");
14306 fformat (vam->ofp, " tx on %d, rx fib index %d\n",
14307 ntohl (mp->tx_sw_if_index), ntohl (mp->inner_fib_index));
14310 static void vl_api_mpls_eth_tunnel_details_t_handler_json
14311 (vl_api_mpls_eth_tunnel_details_t * mp)
14313 vat_main_t *vam = &vat_main;
14314 vat_json_node_t *node = NULL;
14315 struct in_addr ip4;
14317 i32 len = ntohl (mp->nlabels);
14319 if (VAT_JSON_ARRAY != vam->json_tree.type)
14321 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14322 vat_json_init_array (&vam->json_tree);
14324 node = vat_json_array_add (&vam->json_tree);
14326 vat_json_init_object (node);
14327 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
14328 clib_memcpy (&ip4, &(mp->intfc_address), sizeof (ip4));
14329 vat_json_object_add_ip4 (node, "intfc_address", ip4);
14330 vat_json_object_add_uint (node, "inner_fib_index",
14331 ntohl (mp->inner_fib_index));
14332 vat_json_object_add_uint (node, "mask_width", ntohl (mp->mask_width));
14333 vat_json_object_add_uint (node, "encap_index", ntohl (mp->encap_index));
14334 vat_json_object_add_uint (node, "hw_if_index", ntohl (mp->hw_if_index));
14335 vat_json_object_add_uint (node, "l2_only", ntohl (mp->l2_only));
14336 vat_json_object_add_string_copy (node, "tunnel_dst_mac",
14337 format (0, "%U", format_ethernet_address,
14338 &mp->tunnel_dst_mac));
14339 vat_json_object_add_uint (node, "tx_sw_if_index",
14340 ntohl (mp->tx_sw_if_index));
14341 vat_json_object_add_uint (node, "label_count", len);
14342 for (i = 0; i < len; i++)
14344 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14349 api_mpls_eth_tunnel_dump (vat_main_t * vam)
14351 vl_api_mpls_eth_tunnel_dump_t *mp;
14355 /* Parse args required to build the message */
14356 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
14358 if (!unformat (vam->input, "tunnel_index %d", &index))
14365 fformat (vam->ofp, " tunnel_index %d\n", index);
14367 M (MPLS_ETH_TUNNEL_DUMP, mpls_eth_tunnel_dump);
14368 mp->tunnel_index = htonl (index);
14371 /* Use a control ping for synchronization */
14373 vl_api_control_ping_t *mp;
14374 M (CONTROL_PING, control_ping);
14380 static void vl_api_mpls_fib_encap_details_t_handler
14381 (vl_api_mpls_fib_encap_details_t * mp)
14383 vat_main_t *vam = &vat_main;
14385 i32 len = ntohl (mp->nlabels);
14387 fformat (vam->ofp, "table %d, dest %U, label ",
14388 ntohl (mp->fib_index), format_ip4_address, &mp->dest, len);
14389 for (i = 0; i < len; i++)
14391 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14393 fformat (vam->ofp, "\n");
14396 static void vl_api_mpls_fib_encap_details_t_handler_json
14397 (vl_api_mpls_fib_encap_details_t * mp)
14399 vat_main_t *vam = &vat_main;
14400 vat_json_node_t *node = NULL;
14402 i32 len = ntohl (mp->nlabels);
14403 struct in_addr ip4;
14405 if (VAT_JSON_ARRAY != vam->json_tree.type)
14407 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14408 vat_json_init_array (&vam->json_tree);
14410 node = vat_json_array_add (&vam->json_tree);
14412 vat_json_init_object (node);
14413 vat_json_object_add_uint (node, "table", ntohl (mp->fib_index));
14414 vat_json_object_add_uint (node, "entry_index", ntohl (mp->entry_index));
14415 clib_memcpy (&ip4, &(mp->dest), sizeof (ip4));
14416 vat_json_object_add_ip4 (node, "dest", ip4);
14417 vat_json_object_add_uint (node, "s_bit", ntohl (mp->s_bit));
14418 vat_json_object_add_uint (node, "label_count", len);
14419 for (i = 0; i < len; i++)
14421 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14426 api_mpls_fib_encap_dump (vat_main_t * vam)
14428 vl_api_mpls_fib_encap_dump_t *mp;
14431 M (MPLS_FIB_ENCAP_DUMP, mpls_fib_encap_dump);
14434 /* Use a control ping for synchronization */
14436 vl_api_control_ping_t *mp;
14437 M (CONTROL_PING, control_ping);
14443 static void vl_api_mpls_fib_decap_details_t_handler
14444 (vl_api_mpls_fib_decap_details_t * mp)
14446 vat_main_t *vam = &vat_main;
14449 "RX table %d, TX table/intfc %u, swif_tag '%s', label %u, s_bit %u\n",
14450 ntohl (mp->rx_table_id), ntohl (mp->tx_table_id), mp->swif_tag,
14451 ntohl (mp->label), ntohl (mp->s_bit));
14454 static void vl_api_mpls_fib_decap_details_t_handler_json
14455 (vl_api_mpls_fib_decap_details_t * mp)
14457 vat_main_t *vam = &vat_main;
14458 vat_json_node_t *node = NULL;
14459 struct in_addr ip4;
14461 if (VAT_JSON_ARRAY != vam->json_tree.type)
14463 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14464 vat_json_init_array (&vam->json_tree);
14466 node = vat_json_array_add (&vam->json_tree);
14468 vat_json_init_object (node);
14469 vat_json_object_add_uint (node, "table", ntohl (mp->fib_index));
14470 vat_json_object_add_uint (node, "entry_index", ntohl (mp->entry_index));
14471 clib_memcpy (&ip4, &(mp->dest), sizeof (ip4));
14472 vat_json_object_add_ip4 (node, "dest", ip4);
14473 vat_json_object_add_uint (node, "s_bit", ntohl (mp->s_bit));
14474 vat_json_object_add_uint (node, "label", ntohl (mp->label));
14475 vat_json_object_add_uint (node, "rx_table_id", ntohl (mp->rx_table_id));
14476 vat_json_object_add_uint (node, "tx_table_id", ntohl (mp->tx_table_id));
14477 vat_json_object_add_string_copy (node, "swif_tag", mp->swif_tag);
14481 api_mpls_fib_decap_dump (vat_main_t * vam)
14483 vl_api_mpls_fib_decap_dump_t *mp;
14486 M (MPLS_FIB_DECAP_DUMP, mpls_fib_decap_dump);
14489 /* Use a control ping for synchronization */
14491 vl_api_control_ping_t *mp;
14492 M (CONTROL_PING, control_ping);
14499 api_classify_table_ids (vat_main_t * vam)
14501 vl_api_classify_table_ids_t *mp;
14504 /* Construct the API message */
14505 M (CLASSIFY_TABLE_IDS, classify_table_ids);
14515 api_classify_table_by_interface (vat_main_t * vam)
14517 unformat_input_t *input = vam->input;
14518 vl_api_classify_table_by_interface_t *mp;
14521 u32 sw_if_index = ~0;
14522 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14524 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
14526 else if (unformat (input, "sw_if_index %d", &sw_if_index))
14531 if (sw_if_index == ~0)
14533 errmsg ("missing interface name or sw_if_index\n");
14537 /* Construct the API message */
14538 M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
14540 mp->sw_if_index = ntohl (sw_if_index);
14549 api_classify_table_info (vat_main_t * vam)
14551 unformat_input_t *input = vam->input;
14552 vl_api_classify_table_info_t *mp;
14556 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14558 if (unformat (input, "table_id %d", &table_id))
14563 if (table_id == ~0)
14565 errmsg ("missing table id\n");
14569 /* Construct the API message */
14570 M (CLASSIFY_TABLE_INFO, classify_table_info);
14572 mp->table_id = ntohl (table_id);
14581 api_classify_session_dump (vat_main_t * vam)
14583 unformat_input_t *input = vam->input;
14584 vl_api_classify_session_dump_t *mp;
14588 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14590 if (unformat (input, "table_id %d", &table_id))
14595 if (table_id == ~0)
14597 errmsg ("missing table id\n");
14601 /* Construct the API message */
14602 M (CLASSIFY_SESSION_DUMP, classify_session_dump);
14604 mp->table_id = ntohl (table_id);
14607 /* Use a control ping for synchronization */
14609 vl_api_control_ping_t *mp;
14610 M (CONTROL_PING, control_ping);
14619 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
14621 vat_main_t *vam = &vat_main;
14623 fformat (vam->ofp, "collector_address %U, collector_port %d, "
14624 "src_address %U, vrf_id %d, path_mtu %u, "
14625 "template_interval %u, udp_checksum %d\n",
14626 format_ip4_address, mp->collector_address,
14627 ntohs (mp->collector_port),
14628 format_ip4_address, mp->src_address,
14629 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
14630 ntohl (mp->template_interval), mp->udp_checksum);
14633 vam->result_ready = 1;
14637 vl_api_ipfix_exporter_details_t_handler_json
14638 (vl_api_ipfix_exporter_details_t * mp)
14640 vat_main_t *vam = &vat_main;
14641 vat_json_node_t node;
14642 struct in_addr collector_address;
14643 struct in_addr src_address;
14645 vat_json_init_object (&node);
14646 clib_memcpy (&collector_address, &mp->collector_address,
14647 sizeof (collector_address));
14648 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
14649 vat_json_object_add_uint (&node, "collector_port",
14650 ntohs (mp->collector_port));
14651 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
14652 vat_json_object_add_ip4 (&node, "src_address", src_address);
14653 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
14654 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
14655 vat_json_object_add_uint (&node, "template_interval",
14656 ntohl (mp->template_interval));
14657 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
14659 vat_json_print (vam->ofp, &node);
14660 vat_json_free (&node);
14662 vam->result_ready = 1;
14666 api_ipfix_exporter_dump (vat_main_t * vam)
14668 vl_api_ipfix_exporter_dump_t *mp;
14671 /* Construct the API message */
14672 M (IPFIX_EXPORTER_DUMP, ipfix_exporter_dump);
14682 api_ipfix_classify_stream_dump (vat_main_t * vam)
14684 vl_api_ipfix_classify_stream_dump_t *mp;
14687 /* Construct the API message */
14688 M (IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump);
14698 vl_api_ipfix_classify_stream_details_t_handler
14699 (vl_api_ipfix_classify_stream_details_t * mp)
14701 vat_main_t *vam = &vat_main;
14702 fformat (vam->ofp, "domain_id %d, src_port %d\n",
14703 ntohl (mp->domain_id), ntohs (mp->src_port));
14705 vam->result_ready = 1;
14709 vl_api_ipfix_classify_stream_details_t_handler_json
14710 (vl_api_ipfix_classify_stream_details_t * mp)
14712 vat_main_t *vam = &vat_main;
14713 vat_json_node_t node;
14715 vat_json_init_object (&node);
14716 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
14717 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
14719 vat_json_print (vam->ofp, &node);
14720 vat_json_free (&node);
14722 vam->result_ready = 1;
14726 api_ipfix_classify_table_dump (vat_main_t * vam)
14728 vl_api_ipfix_classify_table_dump_t *mp;
14731 if (!vam->json_output)
14733 fformat (vam->ofp, "%15s%15s%20s\n", "table_id", "ip_version",
14734 "transport_protocol");
14737 /* Construct the API message */
14738 M (IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump);
14743 /* Use a control ping for synchronization */
14745 vl_api_control_ping_t *mp;
14746 M (CONTROL_PING, control_ping);
14753 vl_api_ipfix_classify_table_details_t_handler
14754 (vl_api_ipfix_classify_table_details_t * mp)
14756 vat_main_t *vam = &vat_main;
14757 fformat (vam->ofp, "%15d%15d%20d\n", ntohl (mp->table_id), mp->ip_version,
14758 mp->transport_protocol);
14762 vl_api_ipfix_classify_table_details_t_handler_json
14763 (vl_api_ipfix_classify_table_details_t * mp)
14765 vat_json_node_t *node = NULL;
14766 vat_main_t *vam = &vat_main;
14768 if (VAT_JSON_ARRAY != vam->json_tree.type)
14770 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14771 vat_json_init_array (&vam->json_tree);
14774 node = vat_json_array_add (&vam->json_tree);
14775 vat_json_init_object (node);
14777 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
14778 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
14779 vat_json_object_add_uint (node, "transport_protocol",
14780 mp->transport_protocol);
14784 api_pg_create_interface (vat_main_t * vam)
14786 unformat_input_t *input = vam->input;
14787 vl_api_pg_create_interface_t *mp;
14791 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14793 if (unformat (input, "if_id %d", &if_id))
14800 errmsg ("missing pg interface index\n");
14804 /* Construct the API message */
14805 M (PG_CREATE_INTERFACE, pg_create_interface);
14807 mp->interface_id = ntohl (if_id);
14816 api_pg_capture (vat_main_t * vam)
14818 unformat_input_t *input = vam->input;
14819 vl_api_pg_capture_t *mp;
14825 u8 pcap_file_set = 0;
14827 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14829 if (unformat (input, "if_id %d", &if_id))
14831 else if (unformat (input, "pcap %s", &pcap_file))
14833 else if (unformat (input, "count %d", &count))
14835 else if (unformat (input, "disable"))
14842 errmsg ("missing pg interface index\n");
14845 if (pcap_file_set > 0)
14847 if (vec_len (pcap_file) > 255)
14849 errmsg ("pcap file name is too long\n");
14854 u32 name_len = vec_len (pcap_file);
14855 /* Construct the API message */
14856 M (PG_CAPTURE, pg_capture);
14858 mp->interface_id = ntohl (if_id);
14859 mp->is_enabled = enable;
14860 mp->count = ntohl (count);
14861 mp->pcap_name_length = ntohl (name_len);
14862 if (pcap_file_set != 0)
14864 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
14866 vec_free (pcap_file);
14875 api_pg_enable_disable (vat_main_t * vam)
14877 unformat_input_t *input = vam->input;
14878 vl_api_pg_enable_disable_t *mp;
14882 u8 stream_name_set = 0;
14883 u8 *stream_name = 0;
14884 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14886 if (unformat (input, "stream %s", &stream_name))
14887 stream_name_set = 1;
14888 else if (unformat (input, "disable"))
14894 if (stream_name_set > 0)
14896 if (vec_len (stream_name) > 255)
14898 errmsg ("stream name too long\n");
14903 u32 name_len = vec_len (stream_name);
14904 /* Construct the API message */
14905 M (PG_ENABLE_DISABLE, pg_enable_disable);
14907 mp->is_enabled = enable;
14908 if (stream_name_set != 0)
14910 mp->stream_name_length = ntohl (name_len);
14911 clib_memcpy (mp->stream_name, stream_name, name_len);
14913 vec_free (stream_name);
14922 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
14924 unformat_input_t *input = vam->input;
14925 vl_api_ip_source_and_port_range_check_add_del_t *mp;
14928 u16 *low_ports = 0;
14929 u16 *high_ports = 0;
14932 ip4_address_t ip4_addr;
14933 ip6_address_t ip6_addr;
14941 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14943 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
14949 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
14954 else if (unformat (input, "vrf %d", &vrf_id))
14956 else if (unformat (input, "del"))
14958 else if (unformat (input, "port %d", &tmp))
14960 if (tmp == 0 || tmp > 65535)
14962 errmsg ("port %d out of range", tmp);
14966 this_hi = this_low + 1;
14967 vec_add1 (low_ports, this_low);
14968 vec_add1 (high_ports, this_hi);
14970 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
14972 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
14974 errmsg ("incorrect range parameters\n");
14978 /* Note: in debug CLI +1 is added to high before
14979 passing to real fn that does "the work"
14980 (ip_source_and_port_range_check_add_del).
14981 This fn is a wrapper around the binary API fn a
14982 control plane will call, which expects this increment
14983 to have occurred. Hence letting the binary API control
14984 plane fn do the increment for consistency between VAT
14985 and other control planes.
14988 vec_add1 (low_ports, this_low);
14989 vec_add1 (high_ports, this_hi);
14995 if (prefix_set == 0)
14997 errmsg ("<address>/<mask> not specified\n");
15003 errmsg ("VRF ID required, not specified\n");
15010 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
15014 if (vec_len (low_ports) == 0)
15016 errmsg ("At least one port or port range required\n");
15020 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,
15021 ip_source_and_port_range_check_add_del);
15023 mp->is_add = is_add;
15028 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
15033 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
15036 mp->mask_length = length;
15037 mp->number_of_ranges = vec_len (low_ports);
15039 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
15040 vec_free (low_ports);
15042 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
15043 vec_free (high_ports);
15045 mp->vrf_id = ntohl (vrf_id);
15054 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
15056 unformat_input_t *input = vam->input;
15057 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
15059 u32 sw_if_index = ~0;
15061 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
15062 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
15065 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15067 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
15069 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15071 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
15073 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
15075 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
15077 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
15079 else if (unformat (input, "del"))
15085 if (sw_if_index == ~0)
15087 errmsg ("Interface required but not specified\n");
15093 errmsg ("VRF ID required but not specified\n");
15097 if (tcp_out_vrf_id == 0
15098 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
15101 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
15105 /* Construct the API message */
15106 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,
15107 ip_source_and_port_range_check_interface_add_del);
15109 mp->sw_if_index = ntohl (sw_if_index);
15110 mp->is_add = is_add;
15111 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
15112 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
15113 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
15114 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
15119 /* Wait for a reply... */
15124 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
15126 unformat_input_t *i = vam->input;
15127 vl_api_ipsec_gre_add_del_tunnel_t *mp;
15129 u32 local_sa_id = 0;
15130 u32 remote_sa_id = 0;
15131 ip4_address_t src_address;
15132 ip4_address_t dst_address;
15135 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15137 if (unformat (i, "local_sa %d", &local_sa_id))
15139 else if (unformat (i, "remote_sa %d", &remote_sa_id))
15141 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
15143 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
15145 else if (unformat (i, "del"))
15149 clib_warning ("parse error '%U'", format_unformat_error, i);
15154 M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel);
15156 mp->local_sa_id = ntohl (local_sa_id);
15157 mp->remote_sa_id = ntohl (remote_sa_id);
15158 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
15159 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
15160 mp->is_add = is_add;
15169 api_punt (vat_main_t * vam)
15171 unformat_input_t *i = vam->input;
15179 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15181 if (unformat (i, "ip %d", &ipv))
15183 else if (unformat (i, "protocol %d", &protocol))
15185 else if (unformat (i, "port %d", &port))
15187 else if (unformat (i, "del"))
15191 clib_warning ("parse error '%U'", format_unformat_error, i);
15198 mp->is_add = (u8) is_add;
15199 mp->ipv = (u8) ipv;
15200 mp->l4_protocol = (u8) protocol;
15201 mp->l4_port = htons ((u16) port);
15209 static void vl_api_ipsec_gre_tunnel_details_t_handler
15210 (vl_api_ipsec_gre_tunnel_details_t * mp)
15212 vat_main_t *vam = &vat_main;
15214 fformat (vam->ofp, "%11d%15U%15U%14d%14d\n",
15215 ntohl (mp->sw_if_index),
15216 format_ip4_address, &mp->src_address,
15217 format_ip4_address, &mp->dst_address,
15218 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
15221 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
15222 (vl_api_ipsec_gre_tunnel_details_t * mp)
15224 vat_main_t *vam = &vat_main;
15225 vat_json_node_t *node = NULL;
15226 struct in_addr ip4;
15228 if (VAT_JSON_ARRAY != vam->json_tree.type)
15230 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15231 vat_json_init_array (&vam->json_tree);
15233 node = vat_json_array_add (&vam->json_tree);
15235 vat_json_init_object (node);
15236 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15237 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
15238 vat_json_object_add_ip4 (node, "src_address", ip4);
15239 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
15240 vat_json_object_add_ip4 (node, "dst_address", ip4);
15241 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
15242 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
15246 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
15248 unformat_input_t *i = vam->input;
15249 vl_api_ipsec_gre_tunnel_dump_t *mp;
15252 u8 sw_if_index_set = 0;
15254 /* Parse args required to build the message */
15255 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15257 if (unformat (i, "sw_if_index %d", &sw_if_index))
15258 sw_if_index_set = 1;
15263 if (sw_if_index_set == 0)
15268 if (!vam->json_output)
15270 fformat (vam->ofp, "%11s%15s%15s%14s%14s\n",
15271 "sw_if_index", "src_address", "dst_address",
15272 "local_sa_id", "remote_sa_id");
15275 /* Get list of gre-tunnel interfaces */
15276 M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump);
15278 mp->sw_if_index = htonl (sw_if_index);
15282 /* Use a control ping for synchronization */
15284 vl_api_control_ping_t *mp;
15285 M (CONTROL_PING, control_ping);
15292 api_delete_subif (vat_main_t * vam)
15294 unformat_input_t *i = vam->input;
15295 vl_api_delete_subif_t *mp;
15297 u32 sw_if_index = ~0;
15299 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15301 if (unformat (i, "sw_if_index %d", &sw_if_index))
15307 if (sw_if_index == ~0)
15309 errmsg ("missing sw_if_index\n");
15313 /* Construct the API message */
15314 M (DELETE_SUBIF, delete_subif);
15315 mp->sw_if_index = ntohl (sw_if_index);
15321 #define foreach_pbb_vtr_op \
15322 _("disable", L2_VTR_DISABLED) \
15323 _("pop", L2_VTR_POP_2) \
15324 _("push", L2_VTR_PUSH_2)
15327 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
15329 unformat_input_t *i = vam->input;
15330 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
15332 u32 sw_if_index = ~0, vtr_op = ~0;
15333 u16 outer_tag = ~0;
15334 u8 dmac[6], smac[6];
15335 u8 dmac_set = 0, smac_set = 0;
15340 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15342 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
15344 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15346 else if (unformat (i, "vtr_op %d", &vtr_op))
15348 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
15351 else if (unformat (i, "translate_pbb_stag"))
15353 if (unformat (i, "%d", &tmp))
15355 vtr_op = L2_VTR_TRANSLATE_2_1;
15361 ("translate_pbb_stag operation requires outer tag definition\n");
15365 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
15367 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
15369 else if (unformat (i, "sid %d", &sid))
15371 else if (unformat (i, "vlanid %d", &tmp))
15375 clib_warning ("parse error '%U'", format_unformat_error, i);
15380 if ((sw_if_index == ~0) || (vtr_op == ~0))
15382 errmsg ("missing sw_if_index or vtr operation\n");
15385 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
15386 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
15389 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid\n");
15393 M (L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite);
15394 mp->sw_if_index = ntohl (sw_if_index);
15395 mp->vtr_op = ntohl (vtr_op);
15396 mp->outer_tag = ntohs (outer_tag);
15397 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
15398 clib_memcpy (mp->b_smac, smac, sizeof (smac));
15399 mp->b_vlanid = ntohs (vlanid);
15400 mp->i_sid = ntohl (sid);
15409 api_flow_classify_set_interface (vat_main_t * vam)
15411 unformat_input_t *i = vam->input;
15412 vl_api_flow_classify_set_interface_t *mp;
15415 int sw_if_index_set;
15416 u32 ip4_table_index = ~0;
15417 u32 ip6_table_index = ~0;
15420 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15422 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
15423 sw_if_index_set = 1;
15424 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15425 sw_if_index_set = 1;
15426 else if (unformat (i, "del"))
15428 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15430 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15434 clib_warning ("parse error '%U'", format_unformat_error, i);
15439 if (sw_if_index_set == 0)
15441 errmsg ("missing interface name or sw_if_index\n");
15445 M (FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface);
15447 mp->sw_if_index = ntohl (sw_if_index);
15448 mp->ip4_table_index = ntohl (ip4_table_index);
15449 mp->ip6_table_index = ntohl (ip6_table_index);
15450 mp->is_add = is_add;
15459 api_flow_classify_dump (vat_main_t * vam)
15461 unformat_input_t *i = vam->input;
15462 vl_api_flow_classify_dump_t *mp;
15464 u8 type = FLOW_CLASSIFY_N_TABLES;
15466 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
15470 errmsg ("classify table type must be specified\n");
15474 if (!vam->json_output)
15476 fformat (vam->ofp, "%10s%20s\n", "Intfc idx", "Classify table");
15479 M (FLOW_CLASSIFY_DUMP, flow_classify_dump);
15484 /* Use a control ping for synchronization */
15486 vl_api_control_ping_t *mp;
15487 M (CONTROL_PING, control_ping);
15490 /* Wait for a reply... */
15498 q_or_quit (vat_main_t * vam)
15500 longjmp (vam->jump_buf, 1);
15501 return 0; /* not so much */
15505 q (vat_main_t * vam)
15507 return q_or_quit (vam);
15511 quit (vat_main_t * vam)
15513 return q_or_quit (vam);
15517 comment (vat_main_t * vam)
15523 cmd_cmp (void *a1, void *a2)
15528 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
15532 help (vat_main_t * vam)
15537 unformat_input_t *i = vam->input;
15540 if (unformat (i, "%s", &name))
15544 vec_add1 (name, 0);
15546 hs = hash_get_mem (vam->help_by_name, name);
15548 fformat (vam->ofp, "usage: %s %s\n", name, hs[0]);
15550 fformat (vam->ofp, "No such msg / command '%s'\n", name);
15555 fformat (vam->ofp, "Help is available for the following:\n");
15558 hash_foreach_pair (p, vam->function_by_name,
15560 vec_add1 (cmds, (u8 *)(p->key));
15564 vec_sort_with_function (cmds, cmd_cmp);
15566 for (j = 0; j < vec_len (cmds); j++)
15567 fformat (vam->ofp, "%s\n", cmds[j]);
15574 set (vat_main_t * vam)
15576 u8 *name = 0, *value = 0;
15577 unformat_input_t *i = vam->input;
15579 if (unformat (i, "%s", &name))
15581 /* The input buffer is a vector, not a string. */
15582 value = vec_dup (i->buffer);
15583 vec_delete (value, i->index, 0);
15584 /* Almost certainly has a trailing newline */
15585 if (value[vec_len (value) - 1] == '\n')
15586 value[vec_len (value) - 1] = 0;
15587 /* Make sure it's a proper string, one way or the other */
15588 vec_add1 (value, 0);
15589 (void) clib_macro_set_value (&vam->macro_main,
15590 (char *) name, (char *) value);
15593 errmsg ("usage: set <name> <value>\n");
15601 unset (vat_main_t * vam)
15605 if (unformat (vam->input, "%s", &name))
15606 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
15607 errmsg ("unset: %s wasn't set\n", name);
15620 macro_sort_cmp (void *a1, void *a2)
15622 macro_sort_t *s1 = a1;
15623 macro_sort_t *s2 = a2;
15625 return strcmp ((char *) (s1->name), (char *) (s2->name));
15629 dump_macro_table (vat_main_t * vam)
15631 macro_sort_t *sort_me = 0, *sm;
15636 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
15638 vec_add2 (sort_me, sm, 1);
15639 sm->name = (u8 *)(p->key);
15640 sm->value = (u8 *) (p->value[0]);
15644 vec_sort_with_function (sort_me, macro_sort_cmp);
15646 if (vec_len (sort_me))
15647 fformat (vam->ofp, "%-15s%s\n", "Name", "Value");
15649 fformat (vam->ofp, "The macro table is empty...\n");
15651 for (i = 0; i < vec_len (sort_me); i++)
15652 fformat (vam->ofp, "%-15s%s\n", sort_me[i].name, sort_me[i].value);
15657 dump_node_table (vat_main_t * vam)
15660 vlib_node_t *node, *next_node;
15662 if (vec_len (vam->graph_nodes) == 0)
15664 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
15668 for (i = 0; i < vec_len (vam->graph_nodes); i++)
15670 node = vam->graph_nodes[i];
15671 fformat (vam->ofp, "[%d] %s\n", i, node->name);
15672 for (j = 0; j < vec_len (node->next_nodes); j++)
15674 if (node->next_nodes[j] != ~0)
15676 next_node = vam->graph_nodes[node->next_nodes[j]];
15677 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
15685 search_node_table (vat_main_t * vam)
15687 unformat_input_t *line_input = vam->input;
15690 vlib_node_t *node, *next_node;
15693 if (vam->graph_node_index_by_name == 0)
15695 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
15699 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15701 if (unformat (line_input, "%s", &node_to_find))
15703 vec_add1 (node_to_find, 0);
15704 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
15707 fformat (vam->ofp, "%s not found...\n", node_to_find);
15710 node = vam->graph_nodes[p[0]];
15711 fformat (vam->ofp, "[%d] %s\n", p[0], node->name);
15712 for (j = 0; j < vec_len (node->next_nodes); j++)
15714 if (node->next_nodes[j] != ~0)
15716 next_node = vam->graph_nodes[node->next_nodes[j]];
15717 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
15724 clib_warning ("parse error '%U'", format_unformat_error,
15730 vec_free (node_to_find);
15739 script (vat_main_t * vam)
15742 char *save_current_file;
15743 unformat_input_t save_input;
15744 jmp_buf save_jump_buf;
15745 u32 save_line_number;
15747 FILE *new_fp, *save_ifp;
15749 if (unformat (vam->input, "%s", &s))
15751 new_fp = fopen ((char *) s, "r");
15754 errmsg ("Couldn't open script file %s\n", s);
15761 errmsg ("Missing script name\n");
15765 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
15766 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
15767 save_ifp = vam->ifp;
15768 save_line_number = vam->input_line_number;
15769 save_current_file = (char *) vam->current_file;
15771 vam->input_line_number = 0;
15773 vam->current_file = s;
15776 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
15777 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
15778 vam->ifp = save_ifp;
15779 vam->input_line_number = save_line_number;
15780 vam->current_file = (u8 *) save_current_file;
15787 echo (vat_main_t * vam)
15789 fformat (vam->ofp, "%v", vam->input->buffer);
15793 /* List of API message constructors, CLI names map to api_xxx */
15794 #define foreach_vpe_api_msg \
15795 _(create_loopback,"[mac <mac-addr>]") \
15796 _(sw_interface_dump,"") \
15797 _(sw_interface_set_flags, \
15798 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
15799 _(sw_interface_add_del_address, \
15800 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
15801 _(sw_interface_set_table, \
15802 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
15803 _(sw_interface_set_vpath, \
15804 "<intfc> | sw_if_index <id> enable | disable") \
15805 _(sw_interface_set_l2_xconnect, \
15806 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
15807 "enable | disable") \
15808 _(sw_interface_set_l2_bridge, \
15809 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
15810 "[shg <split-horizon-group>] [bvi]\n" \
15811 "enable | disable") \
15812 _(sw_interface_set_dpdk_hqos_pipe, \
15813 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
15814 "profile <profile-id>\n") \
15815 _(sw_interface_set_dpdk_hqos_subport, \
15816 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
15817 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
15818 _(sw_interface_set_dpdk_hqos_tctbl, \
15819 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n") \
15820 _(bridge_domain_add_del, \
15821 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n")\
15822 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
15824 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
15826 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
15828 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
15830 "tapname <name> mac <mac-addr> | random-mac") \
15832 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
15834 "<vpp-if-name> | sw_if_index <id>") \
15835 _(sw_interface_tap_dump, "") \
15836 _(ip_add_del_route, \
15837 "<addr>/<mask> via <addr> [vrf <n>]\n" \
15838 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
15839 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
15840 "[multipath] [count <n>]") \
15841 _(proxy_arp_add_del, \
15842 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
15843 _(proxy_arp_intfc_enable_disable, \
15844 "<intfc> | sw_if_index <id> enable | disable") \
15845 _(mpls_add_del_encap, \
15846 "label <n> dst <ip4-addr> [vrf <n>] [del]") \
15847 _(mpls_add_del_decap, \
15848 "label <n> [rx_vrf_id <n>] [tx_vrf_id] [s-bit-clear][del]") \
15849 _(mpls_gre_add_del_tunnel, \
15850 "inner_vrf_id <n> outer_vrf_id <n> src <ip4-address> dst <ip4-address>\n" \
15851 "adj <ip4-address>/<mask-width> [del]") \
15852 _(sw_interface_set_unnumbered, \
15853 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
15854 _(ip_neighbor_add_del, \
15855 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
15856 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
15857 _(reset_vrf, "vrf <id> [ipv6]") \
15858 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
15859 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
15860 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
15861 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
15862 "[outer_vlan_id_any][inner_vlan_id_any]") \
15863 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
15864 _(reset_fib, "vrf <n> [ipv6]") \
15865 _(dhcp_proxy_config, \
15866 "svr <v46-address> src <v46-address>\n" \
15867 "insert-cid <n> [del]") \
15868 _(dhcp_proxy_config_2, \
15869 "svr <v46-address> src <v46-address>\n" \
15870 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
15871 _(dhcp_proxy_set_vss, \
15872 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
15873 _(dhcp_client_config, \
15874 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
15875 _(set_ip_flow_hash, \
15876 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
15877 _(sw_interface_ip6_enable_disable, \
15878 "<intfc> | sw_if_index <id> enable | disable") \
15879 _(sw_interface_ip6_set_link_local_address, \
15880 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
15881 _(sw_interface_ip6nd_ra_prefix, \
15882 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
15883 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
15884 "[nolink] [isno]") \
15885 _(sw_interface_ip6nd_ra_config, \
15886 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
15887 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
15888 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
15889 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
15890 _(l2_patch_add_del, \
15891 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
15892 "enable | disable") \
15893 _(mpls_ethernet_add_del_tunnel, \
15894 "tx <intfc> | tx_sw_if_index <n> dst <mac-addr>\n" \
15895 "adj <ip4-addr>/<mw> dst <mac-addr> [del]") \
15896 _(mpls_ethernet_add_del_tunnel_2, \
15897 "inner_vrf_id <n> outer_vrf_id <n> next-hop <ip4-addr>\n" \
15898 "resolve-attempts <n> resolve-if-needed 0 | 1 [del]") \
15899 _(sr_tunnel_add_del, \
15900 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
15901 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
15902 "[policy <policy_name>]") \
15903 _(sr_policy_add_del, \
15904 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
15905 _(sr_multicast_map_add_del, \
15906 "address [ip6 multicast address] sr-policy [policy name] [del]") \
15907 _(classify_add_del_table, \
15908 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
15909 "[del] mask <mask-value>\n" \
15910 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>") \
15911 _(classify_add_del_session, \
15912 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
15913 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
15914 " [l3 [ip4|ip6]]") \
15915 _(classify_set_interface_ip_table, \
15916 "<intfc> | sw_if_index <nn> table <nn>") \
15917 _(classify_set_interface_l2_tables, \
15918 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
15919 " [other-table <nn>]") \
15920 _(get_node_index, "node <node-name") \
15921 _(add_node_next, "node <node-name> next <next-node-name>") \
15922 _(l2tpv3_create_tunnel, \
15923 "client_address <ip6-addr> our_address <ip6-addr>\n" \
15924 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n"\
15925 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
15926 _(l2tpv3_set_tunnel_cookies, \
15927 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
15928 "[new_remote_cookie <nn>]\n") \
15929 _(l2tpv3_interface_enable_disable, \
15930 "<intfc> | sw_if_index <nn> enable | disable") \
15931 _(l2tpv3_set_lookup_key, \
15932 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
15933 _(sw_if_l2tpv3_tunnel_dump, "") \
15934 _(vxlan_add_del_tunnel, \
15935 "src <ip-addr> dst <ip-addr> vni <vni> [encap-vrf-id <nn>]\n" \
15936 " [decap-next l2|ip4|ip6] [del]") \
15937 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
15938 _(gre_add_del_tunnel, \
15939 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
15940 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
15941 _(l2_fib_clear_table, "") \
15942 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
15943 _(l2_interface_vlan_tag_rewrite, \
15944 "<intfc> | sw_if_index <nn> \n" \
15945 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
15946 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
15947 _(create_vhost_user_if, \
15948 "socket <filename> [server] [renumber <dev_instance>] " \
15949 "[mac <mac_address>]") \
15950 _(modify_vhost_user_if, \
15951 "<intfc> | sw_if_index <nn> socket <filename>\n" \
15952 "[server] [renumber <dev_instance>]") \
15953 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
15954 _(sw_interface_vhost_user_dump, "") \
15955 _(show_version, "") \
15956 _(vxlan_gpe_add_del_tunnel, \
15957 "local <addr> remote <addr> vni <nn>\n" \
15958 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
15959 "[next-ethernet] [next-nsh]\n") \
15960 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
15961 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
15962 _(interface_name_renumber, \
15963 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
15964 _(input_acl_set_interface, \
15965 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
15966 " [l2-table <nn>] [del]") \
15967 _(want_ip4_arp_events, "address <ip4-address> [del]") \
15968 _(want_ip6_nd_events, "address <ip6-address> [del]") \
15969 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
15970 _(ip_dump, "ipv4 | ipv6") \
15971 _(ipsec_spd_add_del, "spd_id <n> [del]") \
15972 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
15974 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
15975 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
15976 " integ_alg <alg> integ_key <hex>") \
15977 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
15978 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
15979 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
15980 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" )\
15981 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
15982 _(ikev2_profile_add_del, "name <profile_name> [del]") \
15983 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
15984 "(auth_data 0x<data> | auth_data <data>)") \
15985 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
15986 "(id_data 0x<data> | id_data <data>) (local|remote)") \
15987 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
15988 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
15989 "(local|remote)") \
15990 _(ikev2_set_local_key, "file <absolute_file_path>") \
15991 _(delete_loopback,"sw_if_index <nn>") \
15992 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
15993 _(map_add_domain, \
15994 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
15995 "ip6-src <ip6addr> " \
15996 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
15997 _(map_del_domain, "index <n>") \
15998 _(map_add_del_rule, \
15999 "index <n> psid <n> dst <ip6addr> [del]") \
16000 _(map_domain_dump, "") \
16001 _(map_rule_dump, "index <map-domain>") \
16002 _(want_interface_events, "enable|disable") \
16003 _(want_stats,"enable|disable") \
16004 _(get_first_msg_id, "client <name>") \
16005 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
16006 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
16007 "fib-id <nn> [ip4][ip6][default]") \
16008 _(get_node_graph, " ") \
16009 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
16010 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
16011 _(ioam_disable, "") \
16012 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
16013 " sw_if_index <sw_if_index> p <priority> " \
16014 "w <weight>] [del]") \
16015 _(lisp_add_del_locator, "locator-set <locator_name> " \
16016 "iface <intf> | sw_if_index <sw_if_index> " \
16017 "p <priority> w <weight> [del]") \
16018 _(lisp_add_del_local_eid,"vni <vni> eid " \
16019 "<ipv4|ipv6>/<prefix> | <L2 address> " \
16020 "locator-set <locator_name> [del]") \
16021 _(lisp_gpe_add_del_fwd_entry, "rmt_eid <eid> [lcl_eid <eid>] vni <vni>" \
16022 "dp_table <table> loc-pair <lcl_loc> <rmt_loc> ... [del]") \
16023 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
16024 _(lisp_gpe_enable_disable, "enable|disable") \
16025 _(lisp_enable_disable, "enable|disable") \
16026 _(lisp_gpe_add_del_iface, "up|down") \
16027 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
16029 "rloc <locator> p <prio> " \
16030 "w <weight> [rloc <loc> ... ] " \
16031 "action <action> [del-all]") \
16032 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
16034 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
16035 _(lisp_map_request_mode, "src-dst|dst-only") \
16036 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
16037 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
16038 _(lisp_locator_set_dump, "[local | remote]") \
16039 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
16040 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
16041 "[local] | [remote]") \
16042 _(lisp_eid_table_vni_dump, "") \
16043 _(lisp_eid_table_map_dump, "l2|l3") \
16044 _(lisp_gpe_tunnel_dump, "") \
16045 _(lisp_map_resolver_dump, "") \
16046 _(show_lisp_status, "") \
16047 _(lisp_get_map_request_itr_rlocs, "") \
16048 _(show_lisp_pitr, "") \
16049 _(show_lisp_map_request_mode, "") \
16050 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
16051 _(af_packet_delete, "name <host interface name>") \
16052 _(policer_add_del, "name <policer name> <params> [del]") \
16053 _(policer_dump, "[name <policer name>]") \
16054 _(policer_classify_set_interface, \
16055 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
16056 " [l2-table <nn>] [del]") \
16057 _(policer_classify_dump, "type [ip4|ip6|l2]") \
16058 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
16059 "[master|slave]") \
16060 _(netmap_delete, "name <interface name>") \
16061 _(mpls_gre_tunnel_dump, "tunnel_index <tunnel-id>") \
16062 _(mpls_eth_tunnel_dump, "tunnel_index <tunnel-id>") \
16063 _(mpls_fib_encap_dump, "") \
16064 _(mpls_fib_decap_dump, "") \
16065 _(classify_table_ids, "") \
16066 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
16067 _(classify_table_info, "table_id <nn>") \
16068 _(classify_session_dump, "table_id <nn>") \
16069 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
16070 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
16071 "[template_interval <nn>] [udp_checksum]") \
16072 _(ipfix_exporter_dump, "") \
16073 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
16074 _(ipfix_classify_stream_dump, "") \
16075 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]")\
16076 _(ipfix_classify_table_dump, "") \
16077 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
16078 _(pg_create_interface, "if_id <nn>") \
16079 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
16080 _(pg_enable_disable, "[stream <id>] disable") \
16081 _(ip_source_and_port_range_check_add_del, \
16082 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
16083 _(ip_source_and_port_range_check_interface_add_del, \
16084 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
16085 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
16086 _(ipsec_gre_add_del_tunnel, \
16087 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
16088 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
16089 _(delete_subif,"sub_sw_if_index <nn> sub_if_id <nn>") \
16090 _(l2_interface_pbb_tag_rewrite, \
16091 "<intfc> | sw_if_index <nn> \n" \
16092 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
16093 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
16094 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
16095 _(flow_classify_set_interface, \
16096 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
16097 _(flow_classify_dump, "type [ip4|ip6]")
16099 /* List of command functions, CLI names map directly to functions */
16100 #define foreach_cli_function \
16101 _(comment, "usage: comment <ignore-rest-of-line>") \
16102 _(dump_interface_table, "usage: dump_interface_table") \
16103 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
16104 _(dump_ipv4_table, "usage: dump_ipv4_table") \
16105 _(dump_ipv6_table, "usage: dump_ipv6_table") \
16106 _(dump_stats_table, "usage: dump_stats_table") \
16107 _(dump_macro_table, "usage: dump_macro_table ") \
16108 _(dump_node_table, "usage: dump_node_table") \
16109 _(echo, "usage: echo <message>") \
16110 _(exec, "usage: exec <vpe-debug-CLI-command>") \
16111 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
16112 _(help, "usage: help") \
16113 _(q, "usage: quit") \
16114 _(quit, "usage: quit") \
16115 _(search_node_table, "usage: search_node_table <name>...") \
16116 _(set, "usage: set <variable-name> <value>") \
16117 _(script, "usage: script <file-name>") \
16118 _(unset, "usage: unset <variable-name>")
16121 static void vl_api_##n##_t_handler_uni \
16122 (vl_api_##n##_t * mp) \
16124 vat_main_t * vam = &vat_main; \
16125 if (vam->json_output) { \
16126 vl_api_##n##_t_handler_json(mp); \
16128 vl_api_##n##_t_handler(mp); \
16131 foreach_vpe_api_reply_msg;
16135 vat_api_hookup (vat_main_t * vam)
16138 vl_msg_api_set_handlers(VL_API_##N, #n, \
16139 vl_api_##n##_t_handler_uni, \
16141 vl_api_##n##_t_endian, \
16142 vl_api_##n##_t_print, \
16143 sizeof(vl_api_##n##_t), 1);
16144 foreach_vpe_api_reply_msg;
16147 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
16149 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
16151 vam->function_by_name = hash_create_string (0, sizeof (uword));
16153 vam->help_by_name = hash_create_string (0, sizeof (uword));
16155 /* API messages we can send */
16156 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
16157 foreach_vpe_api_msg;
16161 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
16162 foreach_vpe_api_msg;
16165 /* CLI functions */
16166 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
16167 foreach_cli_function;
16171 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
16172 foreach_cli_function;
16176 #undef vl_api_version
16177 #define vl_api_version(n,v) static u32 vpe_api_version = v;
16178 #include <vpp-api/vpe.api.h>
16179 #undef vl_api_version
16182 vl_client_add_api_signatures (vl_api_memclnt_create_t * mp)
16185 * Send the main API signature in slot 0. This bit of code must
16186 * match the checks in ../vpe/api/api.c: vl_msg_api_version_check().
16188 mp->api_versions[0] = clib_host_to_net_u32 (vpe_api_version);
16192 * fd.io coding-style-patch-verification: ON
16195 * eval: (c-set-style "gnu")