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>
40 #include <vnet/ipsec/ipsec.h>
41 #include <vnet/ipsec/ikev2.h>
43 #include <vnet/map/map.h>
44 #include <vnet/cop/cop.h>
45 #include <vnet/ip/ip6_hop_by_hop.h>
46 #include <vnet/ip/ip_source_and_port_range_check.h>
47 #include <vnet/policer/xlate.h>
48 #include <vnet/span/span.h>
49 #include <vnet/policer/policer.h>
50 #include <vnet/policer/police.h>
52 #include "vat/json_format.h"
57 #define vl_typedefs /* define message structures */
58 #include <vpp-api/vpe_all_api_h.h>
61 /* declare message handlers for each api */
63 #define vl_endianfun /* define message structures */
64 #include <vpp-api/vpe_all_api_h.h>
67 /* instantiate all the print functions we know about */
68 #define vl_print(handle, ...)
70 #include <vpp-api/vpe_all_api_h.h>
74 unformat_sw_if_index (unformat_input_t * input, va_list * args)
76 vat_main_t *vam = va_arg (*args, vat_main_t *);
77 u32 *result = va_arg (*args, u32 *);
81 if (!unformat (input, "%s", &if_name))
84 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
91 /* Parse an IP4 address %d.%d.%d.%d. */
93 unformat_ip4_address (unformat_input_t * input, va_list * args)
95 u8 *result = va_arg (*args, u8 *);
98 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
101 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
114 unformat_ethernet_address (unformat_input_t * input, va_list * args)
116 u8 *result = va_arg (*args, u8 *);
119 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
120 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
124 for (i = 0; i < 6; i++)
125 if (a[i] >= (1 << 8))
128 for (i = 0; i < 6; i++)
134 /* Returns ethernet type as an int in host byte order. */
136 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
139 u16 *result = va_arg (*args, u16 *);
143 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
145 if (type >= (1 << 16))
153 /* Parse an IP6 address. */
155 unformat_ip6_address (unformat_input_t * input, va_list * args)
157 ip6_address_t *result = va_arg (*args, ip6_address_t *);
159 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
160 uword c, n_colon, double_colon_index;
162 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
163 double_colon_index = ARRAY_LEN (hex_quads);
164 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
167 if (c >= '0' && c <= '9')
169 else if (c >= 'a' && c <= 'f')
170 hex_digit = c + 10 - 'a';
171 else if (c >= 'A' && c <= 'F')
172 hex_digit = c + 10 - 'A';
173 else if (c == ':' && n_colon < 2)
177 unformat_put_input (input);
181 /* Too many hex quads. */
182 if (n_hex_quads >= ARRAY_LEN (hex_quads))
187 hex_quad = (hex_quad << 4) | hex_digit;
189 /* Hex quad must fit in 16 bits. */
190 if (n_hex_digits >= 4)
197 /* Save position of :: */
200 /* More than one :: ? */
201 if (double_colon_index < ARRAY_LEN (hex_quads))
203 double_colon_index = n_hex_quads;
206 if (n_colon > 0 && n_hex_digits > 0)
208 hex_quads[n_hex_quads++] = hex_quad;
214 if (n_hex_digits > 0)
215 hex_quads[n_hex_quads++] = hex_quad;
220 /* Expand :: to appropriate number of zero hex quads. */
221 if (double_colon_index < ARRAY_LEN (hex_quads))
223 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
225 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
226 hex_quads[n_zero + i] = hex_quads[i];
228 for (i = 0; i < n_zero; i++)
229 hex_quads[double_colon_index + i] = 0;
231 n_hex_quads = ARRAY_LEN (hex_quads);
234 /* Too few hex quads given. */
235 if (n_hex_quads < ARRAY_LEN (hex_quads))
238 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
239 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
246 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
248 u32 *r = va_arg (*args, u32 *);
251 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
252 foreach_ipsec_policy_action
260 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
262 u32 *r = va_arg (*args, u32 *);
265 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
266 foreach_ipsec_crypto_alg
274 format_ipsec_crypto_alg (u8 * s, va_list * args)
276 u32 i = va_arg (*args, u32);
281 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
282 foreach_ipsec_crypto_alg
285 return format (s, "unknown");
287 return format (s, "%s", t);
291 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
293 u32 *r = va_arg (*args, u32 *);
296 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
297 foreach_ipsec_integ_alg
305 format_ipsec_integ_alg (u8 * s, va_list * args)
307 u32 i = va_arg (*args, u32);
312 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
313 foreach_ipsec_integ_alg
316 return format (s, "unknown");
318 return format (s, "%s", t);
322 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
324 u32 *r = va_arg (*args, u32 *);
327 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
328 foreach_ikev2_auth_method
336 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
338 u32 *r = va_arg (*args, u32 *);
341 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
342 foreach_ikev2_id_type
350 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
352 u8 *r = va_arg (*args, u8 *);
354 if (unformat (input, "kbps"))
355 *r = SSE2_QOS_RATE_KBPS;
356 else if (unformat (input, "pps"))
357 *r = SSE2_QOS_RATE_PPS;
364 unformat_policer_round_type (unformat_input_t * input, va_list * args)
366 u8 *r = va_arg (*args, u8 *);
368 if (unformat (input, "closest"))
369 *r = SSE2_QOS_ROUND_TO_CLOSEST;
370 else if (unformat (input, "up"))
371 *r = SSE2_QOS_ROUND_TO_UP;
372 else if (unformat (input, "down"))
373 *r = SSE2_QOS_ROUND_TO_DOWN;
380 unformat_policer_type (unformat_input_t * input, va_list * args)
382 u8 *r = va_arg (*args, u8 *);
384 if (unformat (input, "1r2c"))
385 *r = SSE2_QOS_POLICER_TYPE_1R2C;
386 else if (unformat (input, "1r3c"))
387 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
388 else if (unformat (input, "2r3c-2698"))
389 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
390 else if (unformat (input, "2r3c-4115"))
391 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
392 else if (unformat (input, "2r3c-mef5cf1"))
393 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
400 unformat_dscp (unformat_input_t * input, va_list * va)
402 u8 *r = va_arg (*va, u8 *);
405 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
414 unformat_policer_action_type (unformat_input_t * input, va_list * va)
416 sse2_qos_pol_action_params_st *a
417 = va_arg (*va, sse2_qos_pol_action_params_st *);
419 if (unformat (input, "drop"))
420 a->action_type = SSE2_QOS_ACTION_DROP;
421 else if (unformat (input, "transmit"))
422 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
423 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
424 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
431 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
433 u32 *r = va_arg (*va, u32 *);
436 if (unformat (input, "ip4"))
437 tid = POLICER_CLASSIFY_TABLE_IP4;
438 else if (unformat (input, "ip6"))
439 tid = POLICER_CLASSIFY_TABLE_IP6;
440 else if (unformat (input, "l2"))
441 tid = POLICER_CLASSIFY_TABLE_L2;
450 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
452 u32 *r = va_arg (*va, u32 *);
455 if (unformat (input, "ip4"))
456 tid = FLOW_CLASSIFY_TABLE_IP4;
457 else if (unformat (input, "ip6"))
458 tid = FLOW_CLASSIFY_TABLE_IP6;
467 format_ip4_address (u8 * s, va_list * args)
469 u8 *a = va_arg (*args, u8 *);
470 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
474 format_ip6_address (u8 * s, va_list * args)
476 ip6_address_t *a = va_arg (*args, ip6_address_t *);
477 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
479 i_max_n_zero = ARRAY_LEN (a->as_u16);
481 i_first_zero = i_max_n_zero;
483 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
485 u32 is_zero = a->as_u16[i] == 0;
486 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
492 if ((!is_zero && n_zeros > max_n_zeros)
493 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
495 i_max_n_zero = i_first_zero;
496 max_n_zeros = n_zeros;
497 i_first_zero = ARRAY_LEN (a->as_u16);
502 last_double_colon = 0;
503 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
505 if (i == i_max_n_zero && max_n_zeros > 1)
507 s = format (s, "::");
508 i += max_n_zeros - 1;
509 last_double_colon = 1;
513 s = format (s, "%s%x",
514 (last_double_colon || i == 0) ? "" : ":",
515 clib_net_to_host_u16 (a->as_u16[i]));
516 last_double_colon = 0;
523 /* Format an IP46 address. */
525 format_ip46_address (u8 * s, va_list * args)
527 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
528 ip46_type_t type = va_arg (*args, ip46_type_t);
534 is_ip4 = ip46_address_is_ip4 (ip46);
545 format (s, "%U", format_ip4_address, &ip46->ip4) :
546 format (s, "%U", format_ip6_address, &ip46->ip6);
550 format_ethernet_address (u8 * s, va_list * args)
552 u8 *a = va_arg (*args, u8 *);
554 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
555 a[0], a[1], a[2], a[3], a[4], a[5]);
559 increment_v4_address (ip4_address_t * a)
563 v = ntohl (a->as_u32) + 1;
564 a->as_u32 = ntohl (v);
568 increment_v6_address (ip6_address_t * a)
572 v0 = clib_net_to_host_u64 (a->as_u64[0]);
573 v1 = clib_net_to_host_u64 (a->as_u64[1]);
578 a->as_u64[0] = clib_net_to_host_u64 (v0);
579 a->as_u64[1] = clib_net_to_host_u64 (v1);
583 increment_mac_address (u64 * mac)
587 tmp = clib_net_to_host_u64 (tmp);
588 tmp += 1 << 16; /* skip unused (least significant) octets */
589 tmp = clib_host_to_net_u64 (tmp);
593 static void vl_api_create_loopback_reply_t_handler
594 (vl_api_create_loopback_reply_t * mp)
596 vat_main_t *vam = &vat_main;
597 i32 retval = ntohl (mp->retval);
599 vam->retval = retval;
600 vam->regenerate_interface_table = 1;
601 vam->sw_if_index = ntohl (mp->sw_if_index);
602 vam->result_ready = 1;
605 static void vl_api_create_loopback_reply_t_handler_json
606 (vl_api_create_loopback_reply_t * mp)
608 vat_main_t *vam = &vat_main;
609 vat_json_node_t node;
611 vat_json_init_object (&node);
612 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
613 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
615 vat_json_print (vam->ofp, &node);
616 vat_json_free (&node);
617 vam->retval = ntohl (mp->retval);
618 vam->result_ready = 1;
621 static void vl_api_af_packet_create_reply_t_handler
622 (vl_api_af_packet_create_reply_t * mp)
624 vat_main_t *vam = &vat_main;
625 i32 retval = ntohl (mp->retval);
627 vam->retval = retval;
628 vam->regenerate_interface_table = 1;
629 vam->sw_if_index = ntohl (mp->sw_if_index);
630 vam->result_ready = 1;
633 static void vl_api_af_packet_create_reply_t_handler_json
634 (vl_api_af_packet_create_reply_t * mp)
636 vat_main_t *vam = &vat_main;
637 vat_json_node_t node;
639 vat_json_init_object (&node);
640 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
641 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
643 vat_json_print (vam->ofp, &node);
644 vat_json_free (&node);
646 vam->retval = ntohl (mp->retval);
647 vam->result_ready = 1;
650 static void vl_api_create_vlan_subif_reply_t_handler
651 (vl_api_create_vlan_subif_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_create_vlan_subif_reply_t_handler_json
663 (vl_api_create_vlan_subif_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_subif_reply_t_handler
680 (vl_api_create_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_subif_reply_t_handler_json
692 (vl_api_create_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_interface_name_renumber_reply_t_handler
709 (vl_api_interface_name_renumber_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->result_ready = 1;
719 static void vl_api_interface_name_renumber_reply_t_handler_json
720 (vl_api_interface_name_renumber_reply_t * mp)
722 vat_main_t *vam = &vat_main;
723 vat_json_node_t node;
725 vat_json_init_object (&node);
726 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
728 vat_json_print (vam->ofp, &node);
729 vat_json_free (&node);
731 vam->retval = ntohl (mp->retval);
732 vam->result_ready = 1;
736 * Special-case: build the interface table, maintain
737 * the next loopback sw_if_index vbl.
739 static void vl_api_sw_interface_details_t_handler
740 (vl_api_sw_interface_details_t * mp)
742 vat_main_t *vam = &vat_main;
743 u8 *s = format (0, "%s%c", mp->interface_name, 0);
745 hash_set_mem (vam->sw_if_index_by_interface_name, s,
746 ntohl (mp->sw_if_index));
748 /* In sub interface case, fill the sub interface table entry */
749 if (mp->sw_if_index != mp->sup_sw_if_index)
751 sw_interface_subif_t *sub = NULL;
753 vec_add2 (vam->sw_if_subif_table, sub, 1);
755 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
756 strncpy ((char *) sub->interface_name, (char *) s,
757 vec_len (sub->interface_name));
758 sub->sw_if_index = ntohl (mp->sw_if_index);
759 sub->sub_id = ntohl (mp->sub_id);
761 sub->sub_dot1ad = mp->sub_dot1ad;
762 sub->sub_number_of_tags = mp->sub_number_of_tags;
763 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
764 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
765 sub->sub_exact_match = mp->sub_exact_match;
766 sub->sub_default = mp->sub_default;
767 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
768 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
770 /* vlan tag rewrite */
771 sub->vtr_op = ntohl (mp->vtr_op);
772 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
773 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
774 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
778 static void vl_api_sw_interface_details_t_handler_json
779 (vl_api_sw_interface_details_t * mp)
781 vat_main_t *vam = &vat_main;
782 vat_json_node_t *node = NULL;
784 if (VAT_JSON_ARRAY != vam->json_tree.type)
786 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
787 vat_json_init_array (&vam->json_tree);
789 node = vat_json_array_add (&vam->json_tree);
791 vat_json_init_object (node);
792 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
793 vat_json_object_add_uint (node, "sup_sw_if_index",
794 ntohl (mp->sup_sw_if_index));
795 vat_json_object_add_uint (node, "l2_address_length",
796 ntohl (mp->l2_address_length));
797 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
798 sizeof (mp->l2_address));
799 vat_json_object_add_string_copy (node, "interface_name",
801 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
802 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
803 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
804 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
805 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
806 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
807 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
808 vat_json_object_add_uint (node, "sub_number_of_tags",
809 mp->sub_number_of_tags);
810 vat_json_object_add_uint (node, "sub_outer_vlan_id",
811 ntohs (mp->sub_outer_vlan_id));
812 vat_json_object_add_uint (node, "sub_inner_vlan_id",
813 ntohs (mp->sub_inner_vlan_id));
814 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
815 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
816 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
817 mp->sub_outer_vlan_id_any);
818 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
819 mp->sub_inner_vlan_id_any);
820 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
821 vat_json_object_add_uint (node, "vtr_push_dot1q",
822 ntohl (mp->vtr_push_dot1q));
823 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
824 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
827 static void vl_api_sw_interface_set_flags_t_handler
828 (vl_api_sw_interface_set_flags_t * mp)
830 vat_main_t *vam = &vat_main;
831 if (vam->interface_event_display)
832 errmsg ("interface flags: sw_if_index %d %s %s\n",
833 ntohl (mp->sw_if_index),
834 mp->admin_up_down ? "admin-up" : "admin-down",
835 mp->link_up_down ? "link-up" : "link-down");
838 static void vl_api_sw_interface_set_flags_t_handler_json
839 (vl_api_sw_interface_set_flags_t * mp)
841 /* JSON output not supported */
845 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
847 vat_main_t *vam = &vat_main;
848 i32 retval = ntohl (mp->retval);
850 vam->retval = retval;
851 vam->shmem_result = (u8 *) mp->reply_in_shmem;
852 vam->result_ready = 1;
856 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
858 vat_main_t *vam = &vat_main;
859 vat_json_node_t node;
860 api_main_t *am = &api_main;
864 vat_json_init_object (&node);
865 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
866 vat_json_object_add_uint (&node, "reply_in_shmem",
867 ntohl (mp->reply_in_shmem));
868 /* Toss the shared-memory original... */
869 pthread_mutex_lock (&am->vlib_rp->mutex);
870 oldheap = svm_push_data_heap (am->vlib_rp);
872 reply = (u8 *) (mp->reply_in_shmem);
875 svm_pop_heap (oldheap);
876 pthread_mutex_unlock (&am->vlib_rp->mutex);
878 vat_json_print (vam->ofp, &node);
879 vat_json_free (&node);
881 vam->retval = ntohl (mp->retval);
882 vam->result_ready = 1;
886 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
888 vat_main_t *vam = &vat_main;
889 i32 retval = ntohl (mp->retval);
891 vam->retval = retval;
892 vam->cmd_reply = mp->reply;
893 vam->result_ready = 1;
897 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
899 vat_main_t *vam = &vat_main;
900 vat_json_node_t node;
902 vat_json_init_object (&node);
903 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
904 vat_json_object_add_string_copy (&node, "reply", mp->reply);
906 vat_json_print (vam->ofp, &node);
907 vat_json_free (&node);
909 vam->retval = ntohl (mp->retval);
910 vam->result_ready = 1;
913 static void vl_api_classify_add_del_table_reply_t_handler
914 (vl_api_classify_add_del_table_reply_t * mp)
916 vat_main_t *vam = &vat_main;
917 i32 retval = ntohl (mp->retval);
920 vam->async_errors += (retval < 0);
924 vam->retval = retval;
926 ((mp->new_table_index != 0xFFFFFFFF) ||
927 (mp->skip_n_vectors != 0xFFFFFFFF) ||
928 (mp->match_n_vectors != 0xFFFFFFFF)))
930 * Note: this is just barely thread-safe, depends on
931 * the main thread spinning waiting for an answer...
933 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d\n",
934 ntohl (mp->new_table_index),
935 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
936 vam->result_ready = 1;
940 static void vl_api_classify_add_del_table_reply_t_handler_json
941 (vl_api_classify_add_del_table_reply_t * mp)
943 vat_main_t *vam = &vat_main;
944 vat_json_node_t node;
946 vat_json_init_object (&node);
947 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
948 vat_json_object_add_uint (&node, "new_table_index",
949 ntohl (mp->new_table_index));
950 vat_json_object_add_uint (&node, "skip_n_vectors",
951 ntohl (mp->skip_n_vectors));
952 vat_json_object_add_uint (&node, "match_n_vectors",
953 ntohl (mp->match_n_vectors));
955 vat_json_print (vam->ofp, &node);
956 vat_json_free (&node);
958 vam->retval = ntohl (mp->retval);
959 vam->result_ready = 1;
962 static void vl_api_get_node_index_reply_t_handler
963 (vl_api_get_node_index_reply_t * mp)
965 vat_main_t *vam = &vat_main;
966 i32 retval = ntohl (mp->retval);
969 vam->async_errors += (retval < 0);
973 vam->retval = retval;
975 errmsg ("node index %d\n", ntohl (mp->node_index));
976 vam->result_ready = 1;
980 static void vl_api_get_node_index_reply_t_handler_json
981 (vl_api_get_node_index_reply_t * mp)
983 vat_main_t *vam = &vat_main;
984 vat_json_node_t node;
986 vat_json_init_object (&node);
987 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
988 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
990 vat_json_print (vam->ofp, &node);
991 vat_json_free (&node);
993 vam->retval = ntohl (mp->retval);
994 vam->result_ready = 1;
997 static void vl_api_get_next_index_reply_t_handler
998 (vl_api_get_next_index_reply_t * mp)
1000 vat_main_t *vam = &vat_main;
1001 i32 retval = ntohl (mp->retval);
1002 if (vam->async_mode)
1004 vam->async_errors += (retval < 0);
1008 vam->retval = retval;
1010 errmsg ("next node index %d\n", ntohl (mp->next_index));
1011 vam->result_ready = 1;
1015 static void vl_api_get_next_index_reply_t_handler_json
1016 (vl_api_get_next_index_reply_t * mp)
1018 vat_main_t *vam = &vat_main;
1019 vat_json_node_t node;
1021 vat_json_init_object (&node);
1022 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1023 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1025 vat_json_print (vam->ofp, &node);
1026 vat_json_free (&node);
1028 vam->retval = ntohl (mp->retval);
1029 vam->result_ready = 1;
1032 static void vl_api_add_node_next_reply_t_handler
1033 (vl_api_add_node_next_reply_t * mp)
1035 vat_main_t *vam = &vat_main;
1036 i32 retval = ntohl (mp->retval);
1037 if (vam->async_mode)
1039 vam->async_errors += (retval < 0);
1043 vam->retval = retval;
1045 errmsg ("next index %d\n", ntohl (mp->next_index));
1046 vam->result_ready = 1;
1050 static void vl_api_add_node_next_reply_t_handler_json
1051 (vl_api_add_node_next_reply_t * mp)
1053 vat_main_t *vam = &vat_main;
1054 vat_json_node_t node;
1056 vat_json_init_object (&node);
1057 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1058 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1060 vat_json_print (vam->ofp, &node);
1061 vat_json_free (&node);
1063 vam->retval = ntohl (mp->retval);
1064 vam->result_ready = 1;
1067 static void vl_api_show_version_reply_t_handler
1068 (vl_api_show_version_reply_t * mp)
1070 vat_main_t *vam = &vat_main;
1071 i32 retval = ntohl (mp->retval);
1075 errmsg (" program: %s\n", mp->program);
1076 errmsg (" version: %s\n", mp->version);
1077 errmsg (" build date: %s\n", mp->build_date);
1078 errmsg ("build directory: %s\n", mp->build_directory);
1080 vam->retval = retval;
1081 vam->result_ready = 1;
1084 static void vl_api_show_version_reply_t_handler_json
1085 (vl_api_show_version_reply_t * mp)
1087 vat_main_t *vam = &vat_main;
1088 vat_json_node_t node;
1090 vat_json_init_object (&node);
1091 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1092 vat_json_object_add_string_copy (&node, "program", mp->program);
1093 vat_json_object_add_string_copy (&node, "version", mp->version);
1094 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1095 vat_json_object_add_string_copy (&node, "build_directory",
1096 mp->build_directory);
1098 vat_json_print (vam->ofp, &node);
1099 vat_json_free (&node);
1101 vam->retval = ntohl (mp->retval);
1102 vam->result_ready = 1;
1106 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1108 vat_main_t *vam = &vat_main;
1109 errmsg ("arp %s event: address %U new mac %U sw_if_index %d\n",
1110 mp->mac_ip ? "mac/ip binding" : "address resolution",
1111 format_ip4_address, &mp->address,
1112 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1116 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1118 /* JSON output not supported */
1122 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1124 vat_main_t *vam = &vat_main;
1125 errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d\n",
1126 mp->mac_ip ? "mac/ip binding" : "address resolution",
1127 format_ip6_address, mp->address,
1128 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1132 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1134 /* JSON output not supported */
1138 * Special-case: build the bridge domain table, maintain
1139 * the next bd id vbl.
1141 static void vl_api_bridge_domain_details_t_handler
1142 (vl_api_bridge_domain_details_t * mp)
1144 vat_main_t *vam = &vat_main;
1145 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1147 fformat (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s\n",
1148 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1150 fformat (vam->ofp, "%3d %3d %3d %3d %3d %3d\n",
1151 ntohl (mp->bd_id), mp->learn, mp->forward,
1152 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1155 fformat (vam->ofp, "\n\n%s %s %s\n", "sw_if_index", "SHG",
1159 static void vl_api_bridge_domain_details_t_handler_json
1160 (vl_api_bridge_domain_details_t * mp)
1162 vat_main_t *vam = &vat_main;
1163 vat_json_node_t *node, *array = NULL;
1165 if (VAT_JSON_ARRAY != vam->json_tree.type)
1167 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1168 vat_json_init_array (&vam->json_tree);
1170 node = vat_json_array_add (&vam->json_tree);
1172 vat_json_init_object (node);
1173 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1174 vat_json_object_add_uint (node, "flood", mp->flood);
1175 vat_json_object_add_uint (node, "forward", mp->forward);
1176 vat_json_object_add_uint (node, "learn", mp->learn);
1177 vat_json_object_add_uint (node, "bvi_sw_if_index",
1178 ntohl (mp->bvi_sw_if_index));
1179 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1180 array = vat_json_object_add (node, "sw_if");
1181 vat_json_init_array (array);
1185 * Special-case: build the bridge domain sw if table.
1187 static void vl_api_bridge_domain_sw_if_details_t_handler
1188 (vl_api_bridge_domain_sw_if_details_t * mp)
1190 vat_main_t *vam = &vat_main;
1195 sw_if_index = ntohl (mp->sw_if_index);
1197 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1199 if ((u32) p->value[0] == sw_if_index)
1201 sw_if_name = (u8 *)(p->key);
1207 fformat (vam->ofp, "%7d %3d %s", sw_if_index,
1208 mp->shg, sw_if_name ? (char *) sw_if_name :
1209 "sw_if_index not found!");
1212 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1213 (vl_api_bridge_domain_sw_if_details_t * mp)
1215 vat_main_t *vam = &vat_main;
1216 vat_json_node_t *node = NULL;
1217 uword last_index = 0;
1219 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1220 ASSERT (vec_len (vam->json_tree.array) >= 1);
1221 last_index = vec_len (vam->json_tree.array) - 1;
1222 node = &vam->json_tree.array[last_index];
1223 node = vat_json_object_get_element (node, "sw_if");
1224 ASSERT (NULL != node);
1225 node = vat_json_array_add (node);
1227 vat_json_init_object (node);
1228 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1229 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1230 vat_json_object_add_uint (node, "shg", mp->shg);
1233 static void vl_api_control_ping_reply_t_handler
1234 (vl_api_control_ping_reply_t * mp)
1236 vat_main_t *vam = &vat_main;
1237 i32 retval = ntohl (mp->retval);
1238 if (vam->async_mode)
1240 vam->async_errors += (retval < 0);
1244 vam->retval = retval;
1245 vam->result_ready = 1;
1249 static void vl_api_control_ping_reply_t_handler_json
1250 (vl_api_control_ping_reply_t * mp)
1252 vat_main_t *vam = &vat_main;
1253 i32 retval = ntohl (mp->retval);
1255 if (VAT_JSON_NONE != vam->json_tree.type)
1257 vat_json_print (vam->ofp, &vam->json_tree);
1258 vat_json_free (&vam->json_tree);
1259 vam->json_tree.type = VAT_JSON_NONE;
1264 vat_json_init_array (&vam->json_tree);
1265 vat_json_print (vam->ofp, &vam->json_tree);
1266 vam->json_tree.type = VAT_JSON_NONE;
1269 vam->retval = retval;
1270 vam->result_ready = 1;
1274 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1276 vat_main_t *vam = &vat_main;
1277 i32 retval = ntohl (mp->retval);
1278 if (vam->async_mode)
1280 vam->async_errors += (retval < 0);
1284 vam->retval = retval;
1285 vam->result_ready = 1;
1289 static void vl_api_l2_flags_reply_t_handler_json
1290 (vl_api_l2_flags_reply_t * mp)
1292 vat_main_t *vam = &vat_main;
1293 vat_json_node_t node;
1295 vat_json_init_object (&node);
1296 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1297 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1298 ntohl (mp->resulting_feature_bitmap));
1300 vat_json_print (vam->ofp, &node);
1301 vat_json_free (&node);
1303 vam->retval = ntohl (mp->retval);
1304 vam->result_ready = 1;
1307 static void vl_api_bridge_flags_reply_t_handler
1308 (vl_api_bridge_flags_reply_t * mp)
1310 vat_main_t *vam = &vat_main;
1311 i32 retval = ntohl (mp->retval);
1312 if (vam->async_mode)
1314 vam->async_errors += (retval < 0);
1318 vam->retval = retval;
1319 vam->result_ready = 1;
1323 static void vl_api_bridge_flags_reply_t_handler_json
1324 (vl_api_bridge_flags_reply_t * mp)
1326 vat_main_t *vam = &vat_main;
1327 vat_json_node_t node;
1329 vat_json_init_object (&node);
1330 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1331 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1332 ntohl (mp->resulting_feature_bitmap));
1334 vat_json_print (vam->ofp, &node);
1335 vat_json_free (&node);
1337 vam->retval = ntohl (mp->retval);
1338 vam->result_ready = 1;
1341 static void vl_api_tap_connect_reply_t_handler
1342 (vl_api_tap_connect_reply_t * mp)
1344 vat_main_t *vam = &vat_main;
1345 i32 retval = ntohl (mp->retval);
1346 if (vam->async_mode)
1348 vam->async_errors += (retval < 0);
1352 vam->retval = retval;
1353 vam->sw_if_index = ntohl (mp->sw_if_index);
1354 vam->result_ready = 1;
1359 static void vl_api_tap_connect_reply_t_handler_json
1360 (vl_api_tap_connect_reply_t * mp)
1362 vat_main_t *vam = &vat_main;
1363 vat_json_node_t node;
1365 vat_json_init_object (&node);
1366 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1367 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1369 vat_json_print (vam->ofp, &node);
1370 vat_json_free (&node);
1372 vam->retval = ntohl (mp->retval);
1373 vam->result_ready = 1;
1378 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1380 vat_main_t *vam = &vat_main;
1381 i32 retval = ntohl (mp->retval);
1382 if (vam->async_mode)
1384 vam->async_errors += (retval < 0);
1388 vam->retval = retval;
1389 vam->sw_if_index = ntohl (mp->sw_if_index);
1390 vam->result_ready = 1;
1394 static void vl_api_tap_modify_reply_t_handler_json
1395 (vl_api_tap_modify_reply_t * mp)
1397 vat_main_t *vam = &vat_main;
1398 vat_json_node_t node;
1400 vat_json_init_object (&node);
1401 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1402 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1404 vat_json_print (vam->ofp, &node);
1405 vat_json_free (&node);
1407 vam->retval = ntohl (mp->retval);
1408 vam->result_ready = 1;
1412 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1414 vat_main_t *vam = &vat_main;
1415 i32 retval = ntohl (mp->retval);
1416 if (vam->async_mode)
1418 vam->async_errors += (retval < 0);
1422 vam->retval = retval;
1423 vam->result_ready = 1;
1427 static void vl_api_tap_delete_reply_t_handler_json
1428 (vl_api_tap_delete_reply_t * mp)
1430 vat_main_t *vam = &vat_main;
1431 vat_json_node_t node;
1433 vat_json_init_object (&node);
1434 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1436 vat_json_print (vam->ofp, &node);
1437 vat_json_free (&node);
1439 vam->retval = ntohl (mp->retval);
1440 vam->result_ready = 1;
1443 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1444 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1446 vat_main_t *vam = &vat_main;
1447 i32 retval = ntohl (mp->retval);
1448 if (vam->async_mode)
1450 vam->async_errors += (retval < 0);
1454 vam->retval = retval;
1455 vam->result_ready = 1;
1459 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1460 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1462 vat_main_t *vam = &vat_main;
1463 vat_json_node_t node;
1465 vat_json_init_object (&node);
1466 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1467 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1468 ntohl (mp->sw_if_index));
1470 vat_json_print (vam->ofp, &node);
1471 vat_json_free (&node);
1473 vam->retval = ntohl (mp->retval);
1474 vam->result_ready = 1;
1477 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1478 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1480 vat_main_t *vam = &vat_main;
1481 i32 retval = ntohl (mp->retval);
1482 if (vam->async_mode)
1484 vam->async_errors += (retval < 0);
1488 vam->retval = retval;
1489 vam->sw_if_index = ntohl (mp->sw_if_index);
1490 vam->result_ready = 1;
1494 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1495 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1497 vat_main_t *vam = &vat_main;
1498 vat_json_node_t node;
1500 vat_json_init_object (&node);
1501 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1502 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1504 vat_json_print (vam->ofp, &node);
1505 vat_json_free (&node);
1507 vam->retval = ntohl (mp->retval);
1508 vam->result_ready = 1;
1512 static void vl_api_lisp_add_del_locator_set_reply_t_handler
1513 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1515 vat_main_t *vam = &vat_main;
1516 i32 retval = ntohl (mp->retval);
1517 if (vam->async_mode)
1519 vam->async_errors += (retval < 0);
1523 vam->retval = retval;
1524 vam->result_ready = 1;
1528 static void vl_api_lisp_add_del_locator_set_reply_t_handler_json
1529 (vl_api_lisp_add_del_locator_set_reply_t * mp)
1531 vat_main_t *vam = &vat_main;
1532 vat_json_node_t node;
1534 vat_json_init_object (&node);
1535 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1536 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1538 vat_json_print (vam->ofp, &node);
1539 vat_json_free (&node);
1541 vam->retval = ntohl (mp->retval);
1542 vam->result_ready = 1;
1545 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1546 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1548 vat_main_t *vam = &vat_main;
1549 i32 retval = ntohl (mp->retval);
1550 if (vam->async_mode)
1552 vam->async_errors += (retval < 0);
1556 vam->retval = retval;
1557 vam->sw_if_index = ntohl (mp->sw_if_index);
1558 vam->result_ready = 1;
1562 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1563 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1565 vat_main_t *vam = &vat_main;
1566 vat_json_node_t node;
1568 vat_json_init_object (&node);
1569 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1570 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1572 vat_json_print (vam->ofp, &node);
1573 vat_json_free (&node);
1575 vam->retval = ntohl (mp->retval);
1576 vam->result_ready = 1;
1579 static void vl_api_gre_add_del_tunnel_reply_t_handler
1580 (vl_api_gre_add_del_tunnel_reply_t * mp)
1582 vat_main_t *vam = &vat_main;
1583 i32 retval = ntohl (mp->retval);
1584 if (vam->async_mode)
1586 vam->async_errors += (retval < 0);
1590 vam->retval = retval;
1591 vam->sw_if_index = ntohl (mp->sw_if_index);
1592 vam->result_ready = 1;
1596 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1597 (vl_api_gre_add_del_tunnel_reply_t * mp)
1599 vat_main_t *vam = &vat_main;
1600 vat_json_node_t node;
1602 vat_json_init_object (&node);
1603 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1604 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1606 vat_json_print (vam->ofp, &node);
1607 vat_json_free (&node);
1609 vam->retval = ntohl (mp->retval);
1610 vam->result_ready = 1;
1613 static void vl_api_create_vhost_user_if_reply_t_handler
1614 (vl_api_create_vhost_user_if_reply_t * mp)
1616 vat_main_t *vam = &vat_main;
1617 i32 retval = ntohl (mp->retval);
1618 if (vam->async_mode)
1620 vam->async_errors += (retval < 0);
1624 vam->retval = retval;
1625 vam->sw_if_index = ntohl (mp->sw_if_index);
1626 vam->result_ready = 1;
1630 static void vl_api_create_vhost_user_if_reply_t_handler_json
1631 (vl_api_create_vhost_user_if_reply_t * mp)
1633 vat_main_t *vam = &vat_main;
1634 vat_json_node_t node;
1636 vat_json_init_object (&node);
1637 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1638 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1640 vat_json_print (vam->ofp, &node);
1641 vat_json_free (&node);
1643 vam->retval = ntohl (mp->retval);
1644 vam->result_ready = 1;
1647 static void vl_api_ip_address_details_t_handler
1648 (vl_api_ip_address_details_t * mp)
1650 vat_main_t *vam = &vat_main;
1651 static ip_address_details_t empty_ip_address_details = { {0} };
1652 ip_address_details_t *address = NULL;
1653 ip_details_t *current_ip_details = NULL;
1654 ip_details_t *details = NULL;
1656 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1658 if (!details || vam->current_sw_if_index >= vec_len (details)
1659 || !details[vam->current_sw_if_index].present)
1661 errmsg ("ip address details arrived but not stored\n");
1662 errmsg ("ip_dump should be called first\n");
1666 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1668 #define addresses (current_ip_details->addr)
1670 vec_validate_init_empty (addresses, vec_len (addresses),
1671 empty_ip_address_details);
1673 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1675 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1676 address->prefix_length = mp->prefix_length;
1680 static void vl_api_ip_address_details_t_handler_json
1681 (vl_api_ip_address_details_t * mp)
1683 vat_main_t *vam = &vat_main;
1684 vat_json_node_t *node = NULL;
1685 struct in6_addr ip6;
1688 if (VAT_JSON_ARRAY != vam->json_tree.type)
1690 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1691 vat_json_init_array (&vam->json_tree);
1693 node = vat_json_array_add (&vam->json_tree);
1695 vat_json_init_object (node);
1698 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1699 vat_json_object_add_ip6 (node, "ip", ip6);
1703 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1704 vat_json_object_add_ip4 (node, "ip", ip4);
1706 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1710 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1712 vat_main_t *vam = &vat_main;
1713 static ip_details_t empty_ip_details = { 0 };
1714 ip_details_t *ip = NULL;
1715 u32 sw_if_index = ~0;
1717 sw_if_index = ntohl (mp->sw_if_index);
1719 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1720 sw_if_index, empty_ip_details);
1722 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1729 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1731 vat_main_t *vam = &vat_main;
1733 if (VAT_JSON_ARRAY != vam->json_tree.type)
1735 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1736 vat_json_init_array (&vam->json_tree);
1738 vat_json_array_add_uint (&vam->json_tree,
1739 clib_net_to_host_u32 (mp->sw_if_index));
1742 static void vl_api_map_domain_details_t_handler_json
1743 (vl_api_map_domain_details_t * mp)
1745 vat_json_node_t *node = NULL;
1746 vat_main_t *vam = &vat_main;
1747 struct in6_addr ip6;
1750 if (VAT_JSON_ARRAY != vam->json_tree.type)
1752 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1753 vat_json_init_array (&vam->json_tree);
1756 node = vat_json_array_add (&vam->json_tree);
1757 vat_json_init_object (node);
1759 vat_json_object_add_uint (node, "domain_index",
1760 clib_net_to_host_u32 (mp->domain_index));
1761 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1762 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1763 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1764 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1765 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1766 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1767 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1768 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1769 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1770 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1771 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1772 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1773 vat_json_object_add_uint (node, "flags", mp->flags);
1774 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1775 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1778 static void vl_api_map_domain_details_t_handler
1779 (vl_api_map_domain_details_t * mp)
1781 vat_main_t *vam = &vat_main;
1783 if (mp->is_translation)
1786 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u\n",
1787 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1788 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1789 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1790 clib_net_to_host_u32 (mp->domain_index));
1795 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u\n",
1796 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1797 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1798 format_ip6_address, mp->ip6_src,
1799 clib_net_to_host_u32 (mp->domain_index));
1801 fformat (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s\n",
1802 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1803 mp->is_translation ? "map-t" : "");
1806 static void vl_api_map_rule_details_t_handler_json
1807 (vl_api_map_rule_details_t * mp)
1809 struct in6_addr ip6;
1810 vat_json_node_t *node = NULL;
1811 vat_main_t *vam = &vat_main;
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, "psid", clib_net_to_host_u16 (mp->psid));
1823 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1824 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1828 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1830 vat_main_t *vam = &vat_main;
1831 fformat (vam->ofp, " %d (psid) %U (ip6-dst)\n",
1832 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1836 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1838 vat_main_t *vam = &vat_main;
1839 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1840 "router_addr %U host_mac %U\n",
1841 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1842 format_ip4_address, &mp->host_address,
1843 format_ip4_address, &mp->router_address,
1844 format_ethernet_address, mp->host_mac);
1847 static void vl_api_dhcp_compl_event_t_handler_json
1848 (vl_api_dhcp_compl_event_t * mp)
1850 /* JSON output not supported */
1854 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1857 vat_main_t *vam = &vat_main;
1858 static u64 default_counter = 0;
1860 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
1862 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
1863 sw_if_index, default_counter);
1864 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
1868 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
1869 interface_counter_t counter)
1871 vat_main_t *vam = &vat_main;
1872 static interface_counter_t default_counter = { 0, };
1874 vec_validate_init_empty (vam->combined_interface_counters,
1875 vnet_counter_type, NULL);
1876 vec_validate_init_empty (vam->combined_interface_counters
1877 [vnet_counter_type], sw_if_index, default_counter);
1878 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
1881 static void vl_api_vnet_interface_counters_t_handler
1882 (vl_api_vnet_interface_counters_t * mp)
1887 static void vl_api_vnet_interface_counters_t_handler_json
1888 (vl_api_vnet_interface_counters_t * mp)
1890 interface_counter_t counter;
1895 u32 first_sw_if_index;
1898 count = ntohl (mp->count);
1899 first_sw_if_index = ntohl (mp->first_sw_if_index);
1901 if (!mp->is_combined)
1903 v_packets = (u64 *) & mp->data;
1904 for (i = 0; i < count; i++)
1907 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
1908 set_simple_interface_counter (mp->vnet_counter_type,
1909 first_sw_if_index + i, packets);
1915 v = (vlib_counter_t *) & mp->data;
1916 for (i = 0; i < count; i++)
1919 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
1921 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
1922 set_combined_interface_counter (mp->vnet_counter_type,
1923 first_sw_if_index + i, counter);
1930 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
1932 vat_main_t *vam = &vat_main;
1935 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
1937 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
1946 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
1948 vat_main_t *vam = &vat_main;
1951 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
1953 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
1961 static void vl_api_vnet_ip4_fib_counters_t_handler
1962 (vl_api_vnet_ip4_fib_counters_t * mp)
1967 static void vl_api_vnet_ip4_fib_counters_t_handler_json
1968 (vl_api_vnet_ip4_fib_counters_t * mp)
1970 vat_main_t *vam = &vat_main;
1971 vl_api_ip4_fib_counter_t *v;
1972 ip4_fib_counter_t *counter;
1979 vrf_id = ntohl (mp->vrf_id);
1980 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
1981 if (~0 == vrf_index)
1983 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
1984 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
1985 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
1986 vec_validate (vam->ip4_fib_counters, vrf_index);
1987 vam->ip4_fib_counters[vrf_index] = NULL;
1990 vec_free (vam->ip4_fib_counters[vrf_index]);
1991 v = (vl_api_ip4_fib_counter_t *) & mp->c;
1992 count = ntohl (mp->count);
1993 for (i = 0; i < count; i++)
1995 vec_validate (vam->ip4_fib_counters[vrf_index], i);
1996 counter = &vam->ip4_fib_counters[vrf_index][i];
1997 clib_memcpy (&ip4, &v->address, sizeof (ip4));
1998 counter->address = ip4;
1999 counter->address_length = v->address_length;
2000 counter->packets = clib_net_to_host_u64 (v->packets);
2001 counter->bytes = clib_net_to_host_u64 (v->bytes);
2006 static void vl_api_vnet_ip6_fib_counters_t_handler
2007 (vl_api_vnet_ip6_fib_counters_t * mp)
2012 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2013 (vl_api_vnet_ip6_fib_counters_t * mp)
2015 vat_main_t *vam = &vat_main;
2016 vl_api_ip6_fib_counter_t *v;
2017 ip6_fib_counter_t *counter;
2018 struct in6_addr ip6;
2024 vrf_id = ntohl (mp->vrf_id);
2025 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2026 if (~0 == vrf_index)
2028 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2029 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2030 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2031 vec_validate (vam->ip6_fib_counters, vrf_index);
2032 vam->ip6_fib_counters[vrf_index] = NULL;
2035 vec_free (vam->ip6_fib_counters[vrf_index]);
2036 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2037 count = ntohl (mp->count);
2038 for (i = 0; i < count; i++)
2040 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2041 counter = &vam->ip6_fib_counters[vrf_index][i];
2042 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2043 counter->address = ip6;
2044 counter->address_length = v->address_length;
2045 counter->packets = clib_net_to_host_u64 (v->packets);
2046 counter->bytes = clib_net_to_host_u64 (v->bytes);
2051 static void vl_api_get_first_msg_id_reply_t_handler
2052 (vl_api_get_first_msg_id_reply_t * mp)
2054 vat_main_t *vam = &vat_main;
2055 i32 retval = ntohl (mp->retval);
2057 if (vam->async_mode)
2059 vam->async_errors += (retval < 0);
2063 vam->retval = retval;
2064 vam->result_ready = 1;
2068 errmsg ("first message id %d\n", ntohs (mp->first_msg_id));
2072 static void vl_api_get_first_msg_id_reply_t_handler_json
2073 (vl_api_get_first_msg_id_reply_t * mp)
2075 vat_main_t *vam = &vat_main;
2076 vat_json_node_t node;
2078 vat_json_init_object (&node);
2079 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2080 vat_json_object_add_uint (&node, "first_msg_id",
2081 (uint) ntohs (mp->first_msg_id));
2083 vat_json_print (vam->ofp, &node);
2084 vat_json_free (&node);
2086 vam->retval = ntohl (mp->retval);
2087 vam->result_ready = 1;
2090 static void vl_api_get_node_graph_reply_t_handler
2091 (vl_api_get_node_graph_reply_t * mp)
2093 vat_main_t *vam = &vat_main;
2094 api_main_t *am = &api_main;
2095 i32 retval = ntohl (mp->retval);
2096 u8 *pvt_copy, *reply;
2101 if (vam->async_mode)
2103 vam->async_errors += (retval < 0);
2107 vam->retval = retval;
2108 vam->result_ready = 1;
2111 /* "Should never happen..." */
2115 reply = (u8 *) (mp->reply_in_shmem);
2116 pvt_copy = vec_dup (reply);
2118 /* Toss the shared-memory original... */
2119 pthread_mutex_lock (&am->vlib_rp->mutex);
2120 oldheap = svm_push_data_heap (am->vlib_rp);
2124 svm_pop_heap (oldheap);
2125 pthread_mutex_unlock (&am->vlib_rp->mutex);
2127 if (vam->graph_nodes)
2129 hash_free (vam->graph_node_index_by_name);
2131 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2133 node = vam->graph_nodes[i];
2134 vec_free (node->name);
2135 vec_free (node->next_nodes);
2138 vec_free (vam->graph_nodes);
2141 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2142 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2143 vec_free (pvt_copy);
2145 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2147 node = vam->graph_nodes[i];
2148 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2152 static void vl_api_get_node_graph_reply_t_handler_json
2153 (vl_api_get_node_graph_reply_t * mp)
2155 vat_main_t *vam = &vat_main;
2156 api_main_t *am = &api_main;
2158 vat_json_node_t node;
2161 /* $$$$ make this real? */
2162 vat_json_init_object (&node);
2163 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2164 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2166 reply = (u8 *) (mp->reply_in_shmem);
2168 /* Toss the shared-memory original... */
2169 pthread_mutex_lock (&am->vlib_rp->mutex);
2170 oldheap = svm_push_data_heap (am->vlib_rp);
2174 svm_pop_heap (oldheap);
2175 pthread_mutex_unlock (&am->vlib_rp->mutex);
2177 vat_json_print (vam->ofp, &node);
2178 vat_json_free (&node);
2180 vam->retval = ntohl (mp->retval);
2181 vam->result_ready = 1;
2185 vl_api_lisp_locator_details_t_handler (vl_api_lisp_locator_details_t * mp)
2187 vat_main_t *vam = &vat_main;
2192 s = format (s, "%=16d%=16d%=16d\n",
2193 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2197 s = format (s, "%=16U%=16d%=16d\n",
2198 mp->is_ipv6 ? format_ip6_address :
2200 mp->ip_address, mp->priority, mp->weight);
2203 fformat (vam->ofp, "%v", s);
2208 vl_api_lisp_locator_details_t_handler_json (vl_api_lisp_locator_details_t *
2211 vat_main_t *vam = &vat_main;
2212 vat_json_node_t *node = NULL;
2213 struct in6_addr ip6;
2216 if (VAT_JSON_ARRAY != vam->json_tree.type)
2218 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2219 vat_json_init_array (&vam->json_tree);
2221 node = vat_json_array_add (&vam->json_tree);
2222 vat_json_init_object (node);
2224 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2225 vat_json_object_add_uint (node, "priority", mp->priority);
2226 vat_json_object_add_uint (node, "weight", mp->weight);
2229 vat_json_object_add_uint (node, "sw_if_index",
2230 clib_net_to_host_u32 (mp->sw_if_index));
2235 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2236 vat_json_object_add_ip6 (node, "address", ip6);
2240 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2241 vat_json_object_add_ip4 (node, "address", ip4);
2247 vl_api_lisp_locator_set_details_t_handler (vl_api_lisp_locator_set_details_t *
2250 vat_main_t *vam = &vat_main;
2253 ls_name = format (0, "%s", mp->ls_name);
2255 fformat (vam->ofp, "%=10d%=15v\n", clib_net_to_host_u32 (mp->ls_index),
2261 vl_api_lisp_locator_set_details_t_handler_json
2262 (vl_api_lisp_locator_set_details_t * mp)
2264 vat_main_t *vam = &vat_main;
2265 vat_json_node_t *node = 0;
2268 ls_name = format (0, "%s", mp->ls_name);
2269 vec_add1 (ls_name, 0);
2271 if (VAT_JSON_ARRAY != vam->json_tree.type)
2273 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2274 vat_json_init_array (&vam->json_tree);
2276 node = vat_json_array_add (&vam->json_tree);
2278 vat_json_init_object (node);
2279 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2280 vat_json_object_add_uint (node, "ls_index",
2281 clib_net_to_host_u32 (mp->ls_index));
2286 format_lisp_flat_eid (u8 * s, va_list * args)
2288 u32 type = va_arg (*args, u32);
2289 u8 *eid = va_arg (*args, u8 *);
2290 u32 eid_len = va_arg (*args, u32);
2295 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2297 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2299 return format (s, "%U", format_ethernet_address, eid);
2305 format_lisp_eid_vat (u8 * s, va_list * args)
2307 u32 type = va_arg (*args, u32);
2308 u8 *eid = va_arg (*args, u8 *);
2309 u32 eid_len = va_arg (*args, u32);
2310 u8 *seid = va_arg (*args, u8 *);
2311 u32 seid_len = va_arg (*args, u32);
2312 u32 is_src_dst = va_arg (*args, u32);
2315 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2317 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2323 vl_api_lisp_eid_table_details_t_handler (vl_api_lisp_eid_table_details_t * mp)
2325 vat_main_t *vam = &vat_main;
2326 u8 *s = 0, *eid = 0;
2328 if (~0 == mp->locator_set_index)
2329 s = format (0, "action: %d", mp->action);
2331 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2333 eid = format (0, "%U", format_lisp_eid_vat,
2337 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2340 fformat (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-d\n",
2341 clib_net_to_host_u32 (mp->vni),
2343 mp->is_local ? "local" : "remote",
2344 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative);
2350 vl_api_lisp_eid_table_details_t_handler_json (vl_api_lisp_eid_table_details_t
2353 vat_main_t *vam = &vat_main;
2354 vat_json_node_t *node = 0;
2357 if (VAT_JSON_ARRAY != vam->json_tree.type)
2359 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2360 vat_json_init_array (&vam->json_tree);
2362 node = vat_json_array_add (&vam->json_tree);
2364 vat_json_init_object (node);
2365 if (~0 == mp->locator_set_index)
2366 vat_json_object_add_uint (node, "action", mp->action);
2368 vat_json_object_add_uint (node, "locator_set_index",
2369 clib_net_to_host_u32 (mp->locator_set_index));
2371 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2372 eid = format (0, "%U", format_lisp_eid_vat,
2376 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2378 vat_json_object_add_string_copy (node, "eid", eid);
2379 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2380 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2381 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2386 vl_api_lisp_eid_table_map_details_t_handler
2387 (vl_api_lisp_eid_table_map_details_t * mp)
2389 vat_main_t *vam = &vat_main;
2391 u8 *line = format (0, "%=10d%=10d",
2392 clib_net_to_host_u32 (mp->vni),
2393 clib_net_to_host_u32 (mp->dp_table));
2394 fformat (vam->ofp, "%v\n", line);
2399 vl_api_lisp_eid_table_map_details_t_handler_json
2400 (vl_api_lisp_eid_table_map_details_t * mp)
2402 vat_main_t *vam = &vat_main;
2403 vat_json_node_t *node = NULL;
2405 if (VAT_JSON_ARRAY != vam->json_tree.type)
2407 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2408 vat_json_init_array (&vam->json_tree);
2410 node = vat_json_array_add (&vam->json_tree);
2411 vat_json_init_object (node);
2412 vat_json_object_add_uint (node, "dp_table",
2413 clib_net_to_host_u32 (mp->dp_table));
2414 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2418 vl_api_lisp_eid_table_vni_details_t_handler
2419 (vl_api_lisp_eid_table_vni_details_t * mp)
2421 vat_main_t *vam = &vat_main;
2423 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2424 fformat (vam->ofp, "%v\n", line);
2429 vl_api_lisp_eid_table_vni_details_t_handler_json
2430 (vl_api_lisp_eid_table_vni_details_t * mp)
2432 vat_main_t *vam = &vat_main;
2433 vat_json_node_t *node = NULL;
2435 if (VAT_JSON_ARRAY != vam->json_tree.type)
2437 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2438 vat_json_init_array (&vam->json_tree);
2440 node = vat_json_array_add (&vam->json_tree);
2441 vat_json_init_object (node);
2442 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2446 format_decap_next (u8 * s, va_list * args)
2448 u32 next_index = va_arg (*args, u32);
2452 case LISP_GPE_INPUT_NEXT_DROP:
2453 return format (s, "drop");
2454 case LISP_GPE_INPUT_NEXT_IP4_INPUT:
2455 return format (s, "ip4");
2456 case LISP_GPE_INPUT_NEXT_IP6_INPUT:
2457 return format (s, "ip6");
2459 return format (s, "unknown %d", next_index);
2465 vl_api_lisp_gpe_tunnel_details_t_handler (vl_api_lisp_gpe_tunnel_details_t *
2468 vat_main_t *vam = &vat_main;
2470 u8 *flag_str = NULL;
2472 iid_str = format (0, "%d (0x%x)", ntohl (mp->iid), ntohl (mp->iid));
2474 #define _(n,v) if (mp->flags & v) flag_str = format (flag_str, "%s-bit ", #n);
2475 foreach_lisp_gpe_flag_bit;
2478 fformat (vam->ofp, "%=20d%=30U%=16U%=16d%=16d%=16U"
2479 "%=16d%=16d%=16sd=16d%=16s%=16s\n",
2481 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2483 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2485 ntohl (mp->encap_fib_id),
2486 ntohl (mp->decap_fib_id),
2487 format_decap_next, ntohl (mp->dcap_next),
2489 flag_str, mp->next_protocol, mp->ver_res, mp->res, iid_str);
2495 vl_api_lisp_gpe_tunnel_details_t_handler_json
2496 (vl_api_lisp_gpe_tunnel_details_t * mp)
2498 vat_main_t *vam = &vat_main;
2499 vat_json_node_t *node = NULL;
2500 struct in6_addr ip6;
2504 next_decap_str = format (0, "%U", format_decap_next, htonl (mp->dcap_next));
2506 if (VAT_JSON_ARRAY != vam->json_tree.type)
2508 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2509 vat_json_init_array (&vam->json_tree);
2511 node = vat_json_array_add (&vam->json_tree);
2513 vat_json_init_object (node);
2514 vat_json_object_add_uint (node, "tunel", mp->tunnels);
2517 clib_memcpy (&ip6, mp->source_ip, sizeof (ip6));
2518 vat_json_object_add_ip6 (node, "source address", ip6);
2519 clib_memcpy (&ip6, mp->destination_ip, sizeof (ip6));
2520 vat_json_object_add_ip6 (node, "destination address", ip6);
2524 clib_memcpy (&ip4, mp->source_ip, sizeof (ip4));
2525 vat_json_object_add_ip4 (node, "source address", ip4);
2526 clib_memcpy (&ip4, mp->destination_ip, sizeof (ip4));
2527 vat_json_object_add_ip4 (node, "destination address", ip4);
2529 vat_json_object_add_uint (node, "fib encap", ntohl (mp->encap_fib_id));
2530 vat_json_object_add_uint (node, "fib decap", ntohl (mp->decap_fib_id));
2531 vat_json_object_add_string_copy (node, "decap next", next_decap_str);
2532 vat_json_object_add_uint (node, "lisp version", mp->ver_res >> 6);
2533 vat_json_object_add_uint (node, "flags", mp->flags);
2534 vat_json_object_add_uint (node, "next protocol", mp->next_protocol);
2535 vat_json_object_add_uint (node, "ver_res", mp->ver_res);
2536 vat_json_object_add_uint (node, "res", mp->res);
2537 vat_json_object_add_uint (node, "iid", ntohl (mp->iid));
2539 vec_free (next_decap_str);
2543 vl_api_lisp_adjacencies_get_reply_t_handler
2544 (vl_api_lisp_adjacencies_get_reply_t * mp)
2546 vat_main_t *vam = &vat_main;
2548 int retval = clib_net_to_host_u32 (mp->retval);
2549 vl_api_lisp_adjacency_t *a;
2554 n = clib_net_to_host_u32 (mp->count);
2556 for (i = 0; i < n; i++)
2558 a = &mp->adjacencies[i];
2559 fformat (vam->ofp, "%U %40U\n",
2560 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
2561 format_lisp_flat_eid, a->eid_type, a->reid,
2562 a->reid_prefix_len);
2566 vam->retval = retval;
2567 vam->result_ready = 1;
2571 vl_api_lisp_adjacencies_get_reply_t_handler_json
2572 (vl_api_lisp_adjacencies_get_reply_t * mp)
2575 vat_main_t *vam = &vat_main;
2576 vat_json_node_t *e = 0, root;
2578 int retval = clib_net_to_host_u32 (mp->retval);
2579 vl_api_lisp_adjacency_t *a;
2584 n = clib_net_to_host_u32 (mp->count);
2585 vat_json_init_array (&root);
2587 for (i = 0; i < n; i++)
2589 e = vat_json_array_add (&root);
2590 a = &mp->adjacencies[i];
2592 vat_json_init_object (e);
2593 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
2594 a->leid_prefix_len);
2596 vat_json_object_add_string_copy (e, "leid", s);
2599 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
2600 a->reid_prefix_len);
2602 vat_json_object_add_string_copy (e, "reid", s);
2606 vat_json_print (vam->ofp, &root);
2607 vat_json_free (&root);
2610 vam->retval = retval;
2611 vam->result_ready = 1;
2615 vl_api_lisp_map_resolver_details_t_handler (vl_api_lisp_map_resolver_details_t
2618 vat_main_t *vam = &vat_main;
2620 fformat (vam->ofp, "%=20U\n",
2621 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
2626 vl_api_lisp_map_resolver_details_t_handler_json
2627 (vl_api_lisp_map_resolver_details_t * mp)
2629 vat_main_t *vam = &vat_main;
2630 vat_json_node_t *node = NULL;
2631 struct in6_addr ip6;
2634 if (VAT_JSON_ARRAY != vam->json_tree.type)
2636 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2637 vat_json_init_array (&vam->json_tree);
2639 node = vat_json_array_add (&vam->json_tree);
2641 vat_json_init_object (node);
2644 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2645 vat_json_object_add_ip6 (node, "map resolver", ip6);
2649 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2650 vat_json_object_add_ip4 (node, "map resolver", ip4);
2655 vl_api_show_lisp_status_reply_t_handler
2656 (vl_api_show_lisp_status_reply_t * mp)
2658 vat_main_t *vam = &vat_main;
2659 i32 retval = ntohl (mp->retval);
2663 fformat (vam->ofp, "feature: %s\ngpe: %s\n",
2664 mp->feature_status ? "enabled" : "disabled",
2665 mp->gpe_status ? "enabled" : "disabled");
2668 vam->retval = retval;
2669 vam->result_ready = 1;
2673 vl_api_show_lisp_status_reply_t_handler_json
2674 (vl_api_show_lisp_status_reply_t * mp)
2676 vat_main_t *vam = &vat_main;
2677 vat_json_node_t node;
2678 u8 *gpe_status = NULL;
2679 u8 *feature_status = NULL;
2681 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
2682 feature_status = format (0, "%s",
2683 mp->feature_status ? "enabled" : "disabled");
2684 vec_add1 (gpe_status, 0);
2685 vec_add1 (feature_status, 0);
2687 vat_json_init_object (&node);
2688 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
2689 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
2691 vec_free (gpe_status);
2692 vec_free (feature_status);
2694 vat_json_print (vam->ofp, &node);
2695 vat_json_free (&node);
2697 vam->retval = ntohl (mp->retval);
2698 vam->result_ready = 1;
2702 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler
2703 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2705 vat_main_t *vam = &vat_main;
2706 i32 retval = ntohl (mp->retval);
2710 fformat (vam->ofp, "%=20s\n", mp->locator_set_name);
2713 vam->retval = retval;
2714 vam->result_ready = 1;
2718 vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler_json
2719 (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
2721 vat_main_t *vam = &vat_main;
2722 vat_json_node_t *node = NULL;
2724 if (VAT_JSON_ARRAY != vam->json_tree.type)
2726 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2727 vat_json_init_array (&vam->json_tree);
2729 node = vat_json_array_add (&vam->json_tree);
2731 vat_json_init_object (node);
2732 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
2734 vat_json_print (vam->ofp, node);
2735 vat_json_free (node);
2737 vam->retval = ntohl (mp->retval);
2738 vam->result_ready = 1;
2742 format_lisp_map_request_mode (u8 * s, va_list * args)
2744 u32 mode = va_arg (*args, u32);
2749 return format (0, "dst-only");
2751 return format (0, "src-dst");
2757 vl_api_show_lisp_map_request_mode_reply_t_handler
2758 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2760 vat_main_t *vam = &vat_main;
2761 i32 retval = ntohl (mp->retval);
2765 u32 mode = mp->mode;
2766 fformat (vam->ofp, "map_request_mode: %U\n",
2767 format_lisp_map_request_mode, mode);
2770 vam->retval = retval;
2771 vam->result_ready = 1;
2775 vl_api_show_lisp_map_request_mode_reply_t_handler_json
2776 (vl_api_show_lisp_map_request_mode_reply_t * mp)
2778 vat_main_t *vam = &vat_main;
2779 vat_json_node_t node;
2784 s = format (0, "%U", format_lisp_map_request_mode, mode);
2787 vat_json_init_object (&node);
2788 vat_json_object_add_string_copy (&node, "map_request_mode", s);
2789 vat_json_print (vam->ofp, &node);
2790 vat_json_free (&node);
2793 vam->retval = ntohl (mp->retval);
2794 vam->result_ready = 1;
2798 vl_api_show_lisp_pitr_reply_t_handler (vl_api_show_lisp_pitr_reply_t * mp)
2800 vat_main_t *vam = &vat_main;
2801 i32 retval = ntohl (mp->retval);
2805 fformat (vam->ofp, "%-20s%-16s\n",
2806 mp->status ? "enabled" : "disabled",
2807 mp->status ? (char *) mp->locator_set_name : "");
2810 vam->retval = retval;
2811 vam->result_ready = 1;
2815 vl_api_show_lisp_pitr_reply_t_handler_json (vl_api_show_lisp_pitr_reply_t *
2818 vat_main_t *vam = &vat_main;
2819 vat_json_node_t node;
2822 status = format (0, "%s", mp->status ? "enabled" : "disabled");
2823 vec_add1 (status, 0);
2825 vat_json_init_object (&node);
2826 vat_json_object_add_string_copy (&node, "status", status);
2829 vat_json_object_add_string_copy (&node, "locator_set",
2830 mp->locator_set_name);
2835 vat_json_print (vam->ofp, &node);
2836 vat_json_free (&node);
2838 vam->retval = ntohl (mp->retval);
2839 vam->result_ready = 1;
2843 format_policer_type (u8 * s, va_list * va)
2845 u32 i = va_arg (*va, u32);
2847 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
2848 s = format (s, "1r2c");
2849 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
2850 s = format (s, "1r3c");
2851 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
2852 s = format (s, "2r3c-2698");
2853 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
2854 s = format (s, "2r3c-4115");
2855 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
2856 s = format (s, "2r3c-mef5cf1");
2858 s = format (s, "ILLEGAL");
2863 format_policer_rate_type (u8 * s, va_list * va)
2865 u32 i = va_arg (*va, u32);
2867 if (i == SSE2_QOS_RATE_KBPS)
2868 s = format (s, "kbps");
2869 else if (i == SSE2_QOS_RATE_PPS)
2870 s = format (s, "pps");
2872 s = format (s, "ILLEGAL");
2877 format_policer_round_type (u8 * s, va_list * va)
2879 u32 i = va_arg (*va, u32);
2881 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
2882 s = format (s, "closest");
2883 else if (i == SSE2_QOS_ROUND_TO_UP)
2884 s = format (s, "up");
2885 else if (i == SSE2_QOS_ROUND_TO_DOWN)
2886 s = format (s, "down");
2888 s = format (s, "ILLEGAL");
2893 format_policer_action_type (u8 * s, va_list * va)
2895 u32 i = va_arg (*va, u32);
2897 if (i == SSE2_QOS_ACTION_DROP)
2898 s = format (s, "drop");
2899 else if (i == SSE2_QOS_ACTION_TRANSMIT)
2900 s = format (s, "transmit");
2901 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2902 s = format (s, "mark-and-transmit");
2904 s = format (s, "ILLEGAL");
2909 format_dscp (u8 * s, va_list * va)
2911 u32 i = va_arg (*va, u32);
2916 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
2920 return format (s, "ILLEGAL");
2922 s = format (s, "%s", t);
2927 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
2929 vat_main_t *vam = &vat_main;
2930 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
2932 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2933 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
2935 conform_dscp_str = format (0, "");
2937 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2938 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
2940 exceed_dscp_str = format (0, "");
2942 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2943 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
2945 violate_dscp_str = format (0, "");
2947 fformat (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
2948 "rate type %U, round type %U, %s rate, %s color-aware, "
2949 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
2950 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
2951 "conform action %U%s, exceed action %U%s, violate action %U%s\n",
2953 format_policer_type, mp->type,
2956 clib_net_to_host_u64 (mp->cb),
2957 clib_net_to_host_u64 (mp->eb),
2958 format_policer_rate_type, mp->rate_type,
2959 format_policer_round_type, mp->round_type,
2960 mp->single_rate ? "single" : "dual",
2961 mp->color_aware ? "is" : "not",
2962 ntohl (mp->cir_tokens_per_period),
2963 ntohl (mp->pir_tokens_per_period),
2965 ntohl (mp->current_limit),
2966 ntohl (mp->current_bucket),
2967 ntohl (mp->extended_limit),
2968 ntohl (mp->extended_bucket),
2969 clib_net_to_host_u64 (mp->last_update_time),
2970 format_policer_action_type, mp->conform_action_type,
2972 format_policer_action_type, mp->exceed_action_type,
2974 format_policer_action_type, mp->violate_action_type,
2977 vec_free (conform_dscp_str);
2978 vec_free (exceed_dscp_str);
2979 vec_free (violate_dscp_str);
2982 static void vl_api_policer_details_t_handler_json
2983 (vl_api_policer_details_t * mp)
2985 vat_main_t *vam = &vat_main;
2986 vat_json_node_t *node;
2987 u8 *rate_type_str, *round_type_str, *type_str;
2988 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
2990 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
2992 format (0, "%U", format_policer_round_type, mp->round_type);
2993 type_str = format (0, "%U", format_policer_type, mp->type);
2994 conform_action_str = format (0, "%U", format_policer_action_type,
2995 mp->conform_action_type);
2996 exceed_action_str = format (0, "%U", format_policer_action_type,
2997 mp->exceed_action_type);
2998 violate_action_str = format (0, "%U", format_policer_action_type,
2999 mp->violate_action_type);
3001 if (VAT_JSON_ARRAY != vam->json_tree.type)
3003 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3004 vat_json_init_array (&vam->json_tree);
3006 node = vat_json_array_add (&vam->json_tree);
3008 vat_json_init_object (node);
3009 vat_json_object_add_string_copy (node, "name", mp->name);
3010 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3011 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3012 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3013 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3014 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3015 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3016 vat_json_object_add_string_copy (node, "type", type_str);
3017 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3018 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3019 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3020 vat_json_object_add_uint (node, "cir_tokens_per_period",
3021 ntohl (mp->cir_tokens_per_period));
3022 vat_json_object_add_uint (node, "eir_tokens_per_period",
3023 ntohl (mp->pir_tokens_per_period));
3024 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3025 vat_json_object_add_uint (node, "current_bucket",
3026 ntohl (mp->current_bucket));
3027 vat_json_object_add_uint (node, "extended_limit",
3028 ntohl (mp->extended_limit));
3029 vat_json_object_add_uint (node, "extended_bucket",
3030 ntohl (mp->extended_bucket));
3031 vat_json_object_add_uint (node, "last_update_time",
3032 ntohl (mp->last_update_time));
3033 vat_json_object_add_string_copy (node, "conform_action",
3034 conform_action_str);
3035 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3037 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3038 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3039 vec_free (dscp_str);
3041 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3042 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3044 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3045 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3046 vec_free (dscp_str);
3048 vat_json_object_add_string_copy (node, "violate_action",
3049 violate_action_str);
3050 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3052 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3053 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3054 vec_free (dscp_str);
3057 vec_free (rate_type_str);
3058 vec_free (round_type_str);
3059 vec_free (type_str);
3060 vec_free (conform_action_str);
3061 vec_free (exceed_action_str);
3062 vec_free (violate_action_str);
3066 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3069 vat_main_t *vam = &vat_main;
3070 int i, count = ntohl (mp->count);
3073 fformat (vam->ofp, "classify table ids (%d) : ", count);
3074 for (i = 0; i < count; i++)
3076 fformat (vam->ofp, "%d", ntohl (mp->ids[i]));
3077 fformat (vam->ofp, (i < count - 1) ? "," : "\n");
3079 vam->retval = ntohl (mp->retval);
3080 vam->result_ready = 1;
3084 vl_api_classify_table_ids_reply_t_handler_json
3085 (vl_api_classify_table_ids_reply_t * mp)
3087 vat_main_t *vam = &vat_main;
3088 int i, count = ntohl (mp->count);
3092 vat_json_node_t node;
3094 vat_json_init_object (&node);
3095 for (i = 0; i < count; i++)
3097 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3099 vat_json_print (vam->ofp, &node);
3100 vat_json_free (&node);
3102 vam->retval = ntohl (mp->retval);
3103 vam->result_ready = 1;
3107 vl_api_classify_table_by_interface_reply_t_handler
3108 (vl_api_classify_table_by_interface_reply_t * mp)
3110 vat_main_t *vam = &vat_main;
3113 table_id = ntohl (mp->l2_table_id);
3115 fformat (vam->ofp, "l2 table id : %d\n", table_id);
3117 fformat (vam->ofp, "l2 table id : No input ACL tables configured\n");
3118 table_id = ntohl (mp->ip4_table_id);
3120 fformat (vam->ofp, "ip4 table id : %d\n", table_id);
3122 fformat (vam->ofp, "ip4 table id : No input ACL tables configured\n");
3123 table_id = ntohl (mp->ip6_table_id);
3125 fformat (vam->ofp, "ip6 table id : %d\n", table_id);
3127 fformat (vam->ofp, "ip6 table id : No input ACL tables configured\n");
3128 vam->retval = ntohl (mp->retval);
3129 vam->result_ready = 1;
3133 vl_api_classify_table_by_interface_reply_t_handler_json
3134 (vl_api_classify_table_by_interface_reply_t * mp)
3136 vat_main_t *vam = &vat_main;
3137 vat_json_node_t node;
3139 vat_json_init_object (&node);
3141 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3142 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3143 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3145 vat_json_print (vam->ofp, &node);
3146 vat_json_free (&node);
3148 vam->retval = ntohl (mp->retval);
3149 vam->result_ready = 1;
3152 static void vl_api_policer_add_del_reply_t_handler
3153 (vl_api_policer_add_del_reply_t * mp)
3155 vat_main_t *vam = &vat_main;
3156 i32 retval = ntohl (mp->retval);
3157 if (vam->async_mode)
3159 vam->async_errors += (retval < 0);
3163 vam->retval = retval;
3164 vam->result_ready = 1;
3165 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3167 * Note: this is just barely thread-safe, depends on
3168 * the main thread spinning waiting for an answer...
3170 errmsg ("policer index %d\n", ntohl (mp->policer_index));
3174 static void vl_api_policer_add_del_reply_t_handler_json
3175 (vl_api_policer_add_del_reply_t * mp)
3177 vat_main_t *vam = &vat_main;
3178 vat_json_node_t node;
3180 vat_json_init_object (&node);
3181 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3182 vat_json_object_add_uint (&node, "policer_index",
3183 ntohl (mp->policer_index));
3185 vat_json_print (vam->ofp, &node);
3186 vat_json_free (&node);
3188 vam->retval = ntohl (mp->retval);
3189 vam->result_ready = 1;
3192 /* Format hex dump. */
3194 format_hex_bytes (u8 * s, va_list * va)
3196 u8 *bytes = va_arg (*va, u8 *);
3197 int n_bytes = va_arg (*va, int);
3200 /* Print short or long form depending on byte count. */
3201 uword short_form = n_bytes <= 32;
3202 uword indent = format_get_indent (s);
3207 for (i = 0; i < n_bytes; i++)
3209 if (!short_form && (i % 32) == 0)
3210 s = format (s, "%08x: ", i);
3211 s = format (s, "%02x", bytes[i]);
3212 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3213 s = format (s, "\n%U", format_white_space, indent);
3220 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3223 vat_main_t *vam = &vat_main;
3224 i32 retval = ntohl (mp->retval);
3227 fformat (vam->ofp, "classify table info :\n");
3228 fformat (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d\n",
3229 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3230 ntohl (mp->miss_next_index));
3231 fformat (vam->ofp, "nbuckets: %d skip: %d match: %d\n",
3232 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3233 ntohl (mp->match_n_vectors));
3234 fformat (vam->ofp, "mask: %U\n", format_hex_bytes, mp->mask,
3235 ntohl (mp->mask_length));
3237 vam->retval = retval;
3238 vam->result_ready = 1;
3242 vl_api_classify_table_info_reply_t_handler_json
3243 (vl_api_classify_table_info_reply_t * mp)
3245 vat_main_t *vam = &vat_main;
3246 vat_json_node_t node;
3248 i32 retval = ntohl (mp->retval);
3251 vat_json_init_object (&node);
3253 vat_json_object_add_int (&node, "sessions",
3254 ntohl (mp->active_sessions));
3255 vat_json_object_add_int (&node, "nexttbl",
3256 ntohl (mp->next_table_index));
3257 vat_json_object_add_int (&node, "nextnode",
3258 ntohl (mp->miss_next_index));
3259 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3260 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3261 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3262 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3263 ntohl (mp->mask_length), 0);
3264 vat_json_object_add_string_copy (&node, "mask", s);
3266 vat_json_print (vam->ofp, &node);
3267 vat_json_free (&node);
3269 vam->retval = ntohl (mp->retval);
3270 vam->result_ready = 1;
3274 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3277 vat_main_t *vam = &vat_main;
3279 fformat (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3280 ntohl (mp->hit_next_index), ntohl (mp->advance),
3281 ntohl (mp->opaque_index));
3282 fformat (vam->ofp, "mask: %U\n", format_hex_bytes, mp->match,
3283 ntohl (mp->match_length));
3287 vl_api_classify_session_details_t_handler_json
3288 (vl_api_classify_session_details_t * mp)
3290 vat_main_t *vam = &vat_main;
3291 vat_json_node_t *node = NULL;
3293 if (VAT_JSON_ARRAY != vam->json_tree.type)
3295 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3296 vat_json_init_array (&vam->json_tree);
3298 node = vat_json_array_add (&vam->json_tree);
3300 vat_json_init_object (node);
3301 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3302 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3303 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3305 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3307 vat_json_object_add_string_copy (node, "match", s);
3310 static void vl_api_pg_create_interface_reply_t_handler
3311 (vl_api_pg_create_interface_reply_t * mp)
3313 vat_main_t *vam = &vat_main;
3315 vam->retval = ntohl (mp->retval);
3316 vam->result_ready = 1;
3319 static void vl_api_pg_create_interface_reply_t_handler_json
3320 (vl_api_pg_create_interface_reply_t * mp)
3322 vat_main_t *vam = &vat_main;
3323 vat_json_node_t node;
3325 i32 retval = ntohl (mp->retval);
3328 vat_json_init_object (&node);
3330 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3332 vat_json_print (vam->ofp, &node);
3333 vat_json_free (&node);
3335 vam->retval = ntohl (mp->retval);
3336 vam->result_ready = 1;
3339 static void vl_api_policer_classify_details_t_handler
3340 (vl_api_policer_classify_details_t * mp)
3342 vat_main_t *vam = &vat_main;
3344 fformat (vam->ofp, "%10d%20d\n", ntohl (mp->sw_if_index),
3345 ntohl (mp->table_index));
3348 static void vl_api_policer_classify_details_t_handler_json
3349 (vl_api_policer_classify_details_t * mp)
3351 vat_main_t *vam = &vat_main;
3352 vat_json_node_t *node;
3354 if (VAT_JSON_ARRAY != vam->json_tree.type)
3356 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3357 vat_json_init_array (&vam->json_tree);
3359 node = vat_json_array_add (&vam->json_tree);
3361 vat_json_init_object (node);
3362 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3363 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3366 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3367 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3369 vat_main_t *vam = &vat_main;
3370 i32 retval = ntohl (mp->retval);
3371 if (vam->async_mode)
3373 vam->async_errors += (retval < 0);
3377 vam->retval = retval;
3378 vam->sw_if_index = ntohl (mp->sw_if_index);
3379 vam->result_ready = 1;
3383 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3384 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3386 vat_main_t *vam = &vat_main;
3387 vat_json_node_t node;
3389 vat_json_init_object (&node);
3390 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3391 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3393 vat_json_print (vam->ofp, &node);
3394 vat_json_free (&node);
3396 vam->retval = ntohl (mp->retval);
3397 vam->result_ready = 1;
3400 static void vl_api_flow_classify_details_t_handler
3401 (vl_api_flow_classify_details_t * mp)
3403 vat_main_t *vam = &vat_main;
3405 fformat (vam->ofp, "%10d%20d\n", ntohl (mp->sw_if_index),
3406 ntohl (mp->table_index));
3409 static void vl_api_flow_classify_details_t_handler_json
3410 (vl_api_flow_classify_details_t * mp)
3412 vat_main_t *vam = &vat_main;
3413 vat_json_node_t *node;
3415 if (VAT_JSON_ARRAY != vam->json_tree.type)
3417 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3418 vat_json_init_array (&vam->json_tree);
3420 node = vat_json_array_add (&vam->json_tree);
3422 vat_json_init_object (node);
3423 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3424 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3429 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3430 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3431 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3432 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3433 #define vl_api_lisp_adjacencies_get_reply_t_endian vl_noop_handler
3434 #define vl_api_lisp_adjacencies_get_reply_t_print vl_noop_handler
3437 * Generate boilerplate reply handlers, which
3438 * dig the return value out of the xxx_reply_t API message,
3439 * stick it into vam->retval, and set vam->result_ready
3441 * Could also do this by pointing N message decode slots at
3442 * a single function, but that could break in subtle ways.
3445 #define foreach_standard_reply_retval_handler \
3446 _(sw_interface_set_flags_reply) \
3447 _(sw_interface_add_del_address_reply) \
3448 _(sw_interface_set_table_reply) \
3449 _(sw_interface_set_mpls_enable_reply) \
3450 _(sw_interface_set_vpath_reply) \
3451 _(sw_interface_set_vxlan_bypass_reply) \
3452 _(sw_interface_set_l2_bridge_reply) \
3453 _(sw_interface_set_dpdk_hqos_pipe_reply) \
3454 _(sw_interface_set_dpdk_hqos_subport_reply) \
3455 _(sw_interface_set_dpdk_hqos_tctbl_reply) \
3456 _(bridge_domain_add_del_reply) \
3457 _(sw_interface_set_l2_xconnect_reply) \
3458 _(l2fib_add_del_reply) \
3459 _(ip_add_del_route_reply) \
3460 _(mpls_route_add_del_reply) \
3461 _(mpls_ip_bind_unbind_reply) \
3462 _(proxy_arp_add_del_reply) \
3463 _(proxy_arp_intfc_enable_disable_reply) \
3464 _(sw_interface_set_unnumbered_reply) \
3465 _(ip_neighbor_add_del_reply) \
3466 _(reset_vrf_reply) \
3467 _(oam_add_del_reply) \
3468 _(reset_fib_reply) \
3469 _(dhcp_proxy_config_reply) \
3470 _(dhcp_proxy_config_2_reply) \
3471 _(dhcp_proxy_set_vss_reply) \
3472 _(dhcp_client_config_reply) \
3473 _(set_ip_flow_hash_reply) \
3474 _(sw_interface_ip6_enable_disable_reply) \
3475 _(sw_interface_ip6_set_link_local_address_reply) \
3476 _(sw_interface_ip6nd_ra_prefix_reply) \
3477 _(sw_interface_ip6nd_ra_config_reply) \
3478 _(set_arp_neighbor_limit_reply) \
3479 _(l2_patch_add_del_reply) \
3480 _(sr_tunnel_add_del_reply) \
3481 _(sr_policy_add_del_reply) \
3482 _(sr_multicast_map_add_del_reply) \
3483 _(classify_add_del_session_reply) \
3484 _(classify_set_interface_ip_table_reply) \
3485 _(classify_set_interface_l2_tables_reply) \
3486 _(l2tpv3_set_tunnel_cookies_reply) \
3487 _(l2tpv3_interface_enable_disable_reply) \
3488 _(l2tpv3_set_lookup_key_reply) \
3489 _(l2_fib_clear_table_reply) \
3490 _(l2_interface_efp_filter_reply) \
3491 _(l2_interface_vlan_tag_rewrite_reply) \
3492 _(modify_vhost_user_if_reply) \
3493 _(delete_vhost_user_if_reply) \
3494 _(want_ip4_arp_events_reply) \
3495 _(want_ip6_nd_events_reply) \
3496 _(input_acl_set_interface_reply) \
3497 _(ipsec_spd_add_del_reply) \
3498 _(ipsec_interface_add_del_spd_reply) \
3499 _(ipsec_spd_add_del_entry_reply) \
3500 _(ipsec_sad_add_del_entry_reply) \
3501 _(ipsec_sa_set_key_reply) \
3502 _(ikev2_profile_add_del_reply) \
3503 _(ikev2_profile_set_auth_reply) \
3504 _(ikev2_profile_set_id_reply) \
3505 _(ikev2_profile_set_ts_reply) \
3506 _(ikev2_set_local_key_reply) \
3507 _(delete_loopback_reply) \
3508 _(bd_ip_mac_add_del_reply) \
3509 _(map_del_domain_reply) \
3510 _(map_add_del_rule_reply) \
3511 _(want_interface_events_reply) \
3512 _(want_stats_reply) \
3513 _(cop_interface_enable_disable_reply) \
3514 _(cop_whitelist_enable_disable_reply) \
3515 _(sw_interface_clear_stats_reply) \
3516 _(ioam_enable_reply) \
3517 _(ioam_disable_reply) \
3518 _(lisp_add_del_locator_reply) \
3519 _(lisp_add_del_local_eid_reply) \
3520 _(lisp_add_del_remote_mapping_reply) \
3521 _(lisp_add_del_adjacency_reply) \
3522 _(lisp_gpe_add_del_fwd_entry_reply) \
3523 _(lisp_add_del_map_resolver_reply) \
3524 _(lisp_gpe_enable_disable_reply) \
3525 _(lisp_gpe_add_del_iface_reply) \
3526 _(lisp_enable_disable_reply) \
3527 _(lisp_pitr_set_locator_set_reply) \
3528 _(lisp_map_request_mode_reply) \
3529 _(lisp_add_del_map_request_itr_rlocs_reply) \
3530 _(lisp_eid_table_add_del_map_reply) \
3531 _(vxlan_gpe_add_del_tunnel_reply) \
3532 _(af_packet_delete_reply) \
3533 _(policer_classify_set_interface_reply) \
3534 _(netmap_create_reply) \
3535 _(netmap_delete_reply) \
3536 _(set_ipfix_exporter_reply) \
3537 _(set_ipfix_classify_stream_reply) \
3538 _(ipfix_classify_table_add_del_reply) \
3539 _(flow_classify_set_interface_reply) \
3540 _(sw_interface_span_enable_disable_reply) \
3541 _(pg_capture_reply) \
3542 _(pg_enable_disable_reply) \
3543 _(ip_source_and_port_range_check_add_del_reply) \
3544 _(ip_source_and_port_range_check_interface_add_del_reply)\
3545 _(delete_subif_reply) \
3546 _(l2_interface_pbb_tag_rewrite_reply) \
3548 _(feature_enable_disable_reply) \
3549 _(sw_interface_tag_add_del_reply)
3552 static void vl_api_##n##_t_handler \
3553 (vl_api_##n##_t * mp) \
3555 vat_main_t * vam = &vat_main; \
3556 i32 retval = ntohl(mp->retval); \
3557 if (vam->async_mode) { \
3558 vam->async_errors += (retval < 0); \
3560 vam->retval = retval; \
3561 vam->result_ready = 1; \
3564 foreach_standard_reply_retval_handler;
3568 static void vl_api_##n##_t_handler_json \
3569 (vl_api_##n##_t * mp) \
3571 vat_main_t * vam = &vat_main; \
3572 vat_json_node_t node; \
3573 vat_json_init_object(&node); \
3574 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3575 vat_json_print(vam->ofp, &node); \
3576 vam->retval = ntohl(mp->retval); \
3577 vam->result_ready = 1; \
3579 foreach_standard_reply_retval_handler;
3583 * Table of message reply handlers, must include boilerplate handlers
3587 #define foreach_vpe_api_reply_msg \
3588 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3589 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3590 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
3591 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3592 _(CONTROL_PING_REPLY, control_ping_reply) \
3593 _(CLI_REPLY, cli_reply) \
3594 _(CLI_INBAND_REPLY, cli_inband_reply) \
3595 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
3596 sw_interface_add_del_address_reply) \
3597 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
3598 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
3599 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
3600 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
3601 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
3602 sw_interface_set_l2_xconnect_reply) \
3603 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
3604 sw_interface_set_l2_bridge_reply) \
3605 _(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
3606 sw_interface_set_dpdk_hqos_pipe_reply) \
3607 _(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
3608 sw_interface_set_dpdk_hqos_subport_reply) \
3609 _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
3610 sw_interface_set_dpdk_hqos_tctbl_reply) \
3611 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
3612 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
3613 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
3614 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
3615 _(L2_FLAGS_REPLY, l2_flags_reply) \
3616 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
3617 _(TAP_CONNECT_REPLY, tap_connect_reply) \
3618 _(TAP_MODIFY_REPLY, tap_modify_reply) \
3619 _(TAP_DELETE_REPLY, tap_delete_reply) \
3620 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
3621 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
3622 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
3623 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
3624 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
3625 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
3626 proxy_arp_intfc_enable_disable_reply) \
3627 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
3628 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
3629 sw_interface_set_unnumbered_reply) \
3630 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
3631 _(RESET_VRF_REPLY, reset_vrf_reply) \
3632 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
3633 _(CREATE_SUBIF_REPLY, create_subif_reply) \
3634 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
3635 _(RESET_FIB_REPLY, reset_fib_reply) \
3636 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
3637 _(DHCP_PROXY_CONFIG_2_REPLY, dhcp_proxy_config_2_reply) \
3638 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
3639 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
3640 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
3641 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
3642 sw_interface_ip6_enable_disable_reply) \
3643 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
3644 sw_interface_ip6_set_link_local_address_reply) \
3645 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
3646 sw_interface_ip6nd_ra_prefix_reply) \
3647 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
3648 sw_interface_ip6nd_ra_config_reply) \
3649 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
3650 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
3651 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
3652 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
3653 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
3654 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
3655 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
3656 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
3657 classify_set_interface_ip_table_reply) \
3658 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
3659 classify_set_interface_l2_tables_reply) \
3660 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
3661 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
3662 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
3663 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
3664 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
3665 l2tpv3_interface_enable_disable_reply) \
3666 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
3667 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
3668 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
3669 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
3670 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
3671 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
3672 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
3673 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
3674 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
3675 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
3676 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
3677 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
3678 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
3679 _(SHOW_VERSION_REPLY, show_version_reply) \
3680 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
3681 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
3682 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
3683 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
3684 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
3685 _(IP4_ARP_EVENT, ip4_arp_event) \
3686 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
3687 _(IP6_ND_EVENT, ip6_nd_event) \
3688 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
3689 _(IP_ADDRESS_DETAILS, ip_address_details) \
3690 _(IP_DETAILS, ip_details) \
3691 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
3692 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
3693 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
3694 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
3695 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
3696 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
3697 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
3698 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
3699 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
3700 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
3701 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
3702 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
3703 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
3704 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
3705 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
3706 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
3707 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
3708 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
3709 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
3710 _(MAP_DOMAIN_DETAILS, map_domain_details) \
3711 _(MAP_RULE_DETAILS, map_rule_details) \
3712 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
3713 _(WANT_STATS_REPLY, want_stats_reply) \
3714 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
3715 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
3716 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
3717 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
3718 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
3719 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
3720 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
3721 _(LISP_ADD_DEL_LOCATOR_SET_REPLY, lisp_add_del_locator_set_reply) \
3722 _(LISP_ADD_DEL_LOCATOR_REPLY, lisp_add_del_locator_reply) \
3723 _(LISP_ADD_DEL_LOCAL_EID_REPLY, lisp_add_del_local_eid_reply) \
3724 _(LISP_ADD_DEL_REMOTE_MAPPING_REPLY, lisp_add_del_remote_mapping_reply) \
3725 _(LISP_ADD_DEL_ADJACENCY_REPLY, lisp_add_del_adjacency_reply) \
3726 _(LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY, lisp_gpe_add_del_fwd_entry_reply) \
3727 _(LISP_ADD_DEL_MAP_RESOLVER_REPLY, lisp_add_del_map_resolver_reply) \
3728 _(LISP_GPE_ENABLE_DISABLE_REPLY, lisp_gpe_enable_disable_reply) \
3729 _(LISP_ENABLE_DISABLE_REPLY, lisp_enable_disable_reply) \
3730 _(LISP_PITR_SET_LOCATOR_SET_REPLY, lisp_pitr_set_locator_set_reply) \
3731 _(LISP_MAP_REQUEST_MODE_REPLY, lisp_map_request_mode_reply) \
3732 _(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \
3733 _(LISP_GPE_ADD_DEL_IFACE_REPLY, lisp_gpe_add_del_iface_reply) \
3734 _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \
3735 _(LISP_LOCATOR_DETAILS, lisp_locator_details) \
3736 _(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \
3737 _(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \
3738 _(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \
3739 _(LISP_GPE_TUNNEL_DETAILS, lisp_gpe_tunnel_details) \
3740 _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
3741 _(LISP_ADJACENCIES_GET_REPLY, lisp_adjacencies_get_reply) \
3742 _(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
3743 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
3744 lisp_add_del_map_request_itr_rlocs_reply) \
3745 _(LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
3746 lisp_get_map_request_itr_rlocs_reply) \
3747 _(SHOW_LISP_PITR_REPLY, show_lisp_pitr_reply) \
3748 _(SHOW_LISP_MAP_REQUEST_MODE_REPLY, show_lisp_map_request_mode_reply) \
3749 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
3750 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
3751 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
3752 _(POLICER_DETAILS, policer_details) \
3753 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
3754 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
3755 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
3756 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
3757 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
3758 _(MPLS_FIB_DETAILS, mpls_fib_details) \
3759 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
3760 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
3761 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
3762 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
3763 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
3764 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
3765 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
3766 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
3767 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
3768 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
3769 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
3770 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
3771 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
3772 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
3773 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
3774 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
3775 _(PG_CAPTURE_REPLY, pg_capture_reply) \
3776 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
3777 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
3778 ip_source_and_port_range_check_add_del_reply) \
3779 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
3780 ip_source_and_port_range_check_interface_add_del_reply) \
3781 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
3782 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
3783 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
3784 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
3785 _(PUNT_REPLY, punt_reply) \
3786 _(IP_FIB_DETAILS, ip_fib_details) \
3787 _(IP6_FIB_DETAILS, ip6_fib_details) \
3788 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
3789 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
3790 _(L2_XCONNECT_DETAILS, l2_xconnect_details)
3792 /* M: construct, but don't yet send a message */
3796 vam->result_ready = 0; \
3797 mp = vl_msg_api_alloc(sizeof(*mp)); \
3798 memset (mp, 0, sizeof (*mp)); \
3799 mp->_vl_msg_id = ntohs (VL_API_##T); \
3800 mp->client_index = vam->my_client_index; \
3805 vam->result_ready = 0; \
3806 mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
3807 memset (mp, 0, sizeof (*mp)); \
3808 mp->_vl_msg_id = ntohs (VL_API_##T); \
3809 mp->client_index = vam->my_client_index; \
3813 /* S: send a message */
3814 #define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
3816 /* W: wait for results, with timeout */
3819 timeout = vat_time_now (vam) + 1.0; \
3821 while (vat_time_now (vam) < timeout) { \
3822 if (vam->result_ready == 1) { \
3823 return (vam->retval); \
3829 /* W2: wait for results, with timeout */
3832 timeout = vat_time_now (vam) + 1.0; \
3834 while (vat_time_now (vam) < timeout) { \
3835 if (vam->result_ready == 1) { \
3837 return (vam->retval); \
3850 #define STR_VTR_OP_CASE(op) \
3851 case L2_VTR_ ## op: \
3855 str_vtr_op (u32 vtr_op)
3859 STR_VTR_OP_CASE (DISABLED);
3860 STR_VTR_OP_CASE (PUSH_1);
3861 STR_VTR_OP_CASE (PUSH_2);
3862 STR_VTR_OP_CASE (POP_1);
3863 STR_VTR_OP_CASE (POP_2);
3864 STR_VTR_OP_CASE (TRANSLATE_1_1);
3865 STR_VTR_OP_CASE (TRANSLATE_1_2);
3866 STR_VTR_OP_CASE (TRANSLATE_2_1);
3867 STR_VTR_OP_CASE (TRANSLATE_2_2);
3874 dump_sub_interface_table (vat_main_t * vam)
3876 const sw_interface_subif_t *sub = NULL;
3878 if (vam->json_output)
3881 ("JSON output supported only for VPE API calls and dump_stats_table");
3886 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s\n",
3887 "Interface", "sw_if_index",
3888 "sub id", "dot1ad", "tags", "outer id",
3889 "inner id", "exact", "default", "outer any", "inner any");
3891 vec_foreach (sub, vam->sw_if_subif_table)
3894 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d\n",
3895 sub->interface_name,
3897 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
3898 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
3899 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
3900 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
3901 if (sub->vtr_op != L2_VTR_DISABLED)
3904 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
3905 "tag1: %d tag2: %d ]\n",
3906 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
3907 sub->vtr_tag1, sub->vtr_tag2);
3915 name_sort_cmp (void *a1, void *a2)
3917 name_sort_t *n1 = a1;
3918 name_sort_t *n2 = a2;
3920 return strcmp ((char *) n1->name, (char *) n2->name);
3924 dump_interface_table (vat_main_t * vam)
3927 name_sort_t *nses = 0, *ns;
3929 if (vam->json_output)
3932 ("JSON output supported only for VPE API calls and dump_stats_table");
3937 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
3939 vec_add2 (nses, ns, 1);
3940 ns->name = (u8 *)(p->key);
3941 ns->value = (u32) p->value[0];
3945 vec_sort_with_function (nses, name_sort_cmp);
3947 fformat (vam->ofp, "%-25s%-15s\n", "Interface", "sw_if_index");
3948 vec_foreach (ns, nses)
3950 fformat (vam->ofp, "%-25s%-15d\n", ns->name, ns->value);
3957 dump_ip_table (vat_main_t * vam, int is_ipv6)
3959 const ip_details_t *det = NULL;
3960 const ip_address_details_t *address = NULL;
3963 fformat (vam->ofp, "%-12s\n", "sw_if_index");
3965 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
3972 fformat (vam->ofp, "%-12d\n", i);
3974 " %-30s%-13s\n", "Address", "Prefix length");
3979 vec_foreach (address, det->addr)
3983 is_ipv6 ? format_ip6_address : format_ip4_address,
3984 address->ip, address->prefix_length);
3992 dump_ipv4_table (vat_main_t * vam)
3994 if (vam->json_output)
3997 ("JSON output supported only for VPE API calls and dump_stats_table");
4001 return dump_ip_table (vam, 0);
4005 dump_ipv6_table (vat_main_t * vam)
4007 if (vam->json_output)
4010 ("JSON output supported only for VPE API calls and dump_stats_table");
4014 return dump_ip_table (vam, 1);
4018 counter_type_to_str (u8 counter_type, u8 is_combined)
4022 switch (counter_type)
4024 case VNET_INTERFACE_COUNTER_DROP:
4026 case VNET_INTERFACE_COUNTER_PUNT:
4028 case VNET_INTERFACE_COUNTER_IP4:
4030 case VNET_INTERFACE_COUNTER_IP6:
4032 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4034 case VNET_INTERFACE_COUNTER_RX_MISS:
4036 case VNET_INTERFACE_COUNTER_RX_ERROR:
4038 case VNET_INTERFACE_COUNTER_TX_ERROR:
4041 return "INVALID-COUNTER-TYPE";
4046 switch (counter_type)
4048 case VNET_INTERFACE_COUNTER_RX:
4050 case VNET_INTERFACE_COUNTER_TX:
4053 return "INVALID-COUNTER-TYPE";
4059 dump_stats_table (vat_main_t * vam)
4061 vat_json_node_t node;
4062 vat_json_node_t *msg_array;
4063 vat_json_node_t *msg;
4064 vat_json_node_t *counter_array;
4065 vat_json_node_t *counter;
4066 interface_counter_t c;
4068 ip4_fib_counter_t *c4;
4069 ip6_fib_counter_t *c6;
4072 if (!vam->json_output)
4074 clib_warning ("dump_stats_table supported only in JSON format");
4078 vat_json_init_object (&node);
4080 /* interface counters */
4081 msg_array = vat_json_object_add (&node, "interface_counters");
4082 vat_json_init_array (msg_array);
4083 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4085 msg = vat_json_array_add (msg_array);
4086 vat_json_init_object (msg);
4087 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4088 (u8 *) counter_type_to_str (i, 0));
4089 vat_json_object_add_int (msg, "is_combined", 0);
4090 counter_array = vat_json_object_add (msg, "data");
4091 vat_json_init_array (counter_array);
4092 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4094 packets = vam->simple_interface_counters[i][j];
4095 vat_json_array_add_uint (counter_array, packets);
4098 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4100 msg = vat_json_array_add (msg_array);
4101 vat_json_init_object (msg);
4102 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4103 (u8 *) counter_type_to_str (i, 1));
4104 vat_json_object_add_int (msg, "is_combined", 1);
4105 counter_array = vat_json_object_add (msg, "data");
4106 vat_json_init_array (counter_array);
4107 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4109 c = vam->combined_interface_counters[i][j];
4110 counter = vat_json_array_add (counter_array);
4111 vat_json_init_object (counter);
4112 vat_json_object_add_uint (counter, "packets", c.packets);
4113 vat_json_object_add_uint (counter, "bytes", c.bytes);
4117 /* ip4 fib counters */
4118 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4119 vat_json_init_array (msg_array);
4120 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4122 msg = vat_json_array_add (msg_array);
4123 vat_json_init_object (msg);
4124 vat_json_object_add_uint (msg, "vrf_id",
4125 vam->ip4_fib_counters_vrf_id_by_index[i]);
4126 counter_array = vat_json_object_add (msg, "c");
4127 vat_json_init_array (counter_array);
4128 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4130 counter = vat_json_array_add (counter_array);
4131 vat_json_init_object (counter);
4132 c4 = &vam->ip4_fib_counters[i][j];
4133 vat_json_object_add_ip4 (counter, "address", c4->address);
4134 vat_json_object_add_uint (counter, "address_length",
4135 c4->address_length);
4136 vat_json_object_add_uint (counter, "packets", c4->packets);
4137 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4141 /* ip6 fib counters */
4142 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4143 vat_json_init_array (msg_array);
4144 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4146 msg = vat_json_array_add (msg_array);
4147 vat_json_init_object (msg);
4148 vat_json_object_add_uint (msg, "vrf_id",
4149 vam->ip6_fib_counters_vrf_id_by_index[i]);
4150 counter_array = vat_json_object_add (msg, "c");
4151 vat_json_init_array (counter_array);
4152 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4154 counter = vat_json_array_add (counter_array);
4155 vat_json_init_object (counter);
4156 c6 = &vam->ip6_fib_counters[i][j];
4157 vat_json_object_add_ip6 (counter, "address", c6->address);
4158 vat_json_object_add_uint (counter, "address_length",
4159 c6->address_length);
4160 vat_json_object_add_uint (counter, "packets", c6->packets);
4161 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4165 vat_json_print (vam->ofp, &node);
4166 vat_json_free (&node);
4172 exec (vat_main_t * vam)
4174 api_main_t *am = &api_main;
4175 vl_api_cli_request_t *mp;
4179 unformat_input_t *i = vam->input;
4181 if (vec_len (i->buffer) == 0)
4184 if (vam->exec_mode == 0 && unformat (i, "mode"))
4189 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4196 M (CLI_REQUEST, cli_request);
4199 * Copy cmd into shared memory.
4200 * In order for the CLI command to work, it
4201 * must be a vector ending in \n, not a C-string ending
4204 pthread_mutex_lock (&am->vlib_rp->mutex);
4205 oldheap = svm_push_data_heap (am->vlib_rp);
4207 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4208 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4210 svm_pop_heap (oldheap);
4211 pthread_mutex_unlock (&am->vlib_rp->mutex);
4213 mp->cmd_in_shmem = (u64) cmd;
4215 timeout = vat_time_now (vam) + 10.0;
4217 while (vat_time_now (vam) < timeout)
4219 if (vam->result_ready == 1)
4222 if (vam->shmem_result != NULL)
4223 fformat (vam->ofp, "%s", vam->shmem_result);
4224 pthread_mutex_lock (&am->vlib_rp->mutex);
4225 oldheap = svm_push_data_heap (am->vlib_rp);
4227 free_me = (u8 *) vam->shmem_result;
4230 svm_pop_heap (oldheap);
4231 pthread_mutex_unlock (&am->vlib_rp->mutex);
4239 * Future replacement of exec() that passes CLI buffers directly in
4240 * the API messages instead of an additional shared memory area.
4243 exec_inband (vat_main_t * vam)
4245 vl_api_cli_inband_t *mp;
4247 unformat_input_t *i = vam->input;
4249 if (vec_len (i->buffer) == 0)
4252 if (vam->exec_mode == 0 && unformat (i, "mode"))
4257 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4264 * In order for the CLI command to work, it
4265 * must be a vector ending in \n, not a C-string ending
4268 u32 len = vec_len (vam->input->buffer);
4269 M2 (CLI_INBAND, cli_inband, len);
4270 clib_memcpy (mp->cmd, vam->input->buffer, len);
4271 mp->length = htonl (len);
4274 W2 (fformat (vam->ofp, "%s", vam->cmd_reply));
4278 api_create_loopback (vat_main_t * vam)
4280 unformat_input_t *i = vam->input;
4281 vl_api_create_loopback_t *mp;
4286 memset (mac_address, 0, sizeof (mac_address));
4288 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4290 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4296 /* Construct the API message */
4297 M (CREATE_LOOPBACK, create_loopback);
4299 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4306 api_delete_loopback (vat_main_t * vam)
4308 unformat_input_t *i = vam->input;
4309 vl_api_delete_loopback_t *mp;
4311 u32 sw_if_index = ~0;
4313 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4315 if (unformat (i, "sw_if_index %d", &sw_if_index))
4321 if (sw_if_index == ~0)
4323 errmsg ("missing sw_if_index\n");
4327 /* Construct the API message */
4328 M (DELETE_LOOPBACK, delete_loopback);
4329 mp->sw_if_index = ntohl (sw_if_index);
4336 api_want_stats (vat_main_t * vam)
4338 unformat_input_t *i = vam->input;
4339 vl_api_want_stats_t *mp;
4343 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4345 if (unformat (i, "enable"))
4347 else if (unformat (i, "disable"))
4355 errmsg ("missing enable|disable\n");
4359 M (WANT_STATS, want_stats);
4360 mp->enable_disable = enable;
4367 api_want_interface_events (vat_main_t * vam)
4369 unformat_input_t *i = vam->input;
4370 vl_api_want_interface_events_t *mp;
4374 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4376 if (unformat (i, "enable"))
4378 else if (unformat (i, "disable"))
4386 errmsg ("missing enable|disable\n");
4390 M (WANT_INTERFACE_EVENTS, want_interface_events);
4391 mp->enable_disable = enable;
4393 vam->interface_event_display = enable;
4400 /* Note: non-static, called once to set up the initial intfc table */
4402 api_sw_interface_dump (vat_main_t * vam)
4404 vl_api_sw_interface_dump_t *mp;
4407 name_sort_t *nses = 0, *ns;
4408 sw_interface_subif_t *sub = NULL;
4410 /* Toss the old name table */
4412 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4414 vec_add2 (nses, ns, 1);
4415 ns->name = (u8 *)(p->key);
4416 ns->value = (u32) p->value[0];
4420 hash_free (vam->sw_if_index_by_interface_name);
4422 vec_foreach (ns, nses) vec_free (ns->name);
4426 vec_foreach (sub, vam->sw_if_subif_table)
4428 vec_free (sub->interface_name);
4430 vec_free (vam->sw_if_subif_table);
4432 /* recreate the interface name hash table */
4433 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4435 /* Get list of ethernets */
4436 M (SW_INTERFACE_DUMP, sw_interface_dump);
4437 mp->name_filter_valid = 1;
4438 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4441 /* and local / loopback interfaces */
4442 M (SW_INTERFACE_DUMP, sw_interface_dump);
4443 mp->name_filter_valid = 1;
4444 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4447 /* and packet-generator interfaces */
4448 M (SW_INTERFACE_DUMP, sw_interface_dump);
4449 mp->name_filter_valid = 1;
4450 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4453 /* and vxlan-gpe tunnel interfaces */
4454 M (SW_INTERFACE_DUMP, sw_interface_dump);
4455 mp->name_filter_valid = 1;
4456 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4457 sizeof (mp->name_filter) - 1);
4460 /* and vxlan tunnel interfaces */
4461 M (SW_INTERFACE_DUMP, sw_interface_dump);
4462 mp->name_filter_valid = 1;
4463 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4466 /* and host (af_packet) interfaces */
4467 M (SW_INTERFACE_DUMP, sw_interface_dump);
4468 mp->name_filter_valid = 1;
4469 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4472 /* and l2tpv3 tunnel interfaces */
4473 M (SW_INTERFACE_DUMP, sw_interface_dump);
4474 mp->name_filter_valid = 1;
4475 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4476 sizeof (mp->name_filter) - 1);
4479 /* and GRE tunnel interfaces */
4480 M (SW_INTERFACE_DUMP, sw_interface_dump);
4481 mp->name_filter_valid = 1;
4482 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4485 /* and LISP-GPE interfaces */
4486 M (SW_INTERFACE_DUMP, sw_interface_dump);
4487 mp->name_filter_valid = 1;
4488 strncpy ((char *) mp->name_filter, "lisp_gpe",
4489 sizeof (mp->name_filter) - 1);
4492 /* and IPSEC tunnel interfaces */
4493 M (SW_INTERFACE_DUMP, sw_interface_dump);
4494 mp->name_filter_valid = 1;
4495 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4498 /* Use a control ping for synchronization */
4500 vl_api_control_ping_t *mp;
4501 M (CONTROL_PING, control_ping);
4508 api_sw_interface_set_flags (vat_main_t * vam)
4510 unformat_input_t *i = vam->input;
4511 vl_api_sw_interface_set_flags_t *mp;
4514 u8 sw_if_index_set = 0;
4515 u8 admin_up = 0, link_up = 0;
4517 /* Parse args required to build the message */
4518 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4520 if (unformat (i, "admin-up"))
4522 else if (unformat (i, "admin-down"))
4524 else if (unformat (i, "link-up"))
4526 else if (unformat (i, "link-down"))
4528 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4529 sw_if_index_set = 1;
4530 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4531 sw_if_index_set = 1;
4536 if (sw_if_index_set == 0)
4538 errmsg ("missing interface name or sw_if_index\n");
4542 /* Construct the API message */
4543 M (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags);
4544 mp->sw_if_index = ntohl (sw_if_index);
4545 mp->admin_up_down = admin_up;
4546 mp->link_up_down = link_up;
4551 /* Wait for a reply, return the good/bad news... */
4556 api_sw_interface_clear_stats (vat_main_t * vam)
4558 unformat_input_t *i = vam->input;
4559 vl_api_sw_interface_clear_stats_t *mp;
4562 u8 sw_if_index_set = 0;
4564 /* Parse args required to build the message */
4565 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4567 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4568 sw_if_index_set = 1;
4569 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4570 sw_if_index_set = 1;
4575 /* Construct the API message */
4576 M (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats);
4578 if (sw_if_index_set == 1)
4579 mp->sw_if_index = ntohl (sw_if_index);
4581 mp->sw_if_index = ~0;
4586 /* Wait for a reply, return the good/bad news... */
4591 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
4593 unformat_input_t *i = vam->input;
4594 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
4597 u8 sw_if_index_set = 0;
4605 /* Parse args required to build the message */
4606 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4608 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4609 sw_if_index_set = 1;
4610 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4611 sw_if_index_set = 1;
4612 else if (unformat (i, "subport %u", &subport))
4614 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4615 sw_if_index_set = 1;
4616 else if (unformat (i, "pipe %u", &pipe))
4618 else if (unformat (i, "profile %u", &profile))
4624 if (sw_if_index_set == 0)
4626 errmsg ("missing interface name or sw_if_index\n");
4630 if (subport_set == 0)
4632 errmsg ("missing subport \n");
4638 errmsg ("missing pipe\n");
4642 if (profile_set == 0)
4644 errmsg ("missing profile\n");
4648 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe);
4650 mp->sw_if_index = ntohl (sw_if_index);
4651 mp->subport = ntohl (subport);
4652 mp->pipe = ntohl (pipe);
4653 mp->profile = ntohl (profile);
4663 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
4665 unformat_input_t *i = vam->input;
4666 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
4669 u8 sw_if_index_set = 0;
4672 u32 tb_rate = 1250000000; /* 10GbE */
4673 u32 tb_size = 1000000;
4674 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
4677 /* Parse args required to build the message */
4678 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4680 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4681 sw_if_index_set = 1;
4682 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4683 sw_if_index_set = 1;
4684 else if (unformat (i, "subport %u", &subport))
4686 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4687 sw_if_index_set = 1;
4688 else if (unformat (i, "rate %u", &tb_rate))
4692 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
4694 tc_rate[tc_id] = tb_rate;
4696 else if (unformat (i, "bktsize %u", &tb_size))
4698 else if (unformat (i, "tc0 %u", &tc_rate[0]))
4700 else if (unformat (i, "tc1 %u", &tc_rate[1]))
4702 else if (unformat (i, "tc2 %u", &tc_rate[2]))
4704 else if (unformat (i, "tc3 %u", &tc_rate[3]))
4706 else if (unformat (i, "period %u", &tc_period))
4712 if (sw_if_index_set == 0)
4714 errmsg ("missing interface name or sw_if_index\n");
4718 if (subport_set == 0)
4720 errmsg ("missing subport \n");
4724 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport);
4726 mp->sw_if_index = ntohl (sw_if_index);
4727 mp->subport = ntohl (subport);
4728 mp->tb_rate = ntohl (tb_rate);
4729 mp->tb_size = ntohl (tb_size);
4730 mp->tc_rate[0] = ntohl (tc_rate[0]);
4731 mp->tc_rate[1] = ntohl (tc_rate[1]);
4732 mp->tc_rate[2] = ntohl (tc_rate[2]);
4733 mp->tc_rate[3] = ntohl (tc_rate[3]);
4734 mp->tc_period = ntohl (tc_period);
4743 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
4745 unformat_input_t *i = vam->input;
4746 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
4749 u8 sw_if_index_set = 0;
4753 u32 entry, tc, queue;
4755 /* Parse args required to build the message */
4756 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4758 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4759 sw_if_index_set = 1;
4760 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4761 sw_if_index_set = 1;
4762 else if (unformat (i, "entry %d", &entry))
4764 else if (unformat (i, "tc %d", &tc))
4766 else if (unformat (i, "queue %d", &queue))
4772 if (sw_if_index_set == 0)
4774 errmsg ("missing interface name or sw_if_index\n");
4780 errmsg ("missing entry \n");
4786 errmsg ("missing traffic class \n");
4792 errmsg ("missing queue \n");
4796 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl);
4798 mp->sw_if_index = ntohl (sw_if_index);
4799 mp->entry = ntohl (entry);
4800 mp->tc = ntohl (tc);
4801 mp->queue = ntohl (queue);
4810 api_sw_interface_add_del_address (vat_main_t * vam)
4812 unformat_input_t *i = vam->input;
4813 vl_api_sw_interface_add_del_address_t *mp;
4816 u8 sw_if_index_set = 0;
4817 u8 is_add = 1, del_all = 0;
4818 u32 address_length = 0;
4819 u8 v4_address_set = 0;
4820 u8 v6_address_set = 0;
4821 ip4_address_t v4address;
4822 ip6_address_t v6address;
4824 /* Parse args required to build the message */
4825 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4827 if (unformat (i, "del-all"))
4829 else if (unformat (i, "del"))
4831 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4832 sw_if_index_set = 1;
4833 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4834 sw_if_index_set = 1;
4835 else if (unformat (i, "%U/%d",
4836 unformat_ip4_address, &v4address, &address_length))
4838 else if (unformat (i, "%U/%d",
4839 unformat_ip6_address, &v6address, &address_length))
4845 if (sw_if_index_set == 0)
4847 errmsg ("missing interface name or sw_if_index\n");
4850 if (v4_address_set && v6_address_set)
4852 errmsg ("both v4 and v6 addresses set\n");
4855 if (!v4_address_set && !v6_address_set && !del_all)
4857 errmsg ("no addresses set\n");
4861 /* Construct the API message */
4862 M (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address);
4864 mp->sw_if_index = ntohl (sw_if_index);
4865 mp->is_add = is_add;
4866 mp->del_all = del_all;
4870 clib_memcpy (mp->address, &v6address, sizeof (v6address));
4874 clib_memcpy (mp->address, &v4address, sizeof (v4address));
4876 mp->address_length = address_length;
4881 /* Wait for a reply, return good/bad news */
4886 api_sw_interface_set_mpls_enable (vat_main_t * vam)
4888 unformat_input_t *i = vam->input;
4889 vl_api_sw_interface_set_mpls_enable_t *mp;
4892 u8 sw_if_index_set = 0;
4895 /* Parse args required to build the message */
4896 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4898 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4899 sw_if_index_set = 1;
4900 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4901 sw_if_index_set = 1;
4902 else if (unformat (i, "disable"))
4904 else if (unformat (i, "dis"))
4910 if (sw_if_index_set == 0)
4912 errmsg ("missing interface name or sw_if_index\n");
4916 /* Construct the API message */
4917 M (SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable);
4919 mp->sw_if_index = ntohl (sw_if_index);
4920 mp->enable = enable;
4925 /* Wait for a reply... */
4930 api_sw_interface_set_table (vat_main_t * vam)
4932 unformat_input_t *i = vam->input;
4933 vl_api_sw_interface_set_table_t *mp;
4935 u32 sw_if_index, vrf_id = 0;
4936 u8 sw_if_index_set = 0;
4939 /* Parse args required to build the message */
4940 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4942 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4943 sw_if_index_set = 1;
4944 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4945 sw_if_index_set = 1;
4946 else if (unformat (i, "vrf %d", &vrf_id))
4948 else if (unformat (i, "ipv6"))
4954 if (sw_if_index_set == 0)
4956 errmsg ("missing interface name or sw_if_index\n");
4960 /* Construct the API message */
4961 M (SW_INTERFACE_SET_TABLE, sw_interface_set_table);
4963 mp->sw_if_index = ntohl (sw_if_index);
4964 mp->is_ipv6 = is_ipv6;
4965 mp->vrf_id = ntohl (vrf_id);
4970 /* Wait for a reply... */
4975 api_sw_interface_set_vpath (vat_main_t * vam)
4977 unformat_input_t *i = vam->input;
4978 vl_api_sw_interface_set_vpath_t *mp;
4980 u32 sw_if_index = 0;
4981 u8 sw_if_index_set = 0;
4984 /* Parse args required to build the message */
4985 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4987 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4988 sw_if_index_set = 1;
4989 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4990 sw_if_index_set = 1;
4991 else if (unformat (i, "enable"))
4993 else if (unformat (i, "disable"))
4999 if (sw_if_index_set == 0)
5001 errmsg ("missing interface name or sw_if_index\n");
5005 /* Construct the API message */
5006 M (SW_INTERFACE_SET_VPATH, sw_interface_set_vpath);
5008 mp->sw_if_index = ntohl (sw_if_index);
5009 mp->enable = is_enable;
5014 /* Wait for a reply... */
5019 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5021 unformat_input_t *i = vam->input;
5022 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5024 u32 sw_if_index = 0;
5025 u8 sw_if_index_set = 0;
5029 /* Parse args required to build the message */
5030 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5032 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5033 sw_if_index_set = 1;
5034 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5035 sw_if_index_set = 1;
5036 else if (unformat (i, "enable"))
5038 else if (unformat (i, "disable"))
5040 else if (unformat (i, "ip4"))
5042 else if (unformat (i, "ip6"))
5048 if (sw_if_index_set == 0)
5050 errmsg ("missing interface name or sw_if_index\n");
5054 /* Construct the API message */
5055 M (SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass);
5057 mp->sw_if_index = ntohl (sw_if_index);
5058 mp->enable = is_enable;
5059 mp->is_ipv6 = is_ipv6;
5064 /* Wait for a reply... */
5069 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5071 unformat_input_t *i = vam->input;
5072 vl_api_sw_interface_set_l2_xconnect_t *mp;
5075 u8 rx_sw_if_index_set = 0;
5077 u8 tx_sw_if_index_set = 0;
5080 /* Parse args required to build the message */
5081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5083 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5084 rx_sw_if_index_set = 1;
5085 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5086 tx_sw_if_index_set = 1;
5087 else if (unformat (i, "rx"))
5089 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5091 if (unformat (i, "%U", unformat_sw_if_index, vam,
5093 rx_sw_if_index_set = 1;
5098 else if (unformat (i, "tx"))
5100 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5102 if (unformat (i, "%U", unformat_sw_if_index, vam,
5104 tx_sw_if_index_set = 1;
5109 else if (unformat (i, "enable"))
5111 else if (unformat (i, "disable"))
5117 if (rx_sw_if_index_set == 0)
5119 errmsg ("missing rx interface name or rx_sw_if_index\n");
5123 if (enable && (tx_sw_if_index_set == 0))
5125 errmsg ("missing tx interface name or tx_sw_if_index\n");
5129 M (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect);
5131 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5132 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5133 mp->enable = enable;
5142 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5144 unformat_input_t *i = vam->input;
5145 vl_api_sw_interface_set_l2_bridge_t *mp;
5148 u8 rx_sw_if_index_set = 0;
5155 /* Parse args required to build the message */
5156 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5158 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5159 rx_sw_if_index_set = 1;
5160 else if (unformat (i, "bd_id %d", &bd_id))
5162 else if (unformat (i, "%U", unformat_sw_if_index, vam, &rx_sw_if_index))
5163 rx_sw_if_index_set = 1;
5164 else if (unformat (i, "shg %d", &shg))
5166 else if (unformat (i, "bvi"))
5168 else if (unformat (i, "enable"))
5170 else if (unformat (i, "disable"))
5176 if (rx_sw_if_index_set == 0)
5178 errmsg ("missing rx interface name or sw_if_index\n");
5182 if (enable && (bd_id_set == 0))
5184 errmsg ("missing bridge domain\n");
5188 M (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge);
5190 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5191 mp->bd_id = ntohl (bd_id);
5194 mp->enable = enable;
5203 api_bridge_domain_dump (vat_main_t * vam)
5205 unformat_input_t *i = vam->input;
5206 vl_api_bridge_domain_dump_t *mp;
5210 /* Parse args required to build the message */
5211 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5213 if (unformat (i, "bd_id %d", &bd_id))
5219 M (BRIDGE_DOMAIN_DUMP, bridge_domain_dump);
5220 mp->bd_id = ntohl (bd_id);
5223 /* Use a control ping for synchronization */
5225 vl_api_control_ping_t *mp;
5226 M (CONTROL_PING, control_ping);
5236 api_bridge_domain_add_del (vat_main_t * vam)
5238 unformat_input_t *i = vam->input;
5239 vl_api_bridge_domain_add_del_t *mp;
5243 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5245 /* Parse args required to build the message */
5246 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5248 if (unformat (i, "bd_id %d", &bd_id))
5250 else if (unformat (i, "flood %d", &flood))
5252 else if (unformat (i, "uu-flood %d", &uu_flood))
5254 else if (unformat (i, "forward %d", &forward))
5256 else if (unformat (i, "learn %d", &learn))
5258 else if (unformat (i, "arp-term %d", &arp_term))
5260 else if (unformat (i, "del"))
5263 flood = uu_flood = forward = learn = 0;
5271 errmsg ("missing bridge domain\n");
5275 M (BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del);
5277 mp->bd_id = ntohl (bd_id);
5279 mp->uu_flood = uu_flood;
5280 mp->forward = forward;
5282 mp->arp_term = arp_term;
5283 mp->is_add = is_add;
5292 api_l2fib_add_del (vat_main_t * vam)
5294 unformat_input_t *i = vam->input;
5295 vl_api_l2fib_add_del_t *mp;
5301 u32 sw_if_index = ~0;
5302 u8 sw_if_index_set = 0;
5311 /* Parse args required to build the message */
5312 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5314 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5316 else if (unformat (i, "bd_id %d", &bd_id))
5318 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5319 sw_if_index_set = 1;
5320 else if (unformat (i, "sw_if"))
5322 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5324 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5325 sw_if_index_set = 1;
5330 else if (unformat (i, "static"))
5332 else if (unformat (i, "filter"))
5337 else if (unformat (i, "bvi"))
5342 else if (unformat (i, "del"))
5344 else if (unformat (i, "count %d", &count))
5352 errmsg ("missing mac address\n");
5358 errmsg ("missing bridge domain\n");
5362 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5364 errmsg ("missing interface name or sw_if_index\n");
5370 /* Turn on async mode */
5371 vam->async_mode = 1;
5372 vam->async_errors = 0;
5373 before = vat_time_now (vam);
5376 for (j = 0; j < count; j++)
5378 M (L2FIB_ADD_DEL, l2fib_add_del);
5381 mp->bd_id = ntohl (bd_id);
5382 mp->is_add = is_add;
5386 mp->sw_if_index = ntohl (sw_if_index);
5387 mp->static_mac = static_mac;
5388 mp->filter_mac = filter_mac;
5389 mp->bvi_mac = bvi_mac;
5391 increment_mac_address (&mac);
5398 vl_api_control_ping_t *mp;
5401 /* Shut off async mode */
5402 vam->async_mode = 0;
5404 M (CONTROL_PING, control_ping);
5407 timeout = vat_time_now (vam) + 1.0;
5408 while (vat_time_now (vam) < timeout)
5409 if (vam->result_ready == 1)
5414 if (vam->retval == -99)
5415 errmsg ("timeout\n");
5417 if (vam->async_errors > 0)
5419 errmsg ("%d asynchronous errors\n", vam->async_errors);
5422 vam->async_errors = 0;
5423 after = vat_time_now (vam);
5425 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
5426 count, after - before, count / (after - before));
5430 /* Wait for a reply... */
5433 /* Return the good/bad news */
5434 return (vam->retval);
5438 api_l2_flags (vat_main_t * vam)
5440 unformat_input_t *i = vam->input;
5441 vl_api_l2_flags_t *mp;
5444 u32 feature_bitmap = 0;
5445 u8 sw_if_index_set = 0;
5447 /* Parse args required to build the message */
5448 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5450 if (unformat (i, "sw_if_index %d", &sw_if_index))
5451 sw_if_index_set = 1;
5452 else if (unformat (i, "sw_if"))
5454 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5456 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5457 sw_if_index_set = 1;
5462 else if (unformat (i, "learn"))
5463 feature_bitmap |= L2INPUT_FEAT_LEARN;
5464 else if (unformat (i, "forward"))
5465 feature_bitmap |= L2INPUT_FEAT_FWD;
5466 else if (unformat (i, "flood"))
5467 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5468 else if (unformat (i, "uu-flood"))
5469 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5474 if (sw_if_index_set == 0)
5476 errmsg ("missing interface name or sw_if_index\n");
5480 M (L2_FLAGS, l2_flags);
5482 mp->sw_if_index = ntohl (sw_if_index);
5483 mp->feature_bitmap = ntohl (feature_bitmap);
5492 api_bridge_flags (vat_main_t * vam)
5494 unformat_input_t *i = vam->input;
5495 vl_api_bridge_flags_t *mp;
5502 /* Parse args required to build the message */
5503 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5505 if (unformat (i, "bd_id %d", &bd_id))
5507 else if (unformat (i, "learn"))
5509 else if (unformat (i, "forward"))
5511 else if (unformat (i, "flood"))
5513 else if (unformat (i, "uu-flood"))
5514 flags |= L2_UU_FLOOD;
5515 else if (unformat (i, "arp-term"))
5516 flags |= L2_ARP_TERM;
5517 else if (unformat (i, "off"))
5519 else if (unformat (i, "disable"))
5527 errmsg ("missing bridge domain\n");
5531 M (BRIDGE_FLAGS, bridge_flags);
5533 mp->bd_id = ntohl (bd_id);
5534 mp->feature_bitmap = ntohl (flags);
5535 mp->is_set = is_set;
5544 api_bd_ip_mac_add_del (vat_main_t * vam)
5546 unformat_input_t *i = vam->input;
5547 vl_api_bd_ip_mac_add_del_t *mp;
5555 ip4_address_t v4addr;
5556 ip6_address_t v6addr;
5560 /* Parse args required to build the message */
5561 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5563 if (unformat (i, "bd_id %d", &bd_id))
5567 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5571 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5576 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5580 else if (unformat (i, "del"))
5588 errmsg ("missing bridge domain\n");
5591 else if (ip_set == 0)
5593 errmsg ("missing IP address\n");
5596 else if (mac_set == 0)
5598 errmsg ("missing MAC address\n");
5602 M (BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del);
5604 mp->bd_id = ntohl (bd_id);
5605 mp->is_ipv6 = is_ipv6;
5606 mp->is_add = is_add;
5608 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5610 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5611 clib_memcpy (mp->mac_address, macaddr, 6);
5619 api_tap_connect (vat_main_t * vam)
5621 unformat_input_t *i = vam->input;
5622 vl_api_tap_connect_t *mp;
5630 memset (mac_address, 0, sizeof (mac_address));
5632 /* Parse args required to build the message */
5633 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5635 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5639 else if (unformat (i, "random-mac"))
5641 else if (unformat (i, "tapname %s", &tap_name))
5643 else if (unformat (i, "tag %s", &tag))
5651 errmsg ("missing tap name\n");
5654 if (vec_len (tap_name) > 63)
5656 errmsg ("tap name too long\n");
5659 vec_add1 (tap_name, 0);
5661 if (vec_len (tag) > 63)
5663 errmsg ("tag too long\n");
5667 /* Construct the API message */
5668 M (TAP_CONNECT, tap_connect);
5670 mp->use_random_mac = random_mac;
5671 clib_memcpy (mp->mac_address, mac_address, 6);
5672 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5674 clib_memcpy (mp->tag, tag, vec_len (tag));
5676 vec_free (tap_name);
5682 /* Wait for a reply... */
5687 api_tap_modify (vat_main_t * vam)
5689 unformat_input_t *i = vam->input;
5690 vl_api_tap_modify_t *mp;
5696 u32 sw_if_index = ~0;
5697 u8 sw_if_index_set = 0;
5699 memset (mac_address, 0, sizeof (mac_address));
5701 /* Parse args required to build the message */
5702 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5704 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5705 sw_if_index_set = 1;
5706 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5707 sw_if_index_set = 1;
5708 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5712 else if (unformat (i, "random-mac"))
5714 else if (unformat (i, "tapname %s", &tap_name))
5720 if (sw_if_index_set == 0)
5722 errmsg ("missing vpp interface name");
5727 errmsg ("missing tap name\n");
5730 if (vec_len (tap_name) > 63)
5732 errmsg ("tap name too long\n");
5734 vec_add1 (tap_name, 0);
5736 /* Construct the API message */
5737 M (TAP_MODIFY, tap_modify);
5739 mp->use_random_mac = random_mac;
5740 mp->sw_if_index = ntohl (sw_if_index);
5741 clib_memcpy (mp->mac_address, mac_address, 6);
5742 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5743 vec_free (tap_name);
5748 /* Wait for a reply... */
5753 api_tap_delete (vat_main_t * vam)
5755 unformat_input_t *i = vam->input;
5756 vl_api_tap_delete_t *mp;
5758 u32 sw_if_index = ~0;
5759 u8 sw_if_index_set = 0;
5761 /* Parse args required to build the message */
5762 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5764 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5765 sw_if_index_set = 1;
5766 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5767 sw_if_index_set = 1;
5772 if (sw_if_index_set == 0)
5774 errmsg ("missing vpp interface name");
5778 /* Construct the API message */
5779 M (TAP_DELETE, tap_delete);
5781 mp->sw_if_index = ntohl (sw_if_index);
5786 /* Wait for a reply... */
5791 api_ip_add_del_route (vat_main_t * vam)
5793 unformat_input_t *i = vam->input;
5794 vl_api_ip_add_del_route_t *mp;
5796 u32 sw_if_index = ~0, vrf_id = 0;
5798 u8 is_local = 0, is_drop = 0;
5799 u8 is_unreach = 0, is_prohibit = 0;
5800 u8 create_vrf_if_needed = 0;
5802 u32 next_hop_weight = 1;
5804 u8 is_multipath = 0;
5806 u8 address_length_set = 0;
5807 u32 next_hop_table_id = 0;
5808 u32 resolve_attempts = 0;
5809 u32 dst_address_length = 0;
5810 u8 next_hop_set = 0;
5811 ip4_address_t v4_dst_address, v4_next_hop_address;
5812 ip6_address_t v6_dst_address, v6_next_hop_address;
5816 u32 random_add_del = 0;
5817 u32 *random_vector = 0;
5819 u32 random_seed = 0xdeaddabe;
5820 u32 classify_table_index = ~0;
5822 u8 resolve_host = 0, resolve_attached = 0;
5823 mpls_label_t *next_hop_out_label_stack = NULL;
5824 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
5825 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
5827 /* Parse args required to build the message */
5828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5830 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5832 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5834 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
5839 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
5844 else if (unformat (i, "/%d", &dst_address_length))
5846 address_length_set = 1;
5849 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
5850 &v4_next_hop_address))
5854 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
5855 &v6_next_hop_address))
5859 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
5861 else if (unformat (i, "weight %d", &next_hop_weight))
5863 else if (unformat (i, "drop"))
5867 else if (unformat (i, "null-send-unreach"))
5871 else if (unformat (i, "null-send-prohibit"))
5875 else if (unformat (i, "local"))
5879 else if (unformat (i, "classify %d", &classify_table_index))
5883 else if (unformat (i, "del"))
5885 else if (unformat (i, "add"))
5887 else if (unformat (i, "not-last"))
5889 else if (unformat (i, "resolve-via-host"))
5891 else if (unformat (i, "resolve-via-attached"))
5892 resolve_attached = 1;
5893 else if (unformat (i, "multipath"))
5895 else if (unformat (i, "vrf %d", &vrf_id))
5897 else if (unformat (i, "create-vrf"))
5898 create_vrf_if_needed = 1;
5899 else if (unformat (i, "count %d", &count))
5901 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
5903 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
5905 else if (unformat (i, "out-label %d", &next_hop_out_label))
5906 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
5907 else if (unformat (i, "via-label %d", &next_hop_via_label))
5909 else if (unformat (i, "random"))
5911 else if (unformat (i, "seed %d", &random_seed))
5915 clib_warning ("parse error '%U'", format_unformat_error, i);
5920 if (!next_hop_set && !is_drop && !is_local &&
5921 !is_classify && !is_unreach && !is_prohibit &&
5922 MPLS_LABEL_INVALID == next_hop_via_label)
5925 ("next hop / local / drop / unreach / prohibit / classify not set\n");
5929 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
5931 errmsg ("next hop and next-hop via label set\n");
5934 if (address_set == 0)
5936 errmsg ("missing addresses\n");
5940 if (address_length_set == 0)
5942 errmsg ("missing address length\n");
5946 /* Generate a pile of unique, random routes */
5949 u32 this_random_address;
5950 random_hash = hash_create (count, sizeof (uword));
5952 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
5953 for (j = 0; j <= count; j++)
5957 this_random_address = random_u32 (&random_seed);
5958 this_random_address =
5959 clib_host_to_net_u32 (this_random_address);
5961 while (hash_get (random_hash, this_random_address));
5962 vec_add1 (random_vector, this_random_address);
5963 hash_set (random_hash, this_random_address, 1);
5965 hash_free (random_hash);
5966 v4_dst_address.as_u32 = random_vector[0];
5971 /* Turn on async mode */
5972 vam->async_mode = 1;
5973 vam->async_errors = 0;
5974 before = vat_time_now (vam);
5977 for (j = 0; j < count; j++)
5979 /* Construct the API message */
5980 M2 (IP_ADD_DEL_ROUTE, ip_add_del_route,
5981 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
5983 mp->next_hop_sw_if_index = ntohl (sw_if_index);
5984 mp->table_id = ntohl (vrf_id);
5985 mp->create_vrf_if_needed = create_vrf_if_needed;
5987 mp->is_add = is_add;
5988 mp->is_drop = is_drop;
5989 mp->is_unreach = is_unreach;
5990 mp->is_prohibit = is_prohibit;
5991 mp->is_ipv6 = is_ipv6;
5992 mp->is_local = is_local;
5993 mp->is_classify = is_classify;
5994 mp->is_multipath = is_multipath;
5995 mp->is_resolve_host = resolve_host;
5996 mp->is_resolve_attached = resolve_attached;
5997 mp->not_last = not_last;
5998 mp->next_hop_weight = next_hop_weight;
5999 mp->dst_address_length = dst_address_length;
6000 mp->next_hop_table_id = ntohl (next_hop_table_id);
6001 mp->classify_table_index = ntohl (classify_table_index);
6002 mp->next_hop_via_label = ntohl (next_hop_via_label);
6003 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6004 if (0 != mp->next_hop_n_out_labels)
6006 memcpy (mp->next_hop_out_label_stack,
6007 next_hop_out_label_stack,
6008 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6009 vec_free (next_hop_out_label_stack);
6014 clib_memcpy (mp->dst_address, &v6_dst_address,
6015 sizeof (v6_dst_address));
6017 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6018 sizeof (v6_next_hop_address));
6019 increment_v6_address (&v6_dst_address);
6023 clib_memcpy (mp->dst_address, &v4_dst_address,
6024 sizeof (v4_dst_address));
6026 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6027 sizeof (v4_next_hop_address));
6029 v4_dst_address.as_u32 = random_vector[j + 1];
6031 increment_v4_address (&v4_dst_address);
6035 /* If we receive SIGTERM, stop now... */
6040 /* When testing multiple add/del ops, use a control-ping to sync */
6043 vl_api_control_ping_t *mp;
6046 /* Shut off async mode */
6047 vam->async_mode = 0;
6049 M (CONTROL_PING, control_ping);
6052 timeout = vat_time_now (vam) + 1.0;
6053 while (vat_time_now (vam) < timeout)
6054 if (vam->result_ready == 1)
6059 if (vam->retval == -99)
6060 errmsg ("timeout\n");
6062 if (vam->async_errors > 0)
6064 errmsg ("%d asynchronous errors\n", vam->async_errors);
6067 vam->async_errors = 0;
6068 after = vat_time_now (vam);
6070 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6074 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
6075 count, after - before, count / (after - before));
6079 /* Wait for a reply... */
6083 /* Return the good/bad news */
6084 return (vam->retval);
6088 api_mpls_route_add_del (vat_main_t * vam)
6090 unformat_input_t *i = vam->input;
6091 vl_api_mpls_route_add_del_t *mp;
6093 u32 sw_if_index = ~0, table_id = 0;
6094 u8 create_table_if_needed = 0;
6096 u32 next_hop_weight = 1;
6097 u8 is_multipath = 0;
6098 u32 next_hop_table_id = 0;
6099 u8 next_hop_set = 0;
6100 ip4_address_t v4_next_hop_address = {
6103 ip6_address_t v6_next_hop_address = { {0} };
6107 u32 classify_table_index = ~0;
6109 u8 resolve_host = 0, resolve_attached = 0;
6110 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6111 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6112 mpls_label_t *next_hop_out_label_stack = NULL;
6113 mpls_label_t local_label = MPLS_LABEL_INVALID;
6115 u8 next_hop_proto_is_ip4 = 1;
6117 /* Parse args required to build the message */
6118 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6120 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6122 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6124 else if (unformat (i, "%d", &local_label))
6126 else if (unformat (i, "eos"))
6128 else if (unformat (i, "non-eos"))
6130 else if (unformat (i, "via %U", unformat_ip4_address,
6131 &v4_next_hop_address))
6134 next_hop_proto_is_ip4 = 1;
6136 else if (unformat (i, "via %U", unformat_ip6_address,
6137 &v6_next_hop_address))
6140 next_hop_proto_is_ip4 = 0;
6142 else if (unformat (i, "weight %d", &next_hop_weight))
6144 else if (unformat (i, "create-table"))
6145 create_table_if_needed = 1;
6146 else if (unformat (i, "classify %d", &classify_table_index))
6150 else if (unformat (i, "del"))
6152 else if (unformat (i, "add"))
6154 else if (unformat (i, "resolve-via-host"))
6156 else if (unformat (i, "resolve-via-attached"))
6157 resolve_attached = 1;
6158 else if (unformat (i, "multipath"))
6160 else if (unformat (i, "count %d", &count))
6162 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6165 next_hop_proto_is_ip4 = 1;
6167 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6170 next_hop_proto_is_ip4 = 0;
6172 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6174 else if (unformat (i, "via-label %d", &next_hop_via_label))
6176 else if (unformat (i, "out-label %d", &next_hop_out_label))
6177 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6180 clib_warning ("parse error '%U'", format_unformat_error, i);
6185 if (!next_hop_set && !is_classify)
6187 errmsg ("next hop / classify not set\n");
6191 if (MPLS_LABEL_INVALID == local_label)
6193 errmsg ("missing label\n");
6199 /* Turn on async mode */
6200 vam->async_mode = 1;
6201 vam->async_errors = 0;
6202 before = vat_time_now (vam);
6205 for (j = 0; j < count; j++)
6207 /* Construct the API message */
6208 M2 (MPLS_ROUTE_ADD_DEL, mpls_route_add_del,
6209 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6211 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6212 mp->mr_table_id = ntohl (table_id);
6213 mp->mr_create_table_if_needed = create_table_if_needed;
6215 mp->mr_is_add = is_add;
6216 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6217 mp->mr_is_classify = is_classify;
6218 mp->mr_is_multipath = is_multipath;
6219 mp->mr_is_resolve_host = resolve_host;
6220 mp->mr_is_resolve_attached = resolve_attached;
6221 mp->mr_next_hop_weight = next_hop_weight;
6222 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6223 mp->mr_classify_table_index = ntohl (classify_table_index);
6224 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6225 mp->mr_label = ntohl (local_label);
6226 mp->mr_eos = is_eos;
6228 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6229 if (0 != mp->mr_next_hop_n_out_labels)
6231 memcpy (mp->mr_next_hop_out_label_stack,
6232 next_hop_out_label_stack,
6233 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6234 vec_free (next_hop_out_label_stack);
6239 if (next_hop_proto_is_ip4)
6241 clib_memcpy (mp->mr_next_hop,
6242 &v4_next_hop_address,
6243 sizeof (v4_next_hop_address));
6247 clib_memcpy (mp->mr_next_hop,
6248 &v6_next_hop_address,
6249 sizeof (v6_next_hop_address));
6256 /* If we receive SIGTERM, stop now... */
6261 /* When testing multiple add/del ops, use a control-ping to sync */
6264 vl_api_control_ping_t *mp;
6267 /* Shut off async mode */
6268 vam->async_mode = 0;
6270 M (CONTROL_PING, control_ping);
6273 timeout = vat_time_now (vam) + 1.0;
6274 while (vat_time_now (vam) < timeout)
6275 if (vam->result_ready == 1)
6280 if (vam->retval == -99)
6281 errmsg ("timeout\n");
6283 if (vam->async_errors > 0)
6285 errmsg ("%d asynchronous errors\n", vam->async_errors);
6288 vam->async_errors = 0;
6289 after = vat_time_now (vam);
6291 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6295 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
6296 count, after - before, count / (after - before));
6300 /* Wait for a reply... */
6304 /* Return the good/bad news */
6305 return (vam->retval);
6309 api_mpls_ip_bind_unbind (vat_main_t * vam)
6311 unformat_input_t *i = vam->input;
6312 vl_api_mpls_ip_bind_unbind_t *mp;
6314 u32 ip_table_id = 0;
6315 u8 create_table_if_needed = 0;
6318 ip4_address_t v4_address;
6319 ip6_address_t v6_address;
6322 mpls_label_t local_label = MPLS_LABEL_INVALID;
6324 /* Parse args required to build the message */
6325 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6327 if (unformat (i, "%U/%d", unformat_ip4_address,
6328 &v4_address, &address_length))
6333 else if (unformat (i, "%U/%d", unformat_ip6_address,
6334 &v6_address, &address_length))
6339 else if (unformat (i, "%d", &local_label))
6341 else if (unformat (i, "create-table"))
6342 create_table_if_needed = 1;
6343 else if (unformat (i, "table-id %d", &ip_table_id))
6345 else if (unformat (i, "unbind"))
6347 else if (unformat (i, "bind"))
6351 clib_warning ("parse error '%U'", format_unformat_error, i);
6358 errmsg ("IP addres not set\n");
6362 if (MPLS_LABEL_INVALID == local_label)
6364 errmsg ("missing label\n");
6368 /* Construct the API message */
6369 M (MPLS_IP_BIND_UNBIND, mpls_ip_bind_unbind);
6371 mp->mb_create_table_if_needed = create_table_if_needed;
6372 mp->mb_is_bind = is_bind;
6373 mp->mb_is_ip4 = is_ip4;
6374 mp->mb_ip_table_id = ntohl (ip_table_id);
6375 mp->mb_mpls_table_id = 0;
6376 mp->mb_label = ntohl (local_label);
6377 mp->mb_address_length = address_length;
6380 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
6382 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
6387 /* Wait for a reply... */
6392 api_proxy_arp_add_del (vat_main_t * vam)
6394 unformat_input_t *i = vam->input;
6395 vl_api_proxy_arp_add_del_t *mp;
6399 ip4_address_t lo, hi;
6402 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6404 if (unformat (i, "vrf %d", &vrf_id))
6406 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
6407 unformat_ip4_address, &hi))
6409 else if (unformat (i, "del"))
6413 clib_warning ("parse error '%U'", format_unformat_error, i);
6420 errmsg ("address range not set\n");
6424 M (PROXY_ARP_ADD_DEL, proxy_arp_add_del);
6426 mp->vrf_id = ntohl (vrf_id);
6427 mp->is_add = is_add;
6428 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
6429 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
6438 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
6440 unformat_input_t *i = vam->input;
6441 vl_api_proxy_arp_intfc_enable_disable_t *mp;
6445 u8 sw_if_index_set = 0;
6447 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6449 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6450 sw_if_index_set = 1;
6451 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6452 sw_if_index_set = 1;
6453 else if (unformat (i, "enable"))
6455 else if (unformat (i, "disable"))
6459 clib_warning ("parse error '%U'", format_unformat_error, i);
6464 if (sw_if_index_set == 0)
6466 errmsg ("missing interface name or sw_if_index\n");
6470 M (PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable);
6472 mp->sw_if_index = ntohl (sw_if_index);
6473 mp->enable_disable = enable;
6482 api_mpls_tunnel_add_del (vat_main_t * vam)
6484 unformat_input_t *i = vam->input;
6485 vl_api_mpls_tunnel_add_del_t *mp;
6490 u32 sw_if_index = ~0;
6491 u32 next_hop_sw_if_index = ~0;
6492 u32 next_hop_proto_is_ip4 = 1;
6494 u32 next_hop_table_id = 0;
6495 ip4_address_t v4_next_hop_address = {
6498 ip6_address_t v6_next_hop_address = { {0} };
6499 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
6501 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6503 if (unformat (i, "add"))
6505 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
6507 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
6509 else if (unformat (i, "via %U",
6510 unformat_ip4_address, &v4_next_hop_address))
6512 next_hop_proto_is_ip4 = 1;
6514 else if (unformat (i, "via %U",
6515 unformat_ip6_address, &v6_next_hop_address))
6517 next_hop_proto_is_ip4 = 0;
6519 else if (unformat (i, "l2-only"))
6521 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6523 else if (unformat (i, "out-label %d", &next_hop_out_label))
6524 vec_add1 (labels, ntohl (next_hop_out_label));
6527 clib_warning ("parse error '%U'", format_unformat_error, i);
6532 M2 (MPLS_TUNNEL_ADD_DEL, mpls_tunnel_add_del,
6533 sizeof (mpls_label_t) * vec_len (labels));
6535 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
6536 mp->mt_sw_if_index = ntohl (sw_if_index);
6537 mp->mt_is_add = is_add;
6538 mp->mt_l2_only = l2_only;
6539 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
6540 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6542 mp->mt_next_hop_n_out_labels = vec_len (labels);
6544 if (0 != mp->mt_next_hop_n_out_labels)
6546 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
6547 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
6551 if (next_hop_proto_is_ip4)
6553 clib_memcpy (mp->mt_next_hop,
6554 &v4_next_hop_address, sizeof (v4_next_hop_address));
6558 clib_memcpy (mp->mt_next_hop,
6559 &v6_next_hop_address, sizeof (v6_next_hop_address));
6569 api_sw_interface_set_unnumbered (vat_main_t * vam)
6571 unformat_input_t *i = vam->input;
6572 vl_api_sw_interface_set_unnumbered_t *mp;
6575 u32 unnum_sw_index = ~0;
6577 u8 sw_if_index_set = 0;
6579 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6581 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6582 sw_if_index_set = 1;
6583 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6584 sw_if_index_set = 1;
6585 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
6587 else if (unformat (i, "del"))
6591 clib_warning ("parse error '%U'", format_unformat_error, i);
6596 if (sw_if_index_set == 0)
6598 errmsg ("missing interface name or sw_if_index\n");
6602 M (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered);
6604 mp->sw_if_index = ntohl (sw_if_index);
6605 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
6606 mp->is_add = is_add;
6615 api_ip_neighbor_add_del (vat_main_t * vam)
6617 unformat_input_t *i = vam->input;
6618 vl_api_ip_neighbor_add_del_t *mp;
6621 u8 sw_if_index_set = 0;
6627 u8 v4_address_set = 0;
6628 u8 v6_address_set = 0;
6629 ip4_address_t v4address;
6630 ip6_address_t v6address;
6632 memset (mac_address, 0, sizeof (mac_address));
6634 /* Parse args required to build the message */
6635 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6637 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6641 else if (unformat (i, "del"))
6643 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6644 sw_if_index_set = 1;
6645 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6646 sw_if_index_set = 1;
6647 else if (unformat (i, "is_static"))
6649 else if (unformat (i, "vrf %d", &vrf_id))
6651 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
6653 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
6657 clib_warning ("parse error '%U'", format_unformat_error, i);
6662 if (sw_if_index_set == 0)
6664 errmsg ("missing interface name or sw_if_index\n");
6667 if (v4_address_set && v6_address_set)
6669 errmsg ("both v4 and v6 addresses set\n");
6672 if (!v4_address_set && !v6_address_set)
6674 errmsg ("no address set\n");
6678 /* Construct the API message */
6679 M (IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del);
6681 mp->sw_if_index = ntohl (sw_if_index);
6682 mp->is_add = is_add;
6683 mp->vrf_id = ntohl (vrf_id);
6684 mp->is_static = is_static;
6686 clib_memcpy (mp->mac_address, mac_address, 6);
6690 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
6694 /* mp->is_ipv6 = 0; via memset in M macro above */
6695 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
6701 /* Wait for a reply, return good/bad news */
6709 api_reset_vrf (vat_main_t * vam)
6711 unformat_input_t *i = vam->input;
6712 vl_api_reset_vrf_t *mp;
6718 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6720 if (unformat (i, "vrf %d", &vrf_id))
6722 else if (unformat (i, "ipv6"))
6726 clib_warning ("parse error '%U'", format_unformat_error, i);
6731 if (vrf_id_set == 0)
6733 errmsg ("missing vrf id\n");
6737 M (RESET_VRF, reset_vrf);
6739 mp->vrf_id = ntohl (vrf_id);
6740 mp->is_ipv6 = is_ipv6;
6749 api_create_vlan_subif (vat_main_t * vam)
6751 unformat_input_t *i = vam->input;
6752 vl_api_create_vlan_subif_t *mp;
6755 u8 sw_if_index_set = 0;
6759 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6761 if (unformat (i, "sw_if_index %d", &sw_if_index))
6762 sw_if_index_set = 1;
6763 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6764 sw_if_index_set = 1;
6765 else if (unformat (i, "vlan %d", &vlan_id))
6769 clib_warning ("parse error '%U'", format_unformat_error, i);
6774 if (sw_if_index_set == 0)
6776 errmsg ("missing interface name or sw_if_index\n");
6780 if (vlan_id_set == 0)
6782 errmsg ("missing vlan_id\n");
6785 M (CREATE_VLAN_SUBIF, create_vlan_subif);
6787 mp->sw_if_index = ntohl (sw_if_index);
6788 mp->vlan_id = ntohl (vlan_id);
6796 #define foreach_create_subif_bit \
6803 _(outer_vlan_id_any) \
6804 _(inner_vlan_id_any)
6807 api_create_subif (vat_main_t * vam)
6809 unformat_input_t *i = vam->input;
6810 vl_api_create_subif_t *mp;
6813 u8 sw_if_index_set = 0;
6820 u32 exact_match = 0;
6821 u32 default_sub = 0;
6822 u32 outer_vlan_id_any = 0;
6823 u32 inner_vlan_id_any = 0;
6825 u16 outer_vlan_id = 0;
6826 u16 inner_vlan_id = 0;
6828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6830 if (unformat (i, "sw_if_index %d", &sw_if_index))
6831 sw_if_index_set = 1;
6832 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6833 sw_if_index_set = 1;
6834 else if (unformat (i, "sub_id %d", &sub_id))
6836 else if (unformat (i, "outer_vlan_id %d", &tmp))
6837 outer_vlan_id = tmp;
6838 else if (unformat (i, "inner_vlan_id %d", &tmp))
6839 inner_vlan_id = tmp;
6841 #define _(a) else if (unformat (i, #a)) a = 1 ;
6842 foreach_create_subif_bit
6846 clib_warning ("parse error '%U'", format_unformat_error, i);
6851 if (sw_if_index_set == 0)
6853 errmsg ("missing interface name or sw_if_index\n");
6857 if (sub_id_set == 0)
6859 errmsg ("missing sub_id\n");
6862 M (CREATE_SUBIF, create_subif);
6864 mp->sw_if_index = ntohl (sw_if_index);
6865 mp->sub_id = ntohl (sub_id);
6867 #define _(a) mp->a = a;
6868 foreach_create_subif_bit;
6871 mp->outer_vlan_id = ntohs (outer_vlan_id);
6872 mp->inner_vlan_id = ntohs (inner_vlan_id);
6881 api_oam_add_del (vat_main_t * vam)
6883 unformat_input_t *i = vam->input;
6884 vl_api_oam_add_del_t *mp;
6888 ip4_address_t src, dst;
6892 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6894 if (unformat (i, "vrf %d", &vrf_id))
6896 else if (unformat (i, "src %U", unformat_ip4_address, &src))
6898 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
6900 else if (unformat (i, "del"))
6904 clib_warning ("parse error '%U'", format_unformat_error, i);
6911 errmsg ("missing src addr\n");
6917 errmsg ("missing dst addr\n");
6921 M (OAM_ADD_DEL, oam_add_del);
6923 mp->vrf_id = ntohl (vrf_id);
6924 mp->is_add = is_add;
6925 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
6926 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
6935 api_reset_fib (vat_main_t * vam)
6937 unformat_input_t *i = vam->input;
6938 vl_api_reset_fib_t *mp;
6944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6946 if (unformat (i, "vrf %d", &vrf_id))
6948 else if (unformat (i, "ipv6"))
6952 clib_warning ("parse error '%U'", format_unformat_error, i);
6957 if (vrf_id_set == 0)
6959 errmsg ("missing vrf id\n");
6963 M (RESET_FIB, reset_fib);
6965 mp->vrf_id = ntohl (vrf_id);
6966 mp->is_ipv6 = is_ipv6;
6975 api_dhcp_proxy_config (vat_main_t * vam)
6977 unformat_input_t *i = vam->input;
6978 vl_api_dhcp_proxy_config_t *mp;
6983 u8 v4_address_set = 0;
6984 u8 v6_address_set = 0;
6985 ip4_address_t v4address;
6986 ip6_address_t v6address;
6987 u8 v4_src_address_set = 0;
6988 u8 v6_src_address_set = 0;
6989 ip4_address_t v4srcaddress;
6990 ip6_address_t v6srcaddress;
6992 /* Parse args required to build the message */
6993 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6995 if (unformat (i, "del"))
6997 else if (unformat (i, "vrf %d", &vrf_id))
6999 else if (unformat (i, "insert-cid %d", &insert_cid))
7001 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7003 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7005 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7006 v4_src_address_set = 1;
7007 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7008 v6_src_address_set = 1;
7013 if (v4_address_set && v6_address_set)
7015 errmsg ("both v4 and v6 server addresses set\n");
7018 if (!v4_address_set && !v6_address_set)
7020 errmsg ("no server addresses set\n");
7024 if (v4_src_address_set && v6_src_address_set)
7026 errmsg ("both v4 and v6 src addresses set\n");
7029 if (!v4_src_address_set && !v6_src_address_set)
7031 errmsg ("no src addresses set\n");
7035 if (!(v4_src_address_set && v4_address_set) &&
7036 !(v6_src_address_set && v6_address_set))
7038 errmsg ("no matching server and src addresses set\n");
7042 /* Construct the API message */
7043 M (DHCP_PROXY_CONFIG, dhcp_proxy_config);
7045 mp->insert_circuit_id = insert_cid;
7046 mp->is_add = is_add;
7047 mp->vrf_id = ntohl (vrf_id);
7051 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7052 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7056 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7057 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7063 /* Wait for a reply, return good/bad news */
7070 api_dhcp_proxy_config_2 (vat_main_t * vam)
7072 unformat_input_t *i = vam->input;
7073 vl_api_dhcp_proxy_config_2_t *mp;
7076 u32 server_vrf_id = 0;
7079 u8 v4_address_set = 0;
7080 u8 v6_address_set = 0;
7081 ip4_address_t v4address;
7082 ip6_address_t v6address;
7083 u8 v4_src_address_set = 0;
7084 u8 v6_src_address_set = 0;
7085 ip4_address_t v4srcaddress;
7086 ip6_address_t v6srcaddress;
7088 /* Parse args required to build the message */
7089 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7091 if (unformat (i, "del"))
7093 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7095 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7097 else if (unformat (i, "insert-cid %d", &insert_cid))
7099 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7101 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7103 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7104 v4_src_address_set = 1;
7105 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7106 v6_src_address_set = 1;
7111 if (v4_address_set && v6_address_set)
7113 errmsg ("both v4 and v6 server addresses set\n");
7116 if (!v4_address_set && !v6_address_set)
7118 errmsg ("no server addresses set\n");
7122 if (v4_src_address_set && v6_src_address_set)
7124 errmsg ("both v4 and v6 src addresses set\n");
7127 if (!v4_src_address_set && !v6_src_address_set)
7129 errmsg ("no src addresses set\n");
7133 if (!(v4_src_address_set && v4_address_set) &&
7134 !(v6_src_address_set && v6_address_set))
7136 errmsg ("no matching server and src addresses set\n");
7140 /* Construct the API message */
7141 M (DHCP_PROXY_CONFIG_2, dhcp_proxy_config_2);
7143 mp->insert_circuit_id = insert_cid;
7144 mp->is_add = is_add;
7145 mp->rx_vrf_id = ntohl (rx_vrf_id);
7146 mp->server_vrf_id = ntohl (server_vrf_id);
7150 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7151 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7155 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7156 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7162 /* Wait for a reply, return good/bad news */
7169 api_dhcp_proxy_set_vss (vat_main_t * vam)
7171 unformat_input_t *i = vam->input;
7172 vl_api_dhcp_proxy_set_vss_t *mp;
7183 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7185 if (unformat (i, "tbl_id %d", &tbl_id))
7187 if (unformat (i, "fib_id %d", &fib_id))
7189 if (unformat (i, "oui %d", &oui))
7191 else if (unformat (i, "ipv6"))
7193 else if (unformat (i, "del"))
7197 clib_warning ("parse error '%U'", format_unformat_error, i);
7202 if (tbl_id_set == 0)
7204 errmsg ("missing tbl id\n");
7208 if (fib_id_set == 0)
7210 errmsg ("missing fib id\n");
7215 errmsg ("missing oui\n");
7219 M (DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss);
7220 mp->tbl_id = ntohl (tbl_id);
7221 mp->fib_id = ntohl (fib_id);
7222 mp->oui = ntohl (oui);
7223 mp->is_ipv6 = is_ipv6;
7224 mp->is_add = is_add;
7233 api_dhcp_client_config (vat_main_t * vam)
7235 unformat_input_t *i = vam->input;
7236 vl_api_dhcp_client_config_t *mp;
7239 u8 sw_if_index_set = 0;
7242 u8 disable_event = 0;
7244 /* Parse args required to build the message */
7245 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7247 if (unformat (i, "del"))
7249 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7250 sw_if_index_set = 1;
7251 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7252 sw_if_index_set = 1;
7253 else if (unformat (i, "hostname %s", &hostname))
7255 else if (unformat (i, "disable_event"))
7261 if (sw_if_index_set == 0)
7263 errmsg ("missing interface name or sw_if_index\n");
7267 if (vec_len (hostname) > 63)
7269 errmsg ("hostname too long\n");
7271 vec_add1 (hostname, 0);
7273 /* Construct the API message */
7274 M (DHCP_CLIENT_CONFIG, dhcp_client_config);
7276 mp->sw_if_index = ntohl (sw_if_index);
7277 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7278 vec_free (hostname);
7279 mp->is_add = is_add;
7280 mp->want_dhcp_event = disable_event ? 0 : 1;
7281 mp->pid = getpid ();
7286 /* Wait for a reply, return good/bad news */
7293 api_set_ip_flow_hash (vat_main_t * vam)
7295 unformat_input_t *i = vam->input;
7296 vl_api_set_ip_flow_hash_t *mp;
7308 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7310 if (unformat (i, "vrf %d", &vrf_id))
7312 else if (unformat (i, "ipv6"))
7314 else if (unformat (i, "src"))
7316 else if (unformat (i, "dst"))
7318 else if (unformat (i, "sport"))
7320 else if (unformat (i, "dport"))
7322 else if (unformat (i, "proto"))
7324 else if (unformat (i, "reverse"))
7329 clib_warning ("parse error '%U'", format_unformat_error, i);
7334 if (vrf_id_set == 0)
7336 errmsg ("missing vrf id\n");
7340 M (SET_IP_FLOW_HASH, set_ip_flow_hash);
7346 mp->reverse = reverse;
7347 mp->vrf_id = ntohl (vrf_id);
7348 mp->is_ipv6 = is_ipv6;
7357 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7359 unformat_input_t *i = vam->input;
7360 vl_api_sw_interface_ip6_enable_disable_t *mp;
7363 u8 sw_if_index_set = 0;
7366 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7368 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7369 sw_if_index_set = 1;
7370 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7371 sw_if_index_set = 1;
7372 else if (unformat (i, "enable"))
7374 else if (unformat (i, "disable"))
7378 clib_warning ("parse error '%U'", format_unformat_error, i);
7383 if (sw_if_index_set == 0)
7385 errmsg ("missing interface name or sw_if_index\n");
7389 M (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable);
7391 mp->sw_if_index = ntohl (sw_if_index);
7392 mp->enable = enable;
7401 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7403 unformat_input_t *i = vam->input;
7404 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7407 u8 sw_if_index_set = 0;
7408 u32 address_length = 0;
7409 u8 v6_address_set = 0;
7410 ip6_address_t v6address;
7412 /* Parse args required to build the message */
7413 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7415 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7416 sw_if_index_set = 1;
7417 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7418 sw_if_index_set = 1;
7419 else if (unformat (i, "%U/%d",
7420 unformat_ip6_address, &v6address, &address_length))
7426 if (sw_if_index_set == 0)
7428 errmsg ("missing interface name or sw_if_index\n");
7431 if (!v6_address_set)
7433 errmsg ("no address set\n");
7437 /* Construct the API message */
7438 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,
7439 sw_interface_ip6_set_link_local_address);
7441 mp->sw_if_index = ntohl (sw_if_index);
7442 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7443 mp->address_length = address_length;
7448 /* Wait for a reply, return good/bad news */
7457 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
7459 unformat_input_t *i = vam->input;
7460 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
7463 u8 sw_if_index_set = 0;
7464 u32 address_length = 0;
7465 u8 v6_address_set = 0;
7466 ip6_address_t v6address;
7468 u8 no_advertise = 0;
7470 u8 no_autoconfig = 0;
7473 u32 val_lifetime = 0;
7474 u32 pref_lifetime = 0;
7476 /* Parse args required to build the message */
7477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7479 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7480 sw_if_index_set = 1;
7481 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7482 sw_if_index_set = 1;
7483 else if (unformat (i, "%U/%d",
7484 unformat_ip6_address, &v6address, &address_length))
7486 else if (unformat (i, "val_life %d", &val_lifetime))
7488 else if (unformat (i, "pref_life %d", &pref_lifetime))
7490 else if (unformat (i, "def"))
7492 else if (unformat (i, "noadv"))
7494 else if (unformat (i, "offl"))
7496 else if (unformat (i, "noauto"))
7498 else if (unformat (i, "nolink"))
7500 else if (unformat (i, "isno"))
7504 clib_warning ("parse error '%U'", format_unformat_error, i);
7509 if (sw_if_index_set == 0)
7511 errmsg ("missing interface name or sw_if_index\n");
7514 if (!v6_address_set)
7516 errmsg ("no address set\n");
7520 /* Construct the API message */
7521 M (SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix);
7523 mp->sw_if_index = ntohl (sw_if_index);
7524 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7525 mp->address_length = address_length;
7526 mp->use_default = use_default;
7527 mp->no_advertise = no_advertise;
7528 mp->off_link = off_link;
7529 mp->no_autoconfig = no_autoconfig;
7530 mp->no_onlink = no_onlink;
7532 mp->val_lifetime = ntohl (val_lifetime);
7533 mp->pref_lifetime = ntohl (pref_lifetime);
7538 /* Wait for a reply, return good/bad news */
7546 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
7548 unformat_input_t *i = vam->input;
7549 vl_api_sw_interface_ip6nd_ra_config_t *mp;
7552 u8 sw_if_index_set = 0;
7557 u8 send_unicast = 0;
7560 u8 default_router = 0;
7561 u32 max_interval = 0;
7562 u32 min_interval = 0;
7564 u32 initial_count = 0;
7565 u32 initial_interval = 0;
7568 /* Parse args required to build the message */
7569 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7571 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7572 sw_if_index_set = 1;
7573 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7574 sw_if_index_set = 1;
7575 else if (unformat (i, "maxint %d", &max_interval))
7577 else if (unformat (i, "minint %d", &min_interval))
7579 else if (unformat (i, "life %d", &lifetime))
7581 else if (unformat (i, "count %d", &initial_count))
7583 else if (unformat (i, "interval %d", &initial_interval))
7585 else if (unformat (i, "suppress") || unformat (i, "surpress"))
7587 else if (unformat (i, "managed"))
7589 else if (unformat (i, "other"))
7591 else if (unformat (i, "ll"))
7593 else if (unformat (i, "send"))
7595 else if (unformat (i, "cease"))
7597 else if (unformat (i, "isno"))
7599 else if (unformat (i, "def"))
7603 clib_warning ("parse error '%U'", format_unformat_error, i);
7608 if (sw_if_index_set == 0)
7610 errmsg ("missing interface name or sw_if_index\n");
7614 /* Construct the API message */
7615 M (SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config);
7617 mp->sw_if_index = ntohl (sw_if_index);
7618 mp->max_interval = ntohl (max_interval);
7619 mp->min_interval = ntohl (min_interval);
7620 mp->lifetime = ntohl (lifetime);
7621 mp->initial_count = ntohl (initial_count);
7622 mp->initial_interval = ntohl (initial_interval);
7623 mp->suppress = suppress;
7624 mp->managed = managed;
7626 mp->ll_option = ll_option;
7627 mp->send_unicast = send_unicast;
7630 mp->default_router = default_router;
7635 /* Wait for a reply, return good/bad news */
7643 api_set_arp_neighbor_limit (vat_main_t * vam)
7645 unformat_input_t *i = vam->input;
7646 vl_api_set_arp_neighbor_limit_t *mp;
7652 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7654 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
7656 else if (unformat (i, "ipv6"))
7660 clib_warning ("parse error '%U'", format_unformat_error, i);
7667 errmsg ("missing limit value\n");
7671 M (SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit);
7673 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
7674 mp->is_ipv6 = is_ipv6;
7683 api_l2_patch_add_del (vat_main_t * vam)
7685 unformat_input_t *i = vam->input;
7686 vl_api_l2_patch_add_del_t *mp;
7689 u8 rx_sw_if_index_set = 0;
7691 u8 tx_sw_if_index_set = 0;
7694 /* Parse args required to build the message */
7695 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7697 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7698 rx_sw_if_index_set = 1;
7699 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7700 tx_sw_if_index_set = 1;
7701 else if (unformat (i, "rx"))
7703 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7705 if (unformat (i, "%U", unformat_sw_if_index, vam,
7707 rx_sw_if_index_set = 1;
7712 else if (unformat (i, "tx"))
7714 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7716 if (unformat (i, "%U", unformat_sw_if_index, vam,
7718 tx_sw_if_index_set = 1;
7723 else if (unformat (i, "del"))
7729 if (rx_sw_if_index_set == 0)
7731 errmsg ("missing rx interface name or rx_sw_if_index\n");
7735 if (tx_sw_if_index_set == 0)
7737 errmsg ("missing tx interface name or tx_sw_if_index\n");
7741 M (L2_PATCH_ADD_DEL, l2_patch_add_del);
7743 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7744 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7745 mp->is_add = is_add;
7754 api_ioam_enable (vat_main_t * vam)
7756 unformat_input_t *input = vam->input;
7757 vl_api_ioam_enable_t *mp;
7760 int has_trace_option = 0;
7761 int has_pot_option = 0;
7762 int has_seqno_option = 0;
7763 int has_analyse_option = 0;
7765 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7767 if (unformat (input, "trace"))
7768 has_trace_option = 1;
7769 else if (unformat (input, "pot"))
7771 else if (unformat (input, "seqno"))
7772 has_seqno_option = 1;
7773 else if (unformat (input, "analyse"))
7774 has_analyse_option = 1;
7778 M (IOAM_ENABLE, ioam_enable);
7779 mp->id = htons (id);
7780 mp->seqno = has_seqno_option;
7781 mp->analyse = has_analyse_option;
7782 mp->pot_enable = has_pot_option;
7783 mp->trace_enable = has_trace_option;
7794 api_ioam_disable (vat_main_t * vam)
7796 vl_api_ioam_disable_t *mp;
7799 M (IOAM_DISABLE, ioam_disable);
7806 api_sr_tunnel_add_del (vat_main_t * vam)
7808 unformat_input_t *i = vam->input;
7809 vl_api_sr_tunnel_add_del_t *mp;
7813 ip6_address_t src_address;
7814 int src_address_set = 0;
7815 ip6_address_t dst_address;
7817 int dst_address_set = 0;
7819 u32 rx_table_id = 0;
7820 u32 tx_table_id = 0;
7821 ip6_address_t *segments = 0;
7822 ip6_address_t *this_seg;
7823 ip6_address_t *tags = 0;
7824 ip6_address_t *this_tag;
7825 ip6_address_t next_address, tag;
7827 u8 *policy_name = 0;
7829 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7831 if (unformat (i, "del"))
7833 else if (unformat (i, "name %s", &name))
7835 else if (unformat (i, "policy %s", &policy_name))
7837 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
7839 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
7841 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
7842 src_address_set = 1;
7843 else if (unformat (i, "dst %U/%d",
7844 unformat_ip6_address, &dst_address, &dst_mask_width))
7845 dst_address_set = 1;
7846 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
7848 vec_add2 (segments, this_seg, 1);
7849 clib_memcpy (this_seg->as_u8, next_address.as_u8,
7850 sizeof (*this_seg));
7852 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
7854 vec_add2 (tags, this_tag, 1);
7855 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
7857 else if (unformat (i, "clean"))
7858 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
7859 else if (unformat (i, "protected"))
7860 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
7861 else if (unformat (i, "InPE %d", &pl_index))
7863 if (pl_index <= 0 || pl_index > 4)
7865 pl_index_range_error:
7866 errmsg ("pl index %d out of range\n", pl_index);
7870 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
7872 else if (unformat (i, "EgPE %d", &pl_index))
7874 if (pl_index <= 0 || pl_index > 4)
7875 goto pl_index_range_error;
7877 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
7879 else if (unformat (i, "OrgSrc %d", &pl_index))
7881 if (pl_index <= 0 || pl_index > 4)
7882 goto pl_index_range_error;
7884 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
7890 if (!src_address_set)
7892 errmsg ("src address required\n");
7896 if (!dst_address_set)
7898 errmsg ("dst address required\n");
7904 errmsg ("at least one sr segment required\n");
7908 M2 (SR_TUNNEL_ADD_DEL, sr_tunnel_add_del,
7909 vec_len (segments) * sizeof (ip6_address_t)
7910 + vec_len (tags) * sizeof (ip6_address_t));
7912 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
7913 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
7914 mp->dst_mask_width = dst_mask_width;
7915 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
7916 mp->n_segments = vec_len (segments);
7917 mp->n_tags = vec_len (tags);
7918 mp->is_add = is_del == 0;
7919 clib_memcpy (mp->segs_and_tags, segments,
7920 vec_len (segments) * sizeof (ip6_address_t));
7921 clib_memcpy (mp->segs_and_tags +
7922 vec_len (segments) * sizeof (ip6_address_t), tags,
7923 vec_len (tags) * sizeof (ip6_address_t));
7925 mp->outer_vrf_id = ntohl (rx_table_id);
7926 mp->inner_vrf_id = ntohl (tx_table_id);
7927 memcpy (mp->name, name, vec_len (name));
7928 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
7930 vec_free (segments);
7939 api_sr_policy_add_del (vat_main_t * vam)
7941 unformat_input_t *input = vam->input;
7942 vl_api_sr_policy_add_del_t *mp;
7946 u8 *tunnel_name = 0;
7947 u8 **tunnel_names = 0;
7952 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
7953 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
7955 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7957 if (unformat (input, "del"))
7959 else if (unformat (input, "name %s", &name))
7961 else if (unformat (input, "tunnel %s", &tunnel_name))
7965 vec_add1 (tunnel_names, tunnel_name);
7967 - length = #bytes to store in serial vector
7968 - +1 = byte to store that length
7970 tunnel_names_length += (vec_len (tunnel_name) + 1);
7981 errmsg ("policy name required\n");
7985 if ((!tunnel_set) && (!is_del))
7987 errmsg ("tunnel name required\n");
7991 M2 (SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length);
7995 mp->is_add = !is_del;
7997 memcpy (mp->name, name, vec_len (name));
7998 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
7999 u8 *serial_orig = 0;
8000 vec_validate (serial_orig, tunnel_names_length);
8001 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
8002 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
8004 for (j = 0; j < vec_len (tunnel_names); j++)
8006 tun_name_len = vec_len (tunnel_names[j]);
8007 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
8008 serial_orig += 1; // Move along one byte to store the actual tunnel name
8009 memcpy (serial_orig, tunnel_names[j], tun_name_len);
8010 serial_orig += tun_name_len; // Advance past the copy
8012 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
8014 vec_free (tunnel_names);
8015 vec_free (tunnel_name);
8023 api_sr_multicast_map_add_del (vat_main_t * vam)
8025 unformat_input_t *input = vam->input;
8026 vl_api_sr_multicast_map_add_del_t *mp;
8029 ip6_address_t multicast_address;
8030 u8 *policy_name = 0;
8031 int multicast_address_set = 0;
8033 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8035 if (unformat (input, "del"))
8039 (input, "address %U", unformat_ip6_address, &multicast_address))
8040 multicast_address_set = 1;
8041 else if (unformat (input, "sr-policy %s", &policy_name))
8047 if (!is_del && !policy_name)
8049 errmsg ("sr-policy name required\n");
8054 if (!multicast_address_set)
8056 errmsg ("address required\n");
8060 M (SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del);
8062 mp->is_add = !is_del;
8063 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8064 clib_memcpy (mp->multicast_address, &multicast_address,
8065 sizeof (mp->multicast_address));
8068 vec_free (policy_name);
8076 #define foreach_tcp_proto_field \
8080 #define foreach_udp_proto_field \
8084 #define foreach_ip4_proto_field \
8095 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8097 u8 **maskp = va_arg (*args, u8 **);
8099 u8 found_something = 0;
8102 #define _(a) u8 a=0;
8103 foreach_tcp_proto_field;
8106 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8109 #define _(a) else if (unformat (input, #a)) a=1;
8110 foreach_tcp_proto_field
8116 #define _(a) found_something += a;
8117 foreach_tcp_proto_field;
8120 if (found_something == 0)
8123 vec_validate (mask, sizeof (*tcp) - 1);
8125 tcp = (tcp_header_t *) mask;
8127 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8128 foreach_tcp_proto_field;
8136 unformat_udp_mask (unformat_input_t * input, va_list * args)
8138 u8 **maskp = va_arg (*args, u8 **);
8140 u8 found_something = 0;
8143 #define _(a) u8 a=0;
8144 foreach_udp_proto_field;
8147 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8150 #define _(a) else if (unformat (input, #a)) a=1;
8151 foreach_udp_proto_field
8157 #define _(a) found_something += a;
8158 foreach_udp_proto_field;
8161 if (found_something == 0)
8164 vec_validate (mask, sizeof (*udp) - 1);
8166 udp = (udp_header_t *) mask;
8168 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8169 foreach_udp_proto_field;
8178 u16 src_port, dst_port;
8182 unformat_l4_mask (unformat_input_t * input, va_list * args)
8184 u8 **maskp = va_arg (*args, u8 **);
8185 u16 src_port = 0, dst_port = 0;
8186 tcpudp_header_t *tcpudp;
8188 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8190 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8192 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8194 else if (unformat (input, "src_port"))
8196 else if (unformat (input, "dst_port"))
8202 if (!src_port && !dst_port)
8206 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8208 tcpudp = (tcpudp_header_t *) mask;
8209 tcpudp->src_port = src_port;
8210 tcpudp->dst_port = dst_port;
8218 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8220 u8 **maskp = va_arg (*args, u8 **);
8222 u8 found_something = 0;
8225 #define _(a) u8 a=0;
8226 foreach_ip4_proto_field;
8232 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8234 if (unformat (input, "version"))
8236 else if (unformat (input, "hdr_length"))
8238 else if (unformat (input, "src"))
8240 else if (unformat (input, "dst"))
8242 else if (unformat (input, "proto"))
8245 #define _(a) else if (unformat (input, #a)) a=1;
8246 foreach_ip4_proto_field
8252 #define _(a) found_something += a;
8253 foreach_ip4_proto_field;
8256 if (found_something == 0)
8259 vec_validate (mask, sizeof (*ip) - 1);
8261 ip = (ip4_header_t *) mask;
8263 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8264 foreach_ip4_proto_field;
8267 ip->ip_version_and_header_length = 0;
8270 ip->ip_version_and_header_length |= 0xF0;
8273 ip->ip_version_and_header_length |= 0x0F;
8279 #define foreach_ip6_proto_field \
8287 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8289 u8 **maskp = va_arg (*args, u8 **);
8291 u8 found_something = 0;
8293 u32 ip_version_traffic_class_and_flow_label;
8295 #define _(a) u8 a=0;
8296 foreach_ip6_proto_field;
8299 u8 traffic_class = 0;
8302 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8304 if (unformat (input, "version"))
8306 else if (unformat (input, "traffic-class"))
8308 else if (unformat (input, "flow-label"))
8310 else if (unformat (input, "src"))
8312 else if (unformat (input, "dst"))
8314 else if (unformat (input, "proto"))
8317 #define _(a) else if (unformat (input, #a)) a=1;
8318 foreach_ip6_proto_field
8324 #define _(a) found_something += a;
8325 foreach_ip6_proto_field;
8328 if (found_something == 0)
8331 vec_validate (mask, sizeof (*ip) - 1);
8333 ip = (ip6_header_t *) mask;
8335 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8336 foreach_ip6_proto_field;
8339 ip_version_traffic_class_and_flow_label = 0;
8342 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8345 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8348 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8350 ip->ip_version_traffic_class_and_flow_label =
8351 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8358 unformat_l3_mask (unformat_input_t * input, va_list * args)
8360 u8 **maskp = va_arg (*args, u8 **);
8362 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8364 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8366 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8375 unformat_l2_mask (unformat_input_t * input, va_list * args)
8377 u8 **maskp = va_arg (*args, u8 **);
8392 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8394 if (unformat (input, "src"))
8396 else if (unformat (input, "dst"))
8398 else if (unformat (input, "proto"))
8400 else if (unformat (input, "tag1"))
8402 else if (unformat (input, "tag2"))
8404 else if (unformat (input, "ignore-tag1"))
8406 else if (unformat (input, "ignore-tag2"))
8408 else if (unformat (input, "cos1"))
8410 else if (unformat (input, "cos2"))
8412 else if (unformat (input, "dot1q"))
8414 else if (unformat (input, "dot1ad"))
8419 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8420 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8423 if (tag1 || ignore_tag1 || cos1 || dot1q)
8425 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8428 vec_validate (mask, len - 1);
8431 memset (mask, 0xff, 6);
8434 memset (mask + 6, 0xff, 6);
8438 /* inner vlan tag */
8447 mask[21] = mask[20] = 0xff;
8468 mask[16] = mask[17] = 0xff;
8478 mask[12] = mask[13] = 0xff;
8485 unformat_classify_mask (unformat_input_t * input, va_list * args)
8487 u8 **maskp = va_arg (*args, u8 **);
8488 u32 *skipp = va_arg (*args, u32 *);
8489 u32 *matchp = va_arg (*args, u32 *);
8497 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8499 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8501 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8503 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8505 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
8519 if (mask || l2 || l3 || l4)
8523 /* "With a free Ethernet header in every package" */
8525 vec_validate (l2, 13);
8529 vec_append (mask, l3);
8534 vec_append (mask, l4);
8539 /* Scan forward looking for the first significant mask octet */
8540 for (i = 0; i < vec_len (mask); i++)
8544 /* compute (skip, match) params */
8545 *skipp = i / sizeof (u32x4);
8546 vec_delete (mask, *skipp * sizeof (u32x4), 0);
8548 /* Pad mask to an even multiple of the vector size */
8549 while (vec_len (mask) % sizeof (u32x4))
8552 match = vec_len (mask) / sizeof (u32x4);
8554 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
8556 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
8557 if (*tmp || *(tmp + 1))
8562 clib_warning ("BUG: match 0");
8564 _vec_len (mask) = match * sizeof (u32x4);
8575 #define foreach_l2_next \
8577 _(ethernet, ETHERNET_INPUT) \
8582 unformat_l2_next_index (unformat_input_t * input, va_list * args)
8584 u32 *miss_next_indexp = va_arg (*args, u32 *);
8589 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
8593 if (unformat (input, "%d", &tmp))
8602 *miss_next_indexp = next_index;
8606 #define foreach_ip_next \
8612 unformat_ip_next_index (unformat_input_t * input, va_list * args)
8614 u32 *miss_next_indexp = va_arg (*args, u32 *);
8619 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
8623 if (unformat (input, "%d", &tmp))
8632 *miss_next_indexp = next_index;
8636 #define foreach_acl_next \
8640 unformat_acl_next_index (unformat_input_t * input, va_list * args)
8642 u32 *miss_next_indexp = va_arg (*args, u32 *);
8647 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
8651 if (unformat (input, "permit"))
8656 else if (unformat (input, "%d", &tmp))
8665 *miss_next_indexp = next_index;
8670 unformat_policer_precolor (unformat_input_t * input, va_list * args)
8672 u32 *r = va_arg (*args, u32 *);
8674 if (unformat (input, "conform-color"))
8675 *r = POLICE_CONFORM;
8676 else if (unformat (input, "exceed-color"))
8685 api_classify_add_del_table (vat_main_t * vam)
8687 unformat_input_t *i = vam->input;
8688 vl_api_classify_add_del_table_t *mp;
8694 u32 table_index = ~0;
8695 u32 next_table_index = ~0;
8696 u32 miss_next_index = ~0;
8697 u32 memory_size = 32 << 20;
8700 u32 current_data_flag = 0;
8701 int current_data_offset = 0;
8703 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8705 if (unformat (i, "del"))
8707 else if (unformat (i, "buckets %d", &nbuckets))
8709 else if (unformat (i, "memory_size %d", &memory_size))
8711 else if (unformat (i, "skip %d", &skip))
8713 else if (unformat (i, "match %d", &match))
8715 else if (unformat (i, "table %d", &table_index))
8717 else if (unformat (i, "mask %U", unformat_classify_mask,
8718 &mask, &skip, &match))
8720 else if (unformat (i, "next-table %d", &next_table_index))
8722 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
8725 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
8728 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
8731 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
8733 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
8739 if (is_add && mask == 0)
8741 errmsg ("Mask required\n");
8745 if (is_add && skip == ~0)
8747 errmsg ("skip count required\n");
8751 if (is_add && match == ~0)
8753 errmsg ("match count required\n");
8757 if (!is_add && table_index == ~0)
8759 errmsg ("table index required for delete\n");
8763 M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask));
8765 mp->is_add = is_add;
8766 mp->table_index = ntohl (table_index);
8767 mp->nbuckets = ntohl (nbuckets);
8768 mp->memory_size = ntohl (memory_size);
8769 mp->skip_n_vectors = ntohl (skip);
8770 mp->match_n_vectors = ntohl (match);
8771 mp->next_table_index = ntohl (next_table_index);
8772 mp->miss_next_index = ntohl (miss_next_index);
8773 mp->current_data_flag = ntohl (current_data_flag);
8774 mp->current_data_offset = ntohl (current_data_offset);
8775 clib_memcpy (mp->mask, mask, vec_len (mask));
8785 unformat_l4_match (unformat_input_t * input, va_list * args)
8787 u8 **matchp = va_arg (*args, u8 **);
8789 u8 *proto_header = 0;
8795 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8797 if (unformat (input, "src_port %d", &src_port))
8799 else if (unformat (input, "dst_port %d", &dst_port))
8805 h.src_port = clib_host_to_net_u16 (src_port);
8806 h.dst_port = clib_host_to_net_u16 (dst_port);
8807 vec_validate (proto_header, sizeof (h) - 1);
8808 memcpy (proto_header, &h, sizeof (h));
8810 *matchp = proto_header;
8816 unformat_ip4_match (unformat_input_t * input, va_list * args)
8818 u8 **matchp = va_arg (*args, u8 **);
8825 int src = 0, dst = 0;
8826 ip4_address_t src_val, dst_val;
8833 int fragment_id = 0;
8834 u32 fragment_id_val;
8840 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8842 if (unformat (input, "version %d", &version_val))
8844 else if (unformat (input, "hdr_length %d", &hdr_length_val))
8846 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
8848 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
8850 else if (unformat (input, "proto %d", &proto_val))
8852 else if (unformat (input, "tos %d", &tos_val))
8854 else if (unformat (input, "length %d", &length_val))
8856 else if (unformat (input, "fragment_id %d", &fragment_id_val))
8858 else if (unformat (input, "ttl %d", &ttl_val))
8860 else if (unformat (input, "checksum %d", &checksum_val))
8866 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
8867 + ttl + checksum == 0)
8871 * Aligned because we use the real comparison functions
8873 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
8875 ip = (ip4_header_t *) match;
8877 /* These are realistically matched in practice */
8879 ip->src_address.as_u32 = src_val.as_u32;
8882 ip->dst_address.as_u32 = dst_val.as_u32;
8885 ip->protocol = proto_val;
8888 /* These are not, but they're included for completeness */
8890 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
8893 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
8899 ip->length = clib_host_to_net_u16 (length_val);
8905 ip->checksum = clib_host_to_net_u16 (checksum_val);
8912 unformat_ip6_match (unformat_input_t * input, va_list * args)
8914 u8 **matchp = va_arg (*args, u8 **);
8919 u8 traffic_class = 0;
8920 u32 traffic_class_val = 0;
8923 int src = 0, dst = 0;
8924 ip6_address_t src_val, dst_val;
8927 int payload_length = 0;
8928 u32 payload_length_val;
8931 u32 ip_version_traffic_class_and_flow_label;
8933 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8935 if (unformat (input, "version %d", &version_val))
8937 else if (unformat (input, "traffic_class %d", &traffic_class_val))
8939 else if (unformat (input, "flow_label %d", &flow_label_val))
8941 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
8943 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
8945 else if (unformat (input, "proto %d", &proto_val))
8947 else if (unformat (input, "payload_length %d", &payload_length_val))
8949 else if (unformat (input, "hop_limit %d", &hop_limit_val))
8955 if (version + traffic_class + flow_label + src + dst + proto +
8956 payload_length + hop_limit == 0)
8960 * Aligned because we use the real comparison functions
8962 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
8964 ip = (ip6_header_t *) match;
8967 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
8970 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
8973 ip->protocol = proto_val;
8975 ip_version_traffic_class_and_flow_label = 0;
8978 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
8981 ip_version_traffic_class_and_flow_label |=
8982 (traffic_class_val & 0xFF) << 20;
8985 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
8987 ip->ip_version_traffic_class_and_flow_label =
8988 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8991 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
8994 ip->hop_limit = hop_limit_val;
9001 unformat_l3_match (unformat_input_t * input, va_list * args)
9003 u8 **matchp = va_arg (*args, u8 **);
9005 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9007 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9009 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9018 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9020 u8 *tagp = va_arg (*args, u8 *);
9023 if (unformat (input, "%d", &tag))
9025 tagp[0] = (tag >> 8) & 0x0F;
9026 tagp[1] = tag & 0xFF;
9034 unformat_l2_match (unformat_input_t * input, va_list * args)
9036 u8 **matchp = va_arg (*args, u8 **);
9056 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9058 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9061 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9063 else if (unformat (input, "proto %U",
9064 unformat_ethernet_type_host_byte_order, &proto_val))
9066 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9068 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9070 else if (unformat (input, "ignore-tag1"))
9072 else if (unformat (input, "ignore-tag2"))
9074 else if (unformat (input, "cos1 %d", &cos1_val))
9076 else if (unformat (input, "cos2 %d", &cos2_val))
9081 if ((src + dst + proto + tag1 + tag2 +
9082 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9085 if (tag1 || ignore_tag1 || cos1)
9087 if (tag2 || ignore_tag2 || cos2)
9090 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9093 clib_memcpy (match, dst_val, 6);
9096 clib_memcpy (match + 6, src_val, 6);
9100 /* inner vlan tag */
9101 match[19] = tag2_val[1];
9102 match[18] = tag2_val[0];
9104 match[18] |= (cos2_val & 0x7) << 5;
9107 match[21] = proto_val & 0xff;
9108 match[20] = proto_val >> 8;
9112 match[15] = tag1_val[1];
9113 match[14] = tag1_val[0];
9116 match[14] |= (cos1_val & 0x7) << 5;
9122 match[15] = tag1_val[1];
9123 match[14] = tag1_val[0];
9126 match[17] = proto_val & 0xff;
9127 match[16] = proto_val >> 8;
9130 match[14] |= (cos1_val & 0x7) << 5;
9136 match[18] |= (cos2_val & 0x7) << 5;
9138 match[14] |= (cos1_val & 0x7) << 5;
9141 match[13] = proto_val & 0xff;
9142 match[12] = proto_val >> 8;
9151 unformat_classify_match (unformat_input_t * input, va_list * args)
9153 u8 **matchp = va_arg (*args, u8 **);
9154 u32 skip_n_vectors = va_arg (*args, u32);
9155 u32 match_n_vectors = va_arg (*args, u32);
9162 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9164 if (unformat (input, "hex %U", unformat_hex_string, &match))
9166 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9168 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9170 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9184 if (match || l2 || l3 || l4)
9188 /* "Win a free Ethernet header in every packet" */
9190 vec_validate_aligned (l2, 13, sizeof (u32x4));
9194 vec_append_aligned (match, l3, sizeof (u32x4));
9199 vec_append_aligned (match, l4, sizeof (u32x4));
9204 /* Make sure the vector is big enough even if key is all 0's */
9205 vec_validate_aligned
9206 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9209 /* Set size, include skipped vectors */
9210 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9221 api_classify_add_del_session (vat_main_t * vam)
9223 unformat_input_t *i = vam->input;
9224 vl_api_classify_add_del_session_t *mp;
9226 u32 table_index = ~0;
9227 u32 hit_next_index = ~0;
9228 u32 opaque_index = ~0;
9232 u32 skip_n_vectors = 0;
9233 u32 match_n_vectors = 0;
9238 * Warning: you have to supply skip_n and match_n
9239 * because the API client cant simply look at the classify
9243 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9245 if (unformat (i, "del"))
9247 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
9250 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9253 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
9256 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9258 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9260 else if (unformat (i, "opaque-index %d", &opaque_index))
9262 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9264 else if (unformat (i, "match_n %d", &match_n_vectors))
9266 else if (unformat (i, "match %U", unformat_classify_match,
9267 &match, skip_n_vectors, match_n_vectors))
9269 else if (unformat (i, "advance %d", &advance))
9271 else if (unformat (i, "table-index %d", &table_index))
9273 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9275 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9277 else if (unformat (i, "action %d", &action))
9279 else if (unformat (i, "metadata %d", &metadata))
9285 if (table_index == ~0)
9287 errmsg ("Table index required\n");
9291 if (is_add && match == 0)
9293 errmsg ("Match value required\n");
9297 M2 (CLASSIFY_ADD_DEL_SESSION, classify_add_del_session, vec_len (match));
9299 mp->is_add = is_add;
9300 mp->table_index = ntohl (table_index);
9301 mp->hit_next_index = ntohl (hit_next_index);
9302 mp->opaque_index = ntohl (opaque_index);
9303 mp->advance = ntohl (advance);
9304 mp->action = action;
9305 mp->metadata = ntohl (metadata);
9306 clib_memcpy (mp->match, match, vec_len (match));
9315 api_classify_set_interface_ip_table (vat_main_t * vam)
9317 unformat_input_t *i = vam->input;
9318 vl_api_classify_set_interface_ip_table_t *mp;
9321 int sw_if_index_set;
9322 u32 table_index = ~0;
9325 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9327 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9328 sw_if_index_set = 1;
9329 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9330 sw_if_index_set = 1;
9331 else if (unformat (i, "table %d", &table_index))
9335 clib_warning ("parse error '%U'", format_unformat_error, i);
9340 if (sw_if_index_set == 0)
9342 errmsg ("missing interface name or sw_if_index\n");
9347 M (CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table);
9349 mp->sw_if_index = ntohl (sw_if_index);
9350 mp->table_index = ntohl (table_index);
9351 mp->is_ipv6 = is_ipv6;
9360 api_classify_set_interface_l2_tables (vat_main_t * vam)
9362 unformat_input_t *i = vam->input;
9363 vl_api_classify_set_interface_l2_tables_t *mp;
9366 int sw_if_index_set;
9367 u32 ip4_table_index = ~0;
9368 u32 ip6_table_index = ~0;
9369 u32 other_table_index = ~0;
9372 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9374 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9375 sw_if_index_set = 1;
9376 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9377 sw_if_index_set = 1;
9378 else if (unformat (i, "ip4-table %d", &ip4_table_index))
9380 else if (unformat (i, "ip6-table %d", &ip6_table_index))
9382 else if (unformat (i, "other-table %d", &other_table_index))
9384 else if (unformat (i, "is-input %d", &is_input))
9388 clib_warning ("parse error '%U'", format_unformat_error, i);
9393 if (sw_if_index_set == 0)
9395 errmsg ("missing interface name or sw_if_index\n");
9400 M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables);
9402 mp->sw_if_index = ntohl (sw_if_index);
9403 mp->ip4_table_index = ntohl (ip4_table_index);
9404 mp->ip6_table_index = ntohl (ip6_table_index);
9405 mp->other_table_index = ntohl (other_table_index);
9406 mp->is_input = (u8) is_input;
9415 api_set_ipfix_exporter (vat_main_t * vam)
9417 unformat_input_t *i = vam->input;
9418 vl_api_set_ipfix_exporter_t *mp;
9419 ip4_address_t collector_address;
9420 u8 collector_address_set = 0;
9421 u32 collector_port = ~0;
9422 ip4_address_t src_address;
9423 u8 src_address_set = 0;
9426 u32 template_interval = ~0;
9427 u8 udp_checksum = 0;
9430 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9432 if (unformat (i, "collector_address %U", unformat_ip4_address,
9433 &collector_address))
9434 collector_address_set = 1;
9435 else if (unformat (i, "collector_port %d", &collector_port))
9437 else if (unformat (i, "src_address %U", unformat_ip4_address,
9439 src_address_set = 1;
9440 else if (unformat (i, "vrf_id %d", &vrf_id))
9442 else if (unformat (i, "path_mtu %d", &path_mtu))
9444 else if (unformat (i, "template_interval %d", &template_interval))
9446 else if (unformat (i, "udp_checksum"))
9452 if (collector_address_set == 0)
9454 errmsg ("collector_address required\n");
9458 if (src_address_set == 0)
9460 errmsg ("src_address required\n");
9464 M (SET_IPFIX_EXPORTER, set_ipfix_exporter);
9466 memcpy (mp->collector_address, collector_address.data,
9467 sizeof (collector_address.data));
9468 mp->collector_port = htons ((u16) collector_port);
9469 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
9470 mp->vrf_id = htonl (vrf_id);
9471 mp->path_mtu = htonl (path_mtu);
9472 mp->template_interval = htonl (template_interval);
9473 mp->udp_checksum = udp_checksum;
9481 api_set_ipfix_classify_stream (vat_main_t * vam)
9483 unformat_input_t *i = vam->input;
9484 vl_api_set_ipfix_classify_stream_t *mp;
9486 u32 src_port = UDP_DST_PORT_ipfix;
9489 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9491 if (unformat (i, "domain %d", &domain_id))
9493 else if (unformat (i, "src_port %d", &src_port))
9497 errmsg ("unknown input `%U'", format_unformat_error, i);
9502 M (SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream);
9504 mp->domain_id = htonl (domain_id);
9505 mp->src_port = htons ((u16) src_port);
9513 api_ipfix_classify_table_add_del (vat_main_t * vam)
9515 unformat_input_t *i = vam->input;
9516 vl_api_ipfix_classify_table_add_del_t *mp;
9518 u32 classify_table_index = ~0;
9520 u8 transport_protocol = 255;
9523 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9525 if (unformat (i, "add"))
9527 else if (unformat (i, "del"))
9529 else if (unformat (i, "table %d", &classify_table_index))
9531 else if (unformat (i, "ip4"))
9533 else if (unformat (i, "ip6"))
9535 else if (unformat (i, "tcp"))
9536 transport_protocol = 6;
9537 else if (unformat (i, "udp"))
9538 transport_protocol = 17;
9541 errmsg ("unknown input `%U'", format_unformat_error, i);
9548 errmsg ("expecting: add|del");
9551 if (classify_table_index == ~0)
9553 errmsg ("classifier table not specified");
9556 if (ip_version == 0)
9558 errmsg ("IP version not specified");
9562 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del);
9564 mp->is_add = is_add;
9565 mp->table_id = htonl (classify_table_index);
9566 mp->ip_version = ip_version;
9567 mp->transport_protocol = transport_protocol;
9575 api_get_node_index (vat_main_t * vam)
9577 unformat_input_t *i = vam->input;
9578 vl_api_get_node_index_t *mp;
9582 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9584 if (unformat (i, "node %s", &name))
9591 errmsg ("node name required\n");
9594 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9596 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9600 M (GET_NODE_INDEX, get_node_index);
9601 clib_memcpy (mp->node_name, name, vec_len (name));
9611 api_get_next_index (vat_main_t * vam)
9613 unformat_input_t *i = vam->input;
9614 vl_api_get_next_index_t *mp;
9616 u8 *node_name = 0, *next_node_name = 0;
9618 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9620 if (unformat (i, "node-name %s", &node_name))
9622 else if (unformat (i, "next-node-name %s", &next_node_name))
9628 errmsg ("node name required\n");
9631 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
9633 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9637 if (next_node_name == 0)
9639 errmsg ("next node name required\n");
9642 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
9644 errmsg ("next node name too long, max %d\n", ARRAY_LEN (mp->next_name));
9648 M (GET_NEXT_INDEX, get_next_index);
9649 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
9650 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
9651 vec_free (node_name);
9652 vec_free (next_node_name);
9661 api_add_node_next (vat_main_t * vam)
9663 unformat_input_t *i = vam->input;
9664 vl_api_add_node_next_t *mp;
9669 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9671 if (unformat (i, "node %s", &name))
9673 else if (unformat (i, "next %s", &next))
9680 errmsg ("node name required\n");
9683 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9685 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9690 errmsg ("next node required\n");
9693 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
9695 errmsg ("next name too long, max %d\n", ARRAY_LEN (mp->next_name));
9699 M (ADD_NODE_NEXT, add_node_next);
9700 clib_memcpy (mp->node_name, name, vec_len (name));
9701 clib_memcpy (mp->next_name, next, vec_len (next));
9712 api_l2tpv3_create_tunnel (vat_main_t * vam)
9714 unformat_input_t *i = vam->input;
9715 ip6_address_t client_address, our_address;
9716 int client_address_set = 0;
9717 int our_address_set = 0;
9718 u32 local_session_id = 0;
9719 u32 remote_session_id = 0;
9720 u64 local_cookie = 0;
9721 u64 remote_cookie = 0;
9722 u8 l2_sublayer_present = 0;
9723 vl_api_l2tpv3_create_tunnel_t *mp;
9726 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9728 if (unformat (i, "client_address %U", unformat_ip6_address,
9730 client_address_set = 1;
9731 else if (unformat (i, "our_address %U", unformat_ip6_address,
9733 our_address_set = 1;
9734 else if (unformat (i, "local_session_id %d", &local_session_id))
9736 else if (unformat (i, "remote_session_id %d", &remote_session_id))
9738 else if (unformat (i, "local_cookie %lld", &local_cookie))
9740 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
9742 else if (unformat (i, "l2-sublayer-present"))
9743 l2_sublayer_present = 1;
9748 if (client_address_set == 0)
9750 errmsg ("client_address required\n");
9754 if (our_address_set == 0)
9756 errmsg ("our_address required\n");
9760 M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel);
9762 clib_memcpy (mp->client_address, client_address.as_u8,
9763 sizeof (mp->client_address));
9765 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
9767 mp->local_session_id = ntohl (local_session_id);
9768 mp->remote_session_id = ntohl (remote_session_id);
9769 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
9770 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
9771 mp->l2_sublayer_present = l2_sublayer_present;
9781 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
9783 unformat_input_t *i = vam->input;
9785 u8 sw_if_index_set = 0;
9786 u64 new_local_cookie = 0;
9787 u64 new_remote_cookie = 0;
9788 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
9791 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9793 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9794 sw_if_index_set = 1;
9795 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9796 sw_if_index_set = 1;
9797 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
9799 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
9805 if (sw_if_index_set == 0)
9807 errmsg ("missing interface name or sw_if_index\n");
9811 M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies);
9813 mp->sw_if_index = ntohl (sw_if_index);
9814 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
9815 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
9824 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
9826 unformat_input_t *i = vam->input;
9827 vl_api_l2tpv3_interface_enable_disable_t *mp;
9830 u8 sw_if_index_set = 0;
9831 u8 enable_disable = 1;
9833 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9835 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9836 sw_if_index_set = 1;
9837 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9838 sw_if_index_set = 1;
9839 else if (unformat (i, "enable"))
9841 else if (unformat (i, "disable"))
9847 if (sw_if_index_set == 0)
9849 errmsg ("missing interface name or sw_if_index\n");
9853 M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable);
9855 mp->sw_if_index = ntohl (sw_if_index);
9856 mp->enable_disable = enable_disable;
9865 api_l2tpv3_set_lookup_key (vat_main_t * vam)
9867 unformat_input_t *i = vam->input;
9868 vl_api_l2tpv3_set_lookup_key_t *mp;
9872 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9874 if (unformat (i, "lookup_v6_src"))
9875 key = L2T_LOOKUP_SRC_ADDRESS;
9876 else if (unformat (i, "lookup_v6_dst"))
9877 key = L2T_LOOKUP_DST_ADDRESS;
9878 else if (unformat (i, "lookup_session_id"))
9879 key = L2T_LOOKUP_SESSION_ID;
9884 if (key == (u8) ~ 0)
9886 errmsg ("l2tp session lookup key unset\n");
9890 M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key);
9900 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
9901 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
9903 vat_main_t *vam = &vat_main;
9905 fformat (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)\n",
9906 format_ip6_address, mp->our_address,
9907 format_ip6_address, mp->client_address,
9908 clib_net_to_host_u32 (mp->sw_if_index));
9911 " local cookies %016llx %016llx remote cookie %016llx\n",
9912 clib_net_to_host_u64 (mp->local_cookie[0]),
9913 clib_net_to_host_u64 (mp->local_cookie[1]),
9914 clib_net_to_host_u64 (mp->remote_cookie));
9916 fformat (vam->ofp, " local session-id %d remote session-id %d\n",
9917 clib_net_to_host_u32 (mp->local_session_id),
9918 clib_net_to_host_u32 (mp->remote_session_id));
9920 fformat (vam->ofp, " l2 specific sublayer %s\n\n",
9921 mp->l2_sublayer_present ? "preset" : "absent");
9925 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
9926 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
9928 vat_main_t *vam = &vat_main;
9929 vat_json_node_t *node = NULL;
9930 struct in6_addr addr;
9932 if (VAT_JSON_ARRAY != vam->json_tree.type)
9934 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9935 vat_json_init_array (&vam->json_tree);
9937 node = vat_json_array_add (&vam->json_tree);
9939 vat_json_init_object (node);
9941 clib_memcpy (&addr, mp->our_address, sizeof (addr));
9942 vat_json_object_add_ip6 (node, "our_address", addr);
9943 clib_memcpy (&addr, mp->client_address, sizeof (addr));
9944 vat_json_object_add_ip6 (node, "client_address", addr);
9946 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
9947 vat_json_init_array (lc);
9948 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
9949 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
9950 vat_json_object_add_uint (node, "remote_cookie",
9951 clib_net_to_host_u64 (mp->remote_cookie));
9953 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
9954 vat_json_object_add_uint (node, "local_session_id",
9955 clib_net_to_host_u32 (mp->local_session_id));
9956 vat_json_object_add_uint (node, "remote_session_id",
9957 clib_net_to_host_u32 (mp->remote_session_id));
9958 vat_json_object_add_string_copy (node, "l2_sublayer",
9959 mp->l2_sublayer_present ? (u8 *) "present"
9964 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
9966 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
9969 /* Get list of l2tpv3-tunnel interfaces */
9970 M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump);
9973 /* Use a control ping for synchronization */
9975 vl_api_control_ping_t *mp;
9976 M (CONTROL_PING, control_ping);
9983 static void vl_api_sw_interface_tap_details_t_handler
9984 (vl_api_sw_interface_tap_details_t * mp)
9986 vat_main_t *vam = &vat_main;
9988 fformat (vam->ofp, "%-16s %d\n",
9989 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
9992 static void vl_api_sw_interface_tap_details_t_handler_json
9993 (vl_api_sw_interface_tap_details_t * mp)
9995 vat_main_t *vam = &vat_main;
9996 vat_json_node_t *node = NULL;
9998 if (VAT_JSON_ARRAY != vam->json_tree.type)
10000 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10001 vat_json_init_array (&vam->json_tree);
10003 node = vat_json_array_add (&vam->json_tree);
10005 vat_json_init_object (node);
10006 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10007 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10011 api_sw_interface_tap_dump (vat_main_t * vam)
10013 vl_api_sw_interface_tap_dump_t *mp;
10016 fformat (vam->ofp, "\n%-16s %s\n", "dev_name", "sw_if_index");
10017 /* Get list of tap interfaces */
10018 M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump);
10021 /* Use a control ping for synchronization */
10023 vl_api_control_ping_t *mp;
10024 M (CONTROL_PING, control_ping);
10030 static uword unformat_vxlan_decap_next
10031 (unformat_input_t * input, va_list * args)
10033 u32 *result = va_arg (*args, u32 *);
10036 if (unformat (input, "l2"))
10037 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10038 else if (unformat (input, "%d", &tmp))
10046 api_vxlan_add_del_tunnel (vat_main_t * vam)
10048 unformat_input_t *line_input = vam->input;
10049 vl_api_vxlan_add_del_tunnel_t *mp;
10051 ip46_address_t src, dst;
10053 u8 ipv4_set = 0, ipv6_set = 0;
10057 u32 mcast_sw_if_index = ~0;
10058 u32 encap_vrf_id = 0;
10059 u32 decap_next_index = ~0;
10062 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10063 memset (&src, 0, sizeof src);
10064 memset (&dst, 0, sizeof dst);
10066 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10068 if (unformat (line_input, "del"))
10071 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10077 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10083 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10089 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10094 else if (unformat (line_input, "group %U %U",
10095 unformat_ip4_address, &dst.ip4,
10096 unformat_sw_if_index, vam, &mcast_sw_if_index))
10098 grp_set = dst_set = 1;
10101 else if (unformat (line_input, "group %U",
10102 unformat_ip4_address, &dst.ip4))
10104 grp_set = dst_set = 1;
10107 else if (unformat (line_input, "group %U %U",
10108 unformat_ip6_address, &dst.ip6,
10109 unformat_sw_if_index, vam, &mcast_sw_if_index))
10111 grp_set = dst_set = 1;
10114 else if (unformat (line_input, "group %U",
10115 unformat_ip6_address, &dst.ip6))
10117 grp_set = dst_set = 1;
10121 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10123 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10125 else if (unformat (line_input, "decap-next %U",
10126 unformat_vxlan_decap_next, &decap_next_index))
10128 else if (unformat (line_input, "vni %d", &vni))
10132 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
10139 errmsg ("tunnel src address not specified\n");
10144 errmsg ("tunnel dst address not specified\n");
10148 if (grp_set && !ip46_address_is_multicast (&dst))
10150 errmsg ("tunnel group address not multicast\n");
10153 if (grp_set && mcast_sw_if_index == ~0)
10155 errmsg ("tunnel nonexistent multicast device\n");
10160 if (ipv4_set && ipv6_set)
10162 errmsg ("both IPv4 and IPv6 addresses specified");
10166 if ((vni == 0) || (vni >> 24))
10168 errmsg ("vni not specified or out of range\n");
10172 M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel);
10176 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10177 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10181 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10182 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10184 mp->encap_vrf_id = ntohl (encap_vrf_id);
10185 mp->decap_next_index = ntohl (decap_next_index);
10186 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10187 mp->vni = ntohl (vni);
10188 mp->is_add = is_add;
10189 mp->is_ipv6 = ipv6_set;
10197 static void vl_api_vxlan_tunnel_details_t_handler
10198 (vl_api_vxlan_tunnel_details_t * mp)
10200 vat_main_t *vam = &vat_main;
10201 ip46_address_t src, dst;
10203 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10204 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10206 fformat (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d\n",
10207 ntohl (mp->sw_if_index),
10208 format_ip46_address, &src, IP46_TYPE_ANY,
10209 format_ip46_address, &dst, IP46_TYPE_ANY,
10210 ntohl (mp->encap_vrf_id),
10211 ntohl (mp->decap_next_index), ntohl (mp->vni),
10212 ntohl (mp->mcast_sw_if_index));
10215 static void vl_api_vxlan_tunnel_details_t_handler_json
10216 (vl_api_vxlan_tunnel_details_t * mp)
10218 vat_main_t *vam = &vat_main;
10219 vat_json_node_t *node = NULL;
10221 if (VAT_JSON_ARRAY != vam->json_tree.type)
10223 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10224 vat_json_init_array (&vam->json_tree);
10226 node = vat_json_array_add (&vam->json_tree);
10228 vat_json_init_object (node);
10229 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10232 struct in6_addr ip6;
10234 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10235 vat_json_object_add_ip6 (node, "src_address", ip6);
10236 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10237 vat_json_object_add_ip6 (node, "dst_address", ip6);
10241 struct in_addr ip4;
10243 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10244 vat_json_object_add_ip4 (node, "src_address", ip4);
10245 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10246 vat_json_object_add_ip4 (node, "dst_address", ip4);
10248 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10249 vat_json_object_add_uint (node, "decap_next_index",
10250 ntohl (mp->decap_next_index));
10251 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10252 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10253 vat_json_object_add_uint (node, "mcast_sw_if_index",
10254 ntohl (mp->mcast_sw_if_index));
10258 api_vxlan_tunnel_dump (vat_main_t * vam)
10260 unformat_input_t *i = vam->input;
10261 vl_api_vxlan_tunnel_dump_t *mp;
10264 u8 sw_if_index_set = 0;
10266 /* Parse args required to build the message */
10267 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10269 if (unformat (i, "sw_if_index %d", &sw_if_index))
10270 sw_if_index_set = 1;
10275 if (sw_if_index_set == 0)
10280 if (!vam->json_output)
10282 fformat (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s\n",
10283 "sw_if_index", "src_address", "dst_address",
10284 "encap_vrf_id", "decap_next_index", "vni",
10285 "mcast_sw_if_index");
10288 /* Get list of vxlan-tunnel interfaces */
10289 M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
10291 mp->sw_if_index = htonl (sw_if_index);
10295 /* Use a control ping for synchronization */
10297 vl_api_control_ping_t *mp;
10298 M (CONTROL_PING, control_ping);
10305 api_gre_add_del_tunnel (vat_main_t * vam)
10307 unformat_input_t *line_input = vam->input;
10308 vl_api_gre_add_del_tunnel_t *mp;
10310 ip4_address_t src4, dst4;
10315 u32 outer_fib_id = 0;
10317 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10319 if (unformat (line_input, "del"))
10321 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10323 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10325 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10327 else if (unformat (line_input, "teb"))
10331 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
10338 errmsg ("tunnel src address not specified\n");
10343 errmsg ("tunnel dst address not specified\n");
10348 M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel);
10350 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10351 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10352 mp->outer_fib_id = ntohl (outer_fib_id);
10353 mp->is_add = is_add;
10362 static void vl_api_gre_tunnel_details_t_handler
10363 (vl_api_gre_tunnel_details_t * mp)
10365 vat_main_t *vam = &vat_main;
10367 fformat (vam->ofp, "%11d%15U%15U%6d%14d\n",
10368 ntohl (mp->sw_if_index),
10369 format_ip4_address, &mp->src_address,
10370 format_ip4_address, &mp->dst_address,
10371 mp->teb, ntohl (mp->outer_fib_id));
10374 static void vl_api_gre_tunnel_details_t_handler_json
10375 (vl_api_gre_tunnel_details_t * mp)
10377 vat_main_t *vam = &vat_main;
10378 vat_json_node_t *node = NULL;
10379 struct in_addr ip4;
10381 if (VAT_JSON_ARRAY != vam->json_tree.type)
10383 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10384 vat_json_init_array (&vam->json_tree);
10386 node = vat_json_array_add (&vam->json_tree);
10388 vat_json_init_object (node);
10389 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10390 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10391 vat_json_object_add_ip4 (node, "src_address", ip4);
10392 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10393 vat_json_object_add_ip4 (node, "dst_address", ip4);
10394 vat_json_object_add_uint (node, "teb", mp->teb);
10395 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10399 api_gre_tunnel_dump (vat_main_t * vam)
10401 unformat_input_t *i = vam->input;
10402 vl_api_gre_tunnel_dump_t *mp;
10405 u8 sw_if_index_set = 0;
10407 /* Parse args required to build the message */
10408 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10410 if (unformat (i, "sw_if_index %d", &sw_if_index))
10411 sw_if_index_set = 1;
10416 if (sw_if_index_set == 0)
10421 if (!vam->json_output)
10423 fformat (vam->ofp, "%11s%15s%15s%6s%14s\n",
10424 "sw_if_index", "src_address", "dst_address", "teb",
10428 /* Get list of gre-tunnel interfaces */
10429 M (GRE_TUNNEL_DUMP, gre_tunnel_dump);
10431 mp->sw_if_index = htonl (sw_if_index);
10435 /* Use a control ping for synchronization */
10437 vl_api_control_ping_t *mp;
10438 M (CONTROL_PING, control_ping);
10445 api_l2_fib_clear_table (vat_main_t * vam)
10447 // unformat_input_t * i = vam->input;
10448 vl_api_l2_fib_clear_table_t *mp;
10451 M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table);
10460 api_l2_interface_efp_filter (vat_main_t * vam)
10462 unformat_input_t *i = vam->input;
10463 vl_api_l2_interface_efp_filter_t *mp;
10467 u8 sw_if_index_set = 0;
10469 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10471 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10472 sw_if_index_set = 1;
10473 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10474 sw_if_index_set = 1;
10475 else if (unformat (i, "enable"))
10477 else if (unformat (i, "disable"))
10481 clib_warning ("parse error '%U'", format_unformat_error, i);
10486 if (sw_if_index_set == 0)
10488 errmsg ("missing sw_if_index\n");
10492 M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter);
10494 mp->sw_if_index = ntohl (sw_if_index);
10495 mp->enable_disable = enable;
10503 #define foreach_vtr_op \
10504 _("disable", L2_VTR_DISABLED) \
10505 _("push-1", L2_VTR_PUSH_1) \
10506 _("push-2", L2_VTR_PUSH_2) \
10507 _("pop-1", L2_VTR_POP_1) \
10508 _("pop-2", L2_VTR_POP_2) \
10509 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10510 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10511 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10512 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10515 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10517 unformat_input_t *i = vam->input;
10518 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
10521 u8 sw_if_index_set = 0;
10524 u32 push_dot1q = 1;
10528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10530 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10531 sw_if_index_set = 1;
10532 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10533 sw_if_index_set = 1;
10534 else if (unformat (i, "vtr_op %d", &vtr_op))
10536 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
10539 else if (unformat (i, "push_dot1q %d", &push_dot1q))
10541 else if (unformat (i, "tag1 %d", &tag1))
10543 else if (unformat (i, "tag2 %d", &tag2))
10547 clib_warning ("parse error '%U'", format_unformat_error, i);
10552 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
10554 errmsg ("missing vtr operation or sw_if_index\n");
10558 M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)
10559 mp->sw_if_index = ntohl (sw_if_index);
10560 mp->vtr_op = ntohl (vtr_op);
10561 mp->push_dot1q = ntohl (push_dot1q);
10562 mp->tag1 = ntohl (tag1);
10563 mp->tag2 = ntohl (tag2);
10572 api_create_vhost_user_if (vat_main_t * vam)
10574 unformat_input_t *i = vam->input;
10575 vl_api_create_vhost_user_if_t *mp;
10579 u8 file_name_set = 0;
10580 u32 custom_dev_instance = ~0;
10582 u8 use_custom_mac = 0;
10585 /* Shut up coverity */
10586 memset (hwaddr, 0, sizeof (hwaddr));
10588 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10590 if (unformat (i, "socket %s", &file_name))
10594 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10596 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
10597 use_custom_mac = 1;
10598 else if (unformat (i, "server"))
10600 else if (unformat (i, "tag %s", &tag))
10606 if (file_name_set == 0)
10608 errmsg ("missing socket file name\n");
10612 if (vec_len (file_name) > 255)
10614 errmsg ("socket file name too long\n");
10617 vec_add1 (file_name, 0);
10619 M (CREATE_VHOST_USER_IF, create_vhost_user_if);
10621 mp->is_server = is_server;
10622 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10623 vec_free (file_name);
10624 if (custom_dev_instance != ~0)
10627 mp->custom_dev_instance = ntohl (custom_dev_instance);
10629 mp->use_custom_mac = use_custom_mac;
10630 clib_memcpy (mp->mac_address, hwaddr, 6);
10632 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
10642 api_modify_vhost_user_if (vat_main_t * vam)
10644 unformat_input_t *i = vam->input;
10645 vl_api_modify_vhost_user_if_t *mp;
10649 u8 file_name_set = 0;
10650 u32 custom_dev_instance = ~0;
10651 u8 sw_if_index_set = 0;
10652 u32 sw_if_index = (u32) ~ 0;
10654 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10656 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10657 sw_if_index_set = 1;
10658 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10659 sw_if_index_set = 1;
10660 else if (unformat (i, "socket %s", &file_name))
10664 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10666 else if (unformat (i, "server"))
10672 if (sw_if_index_set == 0)
10674 errmsg ("missing sw_if_index or interface name\n");
10678 if (file_name_set == 0)
10680 errmsg ("missing socket file name\n");
10684 if (vec_len (file_name) > 255)
10686 errmsg ("socket file name too long\n");
10689 vec_add1 (file_name, 0);
10691 M (MODIFY_VHOST_USER_IF, modify_vhost_user_if);
10693 mp->sw_if_index = ntohl (sw_if_index);
10694 mp->is_server = is_server;
10695 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10696 vec_free (file_name);
10697 if (custom_dev_instance != ~0)
10700 mp->custom_dev_instance = ntohl (custom_dev_instance);
10710 api_delete_vhost_user_if (vat_main_t * vam)
10712 unformat_input_t *i = vam->input;
10713 vl_api_delete_vhost_user_if_t *mp;
10715 u32 sw_if_index = ~0;
10716 u8 sw_if_index_set = 0;
10718 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10720 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10721 sw_if_index_set = 1;
10722 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10723 sw_if_index_set = 1;
10728 if (sw_if_index_set == 0)
10730 errmsg ("missing sw_if_index or interface name\n");
10735 M (DELETE_VHOST_USER_IF, delete_vhost_user_if);
10737 mp->sw_if_index = ntohl (sw_if_index);
10745 static void vl_api_sw_interface_vhost_user_details_t_handler
10746 (vl_api_sw_interface_vhost_user_details_t * mp)
10748 vat_main_t *vam = &vat_main;
10750 fformat (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s\n",
10751 (char *) mp->interface_name,
10752 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
10753 clib_net_to_host_u64 (mp->features), mp->is_server,
10754 ntohl (mp->num_regions), (char *) mp->sock_filename);
10755 fformat (vam->ofp, " Status: '%s'\n", strerror (ntohl (mp->sock_errno)));
10758 static void vl_api_sw_interface_vhost_user_details_t_handler_json
10759 (vl_api_sw_interface_vhost_user_details_t * mp)
10761 vat_main_t *vam = &vat_main;
10762 vat_json_node_t *node = NULL;
10764 if (VAT_JSON_ARRAY != vam->json_tree.type)
10766 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10767 vat_json_init_array (&vam->json_tree);
10769 node = vat_json_array_add (&vam->json_tree);
10771 vat_json_init_object (node);
10772 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10773 vat_json_object_add_string_copy (node, "interface_name",
10774 mp->interface_name);
10775 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
10776 ntohl (mp->virtio_net_hdr_sz));
10777 vat_json_object_add_uint (node, "features",
10778 clib_net_to_host_u64 (mp->features));
10779 vat_json_object_add_uint (node, "is_server", mp->is_server);
10780 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
10781 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
10782 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
10786 api_sw_interface_vhost_user_dump (vat_main_t * vam)
10788 vl_api_sw_interface_vhost_user_dump_t *mp;
10791 "Interface name idx hdr_sz features server regions filename\n");
10793 /* Get list of vhost-user interfaces */
10794 M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump);
10797 /* Use a control ping for synchronization */
10799 vl_api_control_ping_t *mp;
10800 M (CONTROL_PING, control_ping);
10807 api_show_version (vat_main_t * vam)
10809 vl_api_show_version_t *mp;
10812 M (SHOW_VERSION, show_version);
10822 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
10824 unformat_input_t *line_input = vam->input;
10825 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
10827 ip4_address_t local4, remote4;
10828 ip6_address_t local6, remote6;
10830 u8 ipv4_set = 0, ipv6_set = 0;
10833 u32 encap_vrf_id = 0;
10834 u32 decap_vrf_id = 0;
10839 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10841 if (unformat (line_input, "del"))
10843 else if (unformat (line_input, "local %U",
10844 unformat_ip4_address, &local4))
10849 else if (unformat (line_input, "remote %U",
10850 unformat_ip4_address, &remote4))
10855 else if (unformat (line_input, "local %U",
10856 unformat_ip6_address, &local6))
10861 else if (unformat (line_input, "remote %U",
10862 unformat_ip6_address, &remote6))
10867 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10869 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
10871 else if (unformat (line_input, "vni %d", &vni))
10873 else if (unformat (line_input, "next-ip4"))
10875 else if (unformat (line_input, "next-ip6"))
10877 else if (unformat (line_input, "next-ethernet"))
10879 else if (unformat (line_input, "next-nsh"))
10883 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
10888 if (local_set == 0)
10890 errmsg ("tunnel local address not specified\n");
10893 if (remote_set == 0)
10895 errmsg ("tunnel remote address not specified\n");
10898 if (ipv4_set && ipv6_set)
10900 errmsg ("both IPv4 and IPv6 addresses specified");
10906 errmsg ("vni not specified\n");
10910 M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel);
10915 clib_memcpy (&mp->local, &local6, sizeof (local6));
10916 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
10920 clib_memcpy (&mp->local, &local4, sizeof (local4));
10921 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
10924 mp->encap_vrf_id = ntohl (encap_vrf_id);
10925 mp->decap_vrf_id = ntohl (decap_vrf_id);
10926 mp->protocol = ntohl (protocol);
10927 mp->vni = ntohl (vni);
10928 mp->is_add = is_add;
10929 mp->is_ipv6 = ipv6_set;
10937 static void vl_api_vxlan_gpe_tunnel_details_t_handler
10938 (vl_api_vxlan_gpe_tunnel_details_t * mp)
10940 vat_main_t *vam = &vat_main;
10942 fformat (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d\n",
10943 ntohl (mp->sw_if_index),
10944 format_ip46_address, &(mp->local[0]),
10945 format_ip46_address, &(mp->remote[0]),
10947 ntohl (mp->protocol),
10948 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
10951 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
10952 (vl_api_vxlan_gpe_tunnel_details_t * mp)
10954 vat_main_t *vam = &vat_main;
10955 vat_json_node_t *node = NULL;
10956 struct in_addr ip4;
10957 struct in6_addr ip6;
10959 if (VAT_JSON_ARRAY != vam->json_tree.type)
10961 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10962 vat_json_init_array (&vam->json_tree);
10964 node = vat_json_array_add (&vam->json_tree);
10966 vat_json_init_object (node);
10967 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10970 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
10971 vat_json_object_add_ip6 (node, "local", ip6);
10972 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
10973 vat_json_object_add_ip6 (node, "remote", ip6);
10977 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
10978 vat_json_object_add_ip4 (node, "local", ip4);
10979 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
10980 vat_json_object_add_ip4 (node, "remote", ip4);
10982 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10983 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
10984 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10985 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
10986 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10990 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
10992 unformat_input_t *i = vam->input;
10993 vl_api_vxlan_gpe_tunnel_dump_t *mp;
10996 u8 sw_if_index_set = 0;
10998 /* Parse args required to build the message */
10999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11001 if (unformat (i, "sw_if_index %d", &sw_if_index))
11002 sw_if_index_set = 1;
11007 if (sw_if_index_set == 0)
11012 if (!vam->json_output)
11014 fformat (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s\n",
11015 "sw_if_index", "local", "remote", "vni",
11016 "protocol", "encap_vrf_id", "decap_vrf_id");
11019 /* Get list of vxlan-tunnel interfaces */
11020 M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump);
11022 mp->sw_if_index = htonl (sw_if_index);
11026 /* Use a control ping for synchronization */
11028 vl_api_control_ping_t *mp;
11029 M (CONTROL_PING, control_ping);
11036 format_l2_fib_mac_address (u8 * s, va_list * args)
11038 u8 *a = va_arg (*args, u8 *);
11040 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11041 a[2], a[3], a[4], a[5], a[6], a[7]);
11044 static void vl_api_l2_fib_table_entry_t_handler
11045 (vl_api_l2_fib_table_entry_t * mp)
11047 vat_main_t *vam = &vat_main;
11049 fformat (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11051 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11052 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11056 static void vl_api_l2_fib_table_entry_t_handler_json
11057 (vl_api_l2_fib_table_entry_t * mp)
11059 vat_main_t *vam = &vat_main;
11060 vat_json_node_t *node = NULL;
11062 if (VAT_JSON_ARRAY != vam->json_tree.type)
11064 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11065 vat_json_init_array (&vam->json_tree);
11067 node = vat_json_array_add (&vam->json_tree);
11069 vat_json_init_object (node);
11070 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11071 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11072 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11073 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11074 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11075 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11079 api_l2_fib_table_dump (vat_main_t * vam)
11081 unformat_input_t *i = vam->input;
11082 vl_api_l2_fib_table_dump_t *mp;
11087 /* Parse args required to build the message */
11088 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11090 if (unformat (i, "bd_id %d", &bd_id))
11096 if (bd_id_set == 0)
11098 errmsg ("missing bridge domain\n");
11103 "BD-ID Mac Address sw-ndx Static Filter BVI\n");
11105 /* Get list of l2 fib entries */
11106 M (L2_FIB_TABLE_DUMP, l2_fib_table_dump);
11108 mp->bd_id = ntohl (bd_id);
11111 /* Use a control ping for synchronization */
11113 vl_api_control_ping_t *mp;
11114 M (CONTROL_PING, control_ping);
11122 api_interface_name_renumber (vat_main_t * vam)
11124 unformat_input_t *line_input = vam->input;
11125 vl_api_interface_name_renumber_t *mp;
11126 u32 sw_if_index = ~0;
11128 u32 new_show_dev_instance = ~0;
11130 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11132 if (unformat (line_input, "%U", unformat_sw_if_index, vam,
11135 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11137 else if (unformat (line_input, "new_show_dev_instance %d",
11138 &new_show_dev_instance))
11144 if (sw_if_index == ~0)
11146 errmsg ("missing interface name or sw_if_index\n");
11150 if (new_show_dev_instance == ~0)
11152 errmsg ("missing new_show_dev_instance\n");
11156 M (INTERFACE_NAME_RENUMBER, interface_name_renumber);
11158 mp->sw_if_index = ntohl (sw_if_index);
11159 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11166 api_want_ip4_arp_events (vat_main_t * vam)
11168 unformat_input_t *line_input = vam->input;
11169 vl_api_want_ip4_arp_events_t *mp;
11171 ip4_address_t address;
11172 int address_set = 0;
11173 u32 enable_disable = 1;
11175 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11177 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11179 else if (unformat (line_input, "del"))
11180 enable_disable = 0;
11185 if (address_set == 0)
11187 errmsg ("missing addresses\n");
11191 M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events);
11192 mp->enable_disable = enable_disable;
11193 mp->pid = getpid ();
11194 mp->address = address.as_u32;
11201 api_want_ip6_nd_events (vat_main_t * vam)
11203 unformat_input_t *line_input = vam->input;
11204 vl_api_want_ip6_nd_events_t *mp;
11206 ip6_address_t address;
11207 int address_set = 0;
11208 u32 enable_disable = 1;
11210 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11212 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11214 else if (unformat (line_input, "del"))
11215 enable_disable = 0;
11220 if (address_set == 0)
11222 errmsg ("missing addresses\n");
11226 M (WANT_IP6_ND_EVENTS, want_ip6_nd_events);
11227 mp->enable_disable = enable_disable;
11228 mp->pid = getpid ();
11229 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11236 api_input_acl_set_interface (vat_main_t * vam)
11238 unformat_input_t *i = vam->input;
11239 vl_api_input_acl_set_interface_t *mp;
11242 int sw_if_index_set;
11243 u32 ip4_table_index = ~0;
11244 u32 ip6_table_index = ~0;
11245 u32 l2_table_index = ~0;
11248 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11250 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
11251 sw_if_index_set = 1;
11252 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11253 sw_if_index_set = 1;
11254 else if (unformat (i, "del"))
11256 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11258 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11260 else if (unformat (i, "l2-table %d", &l2_table_index))
11264 clib_warning ("parse error '%U'", format_unformat_error, i);
11269 if (sw_if_index_set == 0)
11271 errmsg ("missing interface name or sw_if_index\n");
11275 M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface);
11277 mp->sw_if_index = ntohl (sw_if_index);
11278 mp->ip4_table_index = ntohl (ip4_table_index);
11279 mp->ip6_table_index = ntohl (ip6_table_index);
11280 mp->l2_table_index = ntohl (l2_table_index);
11281 mp->is_add = is_add;
11290 api_ip_address_dump (vat_main_t * vam)
11292 unformat_input_t *i = vam->input;
11293 vl_api_ip_address_dump_t *mp;
11294 u32 sw_if_index = ~0;
11295 u8 sw_if_index_set = 0;
11300 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11302 if (unformat (i, "sw_if_index %d", &sw_if_index))
11303 sw_if_index_set = 1;
11304 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
11305 sw_if_index_set = 1;
11306 else if (unformat (i, "ipv4"))
11308 else if (unformat (i, "ipv6"))
11314 if (ipv4_set && ipv6_set)
11316 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
11320 if ((!ipv4_set) && (!ipv6_set))
11322 errmsg ("no ipv4 nor ipv6 flag set\n");
11326 if (sw_if_index_set == 0)
11328 errmsg ("missing interface name or sw_if_index\n");
11332 vam->current_sw_if_index = sw_if_index;
11333 vam->is_ipv6 = ipv6_set;
11335 M (IP_ADDRESS_DUMP, ip_address_dump);
11336 mp->sw_if_index = ntohl (sw_if_index);
11337 mp->is_ipv6 = ipv6_set;
11340 /* Use a control ping for synchronization */
11342 vl_api_control_ping_t *mp;
11343 M (CONTROL_PING, control_ping);
11350 api_ip_dump (vat_main_t * vam)
11352 vl_api_ip_dump_t *mp;
11353 unformat_input_t *in = vam->input;
11360 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11362 if (unformat (in, "ipv4"))
11364 else if (unformat (in, "ipv6"))
11370 if (ipv4_set && ipv6_set)
11372 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
11376 if ((!ipv4_set) && (!ipv6_set))
11378 errmsg ("no ipv4 nor ipv6 flag set\n");
11382 is_ipv6 = ipv6_set;
11383 vam->is_ipv6 = is_ipv6;
11385 /* free old data */
11386 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11388 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11390 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11392 M (IP_DUMP, ip_dump);
11393 mp->is_ipv6 = ipv6_set;
11396 /* Use a control ping for synchronization */
11398 vl_api_control_ping_t *mp;
11399 M (CONTROL_PING, control_ping);
11406 api_ipsec_spd_add_del (vat_main_t * vam)
11408 unformat_input_t *i = vam->input;
11409 vl_api_ipsec_spd_add_del_t *mp;
11414 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11416 if (unformat (i, "spd_id %d", &spd_id))
11418 else if (unformat (i, "del"))
11422 clib_warning ("parse error '%U'", format_unformat_error, i);
11428 errmsg ("spd_id must be set\n");
11432 M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del);
11434 mp->spd_id = ntohl (spd_id);
11435 mp->is_add = is_add;
11444 api_ipsec_interface_add_del_spd (vat_main_t * vam)
11446 unformat_input_t *i = vam->input;
11447 vl_api_ipsec_interface_add_del_spd_t *mp;
11450 u8 sw_if_index_set = 0;
11451 u32 spd_id = (u32) ~ 0;
11454 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11456 if (unformat (i, "del"))
11458 else if (unformat (i, "spd_id %d", &spd_id))
11460 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
11461 sw_if_index_set = 1;
11462 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11463 sw_if_index_set = 1;
11466 clib_warning ("parse error '%U'", format_unformat_error, i);
11472 if (spd_id == (u32) ~ 0)
11474 errmsg ("spd_id must be set\n");
11478 if (sw_if_index_set == 0)
11480 errmsg ("missing interface name or sw_if_index\n");
11484 M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd);
11486 mp->spd_id = ntohl (spd_id);
11487 mp->sw_if_index = ntohl (sw_if_index);
11488 mp->is_add = is_add;
11497 api_ipsec_spd_add_del_entry (vat_main_t * vam)
11499 unformat_input_t *i = vam->input;
11500 vl_api_ipsec_spd_add_del_entry_t *mp;
11502 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11503 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11505 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11506 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11507 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11508 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11510 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11511 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11512 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11513 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11514 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11515 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11517 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11519 if (unformat (i, "del"))
11521 if (unformat (i, "outbound"))
11523 if (unformat (i, "inbound"))
11525 else if (unformat (i, "spd_id %d", &spd_id))
11527 else if (unformat (i, "sa_id %d", &sa_id))
11529 else if (unformat (i, "priority %d", &priority))
11531 else if (unformat (i, "protocol %d", &protocol))
11533 else if (unformat (i, "lport_start %d", &lport_start))
11535 else if (unformat (i, "lport_stop %d", &lport_stop))
11537 else if (unformat (i, "rport_start %d", &rport_start))
11539 else if (unformat (i, "rport_stop %d", &rport_stop))
11543 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
11549 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
11556 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
11562 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
11569 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
11575 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
11582 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
11588 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
11594 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
11596 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
11598 clib_warning ("unsupported action: 'resolve'");
11604 clib_warning ("parse error '%U'", format_unformat_error, i);
11610 M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry);
11612 mp->spd_id = ntohl (spd_id);
11613 mp->priority = ntohl (priority);
11614 mp->is_outbound = is_outbound;
11616 mp->is_ipv6 = is_ipv6;
11617 if (is_ipv6 || is_ip_any)
11619 clib_memcpy (mp->remote_address_start, &raddr6_start,
11620 sizeof (ip6_address_t));
11621 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
11622 sizeof (ip6_address_t));
11623 clib_memcpy (mp->local_address_start, &laddr6_start,
11624 sizeof (ip6_address_t));
11625 clib_memcpy (mp->local_address_stop, &laddr6_stop,
11626 sizeof (ip6_address_t));
11630 clib_memcpy (mp->remote_address_start, &raddr4_start,
11631 sizeof (ip4_address_t));
11632 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
11633 sizeof (ip4_address_t));
11634 clib_memcpy (mp->local_address_start, &laddr4_start,
11635 sizeof (ip4_address_t));
11636 clib_memcpy (mp->local_address_stop, &laddr4_stop,
11637 sizeof (ip4_address_t));
11639 mp->protocol = (u8) protocol;
11640 mp->local_port_start = ntohs ((u16) lport_start);
11641 mp->local_port_stop = ntohs ((u16) lport_stop);
11642 mp->remote_port_start = ntohs ((u16) rport_start);
11643 mp->remote_port_stop = ntohs ((u16) rport_stop);
11644 mp->policy = (u8) policy;
11645 mp->sa_id = ntohl (sa_id);
11646 mp->is_add = is_add;
11647 mp->is_ip_any = is_ip_any;
11655 api_ipsec_sad_add_del_entry (vat_main_t * vam)
11657 unformat_input_t *i = vam->input;
11658 vl_api_ipsec_sad_add_del_entry_t *mp;
11660 u32 sad_id = 0, spi = 0;
11661 u8 *ck = 0, *ik = 0;
11664 u8 protocol = IPSEC_PROTOCOL_AH;
11665 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
11666 u32 crypto_alg = 0, integ_alg = 0;
11667 ip4_address_t tun_src4;
11668 ip4_address_t tun_dst4;
11669 ip6_address_t tun_src6;
11670 ip6_address_t tun_dst6;
11672 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11674 if (unformat (i, "del"))
11676 else if (unformat (i, "sad_id %d", &sad_id))
11678 else if (unformat (i, "spi %d", &spi))
11680 else if (unformat (i, "esp"))
11681 protocol = IPSEC_PROTOCOL_ESP;
11682 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
11685 is_tunnel_ipv6 = 0;
11687 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
11690 is_tunnel_ipv6 = 0;
11692 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
11695 is_tunnel_ipv6 = 1;
11697 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
11700 is_tunnel_ipv6 = 1;
11704 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
11706 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
11707 crypto_alg >= IPSEC_CRYPTO_N_ALG)
11709 clib_warning ("unsupported crypto-alg: '%U'",
11710 format_ipsec_crypto_alg, crypto_alg);
11714 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11718 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
11721 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
11723 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
11725 integ_alg >= IPSEC_INTEG_N_ALG)
11727 clib_warning ("unsupported integ-alg: '%U'",
11728 format_ipsec_integ_alg, integ_alg);
11732 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
11736 clib_warning ("parse error '%U'", format_unformat_error, i);
11743 /*Special cases, aes-gcm-128 encryption */
11744 if (crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128)
11746 if (integ_alg != IPSEC_INTEG_ALG_NONE
11747 && integ_alg != IPSEC_INTEG_ALG_AES_GCM_128)
11750 ("unsupported: aes-gcm-128 crypto-alg needs none as integ-alg");
11753 else /*set integ-alg internally to aes-gcm-128 */
11754 integ_alg = IPSEC_INTEG_ALG_AES_GCM_128;
11756 else if (integ_alg == IPSEC_INTEG_ALG_AES_GCM_128)
11758 clib_warning ("unsupported integ-alg: aes-gcm-128");
11761 else if (integ_alg == IPSEC_INTEG_ALG_NONE)
11763 clib_warning ("unsupported integ-alg: none");
11769 M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
11771 mp->sad_id = ntohl (sad_id);
11772 mp->is_add = is_add;
11773 mp->protocol = protocol;
11774 mp->spi = ntohl (spi);
11775 mp->is_tunnel = is_tunnel;
11776 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
11777 mp->crypto_algorithm = crypto_alg;
11778 mp->integrity_algorithm = integ_alg;
11779 mp->crypto_key_length = vec_len (ck);
11780 mp->integrity_key_length = vec_len (ik);
11782 if (mp->crypto_key_length > sizeof (mp->crypto_key))
11783 mp->crypto_key_length = sizeof (mp->crypto_key);
11785 if (mp->integrity_key_length > sizeof (mp->integrity_key))
11786 mp->integrity_key_length = sizeof (mp->integrity_key);
11789 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
11791 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
11795 if (is_tunnel_ipv6)
11797 clib_memcpy (mp->tunnel_src_address, &tun_src6,
11798 sizeof (ip6_address_t));
11799 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
11800 sizeof (ip6_address_t));
11804 clib_memcpy (mp->tunnel_src_address, &tun_src4,
11805 sizeof (ip4_address_t));
11806 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
11807 sizeof (ip4_address_t));
11818 api_ipsec_sa_set_key (vat_main_t * vam)
11820 unformat_input_t *i = vam->input;
11821 vl_api_ipsec_sa_set_key_t *mp;
11824 u8 *ck = 0, *ik = 0;
11826 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11828 if (unformat (i, "sa_id %d", &sa_id))
11830 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11832 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
11836 clib_warning ("parse error '%U'", format_unformat_error, i);
11841 M (IPSEC_SA_SET_KEY, ipsec_set_sa_key);
11843 mp->sa_id = ntohl (sa_id);
11844 mp->crypto_key_length = vec_len (ck);
11845 mp->integrity_key_length = vec_len (ik);
11847 if (mp->crypto_key_length > sizeof (mp->crypto_key))
11848 mp->crypto_key_length = sizeof (mp->crypto_key);
11850 if (mp->integrity_key_length > sizeof (mp->integrity_key))
11851 mp->integrity_key_length = sizeof (mp->integrity_key);
11854 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
11856 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
11865 api_ikev2_profile_add_del (vat_main_t * vam)
11867 unformat_input_t *i = vam->input;
11868 vl_api_ikev2_profile_add_del_t *mp;
11873 const char *valid_chars = "a-zA-Z0-9_";
11875 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11877 if (unformat (i, "del"))
11879 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11880 vec_add1 (name, 0);
11883 errmsg ("parse error '%U'", format_unformat_error, i);
11888 if (!vec_len (name))
11890 errmsg ("profile name must be specified");
11894 if (vec_len (name) > 64)
11896 errmsg ("profile name too long");
11900 M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del);
11902 clib_memcpy (mp->name, name, vec_len (name));
11903 mp->is_add = is_add;
11913 api_ikev2_profile_set_auth (vat_main_t * vam)
11915 unformat_input_t *i = vam->input;
11916 vl_api_ikev2_profile_set_auth_t *mp;
11920 u32 auth_method = 0;
11923 const char *valid_chars = "a-zA-Z0-9_";
11925 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11927 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11928 vec_add1 (name, 0);
11929 else if (unformat (i, "auth_method %U",
11930 unformat_ikev2_auth_method, &auth_method))
11932 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
11934 else if (unformat (i, "auth_data %v", &data))
11938 errmsg ("parse error '%U'", format_unformat_error, i);
11943 if (!vec_len (name))
11945 errmsg ("profile name must be specified");
11949 if (vec_len (name) > 64)
11951 errmsg ("profile name too long");
11955 if (!vec_len (data))
11957 errmsg ("auth_data must be specified");
11963 errmsg ("auth_method must be specified");
11967 M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth);
11969 mp->is_hex = is_hex;
11970 mp->auth_method = (u8) auth_method;
11971 mp->data_len = vec_len (data);
11972 clib_memcpy (mp->name, name, vec_len (name));
11973 clib_memcpy (mp->data, data, vec_len (data));
11984 api_ikev2_profile_set_id (vat_main_t * vam)
11986 unformat_input_t *i = vam->input;
11987 vl_api_ikev2_profile_set_id_t *mp;
11995 const char *valid_chars = "a-zA-Z0-9_";
11997 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11999 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12000 vec_add1 (name, 0);
12001 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12003 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12005 data = vec_new (u8, 4);
12006 clib_memcpy (data, ip4.as_u8, 4);
12008 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12010 else if (unformat (i, "id_data %v", &data))
12012 else if (unformat (i, "local"))
12014 else if (unformat (i, "remote"))
12018 errmsg ("parse error '%U'", format_unformat_error, i);
12023 if (!vec_len (name))
12025 errmsg ("profile name must be specified");
12029 if (vec_len (name) > 64)
12031 errmsg ("profile name too long");
12035 if (!vec_len (data))
12037 errmsg ("id_data must be specified");
12043 errmsg ("id_type must be specified");
12047 M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id);
12049 mp->is_local = is_local;
12050 mp->id_type = (u8) id_type;
12051 mp->data_len = vec_len (data);
12052 clib_memcpy (mp->name, name, vec_len (name));
12053 clib_memcpy (mp->data, data, vec_len (data));
12064 api_ikev2_profile_set_ts (vat_main_t * vam)
12066 unformat_input_t *i = vam->input;
12067 vl_api_ikev2_profile_set_ts_t *mp;
12071 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12072 ip4_address_t start_addr, end_addr;
12074 const char *valid_chars = "a-zA-Z0-9_";
12076 start_addr.as_u32 = 0;
12077 end_addr.as_u32 = (u32) ~ 0;
12079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12081 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12082 vec_add1 (name, 0);
12083 else if (unformat (i, "protocol %d", &proto))
12085 else if (unformat (i, "start_port %d", &start_port))
12087 else if (unformat (i, "end_port %d", &end_port))
12090 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12092 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12094 else if (unformat (i, "local"))
12096 else if (unformat (i, "remote"))
12100 errmsg ("parse error '%U'", format_unformat_error, i);
12105 if (!vec_len (name))
12107 errmsg ("profile name must be specified");
12111 if (vec_len (name) > 64)
12113 errmsg ("profile name too long");
12117 M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts);
12119 mp->is_local = is_local;
12120 mp->proto = (u8) proto;
12121 mp->start_port = (u16) start_port;
12122 mp->end_port = (u16) end_port;
12123 mp->start_addr = start_addr.as_u32;
12124 mp->end_addr = end_addr.as_u32;
12125 clib_memcpy (mp->name, name, vec_len (name));
12135 api_ikev2_set_local_key (vat_main_t * vam)
12137 unformat_input_t *i = vam->input;
12138 vl_api_ikev2_set_local_key_t *mp;
12142 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12144 if (unformat (i, "file %v", &file))
12145 vec_add1 (file, 0);
12148 errmsg ("parse error '%U'", format_unformat_error, i);
12153 if (!vec_len (file))
12155 errmsg ("RSA key file must be specified");
12159 if (vec_len (file) > 256)
12161 errmsg ("file name too long");
12165 M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key);
12167 clib_memcpy (mp->key_file, file, vec_len (file));
12180 api_map_add_domain (vat_main_t * vam)
12182 unformat_input_t *i = vam->input;
12183 vl_api_map_add_domain_t *mp;
12186 ip4_address_t ip4_prefix;
12187 ip6_address_t ip6_prefix;
12188 ip6_address_t ip6_src;
12189 u32 num_m_args = 0;
12190 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12191 0, psid_length = 0;
12192 u8 is_translation = 0;
12194 u32 ip6_src_len = 128;
12196 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12198 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12199 &ip4_prefix, &ip4_prefix_len))
12201 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12202 &ip6_prefix, &ip6_prefix_len))
12206 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12209 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12211 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12213 else if (unformat (i, "psid-offset %d", &psid_offset))
12215 else if (unformat (i, "psid-len %d", &psid_length))
12217 else if (unformat (i, "mtu %d", &mtu))
12219 else if (unformat (i, "map-t"))
12220 is_translation = 1;
12223 clib_warning ("parse error '%U'", format_unformat_error, i);
12228 if (num_m_args < 3)
12230 errmsg ("mandatory argument(s) missing\n");
12234 /* Construct the API message */
12235 M (MAP_ADD_DOMAIN, map_add_domain);
12237 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12238 mp->ip4_prefix_len = ip4_prefix_len;
12240 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12241 mp->ip6_prefix_len = ip6_prefix_len;
12243 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12244 mp->ip6_src_prefix_len = ip6_src_len;
12246 mp->ea_bits_len = ea_bits_len;
12247 mp->psid_offset = psid_offset;
12248 mp->psid_length = psid_length;
12249 mp->is_translation = is_translation;
12250 mp->mtu = htons (mtu);
12255 /* Wait for a reply, return good/bad news */
12260 api_map_del_domain (vat_main_t * vam)
12262 unformat_input_t *i = vam->input;
12263 vl_api_map_del_domain_t *mp;
12266 u32 num_m_args = 0;
12269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12271 if (unformat (i, "index %d", &index))
12275 clib_warning ("parse error '%U'", format_unformat_error, i);
12280 if (num_m_args != 1)
12282 errmsg ("mandatory argument(s) missing\n");
12286 /* Construct the API message */
12287 M (MAP_DEL_DOMAIN, map_del_domain);
12289 mp->index = ntohl (index);
12294 /* Wait for a reply, return good/bad news */
12299 api_map_add_del_rule (vat_main_t * vam)
12301 unformat_input_t *i = vam->input;
12302 vl_api_map_add_del_rule_t *mp;
12305 ip6_address_t ip6_dst;
12306 u32 num_m_args = 0, index, psid = 0;
12308 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12310 if (unformat (i, "index %d", &index))
12312 else if (unformat (i, "psid %d", &psid))
12314 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
12316 else if (unformat (i, "del"))
12322 clib_warning ("parse error '%U'", format_unformat_error, i);
12327 /* Construct the API message */
12328 M (MAP_ADD_DEL_RULE, map_add_del_rule);
12330 mp->index = ntohl (index);
12331 mp->is_add = is_add;
12332 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
12333 mp->psid = ntohs (psid);
12338 /* Wait for a reply, return good/bad news */
12343 api_map_domain_dump (vat_main_t * vam)
12345 vl_api_map_domain_dump_t *mp;
12348 /* Construct the API message */
12349 M (MAP_DOMAIN_DUMP, map_domain_dump);
12354 /* Use a control ping for synchronization */
12356 vl_api_control_ping_t *mp;
12357 M (CONTROL_PING, control_ping);
12364 api_map_rule_dump (vat_main_t * vam)
12366 unformat_input_t *i = vam->input;
12367 vl_api_map_rule_dump_t *mp;
12369 u32 domain_index = ~0;
12371 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12373 if (unformat (i, "index %u", &domain_index))
12379 if (domain_index == ~0)
12381 clib_warning ("parse error: domain index expected");
12385 /* Construct the API message */
12386 M (MAP_RULE_DUMP, map_rule_dump);
12388 mp->domain_index = htonl (domain_index);
12393 /* Use a control ping for synchronization */
12395 vl_api_control_ping_t *mp;
12396 M (CONTROL_PING, control_ping);
12402 static void vl_api_map_add_domain_reply_t_handler
12403 (vl_api_map_add_domain_reply_t * mp)
12405 vat_main_t *vam = &vat_main;
12406 i32 retval = ntohl (mp->retval);
12408 if (vam->async_mode)
12410 vam->async_errors += (retval < 0);
12414 vam->retval = retval;
12415 vam->result_ready = 1;
12419 static void vl_api_map_add_domain_reply_t_handler_json
12420 (vl_api_map_add_domain_reply_t * mp)
12422 vat_main_t *vam = &vat_main;
12423 vat_json_node_t node;
12425 vat_json_init_object (&node);
12426 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
12427 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
12429 vat_json_print (vam->ofp, &node);
12430 vat_json_free (&node);
12432 vam->retval = ntohl (mp->retval);
12433 vam->result_ready = 1;
12437 api_get_first_msg_id (vat_main_t * vam)
12439 vl_api_get_first_msg_id_t *mp;
12441 unformat_input_t *i = vam->input;
12445 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12447 if (unformat (i, "client %s", &name))
12455 errmsg ("missing client name\n");
12458 vec_add1 (name, 0);
12460 if (vec_len (name) > 63)
12462 errmsg ("client name too long\n");
12466 M (GET_FIRST_MSG_ID, get_first_msg_id);
12467 clib_memcpy (mp->name, name, vec_len (name));
12475 api_cop_interface_enable_disable (vat_main_t * vam)
12477 unformat_input_t *line_input = vam->input;
12478 vl_api_cop_interface_enable_disable_t *mp;
12480 u32 sw_if_index = ~0;
12481 u8 enable_disable = 1;
12483 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12485 if (unformat (line_input, "disable"))
12486 enable_disable = 0;
12487 if (unformat (line_input, "enable"))
12488 enable_disable = 1;
12489 else if (unformat (line_input, "%U", unformat_sw_if_index,
12490 vam, &sw_if_index))
12492 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12498 if (sw_if_index == ~0)
12500 errmsg ("missing interface name or sw_if_index\n");
12504 /* Construct the API message */
12505 M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable);
12506 mp->sw_if_index = ntohl (sw_if_index);
12507 mp->enable_disable = enable_disable;
12511 /* Wait for the reply */
12516 api_cop_whitelist_enable_disable (vat_main_t * vam)
12518 unformat_input_t *line_input = vam->input;
12519 vl_api_cop_whitelist_enable_disable_t *mp;
12521 u32 sw_if_index = ~0;
12522 u8 ip4 = 0, ip6 = 0, default_cop = 0;
12525 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12527 if (unformat (line_input, "ip4"))
12529 else if (unformat (line_input, "ip6"))
12531 else if (unformat (line_input, "default"))
12533 else if (unformat (line_input, "%U", unformat_sw_if_index,
12534 vam, &sw_if_index))
12536 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12538 else if (unformat (line_input, "fib-id %d", &fib_id))
12544 if (sw_if_index == ~0)
12546 errmsg ("missing interface name or sw_if_index\n");
12550 /* Construct the API message */
12551 M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable);
12552 mp->sw_if_index = ntohl (sw_if_index);
12553 mp->fib_id = ntohl (fib_id);
12556 mp->default_cop = default_cop;
12560 /* Wait for the reply */
12565 api_get_node_graph (vat_main_t * vam)
12567 vl_api_get_node_graph_t *mp;
12570 M (GET_NODE_GRAPH, get_node_graph);
12574 /* Wait for the reply */
12579 /** Used for parsing LISP eids */
12580 typedef CLIB_PACKED(struct{
12581 u8 addr[16]; /**< eid address */
12582 u32 len; /**< prefix length if IP */
12583 u8 type; /**< type of eid */
12588 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
12590 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
12592 memset (a, 0, sizeof (a[0]));
12594 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
12596 a->type = 0; /* ipv4 type */
12598 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
12600 a->type = 1; /* ipv6 type */
12602 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
12604 a->type = 2; /* mac type */
12611 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
12620 lisp_eid_size_vat (u8 type)
12635 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
12637 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
12641 /** Used for transferring locators via VPP API */
12642 typedef CLIB_PACKED(struct
12644 u32 sw_if_index; /**< locator sw_if_index */
12645 u8 priority; /**< locator priority */
12646 u8 weight; /**< locator weight */
12651 api_lisp_add_del_locator_set (vat_main_t * vam)
12653 unformat_input_t *input = vam->input;
12654 vl_api_lisp_add_del_locator_set_t *mp;
12657 u8 *locator_set_name = NULL;
12658 u8 locator_set_name_set = 0;
12659 ls_locator_t locator, *locators = 0;
12660 u32 sw_if_index, priority, weight;
12663 /* Parse args required to build the message */
12664 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12666 if (unformat (input, "del"))
12670 else if (unformat (input, "locator-set %s", &locator_set_name))
12672 locator_set_name_set = 1;
12674 else if (unformat (input, "sw_if_index %u p %u w %u",
12675 &sw_if_index, &priority, &weight))
12677 locator.sw_if_index = htonl (sw_if_index);
12678 locator.priority = priority;
12679 locator.weight = weight;
12680 vec_add1 (locators, locator);
12682 else if (unformat (input, "iface %U p %u w %u", unformat_sw_if_index,
12683 vam, &sw_if_index, &priority, &weight))
12685 locator.sw_if_index = htonl (sw_if_index);
12686 locator.priority = priority;
12687 locator.weight = weight;
12688 vec_add1 (locators, locator);
12694 if (locator_set_name_set == 0)
12696 errmsg ("missing locator-set name");
12697 vec_free (locators);
12701 if (vec_len (locator_set_name) > 64)
12703 errmsg ("locator-set name too long\n");
12704 vec_free (locator_set_name);
12705 vec_free (locators);
12708 vec_add1 (locator_set_name, 0);
12710 data_len = sizeof (ls_locator_t) * vec_len (locators);
12712 /* Construct the API message */
12713 M2 (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set, data_len);
12715 mp->is_add = is_add;
12716 clib_memcpy (mp->locator_set_name, locator_set_name,
12717 vec_len (locator_set_name));
12718 vec_free (locator_set_name);
12720 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
12722 clib_memcpy (mp->locators, locators, data_len);
12723 vec_free (locators);
12728 /* Wait for a reply... */
12736 api_lisp_add_del_locator (vat_main_t * vam)
12738 unformat_input_t *input = vam->input;
12739 vl_api_lisp_add_del_locator_t *mp;
12741 u32 tmp_if_index = ~0;
12742 u32 sw_if_index = ~0;
12743 u8 sw_if_index_set = 0;
12744 u8 sw_if_index_if_name_set = 0;
12746 u8 priority_set = 0;
12750 u8 *locator_set_name = NULL;
12751 u8 locator_set_name_set = 0;
12753 /* Parse args required to build the message */
12754 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12756 if (unformat (input, "del"))
12760 else if (unformat (input, "locator-set %s", &locator_set_name))
12762 locator_set_name_set = 1;
12764 else if (unformat (input, "iface %U", unformat_sw_if_index, vam,
12767 sw_if_index_if_name_set = 1;
12768 sw_if_index = tmp_if_index;
12770 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
12772 sw_if_index_set = 1;
12773 sw_if_index = tmp_if_index;
12775 else if (unformat (input, "p %d", &priority))
12779 else if (unformat (input, "w %d", &weight))
12787 if (locator_set_name_set == 0)
12789 errmsg ("missing locator-set name");
12793 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
12795 errmsg ("missing sw_if_index");
12796 vec_free (locator_set_name);
12800 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
12802 errmsg ("cannot use both params interface name and sw_if_index");
12803 vec_free (locator_set_name);
12807 if (priority_set == 0)
12809 errmsg ("missing locator-set priority\n");
12810 vec_free (locator_set_name);
12814 if (weight_set == 0)
12816 errmsg ("missing locator-set weight\n");
12817 vec_free (locator_set_name);
12821 if (vec_len (locator_set_name) > 64)
12823 errmsg ("locator-set name too long\n");
12824 vec_free (locator_set_name);
12827 vec_add1 (locator_set_name, 0);
12829 /* Construct the API message */
12830 M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
12832 mp->is_add = is_add;
12833 mp->sw_if_index = ntohl (sw_if_index);
12834 mp->priority = priority;
12835 mp->weight = weight;
12836 clib_memcpy (mp->locator_set_name, locator_set_name,
12837 vec_len (locator_set_name));
12838 vec_free (locator_set_name);
12843 /* Wait for a reply... */
12851 api_lisp_add_del_local_eid (vat_main_t * vam)
12853 unformat_input_t *input = vam->input;
12854 vl_api_lisp_add_del_local_eid_t *mp;
12858 lisp_eid_vat_t _eid, *eid = &_eid;
12859 u8 *locator_set_name = 0;
12860 u8 locator_set_name_set = 0;
12863 /* Parse args required to build the message */
12864 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12866 if (unformat (input, "del"))
12870 else if (unformat (input, "vni %d", &vni))
12874 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
12878 else if (unformat (input, "locator-set %s", &locator_set_name))
12880 locator_set_name_set = 1;
12886 if (locator_set_name_set == 0)
12888 errmsg ("missing locator-set name\n");
12894 errmsg ("EID address not set!");
12895 vec_free (locator_set_name);
12899 if (vec_len (locator_set_name) > 64)
12901 errmsg ("locator-set name too long\n");
12902 vec_free (locator_set_name);
12905 vec_add1 (locator_set_name, 0);
12907 /* Construct the API message */
12908 M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
12910 mp->is_add = is_add;
12911 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
12912 mp->eid_type = eid->type;
12913 mp->prefix_len = eid->len;
12914 mp->vni = clib_host_to_net_u32 (vni);
12915 clib_memcpy (mp->locator_set_name, locator_set_name,
12916 vec_len (locator_set_name));
12918 vec_free (locator_set_name);
12923 /* Wait for a reply... */
12931 /** Used for transferring locators via VPP API */
12932 typedef CLIB_PACKED(struct
12934 u8 is_ip4; /**< is locator an IPv4 address? */
12935 u8 priority; /**< locator priority */
12936 u8 weight; /**< locator weight */
12937 u8 addr[16]; /**< IPv4/IPv6 address */
12942 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
12944 unformat_input_t *input = vam->input;
12945 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
12948 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
12949 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
12950 u8 rmt_eid_set = 0, lcl_eid_set = 0;
12951 u32 action = ~0, p, w;
12952 ip4_address_t rmt_rloc4, lcl_rloc4;
12953 ip6_address_t rmt_rloc6, lcl_rloc6;
12954 rloc_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
12956 memset (&rloc, 0, sizeof (rloc));
12958 /* Parse args required to build the message */
12959 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12961 if (unformat (input, "del"))
12965 else if (unformat (input, "rmt_eid %U", unformat_lisp_eid_vat, rmt_eid))
12969 else if (unformat (input, "lcl_eid %U", unformat_lisp_eid_vat, lcl_eid))
12973 else if (unformat (input, "p %d w %d", &p, &w))
12977 errmsg ("No RLOC configured for setting priority/weight!");
12980 curr_rloc->priority = p;
12981 curr_rloc->weight = w;
12983 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
12984 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
12988 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
12989 rloc.priority = rloc.weight = 0;
12990 vec_add1 (lcl_locs, rloc);
12992 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
12993 vec_add1 (rmt_locs, rloc);
12994 /* priority and weight saved in rmt loc */
12995 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
12997 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
12998 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13001 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13002 rloc.priority = rloc.weight = 0;
13003 vec_add1 (lcl_locs, rloc);
13005 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13006 vec_add1 (rmt_locs, rloc);
13007 /* priority and weight saved in rmt loc */
13008 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13010 else if (unformat (input, "action %d", &action))
13016 clib_warning ("parse error '%U'", format_unformat_error, input);
13023 errmsg ("remote eid addresses not set\n");
13027 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13029 errmsg ("eid types don't match\n");
13033 if (0 == rmt_locs && (u32) ~ 0 == action)
13035 errmsg ("action not set for negative mapping\n");
13039 /* Construct the API message */
13040 M (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry);
13042 mp->is_add = is_add;
13043 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13044 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13045 mp->eid_type = rmt_eid->type;
13046 mp->rmt_len = rmt_eid->len;
13047 mp->lcl_len = lcl_eid->len;
13048 mp->action = action;
13050 if (0 != rmt_locs && 0 != lcl_locs)
13052 mp->loc_num = vec_len (rmt_locs);
13053 clib_memcpy (mp->lcl_locs, lcl_locs,
13054 (sizeof (rloc_t) * vec_len (lcl_locs)));
13055 clib_memcpy (mp->rmt_locs, rmt_locs,
13056 (sizeof (rloc_t) * vec_len (rmt_locs)));
13058 vec_free (lcl_locs);
13059 vec_free (rmt_locs);
13064 /* Wait for a reply... */
13072 api_lisp_add_del_map_resolver (vat_main_t * vam)
13074 unformat_input_t *input = vam->input;
13075 vl_api_lisp_add_del_map_resolver_t *mp;
13080 ip4_address_t ipv4;
13081 ip6_address_t ipv6;
13083 /* Parse args required to build the message */
13084 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13086 if (unformat (input, "del"))
13090 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13094 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13102 if (ipv4_set && ipv6_set)
13104 errmsg ("both eid v4 and v6 addresses set\n");
13108 if (!ipv4_set && !ipv6_set)
13110 errmsg ("eid addresses not set\n");
13114 /* Construct the API message */
13115 M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
13117 mp->is_add = is_add;
13121 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13126 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13132 /* Wait for a reply... */
13140 api_lisp_gpe_enable_disable (vat_main_t * vam)
13142 unformat_input_t *input = vam->input;
13143 vl_api_lisp_gpe_enable_disable_t *mp;
13148 /* Parse args required to build the message */
13149 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13151 if (unformat (input, "enable"))
13156 else if (unformat (input, "disable"))
13167 errmsg ("Value not set\n");
13171 /* Construct the API message */
13172 M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
13179 /* Wait for a reply... */
13187 api_lisp_enable_disable (vat_main_t * vam)
13189 unformat_input_t *input = vam->input;
13190 vl_api_lisp_enable_disable_t *mp;
13195 /* Parse args required to build the message */
13196 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13198 if (unformat (input, "enable"))
13203 else if (unformat (input, "disable"))
13213 errmsg ("Value not set\n");
13217 /* Construct the API message */
13218 M (LISP_ENABLE_DISABLE, lisp_enable_disable);
13225 /* Wait for a reply... */
13233 api_show_lisp_map_request_mode (vat_main_t * vam)
13236 vl_api_show_lisp_map_request_mode_t *mp;
13238 M (SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode);
13243 /* wait for reply */
13250 api_lisp_map_request_mode (vat_main_t * vam)
13253 unformat_input_t *input = vam->input;
13254 vl_api_lisp_map_request_mode_t *mp;
13257 /* Parse args required to build the message */
13258 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13260 if (unformat (input, "dst-only"))
13262 else if (unformat (input, "src-dst"))
13266 errmsg ("parse error '%U'", format_unformat_error, input);
13271 M (LISP_MAP_REQUEST_MODE, lisp_map_request_mode);
13278 /* wait for reply */
13286 * Enable/disable LISP proxy ITR.
13288 * @param vam vpp API test context
13289 * @return return code
13292 api_lisp_pitr_set_locator_set (vat_main_t * vam)
13295 u8 ls_name_set = 0;
13296 unformat_input_t *input = vam->input;
13297 vl_api_lisp_pitr_set_locator_set_t *mp;
13301 /* Parse args required to build the message */
13302 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13304 if (unformat (input, "del"))
13306 else if (unformat (input, "locator-set %s", &ls_name))
13310 errmsg ("parse error '%U'", format_unformat_error, input);
13317 errmsg ("locator-set name not set!");
13321 M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set);
13323 mp->is_add = is_add;
13324 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
13325 vec_free (ls_name);
13330 /* wait for reply */
13338 api_show_lisp_pitr (vat_main_t * vam)
13340 vl_api_show_lisp_pitr_t *mp;
13343 if (!vam->json_output)
13345 fformat (vam->ofp, "%=20s\n", "lisp status:");
13348 M (SHOW_LISP_PITR, show_lisp_pitr);
13352 /* Wait for a reply... */
13360 * Add/delete mapping between vni and vrf
13363 api_lisp_eid_table_add_del_map (vat_main_t * vam)
13366 unformat_input_t *input = vam->input;
13367 vl_api_lisp_eid_table_add_del_map_t *mp;
13368 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
13369 u32 vni, vrf, bd_index;
13371 /* Parse args required to build the message */
13372 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13374 if (unformat (input, "del"))
13376 else if (unformat (input, "vrf %d", &vrf))
13378 else if (unformat (input, "bd_index %d", &bd_index))
13380 else if (unformat (input, "vni %d", &vni))
13386 if (!vni_set || (!vrf_set && !bd_index_set))
13388 errmsg ("missing arguments!");
13392 if (vrf_set && bd_index_set)
13394 errmsg ("error: both vrf and bd entered!");
13398 M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
13400 mp->is_add = is_add;
13401 mp->vni = htonl (vni);
13402 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
13403 mp->is_l2 = bd_index_set;
13408 /* wait for reply */
13416 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
13418 u32 *action = va_arg (*args, u32 *);
13421 if (unformat (input, "%s", &s))
13423 if (!strcmp ((char *) s, "no-action"))
13425 else if (!strcmp ((char *) s, "natively-forward"))
13427 else if (!strcmp ((char *) s, "send-map-request"))
13429 else if (!strcmp ((char *) s, "drop"))
13433 clib_warning ("invalid action: '%s'", s);
13445 * Add/del remote mapping to/from LISP control plane
13447 * @param vam vpp API test context
13448 * @return return code
13451 api_lisp_add_del_remote_mapping (vat_main_t * vam)
13453 unformat_input_t *input = vam->input;
13454 vl_api_lisp_add_del_remote_mapping_t *mp;
13457 lisp_eid_vat_t _eid, *eid = &_eid;
13458 lisp_eid_vat_t _seid, *seid = &_seid;
13459 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
13460 u32 action = ~0, p, w, data_len;
13461 ip4_address_t rloc4;
13462 ip6_address_t rloc6;
13463 rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
13465 memset (&rloc, 0, sizeof (rloc));
13467 /* Parse args required to build the message */
13468 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13470 if (unformat (input, "del-all"))
13474 else if (unformat (input, "del"))
13478 else if (unformat (input, "add"))
13482 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13486 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
13490 else if (unformat (input, "vni %d", &vni))
13494 else if (unformat (input, "p %d w %d", &p, &w))
13498 errmsg ("No RLOC configured for setting priority/weight!");
13501 curr_rloc->priority = p;
13502 curr_rloc->weight = w;
13504 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
13507 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
13508 vec_add1 (rlocs, rloc);
13509 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13511 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
13514 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
13515 vec_add1 (rlocs, rloc);
13516 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13518 else if (unformat (input, "action %U",
13519 unformat_negative_mapping_action, &action))
13525 clib_warning ("parse error '%U'", format_unformat_error, input);
13532 errmsg ("missing params!");
13536 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
13538 errmsg ("no action set for negative map-reply!");
13542 data_len = vec_len (rlocs) * sizeof (rloc_t);
13544 M2 (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping, data_len);
13545 mp->is_add = is_add;
13546 mp->vni = htonl (vni);
13547 mp->action = (u8) action;
13548 mp->is_src_dst = seid_set;
13549 mp->eid_len = eid->len;
13550 mp->seid_len = seid->len;
13551 mp->del_all = del_all;
13552 mp->eid_type = eid->type;
13553 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13554 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
13556 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
13557 clib_memcpy (mp->rlocs, rlocs, data_len);
13563 /* Wait for a reply... */
13571 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
13572 * forwarding entries in data-plane accordingly.
13574 * @param vam vpp API test context
13575 * @return return code
13578 api_lisp_add_del_adjacency (vat_main_t * vam)
13580 unformat_input_t *input = vam->input;
13581 vl_api_lisp_add_del_adjacency_t *mp;
13584 ip4_address_t leid4, reid4;
13585 ip6_address_t leid6, reid6;
13586 u8 reid_mac[6] = { 0 };
13587 u8 leid_mac[6] = { 0 };
13588 u8 reid_type, leid_type;
13589 u32 leid_len = 0, reid_len = 0, len;
13592 leid_type = reid_type = (u8) ~ 0;
13594 /* Parse args required to build the message */
13595 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13597 if (unformat (input, "del"))
13601 else if (unformat (input, "add"))
13605 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
13608 reid_type = 0; /* ipv4 */
13611 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
13614 reid_type = 1; /* ipv6 */
13617 else if (unformat (input, "reid %U", unformat_ethernet_address,
13620 reid_type = 2; /* mac */
13622 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
13625 leid_type = 0; /* ipv4 */
13628 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
13631 leid_type = 1; /* ipv6 */
13634 else if (unformat (input, "leid %U", unformat_ethernet_address,
13637 leid_type = 2; /* mac */
13639 else if (unformat (input, "vni %d", &vni))
13645 errmsg ("parse error '%U'", format_unformat_error, input);
13650 if ((u8) ~ 0 == reid_type)
13652 errmsg ("missing params!");
13656 if (leid_type != reid_type)
13658 errmsg ("remote and local EIDs are of different types!");
13662 M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency);
13663 mp->is_add = is_add;
13664 mp->vni = htonl (vni);
13665 mp->leid_len = leid_len;
13666 mp->reid_len = reid_len;
13667 mp->eid_type = reid_type;
13669 switch (mp->eid_type)
13672 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
13673 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
13676 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
13677 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
13680 clib_memcpy (mp->leid, leid_mac, 6);
13681 clib_memcpy (mp->reid, reid_mac, 6);
13684 errmsg ("unknown EID type %d!", mp->eid_type);
13691 /* Wait for a reply... */
13699 api_lisp_gpe_add_del_iface (vat_main_t * vam)
13701 unformat_input_t *input = vam->input;
13702 vl_api_lisp_gpe_add_del_iface_t *mp;
13704 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
13705 u32 dp_table = 0, vni = 0;
13707 /* Parse args required to build the message */
13708 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13710 if (unformat (input, "up"))
13715 else if (unformat (input, "down"))
13720 else if (unformat (input, "table_id %d", &dp_table))
13724 else if (unformat (input, "bd_id %d", &dp_table))
13729 else if (unformat (input, "vni %d", &vni))
13737 if (action_set == 0)
13739 errmsg ("Action not set\n");
13742 if (dp_table_set == 0 || vni_set == 0)
13744 errmsg ("vni and dp_table must be set\n");
13748 /* Construct the API message */
13749 M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
13751 mp->is_add = is_add;
13752 mp->dp_table = dp_table;
13759 /* Wait for a reply... */
13767 * Add/del map request itr rlocs from LISP control plane and updates
13769 * @param vam vpp API test context
13770 * @return return code
13773 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
13775 unformat_input_t *input = vam->input;
13776 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
13778 u8 *locator_set_name = 0;
13779 u8 locator_set_name_set = 0;
13782 /* Parse args required to build the message */
13783 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13785 if (unformat (input, "del"))
13789 else if (unformat (input, "%_%v%_", &locator_set_name))
13791 locator_set_name_set = 1;
13795 clib_warning ("parse error '%U'", format_unformat_error, input);
13800 if (is_add && !locator_set_name_set)
13802 errmsg ("itr-rloc is not set!");
13806 if (is_add && vec_len (locator_set_name) > 64)
13808 errmsg ("itr-rloc locator-set name too long\n");
13809 vec_free (locator_set_name);
13813 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs);
13814 mp->is_add = is_add;
13817 clib_memcpy (mp->locator_set_name, locator_set_name,
13818 vec_len (locator_set_name));
13822 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
13824 vec_free (locator_set_name);
13829 /* Wait for a reply... */
13837 api_lisp_locator_dump (vat_main_t * vam)
13839 unformat_input_t *input = vam->input;
13840 vl_api_lisp_locator_dump_t *mp;
13842 u8 is_index_set = 0, is_name_set = 0;
13846 /* Parse args required to build the message */
13847 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13849 if (unformat (input, "ls_name %_%v%_", &ls_name))
13853 else if (unformat (input, "ls_index %d", &ls_index))
13859 errmsg ("parse error '%U'", format_unformat_error, input);
13864 if (!is_index_set && !is_name_set)
13866 errmsg ("error: expected one of index or name!\n");
13870 if (is_index_set && is_name_set)
13872 errmsg ("error: only one param expected!\n");
13876 if (vec_len (ls_name) > 62)
13878 errmsg ("error: locator set name too long!");
13882 if (!vam->json_output)
13884 fformat (vam->ofp, "%=16s%=16s%=16s\n", "locator", "priority",
13888 M (LISP_LOCATOR_DUMP, lisp_locator_dump);
13889 mp->is_index_set = is_index_set;
13892 mp->ls_index = clib_host_to_net_u32 (ls_index);
13895 vec_add1 (ls_name, 0);
13896 strncpy ((char *) mp->ls_name, (char *) ls_name,
13897 sizeof (mp->ls_name) - 1);
13903 /* Use a control ping for synchronization */
13905 vl_api_control_ping_t *mp;
13906 M (CONTROL_PING, control_ping);
13909 /* Wait for a reply... */
13917 api_lisp_locator_set_dump (vat_main_t * vam)
13919 vl_api_lisp_locator_set_dump_t *mp;
13920 unformat_input_t *input = vam->input;
13924 /* Parse args required to build the message */
13925 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13927 if (unformat (input, "local"))
13931 else if (unformat (input, "remote"))
13937 errmsg ("parse error '%U'", format_unformat_error, input);
13942 if (!vam->json_output)
13944 fformat (vam->ofp, "%=10s%=15s\n", "ls_index", "ls_name");
13947 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
13949 mp->filter = filter;
13954 /* Use a control ping for synchronization */
13956 vl_api_control_ping_t *mp;
13957 M (CONTROL_PING, control_ping);
13960 /* Wait for a reply... */
13968 api_lisp_eid_table_map_dump (vat_main_t * vam)
13972 unformat_input_t *input = vam->input;
13973 vl_api_lisp_eid_table_map_dump_t *mp;
13976 /* Parse args required to build the message */
13977 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13979 if (unformat (input, "l2"))
13984 else if (unformat (input, "l3"))
13991 errmsg ("parse error '%U'", format_unformat_error, input);
13998 errmsg ("expected one of 'l2' or 'l3' parameter!\n");
14002 if (!vam->json_output)
14004 fformat (vam->ofp, "%=10s%=10s\n", "VNI", is_l2 ? "BD" : "VRF");
14007 M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump);
14013 /* Use a control ping for synchronization */
14015 vl_api_control_ping_t *mp;
14016 M (CONTROL_PING, control_ping);
14019 /* Wait for a reply... */
14027 api_lisp_eid_table_vni_dump (vat_main_t * vam)
14029 vl_api_lisp_eid_table_vni_dump_t *mp;
14032 if (!vam->json_output)
14034 fformat (vam->ofp, "VNI\n");
14037 M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
14042 /* Use a control ping for synchronization */
14044 vl_api_control_ping_t *mp;
14045 M (CONTROL_PING, control_ping);
14048 /* Wait for a reply... */
14056 api_lisp_eid_table_dump (vat_main_t * vam)
14058 unformat_input_t *i = vam->input;
14059 vl_api_lisp_eid_table_dump_t *mp;
14061 struct in_addr ip4;
14062 struct in6_addr ip6;
14064 u8 eid_type = ~0, eid_set = 0;
14065 u32 prefix_length = ~0, t, vni = 0;
14068 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14070 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
14076 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
14082 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
14087 else if (unformat (i, "vni %d", &t))
14091 else if (unformat (i, "local"))
14095 else if (unformat (i, "remote"))
14101 errmsg ("parse error '%U'", format_unformat_error, i);
14106 if (!vam->json_output)
14108 fformat (vam->ofp, "%-35s%-20s%-30s%-20s%-s\n", "EID", "type",
14109 "ls_index", "ttl", "authoritative");
14112 M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump);
14114 mp->filter = filter;
14118 mp->vni = htonl (vni);
14119 mp->eid_type = eid_type;
14123 mp->prefix_length = prefix_length;
14124 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
14127 mp->prefix_length = prefix_length;
14128 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
14131 clib_memcpy (mp->eid, mac, sizeof (mac));
14134 errmsg ("unknown EID type %d!", eid_type);
14142 /* Use a control ping for synchronization */
14144 vl_api_control_ping_t *mp;
14145 M (CONTROL_PING, control_ping);
14149 /* Wait for a reply... */
14157 api_lisp_gpe_tunnel_dump (vat_main_t * vam)
14159 vl_api_lisp_gpe_tunnel_dump_t *mp;
14162 if (!vam->json_output)
14164 fformat (vam->ofp, "%=20s%=30s%=16s%=16s%=16s%=16s"
14165 "%=16s%=16s%=16s%=16s%=16s\n",
14166 "Tunel", "Source", "Destination", "Fib encap", "Fib decap",
14167 "Decap next", "Lisp version", "Flags", "Next protocol",
14168 "ver_res", "res", "iid");
14171 M (LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump);
14175 /* Use a control ping for synchronization */
14177 vl_api_control_ping_t *mp;
14178 M (CONTROL_PING, control_ping);
14181 /* Wait for a reply... */
14189 api_lisp_adjacencies_get (vat_main_t * vam)
14191 unformat_input_t *i = vam->input;
14192 vl_api_lisp_adjacencies_get_t *mp;
14197 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14199 if (unformat (i, "vni %d", &vni))
14205 errmsg ("parse error '%U'\n", format_unformat_error, i);
14212 errmsg ("vni not set!\n");
14216 if (!vam->json_output)
14218 fformat (vam->ofp, "%s %40s\n", "leid", "reid");
14221 M (LISP_ADJACENCIES_GET, lisp_adjacencies_get);
14222 mp->vni = clib_host_to_net_u32 (vni);
14227 /* Wait for a reply... */
14235 api_lisp_map_resolver_dump (vat_main_t * vam)
14237 vl_api_lisp_map_resolver_dump_t *mp;
14240 if (!vam->json_output)
14242 fformat (vam->ofp, "%=20s\n", "Map resolver");
14245 M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
14249 /* Use a control ping for synchronization */
14251 vl_api_control_ping_t *mp;
14252 M (CONTROL_PING, control_ping);
14255 /* Wait for a reply... */
14263 api_show_lisp_status (vat_main_t * vam)
14265 vl_api_show_lisp_status_t *mp;
14268 if (!vam->json_output)
14270 fformat (vam->ofp, "%-20s%-16s\n", "lisp status", "locator-set");
14273 M (SHOW_LISP_STATUS, show_lisp_status);
14276 /* Wait for a reply... */
14284 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
14286 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
14289 if (!vam->json_output)
14291 fformat (vam->ofp, "%=20s\n", "itr-rlocs:");
14294 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
14297 /* Wait for a reply... */
14305 api_af_packet_create (vat_main_t * vam)
14307 unformat_input_t *i = vam->input;
14308 vl_api_af_packet_create_t *mp;
14310 u8 *host_if_name = 0;
14312 u8 random_hw_addr = 1;
14314 memset (hw_addr, 0, sizeof (hw_addr));
14316 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14318 if (unformat (i, "name %s", &host_if_name))
14319 vec_add1 (host_if_name, 0);
14320 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14321 random_hw_addr = 0;
14326 if (!vec_len (host_if_name))
14328 errmsg ("host-interface name must be specified");
14332 if (vec_len (host_if_name) > 64)
14334 errmsg ("host-interface name too long");
14338 M (AF_PACKET_CREATE, af_packet_create);
14340 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14341 clib_memcpy (mp->hw_addr, hw_addr, 6);
14342 mp->use_random_hw_addr = random_hw_addr;
14343 vec_free (host_if_name);
14346 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
14352 api_af_packet_delete (vat_main_t * vam)
14354 unformat_input_t *i = vam->input;
14355 vl_api_af_packet_delete_t *mp;
14357 u8 *host_if_name = 0;
14359 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14361 if (unformat (i, "name %s", &host_if_name))
14362 vec_add1 (host_if_name, 0);
14367 if (!vec_len (host_if_name))
14369 errmsg ("host-interface name must be specified");
14373 if (vec_len (host_if_name) > 64)
14375 errmsg ("host-interface name too long");
14379 M (AF_PACKET_DELETE, af_packet_delete);
14381 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14382 vec_free (host_if_name);
14391 api_policer_add_del (vat_main_t * vam)
14393 unformat_input_t *i = vam->input;
14394 vl_api_policer_add_del_t *mp;
14405 u8 color_aware = 0;
14406 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
14408 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
14409 conform_action.dscp = 0;
14410 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
14411 exceed_action.dscp = 0;
14412 violate_action.action_type = SSE2_QOS_ACTION_DROP;
14413 violate_action.dscp = 0;
14415 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14417 if (unformat (i, "del"))
14419 else if (unformat (i, "name %s", &name))
14420 vec_add1 (name, 0);
14421 else if (unformat (i, "cir %u", &cir))
14423 else if (unformat (i, "eir %u", &eir))
14425 else if (unformat (i, "cb %u", &cb))
14427 else if (unformat (i, "eb %u", &eb))
14429 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
14432 else if (unformat (i, "round_type %U", unformat_policer_round_type,
14435 else if (unformat (i, "type %U", unformat_policer_type, &type))
14437 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
14440 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
14443 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
14446 else if (unformat (i, "color-aware"))
14452 if (!vec_len (name))
14454 errmsg ("policer name must be specified");
14458 if (vec_len (name) > 64)
14460 errmsg ("policer name too long");
14464 M (POLICER_ADD_DEL, policer_add_del);
14466 clib_memcpy (mp->name, name, vec_len (name));
14468 mp->is_add = is_add;
14473 mp->rate_type = rate_type;
14474 mp->round_type = round_type;
14476 mp->conform_action_type = conform_action.action_type;
14477 mp->conform_dscp = conform_action.dscp;
14478 mp->exceed_action_type = exceed_action.action_type;
14479 mp->exceed_dscp = exceed_action.dscp;
14480 mp->violate_action_type = violate_action.action_type;
14481 mp->violate_dscp = violate_action.dscp;
14482 mp->color_aware = color_aware;
14491 api_policer_dump (vat_main_t * vam)
14493 unformat_input_t *i = vam->input;
14494 vl_api_policer_dump_t *mp;
14496 u8 *match_name = 0;
14497 u8 match_name_valid = 0;
14499 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14501 if (unformat (i, "name %s", &match_name))
14503 vec_add1 (match_name, 0);
14504 match_name_valid = 1;
14510 M (POLICER_DUMP, policer_dump);
14511 mp->match_name_valid = match_name_valid;
14512 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
14513 vec_free (match_name);
14517 /* Use a control ping for synchronization */
14519 vl_api_control_ping_t *mp;
14520 M (CONTROL_PING, control_ping);
14523 /* Wait for a reply... */
14531 api_policer_classify_set_interface (vat_main_t * vam)
14533 unformat_input_t *i = vam->input;
14534 vl_api_policer_classify_set_interface_t *mp;
14537 int sw_if_index_set;
14538 u32 ip4_table_index = ~0;
14539 u32 ip6_table_index = ~0;
14540 u32 l2_table_index = ~0;
14543 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14545 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
14546 sw_if_index_set = 1;
14547 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14548 sw_if_index_set = 1;
14549 else if (unformat (i, "del"))
14551 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14553 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14555 else if (unformat (i, "l2-table %d", &l2_table_index))
14559 clib_warning ("parse error '%U'", format_unformat_error, i);
14564 if (sw_if_index_set == 0)
14566 errmsg ("missing interface name or sw_if_index\n");
14570 M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface);
14572 mp->sw_if_index = ntohl (sw_if_index);
14573 mp->ip4_table_index = ntohl (ip4_table_index);
14574 mp->ip6_table_index = ntohl (ip6_table_index);
14575 mp->l2_table_index = ntohl (l2_table_index);
14576 mp->is_add = is_add;
14585 api_policer_classify_dump (vat_main_t * vam)
14587 unformat_input_t *i = vam->input;
14588 vl_api_policer_classify_dump_t *mp;
14590 u8 type = POLICER_CLASSIFY_N_TABLES;
14592 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
14596 errmsg ("classify table type must be specified\n");
14600 if (!vam->json_output)
14602 fformat (vam->ofp, "%10s%20s\n", "Intfc idx", "Classify table");
14605 M (POLICER_CLASSIFY_DUMP, policer_classify_dump);
14610 /* Use a control ping for synchronization */
14612 vl_api_control_ping_t *mp;
14613 M (CONTROL_PING, control_ping);
14616 /* Wait for a reply... */
14624 api_netmap_create (vat_main_t * vam)
14626 unformat_input_t *i = vam->input;
14627 vl_api_netmap_create_t *mp;
14631 u8 random_hw_addr = 1;
14635 memset (hw_addr, 0, sizeof (hw_addr));
14637 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14639 if (unformat (i, "name %s", &if_name))
14640 vec_add1 (if_name, 0);
14641 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14642 random_hw_addr = 0;
14643 else if (unformat (i, "pipe"))
14645 else if (unformat (i, "master"))
14647 else if (unformat (i, "slave"))
14653 if (!vec_len (if_name))
14655 errmsg ("interface name must be specified");
14659 if (vec_len (if_name) > 64)
14661 errmsg ("interface name too long");
14665 M (NETMAP_CREATE, netmap_create);
14667 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
14668 clib_memcpy (mp->hw_addr, hw_addr, 6);
14669 mp->use_random_hw_addr = random_hw_addr;
14670 mp->is_pipe = is_pipe;
14671 mp->is_master = is_master;
14672 vec_free (if_name);
14681 api_netmap_delete (vat_main_t * vam)
14683 unformat_input_t *i = vam->input;
14684 vl_api_netmap_delete_t *mp;
14688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14690 if (unformat (i, "name %s", &if_name))
14691 vec_add1 (if_name, 0);
14696 if (!vec_len (if_name))
14698 errmsg ("interface name must be specified");
14702 if (vec_len (if_name) > 64)
14704 errmsg ("interface name too long");
14708 M (NETMAP_DELETE, netmap_delete);
14710 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
14711 vec_free (if_name);
14719 static void vl_api_mpls_tunnel_details_t_handler
14720 (vl_api_mpls_tunnel_details_t * mp)
14722 vat_main_t *vam = &vat_main;
14723 i32 len = mp->mt_next_hop_n_labels;
14726 fformat (vam->ofp, "[%d]: via %U %d labels ",
14728 format_ip4_address, mp->mt_next_hop,
14729 ntohl (mp->mt_next_hop_sw_if_index));
14730 for (i = 0; i < len; i++)
14732 fformat (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
14734 fformat (vam->ofp, "\n");
14737 static void vl_api_mpls_tunnel_details_t_handler_json
14738 (vl_api_mpls_tunnel_details_t * mp)
14740 vat_main_t *vam = &vat_main;
14741 vat_json_node_t *node = NULL;
14742 struct in_addr ip4;
14744 i32 len = mp->mt_next_hop_n_labels;
14746 if (VAT_JSON_ARRAY != vam->json_tree.type)
14748 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14749 vat_json_init_array (&vam->json_tree);
14751 node = vat_json_array_add (&vam->json_tree);
14753 vat_json_init_object (node);
14754 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
14755 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
14756 vat_json_object_add_ip4 (node, "next_hop", ip4);
14757 vat_json_object_add_uint (node, "next_hop_sw_if_index",
14758 ntohl (mp->mt_next_hop_sw_if_index));
14759 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
14760 vat_json_object_add_uint (node, "label_count", len);
14761 for (i = 0; i < len; i++)
14763 vat_json_object_add_uint (node, "label",
14764 ntohl (mp->mt_next_hop_out_labels[i]));
14769 api_mpls_tunnel_dump (vat_main_t * vam)
14771 vl_api_mpls_tunnel_dump_t *mp;
14775 /* Parse args required to build the message */
14776 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
14778 if (!unformat (vam->input, "tunnel_index %d", &index))
14785 fformat (vam->ofp, " tunnel_index %d\n", index);
14787 M (MPLS_TUNNEL_DUMP, mpls_tunnel_dump);
14788 mp->tunnel_index = htonl (index);
14791 /* Use a control ping for synchronization */
14793 vl_api_control_ping_t *mp;
14794 M (CONTROL_PING, control_ping);
14800 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
14801 #define vl_api_mpls_fib_details_t_print vl_noop_handler
14804 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
14806 vat_main_t *vam = &vat_main;
14807 int count = ntohl (mp->count);
14808 vl_api_fib_path_t *fp;
14812 "table-id %d, label %u, ess_bit %u\n",
14813 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
14815 for (i = 0; i < count; i++)
14817 if (fp->afi == IP46_TYPE_IP6)
14819 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
14820 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
14821 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
14822 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
14823 format_ip6_address, fp->next_hop);
14824 else if (fp->afi == IP46_TYPE_IP4)
14826 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
14827 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
14828 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
14829 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
14830 format_ip4_address, fp->next_hop);
14835 static void vl_api_mpls_fib_details_t_handler_json
14836 (vl_api_mpls_fib_details_t * mp)
14838 vat_main_t *vam = &vat_main;
14839 int count = ntohl (mp->count);
14840 vat_json_node_t *node = NULL;
14841 struct in_addr ip4;
14842 struct in6_addr ip6;
14843 vl_api_fib_path_t *fp;
14846 if (VAT_JSON_ARRAY != vam->json_tree.type)
14848 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14849 vat_json_init_array (&vam->json_tree);
14851 node = vat_json_array_add (&vam->json_tree);
14853 vat_json_init_object (node);
14854 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
14855 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
14856 vat_json_object_add_uint (node, "label", ntohl (mp->label));
14857 vat_json_object_add_uint (node, "path_count", count);
14859 for (i = 0; i < count; i++)
14861 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
14862 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
14863 vat_json_object_add_uint (node, "is_local", fp->is_local);
14864 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
14865 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
14866 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
14867 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
14868 if (fp->afi == IP46_TYPE_IP4)
14870 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
14871 vat_json_object_add_ip4 (node, "next_hop", ip4);
14873 else if (fp->afi == IP46_TYPE_IP6)
14875 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
14876 vat_json_object_add_ip6 (node, "next_hop", ip6);
14882 api_mpls_fib_dump (vat_main_t * vam)
14884 vl_api_mpls_fib_dump_t *mp;
14887 M (MPLS_FIB_DUMP, mpls_fib_dump);
14890 /* Use a control ping for synchronization */
14892 vl_api_control_ping_t *mp;
14893 M (CONTROL_PING, control_ping);
14899 #define vl_api_ip_fib_details_t_endian vl_noop_handler
14900 #define vl_api_ip_fib_details_t_print vl_noop_handler
14903 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
14905 vat_main_t *vam = &vat_main;
14906 int count = ntohl (mp->count);
14907 vl_api_fib_path_t *fp;
14911 "table-id %d, prefix %U/%d\n",
14912 ntohl (mp->table_id), format_ip4_address, mp->address,
14913 mp->address_length);
14915 for (i = 0; i < count; i++)
14917 if (fp->afi == IP46_TYPE_IP6)
14919 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
14920 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
14921 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
14922 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
14923 format_ip6_address, fp->next_hop);
14924 else if (fp->afi == IP46_TYPE_IP4)
14926 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
14927 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
14928 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
14929 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
14930 format_ip4_address, fp->next_hop);
14935 static void vl_api_ip_fib_details_t_handler_json
14936 (vl_api_ip_fib_details_t * mp)
14938 vat_main_t *vam = &vat_main;
14939 int count = ntohl (mp->count);
14940 vat_json_node_t *node = NULL;
14941 struct in_addr ip4;
14942 struct in6_addr ip6;
14943 vl_api_fib_path_t *fp;
14946 if (VAT_JSON_ARRAY != vam->json_tree.type)
14948 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14949 vat_json_init_array (&vam->json_tree);
14951 node = vat_json_array_add (&vam->json_tree);
14953 vat_json_init_object (node);
14954 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
14955 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
14956 vat_json_object_add_ip4 (node, "prefix", ip4);
14957 vat_json_object_add_uint (node, "mask_length", mp->address_length);
14958 vat_json_object_add_uint (node, "path_count", count);
14960 for (i = 0; i < count; i++)
14962 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
14963 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
14964 vat_json_object_add_uint (node, "is_local", fp->is_local);
14965 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
14966 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
14967 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
14968 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
14969 if (fp->afi == IP46_TYPE_IP4)
14971 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
14972 vat_json_object_add_ip4 (node, "next_hop", ip4);
14974 else if (fp->afi == IP46_TYPE_IP6)
14976 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
14977 vat_json_object_add_ip6 (node, "next_hop", ip6);
14983 api_ip_fib_dump (vat_main_t * vam)
14985 vl_api_ip_fib_dump_t *mp;
14988 M (IP_FIB_DUMP, ip_fib_dump);
14991 /* Use a control ping for synchronization */
14993 vl_api_control_ping_t *mp;
14994 M (CONTROL_PING, control_ping);
15000 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
15001 #define vl_api_ip6_fib_details_t_print vl_noop_handler
15004 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
15006 vat_main_t *vam = &vat_main;
15007 int count = ntohl (mp->count);
15008 vl_api_fib_path_t *fp;
15012 "table-id %d, prefix %U/%d\n",
15013 ntohl (mp->table_id), format_ip6_address, mp->address,
15014 mp->address_length);
15016 for (i = 0; i < count; i++)
15018 if (fp->afi == IP46_TYPE_IP6)
15020 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15021 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15022 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15023 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15024 format_ip6_address, fp->next_hop);
15025 else if (fp->afi == IP46_TYPE_IP4)
15027 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15028 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15029 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15030 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15031 format_ip4_address, fp->next_hop);
15036 static void vl_api_ip6_fib_details_t_handler_json
15037 (vl_api_ip6_fib_details_t * mp)
15039 vat_main_t *vam = &vat_main;
15040 int count = ntohl (mp->count);
15041 vat_json_node_t *node = NULL;
15042 struct in_addr ip4;
15043 struct in6_addr ip6;
15044 vl_api_fib_path_t *fp;
15047 if (VAT_JSON_ARRAY != vam->json_tree.type)
15049 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15050 vat_json_init_array (&vam->json_tree);
15052 node = vat_json_array_add (&vam->json_tree);
15054 vat_json_init_object (node);
15055 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15056 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
15057 vat_json_object_add_ip6 (node, "prefix", ip6);
15058 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15059 vat_json_object_add_uint (node, "path_count", count);
15061 for (i = 0; i < count; i++)
15063 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15064 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15065 vat_json_object_add_uint (node, "is_local", fp->is_local);
15066 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15067 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15068 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15069 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15070 if (fp->afi == IP46_TYPE_IP4)
15072 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15073 vat_json_object_add_ip4 (node, "next_hop", ip4);
15075 else if (fp->afi == IP46_TYPE_IP6)
15077 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15078 vat_json_object_add_ip6 (node, "next_hop", ip6);
15084 api_ip6_fib_dump (vat_main_t * vam)
15086 vl_api_ip6_fib_dump_t *mp;
15089 M (IP6_FIB_DUMP, ip6_fib_dump);
15092 /* Use a control ping for synchronization */
15094 vl_api_control_ping_t *mp;
15095 M (CONTROL_PING, control_ping);
15102 api_classify_table_ids (vat_main_t * vam)
15104 vl_api_classify_table_ids_t *mp;
15107 /* Construct the API message */
15108 M (CLASSIFY_TABLE_IDS, classify_table_ids);
15118 api_classify_table_by_interface (vat_main_t * vam)
15120 unformat_input_t *input = vam->input;
15121 vl_api_classify_table_by_interface_t *mp;
15124 u32 sw_if_index = ~0;
15125 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15127 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
15129 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15134 if (sw_if_index == ~0)
15136 errmsg ("missing interface name or sw_if_index\n");
15140 /* Construct the API message */
15141 M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
15143 mp->sw_if_index = ntohl (sw_if_index);
15152 api_classify_table_info (vat_main_t * vam)
15154 unformat_input_t *input = vam->input;
15155 vl_api_classify_table_info_t *mp;
15159 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15161 if (unformat (input, "table_id %d", &table_id))
15166 if (table_id == ~0)
15168 errmsg ("missing table id\n");
15172 /* Construct the API message */
15173 M (CLASSIFY_TABLE_INFO, classify_table_info);
15175 mp->table_id = ntohl (table_id);
15184 api_classify_session_dump (vat_main_t * vam)
15186 unformat_input_t *input = vam->input;
15187 vl_api_classify_session_dump_t *mp;
15191 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15193 if (unformat (input, "table_id %d", &table_id))
15198 if (table_id == ~0)
15200 errmsg ("missing table id\n");
15204 /* Construct the API message */
15205 M (CLASSIFY_SESSION_DUMP, classify_session_dump);
15207 mp->table_id = ntohl (table_id);
15210 /* Use a control ping for synchronization */
15212 vl_api_control_ping_t *mp;
15213 M (CONTROL_PING, control_ping);
15222 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
15224 vat_main_t *vam = &vat_main;
15226 fformat (vam->ofp, "collector_address %U, collector_port %d, "
15227 "src_address %U, vrf_id %d, path_mtu %u, "
15228 "template_interval %u, udp_checksum %d\n",
15229 format_ip4_address, mp->collector_address,
15230 ntohs (mp->collector_port),
15231 format_ip4_address, mp->src_address,
15232 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
15233 ntohl (mp->template_interval), mp->udp_checksum);
15236 vam->result_ready = 1;
15240 vl_api_ipfix_exporter_details_t_handler_json
15241 (vl_api_ipfix_exporter_details_t * mp)
15243 vat_main_t *vam = &vat_main;
15244 vat_json_node_t node;
15245 struct in_addr collector_address;
15246 struct in_addr src_address;
15248 vat_json_init_object (&node);
15249 clib_memcpy (&collector_address, &mp->collector_address,
15250 sizeof (collector_address));
15251 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
15252 vat_json_object_add_uint (&node, "collector_port",
15253 ntohs (mp->collector_port));
15254 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
15255 vat_json_object_add_ip4 (&node, "src_address", src_address);
15256 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
15257 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
15258 vat_json_object_add_uint (&node, "template_interval",
15259 ntohl (mp->template_interval));
15260 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
15262 vat_json_print (vam->ofp, &node);
15263 vat_json_free (&node);
15265 vam->result_ready = 1;
15269 api_ipfix_exporter_dump (vat_main_t * vam)
15271 vl_api_ipfix_exporter_dump_t *mp;
15274 /* Construct the API message */
15275 M (IPFIX_EXPORTER_DUMP, ipfix_exporter_dump);
15285 api_ipfix_classify_stream_dump (vat_main_t * vam)
15287 vl_api_ipfix_classify_stream_dump_t *mp;
15290 /* Construct the API message */
15291 M (IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump);
15301 vl_api_ipfix_classify_stream_details_t_handler
15302 (vl_api_ipfix_classify_stream_details_t * mp)
15304 vat_main_t *vam = &vat_main;
15305 fformat (vam->ofp, "domain_id %d, src_port %d\n",
15306 ntohl (mp->domain_id), ntohs (mp->src_port));
15308 vam->result_ready = 1;
15312 vl_api_ipfix_classify_stream_details_t_handler_json
15313 (vl_api_ipfix_classify_stream_details_t * mp)
15315 vat_main_t *vam = &vat_main;
15316 vat_json_node_t node;
15318 vat_json_init_object (&node);
15319 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
15320 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
15322 vat_json_print (vam->ofp, &node);
15323 vat_json_free (&node);
15325 vam->result_ready = 1;
15329 api_ipfix_classify_table_dump (vat_main_t * vam)
15331 vl_api_ipfix_classify_table_dump_t *mp;
15334 if (!vam->json_output)
15336 fformat (vam->ofp, "%15s%15s%20s\n", "table_id", "ip_version",
15337 "transport_protocol");
15340 /* Construct the API message */
15341 M (IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump);
15346 /* Use a control ping for synchronization */
15348 vl_api_control_ping_t *mp;
15349 M (CONTROL_PING, control_ping);
15356 vl_api_ipfix_classify_table_details_t_handler
15357 (vl_api_ipfix_classify_table_details_t * mp)
15359 vat_main_t *vam = &vat_main;
15360 fformat (vam->ofp, "%15d%15d%20d\n", ntohl (mp->table_id), mp->ip_version,
15361 mp->transport_protocol);
15365 vl_api_ipfix_classify_table_details_t_handler_json
15366 (vl_api_ipfix_classify_table_details_t * mp)
15368 vat_json_node_t *node = NULL;
15369 vat_main_t *vam = &vat_main;
15371 if (VAT_JSON_ARRAY != vam->json_tree.type)
15373 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15374 vat_json_init_array (&vam->json_tree);
15377 node = vat_json_array_add (&vam->json_tree);
15378 vat_json_init_object (node);
15380 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
15381 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
15382 vat_json_object_add_uint (node, "transport_protocol",
15383 mp->transport_protocol);
15387 api_sw_interface_span_enable_disable (vat_main_t * vam)
15389 unformat_input_t *i = vam->input;
15390 vl_api_sw_interface_span_enable_disable_t *mp;
15392 u32 src_sw_if_index = ~0;
15393 u32 dst_sw_if_index = ~0;
15396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15398 if (unformat (i, "src %U", unformat_sw_if_index, vam, &src_sw_if_index))
15400 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
15404 (i, "dst %U", unformat_sw_if_index, vam, &dst_sw_if_index))
15406 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
15408 else if (unformat (i, "disable"))
15414 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, sw_interface_span_enable_disable);
15416 mp->sw_if_index_from = htonl (src_sw_if_index);
15417 mp->sw_if_index_to = htonl (dst_sw_if_index);
15418 mp->enable = enable;
15427 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
15430 vat_main_t *vam = &vat_main;
15432 fformat (vam->ofp, "%u => %u\n",
15433 ntohl (mp->sw_if_index_from), ntohl (mp->sw_if_index_to));
15437 vl_api_sw_interface_span_details_t_handler_json
15438 (vl_api_sw_interface_span_details_t * mp)
15440 vat_main_t *vam = &vat_main;
15441 vat_json_node_t *node = NULL;
15443 if (VAT_JSON_ARRAY != vam->json_tree.type)
15445 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15446 vat_json_init_array (&vam->json_tree);
15448 node = vat_json_array_add (&vam->json_tree);
15450 vat_json_init_object (node);
15451 vat_json_object_add_uint (node, "src-if-index",
15452 ntohl (mp->sw_if_index_from));
15453 vat_json_object_add_uint (node, "dst-if-index", ntohl (mp->sw_if_index_to));
15457 api_sw_interface_span_dump (vat_main_t * vam)
15459 vl_api_sw_interface_span_dump_t *mp;
15462 M (SW_INTERFACE_SPAN_DUMP, sw_interface_span_dump);
15465 /* Use a control ping for synchronization */
15467 vl_api_control_ping_t *mp;
15468 M (CONTROL_PING, control_ping);
15475 api_pg_create_interface (vat_main_t * vam)
15477 unformat_input_t *input = vam->input;
15478 vl_api_pg_create_interface_t *mp;
15482 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15484 if (unformat (input, "if_id %d", &if_id))
15491 errmsg ("missing pg interface index\n");
15495 /* Construct the API message */
15496 M (PG_CREATE_INTERFACE, pg_create_interface);
15498 mp->interface_id = ntohl (if_id);
15507 api_pg_capture (vat_main_t * vam)
15509 unformat_input_t *input = vam->input;
15510 vl_api_pg_capture_t *mp;
15516 u8 pcap_file_set = 0;
15518 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15520 if (unformat (input, "if_id %d", &if_id))
15522 else if (unformat (input, "pcap %s", &pcap_file))
15524 else if (unformat (input, "count %d", &count))
15526 else if (unformat (input, "disable"))
15533 errmsg ("missing pg interface index\n");
15536 if (pcap_file_set > 0)
15538 if (vec_len (pcap_file) > 255)
15540 errmsg ("pcap file name is too long\n");
15545 u32 name_len = vec_len (pcap_file);
15546 /* Construct the API message */
15547 M (PG_CAPTURE, pg_capture);
15549 mp->interface_id = ntohl (if_id);
15550 mp->is_enabled = enable;
15551 mp->count = ntohl (count);
15552 mp->pcap_name_length = ntohl (name_len);
15553 if (pcap_file_set != 0)
15555 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
15557 vec_free (pcap_file);
15566 api_pg_enable_disable (vat_main_t * vam)
15568 unformat_input_t *input = vam->input;
15569 vl_api_pg_enable_disable_t *mp;
15573 u8 stream_name_set = 0;
15574 u8 *stream_name = 0;
15575 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15577 if (unformat (input, "stream %s", &stream_name))
15578 stream_name_set = 1;
15579 else if (unformat (input, "disable"))
15585 if (stream_name_set > 0)
15587 if (vec_len (stream_name) > 255)
15589 errmsg ("stream name too long\n");
15594 u32 name_len = vec_len (stream_name);
15595 /* Construct the API message */
15596 M (PG_ENABLE_DISABLE, pg_enable_disable);
15598 mp->is_enabled = enable;
15599 if (stream_name_set != 0)
15601 mp->stream_name_length = ntohl (name_len);
15602 clib_memcpy (mp->stream_name, stream_name, name_len);
15604 vec_free (stream_name);
15613 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
15615 unformat_input_t *input = vam->input;
15616 vl_api_ip_source_and_port_range_check_add_del_t *mp;
15619 u16 *low_ports = 0;
15620 u16 *high_ports = 0;
15623 ip4_address_t ip4_addr;
15624 ip6_address_t ip6_addr;
15632 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15634 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
15640 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
15645 else if (unformat (input, "vrf %d", &vrf_id))
15647 else if (unformat (input, "del"))
15649 else if (unformat (input, "port %d", &tmp))
15651 if (tmp == 0 || tmp > 65535)
15653 errmsg ("port %d out of range", tmp);
15657 this_hi = this_low + 1;
15658 vec_add1 (low_ports, this_low);
15659 vec_add1 (high_ports, this_hi);
15661 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
15663 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
15665 errmsg ("incorrect range parameters\n");
15669 /* Note: in debug CLI +1 is added to high before
15670 passing to real fn that does "the work"
15671 (ip_source_and_port_range_check_add_del).
15672 This fn is a wrapper around the binary API fn a
15673 control plane will call, which expects this increment
15674 to have occurred. Hence letting the binary API control
15675 plane fn do the increment for consistency between VAT
15676 and other control planes.
15679 vec_add1 (low_ports, this_low);
15680 vec_add1 (high_ports, this_hi);
15686 if (prefix_set == 0)
15688 errmsg ("<address>/<mask> not specified\n");
15694 errmsg ("VRF ID required, not specified\n");
15701 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
15705 if (vec_len (low_ports) == 0)
15707 errmsg ("At least one port or port range required\n");
15711 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,
15712 ip_source_and_port_range_check_add_del);
15714 mp->is_add = is_add;
15719 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
15724 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
15727 mp->mask_length = length;
15728 mp->number_of_ranges = vec_len (low_ports);
15730 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
15731 vec_free (low_ports);
15733 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
15734 vec_free (high_ports);
15736 mp->vrf_id = ntohl (vrf_id);
15745 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
15747 unformat_input_t *input = vam->input;
15748 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
15750 u32 sw_if_index = ~0;
15752 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
15753 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
15756 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15758 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
15760 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15762 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
15764 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
15766 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
15768 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
15770 else if (unformat (input, "del"))
15776 if (sw_if_index == ~0)
15778 errmsg ("Interface required but not specified\n");
15784 errmsg ("VRF ID required but not specified\n");
15788 if (tcp_out_vrf_id == 0
15789 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
15792 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
15796 /* Construct the API message */
15797 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,
15798 ip_source_and_port_range_check_interface_add_del);
15800 mp->sw_if_index = ntohl (sw_if_index);
15801 mp->is_add = is_add;
15802 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
15803 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
15804 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
15805 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
15810 /* Wait for a reply... */
15815 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
15817 unformat_input_t *i = vam->input;
15818 vl_api_ipsec_gre_add_del_tunnel_t *mp;
15820 u32 local_sa_id = 0;
15821 u32 remote_sa_id = 0;
15822 ip4_address_t src_address;
15823 ip4_address_t dst_address;
15826 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15828 if (unformat (i, "local_sa %d", &local_sa_id))
15830 else if (unformat (i, "remote_sa %d", &remote_sa_id))
15832 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
15834 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
15836 else if (unformat (i, "del"))
15840 clib_warning ("parse error '%U'", format_unformat_error, i);
15845 M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel);
15847 mp->local_sa_id = ntohl (local_sa_id);
15848 mp->remote_sa_id = ntohl (remote_sa_id);
15849 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
15850 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
15851 mp->is_add = is_add;
15860 api_punt (vat_main_t * vam)
15862 unformat_input_t *i = vam->input;
15870 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15872 if (unformat (i, "ip %d", &ipv))
15874 else if (unformat (i, "protocol %d", &protocol))
15876 else if (unformat (i, "port %d", &port))
15878 else if (unformat (i, "del"))
15882 clib_warning ("parse error '%U'", format_unformat_error, i);
15889 mp->is_add = (u8) is_add;
15890 mp->ipv = (u8) ipv;
15891 mp->l4_protocol = (u8) protocol;
15892 mp->l4_port = htons ((u16) port);
15900 static void vl_api_ipsec_gre_tunnel_details_t_handler
15901 (vl_api_ipsec_gre_tunnel_details_t * mp)
15903 vat_main_t *vam = &vat_main;
15905 fformat (vam->ofp, "%11d%15U%15U%14d%14d\n",
15906 ntohl (mp->sw_if_index),
15907 format_ip4_address, &mp->src_address,
15908 format_ip4_address, &mp->dst_address,
15909 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
15912 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
15913 (vl_api_ipsec_gre_tunnel_details_t * mp)
15915 vat_main_t *vam = &vat_main;
15916 vat_json_node_t *node = NULL;
15917 struct in_addr ip4;
15919 if (VAT_JSON_ARRAY != vam->json_tree.type)
15921 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15922 vat_json_init_array (&vam->json_tree);
15924 node = vat_json_array_add (&vam->json_tree);
15926 vat_json_init_object (node);
15927 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15928 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
15929 vat_json_object_add_ip4 (node, "src_address", ip4);
15930 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
15931 vat_json_object_add_ip4 (node, "dst_address", ip4);
15932 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
15933 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
15937 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
15939 unformat_input_t *i = vam->input;
15940 vl_api_ipsec_gre_tunnel_dump_t *mp;
15943 u8 sw_if_index_set = 0;
15945 /* Parse args required to build the message */
15946 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15948 if (unformat (i, "sw_if_index %d", &sw_if_index))
15949 sw_if_index_set = 1;
15954 if (sw_if_index_set == 0)
15959 if (!vam->json_output)
15961 fformat (vam->ofp, "%11s%15s%15s%14s%14s\n",
15962 "sw_if_index", "src_address", "dst_address",
15963 "local_sa_id", "remote_sa_id");
15966 /* Get list of gre-tunnel interfaces */
15967 M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump);
15969 mp->sw_if_index = htonl (sw_if_index);
15973 /* Use a control ping for synchronization */
15975 vl_api_control_ping_t *mp;
15976 M (CONTROL_PING, control_ping);
15983 api_delete_subif (vat_main_t * vam)
15985 unformat_input_t *i = vam->input;
15986 vl_api_delete_subif_t *mp;
15988 u32 sw_if_index = ~0;
15990 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15992 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
15994 if (unformat (i, "sw_if_index %d", &sw_if_index))
16000 if (sw_if_index == ~0)
16002 errmsg ("missing sw_if_index\n");
16006 /* Construct the API message */
16007 M (DELETE_SUBIF, delete_subif);
16008 mp->sw_if_index = ntohl (sw_if_index);
16014 #define foreach_pbb_vtr_op \
16015 _("disable", L2_VTR_DISABLED) \
16016 _("pop", L2_VTR_POP_2) \
16017 _("push", L2_VTR_PUSH_2)
16020 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
16022 unformat_input_t *i = vam->input;
16023 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
16025 u32 sw_if_index = ~0, vtr_op = ~0;
16026 u16 outer_tag = ~0;
16027 u8 dmac[6], smac[6];
16028 u8 dmac_set = 0, smac_set = 0;
16033 /* Shut up coverity */
16034 memset (dmac, 0, sizeof (dmac));
16035 memset (smac, 0, sizeof (smac));
16037 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16039 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16041 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16043 else if (unformat (i, "vtr_op %d", &vtr_op))
16045 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
16048 else if (unformat (i, "translate_pbb_stag"))
16050 if (unformat (i, "%d", &tmp))
16052 vtr_op = L2_VTR_TRANSLATE_2_1;
16058 ("translate_pbb_stag operation requires outer tag definition\n");
16062 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
16064 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
16066 else if (unformat (i, "sid %d", &sid))
16068 else if (unformat (i, "vlanid %d", &tmp))
16072 clib_warning ("parse error '%U'", format_unformat_error, i);
16077 if ((sw_if_index == ~0) || (vtr_op == ~0))
16079 errmsg ("missing sw_if_index or vtr operation\n");
16082 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
16083 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
16086 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid\n");
16090 M (L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite);
16091 mp->sw_if_index = ntohl (sw_if_index);
16092 mp->vtr_op = ntohl (vtr_op);
16093 mp->outer_tag = ntohs (outer_tag);
16094 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
16095 clib_memcpy (mp->b_smac, smac, sizeof (smac));
16096 mp->b_vlanid = ntohs (vlanid);
16097 mp->i_sid = ntohl (sid);
16106 api_flow_classify_set_interface (vat_main_t * vam)
16108 unformat_input_t *i = vam->input;
16109 vl_api_flow_classify_set_interface_t *mp;
16112 int sw_if_index_set;
16113 u32 ip4_table_index = ~0;
16114 u32 ip6_table_index = ~0;
16117 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16119 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16120 sw_if_index_set = 1;
16121 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16122 sw_if_index_set = 1;
16123 else if (unformat (i, "del"))
16125 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16127 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16131 clib_warning ("parse error '%U'", format_unformat_error, i);
16136 if (sw_if_index_set == 0)
16138 errmsg ("missing interface name or sw_if_index\n");
16142 M (FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface);
16144 mp->sw_if_index = ntohl (sw_if_index);
16145 mp->ip4_table_index = ntohl (ip4_table_index);
16146 mp->ip6_table_index = ntohl (ip6_table_index);
16147 mp->is_add = is_add;
16156 api_flow_classify_dump (vat_main_t * vam)
16158 unformat_input_t *i = vam->input;
16159 vl_api_flow_classify_dump_t *mp;
16161 u8 type = FLOW_CLASSIFY_N_TABLES;
16163 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
16167 errmsg ("classify table type must be specified\n");
16171 if (!vam->json_output)
16173 fformat (vam->ofp, "%10s%20s\n", "Intfc idx", "Classify table");
16176 M (FLOW_CLASSIFY_DUMP, flow_classify_dump);
16181 /* Use a control ping for synchronization */
16183 vl_api_control_ping_t *mp;
16184 M (CONTROL_PING, control_ping);
16187 /* Wait for a reply... */
16195 api_feature_enable_disable (vat_main_t * vam)
16197 unformat_input_t *i = vam->input;
16198 vl_api_feature_enable_disable_t *mp;
16201 u8 *feature_name = 0;
16202 u32 sw_if_index = ~0;
16205 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16207 if (unformat (i, "arc_name %s", &arc_name))
16209 else if (unformat (i, "feature_name %s", &feature_name))
16211 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16213 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16215 else if (unformat (i, "disable"))
16223 errmsg ("missing arc name\n");
16226 if (vec_len (arc_name) > 63)
16228 errmsg ("arc name too long\n");
16231 if (feature_name == 0)
16233 errmsg ("missing feature name\n");
16236 if (vec_len (feature_name) > 63)
16238 errmsg ("feature name too long\n");
16241 if (sw_if_index == ~0)
16243 errmsg ("missing interface name or sw_if_index\n");
16247 /* Construct the API message */
16248 M (FEATURE_ENABLE_DISABLE, feature_enable_disable);
16249 mp->sw_if_index = ntohl (sw_if_index);
16250 mp->enable = enable;
16251 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
16252 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
16253 vec_free (arc_name);
16254 vec_free (feature_name);
16261 api_sw_interface_tag_add_del (vat_main_t * vam)
16263 unformat_input_t *i = vam->input;
16264 vl_api_sw_interface_tag_add_del_t *mp;
16266 u32 sw_if_index = ~0;
16270 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16272 if (unformat (i, "tag %s", &tag))
16274 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16276 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16278 else if (unformat (i, "del"))
16284 if (sw_if_index == ~0)
16286 errmsg ("missing interface name or sw_if_index\n");
16290 if (enable && (tag == 0))
16292 errmsg ("no tag specified\n");
16296 /* Construct the API message */
16297 M (SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del);
16298 mp->sw_if_index = ntohl (sw_if_index);
16299 mp->is_add = enable;
16301 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
16308 static void vl_api_l2_xconnect_details_t_handler
16309 (vl_api_l2_xconnect_details_t * mp)
16311 vat_main_t *vam = &vat_main;
16313 fformat (vam->ofp, "%15d%15d\n",
16314 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
16317 static void vl_api_l2_xconnect_details_t_handler_json
16318 (vl_api_l2_xconnect_details_t * mp)
16320 vat_main_t *vam = &vat_main;
16321 vat_json_node_t *node = NULL;
16323 if (VAT_JSON_ARRAY != vam->json_tree.type)
16325 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16326 vat_json_init_array (&vam->json_tree);
16328 node = vat_json_array_add (&vam->json_tree);
16330 vat_json_init_object (node);
16331 vat_json_object_add_uint (node, "rx_sw_if_index",
16332 ntohl (mp->rx_sw_if_index));
16333 vat_json_object_add_uint (node, "tx_sw_if_index",
16334 ntohl (mp->tx_sw_if_index));
16338 api_l2_xconnect_dump (vat_main_t * vam)
16340 vl_api_l2_xconnect_dump_t *mp;
16343 if (!vam->json_output)
16345 fformat (vam->ofp, "%15s%15s\n", "rx_sw_if_index", "tx_sw_if_index");
16348 M (L2_XCONNECT_DUMP, l2_xconnect_dump);
16352 /* Use a control ping for synchronization */
16354 vl_api_control_ping_t *mp;
16355 M (CONTROL_PING, control_ping);
16362 q_or_quit (vat_main_t * vam)
16364 longjmp (vam->jump_buf, 1);
16365 return 0; /* not so much */
16369 q (vat_main_t * vam)
16371 return q_or_quit (vam);
16375 quit (vat_main_t * vam)
16377 return q_or_quit (vam);
16381 comment (vat_main_t * vam)
16387 cmd_cmp (void *a1, void *a2)
16392 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
16396 help (vat_main_t * vam)
16401 unformat_input_t *i = vam->input;
16404 if (unformat (i, "%s", &name))
16408 vec_add1 (name, 0);
16410 hs = hash_get_mem (vam->help_by_name, name);
16412 fformat (vam->ofp, "usage: %s %s\n", name, hs[0]);
16414 fformat (vam->ofp, "No such msg / command '%s'\n", name);
16419 fformat (vam->ofp, "Help is available for the following:\n");
16422 hash_foreach_pair (p, vam->function_by_name,
16424 vec_add1 (cmds, (u8 *)(p->key));
16428 vec_sort_with_function (cmds, cmd_cmp);
16430 for (j = 0; j < vec_len (cmds); j++)
16431 fformat (vam->ofp, "%s\n", cmds[j]);
16438 set (vat_main_t * vam)
16440 u8 *name = 0, *value = 0;
16441 unformat_input_t *i = vam->input;
16443 if (unformat (i, "%s", &name))
16445 /* The input buffer is a vector, not a string. */
16446 value = vec_dup (i->buffer);
16447 vec_delete (value, i->index, 0);
16448 /* Almost certainly has a trailing newline */
16449 if (value[vec_len (value) - 1] == '\n')
16450 value[vec_len (value) - 1] = 0;
16451 /* Make sure it's a proper string, one way or the other */
16452 vec_add1 (value, 0);
16453 (void) clib_macro_set_value (&vam->macro_main,
16454 (char *) name, (char *) value);
16457 errmsg ("usage: set <name> <value>\n");
16465 unset (vat_main_t * vam)
16469 if (unformat (vam->input, "%s", &name))
16470 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
16471 errmsg ("unset: %s wasn't set\n", name);
16484 macro_sort_cmp (void *a1, void *a2)
16486 macro_sort_t *s1 = a1;
16487 macro_sort_t *s2 = a2;
16489 return strcmp ((char *) (s1->name), (char *) (s2->name));
16493 dump_macro_table (vat_main_t * vam)
16495 macro_sort_t *sort_me = 0, *sm;
16500 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
16502 vec_add2 (sort_me, sm, 1);
16503 sm->name = (u8 *)(p->key);
16504 sm->value = (u8 *) (p->value[0]);
16508 vec_sort_with_function (sort_me, macro_sort_cmp);
16510 if (vec_len (sort_me))
16511 fformat (vam->ofp, "%-15s%s\n", "Name", "Value");
16513 fformat (vam->ofp, "The macro table is empty...\n");
16515 for (i = 0; i < vec_len (sort_me); i++)
16516 fformat (vam->ofp, "%-15s%s\n", sort_me[i].name, sort_me[i].value);
16521 dump_node_table (vat_main_t * vam)
16524 vlib_node_t *node, *next_node;
16526 if (vec_len (vam->graph_nodes) == 0)
16528 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
16532 for (i = 0; i < vec_len (vam->graph_nodes); i++)
16534 node = vam->graph_nodes[i];
16535 fformat (vam->ofp, "[%d] %s\n", i, node->name);
16536 for (j = 0; j < vec_len (node->next_nodes); j++)
16538 if (node->next_nodes[j] != ~0)
16540 next_node = vam->graph_nodes[node->next_nodes[j]];
16541 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
16549 value_sort_cmp (void *a1, void *a2)
16551 name_sort_t *n1 = a1;
16552 name_sort_t *n2 = a2;
16554 if (n1->value < n2->value)
16556 if (n1->value > n2->value)
16563 dump_msg_api_table (vat_main_t * vam)
16565 api_main_t *am = &api_main;
16566 name_sort_t *nses = 0, *ns;
16571 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
16573 vec_add2 (nses, ns, 1);
16574 ns->name = (u8 *)(hp->key);
16575 ns->value = (u32) hp->value[0];
16579 vec_sort_with_function (nses, value_sort_cmp);
16581 for (i = 0; i < vec_len (nses); i++)
16582 fformat (vam->ofp, " [%d]: %s\n", nses[i].value, nses[i].name);
16588 get_msg_id (vat_main_t * vam)
16593 if (unformat (vam->input, "%s", &name_and_crc))
16595 message_index = vl_api_get_msg_index (name_and_crc);
16596 if (message_index == ~0)
16598 fformat (vam->ofp, " '%s' not found\n", name_and_crc);
16601 fformat (vam->ofp, " '%s' has message index %d\n",
16602 name_and_crc, message_index);
16605 errmsg ("name_and_crc required...\n");
16610 search_node_table (vat_main_t * vam)
16612 unformat_input_t *line_input = vam->input;
16615 vlib_node_t *node, *next_node;
16618 if (vam->graph_node_index_by_name == 0)
16620 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
16624 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16626 if (unformat (line_input, "%s", &node_to_find))
16628 vec_add1 (node_to_find, 0);
16629 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
16632 fformat (vam->ofp, "%s not found...\n", node_to_find);
16635 node = vam->graph_nodes[p[0]];
16636 fformat (vam->ofp, "[%d] %s\n", p[0], node->name);
16637 for (j = 0; j < vec_len (node->next_nodes); j++)
16639 if (node->next_nodes[j] != ~0)
16641 next_node = vam->graph_nodes[node->next_nodes[j]];
16642 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
16649 clib_warning ("parse error '%U'", format_unformat_error,
16655 vec_free (node_to_find);
16664 script (vat_main_t * vam)
16667 char *save_current_file;
16668 unformat_input_t save_input;
16669 jmp_buf save_jump_buf;
16670 u32 save_line_number;
16672 FILE *new_fp, *save_ifp;
16674 if (unformat (vam->input, "%s", &s))
16676 new_fp = fopen ((char *) s, "r");
16679 errmsg ("Couldn't open script file %s\n", s);
16686 errmsg ("Missing script name\n");
16690 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
16691 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
16692 save_ifp = vam->ifp;
16693 save_line_number = vam->input_line_number;
16694 save_current_file = (char *) vam->current_file;
16696 vam->input_line_number = 0;
16698 vam->current_file = s;
16701 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
16702 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
16703 vam->ifp = save_ifp;
16704 vam->input_line_number = save_line_number;
16705 vam->current_file = (u8 *) save_current_file;
16712 echo (vat_main_t * vam)
16714 fformat (vam->ofp, "%v", vam->input->buffer);
16718 /* List of API message constructors, CLI names map to api_xxx */
16719 #define foreach_vpe_api_msg \
16720 _(create_loopback,"[mac <mac-addr>]") \
16721 _(sw_interface_dump,"") \
16722 _(sw_interface_set_flags, \
16723 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
16724 _(sw_interface_add_del_address, \
16725 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
16726 _(sw_interface_set_table, \
16727 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
16728 _(sw_interface_set_mpls_enable, \
16729 "<intfc> | sw_if_index [disable | dis]") \
16730 _(sw_interface_set_vpath, \
16731 "<intfc> | sw_if_index <id> enable | disable") \
16732 _(sw_interface_set_vxlan_bypass, \
16733 "<intfc> | sw_if_index <id> [ip4 | ip6] enable | disable") \
16734 _(sw_interface_set_l2_xconnect, \
16735 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
16736 "enable | disable") \
16737 _(sw_interface_set_l2_bridge, \
16738 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
16739 "[shg <split-horizon-group>] [bvi]\n" \
16740 "enable | disable") \
16741 _(sw_interface_set_dpdk_hqos_pipe, \
16742 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
16743 "profile <profile-id>\n") \
16744 _(sw_interface_set_dpdk_hqos_subport, \
16745 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
16746 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
16747 _(sw_interface_set_dpdk_hqos_tctbl, \
16748 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n") \
16749 _(bridge_domain_add_del, \
16750 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n")\
16751 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
16753 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
16755 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
16757 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
16759 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
16761 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
16763 "<vpp-if-name> | sw_if_index <id>") \
16764 _(sw_interface_tap_dump, "") \
16765 _(ip_add_del_route, \
16766 "<addr>/<mask> via <addr> [table-id <n>]\n" \
16767 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
16768 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
16769 "[multipath] [count <n>]") \
16770 _(mpls_route_add_del, \
16771 "<label> <eos> via <addr> [table-id <n>]\n" \
16772 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
16773 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
16774 "[multipath] [count <n>]") \
16775 _(mpls_ip_bind_unbind, \
16776 "<label> <addr/len>") \
16777 _(mpls_tunnel_add_del, \
16778 " via <addr> [table-id <n>]\n" \
16779 "sw_if_index <id>] [l2] [del]") \
16780 _(proxy_arp_add_del, \
16781 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
16782 _(proxy_arp_intfc_enable_disable, \
16783 "<intfc> | sw_if_index <id> enable | disable") \
16784 _(sw_interface_set_unnumbered, \
16785 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
16786 _(ip_neighbor_add_del, \
16787 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
16788 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
16789 _(reset_vrf, "vrf <id> [ipv6]") \
16790 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
16791 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
16792 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
16793 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
16794 "[outer_vlan_id_any][inner_vlan_id_any]") \
16795 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
16796 _(reset_fib, "vrf <n> [ipv6]") \
16797 _(dhcp_proxy_config, \
16798 "svr <v46-address> src <v46-address>\n" \
16799 "insert-cid <n> [del]") \
16800 _(dhcp_proxy_config_2, \
16801 "svr <v46-address> src <v46-address>\n" \
16802 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
16803 _(dhcp_proxy_set_vss, \
16804 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
16805 _(dhcp_client_config, \
16806 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
16807 _(set_ip_flow_hash, \
16808 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
16809 _(sw_interface_ip6_enable_disable, \
16810 "<intfc> | sw_if_index <id> enable | disable") \
16811 _(sw_interface_ip6_set_link_local_address, \
16812 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
16813 _(sw_interface_ip6nd_ra_prefix, \
16814 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
16815 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
16816 "[nolink] [isno]") \
16817 _(sw_interface_ip6nd_ra_config, \
16818 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
16819 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
16820 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
16821 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
16822 _(l2_patch_add_del, \
16823 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
16824 "enable | disable") \
16825 _(sr_tunnel_add_del, \
16826 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
16827 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
16828 "[policy <policy_name>]") \
16829 _(sr_policy_add_del, \
16830 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
16831 _(sr_multicast_map_add_del, \
16832 "address [ip6 multicast address] sr-policy [policy name] [del]") \
16833 _(classify_add_del_table, \
16834 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
16835 " [del] mask <mask-value>\n" \
16836 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
16837 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
16838 _(classify_add_del_session, \
16839 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
16840 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
16841 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
16842 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
16843 _(classify_set_interface_ip_table, \
16844 "<intfc> | sw_if_index <nn> table <nn>") \
16845 _(classify_set_interface_l2_tables, \
16846 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
16847 " [other-table <nn>]") \
16848 _(get_node_index, "node <node-name") \
16849 _(add_node_next, "node <node-name> next <next-node-name>") \
16850 _(l2tpv3_create_tunnel, \
16851 "client_address <ip6-addr> our_address <ip6-addr>\n" \
16852 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n"\
16853 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
16854 _(l2tpv3_set_tunnel_cookies, \
16855 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
16856 "[new_remote_cookie <nn>]\n") \
16857 _(l2tpv3_interface_enable_disable, \
16858 "<intfc> | sw_if_index <nn> enable | disable") \
16859 _(l2tpv3_set_lookup_key, \
16860 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
16861 _(sw_if_l2tpv3_tunnel_dump, "") \
16862 _(vxlan_add_del_tunnel, \
16863 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
16864 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
16865 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
16866 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
16867 _(gre_add_del_tunnel, \
16868 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
16869 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
16870 _(l2_fib_clear_table, "") \
16871 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
16872 _(l2_interface_vlan_tag_rewrite, \
16873 "<intfc> | sw_if_index <nn> \n" \
16874 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
16875 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
16876 _(create_vhost_user_if, \
16877 "socket <filename> [server] [renumber <dev_instance>] " \
16878 "[mac <mac_address>]") \
16879 _(modify_vhost_user_if, \
16880 "<intfc> | sw_if_index <nn> socket <filename>\n" \
16881 "[server] [renumber <dev_instance>]") \
16882 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
16883 _(sw_interface_vhost_user_dump, "") \
16884 _(show_version, "") \
16885 _(vxlan_gpe_add_del_tunnel, \
16886 "local <addr> remote <addr> vni <nn>\n" \
16887 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
16888 "[next-ethernet] [next-nsh]\n") \
16889 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
16890 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
16891 _(interface_name_renumber, \
16892 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
16893 _(input_acl_set_interface, \
16894 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
16895 " [l2-table <nn>] [del]") \
16896 _(want_ip4_arp_events, "address <ip4-address> [del]") \
16897 _(want_ip6_nd_events, "address <ip6-address> [del]") \
16898 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
16899 _(ip_dump, "ipv4 | ipv6") \
16900 _(ipsec_spd_add_del, "spd_id <n> [del]") \
16901 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
16903 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
16904 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
16905 " integ_alg <alg> integ_key <hex>") \
16906 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
16907 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
16908 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
16909 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" )\
16910 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
16911 _(ikev2_profile_add_del, "name <profile_name> [del]") \
16912 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
16913 "(auth_data 0x<data> | auth_data <data>)") \
16914 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
16915 "(id_data 0x<data> | id_data <data>) (local|remote)") \
16916 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
16917 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
16918 "(local|remote)") \
16919 _(ikev2_set_local_key, "file <absolute_file_path>") \
16920 _(delete_loopback,"sw_if_index <nn>") \
16921 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
16922 _(map_add_domain, \
16923 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
16924 "ip6-src <ip6addr> " \
16925 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
16926 _(map_del_domain, "index <n>") \
16927 _(map_add_del_rule, \
16928 "index <n> psid <n> dst <ip6addr> [del]") \
16929 _(map_domain_dump, "") \
16930 _(map_rule_dump, "index <map-domain>") \
16931 _(want_interface_events, "enable|disable") \
16932 _(want_stats,"enable|disable") \
16933 _(get_first_msg_id, "client <name>") \
16934 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
16935 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
16936 "fib-id <nn> [ip4][ip6][default]") \
16937 _(get_node_graph, " ") \
16938 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
16939 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
16940 _(ioam_disable, "") \
16941 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
16942 " sw_if_index <sw_if_index> p <priority> " \
16943 "w <weight>] [del]") \
16944 _(lisp_add_del_locator, "locator-set <locator_name> " \
16945 "iface <intf> | sw_if_index <sw_if_index> " \
16946 "p <priority> w <weight> [del]") \
16947 _(lisp_add_del_local_eid,"vni <vni> eid " \
16948 "<ipv4|ipv6>/<prefix> | <L2 address> " \
16949 "locator-set <locator_name> [del]") \
16950 _(lisp_gpe_add_del_fwd_entry, "rmt_eid <eid> [lcl_eid <eid>] vni <vni>" \
16951 "dp_table <table> loc-pair <lcl_loc> <rmt_loc> ... [del]") \
16952 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
16953 _(lisp_gpe_enable_disable, "enable|disable") \
16954 _(lisp_enable_disable, "enable|disable") \
16955 _(lisp_gpe_add_del_iface, "up|down") \
16956 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
16958 "rloc <locator> p <prio> " \
16959 "w <weight> [rloc <loc> ... ] " \
16960 "action <action> [del-all]") \
16961 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
16963 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
16964 _(lisp_map_request_mode, "src-dst|dst-only") \
16965 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
16966 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
16967 _(lisp_locator_set_dump, "[local | remote]") \
16968 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
16969 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
16970 "[local] | [remote]") \
16971 _(lisp_eid_table_vni_dump, "") \
16972 _(lisp_eid_table_map_dump, "l2|l3") \
16973 _(lisp_gpe_tunnel_dump, "") \
16974 _(lisp_map_resolver_dump, "") \
16975 _(lisp_adjacencies_get, "vni <vni>") \
16976 _(show_lisp_status, "") \
16977 _(lisp_get_map_request_itr_rlocs, "") \
16978 _(show_lisp_pitr, "") \
16979 _(show_lisp_map_request_mode, "") \
16980 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
16981 _(af_packet_delete, "name <host interface name>") \
16982 _(policer_add_del, "name <policer name> <params> [del]") \
16983 _(policer_dump, "[name <policer name>]") \
16984 _(policer_classify_set_interface, \
16985 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
16986 " [l2-table <nn>] [del]") \
16987 _(policer_classify_dump, "type [ip4|ip6|l2]") \
16988 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
16989 "[master|slave]") \
16990 _(netmap_delete, "name <interface name>") \
16991 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
16992 _(mpls_fib_dump, "") \
16993 _(classify_table_ids, "") \
16994 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
16995 _(classify_table_info, "table_id <nn>") \
16996 _(classify_session_dump, "table_id <nn>") \
16997 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
16998 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
16999 "[template_interval <nn>] [udp_checksum]") \
17000 _(ipfix_exporter_dump, "") \
17001 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
17002 _(ipfix_classify_stream_dump, "") \
17003 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]")\
17004 _(ipfix_classify_table_dump, "") \
17005 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [[dst <intfc> | dst_sw_if_index <id>] | disable]") \
17006 _(sw_interface_span_dump, "") \
17007 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
17008 _(pg_create_interface, "if_id <nn>") \
17009 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
17010 _(pg_enable_disable, "[stream <id>] disable") \
17011 _(ip_source_and_port_range_check_add_del, \
17012 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
17013 _(ip_source_and_port_range_check_interface_add_del, \
17014 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
17015 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
17016 _(ipsec_gre_add_del_tunnel, \
17017 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
17018 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
17019 _(delete_subif,"<intfc> | sw_if_index <nn>") \
17020 _(l2_interface_pbb_tag_rewrite, \
17021 "<intfc> | sw_if_index <nn> \n" \
17022 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
17023 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
17024 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
17025 _(flow_classify_set_interface, \
17026 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
17027 _(flow_classify_dump, "type [ip4|ip6]") \
17028 _(ip_fib_dump, "") \
17029 _(ip6_fib_dump, "") \
17030 _(feature_enable_disable, "arc_name <arc_name> " \
17031 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
17032 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
17034 _(l2_xconnect_dump, "")
17036 /* List of command functions, CLI names map directly to functions */
17037 #define foreach_cli_function \
17038 _(comment, "usage: comment <ignore-rest-of-line>") \
17039 _(dump_interface_table, "usage: dump_interface_table") \
17040 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
17041 _(dump_ipv4_table, "usage: dump_ipv4_table") \
17042 _(dump_ipv6_table, "usage: dump_ipv6_table") \
17043 _(dump_stats_table, "usage: dump_stats_table") \
17044 _(dump_macro_table, "usage: dump_macro_table ") \
17045 _(dump_node_table, "usage: dump_node_table") \
17046 _(dump_msg_api_table, "usage: dump_msg_api_table") \
17047 _(get_msg_id, "usage: get_msg_id name_and_crc") \
17048 _(echo, "usage: echo <message>") \
17049 _(exec, "usage: exec <vpe-debug-CLI-command>") \
17050 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
17051 _(help, "usage: help") \
17052 _(q, "usage: quit") \
17053 _(quit, "usage: quit") \
17054 _(search_node_table, "usage: search_node_table <name>...") \
17055 _(set, "usage: set <variable-name> <value>") \
17056 _(script, "usage: script <file-name>") \
17057 _(unset, "usage: unset <variable-name>")
17060 static void vl_api_##n##_t_handler_uni \
17061 (vl_api_##n##_t * mp) \
17063 vat_main_t * vam = &vat_main; \
17064 if (vam->json_output) { \
17065 vl_api_##n##_t_handler_json(mp); \
17067 vl_api_##n##_t_handler(mp); \
17070 foreach_vpe_api_reply_msg;
17074 vat_api_hookup (vat_main_t * vam)
17077 vl_msg_api_set_handlers(VL_API_##N, #n, \
17078 vl_api_##n##_t_handler_uni, \
17080 vl_api_##n##_t_endian, \
17081 vl_api_##n##_t_print, \
17082 sizeof(vl_api_##n##_t), 1);
17083 foreach_vpe_api_reply_msg;
17086 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
17088 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
17090 vam->function_by_name = hash_create_string (0, sizeof (uword));
17092 vam->help_by_name = hash_create_string (0, sizeof (uword));
17094 /* API messages we can send */
17095 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
17096 foreach_vpe_api_msg;
17100 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17101 foreach_vpe_api_msg;
17104 /* CLI functions */
17105 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
17106 foreach_cli_function;
17110 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17111 foreach_cli_function;
17115 #undef vl_api_version
17116 #define vl_api_version(n,v) static u32 memory_api_version = v;
17117 #include <vlibmemory/vl_memory_api_h.h>
17118 #undef vl_api_version
17120 #undef vl_api_version
17121 #define vl_api_version(n,v) static u32 vnet_interface_api_version = v;
17122 #include <vnet/interface.api.h>
17123 #undef vl_api_version
17125 #undef vl_api_version
17126 #define vl_api_version(n,v) static u32 vpp_api_version = v;
17127 #include <vpp-api/vpe.api.h>
17128 #undef vl_api_version
17130 static u32 *api_versions[] = {
17131 &memory_api_version,
17132 &vnet_interface_api_version,
17137 vl_client_add_api_signatures (vl_api_memclnt_create_t * mp)
17141 ASSERT (ARRAY_LEN (mp->api_versions) >= ARRAY_LEN (api_versions));
17144 * Send the API signatures. This bit of code must
17145 * match the checks in ../vpe/api/api.c: vl_msg_api_version_check().
17148 for (i = 0; i < ARRAY_LEN (api_versions); i++)
17149 mp->api_versions[i] = clib_host_to_net_u32 (*api_versions[i]);
17153 * fd.io coding-style-patch-verification: ON
17156 * eval: (c-set-style "gnu")