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_ethernet_add_del_tunnel_reply_t_handler
1444 (vl_api_mpls_ethernet_add_del_tunnel_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_ethernet_add_del_tunnel_reply_t_handler_json
1460 (vl_api_mpls_ethernet_add_del_tunnel_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->tunnel_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 _(mpls_add_del_encap_reply) \
3465 _(mpls_ethernet_add_del_tunnel_2_reply) \
3466 _(sw_interface_set_unnumbered_reply) \
3467 _(ip_neighbor_add_del_reply) \
3468 _(reset_vrf_reply) \
3469 _(oam_add_del_reply) \
3470 _(reset_fib_reply) \
3471 _(dhcp_proxy_config_reply) \
3472 _(dhcp_proxy_config_2_reply) \
3473 _(dhcp_proxy_set_vss_reply) \
3474 _(dhcp_client_config_reply) \
3475 _(set_ip_flow_hash_reply) \
3476 _(sw_interface_ip6_enable_disable_reply) \
3477 _(sw_interface_ip6_set_link_local_address_reply) \
3478 _(sw_interface_ip6nd_ra_prefix_reply) \
3479 _(sw_interface_ip6nd_ra_config_reply) \
3480 _(set_arp_neighbor_limit_reply) \
3481 _(l2_patch_add_del_reply) \
3482 _(sr_tunnel_add_del_reply) \
3483 _(sr_policy_add_del_reply) \
3484 _(sr_multicast_map_add_del_reply) \
3485 _(classify_add_del_session_reply) \
3486 _(classify_set_interface_ip_table_reply) \
3487 _(classify_set_interface_l2_tables_reply) \
3488 _(l2tpv3_set_tunnel_cookies_reply) \
3489 _(l2tpv3_interface_enable_disable_reply) \
3490 _(l2tpv3_set_lookup_key_reply) \
3491 _(l2_fib_clear_table_reply) \
3492 _(l2_interface_efp_filter_reply) \
3493 _(l2_interface_vlan_tag_rewrite_reply) \
3494 _(modify_vhost_user_if_reply) \
3495 _(delete_vhost_user_if_reply) \
3496 _(want_ip4_arp_events_reply) \
3497 _(want_ip6_nd_events_reply) \
3498 _(input_acl_set_interface_reply) \
3499 _(ipsec_spd_add_del_reply) \
3500 _(ipsec_interface_add_del_spd_reply) \
3501 _(ipsec_spd_add_del_entry_reply) \
3502 _(ipsec_sad_add_del_entry_reply) \
3503 _(ipsec_sa_set_key_reply) \
3504 _(ikev2_profile_add_del_reply) \
3505 _(ikev2_profile_set_auth_reply) \
3506 _(ikev2_profile_set_id_reply) \
3507 _(ikev2_profile_set_ts_reply) \
3508 _(ikev2_set_local_key_reply) \
3509 _(delete_loopback_reply) \
3510 _(bd_ip_mac_add_del_reply) \
3511 _(map_del_domain_reply) \
3512 _(map_add_del_rule_reply) \
3513 _(want_interface_events_reply) \
3514 _(want_stats_reply) \
3515 _(cop_interface_enable_disable_reply) \
3516 _(cop_whitelist_enable_disable_reply) \
3517 _(sw_interface_clear_stats_reply) \
3518 _(ioam_enable_reply) \
3519 _(ioam_disable_reply) \
3520 _(lisp_add_del_locator_reply) \
3521 _(lisp_add_del_local_eid_reply) \
3522 _(lisp_add_del_remote_mapping_reply) \
3523 _(lisp_add_del_adjacency_reply) \
3524 _(lisp_gpe_add_del_fwd_entry_reply) \
3525 _(lisp_add_del_map_resolver_reply) \
3526 _(lisp_gpe_enable_disable_reply) \
3527 _(lisp_gpe_add_del_iface_reply) \
3528 _(lisp_enable_disable_reply) \
3529 _(lisp_pitr_set_locator_set_reply) \
3530 _(lisp_map_request_mode_reply) \
3531 _(lisp_add_del_map_request_itr_rlocs_reply) \
3532 _(lisp_eid_table_add_del_map_reply) \
3533 _(vxlan_gpe_add_del_tunnel_reply) \
3534 _(af_packet_delete_reply) \
3535 _(policer_classify_set_interface_reply) \
3536 _(netmap_create_reply) \
3537 _(netmap_delete_reply) \
3538 _(set_ipfix_exporter_reply) \
3539 _(set_ipfix_classify_stream_reply) \
3540 _(ipfix_classify_table_add_del_reply) \
3541 _(flow_classify_set_interface_reply) \
3542 _(sw_interface_span_enable_disable_reply) \
3543 _(pg_capture_reply) \
3544 _(pg_enable_disable_reply) \
3545 _(ip_source_and_port_range_check_add_del_reply) \
3546 _(ip_source_and_port_range_check_interface_add_del_reply)\
3547 _(delete_subif_reply) \
3548 _(l2_interface_pbb_tag_rewrite_reply) \
3550 _(feature_enable_disable_reply)
3553 static void vl_api_##n##_t_handler \
3554 (vl_api_##n##_t * mp) \
3556 vat_main_t * vam = &vat_main; \
3557 i32 retval = ntohl(mp->retval); \
3558 if (vam->async_mode) { \
3559 vam->async_errors += (retval < 0); \
3561 vam->retval = retval; \
3562 vam->result_ready = 1; \
3565 foreach_standard_reply_retval_handler;
3569 static void vl_api_##n##_t_handler_json \
3570 (vl_api_##n##_t * mp) \
3572 vat_main_t * vam = &vat_main; \
3573 vat_json_node_t node; \
3574 vat_json_init_object(&node); \
3575 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3576 vat_json_print(vam->ofp, &node); \
3577 vam->retval = ntohl(mp->retval); \
3578 vam->result_ready = 1; \
3580 foreach_standard_reply_retval_handler;
3584 * Table of message reply handlers, must include boilerplate handlers
3588 #define foreach_vpe_api_reply_msg \
3589 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3590 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3591 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
3592 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3593 _(CONTROL_PING_REPLY, control_ping_reply) \
3594 _(CLI_REPLY, cli_reply) \
3595 _(CLI_INBAND_REPLY, cli_inband_reply) \
3596 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
3597 sw_interface_add_del_address_reply) \
3598 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
3599 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
3600 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
3601 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
3602 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
3603 sw_interface_set_l2_xconnect_reply) \
3604 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
3605 sw_interface_set_l2_bridge_reply) \
3606 _(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
3607 sw_interface_set_dpdk_hqos_pipe_reply) \
3608 _(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
3609 sw_interface_set_dpdk_hqos_subport_reply) \
3610 _(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
3611 sw_interface_set_dpdk_hqos_tctbl_reply) \
3612 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
3613 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
3614 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
3615 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
3616 _(L2_FLAGS_REPLY, l2_flags_reply) \
3617 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
3618 _(TAP_CONNECT_REPLY, tap_connect_reply) \
3619 _(TAP_MODIFY_REPLY, tap_modify_reply) \
3620 _(TAP_DELETE_REPLY, tap_delete_reply) \
3621 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
3622 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
3623 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
3624 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
3625 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
3626 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
3627 proxy_arp_intfc_enable_disable_reply) \
3628 _(MPLS_ADD_DEL_ENCAP_REPLY, mpls_add_del_encap_reply) \
3629 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_REPLY, \
3630 mpls_ethernet_add_del_tunnel_reply) \
3631 _(MPLS_ETHERNET_ADD_DEL_TUNNEL_2_REPLY, \
3632 mpls_ethernet_add_del_tunnel_2_reply) \
3633 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
3634 sw_interface_set_unnumbered_reply) \
3635 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
3636 _(RESET_VRF_REPLY, reset_vrf_reply) \
3637 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
3638 _(CREATE_SUBIF_REPLY, create_subif_reply) \
3639 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
3640 _(RESET_FIB_REPLY, reset_fib_reply) \
3641 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
3642 _(DHCP_PROXY_CONFIG_2_REPLY, dhcp_proxy_config_2_reply) \
3643 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
3644 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
3645 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
3646 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
3647 sw_interface_ip6_enable_disable_reply) \
3648 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
3649 sw_interface_ip6_set_link_local_address_reply) \
3650 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
3651 sw_interface_ip6nd_ra_prefix_reply) \
3652 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
3653 sw_interface_ip6nd_ra_config_reply) \
3654 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
3655 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
3656 _(SR_TUNNEL_ADD_DEL_REPLY, sr_tunnel_add_del_reply) \
3657 _(SR_POLICY_ADD_DEL_REPLY, sr_policy_add_del_reply) \
3658 _(SR_MULTICAST_MAP_ADD_DEL_REPLY, sr_multicast_map_add_del_reply) \
3659 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
3660 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
3661 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
3662 classify_set_interface_ip_table_reply) \
3663 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
3664 classify_set_interface_l2_tables_reply) \
3665 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
3666 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
3667 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
3668 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
3669 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
3670 l2tpv3_interface_enable_disable_reply) \
3671 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
3672 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
3673 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
3674 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
3675 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
3676 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
3677 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
3678 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
3679 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
3680 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
3681 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
3682 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
3683 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
3684 _(SHOW_VERSION_REPLY, show_version_reply) \
3685 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
3686 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
3687 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
3688 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
3689 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
3690 _(IP4_ARP_EVENT, ip4_arp_event) \
3691 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
3692 _(IP6_ND_EVENT, ip6_nd_event) \
3693 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
3694 _(IP_ADDRESS_DETAILS, ip_address_details) \
3695 _(IP_DETAILS, ip_details) \
3696 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
3697 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
3698 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
3699 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
3700 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
3701 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
3702 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
3703 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
3704 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
3705 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
3706 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
3707 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
3708 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
3709 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
3710 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
3711 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
3712 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
3713 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
3714 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
3715 _(MAP_DOMAIN_DETAILS, map_domain_details) \
3716 _(MAP_RULE_DETAILS, map_rule_details) \
3717 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
3718 _(WANT_STATS_REPLY, want_stats_reply) \
3719 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
3720 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
3721 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
3722 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
3723 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
3724 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
3725 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
3726 _(LISP_ADD_DEL_LOCATOR_SET_REPLY, lisp_add_del_locator_set_reply) \
3727 _(LISP_ADD_DEL_LOCATOR_REPLY, lisp_add_del_locator_reply) \
3728 _(LISP_ADD_DEL_LOCAL_EID_REPLY, lisp_add_del_local_eid_reply) \
3729 _(LISP_ADD_DEL_REMOTE_MAPPING_REPLY, lisp_add_del_remote_mapping_reply) \
3730 _(LISP_ADD_DEL_ADJACENCY_REPLY, lisp_add_del_adjacency_reply) \
3731 _(LISP_GPE_ADD_DEL_FWD_ENTRY_REPLY, lisp_gpe_add_del_fwd_entry_reply) \
3732 _(LISP_ADD_DEL_MAP_RESOLVER_REPLY, lisp_add_del_map_resolver_reply) \
3733 _(LISP_GPE_ENABLE_DISABLE_REPLY, lisp_gpe_enable_disable_reply) \
3734 _(LISP_ENABLE_DISABLE_REPLY, lisp_enable_disable_reply) \
3735 _(LISP_PITR_SET_LOCATOR_SET_REPLY, lisp_pitr_set_locator_set_reply) \
3736 _(LISP_MAP_REQUEST_MODE_REPLY, lisp_map_request_mode_reply) \
3737 _(LISP_EID_TABLE_ADD_DEL_MAP_REPLY, lisp_eid_table_add_del_map_reply) \
3738 _(LISP_GPE_ADD_DEL_IFACE_REPLY, lisp_gpe_add_del_iface_reply) \
3739 _(LISP_LOCATOR_SET_DETAILS, lisp_locator_set_details) \
3740 _(LISP_LOCATOR_DETAILS, lisp_locator_details) \
3741 _(LISP_EID_TABLE_DETAILS, lisp_eid_table_details) \
3742 _(LISP_EID_TABLE_MAP_DETAILS, lisp_eid_table_map_details) \
3743 _(LISP_EID_TABLE_VNI_DETAILS, lisp_eid_table_vni_details) \
3744 _(LISP_GPE_TUNNEL_DETAILS, lisp_gpe_tunnel_details) \
3745 _(LISP_MAP_RESOLVER_DETAILS, lisp_map_resolver_details) \
3746 _(LISP_ADJACENCIES_GET_REPLY, lisp_adjacencies_get_reply) \
3747 _(SHOW_LISP_STATUS_REPLY, show_lisp_status_reply) \
3748 _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
3749 lisp_add_del_map_request_itr_rlocs_reply) \
3750 _(LISP_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
3751 lisp_get_map_request_itr_rlocs_reply) \
3752 _(SHOW_LISP_PITR_REPLY, show_lisp_pitr_reply) \
3753 _(SHOW_LISP_MAP_REQUEST_MODE_REPLY, show_lisp_map_request_mode_reply) \
3754 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
3755 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
3756 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
3757 _(POLICER_DETAILS, policer_details) \
3758 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
3759 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
3760 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
3761 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
3762 _(MPLS_ETH_TUNNEL_DETAILS, mpls_eth_tunnel_details) \
3763 _(MPLS_FIB_ENCAP_DETAILS, mpls_fib_encap_details) \
3764 _(MPLS_FIB_DETAILS, mpls_fib_details) \
3765 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
3766 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
3767 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
3768 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
3769 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
3770 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
3771 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
3772 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
3773 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
3774 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
3775 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
3776 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
3777 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
3778 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
3779 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
3780 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
3781 _(PG_CAPTURE_REPLY, pg_capture_reply) \
3782 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
3783 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
3784 ip_source_and_port_range_check_add_del_reply) \
3785 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
3786 ip_source_and_port_range_check_interface_add_del_reply) \
3787 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
3788 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
3789 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
3790 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
3791 _(PUNT_REPLY, punt_reply) \
3792 _(IP_FIB_DETAILS, ip_fib_details) \
3793 _(IP6_FIB_DETAILS, ip6_fib_details) \
3794 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply)
3796 /* M: construct, but don't yet send a message */
3800 vam->result_ready = 0; \
3801 mp = vl_msg_api_alloc(sizeof(*mp)); \
3802 memset (mp, 0, sizeof (*mp)); \
3803 mp->_vl_msg_id = ntohs (VL_API_##T); \
3804 mp->client_index = vam->my_client_index; \
3809 vam->result_ready = 0; \
3810 mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
3811 memset (mp, 0, sizeof (*mp)); \
3812 mp->_vl_msg_id = ntohs (VL_API_##T); \
3813 mp->client_index = vam->my_client_index; \
3817 /* S: send a message */
3818 #define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
3820 /* W: wait for results, with timeout */
3823 timeout = vat_time_now (vam) + 1.0; \
3825 while (vat_time_now (vam) < timeout) { \
3826 if (vam->result_ready == 1) { \
3827 return (vam->retval); \
3833 /* W2: wait for results, with timeout */
3836 timeout = vat_time_now (vam) + 1.0; \
3838 while (vat_time_now (vam) < timeout) { \
3839 if (vam->result_ready == 1) { \
3841 return (vam->retval); \
3854 #define STR_VTR_OP_CASE(op) \
3855 case L2_VTR_ ## op: \
3859 str_vtr_op (u32 vtr_op)
3863 STR_VTR_OP_CASE (DISABLED);
3864 STR_VTR_OP_CASE (PUSH_1);
3865 STR_VTR_OP_CASE (PUSH_2);
3866 STR_VTR_OP_CASE (POP_1);
3867 STR_VTR_OP_CASE (POP_2);
3868 STR_VTR_OP_CASE (TRANSLATE_1_1);
3869 STR_VTR_OP_CASE (TRANSLATE_1_2);
3870 STR_VTR_OP_CASE (TRANSLATE_2_1);
3871 STR_VTR_OP_CASE (TRANSLATE_2_2);
3878 dump_sub_interface_table (vat_main_t * vam)
3880 const sw_interface_subif_t *sub = NULL;
3882 if (vam->json_output)
3885 ("JSON output supported only for VPE API calls and dump_stats_table");
3890 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s\n",
3891 "Interface", "sw_if_index",
3892 "sub id", "dot1ad", "tags", "outer id",
3893 "inner id", "exact", "default", "outer any", "inner any");
3895 vec_foreach (sub, vam->sw_if_subif_table)
3898 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d\n",
3899 sub->interface_name,
3901 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
3902 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
3903 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
3904 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
3905 if (sub->vtr_op != L2_VTR_DISABLED)
3908 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
3909 "tag1: %d tag2: %d ]\n",
3910 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
3911 sub->vtr_tag1, sub->vtr_tag2);
3919 name_sort_cmp (void *a1, void *a2)
3921 name_sort_t *n1 = a1;
3922 name_sort_t *n2 = a2;
3924 return strcmp ((char *) n1->name, (char *) n2->name);
3928 dump_interface_table (vat_main_t * vam)
3931 name_sort_t *nses = 0, *ns;
3933 if (vam->json_output)
3936 ("JSON output supported only for VPE API calls and dump_stats_table");
3941 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
3943 vec_add2 (nses, ns, 1);
3944 ns->name = (u8 *)(p->key);
3945 ns->value = (u32) p->value[0];
3949 vec_sort_with_function (nses, name_sort_cmp);
3951 fformat (vam->ofp, "%-25s%-15s\n", "Interface", "sw_if_index");
3952 vec_foreach (ns, nses)
3954 fformat (vam->ofp, "%-25s%-15d\n", ns->name, ns->value);
3961 dump_ip_table (vat_main_t * vam, int is_ipv6)
3963 const ip_details_t *det = NULL;
3964 const ip_address_details_t *address = NULL;
3967 fformat (vam->ofp, "%-12s\n", "sw_if_index");
3969 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
3976 fformat (vam->ofp, "%-12d\n", i);
3978 " %-30s%-13s\n", "Address", "Prefix length");
3983 vec_foreach (address, det->addr)
3987 is_ipv6 ? format_ip6_address : format_ip4_address,
3988 address->ip, address->prefix_length);
3996 dump_ipv4_table (vat_main_t * vam)
3998 if (vam->json_output)
4001 ("JSON output supported only for VPE API calls and dump_stats_table");
4005 return dump_ip_table (vam, 0);
4009 dump_ipv6_table (vat_main_t * vam)
4011 if (vam->json_output)
4014 ("JSON output supported only for VPE API calls and dump_stats_table");
4018 return dump_ip_table (vam, 1);
4022 counter_type_to_str (u8 counter_type, u8 is_combined)
4026 switch (counter_type)
4028 case VNET_INTERFACE_COUNTER_DROP:
4030 case VNET_INTERFACE_COUNTER_PUNT:
4032 case VNET_INTERFACE_COUNTER_IP4:
4034 case VNET_INTERFACE_COUNTER_IP6:
4036 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4038 case VNET_INTERFACE_COUNTER_RX_MISS:
4040 case VNET_INTERFACE_COUNTER_RX_ERROR:
4042 case VNET_INTERFACE_COUNTER_TX_ERROR:
4045 return "INVALID-COUNTER-TYPE";
4050 switch (counter_type)
4052 case VNET_INTERFACE_COUNTER_RX:
4054 case VNET_INTERFACE_COUNTER_TX:
4057 return "INVALID-COUNTER-TYPE";
4063 dump_stats_table (vat_main_t * vam)
4065 vat_json_node_t node;
4066 vat_json_node_t *msg_array;
4067 vat_json_node_t *msg;
4068 vat_json_node_t *counter_array;
4069 vat_json_node_t *counter;
4070 interface_counter_t c;
4072 ip4_fib_counter_t *c4;
4073 ip6_fib_counter_t *c6;
4076 if (!vam->json_output)
4078 clib_warning ("dump_stats_table supported only in JSON format");
4082 vat_json_init_object (&node);
4084 /* interface counters */
4085 msg_array = vat_json_object_add (&node, "interface_counters");
4086 vat_json_init_array (msg_array);
4087 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4089 msg = vat_json_array_add (msg_array);
4090 vat_json_init_object (msg);
4091 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4092 (u8 *) counter_type_to_str (i, 0));
4093 vat_json_object_add_int (msg, "is_combined", 0);
4094 counter_array = vat_json_object_add (msg, "data");
4095 vat_json_init_array (counter_array);
4096 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4098 packets = vam->simple_interface_counters[i][j];
4099 vat_json_array_add_uint (counter_array, packets);
4102 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4104 msg = vat_json_array_add (msg_array);
4105 vat_json_init_object (msg);
4106 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4107 (u8 *) counter_type_to_str (i, 1));
4108 vat_json_object_add_int (msg, "is_combined", 1);
4109 counter_array = vat_json_object_add (msg, "data");
4110 vat_json_init_array (counter_array);
4111 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4113 c = vam->combined_interface_counters[i][j];
4114 counter = vat_json_array_add (counter_array);
4115 vat_json_init_object (counter);
4116 vat_json_object_add_uint (counter, "packets", c.packets);
4117 vat_json_object_add_uint (counter, "bytes", c.bytes);
4121 /* ip4 fib counters */
4122 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4123 vat_json_init_array (msg_array);
4124 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4126 msg = vat_json_array_add (msg_array);
4127 vat_json_init_object (msg);
4128 vat_json_object_add_uint (msg, "vrf_id",
4129 vam->ip4_fib_counters_vrf_id_by_index[i]);
4130 counter_array = vat_json_object_add (msg, "c");
4131 vat_json_init_array (counter_array);
4132 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4134 counter = vat_json_array_add (counter_array);
4135 vat_json_init_object (counter);
4136 c4 = &vam->ip4_fib_counters[i][j];
4137 vat_json_object_add_ip4 (counter, "address", c4->address);
4138 vat_json_object_add_uint (counter, "address_length",
4139 c4->address_length);
4140 vat_json_object_add_uint (counter, "packets", c4->packets);
4141 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4145 /* ip6 fib counters */
4146 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4147 vat_json_init_array (msg_array);
4148 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4150 msg = vat_json_array_add (msg_array);
4151 vat_json_init_object (msg);
4152 vat_json_object_add_uint (msg, "vrf_id",
4153 vam->ip6_fib_counters_vrf_id_by_index[i]);
4154 counter_array = vat_json_object_add (msg, "c");
4155 vat_json_init_array (counter_array);
4156 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4158 counter = vat_json_array_add (counter_array);
4159 vat_json_init_object (counter);
4160 c6 = &vam->ip6_fib_counters[i][j];
4161 vat_json_object_add_ip6 (counter, "address", c6->address);
4162 vat_json_object_add_uint (counter, "address_length",
4163 c6->address_length);
4164 vat_json_object_add_uint (counter, "packets", c6->packets);
4165 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4169 vat_json_print (vam->ofp, &node);
4170 vat_json_free (&node);
4176 exec (vat_main_t * vam)
4178 api_main_t *am = &api_main;
4179 vl_api_cli_request_t *mp;
4183 unformat_input_t *i = vam->input;
4185 if (vec_len (i->buffer) == 0)
4188 if (vam->exec_mode == 0 && unformat (i, "mode"))
4193 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4200 M (CLI_REQUEST, cli_request);
4203 * Copy cmd into shared memory.
4204 * In order for the CLI command to work, it
4205 * must be a vector ending in \n, not a C-string ending
4208 pthread_mutex_lock (&am->vlib_rp->mutex);
4209 oldheap = svm_push_data_heap (am->vlib_rp);
4211 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4212 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4214 svm_pop_heap (oldheap);
4215 pthread_mutex_unlock (&am->vlib_rp->mutex);
4217 mp->cmd_in_shmem = (u64) cmd;
4219 timeout = vat_time_now (vam) + 10.0;
4221 while (vat_time_now (vam) < timeout)
4223 if (vam->result_ready == 1)
4226 if (vam->shmem_result != NULL)
4227 fformat (vam->ofp, "%s", vam->shmem_result);
4228 pthread_mutex_lock (&am->vlib_rp->mutex);
4229 oldheap = svm_push_data_heap (am->vlib_rp);
4231 free_me = (u8 *) vam->shmem_result;
4234 svm_pop_heap (oldheap);
4235 pthread_mutex_unlock (&am->vlib_rp->mutex);
4243 * Future replacement of exec() that passes CLI buffers directly in
4244 * the API messages instead of an additional shared memory area.
4247 exec_inband (vat_main_t * vam)
4249 vl_api_cli_inband_t *mp;
4251 unformat_input_t *i = vam->input;
4253 if (vec_len (i->buffer) == 0)
4256 if (vam->exec_mode == 0 && unformat (i, "mode"))
4261 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4268 * In order for the CLI command to work, it
4269 * must be a vector ending in \n, not a C-string ending
4272 u32 len = vec_len (vam->input->buffer);
4273 M2 (CLI_INBAND, cli_inband, len);
4274 clib_memcpy (mp->cmd, vam->input->buffer, len);
4275 mp->length = htonl (len);
4278 W2 (fformat (vam->ofp, "%s", vam->cmd_reply));
4282 api_create_loopback (vat_main_t * vam)
4284 unformat_input_t *i = vam->input;
4285 vl_api_create_loopback_t *mp;
4290 memset (mac_address, 0, sizeof (mac_address));
4292 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4294 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4300 /* Construct the API message */
4301 M (CREATE_LOOPBACK, create_loopback);
4303 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4310 api_delete_loopback (vat_main_t * vam)
4312 unformat_input_t *i = vam->input;
4313 vl_api_delete_loopback_t *mp;
4315 u32 sw_if_index = ~0;
4317 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4319 if (unformat (i, "sw_if_index %d", &sw_if_index))
4325 if (sw_if_index == ~0)
4327 errmsg ("missing sw_if_index\n");
4331 /* Construct the API message */
4332 M (DELETE_LOOPBACK, delete_loopback);
4333 mp->sw_if_index = ntohl (sw_if_index);
4340 api_want_stats (vat_main_t * vam)
4342 unformat_input_t *i = vam->input;
4343 vl_api_want_stats_t *mp;
4347 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4349 if (unformat (i, "enable"))
4351 else if (unformat (i, "disable"))
4359 errmsg ("missing enable|disable\n");
4363 M (WANT_STATS, want_stats);
4364 mp->enable_disable = enable;
4371 api_want_interface_events (vat_main_t * vam)
4373 unformat_input_t *i = vam->input;
4374 vl_api_want_interface_events_t *mp;
4378 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4380 if (unformat (i, "enable"))
4382 else if (unformat (i, "disable"))
4390 errmsg ("missing enable|disable\n");
4394 M (WANT_INTERFACE_EVENTS, want_interface_events);
4395 mp->enable_disable = enable;
4397 vam->interface_event_display = enable;
4404 /* Note: non-static, called once to set up the initial intfc table */
4406 api_sw_interface_dump (vat_main_t * vam)
4408 vl_api_sw_interface_dump_t *mp;
4411 name_sort_t *nses = 0, *ns;
4412 sw_interface_subif_t *sub = NULL;
4414 /* Toss the old name table */
4416 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4418 vec_add2 (nses, ns, 1);
4419 ns->name = (u8 *)(p->key);
4420 ns->value = (u32) p->value[0];
4424 hash_free (vam->sw_if_index_by_interface_name);
4426 vec_foreach (ns, nses) vec_free (ns->name);
4430 vec_foreach (sub, vam->sw_if_subif_table)
4432 vec_free (sub->interface_name);
4434 vec_free (vam->sw_if_subif_table);
4436 /* recreate the interface name hash table */
4437 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4439 /* Get list of ethernets */
4440 M (SW_INTERFACE_DUMP, sw_interface_dump);
4441 mp->name_filter_valid = 1;
4442 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4445 /* and local / loopback interfaces */
4446 M (SW_INTERFACE_DUMP, sw_interface_dump);
4447 mp->name_filter_valid = 1;
4448 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4451 /* and packet-generator interfaces */
4452 M (SW_INTERFACE_DUMP, sw_interface_dump);
4453 mp->name_filter_valid = 1;
4454 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4457 /* and vxlan-gpe tunnel interfaces */
4458 M (SW_INTERFACE_DUMP, sw_interface_dump);
4459 mp->name_filter_valid = 1;
4460 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4461 sizeof (mp->name_filter) - 1);
4464 /* and vxlan tunnel interfaces */
4465 M (SW_INTERFACE_DUMP, sw_interface_dump);
4466 mp->name_filter_valid = 1;
4467 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4470 /* and host (af_packet) interfaces */
4471 M (SW_INTERFACE_DUMP, sw_interface_dump);
4472 mp->name_filter_valid = 1;
4473 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4476 /* and l2tpv3 tunnel interfaces */
4477 M (SW_INTERFACE_DUMP, sw_interface_dump);
4478 mp->name_filter_valid = 1;
4479 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4480 sizeof (mp->name_filter) - 1);
4483 /* and GRE tunnel interfaces */
4484 M (SW_INTERFACE_DUMP, sw_interface_dump);
4485 mp->name_filter_valid = 1;
4486 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4489 /* and LISP-GPE interfaces */
4490 M (SW_INTERFACE_DUMP, sw_interface_dump);
4491 mp->name_filter_valid = 1;
4492 strncpy ((char *) mp->name_filter, "lisp_gpe",
4493 sizeof (mp->name_filter) - 1);
4496 /* and IPSEC tunnel interfaces */
4497 M (SW_INTERFACE_DUMP, sw_interface_dump);
4498 mp->name_filter_valid = 1;
4499 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4502 /* Use a control ping for synchronization */
4504 vl_api_control_ping_t *mp;
4505 M (CONTROL_PING, control_ping);
4512 api_sw_interface_set_flags (vat_main_t * vam)
4514 unformat_input_t *i = vam->input;
4515 vl_api_sw_interface_set_flags_t *mp;
4518 u8 sw_if_index_set = 0;
4519 u8 admin_up = 0, link_up = 0;
4521 /* Parse args required to build the message */
4522 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4524 if (unformat (i, "admin-up"))
4526 else if (unformat (i, "admin-down"))
4528 else if (unformat (i, "link-up"))
4530 else if (unformat (i, "link-down"))
4532 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4533 sw_if_index_set = 1;
4534 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4535 sw_if_index_set = 1;
4540 if (sw_if_index_set == 0)
4542 errmsg ("missing interface name or sw_if_index\n");
4546 /* Construct the API message */
4547 M (SW_INTERFACE_SET_FLAGS, sw_interface_set_flags);
4548 mp->sw_if_index = ntohl (sw_if_index);
4549 mp->admin_up_down = admin_up;
4550 mp->link_up_down = link_up;
4555 /* Wait for a reply, return the good/bad news... */
4560 api_sw_interface_clear_stats (vat_main_t * vam)
4562 unformat_input_t *i = vam->input;
4563 vl_api_sw_interface_clear_stats_t *mp;
4566 u8 sw_if_index_set = 0;
4568 /* Parse args required to build the message */
4569 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4571 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4572 sw_if_index_set = 1;
4573 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4574 sw_if_index_set = 1;
4579 /* Construct the API message */
4580 M (SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats);
4582 if (sw_if_index_set == 1)
4583 mp->sw_if_index = ntohl (sw_if_index);
4585 mp->sw_if_index = ~0;
4590 /* Wait for a reply, return the good/bad news... */
4595 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
4597 unformat_input_t *i = vam->input;
4598 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
4601 u8 sw_if_index_set = 0;
4609 /* Parse args required to build the message */
4610 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4612 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4613 sw_if_index_set = 1;
4614 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4615 sw_if_index_set = 1;
4616 else if (unformat (i, "subport %u", &subport))
4618 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4619 sw_if_index_set = 1;
4620 else if (unformat (i, "pipe %u", &pipe))
4622 else if (unformat (i, "profile %u", &profile))
4628 if (sw_if_index_set == 0)
4630 errmsg ("missing interface name or sw_if_index\n");
4634 if (subport_set == 0)
4636 errmsg ("missing subport \n");
4642 errmsg ("missing pipe\n");
4646 if (profile_set == 0)
4648 errmsg ("missing profile\n");
4652 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe);
4654 mp->sw_if_index = ntohl (sw_if_index);
4655 mp->subport = ntohl (subport);
4656 mp->pipe = ntohl (pipe);
4657 mp->profile = ntohl (profile);
4667 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
4669 unformat_input_t *i = vam->input;
4670 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
4673 u8 sw_if_index_set = 0;
4676 u32 tb_rate = 1250000000; /* 10GbE */
4677 u32 tb_size = 1000000;
4678 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
4681 /* Parse args required to build the message */
4682 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4684 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4685 sw_if_index_set = 1;
4686 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4687 sw_if_index_set = 1;
4688 else if (unformat (i, "subport %u", &subport))
4690 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4691 sw_if_index_set = 1;
4692 else if (unformat (i, "rate %u", &tb_rate))
4696 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
4698 tc_rate[tc_id] = tb_rate;
4700 else if (unformat (i, "bktsize %u", &tb_size))
4702 else if (unformat (i, "tc0 %u", &tc_rate[0]))
4704 else if (unformat (i, "tc1 %u", &tc_rate[1]))
4706 else if (unformat (i, "tc2 %u", &tc_rate[2]))
4708 else if (unformat (i, "tc3 %u", &tc_rate[3]))
4710 else if (unformat (i, "period %u", &tc_period))
4716 if (sw_if_index_set == 0)
4718 errmsg ("missing interface name or sw_if_index\n");
4722 if (subport_set == 0)
4724 errmsg ("missing subport \n");
4728 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport);
4730 mp->sw_if_index = ntohl (sw_if_index);
4731 mp->subport = ntohl (subport);
4732 mp->tb_rate = ntohl (tb_rate);
4733 mp->tb_size = ntohl (tb_size);
4734 mp->tc_rate[0] = ntohl (tc_rate[0]);
4735 mp->tc_rate[1] = ntohl (tc_rate[1]);
4736 mp->tc_rate[2] = ntohl (tc_rate[2]);
4737 mp->tc_rate[3] = ntohl (tc_rate[3]);
4738 mp->tc_period = ntohl (tc_period);
4747 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
4749 unformat_input_t *i = vam->input;
4750 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
4753 u8 sw_if_index_set = 0;
4757 u32 entry, tc, queue;
4759 /* Parse args required to build the message */
4760 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4762 if (unformat (i, "rx %U", unformat_sw_if_index, vam, &sw_if_index))
4763 sw_if_index_set = 1;
4764 else if (unformat (i, "sw_if_index %u", &sw_if_index))
4765 sw_if_index_set = 1;
4766 else if (unformat (i, "entry %d", &entry))
4768 else if (unformat (i, "tc %d", &tc))
4770 else if (unformat (i, "queue %d", &queue))
4776 if (sw_if_index_set == 0)
4778 errmsg ("missing interface name or sw_if_index\n");
4784 errmsg ("missing entry \n");
4790 errmsg ("missing traffic class \n");
4796 errmsg ("missing queue \n");
4800 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl);
4802 mp->sw_if_index = ntohl (sw_if_index);
4803 mp->entry = ntohl (entry);
4804 mp->tc = ntohl (tc);
4805 mp->queue = ntohl (queue);
4814 api_sw_interface_add_del_address (vat_main_t * vam)
4816 unformat_input_t *i = vam->input;
4817 vl_api_sw_interface_add_del_address_t *mp;
4820 u8 sw_if_index_set = 0;
4821 u8 is_add = 1, del_all = 0;
4822 u32 address_length = 0;
4823 u8 v4_address_set = 0;
4824 u8 v6_address_set = 0;
4825 ip4_address_t v4address;
4826 ip6_address_t v6address;
4828 /* Parse args required to build the message */
4829 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4831 if (unformat (i, "del-all"))
4833 else if (unformat (i, "del"))
4835 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4836 sw_if_index_set = 1;
4837 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4838 sw_if_index_set = 1;
4839 else if (unformat (i, "%U/%d",
4840 unformat_ip4_address, &v4address, &address_length))
4842 else if (unformat (i, "%U/%d",
4843 unformat_ip6_address, &v6address, &address_length))
4849 if (sw_if_index_set == 0)
4851 errmsg ("missing interface name or sw_if_index\n");
4854 if (v4_address_set && v6_address_set)
4856 errmsg ("both v4 and v6 addresses set\n");
4859 if (!v4_address_set && !v6_address_set && !del_all)
4861 errmsg ("no addresses set\n");
4865 /* Construct the API message */
4866 M (SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address);
4868 mp->sw_if_index = ntohl (sw_if_index);
4869 mp->is_add = is_add;
4870 mp->del_all = del_all;
4874 clib_memcpy (mp->address, &v6address, sizeof (v6address));
4878 clib_memcpy (mp->address, &v4address, sizeof (v4address));
4880 mp->address_length = address_length;
4885 /* Wait for a reply, return good/bad news */
4890 api_sw_interface_set_mpls_enable (vat_main_t * vam)
4892 unformat_input_t *i = vam->input;
4893 vl_api_sw_interface_set_mpls_enable_t *mp;
4896 u8 sw_if_index_set = 0;
4899 /* Parse args required to build the message */
4900 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4902 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4903 sw_if_index_set = 1;
4904 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4905 sw_if_index_set = 1;
4906 else if (unformat (i, "disable"))
4908 else if (unformat (i, "dis"))
4914 if (sw_if_index_set == 0)
4916 errmsg ("missing interface name or sw_if_index\n");
4920 /* Construct the API message */
4921 M (SW_INTERFACE_SET_MPLS_ENABLE, sw_interface_set_mpls_enable);
4923 mp->sw_if_index = ntohl (sw_if_index);
4924 mp->enable = enable;
4929 /* Wait for a reply... */
4934 api_sw_interface_set_table (vat_main_t * vam)
4936 unformat_input_t *i = vam->input;
4937 vl_api_sw_interface_set_table_t *mp;
4939 u32 sw_if_index, vrf_id = 0;
4940 u8 sw_if_index_set = 0;
4943 /* Parse args required to build the message */
4944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4946 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4947 sw_if_index_set = 1;
4948 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4949 sw_if_index_set = 1;
4950 else if (unformat (i, "vrf %d", &vrf_id))
4952 else if (unformat (i, "ipv6"))
4958 if (sw_if_index_set == 0)
4960 errmsg ("missing interface name or sw_if_index\n");
4964 /* Construct the API message */
4965 M (SW_INTERFACE_SET_TABLE, sw_interface_set_table);
4967 mp->sw_if_index = ntohl (sw_if_index);
4968 mp->is_ipv6 = is_ipv6;
4969 mp->vrf_id = ntohl (vrf_id);
4974 /* Wait for a reply... */
4979 api_sw_interface_set_vpath (vat_main_t * vam)
4981 unformat_input_t *i = vam->input;
4982 vl_api_sw_interface_set_vpath_t *mp;
4984 u32 sw_if_index = 0;
4985 u8 sw_if_index_set = 0;
4988 /* Parse args required to build the message */
4989 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4991 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
4992 sw_if_index_set = 1;
4993 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4994 sw_if_index_set = 1;
4995 else if (unformat (i, "enable"))
4997 else if (unformat (i, "disable"))
5003 if (sw_if_index_set == 0)
5005 errmsg ("missing interface name or sw_if_index\n");
5009 /* Construct the API message */
5010 M (SW_INTERFACE_SET_VPATH, sw_interface_set_vpath);
5012 mp->sw_if_index = ntohl (sw_if_index);
5013 mp->enable = is_enable;
5018 /* Wait for a reply... */
5023 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5025 unformat_input_t *i = vam->input;
5026 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5028 u32 sw_if_index = 0;
5029 u8 sw_if_index_set = 0;
5033 /* Parse args required to build the message */
5034 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5036 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5037 sw_if_index_set = 1;
5038 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5039 sw_if_index_set = 1;
5040 else if (unformat (i, "enable"))
5042 else if (unformat (i, "disable"))
5044 else if (unformat (i, "ip4"))
5046 else if (unformat (i, "ip6"))
5052 if (sw_if_index_set == 0)
5054 errmsg ("missing interface name or sw_if_index\n");
5058 /* Construct the API message */
5059 M (SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass);
5061 mp->sw_if_index = ntohl (sw_if_index);
5062 mp->enable = is_enable;
5063 mp->is_ipv6 = is_ipv6;
5068 /* Wait for a reply... */
5073 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5075 unformat_input_t *i = vam->input;
5076 vl_api_sw_interface_set_l2_xconnect_t *mp;
5079 u8 rx_sw_if_index_set = 0;
5081 u8 tx_sw_if_index_set = 0;
5084 /* Parse args required to build the message */
5085 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5087 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5088 rx_sw_if_index_set = 1;
5089 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5090 tx_sw_if_index_set = 1;
5091 else if (unformat (i, "rx"))
5093 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5095 if (unformat (i, "%U", unformat_sw_if_index, vam,
5097 rx_sw_if_index_set = 1;
5102 else if (unformat (i, "tx"))
5104 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5106 if (unformat (i, "%U", unformat_sw_if_index, vam,
5108 tx_sw_if_index_set = 1;
5113 else if (unformat (i, "enable"))
5115 else if (unformat (i, "disable"))
5121 if (rx_sw_if_index_set == 0)
5123 errmsg ("missing rx interface name or rx_sw_if_index\n");
5127 if (enable && (tx_sw_if_index_set == 0))
5129 errmsg ("missing tx interface name or tx_sw_if_index\n");
5133 M (SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect);
5135 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5136 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5137 mp->enable = enable;
5146 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5148 unformat_input_t *i = vam->input;
5149 vl_api_sw_interface_set_l2_bridge_t *mp;
5152 u8 rx_sw_if_index_set = 0;
5159 /* Parse args required to build the message */
5160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5162 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5163 rx_sw_if_index_set = 1;
5164 else if (unformat (i, "bd_id %d", &bd_id))
5166 else if (unformat (i, "%U", unformat_sw_if_index, vam, &rx_sw_if_index))
5167 rx_sw_if_index_set = 1;
5168 else if (unformat (i, "shg %d", &shg))
5170 else if (unformat (i, "bvi"))
5172 else if (unformat (i, "enable"))
5174 else if (unformat (i, "disable"))
5180 if (rx_sw_if_index_set == 0)
5182 errmsg ("missing rx interface name or sw_if_index\n");
5186 if (enable && (bd_id_set == 0))
5188 errmsg ("missing bridge domain\n");
5192 M (SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge);
5194 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5195 mp->bd_id = ntohl (bd_id);
5198 mp->enable = enable;
5207 api_bridge_domain_dump (vat_main_t * vam)
5209 unformat_input_t *i = vam->input;
5210 vl_api_bridge_domain_dump_t *mp;
5214 /* Parse args required to build the message */
5215 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5217 if (unformat (i, "bd_id %d", &bd_id))
5223 M (BRIDGE_DOMAIN_DUMP, bridge_domain_dump);
5224 mp->bd_id = ntohl (bd_id);
5227 /* Use a control ping for synchronization */
5229 vl_api_control_ping_t *mp;
5230 M (CONTROL_PING, control_ping);
5240 api_bridge_domain_add_del (vat_main_t * vam)
5242 unformat_input_t *i = vam->input;
5243 vl_api_bridge_domain_add_del_t *mp;
5247 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5249 /* Parse args required to build the message */
5250 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5252 if (unformat (i, "bd_id %d", &bd_id))
5254 else if (unformat (i, "flood %d", &flood))
5256 else if (unformat (i, "uu-flood %d", &uu_flood))
5258 else if (unformat (i, "forward %d", &forward))
5260 else if (unformat (i, "learn %d", &learn))
5262 else if (unformat (i, "arp-term %d", &arp_term))
5264 else if (unformat (i, "del"))
5267 flood = uu_flood = forward = learn = 0;
5275 errmsg ("missing bridge domain\n");
5279 M (BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del);
5281 mp->bd_id = ntohl (bd_id);
5283 mp->uu_flood = uu_flood;
5284 mp->forward = forward;
5286 mp->arp_term = arp_term;
5287 mp->is_add = is_add;
5296 api_l2fib_add_del (vat_main_t * vam)
5298 unformat_input_t *i = vam->input;
5299 vl_api_l2fib_add_del_t *mp;
5306 u8 sw_if_index_set = 0;
5315 /* Parse args required to build the message */
5316 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5318 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5320 else if (unformat (i, "bd_id %d", &bd_id))
5322 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5323 sw_if_index_set = 1;
5324 else if (unformat (i, "sw_if"))
5326 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5328 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5329 sw_if_index_set = 1;
5334 else if (unformat (i, "static"))
5336 else if (unformat (i, "filter"))
5341 else if (unformat (i, "bvi"))
5346 else if (unformat (i, "del"))
5348 else if (unformat (i, "count %d", &count))
5356 errmsg ("missing mac address\n");
5362 errmsg ("missing bridge domain\n");
5366 if (is_add && (sw_if_index_set == 0))
5368 errmsg ("missing interface name or sw_if_index\n");
5374 /* Turn on async mode */
5375 vam->async_mode = 1;
5376 vam->async_errors = 0;
5377 before = vat_time_now (vam);
5380 for (j = 0; j < count; j++)
5382 M (L2FIB_ADD_DEL, l2fib_add_del);
5385 mp->bd_id = ntohl (bd_id);
5386 mp->is_add = is_add;
5390 mp->sw_if_index = ntohl (sw_if_index);
5391 mp->static_mac = static_mac;
5392 mp->filter_mac = filter_mac;
5393 mp->bvi_mac = bvi_mac;
5395 increment_mac_address (&mac);
5402 vl_api_control_ping_t *mp;
5405 /* Shut off async mode */
5406 vam->async_mode = 0;
5408 M (CONTROL_PING, control_ping);
5411 timeout = vat_time_now (vam) + 1.0;
5412 while (vat_time_now (vam) < timeout)
5413 if (vam->result_ready == 1)
5418 if (vam->retval == -99)
5419 errmsg ("timeout\n");
5421 if (vam->async_errors > 0)
5423 errmsg ("%d asynchronous errors\n", vam->async_errors);
5426 vam->async_errors = 0;
5427 after = vat_time_now (vam);
5429 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
5430 count, after - before, count / (after - before));
5434 /* Wait for a reply... */
5437 /* Return the good/bad news */
5438 return (vam->retval);
5442 api_l2_flags (vat_main_t * vam)
5444 unformat_input_t *i = vam->input;
5445 vl_api_l2_flags_t *mp;
5448 u32 feature_bitmap = 0;
5449 u8 sw_if_index_set = 0;
5451 /* Parse args required to build the message */
5452 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5454 if (unformat (i, "sw_if_index %d", &sw_if_index))
5455 sw_if_index_set = 1;
5456 else if (unformat (i, "sw_if"))
5458 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5460 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5461 sw_if_index_set = 1;
5466 else if (unformat (i, "learn"))
5467 feature_bitmap |= L2INPUT_FEAT_LEARN;
5468 else if (unformat (i, "forward"))
5469 feature_bitmap |= L2INPUT_FEAT_FWD;
5470 else if (unformat (i, "flood"))
5471 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5472 else if (unformat (i, "uu-flood"))
5473 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5478 if (sw_if_index_set == 0)
5480 errmsg ("missing interface name or sw_if_index\n");
5484 M (L2_FLAGS, l2_flags);
5486 mp->sw_if_index = ntohl (sw_if_index);
5487 mp->feature_bitmap = ntohl (feature_bitmap);
5496 api_bridge_flags (vat_main_t * vam)
5498 unformat_input_t *i = vam->input;
5499 vl_api_bridge_flags_t *mp;
5506 /* Parse args required to build the message */
5507 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5509 if (unformat (i, "bd_id %d", &bd_id))
5511 else if (unformat (i, "learn"))
5513 else if (unformat (i, "forward"))
5515 else if (unformat (i, "flood"))
5517 else if (unformat (i, "uu-flood"))
5518 flags |= L2_UU_FLOOD;
5519 else if (unformat (i, "arp-term"))
5520 flags |= L2_ARP_TERM;
5521 else if (unformat (i, "off"))
5523 else if (unformat (i, "disable"))
5531 errmsg ("missing bridge domain\n");
5535 M (BRIDGE_FLAGS, bridge_flags);
5537 mp->bd_id = ntohl (bd_id);
5538 mp->feature_bitmap = ntohl (flags);
5539 mp->is_set = is_set;
5548 api_bd_ip_mac_add_del (vat_main_t * vam)
5550 unformat_input_t *i = vam->input;
5551 vl_api_bd_ip_mac_add_del_t *mp;
5559 ip4_address_t v4addr;
5560 ip6_address_t v6addr;
5564 /* Parse args required to build the message */
5565 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5567 if (unformat (i, "bd_id %d", &bd_id))
5571 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5575 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5580 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5584 else if (unformat (i, "del"))
5592 errmsg ("missing bridge domain\n");
5595 else if (ip_set == 0)
5597 errmsg ("missing IP address\n");
5600 else if (mac_set == 0)
5602 errmsg ("missing MAC address\n");
5606 M (BD_IP_MAC_ADD_DEL, bd_ip_mac_add_del);
5608 mp->bd_id = ntohl (bd_id);
5609 mp->is_ipv6 = is_ipv6;
5610 mp->is_add = is_add;
5612 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5614 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5615 clib_memcpy (mp->mac_address, macaddr, 6);
5623 api_tap_connect (vat_main_t * vam)
5625 unformat_input_t *i = vam->input;
5626 vl_api_tap_connect_t *mp;
5633 memset (mac_address, 0, sizeof (mac_address));
5635 /* Parse args required to build the message */
5636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5638 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5642 else if (unformat (i, "random-mac"))
5644 else if (unformat (i, "tapname %s", &tap_name))
5652 errmsg ("missing tap name\n");
5655 if (vec_len (tap_name) > 63)
5657 errmsg ("tap name too long\n");
5659 vec_add1 (tap_name, 0);
5661 /* Construct the API message */
5662 M (TAP_CONNECT, tap_connect);
5664 mp->use_random_mac = random_mac;
5665 clib_memcpy (mp->mac_address, mac_address, 6);
5666 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5667 vec_free (tap_name);
5672 /* Wait for a reply... */
5677 api_tap_modify (vat_main_t * vam)
5679 unformat_input_t *i = vam->input;
5680 vl_api_tap_modify_t *mp;
5686 u32 sw_if_index = ~0;
5687 u8 sw_if_index_set = 0;
5689 memset (mac_address, 0, sizeof (mac_address));
5691 /* Parse args required to build the message */
5692 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5694 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5695 sw_if_index_set = 1;
5696 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5697 sw_if_index_set = 1;
5698 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5702 else if (unformat (i, "random-mac"))
5704 else if (unformat (i, "tapname %s", &tap_name))
5710 if (sw_if_index_set == 0)
5712 errmsg ("missing vpp interface name");
5717 errmsg ("missing tap name\n");
5720 if (vec_len (tap_name) > 63)
5722 errmsg ("tap name too long\n");
5724 vec_add1 (tap_name, 0);
5726 /* Construct the API message */
5727 M (TAP_MODIFY, tap_modify);
5729 mp->use_random_mac = random_mac;
5730 mp->sw_if_index = ntohl (sw_if_index);
5731 clib_memcpy (mp->mac_address, mac_address, 6);
5732 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
5733 vec_free (tap_name);
5738 /* Wait for a reply... */
5743 api_tap_delete (vat_main_t * vam)
5745 unformat_input_t *i = vam->input;
5746 vl_api_tap_delete_t *mp;
5748 u32 sw_if_index = ~0;
5749 u8 sw_if_index_set = 0;
5751 /* Parse args required to build the message */
5752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5754 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5755 sw_if_index_set = 1;
5756 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5757 sw_if_index_set = 1;
5762 if (sw_if_index_set == 0)
5764 errmsg ("missing vpp interface name");
5768 /* Construct the API message */
5769 M (TAP_DELETE, tap_delete);
5771 mp->sw_if_index = ntohl (sw_if_index);
5776 /* Wait for a reply... */
5781 api_ip_add_del_route (vat_main_t * vam)
5783 unformat_input_t *i = vam->input;
5784 vl_api_ip_add_del_route_t *mp;
5786 u32 sw_if_index = ~0, vrf_id = 0;
5787 u8 sw_if_index_set = 0;
5789 u8 is_local = 0, is_drop = 0;
5790 u8 is_unreach = 0, is_prohibit = 0;
5791 u8 create_vrf_if_needed = 0;
5793 u32 next_hop_weight = 1;
5795 u8 is_multipath = 0;
5797 u8 address_length_set = 0;
5798 u32 next_hop_table_id = 0;
5799 u32 resolve_attempts = 0;
5800 u32 dst_address_length = 0;
5801 u8 next_hop_set = 0;
5802 ip4_address_t v4_dst_address, v4_next_hop_address;
5803 ip6_address_t v6_dst_address, v6_next_hop_address;
5807 u32 random_add_del = 0;
5808 u32 *random_vector = 0;
5810 u32 random_seed = 0xdeaddabe;
5811 u32 classify_table_index = ~0;
5813 u8 resolve_host = 0, resolve_attached = 0;
5814 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
5816 /* Parse args required to build the message */
5817 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5819 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
5820 sw_if_index_set = 1;
5821 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5822 sw_if_index_set = 1;
5823 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
5828 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
5833 else if (unformat (i, "/%d", &dst_address_length))
5835 address_length_set = 1;
5838 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
5839 &v4_next_hop_address))
5843 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
5844 &v6_next_hop_address))
5848 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
5850 else if (unformat (i, "weight %d", &next_hop_weight))
5852 else if (unformat (i, "drop"))
5856 else if (unformat (i, "null-send-unreach"))
5860 else if (unformat (i, "null-send-prohibit"))
5864 else if (unformat (i, "local"))
5868 else if (unformat (i, "classify %d", &classify_table_index))
5872 else if (unformat (i, "del"))
5874 else if (unformat (i, "add"))
5876 else if (unformat (i, "not-last"))
5878 else if (unformat (i, "resolve-via-host"))
5880 else if (unformat (i, "resolve-via-attached"))
5881 resolve_attached = 1;
5882 else if (unformat (i, "multipath"))
5884 else if (unformat (i, "vrf %d", &vrf_id))
5886 else if (unformat (i, "create-vrf"))
5887 create_vrf_if_needed = 1;
5888 else if (unformat (i, "count %d", &count))
5890 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
5892 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
5894 else if (unformat (i, "out-label %d", &next_hop_out_label))
5896 else if (unformat (i, "random"))
5898 else if (unformat (i, "seed %d", &random_seed))
5902 clib_warning ("parse error '%U'", format_unformat_error, i);
5907 if (resolve_attempts > 0 && sw_if_index_set == 0)
5909 errmsg ("ARP resolution needs explicit interface or sw_if_index\n");
5913 if (!next_hop_set && !is_drop && !is_local &&
5914 !is_classify && !is_unreach && !is_prohibit)
5917 ("next hop / local / drop / unreach / prohibit / classify not set\n");
5921 if (address_set == 0)
5923 errmsg ("missing addresses\n");
5927 if (address_length_set == 0)
5929 errmsg ("missing address length\n");
5933 /* Generate a pile of unique, random routes */
5936 u32 this_random_address;
5937 random_hash = hash_create (count, sizeof (uword));
5939 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
5940 for (j = 0; j <= count; j++)
5944 this_random_address = random_u32 (&random_seed);
5945 this_random_address =
5946 clib_host_to_net_u32 (this_random_address);
5948 while (hash_get (random_hash, this_random_address));
5949 vec_add1 (random_vector, this_random_address);
5950 hash_set (random_hash, this_random_address, 1);
5952 hash_free (random_hash);
5953 v4_dst_address.as_u32 = random_vector[0];
5958 /* Turn on async mode */
5959 vam->async_mode = 1;
5960 vam->async_errors = 0;
5961 before = vat_time_now (vam);
5964 for (j = 0; j < count; j++)
5966 /* Construct the API message */
5967 M (IP_ADD_DEL_ROUTE, ip_add_del_route);
5969 mp->next_hop_sw_if_index = ntohl (sw_if_index);
5970 mp->table_id = ntohl (vrf_id);
5971 if (resolve_attempts > 0)
5973 mp->resolve_attempts = ntohl (resolve_attempts);
5974 mp->resolve_if_needed = 1;
5976 mp->create_vrf_if_needed = create_vrf_if_needed;
5978 mp->is_add = is_add;
5979 mp->is_drop = is_drop;
5980 mp->is_unreach = is_unreach;
5981 mp->is_prohibit = is_prohibit;
5982 mp->is_ipv6 = is_ipv6;
5983 mp->is_local = is_local;
5984 mp->is_classify = is_classify;
5985 mp->is_multipath = is_multipath;
5986 mp->is_resolve_host = resolve_host;
5987 mp->is_resolve_attached = resolve_attached;
5988 mp->not_last = not_last;
5989 mp->next_hop_weight = next_hop_weight;
5990 mp->dst_address_length = dst_address_length;
5991 mp->next_hop_table_id = ntohl (next_hop_table_id);
5992 mp->classify_table_index = ntohl (classify_table_index);
5993 mp->next_hop_out_label = ntohl (next_hop_out_label);
5997 clib_memcpy (mp->dst_address, &v6_dst_address,
5998 sizeof (v6_dst_address));
6000 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6001 sizeof (v6_next_hop_address));
6002 increment_v6_address (&v6_dst_address);
6006 clib_memcpy (mp->dst_address, &v4_dst_address,
6007 sizeof (v4_dst_address));
6009 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6010 sizeof (v4_next_hop_address));
6012 v4_dst_address.as_u32 = random_vector[j + 1];
6014 increment_v4_address (&v4_dst_address);
6018 /* If we receive SIGTERM, stop now... */
6023 /* When testing multiple add/del ops, use a control-ping to sync */
6026 vl_api_control_ping_t *mp;
6029 /* Shut off async mode */
6030 vam->async_mode = 0;
6032 M (CONTROL_PING, control_ping);
6035 timeout = vat_time_now (vam) + 1.0;
6036 while (vat_time_now (vam) < timeout)
6037 if (vam->result_ready == 1)
6042 if (vam->retval == -99)
6043 errmsg ("timeout\n");
6045 if (vam->async_errors > 0)
6047 errmsg ("%d asynchronous errors\n", vam->async_errors);
6050 vam->async_errors = 0;
6051 after = vat_time_now (vam);
6053 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6057 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
6058 count, after - before, count / (after - before));
6062 /* Wait for a reply... */
6066 /* Return the good/bad news */
6067 return (vam->retval);
6071 api_mpls_route_add_del (vat_main_t * vam)
6073 unformat_input_t *i = vam->input;
6074 vl_api_mpls_route_add_del_t *mp;
6076 u32 sw_if_index = ~0, table_id = 0;
6077 u8 create_table_if_needed = 0;
6079 u32 next_hop_weight = 1;
6080 u8 is_multipath = 0;
6081 u32 next_hop_table_id = 0;
6082 u8 next_hop_set = 0;
6083 ip4_address_t v4_next_hop_address = {
6086 ip6_address_t v6_next_hop_address = { {0} };
6090 u32 classify_table_index = ~0;
6092 u8 resolve_host = 0, resolve_attached = 0;
6093 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6094 mpls_label_t local_label = MPLS_LABEL_INVALID;
6096 u8 next_hop_proto_is_ip4 = 1;
6098 /* Parse args required to build the message */
6099 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6101 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6103 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6105 else if (unformat (i, "%d", &local_label))
6107 else if (unformat (i, "eos"))
6109 else if (unformat (i, "non-eos"))
6111 else if (unformat (i, "via %U", unformat_ip4_address,
6112 &v4_next_hop_address))
6115 next_hop_proto_is_ip4 = 1;
6117 else if (unformat (i, "via %U", unformat_ip6_address,
6118 &v6_next_hop_address))
6121 next_hop_proto_is_ip4 = 0;
6123 else if (unformat (i, "weight %d", &next_hop_weight))
6125 else if (unformat (i, "create-table"))
6126 create_table_if_needed = 1;
6127 else if (unformat (i, "classify %d", &classify_table_index))
6131 else if (unformat (i, "del"))
6133 else if (unformat (i, "add"))
6135 else if (unformat (i, "resolve-via-host"))
6137 else if (unformat (i, "resolve-via-attached"))
6138 resolve_attached = 1;
6139 else if (unformat (i, "multipath"))
6141 else if (unformat (i, "count %d", &count))
6143 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6146 next_hop_proto_is_ip4 = 1;
6148 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6151 next_hop_proto_is_ip4 = 0;
6153 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6155 else if (unformat (i, "out-label %d", &next_hop_out_label))
6159 clib_warning ("parse error '%U'", format_unformat_error, i);
6164 if (!next_hop_set && !is_classify)
6166 errmsg ("next hop / classify not set\n");
6170 if (MPLS_LABEL_INVALID == local_label)
6172 errmsg ("missing label\n");
6178 /* Turn on async mode */
6179 vam->async_mode = 1;
6180 vam->async_errors = 0;
6181 before = vat_time_now (vam);
6184 for (j = 0; j < count; j++)
6186 /* Construct the API message */
6187 M (MPLS_ROUTE_ADD_DEL, mpls_route_add_del);
6189 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6190 mp->mr_table_id = ntohl (table_id);
6191 mp->mr_create_table_if_needed = create_table_if_needed;
6193 mp->mr_is_add = is_add;
6194 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6195 mp->mr_is_classify = is_classify;
6196 mp->mr_is_multipath = is_multipath;
6197 mp->mr_is_resolve_host = resolve_host;
6198 mp->mr_is_resolve_attached = resolve_attached;
6199 mp->mr_next_hop_weight = next_hop_weight;
6200 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6201 mp->mr_classify_table_index = ntohl (classify_table_index);
6202 mp->mr_next_hop_out_label = ntohl (next_hop_out_label);
6203 mp->mr_label = ntohl (local_label);
6204 mp->mr_eos = is_eos;
6208 if (next_hop_proto_is_ip4)
6210 clib_memcpy (mp->mr_next_hop,
6211 &v4_next_hop_address,
6212 sizeof (v4_next_hop_address));
6216 clib_memcpy (mp->mr_next_hop,
6217 &v6_next_hop_address,
6218 sizeof (v6_next_hop_address));
6225 /* If we receive SIGTERM, stop now... */
6230 /* When testing multiple add/del ops, use a control-ping to sync */
6233 vl_api_control_ping_t *mp;
6236 /* Shut off async mode */
6237 vam->async_mode = 0;
6239 M (CONTROL_PING, control_ping);
6242 timeout = vat_time_now (vam) + 1.0;
6243 while (vat_time_now (vam) < timeout)
6244 if (vam->result_ready == 1)
6249 if (vam->retval == -99)
6250 errmsg ("timeout\n");
6252 if (vam->async_errors > 0)
6254 errmsg ("%d asynchronous errors\n", vam->async_errors);
6257 vam->async_errors = 0;
6258 after = vat_time_now (vam);
6260 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6264 fformat (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec\n",
6265 count, after - before, count / (after - before));
6269 /* Wait for a reply... */
6273 /* Return the good/bad news */
6274 return (vam->retval);
6278 api_mpls_ip_bind_unbind (vat_main_t * vam)
6280 unformat_input_t *i = vam->input;
6281 vl_api_mpls_ip_bind_unbind_t *mp;
6283 u32 ip_table_id = 0;
6284 u8 create_table_if_needed = 0;
6287 ip4_address_t v4_address;
6288 ip6_address_t v6_address;
6291 mpls_label_t local_label = MPLS_LABEL_INVALID;
6293 /* Parse args required to build the message */
6294 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6296 if (unformat (i, "%U/%d", unformat_ip4_address,
6297 &v4_address, &address_length))
6302 else if (unformat (i, "%U/%d", unformat_ip6_address,
6303 &v6_address, &address_length))
6308 else if (unformat (i, "%d", &local_label))
6310 else if (unformat (i, "create-table"))
6311 create_table_if_needed = 1;
6312 else if (unformat (i, "table-id %d", &ip_table_id))
6314 else if (unformat (i, "unbind"))
6316 else if (unformat (i, "bind"))
6320 clib_warning ("parse error '%U'", format_unformat_error, i);
6327 errmsg ("IP addres not set\n");
6331 if (MPLS_LABEL_INVALID == local_label)
6333 errmsg ("missing label\n");
6337 /* Construct the API message */
6338 M (MPLS_IP_BIND_UNBIND, mpls_ip_bind_unbind);
6340 mp->mb_create_table_if_needed = create_table_if_needed;
6341 mp->mb_is_bind = is_bind;
6342 mp->mb_is_ip4 = is_ip4;
6343 mp->mb_ip_table_id = ntohl (ip_table_id);
6344 mp->mb_mpls_table_id = 0;
6345 mp->mb_label = ntohl (local_label);
6346 mp->mb_address_length = address_length;
6349 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
6351 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
6356 /* Wait for a reply... */
6361 api_proxy_arp_add_del (vat_main_t * vam)
6363 unformat_input_t *i = vam->input;
6364 vl_api_proxy_arp_add_del_t *mp;
6368 ip4_address_t lo, hi;
6371 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6373 if (unformat (i, "vrf %d", &vrf_id))
6375 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
6376 unformat_ip4_address, &hi))
6378 else if (unformat (i, "del"))
6382 clib_warning ("parse error '%U'", format_unformat_error, i);
6389 errmsg ("address range not set\n");
6393 M (PROXY_ARP_ADD_DEL, proxy_arp_add_del);
6395 mp->vrf_id = ntohl (vrf_id);
6396 mp->is_add = is_add;
6397 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
6398 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
6407 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
6409 unformat_input_t *i = vam->input;
6410 vl_api_proxy_arp_intfc_enable_disable_t *mp;
6414 u8 sw_if_index_set = 0;
6416 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6418 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6419 sw_if_index_set = 1;
6420 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6421 sw_if_index_set = 1;
6422 else if (unformat (i, "enable"))
6424 else if (unformat (i, "disable"))
6428 clib_warning ("parse error '%U'", format_unformat_error, i);
6433 if (sw_if_index_set == 0)
6435 errmsg ("missing interface name or sw_if_index\n");
6439 M (PROXY_ARP_INTFC_ENABLE_DISABLE, proxy_arp_intfc_enable_disable);
6441 mp->sw_if_index = ntohl (sw_if_index);
6442 mp->enable_disable = enable;
6451 api_mpls_add_del_encap (vat_main_t * vam)
6453 unformat_input_t *i = vam->input;
6454 vl_api_mpls_add_del_encap_t *mp;
6459 ip4_address_t dst_address;
6462 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6464 if (unformat (i, "vrf %d", &vrf_id))
6466 else if (unformat (i, "label %d", &label))
6467 vec_add1 (labels, ntohl (label));
6468 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
6470 else if (unformat (i, "del"))
6474 clib_warning ("parse error '%U'", format_unformat_error, i);
6479 if (vec_len (labels) == 0)
6481 errmsg ("missing encap label stack\n");
6485 M2 (MPLS_ADD_DEL_ENCAP, mpls_add_del_encap,
6486 sizeof (u32) * vec_len (labels));
6488 mp->vrf_id = ntohl (vrf_id);
6489 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
6490 mp->is_add = is_add;
6491 mp->nlabels = vec_len (labels);
6492 clib_memcpy (mp->labels, labels, sizeof (u32) * mp->nlabels);
6503 api_mpls_ethernet_add_del_tunnel (vat_main_t * vam)
6505 unformat_input_t *i = vam->input;
6506 vl_api_mpls_ethernet_add_del_tunnel_t *mp;
6508 u32 inner_vrf_id = 0;
6509 ip4_address_t intfc_address;
6510 u8 dst_mac_address[6];
6513 u8 intfc_address_length = 0;
6517 int tx_sw_if_index_set = 0;
6519 /* Shut up coverity */
6520 memset (dst_mac_address, 0, sizeof (dst_mac_address));
6522 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6524 if (unformat (i, "vrf %d", &inner_vrf_id))
6526 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
6527 &intfc_address, &tmp))
6528 intfc_address_length = tmp;
6529 else if (unformat (i, "%U", unformat_sw_if_index, vam, &tx_sw_if_index))
6530 tx_sw_if_index_set = 1;
6531 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6532 tx_sw_if_index_set = 1;
6533 else if (unformat (i, "dst %U", unformat_ethernet_address,
6536 else if (unformat (i, "l2-only"))
6538 else if (unformat (i, "del"))
6542 clib_warning ("parse error '%U'", format_unformat_error, i);
6549 errmsg ("dst (mac address) not set\n");
6552 if (!tx_sw_if_index_set)
6554 errmsg ("tx-intfc not set\n");
6558 M (MPLS_ETHERNET_ADD_DEL_TUNNEL, mpls_ethernet_add_del_tunnel);
6560 mp->vrf_id = ntohl (inner_vrf_id);
6561 clib_memcpy (mp->adj_address, &intfc_address, sizeof (intfc_address));
6562 mp->adj_address_length = intfc_address_length;
6563 clib_memcpy (mp->dst_mac_address, dst_mac_address,
6564 sizeof (dst_mac_address));
6565 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6566 mp->l2_only = l2_only;
6567 mp->is_add = is_add;
6576 api_mpls_ethernet_add_del_tunnel_2 (vat_main_t * vam)
6578 unformat_input_t *i = vam->input;
6579 vl_api_mpls_ethernet_add_del_tunnel_2_t *mp;
6581 u32 inner_vrf_id = 0;
6582 u32 outer_vrf_id = 0;
6583 ip4_address_t adj_address;
6584 int adj_address_set = 0;
6585 ip4_address_t next_hop_address;
6586 int next_hop_address_set = 0;
6588 u8 adj_address_length = 0;
6591 u32 resolve_attempts = 5;
6592 u8 resolve_if_needed = 1;
6594 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6596 if (unformat (i, "inner_vrf_id %d", &inner_vrf_id))
6598 else if (unformat (i, "outer_vrf_id %d", &outer_vrf_id))
6600 else if (unformat (i, "adj %U/%d", unformat_ip4_address,
6601 &adj_address, &tmp))
6603 adj_address_length = tmp;
6604 adj_address_set = 1;
6606 else if (unformat (i, "next-hop %U", unformat_ip4_address,
6608 next_hop_address_set = 1;
6609 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6611 else if (unformat (i, "resolve-if-needed %d", &tmp))
6612 resolve_if_needed = tmp;
6613 else if (unformat (i, "l2-only"))
6615 else if (unformat (i, "del"))
6619 clib_warning ("parse error '%U'", format_unformat_error, i);
6624 if (!adj_address_set)
6626 errmsg ("adjacency address/mask not set\n");
6629 if (!next_hop_address_set)
6631 errmsg ("ip4 next hop address (in outer fib) not set\n");
6635 M (MPLS_ETHERNET_ADD_DEL_TUNNEL_2, mpls_ethernet_add_del_tunnel_2);
6637 mp->inner_vrf_id = ntohl (inner_vrf_id);
6638 mp->outer_vrf_id = ntohl (outer_vrf_id);
6639 mp->resolve_attempts = ntohl (resolve_attempts);
6640 mp->resolve_if_needed = resolve_if_needed;
6641 mp->is_add = is_add;
6642 mp->l2_only = l2_only;
6643 clib_memcpy (mp->adj_address, &adj_address, sizeof (adj_address));
6644 mp->adj_address_length = adj_address_length;
6645 clib_memcpy (mp->next_hop_ip4_address_in_outer_vrf, &next_hop_address,
6646 sizeof (next_hop_address));
6655 api_sw_interface_set_unnumbered (vat_main_t * vam)
6657 unformat_input_t *i = vam->input;
6658 vl_api_sw_interface_set_unnumbered_t *mp;
6661 u32 unnum_sw_index = ~0;
6663 u8 sw_if_index_set = 0;
6665 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6667 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6668 sw_if_index_set = 1;
6669 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6670 sw_if_index_set = 1;
6671 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
6673 else if (unformat (i, "del"))
6677 clib_warning ("parse error '%U'", format_unformat_error, i);
6682 if (sw_if_index_set == 0)
6684 errmsg ("missing interface name or sw_if_index\n");
6688 M (SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered);
6690 mp->sw_if_index = ntohl (sw_if_index);
6691 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
6692 mp->is_add = is_add;
6701 api_ip_neighbor_add_del (vat_main_t * vam)
6703 unformat_input_t *i = vam->input;
6704 vl_api_ip_neighbor_add_del_t *mp;
6707 u8 sw_if_index_set = 0;
6713 u8 v4_address_set = 0;
6714 u8 v6_address_set = 0;
6715 ip4_address_t v4address;
6716 ip6_address_t v6address;
6718 memset (mac_address, 0, sizeof (mac_address));
6720 /* Parse args required to build the message */
6721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6723 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6727 else if (unformat (i, "del"))
6729 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6730 sw_if_index_set = 1;
6731 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6732 sw_if_index_set = 1;
6733 else if (unformat (i, "is_static"))
6735 else if (unformat (i, "vrf %d", &vrf_id))
6737 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
6739 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
6743 clib_warning ("parse error '%U'", format_unformat_error, i);
6748 if (sw_if_index_set == 0)
6750 errmsg ("missing interface name or sw_if_index\n");
6753 if (v4_address_set && v6_address_set)
6755 errmsg ("both v4 and v6 addresses set\n");
6758 if (!v4_address_set && !v6_address_set)
6760 errmsg ("no address set\n");
6764 /* Construct the API message */
6765 M (IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del);
6767 mp->sw_if_index = ntohl (sw_if_index);
6768 mp->is_add = is_add;
6769 mp->vrf_id = ntohl (vrf_id);
6770 mp->is_static = is_static;
6772 clib_memcpy (mp->mac_address, mac_address, 6);
6776 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
6780 /* mp->is_ipv6 = 0; via memset in M macro above */
6781 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
6787 /* Wait for a reply, return good/bad news */
6795 api_reset_vrf (vat_main_t * vam)
6797 unformat_input_t *i = vam->input;
6798 vl_api_reset_vrf_t *mp;
6804 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6806 if (unformat (i, "vrf %d", &vrf_id))
6808 else if (unformat (i, "ipv6"))
6812 clib_warning ("parse error '%U'", format_unformat_error, i);
6817 if (vrf_id_set == 0)
6819 errmsg ("missing vrf id\n");
6823 M (RESET_VRF, reset_vrf);
6825 mp->vrf_id = ntohl (vrf_id);
6826 mp->is_ipv6 = is_ipv6;
6835 api_create_vlan_subif (vat_main_t * vam)
6837 unformat_input_t *i = vam->input;
6838 vl_api_create_vlan_subif_t *mp;
6841 u8 sw_if_index_set = 0;
6845 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6847 if (unformat (i, "sw_if_index %d", &sw_if_index))
6848 sw_if_index_set = 1;
6849 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6850 sw_if_index_set = 1;
6851 else if (unformat (i, "vlan %d", &vlan_id))
6855 clib_warning ("parse error '%U'", format_unformat_error, i);
6860 if (sw_if_index_set == 0)
6862 errmsg ("missing interface name or sw_if_index\n");
6866 if (vlan_id_set == 0)
6868 errmsg ("missing vlan_id\n");
6871 M (CREATE_VLAN_SUBIF, create_vlan_subif);
6873 mp->sw_if_index = ntohl (sw_if_index);
6874 mp->vlan_id = ntohl (vlan_id);
6882 #define foreach_create_subif_bit \
6889 _(outer_vlan_id_any) \
6890 _(inner_vlan_id_any)
6893 api_create_subif (vat_main_t * vam)
6895 unformat_input_t *i = vam->input;
6896 vl_api_create_subif_t *mp;
6899 u8 sw_if_index_set = 0;
6906 u32 exact_match = 0;
6907 u32 default_sub = 0;
6908 u32 outer_vlan_id_any = 0;
6909 u32 inner_vlan_id_any = 0;
6911 u16 outer_vlan_id = 0;
6912 u16 inner_vlan_id = 0;
6914 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6916 if (unformat (i, "sw_if_index %d", &sw_if_index))
6917 sw_if_index_set = 1;
6918 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
6919 sw_if_index_set = 1;
6920 else if (unformat (i, "sub_id %d", &sub_id))
6922 else if (unformat (i, "outer_vlan_id %d", &tmp))
6923 outer_vlan_id = tmp;
6924 else if (unformat (i, "inner_vlan_id %d", &tmp))
6925 inner_vlan_id = tmp;
6927 #define _(a) else if (unformat (i, #a)) a = 1 ;
6928 foreach_create_subif_bit
6932 clib_warning ("parse error '%U'", format_unformat_error, i);
6937 if (sw_if_index_set == 0)
6939 errmsg ("missing interface name or sw_if_index\n");
6943 if (sub_id_set == 0)
6945 errmsg ("missing sub_id\n");
6948 M (CREATE_SUBIF, create_subif);
6950 mp->sw_if_index = ntohl (sw_if_index);
6951 mp->sub_id = ntohl (sub_id);
6953 #define _(a) mp->a = a;
6954 foreach_create_subif_bit;
6957 mp->outer_vlan_id = ntohs (outer_vlan_id);
6958 mp->inner_vlan_id = ntohs (inner_vlan_id);
6967 api_oam_add_del (vat_main_t * vam)
6969 unformat_input_t *i = vam->input;
6970 vl_api_oam_add_del_t *mp;
6974 ip4_address_t src, dst;
6978 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6980 if (unformat (i, "vrf %d", &vrf_id))
6982 else if (unformat (i, "src %U", unformat_ip4_address, &src))
6984 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
6986 else if (unformat (i, "del"))
6990 clib_warning ("parse error '%U'", format_unformat_error, i);
6997 errmsg ("missing src addr\n");
7003 errmsg ("missing dst addr\n");
7007 M (OAM_ADD_DEL, oam_add_del);
7009 mp->vrf_id = ntohl (vrf_id);
7010 mp->is_add = is_add;
7011 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7012 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7021 api_reset_fib (vat_main_t * vam)
7023 unformat_input_t *i = vam->input;
7024 vl_api_reset_fib_t *mp;
7030 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7032 if (unformat (i, "vrf %d", &vrf_id))
7034 else if (unformat (i, "ipv6"))
7038 clib_warning ("parse error '%U'", format_unformat_error, i);
7043 if (vrf_id_set == 0)
7045 errmsg ("missing vrf id\n");
7049 M (RESET_FIB, reset_fib);
7051 mp->vrf_id = ntohl (vrf_id);
7052 mp->is_ipv6 = is_ipv6;
7061 api_dhcp_proxy_config (vat_main_t * vam)
7063 unformat_input_t *i = vam->input;
7064 vl_api_dhcp_proxy_config_t *mp;
7069 u8 v4_address_set = 0;
7070 u8 v6_address_set = 0;
7071 ip4_address_t v4address;
7072 ip6_address_t v6address;
7073 u8 v4_src_address_set = 0;
7074 u8 v6_src_address_set = 0;
7075 ip4_address_t v4srcaddress;
7076 ip6_address_t v6srcaddress;
7078 /* Parse args required to build the message */
7079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7081 if (unformat (i, "del"))
7083 else if (unformat (i, "vrf %d", &vrf_id))
7085 else if (unformat (i, "insert-cid %d", &insert_cid))
7087 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7089 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7091 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7092 v4_src_address_set = 1;
7093 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7094 v6_src_address_set = 1;
7099 if (v4_address_set && v6_address_set)
7101 errmsg ("both v4 and v6 server addresses set\n");
7104 if (!v4_address_set && !v6_address_set)
7106 errmsg ("no server addresses set\n");
7110 if (v4_src_address_set && v6_src_address_set)
7112 errmsg ("both v4 and v6 src addresses set\n");
7115 if (!v4_src_address_set && !v6_src_address_set)
7117 errmsg ("no src addresses set\n");
7121 if (!(v4_src_address_set && v4_address_set) &&
7122 !(v6_src_address_set && v6_address_set))
7124 errmsg ("no matching server and src addresses set\n");
7128 /* Construct the API message */
7129 M (DHCP_PROXY_CONFIG, dhcp_proxy_config);
7131 mp->insert_circuit_id = insert_cid;
7132 mp->is_add = is_add;
7133 mp->vrf_id = ntohl (vrf_id);
7137 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7138 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7142 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7143 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7149 /* Wait for a reply, return good/bad news */
7156 api_dhcp_proxy_config_2 (vat_main_t * vam)
7158 unformat_input_t *i = vam->input;
7159 vl_api_dhcp_proxy_config_2_t *mp;
7162 u32 server_vrf_id = 0;
7165 u8 v4_address_set = 0;
7166 u8 v6_address_set = 0;
7167 ip4_address_t v4address;
7168 ip6_address_t v6address;
7169 u8 v4_src_address_set = 0;
7170 u8 v6_src_address_set = 0;
7171 ip4_address_t v4srcaddress;
7172 ip6_address_t v6srcaddress;
7174 /* Parse args required to build the message */
7175 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7177 if (unformat (i, "del"))
7179 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7181 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7183 else if (unformat (i, "insert-cid %d", &insert_cid))
7185 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7187 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7189 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7190 v4_src_address_set = 1;
7191 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7192 v6_src_address_set = 1;
7197 if (v4_address_set && v6_address_set)
7199 errmsg ("both v4 and v6 server addresses set\n");
7202 if (!v4_address_set && !v6_address_set)
7204 errmsg ("no server addresses set\n");
7208 if (v4_src_address_set && v6_src_address_set)
7210 errmsg ("both v4 and v6 src addresses set\n");
7213 if (!v4_src_address_set && !v6_src_address_set)
7215 errmsg ("no src addresses set\n");
7219 if (!(v4_src_address_set && v4_address_set) &&
7220 !(v6_src_address_set && v6_address_set))
7222 errmsg ("no matching server and src addresses set\n");
7226 /* Construct the API message */
7227 M (DHCP_PROXY_CONFIG_2, dhcp_proxy_config_2);
7229 mp->insert_circuit_id = insert_cid;
7230 mp->is_add = is_add;
7231 mp->rx_vrf_id = ntohl (rx_vrf_id);
7232 mp->server_vrf_id = ntohl (server_vrf_id);
7236 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7237 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7241 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7242 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7248 /* Wait for a reply, return good/bad news */
7255 api_dhcp_proxy_set_vss (vat_main_t * vam)
7257 unformat_input_t *i = vam->input;
7258 vl_api_dhcp_proxy_set_vss_t *mp;
7269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7271 if (unformat (i, "tbl_id %d", &tbl_id))
7273 if (unformat (i, "fib_id %d", &fib_id))
7275 if (unformat (i, "oui %d", &oui))
7277 else if (unformat (i, "ipv6"))
7279 else if (unformat (i, "del"))
7283 clib_warning ("parse error '%U'", format_unformat_error, i);
7288 if (tbl_id_set == 0)
7290 errmsg ("missing tbl id\n");
7294 if (fib_id_set == 0)
7296 errmsg ("missing fib id\n");
7301 errmsg ("missing oui\n");
7305 M (DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss);
7306 mp->tbl_id = ntohl (tbl_id);
7307 mp->fib_id = ntohl (fib_id);
7308 mp->oui = ntohl (oui);
7309 mp->is_ipv6 = is_ipv6;
7310 mp->is_add = is_add;
7319 api_dhcp_client_config (vat_main_t * vam)
7321 unformat_input_t *i = vam->input;
7322 vl_api_dhcp_client_config_t *mp;
7325 u8 sw_if_index_set = 0;
7328 u8 disable_event = 0;
7330 /* Parse args required to build the message */
7331 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7333 if (unformat (i, "del"))
7335 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7336 sw_if_index_set = 1;
7337 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7338 sw_if_index_set = 1;
7339 else if (unformat (i, "hostname %s", &hostname))
7341 else if (unformat (i, "disable_event"))
7347 if (sw_if_index_set == 0)
7349 errmsg ("missing interface name or sw_if_index\n");
7353 if (vec_len (hostname) > 63)
7355 errmsg ("hostname too long\n");
7357 vec_add1 (hostname, 0);
7359 /* Construct the API message */
7360 M (DHCP_CLIENT_CONFIG, dhcp_client_config);
7362 mp->sw_if_index = ntohl (sw_if_index);
7363 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7364 vec_free (hostname);
7365 mp->is_add = is_add;
7366 mp->want_dhcp_event = disable_event ? 0 : 1;
7367 mp->pid = getpid ();
7372 /* Wait for a reply, return good/bad news */
7379 api_set_ip_flow_hash (vat_main_t * vam)
7381 unformat_input_t *i = vam->input;
7382 vl_api_set_ip_flow_hash_t *mp;
7394 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7396 if (unformat (i, "vrf %d", &vrf_id))
7398 else if (unformat (i, "ipv6"))
7400 else if (unformat (i, "src"))
7402 else if (unformat (i, "dst"))
7404 else if (unformat (i, "sport"))
7406 else if (unformat (i, "dport"))
7408 else if (unformat (i, "proto"))
7410 else if (unformat (i, "reverse"))
7415 clib_warning ("parse error '%U'", format_unformat_error, i);
7420 if (vrf_id_set == 0)
7422 errmsg ("missing vrf id\n");
7426 M (SET_IP_FLOW_HASH, set_ip_flow_hash);
7432 mp->reverse = reverse;
7433 mp->vrf_id = ntohl (vrf_id);
7434 mp->is_ipv6 = is_ipv6;
7443 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7445 unformat_input_t *i = vam->input;
7446 vl_api_sw_interface_ip6_enable_disable_t *mp;
7449 u8 sw_if_index_set = 0;
7452 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7454 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7455 sw_if_index_set = 1;
7456 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7457 sw_if_index_set = 1;
7458 else if (unformat (i, "enable"))
7460 else if (unformat (i, "disable"))
7464 clib_warning ("parse error '%U'", format_unformat_error, i);
7469 if (sw_if_index_set == 0)
7471 errmsg ("missing interface name or sw_if_index\n");
7475 M (SW_INTERFACE_IP6_ENABLE_DISABLE, sw_interface_ip6_enable_disable);
7477 mp->sw_if_index = ntohl (sw_if_index);
7478 mp->enable = enable;
7487 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7489 unformat_input_t *i = vam->input;
7490 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7493 u8 sw_if_index_set = 0;
7494 u32 address_length = 0;
7495 u8 v6_address_set = 0;
7496 ip6_address_t v6address;
7498 /* Parse args required to build the message */
7499 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7501 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7502 sw_if_index_set = 1;
7503 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7504 sw_if_index_set = 1;
7505 else if (unformat (i, "%U/%d",
7506 unformat_ip6_address, &v6address, &address_length))
7512 if (sw_if_index_set == 0)
7514 errmsg ("missing interface name or sw_if_index\n");
7517 if (!v6_address_set)
7519 errmsg ("no address set\n");
7523 /* Construct the API message */
7524 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS,
7525 sw_interface_ip6_set_link_local_address);
7527 mp->sw_if_index = ntohl (sw_if_index);
7528 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7529 mp->address_length = address_length;
7534 /* Wait for a reply, return good/bad news */
7543 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
7545 unformat_input_t *i = vam->input;
7546 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
7549 u8 sw_if_index_set = 0;
7550 u32 address_length = 0;
7551 u8 v6_address_set = 0;
7552 ip6_address_t v6address;
7554 u8 no_advertise = 0;
7556 u8 no_autoconfig = 0;
7559 u32 val_lifetime = 0;
7560 u32 pref_lifetime = 0;
7562 /* Parse args required to build the message */
7563 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7565 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7566 sw_if_index_set = 1;
7567 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7568 sw_if_index_set = 1;
7569 else if (unformat (i, "%U/%d",
7570 unformat_ip6_address, &v6address, &address_length))
7572 else if (unformat (i, "val_life %d", &val_lifetime))
7574 else if (unformat (i, "pref_life %d", &pref_lifetime))
7576 else if (unformat (i, "def"))
7578 else if (unformat (i, "noadv"))
7580 else if (unformat (i, "offl"))
7582 else if (unformat (i, "noauto"))
7584 else if (unformat (i, "nolink"))
7586 else if (unformat (i, "isno"))
7590 clib_warning ("parse error '%U'", format_unformat_error, i);
7595 if (sw_if_index_set == 0)
7597 errmsg ("missing interface name or sw_if_index\n");
7600 if (!v6_address_set)
7602 errmsg ("no address set\n");
7606 /* Construct the API message */
7607 M (SW_INTERFACE_IP6ND_RA_PREFIX, sw_interface_ip6nd_ra_prefix);
7609 mp->sw_if_index = ntohl (sw_if_index);
7610 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7611 mp->address_length = address_length;
7612 mp->use_default = use_default;
7613 mp->no_advertise = no_advertise;
7614 mp->off_link = off_link;
7615 mp->no_autoconfig = no_autoconfig;
7616 mp->no_onlink = no_onlink;
7618 mp->val_lifetime = ntohl (val_lifetime);
7619 mp->pref_lifetime = ntohl (pref_lifetime);
7624 /* Wait for a reply, return good/bad news */
7632 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
7634 unformat_input_t *i = vam->input;
7635 vl_api_sw_interface_ip6nd_ra_config_t *mp;
7638 u8 sw_if_index_set = 0;
7643 u8 send_unicast = 0;
7646 u8 default_router = 0;
7647 u32 max_interval = 0;
7648 u32 min_interval = 0;
7650 u32 initial_count = 0;
7651 u32 initial_interval = 0;
7654 /* Parse args required to build the message */
7655 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7657 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
7658 sw_if_index_set = 1;
7659 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7660 sw_if_index_set = 1;
7661 else if (unformat (i, "maxint %d", &max_interval))
7663 else if (unformat (i, "minint %d", &min_interval))
7665 else if (unformat (i, "life %d", &lifetime))
7667 else if (unformat (i, "count %d", &initial_count))
7669 else if (unformat (i, "interval %d", &initial_interval))
7671 else if (unformat (i, "suppress") || unformat (i, "surpress"))
7673 else if (unformat (i, "managed"))
7675 else if (unformat (i, "other"))
7677 else if (unformat (i, "ll"))
7679 else if (unformat (i, "send"))
7681 else if (unformat (i, "cease"))
7683 else if (unformat (i, "isno"))
7685 else if (unformat (i, "def"))
7689 clib_warning ("parse error '%U'", format_unformat_error, i);
7694 if (sw_if_index_set == 0)
7696 errmsg ("missing interface name or sw_if_index\n");
7700 /* Construct the API message */
7701 M (SW_INTERFACE_IP6ND_RA_CONFIG, sw_interface_ip6nd_ra_config);
7703 mp->sw_if_index = ntohl (sw_if_index);
7704 mp->max_interval = ntohl (max_interval);
7705 mp->min_interval = ntohl (min_interval);
7706 mp->lifetime = ntohl (lifetime);
7707 mp->initial_count = ntohl (initial_count);
7708 mp->initial_interval = ntohl (initial_interval);
7709 mp->suppress = suppress;
7710 mp->managed = managed;
7712 mp->ll_option = ll_option;
7713 mp->send_unicast = send_unicast;
7716 mp->default_router = default_router;
7721 /* Wait for a reply, return good/bad news */
7729 api_set_arp_neighbor_limit (vat_main_t * vam)
7731 unformat_input_t *i = vam->input;
7732 vl_api_set_arp_neighbor_limit_t *mp;
7738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7740 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
7742 else if (unformat (i, "ipv6"))
7746 clib_warning ("parse error '%U'", format_unformat_error, i);
7753 errmsg ("missing limit value\n");
7757 M (SET_ARP_NEIGHBOR_LIMIT, set_arp_neighbor_limit);
7759 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
7760 mp->is_ipv6 = is_ipv6;
7769 api_l2_patch_add_del (vat_main_t * vam)
7771 unformat_input_t *i = vam->input;
7772 vl_api_l2_patch_add_del_t *mp;
7775 u8 rx_sw_if_index_set = 0;
7777 u8 tx_sw_if_index_set = 0;
7780 /* Parse args required to build the message */
7781 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7783 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7784 rx_sw_if_index_set = 1;
7785 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7786 tx_sw_if_index_set = 1;
7787 else if (unformat (i, "rx"))
7789 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7791 if (unformat (i, "%U", unformat_sw_if_index, vam,
7793 rx_sw_if_index_set = 1;
7798 else if (unformat (i, "tx"))
7800 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7802 if (unformat (i, "%U", unformat_sw_if_index, vam,
7804 tx_sw_if_index_set = 1;
7809 else if (unformat (i, "del"))
7815 if (rx_sw_if_index_set == 0)
7817 errmsg ("missing rx interface name or rx_sw_if_index\n");
7821 if (tx_sw_if_index_set == 0)
7823 errmsg ("missing tx interface name or tx_sw_if_index\n");
7827 M (L2_PATCH_ADD_DEL, l2_patch_add_del);
7829 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7830 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7831 mp->is_add = is_add;
7840 api_ioam_enable (vat_main_t * vam)
7842 unformat_input_t *input = vam->input;
7843 vl_api_ioam_enable_t *mp;
7846 int has_trace_option = 0;
7847 int has_pot_option = 0;
7848 int has_seqno_option = 0;
7849 int has_analyse_option = 0;
7851 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7853 if (unformat (input, "trace"))
7854 has_trace_option = 1;
7855 else if (unformat (input, "pot"))
7857 else if (unformat (input, "seqno"))
7858 has_seqno_option = 1;
7859 else if (unformat (input, "analyse"))
7860 has_analyse_option = 1;
7864 M (IOAM_ENABLE, ioam_enable);
7865 mp->id = htons (id);
7866 mp->seqno = has_seqno_option;
7867 mp->analyse = has_analyse_option;
7868 mp->pot_enable = has_pot_option;
7869 mp->trace_enable = has_trace_option;
7880 api_ioam_disable (vat_main_t * vam)
7882 vl_api_ioam_disable_t *mp;
7885 M (IOAM_DISABLE, ioam_disable);
7892 api_sr_tunnel_add_del (vat_main_t * vam)
7894 unformat_input_t *i = vam->input;
7895 vl_api_sr_tunnel_add_del_t *mp;
7899 ip6_address_t src_address;
7900 int src_address_set = 0;
7901 ip6_address_t dst_address;
7903 int dst_address_set = 0;
7905 u32 rx_table_id = 0;
7906 u32 tx_table_id = 0;
7907 ip6_address_t *segments = 0;
7908 ip6_address_t *this_seg;
7909 ip6_address_t *tags = 0;
7910 ip6_address_t *this_tag;
7911 ip6_address_t next_address, tag;
7913 u8 *policy_name = 0;
7915 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7917 if (unformat (i, "del"))
7919 else if (unformat (i, "name %s", &name))
7921 else if (unformat (i, "policy %s", &policy_name))
7923 else if (unformat (i, "rx_fib_id %d", &rx_table_id))
7925 else if (unformat (i, "tx_fib_id %d", &tx_table_id))
7927 else if (unformat (i, "src %U", unformat_ip6_address, &src_address))
7928 src_address_set = 1;
7929 else if (unformat (i, "dst %U/%d",
7930 unformat_ip6_address, &dst_address, &dst_mask_width))
7931 dst_address_set = 1;
7932 else if (unformat (i, "next %U", unformat_ip6_address, &next_address))
7934 vec_add2 (segments, this_seg, 1);
7935 clib_memcpy (this_seg->as_u8, next_address.as_u8,
7936 sizeof (*this_seg));
7938 else if (unformat (i, "tag %U", unformat_ip6_address, &tag))
7940 vec_add2 (tags, this_tag, 1);
7941 clib_memcpy (this_tag->as_u8, tag.as_u8, sizeof (*this_tag));
7943 else if (unformat (i, "clean"))
7944 flags |= IP6_SR_HEADER_FLAG_CLEANUP;
7945 else if (unformat (i, "protected"))
7946 flags |= IP6_SR_HEADER_FLAG_PROTECTED;
7947 else if (unformat (i, "InPE %d", &pl_index))
7949 if (pl_index <= 0 || pl_index > 4)
7951 pl_index_range_error:
7952 errmsg ("pl index %d out of range\n", pl_index);
7956 IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE << (3 * (pl_index - 1));
7958 else if (unformat (i, "EgPE %d", &pl_index))
7960 if (pl_index <= 0 || pl_index > 4)
7961 goto pl_index_range_error;
7963 IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE << (3 * (pl_index - 1));
7965 else if (unformat (i, "OrgSrc %d", &pl_index))
7967 if (pl_index <= 0 || pl_index > 4)
7968 goto pl_index_range_error;
7970 IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR << (3 * (pl_index - 1));
7976 if (!src_address_set)
7978 errmsg ("src address required\n");
7982 if (!dst_address_set)
7984 errmsg ("dst address required\n");
7990 errmsg ("at least one sr segment required\n");
7994 M2 (SR_TUNNEL_ADD_DEL, sr_tunnel_add_del,
7995 vec_len (segments) * sizeof (ip6_address_t)
7996 + vec_len (tags) * sizeof (ip6_address_t));
7998 clib_memcpy (mp->src_address, &src_address, sizeof (mp->src_address));
7999 clib_memcpy (mp->dst_address, &dst_address, sizeof (mp->dst_address));
8000 mp->dst_mask_width = dst_mask_width;
8001 mp->flags_net_byte_order = clib_host_to_net_u16 (flags);
8002 mp->n_segments = vec_len (segments);
8003 mp->n_tags = vec_len (tags);
8004 mp->is_add = is_del == 0;
8005 clib_memcpy (mp->segs_and_tags, segments,
8006 vec_len (segments) * sizeof (ip6_address_t));
8007 clib_memcpy (mp->segs_and_tags +
8008 vec_len (segments) * sizeof (ip6_address_t), tags,
8009 vec_len (tags) * sizeof (ip6_address_t));
8011 mp->outer_vrf_id = ntohl (rx_table_id);
8012 mp->inner_vrf_id = ntohl (tx_table_id);
8013 memcpy (mp->name, name, vec_len (name));
8014 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8016 vec_free (segments);
8025 api_sr_policy_add_del (vat_main_t * vam)
8027 unformat_input_t *input = vam->input;
8028 vl_api_sr_policy_add_del_t *mp;
8032 u8 *tunnel_name = 0;
8033 u8 **tunnel_names = 0;
8038 int tunnel_names_length = 1; // Init to 1 to offset the #tunnel_names counter byte
8039 int tun_name_len = 0; // Different naming convention used as confusing these would be "bad" (TM)
8041 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8043 if (unformat (input, "del"))
8045 else if (unformat (input, "name %s", &name))
8047 else if (unformat (input, "tunnel %s", &tunnel_name))
8051 vec_add1 (tunnel_names, tunnel_name);
8053 - length = #bytes to store in serial vector
8054 - +1 = byte to store that length
8056 tunnel_names_length += (vec_len (tunnel_name) + 1);
8067 errmsg ("policy name required\n");
8071 if ((!tunnel_set) && (!is_del))
8073 errmsg ("tunnel name required\n");
8077 M2 (SR_POLICY_ADD_DEL, sr_policy_add_del, tunnel_names_length);
8081 mp->is_add = !is_del;
8083 memcpy (mp->name, name, vec_len (name));
8084 // Since mp->tunnel_names is of type u8[0] and not a u8 *, u8 ** needs to be serialized
8085 u8 *serial_orig = 0;
8086 vec_validate (serial_orig, tunnel_names_length);
8087 *serial_orig = vec_len (tunnel_names); // Store the number of tunnels as length in first byte of serialized vector
8088 serial_orig += 1; // Move along one byte to store the length of first tunnel_name
8090 for (j = 0; j < vec_len (tunnel_names); j++)
8092 tun_name_len = vec_len (tunnel_names[j]);
8093 *serial_orig = tun_name_len; // Store length of tunnel name in first byte of Length/Value pair
8094 serial_orig += 1; // Move along one byte to store the actual tunnel name
8095 memcpy (serial_orig, tunnel_names[j], tun_name_len);
8096 serial_orig += tun_name_len; // Advance past the copy
8098 memcpy (mp->tunnel_names, serial_orig - tunnel_names_length, tunnel_names_length); // Regress serial_orig to head then copy fwd
8100 vec_free (tunnel_names);
8101 vec_free (tunnel_name);
8109 api_sr_multicast_map_add_del (vat_main_t * vam)
8111 unformat_input_t *input = vam->input;
8112 vl_api_sr_multicast_map_add_del_t *mp;
8115 ip6_address_t multicast_address;
8116 u8 *policy_name = 0;
8117 int multicast_address_set = 0;
8119 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8121 if (unformat (input, "del"))
8125 (input, "address %U", unformat_ip6_address, &multicast_address))
8126 multicast_address_set = 1;
8127 else if (unformat (input, "sr-policy %s", &policy_name))
8133 if (!is_del && !policy_name)
8135 errmsg ("sr-policy name required\n");
8140 if (!multicast_address_set)
8142 errmsg ("address required\n");
8146 M (SR_MULTICAST_MAP_ADD_DEL, sr_multicast_map_add_del);
8148 mp->is_add = !is_del;
8149 memcpy (mp->policy_name, policy_name, vec_len (policy_name));
8150 clib_memcpy (mp->multicast_address, &multicast_address,
8151 sizeof (mp->multicast_address));
8154 vec_free (policy_name);
8162 #define foreach_tcp_proto_field \
8166 #define foreach_udp_proto_field \
8170 #define foreach_ip4_proto_field \
8181 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8183 u8 **maskp = va_arg (*args, u8 **);
8185 u8 found_something = 0;
8188 #define _(a) u8 a=0;
8189 foreach_tcp_proto_field;
8192 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8195 #define _(a) else if (unformat (input, #a)) a=1;
8196 foreach_tcp_proto_field
8202 #define _(a) found_something += a;
8203 foreach_tcp_proto_field;
8206 if (found_something == 0)
8209 vec_validate (mask, sizeof (*tcp) - 1);
8211 tcp = (tcp_header_t *) mask;
8213 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8214 foreach_tcp_proto_field;
8222 unformat_udp_mask (unformat_input_t * input, va_list * args)
8224 u8 **maskp = va_arg (*args, u8 **);
8226 u8 found_something = 0;
8229 #define _(a) u8 a=0;
8230 foreach_udp_proto_field;
8233 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8236 #define _(a) else if (unformat (input, #a)) a=1;
8237 foreach_udp_proto_field
8243 #define _(a) found_something += a;
8244 foreach_udp_proto_field;
8247 if (found_something == 0)
8250 vec_validate (mask, sizeof (*udp) - 1);
8252 udp = (udp_header_t *) mask;
8254 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8255 foreach_udp_proto_field;
8264 u16 src_port, dst_port;
8268 unformat_l4_mask (unformat_input_t * input, va_list * args)
8270 u8 **maskp = va_arg (*args, u8 **);
8271 u16 src_port = 0, dst_port = 0;
8272 tcpudp_header_t *tcpudp;
8274 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8276 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8278 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8280 else if (unformat (input, "src_port"))
8282 else if (unformat (input, "dst_port"))
8288 if (!src_port && !dst_port)
8292 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8294 tcpudp = (tcpudp_header_t *) mask;
8295 tcpudp->src_port = src_port;
8296 tcpudp->dst_port = dst_port;
8304 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8306 u8 **maskp = va_arg (*args, u8 **);
8308 u8 found_something = 0;
8311 #define _(a) u8 a=0;
8312 foreach_ip4_proto_field;
8318 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8320 if (unformat (input, "version"))
8322 else if (unformat (input, "hdr_length"))
8324 else if (unformat (input, "src"))
8326 else if (unformat (input, "dst"))
8328 else if (unformat (input, "proto"))
8331 #define _(a) else if (unformat (input, #a)) a=1;
8332 foreach_ip4_proto_field
8338 #define _(a) found_something += a;
8339 foreach_ip4_proto_field;
8342 if (found_something == 0)
8345 vec_validate (mask, sizeof (*ip) - 1);
8347 ip = (ip4_header_t *) mask;
8349 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8350 foreach_ip4_proto_field;
8353 ip->ip_version_and_header_length = 0;
8356 ip->ip_version_and_header_length |= 0xF0;
8359 ip->ip_version_and_header_length |= 0x0F;
8365 #define foreach_ip6_proto_field \
8373 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8375 u8 **maskp = va_arg (*args, u8 **);
8377 u8 found_something = 0;
8379 u32 ip_version_traffic_class_and_flow_label;
8381 #define _(a) u8 a=0;
8382 foreach_ip6_proto_field;
8385 u8 traffic_class = 0;
8388 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8390 if (unformat (input, "version"))
8392 else if (unformat (input, "traffic-class"))
8394 else if (unformat (input, "flow-label"))
8396 else if (unformat (input, "src"))
8398 else if (unformat (input, "dst"))
8400 else if (unformat (input, "proto"))
8403 #define _(a) else if (unformat (input, #a)) a=1;
8404 foreach_ip6_proto_field
8410 #define _(a) found_something += a;
8411 foreach_ip6_proto_field;
8414 if (found_something == 0)
8417 vec_validate (mask, sizeof (*ip) - 1);
8419 ip = (ip6_header_t *) mask;
8421 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8422 foreach_ip6_proto_field;
8425 ip_version_traffic_class_and_flow_label = 0;
8428 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8431 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8434 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8436 ip->ip_version_traffic_class_and_flow_label =
8437 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8444 unformat_l3_mask (unformat_input_t * input, va_list * args)
8446 u8 **maskp = va_arg (*args, u8 **);
8448 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8450 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8452 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8461 unformat_l2_mask (unformat_input_t * input, va_list * args)
8463 u8 **maskp = va_arg (*args, u8 **);
8478 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8480 if (unformat (input, "src"))
8482 else if (unformat (input, "dst"))
8484 else if (unformat (input, "proto"))
8486 else if (unformat (input, "tag1"))
8488 else if (unformat (input, "tag2"))
8490 else if (unformat (input, "ignore-tag1"))
8492 else if (unformat (input, "ignore-tag2"))
8494 else if (unformat (input, "cos1"))
8496 else if (unformat (input, "cos2"))
8498 else if (unformat (input, "dot1q"))
8500 else if (unformat (input, "dot1ad"))
8505 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8506 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8509 if (tag1 || ignore_tag1 || cos1 || dot1q)
8511 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8514 vec_validate (mask, len - 1);
8517 memset (mask, 0xff, 6);
8520 memset (mask + 6, 0xff, 6);
8524 /* inner vlan tag */
8533 mask[21] = mask[20] = 0xff;
8554 mask[16] = mask[17] = 0xff;
8564 mask[12] = mask[13] = 0xff;
8571 unformat_classify_mask (unformat_input_t * input, va_list * args)
8573 u8 **maskp = va_arg (*args, u8 **);
8574 u32 *skipp = va_arg (*args, u32 *);
8575 u32 *matchp = va_arg (*args, u32 *);
8583 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8585 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8587 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8589 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8591 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
8605 if (mask || l2 || l3 || l4)
8609 /* "With a free Ethernet header in every package" */
8611 vec_validate (l2, 13);
8615 vec_append (mask, l3);
8620 vec_append (mask, l4);
8625 /* Scan forward looking for the first significant mask octet */
8626 for (i = 0; i < vec_len (mask); i++)
8630 /* compute (skip, match) params */
8631 *skipp = i / sizeof (u32x4);
8632 vec_delete (mask, *skipp * sizeof (u32x4), 0);
8634 /* Pad mask to an even multiple of the vector size */
8635 while (vec_len (mask) % sizeof (u32x4))
8638 match = vec_len (mask) / sizeof (u32x4);
8640 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
8642 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
8643 if (*tmp || *(tmp + 1))
8648 clib_warning ("BUG: match 0");
8650 _vec_len (mask) = match * sizeof (u32x4);
8661 #define foreach_l2_next \
8663 _(ethernet, ETHERNET_INPUT) \
8668 unformat_l2_next_index (unformat_input_t * input, va_list * args)
8670 u32 *miss_next_indexp = va_arg (*args, u32 *);
8675 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
8679 if (unformat (input, "%d", &tmp))
8688 *miss_next_indexp = next_index;
8692 #define foreach_ip_next \
8698 unformat_ip_next_index (unformat_input_t * input, va_list * args)
8700 u32 *miss_next_indexp = va_arg (*args, u32 *);
8705 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
8709 if (unformat (input, "%d", &tmp))
8718 *miss_next_indexp = next_index;
8722 #define foreach_acl_next \
8726 unformat_acl_next_index (unformat_input_t * input, va_list * args)
8728 u32 *miss_next_indexp = va_arg (*args, u32 *);
8733 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
8737 if (unformat (input, "permit"))
8742 else if (unformat (input, "%d", &tmp))
8751 *miss_next_indexp = next_index;
8756 unformat_policer_precolor (unformat_input_t * input, va_list * args)
8758 u32 *r = va_arg (*args, u32 *);
8760 if (unformat (input, "conform-color"))
8761 *r = POLICE_CONFORM;
8762 else if (unformat (input, "exceed-color"))
8771 api_classify_add_del_table (vat_main_t * vam)
8773 unformat_input_t *i = vam->input;
8774 vl_api_classify_add_del_table_t *mp;
8780 u32 table_index = ~0;
8781 u32 next_table_index = ~0;
8782 u32 miss_next_index = ~0;
8783 u32 memory_size = 32 << 20;
8786 u32 current_data_flag = 0;
8787 int current_data_offset = 0;
8789 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8791 if (unformat (i, "del"))
8793 else if (unformat (i, "buckets %d", &nbuckets))
8795 else if (unformat (i, "memory_size %d", &memory_size))
8797 else if (unformat (i, "skip %d", &skip))
8799 else if (unformat (i, "match %d", &match))
8801 else if (unformat (i, "table %d", &table_index))
8803 else if (unformat (i, "mask %U", unformat_classify_mask,
8804 &mask, &skip, &match))
8806 else if (unformat (i, "next-table %d", &next_table_index))
8808 else if (unformat (i, "miss-next %U", unformat_ip_next_index,
8811 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
8814 else if (unformat (i, "acl-miss-next %U", unformat_acl_next_index,
8817 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
8819 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
8825 if (is_add && mask == 0)
8827 errmsg ("Mask required\n");
8831 if (is_add && skip == ~0)
8833 errmsg ("skip count required\n");
8837 if (is_add && match == ~0)
8839 errmsg ("match count required\n");
8843 if (!is_add && table_index == ~0)
8845 errmsg ("table index required for delete\n");
8849 M2 (CLASSIFY_ADD_DEL_TABLE, classify_add_del_table, vec_len (mask));
8851 mp->is_add = is_add;
8852 mp->table_index = ntohl (table_index);
8853 mp->nbuckets = ntohl (nbuckets);
8854 mp->memory_size = ntohl (memory_size);
8855 mp->skip_n_vectors = ntohl (skip);
8856 mp->match_n_vectors = ntohl (match);
8857 mp->next_table_index = ntohl (next_table_index);
8858 mp->miss_next_index = ntohl (miss_next_index);
8859 mp->current_data_flag = ntohl (current_data_flag);
8860 mp->current_data_offset = ntohl (current_data_offset);
8861 clib_memcpy (mp->mask, mask, vec_len (mask));
8871 unformat_l4_match (unformat_input_t * input, va_list * args)
8873 u8 **matchp = va_arg (*args, u8 **);
8875 u8 *proto_header = 0;
8881 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8883 if (unformat (input, "src_port %d", &src_port))
8885 else if (unformat (input, "dst_port %d", &dst_port))
8891 h.src_port = clib_host_to_net_u16 (src_port);
8892 h.dst_port = clib_host_to_net_u16 (dst_port);
8893 vec_validate (proto_header, sizeof (h) - 1);
8894 memcpy (proto_header, &h, sizeof (h));
8896 *matchp = proto_header;
8902 unformat_ip4_match (unformat_input_t * input, va_list * args)
8904 u8 **matchp = va_arg (*args, u8 **);
8911 int src = 0, dst = 0;
8912 ip4_address_t src_val, dst_val;
8919 int fragment_id = 0;
8920 u32 fragment_id_val;
8926 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8928 if (unformat (input, "version %d", &version_val))
8930 else if (unformat (input, "hdr_length %d", &hdr_length_val))
8932 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
8934 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
8936 else if (unformat (input, "proto %d", &proto_val))
8938 else if (unformat (input, "tos %d", &tos_val))
8940 else if (unformat (input, "length %d", &length_val))
8942 else if (unformat (input, "fragment_id %d", &fragment_id_val))
8944 else if (unformat (input, "ttl %d", &ttl_val))
8946 else if (unformat (input, "checksum %d", &checksum_val))
8952 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
8953 + ttl + checksum == 0)
8957 * Aligned because we use the real comparison functions
8959 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
8961 ip = (ip4_header_t *) match;
8963 /* These are realistically matched in practice */
8965 ip->src_address.as_u32 = src_val.as_u32;
8968 ip->dst_address.as_u32 = dst_val.as_u32;
8971 ip->protocol = proto_val;
8974 /* These are not, but they're included for completeness */
8976 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
8979 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
8985 ip->length = clib_host_to_net_u16 (length_val);
8991 ip->checksum = clib_host_to_net_u16 (checksum_val);
8998 unformat_ip6_match (unformat_input_t * input, va_list * args)
9000 u8 **matchp = va_arg (*args, u8 **);
9005 u8 traffic_class = 0;
9006 u32 traffic_class_val = 0;
9009 int src = 0, dst = 0;
9010 ip6_address_t src_val, dst_val;
9013 int payload_length = 0;
9014 u32 payload_length_val;
9017 u32 ip_version_traffic_class_and_flow_label;
9019 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9021 if (unformat (input, "version %d", &version_val))
9023 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9025 else if (unformat (input, "flow_label %d", &flow_label_val))
9027 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9029 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9031 else if (unformat (input, "proto %d", &proto_val))
9033 else if (unformat (input, "payload_length %d", &payload_length_val))
9035 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9041 if (version + traffic_class + flow_label + src + dst + proto +
9042 payload_length + hop_limit == 0)
9046 * Aligned because we use the real comparison functions
9048 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9050 ip = (ip6_header_t *) match;
9053 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9056 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9059 ip->protocol = proto_val;
9061 ip_version_traffic_class_and_flow_label = 0;
9064 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9067 ip_version_traffic_class_and_flow_label |=
9068 (traffic_class_val & 0xFF) << 20;
9071 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9073 ip->ip_version_traffic_class_and_flow_label =
9074 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9077 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9080 ip->hop_limit = hop_limit_val;
9087 unformat_l3_match (unformat_input_t * input, va_list * args)
9089 u8 **matchp = va_arg (*args, u8 **);
9091 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9093 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9095 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9104 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9106 u8 *tagp = va_arg (*args, u8 *);
9109 if (unformat (input, "%d", &tag))
9111 tagp[0] = (tag >> 8) & 0x0F;
9112 tagp[1] = tag & 0xFF;
9120 unformat_l2_match (unformat_input_t * input, va_list * args)
9122 u8 **matchp = va_arg (*args, u8 **);
9142 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9144 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9147 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9149 else if (unformat (input, "proto %U",
9150 unformat_ethernet_type_host_byte_order, &proto_val))
9152 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9154 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9156 else if (unformat (input, "ignore-tag1"))
9158 else if (unformat (input, "ignore-tag2"))
9160 else if (unformat (input, "cos1 %d", &cos1_val))
9162 else if (unformat (input, "cos2 %d", &cos2_val))
9167 if ((src + dst + proto + tag1 + tag2 +
9168 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9171 if (tag1 || ignore_tag1 || cos1)
9173 if (tag2 || ignore_tag2 || cos2)
9176 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9179 clib_memcpy (match, dst_val, 6);
9182 clib_memcpy (match + 6, src_val, 6);
9186 /* inner vlan tag */
9187 match[19] = tag2_val[1];
9188 match[18] = tag2_val[0];
9190 match[18] |= (cos2_val & 0x7) << 5;
9193 match[21] = proto_val & 0xff;
9194 match[20] = proto_val >> 8;
9198 match[15] = tag1_val[1];
9199 match[14] = tag1_val[0];
9202 match[14] |= (cos1_val & 0x7) << 5;
9208 match[15] = tag1_val[1];
9209 match[14] = tag1_val[0];
9212 match[17] = proto_val & 0xff;
9213 match[16] = proto_val >> 8;
9216 match[14] |= (cos1_val & 0x7) << 5;
9222 match[18] |= (cos2_val & 0x7) << 5;
9224 match[14] |= (cos1_val & 0x7) << 5;
9227 match[13] = proto_val & 0xff;
9228 match[12] = proto_val >> 8;
9237 unformat_classify_match (unformat_input_t * input, va_list * args)
9239 u8 **matchp = va_arg (*args, u8 **);
9240 u32 skip_n_vectors = va_arg (*args, u32);
9241 u32 match_n_vectors = va_arg (*args, u32);
9248 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9250 if (unformat (input, "hex %U", unformat_hex_string, &match))
9252 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9254 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9256 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9270 if (match || l2 || l3 || l4)
9274 /* "Win a free Ethernet header in every packet" */
9276 vec_validate_aligned (l2, 13, sizeof (u32x4));
9280 vec_append_aligned (match, l3, sizeof (u32x4));
9285 vec_append_aligned (match, l4, sizeof (u32x4));
9290 /* Make sure the vector is big enough even if key is all 0's */
9291 vec_validate_aligned
9292 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9295 /* Set size, include skipped vectors */
9296 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9307 api_classify_add_del_session (vat_main_t * vam)
9309 unformat_input_t *i = vam->input;
9310 vl_api_classify_add_del_session_t *mp;
9312 u32 table_index = ~0;
9313 u32 hit_next_index = ~0;
9314 u32 opaque_index = ~0;
9318 u32 skip_n_vectors = 0;
9319 u32 match_n_vectors = 0;
9324 * Warning: you have to supply skip_n and match_n
9325 * because the API client cant simply look at the classify
9329 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9331 if (unformat (i, "del"))
9333 else if (unformat (i, "hit-next %U", unformat_ip_next_index,
9336 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9339 else if (unformat (i, "acl-hit-next %U", unformat_acl_next_index,
9342 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9344 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9346 else if (unformat (i, "opaque-index %d", &opaque_index))
9348 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9350 else if (unformat (i, "match_n %d", &match_n_vectors))
9352 else if (unformat (i, "match %U", unformat_classify_match,
9353 &match, skip_n_vectors, match_n_vectors))
9355 else if (unformat (i, "advance %d", &advance))
9357 else if (unformat (i, "table-index %d", &table_index))
9359 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9361 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9363 else if (unformat (i, "action %d", &action))
9365 else if (unformat (i, "metadata %d", &metadata))
9371 if (table_index == ~0)
9373 errmsg ("Table index required\n");
9377 if (is_add && match == 0)
9379 errmsg ("Match value required\n");
9383 M2 (CLASSIFY_ADD_DEL_SESSION, classify_add_del_session, vec_len (match));
9385 mp->is_add = is_add;
9386 mp->table_index = ntohl (table_index);
9387 mp->hit_next_index = ntohl (hit_next_index);
9388 mp->opaque_index = ntohl (opaque_index);
9389 mp->advance = ntohl (advance);
9390 mp->action = action;
9391 mp->metadata = ntohl (metadata);
9392 clib_memcpy (mp->match, match, vec_len (match));
9401 api_classify_set_interface_ip_table (vat_main_t * vam)
9403 unformat_input_t *i = vam->input;
9404 vl_api_classify_set_interface_ip_table_t *mp;
9407 int sw_if_index_set;
9408 u32 table_index = ~0;
9411 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9413 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9414 sw_if_index_set = 1;
9415 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9416 sw_if_index_set = 1;
9417 else if (unformat (i, "table %d", &table_index))
9421 clib_warning ("parse error '%U'", format_unformat_error, i);
9426 if (sw_if_index_set == 0)
9428 errmsg ("missing interface name or sw_if_index\n");
9433 M (CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table);
9435 mp->sw_if_index = ntohl (sw_if_index);
9436 mp->table_index = ntohl (table_index);
9437 mp->is_ipv6 = is_ipv6;
9446 api_classify_set_interface_l2_tables (vat_main_t * vam)
9448 unformat_input_t *i = vam->input;
9449 vl_api_classify_set_interface_l2_tables_t *mp;
9452 int sw_if_index_set;
9453 u32 ip4_table_index = ~0;
9454 u32 ip6_table_index = ~0;
9455 u32 other_table_index = ~0;
9458 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9460 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9461 sw_if_index_set = 1;
9462 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9463 sw_if_index_set = 1;
9464 else if (unformat (i, "ip4-table %d", &ip4_table_index))
9466 else if (unformat (i, "ip6-table %d", &ip6_table_index))
9468 else if (unformat (i, "other-table %d", &other_table_index))
9470 else if (unformat (i, "is-input %d", &is_input))
9474 clib_warning ("parse error '%U'", format_unformat_error, i);
9479 if (sw_if_index_set == 0)
9481 errmsg ("missing interface name or sw_if_index\n");
9486 M (CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables);
9488 mp->sw_if_index = ntohl (sw_if_index);
9489 mp->ip4_table_index = ntohl (ip4_table_index);
9490 mp->ip6_table_index = ntohl (ip6_table_index);
9491 mp->other_table_index = ntohl (other_table_index);
9492 mp->is_input = (u8) is_input;
9501 api_set_ipfix_exporter (vat_main_t * vam)
9503 unformat_input_t *i = vam->input;
9504 vl_api_set_ipfix_exporter_t *mp;
9505 ip4_address_t collector_address;
9506 u8 collector_address_set = 0;
9507 u32 collector_port = ~0;
9508 ip4_address_t src_address;
9509 u8 src_address_set = 0;
9512 u32 template_interval = ~0;
9513 u8 udp_checksum = 0;
9516 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9518 if (unformat (i, "collector_address %U", unformat_ip4_address,
9519 &collector_address))
9520 collector_address_set = 1;
9521 else if (unformat (i, "collector_port %d", &collector_port))
9523 else if (unformat (i, "src_address %U", unformat_ip4_address,
9525 src_address_set = 1;
9526 else if (unformat (i, "vrf_id %d", &vrf_id))
9528 else if (unformat (i, "path_mtu %d", &path_mtu))
9530 else if (unformat (i, "template_interval %d", &template_interval))
9532 else if (unformat (i, "udp_checksum"))
9538 if (collector_address_set == 0)
9540 errmsg ("collector_address required\n");
9544 if (src_address_set == 0)
9546 errmsg ("src_address required\n");
9550 M (SET_IPFIX_EXPORTER, set_ipfix_exporter);
9552 memcpy (mp->collector_address, collector_address.data,
9553 sizeof (collector_address.data));
9554 mp->collector_port = htons ((u16) collector_port);
9555 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
9556 mp->vrf_id = htonl (vrf_id);
9557 mp->path_mtu = htonl (path_mtu);
9558 mp->template_interval = htonl (template_interval);
9559 mp->udp_checksum = udp_checksum;
9567 api_set_ipfix_classify_stream (vat_main_t * vam)
9569 unformat_input_t *i = vam->input;
9570 vl_api_set_ipfix_classify_stream_t *mp;
9572 u32 src_port = UDP_DST_PORT_ipfix;
9575 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9577 if (unformat (i, "domain %d", &domain_id))
9579 else if (unformat (i, "src_port %d", &src_port))
9583 errmsg ("unknown input `%U'", format_unformat_error, i);
9588 M (SET_IPFIX_CLASSIFY_STREAM, set_ipfix_classify_stream);
9590 mp->domain_id = htonl (domain_id);
9591 mp->src_port = htons ((u16) src_port);
9599 api_ipfix_classify_table_add_del (vat_main_t * vam)
9601 unformat_input_t *i = vam->input;
9602 vl_api_ipfix_classify_table_add_del_t *mp;
9604 u32 classify_table_index = ~0;
9606 u8 transport_protocol = 255;
9609 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9611 if (unformat (i, "add"))
9613 else if (unformat (i, "del"))
9615 else if (unformat (i, "table %d", &classify_table_index))
9617 else if (unformat (i, "ip4"))
9619 else if (unformat (i, "ip6"))
9621 else if (unformat (i, "tcp"))
9622 transport_protocol = 6;
9623 else if (unformat (i, "udp"))
9624 transport_protocol = 17;
9627 errmsg ("unknown input `%U'", format_unformat_error, i);
9634 errmsg ("expecting: add|del");
9637 if (classify_table_index == ~0)
9639 errmsg ("classifier table not specified");
9642 if (ip_version == 0)
9644 errmsg ("IP version not specified");
9648 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, ipfix_classify_table_add_del);
9650 mp->is_add = is_add;
9651 mp->table_id = htonl (classify_table_index);
9652 mp->ip_version = ip_version;
9653 mp->transport_protocol = transport_protocol;
9661 api_get_node_index (vat_main_t * vam)
9663 unformat_input_t *i = vam->input;
9664 vl_api_get_node_index_t *mp;
9668 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9670 if (unformat (i, "node %s", &name))
9677 errmsg ("node name required\n");
9680 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9682 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9686 M (GET_NODE_INDEX, get_node_index);
9687 clib_memcpy (mp->node_name, name, vec_len (name));
9697 api_get_next_index (vat_main_t * vam)
9699 unformat_input_t *i = vam->input;
9700 vl_api_get_next_index_t *mp;
9702 u8 *node_name = 0, *next_node_name = 0;
9704 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9706 if (unformat (i, "node-name %s", &node_name))
9708 else if (unformat (i, "next-node-name %s", &next_node_name))
9714 errmsg ("node name required\n");
9717 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
9719 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9723 if (next_node_name == 0)
9725 errmsg ("next node name required\n");
9728 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
9730 errmsg ("next node name too long, max %d\n", ARRAY_LEN (mp->next_name));
9734 M (GET_NEXT_INDEX, get_next_index);
9735 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
9736 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
9737 vec_free (node_name);
9738 vec_free (next_node_name);
9747 api_add_node_next (vat_main_t * vam)
9749 unformat_input_t *i = vam->input;
9750 vl_api_add_node_next_t *mp;
9755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9757 if (unformat (i, "node %s", &name))
9759 else if (unformat (i, "next %s", &next))
9766 errmsg ("node name required\n");
9769 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9771 errmsg ("node name too long, max %d\n", ARRAY_LEN (mp->node_name));
9776 errmsg ("next node required\n");
9779 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
9781 errmsg ("next name too long, max %d\n", ARRAY_LEN (mp->next_name));
9785 M (ADD_NODE_NEXT, add_node_next);
9786 clib_memcpy (mp->node_name, name, vec_len (name));
9787 clib_memcpy (mp->next_name, next, vec_len (next));
9798 api_l2tpv3_create_tunnel (vat_main_t * vam)
9800 unformat_input_t *i = vam->input;
9801 ip6_address_t client_address, our_address;
9802 int client_address_set = 0;
9803 int our_address_set = 0;
9804 u32 local_session_id = 0;
9805 u32 remote_session_id = 0;
9806 u64 local_cookie = 0;
9807 u64 remote_cookie = 0;
9808 u8 l2_sublayer_present = 0;
9809 vl_api_l2tpv3_create_tunnel_t *mp;
9812 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9814 if (unformat (i, "client_address %U", unformat_ip6_address,
9816 client_address_set = 1;
9817 else if (unformat (i, "our_address %U", unformat_ip6_address,
9819 our_address_set = 1;
9820 else if (unformat (i, "local_session_id %d", &local_session_id))
9822 else if (unformat (i, "remote_session_id %d", &remote_session_id))
9824 else if (unformat (i, "local_cookie %lld", &local_cookie))
9826 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
9828 else if (unformat (i, "l2-sublayer-present"))
9829 l2_sublayer_present = 1;
9834 if (client_address_set == 0)
9836 errmsg ("client_address required\n");
9840 if (our_address_set == 0)
9842 errmsg ("our_address required\n");
9846 M (L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel);
9848 clib_memcpy (mp->client_address, client_address.as_u8,
9849 sizeof (mp->client_address));
9851 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
9853 mp->local_session_id = ntohl (local_session_id);
9854 mp->remote_session_id = ntohl (remote_session_id);
9855 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
9856 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
9857 mp->l2_sublayer_present = l2_sublayer_present;
9867 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
9869 unformat_input_t *i = vam->input;
9871 u8 sw_if_index_set = 0;
9872 u64 new_local_cookie = 0;
9873 u64 new_remote_cookie = 0;
9874 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
9877 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9879 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9880 sw_if_index_set = 1;
9881 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9882 sw_if_index_set = 1;
9883 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
9885 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
9891 if (sw_if_index_set == 0)
9893 errmsg ("missing interface name or sw_if_index\n");
9897 M (L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies);
9899 mp->sw_if_index = ntohl (sw_if_index);
9900 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
9901 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
9910 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
9912 unformat_input_t *i = vam->input;
9913 vl_api_l2tpv3_interface_enable_disable_t *mp;
9916 u8 sw_if_index_set = 0;
9917 u8 enable_disable = 1;
9919 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9921 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
9922 sw_if_index_set = 1;
9923 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9924 sw_if_index_set = 1;
9925 else if (unformat (i, "enable"))
9927 else if (unformat (i, "disable"))
9933 if (sw_if_index_set == 0)
9935 errmsg ("missing interface name or sw_if_index\n");
9939 M (L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable);
9941 mp->sw_if_index = ntohl (sw_if_index);
9942 mp->enable_disable = enable_disable;
9951 api_l2tpv3_set_lookup_key (vat_main_t * vam)
9953 unformat_input_t *i = vam->input;
9954 vl_api_l2tpv3_set_lookup_key_t *mp;
9958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9960 if (unformat (i, "lookup_v6_src"))
9961 key = L2T_LOOKUP_SRC_ADDRESS;
9962 else if (unformat (i, "lookup_v6_dst"))
9963 key = L2T_LOOKUP_DST_ADDRESS;
9964 else if (unformat (i, "lookup_session_id"))
9965 key = L2T_LOOKUP_SESSION_ID;
9970 if (key == (u8) ~ 0)
9972 errmsg ("l2tp session lookup key unset\n");
9976 M (L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key);
9986 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
9987 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
9989 vat_main_t *vam = &vat_main;
9991 fformat (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)\n",
9992 format_ip6_address, mp->our_address,
9993 format_ip6_address, mp->client_address,
9994 clib_net_to_host_u32 (mp->sw_if_index));
9997 " local cookies %016llx %016llx remote cookie %016llx\n",
9998 clib_net_to_host_u64 (mp->local_cookie[0]),
9999 clib_net_to_host_u64 (mp->local_cookie[1]),
10000 clib_net_to_host_u64 (mp->remote_cookie));
10002 fformat (vam->ofp, " local session-id %d remote session-id %d\n",
10003 clib_net_to_host_u32 (mp->local_session_id),
10004 clib_net_to_host_u32 (mp->remote_session_id));
10006 fformat (vam->ofp, " l2 specific sublayer %s\n\n",
10007 mp->l2_sublayer_present ? "preset" : "absent");
10011 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10012 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10014 vat_main_t *vam = &vat_main;
10015 vat_json_node_t *node = NULL;
10016 struct in6_addr addr;
10018 if (VAT_JSON_ARRAY != vam->json_tree.type)
10020 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10021 vat_json_init_array (&vam->json_tree);
10023 node = vat_json_array_add (&vam->json_tree);
10025 vat_json_init_object (node);
10027 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10028 vat_json_object_add_ip6 (node, "our_address", addr);
10029 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10030 vat_json_object_add_ip6 (node, "client_address", addr);
10032 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10033 vat_json_init_array (lc);
10034 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10035 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10036 vat_json_object_add_uint (node, "remote_cookie",
10037 clib_net_to_host_u64 (mp->remote_cookie));
10039 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10040 vat_json_object_add_uint (node, "local_session_id",
10041 clib_net_to_host_u32 (mp->local_session_id));
10042 vat_json_object_add_uint (node, "remote_session_id",
10043 clib_net_to_host_u32 (mp->remote_session_id));
10044 vat_json_object_add_string_copy (node, "l2_sublayer",
10045 mp->l2_sublayer_present ? (u8 *) "present"
10046 : (u8 *) "absent");
10050 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10052 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10055 /* Get list of l2tpv3-tunnel interfaces */
10056 M (SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump);
10059 /* Use a control ping for synchronization */
10061 vl_api_control_ping_t *mp;
10062 M (CONTROL_PING, control_ping);
10069 static void vl_api_sw_interface_tap_details_t_handler
10070 (vl_api_sw_interface_tap_details_t * mp)
10072 vat_main_t *vam = &vat_main;
10074 fformat (vam->ofp, "%-16s %d\n",
10075 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10078 static void vl_api_sw_interface_tap_details_t_handler_json
10079 (vl_api_sw_interface_tap_details_t * mp)
10081 vat_main_t *vam = &vat_main;
10082 vat_json_node_t *node = NULL;
10084 if (VAT_JSON_ARRAY != vam->json_tree.type)
10086 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10087 vat_json_init_array (&vam->json_tree);
10089 node = vat_json_array_add (&vam->json_tree);
10091 vat_json_init_object (node);
10092 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10093 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10097 api_sw_interface_tap_dump (vat_main_t * vam)
10099 vl_api_sw_interface_tap_dump_t *mp;
10102 fformat (vam->ofp, "\n%-16s %s\n", "dev_name", "sw_if_index");
10103 /* Get list of tap interfaces */
10104 M (SW_INTERFACE_TAP_DUMP, sw_interface_tap_dump);
10107 /* Use a control ping for synchronization */
10109 vl_api_control_ping_t *mp;
10110 M (CONTROL_PING, control_ping);
10116 static uword unformat_vxlan_decap_next
10117 (unformat_input_t * input, va_list * args)
10119 u32 *result = va_arg (*args, u32 *);
10122 if (unformat (input, "l2"))
10123 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10124 else if (unformat (input, "%d", &tmp))
10132 api_vxlan_add_del_tunnel (vat_main_t * vam)
10134 unformat_input_t *line_input = vam->input;
10135 vl_api_vxlan_add_del_tunnel_t *mp;
10137 ip46_address_t src, dst;
10139 u8 ipv4_set = 0, ipv6_set = 0;
10143 u32 mcast_sw_if_index = ~0;
10144 u32 encap_vrf_id = 0;
10145 u32 decap_next_index = ~0;
10148 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10149 memset (&src, 0, sizeof src);
10150 memset (&dst, 0, sizeof dst);
10152 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10154 if (unformat (line_input, "del"))
10157 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10163 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10169 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10175 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10180 else if (unformat (line_input, "group %U %U",
10181 unformat_ip4_address, &dst.ip4,
10182 unformat_sw_if_index, vam, &mcast_sw_if_index))
10184 grp_set = dst_set = 1;
10187 else if (unformat (line_input, "group %U",
10188 unformat_ip4_address, &dst.ip4))
10190 grp_set = dst_set = 1;
10193 else if (unformat (line_input, "group %U %U",
10194 unformat_ip6_address, &dst.ip6,
10195 unformat_sw_if_index, vam, &mcast_sw_if_index))
10197 grp_set = dst_set = 1;
10200 else if (unformat (line_input, "group %U",
10201 unformat_ip6_address, &dst.ip6))
10203 grp_set = dst_set = 1;
10207 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10209 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10211 else if (unformat (line_input, "decap-next %U",
10212 unformat_vxlan_decap_next, &decap_next_index))
10214 else if (unformat (line_input, "vni %d", &vni))
10218 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
10225 errmsg ("tunnel src address not specified\n");
10230 errmsg ("tunnel dst address not specified\n");
10234 if (grp_set && !ip46_address_is_multicast (&dst))
10236 errmsg ("tunnel group address not multicast\n");
10239 if (grp_set && mcast_sw_if_index == ~0)
10241 errmsg ("tunnel nonexistent multicast device\n");
10246 if (ipv4_set && ipv6_set)
10248 errmsg ("both IPv4 and IPv6 addresses specified");
10252 if ((vni == 0) || (vni >> 24))
10254 errmsg ("vni not specified or out of range\n");
10258 M (VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel);
10262 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10263 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10267 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10268 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10270 mp->encap_vrf_id = ntohl (encap_vrf_id);
10271 mp->decap_next_index = ntohl (decap_next_index);
10272 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10273 mp->vni = ntohl (vni);
10274 mp->is_add = is_add;
10275 mp->is_ipv6 = ipv6_set;
10283 static void vl_api_vxlan_tunnel_details_t_handler
10284 (vl_api_vxlan_tunnel_details_t * mp)
10286 vat_main_t *vam = &vat_main;
10287 ip46_address_t src, dst;
10289 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10290 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10292 fformat (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d\n",
10293 ntohl (mp->sw_if_index),
10294 format_ip46_address, &src, IP46_TYPE_ANY,
10295 format_ip46_address, &dst, IP46_TYPE_ANY,
10296 ntohl (mp->encap_vrf_id),
10297 ntohl (mp->decap_next_index), ntohl (mp->vni),
10298 ntohl (mp->mcast_sw_if_index));
10301 static void vl_api_vxlan_tunnel_details_t_handler_json
10302 (vl_api_vxlan_tunnel_details_t * mp)
10304 vat_main_t *vam = &vat_main;
10305 vat_json_node_t *node = NULL;
10307 if (VAT_JSON_ARRAY != vam->json_tree.type)
10309 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10310 vat_json_init_array (&vam->json_tree);
10312 node = vat_json_array_add (&vam->json_tree);
10314 vat_json_init_object (node);
10315 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10318 struct in6_addr ip6;
10320 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10321 vat_json_object_add_ip6 (node, "src_address", ip6);
10322 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10323 vat_json_object_add_ip6 (node, "dst_address", ip6);
10327 struct in_addr ip4;
10329 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10330 vat_json_object_add_ip4 (node, "src_address", ip4);
10331 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10332 vat_json_object_add_ip4 (node, "dst_address", ip4);
10334 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10335 vat_json_object_add_uint (node, "decap_next_index",
10336 ntohl (mp->decap_next_index));
10337 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10338 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10339 vat_json_object_add_uint (node, "mcast_sw_if_index",
10340 ntohl (mp->mcast_sw_if_index));
10344 api_vxlan_tunnel_dump (vat_main_t * vam)
10346 unformat_input_t *i = vam->input;
10347 vl_api_vxlan_tunnel_dump_t *mp;
10350 u8 sw_if_index_set = 0;
10352 /* Parse args required to build the message */
10353 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10355 if (unformat (i, "sw_if_index %d", &sw_if_index))
10356 sw_if_index_set = 1;
10361 if (sw_if_index_set == 0)
10366 if (!vam->json_output)
10368 fformat (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s\n",
10369 "sw_if_index", "src_address", "dst_address",
10370 "encap_vrf_id", "decap_next_index", "vni",
10371 "mcast_sw_if_index");
10374 /* Get list of vxlan-tunnel interfaces */
10375 M (VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump);
10377 mp->sw_if_index = htonl (sw_if_index);
10381 /* Use a control ping for synchronization */
10383 vl_api_control_ping_t *mp;
10384 M (CONTROL_PING, control_ping);
10391 api_gre_add_del_tunnel (vat_main_t * vam)
10393 unformat_input_t *line_input = vam->input;
10394 vl_api_gre_add_del_tunnel_t *mp;
10396 ip4_address_t src4, dst4;
10401 u32 outer_fib_id = 0;
10403 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10405 if (unformat (line_input, "del"))
10407 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10409 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10411 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10413 else if (unformat (line_input, "teb"))
10417 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
10424 errmsg ("tunnel src address not specified\n");
10429 errmsg ("tunnel dst address not specified\n");
10434 M (GRE_ADD_DEL_TUNNEL, gre_add_del_tunnel);
10436 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10437 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10438 mp->outer_fib_id = ntohl (outer_fib_id);
10439 mp->is_add = is_add;
10448 static void vl_api_gre_tunnel_details_t_handler
10449 (vl_api_gre_tunnel_details_t * mp)
10451 vat_main_t *vam = &vat_main;
10453 fformat (vam->ofp, "%11d%15U%15U%6d%14d\n",
10454 ntohl (mp->sw_if_index),
10455 format_ip4_address, &mp->src_address,
10456 format_ip4_address, &mp->dst_address,
10457 mp->teb, ntohl (mp->outer_fib_id));
10460 static void vl_api_gre_tunnel_details_t_handler_json
10461 (vl_api_gre_tunnel_details_t * mp)
10463 vat_main_t *vam = &vat_main;
10464 vat_json_node_t *node = NULL;
10465 struct in_addr ip4;
10467 if (VAT_JSON_ARRAY != vam->json_tree.type)
10469 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10470 vat_json_init_array (&vam->json_tree);
10472 node = vat_json_array_add (&vam->json_tree);
10474 vat_json_init_object (node);
10475 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10476 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10477 vat_json_object_add_ip4 (node, "src_address", ip4);
10478 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10479 vat_json_object_add_ip4 (node, "dst_address", ip4);
10480 vat_json_object_add_uint (node, "teb", mp->teb);
10481 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10485 api_gre_tunnel_dump (vat_main_t * vam)
10487 unformat_input_t *i = vam->input;
10488 vl_api_gre_tunnel_dump_t *mp;
10491 u8 sw_if_index_set = 0;
10493 /* Parse args required to build the message */
10494 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10496 if (unformat (i, "sw_if_index %d", &sw_if_index))
10497 sw_if_index_set = 1;
10502 if (sw_if_index_set == 0)
10507 if (!vam->json_output)
10509 fformat (vam->ofp, "%11s%15s%15s%6s%14s\n",
10510 "sw_if_index", "src_address", "dst_address", "teb",
10514 /* Get list of gre-tunnel interfaces */
10515 M (GRE_TUNNEL_DUMP, gre_tunnel_dump);
10517 mp->sw_if_index = htonl (sw_if_index);
10521 /* Use a control ping for synchronization */
10523 vl_api_control_ping_t *mp;
10524 M (CONTROL_PING, control_ping);
10531 api_l2_fib_clear_table (vat_main_t * vam)
10533 // unformat_input_t * i = vam->input;
10534 vl_api_l2_fib_clear_table_t *mp;
10537 M (L2_FIB_CLEAR_TABLE, l2_fib_clear_table);
10546 api_l2_interface_efp_filter (vat_main_t * vam)
10548 unformat_input_t *i = vam->input;
10549 vl_api_l2_interface_efp_filter_t *mp;
10553 u8 sw_if_index_set = 0;
10555 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10557 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10558 sw_if_index_set = 1;
10559 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10560 sw_if_index_set = 1;
10561 else if (unformat (i, "enable"))
10563 else if (unformat (i, "disable"))
10567 clib_warning ("parse error '%U'", format_unformat_error, i);
10572 if (sw_if_index_set == 0)
10574 errmsg ("missing sw_if_index\n");
10578 M (L2_INTERFACE_EFP_FILTER, l2_interface_efp_filter);
10580 mp->sw_if_index = ntohl (sw_if_index);
10581 mp->enable_disable = enable;
10589 #define foreach_vtr_op \
10590 _("disable", L2_VTR_DISABLED) \
10591 _("push-1", L2_VTR_PUSH_1) \
10592 _("push-2", L2_VTR_PUSH_2) \
10593 _("pop-1", L2_VTR_POP_1) \
10594 _("pop-2", L2_VTR_POP_2) \
10595 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10596 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10597 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10598 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10601 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10603 unformat_input_t *i = vam->input;
10604 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
10607 u8 sw_if_index_set = 0;
10610 u32 push_dot1q = 1;
10614 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10616 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10617 sw_if_index_set = 1;
10618 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10619 sw_if_index_set = 1;
10620 else if (unformat (i, "vtr_op %d", &vtr_op))
10622 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
10625 else if (unformat (i, "push_dot1q %d", &push_dot1q))
10627 else if (unformat (i, "tag1 %d", &tag1))
10629 else if (unformat (i, "tag2 %d", &tag2))
10633 clib_warning ("parse error '%U'", format_unformat_error, i);
10638 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
10640 errmsg ("missing vtr operation or sw_if_index\n");
10644 M (L2_INTERFACE_VLAN_TAG_REWRITE, l2_interface_vlan_tag_rewrite)
10645 mp->sw_if_index = ntohl (sw_if_index);
10646 mp->vtr_op = ntohl (vtr_op);
10647 mp->push_dot1q = ntohl (push_dot1q);
10648 mp->tag1 = ntohl (tag1);
10649 mp->tag2 = ntohl (tag2);
10658 api_create_vhost_user_if (vat_main_t * vam)
10660 unformat_input_t *i = vam->input;
10661 vl_api_create_vhost_user_if_t *mp;
10665 u8 file_name_set = 0;
10666 u32 custom_dev_instance = ~0;
10668 u8 use_custom_mac = 0;
10670 /* Shut up coverity */
10671 memset (hwaddr, 0, sizeof (hwaddr));
10673 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10675 if (unformat (i, "socket %s", &file_name))
10679 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10681 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
10682 use_custom_mac = 1;
10683 else if (unformat (i, "server"))
10689 if (file_name_set == 0)
10691 errmsg ("missing socket file name\n");
10695 if (vec_len (file_name) > 255)
10697 errmsg ("socket file name too long\n");
10700 vec_add1 (file_name, 0);
10702 M (CREATE_VHOST_USER_IF, create_vhost_user_if);
10704 mp->is_server = is_server;
10705 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10706 vec_free (file_name);
10707 if (custom_dev_instance != ~0)
10710 mp->custom_dev_instance = ntohl (custom_dev_instance);
10712 mp->use_custom_mac = use_custom_mac;
10713 clib_memcpy (mp->mac_address, hwaddr, 6);
10722 api_modify_vhost_user_if (vat_main_t * vam)
10724 unformat_input_t *i = vam->input;
10725 vl_api_modify_vhost_user_if_t *mp;
10729 u8 file_name_set = 0;
10730 u32 custom_dev_instance = ~0;
10731 u8 sw_if_index_set = 0;
10732 u32 sw_if_index = (u32) ~ 0;
10734 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10736 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10737 sw_if_index_set = 1;
10738 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10739 sw_if_index_set = 1;
10740 else if (unformat (i, "socket %s", &file_name))
10744 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10746 else if (unformat (i, "server"))
10752 if (sw_if_index_set == 0)
10754 errmsg ("missing sw_if_index or interface name\n");
10758 if (file_name_set == 0)
10760 errmsg ("missing socket file name\n");
10764 if (vec_len (file_name) > 255)
10766 errmsg ("socket file name too long\n");
10769 vec_add1 (file_name, 0);
10771 M (MODIFY_VHOST_USER_IF, modify_vhost_user_if);
10773 mp->sw_if_index = ntohl (sw_if_index);
10774 mp->is_server = is_server;
10775 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10776 vec_free (file_name);
10777 if (custom_dev_instance != ~0)
10780 mp->custom_dev_instance = ntohl (custom_dev_instance);
10790 api_delete_vhost_user_if (vat_main_t * vam)
10792 unformat_input_t *i = vam->input;
10793 vl_api_delete_vhost_user_if_t *mp;
10795 u32 sw_if_index = ~0;
10796 u8 sw_if_index_set = 0;
10798 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10800 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
10801 sw_if_index_set = 1;
10802 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10803 sw_if_index_set = 1;
10808 if (sw_if_index_set == 0)
10810 errmsg ("missing sw_if_index or interface name\n");
10815 M (DELETE_VHOST_USER_IF, delete_vhost_user_if);
10817 mp->sw_if_index = ntohl (sw_if_index);
10825 static void vl_api_sw_interface_vhost_user_details_t_handler
10826 (vl_api_sw_interface_vhost_user_details_t * mp)
10828 vat_main_t *vam = &vat_main;
10830 fformat (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s\n",
10831 (char *) mp->interface_name,
10832 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
10833 clib_net_to_host_u64 (mp->features), mp->is_server,
10834 ntohl (mp->num_regions), (char *) mp->sock_filename);
10835 fformat (vam->ofp, " Status: '%s'\n", strerror (ntohl (mp->sock_errno)));
10838 static void vl_api_sw_interface_vhost_user_details_t_handler_json
10839 (vl_api_sw_interface_vhost_user_details_t * mp)
10841 vat_main_t *vam = &vat_main;
10842 vat_json_node_t *node = NULL;
10844 if (VAT_JSON_ARRAY != vam->json_tree.type)
10846 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10847 vat_json_init_array (&vam->json_tree);
10849 node = vat_json_array_add (&vam->json_tree);
10851 vat_json_init_object (node);
10852 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10853 vat_json_object_add_string_copy (node, "interface_name",
10854 mp->interface_name);
10855 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
10856 ntohl (mp->virtio_net_hdr_sz));
10857 vat_json_object_add_uint (node, "features",
10858 clib_net_to_host_u64 (mp->features));
10859 vat_json_object_add_uint (node, "is_server", mp->is_server);
10860 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
10861 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
10862 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
10866 api_sw_interface_vhost_user_dump (vat_main_t * vam)
10868 vl_api_sw_interface_vhost_user_dump_t *mp;
10871 "Interface name idx hdr_sz features server regions filename\n");
10873 /* Get list of vhost-user interfaces */
10874 M (SW_INTERFACE_VHOST_USER_DUMP, sw_interface_vhost_user_dump);
10877 /* Use a control ping for synchronization */
10879 vl_api_control_ping_t *mp;
10880 M (CONTROL_PING, control_ping);
10887 api_show_version (vat_main_t * vam)
10889 vl_api_show_version_t *mp;
10892 M (SHOW_VERSION, show_version);
10902 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
10904 unformat_input_t *line_input = vam->input;
10905 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
10907 ip4_address_t local4, remote4;
10908 ip6_address_t local6, remote6;
10910 u8 ipv4_set = 0, ipv6_set = 0;
10913 u32 encap_vrf_id = 0;
10914 u32 decap_vrf_id = 0;
10919 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10921 if (unformat (line_input, "del"))
10923 else if (unformat (line_input, "local %U",
10924 unformat_ip4_address, &local4))
10929 else if (unformat (line_input, "remote %U",
10930 unformat_ip4_address, &remote4))
10935 else if (unformat (line_input, "local %U",
10936 unformat_ip6_address, &local6))
10941 else if (unformat (line_input, "remote %U",
10942 unformat_ip6_address, &remote6))
10947 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10949 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
10951 else if (unformat (line_input, "vni %d", &vni))
10953 else if (unformat (line_input, "next-ip4"))
10955 else if (unformat (line_input, "next-ip6"))
10957 else if (unformat (line_input, "next-ethernet"))
10959 else if (unformat (line_input, "next-nsh"))
10963 errmsg ("parse error '%U'\n", format_unformat_error, line_input);
10968 if (local_set == 0)
10970 errmsg ("tunnel local address not specified\n");
10973 if (remote_set == 0)
10975 errmsg ("tunnel remote address not specified\n");
10978 if (ipv4_set && ipv6_set)
10980 errmsg ("both IPv4 and IPv6 addresses specified");
10986 errmsg ("vni not specified\n");
10990 M (VXLAN_GPE_ADD_DEL_TUNNEL, vxlan_gpe_add_del_tunnel);
10995 clib_memcpy (&mp->local, &local6, sizeof (local6));
10996 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11000 clib_memcpy (&mp->local, &local4, sizeof (local4));
11001 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11004 mp->encap_vrf_id = ntohl (encap_vrf_id);
11005 mp->decap_vrf_id = ntohl (decap_vrf_id);
11006 mp->protocol = ntohl (protocol);
11007 mp->vni = ntohl (vni);
11008 mp->is_add = is_add;
11009 mp->is_ipv6 = ipv6_set;
11017 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11018 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11020 vat_main_t *vam = &vat_main;
11022 fformat (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d\n",
11023 ntohl (mp->sw_if_index),
11024 format_ip46_address, &(mp->local[0]),
11025 format_ip46_address, &(mp->remote[0]),
11027 ntohl (mp->protocol),
11028 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11031 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11032 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11034 vat_main_t *vam = &vat_main;
11035 vat_json_node_t *node = NULL;
11036 struct in_addr ip4;
11037 struct in6_addr ip6;
11039 if (VAT_JSON_ARRAY != vam->json_tree.type)
11041 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11042 vat_json_init_array (&vam->json_tree);
11044 node = vat_json_array_add (&vam->json_tree);
11046 vat_json_init_object (node);
11047 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11050 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11051 vat_json_object_add_ip6 (node, "local", ip6);
11052 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11053 vat_json_object_add_ip6 (node, "remote", ip6);
11057 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11058 vat_json_object_add_ip4 (node, "local", ip4);
11059 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11060 vat_json_object_add_ip4 (node, "remote", ip4);
11062 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11063 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11064 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11065 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11066 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11070 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11072 unformat_input_t *i = vam->input;
11073 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11076 u8 sw_if_index_set = 0;
11078 /* Parse args required to build the message */
11079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11081 if (unformat (i, "sw_if_index %d", &sw_if_index))
11082 sw_if_index_set = 1;
11087 if (sw_if_index_set == 0)
11092 if (!vam->json_output)
11094 fformat (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s\n",
11095 "sw_if_index", "local", "remote", "vni",
11096 "protocol", "encap_vrf_id", "decap_vrf_id");
11099 /* Get list of vxlan-tunnel interfaces */
11100 M (VXLAN_GPE_TUNNEL_DUMP, vxlan_gpe_tunnel_dump);
11102 mp->sw_if_index = htonl (sw_if_index);
11106 /* Use a control ping for synchronization */
11108 vl_api_control_ping_t *mp;
11109 M (CONTROL_PING, control_ping);
11116 format_l2_fib_mac_address (u8 * s, va_list * args)
11118 u8 *a = va_arg (*args, u8 *);
11120 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11121 a[2], a[3], a[4], a[5], a[6], a[7]);
11124 static void vl_api_l2_fib_table_entry_t_handler
11125 (vl_api_l2_fib_table_entry_t * mp)
11127 vat_main_t *vam = &vat_main;
11129 fformat (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11131 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11132 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11136 static void vl_api_l2_fib_table_entry_t_handler_json
11137 (vl_api_l2_fib_table_entry_t * mp)
11139 vat_main_t *vam = &vat_main;
11140 vat_json_node_t *node = NULL;
11142 if (VAT_JSON_ARRAY != vam->json_tree.type)
11144 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11145 vat_json_init_array (&vam->json_tree);
11147 node = vat_json_array_add (&vam->json_tree);
11149 vat_json_init_object (node);
11150 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11151 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11152 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11153 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11154 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11155 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11159 api_l2_fib_table_dump (vat_main_t * vam)
11161 unformat_input_t *i = vam->input;
11162 vl_api_l2_fib_table_dump_t *mp;
11167 /* Parse args required to build the message */
11168 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11170 if (unformat (i, "bd_id %d", &bd_id))
11176 if (bd_id_set == 0)
11178 errmsg ("missing bridge domain\n");
11183 "BD-ID Mac Address sw-ndx Static Filter BVI\n");
11185 /* Get list of l2 fib entries */
11186 M (L2_FIB_TABLE_DUMP, l2_fib_table_dump);
11188 mp->bd_id = ntohl (bd_id);
11191 /* Use a control ping for synchronization */
11193 vl_api_control_ping_t *mp;
11194 M (CONTROL_PING, control_ping);
11202 api_interface_name_renumber (vat_main_t * vam)
11204 unformat_input_t *line_input = vam->input;
11205 vl_api_interface_name_renumber_t *mp;
11206 u32 sw_if_index = ~0;
11208 u32 new_show_dev_instance = ~0;
11210 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11212 if (unformat (line_input, "%U", unformat_sw_if_index, vam,
11215 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11217 else if (unformat (line_input, "new_show_dev_instance %d",
11218 &new_show_dev_instance))
11224 if (sw_if_index == ~0)
11226 errmsg ("missing interface name or sw_if_index\n");
11230 if (new_show_dev_instance == ~0)
11232 errmsg ("missing new_show_dev_instance\n");
11236 M (INTERFACE_NAME_RENUMBER, interface_name_renumber);
11238 mp->sw_if_index = ntohl (sw_if_index);
11239 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11246 api_want_ip4_arp_events (vat_main_t * vam)
11248 unformat_input_t *line_input = vam->input;
11249 vl_api_want_ip4_arp_events_t *mp;
11251 ip4_address_t address;
11252 int address_set = 0;
11253 u32 enable_disable = 1;
11255 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11257 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11259 else if (unformat (line_input, "del"))
11260 enable_disable = 0;
11265 if (address_set == 0)
11267 errmsg ("missing addresses\n");
11271 M (WANT_IP4_ARP_EVENTS, want_ip4_arp_events);
11272 mp->enable_disable = enable_disable;
11273 mp->pid = getpid ();
11274 mp->address = address.as_u32;
11281 api_want_ip6_nd_events (vat_main_t * vam)
11283 unformat_input_t *line_input = vam->input;
11284 vl_api_want_ip6_nd_events_t *mp;
11286 ip6_address_t address;
11287 int address_set = 0;
11288 u32 enable_disable = 1;
11290 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11292 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11294 else if (unformat (line_input, "del"))
11295 enable_disable = 0;
11300 if (address_set == 0)
11302 errmsg ("missing addresses\n");
11306 M (WANT_IP6_ND_EVENTS, want_ip6_nd_events);
11307 mp->enable_disable = enable_disable;
11308 mp->pid = getpid ();
11309 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11316 api_input_acl_set_interface (vat_main_t * vam)
11318 unformat_input_t *i = vam->input;
11319 vl_api_input_acl_set_interface_t *mp;
11322 int sw_if_index_set;
11323 u32 ip4_table_index = ~0;
11324 u32 ip6_table_index = ~0;
11325 u32 l2_table_index = ~0;
11328 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11330 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
11331 sw_if_index_set = 1;
11332 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11333 sw_if_index_set = 1;
11334 else if (unformat (i, "del"))
11336 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11338 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11340 else if (unformat (i, "l2-table %d", &l2_table_index))
11344 clib_warning ("parse error '%U'", format_unformat_error, i);
11349 if (sw_if_index_set == 0)
11351 errmsg ("missing interface name or sw_if_index\n");
11355 M (INPUT_ACL_SET_INTERFACE, input_acl_set_interface);
11357 mp->sw_if_index = ntohl (sw_if_index);
11358 mp->ip4_table_index = ntohl (ip4_table_index);
11359 mp->ip6_table_index = ntohl (ip6_table_index);
11360 mp->l2_table_index = ntohl (l2_table_index);
11361 mp->is_add = is_add;
11370 api_ip_address_dump (vat_main_t * vam)
11372 unformat_input_t *i = vam->input;
11373 vl_api_ip_address_dump_t *mp;
11374 u32 sw_if_index = ~0;
11375 u8 sw_if_index_set = 0;
11380 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11382 if (unformat (i, "sw_if_index %d", &sw_if_index))
11383 sw_if_index_set = 1;
11384 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
11385 sw_if_index_set = 1;
11386 else if (unformat (i, "ipv4"))
11388 else if (unformat (i, "ipv6"))
11394 if (ipv4_set && ipv6_set)
11396 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
11400 if ((!ipv4_set) && (!ipv6_set))
11402 errmsg ("no ipv4 nor ipv6 flag set\n");
11406 if (sw_if_index_set == 0)
11408 errmsg ("missing interface name or sw_if_index\n");
11412 vam->current_sw_if_index = sw_if_index;
11413 vam->is_ipv6 = ipv6_set;
11415 M (IP_ADDRESS_DUMP, ip_address_dump);
11416 mp->sw_if_index = ntohl (sw_if_index);
11417 mp->is_ipv6 = ipv6_set;
11420 /* Use a control ping for synchronization */
11422 vl_api_control_ping_t *mp;
11423 M (CONTROL_PING, control_ping);
11430 api_ip_dump (vat_main_t * vam)
11432 vl_api_ip_dump_t *mp;
11433 unformat_input_t *in = vam->input;
11440 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11442 if (unformat (in, "ipv4"))
11444 else if (unformat (in, "ipv6"))
11450 if (ipv4_set && ipv6_set)
11452 errmsg ("ipv4 and ipv6 flags cannot be both set\n");
11456 if ((!ipv4_set) && (!ipv6_set))
11458 errmsg ("no ipv4 nor ipv6 flag set\n");
11462 is_ipv6 = ipv6_set;
11463 vam->is_ipv6 = is_ipv6;
11465 /* free old data */
11466 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11468 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11470 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11472 M (IP_DUMP, ip_dump);
11473 mp->is_ipv6 = ipv6_set;
11476 /* Use a control ping for synchronization */
11478 vl_api_control_ping_t *mp;
11479 M (CONTROL_PING, control_ping);
11486 api_ipsec_spd_add_del (vat_main_t * vam)
11488 unformat_input_t *i = vam->input;
11489 vl_api_ipsec_spd_add_del_t *mp;
11494 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11496 if (unformat (i, "spd_id %d", &spd_id))
11498 else if (unformat (i, "del"))
11502 clib_warning ("parse error '%U'", format_unformat_error, i);
11508 errmsg ("spd_id must be set\n");
11512 M (IPSEC_SPD_ADD_DEL, ipsec_spd_add_del);
11514 mp->spd_id = ntohl (spd_id);
11515 mp->is_add = is_add;
11524 api_ipsec_interface_add_del_spd (vat_main_t * vam)
11526 unformat_input_t *i = vam->input;
11527 vl_api_ipsec_interface_add_del_spd_t *mp;
11530 u8 sw_if_index_set = 0;
11531 u32 spd_id = (u32) ~ 0;
11534 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11536 if (unformat (i, "del"))
11538 else if (unformat (i, "spd_id %d", &spd_id))
11540 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
11541 sw_if_index_set = 1;
11542 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11543 sw_if_index_set = 1;
11546 clib_warning ("parse error '%U'", format_unformat_error, i);
11552 if (spd_id == (u32) ~ 0)
11554 errmsg ("spd_id must be set\n");
11558 if (sw_if_index_set == 0)
11560 errmsg ("missing interface name or sw_if_index\n");
11564 M (IPSEC_INTERFACE_ADD_DEL_SPD, ipsec_interface_add_del_spd);
11566 mp->spd_id = ntohl (spd_id);
11567 mp->sw_if_index = ntohl (sw_if_index);
11568 mp->is_add = is_add;
11577 api_ipsec_spd_add_del_entry (vat_main_t * vam)
11579 unformat_input_t *i = vam->input;
11580 vl_api_ipsec_spd_add_del_entry_t *mp;
11582 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11583 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11585 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11586 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11587 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11588 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11590 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11591 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11592 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11593 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11594 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11595 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11597 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11599 if (unformat (i, "del"))
11601 if (unformat (i, "outbound"))
11603 if (unformat (i, "inbound"))
11605 else if (unformat (i, "spd_id %d", &spd_id))
11607 else if (unformat (i, "sa_id %d", &sa_id))
11609 else if (unformat (i, "priority %d", &priority))
11611 else if (unformat (i, "protocol %d", &protocol))
11613 else if (unformat (i, "lport_start %d", &lport_start))
11615 else if (unformat (i, "lport_stop %d", &lport_stop))
11617 else if (unformat (i, "rport_start %d", &rport_start))
11619 else if (unformat (i, "rport_stop %d", &rport_stop))
11623 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
11629 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
11636 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
11642 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
11649 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
11655 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
11662 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
11668 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
11674 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
11676 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
11678 clib_warning ("unsupported action: 'resolve'");
11684 clib_warning ("parse error '%U'", format_unformat_error, i);
11690 M (IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry);
11692 mp->spd_id = ntohl (spd_id);
11693 mp->priority = ntohl (priority);
11694 mp->is_outbound = is_outbound;
11696 mp->is_ipv6 = is_ipv6;
11697 if (is_ipv6 || is_ip_any)
11699 clib_memcpy (mp->remote_address_start, &raddr6_start,
11700 sizeof (ip6_address_t));
11701 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
11702 sizeof (ip6_address_t));
11703 clib_memcpy (mp->local_address_start, &laddr6_start,
11704 sizeof (ip6_address_t));
11705 clib_memcpy (mp->local_address_stop, &laddr6_stop,
11706 sizeof (ip6_address_t));
11710 clib_memcpy (mp->remote_address_start, &raddr4_start,
11711 sizeof (ip4_address_t));
11712 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
11713 sizeof (ip4_address_t));
11714 clib_memcpy (mp->local_address_start, &laddr4_start,
11715 sizeof (ip4_address_t));
11716 clib_memcpy (mp->local_address_stop, &laddr4_stop,
11717 sizeof (ip4_address_t));
11719 mp->protocol = (u8) protocol;
11720 mp->local_port_start = ntohs ((u16) lport_start);
11721 mp->local_port_stop = ntohs ((u16) lport_stop);
11722 mp->remote_port_start = ntohs ((u16) rport_start);
11723 mp->remote_port_stop = ntohs ((u16) rport_stop);
11724 mp->policy = (u8) policy;
11725 mp->sa_id = ntohl (sa_id);
11726 mp->is_add = is_add;
11727 mp->is_ip_any = is_ip_any;
11735 api_ipsec_sad_add_del_entry (vat_main_t * vam)
11737 unformat_input_t *i = vam->input;
11738 vl_api_ipsec_sad_add_del_entry_t *mp;
11740 u32 sad_id = 0, spi = 0;
11741 u8 *ck = 0, *ik = 0;
11744 u8 protocol = IPSEC_PROTOCOL_AH;
11745 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
11746 u32 crypto_alg = 0, integ_alg = 0;
11747 ip4_address_t tun_src4;
11748 ip4_address_t tun_dst4;
11749 ip6_address_t tun_src6;
11750 ip6_address_t tun_dst6;
11752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11754 if (unformat (i, "del"))
11756 else if (unformat (i, "sad_id %d", &sad_id))
11758 else if (unformat (i, "spi %d", &spi))
11760 else if (unformat (i, "esp"))
11761 protocol = IPSEC_PROTOCOL_ESP;
11762 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
11765 is_tunnel_ipv6 = 0;
11767 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
11770 is_tunnel_ipv6 = 0;
11772 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
11775 is_tunnel_ipv6 = 1;
11777 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
11780 is_tunnel_ipv6 = 1;
11784 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
11786 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
11787 crypto_alg >= IPSEC_CRYPTO_N_ALG)
11789 clib_warning ("unsupported crypto-alg: '%U'",
11790 format_ipsec_crypto_alg, crypto_alg);
11794 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11798 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
11801 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
11803 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
11805 integ_alg >= IPSEC_INTEG_N_ALG)
11807 clib_warning ("unsupported integ-alg: '%U'",
11808 format_ipsec_integ_alg, integ_alg);
11812 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
11816 clib_warning ("parse error '%U'", format_unformat_error, i);
11823 /*Special cases, aes-gcm-128 encryption */
11824 if (crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128)
11826 if (integ_alg != IPSEC_INTEG_ALG_NONE
11827 && integ_alg != IPSEC_INTEG_ALG_AES_GCM_128)
11830 ("unsupported: aes-gcm-128 crypto-alg needs none as integ-alg");
11833 else /*set integ-alg internally to aes-gcm-128 */
11834 integ_alg = IPSEC_INTEG_ALG_AES_GCM_128;
11836 else if (integ_alg == IPSEC_INTEG_ALG_AES_GCM_128)
11838 clib_warning ("unsupported integ-alg: aes-gcm-128");
11841 else if (integ_alg == IPSEC_INTEG_ALG_NONE)
11843 clib_warning ("unsupported integ-alg: none");
11849 M (IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry);
11851 mp->sad_id = ntohl (sad_id);
11852 mp->is_add = is_add;
11853 mp->protocol = protocol;
11854 mp->spi = ntohl (spi);
11855 mp->is_tunnel = is_tunnel;
11856 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
11857 mp->crypto_algorithm = crypto_alg;
11858 mp->integrity_algorithm = integ_alg;
11859 mp->crypto_key_length = vec_len (ck);
11860 mp->integrity_key_length = vec_len (ik);
11862 if (mp->crypto_key_length > sizeof (mp->crypto_key))
11863 mp->crypto_key_length = sizeof (mp->crypto_key);
11865 if (mp->integrity_key_length > sizeof (mp->integrity_key))
11866 mp->integrity_key_length = sizeof (mp->integrity_key);
11869 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
11871 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
11875 if (is_tunnel_ipv6)
11877 clib_memcpy (mp->tunnel_src_address, &tun_src6,
11878 sizeof (ip6_address_t));
11879 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
11880 sizeof (ip6_address_t));
11884 clib_memcpy (mp->tunnel_src_address, &tun_src4,
11885 sizeof (ip4_address_t));
11886 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
11887 sizeof (ip4_address_t));
11898 api_ipsec_sa_set_key (vat_main_t * vam)
11900 unformat_input_t *i = vam->input;
11901 vl_api_ipsec_sa_set_key_t *mp;
11904 u8 *ck = 0, *ik = 0;
11906 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11908 if (unformat (i, "sa_id %d", &sa_id))
11910 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11912 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
11916 clib_warning ("parse error '%U'", format_unformat_error, i);
11921 M (IPSEC_SA_SET_KEY, ipsec_set_sa_key);
11923 mp->sa_id = ntohl (sa_id);
11924 mp->crypto_key_length = vec_len (ck);
11925 mp->integrity_key_length = vec_len (ik);
11927 if (mp->crypto_key_length > sizeof (mp->crypto_key))
11928 mp->crypto_key_length = sizeof (mp->crypto_key);
11930 if (mp->integrity_key_length > sizeof (mp->integrity_key))
11931 mp->integrity_key_length = sizeof (mp->integrity_key);
11934 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
11936 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
11945 api_ikev2_profile_add_del (vat_main_t * vam)
11947 unformat_input_t *i = vam->input;
11948 vl_api_ikev2_profile_add_del_t *mp;
11953 const char *valid_chars = "a-zA-Z0-9_";
11955 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11957 if (unformat (i, "del"))
11959 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
11960 vec_add1 (name, 0);
11963 errmsg ("parse error '%U'", format_unformat_error, i);
11968 if (!vec_len (name))
11970 errmsg ("profile name must be specified");
11974 if (vec_len (name) > 64)
11976 errmsg ("profile name too long");
11980 M (IKEV2_PROFILE_ADD_DEL, ikev2_profile_add_del);
11982 clib_memcpy (mp->name, name, vec_len (name));
11983 mp->is_add = is_add;
11993 api_ikev2_profile_set_auth (vat_main_t * vam)
11995 unformat_input_t *i = vam->input;
11996 vl_api_ikev2_profile_set_auth_t *mp;
12000 u32 auth_method = 0;
12003 const char *valid_chars = "a-zA-Z0-9_";
12005 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12007 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12008 vec_add1 (name, 0);
12009 else if (unformat (i, "auth_method %U",
12010 unformat_ikev2_auth_method, &auth_method))
12012 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12014 else if (unformat (i, "auth_data %v", &data))
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 ("auth_data must be specified");
12043 errmsg ("auth_method must be specified");
12047 M (IKEV2_PROFILE_SET_AUTH, ikev2_profile_set_auth);
12049 mp->is_hex = is_hex;
12050 mp->auth_method = (u8) auth_method;
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_id (vat_main_t * vam)
12066 unformat_input_t *i = vam->input;
12067 vl_api_ikev2_profile_set_id_t *mp;
12075 const char *valid_chars = "a-zA-Z0-9_";
12077 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12079 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12080 vec_add1 (name, 0);
12081 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12083 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12085 data = vec_new (u8, 4);
12086 clib_memcpy (data, ip4.as_u8, 4);
12088 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12090 else if (unformat (i, "id_data %v", &data))
12092 else if (unformat (i, "local"))
12094 else if (unformat (i, "remote"))
12098 errmsg ("parse error '%U'", format_unformat_error, i);
12103 if (!vec_len (name))
12105 errmsg ("profile name must be specified");
12109 if (vec_len (name) > 64)
12111 errmsg ("profile name too long");
12115 if (!vec_len (data))
12117 errmsg ("id_data must be specified");
12123 errmsg ("id_type must be specified");
12127 M (IKEV2_PROFILE_SET_ID, ikev2_profile_set_id);
12129 mp->is_local = is_local;
12130 mp->id_type = (u8) id_type;
12131 mp->data_len = vec_len (data);
12132 clib_memcpy (mp->name, name, vec_len (name));
12133 clib_memcpy (mp->data, data, vec_len (data));
12144 api_ikev2_profile_set_ts (vat_main_t * vam)
12146 unformat_input_t *i = vam->input;
12147 vl_api_ikev2_profile_set_ts_t *mp;
12151 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12152 ip4_address_t start_addr, end_addr;
12154 const char *valid_chars = "a-zA-Z0-9_";
12156 start_addr.as_u32 = 0;
12157 end_addr.as_u32 = (u32) ~ 0;
12159 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12161 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12162 vec_add1 (name, 0);
12163 else if (unformat (i, "protocol %d", &proto))
12165 else if (unformat (i, "start_port %d", &start_port))
12167 else if (unformat (i, "end_port %d", &end_port))
12170 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12172 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12174 else if (unformat (i, "local"))
12176 else if (unformat (i, "remote"))
12180 errmsg ("parse error '%U'", format_unformat_error, i);
12185 if (!vec_len (name))
12187 errmsg ("profile name must be specified");
12191 if (vec_len (name) > 64)
12193 errmsg ("profile name too long");
12197 M (IKEV2_PROFILE_SET_TS, ikev2_profile_set_ts);
12199 mp->is_local = is_local;
12200 mp->proto = (u8) proto;
12201 mp->start_port = (u16) start_port;
12202 mp->end_port = (u16) end_port;
12203 mp->start_addr = start_addr.as_u32;
12204 mp->end_addr = end_addr.as_u32;
12205 clib_memcpy (mp->name, name, vec_len (name));
12215 api_ikev2_set_local_key (vat_main_t * vam)
12217 unformat_input_t *i = vam->input;
12218 vl_api_ikev2_set_local_key_t *mp;
12222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12224 if (unformat (i, "file %v", &file))
12225 vec_add1 (file, 0);
12228 errmsg ("parse error '%U'", format_unformat_error, i);
12233 if (!vec_len (file))
12235 errmsg ("RSA key file must be specified");
12239 if (vec_len (file) > 256)
12241 errmsg ("file name too long");
12245 M (IKEV2_SET_LOCAL_KEY, ikev2_set_local_key);
12247 clib_memcpy (mp->key_file, file, vec_len (file));
12260 api_map_add_domain (vat_main_t * vam)
12262 unformat_input_t *i = vam->input;
12263 vl_api_map_add_domain_t *mp;
12266 ip4_address_t ip4_prefix;
12267 ip6_address_t ip6_prefix;
12268 ip6_address_t ip6_src;
12269 u32 num_m_args = 0;
12270 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12271 0, psid_length = 0;
12272 u8 is_translation = 0;
12274 u32 ip6_src_len = 128;
12276 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12278 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12279 &ip4_prefix, &ip4_prefix_len))
12281 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12282 &ip6_prefix, &ip6_prefix_len))
12286 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12289 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12291 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12293 else if (unformat (i, "psid-offset %d", &psid_offset))
12295 else if (unformat (i, "psid-len %d", &psid_length))
12297 else if (unformat (i, "mtu %d", &mtu))
12299 else if (unformat (i, "map-t"))
12300 is_translation = 1;
12303 clib_warning ("parse error '%U'", format_unformat_error, i);
12308 if (num_m_args < 3)
12310 errmsg ("mandatory argument(s) missing\n");
12314 /* Construct the API message */
12315 M (MAP_ADD_DOMAIN, map_add_domain);
12317 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12318 mp->ip4_prefix_len = ip4_prefix_len;
12320 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12321 mp->ip6_prefix_len = ip6_prefix_len;
12323 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12324 mp->ip6_src_prefix_len = ip6_src_len;
12326 mp->ea_bits_len = ea_bits_len;
12327 mp->psid_offset = psid_offset;
12328 mp->psid_length = psid_length;
12329 mp->is_translation = is_translation;
12330 mp->mtu = htons (mtu);
12335 /* Wait for a reply, return good/bad news */
12340 api_map_del_domain (vat_main_t * vam)
12342 unformat_input_t *i = vam->input;
12343 vl_api_map_del_domain_t *mp;
12346 u32 num_m_args = 0;
12349 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12351 if (unformat (i, "index %d", &index))
12355 clib_warning ("parse error '%U'", format_unformat_error, i);
12360 if (num_m_args != 1)
12362 errmsg ("mandatory argument(s) missing\n");
12366 /* Construct the API message */
12367 M (MAP_DEL_DOMAIN, map_del_domain);
12369 mp->index = ntohl (index);
12374 /* Wait for a reply, return good/bad news */
12379 api_map_add_del_rule (vat_main_t * vam)
12381 unformat_input_t *i = vam->input;
12382 vl_api_map_add_del_rule_t *mp;
12385 ip6_address_t ip6_dst;
12386 u32 num_m_args = 0, index, psid = 0;
12388 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12390 if (unformat (i, "index %d", &index))
12392 else if (unformat (i, "psid %d", &psid))
12394 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
12396 else if (unformat (i, "del"))
12402 clib_warning ("parse error '%U'", format_unformat_error, i);
12407 /* Construct the API message */
12408 M (MAP_ADD_DEL_RULE, map_add_del_rule);
12410 mp->index = ntohl (index);
12411 mp->is_add = is_add;
12412 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
12413 mp->psid = ntohs (psid);
12418 /* Wait for a reply, return good/bad news */
12423 api_map_domain_dump (vat_main_t * vam)
12425 vl_api_map_domain_dump_t *mp;
12428 /* Construct the API message */
12429 M (MAP_DOMAIN_DUMP, map_domain_dump);
12434 /* Use a control ping for synchronization */
12436 vl_api_control_ping_t *mp;
12437 M (CONTROL_PING, control_ping);
12444 api_map_rule_dump (vat_main_t * vam)
12446 unformat_input_t *i = vam->input;
12447 vl_api_map_rule_dump_t *mp;
12449 u32 domain_index = ~0;
12451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12453 if (unformat (i, "index %u", &domain_index))
12459 if (domain_index == ~0)
12461 clib_warning ("parse error: domain index expected");
12465 /* Construct the API message */
12466 M (MAP_RULE_DUMP, map_rule_dump);
12468 mp->domain_index = htonl (domain_index);
12473 /* Use a control ping for synchronization */
12475 vl_api_control_ping_t *mp;
12476 M (CONTROL_PING, control_ping);
12482 static void vl_api_map_add_domain_reply_t_handler
12483 (vl_api_map_add_domain_reply_t * mp)
12485 vat_main_t *vam = &vat_main;
12486 i32 retval = ntohl (mp->retval);
12488 if (vam->async_mode)
12490 vam->async_errors += (retval < 0);
12494 vam->retval = retval;
12495 vam->result_ready = 1;
12499 static void vl_api_map_add_domain_reply_t_handler_json
12500 (vl_api_map_add_domain_reply_t * mp)
12502 vat_main_t *vam = &vat_main;
12503 vat_json_node_t node;
12505 vat_json_init_object (&node);
12506 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
12507 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
12509 vat_json_print (vam->ofp, &node);
12510 vat_json_free (&node);
12512 vam->retval = ntohl (mp->retval);
12513 vam->result_ready = 1;
12517 api_get_first_msg_id (vat_main_t * vam)
12519 vl_api_get_first_msg_id_t *mp;
12521 unformat_input_t *i = vam->input;
12525 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12527 if (unformat (i, "client %s", &name))
12535 errmsg ("missing client name\n");
12538 vec_add1 (name, 0);
12540 if (vec_len (name) > 63)
12542 errmsg ("client name too long\n");
12546 M (GET_FIRST_MSG_ID, get_first_msg_id);
12547 clib_memcpy (mp->name, name, vec_len (name));
12555 api_cop_interface_enable_disable (vat_main_t * vam)
12557 unformat_input_t *line_input = vam->input;
12558 vl_api_cop_interface_enable_disable_t *mp;
12560 u32 sw_if_index = ~0;
12561 u8 enable_disable = 1;
12563 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12565 if (unformat (line_input, "disable"))
12566 enable_disable = 0;
12567 if (unformat (line_input, "enable"))
12568 enable_disable = 1;
12569 else if (unformat (line_input, "%U", unformat_sw_if_index,
12570 vam, &sw_if_index))
12572 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12578 if (sw_if_index == ~0)
12580 errmsg ("missing interface name or sw_if_index\n");
12584 /* Construct the API message */
12585 M (COP_INTERFACE_ENABLE_DISABLE, cop_interface_enable_disable);
12586 mp->sw_if_index = ntohl (sw_if_index);
12587 mp->enable_disable = enable_disable;
12591 /* Wait for the reply */
12596 api_cop_whitelist_enable_disable (vat_main_t * vam)
12598 unformat_input_t *line_input = vam->input;
12599 vl_api_cop_whitelist_enable_disable_t *mp;
12601 u32 sw_if_index = ~0;
12602 u8 ip4 = 0, ip6 = 0, default_cop = 0;
12605 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12607 if (unformat (line_input, "ip4"))
12609 else if (unformat (line_input, "ip6"))
12611 else if (unformat (line_input, "default"))
12613 else if (unformat (line_input, "%U", unformat_sw_if_index,
12614 vam, &sw_if_index))
12616 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12618 else if (unformat (line_input, "fib-id %d", &fib_id))
12624 if (sw_if_index == ~0)
12626 errmsg ("missing interface name or sw_if_index\n");
12630 /* Construct the API message */
12631 M (COP_WHITELIST_ENABLE_DISABLE, cop_whitelist_enable_disable);
12632 mp->sw_if_index = ntohl (sw_if_index);
12633 mp->fib_id = ntohl (fib_id);
12636 mp->default_cop = default_cop;
12640 /* Wait for the reply */
12645 api_get_node_graph (vat_main_t * vam)
12647 vl_api_get_node_graph_t *mp;
12650 M (GET_NODE_GRAPH, get_node_graph);
12654 /* Wait for the reply */
12659 /** Used for parsing LISP eids */
12660 typedef CLIB_PACKED(struct{
12661 u8 addr[16]; /**< eid address */
12662 u32 len; /**< prefix length if IP */
12663 u8 type; /**< type of eid */
12668 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
12670 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
12672 memset (a, 0, sizeof (a[0]));
12674 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
12676 a->type = 0; /* ipv4 type */
12678 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
12680 a->type = 1; /* ipv6 type */
12682 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
12684 a->type = 2; /* mac type */
12691 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
12700 lisp_eid_size_vat (u8 type)
12715 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
12717 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
12721 /** Used for transferring locators via VPP API */
12722 typedef CLIB_PACKED(struct
12724 u32 sw_if_index; /**< locator sw_if_index */
12725 u8 priority; /**< locator priority */
12726 u8 weight; /**< locator weight */
12731 api_lisp_add_del_locator_set (vat_main_t * vam)
12733 unformat_input_t *input = vam->input;
12734 vl_api_lisp_add_del_locator_set_t *mp;
12737 u8 *locator_set_name = NULL;
12738 u8 locator_set_name_set = 0;
12739 ls_locator_t locator, *locators = 0;
12740 u32 sw_if_index, priority, weight;
12743 /* Parse args required to build the message */
12744 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12746 if (unformat (input, "del"))
12750 else if (unformat (input, "locator-set %s", &locator_set_name))
12752 locator_set_name_set = 1;
12754 else if (unformat (input, "sw_if_index %u p %u w %u",
12755 &sw_if_index, &priority, &weight))
12757 locator.sw_if_index = htonl (sw_if_index);
12758 locator.priority = priority;
12759 locator.weight = weight;
12760 vec_add1 (locators, locator);
12762 else if (unformat (input, "iface %U p %u w %u", unformat_sw_if_index,
12763 vam, &sw_if_index, &priority, &weight))
12765 locator.sw_if_index = htonl (sw_if_index);
12766 locator.priority = priority;
12767 locator.weight = weight;
12768 vec_add1 (locators, locator);
12774 if (locator_set_name_set == 0)
12776 errmsg ("missing locator-set name");
12777 vec_free (locators);
12781 if (vec_len (locator_set_name) > 64)
12783 errmsg ("locator-set name too long\n");
12784 vec_free (locator_set_name);
12785 vec_free (locators);
12788 vec_add1 (locator_set_name, 0);
12790 data_len = sizeof (ls_locator_t) * vec_len (locators);
12792 /* Construct the API message */
12793 M2 (LISP_ADD_DEL_LOCATOR_SET, lisp_add_del_locator_set, data_len);
12795 mp->is_add = is_add;
12796 clib_memcpy (mp->locator_set_name, locator_set_name,
12797 vec_len (locator_set_name));
12798 vec_free (locator_set_name);
12800 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
12802 clib_memcpy (mp->locators, locators, data_len);
12803 vec_free (locators);
12808 /* Wait for a reply... */
12816 api_lisp_add_del_locator (vat_main_t * vam)
12818 unformat_input_t *input = vam->input;
12819 vl_api_lisp_add_del_locator_t *mp;
12821 u32 tmp_if_index = ~0;
12822 u32 sw_if_index = ~0;
12823 u8 sw_if_index_set = 0;
12824 u8 sw_if_index_if_name_set = 0;
12826 u8 priority_set = 0;
12830 u8 *locator_set_name = NULL;
12831 u8 locator_set_name_set = 0;
12833 /* Parse args required to build the message */
12834 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12836 if (unformat (input, "del"))
12840 else if (unformat (input, "locator-set %s", &locator_set_name))
12842 locator_set_name_set = 1;
12844 else if (unformat (input, "iface %U", unformat_sw_if_index, vam,
12847 sw_if_index_if_name_set = 1;
12848 sw_if_index = tmp_if_index;
12850 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
12852 sw_if_index_set = 1;
12853 sw_if_index = tmp_if_index;
12855 else if (unformat (input, "p %d", &priority))
12859 else if (unformat (input, "w %d", &weight))
12867 if (locator_set_name_set == 0)
12869 errmsg ("missing locator-set name");
12873 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
12875 errmsg ("missing sw_if_index");
12876 vec_free (locator_set_name);
12880 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
12882 errmsg ("cannot use both params interface name and sw_if_index");
12883 vec_free (locator_set_name);
12887 if (priority_set == 0)
12889 errmsg ("missing locator-set priority\n");
12890 vec_free (locator_set_name);
12894 if (weight_set == 0)
12896 errmsg ("missing locator-set weight\n");
12897 vec_free (locator_set_name);
12901 if (vec_len (locator_set_name) > 64)
12903 errmsg ("locator-set name too long\n");
12904 vec_free (locator_set_name);
12907 vec_add1 (locator_set_name, 0);
12909 /* Construct the API message */
12910 M (LISP_ADD_DEL_LOCATOR, lisp_add_del_locator);
12912 mp->is_add = is_add;
12913 mp->sw_if_index = ntohl (sw_if_index);
12914 mp->priority = priority;
12915 mp->weight = weight;
12916 clib_memcpy (mp->locator_set_name, locator_set_name,
12917 vec_len (locator_set_name));
12918 vec_free (locator_set_name);
12923 /* Wait for a reply... */
12931 api_lisp_add_del_local_eid (vat_main_t * vam)
12933 unformat_input_t *input = vam->input;
12934 vl_api_lisp_add_del_local_eid_t *mp;
12938 lisp_eid_vat_t _eid, *eid = &_eid;
12939 u8 *locator_set_name = 0;
12940 u8 locator_set_name_set = 0;
12943 /* Parse args required to build the message */
12944 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12946 if (unformat (input, "del"))
12950 else if (unformat (input, "vni %d", &vni))
12954 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
12958 else if (unformat (input, "locator-set %s", &locator_set_name))
12960 locator_set_name_set = 1;
12966 if (locator_set_name_set == 0)
12968 errmsg ("missing locator-set name\n");
12974 errmsg ("EID address not set!");
12975 vec_free (locator_set_name);
12979 if (vec_len (locator_set_name) > 64)
12981 errmsg ("locator-set name too long\n");
12982 vec_free (locator_set_name);
12985 vec_add1 (locator_set_name, 0);
12987 /* Construct the API message */
12988 M (LISP_ADD_DEL_LOCAL_EID, lisp_add_del_local_eid);
12990 mp->is_add = is_add;
12991 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
12992 mp->eid_type = eid->type;
12993 mp->prefix_len = eid->len;
12994 mp->vni = clib_host_to_net_u32 (vni);
12995 clib_memcpy (mp->locator_set_name, locator_set_name,
12996 vec_len (locator_set_name));
12998 vec_free (locator_set_name);
13003 /* Wait for a reply... */
13011 /** Used for transferring locators via VPP API */
13012 typedef CLIB_PACKED(struct
13014 u8 is_ip4; /**< is locator an IPv4 address? */
13015 u8 priority; /**< locator priority */
13016 u8 weight; /**< locator weight */
13017 u8 addr[16]; /**< IPv4/IPv6 address */
13022 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13024 unformat_input_t *input = vam->input;
13025 vl_api_lisp_gpe_add_del_fwd_entry_t *mp;
13028 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13029 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13030 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13031 u32 action = ~0, p, w;
13032 ip4_address_t rmt_rloc4, lcl_rloc4;
13033 ip6_address_t rmt_rloc6, lcl_rloc6;
13034 rloc_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
13036 memset (&rloc, 0, sizeof (rloc));
13038 /* Parse args required to build the message */
13039 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13041 if (unformat (input, "del"))
13045 else if (unformat (input, "rmt_eid %U", unformat_lisp_eid_vat, rmt_eid))
13049 else if (unformat (input, "lcl_eid %U", unformat_lisp_eid_vat, lcl_eid))
13053 else if (unformat (input, "p %d w %d", &p, &w))
13057 errmsg ("No RLOC configured for setting priority/weight!");
13060 curr_rloc->priority = p;
13061 curr_rloc->weight = w;
13063 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13064 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13068 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13069 rloc.priority = rloc.weight = 0;
13070 vec_add1 (lcl_locs, rloc);
13072 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13073 vec_add1 (rmt_locs, rloc);
13074 /* priority and weight saved in rmt loc */
13075 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13077 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13078 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13081 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13082 rloc.priority = rloc.weight = 0;
13083 vec_add1 (lcl_locs, rloc);
13085 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13086 vec_add1 (rmt_locs, rloc);
13087 /* priority and weight saved in rmt loc */
13088 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13090 else if (unformat (input, "action %d", &action))
13096 clib_warning ("parse error '%U'", format_unformat_error, input);
13103 errmsg ("remote eid addresses not set\n");
13107 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13109 errmsg ("eid types don't match\n");
13113 if (0 == rmt_locs && (u32) ~ 0 == action)
13115 errmsg ("action not set for negative mapping\n");
13119 /* Construct the API message */
13120 M (LISP_GPE_ADD_DEL_FWD_ENTRY, lisp_gpe_add_del_fwd_entry);
13122 mp->is_add = is_add;
13123 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13124 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13125 mp->eid_type = rmt_eid->type;
13126 mp->rmt_len = rmt_eid->len;
13127 mp->lcl_len = lcl_eid->len;
13128 mp->action = action;
13130 if (0 != rmt_locs && 0 != lcl_locs)
13132 mp->loc_num = vec_len (rmt_locs);
13133 clib_memcpy (mp->lcl_locs, lcl_locs,
13134 (sizeof (rloc_t) * vec_len (lcl_locs)));
13135 clib_memcpy (mp->rmt_locs, rmt_locs,
13136 (sizeof (rloc_t) * vec_len (rmt_locs)));
13138 vec_free (lcl_locs);
13139 vec_free (rmt_locs);
13144 /* Wait for a reply... */
13152 api_lisp_add_del_map_resolver (vat_main_t * vam)
13154 unformat_input_t *input = vam->input;
13155 vl_api_lisp_add_del_map_resolver_t *mp;
13160 ip4_address_t ipv4;
13161 ip6_address_t ipv6;
13163 /* Parse args required to build the message */
13164 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13166 if (unformat (input, "del"))
13170 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13174 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13182 if (ipv4_set && ipv6_set)
13184 errmsg ("both eid v4 and v6 addresses set\n");
13188 if (!ipv4_set && !ipv6_set)
13190 errmsg ("eid addresses not set\n");
13194 /* Construct the API message */
13195 M (LISP_ADD_DEL_MAP_RESOLVER, lisp_add_del_map_resolver);
13197 mp->is_add = is_add;
13201 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13206 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13212 /* Wait for a reply... */
13220 api_lisp_gpe_enable_disable (vat_main_t * vam)
13222 unformat_input_t *input = vam->input;
13223 vl_api_lisp_gpe_enable_disable_t *mp;
13228 /* Parse args required to build the message */
13229 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13231 if (unformat (input, "enable"))
13236 else if (unformat (input, "disable"))
13247 errmsg ("Value not set\n");
13251 /* Construct the API message */
13252 M (LISP_GPE_ENABLE_DISABLE, lisp_gpe_enable_disable);
13259 /* Wait for a reply... */
13267 api_lisp_enable_disable (vat_main_t * vam)
13269 unformat_input_t *input = vam->input;
13270 vl_api_lisp_enable_disable_t *mp;
13275 /* Parse args required to build the message */
13276 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13278 if (unformat (input, "enable"))
13283 else if (unformat (input, "disable"))
13293 errmsg ("Value not set\n");
13297 /* Construct the API message */
13298 M (LISP_ENABLE_DISABLE, lisp_enable_disable);
13305 /* Wait for a reply... */
13313 api_show_lisp_map_request_mode (vat_main_t * vam)
13316 vl_api_show_lisp_map_request_mode_t *mp;
13318 M (SHOW_LISP_MAP_REQUEST_MODE, show_lisp_map_request_mode);
13323 /* wait for reply */
13330 api_lisp_map_request_mode (vat_main_t * vam)
13333 unformat_input_t *input = vam->input;
13334 vl_api_lisp_map_request_mode_t *mp;
13337 /* Parse args required to build the message */
13338 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13340 if (unformat (input, "dst-only"))
13342 else if (unformat (input, "src-dst"))
13346 errmsg ("parse error '%U'", format_unformat_error, input);
13351 M (LISP_MAP_REQUEST_MODE, lisp_map_request_mode);
13358 /* wait for reply */
13366 * Enable/disable LISP proxy ITR.
13368 * @param vam vpp API test context
13369 * @return return code
13372 api_lisp_pitr_set_locator_set (vat_main_t * vam)
13375 u8 ls_name_set = 0;
13376 unformat_input_t *input = vam->input;
13377 vl_api_lisp_pitr_set_locator_set_t *mp;
13381 /* Parse args required to build the message */
13382 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13384 if (unformat (input, "del"))
13386 else if (unformat (input, "locator-set %s", &ls_name))
13390 errmsg ("parse error '%U'", format_unformat_error, input);
13397 errmsg ("locator-set name not set!");
13401 M (LISP_PITR_SET_LOCATOR_SET, lisp_pitr_set_locator_set);
13403 mp->is_add = is_add;
13404 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
13405 vec_free (ls_name);
13410 /* wait for reply */
13418 api_show_lisp_pitr (vat_main_t * vam)
13420 vl_api_show_lisp_pitr_t *mp;
13423 if (!vam->json_output)
13425 fformat (vam->ofp, "%=20s\n", "lisp status:");
13428 M (SHOW_LISP_PITR, show_lisp_pitr);
13432 /* Wait for a reply... */
13440 * Add/delete mapping between vni and vrf
13443 api_lisp_eid_table_add_del_map (vat_main_t * vam)
13446 unformat_input_t *input = vam->input;
13447 vl_api_lisp_eid_table_add_del_map_t *mp;
13448 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
13449 u32 vni, vrf, bd_index;
13451 /* Parse args required to build the message */
13452 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13454 if (unformat (input, "del"))
13456 else if (unformat (input, "vrf %d", &vrf))
13458 else if (unformat (input, "bd_index %d", &bd_index))
13460 else if (unformat (input, "vni %d", &vni))
13466 if (!vni_set || (!vrf_set && !bd_index_set))
13468 errmsg ("missing arguments!");
13472 if (vrf_set && bd_index_set)
13474 errmsg ("error: both vrf and bd entered!");
13478 M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
13480 mp->is_add = is_add;
13481 mp->vni = htonl (vni);
13482 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
13483 mp->is_l2 = bd_index_set;
13488 /* wait for reply */
13496 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
13498 u32 *action = va_arg (*args, u32 *);
13501 if (unformat (input, "%s", &s))
13503 if (!strcmp ((char *) s, "no-action"))
13505 else if (!strcmp ((char *) s, "natively-forward"))
13507 else if (!strcmp ((char *) s, "send-map-request"))
13509 else if (!strcmp ((char *) s, "drop"))
13513 clib_warning ("invalid action: '%s'", s);
13525 * Add/del remote mapping to/from LISP control plane
13527 * @param vam vpp API test context
13528 * @return return code
13531 api_lisp_add_del_remote_mapping (vat_main_t * vam)
13533 unformat_input_t *input = vam->input;
13534 vl_api_lisp_add_del_remote_mapping_t *mp;
13537 lisp_eid_vat_t _eid, *eid = &_eid;
13538 lisp_eid_vat_t _seid, *seid = &_seid;
13539 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
13540 u32 action = ~0, p, w, data_len;
13541 ip4_address_t rloc4;
13542 ip6_address_t rloc6;
13543 rloc_t *rlocs = 0, rloc, *curr_rloc = 0;
13545 memset (&rloc, 0, sizeof (rloc));
13547 /* Parse args required to build the message */
13548 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13550 if (unformat (input, "del-all"))
13554 else if (unformat (input, "del"))
13558 else if (unformat (input, "add"))
13562 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13566 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
13570 else if (unformat (input, "vni %d", &vni))
13574 else if (unformat (input, "p %d w %d", &p, &w))
13578 errmsg ("No RLOC configured for setting priority/weight!");
13581 curr_rloc->priority = p;
13582 curr_rloc->weight = w;
13584 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
13587 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
13588 vec_add1 (rlocs, rloc);
13589 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13591 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
13594 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
13595 vec_add1 (rlocs, rloc);
13596 curr_rloc = &rlocs[vec_len (rlocs) - 1];
13598 else if (unformat (input, "action %U",
13599 unformat_negative_mapping_action, &action))
13605 clib_warning ("parse error '%U'", format_unformat_error, input);
13612 errmsg ("missing params!");
13616 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
13618 errmsg ("no action set for negative map-reply!");
13622 data_len = vec_len (rlocs) * sizeof (rloc_t);
13624 M2 (LISP_ADD_DEL_REMOTE_MAPPING, lisp_add_del_remote_mapping, data_len);
13625 mp->is_add = is_add;
13626 mp->vni = htonl (vni);
13627 mp->action = (u8) action;
13628 mp->is_src_dst = seid_set;
13629 mp->eid_len = eid->len;
13630 mp->seid_len = seid->len;
13631 mp->del_all = del_all;
13632 mp->eid_type = eid->type;
13633 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13634 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
13636 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
13637 clib_memcpy (mp->rlocs, rlocs, data_len);
13643 /* Wait for a reply... */
13651 * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
13652 * forwarding entries in data-plane accordingly.
13654 * @param vam vpp API test context
13655 * @return return code
13658 api_lisp_add_del_adjacency (vat_main_t * vam)
13660 unformat_input_t *input = vam->input;
13661 vl_api_lisp_add_del_adjacency_t *mp;
13664 ip4_address_t leid4, reid4;
13665 ip6_address_t leid6, reid6;
13666 u8 reid_mac[6] = { 0 };
13667 u8 leid_mac[6] = { 0 };
13668 u8 reid_type, leid_type;
13669 u32 leid_len = 0, reid_len = 0, len;
13672 leid_type = reid_type = (u8) ~ 0;
13674 /* Parse args required to build the message */
13675 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13677 if (unformat (input, "del"))
13681 else if (unformat (input, "add"))
13685 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
13688 reid_type = 0; /* ipv4 */
13691 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
13694 reid_type = 1; /* ipv6 */
13697 else if (unformat (input, "reid %U", unformat_ethernet_address,
13700 reid_type = 2; /* mac */
13702 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
13705 leid_type = 0; /* ipv4 */
13708 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
13711 leid_type = 1; /* ipv6 */
13714 else if (unformat (input, "leid %U", unformat_ethernet_address,
13717 leid_type = 2; /* mac */
13719 else if (unformat (input, "vni %d", &vni))
13725 errmsg ("parse error '%U'", format_unformat_error, input);
13730 if ((u8) ~ 0 == reid_type)
13732 errmsg ("missing params!");
13736 if (leid_type != reid_type)
13738 errmsg ("remote and local EIDs are of different types!");
13742 M (LISP_ADD_DEL_ADJACENCY, lisp_add_del_adjacency);
13743 mp->is_add = is_add;
13744 mp->vni = htonl (vni);
13745 mp->leid_len = leid_len;
13746 mp->reid_len = reid_len;
13747 mp->eid_type = reid_type;
13749 switch (mp->eid_type)
13752 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
13753 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
13756 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
13757 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
13760 clib_memcpy (mp->leid, leid_mac, 6);
13761 clib_memcpy (mp->reid, reid_mac, 6);
13764 errmsg ("unknown EID type %d!", mp->eid_type);
13771 /* Wait for a reply... */
13779 api_lisp_gpe_add_del_iface (vat_main_t * vam)
13781 unformat_input_t *input = vam->input;
13782 vl_api_lisp_gpe_add_del_iface_t *mp;
13784 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
13785 u32 dp_table = 0, vni = 0;
13787 /* Parse args required to build the message */
13788 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13790 if (unformat (input, "up"))
13795 else if (unformat (input, "down"))
13800 else if (unformat (input, "table_id %d", &dp_table))
13804 else if (unformat (input, "bd_id %d", &dp_table))
13809 else if (unformat (input, "vni %d", &vni))
13817 if (action_set == 0)
13819 errmsg ("Action not set\n");
13822 if (dp_table_set == 0 || vni_set == 0)
13824 errmsg ("vni and dp_table must be set\n");
13828 /* Construct the API message */
13829 M (LISP_GPE_ADD_DEL_IFACE, lisp_gpe_add_del_iface);
13831 mp->is_add = is_add;
13832 mp->dp_table = dp_table;
13839 /* Wait for a reply... */
13847 * Add/del map request itr rlocs from LISP control plane and updates
13849 * @param vam vpp API test context
13850 * @return return code
13853 api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
13855 unformat_input_t *input = vam->input;
13856 vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
13858 u8 *locator_set_name = 0;
13859 u8 locator_set_name_set = 0;
13862 /* Parse args required to build the message */
13863 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13865 if (unformat (input, "del"))
13869 else if (unformat (input, "%_%v%_", &locator_set_name))
13871 locator_set_name_set = 1;
13875 clib_warning ("parse error '%U'", format_unformat_error, input);
13880 if (is_add && !locator_set_name_set)
13882 errmsg ("itr-rloc is not set!");
13886 if (is_add && vec_len (locator_set_name) > 64)
13888 errmsg ("itr-rloc locator-set name too long\n");
13889 vec_free (locator_set_name);
13893 M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, lisp_add_del_map_request_itr_rlocs);
13894 mp->is_add = is_add;
13897 clib_memcpy (mp->locator_set_name, locator_set_name,
13898 vec_len (locator_set_name));
13902 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
13904 vec_free (locator_set_name);
13909 /* Wait for a reply... */
13917 api_lisp_locator_dump (vat_main_t * vam)
13919 unformat_input_t *input = vam->input;
13920 vl_api_lisp_locator_dump_t *mp;
13922 u8 is_index_set = 0, is_name_set = 0;
13926 /* Parse args required to build the message */
13927 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13929 if (unformat (input, "ls_name %_%v%_", &ls_name))
13933 else if (unformat (input, "ls_index %d", &ls_index))
13939 errmsg ("parse error '%U'", format_unformat_error, input);
13944 if (!is_index_set && !is_name_set)
13946 errmsg ("error: expected one of index or name!\n");
13950 if (is_index_set && is_name_set)
13952 errmsg ("error: only one param expected!\n");
13956 if (vec_len (ls_name) > 62)
13958 errmsg ("error: locator set name too long!");
13962 if (!vam->json_output)
13964 fformat (vam->ofp, "%=16s%=16s%=16s\n", "locator", "priority",
13968 M (LISP_LOCATOR_DUMP, lisp_locator_dump);
13969 mp->is_index_set = is_index_set;
13972 mp->ls_index = clib_host_to_net_u32 (ls_index);
13975 vec_add1 (ls_name, 0);
13976 strncpy ((char *) mp->ls_name, (char *) ls_name,
13977 sizeof (mp->ls_name) - 1);
13983 /* Use a control ping for synchronization */
13985 vl_api_control_ping_t *mp;
13986 M (CONTROL_PING, control_ping);
13989 /* Wait for a reply... */
13997 api_lisp_locator_set_dump (vat_main_t * vam)
13999 vl_api_lisp_locator_set_dump_t *mp;
14000 unformat_input_t *input = vam->input;
14004 /* Parse args required to build the message */
14005 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14007 if (unformat (input, "local"))
14011 else if (unformat (input, "remote"))
14017 errmsg ("parse error '%U'", format_unformat_error, input);
14022 if (!vam->json_output)
14024 fformat (vam->ofp, "%=10s%=15s\n", "ls_index", "ls_name");
14027 M (LISP_LOCATOR_SET_DUMP, lisp_locator_set_dump);
14029 mp->filter = filter;
14034 /* Use a control ping for synchronization */
14036 vl_api_control_ping_t *mp;
14037 M (CONTROL_PING, control_ping);
14040 /* Wait for a reply... */
14048 api_lisp_eid_table_map_dump (vat_main_t * vam)
14052 unformat_input_t *input = vam->input;
14053 vl_api_lisp_eid_table_map_dump_t *mp;
14056 /* Parse args required to build the message */
14057 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14059 if (unformat (input, "l2"))
14064 else if (unformat (input, "l3"))
14071 errmsg ("parse error '%U'", format_unformat_error, input);
14078 errmsg ("expected one of 'l2' or 'l3' parameter!\n");
14082 if (!vam->json_output)
14084 fformat (vam->ofp, "%=10s%=10s\n", "VNI", is_l2 ? "BD" : "VRF");
14087 M (LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump);
14093 /* Use a control ping for synchronization */
14095 vl_api_control_ping_t *mp;
14096 M (CONTROL_PING, control_ping);
14099 /* Wait for a reply... */
14107 api_lisp_eid_table_vni_dump (vat_main_t * vam)
14109 vl_api_lisp_eid_table_vni_dump_t *mp;
14112 if (!vam->json_output)
14114 fformat (vam->ofp, "VNI\n");
14117 M (LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump);
14122 /* Use a control ping for synchronization */
14124 vl_api_control_ping_t *mp;
14125 M (CONTROL_PING, control_ping);
14128 /* Wait for a reply... */
14136 api_lisp_eid_table_dump (vat_main_t * vam)
14138 unformat_input_t *i = vam->input;
14139 vl_api_lisp_eid_table_dump_t *mp;
14141 struct in_addr ip4;
14142 struct in6_addr ip6;
14144 u8 eid_type = ~0, eid_set = 0;
14145 u32 prefix_length = ~0, t, vni = 0;
14148 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14150 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
14156 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
14162 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
14167 else if (unformat (i, "vni %d", &t))
14171 else if (unformat (i, "local"))
14175 else if (unformat (i, "remote"))
14181 errmsg ("parse error '%U'", format_unformat_error, i);
14186 if (!vam->json_output)
14188 fformat (vam->ofp, "%-35s%-20s%-30s%-20s%-s\n", "EID", "type",
14189 "ls_index", "ttl", "authoritative");
14192 M (LISP_EID_TABLE_DUMP, lisp_eid_table_dump);
14194 mp->filter = filter;
14198 mp->vni = htonl (vni);
14199 mp->eid_type = eid_type;
14203 mp->prefix_length = prefix_length;
14204 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
14207 mp->prefix_length = prefix_length;
14208 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
14211 clib_memcpy (mp->eid, mac, sizeof (mac));
14214 errmsg ("unknown EID type %d!", eid_type);
14222 /* Use a control ping for synchronization */
14224 vl_api_control_ping_t *mp;
14225 M (CONTROL_PING, control_ping);
14229 /* Wait for a reply... */
14237 api_lisp_gpe_tunnel_dump (vat_main_t * vam)
14239 vl_api_lisp_gpe_tunnel_dump_t *mp;
14242 if (!vam->json_output)
14244 fformat (vam->ofp, "%=20s%=30s%=16s%=16s%=16s%=16s"
14245 "%=16s%=16s%=16s%=16s%=16s\n",
14246 "Tunel", "Source", "Destination", "Fib encap", "Fib decap",
14247 "Decap next", "Lisp version", "Flags", "Next protocol",
14248 "ver_res", "res", "iid");
14251 M (LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump);
14255 /* Use a control ping for synchronization */
14257 vl_api_control_ping_t *mp;
14258 M (CONTROL_PING, control_ping);
14261 /* Wait for a reply... */
14269 api_lisp_adjacencies_get (vat_main_t * vam)
14271 unformat_input_t *i = vam->input;
14272 vl_api_lisp_adjacencies_get_t *mp;
14277 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14279 if (unformat (i, "vni %d", &vni))
14285 errmsg ("parse error '%U'\n", format_unformat_error, i);
14292 errmsg ("vni not set!\n");
14296 if (!vam->json_output)
14298 fformat (vam->ofp, "%s %40s\n", "leid", "reid");
14301 M (LISP_ADJACENCIES_GET, lisp_adjacencies_get);
14302 mp->vni = clib_host_to_net_u32 (vni);
14307 /* Wait for a reply... */
14315 api_lisp_map_resolver_dump (vat_main_t * vam)
14317 vl_api_lisp_map_resolver_dump_t *mp;
14320 if (!vam->json_output)
14322 fformat (vam->ofp, "%=20s\n", "Map resolver");
14325 M (LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump);
14329 /* Use a control ping for synchronization */
14331 vl_api_control_ping_t *mp;
14332 M (CONTROL_PING, control_ping);
14335 /* Wait for a reply... */
14343 api_show_lisp_status (vat_main_t * vam)
14345 vl_api_show_lisp_status_t *mp;
14348 if (!vam->json_output)
14350 fformat (vam->ofp, "%-20s%-16s\n", "lisp status", "locator-set");
14353 M (SHOW_LISP_STATUS, show_lisp_status);
14356 /* Wait for a reply... */
14364 api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
14366 vl_api_lisp_get_map_request_itr_rlocs_t *mp;
14369 if (!vam->json_output)
14371 fformat (vam->ofp, "%=20s\n", "itr-rlocs:");
14374 M (LISP_GET_MAP_REQUEST_ITR_RLOCS, lisp_get_map_request_itr_rlocs);
14377 /* Wait for a reply... */
14385 api_af_packet_create (vat_main_t * vam)
14387 unformat_input_t *i = vam->input;
14388 vl_api_af_packet_create_t *mp;
14390 u8 *host_if_name = 0;
14392 u8 random_hw_addr = 1;
14394 memset (hw_addr, 0, sizeof (hw_addr));
14396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14398 if (unformat (i, "name %s", &host_if_name))
14399 vec_add1 (host_if_name, 0);
14400 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14401 random_hw_addr = 0;
14406 if (!vec_len (host_if_name))
14408 errmsg ("host-interface name must be specified");
14412 if (vec_len (host_if_name) > 64)
14414 errmsg ("host-interface name too long");
14418 M (AF_PACKET_CREATE, af_packet_create);
14420 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14421 clib_memcpy (mp->hw_addr, hw_addr, 6);
14422 mp->use_random_hw_addr = random_hw_addr;
14423 vec_free (host_if_name);
14426 W2 (fprintf (vam->ofp, " new sw_if_index = %d ", vam->sw_if_index));
14432 api_af_packet_delete (vat_main_t * vam)
14434 unformat_input_t *i = vam->input;
14435 vl_api_af_packet_delete_t *mp;
14437 u8 *host_if_name = 0;
14439 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14441 if (unformat (i, "name %s", &host_if_name))
14442 vec_add1 (host_if_name, 0);
14447 if (!vec_len (host_if_name))
14449 errmsg ("host-interface name must be specified");
14453 if (vec_len (host_if_name) > 64)
14455 errmsg ("host-interface name too long");
14459 M (AF_PACKET_DELETE, af_packet_delete);
14461 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
14462 vec_free (host_if_name);
14471 api_policer_add_del (vat_main_t * vam)
14473 unformat_input_t *i = vam->input;
14474 vl_api_policer_add_del_t *mp;
14485 u8 color_aware = 0;
14486 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
14488 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
14489 conform_action.dscp = 0;
14490 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
14491 exceed_action.dscp = 0;
14492 violate_action.action_type = SSE2_QOS_ACTION_DROP;
14493 violate_action.dscp = 0;
14495 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14497 if (unformat (i, "del"))
14499 else if (unformat (i, "name %s", &name))
14500 vec_add1 (name, 0);
14501 else if (unformat (i, "cir %u", &cir))
14503 else if (unformat (i, "eir %u", &eir))
14505 else if (unformat (i, "cb %u", &cb))
14507 else if (unformat (i, "eb %u", &eb))
14509 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
14512 else if (unformat (i, "round_type %U", unformat_policer_round_type,
14515 else if (unformat (i, "type %U", unformat_policer_type, &type))
14517 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
14520 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
14523 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
14526 else if (unformat (i, "color-aware"))
14532 if (!vec_len (name))
14534 errmsg ("policer name must be specified");
14538 if (vec_len (name) > 64)
14540 errmsg ("policer name too long");
14544 M (POLICER_ADD_DEL, policer_add_del);
14546 clib_memcpy (mp->name, name, vec_len (name));
14548 mp->is_add = is_add;
14553 mp->rate_type = rate_type;
14554 mp->round_type = round_type;
14556 mp->conform_action_type = conform_action.action_type;
14557 mp->conform_dscp = conform_action.dscp;
14558 mp->exceed_action_type = exceed_action.action_type;
14559 mp->exceed_dscp = exceed_action.dscp;
14560 mp->violate_action_type = violate_action.action_type;
14561 mp->violate_dscp = violate_action.dscp;
14562 mp->color_aware = color_aware;
14571 api_policer_dump (vat_main_t * vam)
14573 unformat_input_t *i = vam->input;
14574 vl_api_policer_dump_t *mp;
14576 u8 *match_name = 0;
14577 u8 match_name_valid = 0;
14579 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14581 if (unformat (i, "name %s", &match_name))
14583 vec_add1 (match_name, 0);
14584 match_name_valid = 1;
14590 M (POLICER_DUMP, policer_dump);
14591 mp->match_name_valid = match_name_valid;
14592 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
14593 vec_free (match_name);
14597 /* Use a control ping for synchronization */
14599 vl_api_control_ping_t *mp;
14600 M (CONTROL_PING, control_ping);
14603 /* Wait for a reply... */
14611 api_policer_classify_set_interface (vat_main_t * vam)
14613 unformat_input_t *i = vam->input;
14614 vl_api_policer_classify_set_interface_t *mp;
14617 int sw_if_index_set;
14618 u32 ip4_table_index = ~0;
14619 u32 ip6_table_index = ~0;
14620 u32 l2_table_index = ~0;
14623 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14625 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
14626 sw_if_index_set = 1;
14627 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14628 sw_if_index_set = 1;
14629 else if (unformat (i, "del"))
14631 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14633 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14635 else if (unformat (i, "l2-table %d", &l2_table_index))
14639 clib_warning ("parse error '%U'", format_unformat_error, i);
14644 if (sw_if_index_set == 0)
14646 errmsg ("missing interface name or sw_if_index\n");
14650 M (POLICER_CLASSIFY_SET_INTERFACE, policer_classify_set_interface);
14652 mp->sw_if_index = ntohl (sw_if_index);
14653 mp->ip4_table_index = ntohl (ip4_table_index);
14654 mp->ip6_table_index = ntohl (ip6_table_index);
14655 mp->l2_table_index = ntohl (l2_table_index);
14656 mp->is_add = is_add;
14665 api_policer_classify_dump (vat_main_t * vam)
14667 unformat_input_t *i = vam->input;
14668 vl_api_policer_classify_dump_t *mp;
14670 u8 type = POLICER_CLASSIFY_N_TABLES;
14672 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
14676 errmsg ("classify table type must be specified\n");
14680 if (!vam->json_output)
14682 fformat (vam->ofp, "%10s%20s\n", "Intfc idx", "Classify table");
14685 M (POLICER_CLASSIFY_DUMP, policer_classify_dump);
14690 /* Use a control ping for synchronization */
14692 vl_api_control_ping_t *mp;
14693 M (CONTROL_PING, control_ping);
14696 /* Wait for a reply... */
14704 api_netmap_create (vat_main_t * vam)
14706 unformat_input_t *i = vam->input;
14707 vl_api_netmap_create_t *mp;
14711 u8 random_hw_addr = 1;
14715 memset (hw_addr, 0, sizeof (hw_addr));
14717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14719 if (unformat (i, "name %s", &if_name))
14720 vec_add1 (if_name, 0);
14721 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
14722 random_hw_addr = 0;
14723 else if (unformat (i, "pipe"))
14725 else if (unformat (i, "master"))
14727 else if (unformat (i, "slave"))
14733 if (!vec_len (if_name))
14735 errmsg ("interface name must be specified");
14739 if (vec_len (if_name) > 64)
14741 errmsg ("interface name too long");
14745 M (NETMAP_CREATE, netmap_create);
14747 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
14748 clib_memcpy (mp->hw_addr, hw_addr, 6);
14749 mp->use_random_hw_addr = random_hw_addr;
14750 mp->is_pipe = is_pipe;
14751 mp->is_master = is_master;
14752 vec_free (if_name);
14761 api_netmap_delete (vat_main_t * vam)
14763 unformat_input_t *i = vam->input;
14764 vl_api_netmap_delete_t *mp;
14768 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14770 if (unformat (i, "name %s", &if_name))
14771 vec_add1 (if_name, 0);
14776 if (!vec_len (if_name))
14778 errmsg ("interface name must be specified");
14782 if (vec_len (if_name) > 64)
14784 errmsg ("interface name too long");
14788 M (NETMAP_DELETE, netmap_delete);
14790 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
14791 vec_free (if_name);
14799 static void vl_api_mpls_eth_tunnel_details_t_handler
14800 (vl_api_mpls_eth_tunnel_details_t * mp)
14802 vat_main_t *vam = &vat_main;
14804 i32 len = ntohl (mp->nlabels);
14806 fformat (vam->ofp, "[%d]: dst %U, adj %U/%d, labels ",
14807 ntohl (mp->tunnel_index),
14808 format_ethernet_address, &mp->tunnel_dst_mac,
14809 format_ip4_address, &mp->intfc_address, ntohl (mp->mask_width));
14810 for (i = 0; i < len; i++)
14812 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14814 fformat (vam->ofp, "\n");
14815 fformat (vam->ofp, " tx on %d, rx fib index %d\n",
14816 ntohl (mp->tx_sw_if_index), ntohl (mp->inner_fib_index));
14819 static void vl_api_mpls_eth_tunnel_details_t_handler_json
14820 (vl_api_mpls_eth_tunnel_details_t * mp)
14822 vat_main_t *vam = &vat_main;
14823 vat_json_node_t *node = NULL;
14824 struct in_addr ip4;
14826 i32 len = ntohl (mp->nlabels);
14828 if (VAT_JSON_ARRAY != vam->json_tree.type)
14830 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14831 vat_json_init_array (&vam->json_tree);
14833 node = vat_json_array_add (&vam->json_tree);
14835 vat_json_init_object (node);
14836 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
14837 clib_memcpy (&ip4, &(mp->intfc_address), sizeof (ip4));
14838 vat_json_object_add_ip4 (node, "intfc_address", ip4);
14839 vat_json_object_add_uint (node, "inner_fib_index",
14840 ntohl (mp->inner_fib_index));
14841 vat_json_object_add_uint (node, "mask_width", ntohl (mp->mask_width));
14842 vat_json_object_add_uint (node, "encap_index", ntohl (mp->encap_index));
14843 vat_json_object_add_uint (node, "hw_if_index", ntohl (mp->hw_if_index));
14844 vat_json_object_add_uint (node, "l2_only", ntohl (mp->l2_only));
14845 vat_json_object_add_string_copy (node, "tunnel_dst_mac",
14846 format (0, "%U", format_ethernet_address,
14847 &mp->tunnel_dst_mac));
14848 vat_json_object_add_uint (node, "tx_sw_if_index",
14849 ntohl (mp->tx_sw_if_index));
14850 vat_json_object_add_uint (node, "label_count", len);
14851 for (i = 0; i < len; i++)
14853 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14858 api_mpls_eth_tunnel_dump (vat_main_t * vam)
14860 vl_api_mpls_eth_tunnel_dump_t *mp;
14864 /* Parse args required to build the message */
14865 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
14867 if (!unformat (vam->input, "tunnel_index %d", &index))
14874 fformat (vam->ofp, " tunnel_index %d\n", index);
14876 M (MPLS_ETH_TUNNEL_DUMP, mpls_eth_tunnel_dump);
14877 mp->tunnel_index = htonl (index);
14880 /* Use a control ping for synchronization */
14882 vl_api_control_ping_t *mp;
14883 M (CONTROL_PING, control_ping);
14889 static void vl_api_mpls_fib_encap_details_t_handler
14890 (vl_api_mpls_fib_encap_details_t * mp)
14892 vat_main_t *vam = &vat_main;
14894 i32 len = ntohl (mp->nlabels);
14896 fformat (vam->ofp, "table %d, dest %U, label ",
14897 ntohl (mp->fib_index), format_ip4_address, &mp->dest, len);
14898 for (i = 0; i < len; i++)
14900 fformat (vam->ofp, "%u ", ntohl (mp->labels[i]));
14902 fformat (vam->ofp, "\n");
14905 static void vl_api_mpls_fib_encap_details_t_handler_json
14906 (vl_api_mpls_fib_encap_details_t * mp)
14908 vat_main_t *vam = &vat_main;
14909 vat_json_node_t *node = NULL;
14911 i32 len = ntohl (mp->nlabels);
14912 struct in_addr ip4;
14914 if (VAT_JSON_ARRAY != vam->json_tree.type)
14916 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14917 vat_json_init_array (&vam->json_tree);
14919 node = vat_json_array_add (&vam->json_tree);
14921 vat_json_init_object (node);
14922 vat_json_object_add_uint (node, "table", ntohl (mp->fib_index));
14923 vat_json_object_add_uint (node, "entry_index", ntohl (mp->entry_index));
14924 clib_memcpy (&ip4, &(mp->dest), sizeof (ip4));
14925 vat_json_object_add_ip4 (node, "dest", ip4);
14926 vat_json_object_add_uint (node, "s_bit", ntohl (mp->s_bit));
14927 vat_json_object_add_uint (node, "label_count", len);
14928 for (i = 0; i < len; i++)
14930 vat_json_object_add_uint (node, "label", ntohl (mp->labels[i]));
14935 api_mpls_fib_encap_dump (vat_main_t * vam)
14937 vl_api_mpls_fib_encap_dump_t *mp;
14940 M (MPLS_FIB_ENCAP_DUMP, mpls_fib_encap_dump);
14943 /* Use a control ping for synchronization */
14945 vl_api_control_ping_t *mp;
14946 M (CONTROL_PING, control_ping);
14952 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
14953 #define vl_api_mpls_fib_details_t_print vl_noop_handler
14956 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
14958 vat_main_t *vam = &vat_main;
14959 int count = ntohl (mp->count);
14960 vl_api_fib_path_t *fp;
14964 "table-id %d, label %u, ess_bit %u\n",
14965 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
14967 for (i = 0; i < count; i++)
14969 if (fp->afi == IP46_TYPE_IP6)
14971 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
14972 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
14973 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
14974 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
14975 format_ip6_address, fp->next_hop);
14976 else if (fp->afi == IP46_TYPE_IP4)
14978 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
14979 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
14980 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
14981 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
14982 format_ip4_address, fp->next_hop);
14987 static void vl_api_mpls_fib_details_t_handler_json
14988 (vl_api_mpls_fib_details_t * mp)
14990 vat_main_t *vam = &vat_main;
14991 int count = ntohl (mp->count);
14992 vat_json_node_t *node = NULL;
14993 struct in_addr ip4;
14994 struct in6_addr ip6;
14995 vl_api_fib_path_t *fp;
14998 if (VAT_JSON_ARRAY != vam->json_tree.type)
15000 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15001 vat_json_init_array (&vam->json_tree);
15003 node = vat_json_array_add (&vam->json_tree);
15005 vat_json_init_object (node);
15006 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15007 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
15008 vat_json_object_add_uint (node, "label", ntohl (mp->label));
15009 vat_json_object_add_uint (node, "path_count", count);
15011 for (i = 0; i < count; i++)
15013 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15014 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15015 vat_json_object_add_uint (node, "is_local", fp->is_local);
15016 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15017 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15018 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15019 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15020 if (fp->afi == IP46_TYPE_IP4)
15022 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15023 vat_json_object_add_ip4 (node, "next_hop", ip4);
15025 else if (fp->afi == IP46_TYPE_IP6)
15027 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15028 vat_json_object_add_ip6 (node, "next_hop", ip6);
15034 api_mpls_fib_dump (vat_main_t * vam)
15036 vl_api_mpls_fib_dump_t *mp;
15039 M (MPLS_FIB_DUMP, mpls_fib_dump);
15042 /* Use a control ping for synchronization */
15044 vl_api_control_ping_t *mp;
15045 M (CONTROL_PING, control_ping);
15051 #define vl_api_ip_fib_details_t_endian vl_noop_handler
15052 #define vl_api_ip_fib_details_t_print vl_noop_handler
15055 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
15057 vat_main_t *vam = &vat_main;
15058 int count = ntohl (mp->count);
15059 vl_api_fib_path_t *fp;
15063 "table-id %d, prefix %U/%d\n",
15064 ntohl (mp->table_id), format_ip4_address, mp->address,
15065 mp->address_length);
15067 for (i = 0; i < count; i++)
15069 if (fp->afi == IP46_TYPE_IP6)
15071 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15072 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15073 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15074 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15075 format_ip6_address, fp->next_hop);
15076 else if (fp->afi == IP46_TYPE_IP4)
15078 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15079 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15080 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15081 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15082 format_ip4_address, fp->next_hop);
15087 static void vl_api_ip_fib_details_t_handler_json
15088 (vl_api_ip_fib_details_t * mp)
15090 vat_main_t *vam = &vat_main;
15091 int count = ntohl (mp->count);
15092 vat_json_node_t *node = NULL;
15093 struct in_addr ip4;
15094 struct in6_addr ip6;
15095 vl_api_fib_path_t *fp;
15098 if (VAT_JSON_ARRAY != vam->json_tree.type)
15100 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15101 vat_json_init_array (&vam->json_tree);
15103 node = vat_json_array_add (&vam->json_tree);
15105 vat_json_init_object (node);
15106 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15107 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
15108 vat_json_object_add_ip4 (node, "prefix", ip4);
15109 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15110 vat_json_object_add_uint (node, "path_count", count);
15112 for (i = 0; i < count; i++)
15114 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15115 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15116 vat_json_object_add_uint (node, "is_local", fp->is_local);
15117 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15118 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15119 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15120 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15121 if (fp->afi == IP46_TYPE_IP4)
15123 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15124 vat_json_object_add_ip4 (node, "next_hop", ip4);
15126 else if (fp->afi == IP46_TYPE_IP6)
15128 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15129 vat_json_object_add_ip6 (node, "next_hop", ip6);
15135 api_ip_fib_dump (vat_main_t * vam)
15137 vl_api_ip_fib_dump_t *mp;
15140 M (IP_FIB_DUMP, ip_fib_dump);
15143 /* Use a control ping for synchronization */
15145 vl_api_control_ping_t *mp;
15146 M (CONTROL_PING, control_ping);
15152 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
15153 #define vl_api_ip6_fib_details_t_print vl_noop_handler
15156 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
15158 vat_main_t *vam = &vat_main;
15159 int count = ntohl (mp->count);
15160 vl_api_fib_path_t *fp;
15164 "table-id %d, prefix %U/%d\n",
15165 ntohl (mp->table_id), format_ip6_address, mp->address,
15166 mp->address_length);
15168 for (i = 0; i < count; i++)
15170 if (fp->afi == IP46_TYPE_IP6)
15172 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15173 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15174 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15175 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15176 format_ip6_address, fp->next_hop);
15177 else if (fp->afi == IP46_TYPE_IP4)
15179 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15180 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U\n",
15181 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15182 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15183 format_ip4_address, fp->next_hop);
15188 static void vl_api_ip6_fib_details_t_handler_json
15189 (vl_api_ip6_fib_details_t * mp)
15191 vat_main_t *vam = &vat_main;
15192 int count = ntohl (mp->count);
15193 vat_json_node_t *node = NULL;
15194 struct in_addr ip4;
15195 struct in6_addr ip6;
15196 vl_api_fib_path_t *fp;
15199 if (VAT_JSON_ARRAY != vam->json_tree.type)
15201 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15202 vat_json_init_array (&vam->json_tree);
15204 node = vat_json_array_add (&vam->json_tree);
15206 vat_json_init_object (node);
15207 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15208 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
15209 vat_json_object_add_ip6 (node, "prefix", ip6);
15210 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15211 vat_json_object_add_uint (node, "path_count", count);
15213 for (i = 0; i < count; i++)
15215 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15216 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15217 vat_json_object_add_uint (node, "is_local", fp->is_local);
15218 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15219 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15220 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15221 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15222 if (fp->afi == IP46_TYPE_IP4)
15224 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15225 vat_json_object_add_ip4 (node, "next_hop", ip4);
15227 else if (fp->afi == IP46_TYPE_IP6)
15229 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15230 vat_json_object_add_ip6 (node, "next_hop", ip6);
15236 api_ip6_fib_dump (vat_main_t * vam)
15238 vl_api_ip6_fib_dump_t *mp;
15241 M (IP6_FIB_DUMP, ip6_fib_dump);
15244 /* Use a control ping for synchronization */
15246 vl_api_control_ping_t *mp;
15247 M (CONTROL_PING, control_ping);
15254 api_classify_table_ids (vat_main_t * vam)
15256 vl_api_classify_table_ids_t *mp;
15259 /* Construct the API message */
15260 M (CLASSIFY_TABLE_IDS, classify_table_ids);
15270 api_classify_table_by_interface (vat_main_t * vam)
15272 unformat_input_t *input = vam->input;
15273 vl_api_classify_table_by_interface_t *mp;
15276 u32 sw_if_index = ~0;
15277 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15279 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
15281 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15286 if (sw_if_index == ~0)
15288 errmsg ("missing interface name or sw_if_index\n");
15292 /* Construct the API message */
15293 M (CLASSIFY_TABLE_BY_INTERFACE, classify_table_by_interface);
15295 mp->sw_if_index = ntohl (sw_if_index);
15304 api_classify_table_info (vat_main_t * vam)
15306 unformat_input_t *input = vam->input;
15307 vl_api_classify_table_info_t *mp;
15311 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15313 if (unformat (input, "table_id %d", &table_id))
15318 if (table_id == ~0)
15320 errmsg ("missing table id\n");
15324 /* Construct the API message */
15325 M (CLASSIFY_TABLE_INFO, classify_table_info);
15327 mp->table_id = ntohl (table_id);
15336 api_classify_session_dump (vat_main_t * vam)
15338 unformat_input_t *input = vam->input;
15339 vl_api_classify_session_dump_t *mp;
15343 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15345 if (unformat (input, "table_id %d", &table_id))
15350 if (table_id == ~0)
15352 errmsg ("missing table id\n");
15356 /* Construct the API message */
15357 M (CLASSIFY_SESSION_DUMP, classify_session_dump);
15359 mp->table_id = ntohl (table_id);
15362 /* Use a control ping for synchronization */
15364 vl_api_control_ping_t *mp;
15365 M (CONTROL_PING, control_ping);
15374 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
15376 vat_main_t *vam = &vat_main;
15378 fformat (vam->ofp, "collector_address %U, collector_port %d, "
15379 "src_address %U, vrf_id %d, path_mtu %u, "
15380 "template_interval %u, udp_checksum %d\n",
15381 format_ip4_address, mp->collector_address,
15382 ntohs (mp->collector_port),
15383 format_ip4_address, mp->src_address,
15384 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
15385 ntohl (mp->template_interval), mp->udp_checksum);
15388 vam->result_ready = 1;
15392 vl_api_ipfix_exporter_details_t_handler_json
15393 (vl_api_ipfix_exporter_details_t * mp)
15395 vat_main_t *vam = &vat_main;
15396 vat_json_node_t node;
15397 struct in_addr collector_address;
15398 struct in_addr src_address;
15400 vat_json_init_object (&node);
15401 clib_memcpy (&collector_address, &mp->collector_address,
15402 sizeof (collector_address));
15403 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
15404 vat_json_object_add_uint (&node, "collector_port",
15405 ntohs (mp->collector_port));
15406 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
15407 vat_json_object_add_ip4 (&node, "src_address", src_address);
15408 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
15409 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
15410 vat_json_object_add_uint (&node, "template_interval",
15411 ntohl (mp->template_interval));
15412 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
15414 vat_json_print (vam->ofp, &node);
15415 vat_json_free (&node);
15417 vam->result_ready = 1;
15421 api_ipfix_exporter_dump (vat_main_t * vam)
15423 vl_api_ipfix_exporter_dump_t *mp;
15426 /* Construct the API message */
15427 M (IPFIX_EXPORTER_DUMP, ipfix_exporter_dump);
15437 api_ipfix_classify_stream_dump (vat_main_t * vam)
15439 vl_api_ipfix_classify_stream_dump_t *mp;
15442 /* Construct the API message */
15443 M (IPFIX_CLASSIFY_STREAM_DUMP, ipfix_classify_stream_dump);
15453 vl_api_ipfix_classify_stream_details_t_handler
15454 (vl_api_ipfix_classify_stream_details_t * mp)
15456 vat_main_t *vam = &vat_main;
15457 fformat (vam->ofp, "domain_id %d, src_port %d\n",
15458 ntohl (mp->domain_id), ntohs (mp->src_port));
15460 vam->result_ready = 1;
15464 vl_api_ipfix_classify_stream_details_t_handler_json
15465 (vl_api_ipfix_classify_stream_details_t * mp)
15467 vat_main_t *vam = &vat_main;
15468 vat_json_node_t node;
15470 vat_json_init_object (&node);
15471 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
15472 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
15474 vat_json_print (vam->ofp, &node);
15475 vat_json_free (&node);
15477 vam->result_ready = 1;
15481 api_ipfix_classify_table_dump (vat_main_t * vam)
15483 vl_api_ipfix_classify_table_dump_t *mp;
15486 if (!vam->json_output)
15488 fformat (vam->ofp, "%15s%15s%20s\n", "table_id", "ip_version",
15489 "transport_protocol");
15492 /* Construct the API message */
15493 M (IPFIX_CLASSIFY_TABLE_DUMP, ipfix_classify_table_dump);
15498 /* Use a control ping for synchronization */
15500 vl_api_control_ping_t *mp;
15501 M (CONTROL_PING, control_ping);
15508 vl_api_ipfix_classify_table_details_t_handler
15509 (vl_api_ipfix_classify_table_details_t * mp)
15511 vat_main_t *vam = &vat_main;
15512 fformat (vam->ofp, "%15d%15d%20d\n", ntohl (mp->table_id), mp->ip_version,
15513 mp->transport_protocol);
15517 vl_api_ipfix_classify_table_details_t_handler_json
15518 (vl_api_ipfix_classify_table_details_t * mp)
15520 vat_json_node_t *node = NULL;
15521 vat_main_t *vam = &vat_main;
15523 if (VAT_JSON_ARRAY != vam->json_tree.type)
15525 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15526 vat_json_init_array (&vam->json_tree);
15529 node = vat_json_array_add (&vam->json_tree);
15530 vat_json_init_object (node);
15532 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
15533 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
15534 vat_json_object_add_uint (node, "transport_protocol",
15535 mp->transport_protocol);
15539 api_sw_interface_span_enable_disable (vat_main_t * vam)
15541 unformat_input_t *i = vam->input;
15542 vl_api_sw_interface_span_enable_disable_t *mp;
15544 u32 src_sw_if_index = ~0;
15545 u32 dst_sw_if_index = ~0;
15548 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15550 if (unformat (i, "src %U", unformat_sw_if_index, vam, &src_sw_if_index))
15552 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
15556 (i, "dst %U", unformat_sw_if_index, vam, &dst_sw_if_index))
15558 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
15560 else if (unformat (i, "disable"))
15566 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, sw_interface_span_enable_disable);
15568 mp->sw_if_index_from = htonl (src_sw_if_index);
15569 mp->sw_if_index_to = htonl (dst_sw_if_index);
15570 mp->enable = enable;
15579 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
15582 vat_main_t *vam = &vat_main;
15584 fformat (vam->ofp, "%u => %u\n",
15585 ntohl (mp->sw_if_index_from), ntohl (mp->sw_if_index_to));
15589 vl_api_sw_interface_span_details_t_handler_json
15590 (vl_api_sw_interface_span_details_t * mp)
15592 vat_main_t *vam = &vat_main;
15593 vat_json_node_t *node = NULL;
15595 if (VAT_JSON_ARRAY != vam->json_tree.type)
15597 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15598 vat_json_init_array (&vam->json_tree);
15600 node = vat_json_array_add (&vam->json_tree);
15602 vat_json_init_object (node);
15603 vat_json_object_add_uint (node, "src-if-index",
15604 ntohl (mp->sw_if_index_from));
15605 vat_json_object_add_uint (node, "dst-if-index", ntohl (mp->sw_if_index_to));
15609 api_sw_interface_span_dump (vat_main_t * vam)
15611 vl_api_sw_interface_span_dump_t *mp;
15614 M (SW_INTERFACE_SPAN_DUMP, sw_interface_span_dump);
15617 /* Use a control ping for synchronization */
15619 vl_api_control_ping_t *mp;
15620 M (CONTROL_PING, control_ping);
15627 api_pg_create_interface (vat_main_t * vam)
15629 unformat_input_t *input = vam->input;
15630 vl_api_pg_create_interface_t *mp;
15634 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15636 if (unformat (input, "if_id %d", &if_id))
15643 errmsg ("missing pg interface index\n");
15647 /* Construct the API message */
15648 M (PG_CREATE_INTERFACE, pg_create_interface);
15650 mp->interface_id = ntohl (if_id);
15659 api_pg_capture (vat_main_t * vam)
15661 unformat_input_t *input = vam->input;
15662 vl_api_pg_capture_t *mp;
15668 u8 pcap_file_set = 0;
15670 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15672 if (unformat (input, "if_id %d", &if_id))
15674 else if (unformat (input, "pcap %s", &pcap_file))
15676 else if (unformat (input, "count %d", &count))
15678 else if (unformat (input, "disable"))
15685 errmsg ("missing pg interface index\n");
15688 if (pcap_file_set > 0)
15690 if (vec_len (pcap_file) > 255)
15692 errmsg ("pcap file name is too long\n");
15697 u32 name_len = vec_len (pcap_file);
15698 /* Construct the API message */
15699 M (PG_CAPTURE, pg_capture);
15701 mp->interface_id = ntohl (if_id);
15702 mp->is_enabled = enable;
15703 mp->count = ntohl (count);
15704 mp->pcap_name_length = ntohl (name_len);
15705 if (pcap_file_set != 0)
15707 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
15709 vec_free (pcap_file);
15718 api_pg_enable_disable (vat_main_t * vam)
15720 unformat_input_t *input = vam->input;
15721 vl_api_pg_enable_disable_t *mp;
15725 u8 stream_name_set = 0;
15726 u8 *stream_name = 0;
15727 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15729 if (unformat (input, "stream %s", &stream_name))
15730 stream_name_set = 1;
15731 else if (unformat (input, "disable"))
15737 if (stream_name_set > 0)
15739 if (vec_len (stream_name) > 255)
15741 errmsg ("stream name too long\n");
15746 u32 name_len = vec_len (stream_name);
15747 /* Construct the API message */
15748 M (PG_ENABLE_DISABLE, pg_enable_disable);
15750 mp->is_enabled = enable;
15751 if (stream_name_set != 0)
15753 mp->stream_name_length = ntohl (name_len);
15754 clib_memcpy (mp->stream_name, stream_name, name_len);
15756 vec_free (stream_name);
15765 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
15767 unformat_input_t *input = vam->input;
15768 vl_api_ip_source_and_port_range_check_add_del_t *mp;
15771 u16 *low_ports = 0;
15772 u16 *high_ports = 0;
15775 ip4_address_t ip4_addr;
15776 ip6_address_t ip6_addr;
15784 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15786 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
15792 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
15797 else if (unformat (input, "vrf %d", &vrf_id))
15799 else if (unformat (input, "del"))
15801 else if (unformat (input, "port %d", &tmp))
15803 if (tmp == 0 || tmp > 65535)
15805 errmsg ("port %d out of range", tmp);
15809 this_hi = this_low + 1;
15810 vec_add1 (low_ports, this_low);
15811 vec_add1 (high_ports, this_hi);
15813 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
15815 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
15817 errmsg ("incorrect range parameters\n");
15821 /* Note: in debug CLI +1 is added to high before
15822 passing to real fn that does "the work"
15823 (ip_source_and_port_range_check_add_del).
15824 This fn is a wrapper around the binary API fn a
15825 control plane will call, which expects this increment
15826 to have occurred. Hence letting the binary API control
15827 plane fn do the increment for consistency between VAT
15828 and other control planes.
15831 vec_add1 (low_ports, this_low);
15832 vec_add1 (high_ports, this_hi);
15838 if (prefix_set == 0)
15840 errmsg ("<address>/<mask> not specified\n");
15846 errmsg ("VRF ID required, not specified\n");
15853 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
15857 if (vec_len (low_ports) == 0)
15859 errmsg ("At least one port or port range required\n");
15863 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL,
15864 ip_source_and_port_range_check_add_del);
15866 mp->is_add = is_add;
15871 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
15876 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
15879 mp->mask_length = length;
15880 mp->number_of_ranges = vec_len (low_ports);
15882 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
15883 vec_free (low_ports);
15885 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
15886 vec_free (high_ports);
15888 mp->vrf_id = ntohl (vrf_id);
15897 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
15899 unformat_input_t *input = vam->input;
15900 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
15902 u32 sw_if_index = ~0;
15904 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
15905 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
15908 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15910 if (unformat (input, "%U", unformat_sw_if_index, vam, &sw_if_index))
15912 else if (unformat (input, "sw_if_index %d", &sw_if_index))
15914 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
15916 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
15918 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
15920 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
15922 else if (unformat (input, "del"))
15928 if (sw_if_index == ~0)
15930 errmsg ("Interface required but not specified\n");
15936 errmsg ("VRF ID required but not specified\n");
15940 if (tcp_out_vrf_id == 0
15941 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
15944 ("VRF ID should not be default. Should be distinct VRF for this purpose.\n");
15948 /* Construct the API message */
15949 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL,
15950 ip_source_and_port_range_check_interface_add_del);
15952 mp->sw_if_index = ntohl (sw_if_index);
15953 mp->is_add = is_add;
15954 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
15955 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
15956 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
15957 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
15962 /* Wait for a reply... */
15967 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
15969 unformat_input_t *i = vam->input;
15970 vl_api_ipsec_gre_add_del_tunnel_t *mp;
15972 u32 local_sa_id = 0;
15973 u32 remote_sa_id = 0;
15974 ip4_address_t src_address;
15975 ip4_address_t dst_address;
15978 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15980 if (unformat (i, "local_sa %d", &local_sa_id))
15982 else if (unformat (i, "remote_sa %d", &remote_sa_id))
15984 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
15986 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
15988 else if (unformat (i, "del"))
15992 clib_warning ("parse error '%U'", format_unformat_error, i);
15997 M (IPSEC_GRE_ADD_DEL_TUNNEL, ipsec_gre_add_del_tunnel);
15999 mp->local_sa_id = ntohl (local_sa_id);
16000 mp->remote_sa_id = ntohl (remote_sa_id);
16001 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
16002 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
16003 mp->is_add = is_add;
16012 api_punt (vat_main_t * vam)
16014 unformat_input_t *i = vam->input;
16022 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16024 if (unformat (i, "ip %d", &ipv))
16026 else if (unformat (i, "protocol %d", &protocol))
16028 else if (unformat (i, "port %d", &port))
16030 else if (unformat (i, "del"))
16034 clib_warning ("parse error '%U'", format_unformat_error, i);
16041 mp->is_add = (u8) is_add;
16042 mp->ipv = (u8) ipv;
16043 mp->l4_protocol = (u8) protocol;
16044 mp->l4_port = htons ((u16) port);
16052 static void vl_api_ipsec_gre_tunnel_details_t_handler
16053 (vl_api_ipsec_gre_tunnel_details_t * mp)
16055 vat_main_t *vam = &vat_main;
16057 fformat (vam->ofp, "%11d%15U%15U%14d%14d\n",
16058 ntohl (mp->sw_if_index),
16059 format_ip4_address, &mp->src_address,
16060 format_ip4_address, &mp->dst_address,
16061 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
16064 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
16065 (vl_api_ipsec_gre_tunnel_details_t * mp)
16067 vat_main_t *vam = &vat_main;
16068 vat_json_node_t *node = NULL;
16069 struct in_addr ip4;
16071 if (VAT_JSON_ARRAY != vam->json_tree.type)
16073 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16074 vat_json_init_array (&vam->json_tree);
16076 node = vat_json_array_add (&vam->json_tree);
16078 vat_json_init_object (node);
16079 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
16080 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
16081 vat_json_object_add_ip4 (node, "src_address", ip4);
16082 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
16083 vat_json_object_add_ip4 (node, "dst_address", ip4);
16084 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
16085 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
16089 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
16091 unformat_input_t *i = vam->input;
16092 vl_api_ipsec_gre_tunnel_dump_t *mp;
16095 u8 sw_if_index_set = 0;
16097 /* Parse args required to build the message */
16098 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16100 if (unformat (i, "sw_if_index %d", &sw_if_index))
16101 sw_if_index_set = 1;
16106 if (sw_if_index_set == 0)
16111 if (!vam->json_output)
16113 fformat (vam->ofp, "%11s%15s%15s%14s%14s\n",
16114 "sw_if_index", "src_address", "dst_address",
16115 "local_sa_id", "remote_sa_id");
16118 /* Get list of gre-tunnel interfaces */
16119 M (IPSEC_GRE_TUNNEL_DUMP, ipsec_gre_tunnel_dump);
16121 mp->sw_if_index = htonl (sw_if_index);
16125 /* Use a control ping for synchronization */
16127 vl_api_control_ping_t *mp;
16128 M (CONTROL_PING, control_ping);
16135 api_delete_subif (vat_main_t * vam)
16137 unformat_input_t *i = vam->input;
16138 vl_api_delete_subif_t *mp;
16140 u32 sw_if_index = ~0;
16142 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16144 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16146 if (unformat (i, "sw_if_index %d", &sw_if_index))
16152 if (sw_if_index == ~0)
16154 errmsg ("missing sw_if_index\n");
16158 /* Construct the API message */
16159 M (DELETE_SUBIF, delete_subif);
16160 mp->sw_if_index = ntohl (sw_if_index);
16166 #define foreach_pbb_vtr_op \
16167 _("disable", L2_VTR_DISABLED) \
16168 _("pop", L2_VTR_POP_2) \
16169 _("push", L2_VTR_PUSH_2)
16172 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
16174 unformat_input_t *i = vam->input;
16175 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
16177 u32 sw_if_index = ~0, vtr_op = ~0;
16178 u16 outer_tag = ~0;
16179 u8 dmac[6], smac[6];
16180 u8 dmac_set = 0, smac_set = 0;
16185 /* Shut up coverity */
16186 memset (dmac, 0, sizeof (dmac));
16187 memset (smac, 0, sizeof (smac));
16189 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16191 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16193 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16195 else if (unformat (i, "vtr_op %d", &vtr_op))
16197 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
16200 else if (unformat (i, "translate_pbb_stag"))
16202 if (unformat (i, "%d", &tmp))
16204 vtr_op = L2_VTR_TRANSLATE_2_1;
16210 ("translate_pbb_stag operation requires outer tag definition\n");
16214 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
16216 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
16218 else if (unformat (i, "sid %d", &sid))
16220 else if (unformat (i, "vlanid %d", &tmp))
16224 clib_warning ("parse error '%U'", format_unformat_error, i);
16229 if ((sw_if_index == ~0) || (vtr_op == ~0))
16231 errmsg ("missing sw_if_index or vtr operation\n");
16234 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
16235 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
16238 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid\n");
16242 M (L2_INTERFACE_PBB_TAG_REWRITE, l2_interface_pbb_tag_rewrite);
16243 mp->sw_if_index = ntohl (sw_if_index);
16244 mp->vtr_op = ntohl (vtr_op);
16245 mp->outer_tag = ntohs (outer_tag);
16246 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
16247 clib_memcpy (mp->b_smac, smac, sizeof (smac));
16248 mp->b_vlanid = ntohs (vlanid);
16249 mp->i_sid = ntohl (sid);
16258 api_flow_classify_set_interface (vat_main_t * vam)
16260 unformat_input_t *i = vam->input;
16261 vl_api_flow_classify_set_interface_t *mp;
16264 int sw_if_index_set;
16265 u32 ip4_table_index = ~0;
16266 u32 ip6_table_index = ~0;
16269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16271 if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16272 sw_if_index_set = 1;
16273 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16274 sw_if_index_set = 1;
16275 else if (unformat (i, "del"))
16277 else if (unformat (i, "ip4-table %d", &ip4_table_index))
16279 else if (unformat (i, "ip6-table %d", &ip6_table_index))
16283 clib_warning ("parse error '%U'", format_unformat_error, i);
16288 if (sw_if_index_set == 0)
16290 errmsg ("missing interface name or sw_if_index\n");
16294 M (FLOW_CLASSIFY_SET_INTERFACE, flow_classify_set_interface);
16296 mp->sw_if_index = ntohl (sw_if_index);
16297 mp->ip4_table_index = ntohl (ip4_table_index);
16298 mp->ip6_table_index = ntohl (ip6_table_index);
16299 mp->is_add = is_add;
16308 api_flow_classify_dump (vat_main_t * vam)
16310 unformat_input_t *i = vam->input;
16311 vl_api_flow_classify_dump_t *mp;
16313 u8 type = FLOW_CLASSIFY_N_TABLES;
16315 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
16319 errmsg ("classify table type must be specified\n");
16323 if (!vam->json_output)
16325 fformat (vam->ofp, "%10s%20s\n", "Intfc idx", "Classify table");
16328 M (FLOW_CLASSIFY_DUMP, flow_classify_dump);
16333 /* Use a control ping for synchronization */
16335 vl_api_control_ping_t *mp;
16336 M (CONTROL_PING, control_ping);
16339 /* Wait for a reply... */
16347 api_feature_enable_disable (vat_main_t * vam)
16349 unformat_input_t *i = vam->input;
16350 vl_api_feature_enable_disable_t *mp;
16353 u8 *feature_name = 0;
16354 u32 sw_if_index = ~0;
16357 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16359 if (unformat (i, "arc_name %s", &arc_name))
16361 else if (unformat (i, "feature_name %s", &feature_name))
16363 else if (unformat (i, "%U", unformat_sw_if_index, vam, &sw_if_index))
16365 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16367 else if (unformat (i, "disable"))
16375 errmsg ("missing arc name\n");
16378 if (vec_len (arc_name) > 63)
16380 errmsg ("arc name too long\n");
16383 if (feature_name == 0)
16385 errmsg ("missing feature name\n");
16388 if (vec_len (feature_name) > 63)
16390 errmsg ("feature name too long\n");
16393 if (sw_if_index == ~0)
16395 errmsg ("missing interface name or sw_if_index\n");
16399 /* Construct the API message */
16400 M (FEATURE_ENABLE_DISABLE, feature_enable_disable);
16401 mp->sw_if_index = ntohl (sw_if_index);
16402 mp->enable = enable;
16403 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
16404 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
16405 vec_free (arc_name);
16406 vec_free (feature_name);
16413 q_or_quit (vat_main_t * vam)
16415 longjmp (vam->jump_buf, 1);
16416 return 0; /* not so much */
16420 q (vat_main_t * vam)
16422 return q_or_quit (vam);
16426 quit (vat_main_t * vam)
16428 return q_or_quit (vam);
16432 comment (vat_main_t * vam)
16438 cmd_cmp (void *a1, void *a2)
16443 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
16447 help (vat_main_t * vam)
16452 unformat_input_t *i = vam->input;
16455 if (unformat (i, "%s", &name))
16459 vec_add1 (name, 0);
16461 hs = hash_get_mem (vam->help_by_name, name);
16463 fformat (vam->ofp, "usage: %s %s\n", name, hs[0]);
16465 fformat (vam->ofp, "No such msg / command '%s'\n", name);
16470 fformat (vam->ofp, "Help is available for the following:\n");
16473 hash_foreach_pair (p, vam->function_by_name,
16475 vec_add1 (cmds, (u8 *)(p->key));
16479 vec_sort_with_function (cmds, cmd_cmp);
16481 for (j = 0; j < vec_len (cmds); j++)
16482 fformat (vam->ofp, "%s\n", cmds[j]);
16489 set (vat_main_t * vam)
16491 u8 *name = 0, *value = 0;
16492 unformat_input_t *i = vam->input;
16494 if (unformat (i, "%s", &name))
16496 /* The input buffer is a vector, not a string. */
16497 value = vec_dup (i->buffer);
16498 vec_delete (value, i->index, 0);
16499 /* Almost certainly has a trailing newline */
16500 if (value[vec_len (value) - 1] == '\n')
16501 value[vec_len (value) - 1] = 0;
16502 /* Make sure it's a proper string, one way or the other */
16503 vec_add1 (value, 0);
16504 (void) clib_macro_set_value (&vam->macro_main,
16505 (char *) name, (char *) value);
16508 errmsg ("usage: set <name> <value>\n");
16516 unset (vat_main_t * vam)
16520 if (unformat (vam->input, "%s", &name))
16521 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
16522 errmsg ("unset: %s wasn't set\n", name);
16535 macro_sort_cmp (void *a1, void *a2)
16537 macro_sort_t *s1 = a1;
16538 macro_sort_t *s2 = a2;
16540 return strcmp ((char *) (s1->name), (char *) (s2->name));
16544 dump_macro_table (vat_main_t * vam)
16546 macro_sort_t *sort_me = 0, *sm;
16551 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
16553 vec_add2 (sort_me, sm, 1);
16554 sm->name = (u8 *)(p->key);
16555 sm->value = (u8 *) (p->value[0]);
16559 vec_sort_with_function (sort_me, macro_sort_cmp);
16561 if (vec_len (sort_me))
16562 fformat (vam->ofp, "%-15s%s\n", "Name", "Value");
16564 fformat (vam->ofp, "The macro table is empty...\n");
16566 for (i = 0; i < vec_len (sort_me); i++)
16567 fformat (vam->ofp, "%-15s%s\n", sort_me[i].name, sort_me[i].value);
16572 dump_node_table (vat_main_t * vam)
16575 vlib_node_t *node, *next_node;
16577 if (vec_len (vam->graph_nodes) == 0)
16579 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
16583 for (i = 0; i < vec_len (vam->graph_nodes); i++)
16585 node = vam->graph_nodes[i];
16586 fformat (vam->ofp, "[%d] %s\n", i, node->name);
16587 for (j = 0; j < vec_len (node->next_nodes); j++)
16589 if (node->next_nodes[j] != ~0)
16591 next_node = vam->graph_nodes[node->next_nodes[j]];
16592 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
16600 value_sort_cmp (void *a1, void *a2)
16602 name_sort_t *n1 = a1;
16603 name_sort_t *n2 = a2;
16605 if (n1->value < n2->value)
16607 if (n1->value > n2->value)
16614 dump_msg_api_table (vat_main_t * vam)
16616 api_main_t *am = &api_main;
16617 name_sort_t *nses = 0, *ns;
16622 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
16624 vec_add2 (nses, ns, 1);
16625 ns->name = (u8 *)(hp->key);
16626 ns->value = (u32) hp->value[0];
16630 vec_sort_with_function (nses, value_sort_cmp);
16632 for (i = 0; i < vec_len (nses); i++)
16633 fformat (vam->ofp, " [%d]: %s\n", nses[i].value, nses[i].name);
16639 get_msg_id (vat_main_t * vam)
16644 if (unformat (vam->input, "%s", &name_and_crc))
16646 message_index = vl_api_get_msg_index (name_and_crc);
16647 if (message_index == ~0)
16649 fformat (vam->ofp, " '%s' not found\n", name_and_crc);
16652 fformat (vam->ofp, " '%s' has message index %d\n",
16653 name_and_crc, message_index);
16656 errmsg ("name_and_crc required...\n");
16661 search_node_table (vat_main_t * vam)
16663 unformat_input_t *line_input = vam->input;
16666 vlib_node_t *node, *next_node;
16669 if (vam->graph_node_index_by_name == 0)
16671 fformat (vam->ofp, "Node table empty, issue get_node_graph...\n");
16675 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16677 if (unformat (line_input, "%s", &node_to_find))
16679 vec_add1 (node_to_find, 0);
16680 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
16683 fformat (vam->ofp, "%s not found...\n", node_to_find);
16686 node = vam->graph_nodes[p[0]];
16687 fformat (vam->ofp, "[%d] %s\n", p[0], node->name);
16688 for (j = 0; j < vec_len (node->next_nodes); j++)
16690 if (node->next_nodes[j] != ~0)
16692 next_node = vam->graph_nodes[node->next_nodes[j]];
16693 fformat (vam->ofp, " [%d] %s\n", j, next_node->name);
16700 clib_warning ("parse error '%U'", format_unformat_error,
16706 vec_free (node_to_find);
16715 script (vat_main_t * vam)
16718 char *save_current_file;
16719 unformat_input_t save_input;
16720 jmp_buf save_jump_buf;
16721 u32 save_line_number;
16723 FILE *new_fp, *save_ifp;
16725 if (unformat (vam->input, "%s", &s))
16727 new_fp = fopen ((char *) s, "r");
16730 errmsg ("Couldn't open script file %s\n", s);
16737 errmsg ("Missing script name\n");
16741 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
16742 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
16743 save_ifp = vam->ifp;
16744 save_line_number = vam->input_line_number;
16745 save_current_file = (char *) vam->current_file;
16747 vam->input_line_number = 0;
16749 vam->current_file = s;
16752 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
16753 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
16754 vam->ifp = save_ifp;
16755 vam->input_line_number = save_line_number;
16756 vam->current_file = (u8 *) save_current_file;
16763 echo (vat_main_t * vam)
16765 fformat (vam->ofp, "%v", vam->input->buffer);
16769 /* List of API message constructors, CLI names map to api_xxx */
16770 #define foreach_vpe_api_msg \
16771 _(create_loopback,"[mac <mac-addr>]") \
16772 _(sw_interface_dump,"") \
16773 _(sw_interface_set_flags, \
16774 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
16775 _(sw_interface_add_del_address, \
16776 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
16777 _(sw_interface_set_table, \
16778 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
16779 _(sw_interface_set_mpls_enable, \
16780 "<intfc> | sw_if_index [disable | dis]") \
16781 _(sw_interface_set_vpath, \
16782 "<intfc> | sw_if_index <id> enable | disable") \
16783 _(sw_interface_set_vxlan_bypass, \
16784 "<intfc> | sw_if_index <id> [ip4 | ip6] enable | disable") \
16785 _(sw_interface_set_l2_xconnect, \
16786 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
16787 "enable | disable") \
16788 _(sw_interface_set_l2_bridge, \
16789 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
16790 "[shg <split-horizon-group>] [bvi]\n" \
16791 "enable | disable") \
16792 _(sw_interface_set_dpdk_hqos_pipe, \
16793 "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
16794 "profile <profile-id>\n") \
16795 _(sw_interface_set_dpdk_hqos_subport, \
16796 "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
16797 "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
16798 _(sw_interface_set_dpdk_hqos_tctbl, \
16799 "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n") \
16800 _(bridge_domain_add_del, \
16801 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n")\
16802 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
16804 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
16806 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
16808 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
16810 "tapname <name> mac <mac-addr> | random-mac") \
16812 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
16814 "<vpp-if-name> | sw_if_index <id>") \
16815 _(sw_interface_tap_dump, "") \
16816 _(ip_add_del_route, \
16817 "<addr>/<mask> via <addr> [table-id <n>]\n" \
16818 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
16819 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
16820 "[multipath] [count <n>]") \
16821 _(mpls_route_add_del, \
16822 "<label> <eos> via <addr> [table-id <n>]\n" \
16823 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
16824 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
16825 "[multipath] [count <n>]") \
16826 _(mpls_ip_bind_unbind, \
16827 "<label> <addr/len>") \
16828 _(proxy_arp_add_del, \
16829 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
16830 _(proxy_arp_intfc_enable_disable, \
16831 "<intfc> | sw_if_index <id> enable | disable") \
16832 _(mpls_add_del_encap, \
16833 "label <n> dst <ip4-addr> [vrf <n>] [del]") \
16834 _(sw_interface_set_unnumbered, \
16835 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
16836 _(ip_neighbor_add_del, \
16837 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
16838 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
16839 _(reset_vrf, "vrf <id> [ipv6]") \
16840 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
16841 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
16842 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
16843 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
16844 "[outer_vlan_id_any][inner_vlan_id_any]") \
16845 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
16846 _(reset_fib, "vrf <n> [ipv6]") \
16847 _(dhcp_proxy_config, \
16848 "svr <v46-address> src <v46-address>\n" \
16849 "insert-cid <n> [del]") \
16850 _(dhcp_proxy_config_2, \
16851 "svr <v46-address> src <v46-address>\n" \
16852 "rx_vrf_id <nn> server_vrf_id <nn> insert-cid <n> [del]") \
16853 _(dhcp_proxy_set_vss, \
16854 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
16855 _(dhcp_client_config, \
16856 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
16857 _(set_ip_flow_hash, \
16858 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
16859 _(sw_interface_ip6_enable_disable, \
16860 "<intfc> | sw_if_index <id> enable | disable") \
16861 _(sw_interface_ip6_set_link_local_address, \
16862 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
16863 _(sw_interface_ip6nd_ra_prefix, \
16864 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
16865 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
16866 "[nolink] [isno]") \
16867 _(sw_interface_ip6nd_ra_config, \
16868 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
16869 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
16870 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
16871 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
16872 _(l2_patch_add_del, \
16873 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
16874 "enable | disable") \
16875 _(mpls_ethernet_add_del_tunnel, \
16876 "tx <intfc> | tx_sw_if_index <n> dst <mac-addr>\n" \
16877 "adj <ip4-addr>/<mw> dst <mac-addr> [del]") \
16878 _(mpls_ethernet_add_del_tunnel_2, \
16879 "inner_vrf_id <n> outer_vrf_id <n> next-hop <ip4-addr>\n" \
16880 "resolve-attempts <n> resolve-if-needed 0 | 1 [del]") \
16881 _(sr_tunnel_add_del, \
16882 "[name <name>] src <ip6-addr> dst <ip6-addr>/<mw> \n" \
16883 "(next <ip6-addr>)+ [tag <ip6-addr>]* [clean] [reroute] \n" \
16884 "[policy <policy_name>]") \
16885 _(sr_policy_add_del, \
16886 "name <name> tunnel <tunnel-name> [tunnel <tunnel-name>]* [del]") \
16887 _(sr_multicast_map_add_del, \
16888 "address [ip6 multicast address] sr-policy [policy name] [del]") \
16889 _(classify_add_del_table, \
16890 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
16891 " [del] mask <mask-value>\n" \
16892 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
16893 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
16894 _(classify_add_del_session, \
16895 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
16896 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
16897 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
16898 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
16899 _(classify_set_interface_ip_table, \
16900 "<intfc> | sw_if_index <nn> table <nn>") \
16901 _(classify_set_interface_l2_tables, \
16902 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
16903 " [other-table <nn>]") \
16904 _(get_node_index, "node <node-name") \
16905 _(add_node_next, "node <node-name> next <next-node-name>") \
16906 _(l2tpv3_create_tunnel, \
16907 "client_address <ip6-addr> our_address <ip6-addr>\n" \
16908 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n"\
16909 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
16910 _(l2tpv3_set_tunnel_cookies, \
16911 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
16912 "[new_remote_cookie <nn>]\n") \
16913 _(l2tpv3_interface_enable_disable, \
16914 "<intfc> | sw_if_index <nn> enable | disable") \
16915 _(l2tpv3_set_lookup_key, \
16916 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
16917 _(sw_if_l2tpv3_tunnel_dump, "") \
16918 _(vxlan_add_del_tunnel, \
16919 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
16920 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
16921 "vni <vni> [encap-vrf-id <nn>] [decap-next l2|ip4|ip6] [del]") \
16922 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
16923 _(gre_add_del_tunnel, \
16924 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
16925 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
16926 _(l2_fib_clear_table, "") \
16927 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
16928 _(l2_interface_vlan_tag_rewrite, \
16929 "<intfc> | sw_if_index <nn> \n" \
16930 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
16931 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
16932 _(create_vhost_user_if, \
16933 "socket <filename> [server] [renumber <dev_instance>] " \
16934 "[mac <mac_address>]") \
16935 _(modify_vhost_user_if, \
16936 "<intfc> | sw_if_index <nn> socket <filename>\n" \
16937 "[server] [renumber <dev_instance>]") \
16938 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
16939 _(sw_interface_vhost_user_dump, "") \
16940 _(show_version, "") \
16941 _(vxlan_gpe_add_del_tunnel, \
16942 "local <addr> remote <addr> vni <nn>\n" \
16943 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
16944 "[next-ethernet] [next-nsh]\n") \
16945 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
16946 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
16947 _(interface_name_renumber, \
16948 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
16949 _(input_acl_set_interface, \
16950 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
16951 " [l2-table <nn>] [del]") \
16952 _(want_ip4_arp_events, "address <ip4-address> [del]") \
16953 _(want_ip6_nd_events, "address <ip6-address> [del]") \
16954 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
16955 _(ip_dump, "ipv4 | ipv6") \
16956 _(ipsec_spd_add_del, "spd_id <n> [del]") \
16957 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
16959 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
16960 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
16961 " integ_alg <alg> integ_key <hex>") \
16962 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
16963 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
16964 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
16965 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" )\
16966 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
16967 _(ikev2_profile_add_del, "name <profile_name> [del]") \
16968 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
16969 "(auth_data 0x<data> | auth_data <data>)") \
16970 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
16971 "(id_data 0x<data> | id_data <data>) (local|remote)") \
16972 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
16973 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
16974 "(local|remote)") \
16975 _(ikev2_set_local_key, "file <absolute_file_path>") \
16976 _(delete_loopback,"sw_if_index <nn>") \
16977 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
16978 _(map_add_domain, \
16979 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
16980 "ip6-src <ip6addr> " \
16981 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
16982 _(map_del_domain, "index <n>") \
16983 _(map_add_del_rule, \
16984 "index <n> psid <n> dst <ip6addr> [del]") \
16985 _(map_domain_dump, "") \
16986 _(map_rule_dump, "index <map-domain>") \
16987 _(want_interface_events, "enable|disable") \
16988 _(want_stats,"enable|disable") \
16989 _(get_first_msg_id, "client <name>") \
16990 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
16991 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
16992 "fib-id <nn> [ip4][ip6][default]") \
16993 _(get_node_graph, " ") \
16994 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
16995 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
16996 _(ioam_disable, "") \
16997 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
16998 " sw_if_index <sw_if_index> p <priority> " \
16999 "w <weight>] [del]") \
17000 _(lisp_add_del_locator, "locator-set <locator_name> " \
17001 "iface <intf> | sw_if_index <sw_if_index> " \
17002 "p <priority> w <weight> [del]") \
17003 _(lisp_add_del_local_eid,"vni <vni> eid " \
17004 "<ipv4|ipv6>/<prefix> | <L2 address> " \
17005 "locator-set <locator_name> [del]") \
17006 _(lisp_gpe_add_del_fwd_entry, "rmt_eid <eid> [lcl_eid <eid>] vni <vni>" \
17007 "dp_table <table> loc-pair <lcl_loc> <rmt_loc> ... [del]") \
17008 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
17009 _(lisp_gpe_enable_disable, "enable|disable") \
17010 _(lisp_enable_disable, "enable|disable") \
17011 _(lisp_gpe_add_del_iface, "up|down") \
17012 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
17014 "rloc <locator> p <prio> " \
17015 "w <weight> [rloc <loc> ... ] " \
17016 "action <action> [del-all]") \
17017 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
17019 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
17020 _(lisp_map_request_mode, "src-dst|dst-only") \
17021 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
17022 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
17023 _(lisp_locator_set_dump, "[local | remote]") \
17024 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
17025 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
17026 "[local] | [remote]") \
17027 _(lisp_eid_table_vni_dump, "") \
17028 _(lisp_eid_table_map_dump, "l2|l3") \
17029 _(lisp_gpe_tunnel_dump, "") \
17030 _(lisp_map_resolver_dump, "") \
17031 _(lisp_adjacencies_get, "vni <vni>") \
17032 _(show_lisp_status, "") \
17033 _(lisp_get_map_request_itr_rlocs, "") \
17034 _(show_lisp_pitr, "") \
17035 _(show_lisp_map_request_mode, "") \
17036 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
17037 _(af_packet_delete, "name <host interface name>") \
17038 _(policer_add_del, "name <policer name> <params> [del]") \
17039 _(policer_dump, "[name <policer name>]") \
17040 _(policer_classify_set_interface, \
17041 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17042 " [l2-table <nn>] [del]") \
17043 _(policer_classify_dump, "type [ip4|ip6|l2]") \
17044 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
17045 "[master|slave]") \
17046 _(netmap_delete, "name <interface name>") \
17047 _(mpls_eth_tunnel_dump, "tunnel_index <tunnel-id>") \
17048 _(mpls_fib_encap_dump, "") \
17049 _(mpls_fib_dump, "") \
17050 _(classify_table_ids, "") \
17051 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
17052 _(classify_table_info, "table_id <nn>") \
17053 _(classify_session_dump, "table_id <nn>") \
17054 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
17055 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
17056 "[template_interval <nn>] [udp_checksum]") \
17057 _(ipfix_exporter_dump, "") \
17058 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
17059 _(ipfix_classify_stream_dump, "") \
17060 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]")\
17061 _(ipfix_classify_table_dump, "") \
17062 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [[dst <intfc> | dst_sw_if_index <id>] | disable]") \
17063 _(sw_interface_span_dump, "") \
17064 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
17065 _(pg_create_interface, "if_id <nn>") \
17066 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
17067 _(pg_enable_disable, "[stream <id>] disable") \
17068 _(ip_source_and_port_range_check_add_del, \
17069 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
17070 _(ip_source_and_port_range_check_interface_add_del, \
17071 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
17072 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
17073 _(ipsec_gre_add_del_tunnel, \
17074 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
17075 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
17076 _(delete_subif,"<intfc> | sw_if_index <nn>") \
17077 _(l2_interface_pbb_tag_rewrite, \
17078 "<intfc> | sw_if_index <nn> \n" \
17079 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
17080 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
17081 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
17082 _(flow_classify_set_interface, \
17083 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
17084 _(flow_classify_dump, "type [ip4|ip6]") \
17085 _(ip_fib_dump, "") \
17086 _(ip6_fib_dump, "") \
17087 _(feature_enable_disable, "arc_name <arc_name> " \
17088 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]")
17090 /* List of command functions, CLI names map directly to functions */
17091 #define foreach_cli_function \
17092 _(comment, "usage: comment <ignore-rest-of-line>") \
17093 _(dump_interface_table, "usage: dump_interface_table") \
17094 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
17095 _(dump_ipv4_table, "usage: dump_ipv4_table") \
17096 _(dump_ipv6_table, "usage: dump_ipv6_table") \
17097 _(dump_stats_table, "usage: dump_stats_table") \
17098 _(dump_macro_table, "usage: dump_macro_table ") \
17099 _(dump_node_table, "usage: dump_node_table") \
17100 _(dump_msg_api_table, "usage: dump_msg_api_table") \
17101 _(get_msg_id, "usage: get_msg_id name_and_crc") \
17102 _(echo, "usage: echo <message>") \
17103 _(exec, "usage: exec <vpe-debug-CLI-command>") \
17104 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
17105 _(help, "usage: help") \
17106 _(q, "usage: quit") \
17107 _(quit, "usage: quit") \
17108 _(search_node_table, "usage: search_node_table <name>...") \
17109 _(set, "usage: set <variable-name> <value>") \
17110 _(script, "usage: script <file-name>") \
17111 _(unset, "usage: unset <variable-name>")
17114 static void vl_api_##n##_t_handler_uni \
17115 (vl_api_##n##_t * mp) \
17117 vat_main_t * vam = &vat_main; \
17118 if (vam->json_output) { \
17119 vl_api_##n##_t_handler_json(mp); \
17121 vl_api_##n##_t_handler(mp); \
17124 foreach_vpe_api_reply_msg;
17128 vat_api_hookup (vat_main_t * vam)
17131 vl_msg_api_set_handlers(VL_API_##N, #n, \
17132 vl_api_##n##_t_handler_uni, \
17134 vl_api_##n##_t_endian, \
17135 vl_api_##n##_t_print, \
17136 sizeof(vl_api_##n##_t), 1);
17137 foreach_vpe_api_reply_msg;
17140 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
17142 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
17144 vam->function_by_name = hash_create_string (0, sizeof (uword));
17146 vam->help_by_name = hash_create_string (0, sizeof (uword));
17148 /* API messages we can send */
17149 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
17150 foreach_vpe_api_msg;
17154 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17155 foreach_vpe_api_msg;
17158 /* CLI functions */
17159 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
17160 foreach_cli_function;
17164 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
17165 foreach_cli_function;
17169 #undef vl_api_version
17170 #define vl_api_version(n,v) static u32 memory_api_version = v;
17171 #include <vlibmemory/vl_memory_api_h.h>
17172 #undef vl_api_version
17174 #undef vl_api_version
17175 #define vl_api_version(n,v) static u32 vnet_interface_api_version = v;
17176 #include <vnet/interface.api.h>
17177 #undef vl_api_version
17179 #undef vl_api_version
17180 #define vl_api_version(n,v) static u32 vpp_api_version = v;
17181 #include <vpp-api/vpe.api.h>
17182 #undef vl_api_version
17184 static u32 *api_versions[] = {
17185 &memory_api_version,
17186 &vnet_interface_api_version,
17191 vl_client_add_api_signatures (vl_api_memclnt_create_t * mp)
17195 ASSERT (ARRAY_LEN (mp->api_versions) >= ARRAY_LEN (api_versions));
17198 * Send the API signatures. This bit of code must
17199 * match the checks in ../vpe/api/api.c: vl_msg_api_version_check().
17202 for (i = 0; i < ARRAY_LEN (api_versions); i++)
17203 mp->api_versions[i] = clib_host_to_net_u32 (*api_versions[i]);
17207 * fd.io coding-style-patch-verification: ON
17210 * eval: (c-set-style "gnu")